Whlabel.php 340 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021
  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. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2195. $list['lacesize'] = $this->input->post('lacesize', true);
  2196. }
  2197. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2198. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2199. }
  2200. if ($category == 128) {
  2201. $list['lacetype'] = $this->input->post('lacetype', true);
  2202. $list['haircap'] = $this->input->post('haircap', true);
  2203. $list['density'] = $this->input->post('density', true);
  2204. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2205. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2206. $list['wigother'] = $this->input->post('wigother', true);
  2207. $list['wigother1'] = $this->input->post('wigother1', true);
  2208. $list['wigother2'] = $this->input->post('wigother2', true);
  2209. $list['product_related'] = $this->input->post('product_related', true);
  2210. }
  2211. if ($category == 129) {
  2212. $list['wide'] = $this->input->post('wide', true);
  2213. }
  2214. if ($category == 131) {
  2215. $list['gifttype'] = $this->input->post('gifttype', true);
  2216. $list['giftother'] = $this->input->post('giftother', true);
  2217. }
  2218. if ($category == 134) {
  2219. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2220. }
  2221. if ($category == 1297) {
  2222. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2223. $list['sywigother'] = $this->input->post('sywigother', true);
  2224. }
  2225. if ($category == 130 || $category == 133 || $category == 1702) {
  2226. $list['items'] = $this->input->post('items', true);
  2227. $list['weight'] = $this->input->post('weight', true);
  2228. }
  2229. if($category == 130){
  2230. $list['jfother'] = $this->input->post('jfother', true);
  2231. }
  2232. if ($category == 1702) {
  2233. $list['syhairther'] = $this->input->post('syhairther', true);
  2234. }
  2235. $classid = $this->classid->sku();
  2236. $scsku = $classid;
  2237. $pm = $classid;
  2238. foreach ($list as $k => $v) {
  2239. if ($v != 0) {
  2240. $num .= $v;
  2241. $features .= $v . '-';
  2242. $post[$k] = $v;
  2243. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2244. if ($k != 'size') {
  2245. $title .= $typeclass[$v]['title'] . " ";
  2246. }
  2247. if (isset($pm[$typeclass[$v]['classid']])) {
  2248. if ($typeclass[$v]['title'] == '9A') {
  2249. $pm[$typeclass[$v]['classid']] = '9A';
  2250. } else if ($typeclass[$v]['title'] == '10A') {
  2251. $pm[$typeclass[$v]['classid']] = '10A';
  2252. } else {
  2253. $clzh = $typeclass[$v]['zh'];
  2254. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  2255. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  2256. $clzh = $clzh[0];
  2257. }
  2258. $pm[$typeclass[$v]['classid']] = $clzh;
  2259. }
  2260. }
  2261. }
  2262. }
  2263. $zh = implode(" ", $pm);
  2264. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  2265. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  2266. if ($list['size']) {
  2267. $typeclass = $this->typeclass->read($list['size']);
  2268. $title .= $typeclass['title'];
  2269. }
  2270. $time = time();
  2271. if ($xzsku) {
  2272. $scsku = implode("-", $scsku);
  2273. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  2274. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  2275. $post['sku'] = trim($scsku, ' ');
  2276. } else {
  2277. $post['sku'] = $sku;
  2278. }
  2279. //$post['sku'] = trim($sku,' ');
  2280. $post['title'] = rtrim($title, ' ');
  2281. $post['number'] = $num;
  2282. $post['features'] = '-' . $features;
  2283. $post['enter'] = $time;
  2284. $post['time'] = $time; //操作时间
  2285. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2286. if ($yza) {
  2287. if ($post['features'] != $yza[0]['features']) {
  2288. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  2289. exit;
  2290. }
  2291. }
  2292. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2293. if ($yzb) {
  2294. if ($post['sku'] != $yzb[0]['sku']) {
  2295. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  2296. exit;
  2297. }
  2298. }
  2299. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2300. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2301. exit;
  2302. }
  2303. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2304. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2305. exit;
  2306. }
  2307. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2308. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2309. exit;
  2310. }
  2311. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  2312. if (isset($yz[0]['type'])) {
  2313. $post['type'] = $yz[0]['type'];
  2314. }
  2315. if ($post['state'] == 9) //如果选择预设库存
  2316. {
  2317. $this->whlabel->insert($post);
  2318. } else {
  2319. /**
  2320. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2321. if($ljg == 1)
  2322. {
  2323. for($i=0;$i<$order;$i++)
  2324. {
  2325. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2326. $this->whlabel->insert($post);
  2327. }
  2328. }
  2329. **/
  2330. //if($post['warehouse'] == '5')
  2331. //{
  2332. //}
  2333. $yydata = $post;
  2334. $yydata['zh'] = $zh;
  2335. /**
  2336. $wl = $this->apiyy->get_cjlp($yydata);
  2337. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2338. {
  2339. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2340. }
  2341. if($wl['Data'][0]['m_isSucess'] != 1)
  2342. {
  2343. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2344. }
  2345. **/
  2346. for ($i = 0; $i < $order; $i++) {
  2347. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  2348. $this->whlabel->insert($post);
  2349. }
  2350. }
  2351. echo json_encode(array('msg' => '入库成功', 'success' => true));
  2352. exit;
  2353. }
  2354. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2355. $this->data['wlshop'] = $wlshop;
  2356. $this->_Template('whlabel_enteradd', $this->data);
  2357. }
  2358. //修改产品
  2359. public function _enteredit($arg_array)
  2360. {
  2361. $dt = 0;
  2362. if (isset($_SESSION['api'])) {
  2363. $user = $this->user->get_api($_SESSION['api']);
  2364. $usp = $user;
  2365. $fgshop = "";
  2366. $sid = "";
  2367. $user = explode('|', trim($user['shop'], '|'));
  2368. foreach ($user as $value) {
  2369. $fgshop .= " shop = " . $value . " or";
  2370. $sid .= " id = " . $value . " or";
  2371. }
  2372. }
  2373. $post = $this->input->post(NULL, TRUE);
  2374. if (isset($post['sku'])) {
  2375. $list = array();
  2376. $num = "";
  2377. $title = "";
  2378. $features = "";
  2379. $id = $this->input->post('id', true);
  2380. $order = $this->input->post('order', true);
  2381. $shop = $this->input->post('shop', true);
  2382. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2383. $post['sku'] = $this->input->post('sku', true);
  2384. $post['sm'] = $this->input->post('sm', true);
  2385. $post['warehouse'] = $this->input->post('warehouse', true);
  2386. $post['purchase'] = $this->input->post('purchase', true);
  2387. $post['retreatwarehouse'] = $post['warehouse'];
  2388. $category = $this->input->post('category', true);
  2389. $list['category'] = $category;
  2390. $list['hairtype'] = $this->input->post('hairtype', true);
  2391. $list['grade'] = $this->input->post('grade', true);
  2392. $size = $this->input->post('size', true);
  2393. $list['size'] = rtrim($size, ',');
  2394. $post['rktype'] = $this->input->post('rktype', true);
  2395. $post['text'] = $this->input->post('text', true);
  2396. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2397. $list['extension'] = $this->input->post('extension', true);
  2398. if ($category == 1297) {
  2399. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2400. }
  2401. if ($category == 1702) {
  2402. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2403. $list['syother'] = $this->input->post('syother', true);
  2404. }
  2405. if ($category == 133) {
  2406. $list['fittype'] = $this->input->post('fittype', true);
  2407. $list['acother'] = $this->input->post('acother', true);
  2408. }
  2409. $list['color'] = $this->input->post('color', true);
  2410. $list['lowe'] = $this->input->post('lowe', true);
  2411. if (!$post['purchase']) {
  2412. $post['purchase'] = 1;
  2413. }
  2414. if ($category == 127) {
  2415. $list['type'] = $this->input->post('type', true);
  2416. $list['headroad'] = $this->input->post('headroad', true);
  2417. $list['density'] = $this->input->post('density', true);
  2418. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2419. $list['lacesize'] = $this->input->post('lacesize', true);
  2420. }
  2421. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2422. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2423. }
  2424. if ($category == 128) {
  2425. $list['lacetype'] = $this->input->post('lacetype', true);
  2426. $list['haircap'] = $this->input->post('haircap', true);
  2427. $list['density'] = $this->input->post('density', true);
  2428. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2429. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2430. $list['wigother'] = $this->input->post('wigother', true);
  2431. $list['wigother1'] = $this->input->post('wigother1', true);
  2432. $list['wigother2'] = $this->input->post('wigother2', true);
  2433. $list['product_related'] = $this->input->post('product_related', true);
  2434. }
  2435. if ($category == 129) {
  2436. $list['wide'] = $this->input->post('wide', true);
  2437. }
  2438. if ($category == 131) {
  2439. $list['gifttype'] = $this->input->post('gifttype', true);
  2440. $list['giftother'] = $this->input->post('giftother', true);
  2441. }
  2442. if ($category == 134) {
  2443. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2444. }
  2445. if ($category == 1297) {
  2446. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2447. $list['sywigother'] = $this->input->post('sywigother', true);
  2448. }
  2449. if ($category == 130 || $category == 133 || $category == 1702) {
  2450. $list['items'] = $this->input->post('items', true);
  2451. $list['weight'] = $this->input->post('weight', true);
  2452. }
  2453. if($category == 130){
  2454. $list['jfother'] = $this->input->post('jfother', true);
  2455. }
  2456. if ($category == 1702) {
  2457. $list['syhairther'] = $this->input->post('syhairther', true);
  2458. }
  2459. foreach ($list as $k => $v) {
  2460. if ($v != 0) {
  2461. $num .= $v;
  2462. $features .= $v . '-';
  2463. $typeclass = $this->typeclass->read($v);
  2464. if ($k != 'size') {
  2465. $title .= $typeclass['title'] . " ";
  2466. }
  2467. }
  2468. }
  2469. $typeclass = $this->typeclass->read($list['size']);
  2470. $title .= $typeclass['title'];
  2471. $time = time();
  2472. $post['title'] = rtrim($title, ' ');
  2473. $post['number'] = $num;
  2474. $post['features'] = '-' . $features;
  2475. $post['time'] = $time; //操作时间
  2476. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2477. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2478. exit;
  2479. }
  2480. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2481. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2482. exit;
  2483. }
  2484. $uid = $this->whlabel->read($id);
  2485. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2486. if ($datanum > 0) {
  2487. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2488. exit;
  2489. }
  2490. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2491. {
  2492. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2493. if ($yza) {
  2494. if ($post['features'] != $yza[0]['features']) {
  2495. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2496. exit;
  2497. }
  2498. }
  2499. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2500. if ($yzb) {
  2501. if ($post['sku'] != $yzb[0]['sku']) {
  2502. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2503. exit;
  2504. }
  2505. }
  2506. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2507. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2508. exit;
  2509. }
  2510. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2511. foreach ($data as $v) {
  2512. $post['id'] = $v['id'];
  2513. $this->whlabel->save($post, $v['id']);
  2514. }
  2515. } else {
  2516. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2517. if ($data > 0) {
  2518. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2519. exit;
  2520. } else {
  2521. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2522. foreach ($data as $v) {
  2523. $post['id'] = $v['id'];
  2524. $this->whlabel->save($post, $v['id']);
  2525. }
  2526. }
  2527. }
  2528. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2529. exit;
  2530. }
  2531. $uid = $this->whlabel->read($arg_array[0]);
  2532. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2533. $this->data['enter'] = $uid;
  2534. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2535. $this->data['wlshop'] = $wlshop;
  2536. $this->_Template('whlabel_enteredit', $this->data);
  2537. }
  2538. //入库浏览
  2539. public function _enter()
  2540. {
  2541. $post = $this->input->post(NULL, TRUE);
  2542. if (isset($post['s'])) {
  2543. $id_arr = $this->input->post('s');
  2544. $id_arr = explode(',', $id_arr);
  2545. if (!$id_arr) {
  2546. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2547. exit;
  2548. }
  2549. //循环删除记录
  2550. foreach ($id_arr as $v) {
  2551. $sid = $this->whlabel->read($v);
  2552. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2553. if ($count > 0) {
  2554. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2555. exit;
  2556. }
  2557. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2558. foreach ($info_list as $va) {
  2559. $this->whlabel->remove($va['id']);
  2560. }
  2561. }
  2562. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2563. exit;
  2564. }
  2565. $sp = array();
  2566. $s = $this->shop->find_all('1=1', 'id,shopname');
  2567. foreach ($s as $v) {
  2568. $sp[$v['id']] = $v['shopname'];
  2569. }
  2570. $wh = array();
  2571. $w = $this->warehouse->find_all('1=1', 'id,title');
  2572. foreach ($w as $v) {
  2573. $wh[$v['id']] = $v['title'];
  2574. }
  2575. if (isset($post['page'])) {
  2576. $page = $this->input->post('page', true);
  2577. $perpage = $this->input->post('perpage', true);
  2578. $category = $this->input->post('category', true);
  2579. $size = $this->input->post('size', true);
  2580. $grade = $this->input->post('grade', true);
  2581. $color = $this->input->post('color', true);
  2582. $lowe = $this->input->post('lowe', true);
  2583. $sku = $this->input->post('sku', true);
  2584. $warehouse = $this->input->post('warehouse', true);
  2585. $purchase = $this->input->post('purchase', true);
  2586. $ktime = $this->input->post('ktime', true);
  2587. $jtime = $this->input->post('jtime', true);
  2588. $ktime = strtotime($ktime);
  2589. $jtime = strtotime($jtime);
  2590. $where = "1=1";
  2591. $gj = "";
  2592. $ck = "";
  2593. if ($category) {
  2594. $where .= " and features like '%-$category-%'";
  2595. }
  2596. if ($size) {
  2597. $where .= " and features like '%-$size-%'";
  2598. }
  2599. if ($grade) {
  2600. $where .= " and features like '%-$grade-%'";
  2601. }
  2602. if ($color) {
  2603. $where .= " and features like '%-$color-%'";
  2604. }
  2605. if ($lowe) {
  2606. $where .= " and features like '%-$lowe-%'";
  2607. }
  2608. if ($warehouse) {
  2609. $where .= " and warehouse = '$warehouse'";
  2610. }
  2611. if ($purchase) {
  2612. $where .= " and purchase = '$purchase'";
  2613. }
  2614. if ($sku) {
  2615. $where .= " and sku like '%$sku%'";
  2616. }
  2617. if ($ktime && $jtime) {
  2618. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2619. }
  2620. //数据排序
  2621. $order_str = "enter desc";
  2622. if (empty($page)) {
  2623. $start = 0;
  2624. $perpage = 1;
  2625. } else {
  2626. $start = ($page - 1) * $perpage;
  2627. }
  2628. //取得信息列表
  2629. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2630. foreach ($info_list as $k => $v) {
  2631. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2632. if ($v['shop'] == '') {
  2633. $s = '通用';
  2634. } else {
  2635. $info_list[$k]['shop'] = '';
  2636. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2637. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2638. }
  2639. }
  2640. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2641. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2642. $info_list[$k]['g'] = $g;
  2643. }
  2644. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2645. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2646. $pagenum = ceil($total / $perpage);
  2647. $over = $total - ($start + $perpage);
  2648. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2649. echo json_encode($rows);
  2650. exit;
  2651. }
  2652. $this->_Template('whlabel_enter', $this->data);
  2653. }
  2654. //出库浏览
  2655. public function _out()
  2656. {
  2657. $post = $this->input->post(NULL, TRUE);
  2658. if (isset($post['page'])) {
  2659. $page = $this->input->post('page', true);
  2660. $perpage = $this->input->post('perpage', true);
  2661. $category = $this->input->post('category', true);
  2662. $size = $this->input->post('size', true);
  2663. $grade = $this->input->post('grade', true);
  2664. $color = $this->input->post('color', true);
  2665. $lowe = $this->input->post('lowe', true);
  2666. $sku = $this->input->post('sku', true);
  2667. $warehouse = $this->input->post('warehouse', true);
  2668. $purchase = $this->input->post('purchase', true);
  2669. $state = $this->input->post('state', true);
  2670. $ktime = $this->input->post('ktime', true);
  2671. $jtime = $this->input->post('jtime', true);
  2672. $ktime = strtotime($ktime);
  2673. $jtime = strtotime($jtime);
  2674. $where = "state=3";
  2675. $gj = "";
  2676. $ck = "";
  2677. if ($category) {
  2678. $where .= " and features like '%-$category-%'";
  2679. }
  2680. if ($size) {
  2681. $where .= " and features like '%-$size-%'";
  2682. }
  2683. if ($grade) {
  2684. $where .= " and features like '%-$grade-%'";
  2685. }
  2686. if ($color) {
  2687. $where .= " and features like '%-$color-%'";
  2688. }
  2689. if ($lowe) {
  2690. $where .= " and features like '%-$lowe-%'";
  2691. }
  2692. if ($state) {
  2693. $where .= " and state = '$state'";
  2694. }
  2695. if ($warehouse) {
  2696. $where .= " and warehouse = '$warehouse'";
  2697. }
  2698. if ($purchase) {
  2699. $where .= " and purchase = '$purchase'";
  2700. }
  2701. if ($sku) {
  2702. $where .= " and sku = '$sku'";
  2703. }
  2704. if ($ktime && $jtime) {
  2705. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2706. }
  2707. //数据排序
  2708. $order_str = "id desc";
  2709. if (empty($page)) {
  2710. $start = 0;
  2711. $perpage = 1;
  2712. } else {
  2713. $start = ($page - 1) * $perpage;
  2714. }
  2715. //取得信息列表
  2716. $info_list = $this->whlabel->find_all($where, 'sku');
  2717. $rows = array();
  2718. $list = array();
  2719. foreach ($info_list as $key => $value) {
  2720. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2721. }
  2722. $rows = array_unique($rows); //删除重复记录
  2723. foreach ($rows as $key => $value) {
  2724. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2725. $ck = $this->warehouse->read($data['warehouse']);
  2726. $warehouse = $ck['title'];
  2727. $gy = $this->purchase->read($data['purchase']);
  2728. $purchase = $gy['purchase'];
  2729. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2730. $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);
  2731. }
  2732. $total = count($list);
  2733. $pagenum = ceil($total / $perpage);
  2734. $over = $total - ($start + $perpage);
  2735. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2736. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2737. echo json_encode($rows);
  2738. exit;
  2739. }
  2740. $this->_Template('whlabel_out', $this->data);
  2741. }
  2742. //出库标签浏览
  2743. public function _label()
  2744. {
  2745. $post = $this->input->post(NULL, TRUE);
  2746. if (isset($post['page'])) {
  2747. $page = $this->input->post('page', true);
  2748. $perpage = $this->input->post('perpage', true);
  2749. $sku = $this->input->post('sku', true);
  2750. $warehouse = $this->input->post('warehouse', true);
  2751. $purchase = $this->input->post('purchase', true);
  2752. $orderinfo = $this->input->post('orderinfo', true);
  2753. $waybill = $this->input->post('waybill', true);
  2754. $category = $this->input->post('category', true);
  2755. $size = $this->input->post('size', true);
  2756. $grade = $this->input->post('grade', true);
  2757. $color = $this->input->post('color', true);
  2758. $lowe = $this->input->post('lowe', true);
  2759. $where = "state=1";
  2760. if ($sku) {
  2761. $where .= " and sku = '$sku'";
  2762. }
  2763. if ($warehouse) {
  2764. $where .= " and warehouse = '$warehouse'";
  2765. }
  2766. if ($purchase) {
  2767. $where .= " and purchase = '$purchase'";
  2768. }
  2769. if ($orderinfo) {
  2770. $where .= " and orderinfo = '$orderinfo'";
  2771. }
  2772. if ($waybill) {
  2773. $where .= " and waybill = '$waybill'";
  2774. }
  2775. if ($category) {
  2776. $where .= " and features like '%-$category-%'";
  2777. }
  2778. if ($size) {
  2779. $where .= " and features like '%-$size-%'";
  2780. }
  2781. if ($grade) {
  2782. $where .= " and features like '%-$grade-%'";
  2783. }
  2784. if ($color) {
  2785. $where .= " and features like '%-$color-%'";
  2786. }
  2787. if ($lowe) {
  2788. $where .= " and features like '%-$lowe-%'";
  2789. }
  2790. //数据排序
  2791. $order_str = "outk desc";
  2792. if (empty($page)) {
  2793. $start = 0;
  2794. $perpage = 1;
  2795. } else {
  2796. $start = ($page - 1) * $perpage;
  2797. }
  2798. //取得信息列表
  2799. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2800. foreach ($info_list as $key => $value) {
  2801. $warehouse = $this->warehouse->read($value['warehouse']);
  2802. $info_list[$key]['warehouse'] = $warehouse['title'];
  2803. $purchase = $this->purchase->read($value['purchase']);
  2804. $info_list[$key]['purchase'] = $purchase['title'];
  2805. if ($value['outk'] != 0) {
  2806. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2807. } else {
  2808. $info_list[$key]['outk'] = "";
  2809. }
  2810. if ($value['orderinfo'] == 0) {
  2811. $info_list[$key]['orderinfo'] = "";
  2812. }
  2813. if ($value['waybill'] == 0) {
  2814. $info_list[$key]['waybill'] = "";
  2815. }
  2816. }
  2817. $total = $this->whlabel->find_count($where);
  2818. $pagenum = ceil($total / $perpage);
  2819. $over = $total - ($start + $perpage);
  2820. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2821. echo json_encode($rows);
  2822. exit;
  2823. }
  2824. $this->_Template('whlabel_label', $this->data);
  2825. }
  2826. //独立站出库订单
  2827. public function _outorder()
  2828. {
  2829. if (isset($_SESSION['api'])) {
  2830. $user = $this->user->get_api($_SESSION['api']);
  2831. $usp = $user;
  2832. $fgshop = "";
  2833. $sid = "";
  2834. $user = explode('|', trim($user['shop'], '|'));
  2835. foreach ($user as $value) {
  2836. $fgshop .= " shop = " . $value . " or";
  2837. $sid .= " id = " . $value . " or";
  2838. }
  2839. } else {
  2840. echo "请重新登录";
  2841. }
  2842. $post = $this->input->post(NULL, TRUE);
  2843. if (isset($post['page'])) {
  2844. $page = $this->input->post('page', true);
  2845. $perpage = $this->input->post('perpage', true);
  2846. $warehouse = $this->input->post('warehouse', true);
  2847. $xztime = $this->input->post('xztime', true);
  2848. $timetk = $this->input->post('timetkk', true);
  2849. $timetj = $this->input->post('timetjj', true);
  2850. $shop = $this->input->post('shop', true);
  2851. $source = $this->input->post('source', true);
  2852. $orderinfo = $this->input->post('orderinfo', true);
  2853. $number = $this->input->post('number', true);
  2854. $sfxh = $this->input->post('sfxh', true);
  2855. $express = $this->input->post('express', true);
  2856. $waybill = $this->input->post('waybill', true);
  2857. $library = $this->input->post('library', true);
  2858. $country = $this->input->post('country', true);
  2859. $so = $this->input->post('so', true);
  2860. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2861. $print = $this->input->post('print', true);
  2862. $state = $this->input->post('state', true);
  2863. $orderurl = $this->input->post('orderurl', true);
  2864. $productid = $this->input->post('productid', true);
  2865. $timetk = strtotime($timetk);
  2866. $timetj = strtotime($timetj);
  2867. /**
  2868. $sj = $this->input->post('sj',true);
  2869. if($sj)
  2870. {
  2871. $sj = $this->input->post('sj',true);
  2872. }
  2873. else
  2874. {
  2875. $sj = "fullorder";
  2876. }
  2877. **/
  2878. $sj = "fullorder";
  2879. $where = "1=1";
  2880. if ($warehouse) {
  2881. $where .= " and type = '$warehouse'";
  2882. }
  2883. if ($timetk && $timetj) {
  2884. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2885. }
  2886. if ($orderinfo) {
  2887. $where .= " and orderinfo = '$orderinfo'";
  2888. }
  2889. if ($number) {
  2890. $where .= " and number = '$number'";
  2891. }
  2892. if ($express) {
  2893. $where .= " and express = '$express'";
  2894. }
  2895. if ($waybill) {
  2896. $where .= " and waybill = '$waybill'";
  2897. }
  2898. if ($library) {
  2899. $where .= " and library = '$library'";
  2900. }
  2901. if ($print) {
  2902. $where .= " and print = '$print'";
  2903. }
  2904. if ($libraryconfirm) {
  2905. $where .= " and libraryconfirm = '$libraryconfirm'";
  2906. }
  2907. if ($state) {
  2908. $where .= " and state = '$state'";
  2909. }
  2910. if ($shop) {
  2911. $where .= " and shop = '$shop'";
  2912. }
  2913. if ($country) {
  2914. $where .= " and country = '$country'";
  2915. }
  2916. if ($sfxh != '') {
  2917. $where .= " and sfxh = '$sfxh'";
  2918. }
  2919. if ($so) {
  2920. $where .= " and shipremarks like '%$so%'";
  2921. }
  2922. if ($source) {
  2923. if ($source == '2d') {
  2924. $where .= " and source >= '2'";
  2925. } else {
  2926. $where .= " and source = '$source'";
  2927. }
  2928. }
  2929. if (isset($_SESSION['api'])) {
  2930. foreach ($user as $value) {
  2931. $fgshop .= " shop = " . $value . " or";
  2932. }
  2933. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2934. }
  2935. if ($orderurl) {
  2936. $url = $this->orderurl->read($orderurl);
  2937. $where .= " and link like '%" . $url['url'] . "%'";
  2938. }
  2939. if($productid){
  2940. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2941. }
  2942. //数据排序
  2943. $order_str = "librarytime desc";
  2944. if (empty($page)) {
  2945. $start = 0;
  2946. $perpage = 1;
  2947. } else {
  2948. $start = ($page - 1) * $perpage;
  2949. }
  2950. //取得信息列表
  2951. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2952. //格式化数据
  2953. foreach ($info_list as $key => $value) {
  2954. $shop = $this->shop->read($value['shop']);
  2955. $info_list[$key]['shop'] = $shop['shopname'];
  2956. $express = $this->express->read($value['express']);
  2957. $info_list[$key]['express'] = $express['servicename'];
  2958. $warehouse = $this->warehouse->read($value['type']);
  2959. $info_list[$key]['type'] = $warehouse['title'];
  2960. if ($value['librarytime'] == '0') {
  2961. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2962. } else {
  2963. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2964. }
  2965. }
  2966. $total = $this->$sj->find_count($where);
  2967. $pagenum = ceil($total / $perpage);
  2968. $over = $total - ($start + $perpage);
  2969. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2970. echo json_encode($rows);
  2971. exit;
  2972. }
  2973. $this->data['express'] = $this->express->find_all();
  2974. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2975. $this->data['wlshop'] = $wlshop;
  2976. $user = $this->user->get_api($_SESSION['api']);
  2977. $powerid = $this->power->read($user['power']);
  2978. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2979. $pid = '';
  2980. foreach ($powertext as $v) {
  2981. $pid .= " id = " . $v . " or";
  2982. }
  2983. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2984. $this->data['fullorderexcel'] = $fullorderexcel;
  2985. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2986. $this->data['orderurl'] = $orderurl;
  2987. $this->_Template('whlabel_outorder', $this->data);
  2988. }
  2989. //tt出库
  2990. public function _toutorder()
  2991. {
  2992. $fgshop = "";
  2993. $sid = "";
  2994. if (isset($_SESSION['api'])) {
  2995. $user = $this->user->get_api($_SESSION['api']);
  2996. $usp = $user;
  2997. $user = explode('|', trim($user['shop'], '|'));
  2998. foreach ($user as $value) {
  2999. $fgshop .= " shop = " . $value . " or";
  3000. $sid .= " id = " . $value . " or";
  3001. }
  3002. } else {
  3003. echo "请重新登录";
  3004. die;
  3005. }
  3006. $post = $this->input->post(NULL, TRUE);
  3007. if (isset($post['page'])) {
  3008. $page = $this->input->post('page', true);
  3009. $perpage = $this->input->post('perpage', true);
  3010. $warehouse = $this->input->post('warehouse', true);
  3011. $xztime = $this->input->post('xztime', true);
  3012. $timetk = $this->input->post('timetkk', true);
  3013. $timetj = $this->input->post('timetjj', true);
  3014. $shop = $this->input->post('shop', true);
  3015. $source = $this->input->post('source', true);
  3016. $orderinfo = $this->input->post('orderinfo', true);
  3017. $number = $this->input->post('number', true);
  3018. $sfxh = $this->input->post('sfxh', true);
  3019. $express = $this->input->post('express', true);
  3020. $waybill = $this->input->post('waybill', true);
  3021. $library = $this->input->post('library', true);
  3022. $country = $this->input->post('country', true);
  3023. $so = $this->input->post('so', true);
  3024. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3025. $print = $this->input->post('print', true);
  3026. $state = $this->input->post('state', true);
  3027. $orderurl = $this->input->post('orderurl', true);
  3028. $timetk = strtotime($timetk);
  3029. $timetj = strtotime($timetj);
  3030. /**
  3031. $sj = $this->input->post('sj',true);
  3032. if($sj)
  3033. {
  3034. $sj = $this->input->post('sj',true);
  3035. }
  3036. else
  3037. {
  3038. $sj = "fullorder";
  3039. }
  3040. **/
  3041. $sj = "fullordertt";
  3042. $where = "1=1";
  3043. if ($warehouse) {
  3044. $where .= " and type = '$warehouse'";
  3045. }
  3046. if ($timetk && $timetj) {
  3047. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3048. }
  3049. if ($orderinfo) {
  3050. $where .= " and orderinfo = '$orderinfo'";
  3051. }
  3052. if ($number) {
  3053. $where .= " and number = '$number'";
  3054. }
  3055. if ($express) {
  3056. $where .= " and express = '$express'";
  3057. }
  3058. if ($waybill) {
  3059. $where .= " and waybill = '$waybill'";
  3060. }
  3061. if ($library) {
  3062. $where .= " and library = '$library'";
  3063. }
  3064. if ($print) {
  3065. $where .= " and print = '$print'";
  3066. }
  3067. if ($libraryconfirm) {
  3068. $where .= " and libraryconfirm = '$libraryconfirm'";
  3069. }
  3070. if ($state) {
  3071. $where .= " and state = '$state'";
  3072. }
  3073. if ($shop) {
  3074. $where .= " and shop = '$shop'";
  3075. }
  3076. if ($country) {
  3077. $where .= " and country = '$country'";
  3078. }
  3079. if ($sfxh != '') {
  3080. $where .= " and sfxh = '$sfxh'";
  3081. }
  3082. if ($so) {
  3083. $where .= " and shipremarks like '%$so%'";
  3084. }
  3085. if ($source) {
  3086. if ($source == '2d') {
  3087. $where .= " and source >= '2'";
  3088. } else {
  3089. $where .= " and source = '$source'";
  3090. }
  3091. }
  3092. if (isset($_SESSION['api'])) {
  3093. foreach ($user as $value) {
  3094. $fgshop .= " shop = " . $value . " or";
  3095. }
  3096. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3097. }
  3098. if ($orderurl) {
  3099. $url = $this->orderurl->read($orderurl);
  3100. $where .= " and link like '%" . $url['url'] . "%'";
  3101. }
  3102. //数据排序
  3103. $order_str = "librarytime desc";
  3104. if (empty($page)) {
  3105. $start = 0;
  3106. $perpage = 1;
  3107. } else {
  3108. $start = ($page - 1) * $perpage;
  3109. }
  3110. //取得信息列表
  3111. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3112. //格式化数据
  3113. foreach ($info_list as $key => $value) {
  3114. $shop = $this->shop->read($value['shop']);
  3115. $info_list[$key]['shop'] = $shop['shopname'];
  3116. $express = $this->express->read($value['express']);
  3117. $info_list[$key]['express'] = $express['servicename'];
  3118. $warehouse = $this->warehouse->read($value['type']);
  3119. $info_list[$key]['type'] = $warehouse['title'];
  3120. if ($value['librarytime'] == '0') {
  3121. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3122. } else {
  3123. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3124. }
  3125. }
  3126. $total = $this->$sj->find_count($where);
  3127. $pagenum = ceil($total / $perpage);
  3128. $over = $total - ($start + $perpage);
  3129. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3130. echo json_encode($rows);
  3131. exit;
  3132. }
  3133. $this->data['express'] = $this->express->find_all();
  3134. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3135. $this->data['wlshop'] = $wlshop;
  3136. $user = $this->user->get_api($_SESSION['api']);
  3137. $powerid = $this->power->read($user['power']);
  3138. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3139. $pid = '';
  3140. foreach ($powertext as $v) {
  3141. $pid .= " id = " . $v . " or";
  3142. }
  3143. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3144. $this->data['fullorderexcel'] = $fullorderexcel;
  3145. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3146. $this->data['orderurl'] = $orderurl;
  3147. $this->_Template('whlabel_toutorder', $this->data);
  3148. }
  3149. //tt出库
  3150. public function _aoutorder()
  3151. {
  3152. if (isset($_SESSION['api'])) {
  3153. $user = $this->user->get_api($_SESSION['api']);
  3154. $usp = $user;
  3155. $fgshop = "";
  3156. $sid = "";
  3157. $user = explode('|', trim($user['shop'], '|'));
  3158. foreach ($user as $value) {
  3159. $fgshop .= " shop = " . $value . " or";
  3160. $sid .= " id = " . $value . " or";
  3161. }
  3162. } else {
  3163. echo "请重新登录";
  3164. }
  3165. $post = $this->input->post(NULL, TRUE);
  3166. if (isset($post['page'])) {
  3167. $page = $this->input->post('page', true);
  3168. $perpage = $this->input->post('perpage', true);
  3169. $warehouse = $this->input->post('warehouse', true);
  3170. $xztime = $this->input->post('xztime', true);
  3171. $timetk = $this->input->post('timetkk', true);
  3172. $timetj = $this->input->post('timetjj', true);
  3173. $shop = $this->input->post('shop', true);
  3174. $source = $this->input->post('source', true);
  3175. $orderinfo = $this->input->post('orderinfo', true);
  3176. $number = $this->input->post('number', true);
  3177. $sfxh = $this->input->post('sfxh', true);
  3178. $express = $this->input->post('express', true);
  3179. $waybill = $this->input->post('waybill', true);
  3180. $library = $this->input->post('library', true);
  3181. $country = $this->input->post('country', true);
  3182. $so = $this->input->post('so', true);
  3183. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3184. $print = $this->input->post('print', true);
  3185. $state = $this->input->post('state', true);
  3186. $orderurl = $this->input->post('orderurl', true);
  3187. $timetk = strtotime($timetk);
  3188. $timetj = strtotime($timetj);
  3189. /**
  3190. $sj = $this->input->post('sj',true);
  3191. if($sj)
  3192. {
  3193. $sj = $this->input->post('sj',true);
  3194. }
  3195. else
  3196. {
  3197. $sj = "fullorder";
  3198. }
  3199. **/
  3200. $sj = "fullorderamz";
  3201. $where = "1=1";
  3202. if ($warehouse) {
  3203. $where .= " and type = '$warehouse'";
  3204. }
  3205. if ($timetk && $timetj) {
  3206. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3207. }
  3208. if ($orderinfo) {
  3209. $where .= " and orderinfo = '$orderinfo'";
  3210. }
  3211. if ($number) {
  3212. $where .= " and number = '$number'";
  3213. }
  3214. if ($express) {
  3215. $where .= " and express = '$express'";
  3216. }
  3217. if ($waybill) {
  3218. $where .= " and waybill = '$waybill'";
  3219. }
  3220. if ($library) {
  3221. $where .= " and library = '$library'";
  3222. }
  3223. if ($print) {
  3224. $where .= " and print = '$print'";
  3225. }
  3226. if ($libraryconfirm) {
  3227. $where .= " and libraryconfirm = '$libraryconfirm'";
  3228. }
  3229. if ($state) {
  3230. $where .= " and state = '$state'";
  3231. }
  3232. if ($shop) {
  3233. $where .= " and shop = '$shop'";
  3234. }
  3235. if ($country) {
  3236. $where .= " and country = '$country'";
  3237. }
  3238. if ($sfxh != '') {
  3239. $where .= " and sfxh = '$sfxh'";
  3240. }
  3241. if ($so) {
  3242. $where .= " and shipremarks like '%$so%'";
  3243. }
  3244. if ($source) {
  3245. if ($source == '2d') {
  3246. $where .= " and source >= '2'";
  3247. } else {
  3248. $where .= " and source = '$source'";
  3249. }
  3250. }
  3251. if (isset($_SESSION['api'])) {
  3252. foreach ($user as $value) {
  3253. $fgshop .= " shop = " . $value . " or";
  3254. }
  3255. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3256. }
  3257. if ($orderurl) {
  3258. $url = $this->orderurl->read($orderurl);
  3259. $where .= " and link like '%" . $url['url'] . "%'";
  3260. }
  3261. //数据排序
  3262. $order_str = "librarytime desc";
  3263. if (empty($page)) {
  3264. $start = 0;
  3265. $perpage = 1;
  3266. } else {
  3267. $start = ($page - 1) * $perpage;
  3268. }
  3269. //取得信息列表
  3270. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3271. //格式化数据
  3272. foreach ($info_list as $key => $value) {
  3273. $shop = $this->shop->read($value['shop']);
  3274. $info_list[$key]['shop'] = $shop['shopname'];
  3275. $express = $this->express->read($value['express']);
  3276. $info_list[$key]['express'] = $express['servicename'];
  3277. $warehouse = $this->warehouse->read($value['type']);
  3278. $info_list[$key]['type'] = $warehouse['title'];
  3279. if ($value['librarytime'] == '0') {
  3280. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3281. } else {
  3282. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3283. }
  3284. }
  3285. $total = $this->$sj->find_count($where);
  3286. $pagenum = ceil($total / $perpage);
  3287. $over = $total - ($start + $perpage);
  3288. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3289. echo json_encode($rows);
  3290. exit;
  3291. }
  3292. $this->data['express'] = $this->express->find_all();
  3293. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3294. $this->data['wlshop'] = $wlshop;
  3295. $user = $this->user->get_api($_SESSION['api']);
  3296. $powerid = $this->power->read($user['power']);
  3297. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3298. $pid = '';
  3299. foreach ($powertext as $v) {
  3300. $pid .= " id = " . $v . " or";
  3301. }
  3302. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3303. $this->data['fullorderexcel'] = $fullorderexcel;
  3304. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3305. $this->data['orderurl'] = $orderurl;
  3306. $this->_Template('whlabel_aoutorder', $this->data);
  3307. }
  3308. //速卖通出库订单
  3309. public function _soutorder()
  3310. {
  3311. if (isset($_SESSION['api'])) {
  3312. $user = $this->user->get_api($_SESSION['api']);
  3313. $usp = $user;
  3314. $fgshop = "";
  3315. $sid = "";
  3316. $user = explode('|', trim($user['shop'], '|'));
  3317. foreach ($user as $value) {
  3318. $sid .= " id = " . $value . " or";
  3319. }
  3320. }
  3321. $post = $this->input->post(NULL, TRUE);
  3322. if (isset($post['page'])) {
  3323. $page = $this->input->post('page', true);
  3324. $perpage = $this->input->post('perpage', true);
  3325. $warehouse = $this->input->post('warehouse', true);
  3326. $xztime = $this->input->post('xztime', true);
  3327. $timetk = $this->input->post('timetkk', true);
  3328. $timetj = $this->input->post('timetjj', true);
  3329. $shop = $this->input->post('shop', true);
  3330. $source = $this->input->post('source', true);
  3331. $orderinfo = $this->input->post('orderinfo', true);
  3332. $number = $this->input->post('number', true);
  3333. $express = $this->input->post('express', true);
  3334. $waybill = $this->input->post('waybill', true);
  3335. $library = $this->input->post('library', true);
  3336. $country = $this->input->post('country', true);
  3337. $sfxh = $this->input->post('sfxh', true);
  3338. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3339. $print = $this->input->post('print', true);
  3340. $state = $this->input->post('state', true);
  3341. $so = $this->input->post('so', true);
  3342. $timetk = strtotime($timetk);
  3343. $timetj = strtotime($timetj);
  3344. /**
  3345. $sj = $this->input->post('sj',true);
  3346. if($sj)
  3347. {
  3348. $sj = $this->input->post('sj',true);
  3349. }
  3350. else
  3351. {
  3352. $sj = "fullorder";
  3353. }
  3354. **/
  3355. $sj = "fullordersmt";
  3356. $where = "1=1";
  3357. if ($warehouse) {
  3358. $where .= " and type = '$warehouse'";
  3359. }
  3360. if ($timetk && $timetj) {
  3361. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3362. }
  3363. if ($orderinfo) {
  3364. $where .= " and orderinfo = '$orderinfo'";
  3365. }
  3366. if ($number) {
  3367. $where .= " and number = '$number'";
  3368. }
  3369. if ($express) {
  3370. $where .= " and express = '$express'";
  3371. }
  3372. if ($waybill) {
  3373. $where .= " and waybill = '$waybill'";
  3374. }
  3375. if ($library) {
  3376. $where .= " and library = '$library'";
  3377. }
  3378. if ($print) {
  3379. $where .= " and print = '$print'";
  3380. }
  3381. if ($libraryconfirm) {
  3382. $where .= " and libraryconfirm = '$libraryconfirm'";
  3383. }
  3384. if ($state) {
  3385. $where .= " and state = '$state'";
  3386. }
  3387. if ($shop) {
  3388. $where .= " and shop = '$shop'";
  3389. }
  3390. if ($sfxh != '') {
  3391. $where .= " and sfxh = '$sfxh'";
  3392. }
  3393. if ($so) {
  3394. $where .= " and shipremarks like '%$so%'";
  3395. }
  3396. if ($source) {
  3397. $where .= " and source = '$source'";
  3398. }
  3399. if ($country) {
  3400. $where .= " and country = '$country'";
  3401. } else {
  3402. if (isset($_SESSION['api'])) {
  3403. foreach ($user as $value) {
  3404. $fgshop .= " shop = " . $value . " or";
  3405. }
  3406. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3407. }
  3408. }
  3409. //数据排序
  3410. $order_str = "librarytime desc";
  3411. if (empty($page)) {
  3412. $start = 0;
  3413. $perpage = 1;
  3414. } else {
  3415. $start = ($page - 1) * $perpage;
  3416. }
  3417. //取得信息列表
  3418. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3419. //格式化数据
  3420. foreach ($info_list as $key => $value) {
  3421. $shop = $this->shop->read($value['shop']);
  3422. $info_list[$key]['shop'] = $shop['shopname'];
  3423. $express = $this->express->read($value['express']);
  3424. $info_list[$key]['express'] = $express['servicename'];
  3425. $warehouse = $this->warehouse->read($value['type']);
  3426. $info_list[$key]['type'] = $warehouse['title'];
  3427. if ($value['librarytime'] == '0') {
  3428. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3429. } else {
  3430. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3431. }
  3432. }
  3433. $total = $this->$sj->find_count($where);
  3434. $pagenum = ceil($total / $perpage);
  3435. $over = $total - ($start + $perpage);
  3436. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3437. echo json_encode($rows);
  3438. exit;
  3439. }
  3440. $this->data['express'] = $this->express->find_all();
  3441. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3442. $this->data['wlshop'] = $wlshop;
  3443. $user = $this->user->get_api($_SESSION['api']);
  3444. $powerid = $this->power->read($user['power']);
  3445. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3446. $pid = '';
  3447. foreach ($powertext as $v) {
  3448. $pid .= " id = " . $v . " or";
  3449. }
  3450. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3451. $this->data['fullorderexcel'] = $fullorderexcel;
  3452. $this->_Template('whlabel_soutorder', $this->data);
  3453. }
  3454. //订单退库
  3455. public function _retreat()
  3456. {
  3457. $post = $this->input->post(NULL, TRUE);
  3458. if (isset($post['page'])) {
  3459. $page = $this->input->post('page', true);
  3460. $perpage = $this->input->post('perpage', true);
  3461. $warehouse = $this->input->post('warehouse', true);
  3462. $timetk = $this->input->post('timetk', true);
  3463. $timetj = $this->input->post('timetj', true);
  3464. $shop = $this->input->post('shop', true);
  3465. $source = $this->input->post('source', true);
  3466. $state = $this->input->post('state', true);
  3467. $review = $this->input->post('review', true);
  3468. $state = $this->input->post('state', true);
  3469. $express = $this->input->post('express', true);
  3470. $orderinfo = $this->input->post('orderinfo', true);
  3471. $user = $this->input->post('user', true);
  3472. $name = $this->input->post('name', true);
  3473. $waybill = $this->input->post('waybill', true);
  3474. $timetk = strtotime($timetk);
  3475. $timetj = strtotime($timetj);
  3476. $where = "(state=206 or state=210) and mergeid = 0";
  3477. if ($warehouse) {
  3478. $where .= " and state = '$warehouse'";
  3479. }
  3480. if ($timetk && $timetj) {
  3481. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3482. }
  3483. if ($shop) {
  3484. $where .= " and shop = '$shop'";
  3485. }
  3486. if ($source) {
  3487. $where .= " and source = '$source'";
  3488. }
  3489. if ($state) {
  3490. $where .= " and state = '$state'";
  3491. }
  3492. if ($review) {
  3493. $where .= " and review = '$review'";
  3494. }
  3495. if ($state) {
  3496. $where .= " and state = '$state'";
  3497. }
  3498. if ($express) {
  3499. $where .= " and express = '$express'";
  3500. }
  3501. if ($orderinfo) {
  3502. $where .= " and orderinfo = '$orderinfo'";
  3503. }
  3504. if ($user) {
  3505. $where .= " and user = '$user'";
  3506. }
  3507. if ($name) {
  3508. $where .= " and name = '$name'";
  3509. }
  3510. if ($waybill) {
  3511. $where .= " and waybill = '$waybill'";
  3512. }
  3513. //数据排序
  3514. $order_str = "id desc";
  3515. if (empty($page)) {
  3516. $start = 0;
  3517. $perpage = 1;
  3518. } else {
  3519. $start = ($page - 1) * $perpage;
  3520. }
  3521. //取得信息列表
  3522. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3523. //格式化数据
  3524. foreach ($info_list as $key => $value) {
  3525. $shop = $this->shop->read($value['shop']);
  3526. $info_list[$key]['shop'] = $shop['shopname'];
  3527. $warehouse = $this->warehouse->read($value['warehouse']);
  3528. $info_list[$key]['warehouse'] = $warehouse['title'];
  3529. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3530. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3531. if ($value['waybill'] == 0) {
  3532. $info_list[$key]['waybill'] = "";
  3533. }
  3534. $express = $this->express->read($value['express']);
  3535. $info_list[$key]['express'] = $express['title'];
  3536. $typeclass = $this->typeclass->read($value['state']);
  3537. $info_list[$key]['state'] = $typeclass['title'];
  3538. }
  3539. $total = $this->fullorder->find_count($where);
  3540. $pagenum = ceil($total / $perpage);
  3541. $over = $total - ($start + $perpage);
  3542. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3543. echo json_encode($rows);
  3544. exit;
  3545. }
  3546. $this->data['express'] = $this->express->find_all();
  3547. $this->_Template('whlabel_retreat', $this->data);
  3548. }
  3549. //退库标签浏览
  3550. public function _retreatlk()
  3551. {
  3552. $post = $this->input->post(NULL, TRUE);
  3553. if (isset($post['page'])) {
  3554. $page = $this->input->post('page', true);
  3555. $perpage = $this->input->post('perpage', true);
  3556. $timetk = $this->input->post('timetk', true);
  3557. $timetj = $this->input->post('timetj', true);
  3558. $sku = $this->input->post('sku', true);
  3559. $warehouse = $this->input->post('warehouse', true);
  3560. $purchase = $this->input->post('purchase', true);
  3561. $orderinfo = $this->input->post('orderinfo', true);
  3562. $waybill = $this->input->post('waybill', true);
  3563. $category = $this->input->post('category', true);
  3564. $size = $this->input->post('size', true);
  3565. $grade = $this->input->post('grade', true);
  3566. $color = $this->input->post('color', true);
  3567. $lowe = $this->input->post('lowe', true);
  3568. $state = $this->input->post('state', true);
  3569. $timetk = strtotime($timetk);
  3570. $timetj = strtotime($timetj);
  3571. $where = "state=2";
  3572. if ($timetk && $timetj) {
  3573. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3574. }
  3575. if ($sku) {
  3576. $where .= " and sku = '$sku'";
  3577. }
  3578. if ($warehouse) {
  3579. $where .= " and warehouse = '$warehouse'";
  3580. }
  3581. if ($purchase) {
  3582. $where .= " and purchase = '$purchase'";
  3583. }
  3584. if ($orderinfo) {
  3585. $where .= " and orderinfo = '$orderinfo'";
  3586. }
  3587. if ($waybill) {
  3588. $where .= " and waybill = '$waybill'";
  3589. }
  3590. if ($category) {
  3591. $where .= " and features like '%-$category-%'";
  3592. }
  3593. if ($size) {
  3594. $where .= " and features like '%-$size-%'";
  3595. }
  3596. if ($grade) {
  3597. $where .= " and features like '%-$grade-%'";
  3598. }
  3599. if ($color) {
  3600. $where .= " and features like '%-$color-%'";
  3601. }
  3602. if ($lowe) {
  3603. $where .= " and features like '%-$lowe-%'";
  3604. }
  3605. //数据排序
  3606. $order_str = "time desc";
  3607. if (empty($page)) {
  3608. $start = 0;
  3609. $perpage = 1;
  3610. } else {
  3611. $start = ($page - 1) * $perpage;
  3612. }
  3613. //取得信息列表
  3614. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3615. foreach ($info_list as $key => $value) {
  3616. $warehouse = $this->warehouse->read($value['warehouse']);
  3617. $info_list[$key]['warehouse'] = $warehouse['title'];
  3618. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3619. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3620. $purchase = $this->purchase->read($value['purchase']);
  3621. $info_list[$key]['purchase'] = $purchase['title'];
  3622. if ($value['outk'] != 0) {
  3623. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3624. } else {
  3625. $info_list[$key]['outk'] = "";
  3626. }
  3627. if ($value['retreat'] != 0) {
  3628. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3629. } else {
  3630. $info_list[$key]['retreat'] = "";
  3631. }
  3632. if ($value['orderinfo'] == 0) {
  3633. $info_list[$key]['orderinfo'] = "";
  3634. }
  3635. if ($value['waybill'] == 0) {
  3636. $info_list[$key]['waybill'] = "";
  3637. }
  3638. }
  3639. $total = $this->whlabel->find_count($where);
  3640. $pagenum = ceil($total / $perpage);
  3641. $over = $total - ($start + $perpage);
  3642. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3643. echo json_encode($rows);
  3644. exit;
  3645. }
  3646. $this->_Template('whlabel_retreatlk', $this->data);
  3647. }
  3648. //更换标签及浏览
  3649. public function _change()
  3650. {
  3651. $post = $this->input->post(NULL, TRUE);
  3652. if (isset($post['page'])) {
  3653. $page = $this->input->post('page', true);
  3654. $perpage = $this->input->post('perpage', true);
  3655. $timetk = $this->input->post('timetk', true);
  3656. $timetj = $this->input->post('timetj', true);
  3657. $label = $this->input->post('label', true);
  3658. $oldlabel = $this->input->post('oldlabel', true);
  3659. $timetk = strtotime($timetk);
  3660. $timetj = strtotime($timetj);
  3661. $where = "state=10 ";
  3662. if ($timetk && $timetj) {
  3663. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3664. }
  3665. if ($label) {
  3666. $where .= " and label = '$label'";
  3667. }
  3668. if ($oldlabel) {
  3669. $where .= " and oldlabel = '$oldlabel'";
  3670. }
  3671. //数据排序
  3672. $order_str = "time asc";
  3673. if (empty($page)) {
  3674. $start = 0;
  3675. $perpage = 1;
  3676. } else {
  3677. $start = ($page - 1) * $perpage;
  3678. }
  3679. //取得信息列表
  3680. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3681. foreach ($info_list as $key => $value) {
  3682. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3683. }
  3684. $total = $this->whlabel->find_count($where);
  3685. $pagenum = ceil($total / $perpage);
  3686. $over = $total - ($start + $perpage);
  3687. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3688. echo json_encode($rows);
  3689. exit;
  3690. }
  3691. $this->_Template('whlabel_change', $this->data);
  3692. }
  3693. //产品标签
  3694. public function _cpbqdc()
  3695. {
  3696. if (isset($_GET['excel'])) {
  3697. $where = "1=1";
  3698. //数据排序
  3699. $order_str = "id desc";
  3700. if (empty($page)) {
  3701. $start = 0;
  3702. $perpage = 1;
  3703. } else {
  3704. $start = ($page - 1) * $perpage;
  3705. }
  3706. $warehouse = $this->input->get('warehouse', true);
  3707. $state = $this->input->get('state', true);
  3708. $timetk = $this->input->get('timetkk', true);
  3709. $timetj = $this->input->get('timetjj', true);
  3710. $timetk = strtotime($timetk);
  3711. $timetj = strtotime($timetj);
  3712. if ($warehouse) {
  3713. $where .= " and warehouse = '$warehouse'";
  3714. }
  3715. if ($state || $state == 0) {
  3716. $where .= " and state = '$state'";
  3717. }
  3718. if ($timetk && $timetj) {
  3719. $where .= " and time > '$timetk' and time < '$timetj'";
  3720. }
  3721. //取得信息列表
  3722. $info_list = $this->whlabel->find_all($where, '*');
  3723. $rows = array();
  3724. $list = array();
  3725. foreach ($info_list as $key => $value) {
  3726. $rows[$value['time']] = $value; //所有数据sku
  3727. }
  3728. foreach ($rows as $value) {
  3729. $warehouse = $this->warehouse->read($value['warehouse']);
  3730. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3731. $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);
  3732. }
  3733. $title = "产品标签统计表";
  3734. $titlename = "<table border=1>
  3735. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3736. <tr align='center'>
  3737. <td>仓库</td>
  3738. <td>SKU</td>
  3739. <td>产品</td>
  3740. <td>入库时间</td>
  3741. <td>操作时间</td>
  3742. <td>备注</td>
  3743. <td>数量</td>
  3744. </tr>
  3745. </table>";
  3746. $filename = $title . ".xls";
  3747. $tail = "";
  3748. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3749. }
  3750. }
  3751. //进销存导出
  3752. public function _exceljxc()
  3753. {
  3754. $classid = $this->classid->sku();
  3755. $pm = $classid;
  3756. $typeclass = array();
  3757. $tc = $this->typeclass->find_all();
  3758. foreach ($tc as $v) {
  3759. $typeclass[$v['id']] = $v;
  3760. }
  3761. $prc = array();
  3762. $purchase = $this->purchase->find_all();
  3763. foreach ($purchase as $k => $v) {
  3764. $prc[$v['id']] = $v['title'];
  3765. }
  3766. if (isset($_GET['excel'])) {
  3767. $where = "sku != 'Preset'";
  3768. //数据排序
  3769. $order_str = "id desc";
  3770. if (empty($page)) {
  3771. $start = 0;
  3772. $perpage = 1;
  3773. } else {
  3774. $start = ($page - 1) * $perpage;
  3775. }
  3776. $category = $this->input->get('category', true);
  3777. $warehouse = $this->input->get('warehouse', true);
  3778. $excelid = $this->input->get('sid', true);
  3779. if ($category) {
  3780. $where .= " and features like '%-$category-%'";
  3781. }
  3782. if ($warehouse) {
  3783. $where .= " and warehouse = '$warehouse'";
  3784. }
  3785. $xzid = '';
  3786. if ($excelid) {
  3787. $excelid = explode(',', trim($excelid, ','));
  3788. foreach ($excelid as $key => $value) {
  3789. $xzid .= " id = " . $value . " or";
  3790. }
  3791. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3792. }
  3793. //取得信息列表
  3794. /**
  3795. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3796. $rows = array();$list = array();
  3797. foreach ($info_list as $key=>$value)
  3798. {
  3799. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3800. }
  3801. **/
  3802. $wt = array();
  3803. $whlabel_type = $this->whlabel_type->find_all();
  3804. foreach ($whlabel_type as $v) {
  3805. $wt[$v['id']] = $v['title'];
  3806. }
  3807. $wh = array();
  3808. $w = $this->warehouse->find_all('1=1', 'id,title');
  3809. foreach ($w as $v) {
  3810. $wh[$v['id']] = $v['title'];
  3811. }
  3812. $list = array();
  3813. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3814. foreach ($rows as $key => $value) {
  3815. if (isset($wt[$value['type']])) {
  3816. $rows[$key]['type'] = $wt[$value['type']];
  3817. } else {
  3818. $rows[$key]['type'] = '未设置';
  3819. }
  3820. $bm = '03';
  3821. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3822. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3823. $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');
  3824. $details = array();
  3825. $cpid = array();
  3826. $cpbz = array();
  3827. $c = 0;
  3828. $g = 0;
  3829. $x = 0;
  3830. $t = 0;
  3831. $s = 0;
  3832. $q = 0;
  3833. foreach ($sd as $k => $v) {
  3834. if ($v['state'] == 0) {
  3835. $c++;
  3836. if ($v['cpid'] != 0) {
  3837. $cpid[$v['cpid']] = $v['cpid'];
  3838. }
  3839. if ($v['cpbz'] != '') {
  3840. $cpbz[$v['cpbz']] = $v['cpbz'];
  3841. }
  3842. }
  3843. if ($v['state'] != 9) {
  3844. $g++;
  3845. }
  3846. if ($v['state'] == 1) {
  3847. $x++;
  3848. }
  3849. if ($v['state'] == 2) {
  3850. $t++;
  3851. }
  3852. if ($v['state'] == 8) {
  3853. $s++;
  3854. }
  3855. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3856. $q++;
  3857. }
  3858. $details[$v['details']] = $v['details'];
  3859. }
  3860. $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'] . '"');
  3861. $rows[$key]['details'] = implode("、", $details);
  3862. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3863. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3864. $number = $value['number'];
  3865. $ftime = time() - 15 * 24 * 3600;
  3866. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3867. $rows[$key]['number'] = $g;
  3868. $rows[$key]['c'] = $c;
  3869. $rows[$key]['x'] = $x;
  3870. $rows[$key]['t'] = $t;
  3871. $rows[$key]['s'] = $s;
  3872. $rows[$key]['q'] = $q;
  3873. $rows[$key]['z'] = $z;
  3874. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3875. $features = explode('-', trim($features, '-'));
  3876. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3877. // $pm = $classid;
  3878. // $jm = $classid;
  3879. // foreach($features as $k=>$v)
  3880. // {
  3881. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3882. // {
  3883. // if($typeclass[$v]['bm'] != '')
  3884. // {
  3885. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3886. // }
  3887. // }
  3888. // if($v != 0)
  3889. // {
  3890. // if(!isset($typeclass[$v]))
  3891. // {
  3892. // continue;
  3893. // }
  3894. // if(isset($pm[$typeclass[$v]['classid']]))
  3895. // {
  3896. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3897. // {
  3898. // $tz = explode('|',$typeclass[$v]['zh']);
  3899. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3900. // }
  3901. // else
  3902. // {
  3903. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3904. // }
  3905. // }
  3906. // if(isset($jm[$typeclass[$v]['classid']]))
  3907. // {
  3908. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3909. // }
  3910. // }
  3911. // }
  3912. // $jm = array_filter($jm);
  3913. // $rows[$key]['bs'] = implode("-",$jm);
  3914. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3915. // $zh = implode(" ",$pm);
  3916. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3917. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3918. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3919. // $rows[$key]['features'] = $zh;
  3920. }
  3921. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3922. $final_list = [];
  3923. foreach ($list as $k => $v) {
  3924. if (empty($v['sku'])) {
  3925. continue;
  3926. }
  3927. $final_list[] = [
  3928. "warehouse" => $v["warehouse"],
  3929. "purchase" => $v["purchase"],
  3930. "details" => $v["details"],
  3931. "cpid" => $v["cpid"],
  3932. "dbcontent" => $v["dbcontent"],
  3933. "sku" => $v["sku"],
  3934. "cs" => $v["bm"],
  3935. "bs" => $v["jm"],
  3936. "title" => $v["title"],
  3937. "features" => $v["pm"],
  3938. "cpbz" => $v["cpbz"],
  3939. "sm" => $v["sm"],
  3940. "type" => $v["type"],
  3941. "number" => $v["number"],
  3942. "c" => $v["c"],
  3943. "x" => $v["x"],
  3944. "t" => $v["t"],
  3945. "s" => $v["s"],
  3946. "q" => $v["q"],
  3947. "z" => $v["z"],
  3948. "weight" => $v['weight'],
  3949. ];
  3950. }
  3951. $title = "总进销存统计表";
  3952. $titlename = "<table border=1>
  3953. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3954. <tr align='center'>
  3955. <td>仓库</td>
  3956. <td>供应商</td>
  3957. <td>位置</td>
  3958. <td>库存编码</td>
  3959. <td>类目</td>
  3960. <td>SKU</td>
  3961. <td>用友编码</td>
  3962. <td>用友料号</td>
  3963. <td>商品名称</td>
  3964. <td>商品中文</td>
  3965. <td>产品备注</td>
  3966. <td>库位负责人</td>
  3967. <td>类型</td>
  3968. <td>入库总量</td>
  3969. <td>库存数量</td>
  3970. <td>销售数量</td>
  3971. <td>退货数量</td>
  3972. <td>删除数量</td>
  3973. <td>其它操作</td>
  3974. <td>占单数量</td>
  3975. <td>重量(g)</td>
  3976. </tr>
  3977. </table>";
  3978. $filename = $title . ".xls";
  3979. $tail = "";
  3980. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3981. }
  3982. }
  3983. //入库导出
  3984. public function _excelr()
  3985. {
  3986. if (isset($_GET['excel'])) {
  3987. $category = $this->input->get('category', true);
  3988. $size = $this->input->get('size', true);
  3989. $grade = $this->input->get('grade', true);
  3990. $color = $this->input->get('color', true);
  3991. $lowe = $this->input->get('lowe', true);
  3992. $sku = $this->input->get('sku', true);
  3993. $warehouse = $this->input->get('warehouse', true);
  3994. $purchase = $this->input->get('purchase', true);
  3995. $ktime = $this->input->get('ktime', true);
  3996. $jtime = $this->input->get('jtime', true);
  3997. $rktype = $this->input->get('rktype',true);
  3998. $ktime = strtotime($ktime);
  3999. $jtime = strtotime($jtime);
  4000. $where = "1=1";
  4001. $gj = "";
  4002. $ck = "";
  4003. if ($category) {
  4004. $where .= " and features like '%-$category-%'";
  4005. }
  4006. if ($size) {
  4007. $where .= " and features like '%-$size-%'";
  4008. }
  4009. if ($grade) {
  4010. $where .= " and features like '%-$grade-%'";
  4011. }
  4012. if ($color) {
  4013. $where .= " and features like '%-$color-%'";
  4014. }
  4015. if ($lowe) {
  4016. $where .= " and features like '%-$lowe-%'";
  4017. }
  4018. if ($warehouse) {
  4019. $where .= " and warehouse = '$warehouse'";
  4020. }
  4021. if ($purchase) {
  4022. $where .= " and purchase = '$purchase'";
  4023. }
  4024. if ($sku) {
  4025. $where .= " and sku = '$sku'";
  4026. }
  4027. if($rktype){
  4028. $where .= " and rktype = '$rktype' ";
  4029. }
  4030. if ($ktime && $jtime) {
  4031. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  4032. }
  4033. //数据排序
  4034. $order_str = "id desc";
  4035. if (empty($page)) {
  4036. $start = 0;
  4037. $perpage = 1;
  4038. } else {
  4039. $start = ($page - 1) * $perpage;
  4040. }
  4041. $list = array();
  4042. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  4043. $three_month = strtotime('-3 months');
  4044. $rows_d = $this->whlabelscbf->find_pc($where." and del_time > ".$three_month, 'enter,sku,warehouse', '*', $order_str);
  4045. $rows_d = array_map(function ($item) {
  4046. unset($item['del_time']); // 删除 age 字段
  4047. return $item;
  4048. }, $rows_d);
  4049. $rows = array_merge($rows, $rows_d);
  4050. foreach ($rows as $value) {
  4051. $ck = $this->warehouse->read($value['warehouse']);
  4052. $warehouse = $ck['title'];
  4053. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  4054. $retreatwarehouse = $tkck['title'];
  4055. $gy = $this->purchase->read($value['purchase']);
  4056. $purchase = $gy['title'];
  4057. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  4058. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  4059. }
  4060. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  4061. $titlename = "<table border=1>
  4062. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  4063. <tr align='center'>
  4064. <td>仓库</td>
  4065. <td>SKU</td>
  4066. <td>产品</td>
  4067. <td>时间</td>
  4068. <td>数量</td>
  4069. </tr>
  4070. </table>";
  4071. $filename = $title . ".xls";
  4072. $tail = "";
  4073. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  4074. }
  4075. }
  4076. //出库、退库导出
  4077. public function _excelct()
  4078. {
  4079. $classid = $this->classid->sku();
  4080. $pm = $classid;
  4081. $typeclass = array();
  4082. $tc = $this->typeclass->find_all();
  4083. foreach ($tc as $v) {
  4084. $typeclass[$v['id']] = $v;
  4085. }
  4086. $prc = array();
  4087. $purchase = $this->purchase->find_all();
  4088. foreach ($purchase as $k => $v) {
  4089. $prc[$v['id']] = $v['title'];
  4090. }
  4091. if (isset($_GET['excel'])) {
  4092. $wh = array();
  4093. $w = $this->warehouse->find_all('1=1', 'id,title');
  4094. foreach ($w as $v) {
  4095. $wh[$v['id']] = $v['title'];
  4096. }
  4097. $type = $this->input->get('excel', true);
  4098. $category = $this->input->get('category', true);
  4099. $size = $this->input->get('size', true);
  4100. $grade = $this->input->get('grade', true);
  4101. $color = $this->input->get('color', true);
  4102. $lowe = $this->input->get('lowe', true);
  4103. $sku = $this->input->get('sku', true);
  4104. $title = $this->input->get('title', true);
  4105. $warehouse = $this->input->get('warehouse', true);
  4106. $purchase = $this->input->get('purchase', true);
  4107. $lacetype = $this->input->get('lacetype', true);
  4108. $haircap = $this->input->get('haircap', true);
  4109. $lacecolor = $this->input->get('lacecolor', true);
  4110. $density = $this->input->get('density', true);
  4111. $details = $this->input->get('details', true);
  4112. $state = $this->input->get('state', true);
  4113. $shop = $this->input->get('shop', true);
  4114. $hairnumber = $this->input->get('hairnumber', true);
  4115. $type_leixi = $this->input->get('type', true);
  4116. $cpbz = $this->input->get('cpbz', true);
  4117. $sm = $this->input->get('sm', true);
  4118. $sid = $this->input->get('sid', true);
  4119. $ktime = $this->input->get('ktime', true);
  4120. $jtime = $this->input->get('jtime', true);
  4121. $ktime = strtotime($ktime);
  4122. $jtime = strtotime($jtime);
  4123. //$where = " 1=1 ";
  4124. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  4125. $where = " sku != '' ";
  4126. $gj = "";
  4127. $ck = "";
  4128. if ($category) {
  4129. $where .= " and features like '%-$category-%'";
  4130. }
  4131. if ($size) {
  4132. $where .= " and features like '%-$size-%'";
  4133. }
  4134. if ($grade) {
  4135. $where .= " and features like '%-$grade-%'";
  4136. }
  4137. if ($color) {
  4138. $where .= " and features like '%-$color-%'";
  4139. }
  4140. if ($lowe) {
  4141. $where .= " and features like '%-$lowe-%'";
  4142. }
  4143. if ($warehouse) {
  4144. $where .= " and warehouse = '$warehouse'";
  4145. }
  4146. if ($purchase) {
  4147. $where .= " and purchase = '$purchase'";
  4148. }
  4149. if ($state) {
  4150. $where .= " and state = '$state'";
  4151. }
  4152. if ($lacetype) {
  4153. $where .= " and features like '%-$lacetype-%'";
  4154. }
  4155. if ($lacecolor) {
  4156. $where .= " and features like '%-$lacecolor-%'";
  4157. }
  4158. if ($density) {
  4159. $where .= " and features like '%-$density-%'";
  4160. }
  4161. if ($haircap) {
  4162. $where .= " and features like '%-$haircap-%'";
  4163. }
  4164. if ($details) {
  4165. $where .= " and details = '$details'";
  4166. }
  4167. if ($shop) {
  4168. $where .= " and shop like '%$shop%'";
  4169. }
  4170. if ($title) {
  4171. $title = trim($title, ' ');
  4172. $title = trim($title, ' ');
  4173. $where .= " and title like '%$title%'";
  4174. }
  4175. if (!empty($hairnumber)) {
  4176. $where .= " and features like '%-128-%' ";
  4177. if ($hairnumber < 0) {
  4178. $class_list = $this->typeclass->find_all('classid = 43');
  4179. foreach ($class_list as $v) {
  4180. $where .= " and features not like '%-" . $v['id'] . "-%'";
  4181. }
  4182. } else {
  4183. $where .= " and features like '%-$hairnumber-%'";
  4184. }
  4185. }
  4186. if ($type_leixi) {
  4187. $where .= " and type = '$type_leixi'";
  4188. }
  4189. if ($cpbz) {
  4190. $where .= " and cpbz like '%$cpbz%' ";
  4191. }
  4192. if ($sm) {
  4193. $where .= " and sm like '%$sm%' ";
  4194. }
  4195. if ($sku) {
  4196. $sku = trim($sku, ' ');
  4197. $sku = trim($sku, ' ');
  4198. $where .= " and sku like '%$sku%'";
  4199. }
  4200. if ($ktime && $jtime) {
  4201. if ($type == 1) {
  4202. $tl = '出库';
  4203. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4204. } else if ($type == 2) {
  4205. $tl = '退库';
  4206. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4207. } else if ($type == 3) {
  4208. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4209. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4210. } else if ($type == 4) {
  4211. $tl = '出库+零售';
  4212. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4213. } else if ($type == 5) {
  4214. $tl = '零售';
  4215. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4216. }
  4217. }
  4218. $sidwhere = '';
  4219. if ($sid) {
  4220. $sd = "";
  4221. $s = explode(',', trim($sid, ','));
  4222. foreach ($s as $value) {
  4223. $sd .= " id = " . $value . " or";
  4224. }
  4225. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  4226. }
  4227. //数据排序
  4228. $order_str = "time desc";
  4229. if (empty($page)) {
  4230. $start = 0;
  4231. $perpage = 1;
  4232. } else {
  4233. $start = ($page - 1) * $perpage;
  4234. }
  4235. //取得信息列表
  4236. if ($type != 3 && $type != 5) {
  4237. if ($type == 1 || $type == 4) {
  4238. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  4239. $three_month = strtotime('-3 months');
  4240. $info_list_d = $this->whlabelscbf->find_all($where." and del_time > ".$three_month, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  4241. $info_list_d = array_map(function ($item) {
  4242. unset($item['del_time']); // 删除 age 字段
  4243. return $item;
  4244. }, $info_list_d);
  4245. $info_list = array_merge($info_list, $info_list_d);
  4246. foreach ($info_list as $key => $value) {
  4247. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4248. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4249. $warehouse = $this->warehouse->read($value['warehouse']);
  4250. $info_list[$key]['warehouse'] = $warehouse['title'];
  4251. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4252. $features = explode('-', trim($features, '-'));
  4253. $pm = $classid;
  4254. foreach ($features as $k => $v) {
  4255. if ($v != 0) {
  4256. if (!isset($typeclass[$v])) {
  4257. continue;
  4258. }
  4259. if (isset($pm[$typeclass[$v]['classid']])) {
  4260. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4261. $tz = explode('|', $typeclass[$v]['zh']);
  4262. $pm[$typeclass[$v]['classid']] = $tz[0];
  4263. } else {
  4264. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4265. }
  4266. }
  4267. }
  4268. }
  4269. $zh = implode(" ", $pm);
  4270. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4271. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4272. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4273. $info_list[$key]['features'] = $zh;
  4274. }
  4275. $final_list = [];
  4276. foreach($info_list as $k=>$v){
  4277. $number = "";
  4278. if(!empty($v['orderinfo'])){
  4279. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4280. if(!empty($tmp_info['number'])){
  4281. $number = $tmp_info['number'];
  4282. }
  4283. }
  4284. $final_list[] = [
  4285. 'warehouse'=>$v['warehouse'],
  4286. 'purchase'=>$v['purchase'],
  4287. 'sku'=>$v['sku'],
  4288. 'title'=>$v['title'],
  4289. 'features'=>$v['features'],
  4290. 'label'=>$v['label'],
  4291. 'orderinfo'=>$v['orderinfo'],
  4292. 'number'=>$number,
  4293. 'waybill'=>$v['waybill'],
  4294. 'outk'=>$v['outk'],
  4295. ];
  4296. }
  4297. } else {
  4298. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  4299. foreach ($info_list as $key => $value) {
  4300. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4301. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  4302. $warehouse = $this->warehouse->read($value['warehouse']);
  4303. $info_list[$key]['warehouse'] = $warehouse['title'];
  4304. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4305. $features = explode('-', trim($features, '-'));
  4306. $pm = $classid;
  4307. foreach ($features as $k => $v) {
  4308. if ($v != 0) {
  4309. if (!isset($typeclass[$v])) {
  4310. continue;
  4311. }
  4312. if (isset($pm[$typeclass[$v]['classid']])) {
  4313. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4314. $tz = explode('|', $typeclass[$v]['zh']);
  4315. $pm[$typeclass[$v]['classid']] = $tz[0];
  4316. } else {
  4317. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4318. }
  4319. }
  4320. }
  4321. }
  4322. $zh = implode(" ", $pm);
  4323. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4324. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4325. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4326. $info_list[$key]['features'] = $zh;
  4327. }
  4328. $final_list = [];
  4329. foreach($info_list as $k=>$v){
  4330. $number = "";
  4331. if(!empty($v['orderinfo'])){
  4332. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4333. if(!empty($tmp_info['number'])){
  4334. $number = $tmp_info['number'];
  4335. }
  4336. }
  4337. $final_list[] = [
  4338. 'warehouse'=>$v['warehouse'],
  4339. 'purchase'=>$v['purchase'],
  4340. 'sku'=>$v['sku'],
  4341. 'title'=>$v['title'],
  4342. 'features'=>$v['features'],
  4343. 'label'=>$v['label'],
  4344. 'orderinfo'=>$v['orderinfo'],
  4345. 'number'=>$number,
  4346. 'waybill'=>$v['waybill'],
  4347. 'retreat'=>$v['retreat'],
  4348. ];
  4349. }
  4350. }
  4351. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4352. $titlename = "<table border=1>
  4353. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  4354. <tr align='center'>
  4355. <td>仓库</td>
  4356. <td>供应商</td>
  4357. <td>SKU</td>
  4358. <td>商品名称</td>
  4359. <td>商品中文</td>
  4360. <td>标签</td>
  4361. <td>订单号</td>
  4362. <td>订单编码</td>
  4363. <td>运单号</td>
  4364. <td>" . $tl . "时间(中国时间)</td>
  4365. </tr>
  4366. </table>";
  4367. $filename = $title . ".xls";
  4368. $tail = "";
  4369. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4370. } else if ($type == 5) {
  4371. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  4372. $three_month = strtotime('-3 months');
  4373. $info_list_d = $this->whlabelscbf->find_all($where." and del_time > ".$three_month, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  4374. $info_list_d = array_map(function ($item) {
  4375. unset($item['del_time']); // 删除 age 字段
  4376. return $item;
  4377. }, $info_list_d);
  4378. $info_list = array_merge($info_list, $info_list_d);
  4379. foreach ($info_list as $key => $value) {
  4380. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4381. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4382. $warehouse = $this->warehouse->read($value['warehouse']);
  4383. $info_list[$key]['warehouse'] = $warehouse['title'];
  4384. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4385. $features = explode('-', trim($features, '-'));
  4386. $pm = $classid;
  4387. foreach ($features as $k => $v) {
  4388. if ($v != 0) {
  4389. if (!isset($typeclass[$v])) {
  4390. continue;
  4391. }
  4392. if (isset($pm[$typeclass[$v]['classid']])) {
  4393. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4394. $tz = explode('|', $typeclass[$v]['zh']);
  4395. $pm[$typeclass[$v]['classid']] = $tz[0];
  4396. } else {
  4397. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4398. }
  4399. }
  4400. }
  4401. }
  4402. $zh = implode(" ", $pm);
  4403. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4404. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4405. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4406. $info_list[$key]['features'] = $zh;
  4407. }
  4408. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4409. $titlename = "<table border=1>
  4410. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4411. <tr align='center'>
  4412. <td>仓库</td>
  4413. <td>供应商</td>
  4414. <td>SKU</td>
  4415. <td>商品名称</td>
  4416. <td>商品中文</td>
  4417. <td>标签</td>
  4418. <td>" . $tl . "时间(中国时间)</td>
  4419. </tr>
  4420. </table>";
  4421. $filename = $title . ".xls";
  4422. $tail = "";
  4423. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4424. } else {
  4425. /**
  4426. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4427. $rows = array();$list = array();
  4428. foreach ($info_list as $key=>$value)
  4429. {
  4430. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4431. }
  4432. **/
  4433. $wh = array();
  4434. $w = $this->warehouse->find_all('1=1', 'id,title');
  4435. foreach ($w as $v) {
  4436. $wh[$v['id']] = $v['title'];
  4437. }
  4438. $wt = array();
  4439. $whlabel_type = $this->whlabel_type->find_all();
  4440. foreach ($whlabel_type as $v) {
  4441. $wt[$v['id']] = $v['title'];
  4442. }
  4443. $classid = $this->classid->sku();
  4444. $list = array();
  4445. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4446. foreach ($rows as $key => $value) {
  4447. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4448. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4449. $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');
  4450. $details = array();
  4451. $cpid = array();
  4452. $cpbz = array();
  4453. $c = 0;
  4454. $g = 0;
  4455. $x = 0;
  4456. $t = 0;
  4457. $s = 0;
  4458. $q = 0;
  4459. foreach ($sd as $k => $v) {
  4460. if ($v['state'] == 0) {
  4461. $c++;
  4462. }
  4463. if ($v['state'] != 9) {
  4464. $g++;
  4465. }
  4466. if ($v['outk'] > 1) {
  4467. $x++;
  4468. }
  4469. if ($v['retreat'] > 0) {
  4470. $t++;
  4471. }
  4472. if ($v['state'] == 8) {
  4473. $s++;
  4474. }
  4475. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4476. $q++;
  4477. }
  4478. $details[$v['details']] = $v['details'];
  4479. if($v['state'] == 0){
  4480. if ($v['cpid'] != 0) {
  4481. $cpid[$v['cpid']] = $v['cpid'];
  4482. }
  4483. if ($v['cpbz'] != '') {
  4484. $cpbz[$v['cpbz']] = $v['cpbz'];
  4485. }
  4486. }
  4487. }
  4488. if (isset($wt[$value['type']])) {
  4489. $rows[$key]['type'] = $wt[$value['type']];
  4490. } else {
  4491. $rows[$key]['type'] = '未设置';
  4492. }
  4493. $rows[$key]['details'] = implode("、", $details);
  4494. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4495. $ftime = time() - 15 * 24 * 3600;
  4496. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4497. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4498. $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);
  4499. $rows[$key]['c'] = $c;
  4500. $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);
  4501. $rows[$key]['t'] = $t;
  4502. $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'] . '"');
  4503. $rows[$key]['z'] = $z;
  4504. // $jm = $classid;
  4505. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4506. $features = explode('-', trim($features, '-'));
  4507. // $pm = $classid;
  4508. // foreach ($features as $k => $v) {
  4509. // if ($v != 0) {
  4510. // if (!isset($typeclass[$v])) {
  4511. // continue;
  4512. // }
  4513. // if (isset($pm[$typeclass[$v]['classid']])) {
  4514. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4515. // $tz = explode('|', $typeclass[$v]['zh']);
  4516. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4517. // } else {
  4518. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4519. // }
  4520. // if (isset($jm[$typeclass[$v]['classid']])) {
  4521. // if ($typeclass[$v]['jm']) {
  4522. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4523. // }
  4524. // }
  4525. // }
  4526. // }
  4527. // }
  4528. // $zh = implode(" ", $pm);
  4529. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4530. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4531. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4532. // $rows[$key]['features'] = $zh;
  4533. // $jm = array_filter($jm); //去除空值
  4534. // $jm = implode("-", $jm);
  4535. // $rows[$key]['jm'] = $jm;
  4536. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4537. }
  4538. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4539. // echo "<pre>";
  4540. // print_r($tmp_list);
  4541. // die;
  4542. $final_list =[];
  4543. foreach($tmp_list as $k=>$v){
  4544. $final_list[] = [
  4545. "warehouse"=>$v['warehouse'],
  4546. "purchase"=>$v['purchase'],
  4547. "details"=>trim($v['details'],'、'),
  4548. "cpid"=>$v['cpid'],
  4549. "sku"=>$v['sku'],
  4550. "title"=>$v['title'],
  4551. "features"=>$v['pm'],
  4552. "cpbz"=>$v['cpbz'],
  4553. "sm"=>$v['sm'],
  4554. "type"=>$v['type'],
  4555. "g"=>$v["g"],
  4556. "c"=>$v["c"],
  4557. "x"=>$v["x"],
  4558. "t"=>$v["t"],
  4559. "z"=>$v["z"],
  4560. "jm"=>$v["jm"],
  4561. "weight"=>$v["weight"],
  4562. "asd"=>$v["asd"],
  4563. ];
  4564. }
  4565. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4566. $titlename = "<table border=1>
  4567. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4568. <tr align='center'>
  4569. <td>仓库</td>
  4570. <td>供应商</td>
  4571. <td>位置</td>
  4572. <td>库存编码</td>
  4573. <td>SKU</td>
  4574. <td>商品名称</td>
  4575. <td>商品中文</td>
  4576. <td>产品备注</td>
  4577. <td>说明</td>
  4578. <td>类型</td>
  4579. <td>入库总量</td>
  4580. <td>库存数量</td>
  4581. <td>销售数量</td>
  4582. <td>退货数量</td>
  4583. <td>占单数量</td>
  4584. <td>料号</td>
  4585. <td>重量</td>
  4586. <td>类目</td>
  4587. </tr>
  4588. </table>";
  4589. $filename = $title . ".xls";
  4590. $tail = "";
  4591. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4592. }
  4593. }
  4594. }
  4595. //出库+入库数据整合
  4596. public function _excelcr()
  4597. {
  4598. if (isset($_GET['excel'])) {
  4599. $type = $this->input->get('excel', true);
  4600. $category = $this->input->get('category', true);
  4601. $size = $this->input->get('size', true);
  4602. $grade = $this->input->get('grade', true);
  4603. $color = $this->input->get('color', true);
  4604. $lowe = $this->input->get('lowe', true);
  4605. $sku = $this->input->get('sku', true);
  4606. $warehouse = $this->input->get('warehouse', true);
  4607. $purchase = $this->input->get('purchase', true);
  4608. $state = $this->input->get('state', true);
  4609. $sid = $this->input->get('sid', true);
  4610. $ktime = $this->input->get('ktime', true);
  4611. $jtime = $this->input->get('jtime', true);
  4612. $ktime = strtotime($ktime);
  4613. $jtime = strtotime($jtime);
  4614. $where = "1=1";
  4615. $gj = "";
  4616. $ck = "";
  4617. if ($category) {
  4618. $where .= " and features like '%-$category-%'";
  4619. }
  4620. if ($size) {
  4621. $where .= " and features like '%-$size-%'";
  4622. }
  4623. if ($grade) {
  4624. $where .= " and features like '%-$grade-%'";
  4625. }
  4626. if ($color) {
  4627. $where .= " and features like '%-$color-%'";
  4628. }
  4629. if ($lowe) {
  4630. $where .= " and features like '%-$lowe-%'";
  4631. }
  4632. if ($warehouse) {
  4633. $where .= " and warehouse = '$warehouse'";
  4634. }
  4635. if ($purchase) {
  4636. $where .= " and purchase = '$purchase'";
  4637. }
  4638. if ($state) {
  4639. $where .= " and state = '$state'";
  4640. }
  4641. if ($sku) {
  4642. $where .= " and sku like '%$sku%'";
  4643. }
  4644. if ($ktime && $jtime) {
  4645. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4646. }
  4647. $sidwhere = '';
  4648. if ($sid) {
  4649. $sd = "";
  4650. $s = explode(',', trim($sid, ','));
  4651. foreach ($s as $value) {
  4652. $sd .= " id = " . $value . " or";
  4653. }
  4654. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4655. }
  4656. //取得信息列表
  4657. $timeread = $ktime;
  4658. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4659. $timelist = array();
  4660. for ($i = 0; $i < $timenum; $i++) {
  4661. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4662. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4663. }
  4664. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4665. //echo "<pre>";
  4666. //print_r($info_list);
  4667. //exit();
  4668. $rows = array();
  4669. $list = array();
  4670. foreach ($info_list as $key => $value) {
  4671. $thistime = $timelist;
  4672. if (isset($rows[strtolower($value['sku'])])) {
  4673. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4674. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4675. }
  4676. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4677. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4678. }
  4679. } else {
  4680. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4681. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4682. }
  4683. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4684. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4685. }
  4686. $rows[strtolower($value['sku'])] = $thistime;
  4687. }
  4688. }
  4689. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4690. <head>
  4691. <!--[if gte mso 9]><xml>
  4692. <x:ExcelWorkbook>
  4693. <x:ExcelWorksheets>
  4694. <x:ExcelWorksheet>
  4695. <x:Name>EXCEL</x:Name>
  4696. <x:WorksheetOptions>
  4697. <x:Print>
  4698. <x:ValidPrinterInfo />
  4699. </x:Print>
  4700. </x:WorksheetOptions>
  4701. </x:ExcelWorksheet>
  4702. </x:ExcelWorksheets>
  4703. </x:ExcelWorkbook>
  4704. </xml>
  4705. <![endif]-->
  4706. </head><body>";
  4707. $str .= "<table border=1><tr><td>SKU</td>";
  4708. foreach ($timelist as $k => $v) {
  4709. $str .= "<td>" . $k . "出库</td>";
  4710. $str .= "<td>" . $k . "入库</td>";
  4711. }
  4712. $str .= "</tr></table>";
  4713. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4714. foreach ($rows as $key => $val) {
  4715. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4716. foreach ($val as $k => $v) {
  4717. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4718. if ($val[$k]['r'] > 0) {
  4719. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4720. } else {
  4721. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4722. }
  4723. }
  4724. $str .= "</tr>";
  4725. }
  4726. $str .= "</table>";
  4727. $str .= "</body></html>";
  4728. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4729. header("Content-type: application/octet-stream");
  4730. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4731. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4732. header("Pragma: no-cache");
  4733. header("Expires: 0");
  4734. exit($str);
  4735. }
  4736. }
  4737. //数量调整模板导出
  4738. public function _presetout()
  4739. {
  4740. if (isset($_GET['excel'])) {
  4741. $where = "sku != 'Preset' and purchase != 0";
  4742. //数据排序
  4743. $order_str = "id desc";
  4744. if (empty($page)) {
  4745. $start = 0;
  4746. $perpage = 1;
  4747. } else {
  4748. $start = ($page - 1) * $perpage;
  4749. }
  4750. //取得信息列表
  4751. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4752. $rows = array();
  4753. $list = array();
  4754. foreach ($info_list as $value) {
  4755. $warehouse = $this->warehouse->read($value['warehouse']);
  4756. $number = $value['number'];
  4757. $ftime = time() - 15 * 24 * 3600;
  4758. $purchase = $this->purchase->read($value['purchase']);
  4759. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '', '', '');
  4760. }
  4761. $title = "库存模板";
  4762. $titlename = "<table border=1>
  4763. <tr align='center'>
  4764. <td>仓库</td>
  4765. <td>供应商编码</td>
  4766. <td>SKU</td>
  4767. <td>增减数量(正数或负数)</td>
  4768. <td>增减备注</td>
  4769. <td>库位</td>
  4770. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4771. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4772. </tr>
  4773. </table>";
  4774. $filename = $title . ".xls";
  4775. $tail = "";
  4776. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4777. }
  4778. }
  4779. //数量调整模板导入
  4780. public function _presetedit()
  4781. {
  4782. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4783. $config['upload_path'] = '.' . $dir;
  4784. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4785. $config['allowed_types'] = 'xls|xlsx|csv';
  4786. $config['max_size'] = 10240;
  4787. $this->load->library('upload', $config);
  4788. $this->upload->initialize($config);
  4789. if ($this->upload->do_upload('userfile')) {
  4790. $full_path = $dir . $this->upload->data('file_name');
  4791. $fileName = '.' . $full_path;
  4792. if (!file_exists($fileName)) {
  4793. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4794. exit;
  4795. } else {
  4796. require_once "./data/excel/PHPExcel/IOFactory.php";
  4797. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4798. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4799. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4800. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4801. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4802. ++$column; //如果列数大于26行
  4803. $list = array();
  4804. for ($i = 2; $i <= $row; $i++) // 行数循环
  4805. {
  4806. $data = array();
  4807. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4808. {
  4809. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4810. }
  4811. $list[] = $data;
  4812. }
  4813. }
  4814. $i = 0;
  4815. $j = 0;
  4816. $ed = array();
  4817. foreach ($list as $key => $value) {
  4818. $time = time();
  4819. if ($value['0'] == "") {
  4820. continue;
  4821. }
  4822. $warehouse = $this->warehouse->get_title($value['0']);
  4823. $purchase = $this->purchase->get_bm($value['1']);
  4824. $sku = $value['2'];
  4825. $num = $value['3']; //调整数量
  4826. $text = $value['4']; //扣减说明
  4827. $type = $value['5']; //调整方式0扣减1删除
  4828. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4829. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4830. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4831. if (!$purchase) //如果没有这个SKU
  4832. {
  4833. $ed[] = array($purchase . '-不存在此供应商编码');
  4834. $j++;
  4835. continue;
  4836. }
  4837. if (!$d) //如果没有这个SKU
  4838. {
  4839. $ed[] = array($sku . '-库存中不存在此SKU');
  4840. $j++;
  4841. continue;
  4842. }
  4843. if (!isset($warehouse['id'])) {
  4844. $ed[] = array($sku . '-仓库名错误!');
  4845. $j++;
  4846. continue;
  4847. }
  4848. if ($type != '0' && $type != '1') {
  4849. $ed[] = array($sku . '-扣减方式填写错误!');
  4850. $j++;
  4851. continue;
  4852. }
  4853. if ($num < 0) //扣减库存
  4854. {
  4855. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4856. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4857. $j++;
  4858. continue;
  4859. }
  4860. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4861. if (count($data) < abs($num)) {
  4862. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4863. $j++;
  4864. continue;
  4865. }
  4866. if ($type == 0) //如果扣减方式为 扣减库存
  4867. {
  4868. for ($i = 0; $i < abs($num); $i++) {
  4869. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4870. }
  4871. } else if ($type == 1) {
  4872. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4873. if (count($zt) > 0) {
  4874. $ed[] = array($sku . '-有在途库存无法删除!');
  4875. $j++;
  4876. continue;
  4877. }
  4878. for ($i = 0; $i < abs($num); $i++) {
  4879. $this->whlabel->remove($data[$i]['id']);
  4880. }
  4881. }
  4882. } else if ($num > 0) //增加库存
  4883. {
  4884. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4885. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4886. $j++;
  4887. continue;
  4888. }
  4889. $post['sku'] = $d['sku'];
  4890. $post['shop'] = $d['shop'];
  4891. $post['warehouse'] = $warehouse['id'];
  4892. $post['purchase'] = $purchase['id'];
  4893. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4894. $post['state'] = 0;
  4895. $post['title'] = $d['title'];
  4896. $post['number'] = $d['number'];
  4897. $post['features'] = $d['features'];
  4898. $post['enter'] = $time;
  4899. $post['time'] = $time; //操作时间
  4900. $post['rktype'] = $rktype;
  4901. for ($i = 0; $i < $num; $i++) {
  4902. $post['label'] = time() . rand(100, 999) . $i;
  4903. $this->whlabel->insert($post);
  4904. }
  4905. }
  4906. sleep(1); //防止入库时间一样,需要延迟1秒
  4907. }
  4908. if ($j > 0) {
  4909. $tt = date('Ymd', time());
  4910. $title = '库存导入错误信息-' . $tt;
  4911. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4912. $tail = "\n";
  4913. $filename = $title . ".xls";
  4914. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4915. $dir = '/data/excel/' . $time . '/';
  4916. $file_name = 'error_' . $time . rand(1000, 9999);
  4917. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4918. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4919. fwrite($myfile, $ecl);
  4920. fclose($myfile);
  4921. $error = $dir . $file_name . '.xls';
  4922. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4923. exit;
  4924. } else {
  4925. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4926. exit;
  4927. }
  4928. }
  4929. }
  4930. public function _presetedittwo(){
  4931. $data = $this->input->post(NULL, TRUE);
  4932. if(empty($list)){
  4933. $raw_data = $this->input->raw_input_stream;
  4934. // 解码 JSON
  4935. $data = json_decode($raw_data, true);
  4936. }
  4937. if(empty($data)){
  4938. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4939. exit;
  4940. }
  4941. $list = [];
  4942. if(isset($data['list'])){
  4943. $list = $data['list'];
  4944. }
  4945. $i = 0;
  4946. $j = 0;
  4947. $ed = array();
  4948. foreach ($list as $key => $value) {
  4949. $time = time();
  4950. if ($value['0'] == "") {
  4951. $ed[] = ['msg'=>'第'.($key+1). '行-仓库未填写!'] ;
  4952. $j++;
  4953. continue;
  4954. }
  4955. $warehouse = $this->warehouse->get_title($value['0']);
  4956. if(empty($warehouse)){
  4957. $ed[] = ['msg'=>'第'.($key+1). '行-仓库名错误!'] ;
  4958. $j++;
  4959. continue;
  4960. }
  4961. $purchase = $this->purchase->get_bm($value['1']);
  4962. $sku = $value['2'];
  4963. $num = $value['3']; //调整数量
  4964. $text = $value['4']; //扣减说明
  4965. $type = 0; //调整方式0扣减1删除
  4966. $details = empty($value['5'])?'':$value['5']; //库位
  4967. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4968. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4969. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4970. if (!$purchase) //如果没有这个SKU
  4971. {
  4972. $ed[] = ['msg'=>$value['1'] . '-不存在此供应商编码'] ;
  4973. $j++;
  4974. continue;
  4975. }
  4976. if (!$d) //如果没有这个SKU
  4977. {
  4978. $ed[] = ['msg'=>$sku . '-库存中不存在此SKU'] ;
  4979. $j++;
  4980. continue;
  4981. }
  4982. if (!isset($warehouse['id'])) {
  4983. $ed[] = ['msg'=>$sku . '-仓库名错误!'] ;
  4984. $j++;
  4985. continue;
  4986. }
  4987. if ($type != '0' && $type != '1') {
  4988. $ed[] = ['msg'=>$sku . '-扣减方式填写错误!'] ;
  4989. $j++;
  4990. continue;
  4991. }
  4992. if ($num < 0) //扣减库存
  4993. {
  4994. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4995. $ed[] = ['msg'=>$sku . '-扣减必须填写扣减类型,非类型1必须填写备注.'] ;
  4996. $j++;
  4997. continue;
  4998. }
  4999. if(!empty($details)){
  5000. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0 and details = "'. $details .'"');
  5001. }else{
  5002. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0');
  5003. }
  5004. if (count($data) < abs($num)) {
  5005. $ed[] = ['msg'=>$sku . '-扣减数量大于库存剩余数量!'] ;
  5006. $j++;
  5007. continue;
  5008. }
  5009. if ($type == 0) //如果扣减方式为 扣减库存
  5010. {
  5011. for ($i = 0; $i < abs($num); $i++) {
  5012. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  5013. }
  5014. } else if ($type == 1) {
  5015. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  5016. if (count($zt) > 0) {
  5017. $ed[] = array('msg'=>$sku . '-有在途库存无法删除!');
  5018. $j++;
  5019. continue;
  5020. }
  5021. for ($i = 0; $i < abs($num); $i++) {
  5022. $this->whlabel->remove($data[$i]['id']);
  5023. }
  5024. }
  5025. } else if ($num > 0) //增加库存
  5026. {
  5027. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  5028. $ed[] = array('msg'=>$sku . '-增加必须填写增加类型,非类型1必须填写备注');
  5029. $j++;
  5030. continue;
  5031. }
  5032. if(empty($details)){
  5033. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (details != "" or details is not null) ','*','id desc');
  5034. if(empty($tmp_info)){
  5035. $details = '';
  5036. }else{
  5037. $details = $tmp_info['details'];
  5038. }
  5039. }else{
  5040. if($details == 'DZ001'){
  5041. }else{
  5042. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and details = "'.$details.'" ','*','id desc');
  5043. if(empty($tmp_info)){
  5044. $ed[] = array('msg'=>$sku . '-的库位' . $details . '不存在!');
  5045. $j++;
  5046. continue;
  5047. }
  5048. }
  5049. }
  5050. $post['sku'] = $d['sku'];
  5051. $post['shop'] = $d['shop'];
  5052. $post['warehouse'] = $warehouse['id'];
  5053. $post['purchase'] = $purchase['id'];
  5054. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  5055. $post['state'] = 0;
  5056. $post['title'] = $d['title'];
  5057. $post['number'] = $d['number'];
  5058. $post['features'] = $d['features'];
  5059. $post['details'] = $details;
  5060. $post['enter'] = $time;
  5061. $post['time'] = $time; //操作时间
  5062. $post['rktype'] = $rktype;
  5063. $post['sku_master_id'] = $d['sku_master_id'];
  5064. $post['sku_shop_id'] = $d['sku_shop_id'];
  5065. for ($i = 0; $i < $num; $i++) {
  5066. $post['label'] = time() . rand(100, 999) . $i;
  5067. $this->whlabel->insert($post);
  5068. }
  5069. }
  5070. sleep(1); //防止入库时间一样,需要延迟1秒
  5071. }
  5072. if ($j > 0) {
  5073. $tt = date('Ymd', time());
  5074. $title = '库存导入错误信息-' . $tt;
  5075. $error = $title . '.xls';
  5076. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  5077. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'ed' => $ed, 'success' => true));
  5078. exit;
  5079. } else {
  5080. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  5081. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  5082. exit;
  5083. }
  5084. }
  5085. //笛卡儿积
  5086. function cp($ps, $sets, $list)
  5087. {
  5088. $result = array();
  5089. $j = 0;
  5090. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  5091. if ($i == 0) {
  5092. $result = $sets[$i];
  5093. }
  5094. $tmp = array();
  5095. foreach ($result as $res) {
  5096. foreach ($sets[$i + 1] as $set) {
  5097. $tmp[] = $res . ',' . $set;
  5098. }
  5099. }
  5100. $result = $tmp;
  5101. }
  5102. $this->db->trans_begin();
  5103. foreach ($result as $v) {
  5104. $post = array();
  5105. $title = "";
  5106. $num = "";
  5107. $data = explode(',', $v);
  5108. for ($i = 0; $i < count($list); $i++) {
  5109. $post[$list[$i]] = $data[$i];
  5110. $typeclass = $this->typeclass->read($data[$i]);
  5111. $title = $title . $typeclass['title'] . " ";
  5112. if ($data[$i] != 0) {
  5113. $num .= $data[$i]; //所有数据ID拼接
  5114. }
  5115. }
  5116. foreach ($ps as $kp => $vp) {
  5117. $post[$kp] = $vp;
  5118. }
  5119. $post['number'] = $num;
  5120. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  5121. if ($info_list) {
  5122. $j++;
  5123. } else {
  5124. $skunum = $this->whlabel->find_count();
  5125. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  5126. $post['title'] = rtrim($title, ' ');
  5127. $this->whlabel->insert($post);
  5128. }
  5129. }
  5130. if ($this->db->trans_status() === FALSE) {
  5131. $this->db->trans_commit();
  5132. return NULL;
  5133. } else {
  5134. $this->db->trans_commit();
  5135. return $j;
  5136. }
  5137. }
  5138. public function _kj($arg_array)
  5139. {
  5140. if (isset($_POST['sku'])) {
  5141. $time = time();
  5142. $sku = $this->input->post('sku', true);
  5143. $warehouse = $this->input->post('warehouse', true);
  5144. $num = $this->input->post('num', true);
  5145. $text = $this->input->post('text', true);
  5146. $purchase = $this->input->post('purchase', true);
  5147. $cktype = $this->input->post('cktype', true);
  5148. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  5149. if ($cktype != 1 && $text == '') {
  5150. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  5151. exit;
  5152. }
  5153. if ($num > count($order)) {
  5154. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  5155. exit;
  5156. } else {
  5157. for ($i = 0; $i < $num; $i++) {
  5158. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  5159. }
  5160. }
  5161. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  5162. exit;
  5163. }
  5164. $uid = $this->whlabel->read($arg_array[0]);
  5165. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  5166. $this->data['data'] = $uid;
  5167. $this->_Template('whlabel_kj', $this->data);
  5168. }
  5169. public function _summary($arg_array)
  5170. {
  5171. $prc = array();
  5172. $purchase = $this->purchase->find_all();
  5173. foreach ($purchase as $k => $v) {
  5174. $prc[$v['id']] = $v['title'];
  5175. }
  5176. if (isset($_GET['excel'])) {
  5177. $ktime = $this->input->get('ktime', true);
  5178. $jtime = $this->input->get('jtime', true);
  5179. $ktime = strtotime($ktime);
  5180. $jtime = strtotime($jtime);
  5181. $where = "1=1";
  5182. if ($ktime && $jtime) {
  5183. $where .= " and outk > '$ktime' and outk < '$jtime'";
  5184. }
  5185. //数据排序
  5186. $order_str = "time desc";
  5187. if (empty($page)) {
  5188. $start = 0;
  5189. $perpage = 1;
  5190. } else {
  5191. $start = ($page - 1) * $perpage;
  5192. }
  5193. //取得信息列表
  5194. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  5195. foreach ($info_list as $key => $value) {
  5196. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5197. $warehouse = $this->warehouse->read($value['warehouse']);
  5198. $info_list[$key]['warehouse'] = $warehouse['title'];
  5199. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid,status');
  5200. $details = array();
  5201. $cpid = array();
  5202. foreach ($x as $k => $v) {
  5203. if($v['status'] == 0){
  5204. if ($v['details'] != '') {
  5205. $details[$v['details']] = $v['details'];
  5206. }
  5207. if ($v['cpid'] != 0) {
  5208. $cpid[$v['cpid']] = $v['cpid'];
  5209. }
  5210. }
  5211. }
  5212. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  5213. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  5214. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  5215. $info_list[$key]['s'] = $s;
  5216. $info_list[$key]['x'] = count($x);
  5217. }
  5218. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  5219. $titlename = "<table border=1>
  5220. <tr align='center'>
  5221. <td>仓库</td>
  5222. <td>供应商</td>
  5223. <td>出库位置</td>
  5224. <td>出库编码</td>
  5225. <td>SKU</td>
  5226. <td>产品名</td>
  5227. <td>总剩余库存</td>
  5228. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  5229. </tr>
  5230. </table>";
  5231. $filename = $title . ".xls";
  5232. $tail = "";
  5233. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  5234. }
  5235. }
  5236. //usps发货清单
  5237. public function _manifest()
  5238. {
  5239. if (isset($_POST['manifest'])) {
  5240. $wltext = $this->input->post('wltext', true);
  5241. $time = time() - 16 * 3600;
  5242. $ptime = strtotime(date('Y-m-d', $time));
  5243. $waybill = array();
  5244. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5245. foreach ($fullorder as $v) {
  5246. $waybill[$v['waybill']] = $v['waybill'];
  5247. }
  5248. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5249. foreach ($fullordersmt as $v) {
  5250. $waybill[$v['waybill']] = $v['waybill'];
  5251. }
  5252. $wltext = explode(';', $wltext);
  5253. foreach ($wltext as $v) {
  5254. if (isset($waybill[$v])) {
  5255. unset($waybill[$v]);
  5256. }
  5257. }
  5258. $data = $this->usps->get_manifest($waybill);
  5259. if (isset($data['Description'])) {
  5260. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  5261. exit;
  5262. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  5263. $bctime = date('Ymd', time());
  5264. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  5265. echo json_encode(array('msg' => $pdf, 'success' => true));
  5266. exit;
  5267. } else {
  5268. echo json_encode(array('msg' => $data, 'success' => false));
  5269. exit;
  5270. }
  5271. }
  5272. }
  5273. public function _pdf($pdf, $title, $bctime)
  5274. {
  5275. $pdf_path = './data/pdf/' . $bctime . '/';
  5276. $file_base64 = $pdf;
  5277. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5278. $file_base64 = base64_decode($file_base64);
  5279. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  5280. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  5281. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  5282. }
  5283. /**
  5284. *
  5285. *
  5286. *
  5287. 进销存占单异常索引
  5288. *
  5289. *
  5290. *
  5291. **/
  5292. public function _abnormal()
  5293. {
  5294. $post = $this->input->post(NULL, TRUE);
  5295. if (isset($post['page'])) {
  5296. $page = $this->input->post('page', true);
  5297. $perpage = $this->input->post('perpage', true);
  5298. $sku = $this->input->post('sku', true);
  5299. $where = "1=1";
  5300. //数据排序
  5301. $order_str = "id desc";
  5302. if (empty($page)) {
  5303. $start = 0;
  5304. $perpage = 1;
  5305. } else {
  5306. $start = ($page - 1) * $perpage;
  5307. }
  5308. //取得信息列表
  5309. $info_list = $this->whlabel->find_all($where, '*');
  5310. $rows = array();
  5311. $list = array();
  5312. foreach ($info_list as $key => $value) {
  5313. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  5314. }
  5315. foreach ($rows as $value) {
  5316. $warehouse = $this->warehouse->read($value['warehouse']);
  5317. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  5318. $number = $value['number'];
  5319. $ftime = time() - 15 * 24 * 3600;
  5320. if ($value['shop'] != '') {
  5321. $shop = $value['shop'];
  5322. $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');
  5323. $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');
  5324. $order = array_merge($orderdlz, $ordersmt);
  5325. $od = 0;
  5326. $a = '';
  5327. $orid = '';
  5328. foreach ($order as $v) {
  5329. $or = explode('|', ltrim($v['whlabel'], '|'));
  5330. for ($i = 0; $i < count($or); $i++) {
  5331. $orod = explode('-', $or[$i]);
  5332. if ($orod[0] == $number) {
  5333. $od += $orod[1];
  5334. }
  5335. }
  5336. $orid .= $v['number'] . '-';
  5337. }
  5338. } else {
  5339. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5340. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5341. $order = array_merge($orderdlz, $ordersmt);
  5342. $od = 0;
  5343. $a = '';
  5344. $orid = '';
  5345. $qt = array();
  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. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  5352. if ($czzs > 0) {
  5353. if (isset($qt[$v['shop']])) {
  5354. if ($qt[$v['shop']] < $orod[1]) {
  5355. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  5356. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5357. } else {
  5358. $qt[$v['shop']] -= $orod[1];
  5359. }
  5360. } else {
  5361. $qt[$v['shop']] = $czzs;
  5362. }
  5363. } else {
  5364. $od += $orod[1];
  5365. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5366. }
  5367. }
  5368. }
  5369. }
  5370. }
  5371. $z = $od . '(' . $orid . ')'; //查看订单号
  5372. //$z = $od;
  5373. if ($od > $c) {
  5374. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  5375. }
  5376. }
  5377. $listdata = array_slice($list, $start, $perpage);
  5378. $total = count($list);
  5379. $pagenum = ceil($total / $perpage);
  5380. $over = $total - ($start + $perpage);
  5381. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5382. echo json_encode($rows);
  5383. exit;
  5384. }
  5385. $this->_Template('whlabel_abnormal', $this->data);
  5386. }
  5387. /**
  5388. *
  5389. *
  5390. *
  5391. 进销存占单异常索引
  5392. *
  5393. *
  5394. *
  5395. **/
  5396. public function _error()
  5397. {
  5398. $post = $this->input->post(NULL, TRUE);
  5399. if (isset($post['page'])) {
  5400. $page = $this->input->post('page', true);
  5401. $perpage = $this->input->post('perpage', true);
  5402. $sku = $this->input->post('sku', true);
  5403. $warehouse = $this->input->post('warehouse', true);
  5404. $ktime = $this->input->post('ktime', true);
  5405. $jtime = $this->input->post('jtime', true);
  5406. $ktime = strtotime($ktime);
  5407. $jtime = strtotime($jtime);
  5408. $where = "sku != 'Preset'";
  5409. $gj = '';
  5410. if ($sku) {
  5411. $where .= " and sku like '%$sku%'";
  5412. } else {
  5413. if ($ktime && $jtime) {
  5414. $gj = " and time > '$ktime' and time < '$jtime'";
  5415. }
  5416. }
  5417. if ($warehouse) {
  5418. $where .= " and warehouse = '$warehouse'";
  5419. }
  5420. //数据排序
  5421. $order_str = "id desc";
  5422. if (empty($page)) {
  5423. $start = 0;
  5424. $perpage = 1;
  5425. } else {
  5426. $start = ($page - 1) * $perpage;
  5427. }
  5428. //取得信息列表
  5429. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5430. $rows = array();
  5431. $list = array();
  5432. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5433. // foreach ($info_list as $value)
  5434. // {
  5435. // $warehouse = $this->warehouse->read($value['warehouse']);
  5436. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5437. // $number = $value['number'];$ftime = time()-15*24*3600;
  5438. // if($c < 1)
  5439. // {
  5440. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5441. // }
  5442. // }
  5443. $warehouse_list = $this->warehouse->find_all();
  5444. $warehouse_list = array_column($warehouse_list, null, 'id');
  5445. foreach ($info_list as $value) {
  5446. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5447. 'title' => "",
  5448. ];
  5449. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5450. $number = $value['number'];
  5451. $ftime = time() - 15 * 24 * 3600;
  5452. if ($c < 1) {
  5453. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5454. }
  5455. }
  5456. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5457. // $query = $this->db->query($sql);
  5458. // $info_list = $query->result_array();
  5459. // $sql_two = "select title,id from crowd_warehouse";
  5460. // $query_two = $this->db->query($sql_two);
  5461. // $warehouse_list = $query_two->result_array();
  5462. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5463. // foreach ($info_list as $value)
  5464. // {
  5465. // if(isset($warehouse_arr[$value['warehouse']])){
  5466. // $warehouse = $warehouse_arr[$value['warehouse']];
  5467. // }else{
  5468. // $warehouse = [
  5469. // 'id'=>0,
  5470. // 'title'=>"异常",
  5471. // ];
  5472. // }
  5473. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5474. // $number = $value['number'];$ftime = time()-15*24*3600;
  5475. // if($c < 1)
  5476. // {
  5477. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5478. // }
  5479. // }
  5480. $listdata = array_slice($list, $start, $perpage);
  5481. $total = count($list);
  5482. $pagenum = ceil($total / $perpage);
  5483. $over = $total - ($start + $perpage);
  5484. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5485. echo json_encode($rows);
  5486. exit;
  5487. }
  5488. if (isset($post['s'])) {
  5489. $id_arr = $this->input->post('s');
  5490. $id_arr = explode(',', trim($id_arr, ','));
  5491. if (!$id_arr) {
  5492. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5493. exit;
  5494. }
  5495. //循环删除记录
  5496. foreach ($id_arr as $v) {
  5497. $dd = $this->whlabel->read($v);
  5498. if (!isset($dd['id'])) {
  5499. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5500. exit;
  5501. }
  5502. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5503. if (isset($zt[0])) {
  5504. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5505. exit;
  5506. }
  5507. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5508. foreach ($deldd as $vv) {
  5509. $tmp_info = $vv;
  5510. $tmp_info['del_time'] = time();
  5511. $this->db->insert('whlabelscbf',$tmp_info);
  5512. $this->whlabel->remove($vv['id']);
  5513. }
  5514. }
  5515. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5516. exit;
  5517. }
  5518. $this->_Template('whlabel_error', $this->data);
  5519. }
  5520. public function _errorexcel()
  5521. {
  5522. $post = $this->input->post(NULL, TRUE);
  5523. if (isset($_GET['page'])) {
  5524. $page = $this->input->get('page', true);
  5525. $perpage = $this->input->get('perpage', true);
  5526. $sku = $this->input->get('sku', true);
  5527. $warehouse = $this->input->get('warehouse', true);
  5528. $ktime = $this->input->get('ktime', true);
  5529. $jtime = $this->input->get('jtime', true);
  5530. $ktime = strtotime($ktime);
  5531. $jtime = strtotime($jtime);
  5532. $where = "sku != 'Preset'";
  5533. $gj = '';
  5534. if ($sku) {
  5535. $where .= " and sku like '%$sku%'";
  5536. } else {
  5537. if ($ktime && $jtime) {
  5538. $gj = " and time > '$ktime' and time < '$jtime'";
  5539. }
  5540. }
  5541. if ($warehouse) {
  5542. $where .= " and warehouse = '$warehouse'";
  5543. }
  5544. //数据排序
  5545. $order_str = "id desc";
  5546. if (empty($page)) {
  5547. $start = 0;
  5548. $perpage = 1;
  5549. } else {
  5550. $start = ($page - 1) * $perpage;
  5551. }
  5552. //取得信息列表
  5553. $rows = array();
  5554. $list = array();
  5555. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5556. foreach ($info_list as $value) {
  5557. $warehouse = $this->warehouse->read($value['warehouse']);
  5558. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5559. $number = $value['number'];
  5560. $ftime = time() - 15 * 24 * 3600;
  5561. if ($c < 1) {
  5562. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5563. }
  5564. }
  5565. $title = "0库存汇总";
  5566. $titlename = "<table border=1>
  5567. <tr align='center'>
  5568. <td>仓库</td>
  5569. <td>SKU</td>
  5570. <td>产品</td>
  5571. <td>当前库存</td>
  5572. </tr>
  5573. </table>";
  5574. $filename = $title . ".xls";
  5575. $tail = "";
  5576. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5577. }
  5578. }
  5579. /**
  5580. *
  5581. *
  5582. * 占单
  5583. *
  5584. *
  5585. **/
  5586. public function _kcyz()
  5587. {
  5588. $post = $this->input->post(NULL, TRUE);
  5589. if (isset($post['warehouse'])) {
  5590. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5591. exit; //不再使用
  5592. $warehouse = $this->input->post('warehouse', true);
  5593. $whlabel = $this->input->post('whlabel', true);
  5594. $id = $this->input->post('id', true);
  5595. $shop = $this->input->post('shop', true);
  5596. $number = $this->input->post('number', true);
  5597. if (!$whlabel || $whlabel == '|') {
  5598. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5599. exit;
  5600. }
  5601. $pp = explode('|', trim($whlabel, '|'));
  5602. $x = 0;
  5603. $save = array();
  5604. foreach ($pp as $va) {
  5605. $num = explode('-', $va);
  5606. if ($number) {
  5607. $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 = '')"); //通用
  5608. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5609. } else {
  5610. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5611. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5612. }
  5613. $x++;
  5614. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5615. $save[] = $x - 1;
  5616. continue; //提前先加X不然出错,所以要减1
  5617. }
  5618. }
  5619. if (isset($save[0])) {
  5620. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5621. exit;
  5622. } else {
  5623. echo json_encode(array('success' => true));
  5624. exit;
  5625. }
  5626. }
  5627. }
  5628. public function _db()
  5629. {
  5630. $post = $this->input->post(NULL, TRUE);
  5631. if (isset($post['page'])) {
  5632. $page = $this->input->post('page', true);
  5633. $perpage = $this->input->post('perpage', true);
  5634. $sku = $this->input->post('sku', true);
  5635. $number = $this->input->post('number', true);
  5636. $warehouse = $this->input->post('warehouse', true);
  5637. $purchase = $this->input->post('purchase', true);
  5638. $orderinfo = $this->input->post('orderinfo', true);
  5639. $waybill = $this->input->post('waybill', true);
  5640. $category = $this->input->post('category', true);
  5641. $size = $this->input->post('size', true);
  5642. $grade = $this->input->post('grade', true);
  5643. $color = $this->input->post('color', true);
  5644. $lowe = $this->input->post('lowe', true);
  5645. $state = $this->input->post('state', true);
  5646. $label = $this->input->post('label', true);
  5647. $timetk = $this->input->post('timetkk', true);
  5648. $timetj = $this->input->post('timetjj', true);
  5649. $timetk = strtotime($timetk);
  5650. $timetj = strtotime($timetj);
  5651. $where = "dbtime > 0";
  5652. if ($timetk && $timetj) {
  5653. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5654. }
  5655. if ($sku) {
  5656. $where .= " and sku = '$sku'";
  5657. }
  5658. if ($warehouse) {
  5659. $where .= " and warehouse = '$warehouse'";
  5660. if ($warehouse == 12) {
  5661. $w = 'specialstock';
  5662. } else {
  5663. $w = 'whlabel';
  5664. }
  5665. }
  5666. if ($purchase) {
  5667. $where .= " and purchase = '$purchase'";
  5668. }
  5669. if ($category) {
  5670. $where .= " and features like '%-$category-%'";
  5671. }
  5672. if ($size) {
  5673. $where .= " and features like '%-$size-%'";
  5674. }
  5675. if ($grade) {
  5676. $where .= " and features like '%-$grade-%'";
  5677. }
  5678. if ($color) {
  5679. $where .= " and features like '%-$color-%'";
  5680. }
  5681. if ($lowe) {
  5682. $where .= " and features like '%-$lowe-%'";
  5683. }
  5684. if ($state != '') {
  5685. $where .= " and state = '$state'";
  5686. }
  5687. //数据排序
  5688. $order_str = "dbtime desc";
  5689. if (empty($page)) {
  5690. $start = 0;
  5691. $perpage = 1;
  5692. } else {
  5693. $start = ($page - 1) * $perpage;
  5694. }
  5695. //取得信息列表
  5696. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5697. foreach ($info_list as $key => $value) {
  5698. $warehouse = $this->$w->read($value['warehouse']);
  5699. $info_list[$key]['warehouse'] = $warehouse['title'];
  5700. $purchase = $this->purchase->read($value['purchase']);
  5701. $info_list[$key]['purchase'] = $purchase['title'];
  5702. if ($value['enter'] != 0) {
  5703. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5704. } else {
  5705. $info_list[$key]['enter'] = "";
  5706. }
  5707. if ($value['dbtime'] != 0) {
  5708. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5709. } else {
  5710. $info_list[$key]['dbtime'] = "";
  5711. }
  5712. if ($value['state'] == 0) {
  5713. $info_list[$key]['state'] = "在库";
  5714. } else if ($value['state'] == 1) {
  5715. $info_list[$key]['state'] = "出库";
  5716. } else if ($value['state'] == 2) {
  5717. $info_list[$key]['state'] = "退库";
  5718. } else if ($value['state'] == 3) {
  5719. $info_list[$key]['state'] = "调拨中";
  5720. } else if ($value['state'] == 4) {
  5721. $info_list[$key]['state'] = "再加工";
  5722. } else if ($value['state'] == 5) {
  5723. $info_list[$key]['state'] = "维修中";
  5724. } else if ($value['state'] == 6) {
  5725. $info_list[$key]['state'] = "盘亏";
  5726. } else if ($value['state'] == 7) {
  5727. $info_list[$key]['state'] = "更换标签";
  5728. } else if ($value['state'] == 8) {
  5729. $info_list[$key]['state'] = "其它";
  5730. } else if ($value['state'] == 9) {
  5731. $info_list[$key]['state'] = "预设";
  5732. }
  5733. }
  5734. $total = $this->whlabel->find_count($where);
  5735. $pagenum = ceil($total / $perpage);
  5736. $over = $total - ($start + $perpage);
  5737. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5738. echo json_encode($rows);
  5739. exit;
  5740. }
  5741. if (isset($post['outsku'])) {
  5742. $time = time();
  5743. $cz = $this->input->post('cz', true);
  5744. $label = $this->input->post('outsku', true);
  5745. $sl = $this->input->post('sl', true);
  5746. $num = $this->input->post('num', true);
  5747. //$warehouse = $this->input->post('warehouse',true);
  5748. if (!$sl) {
  5749. $sl = 1;
  5750. }
  5751. if (!$warehouse) {
  5752. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5753. exit;
  5754. }
  5755. $dblabel = $this->whlabellabel->get_label($label);
  5756. if ($dblabel) {
  5757. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5758. if (count($data) < 1) {
  5759. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5760. exit;
  5761. }
  5762. if (count($data) < $num) {
  5763. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5764. exit;
  5765. }
  5766. for ($i = 0; $i < $sl; $i++) {
  5767. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5768. }
  5769. echo json_encode(array('success' => true));
  5770. exit;
  5771. } else {
  5772. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5773. exit;
  5774. }
  5775. }
  5776. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5777. $this->_Template('whlabel_db', $this->data);
  5778. }
  5779. public function _dbrk()
  5780. {
  5781. $post = $this->input->post(NULL, TRUE);
  5782. if (isset($post['page'])) {
  5783. $page = $this->input->post('page', true);
  5784. $perpage = $this->input->post('perpage', true);
  5785. $sku = $this->input->post('sku', true);
  5786. $number = $this->input->post('number', true);
  5787. $warehouse = $this->input->post('warehouse', true);
  5788. $purchase = $this->input->post('purchase', true);
  5789. $orderinfo = $this->input->post('orderinfo', true);
  5790. $waybill = $this->input->post('waybill', true);
  5791. $category = $this->input->post('category', true);
  5792. $size = $this->input->post('size', true);
  5793. $grade = $this->input->post('grade', true);
  5794. $color = $this->input->post('color', true);
  5795. $lowe = $this->input->post('lowe', true);
  5796. $state = $this->input->post('state', true);
  5797. $label = $this->input->post('label', true);
  5798. $ctime = $this->input->post('ctime', true);
  5799. $timetk = $this->input->post('timetkk', true);
  5800. $timetj = $this->input->post('timetjj', true);
  5801. $timetk = strtotime($timetk);
  5802. $timetj = strtotime($timetj);
  5803. $where = "dbtime > 0";
  5804. if ($timetk && $timetj) {
  5805. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5806. }
  5807. if ($sku) {
  5808. $where .= " and sku = '$sku'";
  5809. }
  5810. if ($warehouse) {
  5811. $where .= " and warehouse = '$warehouse'";
  5812. }
  5813. if ($purchase) {
  5814. $where .= " and purchase = '$purchase'";
  5815. }
  5816. if ($category) {
  5817. $where .= " and features like '%-$category-%'";
  5818. }
  5819. if ($size) {
  5820. $where .= " and features like '%-$size-%'";
  5821. }
  5822. if ($grade) {
  5823. $where .= " and features like '%-$grade-%'";
  5824. }
  5825. if ($color) {
  5826. $where .= " and features like '%-$color-%'";
  5827. }
  5828. if ($lowe) {
  5829. $where .= " and features like '%-$lowe-%'";
  5830. }
  5831. if ($state != '') {
  5832. $where .= " and state = '$state'";
  5833. }
  5834. //数据排序
  5835. $order_str = "dbtime desc";
  5836. if (empty($page)) {
  5837. $start = 0;
  5838. $perpage = 1;
  5839. } else {
  5840. $start = ($page - 1) * $perpage;
  5841. }
  5842. //取得信息列表
  5843. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5844. foreach ($info_list as $key => $value) {
  5845. $warehouse = $this->warehouse->read($value['warehouse']);
  5846. $info_list[$key]['warehouse'] = $warehouse['title'];
  5847. $purchase = $this->purchase->read($value['purchase']);
  5848. $info_list[$key]['purchase'] = $purchase['title'];
  5849. if ($value['enter'] != 0) {
  5850. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5851. } else {
  5852. $info_list[$key]['enter'] = "";
  5853. }
  5854. if ($value['dbtime'] != 0) {
  5855. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5856. } else {
  5857. $info_list[$key]['dbtime'] = "";
  5858. }
  5859. if ($value['state'] == 0) {
  5860. $info_list[$key]['state'] = "在库";
  5861. } else if ($value['state'] == 1) {
  5862. $info_list[$key]['state'] = "出库";
  5863. } else if ($value['state'] == 2) {
  5864. $info_list[$key]['state'] = "退库";
  5865. } else if ($value['state'] == 3) {
  5866. $info_list[$key]['state'] = "调拨中";
  5867. } else if ($value['state'] == 4) {
  5868. $info_list[$key]['state'] = "再加工";
  5869. } else if ($value['state'] == 5) {
  5870. $info_list[$key]['state'] = "维修中";
  5871. } else if ($value['state'] == 6) {
  5872. $info_list[$key]['state'] = "盘亏";
  5873. } else if ($value['state'] == 7) {
  5874. $info_list[$key]['state'] = "更换标签";
  5875. } else if ($value['state'] == 8) {
  5876. $info_list[$key]['state'] = "其它";
  5877. } else if ($value['state'] == 9) {
  5878. $info_list[$key]['state'] = "预设";
  5879. }
  5880. }
  5881. $total = $this->whlabel->find_count($where);
  5882. $pagenum = ceil($total / $perpage);
  5883. $over = $total - ($start + $perpage);
  5884. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5885. echo json_encode($rows);
  5886. exit;
  5887. }
  5888. if (isset($post['rsku'])) {
  5889. $cz = $this->input->post('cz', true);
  5890. $label = $this->input->post('rsku', true);
  5891. $sl = $this->input->post('sl', true);
  5892. $warehouse = $this->input->post('warehouse', true);
  5893. if (!$sl) {
  5894. $sl = 1;
  5895. }
  5896. if (!$warehouse) {
  5897. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5898. exit;
  5899. }
  5900. $dblabel = $this->whlabellabel->get_label($label);
  5901. if ($dblabel) {
  5902. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5903. if (count($data) < 1) {
  5904. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5905. exit;
  5906. }
  5907. if ($sl > count($data)) {
  5908. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5909. exit;
  5910. }
  5911. $time = time();
  5912. for ($i = 0; $i < $sl; $i++) {
  5913. $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']);
  5914. }
  5915. echo json_encode(array('success' => true));
  5916. exit;
  5917. } else {
  5918. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5919. exit;
  5920. }
  5921. }
  5922. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5923. $this->_Template('whlabel_dbrk', $this->data);
  5924. }
  5925. public function _whlabelczdc()
  5926. {
  5927. if (isset($_GET['excel'])) {
  5928. //数据排序
  5929. $order_str = "id desc";
  5930. if (empty($page)) {
  5931. $start = 0;
  5932. $perpage = 1;
  5933. } else {
  5934. $start = ($page - 1) * $perpage;
  5935. }
  5936. $state = $this->input->get('state', true);
  5937. $sku = $this->input->get('sku', true);
  5938. $ctime = $this->input->get('ctime', true);
  5939. $category = $this->input->get('category', true);
  5940. $size = $this->input->get('size', true);
  5941. $grade = $this->input->get('grade', true);
  5942. $color = $this->input->get('color', true);
  5943. $lowe = $this->input->get('lowe', true);
  5944. $timetk = $this->input->get('timetkk', true);
  5945. $timetj = $this->input->get('timetjj', true);
  5946. $timetk = strtotime($timetk);
  5947. $timetj = strtotime($timetj);
  5948. $where = "dbtime > 0";
  5949. if ($timetk && $timetj) {
  5950. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5951. }
  5952. if ($category) {
  5953. $where .= " and features like '%-$category-%'";
  5954. }
  5955. if ($size) {
  5956. $where .= " and features like '%-$size-%'";
  5957. }
  5958. if ($grade) {
  5959. $where .= " and features like '%-$grade-%'";
  5960. }
  5961. if ($color) {
  5962. $where .= " and features like '%-$color-%'";
  5963. }
  5964. if ($lowe) {
  5965. $where .= " and features like '%-$lowe-%'";
  5966. }
  5967. //取得信息列表
  5968. $info_list = $this->whlabel->find_all($where, '*');
  5969. $rows = array();
  5970. $list = array();
  5971. foreach ($info_list as $key => $value) {
  5972. $rows[$value['sku']] = $value; //所有数据sku
  5973. }
  5974. foreach ($rows as $value) {
  5975. $warehouse = $this->warehouse->read($value['warehouse']);
  5976. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5977. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5978. if ($value['orderinfo'] == 0) {
  5979. $info_list[$key]['orderinfo'] = "";
  5980. }
  5981. if ($value['waybill'] == 0) {
  5982. $info_list[$key]['waybill'] = "";
  5983. }
  5984. if ($value['state'] == 0) {
  5985. $value['state'] = "在库";
  5986. } else if ($value['state'] == 3) {
  5987. $value['state'] = "调拨中";
  5988. }
  5989. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5990. }
  5991. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5992. $titlename = "<table border=1>
  5993. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5994. <tr align='center'>
  5995. <td>SKU</td>
  5996. <td>产品</td>
  5997. <td>调拨数量</td>
  5998. <td>入库数量</td>
  5999. </tr>
  6000. </table>";
  6001. $filename = $title . ".xls";
  6002. $tail = "";
  6003. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  6004. }
  6005. }
  6006. public function _print($arg_array)
  6007. {
  6008. if (isset($_SESSION['api'])) {
  6009. $user = $this->user->get_api($_SESSION['api']);
  6010. $usp = $user;
  6011. $fgshop = "";
  6012. $sid = "";
  6013. $wid = "";
  6014. $wtype = "";
  6015. $usersp = explode('|', trim($user['shop'], '|'));
  6016. $userwh = explode('|', trim($user['warehouse'], '|'));
  6017. foreach ($usersp as $value) {
  6018. $fgshop .= " shop = " . $value . " or";
  6019. $sid .= " id = " . $value . " or";
  6020. }
  6021. foreach ($userwh as $value) {
  6022. $wid .= " id = " . $value . " or";
  6023. $wtype .= " type = " . $value . " or";
  6024. }
  6025. }
  6026. $post = $this->input->post(NULL, TRUE);
  6027. if (isset($post['tmsku'])) {
  6028. $tmsku = $this->input->post('tmsku', true);
  6029. if (is_numeric($tmsku)) {
  6030. $yyh = $this->whlabellabel->get_label($tmsku);
  6031. } else {
  6032. $yyh = $this->whlabellabel->get_sku($tmsku);
  6033. if(empty($yyh)){
  6034. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  6035. if($r['code'] == -1 ){
  6036. echo json_encode(array('success' => false));
  6037. exit;
  6038. }else{
  6039. echo json_encode(array('features' => $r['data'], 'success' => true));
  6040. exit;
  6041. }
  6042. }
  6043. }
  6044. if ($yyh) {
  6045. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6046. exit;
  6047. } else {
  6048. echo json_encode(array('success' => false));
  6049. exit;
  6050. }
  6051. }
  6052. $classid = $this->classid->sku();
  6053. $pm = $classid;
  6054. $scsku = $classid;
  6055. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6056. if (isset($post['warehouse'])) {
  6057. if ($post['warehouse']) {
  6058. $list = array();
  6059. $num = "";
  6060. $title = "";
  6061. $features = "";
  6062. $order = 0;
  6063. $post['shop'] = '';
  6064. $brand = $this->input->post('brand', true);
  6065. if ($brand != '0,') {
  6066. $b = $this->brand->read(rtrim($brand, ','));
  6067. if ($b) {
  6068. $post['shop'] = str_replace('|', ',', $b['shop']);
  6069. }
  6070. }
  6071. $post['details'] = $this->input->post('details', true); //打印数量
  6072. $xbqnum = $this->input->post('xbqnum', true);
  6073. $post['purchase'] = $this->input->post('purchase', true);
  6074. $post['warehouse'] = $this->input->post('warehouse', true);
  6075. $post['purchase'] = $this->input->post('purchase', true);
  6076. $post['retreatwarehouse'] = $post['warehouse'];
  6077. $post['cpbz'] = $this->input->post('cpbz', true);
  6078. $post['state'] = 9;
  6079. $category = $this->input->post('category', true);
  6080. $list['category'] = $category;
  6081. $list['hairtype'] = $this->input->post('hairtype', true);
  6082. $list['grade'] = $this->input->post('grade', true);
  6083. $size = $this->input->post('size', true);
  6084. $list['size'] = rtrim($size, ',');
  6085. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6086. $list['extension'] = $this->input->post('extension', true);
  6087. if ($category == 1297) {
  6088. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6089. }
  6090. if ($category == 1702) {
  6091. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6092. $list['syother'] = $this->input->post('syother', true);
  6093. }
  6094. if ($category == 133) {
  6095. $list['fittype'] = $this->input->post('fittype', true);
  6096. $list['acother'] = $this->input->post('acother', true);
  6097. }
  6098. $list['color'] = $this->input->post('color', true);
  6099. $list['lowe'] = $this->input->post('lowe', true);
  6100. if ($category == 127) {
  6101. $list['type'] = $this->input->post('type', true);
  6102. $list['headroad'] = $this->input->post('headroad', true);
  6103. $list['density'] = $this->input->post('density', true);
  6104. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6105. $list['lacesize'] = $this->input->post('lacesize', true);
  6106. }
  6107. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6108. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6109. }
  6110. if ($category == 128) {
  6111. $list['lacetype'] = $this->input->post('lacetype', true);
  6112. $list['haircap'] = $this->input->post('haircap', true);
  6113. $list['density'] = $this->input->post('density', true);
  6114. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6115. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6116. $list['wigother'] = $this->input->post('wigother', true);
  6117. $list['wigother1'] = $this->input->post('wigother1', true);
  6118. $list['wigother2'] = $this->input->post('wigother2', true);
  6119. $list['product_related'] = $this->input->post('product_related', true);
  6120. }
  6121. if ($category == 129) {
  6122. $list['wide'] = $this->input->post('wide', true);
  6123. }
  6124. if ($category == 131) {
  6125. $list['gifttype'] = $this->input->post('gifttype', true);
  6126. $list['giftother'] = $this->input->post('giftother', true);
  6127. }
  6128. if ($category == 134) {
  6129. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6130. }
  6131. if ($category == 1297) {
  6132. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6133. $list['sywigother'] = $this->input->post('sywigother', true);
  6134. }
  6135. if ($category == 130 || $category == 133 || $category == 1702) {
  6136. $list['items'] = $this->input->post('items', true);
  6137. $list['weight'] = $this->input->post('weight', true);
  6138. }
  6139. if ($category == 1702) {
  6140. $list['syhairther'] = $this->input->post('syhairther', true);
  6141. }
  6142. if($category == 130){
  6143. $list['jfother'] = $this->input->post('jfother', true);
  6144. }
  6145. foreach ($list as $k => $v) {
  6146. if ($v != 0) {
  6147. $num .= $v;
  6148. $features .= $v . '-';
  6149. $post[$k] = $v;
  6150. $typeclass = $this->typeclass->read($v);
  6151. if (isset($pm[$typeclass['classid']])) {
  6152. if (stripos($typeclass['zh'], '|') !== false) {
  6153. $exzh = explode('|', $typeclass['zh']);
  6154. $pm[$typeclass['classid']] = $exzh[0];
  6155. } else {
  6156. $pm[$typeclass['classid']] = $typeclass['zh'];
  6157. }
  6158. }
  6159. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6160. if ($k != 'size') {
  6161. $title .= $typeclass['title'] . " ";
  6162. }
  6163. }
  6164. }
  6165. $typeclass = $this->typeclass->read($list['size']);
  6166. $title .= $typeclass['title'];
  6167. $time = time();
  6168. $post['title'] = rtrim($title, ' ');
  6169. $post['number'] = $num;
  6170. $post['features'] = '-' . $features;
  6171. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6172. $featurespp = explode('-', trim($featurespp, '-'));
  6173. if (isset($featurespp[5])) {
  6174. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6175. } else {
  6176. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6177. }
  6178. $post['enter'] = $time;
  6179. $post['time'] = $time; //操作时间
  6180. $scsku = implode("-", $scsku);
  6181. $zh = implode(" ", $pm);
  6182. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6183. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6184. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6185. $post['sku'] = $bqsku;
  6186. $label = time() . rand(0, 9);
  6187. $post['label'] = $label;
  6188. $cpid = $this->whlabellabel->find_count();
  6189. $post['cpid'] = $cpid + 1;
  6190. $cpid = $post['cpid'];
  6191. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6192. //if($whlabelbarcode)
  6193. //{
  6194. //$post['label'] = $whlabelbarcode['label'];
  6195. //if(!$this->whlabellabel->insert($post))
  6196. //{
  6197. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6198. //}
  6199. //}
  6200. //else
  6201. //{
  6202. $this->db->trans_begin();
  6203. $this->whlabellabel->insert($post);
  6204. //$this->whlabelbarcode->insert($post);
  6205. if ($this->db->trans_status() === TRUE) {
  6206. $this->db->trans_commit();
  6207. } else {
  6208. $this->db->trans_rollback();
  6209. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6210. exit;
  6211. }
  6212. //}
  6213. $warehouse_name = "";
  6214. $warehouse = $post['warehouse'];
  6215. if($warehouse == 12){
  6216. $warehouse_name = "特殊库存库";
  6217. }
  6218. // if($warehouse == 13){
  6219. // $warehouse_name = "许昌仓";
  6220. // }
  6221. // if($warehouse == 5){
  6222. // $warehouse_name = "美国店";
  6223. // }
  6224. // if($warehouse == 16){
  6225. // $warehouse_name = "定制头套仓";
  6226. // }
  6227. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6228. if(!empty($warehouse_name)){
  6229. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  6230. }
  6231. $purchase = $this->purchase->read($post['purchase']);
  6232. 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));
  6233. exit; //特殊仓目前不需要仓库选项
  6234. }
  6235. }
  6236. if (isset($_SESSION['api'])) {
  6237. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6238. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6239. $this->data['wlshop'] = $wlshop;
  6240. $this->data['warehouse'] = $warehouse;
  6241. }
  6242. $whlabelwz = $this->whlabelwz->find_all();
  6243. $this->data['whlabelwz'] = $whlabelwz;
  6244. $this->_Template('whlabel_print', $this->data);
  6245. }
  6246. public function _usaprint($arg_array)
  6247. {
  6248. if (isset($_SESSION['api'])) {
  6249. $user = $this->user->get_api($_SESSION['api']);
  6250. $usp = $user;
  6251. $fgshop = "";
  6252. $sid = "";
  6253. $wid = "";
  6254. $wtype = "";
  6255. $usersp = explode('|', trim($user['shop'], '|'));
  6256. $userwh = explode('|', trim($user['warehouse'], '|'));
  6257. foreach ($usersp as $value) {
  6258. $fgshop .= " shop = " . $value . " or";
  6259. $sid .= " id = " . $value . " or";
  6260. }
  6261. foreach ($userwh as $value) {
  6262. $wid .= " id = " . $value . " or";
  6263. $wtype .= " type = " . $value . " or";
  6264. }
  6265. }
  6266. $post = $this->input->post(NULL, TRUE);
  6267. if (isset($post['tmsku'])) {
  6268. $tmsku = $this->input->post('tmsku', true);
  6269. if (is_numeric($tmsku)) {
  6270. $yyh = $this->whlabellabel->get_label($tmsku);
  6271. } else {
  6272. $yyh = $this->whlabellabel->get_sku($tmsku);
  6273. }
  6274. if ($yyh) {
  6275. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6276. exit;
  6277. } else {
  6278. echo json_encode(array('success' => false));
  6279. exit;
  6280. }
  6281. }
  6282. $classid = $this->classid->sku();
  6283. $pm = $classid;
  6284. $scsku = $classid;
  6285. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6286. if (isset($post['warehouse'])) {
  6287. if ($post['warehouse']) {
  6288. $list = array();
  6289. $num = "";
  6290. $title = "";
  6291. $features = "";
  6292. $order = 0;
  6293. $post['shop'] = '';
  6294. $brand = $this->input->post('brand', true);
  6295. if ($brand != '0,') {
  6296. $b = $this->brand->read(rtrim($brand, ','));
  6297. if ($b) {
  6298. $post['shop'] = str_replace('|', ',', $b['shop']);
  6299. }
  6300. }
  6301. $post['details'] = $this->input->post('details', true); //打印数量
  6302. $xbqnum = $this->input->post('xbqnum', true);
  6303. $post['purchase'] = $this->input->post('purchase', true);
  6304. $post['warehouse'] = $this->input->post('warehouse', true);
  6305. $post['purchase'] = $this->input->post('purchase', true);
  6306. $post['retreatwarehouse'] = $post['warehouse'];
  6307. $post['cpbz'] = $this->input->post('cpbz', true);
  6308. $post['state'] = 9;
  6309. $category = $this->input->post('category', true);
  6310. $list['category'] = $category;
  6311. $list['hairtype'] = $this->input->post('hairtype', true);
  6312. $list['grade'] = $this->input->post('grade', true);
  6313. $size = $this->input->post('size', true);
  6314. $list['size'] = rtrim($size, ',');
  6315. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6316. $list['extension'] = $this->input->post('extension', true);
  6317. if ($category == 1297) {
  6318. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6319. }
  6320. if ($category == 1702) {
  6321. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6322. $list['syother'] = $this->input->post('syother', true);
  6323. }
  6324. if ($category == 133) {
  6325. $list['fittype'] = $this->input->post('fittype', true);
  6326. $list['acother'] = $this->input->post('acother', true);
  6327. }
  6328. $list['color'] = $this->input->post('color', true);
  6329. $list['lowe'] = $this->input->post('lowe', true);
  6330. if ($category == 127) {
  6331. $list['type'] = $this->input->post('type', true);
  6332. $list['headroad'] = $this->input->post('headroad', true);
  6333. $list['density'] = $this->input->post('density', true);
  6334. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6335. $list['lacesize'] = $this->input->post('lacesize', true);
  6336. }
  6337. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6338. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6339. }
  6340. if ($category == 128) {
  6341. $list['lacetype'] = $this->input->post('lacetype', true);
  6342. $list['haircap'] = $this->input->post('haircap', true);
  6343. $list['density'] = $this->input->post('density', true);
  6344. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6345. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6346. $list['wigother'] = $this->input->post('wigother', true);
  6347. $list['wigother1'] = $this->input->post('wigother1', true);
  6348. $list['wigother2'] = $this->input->post('wigother2', true);
  6349. $list['product_related'] = $this->input->post('product_related', true);
  6350. }
  6351. if ($category == 129) {
  6352. $list['wide'] = $this->input->post('wide', true);
  6353. }
  6354. if ($category == 131) {
  6355. $list['gifttype'] = $this->input->post('gifttype', true);
  6356. $list['giftother'] = $this->input->post('giftother', true);
  6357. }
  6358. if ($category == 134) {
  6359. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6360. }
  6361. if ($category == 1297) {
  6362. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6363. $list['sywigother'] = $this->input->post('sywigother', true);
  6364. }
  6365. if ($category == 130 || $category == 133 || $category == 1702) {
  6366. $list['items'] = $this->input->post('items', true);
  6367. $list['weight'] = $this->input->post('weight', true);
  6368. }
  6369. if ($category == 1702) {
  6370. $list['syhairther'] = $this->input->post('syhairther', true);
  6371. }
  6372. foreach ($list as $k => $v) {
  6373. if ($v != 0) {
  6374. $num .= $v;
  6375. $features .= $v . '-';
  6376. $post[$k] = $v;
  6377. $typeclass = $this->typeclass->read($v);
  6378. if (isset($pm[$typeclass['classid']])) {
  6379. if (stripos($typeclass['zh'], '|') !== false) {
  6380. $exzh = explode('|', $typeclass['zh']);
  6381. $pm[$typeclass['classid']] = $exzh[0];
  6382. } else {
  6383. $pm[$typeclass['classid']] = $typeclass['zh'];
  6384. }
  6385. }
  6386. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6387. if ($k != 'size') {
  6388. $title .= $typeclass['title'] . " ";
  6389. }
  6390. }
  6391. }
  6392. $typeclass = $this->typeclass->read($list['size']);
  6393. $title .= $typeclass['title'];
  6394. $time = time();
  6395. $post['title'] = rtrim($title, ' ');
  6396. $post['number'] = $num;
  6397. $post['features'] = '-' . $features;
  6398. $fp = $this->whlabel->get_features($post['features']);
  6399. if (!$fp) {
  6400. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  6401. exit;
  6402. }
  6403. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6404. $featurespp = explode('-', trim($featurespp, '-'));
  6405. if (isset($featurespp[5])) {
  6406. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6407. } else {
  6408. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6409. }
  6410. $post['enter'] = $time;
  6411. $post['time'] = $time; //操作时间
  6412. $scsku = implode("-", $scsku);
  6413. $zh = implode(" ", $pm);
  6414. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6415. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6416. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6417. $post['sku'] = $fp['sku'];
  6418. $post['label'] = $fp['sku'];
  6419. $cpid = $this->whlabellabel->find_count();
  6420. $post['cpid'] = $cpid + 1;
  6421. $cpid = $post['cpid'];
  6422. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6423. //if($whlabelbarcode)
  6424. //{
  6425. //$post['label'] = $whlabelbarcode['label'];
  6426. //if(!$this->whlabellabel->insert($post))
  6427. //{
  6428. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6429. //}
  6430. //}
  6431. //else
  6432. //{
  6433. $this->db->trans_begin();
  6434. $this->whlabellabel->insert($post);
  6435. //$this->whlabelbarcode->insert($post);
  6436. if ($this->db->trans_status() === TRUE) {
  6437. $this->db->trans_commit();
  6438. } else {
  6439. $this->db->trans_rollback();
  6440. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6441. exit;
  6442. }
  6443. //}
  6444. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6445. $purchase = $this->purchase->read($post['purchase']);
  6446. 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));
  6447. exit; //特殊仓目前不需要仓库选项
  6448. }
  6449. }
  6450. if (isset($_SESSION['api'])) {
  6451. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6452. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6453. $this->data['wlshop'] = $wlshop;
  6454. $this->data['warehouse'] = $warehouse;
  6455. }
  6456. $whlabelwz = $this->whlabelwz->find_all();
  6457. $this->data['whlabelwz'] = $whlabelwz;
  6458. $this->_Template('whlabel_usaprint', $this->data);
  6459. }
  6460. public function _printrk($arg_array)
  6461. {
  6462. $prc = array();
  6463. $purchase = $this->purchase->find_all();
  6464. foreach ($purchase as $k => $v) {
  6465. $prc[$v['id']] = $v['title'];
  6466. }
  6467. $post = $this->input->post(NULL, TRUE);
  6468. if (isset($post['page'])) {
  6469. $page = $this->input->post('page', true);
  6470. $perpage = $this->input->post('perpage', true);
  6471. $sku = $this->input->post('sku', true);
  6472. $bs = $this->input->post('bs', true);
  6473. $number = $this->input->post('number', true);
  6474. $warehouse = $this->input->post('warehouse', true);
  6475. $purchase = $this->input->post('purchase', true);
  6476. $orderinfo = $this->input->post('orderinfo', true);
  6477. $waybill = $this->input->post('waybill', true);
  6478. $category = $this->input->post('category', true);
  6479. $size = $this->input->post('size', true);
  6480. $grade = $this->input->post('grade', true);
  6481. $color = $this->input->post('color', true);
  6482. $lowe = $this->input->post('lowe', true);
  6483. $state = $this->input->post('state', true);
  6484. $label = $this->input->post('label', true);
  6485. $timetk = $this->input->post('ktime', true);
  6486. $timetj = $this->input->post('jtime', true);
  6487. $timetk = strtotime($timetk);
  6488. $timetj = strtotime($timetj);
  6489. $where = "1=1 ";
  6490. if ($timetk && $timetj) {
  6491. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6492. }
  6493. if ($sku) {
  6494. $where .= " and sku = '$sku'";
  6495. }
  6496. if ($bs != '') {
  6497. $where .= " and bs = '$bs'";
  6498. }
  6499. if ($number) {
  6500. $where .= " and number = '$number'";
  6501. }
  6502. if ($warehouse) {
  6503. $where .= " and warehouse = '$warehouse'";
  6504. }
  6505. if ($purchase) {
  6506. $where .= " and purchase = '$purchase'";
  6507. }
  6508. if ($orderinfo) {
  6509. $where .= " and orderinfo = '$orderinfo'";
  6510. }
  6511. if ($waybill) {
  6512. $where .= " and waybill = '$waybill'";
  6513. }
  6514. if ($category) {
  6515. $where .= " and features like '%-$category-%'";
  6516. }
  6517. if ($size) {
  6518. $where .= " and features like '%-$size-%'";
  6519. }
  6520. if ($grade) {
  6521. $where .= " and features like '%-$grade-%'";
  6522. }
  6523. if ($color) {
  6524. $where .= " and features like '%-$color-%'";
  6525. }
  6526. if ($lowe) {
  6527. $where .= " and features like '%-$lowe-%'";
  6528. }
  6529. if ($label) {
  6530. $where .= " and label = '$label'";
  6531. }
  6532. if ($state || $state == 0) {
  6533. $where .= " and state = '$state'";
  6534. }
  6535. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6536. //数据排序
  6537. $order_str = "enter desc";
  6538. if (empty($page)) {
  6539. $start = 0;
  6540. $perpage = 1;
  6541. } else {
  6542. $start = ($page - 1) * $perpage;
  6543. }
  6544. //取得信息列表
  6545. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6546. foreach ($info_list as $key => $value) {
  6547. $warehouse = $this->warehouse->read($value['warehouse']);
  6548. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6549. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6550. if ($value['state'] == 0) {
  6551. $info_list[$key]['state'] = "在库";
  6552. } else if ($value['state'] == 1) {
  6553. $info_list[$key]['state'] = "出库";
  6554. } else if ($value['state'] == 2) {
  6555. $info_list[$key]['state'] = "退库";
  6556. } else if ($value['state'] == 3) {
  6557. $info_list[$key]['state'] = "调拨中";
  6558. } else if ($value['state'] == 4) {
  6559. $info_list[$key]['state'] = "再加工";
  6560. } else if ($value['state'] == 5) {
  6561. $info_list[$key]['state'] = "维修中";
  6562. } else if ($value['state'] == 6) {
  6563. $info_list[$key]['state'] = "盘亏";
  6564. } else if ($value['state'] == 7) {
  6565. $info_list[$key]['state'] = "更换标签";
  6566. } else if ($value['state'] == 8) {
  6567. $info_list[$key]['state'] = "其它";
  6568. } else if ($value['state'] == 9) {
  6569. $info_list[$key]['state'] = "预设";
  6570. } else if ($value['state'] == 10) {
  6571. $info_list[$key]['state'] = "美店零售";
  6572. }
  6573. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6574. }
  6575. $total = $this->$ck->find_count($where);
  6576. $pagenum = ceil($total / $perpage);
  6577. $over = $total - ($start + $perpage);
  6578. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6579. echo json_encode($rows);
  6580. exit;
  6581. }
  6582. if (isset($post['tmsku'])) {
  6583. $time = time();
  6584. $tmsku = $this->input->post('tmsku', true);
  6585. //$post['shop'] = $this->input->post('shop',true);
  6586. $num = $this->input->post('num', true);
  6587. $rktype = $this->input->post('rktype', true);
  6588. if ($num > 200) {
  6589. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6590. exit;
  6591. }
  6592. if (!$rktype) {
  6593. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6594. }
  6595. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6596. /**
  6597. $wz = array();
  6598. foreach ($rk as $key=>$value)
  6599. {
  6600. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6601. }
  6602. if(count($wz) > 1)
  6603. {
  6604. $wz = array_values($wz);
  6605. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6606. }
  6607. **/
  6608. if (isset($rk[0]['purchase'])) {
  6609. $rk = $rk[0];
  6610. $j = 0;
  6611. $post['purchase'] = $rk['purchase'];
  6612. $post['warehouse'] = $rk['warehouse'];
  6613. $post['retreatwarehouse'] = $rk['warehouse'];
  6614. $post['sku'] = $rk['sku'];
  6615. $post['number'] = $rk['number'];
  6616. $post['features'] = $rk['features'];
  6617. $post['title'] = $rk['title'];
  6618. $post['enter'] = $time;
  6619. $post['time'] = $time;
  6620. $post['bs'] = 1;
  6621. $post['shop'] = $rk['shop'];
  6622. $post['details'] = $rk['details'];
  6623. $post['cpid'] = $rk['cpid'];
  6624. $post['cpbz'] = $rk['cpbz'];
  6625. $post['rktype'] = $rktype;
  6626. $warehouse = $this->warehouse->read($rk['warehouse']);
  6627. if ($warehouse['bdck'] == '') {
  6628. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6629. exit;
  6630. } else {
  6631. $bdck = $warehouse['bdck'];
  6632. }
  6633. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6634. if (isset($pdwz['details'])) {
  6635. if ($pdwz['details'] != $post['details']) {
  6636. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6637. }else{
  6638. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6639. exit;
  6640. }
  6641. }
  6642. }
  6643. $post['featurespp'] = $rk['featurespp'];
  6644. if ($post['warehouse'] == '5') {
  6645. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6646. if ($yza) {
  6647. if ($post['features'] != $yza[0]['features']) {
  6648. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6649. exit;
  6650. }
  6651. }
  6652. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6653. if ($yzb) {
  6654. if ($post['sku'] != $yzb[0]['sku']) {
  6655. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6656. exit;
  6657. }
  6658. }
  6659. }
  6660. for ($i = 0; $i < $num; $i++) {
  6661. $post['label'] = time() . rand(100, 999) . $i;
  6662. if ($this->$bdck->insert($post)) {
  6663. $j++;
  6664. }
  6665. }
  6666. /**
  6667. if($post['warehouse'] != 12)
  6668. {
  6669. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6670. }
  6671. **/
  6672. $this->whlabelscanlog->insert([
  6673. 'shop'=>$rk['shop'],
  6674. 'type'=>1,
  6675. 'purchase'=>$rk['purchase'],
  6676. 'sku'=>$rk['sku'],
  6677. 'features'=>$rk['features'],
  6678. 'title'=>$rk['title'],
  6679. 'label'=>$rk['label'],
  6680. 'warehouse'=>$rk['warehouse'],
  6681. 'wlid'=>$rk['id'],
  6682. 'num'=>$num,
  6683. 'addtime'=>time()
  6684. ]);
  6685. if ($j == $num) {
  6686. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6687. exit;
  6688. } else {
  6689. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6690. exit;
  6691. }
  6692. } else {
  6693. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6694. exit;
  6695. }
  6696. }
  6697. $this->_Template('whlabel_printrk', $this->data);
  6698. }
  6699. public function _printxzrk($arg_array)
  6700. {
  6701. $post = $this->input->post(NULL, TRUE);
  6702. if (isset($post['wzid'])) {
  6703. $time = time();
  6704. $id = $this->input->post('wzid', true);
  6705. //$post['shop'] = $this->input->post('shop',true);
  6706. $num = 1;
  6707. $rk = $this->whlabellabel->read($id);
  6708. if (isset($rk['purchase'])) {
  6709. $x = 0;
  6710. $post['purchase'] = $rk['purchase'];
  6711. $post['warehouse'] = $rk['warehouse'];
  6712. $post['retreatwarehouse'] = $rk['warehouse'];
  6713. $post['sku'] = $rk['sku'];
  6714. $post['number'] = $rk['number'];
  6715. $post['features'] = $rk['features'];
  6716. $post['title'] = $rk['title'];
  6717. $post['enter'] = $time;
  6718. $post['time'] = $time;
  6719. $post['bs'] = 1;
  6720. $post['shop'] = $rk['shop'];
  6721. $post['details'] = $rk['details'];
  6722. $post['cpid'] = $rk['cpid'];
  6723. $post['cpbz'] = $rk['cpbz'];
  6724. $warehouse = $this->warehouse->read($rk['warehouse']);
  6725. if ($warehouse['bdck'] == '') {
  6726. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6727. exit;
  6728. } else {
  6729. $bdck = $warehouse['bdck'];
  6730. }
  6731. $post['featurespp'] = $rk['featurespp'];
  6732. $this->db->trans_begin();
  6733. for ($i = 0; $i < $num; $i++) {
  6734. $post['label'] = time() . rand(100, 999) . $i;
  6735. $this->$bdck->insert($post);
  6736. }
  6737. /**
  6738. if($post['warehouse'] != 12)
  6739. {
  6740. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6741. }
  6742. **/
  6743. if ($this->db->trans_status() === TRUE) {
  6744. $this->db->trans_commit();
  6745. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6746. exit;
  6747. } else {
  6748. $this->db->trans_rollback();
  6749. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6750. exit;
  6751. }
  6752. } else {
  6753. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6754. exit;
  6755. }
  6756. }
  6757. }
  6758. public function _printck($arg_array)
  6759. {
  6760. $prc = array();
  6761. $purchase = $this->purchase->find_all();
  6762. foreach ($purchase as $k => $v) {
  6763. $prc[$v['id']] = $v['title'];
  6764. }
  6765. $post = $this->input->post(NULL, TRUE);
  6766. if (isset($post['page'])) {
  6767. $page = $this->input->post('page', true);
  6768. $perpage = $this->input->post('perpage', true);
  6769. $sku = $this->input->post('sku', true);
  6770. $bs = $this->input->post('bs', true);
  6771. $number = $this->input->post('number', true);
  6772. $warehouse = $this->input->post('warehouse', true);
  6773. $purchase = $this->input->post('purchase', true);
  6774. $orderinfo = $this->input->post('orderinfo', true);
  6775. $waybill = $this->input->post('waybill', true);
  6776. $category = $this->input->post('category', true);
  6777. $size = $this->input->post('size', true);
  6778. $grade = $this->input->post('grade', true);
  6779. $color = $this->input->post('color', true);
  6780. $lowe = $this->input->post('lowe', true);
  6781. $state = $this->input->post('state', true);
  6782. $label = $this->input->post('label', true);
  6783. $timetk = $this->input->post('ktime', true);
  6784. $timetj = $this->input->post('jtime', true);
  6785. $timetk = strtotime($timetk);
  6786. $timetj = strtotime($timetj);
  6787. $where = "state=1 ";
  6788. if ($timetk && $timetj) {
  6789. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6790. }
  6791. if ($sku) {
  6792. $where .= " and sku = '$sku'";
  6793. }
  6794. if ($bs != '') {
  6795. $where .= " and bs = '$bs'";
  6796. }
  6797. if ($number) {
  6798. $where .= " and number = '$number'";
  6799. }
  6800. if ($warehouse) {
  6801. $where .= " and warehouse = '$warehouse'";
  6802. }
  6803. if ($purchase) {
  6804. $where .= " and purchase = '$purchase'";
  6805. }
  6806. if ($orderinfo) {
  6807. $where .= " and orderinfo = '$orderinfo'";
  6808. }
  6809. if ($waybill) {
  6810. $where .= " and waybill = '$waybill'";
  6811. }
  6812. if ($category) {
  6813. $where .= " and features like '%-$category-%'";
  6814. }
  6815. if ($size) {
  6816. $where .= " and features like '%-$size-%'";
  6817. }
  6818. if ($grade) {
  6819. $where .= " and features like '%-$grade-%'";
  6820. }
  6821. if ($color) {
  6822. $where .= " and features like '%-$color-%'";
  6823. }
  6824. if ($lowe) {
  6825. $where .= " and features like '%-$lowe-%'";
  6826. }
  6827. if ($label) {
  6828. $where .= " and label = '$label'";
  6829. }
  6830. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6831. //数据排序
  6832. $order_str = "outk desc";
  6833. if (empty($page)) {
  6834. $start = 0;
  6835. $perpage = 1;
  6836. } else {
  6837. $start = ($page - 1) * $perpage;
  6838. }
  6839. //取得信息列表
  6840. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6841. foreach ($info_list as $key => $value) {
  6842. $warehouse = $this->warehouse->read($value['warehouse']);
  6843. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6844. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6845. if ($value['state'] == 0) {
  6846. $info_list[$key]['state'] = "在库";
  6847. } else if ($value['state'] == 1) {
  6848. $info_list[$key]['state'] = "出库";
  6849. } else if ($value['state'] == 2) {
  6850. $info_list[$key]['state'] = "退库";
  6851. } else if ($value['state'] == 3) {
  6852. $info_list[$key]['state'] = "调拨中";
  6853. } else if ($value['state'] == 4) {
  6854. $info_list[$key]['state'] = "再加工";
  6855. } else if ($value['state'] == 5) {
  6856. $info_list[$key]['state'] = "维修中";
  6857. } else if ($value['state'] == 6) {
  6858. $info_list[$key]['state'] = "盘亏";
  6859. } else if ($value['state'] == 7) {
  6860. $info_list[$key]['state'] = "更换标签";
  6861. } else if ($value['state'] == 8) {
  6862. $info_list[$key]['state'] = "其它";
  6863. } else if ($value['state'] == 9) {
  6864. $info_list[$key]['state'] = "预设";
  6865. } else if ($value['state'] == 10) {
  6866. $info_list[$key]['state'] = "美店零售";
  6867. }
  6868. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6869. }
  6870. $total = $this->$ck->find_count($where);
  6871. $pagenum = ceil($total / $perpage);
  6872. $over = $total - ($start + $perpage);
  6873. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6874. echo json_encode($rows);
  6875. exit;
  6876. }
  6877. if (isset($post['tmsku'])) {
  6878. $time = time();
  6879. $tmsku = $this->input->post('tmsku', true);
  6880. //$post['shop'] = $this->input->post('shop',true);
  6881. $num = $this->input->post('num', true);
  6882. $cktype = $this->input->post('cktype', true);
  6883. $label = $this->whlabellabel->get_label($tmsku);
  6884. if (!$cktype) {
  6885. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6886. }
  6887. if (!isset($label['warehouse'])) {
  6888. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6889. exit;
  6890. }
  6891. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6892. $extra_where = "";
  6893. if(!empty($label['details'])){
  6894. $extra_where .= " and details = '" . $label['details'] . "'";
  6895. }
  6896. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6897. if (stripos($label['features'], '-126-') !== false) {
  6898. $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);
  6899. } else {
  6900. $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);
  6901. }
  6902. $j = 0;
  6903. if (count($ck) >= $num) {
  6904. for ($i = 0; $i < $num; $i++) {
  6905. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6906. {
  6907. $j++;
  6908. }
  6909. }
  6910. $this->whlabelscanlog->insert([
  6911. 'shop'=>$label['shop'],
  6912. 'type'=>2,
  6913. 'purchase'=>$label['purchase'],
  6914. 'sku'=>$label['sku'],
  6915. 'features'=>$label['features'],
  6916. 'title'=>$label['title'],
  6917. 'label'=>$label['label'],
  6918. 'warehouse'=>$label['warehouse'],
  6919. 'wlid'=>$label['id'],
  6920. 'num'=>$num,
  6921. 'addtime'=>time()
  6922. ]);
  6923. if ($j == $num) {
  6924. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6925. exit;
  6926. } else {
  6927. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6928. exit;
  6929. }
  6930. } else {
  6931. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6932. exit;
  6933. }
  6934. }
  6935. if(isset($_SESSION['api']))
  6936. {
  6937. $user = $this->user->get_api($_SESSION['api']);
  6938. if(in_array($user['power'],[1,27])){
  6939. $vip = 1;
  6940. }
  6941. }
  6942. else
  6943. {
  6944. $vip = 0;
  6945. header('Location: /');exit;
  6946. }
  6947. $this->data['vip'] = $vip;
  6948. $this->_Template('whlabel_printck', $this->data);
  6949. }
  6950. public function _printexcel()
  6951. {
  6952. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6953. $config['upload_path'] = '.' . $dir;
  6954. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6955. $config['allowed_types'] = 'xls|xlsx|csv';
  6956. $config['max_size'] = 10240;
  6957. $this->load->library('upload', $config);
  6958. $this->upload->initialize($config);
  6959. if ($this->upload->do_upload('userfile')) {
  6960. $full_path = $dir . $this->upload->data('file_name');
  6961. $fileName = '.' . $full_path;
  6962. if (!file_exists($fileName)) {
  6963. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6964. exit;
  6965. } else {
  6966. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6967. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6968. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6969. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6970. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6971. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6972. ++$column; //如果列数大于26行
  6973. $list = array();
  6974. for ($i = 2; $i <= $row; $i++) // 行数循环
  6975. {
  6976. $data = array();
  6977. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6978. {
  6979. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6980. }
  6981. $list[] = $data;
  6982. }
  6983. }
  6984. $ed = array();
  6985. $i = 0;
  6986. $j = 0;
  6987. $dcdata = array();
  6988. $yc = '';
  6989. $cmf_arr = array_column($list, '1');
  6990. array_multisort($cmf_arr, SORT_ASC, $list);
  6991. foreach ($list as $key => $value) {
  6992. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6993. if ($typeclass) {
  6994. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6995. } else {
  6996. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6997. $i++;
  6998. continue;
  6999. }
  7000. }
  7001. if ($i > 0) {
  7002. $yc = $i . '条异常';
  7003. }
  7004. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  7005. exit;
  7006. }
  7007. }
  7008. public function _uck()
  7009. {
  7010. if (isset($_GET['excel'])) {
  7011. $tc = array();
  7012. $typeclass = $this->typeclass->find_all();
  7013. foreach ($typeclass as $v) {
  7014. $tc[$v['id']] = $v['zh'];
  7015. }
  7016. $data = array();
  7017. $t = array();
  7018. $rq = '';
  7019. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  7020. $ts = $ts / (24 * 3600);
  7021. for ($i = 0; $i < $ts; $i++) {
  7022. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  7023. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  7024. }
  7025. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  7026. foreach ($info_list as $k => $v) {
  7027. $features = explode('-', trim($v['features'], '-'));
  7028. if (!isset($features[3]) || !isset($features[4])) {
  7029. continue;
  7030. }
  7031. $data[$k][0] = $tc[$features[0]]; //类型
  7032. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  7033. $data[$k][2] = $tc[$features[4]]; //曲度
  7034. $data[$k][3] = '';
  7035. if (isset($data[$k][1])) {
  7036. $data[$k][3] .= $data[$k][1];
  7037. }
  7038. if (isset($data[$k][2])) {
  7039. $data[$k][3] .= $data[$k][2];
  7040. }
  7041. if (isset($features[5])) {
  7042. $data[$k][3] .= $tc[$features[5]];
  7043. }
  7044. if (isset($features[2])) {
  7045. $data[$k][3] .= $tc[$features[2]];
  7046. }
  7047. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7048. $data[$k][4] = $v['sku'];
  7049. $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())) . '))'); //月初库存
  7050. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  7051. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  7052. $ztrq = '';
  7053. $ztsl = '';
  7054. if (count($zt) > 0) {
  7055. foreach ($zt as $vv) {
  7056. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  7057. $ztsl .= $vv['num'] . '<br>';
  7058. }
  7059. }
  7060. $data[$k][] = trim($ztsl, '<br>');
  7061. $data[$k][] = trim($ztrq, '<br>');
  7062. $byck = 0;
  7063. foreach ($t as $vv) {
  7064. $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));
  7065. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  7066. $byck += $sl;
  7067. }
  7068. $data[$k][] = ($byck > 0) ? $byck : '';
  7069. }
  7070. $title = "详情 " . date("Y-m-d", time());
  7071. $titlename = "<table border=1>
  7072. <tr align='center'>
  7073. <td>类别</td>
  7074. <td>颜色</td>
  7075. <td>曲度</td>
  7076. <td>名称</td>
  7077. <td>SKU</td>
  7078. <td>月初库存</td>
  7079. <td>剩余库存</td>
  7080. <td>在途数量</td>
  7081. <td>预达日期</td>" .
  7082. $rq
  7083. . "<td>本月出库</td></tr>
  7084. </table>";
  7085. $filename = $title . ".xls";
  7086. $tail = "";
  7087. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  7088. }
  7089. }
  7090. //梦体发现 用数字粘贴 会出现遗产给的数据
  7091. public function _whlabelexcelzh_ztsh()
  7092. {
  7093. if (isset($_GET['excel'])) {
  7094. $where = "sku != 'Preset'";
  7095. //数据排序
  7096. $order_str = "id desc";
  7097. if (empty($page)) {
  7098. $start = 0;
  7099. $perpage = 1;
  7100. } else {
  7101. $start = ($page - 1) * $perpage;
  7102. }
  7103. $category = $this->input->get('category', true);
  7104. $warehouse = $this->input->get('warehouse', true);
  7105. $excelid = $this->input->get('sid', true);
  7106. if ($category) {
  7107. $where .= " and features like '%-$category-%'";
  7108. }
  7109. if ($warehouse) {
  7110. $where .= " and warehouse = '$warehouse'";
  7111. }
  7112. $xzid = '';
  7113. if ($excelid) {
  7114. $excelid = explode(',', trim($excelid, ','));
  7115. foreach ($excelid as $key => $value) {
  7116. $xzid .= " id = " . $value . " or";
  7117. }
  7118. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  7119. }
  7120. //取得信息列表
  7121. /**
  7122. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7123. $rows = array();$list = array();
  7124. foreach ($info_list as $key=>$value)
  7125. {
  7126. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7127. }
  7128. **/
  7129. $list = array();
  7130. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  7131. foreach ($rows as $key => $value) {
  7132. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7133. $zh = '';
  7134. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7135. foreach ($zt as $v) {
  7136. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7137. }
  7138. $zt = array_sum(array_column($zt, 'num'));
  7139. $number = $value['number'];
  7140. $ftime = time() - 15 * 24 * 3600;
  7141. $warehouse = $this->warehouse->read($value['warehouse']);
  7142. $rows[$key]['warehouse'] = $warehouse['title'];
  7143. $rows[$key]['number'] = $c;
  7144. $rows[$key]['features'] = $zh;
  7145. $rows[$key]['hb'] = $c + $zt;
  7146. }
  7147. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7148. $titlename = "<table border=1>
  7149. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7150. <tr align='center'>
  7151. <td>仓库</td>
  7152. <td>SKU</td>
  7153. <td>产品</td>
  7154. <td>库存数量</td>
  7155. <td>在途数量及预达日期</td>
  7156. <td>在途+库存数量</td>
  7157. </tr>
  7158. </table>";
  7159. $filename = $title . ".xls";
  7160. $tail = "";
  7161. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7162. }
  7163. if (isset($_GET['excel'])) {
  7164. $warehouse = $this->input->get('warehouse', true);
  7165. $sku = $this->input->get('sku', true);
  7166. $cz = $this->input->get('cz', true);
  7167. $text = $this->input->post('text', true);
  7168. $xztime = $this->input->get('xztime', true);
  7169. $timetk = $this->input->get('timetk', true);
  7170. $timetj = $this->input->get('timetj', true);
  7171. $timetk = strtotime($timetk);
  7172. $timetj = strtotime($timetj);
  7173. $where = "time = '0' ";
  7174. if ($warehouse) {
  7175. $where .= " and warehouse = '$warehouse'";
  7176. }
  7177. if ($sku) {
  7178. $where .= " and sku = '$sku'";
  7179. }
  7180. if ($text) {
  7181. $where .= " and text like '%$text%'";
  7182. }
  7183. if ($cz != '') {
  7184. $where .= " and cz = '$cz'";
  7185. }
  7186. if ($timetk && $timetj) {
  7187. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7188. }
  7189. //数据排序
  7190. $order_str = $xztime . " desc";
  7191. //取得信息列表
  7192. $zh = array();
  7193. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7194. foreach ($info_list as $v) {
  7195. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7196. $warehouse = $this->warehouse->read($v['warehouse']);
  7197. $v['warehouse'] = $warehouse['title'];
  7198. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7199. $v['stime'] = date('Y-m-d', $v['stime']);
  7200. if (isset($zh[$v['features']])) {
  7201. $zh[$v['features']]['num'] += $v['num'];
  7202. } else {
  7203. $zh[$v['features']] = $v;
  7204. }
  7205. $zh[$v['features']]['features'] = $c;
  7206. }
  7207. $title = "在途数据" . date('Y-m-d', time());
  7208. $titlename = "<table border=1>
  7209. <tr align='center'>
  7210. <td>仓库</td>
  7211. <td>SKU</td>
  7212. <td>名称</td>
  7213. <td>在途数量</td>
  7214. <td>库存数量</td>
  7215. <td>添加在途日期</td>
  7216. <td>预达日期</td>
  7217. <td>备注</td>
  7218. </tr>
  7219. </table>";
  7220. $filename = $title . ".xls";
  7221. $tail = "";
  7222. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  7223. }
  7224. }
  7225. //用XML(SpreadsheetML)格式导出excel,逻辑与_whlabelexcelzh一致,仅输出格式不同
  7226. public function _whlabelexcelzh()
  7227. {
  7228. //$colwidths:按表头顺序设置各列宽度(单位≈字符数);$wrapcols:需要自动换行的列下标(从0开始)
  7229. $excelxml = function ($info_list, $headers, $numkeys, $filename, $colwidths = array(), $wrapcols = array()) {
  7230. $str = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
  7231. $str .= '<?mso-application progid="Excel.Sheet"?>' . "\n";
  7232. $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";
  7233. $str .= '<Styles>' . "\n";
  7234. $str .= '<Style ss:ID="wrap"><Alignment ss:Vertical="Center" ss:WrapText="1"/></Style>' . "\n";
  7235. $str .= '</Styles>' . "\n";
  7236. $str .= '<Worksheet ss:Name="Sheet1">' . "\n";
  7237. $str .= '<Table>' . "\n";
  7238. foreach ($colwidths as $w) {
  7239. $str .= '<Column ss:Width="' . $w . '"/>' . "\n";
  7240. }
  7241. $str .= '<Row>' . "\n";
  7242. foreach ($headers as $h) {
  7243. $str .= '<Cell><Data ss:Type="String">' . htmlspecialchars($h, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
  7244. }
  7245. $str .= '</Row>' . "\n";
  7246. foreach ($info_list as $row) {
  7247. $str .= '<Row>' . "\n";
  7248. $j = 0;
  7249. foreach ($row as $ke => $va) {
  7250. $va = (string)$va;
  7251. $va = str_replace('<br>', "\n", $va);
  7252. $wrapattr = in_array($j, $wrapcols) ? ' ss:StyleID="wrap"' : '';
  7253. if ($va === '') {
  7254. $str .= '<Cell' . $wrapattr . '><Data ss:Type="String"></Data></Cell>' . "\n";
  7255. } else if (in_array($ke, $numkeys) && is_numeric($va)) {
  7256. $str .= '<Cell' . $wrapattr . '><Data ss:Type="Number">' . $va . '</Data></Cell>' . "\n";
  7257. } else {
  7258. $str .= '<Cell' . $wrapattr . '><Data ss:Type="String">' . htmlspecialchars($va, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
  7259. }
  7260. $j++;
  7261. }
  7262. $str .= '</Row>' . "\n";
  7263. }
  7264. $str .= '</Table>' . "\n";
  7265. $str .= '</Worksheet>' . "\n";
  7266. $str .= '</Workbook>' . "\n";
  7267. while (ob_get_level()) {
  7268. ob_end_clean();
  7269. }
  7270. header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
  7271. header("Content-Disposition: attachment; filename=" . $filename);
  7272. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  7273. header("Pragma: no-cache");
  7274. header("Expires: 0");
  7275. echo $str;
  7276. exit();
  7277. };
  7278. if (isset($_GET['excel'])) {
  7279. $where = "sku != 'Preset'";
  7280. //数据排序
  7281. $order_str = "id desc";
  7282. if (empty($page)) {
  7283. $start = 0;
  7284. $perpage = 1;
  7285. } else {
  7286. $start = ($page - 1) * $perpage;
  7287. }
  7288. $category = $this->input->get('category', true);
  7289. $warehouse = $this->input->get('warehouse', true);
  7290. $excelid = $this->input->get('sid', true);
  7291. if ($category) {
  7292. $where .= " and features like '%-$category-%'";
  7293. }
  7294. if ($warehouse) {
  7295. $where .= " and warehouse = '$warehouse'";
  7296. }
  7297. $xzid = '';
  7298. if ($excelid) {
  7299. $excelid = explode(',', trim($excelid, ','));
  7300. foreach ($excelid as $key => $value) {
  7301. $xzid .= " id = " . $value . " or";
  7302. }
  7303. $xzid = " and (" . rtrim($xzid, 'or') . ");";
  7304. }
  7305. $list = array();
  7306. $rows = $this->whlabel->find_pc($where, 'sku,title,features,warehouse', 'warehouse,sku,title,number,features');
  7307. foreach ($rows as $key => $value) {
  7308. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7309. $zh = '';
  7310. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7311. foreach ($zt as $v) {
  7312. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7313. }
  7314. $zt = array_sum(array_column($zt, 'num'));
  7315. $number = $value['number'];
  7316. $ftime = time() - 15 * 24 * 3600;
  7317. $warehouse = $this->warehouse->read($value['warehouse']);
  7318. //按表头顺序输出:仓库 | SKU | 产品 | 库存数量 | 在途数量及预达日期 | 在途+库存数量
  7319. $rows[$key] = array(
  7320. 'warehouse' => ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $value['warehouse'],
  7321. 'sku' => $value['sku'],
  7322. 'title' => isset($value['title']) ? $value['title'] : '',
  7323. 'number' => $c,
  7324. 'features' => $zh,
  7325. 'hb' => $c + $zt,
  7326. );
  7327. }
  7328. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7329. $filename = $title . ".xls";
  7330. $headers = array('仓库', 'SKU', '产品', '库存数量', '在途数量及预达日期', '在途+库存数量');
  7331. $numkeys = array('number', 'hb');
  7332. //列宽与表头一一对应(单位≈字符数);SKU(1)、产品(2)、在途列(4)超宽自动换行
  7333. $colwidths = array(80, 300,450, 50, 120, 80);
  7334. $wrapcols = array(1, 2, 4);
  7335. $excelxml($rows, $headers, $numkeys, $filename, $colwidths, $wrapcols);
  7336. }
  7337. if (isset($_GET['excel'])) {
  7338. $warehouse = $this->input->get('warehouse', true);
  7339. $sku = $this->input->get('sku', true);
  7340. $cz = $this->input->get('cz', true);
  7341. $text = $this->input->post('text', true);
  7342. $xztime = $this->input->get('xztime', true);
  7343. $timetk = $this->input->get('timetk', true);
  7344. $timetj = $this->input->get('timetj', true);
  7345. $timetk = strtotime($timetk);
  7346. $timetj = strtotime($timetj);
  7347. $where = "time = '0' ";
  7348. if ($warehouse) {
  7349. $where .= " and warehouse = '$warehouse'";
  7350. }
  7351. if ($sku) {
  7352. $where .= " and sku = '$sku'";
  7353. }
  7354. if ($text) {
  7355. $where .= " and text like '%$text%'";
  7356. }
  7357. if ($cz != '') {
  7358. $where .= " and cz = '$cz'";
  7359. }
  7360. if ($timetk && $timetj) {
  7361. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7362. }
  7363. //数据排序
  7364. $order_str = $xztime . " desc";
  7365. //取得信息列表
  7366. $zh = array();
  7367. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7368. foreach ($info_list as $v) {
  7369. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7370. $warehouse = $this->warehouse->read($v['warehouse']);
  7371. $v['warehouse'] = ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $v['warehouse'];
  7372. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7373. $v['stime'] = date('Y-m-d', $v['stime']);
  7374. if (isset($zh[$v['features']])) {
  7375. $zh[$v['features']]['num'] += $v['num'];
  7376. } else {
  7377. $zh[$v['features']] = $v;
  7378. }
  7379. $zh[$v['features']]['features'] = $c;
  7380. }
  7381. $title = "在途数据" . date('Y-m-d', time());
  7382. $filename = $title . ".xls";
  7383. $headers = array('仓库', 'SKU', '名称', '在途数量', '库存数量', '添加在途日期', '预达日期', '备注');
  7384. $numkeys = array('num', 'features');
  7385. //列宽与表头一一对应(单位≈字符数);SKU(1)、名称(2)、备注(7)超宽自动换行
  7386. $colwidths = array(18, 20, 50, 12, 12, 20, 12, 40);
  7387. $wrapcols = array(1, 2, 7);
  7388. $excelxml($zh, $headers, $numkeys, $filename, $colwidths, $wrapcols);
  7389. }
  7390. }
  7391. public function _fc()
  7392. {
  7393. $vip = 0;
  7394. if (isset($_SESSION['api'])) {
  7395. $user = $this->user->get_api($_SESSION['api']);
  7396. if ($user['vip'] == 1) {
  7397. $vip = 1;
  7398. }
  7399. } else {
  7400. header('Location: /');
  7401. exit;
  7402. }
  7403. $post = $this->input->post(NULL, TRUE);
  7404. if (isset($post['page'])) {
  7405. $page = $this->input->post('page', true);
  7406. $perpage = $this->input->post('perpage', true);
  7407. $category = $this->input->post('category', true);
  7408. $size = $this->input->post('size', true);
  7409. $grade = $this->input->post('grade', true);
  7410. $color = $this->input->post('color', true);
  7411. $lowe = $this->input->post('lowe', true);
  7412. $sku = $this->input->post('sku');
  7413. $title = $this->input->post('title');
  7414. $warehouse = $this->input->post('warehouse', true);
  7415. $usa = $this->input->post('usa', true);
  7416. $purchase = $this->input->post('purchase', true);
  7417. $lacetype = $this->input->post('lacetype', true);
  7418. $haircap = $this->input->post('haircap', true);
  7419. $density = $this->input->post('density', true);
  7420. $details = $this->input->post('details', true);
  7421. $state = $this->input->post('state', true);
  7422. $ktime = $this->input->post('ktime', true);
  7423. $jtime = $this->input->post('jtime', true);
  7424. $ktime = strtotime($ktime);
  7425. $jtime = strtotime($jtime);
  7426. $where = "state = '11'";
  7427. $gj = "";
  7428. $ck = "";
  7429. if ($lacetype) {
  7430. $where .= " and features like '%-$lacetype-%'";
  7431. }
  7432. if ($category) {
  7433. $where .= " and features like '%-$category-%'";
  7434. }
  7435. if ($size) {
  7436. $where .= " and features like '%-$size-%'";
  7437. }
  7438. if ($grade) {
  7439. $where .= " and features like '%-$grade-%'";
  7440. }
  7441. if ($color) {
  7442. $where .= " and features like '%-$color-%'";
  7443. }
  7444. if ($lowe) {
  7445. $where .= " and features like '%-$lowe-%'";
  7446. }
  7447. if ($haircap) {
  7448. $where .= " and features like '%-$haircap-%'";
  7449. }
  7450. if ($density) {
  7451. $where .= " and features like '%-$density-%'";
  7452. }
  7453. if ($usa) {
  7454. if (!$warehouse) {
  7455. $where .= " and (warehouse = '5' or warehouse = '8')";
  7456. }
  7457. }
  7458. if ($warehouse) {
  7459. $where .= " and warehouse = '$warehouse'";
  7460. }
  7461. if ($details) {
  7462. $where .= " and details = '$details'";
  7463. }
  7464. if ($purchase) {
  7465. $where .= " and purchase = '$purchase'";
  7466. }
  7467. if ($state) {
  7468. $where .= " and state = '$state'";
  7469. }
  7470. if ($ktime && $jtime) {
  7471. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7472. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7473. }
  7474. //数据排序
  7475. $order_str = "id desc";
  7476. if (empty($page)) {
  7477. $start = 0;
  7478. $perpage = 1;
  7479. } else {
  7480. $start = ($page - 1) * $perpage;
  7481. }
  7482. if ($sku) {
  7483. $sku = trim($sku, ' ');
  7484. $sku = trim($sku, ' ');
  7485. $where .= " and sku like '%$sku%'";
  7486. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7487. } else if ($title) {
  7488. $title = trim($title, ' ');
  7489. $title = trim($title, ' ');
  7490. $where .= " and title like '%$title%'";
  7491. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7492. } else {
  7493. //$where .= " and time > '$ktime' and time < '$jtime'";
  7494. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7495. }
  7496. //取得信息列表
  7497. $rows = array();
  7498. $list = array();
  7499. foreach ($info_list as $key => $value) {
  7500. $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'] . '"');
  7501. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7502. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7503. $warehouse = $this->warehouse->read($value['warehouse']);
  7504. $info_list[$key]['warehouse'] = $warehouse['title'];
  7505. $info_list[$key]['number'] = $g;
  7506. $info_list[$key]['features'] = $x;
  7507. $info_list[$key]['x'] = $s;
  7508. }
  7509. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  7510. $pagenum = ceil($total / $perpage);
  7511. $over = $total - ($start + $perpage);
  7512. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  7513. echo json_encode($rows);
  7514. exit;
  7515. }
  7516. $this->data['vip'] = $vip;
  7517. $this->_Template('whlabel_fc', $this->data);
  7518. }
  7519. public function _fcmb()
  7520. {
  7521. $where = "sku != 'Preset'";
  7522. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  7523. foreach ($rows as $k => $v) {
  7524. $warehouse = $this->warehouse->read($v['warehouse']);
  7525. $rows[$k]['warehouse'] = $warehouse['title'];
  7526. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  7527. $rows[$k]['t'] = '';
  7528. $rows[$k]['n'] = '';
  7529. }
  7530. $title = "封货产品数据导入模板";
  7531. $titlename = "<table border=1>
  7532. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7533. <tr align='center'>
  7534. <td>仓库</td>
  7535. <td>SKU</td>
  7536. <td>产品</td>
  7537. <td>封存产品总数量</td>
  7538. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7539. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7540. </tr>
  7541. </table>";
  7542. $filename = $title . ".xls";
  7543. $tail = "";
  7544. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7545. }
  7546. public function _fcexcel()
  7547. {
  7548. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7549. $config['upload_path'] = '.' . $dir;
  7550. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7551. $config['allowed_types'] = 'xls|xlsx|csv';
  7552. $config['max_size'] = 10240;
  7553. $this->load->library('upload', $config);
  7554. $this->upload->initialize($config);
  7555. if ($this->upload->do_upload('userfile')) {
  7556. $full_path = $dir . $this->upload->data('file_name');
  7557. $fileName = '.' . $full_path;
  7558. if (!file_exists($fileName)) {
  7559. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7560. exit;
  7561. } else {
  7562. libxml_use_internal_errors(true);
  7563. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7564. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7565. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7566. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7567. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7568. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7569. ++$column; //如果列数大于26行
  7570. $list = array();
  7571. for ($i = 2; $i <= $row; $i++) // 行数循环
  7572. {
  7573. $data = array();
  7574. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7575. {
  7576. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7577. }
  7578. $list[] = $data;
  7579. }
  7580. }
  7581. $i = 0;
  7582. $j = 0;
  7583. $ed = array();
  7584. foreach ($list as $key => $value) {
  7585. $time = time();
  7586. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  7587. continue;
  7588. }
  7589. $warehouse = $this->warehouse->get_title($value['0']);
  7590. $sku = $value['1'];
  7591. $type = $value['4']; //调整方式0扣减1删除
  7592. $num = $value['5']; //调整数量
  7593. //$text = $value['4'];//扣减说明
  7594. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7595. if (!$d) //如果没有这个SKU
  7596. {
  7597. $ed[] = array($sku . '-库存中不存在此SKU');
  7598. $j++;
  7599. continue;
  7600. }
  7601. if (!isset($warehouse['id'])) {
  7602. $ed[] = array($sku . '-仓库名错误!');
  7603. $j++;
  7604. continue;
  7605. }
  7606. if ($type == 1 || $type == 2) //扣减库存
  7607. {
  7608. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7609. if (count($data) < abs($num)) {
  7610. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7611. $j++;
  7612. continue;
  7613. }
  7614. if ($type == 1) //转入库存
  7615. {
  7616. for ($i = 0; $i < abs($num); $i++) {
  7617. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7618. }
  7619. } else if ($type == 2) //删除
  7620. {
  7621. for ($i = 0; $i < abs($num); $i++) {
  7622. $this->whlabel->remove($data[$i]['id']);
  7623. }
  7624. }
  7625. } else if ($type == 0) //增加库存
  7626. {
  7627. $post['sku'] = $d['sku'];
  7628. $post['shop'] = '';
  7629. $post['warehouse'] = $warehouse['id'];
  7630. $post['purchase'] = $d['purchase'];
  7631. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7632. $post['state'] = 11;
  7633. $post['title'] = $d['title'];
  7634. $post['number'] = $d['number'];
  7635. $post['features'] = $d['features'];
  7636. $post['enter'] = $time;
  7637. $post['time'] = $time; //操作时间
  7638. for ($i = 0; $i < $num; $i++) {
  7639. $post['label'] = time() . rand(100, 999) . $i;
  7640. $this->whlabel->insert($post);
  7641. }
  7642. }
  7643. sleep(1); //防止入库时间一样,需要延迟1秒
  7644. }
  7645. if ($j > 0) {
  7646. $tt = date('Ymd', time());
  7647. $title = '库存导入错误信息-' . $tt;
  7648. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7649. $tail = "\n";
  7650. $filename = $title . ".xls";
  7651. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7652. $dir = '/data/excel/' . $time . '/';
  7653. $file_name = 'error_' . $time . rand(1000, 9999);
  7654. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7655. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7656. fwrite($myfile, $ecl);
  7657. fclose($myfile);
  7658. $error = $dir . $file_name . '.xls';
  7659. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7660. exit;
  7661. } else {
  7662. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7663. exit;
  7664. }
  7665. }
  7666. }
  7667. public function _fcjxc($arg_array)
  7668. {
  7669. if (isset($_GET['excel'])) {
  7670. $category = $this->input->get('category', true);
  7671. $size = $this->input->get('size', true);
  7672. $grade = $this->input->get('grade', true);
  7673. $color = $this->input->get('color', true);
  7674. $lowe = $this->input->get('lowe', true);
  7675. $sku = $this->input->get('sku');
  7676. $title = $this->input->get('title');
  7677. $warehouse = $arg_array[0];
  7678. $usa = $this->input->get('usa', true);
  7679. $purchase = $this->input->get('purchase', true);
  7680. $lacetype = $this->input->get('lacetype', true);
  7681. $haircap = $this->input->get('haircap', true);
  7682. $density = $this->input->get('density', true);
  7683. $title = $this->input->get('title', true);
  7684. $state = $this->input->get('state', true);
  7685. $ktime = $this->input->get('ktime', true);
  7686. $jtime = $this->input->get('jtime', true);
  7687. $where = "state=11";
  7688. $gj = "";
  7689. $ck = "";
  7690. if ($lacetype) {
  7691. $where .= " and features like '%-$lacetype-%'";
  7692. }
  7693. if ($category) {
  7694. $where .= " and features like '%-$category-%'";
  7695. }
  7696. if ($size) {
  7697. $where .= " and features like '%-$size-%'";
  7698. }
  7699. if ($grade) {
  7700. $where .= " and features like '%-$grade-%'";
  7701. }
  7702. if ($color) {
  7703. $where .= " and features like '%-$color-%'";
  7704. }
  7705. if ($lowe) {
  7706. $where .= " and features like '%-$lowe-%'";
  7707. }
  7708. if ($haircap) {
  7709. $where .= " and features like '%-$haircap-%'";
  7710. }
  7711. if ($density) {
  7712. $where .= " and features like '%-$density-%'";
  7713. }
  7714. if ($usa) {
  7715. if (!$warehouse) {
  7716. $where .= " and (warehouse = '5' or warehouse = '8')";
  7717. }
  7718. }
  7719. if ($warehouse) {
  7720. $where .= " and warehouse = '$warehouse'";
  7721. }
  7722. if ($purchase) {
  7723. $where .= " and purchase = '$purchase'";
  7724. }
  7725. if ($state) {
  7726. $where .= " and state = '$state'";
  7727. }
  7728. $order_str = "id desc";
  7729. if ($sku) {
  7730. $sku = trim($sku, ' ');
  7731. $sku = trim($sku, ' ');
  7732. $where .= " and sku like '%$sku%'";
  7733. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7734. } else if ($title) {
  7735. $title = trim($title, ' ');
  7736. $title = trim($title, ' ');
  7737. $where .= " and title like '%$title%'";
  7738. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7739. } else {
  7740. //$where .= " and time > '$ktime' and time < '$jtime'";
  7741. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7742. }
  7743. //取得信息列表
  7744. $rows = array();
  7745. $list = array();
  7746. foreach ($info_list as $key => $value) {
  7747. $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'] . '"');
  7748. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7749. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7750. $rows[$key] = $value;
  7751. $warehouse = $this->warehouse->read($value['warehouse']);
  7752. $rows[$key]['warehouse'] = $warehouse['title'];
  7753. $rows[$key]['features'] = $g;
  7754. $rows[$key]['a'] = $x;
  7755. $rows[$key]['b'] = $s;
  7756. }
  7757. $title = "总统计表";
  7758. $titlename = "<table border=1>
  7759. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7760. <tr align='center'>
  7761. <td>仓库</td>
  7762. <td>SKU</td>
  7763. <td>产品名称</td>
  7764. <td>录入总量</td>
  7765. <td>取出总量</td>
  7766. <td>剩余总量</td>
  7767. </tr>
  7768. </table>";
  7769. $filename = $title . ".xls";
  7770. $tail = "";
  7771. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7772. }
  7773. $vip = 0;
  7774. if (isset($_SESSION['api'])) {
  7775. $user = $this->user->get_api($_SESSION['api']);
  7776. if ($user['vip'] == 1) {
  7777. $vip = 1;
  7778. }
  7779. } else {
  7780. header('Location: /');
  7781. exit;
  7782. }
  7783. $post = $this->input->post(NULL, TRUE);
  7784. if (isset($post['page'])) {
  7785. $page = $this->input->post('page', true);
  7786. $perpage = $this->input->post('perpage', true);
  7787. $category = $this->input->post('category', true);
  7788. $size = $this->input->post('size', true);
  7789. $grade = $this->input->post('grade', true);
  7790. $color = $this->input->post('color', true);
  7791. $lowe = $this->input->post('lowe', true);
  7792. $sku = $this->input->post('sku');
  7793. $title = $this->input->post('title');
  7794. $warehouse = $arg_array[0];
  7795. $usa = $this->input->post('usa', true);
  7796. $purchase = $this->input->post('purchase', true);
  7797. $lacetype = $this->input->post('lacetype', true);
  7798. $haircap = $this->input->post('haircap', true);
  7799. $density = $this->input->post('density', true);
  7800. $title = $this->input->post('title', true);
  7801. $state = $this->input->post('state', true);
  7802. $ktime = $this->input->post('ktime', true);
  7803. $jtime = $this->input->post('jtime', true);
  7804. $ktime = strtotime($ktime);
  7805. $jtime = strtotime($jtime);
  7806. $where = "state=11";
  7807. $gj = "";
  7808. $ck = "";
  7809. if ($lacetype) {
  7810. $where .= " and features like '%-$lacetype-%'";
  7811. }
  7812. if ($category) {
  7813. $where .= " and features like '%-$category-%'";
  7814. }
  7815. if ($size) {
  7816. $where .= " and features like '%-$size-%'";
  7817. }
  7818. if ($grade) {
  7819. $where .= " and features like '%-$grade-%'";
  7820. }
  7821. if ($color) {
  7822. $where .= " and features like '%-$color-%'";
  7823. }
  7824. if ($lowe) {
  7825. $where .= " and features like '%-$lowe-%'";
  7826. }
  7827. if ($haircap) {
  7828. $where .= " and features like '%-$haircap-%'";
  7829. }
  7830. if ($density) {
  7831. $where .= " and features like '%-$density-%'";
  7832. }
  7833. if ($usa) {
  7834. if (!$warehouse) {
  7835. $where .= " and (warehouse = '5' or warehouse = '8')";
  7836. }
  7837. }
  7838. if ($warehouse) {
  7839. $where .= " and warehouse = '$warehouse'";
  7840. }
  7841. if ($purchase) {
  7842. $where .= " and purchase = '$purchase'";
  7843. }
  7844. if ($state) {
  7845. $where .= " and state = '$state'";
  7846. }
  7847. if ($ktime && $jtime) {
  7848. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7849. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7850. }
  7851. //数据排序
  7852. $order_str = "id desc";
  7853. $xs = 0;
  7854. $rows = array();
  7855. $list = array();
  7856. if (empty($page)) {
  7857. $start = 0;
  7858. $perpage = 1;
  7859. } else {
  7860. $start = ($page - 1) * $perpage;
  7861. }
  7862. if ($sku || $title) {
  7863. if ($title) {
  7864. $title = trim($title, ' ');
  7865. $title = trim($title, ' ');
  7866. $where .= " and title like '%$title%'";
  7867. } else {
  7868. $sku = trim($sku, ' ');
  7869. $sku = trim($sku, ' ');
  7870. $where .= " and sku like '%$sku%'";
  7871. }
  7872. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7873. foreach ($info_list as $key => $value) {
  7874. $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'] . '"');
  7875. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7876. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7877. $rows[$key] = $value;
  7878. $warehouse = $this->warehouse->read($value['warehouse']);
  7879. $rows[$key]['warehouse'] = $warehouse['title'];
  7880. $rows[$key]['features'] = $g;
  7881. $rows[$key]['a'] = $x;
  7882. $rows[$key]['b'] = $s;
  7883. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7884. $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天销量
  7885. $yj = $c / ($xl / 30);
  7886. if ($yj < 7) {
  7887. $rows[$key]['y'] = round($yj) . '天销量';
  7888. } else {
  7889. $rows[$key]['y'] = '正常';
  7890. }
  7891. }
  7892. } else {
  7893. //$where .= " and time > '$ktime' and time < '$jtime'";
  7894. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7895. foreach ($info_list as $key => $value) {
  7896. $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'] . '"');
  7897. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7898. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7899. $zs[$key] = $value;
  7900. $warehouse = $this->warehouse->read($value['warehouse']);
  7901. $zs[$key]['warehouse'] = $warehouse['title'];
  7902. $zs[$key]['features'] = $g;
  7903. $zs[$key]['a'] = $x;
  7904. $zs[$key]['b'] = $s;
  7905. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7906. $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天销量
  7907. $yj = $c / ($xl / 30);
  7908. if ($yj < 7) {
  7909. $zs[$key]['y'] = round($yj) . '天销量';
  7910. $rows[$key] = $zs[$key];
  7911. }
  7912. }
  7913. }
  7914. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7915. $pagenum = ceil($total / $perpage);
  7916. $over = $total - ($start + $perpage);
  7917. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7918. echo json_encode($rows);
  7919. exit;
  7920. }
  7921. $this->data['arg_array'] = $arg_array[0];
  7922. $this->_Template('whlabel_fcjxc', $this->data);
  7923. }
  7924. public function _0kcdel()
  7925. {
  7926. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7927. $config['upload_path'] = '.' . $dir;
  7928. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7929. $config['allowed_types'] = 'xls|xlsx|csv';
  7930. $config['max_size'] = 10240;
  7931. $this->load->library('upload', $config);
  7932. $this->upload->initialize($config);
  7933. if ($this->upload->do_upload('userfile')) {
  7934. $full_path = $dir . $this->upload->data('file_name');
  7935. $fileName = '.' . $full_path;
  7936. if (!file_exists($fileName)) {
  7937. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7938. exit;
  7939. } else {
  7940. require_once "./data/excel/PHPExcel/IOFactory.php";
  7941. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7942. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7943. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7944. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7945. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7946. ++$column; //如果列数大于26行
  7947. $list = array();
  7948. for ($i = 2; $i <= $row; $i++) // 行数循环
  7949. {
  7950. $data = array();
  7951. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7952. {
  7953. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7954. }
  7955. $list[] = $data;
  7956. }
  7957. }
  7958. $i = 0;
  7959. $j = 0;
  7960. $ed = array();
  7961. foreach ($list as $key => $value) {
  7962. $time = time();
  7963. if ($value['0'] == "" || $value['1'] == "") {
  7964. continue;
  7965. }
  7966. $warehouse = $this->warehouse->get_title($value['0']);
  7967. $sku = $value['1'];
  7968. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7969. if (!$d) //如果没有这个SKU
  7970. {
  7971. $ed[] = array($sku . '-库存中不存在此SKU');
  7972. $j++;
  7973. continue;
  7974. }
  7975. if (!isset($warehouse['id'])) {
  7976. $ed[] = array($sku . '-仓库名错误!');
  7977. $j++;
  7978. continue;
  7979. }
  7980. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7981. if ($z < 1) {
  7982. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7983. foreach ($z as $v) {
  7984. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7985. if (count($zt) > 0) {
  7986. $ed[] = array($sku . '-有在途库存无法删除!');
  7987. $j++;
  7988. continue;
  7989. }
  7990. $tmp_info = $v;
  7991. $tmp_info['del_time'] = time();
  7992. $this->db->insert('whlabelscbf',$tmp_info);
  7993. $this->whlabel->remove($v['id']);
  7994. }
  7995. } else {
  7996. $ed[] = array($sku . '-非0库存!');
  7997. $j++;
  7998. continue;
  7999. }
  8000. }
  8001. if ($j > 0) {
  8002. $tt = date('Ymd', time());
  8003. $title = '删除0库存错误信息-' . $tt;
  8004. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  8005. $tail = "\n";
  8006. $filename = $title . ".xls";
  8007. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  8008. $dir = '/data/excel/' . $time . '/';
  8009. $file_name = 'error_' . $time . rand(1000, 9999);
  8010. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  8011. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  8012. fwrite($myfile, $ecl);
  8013. fclose($myfile);
  8014. $error = $dir . $file_name . '.xls';
  8015. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  8016. exit;
  8017. } else {
  8018. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  8019. exit;
  8020. }
  8021. }
  8022. }
  8023. public function _gbhtype()
  8024. {
  8025. $post = $this->input->post(NULL, TRUE);
  8026. if (isset($post['s'])) {
  8027. $n = $this->input->post('n');
  8028. $d = $this->input->post('s');
  8029. if (!$d) {
  8030. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  8031. exit;
  8032. }
  8033. $d = explode(',', trim($d, ','));
  8034. $t = $this->whlabel_type->read($n);
  8035. //循环删除记录
  8036. foreach ($d as $v) {
  8037. $u = $this->whlabel->read($v);
  8038. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  8039. foreach ($data as $val) {
  8040. $this->whlabel->save(array('type' => $n), $val['id']);
  8041. }
  8042. }
  8043. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  8044. }
  8045. }
  8046. //出库、退库导出
  8047. public function _dccrtype()
  8048. {
  8049. $classid = $this->classid->sku();
  8050. $pm = $classid;
  8051. $typeclass = array();
  8052. $tc = $this->typeclass->find_all();
  8053. foreach ($tc as $v) {
  8054. $typeclass[$v['id']] = $v;
  8055. }
  8056. $prc = array();
  8057. $purchase = $this->purchase->find_all();
  8058. foreach ($purchase as $k => $v) {
  8059. $prc[$v['id']] = $v['title'];
  8060. }
  8061. if (isset($_GET['sid'])) {
  8062. $wh = array();
  8063. $w = $this->warehouse->find_all('1=1', 'id,title');
  8064. foreach ($w as $v) {
  8065. $wh[$v['id']] = $v['title'];
  8066. }
  8067. $type = $this->input->get('excel', true);
  8068. $category = $this->input->get('category', true);
  8069. $size = $this->input->get('size', true);
  8070. $grade = $this->input->get('grade', true);
  8071. $color = $this->input->get('color', true);
  8072. $lowe = $this->input->get('lowe', true);
  8073. $sku = $this->input->get('sku', true);
  8074. $warehouse = $this->input->get('warehouse', true);
  8075. $lacetype = $this->input->get('lacetype', true);
  8076. $lacecolor = $this->input->get('lacecolor', true);
  8077. $density = $this->input->get('density', true);
  8078. $haircap = $this->input->get('haircap', true);
  8079. $purchase = $this->input->get('purchase', true);
  8080. $title = $this->input->get('title', true);
  8081. $state = $this->input->get('state', true);
  8082. $sid = $this->input->get('sid', true);
  8083. $ktime = $this->input->get('ktime', true);
  8084. $jtime = $this->input->get('jtime', true);
  8085. $ktime = strtotime($ktime);
  8086. $jtime = strtotime($jtime);
  8087. $where = "1=1";
  8088. $gj = "";
  8089. $ck = "";
  8090. if ($category) {
  8091. $where .= " and features like '%-$category-%'";
  8092. }
  8093. if ($size) {
  8094. $where .= " and features like '%-$size-%'";
  8095. }
  8096. if ($grade) {
  8097. $where .= " and features like '%-$grade-%'";
  8098. }
  8099. if ($color) {
  8100. $where .= " and features like '%-$color-%'";
  8101. }
  8102. if ($lowe) {
  8103. $where .= " and features like '%-$lowe-%'";
  8104. }
  8105. if ($warehouse) {
  8106. $where .= " and warehouse = '$warehouse'";
  8107. }
  8108. if ($purchase) {
  8109. $where .= " and purchase = '$purchase'";
  8110. }
  8111. if ($state) {
  8112. $where .= " and state = '$state'";
  8113. }
  8114. if ($lacetype) {
  8115. $where .= " and features like '%-$lacetype-%'";
  8116. }
  8117. if ($lacecolor) {
  8118. $where .= " and features like '%-$lacecolor-%'";
  8119. }
  8120. if ($density) {
  8121. $where .= " and features like '%-$density-%'";
  8122. }
  8123. if ($haircap) {
  8124. $where .= " and features like '%-$haircap-%'";
  8125. }
  8126. if ($title) {
  8127. $title = trim($title, ' ');
  8128. $title = trim($title, ' ');
  8129. $where .= " and title like '%$title%'";
  8130. }
  8131. if ($sku) {
  8132. $sku = trim($sku, ' ');
  8133. $sku = trim($sku, ' ');
  8134. $where .= " and sku like '%$sku%'";
  8135. }
  8136. if ($ktime && $jtime) {
  8137. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8138. }
  8139. $sidwhere = '';
  8140. if ($sid) {
  8141. $sd = "";
  8142. $s = explode(',', trim($sid, ','));
  8143. foreach ($s as $value) {
  8144. $sd .= " id = " . $value . " or";
  8145. }
  8146. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8147. }
  8148. //数据排序
  8149. $order_str = "time desc";
  8150. if (empty($page)) {
  8151. $start = 0;
  8152. $perpage = 1;
  8153. } else {
  8154. $start = ($page - 1) * $perpage;
  8155. }
  8156. $wh = array();
  8157. $w = $this->warehouse->find_all('1=1', 'id,title');
  8158. foreach ($w as $v) {
  8159. $wh[$v['id']] = $v['title'];
  8160. }
  8161. $wt = array();
  8162. $whlabel_type = $this->whlabel_type->find_all();
  8163. foreach ($whlabel_type as $v) {
  8164. $wt[$v['id']] = $v['title'];
  8165. }
  8166. $classid = $this->classid->sku();
  8167. $list = array();
  8168. $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');
  8169. foreach ($rows_r as $key => $value) {
  8170. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8171. $pm = $classid;
  8172. $jm = $classid;
  8173. $rows_r[$key]['enter'] = '入库';
  8174. $rows_r[$key]['time'] = $value['enter'];
  8175. if ($value['rktype'] == 1) {
  8176. $rows_r[$key]['rktype'] = '采购入库';
  8177. } else if ($value['rktype'] == 2) {
  8178. $rows_r[$key]['rktype'] = '盘盈调整';
  8179. } else if ($value['rktype'] == 3) {
  8180. $rows_r[$key]['rktype'] = '其他调整入库';
  8181. } else if ($value['rktype'] == 4) {
  8182. $rows_r[$key]['rktype'] = '其他调整入库';
  8183. } else if ($value['rktype'] == 5) {
  8184. $rows_r[$key]['rktype'] = '退库入库';
  8185. } else if ($value['rktype'] == 6) {
  8186. $rows_r[$key]['rktype'] = '退货可用入库';
  8187. } else if ($value['rktype'] == 7) {
  8188. $rows_r[$key]['rktype'] = '形态转换入库';
  8189. } else {
  8190. $rows_r[$key]['rktype'] = '';
  8191. }
  8192. $features = explode('-', trim($value['features'], '-'));
  8193. foreach ($features as $v) {
  8194. if (isset($typeclass[$v])) {
  8195. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8196. $pm[$typeclass[$v]['classid']] = $zh[0];
  8197. }
  8198. if (isset($typeclass[$v])) {
  8199. if (isset($jm[$typeclass[$v]['classid']])) {
  8200. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8201. }
  8202. }
  8203. }
  8204. $zh = implode(" ", $pm);
  8205. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8206. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8207. $rows_r[$key]['zh'] = $zh;
  8208. $jm = array_filter($jm);
  8209. $rows_r[$key]['features'] = implode("-", $jm);
  8210. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8211. }
  8212. $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');
  8213. foreach ($rows_c as $key => $value) {
  8214. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8215. $pm = $classid;
  8216. $jm = $classid;
  8217. $rows_c[$key]['time'] = $value['outk'];
  8218. $rows_c[$key]['outk'] = '出库';
  8219. if ($value['cktype'] == 1) {
  8220. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8221. } else if ($value['cktype'] == 2) {
  8222. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8223. } else if ($value['cktype'] == 3) {
  8224. $rows_c[$key]['cktype'] = '盘亏调整';
  8225. } else if ($value['cktype'] == 4) {
  8226. $rows_c[$key]['cktype'] = '其他调整出库';
  8227. } else if ($value['cktype'] == 5) {
  8228. $rows_c[$key]['cktype'] = '形态转换出库';
  8229. } else {
  8230. $rows_c[$key]['cktype'] = '';
  8231. }
  8232. unset($rows_c[$key]['state']);
  8233. $features = explode('-', trim($value['features'], '-'));
  8234. foreach ($features as $v) {
  8235. if (isset($typeclass[$v])) {
  8236. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8237. $pm[$typeclass[$v]['classid']] = $zh[0];
  8238. }
  8239. if (isset($typeclass[$v])) {
  8240. if (isset($jm[$typeclass[$v]['classid']])) {
  8241. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8242. }
  8243. }
  8244. }
  8245. $zh = implode(" ", $pm);
  8246. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8247. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8248. $rows_c[$key]['zh'] = $zh;
  8249. $jm = array_filter($jm);
  8250. $rows_c[$key]['features'] = implode("-", $jm);
  8251. $rows_c[$key]['number'] = 1;
  8252. }
  8253. $merged = $rows_r;
  8254. foreach ($rows_c as $key => $value) {
  8255. if (isset($merged[$key])) {
  8256. $merged[] = $value;
  8257. } else {
  8258. $merged[$key] = $value;
  8259. }
  8260. }
  8261. usort($merged, function ($a, $b) {
  8262. return $a['time'] - $b['time'];
  8263. });
  8264. foreach ($merged as $key => $value) {
  8265. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8266. }
  8267. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8268. $titlename = "<table border=1>
  8269. <tr align='center'>
  8270. <td>仓库</td>
  8271. <td>SKU</td>
  8272. <td>商品名称</td>
  8273. <td>仓库品名</td>
  8274. <td>料号</td>
  8275. <td>时间</td>
  8276. <td>操作</td>
  8277. <td>类型</td>
  8278. <td>数量</td>
  8279. <td>备注</td>
  8280. </tr>
  8281. </table>";
  8282. $filename = $title . ".xlsx";
  8283. $tail = "";
  8284. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  8285. }
  8286. }
  8287. /*************************************处理exceljs导出****************************************************/
  8288. public function _excelrjs(){
  8289. if (isset($_GET['excel'])) {
  8290. $category = $this->input->get('category', true);
  8291. $size = $this->input->get('size', true);
  8292. $grade = $this->input->get('grade', true);
  8293. $color = $this->input->get('color', true);
  8294. $lowe = $this->input->get('lowe', true);
  8295. $sku = $this->input->get('sku', true);
  8296. $warehouse = $this->input->get('warehouse', true);
  8297. $purchase = $this->input->get('purchase', true);
  8298. $ktime = $this->input->get('ktime', true);
  8299. $jtime = $this->input->get('jtime', true);
  8300. $ktime = strtotime($ktime);
  8301. $jtime = strtotime($jtime);
  8302. $where = "1=1";
  8303. $gj = "";
  8304. $ck = "";
  8305. if ($category) {
  8306. $where .= " and features like '%-$category-%'";
  8307. }
  8308. if ($size) {
  8309. $where .= " and features like '%-$size-%'";
  8310. }
  8311. if ($grade) {
  8312. $where .= " and features like '%-$grade-%'";
  8313. }
  8314. if ($color) {
  8315. $where .= " and features like '%-$color-%'";
  8316. }
  8317. if ($lowe) {
  8318. $where .= " and features like '%-$lowe-%'";
  8319. }
  8320. if ($warehouse) {
  8321. $where .= " and warehouse = '$warehouse'";
  8322. }
  8323. if ($purchase) {
  8324. $where .= " and purchase = '$purchase'";
  8325. }
  8326. if ($sku) {
  8327. $where .= " and sku = '$sku'";
  8328. }
  8329. if ($ktime && $jtime) {
  8330. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  8331. }
  8332. //数据排序
  8333. $order_str = "id desc";
  8334. if (empty($page)) {
  8335. $start = 0;
  8336. $perpage = 1;
  8337. } else {
  8338. $start = ($page - 1) * $perpage;
  8339. }
  8340. $list = array();
  8341. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  8342. foreach ($rows as $value) {
  8343. $ck = $this->warehouse->read($value['warehouse']);
  8344. $warehouse = $ck['title'];
  8345. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  8346. $retreatwarehouse = $tkck['title'];
  8347. $gy = $this->purchase->read($value['purchase']);
  8348. $purchase = $gy['title'];
  8349. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  8350. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  8351. }
  8352. if(empty($list)){
  8353. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8354. }else{
  8355. $final_list = [];
  8356. foreach($list as $v){
  8357. $final_list[] = array_values($v);
  8358. }
  8359. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  8360. array_unshift($final_list,[
  8361. "仓库","SKU","商品名称","时间","数量"
  8362. ]);
  8363. array_unshift($final_list,[
  8364. $title,"","","",""
  8365. ]);
  8366. $merges = [
  8367. [
  8368. "s"=>["r"=>0,"c"=>0],
  8369. "e"=>["r"=>0,"c"=>4]
  8370. ]
  8371. ];
  8372. $cols = [
  8373. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  8374. ];
  8375. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  8376. }
  8377. }
  8378. }
  8379. //出库、退库导出
  8380. public function _excelctjs()
  8381. {
  8382. $classid = $this->classid->sku();
  8383. $pm = $classid;
  8384. $typeclass = array();
  8385. $tc = $this->typeclass->find_all();
  8386. foreach ($tc as $v) {
  8387. $typeclass[$v['id']] = $v;
  8388. }
  8389. $prc = array();
  8390. $purchase = $this->purchase->find_all();
  8391. foreach ($purchase as $k => $v) {
  8392. $prc[$v['id']] = $v['title'];
  8393. }
  8394. if (isset($_GET['excel'])) {
  8395. $wh = array();
  8396. $w = $this->warehouse->find_all('1=1', 'id,title');
  8397. foreach ($w as $v) {
  8398. $wh[$v['id']] = $v['title'];
  8399. }
  8400. $type = $this->input->get('excel', true);
  8401. $category = $this->input->get('category', true);
  8402. $size = $this->input->get('size', true);
  8403. $grade = $this->input->get('grade', true);
  8404. $color = $this->input->get('color', true);
  8405. $lowe = $this->input->get('lowe', true);
  8406. $sku = $this->input->get('sku', true);
  8407. $title = $this->input->get('title', true);
  8408. $warehouse = $this->input->get('warehouse', true);
  8409. $purchase = $this->input->get('purchase', true);
  8410. $lacetype = $this->input->get('lacetype', true);
  8411. $haircap = $this->input->get('haircap', true);
  8412. $lacecolor = $this->input->get('lacecolor', true);
  8413. $density = $this->input->get('density', true);
  8414. $details = $this->input->get('details', true);
  8415. $state = $this->input->get('state', true);
  8416. $shop = $this->input->get('shop', true);
  8417. $hairnumber = $this->input->get('hairnumber', true);
  8418. $type_leixi = $this->input->get('type', true);
  8419. $cpbz = $this->input->get('cpbz', true);
  8420. $sm = $this->input->get('sm', true);
  8421. $sid = $this->input->get('sid', true);
  8422. $ktime = $this->input->get('ktime', true);
  8423. $jtime = $this->input->get('jtime', true);
  8424. $ktime = strtotime($ktime);
  8425. $jtime = strtotime($jtime);
  8426. //$where = " 1=1 ";
  8427. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  8428. $where = " sku != '' ";
  8429. $gj = "";
  8430. $ck = "";
  8431. if ($category) {
  8432. $where .= " and features like '%-$category-%'";
  8433. }
  8434. if ($size) {
  8435. $where .= " and features like '%-$size-%'";
  8436. }
  8437. if ($grade) {
  8438. $where .= " and features like '%-$grade-%'";
  8439. }
  8440. if ($color) {
  8441. $where .= " and features like '%-$color-%'";
  8442. }
  8443. if ($lowe) {
  8444. $where .= " and features like '%-$lowe-%'";
  8445. }
  8446. if ($warehouse) {
  8447. $where .= " and warehouse = '$warehouse'";
  8448. }
  8449. if ($purchase) {
  8450. $where .= " and purchase = '$purchase'";
  8451. }
  8452. if ($state) {
  8453. $where .= " and state = '$state'";
  8454. }
  8455. if ($lacetype) {
  8456. $where .= " and features like '%-$lacetype-%'";
  8457. }
  8458. if ($lacecolor) {
  8459. $where .= " and features like '%-$lacecolor-%'";
  8460. }
  8461. if ($density) {
  8462. $where .= " and features like '%-$density-%'";
  8463. }
  8464. if ($haircap) {
  8465. $where .= " and features like '%-$haircap-%'";
  8466. }
  8467. if ($details) {
  8468. $where .= " and details = '$details'";
  8469. }
  8470. if ($shop) {
  8471. $where .= " and shop like '%$shop%'";
  8472. }
  8473. if ($title) {
  8474. $title = trim($title, ' ');
  8475. $title = trim($title, ' ');
  8476. $where .= " and title like '%$title%'";
  8477. }
  8478. if (!empty($hairnumber)) {
  8479. $where .= " and features like '%-128-%' ";
  8480. if ($hairnumber < 0) {
  8481. $class_list = $this->typeclass->find_all('classid = 43');
  8482. foreach ($class_list as $v) {
  8483. $where .= " and features not like '%-" . $v['id'] . "-%'";
  8484. }
  8485. } else {
  8486. $where .= " and features like '%-$hairnumber-%'";
  8487. }
  8488. }
  8489. if ($type_leixi) {
  8490. $where .= " and type = '$type_leixi'";
  8491. }
  8492. if ($cpbz) {
  8493. $where .= " and cpbz like '%$cpbz%' ";
  8494. }
  8495. if ($sm) {
  8496. $where .= " and sm like '%$sm%' ";
  8497. }
  8498. if ($sku) {
  8499. $sku = trim($sku, ' ');
  8500. $sku = trim($sku, ' ');
  8501. $where .= " and sku like '%$sku%'";
  8502. }
  8503. if ($ktime && $jtime) {
  8504. if ($type == 1) {
  8505. $tl = '出库';
  8506. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  8507. } else if ($type == 2) {
  8508. $tl = '退库';
  8509. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  8510. } else if ($type == 3) {
  8511. $gj = " and enter > '$ktime' and enter < '$jtime'";
  8512. $ck = " and outk > '$ktime' and outk < '$jtime'";
  8513. } else if ($type == 4) {
  8514. $tl = '出库+零售';
  8515. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  8516. } else if ($type == 5) {
  8517. $tl = '零售';
  8518. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  8519. }
  8520. }
  8521. $sidwhere = '';
  8522. if ($sid) {
  8523. $sd = "";
  8524. $s = explode(',', trim($sid, ','));
  8525. foreach ($s as $value) {
  8526. $sd .= " id = " . $value . " or";
  8527. }
  8528. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8529. }
  8530. //数据排序
  8531. $order_str = "time desc";
  8532. if (empty($page)) {
  8533. $start = 0;
  8534. $perpage = 1;
  8535. } else {
  8536. $start = ($page - 1) * $perpage;
  8537. }
  8538. //取得信息列表
  8539. if ($type != 3 && $type != 5) {
  8540. if ($type == 1 || $type == 4) {
  8541. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  8542. foreach ($info_list as $key => $value) {
  8543. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8544. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8545. $warehouse = $this->warehouse->read($value['warehouse']);
  8546. $info_list[$key]['warehouse'] = $warehouse['title'];
  8547. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8548. $features = explode('-', trim($features, '-'));
  8549. $pm = $classid;
  8550. foreach ($features as $k => $v) {
  8551. if ($v != 0) {
  8552. if (!isset($typeclass[$v])) {
  8553. continue;
  8554. }
  8555. if (isset($pm[$typeclass[$v]['classid']])) {
  8556. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8557. $tz = explode('|', $typeclass[$v]['zh']);
  8558. $pm[$typeclass[$v]['classid']] = $tz[0];
  8559. } else {
  8560. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8561. }
  8562. }
  8563. }
  8564. }
  8565. $zh = implode(" ", $pm);
  8566. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8567. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8568. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8569. $info_list[$key]['features'] = $zh;
  8570. }
  8571. $final_list = [];
  8572. foreach($info_list as $k=>$v){
  8573. $number = "";
  8574. if(!empty($v['orderinfo'])){
  8575. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8576. if(!empty($tmp_info['number'])){
  8577. $number = $tmp_info['number'];
  8578. }
  8579. }
  8580. $final_list[] = [
  8581. 'warehouse'=>$v['warehouse'],
  8582. 'purchase'=>$v['purchase'],
  8583. 'sku'=>$v['sku'],
  8584. 'title'=>$v['title'],
  8585. 'features'=>$v['features'],
  8586. 'label'=>$v['label'],
  8587. 'orderinfo'=>$v['orderinfo'],
  8588. 'number'=>$number,
  8589. 'waybill'=>$v['waybill'],
  8590. 'outk'=>$v['outk'],
  8591. ];
  8592. }
  8593. } else {
  8594. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  8595. foreach ($info_list as $key => $value) {
  8596. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8597. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8598. $warehouse = $this->warehouse->read($value['warehouse']);
  8599. $info_list[$key]['warehouse'] = $warehouse['title'];
  8600. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8601. $features = explode('-', trim($features, '-'));
  8602. $pm = $classid;
  8603. foreach ($features as $k => $v) {
  8604. if ($v != 0) {
  8605. if (!isset($typeclass[$v])) {
  8606. continue;
  8607. }
  8608. if (isset($pm[$typeclass[$v]['classid']])) {
  8609. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8610. $tz = explode('|', $typeclass[$v]['zh']);
  8611. $pm[$typeclass[$v]['classid']] = $tz[0];
  8612. } else {
  8613. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8614. }
  8615. }
  8616. }
  8617. }
  8618. $zh = implode(" ", $pm);
  8619. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8620. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8621. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8622. $info_list[$key]['features'] = $zh;
  8623. }
  8624. $final_list = [];
  8625. foreach($info_list as $k=>$v){
  8626. $number = "";
  8627. if(!empty($v['orderinfo'])){
  8628. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8629. if(!empty($tmp_info['number'])){
  8630. $number = $tmp_info['number'];
  8631. }
  8632. }
  8633. $final_list[] = [
  8634. 'warehouse'=>$v['warehouse'],
  8635. 'purchase'=>$v['purchase'],
  8636. 'sku'=>$v['sku'],
  8637. 'title'=>$v['title'],
  8638. 'features'=>$v['features'],
  8639. 'label'=>$v['label'],
  8640. 'orderinfo'=>$v['orderinfo'],
  8641. 'number'=>$number,
  8642. 'waybill'=>$v['waybill'],
  8643. 'retreat'=>$v['retreat'],
  8644. ];
  8645. }
  8646. }
  8647. if(empty($final_list)){
  8648. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8649. }else{
  8650. $end_list = [];
  8651. foreach($final_list as $v){
  8652. $end_list[] = array_values($v);
  8653. }
  8654. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8655. array_unshift($end_list,[
  8656. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8657. ]);
  8658. array_unshift($end_list,[
  8659. $title,"","","","","","","","",""
  8660. ]);
  8661. $merges = [
  8662. [
  8663. "s"=>["r"=>0,"c"=>0],
  8664. "e"=>["r"=>0,"c"=>9]
  8665. ]
  8666. ];
  8667. $cols = [
  8668. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8669. ];
  8670. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8671. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8672. ] )));
  8673. }
  8674. } else if ($type == 5) {
  8675. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8676. foreach ($info_list as $key => $value) {
  8677. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8678. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8679. $warehouse = $this->warehouse->read($value['warehouse']);
  8680. $info_list[$key]['warehouse'] = $warehouse['title'];
  8681. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8682. $features = explode('-', trim($features, '-'));
  8683. $pm = $classid;
  8684. foreach ($features as $k => $v) {
  8685. if ($v != 0) {
  8686. if (!isset($typeclass[$v])) {
  8687. continue;
  8688. }
  8689. if (isset($pm[$typeclass[$v]['classid']])) {
  8690. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8691. $tz = explode('|', $typeclass[$v]['zh']);
  8692. $pm[$typeclass[$v]['classid']] = $tz[0];
  8693. } else {
  8694. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8695. }
  8696. }
  8697. }
  8698. }
  8699. $zh = implode(" ", $pm);
  8700. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8701. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8702. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8703. $info_list[$key]['features'] = $zh;
  8704. }
  8705. if(empty($info_list)){
  8706. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8707. }else{
  8708. $final_list = [];
  8709. foreach($info_list as $v){
  8710. $final_list[] = array_values($v);
  8711. }
  8712. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8713. array_unshift($final_list,[
  8714. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8715. ]);
  8716. array_unshift($final_list,[
  8717. $title,"","","","","","",
  8718. ]);
  8719. $merges = [
  8720. [
  8721. "s"=>["r"=>0,"c"=>0],
  8722. "e"=>["r"=>0,"c"=>6]
  8723. ]
  8724. ];
  8725. $cols = [
  8726. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8727. ];
  8728. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8729. }
  8730. } else {
  8731. $wh = array();
  8732. $w = $this->warehouse->find_all('1=1', 'id,title');
  8733. foreach ($w as $v) {
  8734. $wh[$v['id']] = $v['title'];
  8735. }
  8736. $wt = array();
  8737. $whlabel_type = $this->whlabel_type->find_all();
  8738. foreach ($whlabel_type as $v) {
  8739. $wt[$v['id']] = $v['title'];
  8740. }
  8741. $classid = $this->classid->sku();
  8742. $list = array();
  8743. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8744. foreach ($rows as $key => $value) {
  8745. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8746. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8747. $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');
  8748. $details = array();
  8749. $cpid = array();
  8750. $cpbz = array();
  8751. $c = 0;
  8752. $g = 0;
  8753. $x = 0;
  8754. $t = 0;
  8755. $s = 0;
  8756. $q = 0;
  8757. foreach ($sd as $k => $v) {
  8758. if ($v['state'] == 0) {
  8759. $c++;
  8760. }
  8761. if ($v['state'] != 9) {
  8762. $g++;
  8763. }
  8764. if ($v['outk'] > 1) {
  8765. $x++;
  8766. }
  8767. if ($v['retreat'] > 0) {
  8768. $t++;
  8769. }
  8770. if ($v['state'] == 8) {
  8771. $s++;
  8772. }
  8773. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8774. $q++;
  8775. }
  8776. $details[$v['details']] = $v['details'];
  8777. if ($v['cpid'] != 0) {
  8778. $cpid[$v['cpid']] = $v['cpid'];
  8779. }
  8780. if ($v['cpbz'] != '') {
  8781. $cpbz[$v['cpbz']] = $v['cpbz'];
  8782. }
  8783. }
  8784. if (isset($wt[$value['type']])) {
  8785. $rows[$key]['type'] = $wt[$value['type']];
  8786. } else {
  8787. $rows[$key]['type'] = '未设置';
  8788. }
  8789. $rows[$key]['details'] = implode("、", $details);
  8790. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8791. $ftime = time() - 15 * 24 * 3600;
  8792. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8793. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8794. $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);
  8795. $rows[$key]['c'] = $c;
  8796. $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);
  8797. $rows[$key]['t'] = $t;
  8798. $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'] . '"');
  8799. $rows[$key]['z'] = $z;
  8800. // $jm = $classid;
  8801. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8802. $features = explode('-', trim($features, '-'));
  8803. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8804. }
  8805. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8806. $final_list =[];
  8807. foreach($tmp_list as $k=>$v){
  8808. $final_list[] = [
  8809. "warehouse"=>$v['warehouse'],
  8810. "purchase"=>$v['purchase'],
  8811. "details"=>$v['details'],
  8812. "cpid"=>$v['cpid'],
  8813. "sku"=>$v['sku'],
  8814. "title"=>$v['title'],
  8815. "features"=>$v['pm'],
  8816. "cpbz"=>$v['cpbz'],
  8817. "sm"=>$v['sm'],
  8818. "type"=>$v['type'],
  8819. "g"=>$v["g"],
  8820. "c"=>$v["c"],
  8821. "x"=>$v["x"],
  8822. "t"=>$v["t"],
  8823. "z"=>$v["z"],
  8824. "jm"=>$v["jm"],
  8825. "weight"=>$v["weight"],
  8826. "asd"=>$v["asd"],
  8827. ];
  8828. }
  8829. if(empty($final_list)){
  8830. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8831. }else{
  8832. $end_list = [];
  8833. foreach($final_list as $v){
  8834. $end_list[] = array_values($v);
  8835. }
  8836. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8837. array_unshift($end_list,[
  8838. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8839. ]);
  8840. array_unshift($end_list,[
  8841. $title,"","","","","","","","","","","","","","","","","",""
  8842. ]);
  8843. $merges = [
  8844. [
  8845. "s"=>["r"=>0,"c"=>0],
  8846. "e"=>["r"=>0,"c"=>6]
  8847. ]
  8848. ];
  8849. $cols = [
  8850. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8851. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8852. ];
  8853. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8854. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8855. ])));
  8856. }
  8857. }
  8858. }
  8859. }
  8860. public function _exceljxcjs(){
  8861. $classid = $this->classid->sku();
  8862. $pm = $classid;
  8863. $typeclass = array();
  8864. $tc = $this->typeclass->find_all();
  8865. foreach ($tc as $v) {
  8866. $typeclass[$v['id']] = $v;
  8867. }
  8868. $prc = array();
  8869. $purchase = $this->purchase->find_all();
  8870. foreach ($purchase as $k => $v) {
  8871. $prc[$v['id']] = $v['title'];
  8872. }
  8873. if(!isset($_GET['excel'])){
  8874. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8875. }
  8876. $where = "sku != 'Preset'";
  8877. //数据排序
  8878. $order_str = "id desc";
  8879. if (empty($page)) {
  8880. $start = 0;
  8881. $perpage = 1;
  8882. } else {
  8883. $start = ($page - 1) * $perpage;
  8884. }
  8885. $category = $this->input->get('category', true);
  8886. $warehouse = $this->input->get('warehouse', true);
  8887. $excelid = $this->input->get('sid', true);
  8888. if ($category) {
  8889. $where .= " and features like '%-$category-%'";
  8890. }
  8891. if ($warehouse) {
  8892. $where .= " and warehouse = '$warehouse'";
  8893. }
  8894. $xzid = '';
  8895. if ($excelid) {
  8896. $excelid = explode(',', trim($excelid, ','));
  8897. foreach ($excelid as $key => $value) {
  8898. $xzid .= " id = " . $value . " or";
  8899. }
  8900. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8901. }
  8902. $wt = array();
  8903. $whlabel_type = $this->whlabel_type->find_all();
  8904. foreach ($whlabel_type as $v) {
  8905. $wt[$v['id']] = $v['title'];
  8906. }
  8907. $wh = array();
  8908. $w = $this->warehouse->find_all('1=1', 'id,title');
  8909. foreach ($w as $v) {
  8910. $wh[$v['id']] = $v['title'];
  8911. }
  8912. $list = array();
  8913. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8914. foreach ($rows as $key => $value) {
  8915. if (isset($wt[$value['type']])) {
  8916. $rows[$key]['type'] = $wt[$value['type']];
  8917. } else {
  8918. $rows[$key]['type'] = '未设置';
  8919. }
  8920. $bm = '03';
  8921. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8922. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8923. $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');
  8924. $details = array();
  8925. $cpid = array();
  8926. $cpbz = array();
  8927. $c = 0;
  8928. $g = 0;
  8929. $x = 0;
  8930. $t = 0;
  8931. $s = 0;
  8932. $q = 0;
  8933. foreach ($sd as $k => $v) {
  8934. if ($v['state'] == 0) {
  8935. $c++;
  8936. if ($v['cpid'] != 0) {
  8937. $cpid[$v['cpid']] = $v['cpid'];
  8938. }
  8939. if ($v['cpbz'] != '') {
  8940. $cpbz[$v['cpbz']] = $v['cpbz'];
  8941. }
  8942. }
  8943. if ($v['state'] != 9) {
  8944. $g++;
  8945. }
  8946. if ($v['state'] == 1) {
  8947. $x++;
  8948. }
  8949. if ($v['state'] == 2) {
  8950. $t++;
  8951. }
  8952. if ($v['state'] == 8) {
  8953. $s++;
  8954. }
  8955. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8956. $q++;
  8957. }
  8958. $details[$v['details']] = $v['details'];
  8959. }
  8960. $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'] . '"');
  8961. $rows[$key]['details'] = implode("、", $details);
  8962. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8963. $number = $value['number'];
  8964. $ftime = time() - 15 * 24 * 3600;
  8965. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8966. $rows[$key]['number'] = $g;
  8967. $rows[$key]['c'] = $c;
  8968. $rows[$key]['x'] = $x;
  8969. $rows[$key]['t'] = $t;
  8970. $rows[$key]['s'] = $s;
  8971. $rows[$key]['q'] = $q;
  8972. $rows[$key]['z'] = $z;
  8973. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8974. $features = explode('-', trim($features, '-'));
  8975. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8976. }
  8977. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8978. $final_list = [];
  8979. foreach ($list as $k => $v) {
  8980. if (empty($v['sku'])) {
  8981. continue;
  8982. }
  8983. $final_list[] = [
  8984. $v["warehouse"],
  8985. $v["purchase"],
  8986. $v["details"],
  8987. $v["cpid"],
  8988. $v["dbcontent"],
  8989. $v["sku"],
  8990. $v["bm"],
  8991. $v["jm"],
  8992. $v["title"],
  8993. $v["pm"],
  8994. $v["cpbz"],
  8995. $v["sm"],
  8996. $v["type"],
  8997. $v["number"],
  8998. $v["c"],
  8999. $v["x"],
  9000. $v["t"],
  9001. $v["s"],
  9002. $v["q"],
  9003. $v["z"],
  9004. $v['weight'],
  9005. ];
  9006. }
  9007. if(empty($final_list)){
  9008. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9009. }
  9010. $title = "总进销存统计表";
  9011. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  9012. $merges = [
  9013. [
  9014. "s"=>["r"=>0,"c"=>0],
  9015. "e"=>["r"=>0,"c"=>21]
  9016. ]
  9017. ];
  9018. $cols = [
  9019. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  9020. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  9021. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  9022. ];
  9023. array_unshift($final_list, $first_row);
  9024. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  9025. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9026. }
  9027. public function _summaryjs($arg_array)
  9028. {
  9029. $prc = array();
  9030. $purchase = $this->purchase->find_all();
  9031. foreach ($purchase as $k => $v) {
  9032. $prc[$v['id']] = $v['title'];
  9033. }
  9034. if (isset($_GET['excel'])) {
  9035. $ktime = $this->input->get('ktime', true);
  9036. $jtime = $this->input->get('jtime', true);
  9037. $ktime = strtotime($ktime);
  9038. $jtime = strtotime($jtime);
  9039. $where = "1=1";
  9040. if ($ktime && $jtime) {
  9041. $where .= " and outk > '$ktime' and outk < '$jtime'";
  9042. }
  9043. //数据排序
  9044. $order_str = "time desc";
  9045. if (empty($page)) {
  9046. $start = 0;
  9047. $perpage = 1;
  9048. } else {
  9049. $start = ($page - 1) * $perpage;
  9050. }
  9051. //取得信息列表
  9052. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  9053. foreach ($info_list as $key => $value) {
  9054. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  9055. $warehouse = $this->warehouse->read($value['warehouse']);
  9056. $info_list[$key]['warehouse'] = $warehouse['title'];
  9057. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  9058. $details = array();
  9059. $cpid = array();
  9060. foreach ($x as $k => $v) {
  9061. if ($v['details'] != '') {
  9062. $details[$v['details']] = $v['details'];
  9063. }
  9064. if ($v['cpid'] != 0) {
  9065. $cpid[$v['cpid']] = $v['cpid'];
  9066. }
  9067. }
  9068. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  9069. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  9070. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  9071. $info_list[$key]['s'] = $s;
  9072. $info_list[$key]['x'] = count($x);
  9073. }
  9074. if(empty($info_list)){
  9075. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9076. }
  9077. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  9078. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  9079. $merges = [
  9080. [
  9081. "s"=>["r"=>0,"c"=>0],
  9082. "e"=>["r"=>0,"c"=>7]
  9083. ]
  9084. ];
  9085. $cols = [
  9086. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  9087. ];
  9088. $final_list = [];
  9089. foreach($info_list as $k => $v){
  9090. $final_list[] = array_values($v);
  9091. }
  9092. array_unshift($final_list, $first_row);
  9093. array_unshift($final_list,[
  9094. $title,"","","","","","","","",
  9095. ]);
  9096. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9097. $titlename = "<table border=1>
  9098. <tr align='center'>
  9099. <td>仓库</td>
  9100. <td>供应商</td>
  9101. <td>出库位置</td>
  9102. <td>出库编码</td>
  9103. <td>SKU</td>
  9104. <td>产品名</td>
  9105. <td>总剩余库存</td>
  9106. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  9107. </tr>
  9108. </table>";
  9109. $filename = $title . ".xls";
  9110. $tail = "";
  9111. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  9112. }
  9113. }
  9114. public function _uckjs()
  9115. {
  9116. if (isset($_GET['excel'])) {
  9117. $tc = array();
  9118. $typeclass = $this->typeclass->find_all();
  9119. foreach ($typeclass as $v) {
  9120. $tc[$v['id']] = $v['zh'];
  9121. }
  9122. $first_row = [
  9123. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  9124. ];
  9125. $t = array();
  9126. $rq = '';
  9127. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  9128. $ts = $ts / (24 * 3600);
  9129. for ($i = 0; $i < $ts; $i++) {
  9130. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  9131. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  9132. }
  9133. $day_len = count($t);
  9134. $first_row[] = "本月出库";
  9135. $merges = [
  9136. ];
  9137. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  9138. $excel_key = 1;
  9139. $final_list = [];
  9140. foreach ($info_list as $k => $v) {
  9141. $features = explode('-', trim($v['features'], '-'));
  9142. if (!isset($features[3]) || !isset($features[4])) {
  9143. continue;
  9144. }
  9145. $tmp = [];
  9146. $tmp[0] = $tc[$features[0]]; //类型
  9147. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  9148. $tmp[2] = $tc[$features[4]]; //曲度
  9149. $tmp[3] = '';
  9150. if (isset($data[$k][1])) {
  9151. $tmp[3] .=$tmp[1];
  9152. }
  9153. if (isset($data[$k][2])) {
  9154. $tmp[3] .= $tmp[2];
  9155. }
  9156. if (isset($features[5])) {
  9157. $tmp[3] .= $tc[$features[5]];
  9158. }
  9159. if (isset($features[2])) {
  9160. $tmp[3] .= $tc[$features[2]];
  9161. }
  9162. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  9163. $tmp[4] = $v['sku'];
  9164. $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())) . '))'); //月初库存
  9165. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  9166. $tmp[7] ="";
  9167. $tmp[8] ="";
  9168. $byck = 0;
  9169. foreach ($t as $vv) {
  9170. $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));
  9171. $tmp[] = ($sl > 0) ? $sl : '';
  9172. $byck += $sl;
  9173. }
  9174. $tmp[] = ($byck > 0) ? $byck : '';
  9175. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  9176. // $ztrq = '';
  9177. // $ztsl = '';
  9178. // if (count($zt) > 0) {
  9179. // foreach ($zt as $vv) {
  9180. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  9181. // $ztsl .= $vv['num'] . '<br>';
  9182. // }
  9183. // }
  9184. if(empty($zt)){
  9185. $final_list[] = $tmp;
  9186. $excel_key = $excel_key + 1;
  9187. }else{
  9188. $len = count($zt);
  9189. if($len == 1){
  9190. $tmp[7] = $zt[0]['num'] ;
  9191. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  9192. $final_list[] = $tmp;
  9193. $excel_key = $excel_key + 1;
  9194. }else{
  9195. foreach($zt as $vv){
  9196. $tmp[7] = "";
  9197. $tmp[8] = "";
  9198. $tmp[7] = $vv['num'];
  9199. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  9200. $final_list[] = $tmp;
  9201. }
  9202. $merges[] = [
  9203. "s"=>["r"=>$excel_key,"c"=>0],
  9204. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  9205. ];
  9206. $merges[] = [
  9207. "s"=>["r"=>$excel_key,"c"=>1],
  9208. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  9209. ];
  9210. $merges[] = [
  9211. "s"=>["r"=>$excel_key,"c"=>2],
  9212. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  9213. ];
  9214. $merges[] = [
  9215. "s"=>["r"=>$excel_key,"c"=>3],
  9216. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  9217. ];
  9218. $merges[] = [
  9219. "s"=>["r"=>$excel_key,"c"=>4],
  9220. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  9221. ];
  9222. $merges[] = [
  9223. "s"=>["r"=>$excel_key,"c"=>5],
  9224. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  9225. ];
  9226. $merges[] = [
  9227. "s"=>["r"=>$excel_key,"c"=>6],
  9228. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  9229. ];
  9230. for($i=1;$i<=$day_len;$i++){
  9231. $merges[] = [
  9232. "s"=>["r"=>$excel_key,"c"=>8+$i],
  9233. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  9234. ];
  9235. }
  9236. $merges[] = [
  9237. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  9238. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  9239. ];
  9240. $excel_key = $excel_key + $len;
  9241. }
  9242. }
  9243. }
  9244. $title = "详情 " . date("Y-m-d", time());
  9245. if(empty($final_list)){
  9246. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9247. }
  9248. $cols = [
  9249. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9250. ];
  9251. array_unshift($final_list, $first_row);
  9252. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9253. }
  9254. }
  9255. public function _whlabelexcelzhjs(){
  9256. if(empty($_GET['excel'])){
  9257. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  9258. }
  9259. $where = "sku != 'Preset' and sku != '' ";
  9260. //数据排序
  9261. $order_str = "id desc";
  9262. if (empty($page)) {
  9263. $start = 0;
  9264. $perpage = 1;
  9265. } else {
  9266. $start = ($page - 1) * $perpage;
  9267. }
  9268. $category = $this->input->get('category', true);
  9269. $warehouse = $this->input->get('warehouse', true);
  9270. $excelid = $this->input->get('sid', true);
  9271. if ($category) {
  9272. $where .= " and features like '%-$category-%'";
  9273. }
  9274. if ($warehouse) {
  9275. $where .= " and warehouse = '$warehouse'";
  9276. }
  9277. $xzid = '';
  9278. if ($excelid) {
  9279. $excelid = explode(',', trim($excelid, ','));
  9280. foreach ($excelid as $key => $value) {
  9281. $xzid .= " id = " . $value . " or";
  9282. }
  9283. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  9284. }
  9285. $merges = [
  9286. [
  9287. "s"=>["r"=>0,"c"=>0],
  9288. "e"=>["r"=>0,"c"=>6]
  9289. ]
  9290. ];
  9291. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  9292. $excel_index = 2;
  9293. $final_list = [];
  9294. foreach ($rows as $key => $value) {
  9295. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  9296. $zh = '';
  9297. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  9298. // foreach ($zt_list as $v) {
  9299. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  9300. // }
  9301. $zt = array_sum(array_column($zt_list, 'num'));
  9302. $number = $value['number'];
  9303. $ftime = time() - 15 * 24 * 3600;
  9304. $warehouse = $this->warehouse->read($value['warehouse']);
  9305. // $rows[$key]['warehouse'] = $warehouse['title'];
  9306. // $rows[$key]['number'] = $c;
  9307. // $rows[$key]['features'] = $zh;
  9308. //$rows[$key]['hb'] = $c + $zt;
  9309. $tmp = [];
  9310. $tmp[0] = $warehouse['title'];
  9311. $tmp[1] = $value['sku'];
  9312. $tmp[2] = $value['title'];
  9313. $tmp[3] = $c;
  9314. $tmp[4] = "";
  9315. $tmp[5] = $c + $zt;
  9316. if(empty($zt_list)){
  9317. $tmp[4] = "";
  9318. $final_list[] = $tmp;
  9319. $excel_index = $excel_index + 1;
  9320. }else{
  9321. if(count($zt_list) == 1){
  9322. $tmp[4] = "";
  9323. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  9324. $final_list[] = $tmp;
  9325. $excel_index = $excel_index + 1;
  9326. }else{
  9327. $len = count($zt_list);
  9328. foreach ($zt_list as $v){
  9329. $tmp[4] = "";
  9330. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  9331. $final_list[] = $tmp;
  9332. }
  9333. $merges[] = [
  9334. "s"=>["r"=>$excel_index,"c"=>0],
  9335. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  9336. ];
  9337. $merges[] = [
  9338. "s"=>["r"=>$excel_index,"c"=>1],
  9339. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  9340. ];
  9341. $merges[] = [
  9342. "s"=>["r"=>$excel_index,"c"=>2],
  9343. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  9344. ];
  9345. $merges[] = [
  9346. "s"=>["r"=>$excel_index,"c"=>3],
  9347. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  9348. ];
  9349. $merges[] = [
  9350. "s"=>["r"=>$excel_index,"c"=>5],
  9351. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  9352. ];
  9353. $excel_index = $excel_index + $len;
  9354. }
  9355. }
  9356. }
  9357. $first_row = [
  9358. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  9359. ];
  9360. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  9361. if(empty($final_list)){
  9362. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9363. }
  9364. $cols = [
  9365. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  9366. ];
  9367. array_unshift($final_list, $first_row);
  9368. array_unshift($final_list, [
  9369. $title,"","","","",""
  9370. ]);
  9371. $end_list = [];
  9372. foreach ($final_list as $key => $value) {
  9373. $end_list[] = array_values($value);
  9374. }
  9375. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9376. }
  9377. //出库、退库导出
  9378. public function _dccrtypejs()
  9379. {
  9380. $classid = $this->classid->sku();
  9381. $pm = $classid;
  9382. $typeclass = array();
  9383. $tc = $this->typeclass->find_all();
  9384. foreach ($tc as $v) {
  9385. $typeclass[$v['id']] = $v;
  9386. }
  9387. $prc = array();
  9388. $purchase = $this->purchase->find_all();
  9389. foreach ($purchase as $k => $v) {
  9390. $prc[$v['id']] = $v['title'];
  9391. }
  9392. if (isset($_GET['sid'])) {
  9393. $wh = array();
  9394. $w = $this->warehouse->find_all('1=1', 'id,title');
  9395. foreach ($w as $v) {
  9396. $wh[$v['id']] = $v['title'];
  9397. }
  9398. $type = $this->input->get('excel', true);
  9399. $category = $this->input->get('category', true);
  9400. $size = $this->input->get('size', true);
  9401. $grade = $this->input->get('grade', true);
  9402. $color = $this->input->get('color', true);
  9403. $lowe = $this->input->get('lowe', true);
  9404. $sku = $this->input->get('sku', true);
  9405. $warehouse = $this->input->get('warehouse', true);
  9406. $lacetype = $this->input->get('lacetype', true);
  9407. $lacecolor = $this->input->get('lacecolor', true);
  9408. $density = $this->input->get('density', true);
  9409. $haircap = $this->input->get('haircap', true);
  9410. $purchase = $this->input->get('purchase', true);
  9411. $title = $this->input->get('title', true);
  9412. $state = $this->input->get('state', true);
  9413. $sid = $this->input->get('sid', true);
  9414. $ktime = $this->input->get('ktime', true);
  9415. $jtime = $this->input->get('jtime', true);
  9416. $ktime = strtotime($ktime);
  9417. $jtime = strtotime($jtime);
  9418. $where = "1=1";
  9419. $gj = "";
  9420. $ck = "";
  9421. if ($category) {
  9422. $where .= " and features like '%-$category-%'";
  9423. }
  9424. if ($size) {
  9425. $where .= " and features like '%-$size-%'";
  9426. }
  9427. if ($grade) {
  9428. $where .= " and features like '%-$grade-%'";
  9429. }
  9430. if ($color) {
  9431. $where .= " and features like '%-$color-%'";
  9432. }
  9433. if ($lowe) {
  9434. $where .= " and features like '%-$lowe-%'";
  9435. }
  9436. if ($warehouse) {
  9437. $where .= " and warehouse = '$warehouse'";
  9438. }
  9439. if ($purchase) {
  9440. $where .= " and purchase = '$purchase'";
  9441. }
  9442. if ($state) {
  9443. $where .= " and state = '$state'";
  9444. }
  9445. if ($lacetype) {
  9446. $where .= " and features like '%-$lacetype-%'";
  9447. }
  9448. if ($lacecolor) {
  9449. $where .= " and features like '%-$lacecolor-%'";
  9450. }
  9451. if ($density) {
  9452. $where .= " and features like '%-$density-%'";
  9453. }
  9454. if ($haircap) {
  9455. $where .= " and features like '%-$haircap-%'";
  9456. }
  9457. if ($title) {
  9458. $title = trim($title, ' ');
  9459. $title = trim($title, ' ');
  9460. $where .= " and title like '%$title%'";
  9461. }
  9462. if ($sku) {
  9463. $sku = trim($sku, ' ');
  9464. $sku = trim($sku, ' ');
  9465. $where .= " and sku like '%$sku%'";
  9466. }
  9467. if ($ktime && $jtime) {
  9468. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  9469. }
  9470. $sidwhere = '';
  9471. if ($sid) {
  9472. $sd = "";
  9473. $s = explode(',', trim($sid, ','));
  9474. foreach ($s as $value) {
  9475. $sd .= " id = " . $value . " or";
  9476. }
  9477. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  9478. }
  9479. //数据排序
  9480. $order_str = "time desc";
  9481. if (empty($page)) {
  9482. $start = 0;
  9483. $perpage = 1;
  9484. } else {
  9485. $start = ($page - 1) * $perpage;
  9486. }
  9487. $wh = array();
  9488. $w = $this->warehouse->find_all('1=1', 'id,title');
  9489. foreach ($w as $v) {
  9490. $wh[$v['id']] = $v['title'];
  9491. }
  9492. $wt = array();
  9493. $whlabel_type = $this->whlabel_type->find_all();
  9494. foreach ($whlabel_type as $v) {
  9495. $wt[$v['id']] = $v['title'];
  9496. }
  9497. $classid = $this->classid->sku();
  9498. $list = array();
  9499. $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');
  9500. foreach ($rows_r as $key => $value) {
  9501. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  9502. $pm = $classid;
  9503. $jm = $classid;
  9504. $rows_r[$key]['enter'] = '入库';
  9505. $rows_r[$key]['time'] = $value['enter'];
  9506. if ($value['rktype'] == 1) {
  9507. $rows_r[$key]['rktype'] = '采购入库';
  9508. } else if ($value['rktype'] == 2) {
  9509. $rows_r[$key]['rktype'] = '盘盈调整';
  9510. } else if ($value['rktype'] == 3) {
  9511. $rows_r[$key]['rktype'] = '其他调整入库';
  9512. } else if ($value['rktype'] == 4) {
  9513. $rows_r[$key]['rktype'] = '其他调整入库';
  9514. } else if ($value['rktype'] == 5) {
  9515. $rows_r[$key]['rktype'] = '退库入库';
  9516. } else if ($value['rktype'] == 6) {
  9517. $rows_r[$key]['rktype'] = '退货可用入库';
  9518. } else if ($value['rktype'] == 7) {
  9519. $rows_r[$key]['rktype'] = '形态转换入库';
  9520. } else {
  9521. $rows_r[$key]['rktype'] = '';
  9522. }
  9523. $features = explode('-', trim($value['features'], '-'));
  9524. foreach ($features as $v) {
  9525. if (isset($typeclass[$v])) {
  9526. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9527. $pm[$typeclass[$v]['classid']] = $zh[0];
  9528. }
  9529. if (isset($typeclass[$v])) {
  9530. if (isset($jm[$typeclass[$v]['classid']])) {
  9531. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9532. }
  9533. }
  9534. }
  9535. $zh = implode(" ", $pm);
  9536. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9537. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9538. $rows_r[$key]['zh'] = $zh;
  9539. $jm = array_filter($jm);
  9540. $rows_r[$key]['features'] = implode("-", $jm);
  9541. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  9542. }
  9543. $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');
  9544. foreach ($rows_c as $key => $value) {
  9545. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  9546. $pm = $classid;
  9547. $jm = $classid;
  9548. $rows_c[$key]['time'] = $value['outk'];
  9549. $rows_c[$key]['outk'] = '出库';
  9550. if ($value['cktype'] == 1) {
  9551. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  9552. } else if ($value['cktype'] == 2) {
  9553. $rows_c[$key]['cktype'] = '美国销售调货出库';
  9554. } else if ($value['cktype'] == 3) {
  9555. $rows_c[$key]['cktype'] = '盘亏调整';
  9556. } else if ($value['cktype'] == 4) {
  9557. $rows_c[$key]['cktype'] = '其他调整出库';
  9558. } else if ($value['cktype'] == 5) {
  9559. $rows_c[$key]['cktype'] = '形态转换出库';
  9560. } else {
  9561. $rows_c[$key]['cktype'] = '';
  9562. }
  9563. unset($rows_c[$key]['state']);
  9564. $features = explode('-', trim($value['features'], '-'));
  9565. foreach ($features as $v) {
  9566. if (isset($typeclass[$v])) {
  9567. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9568. $pm[$typeclass[$v]['classid']] = $zh[0];
  9569. }
  9570. if (isset($typeclass[$v])) {
  9571. if (isset($jm[$typeclass[$v]['classid']])) {
  9572. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9573. }
  9574. }
  9575. }
  9576. $zh = implode(" ", $pm);
  9577. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9578. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9579. $rows_c[$key]['zh'] = $zh;
  9580. $jm = array_filter($jm);
  9581. $rows_c[$key]['features'] = implode("-", $jm);
  9582. $rows_c[$key]['number'] = 1;
  9583. }
  9584. $merged = $rows_r;
  9585. foreach ($rows_c as $key => $value) {
  9586. if (isset($merged[$key])) {
  9587. $merged[] = $value;
  9588. } else {
  9589. $merged[$key] = $value;
  9590. }
  9591. }
  9592. usort($merged, function ($a, $b) {
  9593. return $a['time'] - $b['time'];
  9594. });
  9595. foreach ($merged as $key => $value) {
  9596. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9597. }
  9598. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9599. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9600. $cols = [
  9601. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9602. ];
  9603. $final_list= [];
  9604. foreach($merged as $key => $value){
  9605. $final_list[] = array_values($value) ;
  9606. }
  9607. if(empty($merged)){
  9608. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9609. }
  9610. array_unshift($final_list, $first_row);
  9611. $end_list = [];
  9612. foreach ($final_list as $key => $value) {
  9613. $end_list[] = array_values($value);
  9614. }
  9615. $merges = [];
  9616. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9617. }
  9618. }
  9619. public function _errorexceljs()
  9620. {
  9621. $post = $this->input->post(NULL, TRUE);
  9622. if (isset($_GET['page'])) {
  9623. $page = $this->input->get('page', true);
  9624. $perpage = $this->input->get('perpage', true);
  9625. $sku = $this->input->get('sku', true);
  9626. $warehouse = $this->input->get('warehouse', true);
  9627. $ktime = $this->input->get('ktime', true);
  9628. $jtime = $this->input->get('jtime', true);
  9629. $ktime = strtotime($ktime);
  9630. $jtime = strtotime($jtime);
  9631. $where = "sku != 'Preset'";
  9632. $gj = '';
  9633. if ($sku) {
  9634. $where .= " and sku like '%$sku%'";
  9635. } else {
  9636. if ($ktime && $jtime) {
  9637. $gj = " and time > '$ktime' and time < '$jtime'";
  9638. }
  9639. }
  9640. if ($warehouse) {
  9641. $where .= " and warehouse = '$warehouse'";
  9642. }
  9643. //数据排序
  9644. $order_str = "id desc";
  9645. if (empty($page)) {
  9646. $start = 0;
  9647. $perpage = 1;
  9648. } else {
  9649. $start = ($page - 1) * $perpage;
  9650. }
  9651. //取得信息列表
  9652. $rows = array();
  9653. $list = array();
  9654. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9655. foreach ($info_list as $value) {
  9656. $warehouse = $this->warehouse->read($value['warehouse']);
  9657. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9658. $number = $value['number'];
  9659. $ftime = time() - 15 * 24 * 3600;
  9660. if ($c < 1) {
  9661. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9662. }
  9663. }
  9664. $title = "0库存汇总";
  9665. $first_row = ["仓库","SKU","产品","当前库存"];
  9666. $cols = [
  9667. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9668. ];
  9669. $final_list= [];
  9670. foreach($list as $key => $value){
  9671. $final_list[] = array_values($value) ;
  9672. }
  9673. if(empty($final_list)){
  9674. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9675. }
  9676. array_unshift($final_list, $first_row);
  9677. $merges = [];
  9678. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9679. }
  9680. }
  9681. }