Whlabel.php 265 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_whlabel','whlabel');
  7. $this->load->_model('Model_warehouse','warehouse');
  8. $this->load->_model('Model_purchase','purchase');
  9. $this->load->_model('Model_excel','excel');
  10. $this->load->_model('Model_fullorder','fullorder');
  11. $this->load->_model('Model_fullordertt','fullordertt');
  12. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_shop','shop');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. $this->load->_model('Model_country','country');
  18. $this->load->_model('Model_warehouse','warehouse');
  19. $this->load->_model('Model_kdniao','kdniao');
  20. $this->load->_model('Model_notice','notice');
  21. $this->load->_model('Model_dhl','dhl');
  22. $this->load->_model('Model_shop','shop');
  23. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  24. $this->load->_model('Model_ljg','ljg');
  25. $this->load->_model('Model_usps','usps');
  26. $this->load->_model('Model_specialstock','specialstock');
  27. $this->load->_model('Model_whlabellabel','whlabellabel');
  28. $this->load->_model('Model_whlabelwz','whlabelwz');
  29. $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
  30. $this->load->_model('Model_whlabeltransport','whlabeltransport');
  31. $this->load->_model('Model_orderurl','orderurl');
  32. $this->load->_model('Model_brand','brand');
  33. $this->load->_model('Model_classid','classid');
  34. $this->load->_model('Model_apiyy','apiyy');
  35. $this->load->_model('Model_power','power');
  36. $this->load->_model('Model_whlabel_type','whlabel_type');
  37. $this->load->_model('Model_company','company');
  38. $this->load->_model('Model_whlabel_list','whlabel_list');
  39. }
  40. //定义方法的调用规则 获取URI第二段值
  41. public function _remap($arg,$arg_array)
  42. {
  43. if($arg == 'existence')//在库标签
  44. {
  45. $this->_existence();
  46. }
  47. else if($arg == 'cpbqdc')//在库标签
  48. {
  49. $this->_cpbqdc();
  50. }
  51. else if($arg == 'type')//进销存浏览
  52. {
  53. $this->_type();
  54. }
  55. else if($arg == 'typedy')//进销存浏览店员页面
  56. {
  57. $this->_typedy($arg_array);
  58. }
  59. else if($arg == 'typedy_ck')//进销存浏览店员页面
  60. {
  61. $this->_typedy_ck($arg_array);
  62. }
  63. else if($arg == 'typeck')
  64. {
  65. $this->_typeck($arg_array);
  66. }
  67. else if($arg == 'whlabeckdc')
  68. {
  69. $this->_whlabeckdc($arg_array);
  70. }
  71. else if($arg == 'usatype')//美仓进销存浏览
  72. {
  73. $this->_usatype();
  74. }
  75. else if($arg == 'usatypeapp')//美仓APP进销存浏览
  76. {
  77. $this->_usatypeapp();
  78. }
  79. else if($arg == 'enteradd')//入库操作
  80. {
  81. $this->_enteradd();
  82. }
  83. else if($arg == 'enteredit')//修改
  84. {
  85. $this->_enteredit($arg_array);
  86. }
  87. else if($arg == 'enter')//入库浏览
  88. {
  89. $this->_enter();
  90. }
  91. else if($arg == 'out')//出库浏览
  92. {
  93. $this->_out();
  94. }
  95. else if($arg == 'label')//出库标签浏览
  96. {
  97. $this->_label();
  98. }
  99. else if($arg == 'outorder')//独立站出库订单
  100. {
  101. $this->_outorder();
  102. }
  103. else if($arg == 'soutorder')//速卖通出库订单
  104. {
  105. $this->_soutorder();
  106. }
  107. else if($arg == 'toutorder')//TT出库订单
  108. {
  109. $this->_toutorder();
  110. }
  111. else if($arg == 'retreat')//退库订单
  112. {
  113. $this->_retreat();
  114. }
  115. else if($arg == 'retreatlk')//退库订单
  116. {
  117. $this->_retreatlk();
  118. }
  119. else if($arg == 'change')//更换标签
  120. {
  121. $this->_change();
  122. }
  123. else if($arg == 'del')//删除
  124. {
  125. $this->_del();
  126. }
  127. else if($arg == 'exceljxc')//进销存信息导出
  128. {
  129. $this->_exceljxc();
  130. }
  131. else if($arg == 'excelr')//入库信息导出
  132. {
  133. $this->_excelr();
  134. }
  135. else if($arg == 'excelct')//出库、退库信息导出
  136. {
  137. $this->_excelct();
  138. }
  139. else if($arg == 'dccrtype')//根据出入库类型导出
  140. {
  141. $this->_dccrtype();
  142. }
  143. else if($arg == 'excelcr')//出库、退库信息导出
  144. {
  145. $this->_excelcr();
  146. }
  147. else if($arg == 'kcyz')//库存验证
  148. {
  149. $this->_kcyz();
  150. }
  151. else if($arg == 'kj')//库存扣减
  152. {
  153. $this->_kj($arg_array);
  154. }
  155. else if($arg == 'presetout')//预设库存导入
  156. {
  157. $this->_presetout($arg_array);
  158. }
  159. else if($arg == 'presetedit')//预设库存导入
  160. {
  161. $this->_presetedit($arg_array);
  162. }
  163. else if($arg == 'summary')//汇总导出
  164. {
  165. $this->_summary($arg_array);
  166. }
  167. else if($arg == 'manifest')//usps发货清单
  168. {
  169. $this->_manifest();
  170. }
  171. else if($arg == 'abnormal')//占单异常
  172. {
  173. $this->_abnormal();
  174. }
  175. else if($arg == 'error')//0库存SKU
  176. {
  177. $this->_error();
  178. }
  179. else if($arg == 'errorexcel')//0库存SKU导出
  180. {
  181. $this->_errorexcel();
  182. }
  183. else if($arg == 'db')
  184. {
  185. $this->_db();
  186. }
  187. else if($arg == 'dbrk')
  188. {
  189. $this->_dbrk();
  190. }
  191. else if($arg == 'whlabelczdc')
  192. {
  193. $this->_whlabelczdc();
  194. }
  195. else if($arg == 'print')
  196. {
  197. $this->_print($arg_array);
  198. }
  199. else if($arg == 'usaprint')
  200. {
  201. $this->_usaprint($arg_array);
  202. }
  203. else if($arg == 'printck')
  204. {
  205. $this->_printck($arg_array);
  206. }
  207. else if($arg == 'printrk')
  208. {
  209. $this->_printrk($arg_array);
  210. }
  211. else if($arg == 'printxzrk')
  212. {
  213. $this->_printxzrk($arg_array);
  214. }
  215. else if($arg == 'printexcel')
  216. {
  217. $this->_printexcel($arg_array);
  218. }
  219. else if($arg == 'uck')
  220. {
  221. $this->_uck();
  222. }
  223. else if($arg == 'whlabelexcelzh')
  224. {
  225. $this->_whlabelexcelzh();
  226. }
  227. else if($arg == 'fc')
  228. {
  229. $this->_fc();
  230. }
  231. else if($arg == 'fcmb')
  232. {
  233. $this->_fcmb();
  234. }
  235. else if($arg == 'fcexcel')
  236. {
  237. $this->_fcexcel();
  238. }
  239. else if($arg == 'fcjxc')
  240. {
  241. $this->_fcjxc($arg_array);
  242. }
  243. else if($arg == '0kcdel')
  244. {
  245. $this->_0kcdel();//导表删除0库存
  246. }
  247. else if($arg == 'gbhtype')
  248. {
  249. $this->_gbhtype();//更改备货状态
  250. }
  251. else
  252. {
  253. $this->_index();
  254. }
  255. }
  256. //管理
  257. public function _index()
  258. {
  259. $post = $this->input->post(NULL, TRUE);
  260. if(isset($post['page']))
  261. {
  262. $page = $this->input->post('page',true);
  263. $perpage = $this->input->post('perpage',true);
  264. $sku = $this->input->post('sku',true);
  265. $number = $this->input->post('number',true);
  266. $warehouse = $this->input->post('warehouse',true);
  267. $purchase = $this->input->post('purchase',true);
  268. $orderinfo = $this->input->post('orderinfo',true);
  269. $waybill = $this->input->post('waybill',true);
  270. $category = $this->input->post('category',true);
  271. $size = $this->input->post('size',true);
  272. $grade = $this->input->post('grade',true);
  273. $color = $this->input->post('color',true);
  274. $lowe = $this->input->post('lowe',true);
  275. $state = $this->input->post('state',true);
  276. $label = $this->input->post('label',true);
  277. $timetk = $this->input->post('timetkk',true);
  278. $timetj = $this->input->post('timetjj',true);
  279. $timetk = strtotime($timetk);
  280. $timetj = strtotime($timetj);
  281. $where = "1=1 ";
  282. if($timetk && $timetj)
  283. {
  284. $where .= " and time > '$timetk' and time < '$timetj'";
  285. }
  286. if($sku)
  287. {
  288. $where .= " and sku = '$sku'";
  289. }
  290. if($number)
  291. {
  292. $where .= " and number = '$number'";
  293. }
  294. if($warehouse)
  295. {
  296. $where .= " and warehouse = '$warehouse'";
  297. }
  298. if($purchase)
  299. {
  300. $where .= " and purchase = '$purchase'";
  301. }
  302. if($orderinfo)
  303. {
  304. $where .= " and orderinfo = '$orderinfo'";
  305. }
  306. if($waybill)
  307. {
  308. $where .= " and waybill = '$waybill'";
  309. }
  310. if($category)
  311. {
  312. $where .= " and features like '%-$category-%'";
  313. }
  314. if($size)
  315. {
  316. $where .= " and features like '%-$size-%'";
  317. }
  318. if($grade)
  319. {
  320. $where .= " and features like '%-$grade-%'";
  321. }
  322. if($color)
  323. {
  324. $where .= " and features like '%-$color-%'";
  325. }
  326. if($lowe)
  327. {
  328. $where .= " and features like '%-$lowe-%'";
  329. }
  330. if($label)
  331. {
  332. $where .= " and label = '$label'";
  333. }
  334. if($state != '')
  335. {
  336. $where .= " and state = '$state'";
  337. }
  338. //数据排序
  339. $order_str = "time desc";
  340. if(empty($page))
  341. {
  342. $start = 0;
  343. $perpage = 1;
  344. }
  345. else
  346. {
  347. $start = ($page - 1)*$perpage;
  348. }
  349. //取得信息列表
  350. $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);
  351. foreach ($info_list as $key=>$value)
  352. {
  353. $warehouse = $this->warehouse->read($value['warehouse']);
  354. $info_list[$key]['warehouse'] = $warehouse['title'];
  355. $purchase = $this->purchase->read($value['purchase']);
  356. $info_list[$key]['purchase'] = $purchase['title'];
  357. if($value['enter'] != 0)
  358. {
  359. $info_list[$key]['enter'] = '<p>'.date('Y-m-d',$value['enter']).'</p><p>'.date('H:i:s',$value['enter']).'</p>';
  360. }
  361. else
  362. {
  363. $info_list[$key]['enter'] = "";
  364. }
  365. if($value['outk'] != 0)
  366. {
  367. $info_list[$key]['outk'] = '<p>'.date('Y-m-d',$value['outk']).'</p><p>'.date('H:i:s',$value['outk']).'</p>';
  368. }
  369. else
  370. {
  371. $info_list[$key]['outk'] = "";
  372. }
  373. if($value['printing'] != 0)
  374. {
  375. $info_list[$key]['printing'] = '<p>'.date('Y-m-d',$value['printing']).'</p><p>'.date('H:i:s',$value['printing']).'</p>';
  376. }
  377. else
  378. {
  379. $info_list[$key]['printing'] = "";
  380. }
  381. if($value['orderinfo'] == 0)
  382. {
  383. $info_list[$key]['orderinfo'] = "";
  384. }
  385. if($value['waybill'] == 0)
  386. {
  387. $info_list[$key]['waybill'] = "";
  388. }
  389. if($value['state'] == 0)
  390. {
  391. $info_list[$key]['state'] = "在库";
  392. }
  393. else if($value['state'] == 1)
  394. {
  395. $info_list[$key]['state'] = "出库";
  396. }
  397. else if($value['state'] == 2)
  398. {
  399. $info_list[$key]['state'] = "退库";
  400. }
  401. else if($value['state'] == 3)
  402. {
  403. $info_list[$key]['state'] = "调拨中";
  404. }
  405. else if($value['state'] == 4)
  406. {
  407. $info_list[$key]['state'] = "再加工";
  408. }
  409. else if($value['state'] == 5)
  410. {
  411. $info_list[$key]['state'] = "维修中";
  412. }
  413. else if($value['state'] == 6)
  414. {
  415. $info_list[$key]['state'] = "盘亏";
  416. }
  417. else if($value['state'] == 7)
  418. {
  419. $info_list[$key]['state'] = "更换标签";
  420. }
  421. else if($value['state'] == 8)
  422. {
  423. $info_list[$key]['state'] = "其它";
  424. }
  425. else if($value['state'] == 9)
  426. {
  427. $info_list[$key]['state'] = "预设";
  428. }
  429. else if($value['state'] == 10)
  430. {
  431. $info_list[$key]['state'] = "美店零售";
  432. }
  433. if($value['text'] == "")
  434. {
  435. $info_list[$key]['text'] = "";
  436. }
  437. $info_list[$key]['time'] = '<p>'.date('Y-m-d',$value['time']).'</p><p>'.date('H:i:s',$value['time']).'</p>';
  438. }
  439. $total = $this->whlabel->find_count($where);
  440. $pagenum = ceil($total/$perpage);
  441. $over = $total-($start+$perpage);
  442. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  443. echo json_encode($rows);exit;
  444. }
  445. if(isset($post['outsku']))
  446. {
  447. $cz = $this->input->post('cz',true);
  448. if($cz == '1')
  449. {
  450. $sku = $this->input->post('outsku',true);
  451. if($sku)
  452. {
  453. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  454. if(count($data) < 1)
  455. {
  456. echo json_encode(array('msg'=>'库存不足!','success'=>false));exit;
  457. }
  458. $this->whlabel->save(array('state'=>10,'outk'=>time(),'time'=>time(),'cktype'=>1),$data[0]['id']);
  459. echo json_encode(array('success'=>true));exit;
  460. }
  461. }
  462. else
  463. {
  464. $sku = $this->input->post('outsku',true);
  465. if($sku)
  466. {
  467. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  468. if(count($data) < 1)
  469. {
  470. echo json_encode(array('msg'=>'没有此SKU出库数据!','success'=>false));exit;
  471. }
  472. $this->whlabel->save(array('state'=>0,'outk'=>0,'time'=>time()),$data[0]['id']);
  473. echo json_encode(array('success'=>true));exit;
  474. }
  475. }
  476. }
  477. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  478. $this->_Template('whlabel',$this->data);
  479. }
  480. //在库标签
  481. public function _existence()
  482. {
  483. $post = $this->input->post(NULL, TRUE);
  484. if(isset($post['s']))
  485. {
  486. $id_arr = $this->input->post('s');
  487. $id_arr = explode(',',$id_arr);
  488. if(!$id_arr)
  489. {
  490. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  491. }
  492. //循环删除记录
  493. foreach ($id_arr as $v)
  494. {
  495. $sid = $this->whlabel->read($v);
  496. $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
  497. if($count > 0)
  498. {
  499. echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
  500. }
  501. $zt = $this->whlabeltransport->find_all('sku = "'.$sid['sku'].'" and warehouse = "'.$sid['warehouse'].'" and features = "'.$sid['features'].'" and cz = "0"');
  502. if(count($zt) > 0)
  503. {
  504. echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
  505. }
  506. $this->whlabel->remove($v);
  507. }
  508. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  509. }
  510. if(isset($post['page']))
  511. {
  512. $page = $this->input->post('page',true);
  513. $perpage = $this->input->post('perpage',true);
  514. $warehouse = $this->input->post('warehouse',true);
  515. $label = $this->input->post('label',true);
  516. $where = "1=1 and state = 0";
  517. if($warehouse)
  518. {
  519. $where .= " and warehouse = '$warehouse'";
  520. }
  521. if($label)
  522. {
  523. $where .= " and label = '$label'";
  524. }
  525. //数据排序
  526. $order_str = "time asc";
  527. if(empty($page))
  528. {
  529. $start = 0;
  530. $perpage = 1;
  531. }
  532. else
  533. {
  534. $start = ($page - 1)*$perpage;
  535. }
  536. //取得信息列表
  537. $info_list = $this->whlabel->find_all($where,'id,sku,title,label,printing,enter',$order_str,$start,$perpage);
  538. foreach ($info_list as $key=>$value)
  539. {
  540. if($value['enter'] != 0)
  541. {
  542. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  543. }
  544. else
  545. {
  546. $info_list[$key]['enter'] = "";
  547. }
  548. if($value['printing'] != 0)
  549. {
  550. $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']);
  551. }
  552. else
  553. {
  554. $info_list[$key]['printing'] = "";
  555. }
  556. }
  557. $total = $this->whlabel->find_count($where);
  558. $pagenum = ceil($total/$perpage);
  559. $over = $total-($start+$perpage);
  560. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  561. echo json_encode($rows);exit;
  562. }
  563. $this->_Template('whlabel_existence',$this->data);
  564. }
  565. //进销存浏览
  566. public function _typedy($arg_array)
  567. {
  568. $prc = array();
  569. $purchase = $this->purchase->find_all();
  570. foreach($purchase as $k=>$v)
  571. {
  572. $prc[$v['id']] = $v['title'];
  573. }
  574. $post = $this->input->post(NULL, TRUE);
  575. if(isset($post['page']))
  576. {
  577. $page = $this->input->post('page',true);
  578. $perpage = $this->input->post('perpage',true);
  579. $category = $this->input->post('category',true);
  580. $size = $this->input->post('size',true);
  581. $grade = $this->input->post('grade',true);
  582. $color = $this->input->post('color',true);
  583. $lowe = $this->input->post('lowe',true);
  584. $sku = $this->input->post('sku');
  585. $title = $this->input->post('title');
  586. $warehouse = $this->input->post('warehouse',true);
  587. $usa = $this->input->post('usa',true);
  588. $purchase = $this->input->post('purchase',true);
  589. $lacetype = $this->input->post('lacetype',true);
  590. $haircap = $this->input->post('haircap',true);
  591. $density = $this->input->post('density',true);
  592. $details = $this->input->post('details',true);
  593. $state = $this->input->post('state',true);
  594. $lacecolor = $this->input->post('lacecolor',true);
  595. $cklx = $this->input->post('cklx',true);
  596. $ktime = $this->input->post('ktime',true);
  597. $jtime = $this->input->post('jtime',true);
  598. $ktime = strtotime($ktime);
  599. $jtime = strtotime($jtime);
  600. $where = "1=1";$gj = "";$ck = "";
  601. if($lacetype)
  602. {
  603. $where .= " and features like '%-$lacetype-%'";
  604. }
  605. if($category)
  606. {
  607. $where .= " and features like '%-$category-%'";
  608. }
  609. if($size)
  610. {
  611. $where .= " and features like '%-$size-%'";
  612. }
  613. if($grade)
  614. {
  615. $where .= " and features like '%-$grade-%'";
  616. }
  617. if($color)
  618. {
  619. $where .= " and features like '%-$color-%'";
  620. }
  621. if($lowe)
  622. {
  623. $where .= " and features like '%-$lowe-%'";
  624. }
  625. if($haircap)
  626. {
  627. $where .= " and features like '%-$haircap-%'";
  628. }
  629. if($density)
  630. {
  631. $where .= " and features like '%-$density-%'";
  632. }
  633. if($lacecolor)
  634. {
  635. $where .= " and features like '%-$lacecolor-%'";
  636. }
  637. if($usa)
  638. {
  639. if(!$warehouse)
  640. {
  641. $where .= " and (warehouse = '5' or warehouse = '8')";
  642. }
  643. }
  644. if($warehouse)
  645. {
  646. $where .= " and warehouse = '$warehouse'";
  647. }
  648. if($details)
  649. {
  650. $where .= " and details = '$details'";
  651. }
  652. if($purchase)
  653. {
  654. $where .= " and purchase = '$purchase'";
  655. }
  656. if($state)
  657. {
  658. $where .= " and state = '$state'";
  659. }
  660. $where_add = '';
  661. if($cklx)
  662. {
  663. $shop = $this->shop->read($cklx);
  664. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  665. }
  666. if($ktime && $jtime)
  667. {
  668. $gj = " and enter > '$ktime' and enter < '$jtime'";
  669. $ck = " and outk > '$ktime' and outk < '$jtime'";
  670. }
  671. //数据排序
  672. $order_str = "id desc";
  673. if(empty($page))
  674. {
  675. $start = 0;
  676. $perpage = 1;
  677. }
  678. else
  679. {
  680. $start = ($page - 1)*$perpage;
  681. }
  682. if($sku)
  683. {
  684. $sku = trim($sku,' ');
  685. $sku = trim($sku,' ');
  686. $where .= " and sku like '%$sku%'";
  687. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
  688. }
  689. else if($title)
  690. {
  691. $title = trim($title,' ');
  692. $title = trim($title,' ');
  693. $where .= " and title like '%$title%'";
  694. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
  695. }
  696. else
  697. {
  698. //$where .= " and time > '$ktime' and time < '$jtime'";
  699. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
  700. }
  701. //取得信息列表
  702. $rows = array();$list = array();
  703. foreach ($info_list as $key=>$value)
  704. {
  705. $warehouse = $this->warehouse->read($value['warehouse']);
  706. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  707. $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  708. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  709. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  710. $number = $value['number'];$ftime = time()-15*24*3600;
  711. $info_list[$key]['warehouse'] = $warehouse['title'];
  712. $info_list[$key]['features'] = count($c);
  713. $z = count($z);//查看订单号
  714. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  715. $ztdata = '';
  716. if(count($zt) > 0)
  717. {
  718. foreach ($zt as $vv)
  719. {
  720. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  721. }
  722. }
  723. $info_list[$key]['number'] = $ztdata;
  724. $info_list[$key]['sm'] = $z;
  725. $details = array();
  726. $cpid = array();
  727. foreach ($c as $k=>$v)
  728. {
  729. $details[$v['details']] = $v['details'];
  730. if($v['cpid'] != 0)
  731. {
  732. $cpid[$v['cpid']] = $v['cpid'];
  733. }
  734. }
  735. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  736. if($value['shop'] != '')
  737. {
  738. $shop = explode(',',trim($value['shop'],','));
  739. $shop = $this->shop->read($shop[0]);
  740. $info_list[$key]['shop'] = $shop['shopname'];
  741. }
  742. }
  743. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  744. $pagenum = ceil($total/$perpage);
  745. $over = $total-($start+$perpage);
  746. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  747. echo json_encode($rows);exit;
  748. }
  749. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  750. $this->_Template('whlabel_typedy',$this->data);
  751. }
  752. //进销存浏览
  753. public function _typedy_ck($arg_array)
  754. {
  755. $prc = array();
  756. $purchase = $this->purchase->find_all();
  757. foreach($purchase as $k=>$v)
  758. {
  759. $prc[$v['id']] = $v['title'];
  760. }
  761. $post = $this->input->post(NULL, TRUE);
  762. if(isset($post['page']))
  763. {
  764. $page = $this->input->post('page',true);
  765. $perpage = $this->input->post('perpage',true);
  766. $category = $this->input->post('category',true);
  767. $size = $this->input->post('size',true);
  768. $grade = $this->input->post('grade',true);
  769. $color = $this->input->post('color',true);
  770. $lowe = $this->input->post('lowe',true);
  771. $sku = $this->input->post('sku');
  772. $title = $this->input->post('title');
  773. $warehouse = $this->input->post('warehouse',true);
  774. $usa = $this->input->post('usa',true);
  775. $purchase = $this->input->post('purchase',true);
  776. $lacetype = $this->input->post('lacetype',true);
  777. $haircap = $this->input->post('haircap',true);
  778. $density = $this->input->post('density',true);
  779. $details = $this->input->post('details',true);
  780. $state = $this->input->post('state',true);
  781. $lacecolor = $this->input->post('lacecolor',true);
  782. $cklx = $this->input->post('cklx',true);
  783. $ktime = $this->input->post('ktime',true);
  784. $jtime = $this->input->post('jtime',true);
  785. $ktime = strtotime($ktime);
  786. $jtime = strtotime($jtime);
  787. $where = "1=1";$gj = "";$ck = "";
  788. if($lacetype)
  789. {
  790. $where .= " and features like '%-$lacetype-%'";
  791. }
  792. if($category)
  793. {
  794. $where .= " and features like '%-$category-%'";
  795. }
  796. if($size)
  797. {
  798. $where .= " and features like '%-$size-%'";
  799. }
  800. if($grade)
  801. {
  802. $where .= " and features like '%-$grade-%'";
  803. }
  804. if($color)
  805. {
  806. $where .= " and features like '%-$color-%'";
  807. }
  808. if($lowe)
  809. {
  810. $where .= " and features like '%-$lowe-%'";
  811. }
  812. if($haircap)
  813. {
  814. $where .= " and features like '%-$haircap-%'";
  815. }
  816. if($density)
  817. {
  818. $where .= " and features like '%-$density-%'";
  819. }
  820. if($lacecolor)
  821. {
  822. $where .= " and features like '%-$lacecolor-%'";
  823. }
  824. if($usa)
  825. {
  826. if(!$warehouse)
  827. {
  828. $where .= " and (warehouse = '5' or warehouse = '8')";
  829. }
  830. }
  831. if($warehouse)
  832. {
  833. $where .= " and warehouse = '$warehouse'";
  834. }
  835. if($details)
  836. {
  837. $where .= " and details = '$details'";
  838. }
  839. if($purchase)
  840. {
  841. $where .= " and purchase = '$purchase'";
  842. }
  843. if($state)
  844. {
  845. $where .= " and state = '$state'";
  846. }
  847. $where_add = '';
  848. if($cklx)
  849. {
  850. $shop = $this->shop->read($cklx);
  851. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  852. }
  853. if($ktime && $jtime)
  854. {
  855. $gj = " and enter > '$ktime' and enter < '$jtime'";
  856. $ck = " and outk > '$ktime' and outk < '$jtime'";
  857. }
  858. //数据排序
  859. $order_str = "id desc";
  860. if(empty($page))
  861. {
  862. $start = 0;
  863. $perpage = 1;
  864. }
  865. else
  866. {
  867. $start = ($page - 1)*$perpage;
  868. }
  869. if($sku)
  870. {
  871. $sku = trim($sku,' ');
  872. $sku = trim($sku,' ');
  873. $where .= " and sku like '%$sku%'";
  874. $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);
  875. }
  876. else if($title)
  877. {
  878. $title = trim($title,' ');
  879. $title = trim($title,' ');
  880. $where .= " and title like '%$title%'";
  881. $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);
  882. }
  883. else
  884. {
  885. //$where .= " and time > '$ktime' and time < '$jtime'";
  886. $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);
  887. }
  888. //取得信息列表
  889. $rows = array();$list = array();
  890. foreach ($info_list as $key=>$value)
  891. {
  892. $warehouse = $this->warehouse->read($value['warehouse']);
  893. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  894. $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,text');
  895. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  896. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$c[0]['text'].'</p>';
  897. $ftime = time()-15*24*3600;
  898. $info_list[$key]['warehouse'] = $warehouse['title'];
  899. $info_list[$key]['features'] = count($c)<10?"<em style='color:#F00'>".count($c)."</em>":count($c);
  900. //$z = count($z);//查看订单号
  901. //$info_list[$key]['zd'] = $z;
  902. $details = array();
  903. $cpid = array();
  904. foreach ($c as $k=>$v)
  905. {
  906. $details[$v['details']] = $v['details'];
  907. if($v['cpid'] != 0)
  908. {
  909. $cpid[$v['cpid']] = $v['cpid'];
  910. }
  911. }
  912. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  913. if($value['shop'] != '')
  914. {
  915. $shop = explode(',',trim($value['shop'],','));
  916. $shop = $this->shop->read($shop[0]);
  917. $info_list[$key]['shop'] = $shop['shopname'];
  918. }
  919. }
  920. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  921. $pagenum = ceil($total/$perpage);
  922. $over = $total-($start+$perpage);
  923. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  924. echo json_encode($rows);exit;
  925. }
  926. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  927. $this->_Template('whlabel_typedy_ck',$this->data);
  928. }
  929. public function _typeck($arg_array)
  930. {
  931. $prc = array();
  932. $purchase = $this->purchase->find_all();
  933. foreach($purchase as $k=>$v)
  934. {
  935. $prc[$v['id']] = $v['title'];
  936. }
  937. $post = $this->input->post(NULL, TRUE);
  938. if(isset($post['page']))
  939. {
  940. $page = $this->input->post('page',true);
  941. $perpage = $this->input->post('perpage',true);
  942. $category = $this->input->post('category',true);
  943. $size = $this->input->post('size',true);
  944. $grade = $this->input->post('grade',true);
  945. $color = $this->input->post('color',true);
  946. $lacecolor = $this->input->post('lacecolor',true);
  947. $lowe = $this->input->post('lowe',true);
  948. $sku = $this->input->post('sku');
  949. $title = $this->input->post('title');
  950. $warehouse = 13;
  951. $usa = $this->input->post('usa',true);
  952. $purchase = $this->input->post('purchase',true);
  953. $lacetype = $this->input->post('lacetype',true);
  954. $haircap = $this->input->post('haircap',true);
  955. $density = $this->input->post('density',true);
  956. $details = $this->input->post('details',true);
  957. $state = $this->input->post('state',true);
  958. $ktime = $this->input->post('ktime',true);
  959. $jtime = $this->input->post('jtime',true);
  960. $ktime = strtotime($ktime);
  961. $jtime = strtotime($jtime);
  962. $where = "1=1";$gj = "";$ck = "";
  963. if($lacetype)
  964. {
  965. $where .= " and features like '%-$lacetype-%'";
  966. }
  967. if($category)
  968. {
  969. $where .= " and features like '%-$category-%'";
  970. }
  971. if($size)
  972. {
  973. $where .= " and features like '%-$size-%'";
  974. }
  975. if($grade)
  976. {
  977. $where .= " and features like '%-$grade-%'";
  978. }
  979. if($color)
  980. {
  981. $where .= " and features like '%-$color-%'";
  982. }
  983. if($lacecolor)
  984. {
  985. $where .= " and features like '%-$lacecolor-%'";
  986. }
  987. if($lowe)
  988. {
  989. $where .= " and features like '%-$lowe-%'";
  990. }
  991. if($haircap)
  992. {
  993. $where .= " and features like '%-$haircap-%'";
  994. }
  995. if($density)
  996. {
  997. $where .= " and features like '%-$density-%'";
  998. }
  999. if($warehouse)
  1000. {
  1001. $where .= " and warehouse = '$warehouse'";
  1002. }
  1003. if($details)
  1004. {
  1005. $where .= " and details = '$details'";
  1006. }
  1007. if($purchase)
  1008. {
  1009. $where .= " and purchase = '$purchase'";
  1010. }
  1011. if($state)
  1012. {
  1013. $where .= " and state = '$state'";
  1014. }
  1015. if($ktime && $jtime)
  1016. {
  1017. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1018. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1019. }
  1020. //数据排序
  1021. $order_str = "id desc";
  1022. if(empty($page))
  1023. {
  1024. $start = 0;
  1025. $perpage = 1;
  1026. }
  1027. else
  1028. {
  1029. $start = ($page - 1)*$perpage;
  1030. }
  1031. if($sku)
  1032. {
  1033. $sku = trim($sku,' ');
  1034. $sku = trim($sku,' ');
  1035. $where .= " and sku like '%$sku%'";
  1036. }
  1037. else if($title)
  1038. {
  1039. $title = trim($title,' ');
  1040. $title = trim($title,' ');
  1041. $where .= " and title like '%$title%'";
  1042. }
  1043. $info_list = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,sm,details,cpbz,features,number,',$order_str,$start,$perpage);
  1044. //取得信息列表
  1045. $t = array();
  1046. $typeclass = $this->typeclass->find_all();
  1047. foreach ($typeclass as $v)
  1048. {
  1049. $t[$v['id']] = $v;
  1050. }
  1051. $rows = array();$list = array();
  1052. foreach ($info_list as $key=>$value)
  1053. {
  1054. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1055. $mc = $this->whlabel->find_all("sku = '".$value['sku']."' and features = '".$value['features']."' and warehouse = '".$value['warehouse']."'",'cpbz','id desc',0,1);
  1056. $warehouse = $this->warehouse->read($value['warehouse']);
  1057. $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');
  1058. $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'].'"');
  1059. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  1060. $number = $value['number'];$ftime = time()-15*24*3600;
  1061. $z = count($z);//查看订单号
  1062. $info_list[$key]['warehouse'] = $warehouse['title'];
  1063. $info_list[$key]['features'] = count($c);
  1064. $info_list[$key]['number'] = $z;
  1065. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  1066. $details = array();
  1067. $cpid = array();
  1068. foreach ($c as $k=>$v)
  1069. {
  1070. $details[$v['details']] = $v['details'];
  1071. if($v['cpid'] != 0)
  1072. {
  1073. $cpid[$v['cpid']] = $v['cpid'];
  1074. }
  1075. }
  1076. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1077. $classid = $this->classid->sku();
  1078. $pm = $classid;
  1079. $features = explode('-',trim($value['features'],'-'));
  1080. foreach($features as $v)
  1081. {
  1082. $zh = explode('|',trim($t[$v]['zh'],'|'));
  1083. $pm[$t[$v]['classid']] = $zh[0];
  1084. }
  1085. $zh = implode(" ",$pm);
  1086. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1087. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1088. $info_list[$key]['sm'] = $zh;
  1089. }
  1090. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  1091. $pagenum = ceil($total/$perpage);
  1092. $over = $total-($start+$perpage);
  1093. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1094. echo json_encode($rows);exit;
  1095. }
  1096. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  1097. $this->_Template('whlabel_typeck',$this->data);
  1098. }
  1099. //进销存导出
  1100. public function _whlabeckdc()
  1101. {
  1102. $prc = array();
  1103. $purchase = $this->purchase->find_all();
  1104. foreach($purchase as $k=>$v)
  1105. {
  1106. $prc[$v['id']] = $v['title'];
  1107. }
  1108. if(isset($_GET['excel']))
  1109. {
  1110. $where = "sku != 'Preset'";
  1111. //数据排序
  1112. $order_str = "id desc";
  1113. if(empty($page))
  1114. {
  1115. $start = 0;
  1116. $perpage = 1;
  1117. }
  1118. else
  1119. {
  1120. $start = ($page - 1)*$perpage;
  1121. }
  1122. $category = $this->input->get('category',true);
  1123. $color = $this->input->get('color',true);
  1124. $lowe = $this->input->get('lowe',true);
  1125. $lacetype = $this->input->get('lacetype',true);
  1126. $size = $this->input->get('size',true);
  1127. $density = $this->input->get('density',true);
  1128. $haircap = $this->input->get('haircap',true);
  1129. $sku = $this->input->get('sku',true);
  1130. $details = $this->input->get('details',true);
  1131. $warehouse = 13;
  1132. $excelid = $this->input->get('sid',true);
  1133. if($category)
  1134. {
  1135. $where .= " and features like '%-$category-%'";
  1136. }
  1137. if($color)
  1138. {
  1139. $where .= " and features like '%-$color-%'";
  1140. }
  1141. if($lowe)
  1142. {
  1143. $where .= " and features like '%-$lowe-%'";
  1144. }
  1145. if($lacetype)
  1146. {
  1147. $where .= " and features like '%-$lacetype-%'";
  1148. }
  1149. if($size)
  1150. {
  1151. $where .= " and features like '%-$size-%'";
  1152. }
  1153. if($density)
  1154. {
  1155. $where .= " and features like '%-$density-%'";
  1156. }
  1157. if($haircap)
  1158. {
  1159. $where .= " and features like '%-$haircap-%'";
  1160. }
  1161. if($warehouse)
  1162. {
  1163. $where .= " and warehouse = '$warehouse'";
  1164. }
  1165. if($sku)
  1166. {
  1167. $where .= " and sku like '%$sku%'";
  1168. }
  1169. if($details)
  1170. {
  1171. $where .= " and details = '$details'";
  1172. }
  1173. $xzid = '';
  1174. if($excelid)
  1175. {
  1176. $excelid = explode(',',trim($excelid,','));
  1177. foreach ($excelid as $key=>$value)
  1178. {
  1179. $xzid .= " id = ".$value." or";
  1180. }
  1181. $xzid = " and (".rtrim($xzid,'or').")";;
  1182. }
  1183. //取得信息列表
  1184. /**
  1185. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1186. $rows = array();$list = array();
  1187. foreach ($info_list as $key=>$value)
  1188. {
  1189. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1190. }
  1191. **/
  1192. $wh = array();
  1193. $w = $this->warehouse->find_all('1=1','id,title');
  1194. foreach ($w as $v)
  1195. {
  1196. $wh[$v['id']] = $v['title'];
  1197. }
  1198. $tc = array();$tcdata = array();
  1199. $typeclass = $this->typeclass->find_all();
  1200. foreach ($typeclass as $v)
  1201. {
  1202. $tc[$v['id']] = $v;
  1203. }
  1204. $list = array();
  1205. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1206. foreach ($rows as $key=>$value)
  1207. {
  1208. $bm = '03';
  1209. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1210. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1211. $classid = $this->classid->sku();
  1212. $pm = $classid;
  1213. $jm = $classid;
  1214. $features = explode('-',trim($value['features'],'-'));
  1215. foreach($features as $v)
  1216. {
  1217. if(isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']]))
  1218. {
  1219. if($tc[$v]['bm'] != '')
  1220. {
  1221. $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
  1222. }
  1223. }
  1224. if(isset($tc[$v]))
  1225. {
  1226. $zh = explode('|',trim($tc[$v]['zh'],'|'));
  1227. $pm[$tc[$v]['classid']] = $zh[0];
  1228. }
  1229. if(isset($tc[$v]))
  1230. {
  1231. if(isset($jm[$tc[$v]['classid']]))
  1232. {
  1233. $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
  1234. }
  1235. }
  1236. }
  1237. $zh = implode(" ",$pm);
  1238. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1239. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1240. $rows[$key]['dbcontent'] = $zh;
  1241. $rows[$key]['cpbz'] = $bm.implode("",$bmpx);
  1242. $jm = array_filter($jm);
  1243. $rows[$key]['cs'] = implode("-",$jm);
  1244. $sd = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,cpbz,state');
  1245. $details = array();
  1246. $cpid = array();
  1247. $cpbz = array();
  1248. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  1249. foreach ($sd as $k=>$v)
  1250. {
  1251. if($v['state'] == 0)
  1252. {
  1253. $c++;
  1254. }
  1255. if($v['state'] != 9)
  1256. {
  1257. $g++;
  1258. }
  1259. if($v['state'] == 1)
  1260. {
  1261. $x++;
  1262. }
  1263. if($v['state'] == 2)
  1264. {
  1265. $t++;
  1266. }
  1267. if($v['state'] == 8)
  1268. {
  1269. $s++;
  1270. }
  1271. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  1272. {
  1273. $q++;
  1274. }
  1275. $details[$v['details']] = $v['details'];
  1276. if($v['cpid'] != 0)
  1277. {
  1278. $cpid[$v['cpid']] = $v['cpid'];
  1279. }
  1280. if($v['cpbz'] != '')
  1281. {
  1282. $cpbz[$v['cpbz']] = $v['cpbz'];
  1283. }
  1284. }
  1285. $rows[$key]['details'] = implode("、",$details);
  1286. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  1287. $number = $value['number'];
  1288. $ftime = time()-15*24*3600;
  1289. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1290. $rows[$key]['number'] = $g;
  1291. $rows[$key]['features'] = $c;
  1292. $rows[$key]['x'] = $x;
  1293. $rows[$key]['t'] = $t;
  1294. $rows[$key]['s'] = $s;
  1295. $rows[$key]['q'] = $q;
  1296. $rows[$key]['wzsl'] = count($details);
  1297. }
  1298. $title = "进销存统计表".date('Y-m-d',time());
  1299. $titlename = "<table border=1>
  1300. <tr><th colspan='12' align='center'><h3>".$title."<h3></th></tr>
  1301. <tr align='center'>
  1302. <td>仓库</td>
  1303. <td>供应商</td>
  1304. <td>位置</td>
  1305. <td>库存编码</td>
  1306. <td>SKU</td>
  1307. <td>用友编码</td>
  1308. <td>用友料号</td>
  1309. <td>产品英文名</td>
  1310. <td>产品中文名</td>
  1311. <td>入库总量</td>
  1312. <td>库存数量</td>
  1313. <td>销售数量</td>
  1314. <td>退货数量</td>
  1315. <td>删除数量</td>
  1316. <td>其它操作</td>
  1317. <td>位置数量</td>
  1318. </tr>
  1319. </table>";
  1320. $filename = $title.".xls";
  1321. $tail = "";
  1322. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1323. }
  1324. }
  1325. public function _type()
  1326. {
  1327. $vip = 0;
  1328. if(isset($_SESSION['api']))
  1329. {
  1330. $user = $this->user->get_api($_SESSION['api']);
  1331. $fgshop = "";$sid = "";
  1332. $usersp = explode('|',trim($user['shop'],'|'));
  1333. foreach ($usersp as $value)
  1334. {
  1335. $fgshop .= " shop = ".$value." or";
  1336. $sid .= " id = ".$value." or";
  1337. }
  1338. if($user['vip'] == 1)
  1339. {
  1340. $vip = 1;
  1341. }
  1342. }
  1343. else
  1344. {
  1345. header('Location: /');exit;
  1346. }
  1347. $prc = array();
  1348. $purchase = $this->purchase->find_all();
  1349. foreach($purchase as $k=>$v)
  1350. {
  1351. $prc[$v['id']] = $v['title'];
  1352. }
  1353. $company = array();
  1354. $ct = $this->company->find_all();
  1355. foreach($ct as $k=>$v)
  1356. {
  1357. $company[$v['id']] = $v['title'];
  1358. }
  1359. $sp = array();
  1360. $s = $this->shop->find_all('1=1','id,shopname');
  1361. foreach ($s as $v)
  1362. {
  1363. $sp[$v['id']] = $v['shopname'];
  1364. }
  1365. $wh = array();
  1366. $w = $this->warehouse->find_all('1=1','id,title');
  1367. foreach ($w as $v)
  1368. {
  1369. $wh[$v['id']] = $v['title'];
  1370. }
  1371. $post = $this->input->post(NULL, TRUE);
  1372. if(isset($post['page']))
  1373. {
  1374. $page = $this->input->post('page',true);
  1375. $perpage = $this->input->post('perpage',true);
  1376. $category = $this->input->post('category',true);
  1377. $size = $this->input->post('size',true);
  1378. $grade = $this->input->post('grade',true);
  1379. $color = $this->input->post('color',true);
  1380. $lowe = $this->input->post('lowe',true);
  1381. $sku = $this->input->post('sku');
  1382. $title = $this->input->post('title');
  1383. $warehouse = $this->input->post('warehouse',true);
  1384. $usa = $this->input->post('usa',true);
  1385. $purchase = $this->input->post('purchase',true);
  1386. $lacetype = $this->input->post('lacetype',true);
  1387. $haircap = $this->input->post('haircap',true);
  1388. $density = $this->input->post('density',true);
  1389. $details = $this->input->post('details',true);
  1390. $state = $this->input->post('state',true);
  1391. $shop = $this->input->post('shop',true);
  1392. $lacecolor = $this->input->post('lacecolor',true);
  1393. $type = $this->input->post('type',true);
  1394. $ktime = $this->input->post('ktime',true);
  1395. $jtime = $this->input->post('jtime',true);
  1396. $ktime = strtotime($ktime);
  1397. $jtime = strtotime($jtime);
  1398. $where = "1=1";$gj = "";$ck = "";
  1399. if($lacetype)
  1400. {
  1401. $where .= " and features like '%-$lacetype-%'";
  1402. }
  1403. if($category)
  1404. {
  1405. $where .= " and features like '%-$category-%'";
  1406. }
  1407. if($size)
  1408. {
  1409. $where .= " and features like '%-$size-%'";
  1410. }
  1411. if($grade)
  1412. {
  1413. $where .= " and features like '%-$grade-%'";
  1414. }
  1415. if($color)
  1416. {
  1417. $where .= " and features like '%-$color-%'";
  1418. }
  1419. if($lowe)
  1420. {
  1421. $where .= " and features like '%-$lowe-%'";
  1422. }
  1423. if($haircap)
  1424. {
  1425. $where .= " and features like '%-$haircap-%'";
  1426. }
  1427. if($density)
  1428. {
  1429. $where .= " and features like '%-$density-%'";
  1430. }
  1431. if($usa)
  1432. {
  1433. if(!$warehouse)
  1434. {
  1435. $where .= " and (warehouse = '5' or warehouse = '8')";
  1436. }
  1437. }
  1438. if($warehouse)
  1439. {
  1440. $where .= " and warehouse = '$warehouse'";
  1441. }
  1442. if($details)
  1443. {
  1444. $where .= " and details = '$details'";
  1445. }
  1446. if($purchase)
  1447. {
  1448. $where .= " and purchase = '$purchase'";
  1449. }
  1450. if($state)
  1451. {
  1452. $where .= " and state = '$state'";
  1453. }
  1454. if($shop)
  1455. {
  1456. $where .= " and shop like '%$shop%'";
  1457. }
  1458. if($lacecolor)
  1459. {
  1460. $where .= " and features like '%-$lacecolor-%'";
  1461. }
  1462. if($type)
  1463. {
  1464. $where .= " and type = '$type'";
  1465. }
  1466. if($ktime && $jtime)
  1467. {
  1468. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1469. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1470. }
  1471. //数据排序
  1472. $order_str = "id desc";
  1473. if(empty($page))
  1474. {
  1475. $start = 0;
  1476. $perpage = 1;
  1477. }
  1478. else
  1479. {
  1480. $start = ($page - 1)*$perpage;
  1481. }
  1482. $fjnr = '';
  1483. if($sku)
  1484. {
  1485. $sku = trim($sku,' ');
  1486. $sku = trim($sku,' ');
  1487. $fjnr .= " and sku like '%$sku%'";
  1488. }
  1489. if($title)
  1490. {
  1491. $title = trim($title,' ');
  1492. $title = trim($title,' ');
  1493. $fjnr .= " and title like '%$title%'";
  1494. }
  1495. $wt = array();
  1496. $whlabel_type = $this->whlabel_type->find_all();
  1497. foreach ($whlabel_type as $v)
  1498. {
  1499. $wt[$v['id']] = $v['title'];
  1500. }
  1501. //$where .= " and time > '$ktime' and time < '$jtime'";
  1502. $info_list = $this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,type,features,number,sm',$order_str,$start,$perpage);//改这需要修改_gbhtype
  1503. //取得信息列表
  1504. $rows = array();$list = array();
  1505. foreach ($info_list as $key=>$value)
  1506. {
  1507. if(isset($wt[$value['type']]))
  1508. {
  1509. $info_list[$key]['type'] = $wt[$value['type']];
  1510. }
  1511. else
  1512. {
  1513. $info_list[$key]['type'] = '未设置';
  1514. }
  1515. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1516. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1517. $ztdata = '';
  1518. if(count($zt) > 0)
  1519. {
  1520. foreach ($zt as $vv)
  1521. {
  1522. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1523. }
  1524. }
  1525. $qbdata = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1526. $cdata = array_filter($qbdata, function($item) {
  1527. return $item['state'] < 1;
  1528. });
  1529. $c = array_sum(array_column($cdata, 'jnum'));
  1530. $gdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1531. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1532. });
  1533. $g = array_sum(array_column($gdata, 'jnum'));
  1534. $xdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1535. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1536. });
  1537. $x = array_sum(array_column($xdata, 'jnum'));
  1538. $tdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1539. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1540. });
  1541. $t = array_sum(array_column($tdata, 'jnum'));
  1542. $zdata = array_filter($qbdata, function($item) {
  1543. return $item['zd'] != "" && $item['state'] < 1;
  1544. });
  1545. $z = array_sum(array_column($zdata, 'jnum'));
  1546. $zdata = array_filter($qbdata, function($item) {
  1547. return $item['zd'] != "" && $item['state'] < 1;
  1548. });
  1549. $z = array_sum(array_column($zdata, 'jnum'));
  1550. //$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');
  1551. //$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'].'"');
  1552. //$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'].'"');
  1553. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1554. //$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'].'"');
  1555. $details = array();
  1556. $cpid = array();
  1557. $od = array();$odid = '';
  1558. $companytitle = '';
  1559. foreach ($qbdata as $v)
  1560. {
  1561. if($v['zd'] != "" && $v['state'] < 1)
  1562. {
  1563. if(!isset($od[$v['zd']]))
  1564. {
  1565. $od[$v['zd']] = 1;//所有数据sku
  1566. }
  1567. else
  1568. {
  1569. $od[$v['zd']] = $od[$v['zd']]+1;
  1570. }
  1571. }
  1572. if($v['state'] < 1)
  1573. {
  1574. $details[$v['details']] = $v['details'];
  1575. if($v['cpid'] != 0)
  1576. {
  1577. $cpid[$v['cpid']] = $v['cpid'];
  1578. }
  1579. }
  1580. if($v['companytitle'] != '' && stripos($companytitle,$company[$v['companytitle']]) === false)
  1581. {
  1582. $companytitle .= '<p>'.$company[$v['companytitle']].'</p>';
  1583. }
  1584. }
  1585. foreach ($od as $k=>$vv)
  1586. {
  1587. $odid .= $k.'数量'.$vv;
  1588. }
  1589. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  1590. $number = $value['number'];$ftime = time()-15*24*3600;
  1591. $z = $z.'('.$odid.')';//查看订单号
  1592. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:'无';
  1593. $info_list[$key]['features'] = $c;
  1594. $info_list[$key]['number'] = $ztdata;
  1595. $info_list[$key]['sm'] = $g;
  1596. $info_list[$key]['x'] = $x;
  1597. $info_list[$key]['t'] = $t;
  1598. $info_list[$key]['z'] = $z;
  1599. /**
  1600. foreach ($cdata as $k=>$v)
  1601. {
  1602. $details[$v['details']] = $v['details'];
  1603. if($v['cpid'] != 0)
  1604. {
  1605. $cpid[$v['cpid']] = $v['cpid'];
  1606. }
  1607. }
  1608. **/
  1609. $info_list[$key]['shop'] = '';
  1610. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1611. if($value['shop'] != '')
  1612. {
  1613. $shop = explode(',',trim($value['shop'],','));
  1614. $info_list[$key]['shop'] = '<p>'.$sp[$shop[0]].'</p>';
  1615. }
  1616. $info_list[$key]['shop'] .= $companytitle;
  1617. /**
  1618. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1619. if(isset($companytitle[0]))
  1620. {
  1621. foreach ($companytitle as $k=>$v)
  1622. {
  1623. if($v['companytitle'] != '')
  1624. {
  1625. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1626. }
  1627. }
  1628. }
  1629. **/
  1630. }
  1631. $total = count($this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,sku,title,features,number'));
  1632. $pagenum = ceil($total/$perpage);
  1633. $over = $total-($start+$perpage);
  1634. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  1635. echo json_encode($rows);exit;
  1636. }
  1637. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1638. $this->data['shop'] = $wlshop;
  1639. $this->data['vip'] = $vip;
  1640. $this->_Template('whlabel_type',$this->data);
  1641. }
  1642. //美仓进销存浏览
  1643. public function _usatype()
  1644. {
  1645. if(isset($_SESSION['api']))
  1646. {
  1647. $user = $this->user->get_api($_SESSION['api']);
  1648. $usp = $user;
  1649. $fgshop = "";$sid = "";$wid="";$wtype="";
  1650. $userwh = explode('|',trim($user['warehouse'],'|'));
  1651. foreach ($userwh as $value)
  1652. {
  1653. $wid .= " id = ".$value." or";
  1654. $wtype .= " type = ".$value." or";
  1655. }
  1656. }
  1657. $prc = array();
  1658. $purchase = $this->purchase->find_all();
  1659. foreach($purchase as $k=>$v)
  1660. {
  1661. $prc[$v['id']] = $v['title'];
  1662. }
  1663. $post = $this->input->post(NULL, TRUE);
  1664. if(isset($post['page']))
  1665. {
  1666. $page = $this->input->post('page',true);
  1667. $perpage = $this->input->post('perpage',true);
  1668. $category = $this->input->post('category',true);
  1669. $size = $this->input->post('size',true);
  1670. $grade = $this->input->post('grade',true);
  1671. $color = $this->input->post('color',true);
  1672. $lowe = $this->input->post('lowe',true);
  1673. $sku = $this->input->post('sku');
  1674. $title = $this->input->post('title');
  1675. $warehouse = $this->input->post('warehouse',true);
  1676. $usa = $this->input->post('usa',true);
  1677. $purchase = $this->input->post('purchase',true);
  1678. $lacetype = $this->input->post('lacetype',true);
  1679. $haircap = $this->input->post('haircap',true);
  1680. $density = $this->input->post('density',true);
  1681. $details = $this->input->post('details',true);
  1682. $state = $this->input->post('state',true);
  1683. $lacecolor = $this->input->post('lacecolor',true);
  1684. $cklx = $this->input->post('cklx',true);
  1685. $ktime = $this->input->post('ktime',true);
  1686. $jtime = $this->input->post('jtime',true);
  1687. $ktime = strtotime($ktime);
  1688. $jtime = strtotime($jtime);
  1689. $where = "1=1";$gj = "";$ck = "";
  1690. if($lacetype)
  1691. {
  1692. $where .= " and features like '%-$lacetype-%'";
  1693. }
  1694. if($category)
  1695. {
  1696. $where .= " and features like '%-$category-%'";
  1697. }
  1698. if($size)
  1699. {
  1700. $where .= " and features like '%-$size-%'";
  1701. }
  1702. if($grade)
  1703. {
  1704. $where .= " and features like '%-$grade-%'";
  1705. }
  1706. if($color)
  1707. {
  1708. $where .= " and features like '%-$color-%'";
  1709. }
  1710. if($lowe)
  1711. {
  1712. $where .= " and features like '%-$lowe-%'";
  1713. }
  1714. if($haircap)
  1715. {
  1716. $where .= " and features like '%-$haircap-%'";
  1717. }
  1718. if($density)
  1719. {
  1720. $where .= " and features like '%-$density-%'";
  1721. }
  1722. if($lacecolor)
  1723. {
  1724. $where .= " and features like '%-$lacecolor-%'";
  1725. }
  1726. if($usa)
  1727. {
  1728. if(!$warehouse)
  1729. {
  1730. $where .= " and (warehouse = '5' or warehouse = '8')";
  1731. }
  1732. }
  1733. if($warehouse)
  1734. {
  1735. $where .= " and warehouse = '$warehouse'";
  1736. }
  1737. if($details)
  1738. {
  1739. $where .= " and details = '$details'";
  1740. }
  1741. if($purchase)
  1742. {
  1743. $where .= " and purchase = '$purchase'";
  1744. }
  1745. if($state)
  1746. {
  1747. $where .= " and state = '$state'";
  1748. }
  1749. $where_add = '';
  1750. if($cklx)
  1751. {
  1752. $shop = $this->shop->read($cklx);
  1753. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  1754. }
  1755. if($ktime && $jtime)
  1756. {
  1757. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1758. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1759. }
  1760. //数据排序
  1761. $order_str = "id desc";
  1762. if(empty($page))
  1763. {
  1764. $start = 0;
  1765. $perpage = 1;
  1766. }
  1767. else
  1768. {
  1769. $start = ($page - 1)*$perpage;
  1770. }
  1771. if($sku)
  1772. {
  1773. $sku = trim($sku,' ');
  1774. $sku = trim($sku,' ');
  1775. $where .= " and sku like '%$sku%'";
  1776. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1777. }
  1778. else if($title)
  1779. {
  1780. $title = trim($title,' ');
  1781. $title = trim($title,' ');
  1782. $where .= " and title like '%$title%'";
  1783. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1784. }
  1785. else
  1786. {
  1787. //$where .= " and time > '$ktime' and time < '$jtime'";
  1788. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1789. }
  1790. //取得信息列表
  1791. $rows = array();$list = array();
  1792. foreach ($info_list as $key=>$value)
  1793. {
  1794. $warehouse = $this->warehouse->read($value['warehouse']);
  1795. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1796. $g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1797. $x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1798. $t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1799. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1800. $od = array();$odid = '';
  1801. foreach ($z as $v)
  1802. {
  1803. if(!isset($od[$v['zd']]))
  1804. {
  1805. $od[$v['zd']] = 1;//所有数据sku
  1806. }
  1807. else
  1808. {
  1809. $od[$v['zd']] = $od[$v['zd']]+1;
  1810. }
  1811. }
  1812. foreach ($od as $k=>$vv)
  1813. {
  1814. $odid .= $k.'数量'.$vv.' ';
  1815. }
  1816. $z = count($z).'('.$odid.')';//查看订单号
  1817. $info_list[$key]['features'] = $c;
  1818. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1819. $ztdata = '';
  1820. if(count($zt) > 0)
  1821. {
  1822. foreach ($zt as $vv)
  1823. {
  1824. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1825. }
  1826. }
  1827. $info_list[$key]['warehouse'] = $ztdata;
  1828. $info_list[$key]['g'] = $g;
  1829. $info_list[$key]['x'] = $x;
  1830. $info_list[$key]['t'] = $t;
  1831. $info_list[$key]['z'] = $z;
  1832. }
  1833. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title'));
  1834. $pagenum = ceil($total/$perpage);
  1835. $over = $total-($start+$perpage);
  1836. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1837. echo json_encode($rows);exit;
  1838. }
  1839. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1840. $this->data['warehouse'] = $warehouse;
  1841. $this->_Template('whlabel_typeusa',$this->data);
  1842. }
  1843. //美仓进销存浏览
  1844. public function _usatypeapp()
  1845. {
  1846. $post = $this->input->post(NULL, TRUE);
  1847. if(isset($post['page']))
  1848. {
  1849. $page = $this->input->post('page',true);
  1850. $perpage = $this->input->post('perpage',true);
  1851. $sku = $this->input->post('sku',true);
  1852. $warehouse = 5;
  1853. $title = $this->input->post('title',true);
  1854. $state = $this->input->post('state',true);
  1855. $ktime = $this->input->post('ktime',true);
  1856. $jtime = $this->input->post('jtime',true);
  1857. $ktime = strtotime($ktime);
  1858. $jtime = strtotime($jtime);
  1859. $where = "1=1";$gj = "";$ck = "";
  1860. if($title)
  1861. {
  1862. $st = explode(' ',trim($title,' '));
  1863. foreach ($st as $v)
  1864. {
  1865. $where .= " and title like '%$v%'";
  1866. }
  1867. }
  1868. if($warehouse)
  1869. {
  1870. $where .= " and warehouse = '$warehouse'";
  1871. }
  1872. if($state)
  1873. {
  1874. $where .= " and state = '$state'";
  1875. }
  1876. if($sku)
  1877. {
  1878. $where .= " and sku like '%$sku%'";
  1879. }
  1880. if($ktime && $jtime)
  1881. {
  1882. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1883. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1884. }
  1885. //数据排序
  1886. $order_str = "id desc";
  1887. if(empty($page))
  1888. {
  1889. $start = 0;
  1890. $perpage = 1;
  1891. }
  1892. else
  1893. {
  1894. $start = ($page - 1)*$perpage;
  1895. }
  1896. //取得信息列表
  1897. $info_list = $this->whlabel->find_all($where.' and '.rtrim($wid,'or'),'*');
  1898. $rows = array();$list = array();
  1899. foreach ($info_list as $key=>$value)
  1900. {
  1901. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1902. }
  1903. $rowsdq = array_slice($rows,$start,$perpage);
  1904. foreach ($rowsdq as $value)
  1905. {
  1906. $warehouse = $this->warehouse->read($value['warehouse']);
  1907. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'"');
  1908. $x = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'"');
  1909. $t = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1910. $od = array();$odid = '';
  1911. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'x'=>$x,'t'=>$t);
  1912. }
  1913. $total = count($rows);
  1914. $pagenum = ceil($total/$perpage);
  1915. $over = $total-($start+$perpage);
  1916. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1917. echo json_encode($rows);exit;
  1918. }
  1919. $this->_Template('phone/p_usatypeapp',$this->data);
  1920. }
  1921. //入库操作
  1922. public function _enteradd()
  1923. {
  1924. $dt = 0;
  1925. if(isset($_SESSION['api']))
  1926. {
  1927. $user = $this->user->get_api($_SESSION['api']);
  1928. $usp = $user;
  1929. $fgshop = "";$sid = "";
  1930. $user = explode('|',trim($user['shop'],'|'));
  1931. foreach ($user as $value)
  1932. {
  1933. $fgshop .= " shop = ".$value." or";
  1934. $sid .= " id = ".$value." or";
  1935. }
  1936. }
  1937. $tc = $this->typeclass->find_all();
  1938. $typeclass = array();
  1939. foreach ($tc as $v)
  1940. {
  1941. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1942. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'bqsku'=>$v['bqsku']);
  1943. }
  1944. $post = $this->input->post(NULL, TRUE);
  1945. if(isset($post['sku']))
  1946. {
  1947. $list = array();$num = "";$title = "";$features = "";
  1948. $order = $this->input->post('order',true);
  1949. $shop = $this->input->post('shop',true);
  1950. $post['shop'] = ($shop!="")?','.$shop:"";
  1951. $sku = $this->input->post('sku',true);
  1952. $post['sm'] = $this->input->post('sm',true);
  1953. $post['warehouse'] = $this->input->post('warehouse',true);
  1954. $post['purchase'] = $this->input->post('purchase',true);
  1955. $post['retreatwarehouse'] = $post['warehouse'];
  1956. $post['state'] = $this->input->post('state',true);
  1957. $post['rktype'] = $this->input->post('rktype',true);
  1958. $post['text'] = $this->input->post('text',true);
  1959. $category = $this->input->post('category',true);
  1960. $list['category'] = $category;
  1961. $list['hairtype'] = $this->input->post('hairtype',true);
  1962. $list['grade'] = $this->input->post('grade',true);
  1963. $size = $this->input->post('size',true);
  1964. $xzsku = $this->input->post('xzsku',true);
  1965. $list['size'] = rtrim($size,',');
  1966. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1967. $list['extension'] = $this->input->post('extension',true);
  1968. if($category == 1297)
  1969. {
  1970. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1971. }
  1972. if($category == 1702)
  1973. {
  1974. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1975. $list['syother'] = $this->input->post('syother',true);
  1976. }
  1977. if($category == 133)
  1978. {
  1979. $list['fittype'] = $this->input->post('fittype',true);
  1980. $list['acother'] = $this->input->post('acother',true);
  1981. }
  1982. $list['color'] = $this->input->post('color',true);
  1983. $list['lowe'] = $this->input->post('lowe',true);
  1984. if(!$post['purchase'])
  1985. {
  1986. $post['purchase'] = 1;
  1987. }
  1988. if($category == 127)
  1989. {
  1990. $list['type'] = $this->input->post('type',true);
  1991. $list['headroad'] = $this->input->post('headroad',true);
  1992. $list['density'] = $this->input->post('density',true);
  1993. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  1994. {
  1995. $list['lacesize'] = $this->input->post('lacesize',true);
  1996. }
  1997. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1998. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1999. }
  2000. if($category == 128)
  2001. {
  2002. $list['lacetype'] = $this->input->post('lacetype',true);
  2003. $list['haircap'] = $this->input->post('haircap',true);
  2004. $list['density'] = $this->input->post('density',true);
  2005. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2006. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2007. $list['wigother'] = $this->input->post('wigother',true);
  2008. $list['wigother2'] = $this->input->post('wigother2',true);
  2009. }
  2010. if($category == 129)
  2011. {
  2012. $list['wide'] = $this->input->post('wide',true);
  2013. }
  2014. if($category == 131)
  2015. {
  2016. $list['gifttype'] = $this->input->post('gifttype',true);
  2017. $list['giftother'] = $this->input->post('giftother',true);
  2018. }
  2019. if($category == 134)
  2020. {
  2021. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2022. }
  2023. if($category == 1297)
  2024. {
  2025. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2026. $list['sywigother'] = $this->input->post('sywigother',true);
  2027. }
  2028. if($category == 130 || $category == 133 || $category == 1702)
  2029. {
  2030. $list['items'] = $this->input->post('items',true);
  2031. $list['weight'] = $this->input->post('weight',true);
  2032. }
  2033. if($category == 1702)
  2034. {
  2035. $list['syhairther'] = $this->input->post('syhairther',true);
  2036. }
  2037. $classid = $this->classid->sku();
  2038. $scsku = $classid;
  2039. $pm = $classid;
  2040. foreach($list as $k=>$v)
  2041. {
  2042. if($v != 0)
  2043. {
  2044. $num .=$v;
  2045. $features .=$v.'-';
  2046. $post[$k] = $v;
  2047. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2048. if($k != 'size')
  2049. {
  2050. $title .= $typeclass[$v]['title']." ";
  2051. }
  2052. if(isset($pm[$typeclass[$v]['classid']]))
  2053. {
  2054. if($typeclass[$v]['title'] == '9A')
  2055. {
  2056. $pm[$typeclass[$v]['classid']] = '9A';
  2057. }
  2058. else if($typeclass[$v]['title'] == '10A')
  2059. {
  2060. $pm[$typeclass[$v]['classid']] = '10A';
  2061. }
  2062. else
  2063. {
  2064. $clzh = $typeclass[$v]['zh'];
  2065. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2066. {
  2067. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2068. $clzh = $clzh[0];
  2069. }
  2070. $pm[$typeclass[$v]['classid']] = $clzh;
  2071. }
  2072. }
  2073. }
  2074. }
  2075. $zh = implode(" ",$pm);
  2076. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2077. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2078. if($list['size'])
  2079. {
  2080. $typeclass = $this->typeclass->read($list['size']);
  2081. $title .= $typeclass['title'];
  2082. }
  2083. $time = time();
  2084. if($xzsku)
  2085. {
  2086. $scsku = implode("-",$scsku);
  2087. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2088. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2089. $post['sku'] = trim($scsku,' ');
  2090. }
  2091. else
  2092. {
  2093. $post['sku'] = $sku;
  2094. }
  2095. //$post['sku'] = trim($sku,' ');
  2096. $post['title'] = rtrim($title,' ');
  2097. $post['number'] = $num;
  2098. $post['features'] = '-'.$features;
  2099. $post['enter'] = $time;
  2100. $post['time'] = $time;//操作时间
  2101. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2102. if($yza)
  2103. {
  2104. if($post['features'] != $yza[0]['features'])
  2105. {
  2106. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'success'=>false));exit;
  2107. }
  2108. }
  2109. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2110. if($yzb)
  2111. {
  2112. if($post['sku'] != $yzb[0]['sku'])
  2113. {
  2114. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','success'=>false));exit;
  2115. }
  2116. }
  2117. if(isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
  2118. {
  2119. echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
  2120. }
  2121. if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
  2122. {
  2123. echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
  2124. }
  2125. if($post['rktype'] == '' && $post['warehouse'] == 5)
  2126. {
  2127. echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
  2128. }
  2129. $yz = $this->whlabel->find_all("sku = '".$post['sku']."' and features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'",'type');
  2130. if(isset($yz[0]['type']))
  2131. {
  2132. $post['type'] = $yz[0]['type'];
  2133. }
  2134. if($post['state'] == 9)//如果选择预设库存
  2135. {
  2136. $this->whlabel->insert($post);
  2137. }
  2138. else
  2139. {
  2140. /**
  2141. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2142. if($ljg == 1)
  2143. {
  2144. for($i=0;$i<$order;$i++)
  2145. {
  2146. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2147. $this->whlabel->insert($post);
  2148. }
  2149. }
  2150. **/
  2151. //if($post['warehouse'] == '5')
  2152. //{
  2153. //}
  2154. $yydata = $post;
  2155. $yydata['zh'] = $zh;
  2156. /**
  2157. $wl = $this->apiyy->get_cjlp($yydata);
  2158. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2159. {
  2160. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2161. }
  2162. if($wl['Data'][0]['m_isSucess'] != 1)
  2163. {
  2164. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2165. }
  2166. **/
  2167. for($i=0;$i<$order;$i++)
  2168. {
  2169. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2170. $this->whlabel->insert($post);
  2171. }
  2172. }
  2173. echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
  2174. }
  2175. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2176. $this->data['wlshop'] = $wlshop;
  2177. $this->_Template('whlabel_enteradd',$this->data);
  2178. }
  2179. //修改产品
  2180. public function _enteredit($arg_array)
  2181. {
  2182. $dt = 0;
  2183. if(isset($_SESSION['api']))
  2184. {
  2185. $user = $this->user->get_api($_SESSION['api']);
  2186. $usp = $user;
  2187. $fgshop = "";$sid = "";
  2188. $user = explode('|',trim($user['shop'],'|'));
  2189. foreach ($user as $value)
  2190. {
  2191. $fgshop .= " shop = ".$value." or";
  2192. $sid .= " id = ".$value." or";
  2193. }
  2194. }
  2195. $post = $this->input->post(NULL, TRUE);
  2196. if(isset($post['sku']))
  2197. {
  2198. $list = array();$num = "";$title = "";$features = "";
  2199. $id = $this->input->post('id',true);
  2200. $order = $this->input->post('order',true);
  2201. $shop = $this->input->post('shop',true);
  2202. $post['shop'] = ($shop!="")?','.$shop:"";
  2203. $post['sku'] = $this->input->post('sku',true);
  2204. $post['sm'] = $this->input->post('sm',true);
  2205. $post['warehouse'] = $this->input->post('warehouse',true);
  2206. $post['purchase'] = $this->input->post('purchase',true);
  2207. $post['retreatwarehouse'] = $post['warehouse'];
  2208. $category = $this->input->post('category',true);
  2209. $list['category'] = $category;
  2210. $list['hairtype'] = $this->input->post('hairtype',true);
  2211. $list['grade'] = $this->input->post('grade',true);
  2212. $size = $this->input->post('size',true);
  2213. $list['size'] = rtrim($size,',');
  2214. $post['rktype'] = $this->input->post('rktype',true);
  2215. $post['text'] = $this->input->post('text',true);
  2216. $list['hairnumber'] = $this->input->post('hairnumber',true);
  2217. $list['extension'] = $this->input->post('extension',true);
  2218. if($category == 1297)
  2219. {
  2220. $list['sywignumber'] = $this->input->post('sywignumber',true);
  2221. }
  2222. if($category == 1702)
  2223. {
  2224. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  2225. $list['syother'] = $this->input->post('syother',true);
  2226. }
  2227. if($category == 133)
  2228. {
  2229. $list['fittype'] = $this->input->post('fittype',true);
  2230. $list['acother'] = $this->input->post('acother',true);
  2231. }
  2232. $list['color'] = $this->input->post('color',true);
  2233. $list['lowe'] = $this->input->post('lowe',true);
  2234. if(!$post['purchase'])
  2235. {
  2236. $post['purchase'] = 1;
  2237. }
  2238. if($category == 127)
  2239. {
  2240. $list['type'] = $this->input->post('type',true);
  2241. $list['headroad'] = $this->input->post('headroad',true);
  2242. $list['density'] = $this->input->post('density',true);
  2243. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  2244. {
  2245. $list['lacesize'] = $this->input->post('lacesize',true);
  2246. }
  2247. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2248. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2249. }
  2250. if($category == 128)
  2251. {
  2252. $list['lacetype'] = $this->input->post('lacetype',true);
  2253. $list['haircap'] = $this->input->post('haircap',true);
  2254. $list['density'] = $this->input->post('density',true);
  2255. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2256. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2257. $list['wigother'] = $this->input->post('wigother',true);
  2258. $list['wigother2'] = $this->input->post('wigother2',true);
  2259. }
  2260. if($category == 129)
  2261. {
  2262. $list['wide'] = $this->input->post('wide',true);
  2263. }
  2264. if($category == 131)
  2265. {
  2266. $list['gifttype'] = $this->input->post('gifttype',true);
  2267. $list['giftother'] = $this->input->post('giftother',true);
  2268. }
  2269. if($category == 134)
  2270. {
  2271. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2272. }
  2273. if($category == 1297)
  2274. {
  2275. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2276. $list['sywigother'] = $this->input->post('sywigother',true);
  2277. }
  2278. if($category == 130 || $category == 133 || $category == 1702)
  2279. {
  2280. $list['items'] = $this->input->post('items',true);
  2281. $list['weight'] = $this->input->post('weight',true);
  2282. }
  2283. if($category == 1702)
  2284. {
  2285. $list['syhairther'] = $this->input->post('syhairther',true);
  2286. }
  2287. foreach($list as $k=>$v)
  2288. {
  2289. if($v != 0)
  2290. {
  2291. $num .=$v;
  2292. $features .=$v.'-';
  2293. $typeclass = $this->typeclass->read($v);
  2294. if($k != 'size')
  2295. {
  2296. $title .= $typeclass['title']." ";
  2297. }
  2298. }
  2299. }
  2300. $typeclass = $this->typeclass->read($list['size']);
  2301. $title .= $typeclass['title'];
  2302. $time = time();
  2303. $post['title'] = rtrim($title,' ');
  2304. $post['number'] = $num;
  2305. $post['features'] = '-'.$features;
  2306. $post['time'] = $time;//操作时间
  2307. if($post['rktype'] == '' && $post['warehouse'] == 5)
  2308. {
  2309. echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
  2310. }
  2311. if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
  2312. {
  2313. echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
  2314. }
  2315. $uid = $this->whlabel->read($id);
  2316. $datanum = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2317. if($datanum > 0)
  2318. {
  2319. echo json_encode(array('msg'=>'此SKU有占单,请解除占单后再修改!','success'=>false));exit;
  2320. }
  2321. if($post['warehouse'] != '99999')//现在所有仓都检测,之前只有美仓5检测
  2322. {
  2323. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."'");
  2324. if($yza)
  2325. {
  2326. if($post['features'] != $yza[0]['features'])
  2327. {
  2328. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','success'=>false));exit;
  2329. }
  2330. }
  2331. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."'");
  2332. if($yzb)
  2333. {
  2334. if($post['sku'] != $yzb[0]['sku'])
  2335. {
  2336. echo json_encode(array('msg'=>'此产品信息的SKU和现有不一致!','success'=>false));exit;
  2337. }
  2338. }
  2339. if($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
  2340. {
  2341. echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
  2342. }
  2343. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2344. foreach ($data as $v)
  2345. {
  2346. $post['id'] = $v['id'];
  2347. $this->whlabel->save($post,$v['id']);
  2348. }
  2349. }
  2350. else
  2351. {
  2352. $data = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2353. if($data > 0)
  2354. {
  2355. echo json_encode(array('msg'=>'此产品有占单,无法修改!','success'=>false));exit;
  2356. }
  2357. else
  2358. {
  2359. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2360. foreach ($data as $v)
  2361. {
  2362. $post['id'] = $v['id'];
  2363. $this->whlabel->save($post,$v['id']);
  2364. }
  2365. }
  2366. }
  2367. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  2368. }
  2369. $uid = $this->whlabel->read($arg_array[0]);
  2370. $uid['order'] = $this->whlabel->find_count('enter = "'.$uid['enter'].'" and sku = "'.$uid['sku'].'" and state = "0"');
  2371. $this->data['enter'] = $uid ;
  2372. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2373. $this->data['wlshop'] = $wlshop;
  2374. $this->_Template('whlabel_enteredit',$this->data);
  2375. }
  2376. //入库浏览
  2377. public function _enter()
  2378. {
  2379. $post = $this->input->post(NULL, TRUE);
  2380. if(isset($post['s']))
  2381. {
  2382. $id_arr = $this->input->post('s');
  2383. $id_arr = explode(',',$id_arr);
  2384. if(!$id_arr)
  2385. {
  2386. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2387. }
  2388. //循环删除记录
  2389. foreach ($id_arr as $v)
  2390. {
  2391. $sid = $this->whlabel->read($v);
  2392. $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
  2393. if($count > 0)
  2394. {
  2395. echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
  2396. }
  2397. $info_list = $this->whlabel->find_all('enter ='.$sid['enter']);
  2398. foreach ($info_list as $va)
  2399. {
  2400. $this->whlabel->remove($va['id']);
  2401. }
  2402. }
  2403. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  2404. }
  2405. $sp = array();
  2406. $s = $this->shop->find_all('1=1','id,shopname');
  2407. foreach ($s as $v)
  2408. {
  2409. $sp[$v['id']] = $v['shopname'];
  2410. }
  2411. $wh = array();
  2412. $w = $this->warehouse->find_all('1=1','id,title');
  2413. foreach ($w as $v)
  2414. {
  2415. $wh[$v['id']] = $v['title'];
  2416. }
  2417. if(isset($post['page']))
  2418. {
  2419. $page = $this->input->post('page',true);
  2420. $perpage = $this->input->post('perpage',true);
  2421. $category = $this->input->post('category',true);
  2422. $size = $this->input->post('size',true);
  2423. $grade = $this->input->post('grade',true);
  2424. $color = $this->input->post('color',true);
  2425. $lowe = $this->input->post('lowe',true);
  2426. $sku = $this->input->post('sku',true);
  2427. $warehouse = $this->input->post('warehouse',true);
  2428. $purchase = $this->input->post('purchase',true);
  2429. $ktime = $this->input->post('ktime',true);
  2430. $jtime = $this->input->post('jtime',true);
  2431. $ktime = strtotime($ktime);
  2432. $jtime = strtotime($jtime);
  2433. $where = "1=1";$gj = "";$ck = "";
  2434. if($category)
  2435. {
  2436. $where .= " and features like '%-$category-%'";
  2437. }
  2438. if($size)
  2439. {
  2440. $where .= " and features like '%-$size-%'";
  2441. }
  2442. if($grade)
  2443. {
  2444. $where .= " and features like '%-$grade-%'";
  2445. }
  2446. if($color)
  2447. {
  2448. $where .= " and features like '%-$color-%'";
  2449. }
  2450. if($lowe)
  2451. {
  2452. $where .= " and features like '%-$lowe-%'";
  2453. }
  2454. if($warehouse)
  2455. {
  2456. $where .= " and warehouse = '$warehouse'";
  2457. }
  2458. if($purchase)
  2459. {
  2460. $where .= " and purchase = '$purchase'";
  2461. }
  2462. if($sku)
  2463. {
  2464. $where .= " and sku like '%$sku%'";
  2465. }
  2466. if($ktime && $jtime)
  2467. {
  2468. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2469. }
  2470. //数据排序
  2471. $order_str = "enter desc";
  2472. if(empty($page))
  2473. {
  2474. $start = 0;
  2475. $perpage = 1;
  2476. }
  2477. else
  2478. {
  2479. $start = ($page - 1)*$perpage;
  2480. }
  2481. //取得信息列表
  2482. $info_list = $this->whlabel->find_pc($where,'enter,warehouse,sku','id,warehouse,shop,sku,title,enter',$order_str,$start,$perpage);
  2483. foreach ($info_list as $k=>$v)
  2484. {
  2485. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2486. if($v['shop']=='')
  2487. {
  2488. $s = '通用';
  2489. }
  2490. else
  2491. {
  2492. $info_list[$k]['shop'] = '';
  2493. foreach (explode(',',trim($v['shop'],',')) as $val)
  2494. {
  2495. $info_list[$k]['shop'] .= $sp[$val].'</br>';
  2496. }
  2497. }
  2498. $info_list[$k]['enter'] = date('Y-m-d H:i:s',$v['enter']);
  2499. $g = $this->whlabel->find_count($where.' and enter = "'.$v['enter'].'" and sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'"');
  2500. $info_list[$k]['g'] = $g;
  2501. }
  2502. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  2503. $pagenum = ceil($total/$perpage);
  2504. $over = $total-($start+$perpage);
  2505. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2506. echo json_encode($rows);exit;
  2507. }
  2508. $this->_Template('whlabel_enter',$this->data);
  2509. }
  2510. //出库浏览
  2511. public function _out()
  2512. {
  2513. $post = $this->input->post(NULL, TRUE);
  2514. if(isset($post['page']))
  2515. {
  2516. $page = $this->input->post('page',true);
  2517. $perpage = $this->input->post('perpage',true);
  2518. $category = $this->input->post('category',true);
  2519. $size = $this->input->post('size',true);
  2520. $grade = $this->input->post('grade',true);
  2521. $color = $this->input->post('color',true);
  2522. $lowe = $this->input->post('lowe',true);
  2523. $sku = $this->input->post('sku',true);
  2524. $warehouse = $this->input->post('warehouse',true);
  2525. $purchase = $this->input->post('purchase',true);
  2526. $state = $this->input->post('state',true);
  2527. $ktime = $this->input->post('ktime',true);
  2528. $jtime = $this->input->post('jtime',true);
  2529. $ktime = strtotime($ktime);
  2530. $jtime = strtotime($jtime);
  2531. $where = "state=3";$gj = "";$ck = "";
  2532. if($category)
  2533. {
  2534. $where .= " and features like '%-$category-%'";
  2535. }
  2536. if($size)
  2537. {
  2538. $where .= " and features like '%-$size-%'";
  2539. }
  2540. if($grade)
  2541. {
  2542. $where .= " and features like '%-$grade-%'";
  2543. }
  2544. if($color)
  2545. {
  2546. $where .= " and features like '%-$color-%'";
  2547. }
  2548. if($lowe)
  2549. {
  2550. $where .= " and features like '%-$lowe-%'";
  2551. }
  2552. if($state)
  2553. {
  2554. $where .= " and state = '$state'";
  2555. }
  2556. if($warehouse)
  2557. {
  2558. $where .= " and warehouse = '$warehouse'";
  2559. }
  2560. if($purchase)
  2561. {
  2562. $where .= " and purchase = '$purchase'";
  2563. }
  2564. if($sku)
  2565. {
  2566. $where .= " and sku = '$sku'";
  2567. }
  2568. if($ktime && $jtime)
  2569. {
  2570. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2571. }
  2572. //数据排序
  2573. $order_str = "id desc";
  2574. if(empty($page))
  2575. {
  2576. $start = 0;
  2577. $perpage = 1;
  2578. }
  2579. else
  2580. {
  2581. $start = ($page - 1)*$perpage;
  2582. }
  2583. //取得信息列表
  2584. $info_list = $this->whlabel->find_all($where,'sku');
  2585. $rows = array();$list = array();
  2586. foreach ($info_list as $key=>$value)
  2587. {
  2588. $rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
  2589. }
  2590. $rows = array_unique($rows);//删除重复记录
  2591. foreach ($rows as $key=>$value)
  2592. {
  2593. $data = $this->whlabel->get_sku($value);//获取目前sku的所有数据
  2594. $ck = $this->warehouse->read($data['warehouse']);
  2595. $warehouse = $ck['title'];
  2596. $gy = $this->purchase->read($data['purchase']);
  2597. $purchase = $gy['purchase'];
  2598. $g = $this->whlabel->find_count($where.' and sku = "'.$value.'" and state = 3');
  2599. $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);
  2600. }
  2601. $total = count($list);
  2602. $pagenum = ceil($total/$perpage);
  2603. $over = $total-($start+$perpage);
  2604. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  2605. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  2606. echo json_encode($rows);exit;
  2607. }
  2608. $this->_Template('whlabel_out',$this->data);
  2609. }
  2610. //出库标签浏览
  2611. public function _label()
  2612. {
  2613. $post = $this->input->post(NULL, TRUE);
  2614. if(isset($post['page']))
  2615. {
  2616. $page = $this->input->post('page',true);
  2617. $perpage = $this->input->post('perpage',true);
  2618. $sku = $this->input->post('sku',true);
  2619. $warehouse = $this->input->post('warehouse',true);
  2620. $purchase = $this->input->post('purchase',true);
  2621. $orderinfo = $this->input->post('orderinfo',true);
  2622. $waybill = $this->input->post('waybill',true);
  2623. $category = $this->input->post('category',true);
  2624. $size = $this->input->post('size',true);
  2625. $grade = $this->input->post('grade',true);
  2626. $color = $this->input->post('color',true);
  2627. $lowe = $this->input->post('lowe',true);
  2628. $where = "state=1";
  2629. if($sku)
  2630. {
  2631. $where .= " and sku = '$sku'";
  2632. }
  2633. if($warehouse)
  2634. {
  2635. $where .= " and warehouse = '$warehouse'";
  2636. }
  2637. if($purchase)
  2638. {
  2639. $where .= " and purchase = '$purchase'";
  2640. }
  2641. if($orderinfo)
  2642. {
  2643. $where .= " and orderinfo = '$orderinfo'";
  2644. }
  2645. if($waybill)
  2646. {
  2647. $where .= " and waybill = '$waybill'";
  2648. }
  2649. if($category)
  2650. {
  2651. $where .= " and features like '%-$category-%'";
  2652. }
  2653. if($size)
  2654. {
  2655. $where .= " and features like '%-$size-%'";
  2656. }
  2657. if($grade)
  2658. {
  2659. $where .= " and features like '%-$grade-%'";
  2660. }
  2661. if($color)
  2662. {
  2663. $where .= " and features like '%-$color-%'";
  2664. }
  2665. if($lowe)
  2666. {
  2667. $where .= " and features like '%-$lowe-%'";
  2668. }
  2669. //数据排序
  2670. $order_str = "outk desc";
  2671. if(empty($page))
  2672. {
  2673. $start = 0;
  2674. $perpage = 1;
  2675. }
  2676. else
  2677. {
  2678. $start = ($page - 1)*$perpage;
  2679. }
  2680. //取得信息列表
  2681. $info_list = $this->whlabel->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
  2682. foreach ($info_list as $key=>$value)
  2683. {
  2684. $warehouse = $this->warehouse->read($value['warehouse']);
  2685. $info_list[$key]['warehouse'] = $warehouse['title'];
  2686. $purchase = $this->purchase->read($value['purchase']);
  2687. $info_list[$key]['purchase'] = $purchase['title'];
  2688. if($value['outk'] != 0)
  2689. {
  2690. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  2691. }
  2692. else
  2693. {
  2694. $info_list[$key]['outk'] = "";
  2695. }
  2696. if($value['orderinfo'] == 0)
  2697. {
  2698. $info_list[$key]['orderinfo'] = "";
  2699. }
  2700. if($value['waybill'] == 0)
  2701. {
  2702. $info_list[$key]['waybill'] = "";
  2703. }
  2704. }
  2705. $total = $this->whlabel->find_count($where);
  2706. $pagenum = ceil($total/$perpage);
  2707. $over = $total-($start+$perpage);
  2708. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2709. echo json_encode($rows);exit;
  2710. }
  2711. $this->_Template('whlabel_label',$this->data);
  2712. }
  2713. //独立站出库订单
  2714. public function _outorder()
  2715. {
  2716. if(isset($_SESSION['api']))
  2717. {
  2718. $user = $this->user->get_api($_SESSION['api']);
  2719. $usp = $user;
  2720. $fgshop = "";$sid = "";
  2721. $user = explode('|',trim($user['shop'],'|'));
  2722. foreach ($user as $value)
  2723. {
  2724. $fgshop .= " shop = ".$value." or";
  2725. $sid .= " id = ".$value." or";
  2726. }
  2727. }
  2728. else
  2729. {
  2730. echo "请重新登录";
  2731. }
  2732. $post = $this->input->post(NULL, TRUE);
  2733. if(isset($post['page']))
  2734. {
  2735. $page = $this->input->post('page',true);
  2736. $perpage = $this->input->post('perpage',true);
  2737. $warehouse = $this->input->post('warehouse',true);
  2738. $xztime = $this->input->post('xztime',true);
  2739. $timetk = $this->input->post('timetkk',true);
  2740. $timetj = $this->input->post('timetjj',true);
  2741. $shop = $this->input->post('shop',true);
  2742. $source = $this->input->post('source',true);
  2743. $orderinfo = $this->input->post('orderinfo',true);
  2744. $number = $this->input->post('number',true);
  2745. $sfxh = $this->input->post('sfxh',true);
  2746. $express = $this->input->post('express',true);
  2747. $waybill = $this->input->post('waybill',true);
  2748. $library = $this->input->post('library',true);
  2749. $country = $this->input->post('country',true);
  2750. $so = $this->input->post('so',true);
  2751. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2752. $print = $this->input->post('print',true);
  2753. $state = $this->input->post('state',true);
  2754. $orderurl = $this->input->post('orderurl',true);
  2755. $timetk = strtotime($timetk);
  2756. $timetj = strtotime($timetj);
  2757. /**
  2758. $sj = $this->input->post('sj',true);
  2759. if($sj)
  2760. {
  2761. $sj = $this->input->post('sj',true);
  2762. }
  2763. else
  2764. {
  2765. $sj = "fullorder";
  2766. }
  2767. **/
  2768. $sj = "fullorder";
  2769. $where = "1=1";
  2770. if($warehouse)
  2771. {
  2772. $where .= " and type = '$warehouse'";
  2773. }
  2774. if($timetk && $timetj)
  2775. {
  2776. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2777. }
  2778. if($orderinfo)
  2779. {
  2780. $where .= " and orderinfo = '$orderinfo'";
  2781. }
  2782. if($number)
  2783. {
  2784. $where .= " and number = '$number'";
  2785. }
  2786. if($express)
  2787. {
  2788. $where .= " and express = '$express'";
  2789. }
  2790. if($waybill)
  2791. {
  2792. $where .= " and waybill = '$waybill'";
  2793. }
  2794. if($library)
  2795. {
  2796. $where .= " and library = '$library'";
  2797. }
  2798. if($print)
  2799. {
  2800. $where .= " and print = '$print'";
  2801. }
  2802. if($libraryconfirm)
  2803. {
  2804. $where .= " and libraryconfirm = '$libraryconfirm'";
  2805. }
  2806. if($state)
  2807. {
  2808. $where .= " and state = '$state'";
  2809. }
  2810. if($shop)
  2811. {
  2812. $where .= " and shop = '$shop'";
  2813. }
  2814. if($country)
  2815. {
  2816. $where .= " and country = '$country'";
  2817. }
  2818. if($sfxh != '')
  2819. {
  2820. $where .= " and sfxh = '$sfxh'";
  2821. }
  2822. if($so)
  2823. {
  2824. $where .= " and shipremarks like '%$so%'";
  2825. }
  2826. if($source)
  2827. {
  2828. if($source == '2d')
  2829. {
  2830. $where .= " and source >= '2'";
  2831. }
  2832. else
  2833. {
  2834. $where .= " and source = '$source'";
  2835. }
  2836. }
  2837. if(isset($_SESSION['api']))
  2838. {
  2839. foreach ($user as $value)
  2840. {
  2841. $fgshop .= " shop = ".$value." or";
  2842. }
  2843. $where .= " and (".rtrim($fgshop,'or').")";
  2844. }
  2845. if($orderurl)
  2846. {
  2847. $url = $this->orderurl->read($orderurl);
  2848. $where .= " and link like '%".$url['url']."%'";
  2849. }
  2850. //数据排序
  2851. $order_str = "librarytime desc";
  2852. if(empty($page))
  2853. {
  2854. $start = 0;
  2855. $perpage = 1;
  2856. }
  2857. else
  2858. {
  2859. $start = ($page - 1)*$perpage;
  2860. }
  2861. //取得信息列表
  2862. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2863. //格式化数据
  2864. foreach ($info_list as $key=>$value)
  2865. {
  2866. $shop = $this->shop->read($value['shop']);
  2867. $info_list[$key]['shop'] = $shop['shopname'];
  2868. $express = $this->express->read($value['express']);
  2869. $info_list[$key]['express'] = $express['servicename'];
  2870. $warehouse = $this->warehouse->read($value['type']);
  2871. $info_list[$key]['type'] = $warehouse['title'];
  2872. if($value['librarytime'] == '0')
  2873. {
  2874. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2875. }
  2876. else
  2877. {
  2878. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2879. }
  2880. }
  2881. $total = $this->$sj->find_count($where);
  2882. $pagenum = ceil($total/$perpage);
  2883. $over = $total-($start+$perpage);
  2884. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2885. echo json_encode($rows);exit;
  2886. }
  2887. $this->data['express'] = $this->express->find_all();
  2888. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2889. $this->data['wlshop'] = $wlshop;
  2890. $user = $this->user->get_api($_SESSION['api']);
  2891. $powerid = $this->power->read($user['power']);
  2892. $powertext = explode('|',trim($powerid['excelid'],'|'));
  2893. $pid = '';
  2894. foreach ($powertext as $v)
  2895. {
  2896. $pid .= " id = ".$v." or";
  2897. }
  2898. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  2899. $this->data['fullorderexcel'] = $fullorderexcel;
  2900. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  2901. $this->data['orderurl'] = $orderurl;
  2902. $this->_Template('whlabel_outorder',$this->data);
  2903. }
  2904. //tt出库
  2905. public function _toutorder()
  2906. {
  2907. if(isset($_SESSION['api']))
  2908. {
  2909. $user = $this->user->get_api($_SESSION['api']);
  2910. $usp = $user;
  2911. $fgshop = "";$sid = "";
  2912. $user = explode('|',trim($user['shop'],'|'));
  2913. foreach ($user as $value)
  2914. {
  2915. $fgshop .= " shop = ".$value." or";
  2916. $sid .= " id = ".$value." or";
  2917. }
  2918. }
  2919. else
  2920. {
  2921. echo "请重新登录";
  2922. }
  2923. $post = $this->input->post(NULL, TRUE);
  2924. if(isset($post['page']))
  2925. {
  2926. $page = $this->input->post('page',true);
  2927. $perpage = $this->input->post('perpage',true);
  2928. $warehouse = $this->input->post('warehouse',true);
  2929. $xztime = $this->input->post('xztime',true);
  2930. $timetk = $this->input->post('timetkk',true);
  2931. $timetj = $this->input->post('timetjj',true);
  2932. $shop = $this->input->post('shop',true);
  2933. $source = $this->input->post('source',true);
  2934. $orderinfo = $this->input->post('orderinfo',true);
  2935. $number = $this->input->post('number',true);
  2936. $sfxh = $this->input->post('sfxh',true);
  2937. $express = $this->input->post('express',true);
  2938. $waybill = $this->input->post('waybill',true);
  2939. $library = $this->input->post('library',true);
  2940. $country = $this->input->post('country',true);
  2941. $so = $this->input->post('so',true);
  2942. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2943. $print = $this->input->post('print',true);
  2944. $state = $this->input->post('state',true);
  2945. $orderurl = $this->input->post('orderurl',true);
  2946. $timetk = strtotime($timetk);
  2947. $timetj = strtotime($timetj);
  2948. /**
  2949. $sj = $this->input->post('sj',true);
  2950. if($sj)
  2951. {
  2952. $sj = $this->input->post('sj',true);
  2953. }
  2954. else
  2955. {
  2956. $sj = "fullorder";
  2957. }
  2958. **/
  2959. $sj = "fullordertt";
  2960. $where = "1=1";
  2961. if($warehouse)
  2962. {
  2963. $where .= " and type = '$warehouse'";
  2964. }
  2965. if($timetk && $timetj)
  2966. {
  2967. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2968. }
  2969. if($orderinfo)
  2970. {
  2971. $where .= " and orderinfo = '$orderinfo'";
  2972. }
  2973. if($number)
  2974. {
  2975. $where .= " and number = '$number'";
  2976. }
  2977. if($express)
  2978. {
  2979. $where .= " and express = '$express'";
  2980. }
  2981. if($waybill)
  2982. {
  2983. $where .= " and waybill = '$waybill'";
  2984. }
  2985. if($library)
  2986. {
  2987. $where .= " and library = '$library'";
  2988. }
  2989. if($print)
  2990. {
  2991. $where .= " and print = '$print'";
  2992. }
  2993. if($libraryconfirm)
  2994. {
  2995. $where .= " and libraryconfirm = '$libraryconfirm'";
  2996. }
  2997. if($state)
  2998. {
  2999. $where .= " and state = '$state'";
  3000. }
  3001. if($shop)
  3002. {
  3003. $where .= " and shop = '$shop'";
  3004. }
  3005. if($country)
  3006. {
  3007. $where .= " and country = '$country'";
  3008. }
  3009. if($sfxh != '')
  3010. {
  3011. $where .= " and sfxh = '$sfxh'";
  3012. }
  3013. if($so)
  3014. {
  3015. $where .= " and shipremarks like '%$so%'";
  3016. }
  3017. if($source)
  3018. {
  3019. if($source == '2d')
  3020. {
  3021. $where .= " and source >= '2'";
  3022. }
  3023. else
  3024. {
  3025. $where .= " and source = '$source'";
  3026. }
  3027. }
  3028. if(isset($_SESSION['api']))
  3029. {
  3030. foreach ($user as $value)
  3031. {
  3032. $fgshop .= " shop = ".$value." or";
  3033. }
  3034. $where .= " and (".rtrim($fgshop,'or').")";
  3035. }
  3036. if($orderurl)
  3037. {
  3038. $url = $this->orderurl->read($orderurl);
  3039. $where .= " and link like '%".$url['url']."%'";
  3040. }
  3041. //数据排序
  3042. $order_str = "librarytime desc";
  3043. if(empty($page))
  3044. {
  3045. $start = 0;
  3046. $perpage = 1;
  3047. }
  3048. else
  3049. {
  3050. $start = ($page - 1)*$perpage;
  3051. }
  3052. //取得信息列表
  3053. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3054. //格式化数据
  3055. foreach ($info_list as $key=>$value)
  3056. {
  3057. $shop = $this->shop->read($value['shop']);
  3058. $info_list[$key]['shop'] = $shop['shopname'];
  3059. $express = $this->express->read($value['express']);
  3060. $info_list[$key]['express'] = $express['servicename'];
  3061. $warehouse = $this->warehouse->read($value['type']);
  3062. $info_list[$key]['type'] = $warehouse['title'];
  3063. if($value['librarytime'] == '0')
  3064. {
  3065. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3066. }
  3067. else
  3068. {
  3069. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3070. }
  3071. }
  3072. $total = $this->$sj->find_count($where);
  3073. $pagenum = ceil($total/$perpage);
  3074. $over = $total-($start+$perpage);
  3075. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3076. echo json_encode($rows);exit;
  3077. }
  3078. $this->data['express'] = $this->express->find_all();
  3079. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3080. $this->data['wlshop'] = $wlshop;
  3081. $user = $this->user->get_api($_SESSION['api']);
  3082. $powerid = $this->power->read($user['power']);
  3083. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3084. $pid = '';
  3085. foreach ($powertext as $v)
  3086. {
  3087. $pid .= " id = ".$v." or";
  3088. }
  3089. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3090. $this->data['fullorderexcel'] = $fullorderexcel;
  3091. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  3092. $this->data['orderurl'] = $orderurl;
  3093. $this->_Template('whlabel_toutorder',$this->data);
  3094. }
  3095. //速卖通出库订单
  3096. public function _soutorder()
  3097. {
  3098. if(isset($_SESSION['api']))
  3099. {
  3100. $user = $this->user->get_api($_SESSION['api']);
  3101. $usp = $user;
  3102. $fgshop = "";$sid = "";
  3103. $user = explode('|',trim($user['shop'],'|'));
  3104. foreach ($user as $value)
  3105. {
  3106. $sid .= " id = ".$value." or";
  3107. }
  3108. }
  3109. $post = $this->input->post(NULL, TRUE);
  3110. if(isset($post['page']))
  3111. {
  3112. $page = $this->input->post('page',true);
  3113. $perpage = $this->input->post('perpage',true);
  3114. $warehouse = $this->input->post('warehouse',true);
  3115. $xztime = $this->input->post('xztime',true);
  3116. $timetk = $this->input->post('timetkk',true);
  3117. $timetj = $this->input->post('timetjj',true);
  3118. $shop = $this->input->post('shop',true);
  3119. $source = $this->input->post('source',true);
  3120. $orderinfo = $this->input->post('orderinfo',true);
  3121. $number = $this->input->post('number',true);
  3122. $express = $this->input->post('express',true);
  3123. $waybill = $this->input->post('waybill',true);
  3124. $library = $this->input->post('library',true);
  3125. $country = $this->input->post('country',true);
  3126. $sfxh = $this->input->post('sfxh',true);
  3127. $libraryconfirm = $this->input->post('libraryconfirm',true);
  3128. $print = $this->input->post('print',true);
  3129. $state = $this->input->post('state',true);
  3130. $so = $this->input->post('so',true);
  3131. $timetk = strtotime($timetk);
  3132. $timetj = strtotime($timetj);
  3133. /**
  3134. $sj = $this->input->post('sj',true);
  3135. if($sj)
  3136. {
  3137. $sj = $this->input->post('sj',true);
  3138. }
  3139. else
  3140. {
  3141. $sj = "fullorder";
  3142. }
  3143. **/
  3144. $sj = "fullordersmt";
  3145. $where = "1=1";
  3146. if($warehouse)
  3147. {
  3148. $where .= " and type = '$warehouse'";
  3149. }
  3150. if($timetk && $timetj)
  3151. {
  3152. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3153. }
  3154. if($orderinfo)
  3155. {
  3156. $where .= " and orderinfo = '$orderinfo'";
  3157. }
  3158. if($number)
  3159. {
  3160. $where .= " and number = '$number'";
  3161. }
  3162. if($express)
  3163. {
  3164. $where .= " and express = '$express'";
  3165. }
  3166. if($waybill)
  3167. {
  3168. $where .= " and waybill = '$waybill'";
  3169. }
  3170. if($library)
  3171. {
  3172. $where .= " and library = '$library'";
  3173. }
  3174. if($print)
  3175. {
  3176. $where .= " and print = '$print'";
  3177. }
  3178. if($libraryconfirm)
  3179. {
  3180. $where .= " and libraryconfirm = '$libraryconfirm'";
  3181. }
  3182. if($state)
  3183. {
  3184. $where .= " and state = '$state'";
  3185. }
  3186. if($shop)
  3187. {
  3188. $where .= " and shop = '$shop'";
  3189. }
  3190. if($sfxh != '')
  3191. {
  3192. $where .= " and sfxh = '$sfxh'";
  3193. }
  3194. if($so)
  3195. {
  3196. $where .= " and shipremarks like '%$so%'";
  3197. }
  3198. if($source)
  3199. {
  3200. $where .= " and source = '$source'";
  3201. }
  3202. if($country)
  3203. {
  3204. $where .= " and country = '$country'";
  3205. }
  3206. else
  3207. {
  3208. if(isset($_SESSION['api']))
  3209. {
  3210. foreach ($user as $value)
  3211. {
  3212. $fgshop .= " shop = ".$value." or";
  3213. }
  3214. $where .= " and (".rtrim($fgshop,'or').")";
  3215. }
  3216. }
  3217. //数据排序
  3218. $order_str = "librarytime desc";
  3219. if(empty($page))
  3220. {
  3221. $start = 0;
  3222. $perpage = 1;
  3223. }
  3224. else
  3225. {
  3226. $start = ($page - 1)*$perpage;
  3227. }
  3228. //取得信息列表
  3229. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3230. //格式化数据
  3231. foreach ($info_list as $key=>$value)
  3232. {
  3233. $shop = $this->shop->read($value['shop']);
  3234. $info_list[$key]['shop'] = $shop['shopname'];
  3235. $express = $this->express->read($value['express']);
  3236. $info_list[$key]['express'] = $express['servicename'];
  3237. $warehouse = $this->warehouse->read($value['type']);
  3238. $info_list[$key]['type'] = $warehouse['title'];
  3239. if($value['librarytime'] == '0')
  3240. {
  3241. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3242. }
  3243. else
  3244. {
  3245. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3246. }
  3247. }
  3248. $total = $this->$sj->find_count($where);
  3249. $pagenum = ceil($total/$perpage);
  3250. $over = $total-($start+$perpage);
  3251. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3252. echo json_encode($rows);exit;
  3253. }
  3254. $this->data['express'] = $this->express->find_all();
  3255. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3256. $this->data['wlshop'] = $wlshop;
  3257. $user = $this->user->get_api($_SESSION['api']);
  3258. $powerid = $this->power->read($user['power']);
  3259. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3260. $pid = '';
  3261. foreach ($powertext as $v)
  3262. {
  3263. $pid .= " id = ".$v." or";
  3264. }
  3265. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3266. $this->data['fullorderexcel'] = $fullorderexcel;
  3267. $this->_Template('whlabel_soutorder',$this->data);
  3268. }
  3269. //订单退库
  3270. public function _retreat()
  3271. {
  3272. $post = $this->input->post(NULL, TRUE);
  3273. if(isset($post['page']))
  3274. {
  3275. $page = $this->input->post('page',true);
  3276. $perpage = $this->input->post('perpage',true);
  3277. $warehouse = $this->input->post('warehouse',true);
  3278. $timetk = $this->input->post('timetk',true);
  3279. $timetj = $this->input->post('timetj',true);
  3280. $shop = $this->input->post('shop',true);
  3281. $source = $this->input->post('source',true);
  3282. $state = $this->input->post('state',true);
  3283. $review = $this->input->post('review',true);
  3284. $state = $this->input->post('state',true);
  3285. $express = $this->input->post('express',true);
  3286. $orderinfo = $this->input->post('orderinfo',true);
  3287. $user = $this->input->post('user',true);
  3288. $name = $this->input->post('name',true);
  3289. $waybill = $this->input->post('waybill',true);
  3290. $timetk = strtotime($timetk);
  3291. $timetj = strtotime($timetj);
  3292. $where = "(state=206 or state=210) and mergeid = 0";
  3293. if($warehouse)
  3294. {
  3295. $where .= " and state = '$warehouse'";
  3296. }
  3297. if($timetk && $timetj)
  3298. {
  3299. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3300. }
  3301. if($shop)
  3302. {
  3303. $where .= " and shop = '$shop'";
  3304. }
  3305. if($source)
  3306. {
  3307. $where .= " and source = '$source'";
  3308. }
  3309. if($state)
  3310. {
  3311. $where .= " and state = '$state'";
  3312. }
  3313. if($review)
  3314. {
  3315. $where .= " and review = '$review'";
  3316. }
  3317. if($state)
  3318. {
  3319. $where .= " and state = '$state'";
  3320. }
  3321. if($express)
  3322. {
  3323. $where .= " and express = '$express'";
  3324. }
  3325. if($orderinfo)
  3326. {
  3327. $where .= " and orderinfo = '$orderinfo'";
  3328. }
  3329. if($user)
  3330. {
  3331. $where .= " and user = '$user'";
  3332. }
  3333. if($name)
  3334. {
  3335. $where .= " and name = '$name'";
  3336. }
  3337. if($waybill)
  3338. {
  3339. $where .= " and waybill = '$waybill'";
  3340. }
  3341. //数据排序
  3342. $order_str = "id desc";
  3343. if(empty($page))
  3344. {
  3345. $start = 0;
  3346. $perpage = 1;
  3347. }
  3348. else
  3349. {
  3350. $start = ($page - 1)*$perpage;
  3351. }
  3352. //取得信息列表
  3353. $info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
  3354. //格式化数据
  3355. foreach ($info_list as $key=>$value)
  3356. {
  3357. $shop = $this->shop->read($value['shop']);
  3358. $info_list[$key]['shop'] = $shop['shopname'];
  3359. $warehouse = $this->warehouse->read($value['warehouse']);
  3360. $info_list[$key]['warehouse'] = $warehouse['title'];
  3361. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/".$value['id']."'>".$value['orderinfo']."</a>";
  3362. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  3363. if($value['waybill'] == 0)
  3364. {
  3365. $info_list[$key]['waybill'] = "";
  3366. }
  3367. $express = $this->express->read($value['express']);
  3368. $info_list[$key]['express'] = $express['title'];
  3369. $typeclass = $this->typeclass->read($value['state']);
  3370. $info_list[$key]['state'] = $typeclass['title'];
  3371. }
  3372. $total = $this->fullorder->find_count($where);
  3373. $pagenum = ceil($total/$perpage);
  3374. $over = $total-($start+$perpage);
  3375. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3376. echo json_encode($rows);exit;
  3377. }
  3378. $this->data['express'] = $this->express->find_all();
  3379. $this->_Template('whlabel_retreat',$this->data);
  3380. }
  3381. //退库标签浏览
  3382. public function _retreatlk()
  3383. {
  3384. $post = $this->input->post(NULL, TRUE);
  3385. if(isset($post['page']))
  3386. {
  3387. $page = $this->input->post('page',true);
  3388. $perpage = $this->input->post('perpage',true);
  3389. $timetk = $this->input->post('timetk',true);
  3390. $timetj = $this->input->post('timetj',true);
  3391. $sku = $this->input->post('sku',true);
  3392. $warehouse = $this->input->post('warehouse',true);
  3393. $purchase = $this->input->post('purchase',true);
  3394. $orderinfo = $this->input->post('orderinfo',true);
  3395. $waybill = $this->input->post('waybill',true);
  3396. $category = $this->input->post('category',true);
  3397. $size = $this->input->post('size',true);
  3398. $grade = $this->input->post('grade',true);
  3399. $color = $this->input->post('color',true);
  3400. $lowe = $this->input->post('lowe',true);
  3401. $state = $this->input->post('state',true);
  3402. $timetk = strtotime($timetk);
  3403. $timetj = strtotime($timetj);
  3404. $where = "state=2";
  3405. if($timetk && $timetj)
  3406. {
  3407. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3408. }
  3409. if($sku)
  3410. {
  3411. $where .= " and sku = '$sku'";
  3412. }
  3413. if($warehouse)
  3414. {
  3415. $where .= " and warehouse = '$warehouse'";
  3416. }
  3417. if($purchase)
  3418. {
  3419. $where .= " and purchase = '$purchase'";
  3420. }
  3421. if($orderinfo)
  3422. {
  3423. $where .= " and orderinfo = '$orderinfo'";
  3424. }
  3425. if($waybill)
  3426. {
  3427. $where .= " and waybill = '$waybill'";
  3428. }
  3429. if($category)
  3430. {
  3431. $where .= " and features like '%-$category-%'";
  3432. }
  3433. if($size)
  3434. {
  3435. $where .= " and features like '%-$size-%'";
  3436. }
  3437. if($grade)
  3438. {
  3439. $where .= " and features like '%-$grade-%'";
  3440. }
  3441. if($color)
  3442. {
  3443. $where .= " and features like '%-$color-%'";
  3444. }
  3445. if($lowe)
  3446. {
  3447. $where .= " and features like '%-$lowe-%'";
  3448. }
  3449. //数据排序
  3450. $order_str = "time desc";
  3451. if(empty($page))
  3452. {
  3453. $start = 0;
  3454. $perpage = 1;
  3455. }
  3456. else
  3457. {
  3458. $start = ($page - 1)*$perpage;
  3459. }
  3460. //取得信息列表
  3461. $info_list = $this->whlabel->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
  3462. foreach ($info_list as $key=>$value)
  3463. {
  3464. $warehouse = $this->warehouse->read($value['warehouse']);
  3465. $info_list[$key]['warehouse'] = $warehouse['title'];
  3466. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3467. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3468. $purchase = $this->purchase->read($value['purchase']);
  3469. $info_list[$key]['purchase'] = $purchase['title'];
  3470. if($value['outk'] != 0)
  3471. {
  3472. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  3473. }
  3474. else
  3475. {
  3476. $info_list[$key]['outk'] = "";
  3477. }
  3478. if($value['retreat'] != 0)
  3479. {
  3480. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
  3481. }
  3482. else
  3483. {
  3484. $info_list[$key]['retreat'] = "";
  3485. }
  3486. if($value['orderinfo'] == 0)
  3487. {
  3488. $info_list[$key]['orderinfo'] = "";
  3489. }
  3490. if($value['waybill'] == 0)
  3491. {
  3492. $info_list[$key]['waybill'] = "";
  3493. }
  3494. }
  3495. $total = $this->whlabel->find_count($where);
  3496. $pagenum = ceil($total/$perpage);
  3497. $over = $total-($start+$perpage);
  3498. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3499. echo json_encode($rows);exit;
  3500. }
  3501. $this->_Template('whlabel_retreatlk',$this->data);
  3502. }
  3503. //更换标签及浏览
  3504. public function _change()
  3505. {
  3506. $post = $this->input->post(NULL, TRUE);
  3507. if(isset($post['page']))
  3508. {
  3509. $page = $this->input->post('page',true);
  3510. $perpage = $this->input->post('perpage',true);
  3511. $timetk = $this->input->post('timetk',true);
  3512. $timetj = $this->input->post('timetj',true);
  3513. $label = $this->input->post('label',true);
  3514. $oldlabel = $this->input->post('oldlabel',true);
  3515. $timetk = strtotime($timetk);
  3516. $timetj = strtotime($timetj);
  3517. $where = "state=10 ";
  3518. if($timetk && $timetj)
  3519. {
  3520. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3521. }
  3522. if($label)
  3523. {
  3524. $where .= " and label = '$label'";
  3525. }
  3526. if($oldlabel)
  3527. {
  3528. $where .= " and oldlabel = '$oldlabel'";
  3529. }
  3530. //数据排序
  3531. $order_str = "time asc";
  3532. if(empty($page))
  3533. {
  3534. $start = 0;
  3535. $perpage = 1;
  3536. }
  3537. else
  3538. {
  3539. $start = ($page - 1)*$perpage;
  3540. }
  3541. //取得信息列表
  3542. $info_list = $this->whlabel->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
  3543. foreach ($info_list as $key=>$value)
  3544. {
  3545. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
  3546. }
  3547. $total = $this->whlabel->find_count($where);
  3548. $pagenum = ceil($total/$perpage);
  3549. $over = $total-($start+$perpage);
  3550. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3551. echo json_encode($rows);exit;
  3552. }
  3553. $this->_Template('whlabel_change',$this->data);
  3554. }
  3555. //产品标签
  3556. public function _cpbqdc()
  3557. {
  3558. if(isset($_GET['excel']))
  3559. {
  3560. $where = "1=1";
  3561. //数据排序
  3562. $order_str = "id desc";
  3563. if(empty($page))
  3564. {
  3565. $start = 0;
  3566. $perpage = 1;
  3567. }
  3568. else
  3569. {
  3570. $start = ($page - 1)*$perpage;
  3571. }
  3572. $warehouse = $this->input->get('warehouse',true);
  3573. $state = $this->input->get('state',true);
  3574. $timetk = $this->input->get('timetkk',true);
  3575. $timetj = $this->input->get('timetjj',true);
  3576. $timetk = strtotime($timetk);
  3577. $timetj = strtotime($timetj);
  3578. if($warehouse)
  3579. {
  3580. $where .= " and warehouse = '$warehouse'";
  3581. }
  3582. if($state || $state == 0)
  3583. {
  3584. $where .= " and state = '$state'";
  3585. }
  3586. if($timetk && $timetj)
  3587. {
  3588. $where .= " and time > '$timetk' and time < '$timetj'";
  3589. }
  3590. //取得信息列表
  3591. $info_list = $this->whlabel->find_all($where,'*');
  3592. $rows = array();$list = array();
  3593. foreach ($info_list as $key=>$value)
  3594. {
  3595. $rows[$value['time']] = $value;//所有数据sku
  3596. }
  3597. foreach ($rows as $value)
  3598. {
  3599. $warehouse = $this->warehouse->read($value['warehouse']);
  3600. $s = $this->whlabel->find_count($where.' and time = "'.$value['time'].'"');
  3601. $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);
  3602. }
  3603. $title = "产品标签统计表";
  3604. $titlename = "<table border=1>
  3605. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  3606. <tr align='center'>
  3607. <td>仓库</td>
  3608. <td>SKU</td>
  3609. <td>产品</td>
  3610. <td>入库时间</td>
  3611. <td>操作时间</td>
  3612. <td>备注</td>
  3613. <td>数量</td>
  3614. </tr>
  3615. </table>";
  3616. $filename = $title.".xls";
  3617. $tail = "";
  3618. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3619. }
  3620. }
  3621. //进销存导出
  3622. public function _exceljxc()
  3623. {
  3624. $classid = $this->classid->sku();
  3625. $pm = $classid;
  3626. $typeclass = array();
  3627. $tc = $this->typeclass->find_all();
  3628. foreach ($tc as $v)
  3629. {
  3630. $typeclass[$v['id']] = $v;
  3631. }
  3632. $prc = array();
  3633. $purchase = $this->purchase->find_all();
  3634. foreach($purchase as $k=>$v)
  3635. {
  3636. $prc[$v['id']] = $v['title'];
  3637. }
  3638. if(isset($_GET['excel']))
  3639. {
  3640. $where = "sku != 'Preset'";
  3641. //数据排序
  3642. $order_str = "id desc";
  3643. if(empty($page))
  3644. {
  3645. $start = 0;
  3646. $perpage = 1;
  3647. }
  3648. else
  3649. {
  3650. $start = ($page - 1)*$perpage;
  3651. }
  3652. $category = $this->input->get('category',true);
  3653. $warehouse = $this->input->get('warehouse',true);
  3654. $excelid = $this->input->get('sid',true);
  3655. if($category)
  3656. {
  3657. $where .= " and features like '%-$category-%'";
  3658. }
  3659. if($warehouse)
  3660. {
  3661. $where .= " and warehouse = '$warehouse'";
  3662. }
  3663. $xzid = '';
  3664. if($excelid)
  3665. {
  3666. $excelid = explode(',',trim($excelid,','));
  3667. foreach ($excelid as $key=>$value)
  3668. {
  3669. $xzid .= " id = ".$value." or";
  3670. }
  3671. $xzid = " and (".rtrim($xzid,'or').")";;
  3672. }
  3673. //取得信息列表
  3674. /**
  3675. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3676. $rows = array();$list = array();
  3677. foreach ($info_list as $key=>$value)
  3678. {
  3679. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3680. }
  3681. **/
  3682. $wt = array();
  3683. $whlabel_type = $this->whlabel_type->find_all();
  3684. foreach ($whlabel_type as $v)
  3685. {
  3686. $wt[$v['id']] = $v['title'];
  3687. }
  3688. $wh = array();
  3689. $w = $this->warehouse->find_all('1=1','id,title');
  3690. foreach ($w as $v)
  3691. {
  3692. $wh[$v['id']] = $v['title'];
  3693. }
  3694. $list = array();
  3695. $rows = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3696. foreach ($rows as $key=>$value)
  3697. {
  3698. if(isset($wt[$value['type']]))
  3699. {
  3700. $rows[$key]['type'] = $wt[$value['type']];
  3701. }
  3702. else
  3703. {
  3704. $rows[$key]['type'] = '未设置';
  3705. }
  3706. $bm = '03';
  3707. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  3708. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  3709. $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');
  3710. $details = array();
  3711. $cpid = array();
  3712. $cpbz = array();
  3713. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  3714. foreach ($sd as $k=>$v)
  3715. {
  3716. if($v['state'] == 0)
  3717. {
  3718. $c++;
  3719. if($v['cpid'] != 0)
  3720. {
  3721. $cpid[$v['cpid']] = $v['cpid'];
  3722. }
  3723. if($v['cpbz'] != '')
  3724. {
  3725. $cpbz[$v['cpbz']] = $v['cpbz'];
  3726. }
  3727. }
  3728. if($v['state'] != 9)
  3729. {
  3730. $g++;
  3731. }
  3732. if($v['state'] == 1)
  3733. {
  3734. $x++;
  3735. }
  3736. if($v['state'] == 2)
  3737. {
  3738. $t++;
  3739. }
  3740. if($v['state'] == 8)
  3741. {
  3742. $s++;
  3743. }
  3744. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  3745. {
  3746. $q++;
  3747. }
  3748. $details[$v['details']] = $v['details'];
  3749. }
  3750. $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'].'"');
  3751. $rows[$key]['details'] = implode("、",$details);
  3752. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  3753. $number = $value['number'];
  3754. $ftime = time()-15*24*3600;
  3755. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3756. $rows[$key]['number'] = $g;
  3757. $rows[$key]['c'] = $c;
  3758. $rows[$key]['x'] = $x;
  3759. $rows[$key]['t'] = $t;
  3760. $rows[$key]['s'] = $s;
  3761. $rows[$key]['q'] = $q;
  3762. $rows[$key]['z'] = $z;
  3763. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  3764. $features = explode('-',trim($features,'-'));
  3765. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3766. $pm = $classid;
  3767. $jm = $classid;
  3768. foreach($features as $k=>$v)
  3769. {
  3770. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3771. {
  3772. if($typeclass[$v]['bm'] != '')
  3773. {
  3774. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3775. }
  3776. }
  3777. if($v != 0)
  3778. {
  3779. if(!isset($typeclass[$v]))
  3780. {
  3781. continue;
  3782. }
  3783. if(isset($pm[$typeclass[$v]['classid']]))
  3784. {
  3785. if(stripos($typeclass[$v]['zh'],'|') !== false)
  3786. {
  3787. $tz = explode('|',$typeclass[$v]['zh']);
  3788. $pm[$typeclass[$v]['classid']] = $tz[0];
  3789. }
  3790. else
  3791. {
  3792. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3793. }
  3794. }
  3795. if(isset($jm[$typeclass[$v]['classid']]))
  3796. {
  3797. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3798. }
  3799. }
  3800. }
  3801. $jm = array_filter($jm);
  3802. $rows[$key]['bs'] = implode("-",$jm);
  3803. $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3804. $zh = implode(" ",$pm);
  3805. $zh = str_replace('自然色 ','',trim($zh,' '));
  3806. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3807. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3808. $rows[$key]['features'] = $zh;
  3809. }
  3810. $title = "总进销存统计表";
  3811. $titlename = "<table border=1>
  3812. <tr><th colspan='20' align='center'><h3>".$title."<h3></th></tr>
  3813. <tr align='center'>
  3814. <td>仓库</td>
  3815. <td>供应商</td>
  3816. <td>位置</td>
  3817. <td>库存编码</td>
  3818. <td>类目</td>
  3819. <td>SKU</td>
  3820. <td>用友编码</td>
  3821. <td>用友料号</td>
  3822. <td>商品名称</td>
  3823. <td>商品中文</td>
  3824. <td>产品备注</td>
  3825. <td>说明</td>
  3826. <td>类型</td>
  3827. <td>入库总量</td>
  3828. <td>库存数量</td>
  3829. <td>销售数量</td>
  3830. <td>退货数量</td>
  3831. <td>删除数量</td>
  3832. <td>其它操作</td>
  3833. <td>占单数量</td>
  3834. </tr>
  3835. </table>";
  3836. $filename = $title.".xls";
  3837. $tail = "";
  3838. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  3839. }
  3840. }
  3841. //入库导出
  3842. public function _excelr()
  3843. {
  3844. if(isset($_GET['excel']))
  3845. {
  3846. $category = $this->input->get('category',true);
  3847. $size = $this->input->get('size',true);
  3848. $grade = $this->input->get('grade',true);
  3849. $color = $this->input->get('color',true);
  3850. $lowe = $this->input->get('lowe',true);
  3851. $sku = $this->input->get('sku',true);
  3852. $warehouse = $this->input->get('warehouse',true);
  3853. $purchase = $this->input->get('purchase',true);
  3854. $ktime = $this->input->get('ktime',true);
  3855. $jtime = $this->input->get('jtime',true);
  3856. $ktime = strtotime($ktime);
  3857. $jtime = strtotime($jtime);
  3858. $where = "1=1";$gj = "";$ck = "";
  3859. if($category)
  3860. {
  3861. $where .= " and features like '%-$category-%'";
  3862. }
  3863. if($size)
  3864. {
  3865. $where .= " and features like '%-$size-%'";
  3866. }
  3867. if($grade)
  3868. {
  3869. $where .= " and features like '%-$grade-%'";
  3870. }
  3871. if($color)
  3872. {
  3873. $where .= " and features like '%-$color-%'";
  3874. }
  3875. if($lowe)
  3876. {
  3877. $where .= " and features like '%-$lowe-%'";
  3878. }
  3879. if($warehouse)
  3880. {
  3881. $where .= " and warehouse = '$warehouse'";
  3882. }
  3883. if($purchase)
  3884. {
  3885. $where .= " and purchase = '$purchase'";
  3886. }
  3887. if($sku)
  3888. {
  3889. $where .= " and sku = '$sku'";
  3890. }
  3891. if($ktime && $jtime)
  3892. {
  3893. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3894. }
  3895. //数据排序
  3896. $order_str = "id desc";
  3897. if(empty($page))
  3898. {
  3899. $start = 0;
  3900. $perpage = 1;
  3901. }
  3902. else
  3903. {
  3904. $start = ($page - 1)*$perpage;
  3905. }
  3906. $list = array();
  3907. $rows = $this->whlabel->find_pc($where,'enter,sku,warehouse','*',$order_str);
  3908. foreach ($rows as $value)
  3909. {
  3910. $ck = $this->warehouse->read($value['warehouse']);
  3911. $warehouse = $ck['title'];
  3912. $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
  3913. $retreatwarehouse = $tkck['title'];
  3914. $gy = $this->purchase->read($value['purchase']);
  3915. $purchase = $gy['title'];
  3916. $g = $this->whlabel->find_count($where.' and enter = "'.$value['enter'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'"');
  3917. $list[] = array('warehouse'=>$warehouse,'sku'=>$value['sku'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
  3918. }
  3919. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
  3920. $titlename = "<table border=1>
  3921. <tr><th colspan='5' align='center'><h3>".$title."<h3></th></tr>
  3922. <tr align='center'>
  3923. <td>仓库</td>
  3924. <td>SKU</td>
  3925. <td>产品</td>
  3926. <td>时间</td>
  3927. <td>数量</td>
  3928. </tr>
  3929. </table>";
  3930. $filename = $title.".xls";
  3931. $tail = "";
  3932. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3933. }
  3934. }
  3935. //出库、退库导出
  3936. public function _excelct()
  3937. {
  3938. $classid = $this->classid->sku();
  3939. $pm = $classid;
  3940. $typeclass = array();
  3941. $tc = $this->typeclass->find_all();
  3942. foreach ($tc as $v)
  3943. {
  3944. $typeclass[$v['id']] = $v;
  3945. }
  3946. $prc = array();
  3947. $purchase = $this->purchase->find_all();
  3948. foreach($purchase as $k=>$v)
  3949. {
  3950. $prc[$v['id']] = $v['title'];
  3951. }
  3952. if(isset($_GET['excel']))
  3953. {
  3954. $wh = array();
  3955. $w = $this->warehouse->find_all('1=1','id,title');
  3956. foreach ($w as $v)
  3957. {
  3958. $wh[$v['id']] = $v['title'];
  3959. }
  3960. $type = $this->input->get('excel',true);
  3961. $category = $this->input->get('category',true);
  3962. $size = $this->input->get('size',true);
  3963. $grade = $this->input->get('grade',true);
  3964. $color = $this->input->get('color',true);
  3965. $lowe = $this->input->get('lowe',true);
  3966. $sku = $this->input->get('sku',true);
  3967. $warehouse = $this->input->get('warehouse',true);
  3968. $lacetype = $this->input->get('lacetype',true);
  3969. $lacecolor = $this->input->get('lacecolor',true);
  3970. $density = $this->input->get('density',true);
  3971. $haircap = $this->input->get('haircap',true);
  3972. $purchase = $this->input->get('purchase',true);
  3973. $title = $this->input->get('title',true);
  3974. $state = $this->input->get('state',true);
  3975. $sid = $this->input->get('sid',true);
  3976. $ktime = $this->input->get('ktime',true);
  3977. $jtime = $this->input->get('jtime',true);
  3978. $ktime = strtotime($ktime);
  3979. $jtime = strtotime($jtime);
  3980. $where = "1=1";$gj = "";$ck = "";
  3981. if($category)
  3982. {
  3983. $where .= " and features like '%-$category-%'";
  3984. }
  3985. if($size)
  3986. {
  3987. $where .= " and features like '%-$size-%'";
  3988. }
  3989. if($grade)
  3990. {
  3991. $where .= " and features like '%-$grade-%'";
  3992. }
  3993. if($color)
  3994. {
  3995. $where .= " and features like '%-$color-%'";
  3996. }
  3997. if($lowe)
  3998. {
  3999. $where .= " and features like '%-$lowe-%'";
  4000. }
  4001. if($warehouse)
  4002. {
  4003. $where .= " and warehouse = '$warehouse'";
  4004. }
  4005. if($purchase)
  4006. {
  4007. $where .= " and purchase = '$purchase'";
  4008. }
  4009. if($state)
  4010. {
  4011. $where .= " and state = '$state'";
  4012. }
  4013. if($lacetype)
  4014. {
  4015. $where .= " and features like '%-$lacetype-%'";
  4016. }
  4017. if($lacecolor)
  4018. {
  4019. $where .= " and features like '%-$lacecolor-%'";
  4020. }
  4021. if($density)
  4022. {
  4023. $where .= " and features like '%-$density-%'";
  4024. }
  4025. if($haircap)
  4026. {
  4027. $where .= " and features like '%-$haircap-%'";
  4028. }
  4029. if($title)
  4030. {
  4031. $title = trim($title,' ');
  4032. $title = trim($title,' ');
  4033. $where .= " and title like '%$title%'";
  4034. }
  4035. if($sku)
  4036. {
  4037. $sku = trim($sku,' ');
  4038. $sku = trim($sku,' ');
  4039. $where .= " and sku like '%$sku%'";
  4040. }
  4041. if($ktime && $jtime)
  4042. {
  4043. if($type == 1)
  4044. {
  4045. $tl = '出库';
  4046. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4047. }
  4048. else if($type == 2)
  4049. {
  4050. $tl = '退库';
  4051. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4052. }
  4053. else if($type == 3)
  4054. {
  4055. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4056. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4057. }
  4058. else if($type == 4)
  4059. {
  4060. $tl = '出库+零售';
  4061. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4062. }
  4063. else if($type == 5)
  4064. {
  4065. $tl = '零售';
  4066. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4067. }
  4068. }
  4069. $sidwhere = '';
  4070. if($sid)
  4071. {
  4072. $sd = "";
  4073. $s = explode(',',trim($sid,','));
  4074. foreach ($s as $value)
  4075. {
  4076. $sd .= " id = ".$value." or";
  4077. }
  4078. $sidwhere = " and (".rtrim($sd,'or').")";
  4079. }
  4080. //数据排序
  4081. $order_str = "time desc";
  4082. if(empty($page))
  4083. {
  4084. $start = 0;
  4085. $perpage = 1;
  4086. }
  4087. else
  4088. {
  4089. $start = ($page - 1)*$perpage;
  4090. }
  4091. //取得信息列表
  4092. if($type != 3 && $type != 5)
  4093. {
  4094. if($type == 1 || $type == 4)
  4095. {
  4096. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk',$order_str);
  4097. foreach ($info_list as $key=>$value)
  4098. {
  4099. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4100. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4101. $warehouse = $this->warehouse->read($value['warehouse']);
  4102. $info_list[$key]['warehouse'] = $warehouse['title'];
  4103. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4104. $features = explode('-',trim($features,'-'));
  4105. $pm = $classid;
  4106. foreach($features as $k=>$v)
  4107. {
  4108. if($v != 0)
  4109. {
  4110. if(!isset($typeclass[$v]))
  4111. {
  4112. continue;
  4113. }
  4114. if(isset($pm[$typeclass[$v]['classid']]))
  4115. {
  4116. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4117. {
  4118. $tz = explode('|',$typeclass[$v]['zh']);
  4119. $pm[$typeclass[$v]['classid']] = $tz[0];
  4120. }
  4121. else
  4122. {
  4123. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4124. }
  4125. }
  4126. }
  4127. }
  4128. $zh = implode(" ",$pm);
  4129. $zh = str_replace('自然色 ','',trim($zh,' '));
  4130. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4131. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4132. $info_list[$key]['features'] = $zh;
  4133. }
  4134. }
  4135. else
  4136. {
  4137. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat',$order_str);
  4138. foreach ($info_list as $key=>$value)
  4139. {
  4140. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4141. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
  4142. $warehouse = $this->warehouse->read($value['warehouse']);
  4143. $info_list[$key]['warehouse'] = $warehouse['title'];
  4144. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4145. $features = explode('-',trim($features,'-'));
  4146. $pm = $classid;
  4147. foreach($features as $k=>$v)
  4148. {
  4149. if($v != 0)
  4150. {
  4151. if(!isset($typeclass[$v]))
  4152. {
  4153. continue;
  4154. }
  4155. if(isset($pm[$typeclass[$v]['classid']]))
  4156. {
  4157. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4158. {
  4159. $tz = explode('|',$typeclass[$v]['zh']);
  4160. $pm[$typeclass[$v]['classid']] = $tz[0];
  4161. }
  4162. else
  4163. {
  4164. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4165. }
  4166. }
  4167. }
  4168. }
  4169. $zh = implode(" ",$pm);
  4170. $zh = str_replace('自然色 ','',trim($zh,' '));
  4171. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4172. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4173. $info_list[$key]['features'] = $zh;
  4174. }
  4175. }
  4176. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4177. $titlename = "<table border=1>
  4178. <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
  4179. <tr align='center'>
  4180. <td>仓库</td>
  4181. <td>供应商</td>
  4182. <td>SKU</td>
  4183. <td>商品名称</td>
  4184. <td>商品中文</td>
  4185. <td>标签</td>
  4186. <td>订单号</td>
  4187. <td>运单号</td>
  4188. <td>".$tl."时间(中国时间)</td>
  4189. </tr>
  4190. </table>";
  4191. $filename = $title.".xls";
  4192. $tail = "";
  4193. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4194. }
  4195. else if($type == 5)
  4196. {
  4197. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,outk',$order_str);
  4198. foreach ($info_list as $key=>$value)
  4199. {
  4200. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4201. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4202. $warehouse = $this->warehouse->read($value['warehouse']);
  4203. $info_list[$key]['warehouse'] = $warehouse['title'];
  4204. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4205. $features = explode('-',trim($features,'-'));
  4206. $pm = $classid;
  4207. foreach($features as $k=>$v)
  4208. {
  4209. if($v != 0)
  4210. {
  4211. if(!isset($typeclass[$v]))
  4212. {
  4213. continue;
  4214. }
  4215. if(isset($pm[$typeclass[$v]['classid']]))
  4216. {
  4217. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4218. {
  4219. $tz = explode('|',$typeclass[$v]['zh']);
  4220. $pm[$typeclass[$v]['classid']] = $tz[0];
  4221. }
  4222. else
  4223. {
  4224. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4225. }
  4226. }
  4227. }
  4228. }
  4229. $zh = implode(" ",$pm);
  4230. $zh = str_replace('自然色 ','',trim($zh,' '));
  4231. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4232. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4233. $info_list[$key]['features'] = $zh;
  4234. }
  4235. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4236. $titlename = "<table border=1>
  4237. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  4238. <tr align='center'>
  4239. <td>仓库</td>
  4240. <td>供应商</td>
  4241. <td>SKU</td>
  4242. <td>商品名称</td>
  4243. <td>商品中文</td>
  4244. <td>标签</td>
  4245. <td>".$tl."时间(中国时间)</td>
  4246. </tr>
  4247. </table>";
  4248. $filename = $title.".xls";
  4249. $tail = "";
  4250. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4251. }
  4252. else
  4253. {
  4254. /**
  4255. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4256. $rows = array();$list = array();
  4257. foreach ($info_list as $key=>$value)
  4258. {
  4259. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4260. }
  4261. **/
  4262. $wh = array();
  4263. $w = $this->warehouse->find_all('1=1','id,title');
  4264. foreach ($w as $v)
  4265. {
  4266. $wh[$v['id']] = $v['title'];
  4267. }
  4268. $wt = array();
  4269. $whlabel_type = $this->whlabel_type->find_all();
  4270. foreach ($whlabel_type as $v)
  4271. {
  4272. $wt[$v['id']] = $v['title'];
  4273. }
  4274. $classid = $this->classid->sku();
  4275. $list = array();
  4276. $rows = $this->whlabel->find_pc($where.$sidwhere,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4277. foreach ($rows as $key=>$value)
  4278. {
  4279. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4280. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4281. $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');
  4282. $details = array();
  4283. $cpid = array();
  4284. $cpbz = array();
  4285. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  4286. foreach ($sd as $k=>$v)
  4287. {
  4288. if($v['state'] == 0)
  4289. {
  4290. $c++;
  4291. }
  4292. if($v['state'] != 9)
  4293. {
  4294. $g++;
  4295. }
  4296. if($v['outk'] > 1)
  4297. {
  4298. $x++;
  4299. }
  4300. if($v['retreat'] > 0)
  4301. {
  4302. $t++;
  4303. }
  4304. if($v['state'] == 8)
  4305. {
  4306. $s++;
  4307. }
  4308. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  4309. {
  4310. $q++;
  4311. }
  4312. $details[$v['details']] = $v['details'];
  4313. if($v['cpid'] != 0)
  4314. {
  4315. $cpid[$v['cpid']] = $v['cpid'];
  4316. }
  4317. if($v['cpbz'] != '')
  4318. {
  4319. $cpbz[$v['cpbz']] = $v['cpbz'];
  4320. }
  4321. }
  4322. if(isset($wt[$value['type']]))
  4323. {
  4324. $rows[$key]['type'] = $wt[$value['type']];
  4325. }
  4326. else
  4327. {
  4328. $rows[$key]['type'] = '未设置';
  4329. }
  4330. $rows[$key]['details'] = implode("、",$details);
  4331. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4332. $ftime = time()-15*24*3600;
  4333. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4334. $rows[$key]['cpbz'] = ($cpbz)?implode(" ",$cpbz):'';
  4335. $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);
  4336. $rows[$key]['c'] = $c;
  4337. $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);
  4338. $rows[$key]['t'] = $t;
  4339. $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'].'"');
  4340. $rows[$key]['z'] = $z;
  4341. $jm = $classid;
  4342. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4343. $features = explode('-',trim($features,'-'));
  4344. $pm = $classid;
  4345. foreach($features as $k=>$v)
  4346. {
  4347. if($v != 0)
  4348. {
  4349. if(!isset($typeclass[$v]))
  4350. {
  4351. continue;
  4352. }
  4353. if(isset($pm[$typeclass[$v]['classid']]))
  4354. {
  4355. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4356. {
  4357. $tz = explode('|',$typeclass[$v]['zh']);
  4358. $pm[$typeclass[$v]['classid']] = $tz[0];
  4359. }
  4360. else
  4361. {
  4362. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4363. }
  4364. if(isset($jm[$typeclass[$v]['classid']]))
  4365. {
  4366. if($typeclass[$v]['jm'])
  4367. {
  4368. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4369. }
  4370. }
  4371. }
  4372. }
  4373. }
  4374. $zh = implode(" ",$pm);
  4375. $zh = str_replace('自然色 ','',trim($zh,' '));
  4376. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4377. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4378. $rows[$key]['features'] = $zh;
  4379. $jm = array_filter($jm);//去除空值
  4380. $jm = implode("-",$jm);
  4381. $rows[$key]['jm'] = $jm;
  4382. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4383. }
  4384. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
  4385. $titlename = "<table border=1>
  4386. <tr><th colspan='17' align='center'><h3>".$title."<h3></th></tr>
  4387. <tr align='center'>
  4388. <td>仓库</td>
  4389. <td>供应商</td>
  4390. <td>位置</td>
  4391. <td>库存编码</td>
  4392. <td>SKU</td>
  4393. <td>商品名称</td>
  4394. <td>商品中文</td>
  4395. <td>产品备注</td>
  4396. <td>说明</td>
  4397. <td>类型</td>
  4398. <td>入库总量</td>
  4399. <td>库存数量</td>
  4400. <td>销售数量</td>
  4401. <td>退货数量</td>
  4402. <td>占单数量</td>
  4403. <td>料号</td>
  4404. <td>类目</td>
  4405. </tr>
  4406. </table>";
  4407. $filename = $title.".xls";
  4408. $tail = "";
  4409. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  4410. }
  4411. }
  4412. }
  4413. //出库+入库数据整合
  4414. public function _excelcr()
  4415. {
  4416. if(isset($_GET['excel']))
  4417. {
  4418. $type = $this->input->get('excel',true);
  4419. $category = $this->input->get('category',true);
  4420. $size = $this->input->get('size',true);
  4421. $grade = $this->input->get('grade',true);
  4422. $color = $this->input->get('color',true);
  4423. $lowe = $this->input->get('lowe',true);
  4424. $sku = $this->input->get('sku',true);
  4425. $warehouse = $this->input->get('warehouse',true);
  4426. $purchase = $this->input->get('purchase',true);
  4427. $state = $this->input->get('state',true);
  4428. $sid = $this->input->get('sid',true);
  4429. $ktime = $this->input->get('ktime',true);
  4430. $jtime = $this->input->get('jtime',true);
  4431. $ktime = strtotime($ktime);
  4432. $jtime = strtotime($jtime);
  4433. $where = "1=1";$gj = "";$ck = "";
  4434. if($category)
  4435. {
  4436. $where .= " and features like '%-$category-%'";
  4437. }
  4438. if($size)
  4439. {
  4440. $where .= " and features like '%-$size-%'";
  4441. }
  4442. if($grade)
  4443. {
  4444. $where .= " and features like '%-$grade-%'";
  4445. }
  4446. if($color)
  4447. {
  4448. $where .= " and features like '%-$color-%'";
  4449. }
  4450. if($lowe)
  4451. {
  4452. $where .= " and features like '%-$lowe-%'";
  4453. }
  4454. if($warehouse)
  4455. {
  4456. $where .= " and warehouse = '$warehouse'";
  4457. }
  4458. if($purchase)
  4459. {
  4460. $where .= " and purchase = '$purchase'";
  4461. }
  4462. if($state)
  4463. {
  4464. $where .= " and state = '$state'";
  4465. }
  4466. if($sku)
  4467. {
  4468. $where .= " and sku like '%$sku%'";
  4469. }
  4470. if($ktime && $jtime)
  4471. {
  4472. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4473. }
  4474. $sidwhere = '';
  4475. if($sid)
  4476. {
  4477. $sd = "";
  4478. $s = explode(',',trim($sid,','));
  4479. foreach ($s as $value)
  4480. {
  4481. $sd .= " id = ".$value." or";
  4482. }
  4483. $sidwhere .= " and (".rtrim($sd,'or').")";
  4484. }
  4485. //取得信息列表
  4486. $timeread = $ktime;
  4487. $timenum = ceil(($jtime - $ktime) / (24*3600));
  4488. $timelist = array();
  4489. for($i=0;$i<$timenum;$i++)
  4490. {
  4491. $timeread = ($i>0)?$ktime+$i*24*3600:$ktime;
  4492. $timelist[date('Y-m-d',$timeread)] = array('c'=>0,'r'=>0);
  4493. }
  4494. $info_list = $this->whlabel->find_all($where.$sidwhere,'outk,enter,sku,state');
  4495. //echo "<pre>";
  4496. //print_r($info_list);
  4497. //exit();
  4498. $rows = array();$list = array();
  4499. foreach ($info_list as $key=>$value)
  4500. {
  4501. $thistime = $timelist;
  4502. if(isset($rows[strtolower($value['sku'])]))
  4503. {
  4504. if($value['outk'] > $ktime && $value['state'] < $jtime)
  4505. {
  4506. $rows[strtolower($value['sku'])][date('Y-m-d',$value['outk'])]['c'] += 1;
  4507. }
  4508. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4509. {
  4510. $rows[strtolower($value['sku'])][date('Y-m-d',$value['enter'])]['r'] += 1;
  4511. }
  4512. }
  4513. else
  4514. {
  4515. if($value['outk'] > $ktime && $value['outk'] < $jtime)
  4516. {
  4517. $thistime[date('Y-m-d',$value['outk'])]['c'] += 1;
  4518. }
  4519. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4520. {
  4521. $thistime[date('Y-m-d',$value['enter'])]['r'] += 1;
  4522. }
  4523. $rows[strtolower($value['sku'])] = $thistime;
  4524. }
  4525. }
  4526. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4527. <head>
  4528. <!--[if gte mso 9]><xml>
  4529. <x:ExcelWorkbook>
  4530. <x:ExcelWorksheets>
  4531. <x:ExcelWorksheet>
  4532. <x:Name>EXCEL</x:Name>
  4533. <x:WorksheetOptions>
  4534. <x:Print>
  4535. <x:ValidPrinterInfo />
  4536. </x:Print>
  4537. </x:WorksheetOptions>
  4538. </x:ExcelWorksheet>
  4539. </x:ExcelWorksheets>
  4540. </x:ExcelWorkbook>
  4541. </xml>
  4542. <![endif]-->
  4543. </head><body>";
  4544. $str .= "<table border=1><tr><td>SKU</td>";
  4545. foreach ($timelist as $k=>$v)
  4546. {
  4547. $str .="<td>".$k."出库</td>";
  4548. $str .="<td>".$k."入库</td>";
  4549. }
  4550. $str .= "</tr></table>";
  4551. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4552. foreach ($rows as $key=>$val)
  4553. {
  4554. $str .= "<tr><td>".strtoupper($key)."</td>";
  4555. foreach ($val as $k=>$v)
  4556. {
  4557. $str .= "<td>".$val[$k]['c']."</td>";
  4558. if($val[$k]['r'] > 0)
  4559. {
  4560. $str .= "<td style='color:#f00'>-".$val[$k]['r']."</td>";
  4561. }
  4562. else
  4563. {
  4564. $str .= "<td>".$val[$k]['r']."</td>";
  4565. }
  4566. }
  4567. $str .= "</tr>";
  4568. }
  4569. $str .= "</table>";
  4570. $str .= "</body></html>";
  4571. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  4572. header( "Content-type: application/octet-stream" );
  4573. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  4574. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  4575. header( "Pragma: no-cache" );
  4576. header( "Expires: 0" );
  4577. exit($str);
  4578. }
  4579. }
  4580. //数量调整模板导出
  4581. public function _presetout()
  4582. {
  4583. if(isset($_GET['excel']))
  4584. {
  4585. $where = "sku != 'Preset' and purchase != 0";
  4586. //数据排序
  4587. $order_str = "id desc";
  4588. if(empty($page))
  4589. {
  4590. $start = 0;
  4591. $perpage = 1;
  4592. }
  4593. else
  4594. {
  4595. $start = ($page - 1)*$perpage;
  4596. }
  4597. //取得信息列表
  4598. $info_list = $this->whlabel->find_pc($where,'warehouse,purchase,sku','*','id desc',0,1);
  4599. $rows = array();$list = array();
  4600. foreach ($info_list as $value)
  4601. {
  4602. $warehouse = $this->warehouse->read($value['warehouse']);
  4603. $number = $value['number'];$ftime = time()-15*24*3600;
  4604. $purchase = $this->purchase->read($value['purchase']);
  4605. $list[] = array($warehouse['title'],$purchase['bm'],$value['sku'],'0','','0','','');
  4606. }
  4607. $title = "库存模板";
  4608. $titlename = "<table border=1>
  4609. <tr align='center'>
  4610. <td>仓库</td>
  4611. <td>供应商编码</td>
  4612. <td>SKU</td>
  4613. <td>增减数量(正数或负数)</td>
  4614. <td>增减备注</td>
  4615. <td>扣减方式:0减少库存1删除库存</td>
  4616. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4617. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4618. </tr>
  4619. </table>";
  4620. $filename = $title.".xls";
  4621. $tail = "";
  4622. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4623. }
  4624. }
  4625. //数量调整模板导入
  4626. public function _presetedit()
  4627. {
  4628. $dir = '/data/excel/'.date('Ymd',time()).'/';
  4629. $config['upload_path'] = '.'.$dir ;
  4630. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  4631. $config['allowed_types'] = 'xls|xlsx|csv';
  4632. $config['max_size'] = 10240;
  4633. $this->load->library('upload', $config);
  4634. $this->upload->initialize($config);
  4635. if ($this->upload->do_upload('userfile'))
  4636. {
  4637. $full_path = $dir.$this->upload->data('file_name');
  4638. $fileName = '.' . $full_path;
  4639. if (!file_exists($fileName))
  4640. {
  4641. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  4642. }
  4643. else
  4644. {
  4645. require_once "./data/excel/PHPExcel/IOFactory.php";
  4646. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  4647. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  4648. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  4649. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  4650. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  4651. ++$column;//如果列数大于26行
  4652. $list = array();
  4653. for ($i = 2; $i <= $row; $i++) // 行数循环
  4654. {
  4655. $data = array();
  4656. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4657. {
  4658. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4659. }
  4660. $list[] = $data;
  4661. }
  4662. }
  4663. $i = 0;$j = 0;$ed = array();
  4664. foreach ($list as $key=>$value)
  4665. {
  4666. $time = time();
  4667. if($value['0'] == "")
  4668. {
  4669. continue;
  4670. }
  4671. $warehouse = $this->warehouse->get_title($value['0']);
  4672. $purchase = $this->purchase->get_bm($value['1']);
  4673. $sku = $value['2'];
  4674. $num = $value['3'];//调整数量
  4675. $text = $value['4'];//扣减说明
  4676. $type = $value['5'];//调整方式0扣减1删除
  4677. $rktype = $value['6']!=''?$value['6']:0;//增加库存
  4678. $cktype = $value['7']!=''?$value['7']:0;//减少库存
  4679. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  4680. if(!$purchase)//如果没有这个SKU
  4681. {
  4682. $ed[] = array($purchase.'-不存在此供应商编码');
  4683. $j++;
  4684. continue;
  4685. }
  4686. if(!$d)//如果没有这个SKU
  4687. {
  4688. $ed[] = array($sku.'-库存中不存在此SKU');
  4689. $j++;
  4690. continue;
  4691. }
  4692. if(!isset($warehouse['id']))
  4693. {
  4694. $ed[] = array($sku.'-仓库名错误!');
  4695. $j++;
  4696. continue;
  4697. }
  4698. if($type != '0' && $type != '1')
  4699. {
  4700. $ed[] = array($sku.'-扣减方式填写错误!');
  4701. $j++;
  4702. continue;
  4703. }
  4704. if($num < 0)//扣减库存
  4705. {
  4706. if($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == '')))
  4707. {
  4708. $ed[] = array($sku.'-扣减必须填写扣减类型,非类型1必须填写备注');
  4709. $j++;
  4710. continue;
  4711. }
  4712. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and zd = "" and state = 0');
  4713. if(count($data) < abs($num))
  4714. {
  4715. $ed[] = array($sku.'-扣减数量大于库存剩余数量!');
  4716. $j++;
  4717. continue;
  4718. }
  4719. if($type == 0)//如果扣减方式为 扣减库存
  4720. {
  4721. for($i=0;$i<abs($num);$i++)
  4722. {
  4723. $this->whlabel->save(array('state'=>8,'textout'=>$text,'deltime'=>$time,'cktype'=>$cktype,'time'=>$time,'outk'=>$time),$data[$i]['id']);
  4724. }
  4725. }
  4726. else if($type == 1)
  4727. {
  4728. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  4729. if(count($zt) > 0)
  4730. {
  4731. $ed[] = array($sku.'-有在途库存无法删除!');
  4732. $j++;
  4733. continue;
  4734. }
  4735. for($i=0;$i<abs($num);$i++)
  4736. {
  4737. $this->whlabel->remove($data[$i]['id']);
  4738. }
  4739. }
  4740. }
  4741. else if($num > 0)//增加库存
  4742. {
  4743. if($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == '')))
  4744. {
  4745. $ed[] = array($sku.'-增加必须填写增加类型,非类型1必须填写备注');
  4746. $j++;
  4747. continue;
  4748. }
  4749. $post['sku'] = $d['sku'];
  4750. $post['shop'] = $d['shop'];
  4751. $post['warehouse'] = $warehouse['id'];
  4752. $post['purchase'] = $purchase['id'];
  4753. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4754. $post['state'] = 0;
  4755. $post['title'] = $d['title'];
  4756. $post['number'] = $d['number'];
  4757. $post['features'] = $d['features'];
  4758. $post['enter'] = $time;
  4759. $post['time'] = $time;//操作时间
  4760. $post['rktype'] = $rktype;
  4761. for($i=0;$i<$num;$i++)
  4762. {
  4763. $post['label'] = time().rand(100,999).$i;
  4764. $this->whlabel->insert($post);
  4765. }
  4766. }
  4767. sleep(1);//防止入库时间一样,需要延迟1秒
  4768. }
  4769. if($j > 0)
  4770. {
  4771. $tt = date('Ymd',time());
  4772. $title = '库存导入错误信息-'.$tt;
  4773. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4774. $tail = "\n";
  4775. $filename = $title.".xls";
  4776. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  4777. $dir = '/data/excel/'.$time.'/';
  4778. $file_name = 'error_'.$time.rand(1000,9999);
  4779. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  4780. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  4781. fwrite($myfile,$ecl);
  4782. fclose($myfile);
  4783. $error = $dir.$file_name.'.xls';
  4784. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  4785. }
  4786. else
  4787. {
  4788. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  4789. }
  4790. }
  4791. }
  4792. //笛卡儿积
  4793. function cp($ps,$sets,$list)
  4794. {
  4795. $result = array();$j=0;
  4796. for($i=0,$count=count($sets); $i<$count-1; $i++)
  4797. {
  4798. if($i==0)
  4799. {
  4800. $result = $sets[$i];
  4801. }
  4802. $tmp = array();
  4803. foreach($result as $res)
  4804. {
  4805. foreach($sets[$i+1] as $set)
  4806. {
  4807. $tmp[] = $res.','.$set;
  4808. }
  4809. }
  4810. $result = $tmp;
  4811. }
  4812. $this->db->trans_begin();
  4813. foreach ($result as $v)
  4814. {
  4815. $post = array();$title = "";$num="";
  4816. $data = explode(',',$v);
  4817. for($i=0;$i<count($list); $i++)
  4818. {
  4819. $post[$list[$i]] = $data[$i];
  4820. $typeclass = $this->typeclass->read($data[$i]);
  4821. $title = $title.$typeclass['title']." ";
  4822. if($data[$i] != 0)
  4823. {
  4824. $num .=$data[$i];//所有数据ID拼接
  4825. }
  4826. }
  4827. foreach ($ps as $kp=>$vp)
  4828. {
  4829. $post[$kp] = $vp;
  4830. }
  4831. $post['number'] = $num;
  4832. $info_list = $this->whlabel->get_number($num);//查询whlabel是否存在此拼接的数据ID
  4833. if($info_list)
  4834. {
  4835. $j++;
  4836. }
  4837. else
  4838. {
  4839. $skunum = $this->whlabel->find_count();
  4840. $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
  4841. $post['title'] = rtrim($title,' ');
  4842. $this->whlabel->insert($post);
  4843. }
  4844. }
  4845. if ($this->db->trans_status() === FALSE)
  4846. {
  4847. $this->db->trans_commit();
  4848. return NULL;
  4849. }
  4850. else
  4851. {
  4852. $this->db->trans_commit();
  4853. return $j;
  4854. }
  4855. }
  4856. public function _kj($arg_array)
  4857. {
  4858. if(isset($_POST['sku']))
  4859. {
  4860. $time = time();
  4861. $sku = $this->input->post('sku',true);
  4862. $warehouse = $this->input->post('warehouse',true);
  4863. $num = $this->input->post('num',true);
  4864. $text = $this->input->post('text',true);
  4865. $purchase = $this->input->post('purchase',true);
  4866. $cktype = $this->input->post('cktype',true);
  4867. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4868. if($cktype != 1 && $text == '')
  4869. {
  4870. echo json_encode(array('msg'=>"非销售出库必须填写备注!",'success'=>false));exit;
  4871. }
  4872. if($num > count($order))
  4873. {
  4874. echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
  4875. }
  4876. else
  4877. {
  4878. for($i=0;$i<$num;$i++)
  4879. {
  4880. $this->whlabel->save(array('state'=>8,'cktype'=>$cktype,'textout'=>$text,'deltime'=>$time,'time'=>$time,'outk'=>$time),$order[$i]['id']);
  4881. }
  4882. }
  4883. echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
  4884. }
  4885. $uid = $this->whlabel->read($arg_array[0]);
  4886. $uid['num'] = $this->whlabel->find_count('purchase = "'.$uid['purchase']. '" and sku = "'.$uid['sku']. '" and warehouse = "'.$uid['warehouse']. '" and zd = "" and state = 0');
  4887. $this->data['data'] = $uid ;
  4888. $this->_Template('whlabel_kj',$this->data);
  4889. }
  4890. public function _summary($arg_array)
  4891. {
  4892. $prc = array();
  4893. $purchase = $this->purchase->find_all();
  4894. foreach($purchase as $k=>$v)
  4895. {
  4896. $prc[$v['id']] = $v['title'];
  4897. }
  4898. if(isset($_GET['excel']))
  4899. {
  4900. $ktime = $this->input->get('ktime',true);
  4901. $jtime = $this->input->get('jtime',true);
  4902. $ktime = strtotime($ktime);
  4903. $jtime = strtotime($jtime);
  4904. $where = "1=1";
  4905. if($ktime && $jtime)
  4906. {
  4907. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4908. }
  4909. //数据排序
  4910. $order_str = "time desc";
  4911. if(empty($page))
  4912. {
  4913. $start = 0;
  4914. $perpage = 1;
  4915. }
  4916. else
  4917. {
  4918. $start = ($page - 1)*$perpage;
  4919. }
  4920. //取得信息列表
  4921. $info_list = $this->whlabel->find_pc($where,'sku','warehouse,purchase,details,cpid,sku,title');
  4922. foreach ($info_list as $key=>$value)
  4923. {
  4924. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4925. $warehouse = $this->warehouse->read($value['warehouse']);
  4926. $info_list[$key]['warehouse'] = $warehouse['title'];
  4927. $x = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'"','details,cpid');
  4928. $details = array();
  4929. $cpid = array();
  4930. foreach ($x as $k=>$v)
  4931. {
  4932. if($v['details'] != '')
  4933. {
  4934. $details[$v['details']] = $v['details'];
  4935. }
  4936. if($v['cpid'] != 0)
  4937. {
  4938. $cpid[$v['cpid']] = $v['cpid'];
  4939. }
  4940. }
  4941. $info_list[$key]['details'] = ($details)?implode(" ",$details):'';
  4942. $info_list[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4943. $s = $this->whlabel->find_count('state = 0 and sku = "'.$value['sku'].'"');
  4944. $info_list[$key]['s'] = $s;
  4945. $info_list[$key]['x'] = count($x);
  4946. }
  4947. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
  4948. $titlename = "<table border=1>
  4949. <tr align='center'>
  4950. <td>仓库</td>
  4951. <td>供应商</td>
  4952. <td>出库位置</td>
  4953. <td>出库编码</td>
  4954. <td>SKU</td>
  4955. <td>产品名</td>
  4956. <td>总剩余库存</td>
  4957. <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
  4958. </tr>
  4959. </table>";
  4960. $filename = $title.".xls";
  4961. $tail = "";
  4962. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4963. }
  4964. }
  4965. //usps发货清单
  4966. public function _manifest()
  4967. {
  4968. if(isset($_POST['manifest']))
  4969. {
  4970. $wltext = $this->input->post('wltext',true);
  4971. $time = time()-16*3600;
  4972. $ptime = strtotime(date('Y-m-d',$time));
  4973. $waybill = array();
  4974. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  4975. foreach ($fullorder as $v)
  4976. {
  4977. $waybill[$v['waybill']] = $v['waybill'];
  4978. }
  4979. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  4980. foreach ($fullordersmt as $v)
  4981. {
  4982. $waybill[$v['waybill']] = $v['waybill'];
  4983. }
  4984. $wltext = explode(';',$wltext);
  4985. foreach ($wltext as $v)
  4986. {
  4987. if(isset($waybill[$v]))
  4988. {
  4989. unset($waybill[$v]);
  4990. }
  4991. }
  4992. $data = $this->usps->get_manifest($waybill);
  4993. if(isset($data['Description']))
  4994. {
  4995. echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
  4996. }
  4997. else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
  4998. {
  4999. $bctime = date('Ymd',time());
  5000. $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
  5001. echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
  5002. }
  5003. else
  5004. {
  5005. echo json_encode(array('msg'=>$data,'success'=>false));exit;
  5006. }
  5007. }
  5008. }
  5009. public function _pdf($pdf,$title,$bctime)
  5010. {
  5011. $pdf_path = './data/pdf/'.$bctime.'/';
  5012. $file_base64 = $pdf;
  5013. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5014. $file_base64 = base64_decode($file_base64);
  5015. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  5016. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  5017. return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
  5018. }
  5019. /**
  5020. *
  5021. *
  5022. *
  5023. 进销存占单异常索引
  5024. *
  5025. *
  5026. *
  5027. **/
  5028. public function _abnormal()
  5029. {
  5030. $post = $this->input->post(NULL, TRUE);
  5031. if(isset($post['page']))
  5032. {
  5033. $page = $this->input->post('page',true);
  5034. $perpage = $this->input->post('perpage',true);
  5035. $sku = $this->input->post('sku',true);
  5036. $where = "1=1";
  5037. //数据排序
  5038. $order_str = "id desc";
  5039. if(empty($page))
  5040. {
  5041. $start = 0;
  5042. $perpage = 1;
  5043. }
  5044. else
  5045. {
  5046. $start = ($page - 1)*$perpage;
  5047. }
  5048. //取得信息列表
  5049. $info_list = $this->whlabel->find_all($where,'*');
  5050. $rows = array();$list = array();
  5051. foreach ($info_list as $key=>$value)
  5052. {
  5053. $rows[strtolower($value['sku'])] = $value;//所有数据sku
  5054. }
  5055. foreach ($rows as $value)
  5056. {
  5057. $warehouse = $this->warehouse->read($value['warehouse']);
  5058. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
  5059. $number = $value['number'];$ftime = time()-15*24*3600;
  5060. if($value['shop'] != '')
  5061. {
  5062. $shop = $value['shop'];
  5063. $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');
  5064. $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');
  5065. $order = array_merge($orderdlz,$ordersmt);
  5066. $od = 0;$a = '';$orid = '';
  5067. foreach ($order as $v)
  5068. {
  5069. $or = explode('|',ltrim($v['whlabel'],'|'));
  5070. for($i=0;$i<count($or);$i++)
  5071. {
  5072. $orod = explode('-',$or[$i]);
  5073. if($orod[0] == $number)
  5074. {
  5075. $od += $orod[1];
  5076. }
  5077. }
  5078. $orid .= $v['number'].'-';
  5079. }
  5080. }
  5081. else
  5082. {
  5083. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5084. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5085. $order = array_merge($orderdlz,$ordersmt);
  5086. $od = 0;$a = '';$orid = '';$qt = array();
  5087. foreach ($order as $v)
  5088. {
  5089. $or = explode('|',ltrim($v['whlabel'],'|'));
  5090. for($i=0;$i<count($or);$i++)
  5091. {
  5092. $orod = explode('-',$or[$i]);
  5093. if($orod[0] == $number)
  5094. {
  5095. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
  5096. if($czzs > 0)
  5097. {
  5098. if(isset($qt[$v['shop']]))
  5099. {
  5100. if($qt[$v['shop']] < $orod[1])
  5101. {
  5102. $od += $orod[1];//专属小于单量不计算剩余直接归入通用
  5103. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5104. }
  5105. else
  5106. {
  5107. $qt[$v['shop']] -= $orod[1];
  5108. }
  5109. }
  5110. else
  5111. {
  5112. $qt[$v['shop']] = $czzs;
  5113. }
  5114. }
  5115. else
  5116. {
  5117. $od += $orod[1];
  5118. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5119. }
  5120. }
  5121. }
  5122. }
  5123. }
  5124. $z = $od.'('.$orid.')';//查看订单号
  5125. //$z = $od;
  5126. if($od > $c)
  5127. {
  5128. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
  5129. }
  5130. }
  5131. $listdata = array_slice($list,$start,$perpage);
  5132. $total = count($list);
  5133. $pagenum = ceil($total/$perpage);
  5134. $over = $total-($start+$perpage);
  5135. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5136. echo json_encode($rows);exit;
  5137. }
  5138. $this->_Template('whlabel_abnormal',$this->data);
  5139. }
  5140. /**
  5141. *
  5142. *
  5143. *
  5144. 进销存占单异常索引
  5145. *
  5146. *
  5147. *
  5148. **/
  5149. public function _error()
  5150. {
  5151. $post = $this->input->post(NULL, TRUE);
  5152. if(isset($post['page']))
  5153. {
  5154. $page = $this->input->post('page',true);
  5155. $perpage = $this->input->post('perpage',true);
  5156. $sku = $this->input->post('sku',true);
  5157. $warehouse = $this->input->post('warehouse',true);
  5158. $ktime = $this->input->post('ktime',true);
  5159. $jtime = $this->input->post('jtime',true);
  5160. $ktime = strtotime($ktime);
  5161. $jtime = strtotime($jtime);
  5162. $where = "sku != 'Preset'";
  5163. $gj = '';
  5164. if($sku)
  5165. {
  5166. $where .= " and sku like '%$sku%'";
  5167. }
  5168. else
  5169. {
  5170. if($ktime && $jtime)
  5171. {
  5172. $gj = " and time > '$ktime' and time < '$jtime'";
  5173. }
  5174. }
  5175. if($warehouse)
  5176. {
  5177. $where .= " and warehouse = '$warehouse'";
  5178. }
  5179. //数据排序
  5180. $order_str = "id desc";
  5181. if(empty($page))
  5182. {
  5183. $start = 0;
  5184. $perpage = 1;
  5185. }
  5186. else
  5187. {
  5188. $start = ($page - 1)*$perpage;
  5189. }
  5190. //取得信息列表
  5191. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5192. $rows = array();$list = array();
  5193. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5194. // foreach ($info_list as $value)
  5195. // {
  5196. // $warehouse = $this->warehouse->read($value['warehouse']);
  5197. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5198. // $number = $value['number'];$ftime = time()-15*24*3600;
  5199. // if($c < 1)
  5200. // {
  5201. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5202. // }
  5203. // }
  5204. $warehouse_list = $this->warehouse->find_all();
  5205. $warehouse_list = array_column($warehouse_list,null,'id');
  5206. foreach ($info_list as $value)
  5207. {
  5208. $warehouse = isset($warehouse_list[$value['warehouse']])?$warehouse_list[$value['warehouse']]:[
  5209. 'title'=>"",
  5210. ];
  5211. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5212. $number = $value['number'];$ftime = time()-15*24*3600;
  5213. if($c < 1)
  5214. {
  5215. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5216. }
  5217. }
  5218. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5219. // $query = $this->db->query($sql);
  5220. // $info_list = $query->result_array();
  5221. // $sql_two = "select title,id from crowd_warehouse";
  5222. // $query_two = $this->db->query($sql_two);
  5223. // $warehouse_list = $query_two->result_array();
  5224. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5225. // foreach ($info_list as $value)
  5226. // {
  5227. // if(isset($warehouse_arr[$value['warehouse']])){
  5228. // $warehouse = $warehouse_arr[$value['warehouse']];
  5229. // }else{
  5230. // $warehouse = [
  5231. // 'id'=>0,
  5232. // 'title'=>"异常",
  5233. // ];
  5234. // }
  5235. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5236. // $number = $value['number'];$ftime = time()-15*24*3600;
  5237. // if($c < 1)
  5238. // {
  5239. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5240. // }
  5241. // }
  5242. $listdata = array_slice($list,$start,$perpage);
  5243. $total = count($list);
  5244. $pagenum = ceil($total/$perpage);
  5245. $over = $total-($start+$perpage);
  5246. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5247. echo json_encode($rows);exit;
  5248. }
  5249. if(isset($post['s']))
  5250. {
  5251. $id_arr = $this->input->post('s');
  5252. $id_arr = explode(',',trim($id_arr,','));
  5253. if(!$id_arr)
  5254. {
  5255. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  5256. }
  5257. //循环删除记录
  5258. foreach ($id_arr as $v)
  5259. {
  5260. $dd = $this->whlabel->read($v);
  5261. if(!isset($dd['id']))
  5262. {
  5263. echo json_encode(array('msg'=>$dd['sku'].'已被删除,请刷新页面','success'=>false));exit;
  5264. }
  5265. $zt = $this->whlabeltransport->find_all('sku = "'.$dd['sku'].'" and warehouse = "'.$dd['warehouse'].'" and features = "'.$dd['features'].'" and cz = "0"');
  5266. if(isset($zt[0]))
  5267. {
  5268. echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
  5269. }
  5270. $deldd = $this->whlabel->find_all("sku = '".$dd['sku']."' and warehouse = '".$dd['warehouse']."'");
  5271. foreach ($deldd as $vv)
  5272. {
  5273. $this->whlabel->remove($vv['id']);
  5274. }
  5275. }
  5276. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  5277. }
  5278. $this->_Template('whlabel_error',$this->data);
  5279. }
  5280. public function _errorexcel()
  5281. {
  5282. $post = $this->input->post(NULL, TRUE);
  5283. if(isset($_GET['page']))
  5284. {
  5285. $page = $this->input->get('page',true);
  5286. $perpage = $this->input->get('perpage',true);
  5287. $sku = $this->input->get('sku',true);
  5288. $warehouse = $this->input->get('warehouse',true);
  5289. $ktime = $this->input->get('ktime',true);
  5290. $jtime = $this->input->get('jtime',true);
  5291. $ktime = strtotime($ktime);
  5292. $jtime = strtotime($jtime);
  5293. $where = "sku != 'Preset'";
  5294. $gj = '';
  5295. if($sku)
  5296. {
  5297. $where .= " and sku like '%$sku%'";
  5298. }
  5299. else
  5300. {
  5301. if($ktime && $jtime)
  5302. {
  5303. $gj = " and time > '$ktime' and time < '$jtime'";
  5304. }
  5305. }
  5306. if($warehouse)
  5307. {
  5308. $where .= " and warehouse = '$warehouse'";
  5309. }
  5310. //数据排序
  5311. $order_str = "id desc";
  5312. if(empty($page))
  5313. {
  5314. $start = 0;
  5315. $perpage = 1;
  5316. }
  5317. else
  5318. {
  5319. $start = ($page - 1)*$perpage;
  5320. }
  5321. //取得信息列表
  5322. $rows = array();$list = array();
  5323. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5324. foreach ($info_list as $value)
  5325. {
  5326. $warehouse = $this->warehouse->read($value['warehouse']);
  5327. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5328. $number = $value['number'];$ftime = time()-15*24*3600;
  5329. if($c < 1)
  5330. {
  5331. $list[] = array('warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5332. }
  5333. }
  5334. $title = "0库存汇总";
  5335. $titlename = "<table border=1>
  5336. <tr align='center'>
  5337. <td>仓库</td>
  5338. <td>SKU</td>
  5339. <td>产品</td>
  5340. <td>当前库存</td>
  5341. </tr>
  5342. </table>";
  5343. $filename = $title.".xls";
  5344. $tail = "";
  5345. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5346. }
  5347. }
  5348. /**
  5349. *
  5350. *
  5351. * 占单
  5352. *
  5353. *
  5354. **/
  5355. public function _kcyz()
  5356. {
  5357. $post = $this->input->post(NULL, TRUE);
  5358. if(isset($post['warehouse']))
  5359. {
  5360. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请更新浏览器缓存!','success'=>false)));exit;//不再使用
  5361. $warehouse = $this->input->post('warehouse',true);
  5362. $whlabel = $this->input->post('whlabel',true);
  5363. $id = $this->input->post('id',true);
  5364. $shop = $this->input->post('shop',true);
  5365. $number = $this->input->post('number',true);
  5366. if(!$whlabel || $whlabel == '|')
  5367. {
  5368. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  5369. }
  5370. $pp = explode('|',trim($whlabel,'|'));
  5371. $x = 0;$save = array();
  5372. foreach ($pp as $va)
  5373. {
  5374. $num = explode('-',$va);
  5375. if($number)
  5376. {
  5377. $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 = '')");//通用
  5378. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  5379. }
  5380. else
  5381. {
  5382. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  5383. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  5384. }
  5385. $x++;
  5386. if(count($whlabel)+count($shopwhlabel) < $num[1])
  5387. {
  5388. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  5389. }
  5390. }
  5391. if(isset($save[0]))
  5392. {
  5393. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
  5394. }
  5395. else
  5396. {
  5397. echo json_encode(array('success'=>true));exit;
  5398. }
  5399. }
  5400. }
  5401. public function _db()
  5402. {
  5403. $post = $this->input->post(NULL, TRUE);
  5404. if(isset($post['page']))
  5405. {
  5406. $page = $this->input->post('page',true);
  5407. $perpage = $this->input->post('perpage',true);
  5408. $sku = $this->input->post('sku',true);
  5409. $number = $this->input->post('number',true);
  5410. $warehouse = $this->input->post('warehouse',true);
  5411. $purchase = $this->input->post('purchase',true);
  5412. $orderinfo = $this->input->post('orderinfo',true);
  5413. $waybill = $this->input->post('waybill',true);
  5414. $category = $this->input->post('category',true);
  5415. $size = $this->input->post('size',true);
  5416. $grade = $this->input->post('grade',true);
  5417. $color = $this->input->post('color',true);
  5418. $lowe = $this->input->post('lowe',true);
  5419. $state = $this->input->post('state',true);
  5420. $label = $this->input->post('label',true);
  5421. $timetk = $this->input->post('timetkk',true);
  5422. $timetj = $this->input->post('timetjj',true);
  5423. $timetk = strtotime($timetk);
  5424. $timetj = strtotime($timetj);
  5425. $where = "dbtime > 0";
  5426. if($timetk && $timetj)
  5427. {
  5428. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5429. }
  5430. if($sku)
  5431. {
  5432. $where .= " and sku = '$sku'";
  5433. }
  5434. if($warehouse)
  5435. {
  5436. $where .= " and warehouse = '$warehouse'";
  5437. if($warehouse == 12)
  5438. {
  5439. $w = 'specialstock';
  5440. }
  5441. else
  5442. {
  5443. $w = 'whlabel';
  5444. }
  5445. }
  5446. if($purchase)
  5447. {
  5448. $where .= " and purchase = '$purchase'";
  5449. }
  5450. if($category)
  5451. {
  5452. $where .= " and features like '%-$category-%'";
  5453. }
  5454. if($size)
  5455. {
  5456. $where .= " and features like '%-$size-%'";
  5457. }
  5458. if($grade)
  5459. {
  5460. $where .= " and features like '%-$grade-%'";
  5461. }
  5462. if($color)
  5463. {
  5464. $where .= " and features like '%-$color-%'";
  5465. }
  5466. if($lowe)
  5467. {
  5468. $where .= " and features like '%-$lowe-%'";
  5469. }
  5470. if($state != '')
  5471. {
  5472. $where .= " and state = '$state'";
  5473. }
  5474. //数据排序
  5475. $order_str = "dbtime desc";
  5476. if(empty($page))
  5477. {
  5478. $start = 0;
  5479. $perpage = 1;
  5480. }
  5481. else
  5482. {
  5483. $start = ($page - 1)*$perpage;
  5484. }
  5485. //取得信息列表
  5486. $info_list = $this->$w->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5487. foreach ($info_list as $key=>$value)
  5488. {
  5489. $warehouse = $this->$w->read($value['warehouse']);
  5490. $info_list[$key]['warehouse'] = $warehouse['title'];
  5491. $purchase = $this->purchase->read($value['purchase']);
  5492. $info_list[$key]['purchase'] = $purchase['title'];
  5493. if($value['enter'] != 0)
  5494. {
  5495. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5496. }
  5497. else
  5498. {
  5499. $info_list[$key]['enter'] = "";
  5500. }
  5501. if($value['dbtime'] != 0)
  5502. {
  5503. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5504. }
  5505. else
  5506. {
  5507. $info_list[$key]['dbtime'] = "";
  5508. }
  5509. if($value['state'] == 0)
  5510. {
  5511. $info_list[$key]['state'] = "在库";
  5512. }
  5513. else if($value['state'] == 1)
  5514. {
  5515. $info_list[$key]['state'] = "出库";
  5516. }
  5517. else if($value['state'] == 2)
  5518. {
  5519. $info_list[$key]['state'] = "退库";
  5520. }
  5521. else if($value['state'] == 3)
  5522. {
  5523. $info_list[$key]['state'] = "调拨中";
  5524. }
  5525. else if($value['state'] == 4)
  5526. {
  5527. $info_list[$key]['state'] = "再加工";
  5528. }
  5529. else if($value['state'] == 5)
  5530. {
  5531. $info_list[$key]['state'] = "维修中";
  5532. }
  5533. else if($value['state'] == 6)
  5534. {
  5535. $info_list[$key]['state'] = "盘亏";
  5536. }
  5537. else if($value['state'] == 7)
  5538. {
  5539. $info_list[$key]['state'] = "更换标签";
  5540. }
  5541. else if($value['state'] == 8)
  5542. {
  5543. $info_list[$key]['state'] = "其它";
  5544. }
  5545. else if($value['state'] == 9)
  5546. {
  5547. $info_list[$key]['state'] = "预设";
  5548. }
  5549. }
  5550. $total = $this->whlabel->find_count($where);
  5551. $pagenum = ceil($total/$perpage);
  5552. $over = $total-($start+$perpage);
  5553. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5554. echo json_encode($rows);exit;
  5555. }
  5556. if(isset($post['outsku']))
  5557. {
  5558. $time = time();
  5559. $cz = $this->input->post('cz',true);
  5560. $label = $this->input->post('outsku',true);
  5561. $sl = $this->input->post('sl',true);
  5562. $num = $this->input->post('num',true);
  5563. //$warehouse = $this->input->post('warehouse',true);
  5564. if(!$sl)
  5565. {
  5566. $sl = 1;
  5567. }
  5568. if(!$warehouse)
  5569. {
  5570. echo json_encode(array('msg'=>'请选择调拨到的仓库','success'=>false));exit;
  5571. }
  5572. $dblabel = $this->whlabellabel->get_label($label);
  5573. if($dblabel)
  5574. {
  5575. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '0' and zd = ''");
  5576. if(count($data) < 1)
  5577. {
  5578. echo json_encode(array('msg'=>'没有此产品数据!','success'=>false));exit;
  5579. }
  5580. if(count($data) < $num)
  5581. {
  5582. echo json_encode(array('msg'=>'库存数量少于调拨数量!','success'=>false));exit;
  5583. }
  5584. for($i=0;$i<$sl;$i++)
  5585. {
  5586. $this->whlabel->save(array('state'=>3,'dbtime'=>$dbtime,'dbcontent'=>$data[$i]['warehouse'].'-'.$time.'|','time'=>$time),$data[$i]['id']);
  5587. }
  5588. echo json_encode(array('success'=>true));exit;
  5589. }
  5590. else
  5591. {
  5592. echo json_encode(array('msg'=>'未找到此条码产品!','success'=>false));exit;
  5593. }
  5594. }
  5595. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5596. $this->_Template('whlabel_db',$this->data);
  5597. }
  5598. public function _dbrk()
  5599. {
  5600. $post = $this->input->post(NULL, TRUE);
  5601. if(isset($post['page']))
  5602. {
  5603. $page = $this->input->post('page',true);
  5604. $perpage = $this->input->post('perpage',true);
  5605. $sku = $this->input->post('sku',true);
  5606. $number = $this->input->post('number',true);
  5607. $warehouse = $this->input->post('warehouse',true);
  5608. $purchase = $this->input->post('purchase',true);
  5609. $orderinfo = $this->input->post('orderinfo',true);
  5610. $waybill = $this->input->post('waybill',true);
  5611. $category = $this->input->post('category',true);
  5612. $size = $this->input->post('size',true);
  5613. $grade = $this->input->post('grade',true);
  5614. $color = $this->input->post('color',true);
  5615. $lowe = $this->input->post('lowe',true);
  5616. $state = $this->input->post('state',true);
  5617. $label = $this->input->post('label',true);
  5618. $ctime = $this->input->post('ctime',true);
  5619. $timetk = $this->input->post('timetkk',true);
  5620. $timetj = $this->input->post('timetjj',true);
  5621. $timetk = strtotime($timetk);
  5622. $timetj = strtotime($timetj);
  5623. $where = "dbtime > 0";
  5624. if($timetk && $timetj)
  5625. {
  5626. $where .= " and ".$ctime." > '$timetk' and ".$ctime." < '$timetj'";
  5627. }
  5628. if($sku)
  5629. {
  5630. $where .= " and sku = '$sku'";
  5631. }
  5632. if($warehouse)
  5633. {
  5634. $where .= " and warehouse = '$warehouse'";
  5635. }
  5636. if($purchase)
  5637. {
  5638. $where .= " and purchase = '$purchase'";
  5639. }
  5640. if($category)
  5641. {
  5642. $where .= " and features like '%-$category-%'";
  5643. }
  5644. if($size)
  5645. {
  5646. $where .= " and features like '%-$size-%'";
  5647. }
  5648. if($grade)
  5649. {
  5650. $where .= " and features like '%-$grade-%'";
  5651. }
  5652. if($color)
  5653. {
  5654. $where .= " and features like '%-$color-%'";
  5655. }
  5656. if($lowe)
  5657. {
  5658. $where .= " and features like '%-$lowe-%'";
  5659. }
  5660. if($state != '')
  5661. {
  5662. $where .= " and state = '$state'";
  5663. }
  5664. //数据排序
  5665. $order_str = "dbtime desc";
  5666. if(empty($page))
  5667. {
  5668. $start = 0;
  5669. $perpage = 1;
  5670. }
  5671. else
  5672. {
  5673. $start = ($page - 1)*$perpage;
  5674. }
  5675. //取得信息列表
  5676. $info_list = $this->whlabel->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5677. foreach ($info_list as $key=>$value)
  5678. {
  5679. $warehouse = $this->warehouse->read($value['warehouse']);
  5680. $info_list[$key]['warehouse'] = $warehouse['title'];
  5681. $purchase = $this->purchase->read($value['purchase']);
  5682. $info_list[$key]['purchase'] = $purchase['title'];
  5683. if($value['enter'] != 0)
  5684. {
  5685. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5686. }
  5687. else
  5688. {
  5689. $info_list[$key]['enter'] = "";
  5690. }
  5691. if($value['dbtime'] != 0)
  5692. {
  5693. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5694. }
  5695. else
  5696. {
  5697. $info_list[$key]['dbtime'] = "";
  5698. }
  5699. if($value['state'] == 0)
  5700. {
  5701. $info_list[$key]['state'] = "在库";
  5702. }
  5703. else if($value['state'] == 1)
  5704. {
  5705. $info_list[$key]['state'] = "出库";
  5706. }
  5707. else if($value['state'] == 2)
  5708. {
  5709. $info_list[$key]['state'] = "退库";
  5710. }
  5711. else if($value['state'] == 3)
  5712. {
  5713. $info_list[$key]['state'] = "调拨中";
  5714. }
  5715. else if($value['state'] == 4)
  5716. {
  5717. $info_list[$key]['state'] = "再加工";
  5718. }
  5719. else if($value['state'] == 5)
  5720. {
  5721. $info_list[$key]['state'] = "维修中";
  5722. }
  5723. else if($value['state'] == 6)
  5724. {
  5725. $info_list[$key]['state'] = "盘亏";
  5726. }
  5727. else if($value['state'] == 7)
  5728. {
  5729. $info_list[$key]['state'] = "更换标签";
  5730. }
  5731. else if($value['state'] == 8)
  5732. {
  5733. $info_list[$key]['state'] = "其它";
  5734. }
  5735. else if($value['state'] == 9)
  5736. {
  5737. $info_list[$key]['state'] = "预设";
  5738. }
  5739. }
  5740. $total = $this->whlabel->find_count($where);
  5741. $pagenum = ceil($total/$perpage);
  5742. $over = $total-($start+$perpage);
  5743. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5744. echo json_encode($rows);exit;
  5745. }
  5746. if(isset($post['rsku']))
  5747. {
  5748. $cz = $this->input->post('cz',true);
  5749. $label = $this->input->post('rsku',true);
  5750. $sl = $this->input->post('sl',true);
  5751. $warehouse = $this->input->post('warehouse',true);
  5752. if(!$sl)
  5753. {
  5754. $sl = 1;
  5755. }
  5756. if(!$warehouse)
  5757. {
  5758. echo json_encode(array('msg'=>'请选择入库仓库','success'=>false));exit;
  5759. }
  5760. $dblabel = $this->whlabellabel->get_label($label);
  5761. if($dblabel)
  5762. {
  5763. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '3' and zd = ''");
  5764. if(count($data) < 1)
  5765. {
  5766. echo json_encode(array('msg'=>'没有此SKU调拨数据!','success'=>false));exit;
  5767. }
  5768. if($sl > count($data))
  5769. {
  5770. echo json_encode(array('msg'=>'入库数量大于调拨数量!','success'=>false));exit;
  5771. }
  5772. $time = time();
  5773. for($i=0;$i<$sl;$i++)
  5774. {
  5775. $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']);
  5776. }
  5777. echo json_encode(array('success'=>true));exit;
  5778. }
  5779. else
  5780. {
  5781. echo json_encode(array('msg'=>'没有此条码的库存信息!','success'=>false));exit;
  5782. }
  5783. }
  5784. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5785. $this->_Template('whlabel_dbrk',$this->data);
  5786. }
  5787. public function _whlabelczdc()
  5788. {
  5789. if(isset($_GET['excel']))
  5790. {
  5791. //数据排序
  5792. $order_str = "id desc";
  5793. if(empty($page))
  5794. {
  5795. $start = 0;
  5796. $perpage = 1;
  5797. }
  5798. else
  5799. {
  5800. $start = ($page - 1)*$perpage;
  5801. }
  5802. $state = $this->input->get('state',true);
  5803. $sku = $this->input->get('sku',true);
  5804. $ctime = $this->input->get('ctime',true);
  5805. $category = $this->input->get('category',true);
  5806. $size = $this->input->get('size',true);
  5807. $grade = $this->input->get('grade',true);
  5808. $color = $this->input->get('color',true);
  5809. $lowe = $this->input->get('lowe',true);
  5810. $timetk = $this->input->get('timetkk',true);
  5811. $timetj = $this->input->get('timetjj',true);
  5812. $timetk = strtotime($timetk);
  5813. $timetj = strtotime($timetj);
  5814. $where = "dbtime > 0";
  5815. if($timetk && $timetj)
  5816. {
  5817. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5818. }
  5819. if($category)
  5820. {
  5821. $where .= " and features like '%-$category-%'";
  5822. }
  5823. if($size)
  5824. {
  5825. $where .= " and features like '%-$size-%'";
  5826. }
  5827. if($grade)
  5828. {
  5829. $where .= " and features like '%-$grade-%'";
  5830. }
  5831. if($color)
  5832. {
  5833. $where .= " and features like '%-$color-%'";
  5834. }
  5835. if($lowe)
  5836. {
  5837. $where .= " and features like '%-$lowe-%'";
  5838. }
  5839. //取得信息列表
  5840. $info_list = $this->whlabel->find_all($where,'*');
  5841. $rows = array();$list = array();
  5842. foreach ($info_list as $key=>$value)
  5843. {
  5844. $rows[$value['sku']] = $value;//所有数据sku
  5845. }
  5846. foreach ($rows as $value)
  5847. {
  5848. $warehouse = $this->warehouse->read($value['warehouse']);
  5849. $db = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'"');
  5850. $rk = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and enter > 0');
  5851. if($value['orderinfo'] == 0)
  5852. {
  5853. $info_list[$key]['orderinfo'] = "";
  5854. }
  5855. if($value['waybill'] == 0)
  5856. {
  5857. $info_list[$key]['waybill'] = "";
  5858. }
  5859. if($value['state'] == 0)
  5860. {
  5861. $value['state'] = "在库";
  5862. }
  5863. else if($value['state'] == 3)
  5864. {
  5865. $value['state'] = "调拨中";
  5866. }
  5867. $list[] = array($value['sku'],$value['title'],$db,$rk);
  5868. }
  5869. $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj)."统计表";
  5870. $titlename = "<table border=1>
  5871. <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
  5872. <tr align='center'>
  5873. <td>SKU</td>
  5874. <td>产品</td>
  5875. <td>调拨数量</td>
  5876. <td>入库数量</td>
  5877. </tr>
  5878. </table>";
  5879. $filename = $title.".xls";
  5880. $tail = "";
  5881. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5882. }
  5883. }
  5884. public function _print($arg_array)
  5885. {
  5886. if(isset($_SESSION['api']))
  5887. {
  5888. $user = $this->user->get_api($_SESSION['api']);
  5889. $usp = $user;
  5890. $fgshop = "";$sid = "";$wid="";$wtype="";
  5891. $usersp = explode('|',trim($user['shop'],'|'));
  5892. $userwh = explode('|',trim($user['warehouse'],'|'));
  5893. foreach ($usersp as $value)
  5894. {
  5895. $fgshop .= " shop = ".$value." or";
  5896. $sid .= " id = ".$value." or";
  5897. }
  5898. foreach ($userwh as $value)
  5899. {
  5900. $wid .= " id = ".$value." or";
  5901. $wtype .= " type = ".$value." or";
  5902. }
  5903. }
  5904. $post = $this->input->post(NULL, TRUE);
  5905. if(isset($post['tmsku']))
  5906. {
  5907. $tmsku = $this->input->post('tmsku',true);
  5908. if(is_numeric($tmsku))
  5909. {
  5910. $yyh = $this->whlabellabel->get_label($tmsku);
  5911. }
  5912. else
  5913. {
  5914. $yyh = $this->whlabellabel->get_sku($tmsku);
  5915. }
  5916. if($yyh)
  5917. {
  5918. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  5919. }
  5920. else
  5921. {
  5922. echo json_encode(array('success'=>false));exit;
  5923. }
  5924. }
  5925. $classid = $this->classid->sku();
  5926. $pm = $classid;
  5927. $scsku = $classid;
  5928. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5929. if(isset($post['warehouse']))
  5930. {
  5931. if($post['warehouse'])
  5932. {
  5933. $list = array();$num = "";$title = "";$features = "";
  5934. $order = 0;
  5935. $post['shop'] = '';
  5936. $brand = $this->input->post('brand',true);
  5937. if($brand != '0,')
  5938. {
  5939. $b = $this->brand->read(rtrim($brand,','));
  5940. if($b)
  5941. {
  5942. $post['shop'] = str_replace('|',',',$b['shop']);
  5943. }
  5944. }
  5945. $post['details'] = $this->input->post('details',true);//打印数量
  5946. $xbqnum = $this->input->post('xbqnum',true);
  5947. $post['purchase'] = $this->input->post('purchase',true);
  5948. $post['warehouse'] = $this->input->post('warehouse',true);
  5949. $post['purchase'] = $this->input->post('purchase',true);
  5950. $post['retreatwarehouse'] = $post['warehouse'];
  5951. $post['cpbz'] = $this->input->post('cpbz',true);
  5952. $post['state'] = 9;
  5953. $category = $this->input->post('category',true);
  5954. $list['category'] = $category;
  5955. $list['hairtype'] = $this->input->post('hairtype',true);
  5956. $list['grade'] = $this->input->post('grade',true);
  5957. $size = $this->input->post('size',true);
  5958. $list['size'] = rtrim($size,',');
  5959. $list['hairnumber'] = $this->input->post('hairnumber',true);
  5960. $list['extension'] = $this->input->post('extension',true);
  5961. if($category == 1297)
  5962. {
  5963. $list['sywignumber'] = $this->input->post('sywignumber',true);
  5964. }
  5965. if($category == 1702)
  5966. {
  5967. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  5968. $list['syother'] = $this->input->post('syother',true);
  5969. }
  5970. if($category == 133)
  5971. {
  5972. $list['fittype'] = $this->input->post('fittype',true);
  5973. $list['acother'] = $this->input->post('acother',true);
  5974. }
  5975. $list['color'] = $this->input->post('color',true);
  5976. $list['lowe'] = $this->input->post('lowe',true);
  5977. if($category == 127)
  5978. {
  5979. $list['type'] = $this->input->post('type',true);
  5980. $list['headroad'] = $this->input->post('headroad',true);
  5981. $list['density'] = $this->input->post('density',true);
  5982. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  5983. {
  5984. $list['lacesize'] = $this->input->post('lacesize',true);
  5985. }
  5986. $list['lacecolor'] = $this->input->post('lacecolor',true);
  5987. $list['lacetypes'] = $this->input->post('lacetypes',true);
  5988. }
  5989. if($category == 128)
  5990. {
  5991. $list['lacetype'] = $this->input->post('lacetype',true);
  5992. $list['haircap'] = $this->input->post('haircap',true);
  5993. $list['density'] = $this->input->post('density',true);
  5994. $list['lacecolor'] = $this->input->post('lacecolor',true);
  5995. $list['lacetypes'] = $this->input->post('lacetypes',true);
  5996. $list['wigother'] = $this->input->post('wigother',true);
  5997. $list['wigother2'] = $this->input->post('wigother2',true);
  5998. }
  5999. if($category == 129)
  6000. {
  6001. $list['wide'] = $this->input->post('wide',true);
  6002. }
  6003. if($category == 131)
  6004. {
  6005. $list['gifttype'] = $this->input->post('gifttype',true);
  6006. $list['giftother'] = $this->input->post('giftother',true);
  6007. }
  6008. if($category == 134)
  6009. {
  6010. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6011. }
  6012. if($category == 1297)
  6013. {
  6014. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6015. $list['sywigother'] = $this->input->post('sywigother',true);
  6016. }
  6017. if($category == 130 || $category == 133 || $category == 1702)
  6018. {
  6019. $list['items'] = $this->input->post('items',true);
  6020. $list['weight'] = $this->input->post('weight',true);
  6021. }
  6022. if($category == 1702)
  6023. {
  6024. $list['syhairther'] = $this->input->post('syhairther',true);
  6025. }
  6026. foreach($list as $k=>$v)
  6027. {
  6028. if($v != 0)
  6029. {
  6030. $num .=$v;
  6031. $features .=$v.'-';
  6032. $post[$k] = $v;
  6033. $typeclass = $this->typeclass->read($v);
  6034. if(isset($pm[$typeclass['classid']]))
  6035. {
  6036. if(stripos($typeclass['zh'],'|') !== false)
  6037. {
  6038. $exzh = explode('|',$typeclass['zh']);
  6039. $pm[$typeclass['classid']] = $exzh[0];
  6040. }
  6041. else
  6042. {
  6043. $pm[$typeclass['classid']] = $typeclass['zh'];
  6044. }
  6045. }
  6046. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6047. if($k != 'size')
  6048. {
  6049. $title .= $typeclass['title']." ";
  6050. }
  6051. }
  6052. }
  6053. $typeclass = $this->typeclass->read($list['size']);
  6054. $title .= $typeclass['title'];
  6055. $time = time();
  6056. $post['title'] = rtrim($title,' ');
  6057. $post['number'] = $num;
  6058. $post['features'] = '-'.$features;
  6059. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6060. $featurespp = explode('-',trim($featurespp,'-'));
  6061. if(isset($featurespp[5]))
  6062. {
  6063. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6064. }
  6065. else
  6066. {
  6067. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6068. }
  6069. $post['enter'] = $time;
  6070. $post['time'] = $time;//操作时间
  6071. $scsku = implode("-",$scsku);
  6072. $zh = implode(" ",$pm);
  6073. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6074. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6075. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6076. $post['sku'] = $bqsku;
  6077. $label = time().rand(0,9);
  6078. $post['label'] = $label;
  6079. $cpid = $this->whlabellabel->find_count();
  6080. $post['cpid'] = $cpid+1;
  6081. $cpid = $post['cpid'];
  6082. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6083. //if($whlabelbarcode)
  6084. //{
  6085. //$post['label'] = $whlabelbarcode['label'];
  6086. //if(!$this->whlabellabel->insert($post))
  6087. //{
  6088. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6089. //}
  6090. //}
  6091. //else
  6092. //{
  6093. $this->db->trans_begin();
  6094. $this->whlabellabel->insert($post);
  6095. //$this->whlabelbarcode->insert($post);
  6096. if ($this->db->trans_status() === TRUE)
  6097. {
  6098. $this->db->trans_commit();
  6099. }
  6100. else
  6101. {
  6102. $this->db->trans_rollback();
  6103. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6104. }
  6105. //}
  6106. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6107. $purchase = $this->purchase->read($post['purchase']);
  6108. 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));exit;//特殊仓目前不需要仓库选项
  6109. }
  6110. }
  6111. if(isset($_SESSION['api']))
  6112. {
  6113. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6114. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6115. $this->data['wlshop'] = $wlshop;
  6116. $this->data['warehouse'] = $warehouse;
  6117. }
  6118. $whlabelwz = $this->whlabelwz->find_all();
  6119. $this->data['whlabelwz'] = $whlabelwz;
  6120. $this->_Template('whlabel_print',$this->data);
  6121. }
  6122. public function _usaprint($arg_array)
  6123. {
  6124. if(isset($_SESSION['api']))
  6125. {
  6126. $user = $this->user->get_api($_SESSION['api']);
  6127. $usp = $user;
  6128. $fgshop = "";$sid = "";$wid="";$wtype="";
  6129. $usersp = explode('|',trim($user['shop'],'|'));
  6130. $userwh = explode('|',trim($user['warehouse'],'|'));
  6131. foreach ($usersp as $value)
  6132. {
  6133. $fgshop .= " shop = ".$value." or";
  6134. $sid .= " id = ".$value." or";
  6135. }
  6136. foreach ($userwh as $value)
  6137. {
  6138. $wid .= " id = ".$value." or";
  6139. $wtype .= " type = ".$value." or";
  6140. }
  6141. }
  6142. $post = $this->input->post(NULL, TRUE);
  6143. if(isset($post['tmsku']))
  6144. {
  6145. $tmsku = $this->input->post('tmsku',true);
  6146. if(is_numeric($tmsku))
  6147. {
  6148. $yyh = $this->whlabellabel->get_label($tmsku);
  6149. }
  6150. else
  6151. {
  6152. $yyh = $this->whlabellabel->get_sku($tmsku);
  6153. }
  6154. if($yyh)
  6155. {
  6156. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  6157. }
  6158. else
  6159. {
  6160. echo json_encode(array('success'=>false));exit;
  6161. }
  6162. }
  6163. $classid = $this->classid->sku();
  6164. $pm = $classid;
  6165. $scsku = $classid;
  6166. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6167. if(isset($post['warehouse']))
  6168. {
  6169. if($post['warehouse'])
  6170. {
  6171. $list = array();$num = "";$title = "";$features = "";
  6172. $order = 0;
  6173. $post['shop'] = '';
  6174. $brand = $this->input->post('brand',true);
  6175. if($brand != '0,')
  6176. {
  6177. $b = $this->brand->read(rtrim($brand,','));
  6178. if($b)
  6179. {
  6180. $post['shop'] = str_replace('|',',',$b['shop']);
  6181. }
  6182. }
  6183. $post['details'] = $this->input->post('details',true);//打印数量
  6184. $xbqnum = $this->input->post('xbqnum',true);
  6185. $post['purchase'] = $this->input->post('purchase',true);
  6186. $post['warehouse'] = $this->input->post('warehouse',true);
  6187. $post['purchase'] = $this->input->post('purchase',true);
  6188. $post['retreatwarehouse'] = $post['warehouse'];
  6189. $post['cpbz'] = $this->input->post('cpbz',true);
  6190. $post['state'] = 9;
  6191. $category = $this->input->post('category',true);
  6192. $list['category'] = $category;
  6193. $list['hairtype'] = $this->input->post('hairtype',true);
  6194. $list['grade'] = $this->input->post('grade',true);
  6195. $size = $this->input->post('size',true);
  6196. $list['size'] = rtrim($size,',');
  6197. $list['hairnumber'] = $this->input->post('hairnumber',true);
  6198. $list['extension'] = $this->input->post('extension',true);
  6199. if($category == 1297)
  6200. {
  6201. $list['sywignumber'] = $this->input->post('sywignumber',true);
  6202. }
  6203. if($category == 1702)
  6204. {
  6205. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  6206. $list['syother'] = $this->input->post('syother',true);
  6207. }
  6208. if($category == 133)
  6209. {
  6210. $list['fittype'] = $this->input->post('fittype',true);
  6211. $list['acother'] = $this->input->post('acother',true);
  6212. }
  6213. $list['color'] = $this->input->post('color',true);
  6214. $list['lowe'] = $this->input->post('lowe',true);
  6215. if($category == 127)
  6216. {
  6217. $list['type'] = $this->input->post('type',true);
  6218. $list['headroad'] = $this->input->post('headroad',true);
  6219. $list['density'] = $this->input->post('density',true);
  6220. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  6221. {
  6222. $list['lacesize'] = $this->input->post('lacesize',true);
  6223. }
  6224. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6225. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6226. }
  6227. if($category == 128)
  6228. {
  6229. $list['lacetype'] = $this->input->post('lacetype',true);
  6230. $list['haircap'] = $this->input->post('haircap',true);
  6231. $list['density'] = $this->input->post('density',true);
  6232. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6233. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6234. $list['wigother'] = $this->input->post('wigother',true);
  6235. $list['wigother2'] = $this->input->post('wigother2',true);
  6236. }
  6237. if($category == 129)
  6238. {
  6239. $list['wide'] = $this->input->post('wide',true);
  6240. }
  6241. if($category == 131)
  6242. {
  6243. $list['gifttype'] = $this->input->post('gifttype',true);
  6244. $list['giftother'] = $this->input->post('giftother',true);
  6245. }
  6246. if($category == 134)
  6247. {
  6248. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6249. }
  6250. if($category == 1297)
  6251. {
  6252. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6253. $list['sywigother'] = $this->input->post('sywigother',true);
  6254. }
  6255. if($category == 130 || $category == 133 || $category == 1702)
  6256. {
  6257. $list['items'] = $this->input->post('items',true);
  6258. $list['weight'] = $this->input->post('weight',true);
  6259. }
  6260. if($category == 1702)
  6261. {
  6262. $list['syhairther'] = $this->input->post('syhairther',true);
  6263. }
  6264. foreach($list as $k=>$v)
  6265. {
  6266. if($v != 0)
  6267. {
  6268. $num .=$v;
  6269. $features .=$v.'-';
  6270. $post[$k] = $v;
  6271. $typeclass = $this->typeclass->read($v);
  6272. if(isset($pm[$typeclass['classid']]))
  6273. {
  6274. if(stripos($typeclass['zh'],'|') !== false)
  6275. {
  6276. $exzh = explode('|',$typeclass['zh']);
  6277. $pm[$typeclass['classid']] = $exzh[0];
  6278. }
  6279. else
  6280. {
  6281. $pm[$typeclass['classid']] = $typeclass['zh'];
  6282. }
  6283. }
  6284. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6285. if($k != 'size')
  6286. {
  6287. $title .= $typeclass['title']." ";
  6288. }
  6289. }
  6290. }
  6291. $typeclass = $this->typeclass->read($list['size']);
  6292. $title .= $typeclass['title'];
  6293. $time = time();
  6294. $post['title'] = rtrim($title,' ');
  6295. $post['number'] = $num;
  6296. $post['features'] = '-'.$features;
  6297. $fp = $this->whlabel->get_features($post['features']);
  6298. if(!$fp)
  6299. {
  6300. echo json_encode(array('msg'=>'美仓无此产品,需要添加后才可打印','success'=>false));exit;
  6301. }
  6302. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6303. $featurespp = explode('-',trim($featurespp,'-'));
  6304. if(isset($featurespp[5]))
  6305. {
  6306. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6307. }
  6308. else
  6309. {
  6310. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6311. }
  6312. $post['enter'] = $time;
  6313. $post['time'] = $time;//操作时间
  6314. $scsku = implode("-",$scsku);
  6315. $zh = implode(" ",$pm);
  6316. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6317. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6318. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6319. $post['sku'] = $fp['sku'];
  6320. $post['label'] = $fp['sku'];
  6321. $cpid = $this->whlabellabel->find_count();
  6322. $post['cpid'] = $cpid+1;
  6323. $cpid = $post['cpid'];
  6324. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6325. //if($whlabelbarcode)
  6326. //{
  6327. //$post['label'] = $whlabelbarcode['label'];
  6328. //if(!$this->whlabellabel->insert($post))
  6329. //{
  6330. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6331. //}
  6332. //}
  6333. //else
  6334. //{
  6335. $this->db->trans_begin();
  6336. $this->whlabellabel->insert($post);
  6337. //$this->whlabelbarcode->insert($post);
  6338. if ($this->db->trans_status() === TRUE)
  6339. {
  6340. $this->db->trans_commit();
  6341. }
  6342. else
  6343. {
  6344. $this->db->trans_rollback();
  6345. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6346. }
  6347. //}
  6348. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6349. $purchase = $this->purchase->read($post['purchase']);
  6350. 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));exit;//特殊仓目前不需要仓库选项
  6351. }
  6352. }
  6353. if(isset($_SESSION['api']))
  6354. {
  6355. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6356. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6357. $this->data['wlshop'] = $wlshop;
  6358. $this->data['warehouse'] = $warehouse;
  6359. }
  6360. $whlabelwz = $this->whlabelwz->find_all();
  6361. $this->data['whlabelwz'] = $whlabelwz;
  6362. $this->_Template('whlabel_usaprint',$this->data);
  6363. }
  6364. public function _printrk($arg_array)
  6365. {
  6366. $prc = array();
  6367. $purchase = $this->purchase->find_all();
  6368. foreach($purchase as $k=>$v)
  6369. {
  6370. $prc[$v['id']] = $v['title'];
  6371. }
  6372. $post = $this->input->post(NULL, TRUE);
  6373. if(isset($post['page']))
  6374. {
  6375. $page = $this->input->post('page',true);
  6376. $perpage = $this->input->post('perpage',true);
  6377. $sku = $this->input->post('sku',true);
  6378. $bs = $this->input->post('bs',true);
  6379. $number = $this->input->post('number',true);
  6380. $warehouse = $this->input->post('warehouse',true);
  6381. $purchase = $this->input->post('purchase',true);
  6382. $orderinfo = $this->input->post('orderinfo',true);
  6383. $waybill = $this->input->post('waybill',true);
  6384. $category = $this->input->post('category',true);
  6385. $size = $this->input->post('size',true);
  6386. $grade = $this->input->post('grade',true);
  6387. $color = $this->input->post('color',true);
  6388. $lowe = $this->input->post('lowe',true);
  6389. $state = $this->input->post('state',true);
  6390. $label = $this->input->post('label',true);
  6391. $timetk = $this->input->post('ktime',true);
  6392. $timetj = $this->input->post('jtime',true);
  6393. $timetk = strtotime($timetk);
  6394. $timetj = strtotime($timetj);
  6395. $where = "1=1 ";
  6396. if($timetk && $timetj)
  6397. {
  6398. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6399. }
  6400. if($sku)
  6401. {
  6402. $where .= " and sku = '$sku'";
  6403. }
  6404. if($bs != '')
  6405. {
  6406. $where .= " and bs = '$bs'";
  6407. }
  6408. if($number)
  6409. {
  6410. $where .= " and number = '$number'";
  6411. }
  6412. if($warehouse)
  6413. {
  6414. $where .= " and warehouse = '$warehouse'";
  6415. }
  6416. if($purchase)
  6417. {
  6418. $where .= " and purchase = '$purchase'";
  6419. }
  6420. if($orderinfo)
  6421. {
  6422. $where .= " and orderinfo = '$orderinfo'";
  6423. }
  6424. if($waybill)
  6425. {
  6426. $where .= " and waybill = '$waybill'";
  6427. }
  6428. if($category)
  6429. {
  6430. $where .= " and features like '%-$category-%'";
  6431. }
  6432. if($size)
  6433. {
  6434. $where .= " and features like '%-$size-%'";
  6435. }
  6436. if($grade)
  6437. {
  6438. $where .= " and features like '%-$grade-%'";
  6439. }
  6440. if($color)
  6441. {
  6442. $where .= " and features like '%-$color-%'";
  6443. }
  6444. if($lowe)
  6445. {
  6446. $where .= " and features like '%-$lowe-%'";
  6447. }
  6448. if($label)
  6449. {
  6450. $where .= " and label = '$label'";
  6451. }
  6452. if($state || $state == 0)
  6453. {
  6454. $where .= " and state = '$state'";
  6455. }
  6456. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6457. //数据排序
  6458. $order_str = "enter desc";
  6459. if(empty($page))
  6460. {
  6461. $start = 0;
  6462. $perpage = 1;
  6463. }
  6464. else
  6465. {
  6466. $start = ($page - 1)*$perpage;
  6467. }
  6468. //取得信息列表
  6469. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,enter,details',$order_str,$start,$perpage);
  6470. foreach ($info_list as $key=>$value)
  6471. {
  6472. $warehouse = $this->warehouse->read($value['warehouse']);
  6473. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6474. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6475. if($value['state'] == 0)
  6476. {
  6477. $info_list[$key]['state'] = "在库";
  6478. }
  6479. else if($value['state'] == 1)
  6480. {
  6481. $info_list[$key]['state'] = "出库";
  6482. }
  6483. else if($value['state'] == 2)
  6484. {
  6485. $info_list[$key]['state'] = "退库";
  6486. }
  6487. else if($value['state'] == 3)
  6488. {
  6489. $info_list[$key]['state'] = "调拨中";
  6490. }
  6491. else if($value['state'] == 4)
  6492. {
  6493. $info_list[$key]['state'] = "再加工";
  6494. }
  6495. else if($value['state'] == 5)
  6496. {
  6497. $info_list[$key]['state'] = "维修中";
  6498. }
  6499. else if($value['state'] == 6)
  6500. {
  6501. $info_list[$key]['state'] = "盘亏";
  6502. }
  6503. else if($value['state'] == 7)
  6504. {
  6505. $info_list[$key]['state'] = "更换标签";
  6506. }
  6507. else if($value['state'] == 8)
  6508. {
  6509. $info_list[$key]['state'] = "其它";
  6510. }
  6511. else if($value['state'] == 9)
  6512. {
  6513. $info_list[$key]['state'] = "预设";
  6514. }
  6515. else if($value['state'] == 10)
  6516. {
  6517. $info_list[$key]['state'] = "美店零售";
  6518. }
  6519. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  6520. }
  6521. $total = $this->$ck->find_count($where);
  6522. $pagenum = ceil($total/$perpage);
  6523. $over = $total-($start+$perpage);
  6524. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6525. echo json_encode($rows);exit;
  6526. }
  6527. if(isset($post['tmsku']))
  6528. {
  6529. $time = time();
  6530. $tmsku = $this->input->post('tmsku',true);
  6531. //$post['shop'] = $this->input->post('shop',true);
  6532. $num = $this->input->post('num',true);
  6533. $rktype = $this->input->post('rktype',true);
  6534. if($num > 200)
  6535. {
  6536. echo json_encode(array('msg'=>'入库数量不允许超过200!','c'=>0,'success'=>false));exit;
  6537. }
  6538. if(!$rktype)
  6539. {
  6540. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6541. }
  6542. $rk = $this->whlabellabel->find_all("label = '$tmsku'","*","id desc");
  6543. /**
  6544. $wz = array();
  6545. foreach ($rk as $key=>$value)
  6546. {
  6547. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6548. }
  6549. if(count($wz) > 1)
  6550. {
  6551. $wz = array_values($wz);
  6552. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6553. }
  6554. **/
  6555. if(isset($rk[0]['purchase']))
  6556. {
  6557. $rk = $rk[0];
  6558. $j = 0;
  6559. $post['purchase'] = $rk['purchase'];
  6560. $post['warehouse'] = $rk['warehouse'];
  6561. $post['retreatwarehouse'] = $rk['warehouse'];
  6562. $post['sku'] = $rk['sku'];
  6563. $post['number'] = $rk['number'];
  6564. $post['features'] = $rk['features'];
  6565. $post['title'] = $rk['title'];
  6566. $post['enter'] = $time;
  6567. $post['time'] = $time;
  6568. $post['bs'] = 1;
  6569. $post['shop'] = $rk['shop'];
  6570. $post['details'] = $rk['details'];
  6571. $post['cpid'] = $rk['cpid'];
  6572. $post['cpbz'] = $rk['cpbz'];
  6573. //$post['rktype'] = $rktype;
  6574. $warehouse = $this->warehouse->read($rk['warehouse']);
  6575. if($warehouse['bdck'] == '')
  6576. {
  6577. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','c'=>0,'success'=>false));exit;
  6578. }
  6579. else
  6580. {
  6581. $bdck = $warehouse['bdck'];
  6582. }
  6583. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'],$post['sku']);
  6584. if(isset($pdwz['details']))
  6585. {
  6586. if($pdwz['details'] != $post['details'])
  6587. {
  6588. echo json_encode(array('msg'=>'此产品位置应为:'.$pdwz['details'],'c'=>0,'cs'=>$pdwz['details'].' - '.$post['details'],'success'=>false));exit;
  6589. }
  6590. }
  6591. $post['featurespp'] = $rk['featurespp'];
  6592. if($post['warehouse'] == '5')
  6593. {
  6594. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6595. if($yza)
  6596. {
  6597. if($post['features'] != $yza[0]['features'])
  6598. {
  6599. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'c'=>0,'success'=>false));exit;
  6600. }
  6601. }
  6602. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6603. if($yzb)
  6604. {
  6605. if($post['sku'] != $yzb[0]['sku'])
  6606. {
  6607. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','c'=>0,'success'=>false));exit;
  6608. }
  6609. }
  6610. }
  6611. for($i=0;$i<$num;$i++)
  6612. {
  6613. $post['label'] = time().rand(100,999).$i;
  6614. if($this->$bdck->insert($post))
  6615. {
  6616. $j++;
  6617. }
  6618. }
  6619. /**
  6620. if($post['warehouse'] != 12)
  6621. {
  6622. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6623. }
  6624. **/
  6625. if($j == $num)
  6626. {
  6627. echo json_encode(array('msg'=>'入库成功!','success'=>true));exit;
  6628. }
  6629. else
  6630. {
  6631. echo json_encode(array('msg'=>'未成功入库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6632. }
  6633. }
  6634. else
  6635. {
  6636. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6637. }
  6638. }
  6639. $this->_Template('whlabel_printrk',$this->data);
  6640. }
  6641. public function _printxzrk($arg_array)
  6642. {
  6643. $post = $this->input->post(NULL, TRUE);
  6644. if(isset($post['wzid']))
  6645. {
  6646. $time = time();
  6647. $id = $this->input->post('wzid',true);
  6648. //$post['shop'] = $this->input->post('shop',true);
  6649. $num = 1;
  6650. $rk = $this->whlabellabel->read($id);
  6651. if(isset($rk['purchase']))
  6652. {
  6653. $x = 0;
  6654. $post['purchase'] = $rk['purchase'];
  6655. $post['warehouse'] = $rk['warehouse'];
  6656. $post['retreatwarehouse'] = $rk['warehouse'];
  6657. $post['sku'] = $rk['sku'];
  6658. $post['number'] = $rk['number'];
  6659. $post['features'] = $rk['features'];
  6660. $post['title'] = $rk['title'];
  6661. $post['enter'] = $time;
  6662. $post['time'] = $time;
  6663. $post['bs'] = 1;
  6664. $post['shop'] = $rk['shop'];
  6665. $post['details'] = $rk['details'];
  6666. $post['cpid'] = $rk['cpid'];
  6667. $post['cpbz'] = $rk['cpbz'];
  6668. $warehouse = $this->warehouse->read($rk['warehouse']);
  6669. if($warehouse['bdck'] == '')
  6670. {
  6671. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','success'=>false));exit;
  6672. }
  6673. else
  6674. {
  6675. $bdck = $warehouse['bdck'];
  6676. }
  6677. $post['featurespp'] = $rk['featurespp'];
  6678. $this->db->trans_begin();
  6679. for($i=0;$i<$num;$i++)
  6680. {
  6681. $post['label'] = time().rand(100,999).$i;
  6682. $this->$bdck->insert($post);
  6683. }
  6684. /**
  6685. if($post['warehouse'] != 12)
  6686. {
  6687. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6688. }
  6689. **/
  6690. if ($this->db->trans_status() === TRUE)
  6691. {
  6692. $this->db->trans_commit();
  6693. echo json_encode(array('msg'=>'入库成功!','cs'=>$post,'cs2'=>$warehouse,'success'=>true));exit;
  6694. }
  6695. else
  6696. {
  6697. $this->db->trans_rollback();
  6698. echo json_encode(array('msg'=>'入库失败,请重试','c'=>0,'success'=>false));exit;
  6699. }
  6700. }
  6701. else
  6702. {
  6703. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6704. }
  6705. }
  6706. }
  6707. public function _printck($arg_array)
  6708. {
  6709. $prc = array();
  6710. $purchase = $this->purchase->find_all();
  6711. foreach($purchase as $k=>$v)
  6712. {
  6713. $prc[$v['id']] = $v['title'];
  6714. }
  6715. $post = $this->input->post(NULL, TRUE);
  6716. if(isset($post['page']))
  6717. {
  6718. $page = $this->input->post('page',true);
  6719. $perpage = $this->input->post('perpage',true);
  6720. $sku = $this->input->post('sku',true);
  6721. $bs = $this->input->post('bs',true);
  6722. $number = $this->input->post('number',true);
  6723. $warehouse = $this->input->post('warehouse',true);
  6724. $purchase = $this->input->post('purchase',true);
  6725. $orderinfo = $this->input->post('orderinfo',true);
  6726. $waybill = $this->input->post('waybill',true);
  6727. $category = $this->input->post('category',true);
  6728. $size = $this->input->post('size',true);
  6729. $grade = $this->input->post('grade',true);
  6730. $color = $this->input->post('color',true);
  6731. $lowe = $this->input->post('lowe',true);
  6732. $state = $this->input->post('state',true);
  6733. $label = $this->input->post('label',true);
  6734. $timetk = $this->input->post('ktime',true);
  6735. $timetj = $this->input->post('jtime',true);
  6736. $timetk = strtotime($timetk);
  6737. $timetj = strtotime($timetj);
  6738. $where = "state=1 ";
  6739. if($timetk && $timetj)
  6740. {
  6741. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6742. }
  6743. if($sku)
  6744. {
  6745. $where .= " and sku = '$sku'";
  6746. }
  6747. if($bs != '')
  6748. {
  6749. $where .= " and bs = '$bs'";
  6750. }
  6751. if($number)
  6752. {
  6753. $where .= " and number = '$number'";
  6754. }
  6755. if($warehouse)
  6756. {
  6757. $where .= " and warehouse = '$warehouse'";
  6758. }
  6759. if($purchase)
  6760. {
  6761. $where .= " and purchase = '$purchase'";
  6762. }
  6763. if($orderinfo)
  6764. {
  6765. $where .= " and orderinfo = '$orderinfo'";
  6766. }
  6767. if($waybill)
  6768. {
  6769. $where .= " and waybill = '$waybill'";
  6770. }
  6771. if($category)
  6772. {
  6773. $where .= " and features like '%-$category-%'";
  6774. }
  6775. if($size)
  6776. {
  6777. $where .= " and features like '%-$size-%'";
  6778. }
  6779. if($grade)
  6780. {
  6781. $where .= " and features like '%-$grade-%'";
  6782. }
  6783. if($color)
  6784. {
  6785. $where .= " and features like '%-$color-%'";
  6786. }
  6787. if($lowe)
  6788. {
  6789. $where .= " and features like '%-$lowe-%'";
  6790. }
  6791. if($label)
  6792. {
  6793. $where .= " and label = '$label'";
  6794. }
  6795. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6796. //数据排序
  6797. $order_str = "outk desc";
  6798. if(empty($page))
  6799. {
  6800. $start = 0;
  6801. $perpage = 1;
  6802. }
  6803. else
  6804. {
  6805. $start = ($page - 1)*$perpage;
  6806. }
  6807. //取得信息列表
  6808. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,outk,details',$order_str,$start,$perpage);
  6809. foreach ($info_list as $key=>$value)
  6810. {
  6811. $warehouse = $this->warehouse->read($value['warehouse']);
  6812. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6813. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6814. if($value['state'] == 0)
  6815. {
  6816. $info_list[$key]['state'] = "在库";
  6817. }
  6818. else if($value['state'] == 1)
  6819. {
  6820. $info_list[$key]['state'] = "出库";
  6821. }
  6822. else if($value['state'] == 2)
  6823. {
  6824. $info_list[$key]['state'] = "退库";
  6825. }
  6826. else if($value['state'] == 3)
  6827. {
  6828. $info_list[$key]['state'] = "调拨中";
  6829. }
  6830. else if($value['state'] == 4)
  6831. {
  6832. $info_list[$key]['state'] = "再加工";
  6833. }
  6834. else if($value['state'] == 5)
  6835. {
  6836. $info_list[$key]['state'] = "维修中";
  6837. }
  6838. else if($value['state'] == 6)
  6839. {
  6840. $info_list[$key]['state'] = "盘亏";
  6841. }
  6842. else if($value['state'] == 7)
  6843. {
  6844. $info_list[$key]['state'] = "更换标签";
  6845. }
  6846. else if($value['state'] == 8)
  6847. {
  6848. $info_list[$key]['state'] = "其它";
  6849. }
  6850. else if($value['state'] == 9)
  6851. {
  6852. $info_list[$key]['state'] = "预设";
  6853. }
  6854. else if($value['state'] == 10)
  6855. {
  6856. $info_list[$key]['state'] = "美店零售";
  6857. }
  6858. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  6859. }
  6860. $total = $this->$ck->find_count($where);
  6861. $pagenum = ceil($total/$perpage);
  6862. $over = $total-($start+$perpage);
  6863. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6864. echo json_encode($rows);exit;
  6865. }
  6866. if(isset($post['tmsku']))
  6867. {
  6868. $time = time();
  6869. $tmsku = $this->input->post('tmsku',true);
  6870. //$post['shop'] = $this->input->post('shop',true);
  6871. $num = $this->input->post('num',true);
  6872. $cktype = $this->input->post('cktype',true);
  6873. $label = $this->whlabellabel->get_label($tmsku);
  6874. if(!$cktype)
  6875. {
  6876. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6877. }
  6878. if(!isset($label['warehouse']))
  6879. {
  6880. echo json_encode(array('msg'=>'没有此条码信息!','success'=>false));exit;
  6881. }
  6882. $xzck = ($label['warehouse'] == '12')?'specialstock':'whlabel';
  6883. if(stripos($label['features'],'-126-') !== false)
  6884. {
  6885. $ck = $this->$xzck->find_all("state = '0' and shop = '".$label['shop']."' and number = '".$label['number']."' and warehouse = '".$label['warehouse']."' and zd = ''");
  6886. }
  6887. else
  6888. {
  6889. $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 = ''");
  6890. }
  6891. $j = 0;
  6892. if(count($ck) >= $num)
  6893. {
  6894. for($i=0;$i<$num;$i++)
  6895. {
  6896. if($this->$xzck->save(array('state'=>1,'outk'=>$time,'time'=>$time),$ck[$i]['id']))//,'cktype'=>$cktype
  6897. {
  6898. $j++;
  6899. }
  6900. }
  6901. if($j == $num)
  6902. {
  6903. echo json_encode(array('msg'=>'出库成功!','success'=>true));exit;
  6904. }
  6905. else
  6906. {
  6907. echo json_encode(array('msg'=>'未成功出库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6908. }
  6909. }
  6910. else
  6911. {
  6912. echo json_encode(array('msg'=>'没有足够的库存!','cs'=>$label['sku'].' - '.$label['purchase'],'success'=>false));exit;
  6913. }
  6914. }
  6915. $this->_Template('whlabel_printck',$this->data);
  6916. }
  6917. public function _printexcel()
  6918. {
  6919. $dir = '/data/excel/'.date('Ymd',time()).'/';
  6920. $config['upload_path'] = '.'.$dir ;
  6921. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  6922. $config['allowed_types'] = 'xls|xlsx|csv';
  6923. $config['max_size'] = 10240;
  6924. $this->load->library('upload', $config);
  6925. $this->upload->initialize($config);
  6926. if ($this->upload->do_upload('userfile'))
  6927. {
  6928. $full_path = $dir.$this->upload->data('file_name');
  6929. $fileName = '.' . $full_path;
  6930. if (!file_exists($fileName))
  6931. {
  6932. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  6933. }
  6934. else
  6935. {
  6936. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6937. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  6938. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  6939. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  6940. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  6941. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  6942. ++$column;//如果列数大于26行
  6943. $list = array();
  6944. for ($i = 2; $i <= $row; $i++) // 行数循环
  6945. {
  6946. $data = array();
  6947. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6948. {
  6949. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6950. }
  6951. $list[] = $data;
  6952. }
  6953. }
  6954. $ed = array();$i = 0;$j = 0;$dcdata = array();$yc = '';
  6955. $cmf_arr = array_column($list, '1');
  6956. array_multisort($cmf_arr, SORT_ASC, $list);
  6957. foreach ($list as $key=>$value)
  6958. {
  6959. $typeclass = $this->typeclass->get_bqsku($value['1'],$value['2']);
  6960. if($typeclass)
  6961. {
  6962. $this->typeclass->save(array('bqsku'=>$value['3']),$typeclass['id']);
  6963. }
  6964. else
  6965. {
  6966. $ed[] = array($value['1'].'-系统未找到此订单信息');
  6967. $i++;
  6968. continue;
  6969. }
  6970. }
  6971. if($i > 0)
  6972. {
  6973. $yc = $i.'条异常';
  6974. }
  6975. echo json_encode(array('msg'=>'操作成功 '.$yc,'yc'=>$ed,'success'=>true));exit;
  6976. }
  6977. }
  6978. public function _uck()
  6979. {
  6980. if(isset($_GET['excel']))
  6981. {
  6982. $tc = array();
  6983. $typeclass = $this->typeclass->find_all();
  6984. foreach ($typeclass as $v)
  6985. {
  6986. $tc[$v['id']] = $v['zh'];
  6987. }
  6988. $data = array();$t = array();$rq = '';
  6989. $ts = strtotime(date("Y-m-d",time()))-strtotime(date("Y-m",time()));
  6990. $ts = $ts/(24*3600);
  6991. for($i=0;$i<$ts;$i++)
  6992. {
  6993. $t[] = date("Y-m-d",strtotime('-'.($ts-$i).' day'));
  6994. $rq .= "<td>".date("Y-m-d",strtotime('-'.($ts-$i).' day'))."</td>";
  6995. }
  6996. $info_list = $this->whlabel->find_pc("warehouse = '5'",'sku','warehouse,sku,features');
  6997. foreach ($info_list as $k=>$v)
  6998. {
  6999. $features = explode('-',trim($v['features'],'-'));
  7000. if(!isset($features[3]) || !isset($features[4]))
  7001. {
  7002. continue;
  7003. }
  7004. $data[$k][0] = $tc[$features[0]];//类型
  7005. $data[$k][1] = ($features[3] != 57)?$tc[$features[3]]:'';//颜色,自然色不显示
  7006. $data[$k][2] = $tc[$features[4]];//曲度
  7007. $data[$k][3] = '';
  7008. if(isset($data[$k][1]))
  7009. {
  7010. $data[$k][3] .= $data[$k][1];
  7011. }
  7012. if(isset($data[$k][2]))
  7013. {
  7014. $data[$k][3] .= $data[$k][2];
  7015. }
  7016. if(isset($features[5]))
  7017. {
  7018. $data[$k][3] .= $tc[$features[5]];
  7019. }
  7020. if(isset($features[2]))
  7021. {
  7022. $data[$k][3] .= $tc[$features[2]];
  7023. }
  7024. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7025. $data[$k][4] = $v['sku'];
  7026. $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())).'))');//月初库存
  7027. $data[$k][] = $this->whlabel->find_count('sku = "'.$v['sku'].'" and state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');//剩余库存
  7028. $zt = $this->whlabeltransport->find_all('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and cz = "0"');
  7029. $ztrq = '';$ztsl = '';
  7030. if(count($zt) > 0)
  7031. {
  7032. foreach ($zt as $vv)
  7033. {
  7034. $ztrq .= date('Y-m-d',$vv['stime']).'<br>';
  7035. $ztsl .= $vv['num'].'<br>';
  7036. }
  7037. }
  7038. $data[$k][] = trim($ztsl,'<br>');
  7039. $data[$k][] = trim($ztrq,'<br>');
  7040. $byck = 0;
  7041. foreach ($t as $vv)
  7042. {
  7043. $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));
  7044. $data[$k][] = ($sl > 0)?'<b>'.$sl.'</b>':'';
  7045. $byck += $sl;
  7046. }
  7047. $data[$k][] = ($byck > 0)?$byck:'';
  7048. }
  7049. $title = "详情 ".date("Y-m-d",time());
  7050. $titlename = "<table border=1>
  7051. <tr align='center'>
  7052. <td>类别</td>
  7053. <td>颜色</td>
  7054. <td>曲度</td>
  7055. <td>名称</td>
  7056. <td>SKU</td>
  7057. <td>月初库存</td>
  7058. <td>剩余库存</td>
  7059. <td>在途数量</td>
  7060. <td>预达日期</td>".
  7061. $rq
  7062. ."<td>本月出库</td></tr>
  7063. </table>";
  7064. $filename = $title.".xls";
  7065. $tail = "";
  7066. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  7067. }
  7068. }
  7069. public function _whlabelexcelzh()
  7070. {
  7071. if(isset($_GET['excel']))
  7072. {
  7073. $where = "sku != 'Preset'";
  7074. //数据排序
  7075. $order_str = "id desc";
  7076. if(empty($page))
  7077. {
  7078. $start = 0;
  7079. $perpage = 1;
  7080. }
  7081. else
  7082. {
  7083. $start = ($page - 1)*$perpage;
  7084. }
  7085. $category = $this->input->get('category',true);
  7086. $warehouse = $this->input->get('warehouse',true);
  7087. $excelid = $this->input->get('sid',true);
  7088. if($category)
  7089. {
  7090. $where .= " and features like '%-$category-%'";
  7091. }
  7092. if($warehouse)
  7093. {
  7094. $where .= " and warehouse = '$warehouse'";
  7095. }
  7096. $xzid = '';
  7097. if($excelid)
  7098. {
  7099. $excelid = explode(',',trim($excelid,','));
  7100. foreach ($excelid as $key=>$value)
  7101. {
  7102. $xzid .= " id = ".$value." or";
  7103. }
  7104. $xzid = " and (".rtrim($xzid,'or').")";;
  7105. }
  7106. //取得信息列表
  7107. /**
  7108. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7109. $rows = array();$list = array();
  7110. foreach ($info_list as $key=>$value)
  7111. {
  7112. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7113. }
  7114. **/
  7115. $list = array();
  7116. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,number,features');
  7117. foreach ($rows as $key=>$value)
  7118. {
  7119. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"');
  7120. $zh = '';
  7121. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and time = "0" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','num,stime');
  7122. foreach ($zt as $v)
  7123. {
  7124. $zh .= $v['num']." / ".date('Y-m-d',$v['stime'])."<br>";
  7125. }
  7126. $zt = array_sum(array_column($zt,'num'));
  7127. $number = $value['number'];
  7128. $ftime = time()-15*24*3600;
  7129. $warehouse = $this->warehouse->read($value['warehouse']);
  7130. $rows[$key]['warehouse'] = $warehouse['title'];
  7131. $rows[$key]['number'] = $c;
  7132. $rows[$key]['features'] = $zh;
  7133. $rows[$key]['hb'] = $c+$zt;
  7134. }
  7135. $title = "导出库存数据及在途中数据".date('Y-m-d',time());
  7136. $titlename = "<table border=1>
  7137. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7138. <tr align='center'>
  7139. <td>仓库</td>
  7140. <td>SKU</td>
  7141. <td>产品</td>
  7142. <td>库存数量</td>
  7143. <td>在途数量及预达日期</td>
  7144. <td>在途+库存数量</td>
  7145. </tr>
  7146. </table>";
  7147. $filename = $title.".xls";
  7148. $tail = "";
  7149. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7150. }
  7151. if(isset($_GET['excel']))
  7152. {
  7153. $warehouse = $this->input->get('warehouse',true);
  7154. $sku = $this->input->get('sku',true);
  7155. $cz = $this->input->get('cz',true);
  7156. $text = $this->input->post('text',true);
  7157. $xztime = $this->input->get('xztime',true);
  7158. $timetk = $this->input->get('timetk',true);
  7159. $timetj = $this->input->get('timetj',true);
  7160. $timetk = strtotime($timetk);
  7161. $timetj = strtotime($timetj);
  7162. $where = "time = '0' ";
  7163. if($warehouse)
  7164. {
  7165. $where .= " and warehouse = '$warehouse'";
  7166. }
  7167. if($sku)
  7168. {
  7169. $where .= " and sku = '$sku'";
  7170. }
  7171. if($text)
  7172. {
  7173. $where .= " and text like '%$text%'";
  7174. }
  7175. if($cz != '')
  7176. {
  7177. $where .= " and cz = '$cz'";
  7178. }
  7179. if($timetk && $timetj)
  7180. {
  7181. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  7182. }
  7183. //数据排序
  7184. $order_str = $xztime." desc";
  7185. //取得信息列表
  7186. $zh = array();
  7187. $info_list = $this->whlabeltransport->find_all($where,'warehouse,sku,title,num,features,enter,stime,text');
  7188. foreach ($info_list as $v)
  7189. {
  7190. $c = $this->whlabel->find_count('state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');
  7191. $warehouse = $this->warehouse->read($v['warehouse']);
  7192. $v['warehouse'] = $warehouse['title'];
  7193. $v['enter'] = date('Y-m-d H:i:s',$v['enter']);
  7194. $v['stime'] = date('Y-m-d',$v['stime']);
  7195. if(isset($zh[$v['features']]))
  7196. {
  7197. $zh[$v['features']]['num'] += $v['num'];
  7198. }
  7199. else
  7200. {
  7201. $zh[$v['features']] = $v;
  7202. }
  7203. $zh[$v['features']]['features'] = $c;
  7204. }
  7205. $title = "在途数据".date('Y-m-d',time());
  7206. $titlename = "<table border=1>
  7207. <tr align='center'>
  7208. <td>仓库</td>
  7209. <td>SKU</td>
  7210. <td>名称</td>
  7211. <td>在途数量</td>
  7212. <td>库存数量</td>
  7213. <td>添加在途日期</td>
  7214. <td>预达日期</td>
  7215. <td>备注</td>
  7216. </tr>
  7217. </table>";
  7218. $filename = $title.".xls";
  7219. $tail = "";
  7220. $this->excel->get_fz2($zh,$titlename,$filename,$tail);
  7221. }
  7222. }
  7223. public function _fc()
  7224. {
  7225. $vip = 0;
  7226. if(isset($_SESSION['api']))
  7227. {
  7228. $user = $this->user->get_api($_SESSION['api']);
  7229. if($user['vip'] == 1)
  7230. {
  7231. $vip = 1;
  7232. }
  7233. }
  7234. else
  7235. {
  7236. header('Location: /');exit;
  7237. }
  7238. $post = $this->input->post(NULL, TRUE);
  7239. if(isset($post['page']))
  7240. {
  7241. $page = $this->input->post('page',true);
  7242. $perpage = $this->input->post('perpage',true);
  7243. $category = $this->input->post('category',true);
  7244. $size = $this->input->post('size',true);
  7245. $grade = $this->input->post('grade',true);
  7246. $color = $this->input->post('color',true);
  7247. $lowe = $this->input->post('lowe',true);
  7248. $sku = $this->input->post('sku');
  7249. $title = $this->input->post('title');
  7250. $warehouse = $this->input->post('warehouse',true);
  7251. $usa = $this->input->post('usa',true);
  7252. $purchase = $this->input->post('purchase',true);
  7253. $lacetype = $this->input->post('lacetype',true);
  7254. $haircap = $this->input->post('haircap',true);
  7255. $density = $this->input->post('density',true);
  7256. $details = $this->input->post('details',true);
  7257. $state = $this->input->post('state',true);
  7258. $ktime = $this->input->post('ktime',true);
  7259. $jtime = $this->input->post('jtime',true);
  7260. $ktime = strtotime($ktime);
  7261. $jtime = strtotime($jtime);
  7262. $where = "state = '11'";$gj = "";$ck = "";
  7263. if($lacetype)
  7264. {
  7265. $where .= " and features like '%-$lacetype-%'";
  7266. }
  7267. if($category)
  7268. {
  7269. $where .= " and features like '%-$category-%'";
  7270. }
  7271. if($size)
  7272. {
  7273. $where .= " and features like '%-$size-%'";
  7274. }
  7275. if($grade)
  7276. {
  7277. $where .= " and features like '%-$grade-%'";
  7278. }
  7279. if($color)
  7280. {
  7281. $where .= " and features like '%-$color-%'";
  7282. }
  7283. if($lowe)
  7284. {
  7285. $where .= " and features like '%-$lowe-%'";
  7286. }
  7287. if($haircap)
  7288. {
  7289. $where .= " and features like '%-$haircap-%'";
  7290. }
  7291. if($density)
  7292. {
  7293. $where .= " and features like '%-$density-%'";
  7294. }
  7295. if($usa)
  7296. {
  7297. if(!$warehouse)
  7298. {
  7299. $where .= " and (warehouse = '5' or warehouse = '8')";
  7300. }
  7301. }
  7302. if($warehouse)
  7303. {
  7304. $where .= " and warehouse = '$warehouse'";
  7305. }
  7306. if($details)
  7307. {
  7308. $where .= " and details = '$details'";
  7309. }
  7310. if($purchase)
  7311. {
  7312. $where .= " and purchase = '$purchase'";
  7313. }
  7314. if($state)
  7315. {
  7316. $where .= " and state = '$state'";
  7317. }
  7318. if($ktime && $jtime)
  7319. {
  7320. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7321. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7322. }
  7323. //数据排序
  7324. $order_str = "id desc";
  7325. if(empty($page))
  7326. {
  7327. $start = 0;
  7328. $perpage = 1;
  7329. }
  7330. else
  7331. {
  7332. $start = ($page - 1)*$perpage;
  7333. }
  7334. if($sku)
  7335. {
  7336. $sku = trim($sku,' ');
  7337. $sku = trim($sku,' ');
  7338. $where .= " and sku like '%$sku%'";
  7339. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7340. }
  7341. else if($title)
  7342. {
  7343. $title = trim($title,' ');
  7344. $title = trim($title,' ');
  7345. $where .= " and title like '%$title%'";
  7346. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7347. }
  7348. else
  7349. {
  7350. //$where .= " and time > '$ktime' and time < '$jtime'";
  7351. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7352. }
  7353. //取得信息列表
  7354. $rows = array();$list = array();
  7355. foreach ($info_list as $key=>$value)
  7356. {
  7357. $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'].'"');
  7358. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7359. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7360. $warehouse = $this->warehouse->read($value['warehouse']);
  7361. $info_list[$key]['warehouse'] = $warehouse['title'];
  7362. $info_list[$key]['number'] = $g;
  7363. $info_list[$key]['features'] = $x;
  7364. $info_list[$key]['x'] = $s;
  7365. }
  7366. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  7367. $pagenum = ceil($total/$perpage);
  7368. $over = $total-($start+$perpage);
  7369. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  7370. echo json_encode($rows);exit;
  7371. }
  7372. $this->data['vip'] = $vip;
  7373. $this->_Template('whlabel_fc',$this->data);
  7374. }
  7375. public function _fcmb()
  7376. {
  7377. $where = "sku != 'Preset'";
  7378. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title');
  7379. foreach ($rows as $k=>$v)
  7380. {
  7381. $warehouse = $this->warehouse->read($v['warehouse']);
  7382. $rows[$k]['warehouse'] = $warehouse['title'];
  7383. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "'.$v['warehouse'].'" and sku = "'.$v['sku'].'" and state = 11');
  7384. $rows[$k]['t'] = '';
  7385. $rows[$k]['n'] = '';
  7386. }
  7387. $title = "封货产品数据导入模板";
  7388. $titlename = "<table border=1>
  7389. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7390. <tr align='center'>
  7391. <td>仓库</td>
  7392. <td>SKU</td>
  7393. <td>产品</td>
  7394. <td>封存产品总数量</td>
  7395. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7396. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7397. </tr>
  7398. </table>";
  7399. $filename = $title.".xls";
  7400. $tail = "";
  7401. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7402. }
  7403. public function _fcexcel()
  7404. {
  7405. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7406. $config['upload_path'] = '.'.$dir ;
  7407. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7408. $config['allowed_types'] = 'xls|xlsx|csv';
  7409. $config['max_size'] = 10240;
  7410. $this->load->library('upload', $config);
  7411. $this->upload->initialize($config);
  7412. if ($this->upload->do_upload('userfile'))
  7413. {
  7414. $full_path = $dir.$this->upload->data('file_name');
  7415. $fileName = '.' . $full_path;
  7416. if (!file_exists($fileName))
  7417. {
  7418. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7419. }
  7420. else
  7421. {
  7422. libxml_use_internal_errors(true);
  7423. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7424. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7425. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7426. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7427. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7428. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7429. ++$column;//如果列数大于26行
  7430. $list = array();
  7431. for ($i = 2; $i <= $row; $i++) // 行数循环
  7432. {
  7433. $data = array();
  7434. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7435. {
  7436. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7437. }
  7438. $list[] = $data;
  7439. }
  7440. }
  7441. $i = 0;$j = 0;$ed = array();
  7442. foreach ($list as $key=>$value)
  7443. {
  7444. $time = time();
  7445. if($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4']))
  7446. {
  7447. continue;
  7448. }
  7449. $warehouse = $this->warehouse->get_title($value['0']);
  7450. $sku = $value['1'];
  7451. $type = $value['4'];//调整方式0扣减1删除
  7452. $num = $value['5'];//调整数量
  7453. //$text = $value['4'];//扣减说明
  7454. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7455. if(!$d)//如果没有这个SKU
  7456. {
  7457. $ed[] = array($sku.'-库存中不存在此SKU');
  7458. $j++;
  7459. continue;
  7460. }
  7461. if(!isset($warehouse['id']))
  7462. {
  7463. $ed[] = array($sku.'-仓库名错误!');
  7464. $j++;
  7465. continue;
  7466. }
  7467. if($type == 1 || $type == 2)//扣减库存
  7468. {
  7469. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and state = 11');
  7470. if(count($data) < abs($num))
  7471. {
  7472. $ed[] = array($sku.'-数量大于封存产品剩余数量!');
  7473. $j++;
  7474. continue;
  7475. }
  7476. if($type == 1)//转入库存
  7477. {
  7478. for($i=0;$i<abs($num);$i++)
  7479. {
  7480. $this->whlabel->save(array('state'=>0,'oldstate'=>11,'time'=>$time),$data[$i]['id']);
  7481. }
  7482. }
  7483. else if($type == 2)//删除
  7484. {
  7485. for($i=0;$i<abs($num);$i++)
  7486. {
  7487. $this->whlabel->remove($data[$i]['id']);
  7488. }
  7489. }
  7490. }
  7491. else if($type == 0)//增加库存
  7492. {
  7493. $post['sku'] = $d['sku'];
  7494. $post['shop'] = '';
  7495. $post['warehouse'] = $warehouse['id'];
  7496. $post['purchase'] = $d['purchase'];
  7497. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7498. $post['state'] = 11;
  7499. $post['title'] = $d['title'];
  7500. $post['number'] = $d['number'];
  7501. $post['features'] = $d['features'];
  7502. $post['enter'] = $time;
  7503. $post['time'] = $time;//操作时间
  7504. for($i=0;$i<$num;$i++)
  7505. {
  7506. $post['label'] = time().rand(100,999).$i;
  7507. $this->whlabel->insert($post);
  7508. }
  7509. }
  7510. sleep(1);//防止入库时间一样,需要延迟1秒
  7511. }
  7512. if($j > 0)
  7513. {
  7514. $tt = date('Ymd',time());
  7515. $title = '库存导入错误信息-'.$tt;
  7516. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7517. $tail = "\n";
  7518. $filename = $title.".xls";
  7519. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7520. $dir = '/data/excel/'.$time.'/';
  7521. $file_name = 'error_'.$time.rand(1000,9999);
  7522. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7523. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7524. fwrite($myfile,$ecl);
  7525. fclose($myfile);
  7526. $error = $dir.$file_name.'.xls';
  7527. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7528. }
  7529. else
  7530. {
  7531. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7532. }
  7533. }
  7534. }
  7535. public function _fcjxc($arg_array)
  7536. {
  7537. if(isset($_GET['excel']))
  7538. {
  7539. $category = $this->input->get('category',true);
  7540. $size = $this->input->get('size',true);
  7541. $grade = $this->input->get('grade',true);
  7542. $color = $this->input->get('color',true);
  7543. $lowe = $this->input->get('lowe',true);
  7544. $sku = $this->input->get('sku');
  7545. $title = $this->input->get('title');
  7546. $warehouse = $arg_array[0];
  7547. $usa = $this->input->get('usa',true);
  7548. $purchase = $this->input->get('purchase',true);
  7549. $lacetype = $this->input->get('lacetype',true);
  7550. $haircap = $this->input->get('haircap',true);
  7551. $density = $this->input->get('density',true);
  7552. $title = $this->input->get('title',true);
  7553. $state = $this->input->get('state',true);
  7554. $ktime = $this->input->get('ktime',true);
  7555. $jtime = $this->input->get('jtime',true);
  7556. $where = "state=11";$gj = "";$ck = "";
  7557. if($lacetype)
  7558. {
  7559. $where .= " and features like '%-$lacetype-%'";
  7560. }
  7561. if($category)
  7562. {
  7563. $where .= " and features like '%-$category-%'";
  7564. }
  7565. if($size)
  7566. {
  7567. $where .= " and features like '%-$size-%'";
  7568. }
  7569. if($grade)
  7570. {
  7571. $where .= " and features like '%-$grade-%'";
  7572. }
  7573. if($color)
  7574. {
  7575. $where .= " and features like '%-$color-%'";
  7576. }
  7577. if($lowe)
  7578. {
  7579. $where .= " and features like '%-$lowe-%'";
  7580. }
  7581. if($haircap)
  7582. {
  7583. $where .= " and features like '%-$haircap-%'";
  7584. }
  7585. if($density)
  7586. {
  7587. $where .= " and features like '%-$density-%'";
  7588. }
  7589. if($usa)
  7590. {
  7591. if(!$warehouse)
  7592. {
  7593. $where .= " and (warehouse = '5' or warehouse = '8')";
  7594. }
  7595. }
  7596. if($warehouse)
  7597. {
  7598. $where .= " and warehouse = '$warehouse'";
  7599. }
  7600. if($purchase)
  7601. {
  7602. $where .= " and purchase = '$purchase'";
  7603. }
  7604. if($state)
  7605. {
  7606. $where .= " and state = '$state'";
  7607. }
  7608. $order_str = "id desc";
  7609. if($sku)
  7610. {
  7611. $sku = trim($sku,' ');
  7612. $sku = trim($sku,' ');
  7613. $where .= " and sku like '%$sku%'";
  7614. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7615. }
  7616. else if($title)
  7617. {
  7618. $title = trim($title,' ');
  7619. $title = trim($title,' ');
  7620. $where .= " and title like '%$title%'";
  7621. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7622. }
  7623. else
  7624. {
  7625. //$where .= " and time > '$ktime' and time < '$jtime'";
  7626. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7627. }
  7628. //取得信息列表
  7629. $rows = array();$list = array();
  7630. foreach ($info_list as $key=>$value)
  7631. {
  7632. $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'].'"');
  7633. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7634. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7635. $rows[$key] = $value;
  7636. $warehouse = $this->warehouse->read($value['warehouse']);
  7637. $rows[$key]['warehouse'] = $warehouse['title'];
  7638. $rows[$key]['features'] = $g;
  7639. $rows[$key]['a'] = $x;
  7640. $rows[$key]['b'] = $s;
  7641. }
  7642. $title = "总统计表";
  7643. $titlename = "<table border=1>
  7644. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7645. <tr align='center'>
  7646. <td>仓库</td>
  7647. <td>SKU</td>
  7648. <td>产品名称</td>
  7649. <td>录入总量</td>
  7650. <td>取出总量</td>
  7651. <td>剩余总量</td>
  7652. </tr>
  7653. </table>";
  7654. $filename = $title.".xls";
  7655. $tail = "";
  7656. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7657. }
  7658. $vip = 0;
  7659. if(isset($_SESSION['api']))
  7660. {
  7661. $user = $this->user->get_api($_SESSION['api']);
  7662. if($user['vip'] == 1)
  7663. {
  7664. $vip = 1;
  7665. }
  7666. }
  7667. else
  7668. {
  7669. header('Location: /');exit;
  7670. }
  7671. $post = $this->input->post(NULL, TRUE);
  7672. if(isset($post['page']))
  7673. {
  7674. $page = $this->input->post('page',true);
  7675. $perpage = $this->input->post('perpage',true);
  7676. $category = $this->input->post('category',true);
  7677. $size = $this->input->post('size',true);
  7678. $grade = $this->input->post('grade',true);
  7679. $color = $this->input->post('color',true);
  7680. $lowe = $this->input->post('lowe',true);
  7681. $sku = $this->input->post('sku');
  7682. $title = $this->input->post('title');
  7683. $warehouse = $arg_array[0];
  7684. $usa = $this->input->post('usa',true);
  7685. $purchase = $this->input->post('purchase',true);
  7686. $lacetype = $this->input->post('lacetype',true);
  7687. $haircap = $this->input->post('haircap',true);
  7688. $density = $this->input->post('density',true);
  7689. $title = $this->input->post('title',true);
  7690. $state = $this->input->post('state',true);
  7691. $ktime = $this->input->post('ktime',true);
  7692. $jtime = $this->input->post('jtime',true);
  7693. $ktime = strtotime($ktime);
  7694. $jtime = strtotime($jtime);
  7695. $where = "state=11";$gj = "";$ck = "";
  7696. if($lacetype)
  7697. {
  7698. $where .= " and features like '%-$lacetype-%'";
  7699. }
  7700. if($category)
  7701. {
  7702. $where .= " and features like '%-$category-%'";
  7703. }
  7704. if($size)
  7705. {
  7706. $where .= " and features like '%-$size-%'";
  7707. }
  7708. if($grade)
  7709. {
  7710. $where .= " and features like '%-$grade-%'";
  7711. }
  7712. if($color)
  7713. {
  7714. $where .= " and features like '%-$color-%'";
  7715. }
  7716. if($lowe)
  7717. {
  7718. $where .= " and features like '%-$lowe-%'";
  7719. }
  7720. if($haircap)
  7721. {
  7722. $where .= " and features like '%-$haircap-%'";
  7723. }
  7724. if($density)
  7725. {
  7726. $where .= " and features like '%-$density-%'";
  7727. }
  7728. if($usa)
  7729. {
  7730. if(!$warehouse)
  7731. {
  7732. $where .= " and (warehouse = '5' or warehouse = '8')";
  7733. }
  7734. }
  7735. if($warehouse)
  7736. {
  7737. $where .= " and warehouse = '$warehouse'";
  7738. }
  7739. if($purchase)
  7740. {
  7741. $where .= " and purchase = '$purchase'";
  7742. }
  7743. if($state)
  7744. {
  7745. $where .= " and state = '$state'";
  7746. }
  7747. if($ktime && $jtime)
  7748. {
  7749. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7750. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7751. }
  7752. //数据排序
  7753. $order_str = "id desc";$xs=0;
  7754. $rows = array();$list = array();
  7755. if(empty($page))
  7756. {
  7757. $start = 0;
  7758. $perpage = 1;
  7759. }
  7760. else
  7761. {
  7762. $start = ($page - 1)*$perpage;
  7763. }
  7764. if($sku || $title)
  7765. {
  7766. if($title)
  7767. {
  7768. $title = trim($title,' ');
  7769. $title = trim($title,' ');
  7770. $where .= " and title like '%$title%'";
  7771. }
  7772. else
  7773. {
  7774. $sku = trim($sku,' ');
  7775. $sku = trim($sku,' ');
  7776. $where .= " and sku like '%$sku%'";
  7777. }
  7778. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7779. foreach ($info_list as $key=>$value)
  7780. {
  7781. $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'].'"');
  7782. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7783. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7784. $rows[$key] = $value;
  7785. $warehouse = $this->warehouse->read($value['warehouse']);
  7786. $rows[$key]['warehouse'] = $warehouse['title'];
  7787. $rows[$key]['features'] = $g;
  7788. $rows[$key]['a'] = $x;
  7789. $rows[$key]['b'] = $s;
  7790. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7791. $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天销量
  7792. $yj = $c/($xl/30);
  7793. if($yj < 7)
  7794. {
  7795. $rows[$key]['y'] = round($yj).'天销量';
  7796. }
  7797. else
  7798. {
  7799. $rows[$key]['y'] = '正常';
  7800. }
  7801. }
  7802. }
  7803. else
  7804. {
  7805. //$where .= " and time > '$ktime' and time < '$jtime'";
  7806. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7807. foreach ($info_list as $key=>$value)
  7808. {
  7809. $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'].'"');
  7810. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7811. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7812. $zs[$key] = $value;
  7813. $warehouse = $this->warehouse->read($value['warehouse']);
  7814. $zs[$key]['warehouse'] = $warehouse['title'];
  7815. $zs[$key]['features'] = $g;
  7816. $zs[$key]['a'] = $x;
  7817. $zs[$key]['b'] = $s;
  7818. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7819. $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天销量
  7820. $yj = $c/($xl/30);
  7821. if($yj < 7)
  7822. {
  7823. $zs[$key]['y'] = round($yj).'天销量';
  7824. $rows[$key] = $zs[$key];
  7825. }
  7826. }
  7827. }
  7828. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id'));
  7829. $pagenum = ceil($total/$perpage);
  7830. $over = $total-($start+$perpage);
  7831. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
  7832. echo json_encode($rows);exit;
  7833. }
  7834. $this->data['arg_array'] = $arg_array[0];
  7835. $this->_Template('whlabel_fcjxc',$this->data);
  7836. }
  7837. public function _0kcdel()
  7838. {
  7839. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7840. $config['upload_path'] = '.'.$dir ;
  7841. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7842. $config['allowed_types'] = 'xls|xlsx|csv';
  7843. $config['max_size'] = 10240;
  7844. $this->load->library('upload', $config);
  7845. $this->upload->initialize($config);
  7846. if ($this->upload->do_upload('userfile'))
  7847. {
  7848. $full_path = $dir.$this->upload->data('file_name');
  7849. $fileName = '.' . $full_path;
  7850. if (!file_exists($fileName))
  7851. {
  7852. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7853. }
  7854. else
  7855. {
  7856. require_once "./data/excel/PHPExcel/IOFactory.php";
  7857. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7858. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7859. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7860. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7861. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7862. ++$column;//如果列数大于26行
  7863. $list = array();
  7864. for ($i = 2; $i <= $row; $i++) // 行数循环
  7865. {
  7866. $data = array();
  7867. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7868. {
  7869. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7870. }
  7871. $list[] = $data;
  7872. }
  7873. }
  7874. $i = 0;$j = 0;$ed = array();
  7875. foreach ($list as $key=>$value)
  7876. {
  7877. $time = time();
  7878. if($value['0'] == "" || $value['1'] == "")
  7879. {
  7880. continue;
  7881. }
  7882. $warehouse = $this->warehouse->get_title($value['0']);
  7883. $sku = $value['1'];
  7884. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7885. if(!$d)//如果没有这个SKU
  7886. {
  7887. $ed[] = array($sku.'-库存中不存在此SKU');
  7888. $j++;
  7889. continue;
  7890. }
  7891. if(!isset($warehouse['id']))
  7892. {
  7893. $ed[] = array($sku.'-仓库名错误!');
  7894. $j++;
  7895. continue;
  7896. }
  7897. $z = $this->whlabel->find_count('sku = "'.$sku.'" and zd = "" and state = 0 and warehouse = "'.$warehouse['id'].'"');
  7898. if($z < 1)
  7899. {
  7900. $z = $this->whlabel->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'"');
  7901. foreach ($z as $v)
  7902. {
  7903. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  7904. if(count($zt) > 0)
  7905. {
  7906. $ed[] = array($sku.'-有在途库存无法删除!');
  7907. $j++;
  7908. continue;
  7909. }
  7910. $this->whlabel->remove($v['id']);
  7911. }
  7912. }
  7913. else
  7914. {
  7915. $ed[] = array($sku.'-非0库存!');
  7916. $j++;
  7917. continue;
  7918. }
  7919. }
  7920. if($j > 0)
  7921. {
  7922. $tt = date('Ymd',time());
  7923. $title = '删除0库存错误信息-'.$tt;
  7924. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7925. $tail = "\n";
  7926. $filename = $title.".xls";
  7927. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7928. $dir = '/data/excel/'.$time.'/';
  7929. $file_name = 'error_'.$time.rand(1000,9999);
  7930. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7931. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7932. fwrite($myfile,$ecl);
  7933. fclose($myfile);
  7934. $error = $dir.$file_name.'.xls';
  7935. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7936. }
  7937. else
  7938. {
  7939. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7940. }
  7941. }
  7942. }
  7943. public function _gbhtype()
  7944. {
  7945. $post = $this->input->post(NULL, TRUE);
  7946. if(isset($post['s']))
  7947. {
  7948. $n = $this->input->post('n');
  7949. $d = $this->input->post('s');
  7950. if(!$d)
  7951. {
  7952. echo json_encode(array('msg'=>'未选择需要更改的商品','success'=>false));exit;
  7953. }
  7954. $d = explode(',',trim($d,','));
  7955. $t = $this->whlabel_type->read($n);
  7956. //循环删除记录
  7957. foreach ($d as $v)
  7958. {
  7959. $u = $this->whlabel->read($v);
  7960. $data = $this->whlabel->find_all("sku = '".$u['sku']."' and purchase = '".$u['purchase']."' and features = '".$u['features']."' and warehouse = '".$u['warehouse']."'");
  7961. foreach ($data as $val)
  7962. {
  7963. $this->whlabel->save(array('type'=>$n),$val['id']);
  7964. }
  7965. }
  7966. echo json_encode(array('d'=>$d,'t'=>$t['title'],'msg'=>'修改成功!','success'=>true));
  7967. }
  7968. }
  7969. //出库、退库导出
  7970. public function _dccrtype()
  7971. {
  7972. $classid = $this->classid->sku();
  7973. $pm = $classid;
  7974. $typeclass = array();
  7975. $tc = $this->typeclass->find_all();
  7976. foreach ($tc as $v)
  7977. {
  7978. $typeclass[$v['id']] = $v;
  7979. }
  7980. $prc = array();
  7981. $purchase = $this->purchase->find_all();
  7982. foreach($purchase as $k=>$v)
  7983. {
  7984. $prc[$v['id']] = $v['title'];
  7985. }
  7986. if(isset($_GET['sid']))
  7987. {
  7988. $wh = array();
  7989. $w = $this->warehouse->find_all('1=1','id,title');
  7990. foreach ($w as $v)
  7991. {
  7992. $wh[$v['id']] = $v['title'];
  7993. }
  7994. $type = $this->input->get('excel',true);
  7995. $category = $this->input->get('category',true);
  7996. $size = $this->input->get('size',true);
  7997. $grade = $this->input->get('grade',true);
  7998. $color = $this->input->get('color',true);
  7999. $lowe = $this->input->get('lowe',true);
  8000. $sku = $this->input->get('sku',true);
  8001. $warehouse = $this->input->get('warehouse',true);
  8002. $lacetype = $this->input->get('lacetype',true);
  8003. $lacecolor = $this->input->get('lacecolor',true);
  8004. $density = $this->input->get('density',true);
  8005. $haircap = $this->input->get('haircap',true);
  8006. $purchase = $this->input->get('purchase',true);
  8007. $title = $this->input->get('title',true);
  8008. $state = $this->input->get('state',true);
  8009. $sid = $this->input->get('sid',true);
  8010. $ktime = $this->input->get('ktime',true);
  8011. $jtime = $this->input->get('jtime',true);
  8012. $ktime = strtotime($ktime);
  8013. $jtime = strtotime($jtime);
  8014. $where = "1=1";$gj = "";$ck = "";
  8015. if($category)
  8016. {
  8017. $where .= " and features like '%-$category-%'";
  8018. }
  8019. if($size)
  8020. {
  8021. $where .= " and features like '%-$size-%'";
  8022. }
  8023. if($grade)
  8024. {
  8025. $where .= " and features like '%-$grade-%'";
  8026. }
  8027. if($color)
  8028. {
  8029. $where .= " and features like '%-$color-%'";
  8030. }
  8031. if($lowe)
  8032. {
  8033. $where .= " and features like '%-$lowe-%'";
  8034. }
  8035. if($warehouse)
  8036. {
  8037. $where .= " and warehouse = '$warehouse'";
  8038. }
  8039. if($purchase)
  8040. {
  8041. $where .= " and purchase = '$purchase'";
  8042. }
  8043. if($state)
  8044. {
  8045. $where .= " and state = '$state'";
  8046. }
  8047. if($lacetype)
  8048. {
  8049. $where .= " and features like '%-$lacetype-%'";
  8050. }
  8051. if($lacecolor)
  8052. {
  8053. $where .= " and features like '%-$lacecolor-%'";
  8054. }
  8055. if($density)
  8056. {
  8057. $where .= " and features like '%-$density-%'";
  8058. }
  8059. if($haircap)
  8060. {
  8061. $where .= " and features like '%-$haircap-%'";
  8062. }
  8063. if($title)
  8064. {
  8065. $title = trim($title,' ');
  8066. $title = trim($title,' ');
  8067. $where .= " and title like '%$title%'";
  8068. }
  8069. if($sku)
  8070. {
  8071. $sku = trim($sku,' ');
  8072. $sku = trim($sku,' ');
  8073. $where .= " and sku like '%$sku%'";
  8074. }
  8075. if($ktime && $jtime)
  8076. {
  8077. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8078. }
  8079. $sidwhere = '';
  8080. if($sid)
  8081. {
  8082. $sd = "";
  8083. $s = explode(',',trim($sid,','));
  8084. foreach ($s as $value)
  8085. {
  8086. $sd .= " id = ".$value." or";
  8087. }
  8088. $sidwhere = " and (".rtrim($sd,'or').")";
  8089. }
  8090. //数据排序
  8091. $order_str = "time desc";
  8092. if(empty($page))
  8093. {
  8094. $start = 0;
  8095. $perpage = 1;
  8096. }
  8097. else
  8098. {
  8099. $start = ($page - 1)*$perpage;
  8100. }
  8101. $wh = array();
  8102. $w = $this->warehouse->find_all('1=1','id,title');
  8103. foreach ($w as $v)
  8104. {
  8105. $wh[$v['id']] = $v['title'];
  8106. }
  8107. $wt = array();
  8108. $whlabel_type = $this->whlabel_type->find_all();
  8109. foreach ($whlabel_type as $v)
  8110. {
  8111. $wt[$v['id']] = $v['title'];
  8112. }
  8113. $classid = $this->classid->sku();
  8114. $list = array();
  8115. $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');
  8116. foreach ($rows_r as $key=>$value)
  8117. {
  8118. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8119. $pm = $classid;
  8120. $jm = $classid;
  8121. $rows_r[$key]['enter'] = '入库';
  8122. $rows_r[$key]['time'] = $value['enter'];
  8123. if($value['rktype'] == 1)
  8124. {
  8125. $rows_r[$key]['rktype'] = '采购入库';
  8126. }
  8127. else if($value['rktype'] == 2)
  8128. {
  8129. $rows_r[$key]['rktype'] = '盘盈调整';
  8130. }
  8131. else if($value['rktype'] == 3)
  8132. {
  8133. $rows_r[$key]['rktype'] = '其他调整入库';
  8134. }
  8135. else if($value['rktype'] == 4)
  8136. {
  8137. $rows_r[$key]['rktype'] = '其他调整入库';
  8138. }
  8139. else if($value['rktype'] == 5)
  8140. {
  8141. $rows_r[$key]['rktype'] = '退库入库';
  8142. }
  8143. else if($value['rktype'] == 6)
  8144. {
  8145. $rows_r[$key]['rktype'] = '退货可用入库';
  8146. }
  8147. else if($value['rktype'] == 7)
  8148. {
  8149. $rows_r[$key]['rktype'] = '形态转换入库';
  8150. }
  8151. else
  8152. {
  8153. $rows_r[$key]['rktype'] = '';
  8154. }
  8155. $features = explode('-',trim($value['features'],'-'));
  8156. foreach($features as $v)
  8157. {
  8158. if(isset($typeclass[$v]))
  8159. {
  8160. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8161. $pm[$typeclass[$v]['classid']] = $zh[0];
  8162. }
  8163. if(isset($typeclass[$v]))
  8164. {
  8165. if(isset($jm[$typeclass[$v]['classid']]))
  8166. {
  8167. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8168. }
  8169. }
  8170. }
  8171. $zh = implode(" ",$pm);
  8172. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8173. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8174. $rows_r[$key]['zh'] = $zh;
  8175. $jm = array_filter($jm);
  8176. $rows_r[$key]['features'] = implode("-",$jm);
  8177. $rows_r[$key]['number'] = $this->whlabel->find_count($where." and enter = '".$value['enter']."' ".$sidwhere);
  8178. }
  8179. $rows_c = $this->whlabel->find_all($where." and outk > '$ktime' and outk < '$jtime' ".$sidwhere,'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  8180. foreach ($rows_c as $key=>$value)
  8181. {
  8182. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8183. $pm = $classid;
  8184. $jm = $classid;
  8185. $rows_c[$key]['time'] = $value['outk'];
  8186. $rows_c[$key]['outk'] = '出库';
  8187. if($value['cktype'] == 1)
  8188. {
  8189. $rows_c[$key]['cktype'] = '销售出库';
  8190. }
  8191. else if($value['cktype'] == 2)
  8192. {
  8193. $rows_c[$key]['cktype'] = '销售美国出库';
  8194. }
  8195. else if($value['cktype'] == 3)
  8196. {
  8197. $rows_c[$key]['cktype'] = '盘亏调整';
  8198. }
  8199. else if($value['cktype'] == 4)
  8200. {
  8201. $rows_c[$key]['cktype'] = '其他调整出库';
  8202. }
  8203. else if($value['cktype'] == 5)
  8204. {
  8205. $rows_c[$key]['cktype'] = '形态转换出库';
  8206. }
  8207. else
  8208. {
  8209. $rows_c[$key]['cktype'] = '';
  8210. }
  8211. $features = explode('-',trim($value['features'],'-'));
  8212. foreach($features as $v)
  8213. {
  8214. if(isset($typeclass[$v]))
  8215. {
  8216. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8217. $pm[$typeclass[$v]['classid']] = $zh[0];
  8218. }
  8219. if(isset($typeclass[$v]))
  8220. {
  8221. if(isset($jm[$typeclass[$v]['classid']]))
  8222. {
  8223. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8224. }
  8225. }
  8226. }
  8227. $zh = implode(" ",$pm);
  8228. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8229. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8230. $rows_c[$key]['zh'] = $zh;
  8231. $jm = array_filter($jm);
  8232. $rows_c[$key]['features'] = implode("-",$jm);
  8233. $rows_c[$key]['number'] = 1;
  8234. }
  8235. $merged = $rows_r;
  8236. foreach ($rows_c as $key => $value)
  8237. {
  8238. if (isset($merged[$key]))
  8239. {
  8240. $merged[] = $value;
  8241. }
  8242. else
  8243. {
  8244. $merged[$key] = $value;
  8245. }
  8246. }
  8247. usort($merged, function($a, $b)
  8248. {
  8249. return $a['time'] - $b['time'];
  8250. });
  8251. foreach ($merged as $key=>$value)
  8252. {
  8253. $merged[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  8254. }
  8255. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime);
  8256. $titlename = "<table border=1>
  8257. <tr align='center'>
  8258. <td>仓库</td>
  8259. <td>SKU</td>
  8260. <td>商品名称</td>
  8261. <td>仓库品名</td>
  8262. <td>料号</td>
  8263. <td>时间</td>
  8264. <td>操作</td>
  8265. <td>类型</td>
  8266. <td>数量</td>
  8267. <td>备注</td>
  8268. </tr>
  8269. </table>";
  8270. $filename = $title.".xlsx";
  8271. $tail = "";
  8272. $this->excel->get_fz2($merged,$titlename,$filename,$tail);
  8273. }
  8274. }
  8275. }