Whlabel.php 315 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299
  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. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. }else if ($arg == 'presetedittwo') //预设库存导入
  141. {
  142. $this->_presetedittwo($arg_array);
  143. } else if ($arg == 'summary') //汇总导出
  144. {
  145. $this->_summary($arg_array);
  146. } else if ($arg == 'manifest') //usps发货清单
  147. {
  148. $this->_manifest();
  149. } else if ($arg == 'abnormal') //占单异常
  150. {
  151. $this->_abnormal();
  152. } else if ($arg == 'error') //0库存SKU
  153. {
  154. $this->_error();
  155. } else if ($arg == 'errorexcel') //0库存SKU导出
  156. {
  157. $this->_errorexcel();
  158. } else if ($arg == 'db') {
  159. $this->_db();
  160. } else if ($arg == 'dbrk') {
  161. $this->_dbrk();
  162. } else if ($arg == 'whlabelczdc') {
  163. $this->_whlabelczdc();
  164. } else if ($arg == 'print') {
  165. $this->_print($arg_array);
  166. } else if ($arg == 'usaprint') {
  167. $this->_usaprint($arg_array);
  168. } else if ($arg == 'printck') {
  169. $this->_printck($arg_array);
  170. } else if ($arg == 'printrk') {
  171. $this->_printrk($arg_array);
  172. } else if ($arg == 'printxzrk') {
  173. $this->_printxzrk($arg_array);
  174. } else if ($arg == 'printexcel') {
  175. $this->_printexcel($arg_array);
  176. } else if ($arg == 'uck') {
  177. $this->_uck();
  178. } else if ($arg == 'whlabelexcelzh') {
  179. $this->_whlabelexcelzh();
  180. } else if ($arg == 'fc') {
  181. $this->_fc();
  182. } else if ($arg == 'fcmb') {
  183. $this->_fcmb();
  184. } else if ($arg == 'fcexcel') {
  185. $this->_fcexcel();
  186. } else if ($arg == 'fcjxc') {
  187. $this->_fcjxc($arg_array);
  188. } else if ($arg == '0kcdel') {
  189. $this->_0kcdel(); //导表删除0库存
  190. } else if ($arg == 'gbhtype') {
  191. $this->_gbhtype(); //更改备货状态
  192. } else if($arg == 'excelrjs'){
  193. $this->_excelrjs();
  194. } else if($arg == 'excelctjs'){
  195. $this->_excelctjs();
  196. }else if ($arg == 'exceljxcjs') //进销存信息导出
  197. {
  198. $this->_exceljxcjs();
  199. } else if ($arg == 'summaryjs') //汇总导出
  200. {
  201. $this->_summaryjs($arg_array);
  202. }else if($arg == 'uckjs'){
  203. $this->_uckjs();
  204. }else if ($arg == 'whlabelexcelzhjs') {
  205. $this->_whlabelexcelzhjs();
  206. }else if($arg == 'dccrtypejs'){
  207. $this->_dccrtypejs();
  208. }else if($arg == 'errorexceljs'){
  209. $this->_errorexceljs();
  210. }else if($arg == "w_t_cs"){
  211. $this->_w_t_cs(); //首页
  212. }else {
  213. $this->_index();
  214. }
  215. }
  216. public function _w_t_cs(){
  217. $vip = 0;
  218. if (isset($_SESSION['api'])) {
  219. $user = $this->user->get_api($_SESSION['api']);
  220. $fgshop = "";
  221. $sid = "";
  222. $usersp = explode('|', trim($user['shop'], '|'));
  223. foreach ($usersp as $value) {
  224. $fgshop .= " shop = " . $value . " or";
  225. $sid .= " id = " . $value . " or";
  226. }
  227. if ($user['vip'] == 1) {
  228. $vip = 1;
  229. }
  230. } else {
  231. header('Location: /');
  232. exit;
  233. }
  234. $prc = array();
  235. $purchase = $this->purchase->find_all();
  236. foreach ($purchase as $k => $v) {
  237. $prc[$v['id']] = $v['title'];
  238. }
  239. $company = array();
  240. $ct = $this->company->find_all();
  241. foreach ($ct as $k => $v) {
  242. $company[$v['id']] = $v['title'];
  243. }
  244. $sp = array();
  245. $s = $this->shop->find_all('1=1', 'id,shopname');
  246. foreach ($s as $v) {
  247. $sp[$v['id']] = $v['shopname'];
  248. }
  249. $wh = array();
  250. $w = $this->warehouse->find_all('1=1', 'id,title');
  251. foreach ($w as $v) {
  252. $wh[$v['id']] = $v['title'];
  253. }
  254. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  255. $this->data['shop'] = $wlshop;
  256. $this->data['vip'] = $vip;
  257. $this->_Template('whlabel_typejs', $this->data);
  258. }
  259. //管理
  260. public function _index()
  261. {
  262. $post = $this->input->post(NULL, TRUE);
  263. if (isset($post['page'])) {
  264. $page = $this->input->post('page', true);
  265. $perpage = $this->input->post('perpage', true);
  266. $sku = $this->input->post('sku', true);
  267. $number = $this->input->post('number', true);
  268. $warehouse = $this->input->post('warehouse', true);
  269. $purchase = $this->input->post('purchase', true);
  270. $orderinfo = $this->input->post('orderinfo', true);
  271. $waybill = $this->input->post('waybill', true);
  272. $category = $this->input->post('category', true);
  273. $size = $this->input->post('size', true);
  274. $grade = $this->input->post('grade', true);
  275. $color = $this->input->post('color', true);
  276. $lowe = $this->input->post('lowe', true);
  277. $state = $this->input->post('state', true);
  278. $label = $this->input->post('label', true);
  279. $timetk = $this->input->post('timetkk', true);
  280. $timetj = $this->input->post('timetjj', true);
  281. $timetk = strtotime($timetk);
  282. $timetj = strtotime($timetj);
  283. $where = "1=1 ";
  284. if ($timetk && $timetj) {
  285. $where .= " and time > '$timetk' and time < '$timetj'";
  286. }
  287. if ($sku) {
  288. $where .= " and sku = '$sku'";
  289. }
  290. if ($number) {
  291. $where .= " and number = '$number'";
  292. }
  293. if ($warehouse) {
  294. $where .= " and warehouse = '$warehouse'";
  295. }
  296. if ($purchase) {
  297. $where .= " and purchase = '$purchase'";
  298. }
  299. if ($orderinfo) {
  300. $where .= " and orderinfo = '$orderinfo'";
  301. }
  302. if ($waybill) {
  303. $where .= " and waybill = '$waybill'";
  304. }
  305. if ($category) {
  306. $where .= " and features like '%-$category-%'";
  307. }
  308. if ($size) {
  309. $where .= " and features like '%-$size-%'";
  310. }
  311. if ($grade) {
  312. $where .= " and features like '%-$grade-%'";
  313. }
  314. if ($color) {
  315. $where .= " and features like '%-$color-%'";
  316. }
  317. if ($lowe) {
  318. $where .= " and features like '%-$lowe-%'";
  319. }
  320. if ($label) {
  321. $where .= " and label = '$label'";
  322. }
  323. if ($state != '') {
  324. $where .= " and state = '$state'";
  325. }
  326. //数据排序
  327. $order_str = "time desc";
  328. if (empty($page)) {
  329. $start = 0;
  330. $perpage = 1;
  331. } else {
  332. $start = ($page - 1) * $perpage;
  333. }
  334. //取得信息列表
  335. $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);
  336. foreach ($info_list as $key => $value) {
  337. $warehouse = $this->warehouse->read($value['warehouse']);
  338. $info_list[$key]['warehouse'] = $warehouse['title'];
  339. $purchase = $this->purchase->read($value['purchase']);
  340. $info_list[$key]['purchase'] = $purchase['title'];
  341. if ($value['enter'] != 0) {
  342. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  343. } else {
  344. $info_list[$key]['enter'] = "";
  345. }
  346. if ($value['outk'] != 0) {
  347. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  348. } else {
  349. $info_list[$key]['outk'] = "";
  350. }
  351. if ($value['printing'] != 0) {
  352. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  353. } else {
  354. $info_list[$key]['printing'] = "";
  355. }
  356. if ($value['orderinfo'] == 0) {
  357. $info_list[$key]['orderinfo'] = "";
  358. }
  359. if ($value['waybill'] == 0) {
  360. $info_list[$key]['waybill'] = "";
  361. }
  362. if ($value['state'] == 0) {
  363. $info_list[$key]['state'] = "在库";
  364. } else if ($value['state'] == 1) {
  365. $info_list[$key]['state'] = "出库";
  366. } else if ($value['state'] == 2) {
  367. $info_list[$key]['state'] = "退库";
  368. } else if ($value['state'] == 3) {
  369. $info_list[$key]['state'] = "调拨中";
  370. } else if ($value['state'] == 4) {
  371. $info_list[$key]['state'] = "再加工";
  372. } else if ($value['state'] == 5) {
  373. $info_list[$key]['state'] = "维修中";
  374. } else if ($value['state'] == 6) {
  375. $info_list[$key]['state'] = "盘亏";
  376. } else if ($value['state'] == 7) {
  377. $info_list[$key]['state'] = "更换标签";
  378. } else if ($value['state'] == 8) {
  379. $info_list[$key]['state'] = "其它";
  380. } else if ($value['state'] == 9) {
  381. $info_list[$key]['state'] = "预设";
  382. } else if ($value['state'] == 10) {
  383. $info_list[$key]['state'] = "美店零售";
  384. }
  385. if ($value['text'] == "") {
  386. $info_list[$key]['text'] = "";
  387. }
  388. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  389. }
  390. $total = $this->whlabel->find_count($where);
  391. $pagenum = ceil($total / $perpage);
  392. $over = $total - ($start + $perpage);
  393. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  394. echo json_encode($rows);
  395. exit;
  396. }
  397. if (isset($post['outsku'])) {
  398. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  399. $cz = $this->input->post('cz', true);
  400. if ($cz == '1') {
  401. $sku = $this->input->post('outsku', true);
  402. if ($sku) {
  403. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  404. if (count($data) < 1) {
  405. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  406. exit;
  407. }
  408. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  409. echo json_encode(array('success' => true));
  410. exit;
  411. }
  412. } else {
  413. $sku = $this->input->post('outsku', true);
  414. if ($sku) {
  415. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  416. if (count($data) < 1) {
  417. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  418. exit;
  419. }
  420. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  421. echo json_encode(array('success' => true));
  422. exit;
  423. }
  424. }
  425. }
  426. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  427. $this->_Template('whlabel', $this->data);
  428. }
  429. //在库标签
  430. public function _existence()
  431. {
  432. $post = $this->input->post(NULL, TRUE);
  433. if (isset($post['s'])) {
  434. $id_arr = $this->input->post('s');
  435. $id_arr = explode(',', $id_arr);
  436. if (!$id_arr) {
  437. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  438. exit;
  439. }
  440. //循环删除记录
  441. foreach ($id_arr as $v) {
  442. $sid = $this->whlabel->read($v);
  443. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  444. if ($count > 0) {
  445. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  446. exit;
  447. }
  448. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  449. if (count($zt) > 0) {
  450. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  451. exit;
  452. }
  453. $this->whlabel->remove($v);
  454. }
  455. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  456. exit;
  457. }
  458. if (isset($post['page'])) {
  459. $page = $this->input->post('page', true);
  460. $perpage = $this->input->post('perpage', true);
  461. $warehouse = $this->input->post('warehouse', true);
  462. $label = $this->input->post('label', true);
  463. $where = "1=1 and state = 0";
  464. if ($warehouse) {
  465. $where .= " and warehouse = '$warehouse'";
  466. }
  467. if ($label) {
  468. $where .= " and label = '$label'";
  469. }
  470. //数据排序
  471. $order_str = "time asc";
  472. if (empty($page)) {
  473. $start = 0;
  474. $perpage = 1;
  475. } else {
  476. $start = ($page - 1) * $perpage;
  477. }
  478. //取得信息列表
  479. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  480. foreach ($info_list as $key => $value) {
  481. if ($value['enter'] != 0) {
  482. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  483. } else {
  484. $info_list[$key]['enter'] = "";
  485. }
  486. if ($value['printing'] != 0) {
  487. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  488. } else {
  489. $info_list[$key]['printing'] = "";
  490. }
  491. }
  492. $total = $this->whlabel->find_count($where);
  493. $pagenum = ceil($total / $perpage);
  494. $over = $total - ($start + $perpage);
  495. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  496. echo json_encode($rows);
  497. exit;
  498. }
  499. $this->_Template('whlabel_existence', $this->data);
  500. }
  501. //进销存浏览
  502. public function _typedy($arg_array)
  503. {
  504. $prc = array();
  505. $purchase = $this->purchase->find_all();
  506. foreach ($purchase as $k => $v) {
  507. $prc[$v['id']] = $v['title'];
  508. }
  509. $post = $this->input->post(NULL, TRUE);
  510. if (isset($post['page'])) {
  511. $page = $this->input->post('page', true);
  512. $perpage = $this->input->post('perpage', true);
  513. $category = $this->input->post('category', true);
  514. $size = $this->input->post('size', true);
  515. $grade = $this->input->post('grade', true);
  516. $color = $this->input->post('color', true);
  517. $lowe = $this->input->post('lowe', true);
  518. $sku = $this->input->post('sku');
  519. $title = $this->input->post('title');
  520. $warehouse = $this->input->post('warehouse', true);
  521. $usa = $this->input->post('usa', true);
  522. $purchase = $this->input->post('purchase', true);
  523. $lacetype = $this->input->post('lacetype', true);
  524. $haircap = $this->input->post('haircap', true);
  525. $density = $this->input->post('density', true);
  526. $details = $this->input->post('details', true);
  527. $state = $this->input->post('state', true);
  528. $lacecolor = $this->input->post('lacecolor', true);
  529. $hairnumber = $this->input->post('hairnumber', true);
  530. $cklx = $this->input->post('cklx', true);
  531. $ktime = $this->input->post('ktime', true);
  532. $jtime = $this->input->post('jtime', true);
  533. $sm = $this->input->post('sm', true);
  534. $cpbz = $this->input->post('cpbz', true);
  535. $type = $this->input->post('type', true);
  536. $ktime = strtotime($ktime);
  537. $jtime = strtotime($jtime);
  538. $where = "1=1";
  539. $gj = "";
  540. $ck = "";
  541. if ($usa) {
  542. if (!$warehouse) {
  543. $where .= " and (warehouse = '5' or warehouse = '8')";
  544. }
  545. }
  546. if ($warehouse) {
  547. $where .= " and warehouse = '$warehouse'";
  548. }
  549. if ($details) {
  550. $where .= " and details = '$details'";
  551. }
  552. if ($purchase) {
  553. $where .= " and purchase = '$purchase'";
  554. }
  555. if (isset($state)) {
  556. if($state >-1){
  557. $where .= " and state = '$state'";
  558. }
  559. }
  560. if ($lacetype) {
  561. $where .= " and features like '%-$lacetype-%'";
  562. }
  563. if ($category) {
  564. $where .= " and features like '%-$category-%'";
  565. }
  566. if ($size) {
  567. $where .= " and features like '%-$size-%'";
  568. }
  569. if ($grade) {
  570. $where .= " and features like '%-$grade-%'";
  571. }
  572. if ($color) {
  573. $where .= " and features like '%-$color-%'";
  574. }
  575. if ($lowe) {
  576. $where .= " and features like '%-$lowe-%'";
  577. }
  578. if ($haircap) {
  579. $where .= " and features like '%-$haircap-%'";
  580. }
  581. if ($density) {
  582. $where .= " and features like '%-$density-%'";
  583. }
  584. if ($lacecolor) {
  585. $where .= " and features like '%-$lacecolor-%'";
  586. }
  587. if($sm){
  588. $where .= " and sm like '%".$sm."%'";
  589. }
  590. if($cpbz){
  591. $where .= " and cpbz like '%".$cpbz."%'";
  592. }
  593. if($type){
  594. $where .= " and type = ".$type."";
  595. }
  596. if (!empty($hairnumber)) {
  597. $where .= " and features like '%-128-%' ";
  598. if ($hairnumber < 0) {
  599. $class_list = $this->typeclass->find_all('classid = 43');
  600. foreach ($class_list as $v) {
  601. $where .= " and features not like '%-" . $v['id'] . "-%'";
  602. }
  603. } else {
  604. $where .= " and features like '%-$hairnumber-%'";
  605. }
  606. }
  607. $where_add = '';
  608. if ($cklx) {
  609. $shop = $this->shop->read($cklx);
  610. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  611. }
  612. if ($ktime && $jtime) {
  613. $gj = " and enter > '$ktime' and enter < '$jtime'";
  614. $ck = " and outk > '$ktime' and outk < '$jtime'";
  615. }
  616. //数据排序
  617. $order_str = "id desc";
  618. if (empty($page)) {
  619. $start = 0;
  620. $perpage = 1;
  621. } else {
  622. $start = ($page - 1) * $perpage;
  623. }
  624. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  625. if ($sku) {
  626. $sku = trim($sku, ' ');
  627. $sku = trim($sku, ' ');
  628. $where .= " and sku like '%$sku%'";
  629. $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);
  630. } else if ($title) {
  631. $title = trim($title, ' ');
  632. $title = trim($title, ' ');
  633. $where .= " and title like '%$title%'";
  634. $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);
  635. } else {
  636. //$where .= " and time > '$ktime' and time < '$jtime'";
  637. $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);
  638. }
  639. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  640. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  641. foreach ($info_list as $k => $v) {
  642. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  643. unset($info_list[$k]['pm']);
  644. unset($info_list[$k]['jm']);
  645. unset($info_list[$k]['bm']);
  646. }
  647. //取得信息列表
  648. $rows = array();
  649. $list = array();
  650. foreach ($info_list as $key => $value) {
  651. $warehouse = $this->warehouse->read($value['warehouse']);
  652. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  653. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  654. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  655. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  656. $info_list[$key]['label'] = $value['sm'];
  657. $number = $value['number'];
  658. $ftime = time() - 15 * 24 * 3600;
  659. $info_list[$key]['warehouse'] = $warehouse['title'];
  660. $info_list[$key]['features'] = count($c);
  661. $z = count($z); //查看订单号
  662. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  663. $ztdata = '';
  664. if (count($zt) > 0) {
  665. foreach ($zt as $vv) {
  666. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  667. }
  668. }
  669. $info_list[$key]['number'] = $ztdata;
  670. $info_list[$key]['sm'] = $z;
  671. $details = array();
  672. $cpid = array();
  673. foreach ($c as $k => $v) {
  674. $details[$v['details']] = $v['details'];
  675. if ($v['cpid'] != 0) {
  676. $cpid[$v['cpid']] = $v['cpid'];
  677. }
  678. }
  679. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  680. if ($value['shop'] != '') {
  681. $shop = explode(',', trim($value['shop'], ','));
  682. $shop = $this->shop->read($shop[0]);
  683. $info_list[$key]['shop'] = $shop['shopname'];
  684. }
  685. }
  686. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  687. $pagenum = ceil($total / $perpage);
  688. $over = $total - ($start + $perpage);
  689. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  690. echo json_encode($rows);
  691. exit;
  692. }
  693. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  694. $this->_Template('whlabel_typedy', $this->data);
  695. }
  696. //进销存浏览
  697. public function _typedy_ck($arg_array)
  698. {
  699. $prc = array();
  700. $purchase = $this->purchase->find_all();
  701. foreach ($purchase as $k => $v) {
  702. $prc[$v['id']] = $v['title'];
  703. }
  704. $post = $this->input->post(NULL, TRUE);
  705. if (isset($post['page'])) {
  706. $page = $this->input->post('page', true);
  707. $perpage = $this->input->post('perpage', true);
  708. $category = $this->input->post('category', true);
  709. $size = $this->input->post('size', true);
  710. $grade = $this->input->post('grade', true);
  711. $color = $this->input->post('color', true);
  712. $lowe = $this->input->post('lowe', true);
  713. $sku = $this->input->post('sku');
  714. $title = $this->input->post('title');
  715. $warehouse = $this->input->post('warehouse', true);
  716. $usa = $this->input->post('usa', true);
  717. $purchase = $this->input->post('purchase', true);
  718. $lacetype = $this->input->post('lacetype', true);
  719. $haircap = $this->input->post('haircap', true);
  720. $density = $this->input->post('density', true);
  721. $details = $this->input->post('details', true);
  722. $state = $this->input->post('state', true);
  723. $lacecolor = $this->input->post('lacecolor', true);
  724. $cklx = $this->input->post('cklx', true);
  725. $ktime = $this->input->post('ktime', true);
  726. $jtime = $this->input->post('jtime', true);
  727. $ktime = strtotime($ktime);
  728. $jtime = strtotime($jtime);
  729. $where = "1=1";
  730. $gj = "";
  731. $ck = "";
  732. if ($lacetype) {
  733. $where .= " and features like '%-$lacetype-%'";
  734. }
  735. if ($category) {
  736. $where .= " and features like '%-$category-%'";
  737. }
  738. if ($size) {
  739. $where .= " and features like '%-$size-%'";
  740. }
  741. if ($grade) {
  742. $where .= " and features like '%-$grade-%'";
  743. }
  744. if ($color) {
  745. $where .= " and features like '%-$color-%'";
  746. }
  747. if ($lowe) {
  748. $where .= " and features like '%-$lowe-%'";
  749. }
  750. if ($haircap) {
  751. $where .= " and features like '%-$haircap-%'";
  752. }
  753. if ($density) {
  754. $where .= " and features like '%-$density-%'";
  755. }
  756. if ($lacecolor) {
  757. $where .= " and features like '%-$lacecolor-%'";
  758. }
  759. if ($usa) {
  760. if (!$warehouse) {
  761. $where .= " and (warehouse = '5' or warehouse = '8')";
  762. }
  763. }
  764. if ($warehouse) {
  765. $where .= " and warehouse = '$warehouse'";
  766. }
  767. if ($details) {
  768. $where .= " and details = '$details'";
  769. }
  770. if ($purchase) {
  771. $where .= " and purchase = '$purchase'";
  772. }
  773. if ($state) {
  774. $where .= " and state = '$state'";
  775. }
  776. $where_add = '';
  777. if ($cklx) {
  778. $shop = $this->shop->read($cklx);
  779. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  780. }
  781. if ($ktime && $jtime) {
  782. $gj = " and enter > '$ktime' and enter < '$jtime'";
  783. $ck = " and outk > '$ktime' and outk < '$jtime'";
  784. }
  785. //数据排序
  786. $order_str = "id desc";
  787. if (empty($page)) {
  788. $start = 0;
  789. $perpage = 1;
  790. } else {
  791. $start = ($page - 1) * $perpage;
  792. }
  793. if ($sku) {
  794. $sku = trim($sku, ' ');
  795. $sku = trim($sku, ' ');
  796. $where .= " and sku like '%$sku%'";
  797. $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);
  798. } else if ($title) {
  799. $title = trim($title, ' ');
  800. $title = trim($title, ' ');
  801. $where .= " and title like '%$title%'";
  802. $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);
  803. } else {
  804. //$where .= " and time > '$ktime' and time < '$jtime'";
  805. $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);
  806. }
  807. //取得信息列表
  808. $rows = array();
  809. $list = array();
  810. foreach ($info_list as $key => $value) {
  811. $warehouse = $this->warehouse->read($value['warehouse']);
  812. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  813. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  814. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  815. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  816. $ftime = time() - 15 * 24 * 3600;
  817. $info_list[$key]['warehouse'] = $warehouse['title'];
  818. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  819. //$z = count($z);//查看订单号
  820. //$info_list[$key]['zd'] = $z;
  821. $details = array();
  822. $cpid = array();
  823. foreach ($c as $k => $v) {
  824. $details[$v['details']] = $v['details'];
  825. if ($v['cpid'] != 0) {
  826. $cpid[$v['cpid']] = $v['cpid'];
  827. }
  828. }
  829. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  830. if ($value['shop'] != '') {
  831. $shop = explode(',', trim($value['shop'], ','));
  832. $shop = $this->shop->read($shop[0]);
  833. $info_list[$key]['shop'] = $shop['shopname'];
  834. }
  835. }
  836. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  837. $pagenum = ceil($total / $perpage);
  838. $over = $total - ($start + $perpage);
  839. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  840. echo json_encode($rows);
  841. exit;
  842. }
  843. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  844. $this->_Template('whlabel_typedy_ck', $this->data);
  845. }
  846. public function _typeck($arg_array)
  847. {
  848. $prc = array();
  849. $purchase = $this->purchase->find_all();
  850. foreach ($purchase as $k => $v) {
  851. $prc[$v['id']] = $v['title'];
  852. }
  853. $post = $this->input->post(NULL, TRUE);
  854. if (isset($post['page'])) {
  855. $page = $this->input->post('page', true);
  856. $perpage = $this->input->post('perpage', true);
  857. $category = $this->input->post('category', true);
  858. $size = $this->input->post('size', true);
  859. $grade = $this->input->post('grade', true);
  860. $color = $this->input->post('color', true);
  861. $lacecolor = $this->input->post('lacecolor', true);
  862. $lowe = $this->input->post('lowe', true);
  863. $sku = $this->input->post('sku');
  864. $title = $this->input->post('title');
  865. $warehouse = 13;
  866. $usa = $this->input->post('usa', true);
  867. $purchase = $this->input->post('purchase', true);
  868. $lacetype = $this->input->post('lacetype', true);
  869. $haircap = $this->input->post('haircap', true);
  870. $density = $this->input->post('density', true);
  871. $details = $this->input->post('details', true);
  872. $state = $this->input->post('state', true);
  873. $ktime = $this->input->post('ktime', true);
  874. $jtime = $this->input->post('jtime', true);
  875. $ktime = strtotime($ktime);
  876. $jtime = strtotime($jtime);
  877. $where = "1=1";
  878. $gj = "";
  879. $ck = "";
  880. if ($lacetype) {
  881. $where .= " and features like '%-$lacetype-%'";
  882. }
  883. if ($category) {
  884. $where .= " and features like '%-$category-%'";
  885. }
  886. if ($size) {
  887. $where .= " and features like '%-$size-%'";
  888. }
  889. if ($grade) {
  890. $where .= " and features like '%-$grade-%'";
  891. }
  892. if ($color) {
  893. $where .= " and features like '%-$color-%'";
  894. }
  895. if ($lacecolor) {
  896. $where .= " and features like '%-$lacecolor-%'";
  897. }
  898. if ($lowe) {
  899. $where .= " and features like '%-$lowe-%'";
  900. }
  901. if ($haircap) {
  902. $where .= " and features like '%-$haircap-%'";
  903. }
  904. if ($density) {
  905. $where .= " and features like '%-$density-%'";
  906. }
  907. if ($warehouse) {
  908. $where .= " and warehouse = '$warehouse'";
  909. }
  910. if ($details) {
  911. $where .= " and details = '$details'";
  912. }
  913. if ($purchase) {
  914. $where .= " and purchase = '$purchase'";
  915. }
  916. if ($state) {
  917. $where .= " and state = '$state'";
  918. }
  919. if ($ktime && $jtime) {
  920. $gj = " and enter > '$ktime' and enter < '$jtime'";
  921. $ck = " and outk > '$ktime' and outk < '$jtime'";
  922. }
  923. //数据排序
  924. $order_str = "id desc";
  925. if (empty($page)) {
  926. $start = 0;
  927. $perpage = 1;
  928. } else {
  929. $start = ($page - 1) * $perpage;
  930. }
  931. if ($sku) {
  932. $sku = trim($sku, ' ');
  933. $sku = trim($sku, ' ');
  934. $where .= " and sku like '%$sku%'";
  935. } else if ($title) {
  936. $title = trim($title, ' ');
  937. $title = trim($title, ' ');
  938. $where .= " and title like '%$title%'";
  939. }
  940. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  941. //取得信息列表
  942. $t = array();
  943. $typeclass = $this->typeclass->find_all();
  944. foreach ($typeclass as $v) {
  945. $t[$v['id']] = $v;
  946. }
  947. $rows = array();
  948. $list = array();
  949. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  950. foreach ($info_list as $key => $value) {
  951. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  952. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  953. $warehouse = $this->warehouse->read($value['warehouse']);
  954. $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');
  955. $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'] . '"');
  956. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  957. $number = $value['number'];
  958. $ftime = time() - 15 * 24 * 3600;
  959. $z = count($z); //查看订单号
  960. $info_list[$key]['warehouse'] = $warehouse['title'];
  961. $info_list[$key]['features'] = count($c);
  962. $info_list[$key]['number'] = $z;
  963. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  964. $details = array();
  965. $cpid = array();
  966. foreach ($c as $k => $v) {
  967. $details[$v['details']] = $v['details'];
  968. if ($v['cpid'] != 0) {
  969. $cpid[$v['cpid']] = $v['cpid'];
  970. }
  971. }
  972. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  973. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  974. unset($info_list[$key]['pm']);
  975. unset($info_list[$key]['jm']);
  976. unset($info_list[$key]['bm']);
  977. }
  978. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  979. $pagenum = ceil($total / $perpage);
  980. $over = $total - ($start + $perpage);
  981. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  982. echo json_encode($rows);
  983. exit;
  984. }
  985. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  986. $this->_Template('whlabel_typeck', $this->data);
  987. }
  988. //进销存导出
  989. public function _whlabeckdc()
  990. {
  991. $prc = array();
  992. $purchase = $this->purchase->find_all();
  993. foreach ($purchase as $k => $v) {
  994. $prc[$v['id']] = $v['title'];
  995. }
  996. if (isset($_GET['excel'])) {
  997. $where = "sku != 'Preset'";
  998. //数据排序
  999. $order_str = "id desc";
  1000. if (empty($page)) {
  1001. $start = 0;
  1002. $perpage = 1;
  1003. } else {
  1004. $start = ($page - 1) * $perpage;
  1005. }
  1006. $category = $this->input->get('category', true);
  1007. $color = $this->input->get('color', true);
  1008. $lowe = $this->input->get('lowe', true);
  1009. $lacetype = $this->input->get('lacetype', true);
  1010. $size = $this->input->get('size', true);
  1011. $density = $this->input->get('density', true);
  1012. $haircap = $this->input->get('haircap', true);
  1013. $sku = $this->input->get('sku', true);
  1014. $details = $this->input->get('details', true);
  1015. $warehouse = 13;
  1016. $excelid = $this->input->get('sid', true);
  1017. if ($category) {
  1018. $where .= " and features like '%-$category-%'";
  1019. }
  1020. if ($color) {
  1021. $where .= " and features like '%-$color-%'";
  1022. }
  1023. if ($lowe) {
  1024. $where .= " and features like '%-$lowe-%'";
  1025. }
  1026. if ($lacetype) {
  1027. $where .= " and features like '%-$lacetype-%'";
  1028. }
  1029. if ($size) {
  1030. $where .= " and features like '%-$size-%'";
  1031. }
  1032. if ($density) {
  1033. $where .= " and features like '%-$density-%'";
  1034. }
  1035. if ($haircap) {
  1036. $where .= " and features like '%-$haircap-%'";
  1037. }
  1038. if ($warehouse) {
  1039. $where .= " and warehouse = '$warehouse'";
  1040. }
  1041. if ($sku) {
  1042. $where .= " and sku like '%$sku%'";
  1043. }
  1044. if ($details) {
  1045. $where .= " and details = '$details'";
  1046. }
  1047. $xzid = '';
  1048. if ($excelid) {
  1049. $excelid = explode(',', trim($excelid, ','));
  1050. foreach ($excelid as $key => $value) {
  1051. $xzid .= " id = " . $value . " or";
  1052. }
  1053. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1054. }
  1055. //取得信息列表
  1056. /**
  1057. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1058. $rows = array();$list = array();
  1059. foreach ($info_list as $key=>$value)
  1060. {
  1061. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1062. }
  1063. **/
  1064. $wh = array();
  1065. $w = $this->warehouse->find_all('1=1', 'id,title');
  1066. foreach ($w as $v) {
  1067. $wh[$v['id']] = $v['title'];
  1068. }
  1069. $tc = array();
  1070. $tcdata = array();
  1071. $list = array();
  1072. $classid = $this->classid->sku();
  1073. $tcall = $this->typeclass->find_all();
  1074. $typeclass = array();
  1075. foreach ($tcall as $v)
  1076. {
  1077. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1078. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1079. }
  1080. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1081. foreach ($rows as $key => $value) {
  1082. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1083. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1084. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1085. $rows[$key]['cpbz'] = $u9_info['bm'];
  1086. $rows[$key]['cs'] = $u9_info['jm'];
  1087. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1088. $details = array();
  1089. $cpid = array();
  1090. $cpbz = array();
  1091. $c = 0;
  1092. $g = 0;
  1093. $x = 0;
  1094. $t = 0;
  1095. $s = 0;
  1096. $q = 0;
  1097. foreach ($sd as $k => $v) {
  1098. if ($v['state'] == 0) {
  1099. $c++;
  1100. }
  1101. if ($v['state'] != 9) {
  1102. $g++;
  1103. }
  1104. if ($v['state'] == 1) {
  1105. $x++;
  1106. }
  1107. if ($v['state'] == 2) {
  1108. $t++;
  1109. }
  1110. if ($v['state'] == 8) {
  1111. $s++;
  1112. }
  1113. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1114. $q++;
  1115. }
  1116. $details[$v['details']] = $v['details'];
  1117. if ($v['cpid'] != 0) {
  1118. $cpid[$v['cpid']] = $v['cpid'];
  1119. }
  1120. if ($v['cpbz'] != '') {
  1121. $cpbz[$v['cpbz']] = $v['cpbz'];
  1122. }
  1123. }
  1124. $rows[$key]['details'] = implode("、", $details);
  1125. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1126. $number = $value['number'];
  1127. $ftime = time() - 15 * 24 * 3600;
  1128. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1129. $rows[$key]['number'] = $g;
  1130. $rows[$key]['features'] = $c;
  1131. $rows[$key]['x'] = $x;
  1132. $rows[$key]['t'] = $t;
  1133. $rows[$key]['s'] = $s;
  1134. $rows[$key]['q'] = $q;
  1135. $rows[$key]['wzsl'] = count($details);
  1136. }
  1137. $title = "进销存统计表" . date('Y-m-d', time());
  1138. $titlename = "<table border=1>
  1139. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1140. <tr align='center'>
  1141. <td>仓库</td>
  1142. <td>供应商</td>
  1143. <td>位置</td>
  1144. <td>库存编码</td>
  1145. <td>SKU</td>
  1146. <td>用友编码</td>
  1147. <td>用友料号</td>
  1148. <td>产品英文名</td>
  1149. <td>产品中文名</td>
  1150. <td>入库总量</td>
  1151. <td>库存数量</td>
  1152. <td>销售数量</td>
  1153. <td>退货数量</td>
  1154. <td>删除数量</td>
  1155. <td>其它操作</td>
  1156. <td>位置数量</td>
  1157. </tr>
  1158. </table>";
  1159. $filename = $title . ".xls";
  1160. $tail = "";
  1161. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1162. }
  1163. }
  1164. public function _type()
  1165. {
  1166. $vip = 0;
  1167. if (isset($_SESSION['api'])) {
  1168. $user = $this->user->get_api($_SESSION['api']);
  1169. $fgshop = "";
  1170. $sid = "";
  1171. $usersp = explode('|', trim($user['shop'], '|'));
  1172. foreach ($usersp as $value) {
  1173. $fgshop .= " shop = " . $value . " or";
  1174. $sid .= " id = " . $value . " or";
  1175. }
  1176. if ($user['vip'] == 1) {
  1177. $vip = 1;
  1178. }
  1179. } else {
  1180. header('Location: /');
  1181. exit;
  1182. }
  1183. $prc = array();
  1184. $purchase = $this->purchase->find_all();
  1185. foreach ($purchase as $k => $v) {
  1186. $prc[$v['id']] = $v['title'];
  1187. }
  1188. $company = array();
  1189. $ct = $this->company->find_all();
  1190. foreach ($ct as $k => $v) {
  1191. $company[$v['id']] = $v['title'];
  1192. }
  1193. $sp = array();
  1194. $s = $this->shop->find_all('1=1', 'id,shopname');
  1195. foreach ($s as $v) {
  1196. $sp[$v['id']] = $v['shopname'];
  1197. }
  1198. $wh = array();
  1199. $w = $this->warehouse->find_all('1=1', 'id,title');
  1200. foreach ($w as $v) {
  1201. $wh[$v['id']] = $v['title'];
  1202. }
  1203. $post = $this->input->post(NULL, TRUE);
  1204. if (isset($post['page'])) {
  1205. $page = $this->input->post('page', true);
  1206. $perpage = $this->input->post('perpage', true);
  1207. $category = $this->input->post('category', true);
  1208. $size = $this->input->post('size', true);
  1209. $grade = $this->input->post('grade', true);
  1210. $color = $this->input->post('color', true);
  1211. $lowe = $this->input->post('lowe', true);
  1212. $sku = $this->input->post('sku');
  1213. $title = $this->input->post('title');
  1214. $warehouse = $this->input->post('warehouse', true);
  1215. $usa = $this->input->post('usa', true);
  1216. $purchase = $this->input->post('purchase', true);
  1217. $lacetype = $this->input->post('lacetype', true);
  1218. $haircap = $this->input->post('haircap', true);
  1219. $density = $this->input->post('density', true);
  1220. $details = $this->input->post('details', true);
  1221. $state = $this->input->post('state', true);
  1222. $shop = $this->input->post('shop', true);
  1223. $lacecolor = $this->input->post('lacecolor', true);
  1224. $hairnumber = $this->input->post('hairnumber', true);
  1225. $type = $this->input->post('type', true);
  1226. $ktime = $this->input->post('ktime', true);
  1227. $jtime = $this->input->post('jtime', true);
  1228. $ktime = strtotime($ktime);
  1229. $jtime = strtotime($jtime);
  1230. $cpbz = $this->input->post('cpbz', true);
  1231. $sm = $this->input->post('sm', true);
  1232. $where = "1=1";
  1233. $gj = "";
  1234. $ck = "";
  1235. if ($usa) {
  1236. if (!$warehouse) {
  1237. $where .= " and (warehouse = '5' or warehouse = '8')";
  1238. }
  1239. }
  1240. if ($warehouse) {
  1241. $where .= " and warehouse = '$warehouse'";
  1242. }
  1243. if ($details) {
  1244. $where .= " and details = '$details'";
  1245. }
  1246. if ($purchase) {
  1247. $where .= " and purchase = '$purchase'";
  1248. }
  1249. if ($state) {
  1250. $where .= " and state = '$state'";
  1251. }
  1252. if ($shop) {
  1253. $where .= " and shop like '%$shop%'";
  1254. }
  1255. if ($type) {
  1256. $where .= " and type = '$type'";
  1257. }
  1258. if ($ktime && $jtime) {
  1259. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1260. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1261. }
  1262. if ($cpbz) {
  1263. $where .= " and cpbz like '%$cpbz%' ";
  1264. }
  1265. if ($sm) {
  1266. $where .= " and sm like '%$sm%' ";
  1267. }
  1268. if ($lacecolor) {
  1269. $where .= " and features like '%-$lacecolor-%'";
  1270. }
  1271. if ($lacetype) {
  1272. $where .= " and features like '%-$lacetype-%'";
  1273. }
  1274. if ($category) {
  1275. $where .= " and features like '%-$category-%'";
  1276. }
  1277. if ($size) {
  1278. $where .= " and features like '%-$size-%'";
  1279. }
  1280. if ($grade) {
  1281. $where .= " and features like '%-$grade-%'";
  1282. }
  1283. if ($color) {
  1284. $where .= " and features like '%-$color-%'";
  1285. }
  1286. if ($lowe) {
  1287. $where .= " and features like '%-$lowe-%'";
  1288. }
  1289. if ($haircap) {
  1290. $where .= " and features like '%-$haircap-%'";
  1291. }
  1292. if ($density) {
  1293. $where .= " and features like '%-$density-%'";
  1294. }
  1295. if (!empty($hairnumber)) {
  1296. $where .= " and features like '%-128-%' ";
  1297. if ($hairnumber < 0) {
  1298. $class_list = $this->typeclass->find_all('classid = 43');
  1299. foreach ($class_list as $v) {
  1300. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1301. }
  1302. } else {
  1303. $where .= " and features like '%-$hairnumber-%'";
  1304. }
  1305. }
  1306. //数据排序
  1307. $order_str = "id desc";
  1308. if (empty($page)) {
  1309. $start = 0;
  1310. $perpage = 1;
  1311. } else {
  1312. $start = ($page - 1) * $perpage;
  1313. }
  1314. $fjnr = '';
  1315. if ($sku) {
  1316. $sku = trim($sku, ' ');
  1317. $sku = trim($sku, ' ');
  1318. $fjnr .= " and sku like '%$sku%'";
  1319. }
  1320. if ($title) {
  1321. $title = trim($title, ' ');
  1322. $title = trim($title, ' ');
  1323. $fjnr .= " and title like '%$title%'";
  1324. }
  1325. $wt = array();
  1326. $whlabel_type = $this->whlabel_type->find_all();
  1327. foreach ($whlabel_type as $v) {
  1328. $wt[$v['id']] = $v['title'];
  1329. }
  1330. //$where .= " and time > '$ktime' and time < '$jtime'";
  1331. $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
  1332. //取得信息列表
  1333. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1334. $rows = array();
  1335. $list = array();
  1336. foreach ($info_list as $key => $value) {
  1337. if (isset($wt[$value['type']])) {
  1338. $info_list[$key]['type'] = $wt[$value['type']];
  1339. } else {
  1340. $info_list[$key]['type'] = '未设置';
  1341. }
  1342. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1343. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1344. $ztdata = '';
  1345. if (count($zt) > 0) {
  1346. foreach ($zt as $vv) {
  1347. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1348. }
  1349. }
  1350. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1351. $cdata = array_filter($qbdata, function ($item) {
  1352. return $item['state'] < 1;
  1353. });
  1354. $c = array_sum(array_column($cdata, 'jnum'));
  1355. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1356. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1357. });
  1358. $g = array_sum(array_column($gdata, 'jnum'));
  1359. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1360. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1361. });
  1362. $x = array_sum(array_column($xdata, 'jnum'));
  1363. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1364. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1365. });
  1366. $t = array_sum(array_column($tdata, 'jnum'));
  1367. // $zdata = array_filter($qbdata, function ($item) {
  1368. // return $item['zd'] != "" && $item['state'] < 1;
  1369. // });
  1370. // $z = array_sum(array_column($zdata, 'jnum'));
  1371. $zdata = array_filter($qbdata, function ($item) {
  1372. return $item['zd'] != "" && $item['state'] < 1;
  1373. });
  1374. $z = array_sum(array_column($zdata, 'jnum'));
  1375. //$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');
  1376. //$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'].'"');
  1377. //$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'].'"');
  1378. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1379. //$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'].'"');
  1380. $details = array();
  1381. $cpid = array();
  1382. $od = array();
  1383. $odid = '';
  1384. $companytitle = '';
  1385. $shop_list = [];
  1386. foreach ($qbdata as $v) {
  1387. if ($v['zd'] != "" && $v['state'] < 1) {
  1388. if (!isset($od[$v['zd']])) {
  1389. $od[$v['zd']] = 1; //所有数据sku
  1390. } else {
  1391. $od[$v['zd']] = $od[$v['zd']] + 1;
  1392. }
  1393. }
  1394. if ($v['state'] < 1) {
  1395. $details[$v['details']] = $v['details'];
  1396. if ($v['cpid'] != 0) {
  1397. $cpid[$v['cpid']] = $v['cpid'];
  1398. }
  1399. }
  1400. if($v['state'] == 0){
  1401. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1402. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1403. }
  1404. if ($v['shop'] != '') {
  1405. $shop = explode(',', trim($v['shop'], ','));
  1406. foreach ($shop as $vv) {
  1407. if (!in_array($vv, $shop_list)) {
  1408. $shop_list[] = $vv;
  1409. }
  1410. }
  1411. }
  1412. }
  1413. }
  1414. foreach ($od as $k => $vv) {
  1415. $odid .= $k . '数量' . $vv;
  1416. }
  1417. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1418. $info_list[$key]['label'] = $value['sm'];
  1419. $number = $value['number'];
  1420. $ftime = time() - 15 * 24 * 3600;
  1421. $z = $z . '(' . $odid . ')'; //查看订单号
  1422. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1423. $info_list[$key]['features'] = $c;
  1424. $info_list[$key]['number'] = $ztdata;
  1425. $info_list[$key]['sm'] = $g;
  1426. $info_list[$key]['x'] = $x;
  1427. $info_list[$key]['t'] = $t;
  1428. $info_list[$key]['z'] = $z;
  1429. /**
  1430. foreach ($cdata as $k=>$v)
  1431. {
  1432. $details[$v['details']] = $v['details'];
  1433. if($v['cpid'] != 0)
  1434. {
  1435. $cpid[$v['cpid']] = $v['cpid'];
  1436. }
  1437. }
  1438. **/
  1439. $info_list[$key]['shop'] = '';
  1440. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1441. // if ($value['shop'] != '') {
  1442. // $shop = explode(',', trim($value['shop'], ','));
  1443. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1444. // }
  1445. $shop_list = array_unique($shop_list);
  1446. $shop_str = '';
  1447. foreach ($shop_list as $v) {
  1448. if(isset($sp[$v])){
  1449. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1450. }
  1451. }
  1452. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1453. /**
  1454. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1455. if(isset($companytitle[0]))
  1456. {
  1457. foreach ($companytitle as $k=>$v)
  1458. {
  1459. if($v['companytitle'] != '')
  1460. {
  1461. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1462. }
  1463. }
  1464. }
  1465. **/
  1466. }
  1467. $final_all_list = [];
  1468. foreach ($info_list as $k => $v) {
  1469. $final_all_list[] = [
  1470. 'id' => $v['id'],
  1471. "warehouse" => $v["warehouse"],
  1472. "purchase" => $v["purchase"],
  1473. "sku" => $v["sku"],
  1474. "title" => $v["title"] . "<br/>" . $v["pm"],
  1475. "details" => $v["details"],
  1476. "shop" => $v["shop"],
  1477. "cpbz" => $v["cpbz"],
  1478. 'label' => $v['label'],
  1479. "type" => $v["type"],
  1480. "features" => $v["features"],
  1481. "number" => $v["number"],
  1482. "sm" => $v["sm"],
  1483. "x" => $v["x"],
  1484. "t" => $v["t"],
  1485. "z" => $v["z"]
  1486. ];
  1487. }
  1488. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1489. $pagenum = ceil($total / $perpage);
  1490. $over = $total - ($start + $perpage);
  1491. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1492. echo json_encode($rows);
  1493. exit;
  1494. }
  1495. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1496. $this->data['shop'] = $wlshop;
  1497. $this->data['vip'] = $vip;
  1498. $this->_Template('whlabel_type', $this->data);
  1499. }
  1500. //美仓进销存浏览
  1501. public function _usatype()
  1502. {
  1503. if (isset($_SESSION['api'])) {
  1504. $user = $this->user->get_api($_SESSION['api']);
  1505. $usp = $user;
  1506. $fgshop = "";
  1507. $sid = "";
  1508. $wid = "";
  1509. $wtype = "";
  1510. $userwh = explode('|', trim($user['warehouse'], '|'));
  1511. foreach ($userwh as $value) {
  1512. $wid .= " id = " . $value . " or";
  1513. $wtype .= " type = " . $value . " or";
  1514. }
  1515. }
  1516. $prc = array();
  1517. $purchase = $this->purchase->find_all();
  1518. foreach ($purchase as $k => $v) {
  1519. $prc[$v['id']] = $v['title'];
  1520. }
  1521. $post = $this->input->post(NULL, TRUE);
  1522. if (isset($post['page'])) {
  1523. $page = $this->input->post('page', true);
  1524. $perpage = $this->input->post('perpage', true);
  1525. $category = $this->input->post('category', true);
  1526. $size = $this->input->post('size', true);
  1527. $grade = $this->input->post('grade', true);
  1528. $color = $this->input->post('color', true);
  1529. $lowe = $this->input->post('lowe', true);
  1530. $sku = $this->input->post('sku');
  1531. $title = $this->input->post('title');
  1532. $warehouse = $this->input->post('warehouse', true);
  1533. $usa = $this->input->post('usa', true);
  1534. $purchase = $this->input->post('purchase', true);
  1535. $lacetype = $this->input->post('lacetype', true);
  1536. $haircap = $this->input->post('haircap', true);
  1537. $density = $this->input->post('density', true);
  1538. $details = $this->input->post('details', true);
  1539. $state = $this->input->post('state', true);
  1540. $lacecolor = $this->input->post('lacecolor', true);
  1541. $cklx = $this->input->post('cklx', true);
  1542. $ktime = $this->input->post('ktime', true);
  1543. $jtime = $this->input->post('jtime', true);
  1544. $ktime = strtotime($ktime);
  1545. $jtime = strtotime($jtime);
  1546. $where = "1=1";
  1547. $gj = "";
  1548. $ck = "";
  1549. if ($lacetype) {
  1550. $where .= " and features like '%-$lacetype-%'";
  1551. }
  1552. if ($category) {
  1553. $where .= " and features like '%-$category-%'";
  1554. }
  1555. if ($size) {
  1556. $where .= " and features like '%-$size-%'";
  1557. }
  1558. if ($grade) {
  1559. $where .= " and features like '%-$grade-%'";
  1560. }
  1561. if ($color) {
  1562. $where .= " and features like '%-$color-%'";
  1563. }
  1564. if ($lowe) {
  1565. $where .= " and features like '%-$lowe-%'";
  1566. }
  1567. if ($haircap) {
  1568. $where .= " and features like '%-$haircap-%'";
  1569. }
  1570. if ($density) {
  1571. $where .= " and features like '%-$density-%'";
  1572. }
  1573. if ($lacecolor) {
  1574. $where .= " and features like '%-$lacecolor-%'";
  1575. }
  1576. if ($usa) {
  1577. if (!$warehouse) {
  1578. $where .= " and (warehouse = '5' or warehouse = '8')";
  1579. }
  1580. }
  1581. if ($warehouse) {
  1582. $where .= " and warehouse = '$warehouse'";
  1583. }
  1584. if ($details) {
  1585. $where .= " and details = '$details'";
  1586. }
  1587. if ($purchase) {
  1588. $where .= " and purchase = '$purchase'";
  1589. }
  1590. if ($state) {
  1591. $where .= " and state = '$state'";
  1592. }
  1593. $where_add = '';
  1594. if ($cklx) {
  1595. $shop = $this->shop->read($cklx);
  1596. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1597. }
  1598. if ($ktime && $jtime) {
  1599. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1600. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1601. }
  1602. //数据排序
  1603. $order_str = "id desc";
  1604. if (empty($page)) {
  1605. $start = 0;
  1606. $perpage = 1;
  1607. } else {
  1608. $start = ($page - 1) * $perpage;
  1609. }
  1610. if ($sku) {
  1611. $sku = trim($sku, ' ');
  1612. $sku = trim($sku, ' ');
  1613. $where .= " and sku like '%$sku%'";
  1614. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1615. } else if ($title) {
  1616. $title = trim($title, ' ');
  1617. $title = trim($title, ' ');
  1618. $where .= " and title like '%$title%'";
  1619. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1620. } else {
  1621. //$where .= " and time > '$ktime' and time < '$jtime'";
  1622. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1623. }
  1624. //取得信息列表
  1625. $rows = array();
  1626. $list = array();
  1627. foreach ($info_list as $key => $value) {
  1628. $warehouse = $this->warehouse->read($value['warehouse']);
  1629. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1630. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1631. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1632. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1633. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1634. $od = array();
  1635. $odid = '';
  1636. foreach ($z as $v) {
  1637. if (!isset($od[$v['zd']])) {
  1638. $od[$v['zd']] = 1; //所有数据sku
  1639. } else {
  1640. $od[$v['zd']] = $od[$v['zd']] + 1;
  1641. }
  1642. }
  1643. foreach ($od as $k => $vv) {
  1644. $odid .= $k . '数量' . $vv . ' ';
  1645. }
  1646. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1647. $info_list[$key]['features'] = $c;
  1648. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1649. $ztdata = '';
  1650. if (count($zt) > 0) {
  1651. foreach ($zt as $vv) {
  1652. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1653. }
  1654. }
  1655. $info_list[$key]['warehouse'] = $ztdata;
  1656. $info_list[$key]['g'] = $g;
  1657. $info_list[$key]['x'] = $x;
  1658. $info_list[$key]['t'] = $t;
  1659. $info_list[$key]['z'] = $z;
  1660. }
  1661. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1662. $pagenum = ceil($total / $perpage);
  1663. $over = $total - ($start + $perpage);
  1664. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1665. echo json_encode($rows);
  1666. exit;
  1667. }
  1668. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1669. $this->data['warehouse'] = $warehouse;
  1670. $this->_Template('whlabel_typeusa', $this->data);
  1671. }
  1672. //美仓进销存浏览
  1673. public function _usatypeapp()
  1674. {
  1675. $post = $this->input->post(NULL, TRUE);
  1676. if (isset($post['page'])) {
  1677. $page = $this->input->post('page', true);
  1678. $perpage = $this->input->post('perpage', true);
  1679. $sku = $this->input->post('sku', true);
  1680. $warehouse = 5;
  1681. $title = $this->input->post('title', true);
  1682. $state = $this->input->post('state', true);
  1683. $ktime = $this->input->post('ktime', true);
  1684. $jtime = $this->input->post('jtime', true);
  1685. $ktime = strtotime($ktime);
  1686. $jtime = strtotime($jtime);
  1687. $where = "1=1";
  1688. $gj = "";
  1689. $ck = "";
  1690. if ($title) {
  1691. $st = explode(' ', trim($title, ' '));
  1692. foreach ($st as $v) {
  1693. $where .= " and title like '%$v%'";
  1694. }
  1695. }
  1696. if ($warehouse) {
  1697. $where .= " and warehouse = '$warehouse'";
  1698. }
  1699. if ($state) {
  1700. $where .= " and state = '$state'";
  1701. }
  1702. if ($sku) {
  1703. $where .= " and sku like '%$sku%'";
  1704. }
  1705. if ($ktime && $jtime) {
  1706. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1707. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1708. }
  1709. //数据排序
  1710. $order_str = "id desc";
  1711. if (empty($page)) {
  1712. $start = 0;
  1713. $perpage = 1;
  1714. } else {
  1715. $start = ($page - 1) * $perpage;
  1716. }
  1717. //取得信息列表
  1718. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1719. $rows = array();
  1720. $list = array();
  1721. foreach ($info_list as $key => $value) {
  1722. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1723. }
  1724. $rowsdq = array_slice($rows, $start, $perpage);
  1725. foreach ($rowsdq as $value) {
  1726. $warehouse = $this->warehouse->read($value['warehouse']);
  1727. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1728. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1729. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1730. $od = array();
  1731. $odid = '';
  1732. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1733. }
  1734. $total = count($rows);
  1735. $pagenum = ceil($total / $perpage);
  1736. $over = $total - ($start + $perpage);
  1737. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1738. echo json_encode($rows);
  1739. exit;
  1740. }
  1741. $this->_Template('phone/p_usatypeapp', $this->data);
  1742. }
  1743. //入库操作
  1744. public function _enteradd()
  1745. {
  1746. $dt = 0;
  1747. if (isset($_SESSION['api'])) {
  1748. $user = $this->user->get_api($_SESSION['api']);
  1749. $usp = $user;
  1750. $fgshop = "";
  1751. $sid = "";
  1752. $user = explode('|', trim($user['shop'], '|'));
  1753. foreach ($user as $value) {
  1754. $fgshop .= " shop = " . $value . " or";
  1755. $sid .= " id = " . $value . " or";
  1756. }
  1757. }
  1758. $tc = $this->typeclass->find_all();
  1759. $typeclass = array();
  1760. foreach ($tc as $v) {
  1761. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1762. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1763. }
  1764. $post = $this->input->post(NULL, TRUE);
  1765. if (isset($post['sku'])) {
  1766. $list = array();
  1767. $num = "";
  1768. $title = "";
  1769. $features = "";
  1770. $order = $this->input->post('order', true);
  1771. $shop = $this->input->post('shop', true);
  1772. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1773. $sku = $this->input->post('sku', true);
  1774. $post['sm'] = $this->input->post('sm', true);
  1775. $post['warehouse'] = $this->input->post('warehouse', true);
  1776. $post['purchase'] = $this->input->post('purchase', true);
  1777. $post['retreatwarehouse'] = $post['warehouse'];
  1778. $post['state'] = $this->input->post('state', true);
  1779. $post['rktype'] = $this->input->post('rktype', true);
  1780. $post['text'] = $this->input->post('text', true);
  1781. $category = $this->input->post('category', true);
  1782. $list['category'] = $category;
  1783. $list['hairtype'] = $this->input->post('hairtype', true);
  1784. $list['grade'] = $this->input->post('grade', true);
  1785. $size = $this->input->post('size', true);
  1786. $xzsku = $this->input->post('xzsku', true);
  1787. $list['size'] = rtrim($size, ',');
  1788. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1789. $list['extension'] = $this->input->post('extension', true);
  1790. if ($category == 1297) {
  1791. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1792. }
  1793. if ($category == 1702) {
  1794. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1795. $list['syother'] = $this->input->post('syother', true);
  1796. }
  1797. if ($category == 133) {
  1798. $list['fittype'] = $this->input->post('fittype', true);
  1799. $list['acother'] = $this->input->post('acother', true);
  1800. }
  1801. $list['color'] = $this->input->post('color', true);
  1802. $list['lowe'] = $this->input->post('lowe', true);
  1803. if (!$post['purchase']) {
  1804. $post['purchase'] = 1;
  1805. }
  1806. if ($category == 127) {
  1807. $list['type'] = $this->input->post('type', true);
  1808. $list['headroad'] = $this->input->post('headroad', true);
  1809. $list['density'] = $this->input->post('density', true);
  1810. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1811. $list['lacesize'] = $this->input->post('lacesize', true);
  1812. }
  1813. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1814. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1815. }
  1816. if ($category == 128) {
  1817. $list['lacetype'] = $this->input->post('lacetype', true);
  1818. $list['haircap'] = $this->input->post('haircap', true);
  1819. $list['density'] = $this->input->post('density', true);
  1820. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1821. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1822. $list['wigother'] = $this->input->post('wigother', true);
  1823. $list['wigother1'] = $this->input->post('wigother1', true);
  1824. $list['wigother2'] = $this->input->post('wigother2', true);
  1825. }
  1826. if ($category == 129) {
  1827. $list['wide'] = $this->input->post('wide', true);
  1828. }
  1829. if ($category == 131) {
  1830. $list['gifttype'] = $this->input->post('gifttype', true);
  1831. $list['giftother'] = $this->input->post('giftother', true);
  1832. }
  1833. if ($category == 134) {
  1834. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1835. }
  1836. if ($category == 1297) {
  1837. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1838. $list['sywigother'] = $this->input->post('sywigother', true);
  1839. }
  1840. if ($category == 130 || $category == 133 || $category == 1702) {
  1841. $list['items'] = $this->input->post('items', true);
  1842. $list['weight'] = $this->input->post('weight', true);
  1843. }
  1844. if ($category == 1702) {
  1845. $list['syhairther'] = $this->input->post('syhairther', true);
  1846. }
  1847. $classid = $this->classid->sku();
  1848. $scsku = $classid;
  1849. $pm = $classid;
  1850. foreach ($list as $k => $v) {
  1851. if ($v != 0) {
  1852. $num .= $v;
  1853. $features .= $v . '-';
  1854. $post[$k] = $v;
  1855. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1856. if ($k != 'size') {
  1857. $title .= $typeclass[$v]['title'] . " ";
  1858. }
  1859. if (isset($pm[$typeclass[$v]['classid']])) {
  1860. if ($typeclass[$v]['title'] == '9A') {
  1861. $pm[$typeclass[$v]['classid']] = '9A';
  1862. } else if ($typeclass[$v]['title'] == '10A') {
  1863. $pm[$typeclass[$v]['classid']] = '10A';
  1864. } else {
  1865. $clzh = $typeclass[$v]['zh'];
  1866. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1867. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1868. $clzh = $clzh[0];
  1869. }
  1870. $pm[$typeclass[$v]['classid']] = $clzh;
  1871. }
  1872. }
  1873. }
  1874. }
  1875. $zh = implode(" ", $pm);
  1876. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1877. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1878. if ($list['size']) {
  1879. $typeclass = $this->typeclass->read($list['size']);
  1880. $title .= $typeclass['title'];
  1881. }
  1882. $time = time();
  1883. if ($xzsku) {
  1884. $scsku = implode("-", $scsku);
  1885. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1886. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1887. $post['sku'] = trim($scsku, ' ');
  1888. } else {
  1889. $post['sku'] = $sku;
  1890. }
  1891. //$post['sku'] = trim($sku,' ');
  1892. $post['title'] = rtrim($title, ' ');
  1893. $post['number'] = $num;
  1894. $post['features'] = '-' . $features;
  1895. $post['enter'] = $time;
  1896. $post['time'] = $time; //操作时间
  1897. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1898. if ($yza) {
  1899. if ($post['features'] != $yza[0]['features']) {
  1900. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1901. exit;
  1902. }
  1903. }
  1904. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1905. if ($yzb) {
  1906. if ($post['sku'] != $yzb[0]['sku']) {
  1907. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1908. exit;
  1909. }
  1910. }
  1911. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1912. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1913. exit;
  1914. }
  1915. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1916. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1917. exit;
  1918. }
  1919. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1920. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1921. exit;
  1922. }
  1923. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1924. if (isset($yz[0]['type'])) {
  1925. $post['type'] = $yz[0]['type'];
  1926. }
  1927. if ($post['state'] == 9) //如果选择预设库存
  1928. {
  1929. $this->whlabel->insert($post);
  1930. } else {
  1931. /**
  1932. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1933. if($ljg == 1)
  1934. {
  1935. for($i=0;$i<$order;$i++)
  1936. {
  1937. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1938. $this->whlabel->insert($post);
  1939. }
  1940. }
  1941. **/
  1942. //if($post['warehouse'] == '5')
  1943. //{
  1944. //}
  1945. $yydata = $post;
  1946. $yydata['zh'] = $zh;
  1947. /**
  1948. $wl = $this->apiyy->get_cjlp($yydata);
  1949. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1950. {
  1951. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1952. }
  1953. if($wl['Data'][0]['m_isSucess'] != 1)
  1954. {
  1955. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1956. }
  1957. **/
  1958. for ($i = 0; $i < $order; $i++) {
  1959. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1960. $this->whlabel->insert($post);
  1961. }
  1962. }
  1963. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1964. exit;
  1965. }
  1966. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1967. $this->data['wlshop'] = $wlshop;
  1968. $this->_Template('whlabel_enteradd', $this->data);
  1969. }
  1970. //修改产品
  1971. public function _enteredit($arg_array)
  1972. {
  1973. $dt = 0;
  1974. if (isset($_SESSION['api'])) {
  1975. $user = $this->user->get_api($_SESSION['api']);
  1976. $usp = $user;
  1977. $fgshop = "";
  1978. $sid = "";
  1979. $user = explode('|', trim($user['shop'], '|'));
  1980. foreach ($user as $value) {
  1981. $fgshop .= " shop = " . $value . " or";
  1982. $sid .= " id = " . $value . " or";
  1983. }
  1984. }
  1985. $post = $this->input->post(NULL, TRUE);
  1986. if (isset($post['sku'])) {
  1987. $list = array();
  1988. $num = "";
  1989. $title = "";
  1990. $features = "";
  1991. $id = $this->input->post('id', true);
  1992. $order = $this->input->post('order', true);
  1993. $shop = $this->input->post('shop', true);
  1994. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1995. $post['sku'] = $this->input->post('sku', true);
  1996. $post['sm'] = $this->input->post('sm', true);
  1997. $post['warehouse'] = $this->input->post('warehouse', true);
  1998. $post['purchase'] = $this->input->post('purchase', true);
  1999. $post['retreatwarehouse'] = $post['warehouse'];
  2000. $category = $this->input->post('category', true);
  2001. $list['category'] = $category;
  2002. $list['hairtype'] = $this->input->post('hairtype', true);
  2003. $list['grade'] = $this->input->post('grade', true);
  2004. $size = $this->input->post('size', true);
  2005. $list['size'] = rtrim($size, ',');
  2006. $post['rktype'] = $this->input->post('rktype', true);
  2007. $post['text'] = $this->input->post('text', true);
  2008. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2009. $list['extension'] = $this->input->post('extension', true);
  2010. if ($category == 1297) {
  2011. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2012. }
  2013. if ($category == 1702) {
  2014. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2015. $list['syother'] = $this->input->post('syother', true);
  2016. }
  2017. if ($category == 133) {
  2018. $list['fittype'] = $this->input->post('fittype', true);
  2019. $list['acother'] = $this->input->post('acother', true);
  2020. }
  2021. $list['color'] = $this->input->post('color', true);
  2022. $list['lowe'] = $this->input->post('lowe', true);
  2023. if (!$post['purchase']) {
  2024. $post['purchase'] = 1;
  2025. }
  2026. if ($category == 127) {
  2027. $list['type'] = $this->input->post('type', true);
  2028. $list['headroad'] = $this->input->post('headroad', true);
  2029. $list['density'] = $this->input->post('density', true);
  2030. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2031. $list['lacesize'] = $this->input->post('lacesize', true);
  2032. }
  2033. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2034. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2035. }
  2036. if ($category == 128) {
  2037. $list['lacetype'] = $this->input->post('lacetype', true);
  2038. $list['haircap'] = $this->input->post('haircap', true);
  2039. $list['density'] = $this->input->post('density', true);
  2040. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2041. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2042. $list['wigother'] = $this->input->post('wigother', true);
  2043. $list['wigother1'] = $this->input->post('wigother1', true);
  2044. $list['wigother2'] = $this->input->post('wigother2', true);
  2045. }
  2046. if ($category == 129) {
  2047. $list['wide'] = $this->input->post('wide', true);
  2048. }
  2049. if ($category == 131) {
  2050. $list['gifttype'] = $this->input->post('gifttype', true);
  2051. $list['giftother'] = $this->input->post('giftother', true);
  2052. }
  2053. if ($category == 134) {
  2054. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2055. }
  2056. if ($category == 1297) {
  2057. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2058. $list['sywigother'] = $this->input->post('sywigother', true);
  2059. }
  2060. if ($category == 130 || $category == 133 || $category == 1702) {
  2061. $list['items'] = $this->input->post('items', true);
  2062. $list['weight'] = $this->input->post('weight', true);
  2063. }
  2064. if ($category == 1702) {
  2065. $list['syhairther'] = $this->input->post('syhairther', true);
  2066. }
  2067. foreach ($list as $k => $v) {
  2068. if ($v != 0) {
  2069. $num .= $v;
  2070. $features .= $v . '-';
  2071. $typeclass = $this->typeclass->read($v);
  2072. if ($k != 'size') {
  2073. $title .= $typeclass['title'] . " ";
  2074. }
  2075. }
  2076. }
  2077. $typeclass = $this->typeclass->read($list['size']);
  2078. $title .= $typeclass['title'];
  2079. $time = time();
  2080. $post['title'] = rtrim($title, ' ');
  2081. $post['number'] = $num;
  2082. $post['features'] = '-' . $features;
  2083. $post['time'] = $time; //操作时间
  2084. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2085. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2086. exit;
  2087. }
  2088. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2089. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2090. exit;
  2091. }
  2092. $uid = $this->whlabel->read($id);
  2093. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2094. if ($datanum > 0) {
  2095. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2096. exit;
  2097. }
  2098. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2099. {
  2100. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2101. if ($yza) {
  2102. if ($post['features'] != $yza[0]['features']) {
  2103. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2104. exit;
  2105. }
  2106. }
  2107. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2108. if ($yzb) {
  2109. if ($post['sku'] != $yzb[0]['sku']) {
  2110. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2111. exit;
  2112. }
  2113. }
  2114. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2115. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2116. exit;
  2117. }
  2118. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2119. foreach ($data as $v) {
  2120. $post['id'] = $v['id'];
  2121. $this->whlabel->save($post, $v['id']);
  2122. }
  2123. } else {
  2124. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2125. if ($data > 0) {
  2126. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2127. exit;
  2128. } else {
  2129. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2130. foreach ($data as $v) {
  2131. $post['id'] = $v['id'];
  2132. $this->whlabel->save($post, $v['id']);
  2133. }
  2134. }
  2135. }
  2136. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2137. exit;
  2138. }
  2139. $uid = $this->whlabel->read($arg_array[0]);
  2140. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2141. $this->data['enter'] = $uid;
  2142. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2143. $this->data['wlshop'] = $wlshop;
  2144. $this->_Template('whlabel_enteredit', $this->data);
  2145. }
  2146. //入库浏览
  2147. public function _enter()
  2148. {
  2149. $post = $this->input->post(NULL, TRUE);
  2150. if (isset($post['s'])) {
  2151. $id_arr = $this->input->post('s');
  2152. $id_arr = explode(',', $id_arr);
  2153. if (!$id_arr) {
  2154. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2155. exit;
  2156. }
  2157. //循环删除记录
  2158. foreach ($id_arr as $v) {
  2159. $sid = $this->whlabel->read($v);
  2160. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2161. if ($count > 0) {
  2162. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2163. exit;
  2164. }
  2165. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2166. foreach ($info_list as $va) {
  2167. $this->whlabel->remove($va['id']);
  2168. }
  2169. }
  2170. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2171. exit;
  2172. }
  2173. $sp = array();
  2174. $s = $this->shop->find_all('1=1', 'id,shopname');
  2175. foreach ($s as $v) {
  2176. $sp[$v['id']] = $v['shopname'];
  2177. }
  2178. $wh = array();
  2179. $w = $this->warehouse->find_all('1=1', 'id,title');
  2180. foreach ($w as $v) {
  2181. $wh[$v['id']] = $v['title'];
  2182. }
  2183. if (isset($post['page'])) {
  2184. $page = $this->input->post('page', true);
  2185. $perpage = $this->input->post('perpage', true);
  2186. $category = $this->input->post('category', true);
  2187. $size = $this->input->post('size', true);
  2188. $grade = $this->input->post('grade', true);
  2189. $color = $this->input->post('color', true);
  2190. $lowe = $this->input->post('lowe', true);
  2191. $sku = $this->input->post('sku', true);
  2192. $warehouse = $this->input->post('warehouse', true);
  2193. $purchase = $this->input->post('purchase', true);
  2194. $ktime = $this->input->post('ktime', true);
  2195. $jtime = $this->input->post('jtime', true);
  2196. $ktime = strtotime($ktime);
  2197. $jtime = strtotime($jtime);
  2198. $where = "1=1";
  2199. $gj = "";
  2200. $ck = "";
  2201. if ($category) {
  2202. $where .= " and features like '%-$category-%'";
  2203. }
  2204. if ($size) {
  2205. $where .= " and features like '%-$size-%'";
  2206. }
  2207. if ($grade) {
  2208. $where .= " and features like '%-$grade-%'";
  2209. }
  2210. if ($color) {
  2211. $where .= " and features like '%-$color-%'";
  2212. }
  2213. if ($lowe) {
  2214. $where .= " and features like '%-$lowe-%'";
  2215. }
  2216. if ($warehouse) {
  2217. $where .= " and warehouse = '$warehouse'";
  2218. }
  2219. if ($purchase) {
  2220. $where .= " and purchase = '$purchase'";
  2221. }
  2222. if ($sku) {
  2223. $where .= " and sku like '%$sku%'";
  2224. }
  2225. if ($ktime && $jtime) {
  2226. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2227. }
  2228. //数据排序
  2229. $order_str = "enter desc";
  2230. if (empty($page)) {
  2231. $start = 0;
  2232. $perpage = 1;
  2233. } else {
  2234. $start = ($page - 1) * $perpage;
  2235. }
  2236. //取得信息列表
  2237. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2238. foreach ($info_list as $k => $v) {
  2239. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2240. if ($v['shop'] == '') {
  2241. $s = '通用';
  2242. } else {
  2243. $info_list[$k]['shop'] = '';
  2244. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2245. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2246. }
  2247. }
  2248. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2249. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2250. $info_list[$k]['g'] = $g;
  2251. }
  2252. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2253. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2254. $pagenum = ceil($total / $perpage);
  2255. $over = $total - ($start + $perpage);
  2256. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2257. echo json_encode($rows);
  2258. exit;
  2259. }
  2260. $this->_Template('whlabel_enter', $this->data);
  2261. }
  2262. //出库浏览
  2263. public function _out()
  2264. {
  2265. $post = $this->input->post(NULL, TRUE);
  2266. if (isset($post['page'])) {
  2267. $page = $this->input->post('page', true);
  2268. $perpage = $this->input->post('perpage', true);
  2269. $category = $this->input->post('category', true);
  2270. $size = $this->input->post('size', true);
  2271. $grade = $this->input->post('grade', true);
  2272. $color = $this->input->post('color', true);
  2273. $lowe = $this->input->post('lowe', true);
  2274. $sku = $this->input->post('sku', true);
  2275. $warehouse = $this->input->post('warehouse', true);
  2276. $purchase = $this->input->post('purchase', true);
  2277. $state = $this->input->post('state', true);
  2278. $ktime = $this->input->post('ktime', true);
  2279. $jtime = $this->input->post('jtime', true);
  2280. $ktime = strtotime($ktime);
  2281. $jtime = strtotime($jtime);
  2282. $where = "state=3";
  2283. $gj = "";
  2284. $ck = "";
  2285. if ($category) {
  2286. $where .= " and features like '%-$category-%'";
  2287. }
  2288. if ($size) {
  2289. $where .= " and features like '%-$size-%'";
  2290. }
  2291. if ($grade) {
  2292. $where .= " and features like '%-$grade-%'";
  2293. }
  2294. if ($color) {
  2295. $where .= " and features like '%-$color-%'";
  2296. }
  2297. if ($lowe) {
  2298. $where .= " and features like '%-$lowe-%'";
  2299. }
  2300. if ($state) {
  2301. $where .= " and state = '$state'";
  2302. }
  2303. if ($warehouse) {
  2304. $where .= " and warehouse = '$warehouse'";
  2305. }
  2306. if ($purchase) {
  2307. $where .= " and purchase = '$purchase'";
  2308. }
  2309. if ($sku) {
  2310. $where .= " and sku = '$sku'";
  2311. }
  2312. if ($ktime && $jtime) {
  2313. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2314. }
  2315. //数据排序
  2316. $order_str = "id desc";
  2317. if (empty($page)) {
  2318. $start = 0;
  2319. $perpage = 1;
  2320. } else {
  2321. $start = ($page - 1) * $perpage;
  2322. }
  2323. //取得信息列表
  2324. $info_list = $this->whlabel->find_all($where, 'sku');
  2325. $rows = array();
  2326. $list = array();
  2327. foreach ($info_list as $key => $value) {
  2328. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2329. }
  2330. $rows = array_unique($rows); //删除重复记录
  2331. foreach ($rows as $key => $value) {
  2332. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2333. $ck = $this->warehouse->read($data['warehouse']);
  2334. $warehouse = $ck['title'];
  2335. $gy = $this->purchase->read($data['purchase']);
  2336. $purchase = $gy['purchase'];
  2337. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2338. $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);
  2339. }
  2340. $total = count($list);
  2341. $pagenum = ceil($total / $perpage);
  2342. $over = $total - ($start + $perpage);
  2343. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2344. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2345. echo json_encode($rows);
  2346. exit;
  2347. }
  2348. $this->_Template('whlabel_out', $this->data);
  2349. }
  2350. //出库标签浏览
  2351. public function _label()
  2352. {
  2353. $post = $this->input->post(NULL, TRUE);
  2354. if (isset($post['page'])) {
  2355. $page = $this->input->post('page', true);
  2356. $perpage = $this->input->post('perpage', true);
  2357. $sku = $this->input->post('sku', true);
  2358. $warehouse = $this->input->post('warehouse', true);
  2359. $purchase = $this->input->post('purchase', true);
  2360. $orderinfo = $this->input->post('orderinfo', true);
  2361. $waybill = $this->input->post('waybill', true);
  2362. $category = $this->input->post('category', true);
  2363. $size = $this->input->post('size', true);
  2364. $grade = $this->input->post('grade', true);
  2365. $color = $this->input->post('color', true);
  2366. $lowe = $this->input->post('lowe', true);
  2367. $where = "state=1";
  2368. if ($sku) {
  2369. $where .= " and sku = '$sku'";
  2370. }
  2371. if ($warehouse) {
  2372. $where .= " and warehouse = '$warehouse'";
  2373. }
  2374. if ($purchase) {
  2375. $where .= " and purchase = '$purchase'";
  2376. }
  2377. if ($orderinfo) {
  2378. $where .= " and orderinfo = '$orderinfo'";
  2379. }
  2380. if ($waybill) {
  2381. $where .= " and waybill = '$waybill'";
  2382. }
  2383. if ($category) {
  2384. $where .= " and features like '%-$category-%'";
  2385. }
  2386. if ($size) {
  2387. $where .= " and features like '%-$size-%'";
  2388. }
  2389. if ($grade) {
  2390. $where .= " and features like '%-$grade-%'";
  2391. }
  2392. if ($color) {
  2393. $where .= " and features like '%-$color-%'";
  2394. }
  2395. if ($lowe) {
  2396. $where .= " and features like '%-$lowe-%'";
  2397. }
  2398. //数据排序
  2399. $order_str = "outk desc";
  2400. if (empty($page)) {
  2401. $start = 0;
  2402. $perpage = 1;
  2403. } else {
  2404. $start = ($page - 1) * $perpage;
  2405. }
  2406. //取得信息列表
  2407. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2408. foreach ($info_list as $key => $value) {
  2409. $warehouse = $this->warehouse->read($value['warehouse']);
  2410. $info_list[$key]['warehouse'] = $warehouse['title'];
  2411. $purchase = $this->purchase->read($value['purchase']);
  2412. $info_list[$key]['purchase'] = $purchase['title'];
  2413. if ($value['outk'] != 0) {
  2414. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2415. } else {
  2416. $info_list[$key]['outk'] = "";
  2417. }
  2418. if ($value['orderinfo'] == 0) {
  2419. $info_list[$key]['orderinfo'] = "";
  2420. }
  2421. if ($value['waybill'] == 0) {
  2422. $info_list[$key]['waybill'] = "";
  2423. }
  2424. }
  2425. $total = $this->whlabel->find_count($where);
  2426. $pagenum = ceil($total / $perpage);
  2427. $over = $total - ($start + $perpage);
  2428. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2429. echo json_encode($rows);
  2430. exit;
  2431. }
  2432. $this->_Template('whlabel_label', $this->data);
  2433. }
  2434. //独立站出库订单
  2435. public function _outorder()
  2436. {
  2437. if (isset($_SESSION['api'])) {
  2438. $user = $this->user->get_api($_SESSION['api']);
  2439. $usp = $user;
  2440. $fgshop = "";
  2441. $sid = "";
  2442. $user = explode('|', trim($user['shop'], '|'));
  2443. foreach ($user as $value) {
  2444. $fgshop .= " shop = " . $value . " or";
  2445. $sid .= " id = " . $value . " or";
  2446. }
  2447. } else {
  2448. echo "请重新登录";
  2449. }
  2450. $post = $this->input->post(NULL, TRUE);
  2451. if (isset($post['page'])) {
  2452. $page = $this->input->post('page', true);
  2453. $perpage = $this->input->post('perpage', true);
  2454. $warehouse = $this->input->post('warehouse', true);
  2455. $xztime = $this->input->post('xztime', true);
  2456. $timetk = $this->input->post('timetkk', true);
  2457. $timetj = $this->input->post('timetjj', true);
  2458. $shop = $this->input->post('shop', true);
  2459. $source = $this->input->post('source', true);
  2460. $orderinfo = $this->input->post('orderinfo', true);
  2461. $number = $this->input->post('number', true);
  2462. $sfxh = $this->input->post('sfxh', true);
  2463. $express = $this->input->post('express', true);
  2464. $waybill = $this->input->post('waybill', true);
  2465. $library = $this->input->post('library', true);
  2466. $country = $this->input->post('country', true);
  2467. $so = $this->input->post('so', true);
  2468. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2469. $print = $this->input->post('print', true);
  2470. $state = $this->input->post('state', true);
  2471. $orderurl = $this->input->post('orderurl', true);
  2472. $productid = $this->input->post('productid', true);
  2473. $timetk = strtotime($timetk);
  2474. $timetj = strtotime($timetj);
  2475. /**
  2476. $sj = $this->input->post('sj',true);
  2477. if($sj)
  2478. {
  2479. $sj = $this->input->post('sj',true);
  2480. }
  2481. else
  2482. {
  2483. $sj = "fullorder";
  2484. }
  2485. **/
  2486. $sj = "fullorder";
  2487. $where = "1=1";
  2488. if ($warehouse) {
  2489. $where .= " and type = '$warehouse'";
  2490. }
  2491. if ($timetk && $timetj) {
  2492. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2493. }
  2494. if ($orderinfo) {
  2495. $where .= " and orderinfo = '$orderinfo'";
  2496. }
  2497. if ($number) {
  2498. $where .= " and number = '$number'";
  2499. }
  2500. if ($express) {
  2501. $where .= " and express = '$express'";
  2502. }
  2503. if ($waybill) {
  2504. $where .= " and waybill = '$waybill'";
  2505. }
  2506. if ($library) {
  2507. $where .= " and library = '$library'";
  2508. }
  2509. if ($print) {
  2510. $where .= " and print = '$print'";
  2511. }
  2512. if ($libraryconfirm) {
  2513. $where .= " and libraryconfirm = '$libraryconfirm'";
  2514. }
  2515. if ($state) {
  2516. $where .= " and state = '$state'";
  2517. }
  2518. if ($shop) {
  2519. $where .= " and shop = '$shop'";
  2520. }
  2521. if ($country) {
  2522. $where .= " and country = '$country'";
  2523. }
  2524. if ($sfxh != '') {
  2525. $where .= " and sfxh = '$sfxh'";
  2526. }
  2527. if ($so) {
  2528. $where .= " and shipremarks like '%$so%'";
  2529. }
  2530. if ($source) {
  2531. if ($source == '2d') {
  2532. $where .= " and source >= '2'";
  2533. } else {
  2534. $where .= " and source = '$source'";
  2535. }
  2536. }
  2537. if (isset($_SESSION['api'])) {
  2538. foreach ($user as $value) {
  2539. $fgshop .= " shop = " . $value . " or";
  2540. }
  2541. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2542. }
  2543. if ($orderurl) {
  2544. $url = $this->orderurl->read($orderurl);
  2545. $where .= " and link like '%" . $url['url'] . "%'";
  2546. }
  2547. if($productid){
  2548. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2549. }
  2550. //数据排序
  2551. $order_str = "librarytime desc";
  2552. if (empty($page)) {
  2553. $start = 0;
  2554. $perpage = 1;
  2555. } else {
  2556. $start = ($page - 1) * $perpage;
  2557. }
  2558. //取得信息列表
  2559. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2560. //格式化数据
  2561. foreach ($info_list as $key => $value) {
  2562. $shop = $this->shop->read($value['shop']);
  2563. $info_list[$key]['shop'] = $shop['shopname'];
  2564. $express = $this->express->read($value['express']);
  2565. $info_list[$key]['express'] = $express['servicename'];
  2566. $warehouse = $this->warehouse->read($value['type']);
  2567. $info_list[$key]['type'] = $warehouse['title'];
  2568. if ($value['librarytime'] == '0') {
  2569. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2570. } else {
  2571. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2572. }
  2573. }
  2574. $total = $this->$sj->find_count($where);
  2575. $pagenum = ceil($total / $perpage);
  2576. $over = $total - ($start + $perpage);
  2577. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2578. echo json_encode($rows);
  2579. exit;
  2580. }
  2581. $this->data['express'] = $this->express->find_all();
  2582. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2583. $this->data['wlshop'] = $wlshop;
  2584. $user = $this->user->get_api($_SESSION['api']);
  2585. $powerid = $this->power->read($user['power']);
  2586. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2587. $pid = '';
  2588. foreach ($powertext as $v) {
  2589. $pid .= " id = " . $v . " or";
  2590. }
  2591. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2592. $this->data['fullorderexcel'] = $fullorderexcel;
  2593. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2594. $this->data['orderurl'] = $orderurl;
  2595. $this->_Template('whlabel_outorder', $this->data);
  2596. }
  2597. //tt出库
  2598. public function _toutorder()
  2599. {
  2600. $fgshop = "";
  2601. $sid = "";
  2602. if (isset($_SESSION['api'])) {
  2603. $user = $this->user->get_api($_SESSION['api']);
  2604. $usp = $user;
  2605. $user = explode('|', trim($user['shop'], '|'));
  2606. foreach ($user as $value) {
  2607. $fgshop .= " shop = " . $value . " or";
  2608. $sid .= " id = " . $value . " or";
  2609. }
  2610. } else {
  2611. echo "请重新登录";
  2612. die;
  2613. }
  2614. $post = $this->input->post(NULL, TRUE);
  2615. if (isset($post['page'])) {
  2616. $page = $this->input->post('page', true);
  2617. $perpage = $this->input->post('perpage', true);
  2618. $warehouse = $this->input->post('warehouse', true);
  2619. $xztime = $this->input->post('xztime', true);
  2620. $timetk = $this->input->post('timetkk', true);
  2621. $timetj = $this->input->post('timetjj', true);
  2622. $shop = $this->input->post('shop', true);
  2623. $source = $this->input->post('source', true);
  2624. $orderinfo = $this->input->post('orderinfo', true);
  2625. $number = $this->input->post('number', true);
  2626. $sfxh = $this->input->post('sfxh', true);
  2627. $express = $this->input->post('express', true);
  2628. $waybill = $this->input->post('waybill', true);
  2629. $library = $this->input->post('library', true);
  2630. $country = $this->input->post('country', true);
  2631. $so = $this->input->post('so', true);
  2632. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2633. $print = $this->input->post('print', true);
  2634. $state = $this->input->post('state', true);
  2635. $orderurl = $this->input->post('orderurl', true);
  2636. $timetk = strtotime($timetk);
  2637. $timetj = strtotime($timetj);
  2638. /**
  2639. $sj = $this->input->post('sj',true);
  2640. if($sj)
  2641. {
  2642. $sj = $this->input->post('sj',true);
  2643. }
  2644. else
  2645. {
  2646. $sj = "fullorder";
  2647. }
  2648. **/
  2649. $sj = "fullordertt";
  2650. $where = "1=1";
  2651. if ($warehouse) {
  2652. $where .= " and type = '$warehouse'";
  2653. }
  2654. if ($timetk && $timetj) {
  2655. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2656. }
  2657. if ($orderinfo) {
  2658. $where .= " and orderinfo = '$orderinfo'";
  2659. }
  2660. if ($number) {
  2661. $where .= " and number = '$number'";
  2662. }
  2663. if ($express) {
  2664. $where .= " and express = '$express'";
  2665. }
  2666. if ($waybill) {
  2667. $where .= " and waybill = '$waybill'";
  2668. }
  2669. if ($library) {
  2670. $where .= " and library = '$library'";
  2671. }
  2672. if ($print) {
  2673. $where .= " and print = '$print'";
  2674. }
  2675. if ($libraryconfirm) {
  2676. $where .= " and libraryconfirm = '$libraryconfirm'";
  2677. }
  2678. if ($state) {
  2679. $where .= " and state = '$state'";
  2680. }
  2681. if ($shop) {
  2682. $where .= " and shop = '$shop'";
  2683. }
  2684. if ($country) {
  2685. $where .= " and country = '$country'";
  2686. }
  2687. if ($sfxh != '') {
  2688. $where .= " and sfxh = '$sfxh'";
  2689. }
  2690. if ($so) {
  2691. $where .= " and shipremarks like '%$so%'";
  2692. }
  2693. if ($source) {
  2694. if ($source == '2d') {
  2695. $where .= " and source >= '2'";
  2696. } else {
  2697. $where .= " and source = '$source'";
  2698. }
  2699. }
  2700. if (isset($_SESSION['api'])) {
  2701. foreach ($user as $value) {
  2702. $fgshop .= " shop = " . $value . " or";
  2703. }
  2704. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2705. }
  2706. if ($orderurl) {
  2707. $url = $this->orderurl->read($orderurl);
  2708. $where .= " and link like '%" . $url['url'] . "%'";
  2709. }
  2710. //数据排序
  2711. $order_str = "librarytime desc";
  2712. if (empty($page)) {
  2713. $start = 0;
  2714. $perpage = 1;
  2715. } else {
  2716. $start = ($page - 1) * $perpage;
  2717. }
  2718. //取得信息列表
  2719. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2720. //格式化数据
  2721. foreach ($info_list as $key => $value) {
  2722. $shop = $this->shop->read($value['shop']);
  2723. $info_list[$key]['shop'] = $shop['shopname'];
  2724. $express = $this->express->read($value['express']);
  2725. $info_list[$key]['express'] = $express['servicename'];
  2726. $warehouse = $this->warehouse->read($value['type']);
  2727. $info_list[$key]['type'] = $warehouse['title'];
  2728. if ($value['librarytime'] == '0') {
  2729. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2730. } else {
  2731. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2732. }
  2733. }
  2734. $total = $this->$sj->find_count($where);
  2735. $pagenum = ceil($total / $perpage);
  2736. $over = $total - ($start + $perpage);
  2737. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2738. echo json_encode($rows);
  2739. exit;
  2740. }
  2741. $this->data['express'] = $this->express->find_all();
  2742. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2743. $this->data['wlshop'] = $wlshop;
  2744. $user = $this->user->get_api($_SESSION['api']);
  2745. $powerid = $this->power->read($user['power']);
  2746. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2747. $pid = '';
  2748. foreach ($powertext as $v) {
  2749. $pid .= " id = " . $v . " or";
  2750. }
  2751. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2752. $this->data['fullorderexcel'] = $fullorderexcel;
  2753. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2754. $this->data['orderurl'] = $orderurl;
  2755. $this->_Template('whlabel_toutorder', $this->data);
  2756. }
  2757. //tt出库
  2758. public function _aoutorder()
  2759. {
  2760. if (isset($_SESSION['api'])) {
  2761. $user = $this->user->get_api($_SESSION['api']);
  2762. $usp = $user;
  2763. $fgshop = "";
  2764. $sid = "";
  2765. $user = explode('|', trim($user['shop'], '|'));
  2766. foreach ($user as $value) {
  2767. $fgshop .= " shop = " . $value . " or";
  2768. $sid .= " id = " . $value . " or";
  2769. }
  2770. } else {
  2771. echo "请重新登录";
  2772. }
  2773. $post = $this->input->post(NULL, TRUE);
  2774. if (isset($post['page'])) {
  2775. $page = $this->input->post('page', true);
  2776. $perpage = $this->input->post('perpage', true);
  2777. $warehouse = $this->input->post('warehouse', true);
  2778. $xztime = $this->input->post('xztime', true);
  2779. $timetk = $this->input->post('timetkk', true);
  2780. $timetj = $this->input->post('timetjj', true);
  2781. $shop = $this->input->post('shop', true);
  2782. $source = $this->input->post('source', true);
  2783. $orderinfo = $this->input->post('orderinfo', true);
  2784. $number = $this->input->post('number', true);
  2785. $sfxh = $this->input->post('sfxh', true);
  2786. $express = $this->input->post('express', true);
  2787. $waybill = $this->input->post('waybill', true);
  2788. $library = $this->input->post('library', true);
  2789. $country = $this->input->post('country', true);
  2790. $so = $this->input->post('so', true);
  2791. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2792. $print = $this->input->post('print', true);
  2793. $state = $this->input->post('state', true);
  2794. $orderurl = $this->input->post('orderurl', true);
  2795. $timetk = strtotime($timetk);
  2796. $timetj = strtotime($timetj);
  2797. /**
  2798. $sj = $this->input->post('sj',true);
  2799. if($sj)
  2800. {
  2801. $sj = $this->input->post('sj',true);
  2802. }
  2803. else
  2804. {
  2805. $sj = "fullorder";
  2806. }
  2807. **/
  2808. $sj = "fullorderamz";
  2809. $where = "1=1";
  2810. if ($warehouse) {
  2811. $where .= " and type = '$warehouse'";
  2812. }
  2813. if ($timetk && $timetj) {
  2814. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2815. }
  2816. if ($orderinfo) {
  2817. $where .= " and orderinfo = '$orderinfo'";
  2818. }
  2819. if ($number) {
  2820. $where .= " and number = '$number'";
  2821. }
  2822. if ($express) {
  2823. $where .= " and express = '$express'";
  2824. }
  2825. if ($waybill) {
  2826. $where .= " and waybill = '$waybill'";
  2827. }
  2828. if ($library) {
  2829. $where .= " and library = '$library'";
  2830. }
  2831. if ($print) {
  2832. $where .= " and print = '$print'";
  2833. }
  2834. if ($libraryconfirm) {
  2835. $where .= " and libraryconfirm = '$libraryconfirm'";
  2836. }
  2837. if ($state) {
  2838. $where .= " and state = '$state'";
  2839. }
  2840. if ($shop) {
  2841. $where .= " and shop = '$shop'";
  2842. }
  2843. if ($country) {
  2844. $where .= " and country = '$country'";
  2845. }
  2846. if ($sfxh != '') {
  2847. $where .= " and sfxh = '$sfxh'";
  2848. }
  2849. if ($so) {
  2850. $where .= " and shipremarks like '%$so%'";
  2851. }
  2852. if ($source) {
  2853. if ($source == '2d') {
  2854. $where .= " and source >= '2'";
  2855. } else {
  2856. $where .= " and source = '$source'";
  2857. }
  2858. }
  2859. if (isset($_SESSION['api'])) {
  2860. foreach ($user as $value) {
  2861. $fgshop .= " shop = " . $value . " or";
  2862. }
  2863. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2864. }
  2865. if ($orderurl) {
  2866. $url = $this->orderurl->read($orderurl);
  2867. $where .= " and link like '%" . $url['url'] . "%'";
  2868. }
  2869. //数据排序
  2870. $order_str = "librarytime desc";
  2871. if (empty($page)) {
  2872. $start = 0;
  2873. $perpage = 1;
  2874. } else {
  2875. $start = ($page - 1) * $perpage;
  2876. }
  2877. //取得信息列表
  2878. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2879. //格式化数据
  2880. foreach ($info_list as $key => $value) {
  2881. $shop = $this->shop->read($value['shop']);
  2882. $info_list[$key]['shop'] = $shop['shopname'];
  2883. $express = $this->express->read($value['express']);
  2884. $info_list[$key]['express'] = $express['servicename'];
  2885. $warehouse = $this->warehouse->read($value['type']);
  2886. $info_list[$key]['type'] = $warehouse['title'];
  2887. if ($value['librarytime'] == '0') {
  2888. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2889. } else {
  2890. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2891. }
  2892. }
  2893. $total = $this->$sj->find_count($where);
  2894. $pagenum = ceil($total / $perpage);
  2895. $over = $total - ($start + $perpage);
  2896. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2897. echo json_encode($rows);
  2898. exit;
  2899. }
  2900. $this->data['express'] = $this->express->find_all();
  2901. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2902. $this->data['wlshop'] = $wlshop;
  2903. $user = $this->user->get_api($_SESSION['api']);
  2904. $powerid = $this->power->read($user['power']);
  2905. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2906. $pid = '';
  2907. foreach ($powertext as $v) {
  2908. $pid .= " id = " . $v . " or";
  2909. }
  2910. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2911. $this->data['fullorderexcel'] = $fullorderexcel;
  2912. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2913. $this->data['orderurl'] = $orderurl;
  2914. $this->_Template('whlabel_aoutorder', $this->data);
  2915. }
  2916. //速卖通出库订单
  2917. public function _soutorder()
  2918. {
  2919. if (isset($_SESSION['api'])) {
  2920. $user = $this->user->get_api($_SESSION['api']);
  2921. $usp = $user;
  2922. $fgshop = "";
  2923. $sid = "";
  2924. $user = explode('|', trim($user['shop'], '|'));
  2925. foreach ($user as $value) {
  2926. $sid .= " id = " . $value . " or";
  2927. }
  2928. }
  2929. $post = $this->input->post(NULL, TRUE);
  2930. if (isset($post['page'])) {
  2931. $page = $this->input->post('page', true);
  2932. $perpage = $this->input->post('perpage', true);
  2933. $warehouse = $this->input->post('warehouse', true);
  2934. $xztime = $this->input->post('xztime', true);
  2935. $timetk = $this->input->post('timetkk', true);
  2936. $timetj = $this->input->post('timetjj', true);
  2937. $shop = $this->input->post('shop', true);
  2938. $source = $this->input->post('source', true);
  2939. $orderinfo = $this->input->post('orderinfo', true);
  2940. $number = $this->input->post('number', true);
  2941. $express = $this->input->post('express', true);
  2942. $waybill = $this->input->post('waybill', true);
  2943. $library = $this->input->post('library', true);
  2944. $country = $this->input->post('country', true);
  2945. $sfxh = $this->input->post('sfxh', true);
  2946. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2947. $print = $this->input->post('print', true);
  2948. $state = $this->input->post('state', true);
  2949. $so = $this->input->post('so', true);
  2950. $timetk = strtotime($timetk);
  2951. $timetj = strtotime($timetj);
  2952. /**
  2953. $sj = $this->input->post('sj',true);
  2954. if($sj)
  2955. {
  2956. $sj = $this->input->post('sj',true);
  2957. }
  2958. else
  2959. {
  2960. $sj = "fullorder";
  2961. }
  2962. **/
  2963. $sj = "fullordersmt";
  2964. $where = "1=1";
  2965. if ($warehouse) {
  2966. $where .= " and type = '$warehouse'";
  2967. }
  2968. if ($timetk && $timetj) {
  2969. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2970. }
  2971. if ($orderinfo) {
  2972. $where .= " and orderinfo = '$orderinfo'";
  2973. }
  2974. if ($number) {
  2975. $where .= " and number = '$number'";
  2976. }
  2977. if ($express) {
  2978. $where .= " and express = '$express'";
  2979. }
  2980. if ($waybill) {
  2981. $where .= " and waybill = '$waybill'";
  2982. }
  2983. if ($library) {
  2984. $where .= " and library = '$library'";
  2985. }
  2986. if ($print) {
  2987. $where .= " and print = '$print'";
  2988. }
  2989. if ($libraryconfirm) {
  2990. $where .= " and libraryconfirm = '$libraryconfirm'";
  2991. }
  2992. if ($state) {
  2993. $where .= " and state = '$state'";
  2994. }
  2995. if ($shop) {
  2996. $where .= " and shop = '$shop'";
  2997. }
  2998. if ($sfxh != '') {
  2999. $where .= " and sfxh = '$sfxh'";
  3000. }
  3001. if ($so) {
  3002. $where .= " and shipremarks like '%$so%'";
  3003. }
  3004. if ($source) {
  3005. $where .= " and source = '$source'";
  3006. }
  3007. if ($country) {
  3008. $where .= " and country = '$country'";
  3009. } else {
  3010. if (isset($_SESSION['api'])) {
  3011. foreach ($user as $value) {
  3012. $fgshop .= " shop = " . $value . " or";
  3013. }
  3014. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3015. }
  3016. }
  3017. //数据排序
  3018. $order_str = "librarytime desc";
  3019. if (empty($page)) {
  3020. $start = 0;
  3021. $perpage = 1;
  3022. } else {
  3023. $start = ($page - 1) * $perpage;
  3024. }
  3025. //取得信息列表
  3026. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3027. //格式化数据
  3028. foreach ($info_list as $key => $value) {
  3029. $shop = $this->shop->read($value['shop']);
  3030. $info_list[$key]['shop'] = $shop['shopname'];
  3031. $express = $this->express->read($value['express']);
  3032. $info_list[$key]['express'] = $express['servicename'];
  3033. $warehouse = $this->warehouse->read($value['type']);
  3034. $info_list[$key]['type'] = $warehouse['title'];
  3035. if ($value['librarytime'] == '0') {
  3036. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3037. } else {
  3038. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3039. }
  3040. }
  3041. $total = $this->$sj->find_count($where);
  3042. $pagenum = ceil($total / $perpage);
  3043. $over = $total - ($start + $perpage);
  3044. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3045. echo json_encode($rows);
  3046. exit;
  3047. }
  3048. $this->data['express'] = $this->express->find_all();
  3049. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3050. $this->data['wlshop'] = $wlshop;
  3051. $user = $this->user->get_api($_SESSION['api']);
  3052. $powerid = $this->power->read($user['power']);
  3053. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3054. $pid = '';
  3055. foreach ($powertext as $v) {
  3056. $pid .= " id = " . $v . " or";
  3057. }
  3058. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3059. $this->data['fullorderexcel'] = $fullorderexcel;
  3060. $this->_Template('whlabel_soutorder', $this->data);
  3061. }
  3062. //订单退库
  3063. public function _retreat()
  3064. {
  3065. $post = $this->input->post(NULL, TRUE);
  3066. if (isset($post['page'])) {
  3067. $page = $this->input->post('page', true);
  3068. $perpage = $this->input->post('perpage', true);
  3069. $warehouse = $this->input->post('warehouse', true);
  3070. $timetk = $this->input->post('timetk', true);
  3071. $timetj = $this->input->post('timetj', true);
  3072. $shop = $this->input->post('shop', true);
  3073. $source = $this->input->post('source', true);
  3074. $state = $this->input->post('state', true);
  3075. $review = $this->input->post('review', true);
  3076. $state = $this->input->post('state', true);
  3077. $express = $this->input->post('express', true);
  3078. $orderinfo = $this->input->post('orderinfo', true);
  3079. $user = $this->input->post('user', true);
  3080. $name = $this->input->post('name', true);
  3081. $waybill = $this->input->post('waybill', true);
  3082. $timetk = strtotime($timetk);
  3083. $timetj = strtotime($timetj);
  3084. $where = "(state=206 or state=210) and mergeid = 0";
  3085. if ($warehouse) {
  3086. $where .= " and state = '$warehouse'";
  3087. }
  3088. if ($timetk && $timetj) {
  3089. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3090. }
  3091. if ($shop) {
  3092. $where .= " and shop = '$shop'";
  3093. }
  3094. if ($source) {
  3095. $where .= " and source = '$source'";
  3096. }
  3097. if ($state) {
  3098. $where .= " and state = '$state'";
  3099. }
  3100. if ($review) {
  3101. $where .= " and review = '$review'";
  3102. }
  3103. if ($state) {
  3104. $where .= " and state = '$state'";
  3105. }
  3106. if ($express) {
  3107. $where .= " and express = '$express'";
  3108. }
  3109. if ($orderinfo) {
  3110. $where .= " and orderinfo = '$orderinfo'";
  3111. }
  3112. if ($user) {
  3113. $where .= " and user = '$user'";
  3114. }
  3115. if ($name) {
  3116. $where .= " and name = '$name'";
  3117. }
  3118. if ($waybill) {
  3119. $where .= " and waybill = '$waybill'";
  3120. }
  3121. //数据排序
  3122. $order_str = "id desc";
  3123. if (empty($page)) {
  3124. $start = 0;
  3125. $perpage = 1;
  3126. } else {
  3127. $start = ($page - 1) * $perpage;
  3128. }
  3129. //取得信息列表
  3130. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3131. //格式化数据
  3132. foreach ($info_list as $key => $value) {
  3133. $shop = $this->shop->read($value['shop']);
  3134. $info_list[$key]['shop'] = $shop['shopname'];
  3135. $warehouse = $this->warehouse->read($value['warehouse']);
  3136. $info_list[$key]['warehouse'] = $warehouse['title'];
  3137. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3138. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3139. if ($value['waybill'] == 0) {
  3140. $info_list[$key]['waybill'] = "";
  3141. }
  3142. $express = $this->express->read($value['express']);
  3143. $info_list[$key]['express'] = $express['title'];
  3144. $typeclass = $this->typeclass->read($value['state']);
  3145. $info_list[$key]['state'] = $typeclass['title'];
  3146. }
  3147. $total = $this->fullorder->find_count($where);
  3148. $pagenum = ceil($total / $perpage);
  3149. $over = $total - ($start + $perpage);
  3150. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3151. echo json_encode($rows);
  3152. exit;
  3153. }
  3154. $this->data['express'] = $this->express->find_all();
  3155. $this->_Template('whlabel_retreat', $this->data);
  3156. }
  3157. //退库标签浏览
  3158. public function _retreatlk()
  3159. {
  3160. $post = $this->input->post(NULL, TRUE);
  3161. if (isset($post['page'])) {
  3162. $page = $this->input->post('page', true);
  3163. $perpage = $this->input->post('perpage', true);
  3164. $timetk = $this->input->post('timetk', true);
  3165. $timetj = $this->input->post('timetj', true);
  3166. $sku = $this->input->post('sku', true);
  3167. $warehouse = $this->input->post('warehouse', true);
  3168. $purchase = $this->input->post('purchase', true);
  3169. $orderinfo = $this->input->post('orderinfo', true);
  3170. $waybill = $this->input->post('waybill', true);
  3171. $category = $this->input->post('category', true);
  3172. $size = $this->input->post('size', true);
  3173. $grade = $this->input->post('grade', true);
  3174. $color = $this->input->post('color', true);
  3175. $lowe = $this->input->post('lowe', true);
  3176. $state = $this->input->post('state', true);
  3177. $timetk = strtotime($timetk);
  3178. $timetj = strtotime($timetj);
  3179. $where = "state=2";
  3180. if ($timetk && $timetj) {
  3181. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3182. }
  3183. if ($sku) {
  3184. $where .= " and sku = '$sku'";
  3185. }
  3186. if ($warehouse) {
  3187. $where .= " and warehouse = '$warehouse'";
  3188. }
  3189. if ($purchase) {
  3190. $where .= " and purchase = '$purchase'";
  3191. }
  3192. if ($orderinfo) {
  3193. $where .= " and orderinfo = '$orderinfo'";
  3194. }
  3195. if ($waybill) {
  3196. $where .= " and waybill = '$waybill'";
  3197. }
  3198. if ($category) {
  3199. $where .= " and features like '%-$category-%'";
  3200. }
  3201. if ($size) {
  3202. $where .= " and features like '%-$size-%'";
  3203. }
  3204. if ($grade) {
  3205. $where .= " and features like '%-$grade-%'";
  3206. }
  3207. if ($color) {
  3208. $where .= " and features like '%-$color-%'";
  3209. }
  3210. if ($lowe) {
  3211. $where .= " and features like '%-$lowe-%'";
  3212. }
  3213. //数据排序
  3214. $order_str = "time desc";
  3215. if (empty($page)) {
  3216. $start = 0;
  3217. $perpage = 1;
  3218. } else {
  3219. $start = ($page - 1) * $perpage;
  3220. }
  3221. //取得信息列表
  3222. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3223. foreach ($info_list as $key => $value) {
  3224. $warehouse = $this->warehouse->read($value['warehouse']);
  3225. $info_list[$key]['warehouse'] = $warehouse['title'];
  3226. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3227. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3228. $purchase = $this->purchase->read($value['purchase']);
  3229. $info_list[$key]['purchase'] = $purchase['title'];
  3230. if ($value['outk'] != 0) {
  3231. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3232. } else {
  3233. $info_list[$key]['outk'] = "";
  3234. }
  3235. if ($value['retreat'] != 0) {
  3236. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3237. } else {
  3238. $info_list[$key]['retreat'] = "";
  3239. }
  3240. if ($value['orderinfo'] == 0) {
  3241. $info_list[$key]['orderinfo'] = "";
  3242. }
  3243. if ($value['waybill'] == 0) {
  3244. $info_list[$key]['waybill'] = "";
  3245. }
  3246. }
  3247. $total = $this->whlabel->find_count($where);
  3248. $pagenum = ceil($total / $perpage);
  3249. $over = $total - ($start + $perpage);
  3250. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3251. echo json_encode($rows);
  3252. exit;
  3253. }
  3254. $this->_Template('whlabel_retreatlk', $this->data);
  3255. }
  3256. //更换标签及浏览
  3257. public function _change()
  3258. {
  3259. $post = $this->input->post(NULL, TRUE);
  3260. if (isset($post['page'])) {
  3261. $page = $this->input->post('page', true);
  3262. $perpage = $this->input->post('perpage', true);
  3263. $timetk = $this->input->post('timetk', true);
  3264. $timetj = $this->input->post('timetj', true);
  3265. $label = $this->input->post('label', true);
  3266. $oldlabel = $this->input->post('oldlabel', true);
  3267. $timetk = strtotime($timetk);
  3268. $timetj = strtotime($timetj);
  3269. $where = "state=10 ";
  3270. if ($timetk && $timetj) {
  3271. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3272. }
  3273. if ($label) {
  3274. $where .= " and label = '$label'";
  3275. }
  3276. if ($oldlabel) {
  3277. $where .= " and oldlabel = '$oldlabel'";
  3278. }
  3279. //数据排序
  3280. $order_str = "time asc";
  3281. if (empty($page)) {
  3282. $start = 0;
  3283. $perpage = 1;
  3284. } else {
  3285. $start = ($page - 1) * $perpage;
  3286. }
  3287. //取得信息列表
  3288. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3289. foreach ($info_list as $key => $value) {
  3290. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3291. }
  3292. $total = $this->whlabel->find_count($where);
  3293. $pagenum = ceil($total / $perpage);
  3294. $over = $total - ($start + $perpage);
  3295. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3296. echo json_encode($rows);
  3297. exit;
  3298. }
  3299. $this->_Template('whlabel_change', $this->data);
  3300. }
  3301. //产品标签
  3302. public function _cpbqdc()
  3303. {
  3304. if (isset($_GET['excel'])) {
  3305. $where = "1=1";
  3306. //数据排序
  3307. $order_str = "id desc";
  3308. if (empty($page)) {
  3309. $start = 0;
  3310. $perpage = 1;
  3311. } else {
  3312. $start = ($page - 1) * $perpage;
  3313. }
  3314. $warehouse = $this->input->get('warehouse', true);
  3315. $state = $this->input->get('state', true);
  3316. $timetk = $this->input->get('timetkk', true);
  3317. $timetj = $this->input->get('timetjj', true);
  3318. $timetk = strtotime($timetk);
  3319. $timetj = strtotime($timetj);
  3320. if ($warehouse) {
  3321. $where .= " and warehouse = '$warehouse'";
  3322. }
  3323. if ($state || $state == 0) {
  3324. $where .= " and state = '$state'";
  3325. }
  3326. if ($timetk && $timetj) {
  3327. $where .= " and time > '$timetk' and time < '$timetj'";
  3328. }
  3329. //取得信息列表
  3330. $info_list = $this->whlabel->find_all($where, '*');
  3331. $rows = array();
  3332. $list = array();
  3333. foreach ($info_list as $key => $value) {
  3334. $rows[$value['time']] = $value; //所有数据sku
  3335. }
  3336. foreach ($rows as $value) {
  3337. $warehouse = $this->warehouse->read($value['warehouse']);
  3338. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3339. $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);
  3340. }
  3341. $title = "产品标签统计表";
  3342. $titlename = "<table border=1>
  3343. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3344. <tr align='center'>
  3345. <td>仓库</td>
  3346. <td>SKU</td>
  3347. <td>产品</td>
  3348. <td>入库时间</td>
  3349. <td>操作时间</td>
  3350. <td>备注</td>
  3351. <td>数量</td>
  3352. </tr>
  3353. </table>";
  3354. $filename = $title . ".xls";
  3355. $tail = "";
  3356. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3357. }
  3358. }
  3359. //进销存导出
  3360. public function _exceljxc()
  3361. {
  3362. $classid = $this->classid->sku();
  3363. $pm = $classid;
  3364. $typeclass = array();
  3365. $tc = $this->typeclass->find_all();
  3366. foreach ($tc as $v) {
  3367. $typeclass[$v['id']] = $v;
  3368. }
  3369. $prc = array();
  3370. $purchase = $this->purchase->find_all();
  3371. foreach ($purchase as $k => $v) {
  3372. $prc[$v['id']] = $v['title'];
  3373. }
  3374. if (isset($_GET['excel'])) {
  3375. $where = "sku != 'Preset'";
  3376. //数据排序
  3377. $order_str = "id desc";
  3378. if (empty($page)) {
  3379. $start = 0;
  3380. $perpage = 1;
  3381. } else {
  3382. $start = ($page - 1) * $perpage;
  3383. }
  3384. $category = $this->input->get('category', true);
  3385. $warehouse = $this->input->get('warehouse', true);
  3386. $excelid = $this->input->get('sid', true);
  3387. if ($category) {
  3388. $where .= " and features like '%-$category-%'";
  3389. }
  3390. if ($warehouse) {
  3391. $where .= " and warehouse = '$warehouse'";
  3392. }
  3393. $xzid = '';
  3394. if ($excelid) {
  3395. $excelid = explode(',', trim($excelid, ','));
  3396. foreach ($excelid as $key => $value) {
  3397. $xzid .= " id = " . $value . " or";
  3398. }
  3399. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3400. }
  3401. //取得信息列表
  3402. /**
  3403. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3404. $rows = array();$list = array();
  3405. foreach ($info_list as $key=>$value)
  3406. {
  3407. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3408. }
  3409. **/
  3410. $wt = array();
  3411. $whlabel_type = $this->whlabel_type->find_all();
  3412. foreach ($whlabel_type as $v) {
  3413. $wt[$v['id']] = $v['title'];
  3414. }
  3415. $wh = array();
  3416. $w = $this->warehouse->find_all('1=1', 'id,title');
  3417. foreach ($w as $v) {
  3418. $wh[$v['id']] = $v['title'];
  3419. }
  3420. $list = array();
  3421. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3422. foreach ($rows as $key => $value) {
  3423. if (isset($wt[$value['type']])) {
  3424. $rows[$key]['type'] = $wt[$value['type']];
  3425. } else {
  3426. $rows[$key]['type'] = '未设置';
  3427. }
  3428. $bm = '03';
  3429. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3430. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3431. $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');
  3432. $details = array();
  3433. $cpid = array();
  3434. $cpbz = array();
  3435. $c = 0;
  3436. $g = 0;
  3437. $x = 0;
  3438. $t = 0;
  3439. $s = 0;
  3440. $q = 0;
  3441. foreach ($sd as $k => $v) {
  3442. if ($v['state'] == 0) {
  3443. $c++;
  3444. if ($v['cpid'] != 0) {
  3445. $cpid[$v['cpid']] = $v['cpid'];
  3446. }
  3447. if ($v['cpbz'] != '') {
  3448. $cpbz[$v['cpbz']] = $v['cpbz'];
  3449. }
  3450. }
  3451. if ($v['state'] != 9) {
  3452. $g++;
  3453. }
  3454. if ($v['state'] == 1) {
  3455. $x++;
  3456. }
  3457. if ($v['state'] == 2) {
  3458. $t++;
  3459. }
  3460. if ($v['state'] == 8) {
  3461. $s++;
  3462. }
  3463. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3464. $q++;
  3465. }
  3466. $details[$v['details']] = $v['details'];
  3467. }
  3468. $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'] . '"');
  3469. $rows[$key]['details'] = implode("、", $details);
  3470. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3471. $number = $value['number'];
  3472. $ftime = time() - 15 * 24 * 3600;
  3473. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3474. $rows[$key]['number'] = $g;
  3475. $rows[$key]['c'] = $c;
  3476. $rows[$key]['x'] = $x;
  3477. $rows[$key]['t'] = $t;
  3478. $rows[$key]['s'] = $s;
  3479. $rows[$key]['q'] = $q;
  3480. $rows[$key]['z'] = $z;
  3481. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3482. $features = explode('-', trim($features, '-'));
  3483. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3484. // $pm = $classid;
  3485. // $jm = $classid;
  3486. // foreach($features as $k=>$v)
  3487. // {
  3488. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3489. // {
  3490. // if($typeclass[$v]['bm'] != '')
  3491. // {
  3492. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3493. // }
  3494. // }
  3495. // if($v != 0)
  3496. // {
  3497. // if(!isset($typeclass[$v]))
  3498. // {
  3499. // continue;
  3500. // }
  3501. // if(isset($pm[$typeclass[$v]['classid']]))
  3502. // {
  3503. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3504. // {
  3505. // $tz = explode('|',$typeclass[$v]['zh']);
  3506. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3507. // }
  3508. // else
  3509. // {
  3510. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3511. // }
  3512. // }
  3513. // if(isset($jm[$typeclass[$v]['classid']]))
  3514. // {
  3515. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3516. // }
  3517. // }
  3518. // }
  3519. // $jm = array_filter($jm);
  3520. // $rows[$key]['bs'] = implode("-",$jm);
  3521. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3522. // $zh = implode(" ",$pm);
  3523. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3524. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3525. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3526. // $rows[$key]['features'] = $zh;
  3527. }
  3528. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3529. $final_list = [];
  3530. foreach ($list as $k => $v) {
  3531. if (empty($v['sku'])) {
  3532. continue;
  3533. }
  3534. $final_list[] = [
  3535. "warehouse" => $v["warehouse"],
  3536. "purchase" => $v["purchase"],
  3537. "details" => $v["details"],
  3538. "cpid" => $v["cpid"],
  3539. "dbcontent" => $v["dbcontent"],
  3540. "sku" => $v["sku"],
  3541. "cs" => $v["bm"],
  3542. "bs" => $v["jm"],
  3543. "title" => $v["title"],
  3544. "features" => $v["pm"],
  3545. "cpbz" => $v["cpbz"],
  3546. "sm" => $v["sm"],
  3547. "type" => $v["type"],
  3548. "number" => $v["number"],
  3549. "c" => $v["c"],
  3550. "x" => $v["x"],
  3551. "t" => $v["t"],
  3552. "s" => $v["s"],
  3553. "q" => $v["q"],
  3554. "z" => $v["z"],
  3555. "weight" => $v['weight'],
  3556. ];
  3557. }
  3558. $title = "总进销存统计表";
  3559. $titlename = "<table border=1>
  3560. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3561. <tr align='center'>
  3562. <td>仓库</td>
  3563. <td>供应商</td>
  3564. <td>位置</td>
  3565. <td>库存编码</td>
  3566. <td>类目</td>
  3567. <td>SKU</td>
  3568. <td>用友编码</td>
  3569. <td>用友料号</td>
  3570. <td>商品名称</td>
  3571. <td>商品中文</td>
  3572. <td>产品备注</td>
  3573. <td>说明</td>
  3574. <td>类型</td>
  3575. <td>入库总量</td>
  3576. <td>库存数量</td>
  3577. <td>销售数量</td>
  3578. <td>退货数量</td>
  3579. <td>删除数量</td>
  3580. <td>其它操作</td>
  3581. <td>占单数量</td>
  3582. <td>重量(g)</td>
  3583. </tr>
  3584. </table>";
  3585. $filename = $title . ".xls";
  3586. $tail = "";
  3587. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3588. }
  3589. }
  3590. //入库导出
  3591. public function _excelr()
  3592. {
  3593. if (isset($_GET['excel'])) {
  3594. $category = $this->input->get('category', true);
  3595. $size = $this->input->get('size', true);
  3596. $grade = $this->input->get('grade', true);
  3597. $color = $this->input->get('color', true);
  3598. $lowe = $this->input->get('lowe', true);
  3599. $sku = $this->input->get('sku', true);
  3600. $warehouse = $this->input->get('warehouse', true);
  3601. $purchase = $this->input->get('purchase', true);
  3602. $ktime = $this->input->get('ktime', true);
  3603. $jtime = $this->input->get('jtime', true);
  3604. $ktime = strtotime($ktime);
  3605. $jtime = strtotime($jtime);
  3606. $where = "1=1";
  3607. $gj = "";
  3608. $ck = "";
  3609. if ($category) {
  3610. $where .= " and features like '%-$category-%'";
  3611. }
  3612. if ($size) {
  3613. $where .= " and features like '%-$size-%'";
  3614. }
  3615. if ($grade) {
  3616. $where .= " and features like '%-$grade-%'";
  3617. }
  3618. if ($color) {
  3619. $where .= " and features like '%-$color-%'";
  3620. }
  3621. if ($lowe) {
  3622. $where .= " and features like '%-$lowe-%'";
  3623. }
  3624. if ($warehouse) {
  3625. $where .= " and warehouse = '$warehouse'";
  3626. }
  3627. if ($purchase) {
  3628. $where .= " and purchase = '$purchase'";
  3629. }
  3630. if ($sku) {
  3631. $where .= " and sku = '$sku'";
  3632. }
  3633. if ($ktime && $jtime) {
  3634. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3635. }
  3636. //数据排序
  3637. $order_str = "id desc";
  3638. if (empty($page)) {
  3639. $start = 0;
  3640. $perpage = 1;
  3641. } else {
  3642. $start = ($page - 1) * $perpage;
  3643. }
  3644. $list = array();
  3645. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3646. foreach ($rows as $value) {
  3647. $ck = $this->warehouse->read($value['warehouse']);
  3648. $warehouse = $ck['title'];
  3649. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3650. $retreatwarehouse = $tkck['title'];
  3651. $gy = $this->purchase->read($value['purchase']);
  3652. $purchase = $gy['title'];
  3653. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3654. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3655. }
  3656. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3657. $titlename = "<table border=1>
  3658. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3659. <tr align='center'>
  3660. <td>仓库</td>
  3661. <td>SKU</td>
  3662. <td>产品</td>
  3663. <td>时间</td>
  3664. <td>数量</td>
  3665. </tr>
  3666. </table>";
  3667. $filename = $title . ".xls";
  3668. $tail = "";
  3669. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3670. }
  3671. }
  3672. //出库、退库导出
  3673. public function _excelct()
  3674. {
  3675. $classid = $this->classid->sku();
  3676. $pm = $classid;
  3677. $typeclass = array();
  3678. $tc = $this->typeclass->find_all();
  3679. foreach ($tc as $v) {
  3680. $typeclass[$v['id']] = $v;
  3681. }
  3682. $prc = array();
  3683. $purchase = $this->purchase->find_all();
  3684. foreach ($purchase as $k => $v) {
  3685. $prc[$v['id']] = $v['title'];
  3686. }
  3687. if (isset($_GET['excel'])) {
  3688. $wh = array();
  3689. $w = $this->warehouse->find_all('1=1', 'id,title');
  3690. foreach ($w as $v) {
  3691. $wh[$v['id']] = $v['title'];
  3692. }
  3693. $type = $this->input->get('excel', true);
  3694. $category = $this->input->get('category', true);
  3695. $size = $this->input->get('size', true);
  3696. $grade = $this->input->get('grade', true);
  3697. $color = $this->input->get('color', true);
  3698. $lowe = $this->input->get('lowe', true);
  3699. $sku = $this->input->get('sku', true);
  3700. $title = $this->input->get('title', true);
  3701. $warehouse = $this->input->get('warehouse', true);
  3702. $purchase = $this->input->get('purchase', true);
  3703. $lacetype = $this->input->get('lacetype', true);
  3704. $haircap = $this->input->get('haircap', true);
  3705. $lacecolor = $this->input->get('lacecolor', true);
  3706. $density = $this->input->get('density', true);
  3707. $details = $this->input->get('details', true);
  3708. $state = $this->input->get('state', true);
  3709. $shop = $this->input->get('shop', true);
  3710. $hairnumber = $this->input->get('hairnumber', true);
  3711. $type_leixi = $this->input->get('type', true);
  3712. $cpbz = $this->input->get('cpbz', true);
  3713. $sm = $this->input->get('sm', true);
  3714. $sid = $this->input->get('sid', true);
  3715. $ktime = $this->input->get('ktime', true);
  3716. $jtime = $this->input->get('jtime', true);
  3717. $ktime = strtotime($ktime);
  3718. $jtime = strtotime($jtime);
  3719. //$where = " 1=1 ";
  3720. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3721. $where = " sku != '' ";
  3722. $gj = "";
  3723. $ck = "";
  3724. if ($category) {
  3725. $where .= " and features like '%-$category-%'";
  3726. }
  3727. if ($size) {
  3728. $where .= " and features like '%-$size-%'";
  3729. }
  3730. if ($grade) {
  3731. $where .= " and features like '%-$grade-%'";
  3732. }
  3733. if ($color) {
  3734. $where .= " and features like '%-$color-%'";
  3735. }
  3736. if ($lowe) {
  3737. $where .= " and features like '%-$lowe-%'";
  3738. }
  3739. if ($warehouse) {
  3740. $where .= " and warehouse = '$warehouse'";
  3741. }
  3742. if ($purchase) {
  3743. $where .= " and purchase = '$purchase'";
  3744. }
  3745. if ($state) {
  3746. $where .= " and state = '$state'";
  3747. }
  3748. if ($lacetype) {
  3749. $where .= " and features like '%-$lacetype-%'";
  3750. }
  3751. if ($lacecolor) {
  3752. $where .= " and features like '%-$lacecolor-%'";
  3753. }
  3754. if ($density) {
  3755. $where .= " and features like '%-$density-%'";
  3756. }
  3757. if ($haircap) {
  3758. $where .= " and features like '%-$haircap-%'";
  3759. }
  3760. if ($details) {
  3761. $where .= " and details = '$details'";
  3762. }
  3763. if ($shop) {
  3764. $where .= " and shop like '%$shop%'";
  3765. }
  3766. if ($title) {
  3767. $title = trim($title, ' ');
  3768. $title = trim($title, ' ');
  3769. $where .= " and title like '%$title%'";
  3770. }
  3771. if (!empty($hairnumber)) {
  3772. $where .= " and features like '%-128-%' ";
  3773. if ($hairnumber < 0) {
  3774. $class_list = $this->typeclass->find_all('classid = 43');
  3775. foreach ($class_list as $v) {
  3776. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3777. }
  3778. } else {
  3779. $where .= " and features like '%-$hairnumber-%'";
  3780. }
  3781. }
  3782. if ($type_leixi) {
  3783. $where .= " and type = '$type_leixi'";
  3784. }
  3785. if ($cpbz) {
  3786. $where .= " and cpbz like '%$cpbz%' ";
  3787. }
  3788. if ($sm) {
  3789. $where .= " and sm like '%$sm%' ";
  3790. }
  3791. if ($sku) {
  3792. $sku = trim($sku, ' ');
  3793. $sku = trim($sku, ' ');
  3794. $where .= " and sku like '%$sku%'";
  3795. }
  3796. if ($ktime && $jtime) {
  3797. if ($type == 1) {
  3798. $tl = '出库';
  3799. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3800. } else if ($type == 2) {
  3801. $tl = '退库';
  3802. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3803. } else if ($type == 3) {
  3804. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3805. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3806. } else if ($type == 4) {
  3807. $tl = '出库+零售';
  3808. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3809. } else if ($type == 5) {
  3810. $tl = '零售';
  3811. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3812. }
  3813. }
  3814. $sidwhere = '';
  3815. if ($sid) {
  3816. $sd = "";
  3817. $s = explode(',', trim($sid, ','));
  3818. foreach ($s as $value) {
  3819. $sd .= " id = " . $value . " or";
  3820. }
  3821. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3822. }
  3823. //数据排序
  3824. $order_str = "time desc";
  3825. if (empty($page)) {
  3826. $start = 0;
  3827. $perpage = 1;
  3828. } else {
  3829. $start = ($page - 1) * $perpage;
  3830. }
  3831. //取得信息列表
  3832. if ($type != 3 && $type != 5) {
  3833. if ($type == 1 || $type == 4) {
  3834. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3835. foreach ($info_list as $key => $value) {
  3836. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3837. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3838. $warehouse = $this->warehouse->read($value['warehouse']);
  3839. $info_list[$key]['warehouse'] = $warehouse['title'];
  3840. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3841. $features = explode('-', trim($features, '-'));
  3842. $pm = $classid;
  3843. foreach ($features as $k => $v) {
  3844. if ($v != 0) {
  3845. if (!isset($typeclass[$v])) {
  3846. continue;
  3847. }
  3848. if (isset($pm[$typeclass[$v]['classid']])) {
  3849. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3850. $tz = explode('|', $typeclass[$v]['zh']);
  3851. $pm[$typeclass[$v]['classid']] = $tz[0];
  3852. } else {
  3853. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3854. }
  3855. }
  3856. }
  3857. }
  3858. $zh = implode(" ", $pm);
  3859. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3860. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3861. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3862. $info_list[$key]['features'] = $zh;
  3863. }
  3864. $final_list = [];
  3865. foreach($info_list as $k=>$v){
  3866. $number = "";
  3867. if(!empty($v['orderinfo'])){
  3868. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3869. if(!empty($tmp_info['number'])){
  3870. $number = $tmp_info['number'];
  3871. }
  3872. }
  3873. $final_list[] = [
  3874. 'warehouse'=>$v['warehouse'],
  3875. 'purchase'=>$v['purchase'],
  3876. 'sku'=>$v['sku'],
  3877. 'title'=>$v['title'],
  3878. 'features'=>$v['features'],
  3879. 'label'=>$v['label'],
  3880. 'orderinfo'=>$v['orderinfo'],
  3881. 'number'=>$number,
  3882. 'waybill'=>$v['waybill'],
  3883. 'outk'=>$v['outk'],
  3884. ];
  3885. }
  3886. } else {
  3887. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3888. foreach ($info_list as $key => $value) {
  3889. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3890. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3891. $warehouse = $this->warehouse->read($value['warehouse']);
  3892. $info_list[$key]['warehouse'] = $warehouse['title'];
  3893. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3894. $features = explode('-', trim($features, '-'));
  3895. $pm = $classid;
  3896. foreach ($features as $k => $v) {
  3897. if ($v != 0) {
  3898. if (!isset($typeclass[$v])) {
  3899. continue;
  3900. }
  3901. if (isset($pm[$typeclass[$v]['classid']])) {
  3902. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3903. $tz = explode('|', $typeclass[$v]['zh']);
  3904. $pm[$typeclass[$v]['classid']] = $tz[0];
  3905. } else {
  3906. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3907. }
  3908. }
  3909. }
  3910. }
  3911. $zh = implode(" ", $pm);
  3912. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3913. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3914. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3915. $info_list[$key]['features'] = $zh;
  3916. }
  3917. $final_list = [];
  3918. foreach($info_list as $k=>$v){
  3919. $number = "";
  3920. if(!empty($v['orderinfo'])){
  3921. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3922. if(!empty($tmp_info['number'])){
  3923. $number = $tmp_info['number'];
  3924. }
  3925. }
  3926. $final_list[] = [
  3927. 'warehouse'=>$v['warehouse'],
  3928. 'purchase'=>$v['purchase'],
  3929. 'sku'=>$v['sku'],
  3930. 'title'=>$v['title'],
  3931. 'features'=>$v['features'],
  3932. 'label'=>$v['label'],
  3933. 'orderinfo'=>$v['orderinfo'],
  3934. 'number'=>$number,
  3935. 'waybill'=>$v['waybill'],
  3936. 'retreat'=>$v['retreat'],
  3937. ];
  3938. }
  3939. }
  3940. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3941. $titlename = "<table border=1>
  3942. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3943. <tr align='center'>
  3944. <td>仓库</td>
  3945. <td>供应商</td>
  3946. <td>SKU</td>
  3947. <td>商品名称</td>
  3948. <td>商品中文</td>
  3949. <td>标签</td>
  3950. <td>订单号</td>
  3951. <td>订单编码</td>
  3952. <td>运单号</td>
  3953. <td>" . $tl . "时间(中国时间)</td>
  3954. </tr>
  3955. </table>";
  3956. $filename = $title . ".xls";
  3957. $tail = "";
  3958. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3959. } else if ($type == 5) {
  3960. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3961. foreach ($info_list as $key => $value) {
  3962. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3963. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3964. $warehouse = $this->warehouse->read($value['warehouse']);
  3965. $info_list[$key]['warehouse'] = $warehouse['title'];
  3966. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3967. $features = explode('-', trim($features, '-'));
  3968. $pm = $classid;
  3969. foreach ($features as $k => $v) {
  3970. if ($v != 0) {
  3971. if (!isset($typeclass[$v])) {
  3972. continue;
  3973. }
  3974. if (isset($pm[$typeclass[$v]['classid']])) {
  3975. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3976. $tz = explode('|', $typeclass[$v]['zh']);
  3977. $pm[$typeclass[$v]['classid']] = $tz[0];
  3978. } else {
  3979. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3980. }
  3981. }
  3982. }
  3983. }
  3984. $zh = implode(" ", $pm);
  3985. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3986. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3987. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3988. $info_list[$key]['features'] = $zh;
  3989. }
  3990. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3991. $titlename = "<table border=1>
  3992. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3993. <tr align='center'>
  3994. <td>仓库</td>
  3995. <td>供应商</td>
  3996. <td>SKU</td>
  3997. <td>商品名称</td>
  3998. <td>商品中文</td>
  3999. <td>标签</td>
  4000. <td>" . $tl . "时间(中国时间)</td>
  4001. </tr>
  4002. </table>";
  4003. $filename = $title . ".xls";
  4004. $tail = "";
  4005. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4006. } else {
  4007. /**
  4008. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4009. $rows = array();$list = array();
  4010. foreach ($info_list as $key=>$value)
  4011. {
  4012. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4013. }
  4014. **/
  4015. $wh = array();
  4016. $w = $this->warehouse->find_all('1=1', 'id,title');
  4017. foreach ($w as $v) {
  4018. $wh[$v['id']] = $v['title'];
  4019. }
  4020. $wt = array();
  4021. $whlabel_type = $this->whlabel_type->find_all();
  4022. foreach ($whlabel_type as $v) {
  4023. $wt[$v['id']] = $v['title'];
  4024. }
  4025. $classid = $this->classid->sku();
  4026. $list = array();
  4027. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4028. foreach ($rows as $key => $value) {
  4029. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4030. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4031. $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');
  4032. $details = array();
  4033. $cpid = array();
  4034. $cpbz = array();
  4035. $c = 0;
  4036. $g = 0;
  4037. $x = 0;
  4038. $t = 0;
  4039. $s = 0;
  4040. $q = 0;
  4041. foreach ($sd as $k => $v) {
  4042. if ($v['state'] == 0) {
  4043. $c++;
  4044. }
  4045. if ($v['state'] != 9) {
  4046. $g++;
  4047. }
  4048. if ($v['outk'] > 1) {
  4049. $x++;
  4050. }
  4051. if ($v['retreat'] > 0) {
  4052. $t++;
  4053. }
  4054. if ($v['state'] == 8) {
  4055. $s++;
  4056. }
  4057. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4058. $q++;
  4059. }
  4060. $details[$v['details']] = $v['details'];
  4061. if ($v['cpid'] != 0) {
  4062. $cpid[$v['cpid']] = $v['cpid'];
  4063. }
  4064. if ($v['cpbz'] != '') {
  4065. $cpbz[$v['cpbz']] = $v['cpbz'];
  4066. }
  4067. }
  4068. if (isset($wt[$value['type']])) {
  4069. $rows[$key]['type'] = $wt[$value['type']];
  4070. } else {
  4071. $rows[$key]['type'] = '未设置';
  4072. }
  4073. $rows[$key]['details'] = implode("、", $details);
  4074. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4075. $ftime = time() - 15 * 24 * 3600;
  4076. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4077. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4078. $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);
  4079. $rows[$key]['c'] = $c;
  4080. $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);
  4081. $rows[$key]['t'] = $t;
  4082. $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'] . '"');
  4083. $rows[$key]['z'] = $z;
  4084. // $jm = $classid;
  4085. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4086. $features = explode('-', trim($features, '-'));
  4087. // $pm = $classid;
  4088. // foreach ($features as $k => $v) {
  4089. // if ($v != 0) {
  4090. // if (!isset($typeclass[$v])) {
  4091. // continue;
  4092. // }
  4093. // if (isset($pm[$typeclass[$v]['classid']])) {
  4094. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4095. // $tz = explode('|', $typeclass[$v]['zh']);
  4096. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4097. // } else {
  4098. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4099. // }
  4100. // if (isset($jm[$typeclass[$v]['classid']])) {
  4101. // if ($typeclass[$v]['jm']) {
  4102. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4103. // }
  4104. // }
  4105. // }
  4106. // }
  4107. // }
  4108. // $zh = implode(" ", $pm);
  4109. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4110. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4111. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4112. // $rows[$key]['features'] = $zh;
  4113. // $jm = array_filter($jm); //去除空值
  4114. // $jm = implode("-", $jm);
  4115. // $rows[$key]['jm'] = $jm;
  4116. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4117. }
  4118. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4119. // echo "<pre>";
  4120. // print_r($tmp_list);
  4121. // die;
  4122. $final_list =[];
  4123. foreach($tmp_list as $k=>$v){
  4124. $final_list[] = [
  4125. "warehouse"=>$v['warehouse'],
  4126. "purchase"=>$v['purchase'],
  4127. "details"=>$v['details'],
  4128. "cpid"=>$v['cpid'],
  4129. "sku"=>$v['sku'],
  4130. "title"=>$v['title'],
  4131. "features"=>$v['pm'],
  4132. "cpbz"=>$v['cpbz'],
  4133. "sm"=>$v['sm'],
  4134. "type"=>$v['type'],
  4135. "g"=>$v["g"],
  4136. "c"=>$v["c"],
  4137. "x"=>$v["x"],
  4138. "t"=>$v["t"],
  4139. "z"=>$v["z"],
  4140. "jm"=>$v["jm"],
  4141. "weight"=>$v["weight"],
  4142. "asd"=>$v["asd"],
  4143. ];
  4144. }
  4145. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4146. $titlename = "<table border=1>
  4147. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4148. <tr align='center'>
  4149. <td>仓库</td>
  4150. <td>供应商</td>
  4151. <td>位置</td>
  4152. <td>库存编码</td>
  4153. <td>SKU</td>
  4154. <td>商品名称</td>
  4155. <td>商品中文</td>
  4156. <td>产品备注</td>
  4157. <td>说明</td>
  4158. <td>类型</td>
  4159. <td>入库总量</td>
  4160. <td>库存数量</td>
  4161. <td>销售数量</td>
  4162. <td>退货数量</td>
  4163. <td>占单数量</td>
  4164. <td>料号</td>
  4165. <td>重量</td>
  4166. <td>类目</td>
  4167. </tr>
  4168. </table>";
  4169. $filename = $title . ".xls";
  4170. $tail = "";
  4171. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4172. }
  4173. }
  4174. }
  4175. //出库+入库数据整合
  4176. public function _excelcr()
  4177. {
  4178. if (isset($_GET['excel'])) {
  4179. $type = $this->input->get('excel', true);
  4180. $category = $this->input->get('category', true);
  4181. $size = $this->input->get('size', true);
  4182. $grade = $this->input->get('grade', true);
  4183. $color = $this->input->get('color', true);
  4184. $lowe = $this->input->get('lowe', true);
  4185. $sku = $this->input->get('sku', true);
  4186. $warehouse = $this->input->get('warehouse', true);
  4187. $purchase = $this->input->get('purchase', true);
  4188. $state = $this->input->get('state', true);
  4189. $sid = $this->input->get('sid', true);
  4190. $ktime = $this->input->get('ktime', true);
  4191. $jtime = $this->input->get('jtime', true);
  4192. $ktime = strtotime($ktime);
  4193. $jtime = strtotime($jtime);
  4194. $where = "1=1";
  4195. $gj = "";
  4196. $ck = "";
  4197. if ($category) {
  4198. $where .= " and features like '%-$category-%'";
  4199. }
  4200. if ($size) {
  4201. $where .= " and features like '%-$size-%'";
  4202. }
  4203. if ($grade) {
  4204. $where .= " and features like '%-$grade-%'";
  4205. }
  4206. if ($color) {
  4207. $where .= " and features like '%-$color-%'";
  4208. }
  4209. if ($lowe) {
  4210. $where .= " and features like '%-$lowe-%'";
  4211. }
  4212. if ($warehouse) {
  4213. $where .= " and warehouse = '$warehouse'";
  4214. }
  4215. if ($purchase) {
  4216. $where .= " and purchase = '$purchase'";
  4217. }
  4218. if ($state) {
  4219. $where .= " and state = '$state'";
  4220. }
  4221. if ($sku) {
  4222. $where .= " and sku like '%$sku%'";
  4223. }
  4224. if ($ktime && $jtime) {
  4225. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4226. }
  4227. $sidwhere = '';
  4228. if ($sid) {
  4229. $sd = "";
  4230. $s = explode(',', trim($sid, ','));
  4231. foreach ($s as $value) {
  4232. $sd .= " id = " . $value . " or";
  4233. }
  4234. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4235. }
  4236. //取得信息列表
  4237. $timeread = $ktime;
  4238. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4239. $timelist = array();
  4240. for ($i = 0; $i < $timenum; $i++) {
  4241. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4242. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4243. }
  4244. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4245. //echo "<pre>";
  4246. //print_r($info_list);
  4247. //exit();
  4248. $rows = array();
  4249. $list = array();
  4250. foreach ($info_list as $key => $value) {
  4251. $thistime = $timelist;
  4252. if (isset($rows[strtolower($value['sku'])])) {
  4253. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4254. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4255. }
  4256. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4257. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4258. }
  4259. } else {
  4260. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4261. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4262. }
  4263. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4264. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4265. }
  4266. $rows[strtolower($value['sku'])] = $thistime;
  4267. }
  4268. }
  4269. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4270. <head>
  4271. <!--[if gte mso 9]><xml>
  4272. <x:ExcelWorkbook>
  4273. <x:ExcelWorksheets>
  4274. <x:ExcelWorksheet>
  4275. <x:Name>EXCEL</x:Name>
  4276. <x:WorksheetOptions>
  4277. <x:Print>
  4278. <x:ValidPrinterInfo />
  4279. </x:Print>
  4280. </x:WorksheetOptions>
  4281. </x:ExcelWorksheet>
  4282. </x:ExcelWorksheets>
  4283. </x:ExcelWorkbook>
  4284. </xml>
  4285. <![endif]-->
  4286. </head><body>";
  4287. $str .= "<table border=1><tr><td>SKU</td>";
  4288. foreach ($timelist as $k => $v) {
  4289. $str .= "<td>" . $k . "出库</td>";
  4290. $str .= "<td>" . $k . "入库</td>";
  4291. }
  4292. $str .= "</tr></table>";
  4293. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4294. foreach ($rows as $key => $val) {
  4295. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4296. foreach ($val as $k => $v) {
  4297. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4298. if ($val[$k]['r'] > 0) {
  4299. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4300. } else {
  4301. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4302. }
  4303. }
  4304. $str .= "</tr>";
  4305. }
  4306. $str .= "</table>";
  4307. $str .= "</body></html>";
  4308. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4309. header("Content-type: application/octet-stream");
  4310. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4311. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4312. header("Pragma: no-cache");
  4313. header("Expires: 0");
  4314. exit($str);
  4315. }
  4316. }
  4317. //数量调整模板导出
  4318. public function _presetout()
  4319. {
  4320. if (isset($_GET['excel'])) {
  4321. $where = "sku != 'Preset' and purchase != 0";
  4322. //数据排序
  4323. $order_str = "id desc";
  4324. if (empty($page)) {
  4325. $start = 0;
  4326. $perpage = 1;
  4327. } else {
  4328. $start = ($page - 1) * $perpage;
  4329. }
  4330. //取得信息列表
  4331. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4332. $rows = array();
  4333. $list = array();
  4334. foreach ($info_list as $value) {
  4335. $warehouse = $this->warehouse->read($value['warehouse']);
  4336. $number = $value['number'];
  4337. $ftime = time() - 15 * 24 * 3600;
  4338. $purchase = $this->purchase->read($value['purchase']);
  4339. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4340. }
  4341. $title = "库存模板";
  4342. $titlename = "<table border=1>
  4343. <tr align='center'>
  4344. <td>仓库</td>
  4345. <td>供应商编码</td>
  4346. <td>SKU</td>
  4347. <td>增减数量(正数或负数)</td>
  4348. <td>增减备注</td>
  4349. <td>扣减方式:0减少库存1删除库存</td>
  4350. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4351. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4352. </tr>
  4353. </table>";
  4354. $filename = $title . ".xls";
  4355. $tail = "";
  4356. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4357. }
  4358. }
  4359. //数量调整模板导入
  4360. public function _presetedit()
  4361. {
  4362. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4363. $config['upload_path'] = '.' . $dir;
  4364. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4365. $config['allowed_types'] = 'xls|xlsx|csv';
  4366. $config['max_size'] = 10240;
  4367. $this->load->library('upload', $config);
  4368. $this->upload->initialize($config);
  4369. if ($this->upload->do_upload('userfile')) {
  4370. $full_path = $dir . $this->upload->data('file_name');
  4371. $fileName = '.' . $full_path;
  4372. if (!file_exists($fileName)) {
  4373. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4374. exit;
  4375. } else {
  4376. require_once "./data/excel/PHPExcel/IOFactory.php";
  4377. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4378. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4379. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4380. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4381. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4382. ++$column; //如果列数大于26行
  4383. $list = array();
  4384. for ($i = 2; $i <= $row; $i++) // 行数循环
  4385. {
  4386. $data = array();
  4387. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4388. {
  4389. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4390. }
  4391. $list[] = $data;
  4392. }
  4393. }
  4394. $i = 0;
  4395. $j = 0;
  4396. $ed = array();
  4397. foreach ($list as $key => $value) {
  4398. $time = time();
  4399. if ($value['0'] == "") {
  4400. continue;
  4401. }
  4402. $warehouse = $this->warehouse->get_title($value['0']);
  4403. $purchase = $this->purchase->get_bm($value['1']);
  4404. $sku = $value['2'];
  4405. $num = $value['3']; //调整数量
  4406. $text = $value['4']; //扣减说明
  4407. $type = $value['5']; //调整方式0扣减1删除
  4408. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4409. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4410. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4411. if (!$purchase) //如果没有这个SKU
  4412. {
  4413. $ed[] = array($purchase . '-不存在此供应商编码');
  4414. $j++;
  4415. continue;
  4416. }
  4417. if (!$d) //如果没有这个SKU
  4418. {
  4419. $ed[] = array($sku . '-库存中不存在此SKU');
  4420. $j++;
  4421. continue;
  4422. }
  4423. if (!isset($warehouse['id'])) {
  4424. $ed[] = array($sku . '-仓库名错误!');
  4425. $j++;
  4426. continue;
  4427. }
  4428. if ($type != '0' && $type != '1') {
  4429. $ed[] = array($sku . '-扣减方式填写错误!');
  4430. $j++;
  4431. continue;
  4432. }
  4433. if ($num < 0) //扣减库存
  4434. {
  4435. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4436. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4437. $j++;
  4438. continue;
  4439. }
  4440. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4441. if (count($data) < abs($num)) {
  4442. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4443. $j++;
  4444. continue;
  4445. }
  4446. if ($type == 0) //如果扣减方式为 扣减库存
  4447. {
  4448. for ($i = 0; $i < abs($num); $i++) {
  4449. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4450. }
  4451. } else if ($type == 1) {
  4452. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4453. if (count($zt) > 0) {
  4454. $ed[] = array($sku . '-有在途库存无法删除!');
  4455. $j++;
  4456. continue;
  4457. }
  4458. for ($i = 0; $i < abs($num); $i++) {
  4459. $this->whlabel->remove($data[$i]['id']);
  4460. }
  4461. }
  4462. } else if ($num > 0) //增加库存
  4463. {
  4464. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4465. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4466. $j++;
  4467. continue;
  4468. }
  4469. $post['sku'] = $d['sku'];
  4470. $post['shop'] = $d['shop'];
  4471. $post['warehouse'] = $warehouse['id'];
  4472. $post['purchase'] = $purchase['id'];
  4473. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4474. $post['state'] = 0;
  4475. $post['title'] = $d['title'];
  4476. $post['number'] = $d['number'];
  4477. $post['features'] = $d['features'];
  4478. $post['enter'] = $time;
  4479. $post['time'] = $time; //操作时间
  4480. $post['rktype'] = $rktype;
  4481. for ($i = 0; $i < $num; $i++) {
  4482. $post['label'] = time() . rand(100, 999) . $i;
  4483. $this->whlabel->insert($post);
  4484. }
  4485. }
  4486. sleep(1); //防止入库时间一样,需要延迟1秒
  4487. }
  4488. if ($j > 0) {
  4489. $tt = date('Ymd', time());
  4490. $title = '库存导入错误信息-' . $tt;
  4491. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4492. $tail = "\n";
  4493. $filename = $title . ".xls";
  4494. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4495. $dir = '/data/excel/' . $time . '/';
  4496. $file_name = 'error_' . $time . rand(1000, 9999);
  4497. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4498. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4499. fwrite($myfile, $ecl);
  4500. fclose($myfile);
  4501. $error = $dir . $file_name . '.xls';
  4502. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4503. exit;
  4504. } else {
  4505. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4506. exit;
  4507. }
  4508. }
  4509. }
  4510. public function _presetedittwo(){
  4511. $data = $this->input->post(NULL, TRUE);
  4512. if(empty($list)){
  4513. $raw_data = $this->input->raw_input_stream;
  4514. // 解码 JSON
  4515. $data = json_decode($raw_data, true);
  4516. }
  4517. if(empty($data)){
  4518. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4519. }
  4520. $list = [];
  4521. if(isset($data['list'])){
  4522. $list = $data['list'];
  4523. }
  4524. $i = 0;
  4525. $j = 0;
  4526. $ed = array();
  4527. foreach ($list as $key => $value) {
  4528. $time = time();
  4529. if ($value['0'] == "") {
  4530. continue;
  4531. }
  4532. $warehouse = $this->warehouse->get_title($value['0']);
  4533. $purchase = $this->purchase->get_bm($value['1']);
  4534. $sku = $value['2'];
  4535. $num = $value['3']; //调整数量
  4536. $text = $value['4']; //扣减说明
  4537. $type = $value['5']; //调整方式0扣减1删除
  4538. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4539. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4540. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4541. if (!$purchase) //如果没有这个SKU
  4542. {
  4543. $ed[] = array($value['1'] . '-不存在此供应商编码');
  4544. $j++;
  4545. continue;
  4546. }
  4547. if (!$d) //如果没有这个SKU
  4548. {
  4549. $ed[] = array($sku . '-库存中不存在此SKU');
  4550. $j++;
  4551. continue;
  4552. }
  4553. if (!isset($warehouse['id'])) {
  4554. $ed[] = array($sku . '-仓库名错误!');
  4555. $j++;
  4556. continue;
  4557. }
  4558. if ($type != '0' && $type != '1') {
  4559. $ed[] = array($sku . '-扣减方式填写错误!');
  4560. $j++;
  4561. continue;
  4562. }
  4563. if ($num < 0) //扣减库存
  4564. {
  4565. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4566. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4567. $j++;
  4568. continue;
  4569. }
  4570. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4571. if (count($data) < abs($num)) {
  4572. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4573. $j++;
  4574. continue;
  4575. }
  4576. if ($type == 0) //如果扣减方式为 扣减库存
  4577. {
  4578. for ($i = 0; $i < abs($num); $i++) {
  4579. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4580. }
  4581. } else if ($type == 1) {
  4582. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4583. if (count($zt) > 0) {
  4584. $ed[] = array($sku . '-有在途库存无法删除!');
  4585. $j++;
  4586. continue;
  4587. }
  4588. for ($i = 0; $i < abs($num); $i++) {
  4589. $this->whlabel->remove($data[$i]['id']);
  4590. }
  4591. }
  4592. } else if ($num > 0) //增加库存
  4593. {
  4594. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4595. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4596. $j++;
  4597. continue;
  4598. }
  4599. $post['sku'] = $d['sku'];
  4600. $post['shop'] = $d['shop'];
  4601. $post['warehouse'] = $warehouse['id'];
  4602. $post['purchase'] = $purchase['id'];
  4603. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4604. $post['state'] = 0;
  4605. $post['title'] = $d['title'];
  4606. $post['number'] = $d['number'];
  4607. $post['features'] = $d['features'];
  4608. $post['enter'] = $time;
  4609. $post['time'] = $time; //操作时间
  4610. $post['rktype'] = $rktype;
  4611. $post['sku_master_id'] = $d['sku_master_id'];
  4612. $post['sku_shop_id'] = $d['sku_shop_id'];
  4613. for ($i = 0; $i < $num; $i++) {
  4614. $post['label'] = time() . rand(100, 999) . $i;
  4615. $this->whlabel->insert($post);
  4616. }
  4617. }
  4618. sleep(1); //防止入库时间一样,需要延迟1秒
  4619. }
  4620. if ($j > 0) {
  4621. $tt = date('Ymd', time());
  4622. $title = '库存导入错误信息-' . $tt;
  4623. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4624. $tail = "\n";
  4625. $filename = $title . ".xls";
  4626. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4627. $dir = '/data/excel/' . $time . '/';
  4628. $file_name = 'error_' . $time . rand(1000, 9999);
  4629. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4630. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4631. fwrite($myfile, $ecl);
  4632. fclose($myfile);
  4633. $error = $dir . $file_name . '.xls';
  4634. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4635. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4636. exit;
  4637. } else {
  4638. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4639. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4640. exit;
  4641. }
  4642. }
  4643. //笛卡儿积
  4644. function cp($ps, $sets, $list)
  4645. {
  4646. $result = array();
  4647. $j = 0;
  4648. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4649. if ($i == 0) {
  4650. $result = $sets[$i];
  4651. }
  4652. $tmp = array();
  4653. foreach ($result as $res) {
  4654. foreach ($sets[$i + 1] as $set) {
  4655. $tmp[] = $res . ',' . $set;
  4656. }
  4657. }
  4658. $result = $tmp;
  4659. }
  4660. $this->db->trans_begin();
  4661. foreach ($result as $v) {
  4662. $post = array();
  4663. $title = "";
  4664. $num = "";
  4665. $data = explode(',', $v);
  4666. for ($i = 0; $i < count($list); $i++) {
  4667. $post[$list[$i]] = $data[$i];
  4668. $typeclass = $this->typeclass->read($data[$i]);
  4669. $title = $title . $typeclass['title'] . " ";
  4670. if ($data[$i] != 0) {
  4671. $num .= $data[$i]; //所有数据ID拼接
  4672. }
  4673. }
  4674. foreach ($ps as $kp => $vp) {
  4675. $post[$kp] = $vp;
  4676. }
  4677. $post['number'] = $num;
  4678. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4679. if ($info_list) {
  4680. $j++;
  4681. } else {
  4682. $skunum = $this->whlabel->find_count();
  4683. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4684. $post['title'] = rtrim($title, ' ');
  4685. $this->whlabel->insert($post);
  4686. }
  4687. }
  4688. if ($this->db->trans_status() === FALSE) {
  4689. $this->db->trans_commit();
  4690. return NULL;
  4691. } else {
  4692. $this->db->trans_commit();
  4693. return $j;
  4694. }
  4695. }
  4696. public function _kj($arg_array)
  4697. {
  4698. if (isset($_POST['sku'])) {
  4699. $time = time();
  4700. $sku = $this->input->post('sku', true);
  4701. $warehouse = $this->input->post('warehouse', true);
  4702. $num = $this->input->post('num', true);
  4703. $text = $this->input->post('text', true);
  4704. $purchase = $this->input->post('purchase', true);
  4705. $cktype = $this->input->post('cktype', true);
  4706. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4707. if ($cktype != 1 && $text == '') {
  4708. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4709. exit;
  4710. }
  4711. if ($num > count($order)) {
  4712. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4713. exit;
  4714. } else {
  4715. for ($i = 0; $i < $num; $i++) {
  4716. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4717. }
  4718. }
  4719. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4720. exit;
  4721. }
  4722. $uid = $this->whlabel->read($arg_array[0]);
  4723. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4724. $this->data['data'] = $uid;
  4725. $this->_Template('whlabel_kj', $this->data);
  4726. }
  4727. public function _summary($arg_array)
  4728. {
  4729. $prc = array();
  4730. $purchase = $this->purchase->find_all();
  4731. foreach ($purchase as $k => $v) {
  4732. $prc[$v['id']] = $v['title'];
  4733. }
  4734. if (isset($_GET['excel'])) {
  4735. $ktime = $this->input->get('ktime', true);
  4736. $jtime = $this->input->get('jtime', true);
  4737. $ktime = strtotime($ktime);
  4738. $jtime = strtotime($jtime);
  4739. $where = "1=1";
  4740. if ($ktime && $jtime) {
  4741. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4742. }
  4743. //数据排序
  4744. $order_str = "time desc";
  4745. if (empty($page)) {
  4746. $start = 0;
  4747. $perpage = 1;
  4748. } else {
  4749. $start = ($page - 1) * $perpage;
  4750. }
  4751. //取得信息列表
  4752. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4753. foreach ($info_list as $key => $value) {
  4754. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4755. $warehouse = $this->warehouse->read($value['warehouse']);
  4756. $info_list[$key]['warehouse'] = $warehouse['title'];
  4757. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4758. $details = array();
  4759. $cpid = array();
  4760. foreach ($x as $k => $v) {
  4761. if ($v['details'] != '') {
  4762. $details[$v['details']] = $v['details'];
  4763. }
  4764. if ($v['cpid'] != 0) {
  4765. $cpid[$v['cpid']] = $v['cpid'];
  4766. }
  4767. }
  4768. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4769. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4770. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4771. $info_list[$key]['s'] = $s;
  4772. $info_list[$key]['x'] = count($x);
  4773. }
  4774. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4775. $titlename = "<table border=1>
  4776. <tr align='center'>
  4777. <td>仓库</td>
  4778. <td>供应商</td>
  4779. <td>出库位置</td>
  4780. <td>出库编码</td>
  4781. <td>SKU</td>
  4782. <td>产品名</td>
  4783. <td>总剩余库存</td>
  4784. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4785. </tr>
  4786. </table>";
  4787. $filename = $title . ".xls";
  4788. $tail = "";
  4789. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4790. }
  4791. }
  4792. //usps发货清单
  4793. public function _manifest()
  4794. {
  4795. if (isset($_POST['manifest'])) {
  4796. $wltext = $this->input->post('wltext', true);
  4797. $time = time() - 16 * 3600;
  4798. $ptime = strtotime(date('Y-m-d', $time));
  4799. $waybill = array();
  4800. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4801. foreach ($fullorder as $v) {
  4802. $waybill[$v['waybill']] = $v['waybill'];
  4803. }
  4804. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4805. foreach ($fullordersmt as $v) {
  4806. $waybill[$v['waybill']] = $v['waybill'];
  4807. }
  4808. $wltext = explode(';', $wltext);
  4809. foreach ($wltext as $v) {
  4810. if (isset($waybill[$v])) {
  4811. unset($waybill[$v]);
  4812. }
  4813. }
  4814. $data = $this->usps->get_manifest($waybill);
  4815. if (isset($data['Description'])) {
  4816. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4817. exit;
  4818. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4819. $bctime = date('Ymd', time());
  4820. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4821. echo json_encode(array('msg' => $pdf, 'success' => true));
  4822. exit;
  4823. } else {
  4824. echo json_encode(array('msg' => $data, 'success' => false));
  4825. exit;
  4826. }
  4827. }
  4828. }
  4829. public function _pdf($pdf, $title, $bctime)
  4830. {
  4831. $pdf_path = './data/pdf/' . $bctime . '/';
  4832. $file_base64 = $pdf;
  4833. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4834. $file_base64 = base64_decode($file_base64);
  4835. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4836. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4837. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4838. }
  4839. /**
  4840. *
  4841. *
  4842. *
  4843. 进销存占单异常索引
  4844. *
  4845. *
  4846. *
  4847. **/
  4848. public function _abnormal()
  4849. {
  4850. $post = $this->input->post(NULL, TRUE);
  4851. if (isset($post['page'])) {
  4852. $page = $this->input->post('page', true);
  4853. $perpage = $this->input->post('perpage', true);
  4854. $sku = $this->input->post('sku', true);
  4855. $where = "1=1";
  4856. //数据排序
  4857. $order_str = "id desc";
  4858. if (empty($page)) {
  4859. $start = 0;
  4860. $perpage = 1;
  4861. } else {
  4862. $start = ($page - 1) * $perpage;
  4863. }
  4864. //取得信息列表
  4865. $info_list = $this->whlabel->find_all($where, '*');
  4866. $rows = array();
  4867. $list = array();
  4868. foreach ($info_list as $key => $value) {
  4869. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4870. }
  4871. foreach ($rows as $value) {
  4872. $warehouse = $this->warehouse->read($value['warehouse']);
  4873. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4874. $number = $value['number'];
  4875. $ftime = time() - 15 * 24 * 3600;
  4876. if ($value['shop'] != '') {
  4877. $shop = $value['shop'];
  4878. $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');
  4879. $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');
  4880. $order = array_merge($orderdlz, $ordersmt);
  4881. $od = 0;
  4882. $a = '';
  4883. $orid = '';
  4884. foreach ($order as $v) {
  4885. $or = explode('|', ltrim($v['whlabel'], '|'));
  4886. for ($i = 0; $i < count($or); $i++) {
  4887. $orod = explode('-', $or[$i]);
  4888. if ($orod[0] == $number) {
  4889. $od += $orod[1];
  4890. }
  4891. }
  4892. $orid .= $v['number'] . '-';
  4893. }
  4894. } else {
  4895. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4896. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4897. $order = array_merge($orderdlz, $ordersmt);
  4898. $od = 0;
  4899. $a = '';
  4900. $orid = '';
  4901. $qt = array();
  4902. foreach ($order as $v) {
  4903. $or = explode('|', ltrim($v['whlabel'], '|'));
  4904. for ($i = 0; $i < count($or); $i++) {
  4905. $orod = explode('-', $or[$i]);
  4906. if ($orod[0] == $number) {
  4907. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4908. if ($czzs > 0) {
  4909. if (isset($qt[$v['shop']])) {
  4910. if ($qt[$v['shop']] < $orod[1]) {
  4911. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4912. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4913. } else {
  4914. $qt[$v['shop']] -= $orod[1];
  4915. }
  4916. } else {
  4917. $qt[$v['shop']] = $czzs;
  4918. }
  4919. } else {
  4920. $od += $orod[1];
  4921. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4922. }
  4923. }
  4924. }
  4925. }
  4926. }
  4927. $z = $od . '(' . $orid . ')'; //查看订单号
  4928. //$z = $od;
  4929. if ($od > $c) {
  4930. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4931. }
  4932. }
  4933. $listdata = array_slice($list, $start, $perpage);
  4934. $total = count($list);
  4935. $pagenum = ceil($total / $perpage);
  4936. $over = $total - ($start + $perpage);
  4937. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4938. echo json_encode($rows);
  4939. exit;
  4940. }
  4941. $this->_Template('whlabel_abnormal', $this->data);
  4942. }
  4943. /**
  4944. *
  4945. *
  4946. *
  4947. 进销存占单异常索引
  4948. *
  4949. *
  4950. *
  4951. **/
  4952. public function _error()
  4953. {
  4954. $post = $this->input->post(NULL, TRUE);
  4955. if (isset($post['page'])) {
  4956. $page = $this->input->post('page', true);
  4957. $perpage = $this->input->post('perpage', true);
  4958. $sku = $this->input->post('sku', true);
  4959. $warehouse = $this->input->post('warehouse', true);
  4960. $ktime = $this->input->post('ktime', true);
  4961. $jtime = $this->input->post('jtime', true);
  4962. $ktime = strtotime($ktime);
  4963. $jtime = strtotime($jtime);
  4964. $where = "sku != 'Preset'";
  4965. $gj = '';
  4966. if ($sku) {
  4967. $where .= " and sku like '%$sku%'";
  4968. } else {
  4969. if ($ktime && $jtime) {
  4970. $gj = " and time > '$ktime' and time < '$jtime'";
  4971. }
  4972. }
  4973. if ($warehouse) {
  4974. $where .= " and warehouse = '$warehouse'";
  4975. }
  4976. //数据排序
  4977. $order_str = "id desc";
  4978. if (empty($page)) {
  4979. $start = 0;
  4980. $perpage = 1;
  4981. } else {
  4982. $start = ($page - 1) * $perpage;
  4983. }
  4984. //取得信息列表
  4985. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4986. $rows = array();
  4987. $list = array();
  4988. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4989. // foreach ($info_list as $value)
  4990. // {
  4991. // $warehouse = $this->warehouse->read($value['warehouse']);
  4992. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4993. // $number = $value['number'];$ftime = time()-15*24*3600;
  4994. // if($c < 1)
  4995. // {
  4996. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4997. // }
  4998. // }
  4999. $warehouse_list = $this->warehouse->find_all();
  5000. $warehouse_list = array_column($warehouse_list, null, 'id');
  5001. foreach ($info_list as $value) {
  5002. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5003. 'title' => "",
  5004. ];
  5005. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5006. $number = $value['number'];
  5007. $ftime = time() - 15 * 24 * 3600;
  5008. if ($c < 1) {
  5009. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5010. }
  5011. }
  5012. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5013. // $query = $this->db->query($sql);
  5014. // $info_list = $query->result_array();
  5015. // $sql_two = "select title,id from crowd_warehouse";
  5016. // $query_two = $this->db->query($sql_two);
  5017. // $warehouse_list = $query_two->result_array();
  5018. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5019. // foreach ($info_list as $value)
  5020. // {
  5021. // if(isset($warehouse_arr[$value['warehouse']])){
  5022. // $warehouse = $warehouse_arr[$value['warehouse']];
  5023. // }else{
  5024. // $warehouse = [
  5025. // 'id'=>0,
  5026. // 'title'=>"异常",
  5027. // ];
  5028. // }
  5029. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5030. // $number = $value['number'];$ftime = time()-15*24*3600;
  5031. // if($c < 1)
  5032. // {
  5033. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5034. // }
  5035. // }
  5036. $listdata = array_slice($list, $start, $perpage);
  5037. $total = count($list);
  5038. $pagenum = ceil($total / $perpage);
  5039. $over = $total - ($start + $perpage);
  5040. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5041. echo json_encode($rows);
  5042. exit;
  5043. }
  5044. if (isset($post['s'])) {
  5045. $id_arr = $this->input->post('s');
  5046. $id_arr = explode(',', trim($id_arr, ','));
  5047. if (!$id_arr) {
  5048. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5049. exit;
  5050. }
  5051. //循环删除记录
  5052. foreach ($id_arr as $v) {
  5053. $dd = $this->whlabel->read($v);
  5054. if (!isset($dd['id'])) {
  5055. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5056. exit;
  5057. }
  5058. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5059. if (isset($zt[0])) {
  5060. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5061. exit;
  5062. }
  5063. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5064. foreach ($deldd as $vv) {
  5065. $this->whlabel->remove($vv['id']);
  5066. }
  5067. }
  5068. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5069. exit;
  5070. }
  5071. $this->_Template('whlabel_error', $this->data);
  5072. }
  5073. public function _errorexcel()
  5074. {
  5075. $post = $this->input->post(NULL, TRUE);
  5076. if (isset($_GET['page'])) {
  5077. $page = $this->input->get('page', true);
  5078. $perpage = $this->input->get('perpage', true);
  5079. $sku = $this->input->get('sku', true);
  5080. $warehouse = $this->input->get('warehouse', true);
  5081. $ktime = $this->input->get('ktime', true);
  5082. $jtime = $this->input->get('jtime', true);
  5083. $ktime = strtotime($ktime);
  5084. $jtime = strtotime($jtime);
  5085. $where = "sku != 'Preset'";
  5086. $gj = '';
  5087. if ($sku) {
  5088. $where .= " and sku like '%$sku%'";
  5089. } else {
  5090. if ($ktime && $jtime) {
  5091. $gj = " and time > '$ktime' and time < '$jtime'";
  5092. }
  5093. }
  5094. if ($warehouse) {
  5095. $where .= " and warehouse = '$warehouse'";
  5096. }
  5097. //数据排序
  5098. $order_str = "id desc";
  5099. if (empty($page)) {
  5100. $start = 0;
  5101. $perpage = 1;
  5102. } else {
  5103. $start = ($page - 1) * $perpage;
  5104. }
  5105. //取得信息列表
  5106. $rows = array();
  5107. $list = array();
  5108. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5109. foreach ($info_list as $value) {
  5110. $warehouse = $this->warehouse->read($value['warehouse']);
  5111. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5112. $number = $value['number'];
  5113. $ftime = time() - 15 * 24 * 3600;
  5114. if ($c < 1) {
  5115. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5116. }
  5117. }
  5118. $title = "0库存汇总";
  5119. $titlename = "<table border=1>
  5120. <tr align='center'>
  5121. <td>仓库</td>
  5122. <td>SKU</td>
  5123. <td>产品</td>
  5124. <td>当前库存</td>
  5125. </tr>
  5126. </table>";
  5127. $filename = $title . ".xls";
  5128. $tail = "";
  5129. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5130. }
  5131. }
  5132. /**
  5133. *
  5134. *
  5135. * 占单
  5136. *
  5137. *
  5138. **/
  5139. public function _kcyz()
  5140. {
  5141. $post = $this->input->post(NULL, TRUE);
  5142. if (isset($post['warehouse'])) {
  5143. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5144. exit; //不再使用
  5145. $warehouse = $this->input->post('warehouse', true);
  5146. $whlabel = $this->input->post('whlabel', true);
  5147. $id = $this->input->post('id', true);
  5148. $shop = $this->input->post('shop', true);
  5149. $number = $this->input->post('number', true);
  5150. if (!$whlabel || $whlabel == '|') {
  5151. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5152. exit;
  5153. }
  5154. $pp = explode('|', trim($whlabel, '|'));
  5155. $x = 0;
  5156. $save = array();
  5157. foreach ($pp as $va) {
  5158. $num = explode('-', $va);
  5159. if ($number) {
  5160. $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 = '')"); //通用
  5161. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5162. } else {
  5163. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5164. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5165. }
  5166. $x++;
  5167. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5168. $save[] = $x - 1;
  5169. continue; //提前先加X不然出错,所以要减1
  5170. }
  5171. }
  5172. if (isset($save[0])) {
  5173. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5174. exit;
  5175. } else {
  5176. echo json_encode(array('success' => true));
  5177. exit;
  5178. }
  5179. }
  5180. }
  5181. public function _db()
  5182. {
  5183. $post = $this->input->post(NULL, TRUE);
  5184. if (isset($post['page'])) {
  5185. $page = $this->input->post('page', true);
  5186. $perpage = $this->input->post('perpage', true);
  5187. $sku = $this->input->post('sku', true);
  5188. $number = $this->input->post('number', true);
  5189. $warehouse = $this->input->post('warehouse', true);
  5190. $purchase = $this->input->post('purchase', true);
  5191. $orderinfo = $this->input->post('orderinfo', true);
  5192. $waybill = $this->input->post('waybill', true);
  5193. $category = $this->input->post('category', true);
  5194. $size = $this->input->post('size', true);
  5195. $grade = $this->input->post('grade', true);
  5196. $color = $this->input->post('color', true);
  5197. $lowe = $this->input->post('lowe', true);
  5198. $state = $this->input->post('state', true);
  5199. $label = $this->input->post('label', true);
  5200. $timetk = $this->input->post('timetkk', true);
  5201. $timetj = $this->input->post('timetjj', true);
  5202. $timetk = strtotime($timetk);
  5203. $timetj = strtotime($timetj);
  5204. $where = "dbtime > 0";
  5205. if ($timetk && $timetj) {
  5206. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5207. }
  5208. if ($sku) {
  5209. $where .= " and sku = '$sku'";
  5210. }
  5211. if ($warehouse) {
  5212. $where .= " and warehouse = '$warehouse'";
  5213. if ($warehouse == 12) {
  5214. $w = 'specialstock';
  5215. } else {
  5216. $w = 'whlabel';
  5217. }
  5218. }
  5219. if ($purchase) {
  5220. $where .= " and purchase = '$purchase'";
  5221. }
  5222. if ($category) {
  5223. $where .= " and features like '%-$category-%'";
  5224. }
  5225. if ($size) {
  5226. $where .= " and features like '%-$size-%'";
  5227. }
  5228. if ($grade) {
  5229. $where .= " and features like '%-$grade-%'";
  5230. }
  5231. if ($color) {
  5232. $where .= " and features like '%-$color-%'";
  5233. }
  5234. if ($lowe) {
  5235. $where .= " and features like '%-$lowe-%'";
  5236. }
  5237. if ($state != '') {
  5238. $where .= " and state = '$state'";
  5239. }
  5240. //数据排序
  5241. $order_str = "dbtime desc";
  5242. if (empty($page)) {
  5243. $start = 0;
  5244. $perpage = 1;
  5245. } else {
  5246. $start = ($page - 1) * $perpage;
  5247. }
  5248. //取得信息列表
  5249. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5250. foreach ($info_list as $key => $value) {
  5251. $warehouse = $this->$w->read($value['warehouse']);
  5252. $info_list[$key]['warehouse'] = $warehouse['title'];
  5253. $purchase = $this->purchase->read($value['purchase']);
  5254. $info_list[$key]['purchase'] = $purchase['title'];
  5255. if ($value['enter'] != 0) {
  5256. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5257. } else {
  5258. $info_list[$key]['enter'] = "";
  5259. }
  5260. if ($value['dbtime'] != 0) {
  5261. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5262. } else {
  5263. $info_list[$key]['dbtime'] = "";
  5264. }
  5265. if ($value['state'] == 0) {
  5266. $info_list[$key]['state'] = "在库";
  5267. } else if ($value['state'] == 1) {
  5268. $info_list[$key]['state'] = "出库";
  5269. } else if ($value['state'] == 2) {
  5270. $info_list[$key]['state'] = "退库";
  5271. } else if ($value['state'] == 3) {
  5272. $info_list[$key]['state'] = "调拨中";
  5273. } else if ($value['state'] == 4) {
  5274. $info_list[$key]['state'] = "再加工";
  5275. } else if ($value['state'] == 5) {
  5276. $info_list[$key]['state'] = "维修中";
  5277. } else if ($value['state'] == 6) {
  5278. $info_list[$key]['state'] = "盘亏";
  5279. } else if ($value['state'] == 7) {
  5280. $info_list[$key]['state'] = "更换标签";
  5281. } else if ($value['state'] == 8) {
  5282. $info_list[$key]['state'] = "其它";
  5283. } else if ($value['state'] == 9) {
  5284. $info_list[$key]['state'] = "预设";
  5285. }
  5286. }
  5287. $total = $this->whlabel->find_count($where);
  5288. $pagenum = ceil($total / $perpage);
  5289. $over = $total - ($start + $perpage);
  5290. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5291. echo json_encode($rows);
  5292. exit;
  5293. }
  5294. if (isset($post['outsku'])) {
  5295. $time = time();
  5296. $cz = $this->input->post('cz', true);
  5297. $label = $this->input->post('outsku', true);
  5298. $sl = $this->input->post('sl', true);
  5299. $num = $this->input->post('num', true);
  5300. //$warehouse = $this->input->post('warehouse',true);
  5301. if (!$sl) {
  5302. $sl = 1;
  5303. }
  5304. if (!$warehouse) {
  5305. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5306. exit;
  5307. }
  5308. $dblabel = $this->whlabellabel->get_label($label);
  5309. if ($dblabel) {
  5310. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5311. if (count($data) < 1) {
  5312. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5313. exit;
  5314. }
  5315. if (count($data) < $num) {
  5316. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5317. exit;
  5318. }
  5319. for ($i = 0; $i < $sl; $i++) {
  5320. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5321. }
  5322. echo json_encode(array('success' => true));
  5323. exit;
  5324. } else {
  5325. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5326. exit;
  5327. }
  5328. }
  5329. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5330. $this->_Template('whlabel_db', $this->data);
  5331. }
  5332. public function _dbrk()
  5333. {
  5334. $post = $this->input->post(NULL, TRUE);
  5335. if (isset($post['page'])) {
  5336. $page = $this->input->post('page', true);
  5337. $perpage = $this->input->post('perpage', true);
  5338. $sku = $this->input->post('sku', true);
  5339. $number = $this->input->post('number', true);
  5340. $warehouse = $this->input->post('warehouse', true);
  5341. $purchase = $this->input->post('purchase', true);
  5342. $orderinfo = $this->input->post('orderinfo', true);
  5343. $waybill = $this->input->post('waybill', true);
  5344. $category = $this->input->post('category', true);
  5345. $size = $this->input->post('size', true);
  5346. $grade = $this->input->post('grade', true);
  5347. $color = $this->input->post('color', true);
  5348. $lowe = $this->input->post('lowe', true);
  5349. $state = $this->input->post('state', true);
  5350. $label = $this->input->post('label', true);
  5351. $ctime = $this->input->post('ctime', true);
  5352. $timetk = $this->input->post('timetkk', true);
  5353. $timetj = $this->input->post('timetjj', true);
  5354. $timetk = strtotime($timetk);
  5355. $timetj = strtotime($timetj);
  5356. $where = "dbtime > 0";
  5357. if ($timetk && $timetj) {
  5358. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5359. }
  5360. if ($sku) {
  5361. $where .= " and sku = '$sku'";
  5362. }
  5363. if ($warehouse) {
  5364. $where .= " and warehouse = '$warehouse'";
  5365. }
  5366. if ($purchase) {
  5367. $where .= " and purchase = '$purchase'";
  5368. }
  5369. if ($category) {
  5370. $where .= " and features like '%-$category-%'";
  5371. }
  5372. if ($size) {
  5373. $where .= " and features like '%-$size-%'";
  5374. }
  5375. if ($grade) {
  5376. $where .= " and features like '%-$grade-%'";
  5377. }
  5378. if ($color) {
  5379. $where .= " and features like '%-$color-%'";
  5380. }
  5381. if ($lowe) {
  5382. $where .= " and features like '%-$lowe-%'";
  5383. }
  5384. if ($state != '') {
  5385. $where .= " and state = '$state'";
  5386. }
  5387. //数据排序
  5388. $order_str = "dbtime desc";
  5389. if (empty($page)) {
  5390. $start = 0;
  5391. $perpage = 1;
  5392. } else {
  5393. $start = ($page - 1) * $perpage;
  5394. }
  5395. //取得信息列表
  5396. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5397. foreach ($info_list as $key => $value) {
  5398. $warehouse = $this->warehouse->read($value['warehouse']);
  5399. $info_list[$key]['warehouse'] = $warehouse['title'];
  5400. $purchase = $this->purchase->read($value['purchase']);
  5401. $info_list[$key]['purchase'] = $purchase['title'];
  5402. if ($value['enter'] != 0) {
  5403. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5404. } else {
  5405. $info_list[$key]['enter'] = "";
  5406. }
  5407. if ($value['dbtime'] != 0) {
  5408. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5409. } else {
  5410. $info_list[$key]['dbtime'] = "";
  5411. }
  5412. if ($value['state'] == 0) {
  5413. $info_list[$key]['state'] = "在库";
  5414. } else if ($value['state'] == 1) {
  5415. $info_list[$key]['state'] = "出库";
  5416. } else if ($value['state'] == 2) {
  5417. $info_list[$key]['state'] = "退库";
  5418. } else if ($value['state'] == 3) {
  5419. $info_list[$key]['state'] = "调拨中";
  5420. } else if ($value['state'] == 4) {
  5421. $info_list[$key]['state'] = "再加工";
  5422. } else if ($value['state'] == 5) {
  5423. $info_list[$key]['state'] = "维修中";
  5424. } else if ($value['state'] == 6) {
  5425. $info_list[$key]['state'] = "盘亏";
  5426. } else if ($value['state'] == 7) {
  5427. $info_list[$key]['state'] = "更换标签";
  5428. } else if ($value['state'] == 8) {
  5429. $info_list[$key]['state'] = "其它";
  5430. } else if ($value['state'] == 9) {
  5431. $info_list[$key]['state'] = "预设";
  5432. }
  5433. }
  5434. $total = $this->whlabel->find_count($where);
  5435. $pagenum = ceil($total / $perpage);
  5436. $over = $total - ($start + $perpage);
  5437. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5438. echo json_encode($rows);
  5439. exit;
  5440. }
  5441. if (isset($post['rsku'])) {
  5442. $cz = $this->input->post('cz', true);
  5443. $label = $this->input->post('rsku', true);
  5444. $sl = $this->input->post('sl', true);
  5445. $warehouse = $this->input->post('warehouse', true);
  5446. if (!$sl) {
  5447. $sl = 1;
  5448. }
  5449. if (!$warehouse) {
  5450. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5451. exit;
  5452. }
  5453. $dblabel = $this->whlabellabel->get_label($label);
  5454. if ($dblabel) {
  5455. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5456. if (count($data) < 1) {
  5457. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5458. exit;
  5459. }
  5460. if ($sl > count($data)) {
  5461. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5462. exit;
  5463. }
  5464. $time = time();
  5465. for ($i = 0; $i < $sl; $i++) {
  5466. $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']);
  5467. }
  5468. echo json_encode(array('success' => true));
  5469. exit;
  5470. } else {
  5471. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5472. exit;
  5473. }
  5474. }
  5475. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5476. $this->_Template('whlabel_dbrk', $this->data);
  5477. }
  5478. public function _whlabelczdc()
  5479. {
  5480. if (isset($_GET['excel'])) {
  5481. //数据排序
  5482. $order_str = "id desc";
  5483. if (empty($page)) {
  5484. $start = 0;
  5485. $perpage = 1;
  5486. } else {
  5487. $start = ($page - 1) * $perpage;
  5488. }
  5489. $state = $this->input->get('state', true);
  5490. $sku = $this->input->get('sku', true);
  5491. $ctime = $this->input->get('ctime', true);
  5492. $category = $this->input->get('category', true);
  5493. $size = $this->input->get('size', true);
  5494. $grade = $this->input->get('grade', true);
  5495. $color = $this->input->get('color', true);
  5496. $lowe = $this->input->get('lowe', true);
  5497. $timetk = $this->input->get('timetkk', true);
  5498. $timetj = $this->input->get('timetjj', true);
  5499. $timetk = strtotime($timetk);
  5500. $timetj = strtotime($timetj);
  5501. $where = "dbtime > 0";
  5502. if ($timetk && $timetj) {
  5503. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5504. }
  5505. if ($category) {
  5506. $where .= " and features like '%-$category-%'";
  5507. }
  5508. if ($size) {
  5509. $where .= " and features like '%-$size-%'";
  5510. }
  5511. if ($grade) {
  5512. $where .= " and features like '%-$grade-%'";
  5513. }
  5514. if ($color) {
  5515. $where .= " and features like '%-$color-%'";
  5516. }
  5517. if ($lowe) {
  5518. $where .= " and features like '%-$lowe-%'";
  5519. }
  5520. //取得信息列表
  5521. $info_list = $this->whlabel->find_all($where, '*');
  5522. $rows = array();
  5523. $list = array();
  5524. foreach ($info_list as $key => $value) {
  5525. $rows[$value['sku']] = $value; //所有数据sku
  5526. }
  5527. foreach ($rows as $value) {
  5528. $warehouse = $this->warehouse->read($value['warehouse']);
  5529. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5530. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5531. if ($value['orderinfo'] == 0) {
  5532. $info_list[$key]['orderinfo'] = "";
  5533. }
  5534. if ($value['waybill'] == 0) {
  5535. $info_list[$key]['waybill'] = "";
  5536. }
  5537. if ($value['state'] == 0) {
  5538. $value['state'] = "在库";
  5539. } else if ($value['state'] == 3) {
  5540. $value['state'] = "调拨中";
  5541. }
  5542. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5543. }
  5544. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5545. $titlename = "<table border=1>
  5546. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5547. <tr align='center'>
  5548. <td>SKU</td>
  5549. <td>产品</td>
  5550. <td>调拨数量</td>
  5551. <td>入库数量</td>
  5552. </tr>
  5553. </table>";
  5554. $filename = $title . ".xls";
  5555. $tail = "";
  5556. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5557. }
  5558. }
  5559. public function _print($arg_array)
  5560. {
  5561. if (isset($_SESSION['api'])) {
  5562. $user = $this->user->get_api($_SESSION['api']);
  5563. $usp = $user;
  5564. $fgshop = "";
  5565. $sid = "";
  5566. $wid = "";
  5567. $wtype = "";
  5568. $usersp = explode('|', trim($user['shop'], '|'));
  5569. $userwh = explode('|', trim($user['warehouse'], '|'));
  5570. foreach ($usersp as $value) {
  5571. $fgshop .= " shop = " . $value . " or";
  5572. $sid .= " id = " . $value . " or";
  5573. }
  5574. foreach ($userwh as $value) {
  5575. $wid .= " id = " . $value . " or";
  5576. $wtype .= " type = " . $value . " or";
  5577. }
  5578. }
  5579. $post = $this->input->post(NULL, TRUE);
  5580. if (isset($post['tmsku'])) {
  5581. $tmsku = $this->input->post('tmsku', true);
  5582. if (is_numeric($tmsku)) {
  5583. $yyh = $this->whlabellabel->get_label($tmsku);
  5584. } else {
  5585. $yyh = $this->whlabellabel->get_sku($tmsku);
  5586. }
  5587. if ($yyh) {
  5588. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5589. exit;
  5590. } else {
  5591. echo json_encode(array('success' => false));
  5592. exit;
  5593. }
  5594. }
  5595. $classid = $this->classid->sku();
  5596. $pm = $classid;
  5597. $scsku = $classid;
  5598. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5599. if (isset($post['warehouse'])) {
  5600. if ($post['warehouse']) {
  5601. $list = array();
  5602. $num = "";
  5603. $title = "";
  5604. $features = "";
  5605. $order = 0;
  5606. $post['shop'] = '';
  5607. $brand = $this->input->post('brand', true);
  5608. if ($brand != '0,') {
  5609. $b = $this->brand->read(rtrim($brand, ','));
  5610. if ($b) {
  5611. $post['shop'] = str_replace('|', ',', $b['shop']);
  5612. }
  5613. }
  5614. $post['details'] = $this->input->post('details', true); //打印数量
  5615. $xbqnum = $this->input->post('xbqnum', true);
  5616. $post['purchase'] = $this->input->post('purchase', true);
  5617. $post['warehouse'] = $this->input->post('warehouse', true);
  5618. $post['purchase'] = $this->input->post('purchase', true);
  5619. $post['retreatwarehouse'] = $post['warehouse'];
  5620. $post['cpbz'] = $this->input->post('cpbz', true);
  5621. $post['state'] = 9;
  5622. $category = $this->input->post('category', true);
  5623. $list['category'] = $category;
  5624. $list['hairtype'] = $this->input->post('hairtype', true);
  5625. $list['grade'] = $this->input->post('grade', true);
  5626. $size = $this->input->post('size', true);
  5627. $list['size'] = rtrim($size, ',');
  5628. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5629. $list['extension'] = $this->input->post('extension', true);
  5630. if ($category == 1297) {
  5631. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5632. }
  5633. if ($category == 1702) {
  5634. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5635. $list['syother'] = $this->input->post('syother', true);
  5636. }
  5637. if ($category == 133) {
  5638. $list['fittype'] = $this->input->post('fittype', true);
  5639. $list['acother'] = $this->input->post('acother', true);
  5640. }
  5641. $list['color'] = $this->input->post('color', true);
  5642. $list['lowe'] = $this->input->post('lowe', true);
  5643. if ($category == 127) {
  5644. $list['type'] = $this->input->post('type', true);
  5645. $list['headroad'] = $this->input->post('headroad', true);
  5646. $list['density'] = $this->input->post('density', true);
  5647. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5648. $list['lacesize'] = $this->input->post('lacesize', true);
  5649. }
  5650. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5651. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5652. }
  5653. if ($category == 128) {
  5654. $list['lacetype'] = $this->input->post('lacetype', true);
  5655. $list['haircap'] = $this->input->post('haircap', true);
  5656. $list['density'] = $this->input->post('density', true);
  5657. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5658. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5659. $list['wigother'] = $this->input->post('wigother', true);
  5660. $list['wigother1'] = $this->input->post('wigother1', true);
  5661. $list['wigother2'] = $this->input->post('wigother2', true);
  5662. }
  5663. if ($category == 129) {
  5664. $list['wide'] = $this->input->post('wide', true);
  5665. }
  5666. if ($category == 131) {
  5667. $list['gifttype'] = $this->input->post('gifttype', true);
  5668. $list['giftother'] = $this->input->post('giftother', true);
  5669. }
  5670. if ($category == 134) {
  5671. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5672. }
  5673. if ($category == 1297) {
  5674. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5675. $list['sywigother'] = $this->input->post('sywigother', true);
  5676. }
  5677. if ($category == 130 || $category == 133 || $category == 1702) {
  5678. $list['items'] = $this->input->post('items', true);
  5679. $list['weight'] = $this->input->post('weight', true);
  5680. }
  5681. if ($category == 1702) {
  5682. $list['syhairther'] = $this->input->post('syhairther', true);
  5683. }
  5684. foreach ($list as $k => $v) {
  5685. if ($v != 0) {
  5686. $num .= $v;
  5687. $features .= $v . '-';
  5688. $post[$k] = $v;
  5689. $typeclass = $this->typeclass->read($v);
  5690. if (isset($pm[$typeclass['classid']])) {
  5691. if (stripos($typeclass['zh'], '|') !== false) {
  5692. $exzh = explode('|', $typeclass['zh']);
  5693. $pm[$typeclass['classid']] = $exzh[0];
  5694. } else {
  5695. $pm[$typeclass['classid']] = $typeclass['zh'];
  5696. }
  5697. }
  5698. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5699. if ($k != 'size') {
  5700. $title .= $typeclass['title'] . " ";
  5701. }
  5702. }
  5703. }
  5704. $typeclass = $this->typeclass->read($list['size']);
  5705. $title .= $typeclass['title'];
  5706. $time = time();
  5707. $post['title'] = rtrim($title, ' ');
  5708. $post['number'] = $num;
  5709. $post['features'] = '-' . $features;
  5710. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5711. $featurespp = explode('-', trim($featurespp, '-'));
  5712. if (isset($featurespp[5])) {
  5713. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5714. } else {
  5715. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5716. }
  5717. $post['enter'] = $time;
  5718. $post['time'] = $time; //操作时间
  5719. $scsku = implode("-", $scsku);
  5720. $zh = implode(" ", $pm);
  5721. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5722. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5723. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5724. $post['sku'] = $bqsku;
  5725. $label = time() . rand(0, 9);
  5726. $post['label'] = $label;
  5727. $cpid = $this->whlabellabel->find_count();
  5728. $post['cpid'] = $cpid + 1;
  5729. $cpid = $post['cpid'];
  5730. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5731. //if($whlabelbarcode)
  5732. //{
  5733. //$post['label'] = $whlabelbarcode['label'];
  5734. //if(!$this->whlabellabel->insert($post))
  5735. //{
  5736. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5737. //}
  5738. //}
  5739. //else
  5740. //{
  5741. $this->db->trans_begin();
  5742. $this->whlabellabel->insert($post);
  5743. //$this->whlabelbarcode->insert($post);
  5744. if ($this->db->trans_status() === TRUE) {
  5745. $this->db->trans_commit();
  5746. } else {
  5747. $this->db->trans_rollback();
  5748. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5749. exit;
  5750. }
  5751. //}
  5752. $warehouse_name = "";
  5753. $warehouse = $post['warehouse'];
  5754. if($warehouse == 12){
  5755. $warehouse_name = "特殊库存库";
  5756. }
  5757. // if($warehouse == 13){
  5758. // $warehouse_name = "许昌仓";
  5759. // }
  5760. // if($warehouse == 5){
  5761. // $warehouse_name = "美国店";
  5762. // }
  5763. // if($warehouse == 16){
  5764. // $warehouse_name = "定制头套仓";
  5765. // }
  5766. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5767. if(!empty($warehouse_name)){
  5768. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5769. }
  5770. $purchase = $this->purchase->read($post['purchase']);
  5771. 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));
  5772. exit; //特殊仓目前不需要仓库选项
  5773. }
  5774. }
  5775. if (isset($_SESSION['api'])) {
  5776. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5777. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5778. $this->data['wlshop'] = $wlshop;
  5779. $this->data['warehouse'] = $warehouse;
  5780. }
  5781. $whlabelwz = $this->whlabelwz->find_all();
  5782. $this->data['whlabelwz'] = $whlabelwz;
  5783. $this->_Template('whlabel_print', $this->data);
  5784. }
  5785. public function _usaprint($arg_array)
  5786. {
  5787. if (isset($_SESSION['api'])) {
  5788. $user = $this->user->get_api($_SESSION['api']);
  5789. $usp = $user;
  5790. $fgshop = "";
  5791. $sid = "";
  5792. $wid = "";
  5793. $wtype = "";
  5794. $usersp = explode('|', trim($user['shop'], '|'));
  5795. $userwh = explode('|', trim($user['warehouse'], '|'));
  5796. foreach ($usersp as $value) {
  5797. $fgshop .= " shop = " . $value . " or";
  5798. $sid .= " id = " . $value . " or";
  5799. }
  5800. foreach ($userwh as $value) {
  5801. $wid .= " id = " . $value . " or";
  5802. $wtype .= " type = " . $value . " or";
  5803. }
  5804. }
  5805. $post = $this->input->post(NULL, TRUE);
  5806. if (isset($post['tmsku'])) {
  5807. $tmsku = $this->input->post('tmsku', true);
  5808. if (is_numeric($tmsku)) {
  5809. $yyh = $this->whlabellabel->get_label($tmsku);
  5810. } else {
  5811. $yyh = $this->whlabellabel->get_sku($tmsku);
  5812. }
  5813. if ($yyh) {
  5814. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5815. exit;
  5816. } else {
  5817. echo json_encode(array('success' => false));
  5818. exit;
  5819. }
  5820. }
  5821. $classid = $this->classid->sku();
  5822. $pm = $classid;
  5823. $scsku = $classid;
  5824. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5825. if (isset($post['warehouse'])) {
  5826. if ($post['warehouse']) {
  5827. $list = array();
  5828. $num = "";
  5829. $title = "";
  5830. $features = "";
  5831. $order = 0;
  5832. $post['shop'] = '';
  5833. $brand = $this->input->post('brand', true);
  5834. if ($brand != '0,') {
  5835. $b = $this->brand->read(rtrim($brand, ','));
  5836. if ($b) {
  5837. $post['shop'] = str_replace('|', ',', $b['shop']);
  5838. }
  5839. }
  5840. $post['details'] = $this->input->post('details', true); //打印数量
  5841. $xbqnum = $this->input->post('xbqnum', true);
  5842. $post['purchase'] = $this->input->post('purchase', true);
  5843. $post['warehouse'] = $this->input->post('warehouse', true);
  5844. $post['purchase'] = $this->input->post('purchase', true);
  5845. $post['retreatwarehouse'] = $post['warehouse'];
  5846. $post['cpbz'] = $this->input->post('cpbz', true);
  5847. $post['state'] = 9;
  5848. $category = $this->input->post('category', true);
  5849. $list['category'] = $category;
  5850. $list['hairtype'] = $this->input->post('hairtype', true);
  5851. $list['grade'] = $this->input->post('grade', true);
  5852. $size = $this->input->post('size', true);
  5853. $list['size'] = rtrim($size, ',');
  5854. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5855. $list['extension'] = $this->input->post('extension', true);
  5856. if ($category == 1297) {
  5857. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5858. }
  5859. if ($category == 1702) {
  5860. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5861. $list['syother'] = $this->input->post('syother', true);
  5862. }
  5863. if ($category == 133) {
  5864. $list['fittype'] = $this->input->post('fittype', true);
  5865. $list['acother'] = $this->input->post('acother', true);
  5866. }
  5867. $list['color'] = $this->input->post('color', true);
  5868. $list['lowe'] = $this->input->post('lowe', true);
  5869. if ($category == 127) {
  5870. $list['type'] = $this->input->post('type', true);
  5871. $list['headroad'] = $this->input->post('headroad', true);
  5872. $list['density'] = $this->input->post('density', true);
  5873. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5874. $list['lacesize'] = $this->input->post('lacesize', true);
  5875. }
  5876. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5877. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5878. }
  5879. if ($category == 128) {
  5880. $list['lacetype'] = $this->input->post('lacetype', true);
  5881. $list['haircap'] = $this->input->post('haircap', true);
  5882. $list['density'] = $this->input->post('density', true);
  5883. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5884. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5885. $list['wigother'] = $this->input->post('wigother', true);
  5886. $list['wigother1'] = $this->input->post('wigother1', true);
  5887. $list['wigother2'] = $this->input->post('wigother2', true);
  5888. }
  5889. if ($category == 129) {
  5890. $list['wide'] = $this->input->post('wide', true);
  5891. }
  5892. if ($category == 131) {
  5893. $list['gifttype'] = $this->input->post('gifttype', true);
  5894. $list['giftother'] = $this->input->post('giftother', true);
  5895. }
  5896. if ($category == 134) {
  5897. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5898. }
  5899. if ($category == 1297) {
  5900. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5901. $list['sywigother'] = $this->input->post('sywigother', true);
  5902. }
  5903. if ($category == 130 || $category == 133 || $category == 1702) {
  5904. $list['items'] = $this->input->post('items', true);
  5905. $list['weight'] = $this->input->post('weight', true);
  5906. }
  5907. if ($category == 1702) {
  5908. $list['syhairther'] = $this->input->post('syhairther', true);
  5909. }
  5910. foreach ($list as $k => $v) {
  5911. if ($v != 0) {
  5912. $num .= $v;
  5913. $features .= $v . '-';
  5914. $post[$k] = $v;
  5915. $typeclass = $this->typeclass->read($v);
  5916. if (isset($pm[$typeclass['classid']])) {
  5917. if (stripos($typeclass['zh'], '|') !== false) {
  5918. $exzh = explode('|', $typeclass['zh']);
  5919. $pm[$typeclass['classid']] = $exzh[0];
  5920. } else {
  5921. $pm[$typeclass['classid']] = $typeclass['zh'];
  5922. }
  5923. }
  5924. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5925. if ($k != 'size') {
  5926. $title .= $typeclass['title'] . " ";
  5927. }
  5928. }
  5929. }
  5930. $typeclass = $this->typeclass->read($list['size']);
  5931. $title .= $typeclass['title'];
  5932. $time = time();
  5933. $post['title'] = rtrim($title, ' ');
  5934. $post['number'] = $num;
  5935. $post['features'] = '-' . $features;
  5936. $fp = $this->whlabel->get_features($post['features']);
  5937. if (!$fp) {
  5938. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5939. exit;
  5940. }
  5941. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5942. $featurespp = explode('-', trim($featurespp, '-'));
  5943. if (isset($featurespp[5])) {
  5944. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5945. } else {
  5946. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5947. }
  5948. $post['enter'] = $time;
  5949. $post['time'] = $time; //操作时间
  5950. $scsku = implode("-", $scsku);
  5951. $zh = implode(" ", $pm);
  5952. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5953. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5954. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5955. $post['sku'] = $fp['sku'];
  5956. $post['label'] = $fp['sku'];
  5957. $cpid = $this->whlabellabel->find_count();
  5958. $post['cpid'] = $cpid + 1;
  5959. $cpid = $post['cpid'];
  5960. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5961. //if($whlabelbarcode)
  5962. //{
  5963. //$post['label'] = $whlabelbarcode['label'];
  5964. //if(!$this->whlabellabel->insert($post))
  5965. //{
  5966. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5967. //}
  5968. //}
  5969. //else
  5970. //{
  5971. $this->db->trans_begin();
  5972. $this->whlabellabel->insert($post);
  5973. //$this->whlabelbarcode->insert($post);
  5974. if ($this->db->trans_status() === TRUE) {
  5975. $this->db->trans_commit();
  5976. } else {
  5977. $this->db->trans_rollback();
  5978. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5979. exit;
  5980. }
  5981. //}
  5982. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5983. $purchase = $this->purchase->read($post['purchase']);
  5984. 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));
  5985. exit; //特殊仓目前不需要仓库选项
  5986. }
  5987. }
  5988. if (isset($_SESSION['api'])) {
  5989. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5990. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5991. $this->data['wlshop'] = $wlshop;
  5992. $this->data['warehouse'] = $warehouse;
  5993. }
  5994. $whlabelwz = $this->whlabelwz->find_all();
  5995. $this->data['whlabelwz'] = $whlabelwz;
  5996. $this->_Template('whlabel_usaprint', $this->data);
  5997. }
  5998. public function _printrk($arg_array)
  5999. {
  6000. $prc = array();
  6001. $purchase = $this->purchase->find_all();
  6002. foreach ($purchase as $k => $v) {
  6003. $prc[$v['id']] = $v['title'];
  6004. }
  6005. $post = $this->input->post(NULL, TRUE);
  6006. if (isset($post['page'])) {
  6007. $page = $this->input->post('page', true);
  6008. $perpage = $this->input->post('perpage', true);
  6009. $sku = $this->input->post('sku', true);
  6010. $bs = $this->input->post('bs', true);
  6011. $number = $this->input->post('number', true);
  6012. $warehouse = $this->input->post('warehouse', true);
  6013. $purchase = $this->input->post('purchase', true);
  6014. $orderinfo = $this->input->post('orderinfo', true);
  6015. $waybill = $this->input->post('waybill', true);
  6016. $category = $this->input->post('category', true);
  6017. $size = $this->input->post('size', true);
  6018. $grade = $this->input->post('grade', true);
  6019. $color = $this->input->post('color', true);
  6020. $lowe = $this->input->post('lowe', true);
  6021. $state = $this->input->post('state', true);
  6022. $label = $this->input->post('label', true);
  6023. $timetk = $this->input->post('ktime', true);
  6024. $timetj = $this->input->post('jtime', true);
  6025. $timetk = strtotime($timetk);
  6026. $timetj = strtotime($timetj);
  6027. $where = "1=1 ";
  6028. if ($timetk && $timetj) {
  6029. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6030. }
  6031. if ($sku) {
  6032. $where .= " and sku = '$sku'";
  6033. }
  6034. if ($bs != '') {
  6035. $where .= " and bs = '$bs'";
  6036. }
  6037. if ($number) {
  6038. $where .= " and number = '$number'";
  6039. }
  6040. if ($warehouse) {
  6041. $where .= " and warehouse = '$warehouse'";
  6042. }
  6043. if ($purchase) {
  6044. $where .= " and purchase = '$purchase'";
  6045. }
  6046. if ($orderinfo) {
  6047. $where .= " and orderinfo = '$orderinfo'";
  6048. }
  6049. if ($waybill) {
  6050. $where .= " and waybill = '$waybill'";
  6051. }
  6052. if ($category) {
  6053. $where .= " and features like '%-$category-%'";
  6054. }
  6055. if ($size) {
  6056. $where .= " and features like '%-$size-%'";
  6057. }
  6058. if ($grade) {
  6059. $where .= " and features like '%-$grade-%'";
  6060. }
  6061. if ($color) {
  6062. $where .= " and features like '%-$color-%'";
  6063. }
  6064. if ($lowe) {
  6065. $where .= " and features like '%-$lowe-%'";
  6066. }
  6067. if ($label) {
  6068. $where .= " and label = '$label'";
  6069. }
  6070. if ($state || $state == 0) {
  6071. $where .= " and state = '$state'";
  6072. }
  6073. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6074. //数据排序
  6075. $order_str = "enter desc";
  6076. if (empty($page)) {
  6077. $start = 0;
  6078. $perpage = 1;
  6079. } else {
  6080. $start = ($page - 1) * $perpage;
  6081. }
  6082. //取得信息列表
  6083. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6084. foreach ($info_list as $key => $value) {
  6085. $warehouse = $this->warehouse->read($value['warehouse']);
  6086. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6087. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6088. if ($value['state'] == 0) {
  6089. $info_list[$key]['state'] = "在库";
  6090. } else if ($value['state'] == 1) {
  6091. $info_list[$key]['state'] = "出库";
  6092. } else if ($value['state'] == 2) {
  6093. $info_list[$key]['state'] = "退库";
  6094. } else if ($value['state'] == 3) {
  6095. $info_list[$key]['state'] = "调拨中";
  6096. } else if ($value['state'] == 4) {
  6097. $info_list[$key]['state'] = "再加工";
  6098. } else if ($value['state'] == 5) {
  6099. $info_list[$key]['state'] = "维修中";
  6100. } else if ($value['state'] == 6) {
  6101. $info_list[$key]['state'] = "盘亏";
  6102. } else if ($value['state'] == 7) {
  6103. $info_list[$key]['state'] = "更换标签";
  6104. } else if ($value['state'] == 8) {
  6105. $info_list[$key]['state'] = "其它";
  6106. } else if ($value['state'] == 9) {
  6107. $info_list[$key]['state'] = "预设";
  6108. } else if ($value['state'] == 10) {
  6109. $info_list[$key]['state'] = "美店零售";
  6110. }
  6111. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6112. }
  6113. $total = $this->$ck->find_count($where);
  6114. $pagenum = ceil($total / $perpage);
  6115. $over = $total - ($start + $perpage);
  6116. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6117. echo json_encode($rows);
  6118. exit;
  6119. }
  6120. if (isset($post['tmsku'])) {
  6121. $time = time();
  6122. $tmsku = $this->input->post('tmsku', true);
  6123. //$post['shop'] = $this->input->post('shop',true);
  6124. $num = $this->input->post('num', true);
  6125. $rktype = $this->input->post('rktype', true);
  6126. if ($num > 200) {
  6127. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6128. exit;
  6129. }
  6130. if (!$rktype) {
  6131. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6132. }
  6133. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6134. /**
  6135. $wz = array();
  6136. foreach ($rk as $key=>$value)
  6137. {
  6138. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6139. }
  6140. if(count($wz) > 1)
  6141. {
  6142. $wz = array_values($wz);
  6143. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6144. }
  6145. **/
  6146. if (isset($rk[0]['purchase'])) {
  6147. $rk = $rk[0];
  6148. $j = 0;
  6149. $post['purchase'] = $rk['purchase'];
  6150. $post['warehouse'] = $rk['warehouse'];
  6151. $post['retreatwarehouse'] = $rk['warehouse'];
  6152. $post['sku'] = $rk['sku'];
  6153. $post['number'] = $rk['number'];
  6154. $post['features'] = $rk['features'];
  6155. $post['title'] = $rk['title'];
  6156. $post['enter'] = $time;
  6157. $post['time'] = $time;
  6158. $post['bs'] = 1;
  6159. $post['shop'] = $rk['shop'];
  6160. $post['details'] = $rk['details'];
  6161. $post['cpid'] = $rk['cpid'];
  6162. $post['cpbz'] = $rk['cpbz'];
  6163. //$post['rktype'] = $rktype;
  6164. $warehouse = $this->warehouse->read($rk['warehouse']);
  6165. if ($warehouse['bdck'] == '') {
  6166. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6167. exit;
  6168. } else {
  6169. $bdck = $warehouse['bdck'];
  6170. }
  6171. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6172. if (isset($pdwz['details'])) {
  6173. if ($pdwz['details'] != $post['details']) {
  6174. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6175. exit;
  6176. }
  6177. }
  6178. $post['featurespp'] = $rk['featurespp'];
  6179. if ($post['warehouse'] == '5') {
  6180. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6181. if ($yza) {
  6182. if ($post['features'] != $yza[0]['features']) {
  6183. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6184. exit;
  6185. }
  6186. }
  6187. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6188. if ($yzb) {
  6189. if ($post['sku'] != $yzb[0]['sku']) {
  6190. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6191. exit;
  6192. }
  6193. }
  6194. }
  6195. for ($i = 0; $i < $num; $i++) {
  6196. $post['label'] = time() . rand(100, 999) . $i;
  6197. if ($this->$bdck->insert($post)) {
  6198. $j++;
  6199. }
  6200. }
  6201. /**
  6202. if($post['warehouse'] != 12)
  6203. {
  6204. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6205. }
  6206. **/
  6207. if ($j == $num) {
  6208. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6209. exit;
  6210. } else {
  6211. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6212. exit;
  6213. }
  6214. } else {
  6215. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6216. exit;
  6217. }
  6218. }
  6219. $this->_Template('whlabel_printrk', $this->data);
  6220. }
  6221. public function _printxzrk($arg_array)
  6222. {
  6223. $post = $this->input->post(NULL, TRUE);
  6224. if (isset($post['wzid'])) {
  6225. $time = time();
  6226. $id = $this->input->post('wzid', true);
  6227. //$post['shop'] = $this->input->post('shop',true);
  6228. $num = 1;
  6229. $rk = $this->whlabellabel->read($id);
  6230. if (isset($rk['purchase'])) {
  6231. $x = 0;
  6232. $post['purchase'] = $rk['purchase'];
  6233. $post['warehouse'] = $rk['warehouse'];
  6234. $post['retreatwarehouse'] = $rk['warehouse'];
  6235. $post['sku'] = $rk['sku'];
  6236. $post['number'] = $rk['number'];
  6237. $post['features'] = $rk['features'];
  6238. $post['title'] = $rk['title'];
  6239. $post['enter'] = $time;
  6240. $post['time'] = $time;
  6241. $post['bs'] = 1;
  6242. $post['shop'] = $rk['shop'];
  6243. $post['details'] = $rk['details'];
  6244. $post['cpid'] = $rk['cpid'];
  6245. $post['cpbz'] = $rk['cpbz'];
  6246. $warehouse = $this->warehouse->read($rk['warehouse']);
  6247. if ($warehouse['bdck'] == '') {
  6248. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6249. exit;
  6250. } else {
  6251. $bdck = $warehouse['bdck'];
  6252. }
  6253. $post['featurespp'] = $rk['featurespp'];
  6254. $this->db->trans_begin();
  6255. for ($i = 0; $i < $num; $i++) {
  6256. $post['label'] = time() . rand(100, 999) . $i;
  6257. $this->$bdck->insert($post);
  6258. }
  6259. /**
  6260. if($post['warehouse'] != 12)
  6261. {
  6262. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6263. }
  6264. **/
  6265. if ($this->db->trans_status() === TRUE) {
  6266. $this->db->trans_commit();
  6267. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6268. exit;
  6269. } else {
  6270. $this->db->trans_rollback();
  6271. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6272. exit;
  6273. }
  6274. } else {
  6275. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6276. exit;
  6277. }
  6278. }
  6279. }
  6280. public function _printck($arg_array)
  6281. {
  6282. $prc = array();
  6283. $purchase = $this->purchase->find_all();
  6284. foreach ($purchase as $k => $v) {
  6285. $prc[$v['id']] = $v['title'];
  6286. }
  6287. $post = $this->input->post(NULL, TRUE);
  6288. if (isset($post['page'])) {
  6289. $page = $this->input->post('page', true);
  6290. $perpage = $this->input->post('perpage', true);
  6291. $sku = $this->input->post('sku', true);
  6292. $bs = $this->input->post('bs', true);
  6293. $number = $this->input->post('number', true);
  6294. $warehouse = $this->input->post('warehouse', true);
  6295. $purchase = $this->input->post('purchase', true);
  6296. $orderinfo = $this->input->post('orderinfo', true);
  6297. $waybill = $this->input->post('waybill', true);
  6298. $category = $this->input->post('category', true);
  6299. $size = $this->input->post('size', true);
  6300. $grade = $this->input->post('grade', true);
  6301. $color = $this->input->post('color', true);
  6302. $lowe = $this->input->post('lowe', true);
  6303. $state = $this->input->post('state', true);
  6304. $label = $this->input->post('label', true);
  6305. $timetk = $this->input->post('ktime', true);
  6306. $timetj = $this->input->post('jtime', true);
  6307. $timetk = strtotime($timetk);
  6308. $timetj = strtotime($timetj);
  6309. $where = "state=1 ";
  6310. if ($timetk && $timetj) {
  6311. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6312. }
  6313. if ($sku) {
  6314. $where .= " and sku = '$sku'";
  6315. }
  6316. if ($bs != '') {
  6317. $where .= " and bs = '$bs'";
  6318. }
  6319. if ($number) {
  6320. $where .= " and number = '$number'";
  6321. }
  6322. if ($warehouse) {
  6323. $where .= " and warehouse = '$warehouse'";
  6324. }
  6325. if ($purchase) {
  6326. $where .= " and purchase = '$purchase'";
  6327. }
  6328. if ($orderinfo) {
  6329. $where .= " and orderinfo = '$orderinfo'";
  6330. }
  6331. if ($waybill) {
  6332. $where .= " and waybill = '$waybill'";
  6333. }
  6334. if ($category) {
  6335. $where .= " and features like '%-$category-%'";
  6336. }
  6337. if ($size) {
  6338. $where .= " and features like '%-$size-%'";
  6339. }
  6340. if ($grade) {
  6341. $where .= " and features like '%-$grade-%'";
  6342. }
  6343. if ($color) {
  6344. $where .= " and features like '%-$color-%'";
  6345. }
  6346. if ($lowe) {
  6347. $where .= " and features like '%-$lowe-%'";
  6348. }
  6349. if ($label) {
  6350. $where .= " and label = '$label'";
  6351. }
  6352. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6353. //数据排序
  6354. $order_str = "outk desc";
  6355. if (empty($page)) {
  6356. $start = 0;
  6357. $perpage = 1;
  6358. } else {
  6359. $start = ($page - 1) * $perpage;
  6360. }
  6361. //取得信息列表
  6362. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6363. foreach ($info_list as $key => $value) {
  6364. $warehouse = $this->warehouse->read($value['warehouse']);
  6365. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6366. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6367. if ($value['state'] == 0) {
  6368. $info_list[$key]['state'] = "在库";
  6369. } else if ($value['state'] == 1) {
  6370. $info_list[$key]['state'] = "出库";
  6371. } else if ($value['state'] == 2) {
  6372. $info_list[$key]['state'] = "退库";
  6373. } else if ($value['state'] == 3) {
  6374. $info_list[$key]['state'] = "调拨中";
  6375. } else if ($value['state'] == 4) {
  6376. $info_list[$key]['state'] = "再加工";
  6377. } else if ($value['state'] == 5) {
  6378. $info_list[$key]['state'] = "维修中";
  6379. } else if ($value['state'] == 6) {
  6380. $info_list[$key]['state'] = "盘亏";
  6381. } else if ($value['state'] == 7) {
  6382. $info_list[$key]['state'] = "更换标签";
  6383. } else if ($value['state'] == 8) {
  6384. $info_list[$key]['state'] = "其它";
  6385. } else if ($value['state'] == 9) {
  6386. $info_list[$key]['state'] = "预设";
  6387. } else if ($value['state'] == 10) {
  6388. $info_list[$key]['state'] = "美店零售";
  6389. }
  6390. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6391. }
  6392. $total = $this->$ck->find_count($where);
  6393. $pagenum = ceil($total / $perpage);
  6394. $over = $total - ($start + $perpage);
  6395. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6396. echo json_encode($rows);
  6397. exit;
  6398. }
  6399. if (isset($post['tmsku'])) {
  6400. $time = time();
  6401. $tmsku = $this->input->post('tmsku', true);
  6402. //$post['shop'] = $this->input->post('shop',true);
  6403. $num = $this->input->post('num', true);
  6404. $cktype = $this->input->post('cktype', true);
  6405. $label = $this->whlabellabel->get_label($tmsku);
  6406. if (!$cktype) {
  6407. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6408. }
  6409. if (!isset($label['warehouse'])) {
  6410. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6411. exit;
  6412. }
  6413. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6414. if (stripos($label['features'], '-126-') !== false) {
  6415. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6416. } else {
  6417. $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 = ''");
  6418. }
  6419. $j = 0;
  6420. if (count($ck) >= $num) {
  6421. for ($i = 0; $i < $num; $i++) {
  6422. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6423. {
  6424. $j++;
  6425. }
  6426. }
  6427. if ($j == $num) {
  6428. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6429. exit;
  6430. } else {
  6431. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6432. exit;
  6433. }
  6434. } else {
  6435. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6436. exit;
  6437. }
  6438. }
  6439. if(isset($_SESSION['api']))
  6440. {
  6441. $user = $this->user->get_api($_SESSION['api']);
  6442. if(in_array($user['power'],[1,27])){
  6443. $vip = 1;
  6444. }
  6445. }
  6446. else
  6447. {
  6448. $vip = 0;
  6449. header('Location: /');exit;
  6450. }
  6451. $this->data['vip'] = $vip;
  6452. $this->_Template('whlabel_printck', $this->data);
  6453. }
  6454. public function _printexcel()
  6455. {
  6456. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6457. $config['upload_path'] = '.' . $dir;
  6458. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6459. $config['allowed_types'] = 'xls|xlsx|csv';
  6460. $config['max_size'] = 10240;
  6461. $this->load->library('upload', $config);
  6462. $this->upload->initialize($config);
  6463. if ($this->upload->do_upload('userfile')) {
  6464. $full_path = $dir . $this->upload->data('file_name');
  6465. $fileName = '.' . $full_path;
  6466. if (!file_exists($fileName)) {
  6467. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6468. exit;
  6469. } else {
  6470. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6471. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6472. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6473. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6474. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6475. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6476. ++$column; //如果列数大于26行
  6477. $list = array();
  6478. for ($i = 2; $i <= $row; $i++) // 行数循环
  6479. {
  6480. $data = array();
  6481. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6482. {
  6483. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6484. }
  6485. $list[] = $data;
  6486. }
  6487. }
  6488. $ed = array();
  6489. $i = 0;
  6490. $j = 0;
  6491. $dcdata = array();
  6492. $yc = '';
  6493. $cmf_arr = array_column($list, '1');
  6494. array_multisort($cmf_arr, SORT_ASC, $list);
  6495. foreach ($list as $key => $value) {
  6496. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6497. if ($typeclass) {
  6498. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6499. } else {
  6500. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6501. $i++;
  6502. continue;
  6503. }
  6504. }
  6505. if ($i > 0) {
  6506. $yc = $i . '条异常';
  6507. }
  6508. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6509. exit;
  6510. }
  6511. }
  6512. public function _uck()
  6513. {
  6514. if (isset($_GET['excel'])) {
  6515. $tc = array();
  6516. $typeclass = $this->typeclass->find_all();
  6517. foreach ($typeclass as $v) {
  6518. $tc[$v['id']] = $v['zh'];
  6519. }
  6520. $data = array();
  6521. $t = array();
  6522. $rq = '';
  6523. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6524. $ts = $ts / (24 * 3600);
  6525. for ($i = 0; $i < $ts; $i++) {
  6526. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6527. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6528. }
  6529. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6530. foreach ($info_list as $k => $v) {
  6531. $features = explode('-', trim($v['features'], '-'));
  6532. if (!isset($features[3]) || !isset($features[4])) {
  6533. continue;
  6534. }
  6535. $data[$k][0] = $tc[$features[0]]; //类型
  6536. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6537. $data[$k][2] = $tc[$features[4]]; //曲度
  6538. $data[$k][3] = '';
  6539. if (isset($data[$k][1])) {
  6540. $data[$k][3] .= $data[$k][1];
  6541. }
  6542. if (isset($data[$k][2])) {
  6543. $data[$k][3] .= $data[$k][2];
  6544. }
  6545. if (isset($features[5])) {
  6546. $data[$k][3] .= $tc[$features[5]];
  6547. }
  6548. if (isset($features[2])) {
  6549. $data[$k][3] .= $tc[$features[2]];
  6550. }
  6551. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6552. $data[$k][4] = $v['sku'];
  6553. $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())) . '))'); //月初库存
  6554. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6555. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6556. $ztrq = '';
  6557. $ztsl = '';
  6558. if (count($zt) > 0) {
  6559. foreach ($zt as $vv) {
  6560. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6561. $ztsl .= $vv['num'] . '<br>';
  6562. }
  6563. }
  6564. $data[$k][] = trim($ztsl, '<br>');
  6565. $data[$k][] = trim($ztrq, '<br>');
  6566. $byck = 0;
  6567. foreach ($t as $vv) {
  6568. $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));
  6569. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6570. $byck += $sl;
  6571. }
  6572. $data[$k][] = ($byck > 0) ? $byck : '';
  6573. }
  6574. $title = "详情 " . date("Y-m-d", time());
  6575. $titlename = "<table border=1>
  6576. <tr align='center'>
  6577. <td>类别</td>
  6578. <td>颜色</td>
  6579. <td>曲度</td>
  6580. <td>名称</td>
  6581. <td>SKU</td>
  6582. <td>月初库存</td>
  6583. <td>剩余库存</td>
  6584. <td>在途数量</td>
  6585. <td>预达日期</td>" .
  6586. $rq
  6587. . "<td>本月出库</td></tr>
  6588. </table>";
  6589. $filename = $title . ".xls";
  6590. $tail = "";
  6591. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6592. }
  6593. }
  6594. public function _whlabelexcelzh()
  6595. {
  6596. if (isset($_GET['excel'])) {
  6597. $where = "sku != 'Preset'";
  6598. //数据排序
  6599. $order_str = "id desc";
  6600. if (empty($page)) {
  6601. $start = 0;
  6602. $perpage = 1;
  6603. } else {
  6604. $start = ($page - 1) * $perpage;
  6605. }
  6606. $category = $this->input->get('category', true);
  6607. $warehouse = $this->input->get('warehouse', true);
  6608. $excelid = $this->input->get('sid', true);
  6609. if ($category) {
  6610. $where .= " and features like '%-$category-%'";
  6611. }
  6612. if ($warehouse) {
  6613. $where .= " and warehouse = '$warehouse'";
  6614. }
  6615. $xzid = '';
  6616. if ($excelid) {
  6617. $excelid = explode(',', trim($excelid, ','));
  6618. foreach ($excelid as $key => $value) {
  6619. $xzid .= " id = " . $value . " or";
  6620. }
  6621. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6622. }
  6623. //取得信息列表
  6624. /**
  6625. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6626. $rows = array();$list = array();
  6627. foreach ($info_list as $key=>$value)
  6628. {
  6629. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6630. }
  6631. **/
  6632. $list = array();
  6633. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6634. foreach ($rows as $key => $value) {
  6635. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6636. $zh = '';
  6637. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6638. foreach ($zt as $v) {
  6639. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6640. }
  6641. $zt = array_sum(array_column($zt, 'num'));
  6642. $number = $value['number'];
  6643. $ftime = time() - 15 * 24 * 3600;
  6644. $warehouse = $this->warehouse->read($value['warehouse']);
  6645. $rows[$key]['warehouse'] = $warehouse['title'];
  6646. $rows[$key]['number'] = $c;
  6647. $rows[$key]['features'] = $zh;
  6648. $rows[$key]['hb'] = $c + $zt;
  6649. }
  6650. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6651. $titlename = "<table border=1>
  6652. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6653. <tr align='center'>
  6654. <td>仓库</td>
  6655. <td>SKU</td>
  6656. <td>产品</td>
  6657. <td>库存数量</td>
  6658. <td>在途数量及预达日期</td>
  6659. <td>在途+库存数量</td>
  6660. </tr>
  6661. </table>";
  6662. $filename = $title . ".xls";
  6663. $tail = "";
  6664. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6665. }
  6666. if (isset($_GET['excel'])) {
  6667. $warehouse = $this->input->get('warehouse', true);
  6668. $sku = $this->input->get('sku', true);
  6669. $cz = $this->input->get('cz', true);
  6670. $text = $this->input->post('text', true);
  6671. $xztime = $this->input->get('xztime', true);
  6672. $timetk = $this->input->get('timetk', true);
  6673. $timetj = $this->input->get('timetj', true);
  6674. $timetk = strtotime($timetk);
  6675. $timetj = strtotime($timetj);
  6676. $where = "time = '0' ";
  6677. if ($warehouse) {
  6678. $where .= " and warehouse = '$warehouse'";
  6679. }
  6680. if ($sku) {
  6681. $where .= " and sku = '$sku'";
  6682. }
  6683. if ($text) {
  6684. $where .= " and text like '%$text%'";
  6685. }
  6686. if ($cz != '') {
  6687. $where .= " and cz = '$cz'";
  6688. }
  6689. if ($timetk && $timetj) {
  6690. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6691. }
  6692. //数据排序
  6693. $order_str = $xztime . " desc";
  6694. //取得信息列表
  6695. $zh = array();
  6696. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6697. foreach ($info_list as $v) {
  6698. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6699. $warehouse = $this->warehouse->read($v['warehouse']);
  6700. $v['warehouse'] = $warehouse['title'];
  6701. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6702. $v['stime'] = date('Y-m-d', $v['stime']);
  6703. if (isset($zh[$v['features']])) {
  6704. $zh[$v['features']]['num'] += $v['num'];
  6705. } else {
  6706. $zh[$v['features']] = $v;
  6707. }
  6708. $zh[$v['features']]['features'] = $c;
  6709. }
  6710. $title = "在途数据" . date('Y-m-d', time());
  6711. $titlename = "<table border=1>
  6712. <tr align='center'>
  6713. <td>仓库</td>
  6714. <td>SKU</td>
  6715. <td>名称</td>
  6716. <td>在途数量</td>
  6717. <td>库存数量</td>
  6718. <td>添加在途日期</td>
  6719. <td>预达日期</td>
  6720. <td>备注</td>
  6721. </tr>
  6722. </table>";
  6723. $filename = $title . ".xls";
  6724. $tail = "";
  6725. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6726. }
  6727. }
  6728. public function _fc()
  6729. {
  6730. $vip = 0;
  6731. if (isset($_SESSION['api'])) {
  6732. $user = $this->user->get_api($_SESSION['api']);
  6733. if ($user['vip'] == 1) {
  6734. $vip = 1;
  6735. }
  6736. } else {
  6737. header('Location: /');
  6738. exit;
  6739. }
  6740. $post = $this->input->post(NULL, TRUE);
  6741. if (isset($post['page'])) {
  6742. $page = $this->input->post('page', true);
  6743. $perpage = $this->input->post('perpage', true);
  6744. $category = $this->input->post('category', true);
  6745. $size = $this->input->post('size', true);
  6746. $grade = $this->input->post('grade', true);
  6747. $color = $this->input->post('color', true);
  6748. $lowe = $this->input->post('lowe', true);
  6749. $sku = $this->input->post('sku');
  6750. $title = $this->input->post('title');
  6751. $warehouse = $this->input->post('warehouse', true);
  6752. $usa = $this->input->post('usa', true);
  6753. $purchase = $this->input->post('purchase', true);
  6754. $lacetype = $this->input->post('lacetype', true);
  6755. $haircap = $this->input->post('haircap', true);
  6756. $density = $this->input->post('density', true);
  6757. $details = $this->input->post('details', true);
  6758. $state = $this->input->post('state', true);
  6759. $ktime = $this->input->post('ktime', true);
  6760. $jtime = $this->input->post('jtime', true);
  6761. $ktime = strtotime($ktime);
  6762. $jtime = strtotime($jtime);
  6763. $where = "state = '11'";
  6764. $gj = "";
  6765. $ck = "";
  6766. if ($lacetype) {
  6767. $where .= " and features like '%-$lacetype-%'";
  6768. }
  6769. if ($category) {
  6770. $where .= " and features like '%-$category-%'";
  6771. }
  6772. if ($size) {
  6773. $where .= " and features like '%-$size-%'";
  6774. }
  6775. if ($grade) {
  6776. $where .= " and features like '%-$grade-%'";
  6777. }
  6778. if ($color) {
  6779. $where .= " and features like '%-$color-%'";
  6780. }
  6781. if ($lowe) {
  6782. $where .= " and features like '%-$lowe-%'";
  6783. }
  6784. if ($haircap) {
  6785. $where .= " and features like '%-$haircap-%'";
  6786. }
  6787. if ($density) {
  6788. $where .= " and features like '%-$density-%'";
  6789. }
  6790. if ($usa) {
  6791. if (!$warehouse) {
  6792. $where .= " and (warehouse = '5' or warehouse = '8')";
  6793. }
  6794. }
  6795. if ($warehouse) {
  6796. $where .= " and warehouse = '$warehouse'";
  6797. }
  6798. if ($details) {
  6799. $where .= " and details = '$details'";
  6800. }
  6801. if ($purchase) {
  6802. $where .= " and purchase = '$purchase'";
  6803. }
  6804. if ($state) {
  6805. $where .= " and state = '$state'";
  6806. }
  6807. if ($ktime && $jtime) {
  6808. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6809. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6810. }
  6811. //数据排序
  6812. $order_str = "id desc";
  6813. if (empty($page)) {
  6814. $start = 0;
  6815. $perpage = 1;
  6816. } else {
  6817. $start = ($page - 1) * $perpage;
  6818. }
  6819. if ($sku) {
  6820. $sku = trim($sku, ' ');
  6821. $sku = trim($sku, ' ');
  6822. $where .= " and sku like '%$sku%'";
  6823. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6824. } else if ($title) {
  6825. $title = trim($title, ' ');
  6826. $title = trim($title, ' ');
  6827. $where .= " and title like '%$title%'";
  6828. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6829. } else {
  6830. //$where .= " and time > '$ktime' and time < '$jtime'";
  6831. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6832. }
  6833. //取得信息列表
  6834. $rows = array();
  6835. $list = array();
  6836. foreach ($info_list as $key => $value) {
  6837. $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'] . '"');
  6838. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6839. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6840. $warehouse = $this->warehouse->read($value['warehouse']);
  6841. $info_list[$key]['warehouse'] = $warehouse['title'];
  6842. $info_list[$key]['number'] = $g;
  6843. $info_list[$key]['features'] = $x;
  6844. $info_list[$key]['x'] = $s;
  6845. }
  6846. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6847. $pagenum = ceil($total / $perpage);
  6848. $over = $total - ($start + $perpage);
  6849. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6850. echo json_encode($rows);
  6851. exit;
  6852. }
  6853. $this->data['vip'] = $vip;
  6854. $this->_Template('whlabel_fc', $this->data);
  6855. }
  6856. public function _fcmb()
  6857. {
  6858. $where = "sku != 'Preset'";
  6859. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6860. foreach ($rows as $k => $v) {
  6861. $warehouse = $this->warehouse->read($v['warehouse']);
  6862. $rows[$k]['warehouse'] = $warehouse['title'];
  6863. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6864. $rows[$k]['t'] = '';
  6865. $rows[$k]['n'] = '';
  6866. }
  6867. $title = "封货产品数据导入模板";
  6868. $titlename = "<table border=1>
  6869. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6870. <tr align='center'>
  6871. <td>仓库</td>
  6872. <td>SKU</td>
  6873. <td>产品</td>
  6874. <td>封存产品总数量</td>
  6875. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6876. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6877. </tr>
  6878. </table>";
  6879. $filename = $title . ".xls";
  6880. $tail = "";
  6881. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6882. }
  6883. public function _fcexcel()
  6884. {
  6885. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6886. $config['upload_path'] = '.' . $dir;
  6887. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6888. $config['allowed_types'] = 'xls|xlsx|csv';
  6889. $config['max_size'] = 10240;
  6890. $this->load->library('upload', $config);
  6891. $this->upload->initialize($config);
  6892. if ($this->upload->do_upload('userfile')) {
  6893. $full_path = $dir . $this->upload->data('file_name');
  6894. $fileName = '.' . $full_path;
  6895. if (!file_exists($fileName)) {
  6896. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6897. exit;
  6898. } else {
  6899. libxml_use_internal_errors(true);
  6900. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6901. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6902. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6903. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6904. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6905. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6906. ++$column; //如果列数大于26行
  6907. $list = array();
  6908. for ($i = 2; $i <= $row; $i++) // 行数循环
  6909. {
  6910. $data = array();
  6911. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6912. {
  6913. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6914. }
  6915. $list[] = $data;
  6916. }
  6917. }
  6918. $i = 0;
  6919. $j = 0;
  6920. $ed = array();
  6921. foreach ($list as $key => $value) {
  6922. $time = time();
  6923. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6924. continue;
  6925. }
  6926. $warehouse = $this->warehouse->get_title($value['0']);
  6927. $sku = $value['1'];
  6928. $type = $value['4']; //调整方式0扣减1删除
  6929. $num = $value['5']; //调整数量
  6930. //$text = $value['4'];//扣减说明
  6931. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6932. if (!$d) //如果没有这个SKU
  6933. {
  6934. $ed[] = array($sku . '-库存中不存在此SKU');
  6935. $j++;
  6936. continue;
  6937. }
  6938. if (!isset($warehouse['id'])) {
  6939. $ed[] = array($sku . '-仓库名错误!');
  6940. $j++;
  6941. continue;
  6942. }
  6943. if ($type == 1 || $type == 2) //扣减库存
  6944. {
  6945. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6946. if (count($data) < abs($num)) {
  6947. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6948. $j++;
  6949. continue;
  6950. }
  6951. if ($type == 1) //转入库存
  6952. {
  6953. for ($i = 0; $i < abs($num); $i++) {
  6954. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6955. }
  6956. } else if ($type == 2) //删除
  6957. {
  6958. for ($i = 0; $i < abs($num); $i++) {
  6959. $this->whlabel->remove($data[$i]['id']);
  6960. }
  6961. }
  6962. } else if ($type == 0) //增加库存
  6963. {
  6964. $post['sku'] = $d['sku'];
  6965. $post['shop'] = '';
  6966. $post['warehouse'] = $warehouse['id'];
  6967. $post['purchase'] = $d['purchase'];
  6968. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6969. $post['state'] = 11;
  6970. $post['title'] = $d['title'];
  6971. $post['number'] = $d['number'];
  6972. $post['features'] = $d['features'];
  6973. $post['enter'] = $time;
  6974. $post['time'] = $time; //操作时间
  6975. for ($i = 0; $i < $num; $i++) {
  6976. $post['label'] = time() . rand(100, 999) . $i;
  6977. $this->whlabel->insert($post);
  6978. }
  6979. }
  6980. sleep(1); //防止入库时间一样,需要延迟1秒
  6981. }
  6982. if ($j > 0) {
  6983. $tt = date('Ymd', time());
  6984. $title = '库存导入错误信息-' . $tt;
  6985. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6986. $tail = "\n";
  6987. $filename = $title . ".xls";
  6988. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6989. $dir = '/data/excel/' . $time . '/';
  6990. $file_name = 'error_' . $time . rand(1000, 9999);
  6991. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6992. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6993. fwrite($myfile, $ecl);
  6994. fclose($myfile);
  6995. $error = $dir . $file_name . '.xls';
  6996. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6997. exit;
  6998. } else {
  6999. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7000. exit;
  7001. }
  7002. }
  7003. }
  7004. public function _fcjxc($arg_array)
  7005. {
  7006. if (isset($_GET['excel'])) {
  7007. $category = $this->input->get('category', true);
  7008. $size = $this->input->get('size', true);
  7009. $grade = $this->input->get('grade', true);
  7010. $color = $this->input->get('color', true);
  7011. $lowe = $this->input->get('lowe', true);
  7012. $sku = $this->input->get('sku');
  7013. $title = $this->input->get('title');
  7014. $warehouse = $arg_array[0];
  7015. $usa = $this->input->get('usa', true);
  7016. $purchase = $this->input->get('purchase', true);
  7017. $lacetype = $this->input->get('lacetype', true);
  7018. $haircap = $this->input->get('haircap', true);
  7019. $density = $this->input->get('density', true);
  7020. $title = $this->input->get('title', true);
  7021. $state = $this->input->get('state', true);
  7022. $ktime = $this->input->get('ktime', true);
  7023. $jtime = $this->input->get('jtime', true);
  7024. $where = "state=11";
  7025. $gj = "";
  7026. $ck = "";
  7027. if ($lacetype) {
  7028. $where .= " and features like '%-$lacetype-%'";
  7029. }
  7030. if ($category) {
  7031. $where .= " and features like '%-$category-%'";
  7032. }
  7033. if ($size) {
  7034. $where .= " and features like '%-$size-%'";
  7035. }
  7036. if ($grade) {
  7037. $where .= " and features like '%-$grade-%'";
  7038. }
  7039. if ($color) {
  7040. $where .= " and features like '%-$color-%'";
  7041. }
  7042. if ($lowe) {
  7043. $where .= " and features like '%-$lowe-%'";
  7044. }
  7045. if ($haircap) {
  7046. $where .= " and features like '%-$haircap-%'";
  7047. }
  7048. if ($density) {
  7049. $where .= " and features like '%-$density-%'";
  7050. }
  7051. if ($usa) {
  7052. if (!$warehouse) {
  7053. $where .= " and (warehouse = '5' or warehouse = '8')";
  7054. }
  7055. }
  7056. if ($warehouse) {
  7057. $where .= " and warehouse = '$warehouse'";
  7058. }
  7059. if ($purchase) {
  7060. $where .= " and purchase = '$purchase'";
  7061. }
  7062. if ($state) {
  7063. $where .= " and state = '$state'";
  7064. }
  7065. $order_str = "id desc";
  7066. if ($sku) {
  7067. $sku = trim($sku, ' ');
  7068. $sku = trim($sku, ' ');
  7069. $where .= " and sku like '%$sku%'";
  7070. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7071. } else if ($title) {
  7072. $title = trim($title, ' ');
  7073. $title = trim($title, ' ');
  7074. $where .= " and title like '%$title%'";
  7075. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7076. } else {
  7077. //$where .= " and time > '$ktime' and time < '$jtime'";
  7078. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7079. }
  7080. //取得信息列表
  7081. $rows = array();
  7082. $list = array();
  7083. foreach ($info_list as $key => $value) {
  7084. $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'] . '"');
  7085. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7086. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7087. $rows[$key] = $value;
  7088. $warehouse = $this->warehouse->read($value['warehouse']);
  7089. $rows[$key]['warehouse'] = $warehouse['title'];
  7090. $rows[$key]['features'] = $g;
  7091. $rows[$key]['a'] = $x;
  7092. $rows[$key]['b'] = $s;
  7093. }
  7094. $title = "总统计表";
  7095. $titlename = "<table border=1>
  7096. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7097. <tr align='center'>
  7098. <td>仓库</td>
  7099. <td>SKU</td>
  7100. <td>产品名称</td>
  7101. <td>录入总量</td>
  7102. <td>取出总量</td>
  7103. <td>剩余总量</td>
  7104. </tr>
  7105. </table>";
  7106. $filename = $title . ".xls";
  7107. $tail = "";
  7108. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7109. }
  7110. $vip = 0;
  7111. if (isset($_SESSION['api'])) {
  7112. $user = $this->user->get_api($_SESSION['api']);
  7113. if ($user['vip'] == 1) {
  7114. $vip = 1;
  7115. }
  7116. } else {
  7117. header('Location: /');
  7118. exit;
  7119. }
  7120. $post = $this->input->post(NULL, TRUE);
  7121. if (isset($post['page'])) {
  7122. $page = $this->input->post('page', true);
  7123. $perpage = $this->input->post('perpage', true);
  7124. $category = $this->input->post('category', true);
  7125. $size = $this->input->post('size', true);
  7126. $grade = $this->input->post('grade', true);
  7127. $color = $this->input->post('color', true);
  7128. $lowe = $this->input->post('lowe', true);
  7129. $sku = $this->input->post('sku');
  7130. $title = $this->input->post('title');
  7131. $warehouse = $arg_array[0];
  7132. $usa = $this->input->post('usa', true);
  7133. $purchase = $this->input->post('purchase', true);
  7134. $lacetype = $this->input->post('lacetype', true);
  7135. $haircap = $this->input->post('haircap', true);
  7136. $density = $this->input->post('density', true);
  7137. $title = $this->input->post('title', true);
  7138. $state = $this->input->post('state', true);
  7139. $ktime = $this->input->post('ktime', true);
  7140. $jtime = $this->input->post('jtime', true);
  7141. $ktime = strtotime($ktime);
  7142. $jtime = strtotime($jtime);
  7143. $where = "state=11";
  7144. $gj = "";
  7145. $ck = "";
  7146. if ($lacetype) {
  7147. $where .= " and features like '%-$lacetype-%'";
  7148. }
  7149. if ($category) {
  7150. $where .= " and features like '%-$category-%'";
  7151. }
  7152. if ($size) {
  7153. $where .= " and features like '%-$size-%'";
  7154. }
  7155. if ($grade) {
  7156. $where .= " and features like '%-$grade-%'";
  7157. }
  7158. if ($color) {
  7159. $where .= " and features like '%-$color-%'";
  7160. }
  7161. if ($lowe) {
  7162. $where .= " and features like '%-$lowe-%'";
  7163. }
  7164. if ($haircap) {
  7165. $where .= " and features like '%-$haircap-%'";
  7166. }
  7167. if ($density) {
  7168. $where .= " and features like '%-$density-%'";
  7169. }
  7170. if ($usa) {
  7171. if (!$warehouse) {
  7172. $where .= " and (warehouse = '5' or warehouse = '8')";
  7173. }
  7174. }
  7175. if ($warehouse) {
  7176. $where .= " and warehouse = '$warehouse'";
  7177. }
  7178. if ($purchase) {
  7179. $where .= " and purchase = '$purchase'";
  7180. }
  7181. if ($state) {
  7182. $where .= " and state = '$state'";
  7183. }
  7184. if ($ktime && $jtime) {
  7185. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7186. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7187. }
  7188. //数据排序
  7189. $order_str = "id desc";
  7190. $xs = 0;
  7191. $rows = array();
  7192. $list = array();
  7193. if (empty($page)) {
  7194. $start = 0;
  7195. $perpage = 1;
  7196. } else {
  7197. $start = ($page - 1) * $perpage;
  7198. }
  7199. if ($sku || $title) {
  7200. if ($title) {
  7201. $title = trim($title, ' ');
  7202. $title = trim($title, ' ');
  7203. $where .= " and title like '%$title%'";
  7204. } else {
  7205. $sku = trim($sku, ' ');
  7206. $sku = trim($sku, ' ');
  7207. $where .= " and sku like '%$sku%'";
  7208. }
  7209. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7210. foreach ($info_list as $key => $value) {
  7211. $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'] . '"');
  7212. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7213. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7214. $rows[$key] = $value;
  7215. $warehouse = $this->warehouse->read($value['warehouse']);
  7216. $rows[$key]['warehouse'] = $warehouse['title'];
  7217. $rows[$key]['features'] = $g;
  7218. $rows[$key]['a'] = $x;
  7219. $rows[$key]['b'] = $s;
  7220. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7221. $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天销量
  7222. $yj = $c / ($xl / 30);
  7223. if ($yj < 7) {
  7224. $rows[$key]['y'] = round($yj) . '天销量';
  7225. } else {
  7226. $rows[$key]['y'] = '正常';
  7227. }
  7228. }
  7229. } else {
  7230. //$where .= " and time > '$ktime' and time < '$jtime'";
  7231. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7232. foreach ($info_list as $key => $value) {
  7233. $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'] . '"');
  7234. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7235. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7236. $zs[$key] = $value;
  7237. $warehouse = $this->warehouse->read($value['warehouse']);
  7238. $zs[$key]['warehouse'] = $warehouse['title'];
  7239. $zs[$key]['features'] = $g;
  7240. $zs[$key]['a'] = $x;
  7241. $zs[$key]['b'] = $s;
  7242. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7243. $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天销量
  7244. $yj = $c / ($xl / 30);
  7245. if ($yj < 7) {
  7246. $zs[$key]['y'] = round($yj) . '天销量';
  7247. $rows[$key] = $zs[$key];
  7248. }
  7249. }
  7250. }
  7251. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7252. $pagenum = ceil($total / $perpage);
  7253. $over = $total - ($start + $perpage);
  7254. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7255. echo json_encode($rows);
  7256. exit;
  7257. }
  7258. $this->data['arg_array'] = $arg_array[0];
  7259. $this->_Template('whlabel_fcjxc', $this->data);
  7260. }
  7261. public function _0kcdel()
  7262. {
  7263. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7264. $config['upload_path'] = '.' . $dir;
  7265. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7266. $config['allowed_types'] = 'xls|xlsx|csv';
  7267. $config['max_size'] = 10240;
  7268. $this->load->library('upload', $config);
  7269. $this->upload->initialize($config);
  7270. if ($this->upload->do_upload('userfile')) {
  7271. $full_path = $dir . $this->upload->data('file_name');
  7272. $fileName = '.' . $full_path;
  7273. if (!file_exists($fileName)) {
  7274. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7275. exit;
  7276. } else {
  7277. require_once "./data/excel/PHPExcel/IOFactory.php";
  7278. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7279. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7280. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7281. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7282. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7283. ++$column; //如果列数大于26行
  7284. $list = array();
  7285. for ($i = 2; $i <= $row; $i++) // 行数循环
  7286. {
  7287. $data = array();
  7288. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7289. {
  7290. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7291. }
  7292. $list[] = $data;
  7293. }
  7294. }
  7295. $i = 0;
  7296. $j = 0;
  7297. $ed = array();
  7298. foreach ($list as $key => $value) {
  7299. $time = time();
  7300. if ($value['0'] == "" || $value['1'] == "") {
  7301. continue;
  7302. }
  7303. $warehouse = $this->warehouse->get_title($value['0']);
  7304. $sku = $value['1'];
  7305. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7306. if (!$d) //如果没有这个SKU
  7307. {
  7308. $ed[] = array($sku . '-库存中不存在此SKU');
  7309. $j++;
  7310. continue;
  7311. }
  7312. if (!isset($warehouse['id'])) {
  7313. $ed[] = array($sku . '-仓库名错误!');
  7314. $j++;
  7315. continue;
  7316. }
  7317. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7318. if ($z < 1) {
  7319. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7320. foreach ($z as $v) {
  7321. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7322. if (count($zt) > 0) {
  7323. $ed[] = array($sku . '-有在途库存无法删除!');
  7324. $j++;
  7325. continue;
  7326. }
  7327. $this->whlabel->remove($v['id']);
  7328. }
  7329. } else {
  7330. $ed[] = array($sku . '-非0库存!');
  7331. $j++;
  7332. continue;
  7333. }
  7334. }
  7335. if ($j > 0) {
  7336. $tt = date('Ymd', time());
  7337. $title = '删除0库存错误信息-' . $tt;
  7338. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7339. $tail = "\n";
  7340. $filename = $title . ".xls";
  7341. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7342. $dir = '/data/excel/' . $time . '/';
  7343. $file_name = 'error_' . $time . rand(1000, 9999);
  7344. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7345. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7346. fwrite($myfile, $ecl);
  7347. fclose($myfile);
  7348. $error = $dir . $file_name . '.xls';
  7349. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7350. exit;
  7351. } else {
  7352. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7353. exit;
  7354. }
  7355. }
  7356. }
  7357. public function _gbhtype()
  7358. {
  7359. $post = $this->input->post(NULL, TRUE);
  7360. if (isset($post['s'])) {
  7361. $n = $this->input->post('n');
  7362. $d = $this->input->post('s');
  7363. if (!$d) {
  7364. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7365. exit;
  7366. }
  7367. $d = explode(',', trim($d, ','));
  7368. $t = $this->whlabel_type->read($n);
  7369. //循环删除记录
  7370. foreach ($d as $v) {
  7371. $u = $this->whlabel->read($v);
  7372. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7373. foreach ($data as $val) {
  7374. $this->whlabel->save(array('type' => $n), $val['id']);
  7375. }
  7376. }
  7377. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7378. }
  7379. }
  7380. //出库、退库导出
  7381. public function _dccrtype()
  7382. {
  7383. $classid = $this->classid->sku();
  7384. $pm = $classid;
  7385. $typeclass = array();
  7386. $tc = $this->typeclass->find_all();
  7387. foreach ($tc as $v) {
  7388. $typeclass[$v['id']] = $v;
  7389. }
  7390. $prc = array();
  7391. $purchase = $this->purchase->find_all();
  7392. foreach ($purchase as $k => $v) {
  7393. $prc[$v['id']] = $v['title'];
  7394. }
  7395. if (isset($_GET['sid'])) {
  7396. $wh = array();
  7397. $w = $this->warehouse->find_all('1=1', 'id,title');
  7398. foreach ($w as $v) {
  7399. $wh[$v['id']] = $v['title'];
  7400. }
  7401. $type = $this->input->get('excel', true);
  7402. $category = $this->input->get('category', true);
  7403. $size = $this->input->get('size', true);
  7404. $grade = $this->input->get('grade', true);
  7405. $color = $this->input->get('color', true);
  7406. $lowe = $this->input->get('lowe', true);
  7407. $sku = $this->input->get('sku', true);
  7408. $warehouse = $this->input->get('warehouse', true);
  7409. $lacetype = $this->input->get('lacetype', true);
  7410. $lacecolor = $this->input->get('lacecolor', true);
  7411. $density = $this->input->get('density', true);
  7412. $haircap = $this->input->get('haircap', true);
  7413. $purchase = $this->input->get('purchase', true);
  7414. $title = $this->input->get('title', true);
  7415. $state = $this->input->get('state', true);
  7416. $sid = $this->input->get('sid', true);
  7417. $ktime = $this->input->get('ktime', true);
  7418. $jtime = $this->input->get('jtime', true);
  7419. $ktime = strtotime($ktime);
  7420. $jtime = strtotime($jtime);
  7421. $where = "1=1";
  7422. $gj = "";
  7423. $ck = "";
  7424. if ($category) {
  7425. $where .= " and features like '%-$category-%'";
  7426. }
  7427. if ($size) {
  7428. $where .= " and features like '%-$size-%'";
  7429. }
  7430. if ($grade) {
  7431. $where .= " and features like '%-$grade-%'";
  7432. }
  7433. if ($color) {
  7434. $where .= " and features like '%-$color-%'";
  7435. }
  7436. if ($lowe) {
  7437. $where .= " and features like '%-$lowe-%'";
  7438. }
  7439. if ($warehouse) {
  7440. $where .= " and warehouse = '$warehouse'";
  7441. }
  7442. if ($purchase) {
  7443. $where .= " and purchase = '$purchase'";
  7444. }
  7445. if ($state) {
  7446. $where .= " and state = '$state'";
  7447. }
  7448. if ($lacetype) {
  7449. $where .= " and features like '%-$lacetype-%'";
  7450. }
  7451. if ($lacecolor) {
  7452. $where .= " and features like '%-$lacecolor-%'";
  7453. }
  7454. if ($density) {
  7455. $where .= " and features like '%-$density-%'";
  7456. }
  7457. if ($haircap) {
  7458. $where .= " and features like '%-$haircap-%'";
  7459. }
  7460. if ($title) {
  7461. $title = trim($title, ' ');
  7462. $title = trim($title, ' ');
  7463. $where .= " and title like '%$title%'";
  7464. }
  7465. if ($sku) {
  7466. $sku = trim($sku, ' ');
  7467. $sku = trim($sku, ' ');
  7468. $where .= " and sku like '%$sku%'";
  7469. }
  7470. if ($ktime && $jtime) {
  7471. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7472. }
  7473. $sidwhere = '';
  7474. if ($sid) {
  7475. $sd = "";
  7476. $s = explode(',', trim($sid, ','));
  7477. foreach ($s as $value) {
  7478. $sd .= " id = " . $value . " or";
  7479. }
  7480. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7481. }
  7482. //数据排序
  7483. $order_str = "time desc";
  7484. if (empty($page)) {
  7485. $start = 0;
  7486. $perpage = 1;
  7487. } else {
  7488. $start = ($page - 1) * $perpage;
  7489. }
  7490. $wh = array();
  7491. $w = $this->warehouse->find_all('1=1', 'id,title');
  7492. foreach ($w as $v) {
  7493. $wh[$v['id']] = $v['title'];
  7494. }
  7495. $wt = array();
  7496. $whlabel_type = $this->whlabel_type->find_all();
  7497. foreach ($whlabel_type as $v) {
  7498. $wt[$v['id']] = $v['title'];
  7499. }
  7500. $classid = $this->classid->sku();
  7501. $list = array();
  7502. $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');
  7503. foreach ($rows_r as $key => $value) {
  7504. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7505. $pm = $classid;
  7506. $jm = $classid;
  7507. $rows_r[$key]['enter'] = '入库';
  7508. $rows_r[$key]['time'] = $value['enter'];
  7509. if ($value['rktype'] == 1) {
  7510. $rows_r[$key]['rktype'] = '采购入库';
  7511. } else if ($value['rktype'] == 2) {
  7512. $rows_r[$key]['rktype'] = '盘盈调整';
  7513. } else if ($value['rktype'] == 3) {
  7514. $rows_r[$key]['rktype'] = '其他调整入库';
  7515. } else if ($value['rktype'] == 4) {
  7516. $rows_r[$key]['rktype'] = '其他调整入库';
  7517. } else if ($value['rktype'] == 5) {
  7518. $rows_r[$key]['rktype'] = '退库入库';
  7519. } else if ($value['rktype'] == 6) {
  7520. $rows_r[$key]['rktype'] = '退货可用入库';
  7521. } else if ($value['rktype'] == 7) {
  7522. $rows_r[$key]['rktype'] = '形态转换入库';
  7523. } else {
  7524. $rows_r[$key]['rktype'] = '';
  7525. }
  7526. $features = explode('-', trim($value['features'], '-'));
  7527. foreach ($features as $v) {
  7528. if (isset($typeclass[$v])) {
  7529. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7530. $pm[$typeclass[$v]['classid']] = $zh[0];
  7531. }
  7532. if (isset($typeclass[$v])) {
  7533. if (isset($jm[$typeclass[$v]['classid']])) {
  7534. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7535. }
  7536. }
  7537. }
  7538. $zh = implode(" ", $pm);
  7539. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7540. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7541. $rows_r[$key]['zh'] = $zh;
  7542. $jm = array_filter($jm);
  7543. $rows_r[$key]['features'] = implode("-", $jm);
  7544. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7545. }
  7546. $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');
  7547. foreach ($rows_c as $key => $value) {
  7548. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7549. $pm = $classid;
  7550. $jm = $classid;
  7551. $rows_c[$key]['time'] = $value['outk'];
  7552. $rows_c[$key]['outk'] = '出库';
  7553. if ($value['cktype'] == 1) {
  7554. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7555. } else if ($value['cktype'] == 2) {
  7556. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7557. } else if ($value['cktype'] == 3) {
  7558. $rows_c[$key]['cktype'] = '盘亏调整';
  7559. } else if ($value['cktype'] == 4) {
  7560. $rows_c[$key]['cktype'] = '其他调整出库';
  7561. } else if ($value['cktype'] == 5) {
  7562. $rows_c[$key]['cktype'] = '形态转换出库';
  7563. } else {
  7564. $rows_c[$key]['cktype'] = '';
  7565. }
  7566. unset($rows_c[$key]['state']);
  7567. $features = explode('-', trim($value['features'], '-'));
  7568. foreach ($features as $v) {
  7569. if (isset($typeclass[$v])) {
  7570. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7571. $pm[$typeclass[$v]['classid']] = $zh[0];
  7572. }
  7573. if (isset($typeclass[$v])) {
  7574. if (isset($jm[$typeclass[$v]['classid']])) {
  7575. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7576. }
  7577. }
  7578. }
  7579. $zh = implode(" ", $pm);
  7580. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7581. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7582. $rows_c[$key]['zh'] = $zh;
  7583. $jm = array_filter($jm);
  7584. $rows_c[$key]['features'] = implode("-", $jm);
  7585. $rows_c[$key]['number'] = 1;
  7586. }
  7587. $merged = $rows_r;
  7588. foreach ($rows_c as $key => $value) {
  7589. if (isset($merged[$key])) {
  7590. $merged[] = $value;
  7591. } else {
  7592. $merged[$key] = $value;
  7593. }
  7594. }
  7595. usort($merged, function ($a, $b) {
  7596. return $a['time'] - $b['time'];
  7597. });
  7598. foreach ($merged as $key => $value) {
  7599. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7600. }
  7601. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7602. $titlename = "<table border=1>
  7603. <tr align='center'>
  7604. <td>仓库</td>
  7605. <td>SKU</td>
  7606. <td>商品名称</td>
  7607. <td>仓库品名</td>
  7608. <td>料号</td>
  7609. <td>时间</td>
  7610. <td>操作</td>
  7611. <td>类型</td>
  7612. <td>数量</td>
  7613. <td>备注</td>
  7614. </tr>
  7615. </table>";
  7616. $filename = $title . ".xlsx";
  7617. $tail = "";
  7618. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7619. }
  7620. }
  7621. /*************************************处理exceljs导出****************************************************/
  7622. public function _excelrjs(){
  7623. if (isset($_GET['excel'])) {
  7624. $category = $this->input->get('category', true);
  7625. $size = $this->input->get('size', true);
  7626. $grade = $this->input->get('grade', true);
  7627. $color = $this->input->get('color', true);
  7628. $lowe = $this->input->get('lowe', true);
  7629. $sku = $this->input->get('sku', true);
  7630. $warehouse = $this->input->get('warehouse', true);
  7631. $purchase = $this->input->get('purchase', true);
  7632. $ktime = $this->input->get('ktime', true);
  7633. $jtime = $this->input->get('jtime', true);
  7634. $ktime = strtotime($ktime);
  7635. $jtime = strtotime($jtime);
  7636. $where = "1=1";
  7637. $gj = "";
  7638. $ck = "";
  7639. if ($category) {
  7640. $where .= " and features like '%-$category-%'";
  7641. }
  7642. if ($size) {
  7643. $where .= " and features like '%-$size-%'";
  7644. }
  7645. if ($grade) {
  7646. $where .= " and features like '%-$grade-%'";
  7647. }
  7648. if ($color) {
  7649. $where .= " and features like '%-$color-%'";
  7650. }
  7651. if ($lowe) {
  7652. $where .= " and features like '%-$lowe-%'";
  7653. }
  7654. if ($warehouse) {
  7655. $where .= " and warehouse = '$warehouse'";
  7656. }
  7657. if ($purchase) {
  7658. $where .= " and purchase = '$purchase'";
  7659. }
  7660. if ($sku) {
  7661. $where .= " and sku = '$sku'";
  7662. }
  7663. if ($ktime && $jtime) {
  7664. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7665. }
  7666. //数据排序
  7667. $order_str = "id desc";
  7668. if (empty($page)) {
  7669. $start = 0;
  7670. $perpage = 1;
  7671. } else {
  7672. $start = ($page - 1) * $perpage;
  7673. }
  7674. $list = array();
  7675. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7676. foreach ($rows as $value) {
  7677. $ck = $this->warehouse->read($value['warehouse']);
  7678. $warehouse = $ck['title'];
  7679. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7680. $retreatwarehouse = $tkck['title'];
  7681. $gy = $this->purchase->read($value['purchase']);
  7682. $purchase = $gy['title'];
  7683. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7684. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7685. }
  7686. if(empty($list)){
  7687. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7688. }else{
  7689. $final_list = [];
  7690. foreach($list as $v){
  7691. $final_list[] = array_values($v);
  7692. }
  7693. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7694. array_unshift($final_list,[
  7695. "仓库","SKU","商品名称","时间","数量"
  7696. ]);
  7697. array_unshift($final_list,[
  7698. $title,"","","",""
  7699. ]);
  7700. $merges = [
  7701. [
  7702. "s"=>["r"=>0,"c"=>0],
  7703. "e"=>["r"=>0,"c"=>4]
  7704. ]
  7705. ];
  7706. $cols = [
  7707. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7708. ];
  7709. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7710. }
  7711. }
  7712. }
  7713. //出库、退库导出
  7714. public function _excelctjs()
  7715. {
  7716. $classid = $this->classid->sku();
  7717. $pm = $classid;
  7718. $typeclass = array();
  7719. $tc = $this->typeclass->find_all();
  7720. foreach ($tc as $v) {
  7721. $typeclass[$v['id']] = $v;
  7722. }
  7723. $prc = array();
  7724. $purchase = $this->purchase->find_all();
  7725. foreach ($purchase as $k => $v) {
  7726. $prc[$v['id']] = $v['title'];
  7727. }
  7728. if (isset($_GET['excel'])) {
  7729. $wh = array();
  7730. $w = $this->warehouse->find_all('1=1', 'id,title');
  7731. foreach ($w as $v) {
  7732. $wh[$v['id']] = $v['title'];
  7733. }
  7734. $type = $this->input->get('excel', true);
  7735. $category = $this->input->get('category', true);
  7736. $size = $this->input->get('size', true);
  7737. $grade = $this->input->get('grade', true);
  7738. $color = $this->input->get('color', true);
  7739. $lowe = $this->input->get('lowe', true);
  7740. $sku = $this->input->get('sku', true);
  7741. $title = $this->input->get('title', true);
  7742. $warehouse = $this->input->get('warehouse', true);
  7743. $purchase = $this->input->get('purchase', true);
  7744. $lacetype = $this->input->get('lacetype', true);
  7745. $haircap = $this->input->get('haircap', true);
  7746. $lacecolor = $this->input->get('lacecolor', true);
  7747. $density = $this->input->get('density', true);
  7748. $details = $this->input->get('details', true);
  7749. $state = $this->input->get('state', true);
  7750. $shop = $this->input->get('shop', true);
  7751. $hairnumber = $this->input->get('hairnumber', true);
  7752. $type_leixi = $this->input->get('type', true);
  7753. $cpbz = $this->input->get('cpbz', true);
  7754. $sm = $this->input->get('sm', true);
  7755. $sid = $this->input->get('sid', true);
  7756. $ktime = $this->input->get('ktime', true);
  7757. $jtime = $this->input->get('jtime', true);
  7758. $ktime = strtotime($ktime);
  7759. $jtime = strtotime($jtime);
  7760. //$where = " 1=1 ";
  7761. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7762. $where = " sku != '' ";
  7763. $gj = "";
  7764. $ck = "";
  7765. if ($category) {
  7766. $where .= " and features like '%-$category-%'";
  7767. }
  7768. if ($size) {
  7769. $where .= " and features like '%-$size-%'";
  7770. }
  7771. if ($grade) {
  7772. $where .= " and features like '%-$grade-%'";
  7773. }
  7774. if ($color) {
  7775. $where .= " and features like '%-$color-%'";
  7776. }
  7777. if ($lowe) {
  7778. $where .= " and features like '%-$lowe-%'";
  7779. }
  7780. if ($warehouse) {
  7781. $where .= " and warehouse = '$warehouse'";
  7782. }
  7783. if ($purchase) {
  7784. $where .= " and purchase = '$purchase'";
  7785. }
  7786. if ($state) {
  7787. $where .= " and state = '$state'";
  7788. }
  7789. if ($lacetype) {
  7790. $where .= " and features like '%-$lacetype-%'";
  7791. }
  7792. if ($lacecolor) {
  7793. $where .= " and features like '%-$lacecolor-%'";
  7794. }
  7795. if ($density) {
  7796. $where .= " and features like '%-$density-%'";
  7797. }
  7798. if ($haircap) {
  7799. $where .= " and features like '%-$haircap-%'";
  7800. }
  7801. if ($details) {
  7802. $where .= " and details = '$details'";
  7803. }
  7804. if ($shop) {
  7805. $where .= " and shop like '%$shop%'";
  7806. }
  7807. if ($title) {
  7808. $title = trim($title, ' ');
  7809. $title = trim($title, ' ');
  7810. $where .= " and title like '%$title%'";
  7811. }
  7812. if (!empty($hairnumber)) {
  7813. $where .= " and features like '%-128-%' ";
  7814. if ($hairnumber < 0) {
  7815. $class_list = $this->typeclass->find_all('classid = 43');
  7816. foreach ($class_list as $v) {
  7817. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7818. }
  7819. } else {
  7820. $where .= " and features like '%-$hairnumber-%'";
  7821. }
  7822. }
  7823. if ($type_leixi) {
  7824. $where .= " and type = '$type_leixi'";
  7825. }
  7826. if ($cpbz) {
  7827. $where .= " and cpbz like '%$cpbz%' ";
  7828. }
  7829. if ($sm) {
  7830. $where .= " and sm like '%$sm%' ";
  7831. }
  7832. if ($sku) {
  7833. $sku = trim($sku, ' ');
  7834. $sku = trim($sku, ' ');
  7835. $where .= " and sku like '%$sku%'";
  7836. }
  7837. if ($ktime && $jtime) {
  7838. if ($type == 1) {
  7839. $tl = '出库';
  7840. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7841. } else if ($type == 2) {
  7842. $tl = '退库';
  7843. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7844. } else if ($type == 3) {
  7845. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7846. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7847. } else if ($type == 4) {
  7848. $tl = '出库+零售';
  7849. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7850. } else if ($type == 5) {
  7851. $tl = '零售';
  7852. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7853. }
  7854. }
  7855. $sidwhere = '';
  7856. if ($sid) {
  7857. $sd = "";
  7858. $s = explode(',', trim($sid, ','));
  7859. foreach ($s as $value) {
  7860. $sd .= " id = " . $value . " or";
  7861. }
  7862. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7863. }
  7864. //数据排序
  7865. $order_str = "time desc";
  7866. if (empty($page)) {
  7867. $start = 0;
  7868. $perpage = 1;
  7869. } else {
  7870. $start = ($page - 1) * $perpage;
  7871. }
  7872. //取得信息列表
  7873. if ($type != 3 && $type != 5) {
  7874. if ($type == 1 || $type == 4) {
  7875. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7876. foreach ($info_list as $key => $value) {
  7877. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7878. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7879. $warehouse = $this->warehouse->read($value['warehouse']);
  7880. $info_list[$key]['warehouse'] = $warehouse['title'];
  7881. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7882. $features = explode('-', trim($features, '-'));
  7883. $pm = $classid;
  7884. foreach ($features as $k => $v) {
  7885. if ($v != 0) {
  7886. if (!isset($typeclass[$v])) {
  7887. continue;
  7888. }
  7889. if (isset($pm[$typeclass[$v]['classid']])) {
  7890. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7891. $tz = explode('|', $typeclass[$v]['zh']);
  7892. $pm[$typeclass[$v]['classid']] = $tz[0];
  7893. } else {
  7894. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7895. }
  7896. }
  7897. }
  7898. }
  7899. $zh = implode(" ", $pm);
  7900. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7901. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7902. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7903. $info_list[$key]['features'] = $zh;
  7904. }
  7905. $final_list = [];
  7906. foreach($info_list as $k=>$v){
  7907. $number = "";
  7908. if(!empty($v['orderinfo'])){
  7909. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7910. if(!empty($tmp_info['number'])){
  7911. $number = $tmp_info['number'];
  7912. }
  7913. }
  7914. $final_list[] = [
  7915. 'warehouse'=>$v['warehouse'],
  7916. 'purchase'=>$v['purchase'],
  7917. 'sku'=>$v['sku'],
  7918. 'title'=>$v['title'],
  7919. 'features'=>$v['features'],
  7920. 'label'=>$v['label'],
  7921. 'orderinfo'=>$v['orderinfo'],
  7922. 'number'=>$number,
  7923. 'waybill'=>$v['waybill'],
  7924. 'outk'=>$v['outk'],
  7925. ];
  7926. }
  7927. } else {
  7928. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7929. foreach ($info_list as $key => $value) {
  7930. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7931. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7932. $warehouse = $this->warehouse->read($value['warehouse']);
  7933. $info_list[$key]['warehouse'] = $warehouse['title'];
  7934. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7935. $features = explode('-', trim($features, '-'));
  7936. $pm = $classid;
  7937. foreach ($features as $k => $v) {
  7938. if ($v != 0) {
  7939. if (!isset($typeclass[$v])) {
  7940. continue;
  7941. }
  7942. if (isset($pm[$typeclass[$v]['classid']])) {
  7943. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7944. $tz = explode('|', $typeclass[$v]['zh']);
  7945. $pm[$typeclass[$v]['classid']] = $tz[0];
  7946. } else {
  7947. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7948. }
  7949. }
  7950. }
  7951. }
  7952. $zh = implode(" ", $pm);
  7953. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7954. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7955. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7956. $info_list[$key]['features'] = $zh;
  7957. }
  7958. $final_list = [];
  7959. foreach($info_list as $k=>$v){
  7960. $number = "";
  7961. if(!empty($v['orderinfo'])){
  7962. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7963. if(!empty($tmp_info['number'])){
  7964. $number = $tmp_info['number'];
  7965. }
  7966. }
  7967. $final_list[] = [
  7968. 'warehouse'=>$v['warehouse'],
  7969. 'purchase'=>$v['purchase'],
  7970. 'sku'=>$v['sku'],
  7971. 'title'=>$v['title'],
  7972. 'features'=>$v['features'],
  7973. 'label'=>$v['label'],
  7974. 'orderinfo'=>$v['orderinfo'],
  7975. 'number'=>$number,
  7976. 'waybill'=>$v['waybill'],
  7977. 'retreat'=>$v['retreat'],
  7978. ];
  7979. }
  7980. }
  7981. if(empty($final_list)){
  7982. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7983. }else{
  7984. $end_list = [];
  7985. foreach($final_list as $v){
  7986. $end_list[] = array_values($v);
  7987. }
  7988. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  7989. array_unshift($end_list,[
  7990. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  7991. ]);
  7992. array_unshift($end_list,[
  7993. $title,"","","","","","","","",""
  7994. ]);
  7995. $merges = [
  7996. [
  7997. "s"=>["r"=>0,"c"=>0],
  7998. "e"=>["r"=>0,"c"=>9]
  7999. ]
  8000. ];
  8001. $cols = [
  8002. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8003. ];
  8004. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8005. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8006. ] )));
  8007. }
  8008. } else if ($type == 5) {
  8009. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8010. foreach ($info_list as $key => $value) {
  8011. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8012. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8013. $warehouse = $this->warehouse->read($value['warehouse']);
  8014. $info_list[$key]['warehouse'] = $warehouse['title'];
  8015. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8016. $features = explode('-', trim($features, '-'));
  8017. $pm = $classid;
  8018. foreach ($features as $k => $v) {
  8019. if ($v != 0) {
  8020. if (!isset($typeclass[$v])) {
  8021. continue;
  8022. }
  8023. if (isset($pm[$typeclass[$v]['classid']])) {
  8024. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8025. $tz = explode('|', $typeclass[$v]['zh']);
  8026. $pm[$typeclass[$v]['classid']] = $tz[0];
  8027. } else {
  8028. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8029. }
  8030. }
  8031. }
  8032. }
  8033. $zh = implode(" ", $pm);
  8034. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8035. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8036. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8037. $info_list[$key]['features'] = $zh;
  8038. }
  8039. if(empty($info_list)){
  8040. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8041. }else{
  8042. $final_list = [];
  8043. foreach($info_list as $v){
  8044. $final_list[] = array_values($v);
  8045. }
  8046. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8047. array_unshift($final_list,[
  8048. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8049. ]);
  8050. array_unshift($final_list,[
  8051. $title,"","","","","","",
  8052. ]);
  8053. $merges = [
  8054. [
  8055. "s"=>["r"=>0,"c"=>0],
  8056. "e"=>["r"=>0,"c"=>6]
  8057. ]
  8058. ];
  8059. $cols = [
  8060. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8061. ];
  8062. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8063. }
  8064. } else {
  8065. $wh = array();
  8066. $w = $this->warehouse->find_all('1=1', 'id,title');
  8067. foreach ($w as $v) {
  8068. $wh[$v['id']] = $v['title'];
  8069. }
  8070. $wt = array();
  8071. $whlabel_type = $this->whlabel_type->find_all();
  8072. foreach ($whlabel_type as $v) {
  8073. $wt[$v['id']] = $v['title'];
  8074. }
  8075. $classid = $this->classid->sku();
  8076. $list = array();
  8077. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8078. foreach ($rows as $key => $value) {
  8079. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8080. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8081. $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');
  8082. $details = array();
  8083. $cpid = array();
  8084. $cpbz = array();
  8085. $c = 0;
  8086. $g = 0;
  8087. $x = 0;
  8088. $t = 0;
  8089. $s = 0;
  8090. $q = 0;
  8091. foreach ($sd as $k => $v) {
  8092. if ($v['state'] == 0) {
  8093. $c++;
  8094. }
  8095. if ($v['state'] != 9) {
  8096. $g++;
  8097. }
  8098. if ($v['outk'] > 1) {
  8099. $x++;
  8100. }
  8101. if ($v['retreat'] > 0) {
  8102. $t++;
  8103. }
  8104. if ($v['state'] == 8) {
  8105. $s++;
  8106. }
  8107. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8108. $q++;
  8109. }
  8110. $details[$v['details']] = $v['details'];
  8111. if ($v['cpid'] != 0) {
  8112. $cpid[$v['cpid']] = $v['cpid'];
  8113. }
  8114. if ($v['cpbz'] != '') {
  8115. $cpbz[$v['cpbz']] = $v['cpbz'];
  8116. }
  8117. }
  8118. if (isset($wt[$value['type']])) {
  8119. $rows[$key]['type'] = $wt[$value['type']];
  8120. } else {
  8121. $rows[$key]['type'] = '未设置';
  8122. }
  8123. $rows[$key]['details'] = implode("、", $details);
  8124. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8125. $ftime = time() - 15 * 24 * 3600;
  8126. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8127. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8128. $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);
  8129. $rows[$key]['c'] = $c;
  8130. $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);
  8131. $rows[$key]['t'] = $t;
  8132. $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'] . '"');
  8133. $rows[$key]['z'] = $z;
  8134. // $jm = $classid;
  8135. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8136. $features = explode('-', trim($features, '-'));
  8137. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8138. }
  8139. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8140. $final_list =[];
  8141. foreach($tmp_list as $k=>$v){
  8142. $final_list[] = [
  8143. "warehouse"=>$v['warehouse'],
  8144. "purchase"=>$v['purchase'],
  8145. "details"=>$v['details'],
  8146. "cpid"=>$v['cpid'],
  8147. "sku"=>$v['sku'],
  8148. "title"=>$v['title'],
  8149. "features"=>$v['pm'],
  8150. "cpbz"=>$v['cpbz'],
  8151. "sm"=>$v['sm'],
  8152. "type"=>$v['type'],
  8153. "g"=>$v["g"],
  8154. "c"=>$v["c"],
  8155. "x"=>$v["x"],
  8156. "t"=>$v["t"],
  8157. "z"=>$v["z"],
  8158. "jm"=>$v["jm"],
  8159. "weight"=>$v["weight"],
  8160. "asd"=>$v["asd"],
  8161. ];
  8162. }
  8163. if(empty($final_list)){
  8164. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8165. }else{
  8166. $end_list = [];
  8167. foreach($final_list as $v){
  8168. $end_list[] = array_values($v);
  8169. }
  8170. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8171. array_unshift($end_list,[
  8172. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8173. ]);
  8174. array_unshift($end_list,[
  8175. $title,"","","","","","","","","","","","","","","","","",""
  8176. ]);
  8177. $merges = [
  8178. [
  8179. "s"=>["r"=>0,"c"=>0],
  8180. "e"=>["r"=>0,"c"=>6]
  8181. ]
  8182. ];
  8183. $cols = [
  8184. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8185. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8186. ];
  8187. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8188. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8189. ])));
  8190. }
  8191. }
  8192. }
  8193. }
  8194. public function _exceljxcjs(){
  8195. $classid = $this->classid->sku();
  8196. $pm = $classid;
  8197. $typeclass = array();
  8198. $tc = $this->typeclass->find_all();
  8199. foreach ($tc as $v) {
  8200. $typeclass[$v['id']] = $v;
  8201. }
  8202. $prc = array();
  8203. $purchase = $this->purchase->find_all();
  8204. foreach ($purchase as $k => $v) {
  8205. $prc[$v['id']] = $v['title'];
  8206. }
  8207. if(!isset($_GET['excel'])){
  8208. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8209. }
  8210. $where = "sku != 'Preset'";
  8211. //数据排序
  8212. $order_str = "id desc";
  8213. if (empty($page)) {
  8214. $start = 0;
  8215. $perpage = 1;
  8216. } else {
  8217. $start = ($page - 1) * $perpage;
  8218. }
  8219. $category = $this->input->get('category', true);
  8220. $warehouse = $this->input->get('warehouse', true);
  8221. $excelid = $this->input->get('sid', true);
  8222. if ($category) {
  8223. $where .= " and features like '%-$category-%'";
  8224. }
  8225. if ($warehouse) {
  8226. $where .= " and warehouse = '$warehouse'";
  8227. }
  8228. $xzid = '';
  8229. if ($excelid) {
  8230. $excelid = explode(',', trim($excelid, ','));
  8231. foreach ($excelid as $key => $value) {
  8232. $xzid .= " id = " . $value . " or";
  8233. }
  8234. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8235. }
  8236. $wt = array();
  8237. $whlabel_type = $this->whlabel_type->find_all();
  8238. foreach ($whlabel_type as $v) {
  8239. $wt[$v['id']] = $v['title'];
  8240. }
  8241. $wh = array();
  8242. $w = $this->warehouse->find_all('1=1', 'id,title');
  8243. foreach ($w as $v) {
  8244. $wh[$v['id']] = $v['title'];
  8245. }
  8246. $list = array();
  8247. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8248. foreach ($rows as $key => $value) {
  8249. if (isset($wt[$value['type']])) {
  8250. $rows[$key]['type'] = $wt[$value['type']];
  8251. } else {
  8252. $rows[$key]['type'] = '未设置';
  8253. }
  8254. $bm = '03';
  8255. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8256. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8257. $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');
  8258. $details = array();
  8259. $cpid = array();
  8260. $cpbz = array();
  8261. $c = 0;
  8262. $g = 0;
  8263. $x = 0;
  8264. $t = 0;
  8265. $s = 0;
  8266. $q = 0;
  8267. foreach ($sd as $k => $v) {
  8268. if ($v['state'] == 0) {
  8269. $c++;
  8270. if ($v['cpid'] != 0) {
  8271. $cpid[$v['cpid']] = $v['cpid'];
  8272. }
  8273. if ($v['cpbz'] != '') {
  8274. $cpbz[$v['cpbz']] = $v['cpbz'];
  8275. }
  8276. }
  8277. if ($v['state'] != 9) {
  8278. $g++;
  8279. }
  8280. if ($v['state'] == 1) {
  8281. $x++;
  8282. }
  8283. if ($v['state'] == 2) {
  8284. $t++;
  8285. }
  8286. if ($v['state'] == 8) {
  8287. $s++;
  8288. }
  8289. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8290. $q++;
  8291. }
  8292. $details[$v['details']] = $v['details'];
  8293. }
  8294. $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'] . '"');
  8295. $rows[$key]['details'] = implode("、", $details);
  8296. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8297. $number = $value['number'];
  8298. $ftime = time() - 15 * 24 * 3600;
  8299. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8300. $rows[$key]['number'] = $g;
  8301. $rows[$key]['c'] = $c;
  8302. $rows[$key]['x'] = $x;
  8303. $rows[$key]['t'] = $t;
  8304. $rows[$key]['s'] = $s;
  8305. $rows[$key]['q'] = $q;
  8306. $rows[$key]['z'] = $z;
  8307. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8308. $features = explode('-', trim($features, '-'));
  8309. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8310. }
  8311. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8312. $final_list = [];
  8313. foreach ($list as $k => $v) {
  8314. if (empty($v['sku'])) {
  8315. continue;
  8316. }
  8317. $final_list[] = [
  8318. $v["warehouse"],
  8319. $v["purchase"],
  8320. $v["details"],
  8321. $v["cpid"],
  8322. $v["dbcontent"],
  8323. $v["sku"],
  8324. $v["bm"],
  8325. $v["jm"],
  8326. $v["title"],
  8327. $v["pm"],
  8328. $v["cpbz"],
  8329. $v["sm"],
  8330. $v["type"],
  8331. $v["number"],
  8332. $v["c"],
  8333. $v["x"],
  8334. $v["t"],
  8335. $v["s"],
  8336. $v["q"],
  8337. $v["z"],
  8338. $v['weight'],
  8339. ];
  8340. }
  8341. if(empty($final_list)){
  8342. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8343. }
  8344. $title = "总进销存统计表";
  8345. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8346. $merges = [
  8347. [
  8348. "s"=>["r"=>0,"c"=>0],
  8349. "e"=>["r"=>0,"c"=>21]
  8350. ]
  8351. ];
  8352. $cols = [
  8353. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8354. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8355. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8356. ];
  8357. array_unshift($final_list, $first_row);
  8358. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8359. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8360. }
  8361. public function _summaryjs($arg_array)
  8362. {
  8363. $prc = array();
  8364. $purchase = $this->purchase->find_all();
  8365. foreach ($purchase as $k => $v) {
  8366. $prc[$v['id']] = $v['title'];
  8367. }
  8368. if (isset($_GET['excel'])) {
  8369. $ktime = $this->input->get('ktime', true);
  8370. $jtime = $this->input->get('jtime', true);
  8371. $ktime = strtotime($ktime);
  8372. $jtime = strtotime($jtime);
  8373. $where = "1=1";
  8374. if ($ktime && $jtime) {
  8375. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8376. }
  8377. //数据排序
  8378. $order_str = "time desc";
  8379. if (empty($page)) {
  8380. $start = 0;
  8381. $perpage = 1;
  8382. } else {
  8383. $start = ($page - 1) * $perpage;
  8384. }
  8385. //取得信息列表
  8386. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8387. foreach ($info_list as $key => $value) {
  8388. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8389. $warehouse = $this->warehouse->read($value['warehouse']);
  8390. $info_list[$key]['warehouse'] = $warehouse['title'];
  8391. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8392. $details = array();
  8393. $cpid = array();
  8394. foreach ($x as $k => $v) {
  8395. if ($v['details'] != '') {
  8396. $details[$v['details']] = $v['details'];
  8397. }
  8398. if ($v['cpid'] != 0) {
  8399. $cpid[$v['cpid']] = $v['cpid'];
  8400. }
  8401. }
  8402. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8403. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8404. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8405. $info_list[$key]['s'] = $s;
  8406. $info_list[$key]['x'] = count($x);
  8407. }
  8408. if(empty($info_list)){
  8409. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8410. }
  8411. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8412. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8413. $merges = [
  8414. [
  8415. "s"=>["r"=>0,"c"=>0],
  8416. "e"=>["r"=>0,"c"=>7]
  8417. ]
  8418. ];
  8419. $cols = [
  8420. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8421. ];
  8422. $final_list = [];
  8423. foreach($info_list as $k => $v){
  8424. $final_list[] = array_values($v);
  8425. }
  8426. array_unshift($final_list, $first_row);
  8427. array_unshift($final_list,[
  8428. $title,"","","","","","","","",
  8429. ]);
  8430. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8431. $titlename = "<table border=1>
  8432. <tr align='center'>
  8433. <td>仓库</td>
  8434. <td>供应商</td>
  8435. <td>出库位置</td>
  8436. <td>出库编码</td>
  8437. <td>SKU</td>
  8438. <td>产品名</td>
  8439. <td>总剩余库存</td>
  8440. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8441. </tr>
  8442. </table>";
  8443. $filename = $title . ".xls";
  8444. $tail = "";
  8445. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8446. }
  8447. }
  8448. public function _uckjs()
  8449. {
  8450. if (isset($_GET['excel'])) {
  8451. $tc = array();
  8452. $typeclass = $this->typeclass->find_all();
  8453. foreach ($typeclass as $v) {
  8454. $tc[$v['id']] = $v['zh'];
  8455. }
  8456. $first_row = [
  8457. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8458. ];
  8459. $t = array();
  8460. $rq = '';
  8461. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8462. $ts = $ts / (24 * 3600);
  8463. for ($i = 0; $i < $ts; $i++) {
  8464. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8465. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8466. }
  8467. $day_len = count($t);
  8468. $first_row[] = "本月出库";
  8469. $merges = [
  8470. ];
  8471. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8472. $excel_key = 1;
  8473. $final_list = [];
  8474. foreach ($info_list as $k => $v) {
  8475. $features = explode('-', trim($v['features'], '-'));
  8476. if (!isset($features[3]) || !isset($features[4])) {
  8477. continue;
  8478. }
  8479. $tmp = [];
  8480. $tmp[0] = $tc[$features[0]]; //类型
  8481. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8482. $tmp[2] = $tc[$features[4]]; //曲度
  8483. $tmp[3] = '';
  8484. if (isset($data[$k][1])) {
  8485. $tmp[3] .=$tmp[1];
  8486. }
  8487. if (isset($data[$k][2])) {
  8488. $tmp[3] .= $tmp[2];
  8489. }
  8490. if (isset($features[5])) {
  8491. $tmp[3] .= $tc[$features[5]];
  8492. }
  8493. if (isset($features[2])) {
  8494. $tmp[3] .= $tc[$features[2]];
  8495. }
  8496. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8497. $tmp[4] = $v['sku'];
  8498. $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())) . '))'); //月初库存
  8499. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8500. $tmp[7] ="";
  8501. $tmp[8] ="";
  8502. $byck = 0;
  8503. foreach ($t as $vv) {
  8504. $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));
  8505. $tmp[] = ($sl > 0) ? $sl : '';
  8506. $byck += $sl;
  8507. }
  8508. $tmp[] = ($byck > 0) ? $byck : '';
  8509. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8510. // $ztrq = '';
  8511. // $ztsl = '';
  8512. // if (count($zt) > 0) {
  8513. // foreach ($zt as $vv) {
  8514. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8515. // $ztsl .= $vv['num'] . '<br>';
  8516. // }
  8517. // }
  8518. if(empty($zt)){
  8519. $final_list[] = $tmp;
  8520. $excel_key = $excel_key + 1;
  8521. }else{
  8522. $len = count($zt);
  8523. if($len == 1){
  8524. $tmp[7] = $zt[0]['num'] ;
  8525. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8526. $final_list[] = $tmp;
  8527. $excel_key = $excel_key + 1;
  8528. }else{
  8529. foreach($zt as $vv){
  8530. $tmp[7] = "";
  8531. $tmp[8] = "";
  8532. $tmp[7] = $vv['num'];
  8533. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8534. $final_list[] = $tmp;
  8535. }
  8536. $merges[] = [
  8537. "s"=>["r"=>$excel_key,"c"=>0],
  8538. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8539. ];
  8540. $merges[] = [
  8541. "s"=>["r"=>$excel_key,"c"=>1],
  8542. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8543. ];
  8544. $merges[] = [
  8545. "s"=>["r"=>$excel_key,"c"=>2],
  8546. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8547. ];
  8548. $merges[] = [
  8549. "s"=>["r"=>$excel_key,"c"=>3],
  8550. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8551. ];
  8552. $merges[] = [
  8553. "s"=>["r"=>$excel_key,"c"=>4],
  8554. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8555. ];
  8556. $merges[] = [
  8557. "s"=>["r"=>$excel_key,"c"=>5],
  8558. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8559. ];
  8560. $merges[] = [
  8561. "s"=>["r"=>$excel_key,"c"=>6],
  8562. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8563. ];
  8564. for($i=1;$i<=$day_len;$i++){
  8565. $merges[] = [
  8566. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8567. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8568. ];
  8569. }
  8570. $merges[] = [
  8571. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8572. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8573. ];
  8574. $excel_key = $excel_key + $len;
  8575. }
  8576. }
  8577. }
  8578. $title = "详情 " . date("Y-m-d", time());
  8579. if(empty($final_list)){
  8580. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8581. }
  8582. $cols = [
  8583. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8584. ];
  8585. array_unshift($final_list, $first_row);
  8586. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8587. }
  8588. }
  8589. public function _whlabelexcelzhjs(){
  8590. if(empty($_GET['excel'])){
  8591. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8592. }
  8593. $where = "sku != 'Preset' and sku != '' ";
  8594. //数据排序
  8595. $order_str = "id desc";
  8596. if (empty($page)) {
  8597. $start = 0;
  8598. $perpage = 1;
  8599. } else {
  8600. $start = ($page - 1) * $perpage;
  8601. }
  8602. $category = $this->input->get('category', true);
  8603. $warehouse = $this->input->get('warehouse', true);
  8604. $excelid = $this->input->get('sid', true);
  8605. if ($category) {
  8606. $where .= " and features like '%-$category-%'";
  8607. }
  8608. if ($warehouse) {
  8609. $where .= " and warehouse = '$warehouse'";
  8610. }
  8611. $xzid = '';
  8612. if ($excelid) {
  8613. $excelid = explode(',', trim($excelid, ','));
  8614. foreach ($excelid as $key => $value) {
  8615. $xzid .= " id = " . $value . " or";
  8616. }
  8617. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8618. }
  8619. $merges = [
  8620. [
  8621. "s"=>["r"=>0,"c"=>0],
  8622. "e"=>["r"=>0,"c"=>6]
  8623. ]
  8624. ];
  8625. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8626. $excel_index = 2;
  8627. $final_list = [];
  8628. foreach ($rows as $key => $value) {
  8629. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8630. $zh = '';
  8631. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8632. // foreach ($zt_list as $v) {
  8633. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8634. // }
  8635. $zt = array_sum(array_column($zt_list, 'num'));
  8636. $number = $value['number'];
  8637. $ftime = time() - 15 * 24 * 3600;
  8638. $warehouse = $this->warehouse->read($value['warehouse']);
  8639. // $rows[$key]['warehouse'] = $warehouse['title'];
  8640. // $rows[$key]['number'] = $c;
  8641. // $rows[$key]['features'] = $zh;
  8642. //$rows[$key]['hb'] = $c + $zt;
  8643. $tmp = [];
  8644. $tmp[0] = $warehouse['title'];
  8645. $tmp[1] = $value['sku'];
  8646. $tmp[2] = $value['title'];
  8647. $tmp[3] = $c;
  8648. $tmp[4] = "";
  8649. $tmp[5] = $c + $zt;
  8650. if(empty($zt_list)){
  8651. $tmp[4] = "";
  8652. $final_list[] = $tmp;
  8653. $excel_index = $excel_index + 1;
  8654. }else{
  8655. if(count($zt_list) == 1){
  8656. $tmp[4] = "";
  8657. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8658. $final_list[] = $tmp;
  8659. $excel_index = $excel_index + 1;
  8660. }else{
  8661. $len = count($zt_list);
  8662. foreach ($zt_list as $v){
  8663. $tmp[4] = "";
  8664. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8665. $final_list[] = $tmp;
  8666. }
  8667. $merges[] = [
  8668. "s"=>["r"=>$excel_index,"c"=>0],
  8669. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8670. ];
  8671. $merges[] = [
  8672. "s"=>["r"=>$excel_index,"c"=>1],
  8673. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8674. ];
  8675. $merges[] = [
  8676. "s"=>["r"=>$excel_index,"c"=>2],
  8677. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8678. ];
  8679. $merges[] = [
  8680. "s"=>["r"=>$excel_index,"c"=>3],
  8681. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8682. ];
  8683. $merges[] = [
  8684. "s"=>["r"=>$excel_index,"c"=>5],
  8685. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8686. ];
  8687. $excel_index = $excel_index + $len;
  8688. }
  8689. }
  8690. }
  8691. $first_row = [
  8692. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8693. ];
  8694. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8695. if(empty($final_list)){
  8696. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8697. }
  8698. $cols = [
  8699. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8700. ];
  8701. array_unshift($final_list, $first_row);
  8702. array_unshift($final_list, [
  8703. $title,"","","","",""
  8704. ]);
  8705. $end_list = [];
  8706. foreach ($final_list as $key => $value) {
  8707. $end_list[] = array_values($value);
  8708. }
  8709. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8710. }
  8711. //出库、退库导出
  8712. public function _dccrtypejs()
  8713. {
  8714. $classid = $this->classid->sku();
  8715. $pm = $classid;
  8716. $typeclass = array();
  8717. $tc = $this->typeclass->find_all();
  8718. foreach ($tc as $v) {
  8719. $typeclass[$v['id']] = $v;
  8720. }
  8721. $prc = array();
  8722. $purchase = $this->purchase->find_all();
  8723. foreach ($purchase as $k => $v) {
  8724. $prc[$v['id']] = $v['title'];
  8725. }
  8726. if (isset($_GET['sid'])) {
  8727. $wh = array();
  8728. $w = $this->warehouse->find_all('1=1', 'id,title');
  8729. foreach ($w as $v) {
  8730. $wh[$v['id']] = $v['title'];
  8731. }
  8732. $type = $this->input->get('excel', true);
  8733. $category = $this->input->get('category', true);
  8734. $size = $this->input->get('size', true);
  8735. $grade = $this->input->get('grade', true);
  8736. $color = $this->input->get('color', true);
  8737. $lowe = $this->input->get('lowe', true);
  8738. $sku = $this->input->get('sku', true);
  8739. $warehouse = $this->input->get('warehouse', true);
  8740. $lacetype = $this->input->get('lacetype', true);
  8741. $lacecolor = $this->input->get('lacecolor', true);
  8742. $density = $this->input->get('density', true);
  8743. $haircap = $this->input->get('haircap', true);
  8744. $purchase = $this->input->get('purchase', true);
  8745. $title = $this->input->get('title', true);
  8746. $state = $this->input->get('state', true);
  8747. $sid = $this->input->get('sid', true);
  8748. $ktime = $this->input->get('ktime', true);
  8749. $jtime = $this->input->get('jtime', true);
  8750. $ktime = strtotime($ktime);
  8751. $jtime = strtotime($jtime);
  8752. $where = "1=1";
  8753. $gj = "";
  8754. $ck = "";
  8755. if ($category) {
  8756. $where .= " and features like '%-$category-%'";
  8757. }
  8758. if ($size) {
  8759. $where .= " and features like '%-$size-%'";
  8760. }
  8761. if ($grade) {
  8762. $where .= " and features like '%-$grade-%'";
  8763. }
  8764. if ($color) {
  8765. $where .= " and features like '%-$color-%'";
  8766. }
  8767. if ($lowe) {
  8768. $where .= " and features like '%-$lowe-%'";
  8769. }
  8770. if ($warehouse) {
  8771. $where .= " and warehouse = '$warehouse'";
  8772. }
  8773. if ($purchase) {
  8774. $where .= " and purchase = '$purchase'";
  8775. }
  8776. if ($state) {
  8777. $where .= " and state = '$state'";
  8778. }
  8779. if ($lacetype) {
  8780. $where .= " and features like '%-$lacetype-%'";
  8781. }
  8782. if ($lacecolor) {
  8783. $where .= " and features like '%-$lacecolor-%'";
  8784. }
  8785. if ($density) {
  8786. $where .= " and features like '%-$density-%'";
  8787. }
  8788. if ($haircap) {
  8789. $where .= " and features like '%-$haircap-%'";
  8790. }
  8791. if ($title) {
  8792. $title = trim($title, ' ');
  8793. $title = trim($title, ' ');
  8794. $where .= " and title like '%$title%'";
  8795. }
  8796. if ($sku) {
  8797. $sku = trim($sku, ' ');
  8798. $sku = trim($sku, ' ');
  8799. $where .= " and sku like '%$sku%'";
  8800. }
  8801. if ($ktime && $jtime) {
  8802. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8803. }
  8804. $sidwhere = '';
  8805. if ($sid) {
  8806. $sd = "";
  8807. $s = explode(',', trim($sid, ','));
  8808. foreach ($s as $value) {
  8809. $sd .= " id = " . $value . " or";
  8810. }
  8811. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8812. }
  8813. //数据排序
  8814. $order_str = "time desc";
  8815. if (empty($page)) {
  8816. $start = 0;
  8817. $perpage = 1;
  8818. } else {
  8819. $start = ($page - 1) * $perpage;
  8820. }
  8821. $wh = array();
  8822. $w = $this->warehouse->find_all('1=1', 'id,title');
  8823. foreach ($w as $v) {
  8824. $wh[$v['id']] = $v['title'];
  8825. }
  8826. $wt = array();
  8827. $whlabel_type = $this->whlabel_type->find_all();
  8828. foreach ($whlabel_type as $v) {
  8829. $wt[$v['id']] = $v['title'];
  8830. }
  8831. $classid = $this->classid->sku();
  8832. $list = array();
  8833. $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');
  8834. foreach ($rows_r as $key => $value) {
  8835. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8836. $pm = $classid;
  8837. $jm = $classid;
  8838. $rows_r[$key]['enter'] = '入库';
  8839. $rows_r[$key]['time'] = $value['enter'];
  8840. if ($value['rktype'] == 1) {
  8841. $rows_r[$key]['rktype'] = '采购入库';
  8842. } else if ($value['rktype'] == 2) {
  8843. $rows_r[$key]['rktype'] = '盘盈调整';
  8844. } else if ($value['rktype'] == 3) {
  8845. $rows_r[$key]['rktype'] = '其他调整入库';
  8846. } else if ($value['rktype'] == 4) {
  8847. $rows_r[$key]['rktype'] = '其他调整入库';
  8848. } else if ($value['rktype'] == 5) {
  8849. $rows_r[$key]['rktype'] = '退库入库';
  8850. } else if ($value['rktype'] == 6) {
  8851. $rows_r[$key]['rktype'] = '退货可用入库';
  8852. } else if ($value['rktype'] == 7) {
  8853. $rows_r[$key]['rktype'] = '形态转换入库';
  8854. } else {
  8855. $rows_r[$key]['rktype'] = '';
  8856. }
  8857. $features = explode('-', trim($value['features'], '-'));
  8858. foreach ($features as $v) {
  8859. if (isset($typeclass[$v])) {
  8860. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8861. $pm[$typeclass[$v]['classid']] = $zh[0];
  8862. }
  8863. if (isset($typeclass[$v])) {
  8864. if (isset($jm[$typeclass[$v]['classid']])) {
  8865. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8866. }
  8867. }
  8868. }
  8869. $zh = implode(" ", $pm);
  8870. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8871. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8872. $rows_r[$key]['zh'] = $zh;
  8873. $jm = array_filter($jm);
  8874. $rows_r[$key]['features'] = implode("-", $jm);
  8875. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8876. }
  8877. $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');
  8878. foreach ($rows_c as $key => $value) {
  8879. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8880. $pm = $classid;
  8881. $jm = $classid;
  8882. $rows_c[$key]['time'] = $value['outk'];
  8883. $rows_c[$key]['outk'] = '出库';
  8884. if ($value['cktype'] == 1) {
  8885. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8886. } else if ($value['cktype'] == 2) {
  8887. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8888. } else if ($value['cktype'] == 3) {
  8889. $rows_c[$key]['cktype'] = '盘亏调整';
  8890. } else if ($value['cktype'] == 4) {
  8891. $rows_c[$key]['cktype'] = '其他调整出库';
  8892. } else if ($value['cktype'] == 5) {
  8893. $rows_c[$key]['cktype'] = '形态转换出库';
  8894. } else {
  8895. $rows_c[$key]['cktype'] = '';
  8896. }
  8897. unset($rows_c[$key]['state']);
  8898. $features = explode('-', trim($value['features'], '-'));
  8899. foreach ($features as $v) {
  8900. if (isset($typeclass[$v])) {
  8901. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8902. $pm[$typeclass[$v]['classid']] = $zh[0];
  8903. }
  8904. if (isset($typeclass[$v])) {
  8905. if (isset($jm[$typeclass[$v]['classid']])) {
  8906. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8907. }
  8908. }
  8909. }
  8910. $zh = implode(" ", $pm);
  8911. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8912. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8913. $rows_c[$key]['zh'] = $zh;
  8914. $jm = array_filter($jm);
  8915. $rows_c[$key]['features'] = implode("-", $jm);
  8916. $rows_c[$key]['number'] = 1;
  8917. }
  8918. $merged = $rows_r;
  8919. foreach ($rows_c as $key => $value) {
  8920. if (isset($merged[$key])) {
  8921. $merged[] = $value;
  8922. } else {
  8923. $merged[$key] = $value;
  8924. }
  8925. }
  8926. usort($merged, function ($a, $b) {
  8927. return $a['time'] - $b['time'];
  8928. });
  8929. foreach ($merged as $key => $value) {
  8930. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8931. }
  8932. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8933. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  8934. $cols = [
  8935. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8936. ];
  8937. $final_list= [];
  8938. foreach($merged as $key => $value){
  8939. $final_list[] = array_values($value) ;
  8940. }
  8941. if(empty($merged)){
  8942. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8943. }
  8944. array_unshift($final_list, $first_row);
  8945. $end_list = [];
  8946. foreach ($final_list as $key => $value) {
  8947. $end_list[] = array_values($value);
  8948. }
  8949. $merges = [];
  8950. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8951. }
  8952. }
  8953. public function _errorexceljs()
  8954. {
  8955. $post = $this->input->post(NULL, TRUE);
  8956. if (isset($_GET['page'])) {
  8957. $page = $this->input->get('page', true);
  8958. $perpage = $this->input->get('perpage', true);
  8959. $sku = $this->input->get('sku', true);
  8960. $warehouse = $this->input->get('warehouse', true);
  8961. $ktime = $this->input->get('ktime', true);
  8962. $jtime = $this->input->get('jtime', true);
  8963. $ktime = strtotime($ktime);
  8964. $jtime = strtotime($jtime);
  8965. $where = "sku != 'Preset'";
  8966. $gj = '';
  8967. if ($sku) {
  8968. $where .= " and sku like '%$sku%'";
  8969. } else {
  8970. if ($ktime && $jtime) {
  8971. $gj = " and time > '$ktime' and time < '$jtime'";
  8972. }
  8973. }
  8974. if ($warehouse) {
  8975. $where .= " and warehouse = '$warehouse'";
  8976. }
  8977. //数据排序
  8978. $order_str = "id desc";
  8979. if (empty($page)) {
  8980. $start = 0;
  8981. $perpage = 1;
  8982. } else {
  8983. $start = ($page - 1) * $perpage;
  8984. }
  8985. //取得信息列表
  8986. $rows = array();
  8987. $list = array();
  8988. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  8989. foreach ($info_list as $value) {
  8990. $warehouse = $this->warehouse->read($value['warehouse']);
  8991. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  8992. $number = $value['number'];
  8993. $ftime = time() - 15 * 24 * 3600;
  8994. if ($c < 1) {
  8995. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  8996. }
  8997. }
  8998. $title = "0库存汇总";
  8999. $first_row = ["仓库","SKU","产品","当前库存"];
  9000. $cols = [
  9001. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9002. ];
  9003. $final_list= [];
  9004. foreach($list as $key => $value){
  9005. $final_list[] = array_values($value) ;
  9006. }
  9007. if(empty($final_list)){
  9008. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9009. }
  9010. array_unshift($final_list, $first_row);
  9011. $merges = [];
  9012. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9013. }
  9014. }
  9015. }