Whlabel.php 266 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441
  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. $hairnumber = $this->input->post('hairnumber',true);
  596. $cklx = $this->input->post('cklx',true);
  597. $ktime = $this->input->post('ktime',true);
  598. $jtime = $this->input->post('jtime',true);
  599. $ktime = strtotime($ktime);
  600. $jtime = strtotime($jtime);
  601. $where = "1=1";$gj = "";$ck = "";
  602. if($usa)
  603. {
  604. if(!$warehouse)
  605. {
  606. $where .= " and (warehouse = '5' or warehouse = '8')";
  607. }
  608. }
  609. if($warehouse)
  610. {
  611. $where .= " and warehouse = '$warehouse'";
  612. }
  613. if($details)
  614. {
  615. $where .= " and details = '$details'";
  616. }
  617. if($purchase)
  618. {
  619. $where .= " and purchase = '$purchase'";
  620. }
  621. if($state)
  622. {
  623. $where .= " and state = '$state'";
  624. }
  625. if($lacetype)
  626. {
  627. $where .= " and features like '%-$lacetype-%'";
  628. }
  629. if($category)
  630. {
  631. $where .= " and features like '%-$category-%'";
  632. }
  633. if($size)
  634. {
  635. $where .= " and features like '%-$size-%'";
  636. }
  637. if($grade)
  638. {
  639. $where .= " and features like '%-$grade-%'";
  640. }
  641. if($color)
  642. {
  643. $where .= " and features like '%-$color-%'";
  644. }
  645. if($lowe)
  646. {
  647. $where .= " and features like '%-$lowe-%'";
  648. }
  649. if($haircap)
  650. {
  651. $where .= " and features like '%-$haircap-%'";
  652. }
  653. if($density)
  654. {
  655. $where .= " and features like '%-$density-%'";
  656. }
  657. if($lacecolor)
  658. {
  659. $where .= " and features like '%-$lacecolor-%'";
  660. }
  661. if(!empty($hairnumber)){
  662. $where .= " and features like '%-128-%' ";
  663. if($hairnumber < 0){
  664. $class_list = $this->typeclass->find_all('classid = 43');
  665. foreach($class_list as $v){
  666. $where .= " and features not like '%-".$v['id']."-%'";
  667. }
  668. }else{
  669. $where .= " and features like '%-$hairnumber-%'";
  670. }
  671. }
  672. $where_add = '';
  673. if($cklx)
  674. {
  675. $shop = $this->shop->read($cklx);
  676. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  677. }
  678. if($ktime && $jtime)
  679. {
  680. $gj = " and enter > '$ktime' and enter < '$jtime'";
  681. $ck = " and outk > '$ktime' and outk < '$jtime'";
  682. }
  683. //数据排序
  684. $order_str = "id desc";
  685. if(empty($page))
  686. {
  687. $start = 0;
  688. $perpage = 1;
  689. }
  690. else
  691. {
  692. $start = ($page - 1)*$perpage;
  693. }
  694. if($sku)
  695. {
  696. $sku = trim($sku,' ');
  697. $sku = trim($sku,' ');
  698. $where .= " and sku like '%$sku%'";
  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. else if($title)
  702. {
  703. $title = trim($title,' ');
  704. $title = trim($title,' ');
  705. $where .= " and title like '%$title%'";
  706. $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);
  707. }
  708. else
  709. {
  710. //$where .= " and time > '$ktime' and time < '$jtime'";
  711. $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);
  712. }
  713. //取得信息列表
  714. $rows = array();$list = array();
  715. foreach ($info_list as $key=>$value)
  716. {
  717. $warehouse = $this->warehouse->read($value['warehouse']);
  718. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  719. $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  720. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  721. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  722. $number = $value['number'];$ftime = time()-15*24*3600;
  723. $info_list[$key]['warehouse'] = $warehouse['title'];
  724. $info_list[$key]['features'] = count($c);
  725. $z = count($z);//查看订单号
  726. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  727. $ztdata = '';
  728. if(count($zt) > 0)
  729. {
  730. foreach ($zt as $vv)
  731. {
  732. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  733. }
  734. }
  735. $info_list[$key]['number'] = $ztdata;
  736. $info_list[$key]['sm'] = $z;
  737. $details = array();
  738. $cpid = array();
  739. foreach ($c as $k=>$v)
  740. {
  741. $details[$v['details']] = $v['details'];
  742. if($v['cpid'] != 0)
  743. {
  744. $cpid[$v['cpid']] = $v['cpid'];
  745. }
  746. }
  747. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  748. if($value['shop'] != '')
  749. {
  750. $shop = explode(',',trim($value['shop'],','));
  751. $shop = $this->shop->read($shop[0]);
  752. $info_list[$key]['shop'] = $shop['shopname'];
  753. }
  754. }
  755. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  756. $pagenum = ceil($total/$perpage);
  757. $over = $total-($start+$perpage);
  758. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  759. echo json_encode($rows);exit;
  760. }
  761. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  762. $this->_Template('whlabel_typedy',$this->data);
  763. }
  764. //进销存浏览
  765. public function _typedy_ck($arg_array)
  766. {
  767. $prc = array();
  768. $purchase = $this->purchase->find_all();
  769. foreach($purchase as $k=>$v)
  770. {
  771. $prc[$v['id']] = $v['title'];
  772. }
  773. $post = $this->input->post(NULL, TRUE);
  774. if(isset($post['page']))
  775. {
  776. $page = $this->input->post('page',true);
  777. $perpage = $this->input->post('perpage',true);
  778. $category = $this->input->post('category',true);
  779. $size = $this->input->post('size',true);
  780. $grade = $this->input->post('grade',true);
  781. $color = $this->input->post('color',true);
  782. $lowe = $this->input->post('lowe',true);
  783. $sku = $this->input->post('sku');
  784. $title = $this->input->post('title');
  785. $warehouse = $this->input->post('warehouse',true);
  786. $usa = $this->input->post('usa',true);
  787. $purchase = $this->input->post('purchase',true);
  788. $lacetype = $this->input->post('lacetype',true);
  789. $haircap = $this->input->post('haircap',true);
  790. $density = $this->input->post('density',true);
  791. $details = $this->input->post('details',true);
  792. $state = $this->input->post('state',true);
  793. $lacecolor = $this->input->post('lacecolor',true);
  794. $cklx = $this->input->post('cklx',true);
  795. $ktime = $this->input->post('ktime',true);
  796. $jtime = $this->input->post('jtime',true);
  797. $ktime = strtotime($ktime);
  798. $jtime = strtotime($jtime);
  799. $where = "1=1";$gj = "";$ck = "";
  800. if($lacetype)
  801. {
  802. $where .= " and features like '%-$lacetype-%'";
  803. }
  804. if($category)
  805. {
  806. $where .= " and features like '%-$category-%'";
  807. }
  808. if($size)
  809. {
  810. $where .= " and features like '%-$size-%'";
  811. }
  812. if($grade)
  813. {
  814. $where .= " and features like '%-$grade-%'";
  815. }
  816. if($color)
  817. {
  818. $where .= " and features like '%-$color-%'";
  819. }
  820. if($lowe)
  821. {
  822. $where .= " and features like '%-$lowe-%'";
  823. }
  824. if($haircap)
  825. {
  826. $where .= " and features like '%-$haircap-%'";
  827. }
  828. if($density)
  829. {
  830. $where .= " and features like '%-$density-%'";
  831. }
  832. if($lacecolor)
  833. {
  834. $where .= " and features like '%-$lacecolor-%'";
  835. }
  836. if($usa)
  837. {
  838. if(!$warehouse)
  839. {
  840. $where .= " and (warehouse = '5' or warehouse = '8')";
  841. }
  842. }
  843. if($warehouse)
  844. {
  845. $where .= " and warehouse = '$warehouse'";
  846. }
  847. if($details)
  848. {
  849. $where .= " and details = '$details'";
  850. }
  851. if($purchase)
  852. {
  853. $where .= " and purchase = '$purchase'";
  854. }
  855. if($state)
  856. {
  857. $where .= " and state = '$state'";
  858. }
  859. $where_add = '';
  860. if($cklx)
  861. {
  862. $shop = $this->shop->read($cklx);
  863. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  864. }
  865. if($ktime && $jtime)
  866. {
  867. $gj = " and enter > '$ktime' and enter < '$jtime'";
  868. $ck = " and outk > '$ktime' and outk < '$jtime'";
  869. }
  870. //数据排序
  871. $order_str = "id desc";
  872. if(empty($page))
  873. {
  874. $start = 0;
  875. $perpage = 1;
  876. }
  877. else
  878. {
  879. $start = ($page - 1)*$perpage;
  880. }
  881. if($sku)
  882. {
  883. $sku = trim($sku,' ');
  884. $sku = trim($sku,' ');
  885. $where .= " and sku like '%$sku%'";
  886. $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);
  887. }
  888. else if($title)
  889. {
  890. $title = trim($title,' ');
  891. $title = trim($title,' ');
  892. $where .= " and title like '%$title%'";
  893. $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);
  894. }
  895. else
  896. {
  897. //$where .= " and time > '$ktime' and time < '$jtime'";
  898. $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);
  899. }
  900. //取得信息列表
  901. $rows = array();$list = array();
  902. foreach ($info_list as $key=>$value)
  903. {
  904. $warehouse = $this->warehouse->read($value['warehouse']);
  905. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  906. $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,text');
  907. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  908. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$c[0]['text'].'</p>';
  909. $ftime = time()-15*24*3600;
  910. $info_list[$key]['warehouse'] = $warehouse['title'];
  911. $info_list[$key]['features'] = count($c)<10?"<em style='color:#F00'>".count($c)."</em>":count($c);
  912. //$z = count($z);//查看订单号
  913. //$info_list[$key]['zd'] = $z;
  914. $details = array();
  915. $cpid = array();
  916. foreach ($c as $k=>$v)
  917. {
  918. $details[$v['details']] = $v['details'];
  919. if($v['cpid'] != 0)
  920. {
  921. $cpid[$v['cpid']] = $v['cpid'];
  922. }
  923. }
  924. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  925. if($value['shop'] != '')
  926. {
  927. $shop = explode(',',trim($value['shop'],','));
  928. $shop = $this->shop->read($shop[0]);
  929. $info_list[$key]['shop'] = $shop['shopname'];
  930. }
  931. }
  932. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  933. $pagenum = ceil($total/$perpage);
  934. $over = $total-($start+$perpage);
  935. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  936. echo json_encode($rows);exit;
  937. }
  938. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  939. $this->_Template('whlabel_typedy_ck',$this->data);
  940. }
  941. public function _typeck($arg_array)
  942. {
  943. $prc = array();
  944. $purchase = $this->purchase->find_all();
  945. foreach($purchase as $k=>$v)
  946. {
  947. $prc[$v['id']] = $v['title'];
  948. }
  949. $post = $this->input->post(NULL, TRUE);
  950. if(isset($post['page']))
  951. {
  952. $page = $this->input->post('page',true);
  953. $perpage = $this->input->post('perpage',true);
  954. $category = $this->input->post('category',true);
  955. $size = $this->input->post('size',true);
  956. $grade = $this->input->post('grade',true);
  957. $color = $this->input->post('color',true);
  958. $lacecolor = $this->input->post('lacecolor',true);
  959. $lowe = $this->input->post('lowe',true);
  960. $sku = $this->input->post('sku');
  961. $title = $this->input->post('title');
  962. $warehouse = 13;
  963. $usa = $this->input->post('usa',true);
  964. $purchase = $this->input->post('purchase',true);
  965. $lacetype = $this->input->post('lacetype',true);
  966. $haircap = $this->input->post('haircap',true);
  967. $density = $this->input->post('density',true);
  968. $details = $this->input->post('details',true);
  969. $state = $this->input->post('state',true);
  970. $ktime = $this->input->post('ktime',true);
  971. $jtime = $this->input->post('jtime',true);
  972. $ktime = strtotime($ktime);
  973. $jtime = strtotime($jtime);
  974. $where = "1=1";$gj = "";$ck = "";
  975. if($lacetype)
  976. {
  977. $where .= " and features like '%-$lacetype-%'";
  978. }
  979. if($category)
  980. {
  981. $where .= " and features like '%-$category-%'";
  982. }
  983. if($size)
  984. {
  985. $where .= " and features like '%-$size-%'";
  986. }
  987. if($grade)
  988. {
  989. $where .= " and features like '%-$grade-%'";
  990. }
  991. if($color)
  992. {
  993. $where .= " and features like '%-$color-%'";
  994. }
  995. if($lacecolor)
  996. {
  997. $where .= " and features like '%-$lacecolor-%'";
  998. }
  999. if($lowe)
  1000. {
  1001. $where .= " and features like '%-$lowe-%'";
  1002. }
  1003. if($haircap)
  1004. {
  1005. $where .= " and features like '%-$haircap-%'";
  1006. }
  1007. if($density)
  1008. {
  1009. $where .= " and features like '%-$density-%'";
  1010. }
  1011. if($warehouse)
  1012. {
  1013. $where .= " and warehouse = '$warehouse'";
  1014. }
  1015. if($details)
  1016. {
  1017. $where .= " and details = '$details'";
  1018. }
  1019. if($purchase)
  1020. {
  1021. $where .= " and purchase = '$purchase'";
  1022. }
  1023. if($state)
  1024. {
  1025. $where .= " and state = '$state'";
  1026. }
  1027. if($ktime && $jtime)
  1028. {
  1029. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1030. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1031. }
  1032. //数据排序
  1033. $order_str = "id desc";
  1034. if(empty($page))
  1035. {
  1036. $start = 0;
  1037. $perpage = 1;
  1038. }
  1039. else
  1040. {
  1041. $start = ($page - 1)*$perpage;
  1042. }
  1043. if($sku)
  1044. {
  1045. $sku = trim($sku,' ');
  1046. $sku = trim($sku,' ');
  1047. $where .= " and sku like '%$sku%'";
  1048. }
  1049. else if($title)
  1050. {
  1051. $title = trim($title,' ');
  1052. $title = trim($title,' ');
  1053. $where .= " and title like '%$title%'";
  1054. }
  1055. $info_list = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,sm,details,cpbz,features,number,',$order_str,$start,$perpage);
  1056. //取得信息列表
  1057. $t = array();
  1058. $typeclass = $this->typeclass->find_all();
  1059. foreach ($typeclass as $v)
  1060. {
  1061. $t[$v['id']] = $v;
  1062. }
  1063. $rows = array();$list = array();
  1064. foreach ($info_list as $key=>$value)
  1065. {
  1066. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1067. $mc = $this->whlabel->find_all("sku = '".$value['sku']."' and features = '".$value['features']."' and warehouse = '".$value['warehouse']."'",'cpbz','id desc',0,1);
  1068. $warehouse = $this->warehouse->read($value['warehouse']);
  1069. $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');
  1070. $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'].'"');
  1071. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  1072. $number = $value['number'];$ftime = time()-15*24*3600;
  1073. $z = count($z);//查看订单号
  1074. $info_list[$key]['warehouse'] = $warehouse['title'];
  1075. $info_list[$key]['features'] = count($c);
  1076. $info_list[$key]['number'] = $z;
  1077. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  1078. $details = array();
  1079. $cpid = array();
  1080. foreach ($c as $k=>$v)
  1081. {
  1082. $details[$v['details']] = $v['details'];
  1083. if($v['cpid'] != 0)
  1084. {
  1085. $cpid[$v['cpid']] = $v['cpid'];
  1086. }
  1087. }
  1088. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1089. $classid = $this->classid->sku();
  1090. $pm = $classid;
  1091. $features = explode('-',trim($value['features'],'-'));
  1092. foreach($features as $v)
  1093. {
  1094. $zh = explode('|',trim($t[$v]['zh'],'|'));
  1095. $pm[$t[$v]['classid']] = $zh[0];
  1096. }
  1097. $zh = implode(" ",$pm);
  1098. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1099. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1100. $info_list[$key]['sm'] = $zh;
  1101. }
  1102. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  1103. $pagenum = ceil($total/$perpage);
  1104. $over = $total-($start+$perpage);
  1105. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1106. echo json_encode($rows);exit;
  1107. }
  1108. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  1109. $this->_Template('whlabel_typeck',$this->data);
  1110. }
  1111. //进销存导出
  1112. public function _whlabeckdc()
  1113. {
  1114. $prc = array();
  1115. $purchase = $this->purchase->find_all();
  1116. foreach($purchase as $k=>$v)
  1117. {
  1118. $prc[$v['id']] = $v['title'];
  1119. }
  1120. if(isset($_GET['excel']))
  1121. {
  1122. $where = "sku != 'Preset'";
  1123. //数据排序
  1124. $order_str = "id desc";
  1125. if(empty($page))
  1126. {
  1127. $start = 0;
  1128. $perpage = 1;
  1129. }
  1130. else
  1131. {
  1132. $start = ($page - 1)*$perpage;
  1133. }
  1134. $category = $this->input->get('category',true);
  1135. $color = $this->input->get('color',true);
  1136. $lowe = $this->input->get('lowe',true);
  1137. $lacetype = $this->input->get('lacetype',true);
  1138. $size = $this->input->get('size',true);
  1139. $density = $this->input->get('density',true);
  1140. $haircap = $this->input->get('haircap',true);
  1141. $sku = $this->input->get('sku',true);
  1142. $details = $this->input->get('details',true);
  1143. $warehouse = 13;
  1144. $excelid = $this->input->get('sid',true);
  1145. if($category)
  1146. {
  1147. $where .= " and features like '%-$category-%'";
  1148. }
  1149. if($color)
  1150. {
  1151. $where .= " and features like '%-$color-%'";
  1152. }
  1153. if($lowe)
  1154. {
  1155. $where .= " and features like '%-$lowe-%'";
  1156. }
  1157. if($lacetype)
  1158. {
  1159. $where .= " and features like '%-$lacetype-%'";
  1160. }
  1161. if($size)
  1162. {
  1163. $where .= " and features like '%-$size-%'";
  1164. }
  1165. if($density)
  1166. {
  1167. $where .= " and features like '%-$density-%'";
  1168. }
  1169. if($haircap)
  1170. {
  1171. $where .= " and features like '%-$haircap-%'";
  1172. }
  1173. if($warehouse)
  1174. {
  1175. $where .= " and warehouse = '$warehouse'";
  1176. }
  1177. if($sku)
  1178. {
  1179. $where .= " and sku like '%$sku%'";
  1180. }
  1181. if($details)
  1182. {
  1183. $where .= " and details = '$details'";
  1184. }
  1185. $xzid = '';
  1186. if($excelid)
  1187. {
  1188. $excelid = explode(',',trim($excelid,','));
  1189. foreach ($excelid as $key=>$value)
  1190. {
  1191. $xzid .= " id = ".$value." or";
  1192. }
  1193. $xzid = " and (".rtrim($xzid,'or').")";;
  1194. }
  1195. //取得信息列表
  1196. /**
  1197. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1198. $rows = array();$list = array();
  1199. foreach ($info_list as $key=>$value)
  1200. {
  1201. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1202. }
  1203. **/
  1204. $wh = array();
  1205. $w = $this->warehouse->find_all('1=1','id,title');
  1206. foreach ($w as $v)
  1207. {
  1208. $wh[$v['id']] = $v['title'];
  1209. }
  1210. $tc = array();$tcdata = array();
  1211. $typeclass = $this->typeclass->find_all();
  1212. foreach ($typeclass as $v)
  1213. {
  1214. $tc[$v['id']] = $v;
  1215. }
  1216. $list = array();
  1217. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1218. foreach ($rows as $key=>$value)
  1219. {
  1220. $bm = '03';
  1221. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1222. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1223. $classid = $this->classid->sku();
  1224. $pm = $classid;
  1225. $jm = $classid;
  1226. $features = explode('-',trim($value['features'],'-'));
  1227. foreach($features as $v)
  1228. {
  1229. if(isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']]))
  1230. {
  1231. if($tc[$v]['bm'] != '')
  1232. {
  1233. $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
  1234. }
  1235. }
  1236. if(isset($tc[$v]))
  1237. {
  1238. $zh = explode('|',trim($tc[$v]['zh'],'|'));
  1239. $pm[$tc[$v]['classid']] = $zh[0];
  1240. }
  1241. if(isset($tc[$v]))
  1242. {
  1243. if(isset($jm[$tc[$v]['classid']]))
  1244. {
  1245. $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
  1246. }
  1247. }
  1248. }
  1249. $zh = implode(" ",$pm);
  1250. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1251. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1252. $rows[$key]['dbcontent'] = $zh;
  1253. $rows[$key]['cpbz'] = $bm.implode("",$bmpx);
  1254. $jm = array_filter($jm);
  1255. $rows[$key]['cs'] = implode("-",$jm);
  1256. $sd = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,cpbz,state');
  1257. $details = array();
  1258. $cpid = array();
  1259. $cpbz = array();
  1260. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  1261. foreach ($sd as $k=>$v)
  1262. {
  1263. if($v['state'] == 0)
  1264. {
  1265. $c++;
  1266. }
  1267. if($v['state'] != 9)
  1268. {
  1269. $g++;
  1270. }
  1271. if($v['state'] == 1)
  1272. {
  1273. $x++;
  1274. }
  1275. if($v['state'] == 2)
  1276. {
  1277. $t++;
  1278. }
  1279. if($v['state'] == 8)
  1280. {
  1281. $s++;
  1282. }
  1283. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  1284. {
  1285. $q++;
  1286. }
  1287. $details[$v['details']] = $v['details'];
  1288. if($v['cpid'] != 0)
  1289. {
  1290. $cpid[$v['cpid']] = $v['cpid'];
  1291. }
  1292. if($v['cpbz'] != '')
  1293. {
  1294. $cpbz[$v['cpbz']] = $v['cpbz'];
  1295. }
  1296. }
  1297. $rows[$key]['details'] = implode("、",$details);
  1298. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  1299. $number = $value['number'];
  1300. $ftime = time()-15*24*3600;
  1301. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1302. $rows[$key]['number'] = $g;
  1303. $rows[$key]['features'] = $c;
  1304. $rows[$key]['x'] = $x;
  1305. $rows[$key]['t'] = $t;
  1306. $rows[$key]['s'] = $s;
  1307. $rows[$key]['q'] = $q;
  1308. $rows[$key]['wzsl'] = count($details);
  1309. }
  1310. $title = "进销存统计表".date('Y-m-d',time());
  1311. $titlename = "<table border=1>
  1312. <tr><th colspan='12' align='center'><h3>".$title."<h3></th></tr>
  1313. <tr align='center'>
  1314. <td>仓库</td>
  1315. <td>供应商</td>
  1316. <td>位置</td>
  1317. <td>库存编码</td>
  1318. <td>SKU</td>
  1319. <td>用友编码</td>
  1320. <td>用友料号</td>
  1321. <td>产品英文名</td>
  1322. <td>产品中文名</td>
  1323. <td>入库总量</td>
  1324. <td>库存数量</td>
  1325. <td>销售数量</td>
  1326. <td>退货数量</td>
  1327. <td>删除数量</td>
  1328. <td>其它操作</td>
  1329. <td>位置数量</td>
  1330. </tr>
  1331. </table>";
  1332. $filename = $title.".xls";
  1333. $tail = "";
  1334. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1335. }
  1336. }
  1337. public function _type()
  1338. {
  1339. $vip = 0;
  1340. if(isset($_SESSION['api']))
  1341. {
  1342. $user = $this->user->get_api($_SESSION['api']);
  1343. $fgshop = "";$sid = "";
  1344. $usersp = explode('|',trim($user['shop'],'|'));
  1345. foreach ($usersp as $value)
  1346. {
  1347. $fgshop .= " shop = ".$value." or";
  1348. $sid .= " id = ".$value." or";
  1349. }
  1350. if($user['vip'] == 1)
  1351. {
  1352. $vip = 1;
  1353. }
  1354. }
  1355. else
  1356. {
  1357. header('Location: /');exit;
  1358. }
  1359. $prc = array();
  1360. $purchase = $this->purchase->find_all();
  1361. foreach($purchase as $k=>$v)
  1362. {
  1363. $prc[$v['id']] = $v['title'];
  1364. }
  1365. $company = array();
  1366. $ct = $this->company->find_all();
  1367. foreach($ct as $k=>$v)
  1368. {
  1369. $company[$v['id']] = $v['title'];
  1370. }
  1371. $sp = array();
  1372. $s = $this->shop->find_all('1=1','id,shopname');
  1373. foreach ($s as $v)
  1374. {
  1375. $sp[$v['id']] = $v['shopname'];
  1376. }
  1377. $wh = array();
  1378. $w = $this->warehouse->find_all('1=1','id,title');
  1379. foreach ($w as $v)
  1380. {
  1381. $wh[$v['id']] = $v['title'];
  1382. }
  1383. $post = $this->input->post(NULL, TRUE);
  1384. if(isset($post['page']))
  1385. {
  1386. $page = $this->input->post('page',true);
  1387. $perpage = $this->input->post('perpage',true);
  1388. $category = $this->input->post('category',true);
  1389. $size = $this->input->post('size',true);
  1390. $grade = $this->input->post('grade',true);
  1391. $color = $this->input->post('color',true);
  1392. $lowe = $this->input->post('lowe',true);
  1393. $sku = $this->input->post('sku');
  1394. $title = $this->input->post('title');
  1395. $warehouse = $this->input->post('warehouse',true);
  1396. $usa = $this->input->post('usa',true);
  1397. $purchase = $this->input->post('purchase',true);
  1398. $lacetype = $this->input->post('lacetype',true);
  1399. $haircap = $this->input->post('haircap',true);
  1400. $density = $this->input->post('density',true);
  1401. $details = $this->input->post('details',true);
  1402. $state = $this->input->post('state',true);
  1403. $shop = $this->input->post('shop',true);
  1404. $lacecolor = $this->input->post('lacecolor',true);
  1405. $hairnumber = $this->input->post('hairnumber',true);
  1406. $type = $this->input->post('type',true);
  1407. $ktime = $this->input->post('ktime',true);
  1408. $jtime = $this->input->post('jtime',true);
  1409. $ktime = strtotime($ktime);
  1410. $jtime = strtotime($jtime);
  1411. $cpbz = $this->input->post('cpbz',true);
  1412. $where = "1=1";$gj = "";$ck = "";
  1413. if($usa)
  1414. {
  1415. if(!$warehouse)
  1416. {
  1417. $where .= " and (warehouse = '5' or warehouse = '8')";
  1418. }
  1419. }
  1420. if($warehouse)
  1421. {
  1422. $where .= " and warehouse = '$warehouse'";
  1423. }
  1424. if($details)
  1425. {
  1426. $where .= " and details = '$details'";
  1427. }
  1428. if($purchase)
  1429. {
  1430. $where .= " and purchase = '$purchase'";
  1431. }
  1432. if($state)
  1433. {
  1434. $where .= " and state = '$state'";
  1435. }
  1436. if($shop)
  1437. {
  1438. $where .= " and shop like '%$shop%'";
  1439. }
  1440. if($type)
  1441. {
  1442. $where .= " and type = '$type'";
  1443. }
  1444. if($ktime && $jtime)
  1445. {
  1446. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1447. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1448. }
  1449. if($cpbz){
  1450. $where .= " and cpbz like '%$cpbz%' ";
  1451. }
  1452. if($lacecolor)
  1453. {
  1454. $where .= " and features like '%-$lacecolor-%'";
  1455. }
  1456. if($lacetype)
  1457. {
  1458. $where .= " and features like '%-$lacetype-%'";
  1459. }
  1460. if($category)
  1461. {
  1462. $where .= " and features like '%-$category-%'";
  1463. }
  1464. if($size)
  1465. {
  1466. $where .= " and features like '%-$size-%'";
  1467. }
  1468. if($grade)
  1469. {
  1470. $where .= " and features like '%-$grade-%'";
  1471. }
  1472. if($color)
  1473. {
  1474. $where .= " and features like '%-$color-%'";
  1475. }
  1476. if($lowe)
  1477. {
  1478. $where .= " and features like '%-$lowe-%'";
  1479. }
  1480. if($haircap)
  1481. {
  1482. $where .= " and features like '%-$haircap-%'";
  1483. }
  1484. if($density)
  1485. {
  1486. $where .= " and features like '%-$density-%'";
  1487. }
  1488. if(!empty($hairnumber)){
  1489. $where .= " and features like '%-128-%' ";
  1490. if($hairnumber < 0){
  1491. $class_list = $this->typeclass->find_all('classid = 43');
  1492. foreach($class_list as $v){
  1493. $where .= " and features not like '%-".$v['id']."-%'";
  1494. }
  1495. }else{
  1496. $where .= " and features like '%-$hairnumber-%'";
  1497. }
  1498. }
  1499. //数据排序
  1500. $order_str = "id desc";
  1501. if(empty($page))
  1502. {
  1503. $start = 0;
  1504. $perpage = 1;
  1505. }
  1506. else
  1507. {
  1508. $start = ($page - 1)*$perpage;
  1509. }
  1510. $fjnr = '';
  1511. if($sku)
  1512. {
  1513. $sku = trim($sku,' ');
  1514. $sku = trim($sku,' ');
  1515. $fjnr .= " and sku like '%$sku%'";
  1516. }
  1517. if($title)
  1518. {
  1519. $title = trim($title,' ');
  1520. $title = trim($title,' ');
  1521. $fjnr .= " and title like '%$title%'";
  1522. }
  1523. $wt = array();
  1524. $whlabel_type = $this->whlabel_type->find_all();
  1525. foreach ($whlabel_type as $v)
  1526. {
  1527. $wt[$v['id']] = $v['title'];
  1528. }
  1529. //$where .= " and time > '$ktime' and time < '$jtime'";
  1530. $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
  1531. //取得信息列表
  1532. $rows = array();$list = array();
  1533. foreach ($info_list as $key=>$value)
  1534. {
  1535. if(isset($wt[$value['type']]))
  1536. {
  1537. $info_list[$key]['type'] = $wt[$value['type']];
  1538. }
  1539. else
  1540. {
  1541. $info_list[$key]['type'] = '未设置';
  1542. }
  1543. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1544. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1545. $ztdata = '';
  1546. if(count($zt) > 0)
  1547. {
  1548. foreach ($zt as $vv)
  1549. {
  1550. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1551. }
  1552. }
  1553. $qbdata = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1554. $cdata = array_filter($qbdata, function($item) {
  1555. return $item['state'] < 1;
  1556. });
  1557. $c = array_sum(array_column($cdata, 'jnum'));
  1558. $gdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1559. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1560. });
  1561. $g = array_sum(array_column($gdata, 'jnum'));
  1562. $xdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1563. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1564. });
  1565. $x = array_sum(array_column($xdata, 'jnum'));
  1566. $tdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1567. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1568. });
  1569. $t = array_sum(array_column($tdata, 'jnum'));
  1570. $zdata = array_filter($qbdata, function($item) {
  1571. return $item['zd'] != "" && $item['state'] < 1;
  1572. });
  1573. $z = array_sum(array_column($zdata, 'jnum'));
  1574. $zdata = array_filter($qbdata, function($item) {
  1575. return $item['zd'] != "" && $item['state'] < 1;
  1576. });
  1577. $z = array_sum(array_column($zdata, 'jnum'));
  1578. //$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');
  1579. //$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'].'"');
  1580. //$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'].'"');
  1581. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1582. //$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'].'"');
  1583. $details = array();
  1584. $cpid = array();
  1585. $od = array();$odid = '';
  1586. $companytitle = '';
  1587. foreach ($qbdata as $v)
  1588. {
  1589. if($v['zd'] != "" && $v['state'] < 1)
  1590. {
  1591. if(!isset($od[$v['zd']]))
  1592. {
  1593. $od[$v['zd']] = 1;//所有数据sku
  1594. }
  1595. else
  1596. {
  1597. $od[$v['zd']] = $od[$v['zd']]+1;
  1598. }
  1599. }
  1600. if($v['state'] < 1)
  1601. {
  1602. $details[$v['details']] = $v['details'];
  1603. if($v['cpid'] != 0)
  1604. {
  1605. $cpid[$v['cpid']] = $v['cpid'];
  1606. }
  1607. }
  1608. if($v['companytitle'] != '' && stripos($companytitle,$company[$v['companytitle']]) === false)
  1609. {
  1610. $companytitle .= '<p>'.$company[$v['companytitle']].'</p>';
  1611. }
  1612. }
  1613. foreach ($od as $k=>$vv)
  1614. {
  1615. $odid .= $k.'数量'.$vv;
  1616. }
  1617. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  1618. $number = $value['number'];$ftime = time()-15*24*3600;
  1619. $z = $z.'('.$odid.')';//查看订单号
  1620. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:'无';
  1621. $info_list[$key]['features'] = $c;
  1622. $info_list[$key]['number'] = $ztdata;
  1623. $info_list[$key]['sm'] = $g;
  1624. $info_list[$key]['x'] = $x;
  1625. $info_list[$key]['t'] = $t;
  1626. $info_list[$key]['z'] = $z;
  1627. /**
  1628. foreach ($cdata as $k=>$v)
  1629. {
  1630. $details[$v['details']] = $v['details'];
  1631. if($v['cpid'] != 0)
  1632. {
  1633. $cpid[$v['cpid']] = $v['cpid'];
  1634. }
  1635. }
  1636. **/
  1637. $info_list[$key]['shop'] = '';
  1638. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1639. if($value['shop'] != '')
  1640. {
  1641. $shop = explode(',',trim($value['shop'],','));
  1642. $info_list[$key]['shop'] = '<p>'.$sp[$shop[0]].'</p>';
  1643. }
  1644. $info_list[$key]['shop'] .= $companytitle;
  1645. /**
  1646. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1647. if(isset($companytitle[0]))
  1648. {
  1649. foreach ($companytitle as $k=>$v)
  1650. {
  1651. if($v['companytitle'] != '')
  1652. {
  1653. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1654. }
  1655. }
  1656. }
  1657. **/
  1658. }
  1659. $total = count($this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,sku,title,features,number'));
  1660. $pagenum = ceil($total/$perpage);
  1661. $over = $total-($start+$perpage);
  1662. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  1663. echo json_encode($rows);exit;
  1664. }
  1665. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1666. $this->data['shop'] = $wlshop;
  1667. $this->data['vip'] = $vip;
  1668. $this->_Template('whlabel_type',$this->data);
  1669. }
  1670. //美仓进销存浏览
  1671. public function _usatype()
  1672. {
  1673. if(isset($_SESSION['api']))
  1674. {
  1675. $user = $this->user->get_api($_SESSION['api']);
  1676. $usp = $user;
  1677. $fgshop = "";$sid = "";$wid="";$wtype="";
  1678. $userwh = explode('|',trim($user['warehouse'],'|'));
  1679. foreach ($userwh as $value)
  1680. {
  1681. $wid .= " id = ".$value." or";
  1682. $wtype .= " type = ".$value." or";
  1683. }
  1684. }
  1685. $prc = array();
  1686. $purchase = $this->purchase->find_all();
  1687. foreach($purchase as $k=>$v)
  1688. {
  1689. $prc[$v['id']] = $v['title'];
  1690. }
  1691. $post = $this->input->post(NULL, TRUE);
  1692. if(isset($post['page']))
  1693. {
  1694. $page = $this->input->post('page',true);
  1695. $perpage = $this->input->post('perpage',true);
  1696. $category = $this->input->post('category',true);
  1697. $size = $this->input->post('size',true);
  1698. $grade = $this->input->post('grade',true);
  1699. $color = $this->input->post('color',true);
  1700. $lowe = $this->input->post('lowe',true);
  1701. $sku = $this->input->post('sku');
  1702. $title = $this->input->post('title');
  1703. $warehouse = $this->input->post('warehouse',true);
  1704. $usa = $this->input->post('usa',true);
  1705. $purchase = $this->input->post('purchase',true);
  1706. $lacetype = $this->input->post('lacetype',true);
  1707. $haircap = $this->input->post('haircap',true);
  1708. $density = $this->input->post('density',true);
  1709. $details = $this->input->post('details',true);
  1710. $state = $this->input->post('state',true);
  1711. $lacecolor = $this->input->post('lacecolor',true);
  1712. $cklx = $this->input->post('cklx',true);
  1713. $ktime = $this->input->post('ktime',true);
  1714. $jtime = $this->input->post('jtime',true);
  1715. $ktime = strtotime($ktime);
  1716. $jtime = strtotime($jtime);
  1717. $where = "1=1";$gj = "";$ck = "";
  1718. if($lacetype)
  1719. {
  1720. $where .= " and features like '%-$lacetype-%'";
  1721. }
  1722. if($category)
  1723. {
  1724. $where .= " and features like '%-$category-%'";
  1725. }
  1726. if($size)
  1727. {
  1728. $where .= " and features like '%-$size-%'";
  1729. }
  1730. if($grade)
  1731. {
  1732. $where .= " and features like '%-$grade-%'";
  1733. }
  1734. if($color)
  1735. {
  1736. $where .= " and features like '%-$color-%'";
  1737. }
  1738. if($lowe)
  1739. {
  1740. $where .= " and features like '%-$lowe-%'";
  1741. }
  1742. if($haircap)
  1743. {
  1744. $where .= " and features like '%-$haircap-%'";
  1745. }
  1746. if($density)
  1747. {
  1748. $where .= " and features like '%-$density-%'";
  1749. }
  1750. if($lacecolor)
  1751. {
  1752. $where .= " and features like '%-$lacecolor-%'";
  1753. }
  1754. if($usa)
  1755. {
  1756. if(!$warehouse)
  1757. {
  1758. $where .= " and (warehouse = '5' or warehouse = '8')";
  1759. }
  1760. }
  1761. if($warehouse)
  1762. {
  1763. $where .= " and warehouse = '$warehouse'";
  1764. }
  1765. if($details)
  1766. {
  1767. $where .= " and details = '$details'";
  1768. }
  1769. if($purchase)
  1770. {
  1771. $where .= " and purchase = '$purchase'";
  1772. }
  1773. if($state)
  1774. {
  1775. $where .= " and state = '$state'";
  1776. }
  1777. $where_add = '';
  1778. if($cklx)
  1779. {
  1780. $shop = $this->shop->read($cklx);
  1781. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  1782. }
  1783. if($ktime && $jtime)
  1784. {
  1785. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1786. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1787. }
  1788. //数据排序
  1789. $order_str = "id desc";
  1790. if(empty($page))
  1791. {
  1792. $start = 0;
  1793. $perpage = 1;
  1794. }
  1795. else
  1796. {
  1797. $start = ($page - 1)*$perpage;
  1798. }
  1799. if($sku)
  1800. {
  1801. $sku = trim($sku,' ');
  1802. $sku = trim($sku,' ');
  1803. $where .= " and sku like '%$sku%'";
  1804. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1805. }
  1806. else if($title)
  1807. {
  1808. $title = trim($title,' ');
  1809. $title = trim($title,' ');
  1810. $where .= " and title like '%$title%'";
  1811. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1812. }
  1813. else
  1814. {
  1815. //$where .= " and time > '$ktime' and time < '$jtime'";
  1816. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1817. }
  1818. //取得信息列表
  1819. $rows = array();$list = array();
  1820. foreach ($info_list as $key=>$value)
  1821. {
  1822. $warehouse = $this->warehouse->read($value['warehouse']);
  1823. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1824. $g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1825. $x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1826. $t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1827. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1828. $od = array();$odid = '';
  1829. foreach ($z as $v)
  1830. {
  1831. if(!isset($od[$v['zd']]))
  1832. {
  1833. $od[$v['zd']] = 1;//所有数据sku
  1834. }
  1835. else
  1836. {
  1837. $od[$v['zd']] = $od[$v['zd']]+1;
  1838. }
  1839. }
  1840. foreach ($od as $k=>$vv)
  1841. {
  1842. $odid .= $k.'数量'.$vv.' ';
  1843. }
  1844. $z = count($z).'('.$odid.')';//查看订单号
  1845. $info_list[$key]['features'] = $c;
  1846. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1847. $ztdata = '';
  1848. if(count($zt) > 0)
  1849. {
  1850. foreach ($zt as $vv)
  1851. {
  1852. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1853. }
  1854. }
  1855. $info_list[$key]['warehouse'] = $ztdata;
  1856. $info_list[$key]['g'] = $g;
  1857. $info_list[$key]['x'] = $x;
  1858. $info_list[$key]['t'] = $t;
  1859. $info_list[$key]['z'] = $z;
  1860. }
  1861. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title'));
  1862. $pagenum = ceil($total/$perpage);
  1863. $over = $total-($start+$perpage);
  1864. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1865. echo json_encode($rows);exit;
  1866. }
  1867. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1868. $this->data['warehouse'] = $warehouse;
  1869. $this->_Template('whlabel_typeusa',$this->data);
  1870. }
  1871. //美仓进销存浏览
  1872. public function _usatypeapp()
  1873. {
  1874. $post = $this->input->post(NULL, TRUE);
  1875. if(isset($post['page']))
  1876. {
  1877. $page = $this->input->post('page',true);
  1878. $perpage = $this->input->post('perpage',true);
  1879. $sku = $this->input->post('sku',true);
  1880. $warehouse = 5;
  1881. $title = $this->input->post('title',true);
  1882. $state = $this->input->post('state',true);
  1883. $ktime = $this->input->post('ktime',true);
  1884. $jtime = $this->input->post('jtime',true);
  1885. $ktime = strtotime($ktime);
  1886. $jtime = strtotime($jtime);
  1887. $where = "1=1";$gj = "";$ck = "";
  1888. if($title)
  1889. {
  1890. $st = explode(' ',trim($title,' '));
  1891. foreach ($st as $v)
  1892. {
  1893. $where .= " and title like '%$v%'";
  1894. }
  1895. }
  1896. if($warehouse)
  1897. {
  1898. $where .= " and warehouse = '$warehouse'";
  1899. }
  1900. if($state)
  1901. {
  1902. $where .= " and state = '$state'";
  1903. }
  1904. if($sku)
  1905. {
  1906. $where .= " and sku like '%$sku%'";
  1907. }
  1908. if($ktime && $jtime)
  1909. {
  1910. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1911. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1912. }
  1913. //数据排序
  1914. $order_str = "id desc";
  1915. if(empty($page))
  1916. {
  1917. $start = 0;
  1918. $perpage = 1;
  1919. }
  1920. else
  1921. {
  1922. $start = ($page - 1)*$perpage;
  1923. }
  1924. //取得信息列表
  1925. $info_list = $this->whlabel->find_all($where.' and '.rtrim($wid,'or'),'*');
  1926. $rows = array();$list = array();
  1927. foreach ($info_list as $key=>$value)
  1928. {
  1929. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1930. }
  1931. $rowsdq = array_slice($rows,$start,$perpage);
  1932. foreach ($rowsdq as $value)
  1933. {
  1934. $warehouse = $this->warehouse->read($value['warehouse']);
  1935. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'"');
  1936. $x = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'"');
  1937. $t = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1938. $od = array();$odid = '';
  1939. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'x'=>$x,'t'=>$t);
  1940. }
  1941. $total = count($rows);
  1942. $pagenum = ceil($total/$perpage);
  1943. $over = $total-($start+$perpage);
  1944. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1945. echo json_encode($rows);exit;
  1946. }
  1947. $this->_Template('phone/p_usatypeapp',$this->data);
  1948. }
  1949. //入库操作
  1950. public function _enteradd()
  1951. {
  1952. $dt = 0;
  1953. if(isset($_SESSION['api']))
  1954. {
  1955. $user = $this->user->get_api($_SESSION['api']);
  1956. $usp = $user;
  1957. $fgshop = "";$sid = "";
  1958. $user = explode('|',trim($user['shop'],'|'));
  1959. foreach ($user as $value)
  1960. {
  1961. $fgshop .= " shop = ".$value." or";
  1962. $sid .= " id = ".$value." or";
  1963. }
  1964. }
  1965. $tc = $this->typeclass->find_all();
  1966. $typeclass = array();
  1967. foreach ($tc as $v)
  1968. {
  1969. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1970. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'bqsku'=>$v['bqsku']);
  1971. }
  1972. $post = $this->input->post(NULL, TRUE);
  1973. if(isset($post['sku']))
  1974. {
  1975. $list = array();$num = "";$title = "";$features = "";
  1976. $order = $this->input->post('order',true);
  1977. $shop = $this->input->post('shop',true);
  1978. $post['shop'] = ($shop!="")?','.$shop:"";
  1979. $sku = $this->input->post('sku',true);
  1980. $post['sm'] = $this->input->post('sm',true);
  1981. $post['warehouse'] = $this->input->post('warehouse',true);
  1982. $post['purchase'] = $this->input->post('purchase',true);
  1983. $post['retreatwarehouse'] = $post['warehouse'];
  1984. $post['state'] = $this->input->post('state',true);
  1985. $post['rktype'] = $this->input->post('rktype',true);
  1986. $post['text'] = $this->input->post('text',true);
  1987. $category = $this->input->post('category',true);
  1988. $list['category'] = $category;
  1989. $list['hairtype'] = $this->input->post('hairtype',true);
  1990. $list['grade'] = $this->input->post('grade',true);
  1991. $size = $this->input->post('size',true);
  1992. $xzsku = $this->input->post('xzsku',true);
  1993. $list['size'] = rtrim($size,',');
  1994. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1995. $list['extension'] = $this->input->post('extension',true);
  1996. if($category == 1297)
  1997. {
  1998. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1999. }
  2000. if($category == 1702)
  2001. {
  2002. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  2003. $list['syother'] = $this->input->post('syother',true);
  2004. }
  2005. if($category == 133)
  2006. {
  2007. $list['fittype'] = $this->input->post('fittype',true);
  2008. $list['acother'] = $this->input->post('acother',true);
  2009. }
  2010. $list['color'] = $this->input->post('color',true);
  2011. $list['lowe'] = $this->input->post('lowe',true);
  2012. if(!$post['purchase'])
  2013. {
  2014. $post['purchase'] = 1;
  2015. }
  2016. if($category == 127)
  2017. {
  2018. $list['type'] = $this->input->post('type',true);
  2019. $list['headroad'] = $this->input->post('headroad',true);
  2020. $list['density'] = $this->input->post('density',true);
  2021. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  2022. {
  2023. $list['lacesize'] = $this->input->post('lacesize',true);
  2024. }
  2025. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2026. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2027. }
  2028. if($category == 128)
  2029. {
  2030. $list['lacetype'] = $this->input->post('lacetype',true);
  2031. $list['haircap'] = $this->input->post('haircap',true);
  2032. $list['density'] = $this->input->post('density',true);
  2033. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2034. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2035. $list['wigother'] = $this->input->post('wigother',true);
  2036. $list['wigother2'] = $this->input->post('wigother2',true);
  2037. }
  2038. if($category == 129)
  2039. {
  2040. $list['wide'] = $this->input->post('wide',true);
  2041. }
  2042. if($category == 131)
  2043. {
  2044. $list['gifttype'] = $this->input->post('gifttype',true);
  2045. $list['giftother'] = $this->input->post('giftother',true);
  2046. }
  2047. if($category == 134)
  2048. {
  2049. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2050. }
  2051. if($category == 1297)
  2052. {
  2053. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2054. $list['sywigother'] = $this->input->post('sywigother',true);
  2055. }
  2056. if($category == 130 || $category == 133 || $category == 1702)
  2057. {
  2058. $list['items'] = $this->input->post('items',true);
  2059. $list['weight'] = $this->input->post('weight',true);
  2060. }
  2061. if($category == 1702)
  2062. {
  2063. $list['syhairther'] = $this->input->post('syhairther',true);
  2064. }
  2065. $classid = $this->classid->sku();
  2066. $scsku = $classid;
  2067. $pm = $classid;
  2068. foreach($list as $k=>$v)
  2069. {
  2070. if($v != 0)
  2071. {
  2072. $num .=$v;
  2073. $features .=$v.'-';
  2074. $post[$k] = $v;
  2075. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2076. if($k != 'size')
  2077. {
  2078. $title .= $typeclass[$v]['title']." ";
  2079. }
  2080. if(isset($pm[$typeclass[$v]['classid']]))
  2081. {
  2082. if($typeclass[$v]['title'] == '9A')
  2083. {
  2084. $pm[$typeclass[$v]['classid']] = '9A';
  2085. }
  2086. else if($typeclass[$v]['title'] == '10A')
  2087. {
  2088. $pm[$typeclass[$v]['classid']] = '10A';
  2089. }
  2090. else
  2091. {
  2092. $clzh = $typeclass[$v]['zh'];
  2093. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2094. {
  2095. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2096. $clzh = $clzh[0];
  2097. }
  2098. $pm[$typeclass[$v]['classid']] = $clzh;
  2099. }
  2100. }
  2101. }
  2102. }
  2103. $zh = implode(" ",$pm);
  2104. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2105. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2106. if($list['size'])
  2107. {
  2108. $typeclass = $this->typeclass->read($list['size']);
  2109. $title .= $typeclass['title'];
  2110. }
  2111. $time = time();
  2112. if($xzsku)
  2113. {
  2114. $scsku = implode("-",$scsku);
  2115. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2116. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2117. $post['sku'] = trim($scsku,' ');
  2118. }
  2119. else
  2120. {
  2121. $post['sku'] = $sku;
  2122. }
  2123. //$post['sku'] = trim($sku,' ');
  2124. $post['title'] = rtrim($title,' ');
  2125. $post['number'] = $num;
  2126. $post['features'] = '-'.$features;
  2127. $post['enter'] = $time;
  2128. $post['time'] = $time;//操作时间
  2129. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2130. if($yza)
  2131. {
  2132. if($post['features'] != $yza[0]['features'])
  2133. {
  2134. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'success'=>false));exit;
  2135. }
  2136. }
  2137. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2138. if($yzb)
  2139. {
  2140. if($post['sku'] != $yzb[0]['sku'])
  2141. {
  2142. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','success'=>false));exit;
  2143. }
  2144. }
  2145. if(isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
  2146. {
  2147. echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
  2148. }
  2149. if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
  2150. {
  2151. echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
  2152. }
  2153. if($post['rktype'] == '' && $post['warehouse'] == 5)
  2154. {
  2155. echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
  2156. }
  2157. $yz = $this->whlabel->find_all("sku = '".$post['sku']."' and features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'",'type');
  2158. if(isset($yz[0]['type']))
  2159. {
  2160. $post['type'] = $yz[0]['type'];
  2161. }
  2162. if($post['state'] == 9)//如果选择预设库存
  2163. {
  2164. $this->whlabel->insert($post);
  2165. }
  2166. else
  2167. {
  2168. /**
  2169. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2170. if($ljg == 1)
  2171. {
  2172. for($i=0;$i<$order;$i++)
  2173. {
  2174. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2175. $this->whlabel->insert($post);
  2176. }
  2177. }
  2178. **/
  2179. //if($post['warehouse'] == '5')
  2180. //{
  2181. //}
  2182. $yydata = $post;
  2183. $yydata['zh'] = $zh;
  2184. /**
  2185. $wl = $this->apiyy->get_cjlp($yydata);
  2186. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2187. {
  2188. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2189. }
  2190. if($wl['Data'][0]['m_isSucess'] != 1)
  2191. {
  2192. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2193. }
  2194. **/
  2195. for($i=0;$i<$order;$i++)
  2196. {
  2197. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2198. $this->whlabel->insert($post);
  2199. }
  2200. }
  2201. echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
  2202. }
  2203. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2204. $this->data['wlshop'] = $wlshop;
  2205. $this->_Template('whlabel_enteradd',$this->data);
  2206. }
  2207. //修改产品
  2208. public function _enteredit($arg_array)
  2209. {
  2210. $dt = 0;
  2211. if(isset($_SESSION['api']))
  2212. {
  2213. $user = $this->user->get_api($_SESSION['api']);
  2214. $usp = $user;
  2215. $fgshop = "";$sid = "";
  2216. $user = explode('|',trim($user['shop'],'|'));
  2217. foreach ($user as $value)
  2218. {
  2219. $fgshop .= " shop = ".$value." or";
  2220. $sid .= " id = ".$value." or";
  2221. }
  2222. }
  2223. $post = $this->input->post(NULL, TRUE);
  2224. if(isset($post['sku']))
  2225. {
  2226. $list = array();$num = "";$title = "";$features = "";
  2227. $id = $this->input->post('id',true);
  2228. $order = $this->input->post('order',true);
  2229. $shop = $this->input->post('shop',true);
  2230. $post['shop'] = ($shop!="")?','.$shop:"";
  2231. $post['sku'] = $this->input->post('sku',true);
  2232. $post['sm'] = $this->input->post('sm',true);
  2233. $post['warehouse'] = $this->input->post('warehouse',true);
  2234. $post['purchase'] = $this->input->post('purchase',true);
  2235. $post['retreatwarehouse'] = $post['warehouse'];
  2236. $category = $this->input->post('category',true);
  2237. $list['category'] = $category;
  2238. $list['hairtype'] = $this->input->post('hairtype',true);
  2239. $list['grade'] = $this->input->post('grade',true);
  2240. $size = $this->input->post('size',true);
  2241. $list['size'] = rtrim($size,',');
  2242. $post['rktype'] = $this->input->post('rktype',true);
  2243. $post['text'] = $this->input->post('text',true);
  2244. $list['hairnumber'] = $this->input->post('hairnumber',true);
  2245. $list['extension'] = $this->input->post('extension',true);
  2246. if($category == 1297)
  2247. {
  2248. $list['sywignumber'] = $this->input->post('sywignumber',true);
  2249. }
  2250. if($category == 1702)
  2251. {
  2252. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  2253. $list['syother'] = $this->input->post('syother',true);
  2254. }
  2255. if($category == 133)
  2256. {
  2257. $list['fittype'] = $this->input->post('fittype',true);
  2258. $list['acother'] = $this->input->post('acother',true);
  2259. }
  2260. $list['color'] = $this->input->post('color',true);
  2261. $list['lowe'] = $this->input->post('lowe',true);
  2262. if(!$post['purchase'])
  2263. {
  2264. $post['purchase'] = 1;
  2265. }
  2266. if($category == 127)
  2267. {
  2268. $list['type'] = $this->input->post('type',true);
  2269. $list['headroad'] = $this->input->post('headroad',true);
  2270. $list['density'] = $this->input->post('density',true);
  2271. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  2272. {
  2273. $list['lacesize'] = $this->input->post('lacesize',true);
  2274. }
  2275. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2276. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2277. }
  2278. if($category == 128)
  2279. {
  2280. $list['lacetype'] = $this->input->post('lacetype',true);
  2281. $list['haircap'] = $this->input->post('haircap',true);
  2282. $list['density'] = $this->input->post('density',true);
  2283. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2284. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2285. $list['wigother'] = $this->input->post('wigother',true);
  2286. $list['wigother2'] = $this->input->post('wigother2',true);
  2287. }
  2288. if($category == 129)
  2289. {
  2290. $list['wide'] = $this->input->post('wide',true);
  2291. }
  2292. if($category == 131)
  2293. {
  2294. $list['gifttype'] = $this->input->post('gifttype',true);
  2295. $list['giftother'] = $this->input->post('giftother',true);
  2296. }
  2297. if($category == 134)
  2298. {
  2299. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2300. }
  2301. if($category == 1297)
  2302. {
  2303. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2304. $list['sywigother'] = $this->input->post('sywigother',true);
  2305. }
  2306. if($category == 130 || $category == 133 || $category == 1702)
  2307. {
  2308. $list['items'] = $this->input->post('items',true);
  2309. $list['weight'] = $this->input->post('weight',true);
  2310. }
  2311. if($category == 1702)
  2312. {
  2313. $list['syhairther'] = $this->input->post('syhairther',true);
  2314. }
  2315. foreach($list as $k=>$v)
  2316. {
  2317. if($v != 0)
  2318. {
  2319. $num .=$v;
  2320. $features .=$v.'-';
  2321. $typeclass = $this->typeclass->read($v);
  2322. if($k != 'size')
  2323. {
  2324. $title .= $typeclass['title']." ";
  2325. }
  2326. }
  2327. }
  2328. $typeclass = $this->typeclass->read($list['size']);
  2329. $title .= $typeclass['title'];
  2330. $time = time();
  2331. $post['title'] = rtrim($title,' ');
  2332. $post['number'] = $num;
  2333. $post['features'] = '-'.$features;
  2334. $post['time'] = $time;//操作时间
  2335. if($post['rktype'] == '' && $post['warehouse'] == 5)
  2336. {
  2337. echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
  2338. }
  2339. if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
  2340. {
  2341. echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
  2342. }
  2343. $uid = $this->whlabel->read($id);
  2344. $datanum = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2345. if($datanum > 0)
  2346. {
  2347. echo json_encode(array('msg'=>'此SKU有占单,请解除占单后再修改!','success'=>false));exit;
  2348. }
  2349. if($post['warehouse'] != '99999')//现在所有仓都检测,之前只有美仓5检测
  2350. {
  2351. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."'");
  2352. if($yza)
  2353. {
  2354. if($post['features'] != $yza[0]['features'])
  2355. {
  2356. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','success'=>false));exit;
  2357. }
  2358. }
  2359. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."'");
  2360. if($yzb)
  2361. {
  2362. if($post['sku'] != $yzb[0]['sku'])
  2363. {
  2364. echo json_encode(array('msg'=>'此产品信息的SKU和现有不一致!','success'=>false));exit;
  2365. }
  2366. }
  2367. if($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
  2368. {
  2369. echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
  2370. }
  2371. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2372. foreach ($data as $v)
  2373. {
  2374. $post['id'] = $v['id'];
  2375. $this->whlabel->save($post,$v['id']);
  2376. }
  2377. }
  2378. else
  2379. {
  2380. $data = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2381. if($data > 0)
  2382. {
  2383. echo json_encode(array('msg'=>'此产品有占单,无法修改!','success'=>false));exit;
  2384. }
  2385. else
  2386. {
  2387. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2388. foreach ($data as $v)
  2389. {
  2390. $post['id'] = $v['id'];
  2391. $this->whlabel->save($post,$v['id']);
  2392. }
  2393. }
  2394. }
  2395. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  2396. }
  2397. $uid = $this->whlabel->read($arg_array[0]);
  2398. $uid['order'] = $this->whlabel->find_count('enter = "'.$uid['enter'].'" and sku = "'.$uid['sku'].'" and state = "0"');
  2399. $this->data['enter'] = $uid ;
  2400. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2401. $this->data['wlshop'] = $wlshop;
  2402. $this->_Template('whlabel_enteredit',$this->data);
  2403. }
  2404. //入库浏览
  2405. public function _enter()
  2406. {
  2407. $post = $this->input->post(NULL, TRUE);
  2408. if(isset($post['s']))
  2409. {
  2410. $id_arr = $this->input->post('s');
  2411. $id_arr = explode(',',$id_arr);
  2412. if(!$id_arr)
  2413. {
  2414. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2415. }
  2416. //循环删除记录
  2417. foreach ($id_arr as $v)
  2418. {
  2419. $sid = $this->whlabel->read($v);
  2420. $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
  2421. if($count > 0)
  2422. {
  2423. echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
  2424. }
  2425. $info_list = $this->whlabel->find_all('enter ='.$sid['enter']);
  2426. foreach ($info_list as $va)
  2427. {
  2428. $this->whlabel->remove($va['id']);
  2429. }
  2430. }
  2431. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  2432. }
  2433. $sp = array();
  2434. $s = $this->shop->find_all('1=1','id,shopname');
  2435. foreach ($s as $v)
  2436. {
  2437. $sp[$v['id']] = $v['shopname'];
  2438. }
  2439. $wh = array();
  2440. $w = $this->warehouse->find_all('1=1','id,title');
  2441. foreach ($w as $v)
  2442. {
  2443. $wh[$v['id']] = $v['title'];
  2444. }
  2445. if(isset($post['page']))
  2446. {
  2447. $page = $this->input->post('page',true);
  2448. $perpage = $this->input->post('perpage',true);
  2449. $category = $this->input->post('category',true);
  2450. $size = $this->input->post('size',true);
  2451. $grade = $this->input->post('grade',true);
  2452. $color = $this->input->post('color',true);
  2453. $lowe = $this->input->post('lowe',true);
  2454. $sku = $this->input->post('sku',true);
  2455. $warehouse = $this->input->post('warehouse',true);
  2456. $purchase = $this->input->post('purchase',true);
  2457. $ktime = $this->input->post('ktime',true);
  2458. $jtime = $this->input->post('jtime',true);
  2459. $ktime = strtotime($ktime);
  2460. $jtime = strtotime($jtime);
  2461. $where = "1=1";$gj = "";$ck = "";
  2462. if($category)
  2463. {
  2464. $where .= " and features like '%-$category-%'";
  2465. }
  2466. if($size)
  2467. {
  2468. $where .= " and features like '%-$size-%'";
  2469. }
  2470. if($grade)
  2471. {
  2472. $where .= " and features like '%-$grade-%'";
  2473. }
  2474. if($color)
  2475. {
  2476. $where .= " and features like '%-$color-%'";
  2477. }
  2478. if($lowe)
  2479. {
  2480. $where .= " and features like '%-$lowe-%'";
  2481. }
  2482. if($warehouse)
  2483. {
  2484. $where .= " and warehouse = '$warehouse'";
  2485. }
  2486. if($purchase)
  2487. {
  2488. $where .= " and purchase = '$purchase'";
  2489. }
  2490. if($sku)
  2491. {
  2492. $where .= " and sku like '%$sku%'";
  2493. }
  2494. if($ktime && $jtime)
  2495. {
  2496. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2497. }
  2498. //数据排序
  2499. $order_str = "enter desc";
  2500. if(empty($page))
  2501. {
  2502. $start = 0;
  2503. $perpage = 1;
  2504. }
  2505. else
  2506. {
  2507. $start = ($page - 1)*$perpage;
  2508. }
  2509. //取得信息列表
  2510. $info_list = $this->whlabel->find_pc($where,'enter,warehouse,sku','id,warehouse,shop,sku,title,enter',$order_str,$start,$perpage);
  2511. foreach ($info_list as $k=>$v)
  2512. {
  2513. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2514. if($v['shop']=='')
  2515. {
  2516. $s = '通用';
  2517. }
  2518. else
  2519. {
  2520. $info_list[$k]['shop'] = '';
  2521. foreach (explode(',',trim($v['shop'],',')) as $val)
  2522. {
  2523. $info_list[$k]['shop'] .= $sp[$val].'</br>';
  2524. }
  2525. }
  2526. $info_list[$k]['enter'] = date('Y-m-d H:i:s',$v['enter']);
  2527. $g = $this->whlabel->find_count($where.' and enter = "'.$v['enter'].'" and sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'"');
  2528. $info_list[$k]['g'] = $g;
  2529. }
  2530. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  2531. $pagenum = ceil($total/$perpage);
  2532. $over = $total-($start+$perpage);
  2533. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2534. echo json_encode($rows);exit;
  2535. }
  2536. $this->_Template('whlabel_enter',$this->data);
  2537. }
  2538. //出库浏览
  2539. public function _out()
  2540. {
  2541. $post = $this->input->post(NULL, TRUE);
  2542. if(isset($post['page']))
  2543. {
  2544. $page = $this->input->post('page',true);
  2545. $perpage = $this->input->post('perpage',true);
  2546. $category = $this->input->post('category',true);
  2547. $size = $this->input->post('size',true);
  2548. $grade = $this->input->post('grade',true);
  2549. $color = $this->input->post('color',true);
  2550. $lowe = $this->input->post('lowe',true);
  2551. $sku = $this->input->post('sku',true);
  2552. $warehouse = $this->input->post('warehouse',true);
  2553. $purchase = $this->input->post('purchase',true);
  2554. $state = $this->input->post('state',true);
  2555. $ktime = $this->input->post('ktime',true);
  2556. $jtime = $this->input->post('jtime',true);
  2557. $ktime = strtotime($ktime);
  2558. $jtime = strtotime($jtime);
  2559. $where = "state=3";$gj = "";$ck = "";
  2560. if($category)
  2561. {
  2562. $where .= " and features like '%-$category-%'";
  2563. }
  2564. if($size)
  2565. {
  2566. $where .= " and features like '%-$size-%'";
  2567. }
  2568. if($grade)
  2569. {
  2570. $where .= " and features like '%-$grade-%'";
  2571. }
  2572. if($color)
  2573. {
  2574. $where .= " and features like '%-$color-%'";
  2575. }
  2576. if($lowe)
  2577. {
  2578. $where .= " and features like '%-$lowe-%'";
  2579. }
  2580. if($state)
  2581. {
  2582. $where .= " and state = '$state'";
  2583. }
  2584. if($warehouse)
  2585. {
  2586. $where .= " and warehouse = '$warehouse'";
  2587. }
  2588. if($purchase)
  2589. {
  2590. $where .= " and purchase = '$purchase'";
  2591. }
  2592. if($sku)
  2593. {
  2594. $where .= " and sku = '$sku'";
  2595. }
  2596. if($ktime && $jtime)
  2597. {
  2598. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2599. }
  2600. //数据排序
  2601. $order_str = "id desc";
  2602. if(empty($page))
  2603. {
  2604. $start = 0;
  2605. $perpage = 1;
  2606. }
  2607. else
  2608. {
  2609. $start = ($page - 1)*$perpage;
  2610. }
  2611. //取得信息列表
  2612. $info_list = $this->whlabel->find_all($where,'sku');
  2613. $rows = array();$list = array();
  2614. foreach ($info_list as $key=>$value)
  2615. {
  2616. $rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
  2617. }
  2618. $rows = array_unique($rows);//删除重复记录
  2619. foreach ($rows as $key=>$value)
  2620. {
  2621. $data = $this->whlabel->get_sku($value);//获取目前sku的所有数据
  2622. $ck = $this->warehouse->read($data['warehouse']);
  2623. $warehouse = $ck['title'];
  2624. $gy = $this->purchase->read($data['purchase']);
  2625. $purchase = $gy['purchase'];
  2626. $g = $this->whlabel->find_count($where.' and sku = "'.$value.'" and state = 3');
  2627. $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);
  2628. }
  2629. $total = count($list);
  2630. $pagenum = ceil($total/$perpage);
  2631. $over = $total-($start+$perpage);
  2632. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  2633. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  2634. echo json_encode($rows);exit;
  2635. }
  2636. $this->_Template('whlabel_out',$this->data);
  2637. }
  2638. //出库标签浏览
  2639. public function _label()
  2640. {
  2641. $post = $this->input->post(NULL, TRUE);
  2642. if(isset($post['page']))
  2643. {
  2644. $page = $this->input->post('page',true);
  2645. $perpage = $this->input->post('perpage',true);
  2646. $sku = $this->input->post('sku',true);
  2647. $warehouse = $this->input->post('warehouse',true);
  2648. $purchase = $this->input->post('purchase',true);
  2649. $orderinfo = $this->input->post('orderinfo',true);
  2650. $waybill = $this->input->post('waybill',true);
  2651. $category = $this->input->post('category',true);
  2652. $size = $this->input->post('size',true);
  2653. $grade = $this->input->post('grade',true);
  2654. $color = $this->input->post('color',true);
  2655. $lowe = $this->input->post('lowe',true);
  2656. $where = "state=1";
  2657. if($sku)
  2658. {
  2659. $where .= " and sku = '$sku'";
  2660. }
  2661. if($warehouse)
  2662. {
  2663. $where .= " and warehouse = '$warehouse'";
  2664. }
  2665. if($purchase)
  2666. {
  2667. $where .= " and purchase = '$purchase'";
  2668. }
  2669. if($orderinfo)
  2670. {
  2671. $where .= " and orderinfo = '$orderinfo'";
  2672. }
  2673. if($waybill)
  2674. {
  2675. $where .= " and waybill = '$waybill'";
  2676. }
  2677. if($category)
  2678. {
  2679. $where .= " and features like '%-$category-%'";
  2680. }
  2681. if($size)
  2682. {
  2683. $where .= " and features like '%-$size-%'";
  2684. }
  2685. if($grade)
  2686. {
  2687. $where .= " and features like '%-$grade-%'";
  2688. }
  2689. if($color)
  2690. {
  2691. $where .= " and features like '%-$color-%'";
  2692. }
  2693. if($lowe)
  2694. {
  2695. $where .= " and features like '%-$lowe-%'";
  2696. }
  2697. //数据排序
  2698. $order_str = "outk desc";
  2699. if(empty($page))
  2700. {
  2701. $start = 0;
  2702. $perpage = 1;
  2703. }
  2704. else
  2705. {
  2706. $start = ($page - 1)*$perpage;
  2707. }
  2708. //取得信息列表
  2709. $info_list = $this->whlabel->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
  2710. foreach ($info_list as $key=>$value)
  2711. {
  2712. $warehouse = $this->warehouse->read($value['warehouse']);
  2713. $info_list[$key]['warehouse'] = $warehouse['title'];
  2714. $purchase = $this->purchase->read($value['purchase']);
  2715. $info_list[$key]['purchase'] = $purchase['title'];
  2716. if($value['outk'] != 0)
  2717. {
  2718. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  2719. }
  2720. else
  2721. {
  2722. $info_list[$key]['outk'] = "";
  2723. }
  2724. if($value['orderinfo'] == 0)
  2725. {
  2726. $info_list[$key]['orderinfo'] = "";
  2727. }
  2728. if($value['waybill'] == 0)
  2729. {
  2730. $info_list[$key]['waybill'] = "";
  2731. }
  2732. }
  2733. $total = $this->whlabel->find_count($where);
  2734. $pagenum = ceil($total/$perpage);
  2735. $over = $total-($start+$perpage);
  2736. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2737. echo json_encode($rows);exit;
  2738. }
  2739. $this->_Template('whlabel_label',$this->data);
  2740. }
  2741. //独立站出库订单
  2742. public function _outorder()
  2743. {
  2744. if(isset($_SESSION['api']))
  2745. {
  2746. $user = $this->user->get_api($_SESSION['api']);
  2747. $usp = $user;
  2748. $fgshop = "";$sid = "";
  2749. $user = explode('|',trim($user['shop'],'|'));
  2750. foreach ($user as $value)
  2751. {
  2752. $fgshop .= " shop = ".$value." or";
  2753. $sid .= " id = ".$value." or";
  2754. }
  2755. }
  2756. else
  2757. {
  2758. echo "请重新登录";
  2759. }
  2760. $post = $this->input->post(NULL, TRUE);
  2761. if(isset($post['page']))
  2762. {
  2763. $page = $this->input->post('page',true);
  2764. $perpage = $this->input->post('perpage',true);
  2765. $warehouse = $this->input->post('warehouse',true);
  2766. $xztime = $this->input->post('xztime',true);
  2767. $timetk = $this->input->post('timetkk',true);
  2768. $timetj = $this->input->post('timetjj',true);
  2769. $shop = $this->input->post('shop',true);
  2770. $source = $this->input->post('source',true);
  2771. $orderinfo = $this->input->post('orderinfo',true);
  2772. $number = $this->input->post('number',true);
  2773. $sfxh = $this->input->post('sfxh',true);
  2774. $express = $this->input->post('express',true);
  2775. $waybill = $this->input->post('waybill',true);
  2776. $library = $this->input->post('library',true);
  2777. $country = $this->input->post('country',true);
  2778. $so = $this->input->post('so',true);
  2779. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2780. $print = $this->input->post('print',true);
  2781. $state = $this->input->post('state',true);
  2782. $orderurl = $this->input->post('orderurl',true);
  2783. $timetk = strtotime($timetk);
  2784. $timetj = strtotime($timetj);
  2785. /**
  2786. $sj = $this->input->post('sj',true);
  2787. if($sj)
  2788. {
  2789. $sj = $this->input->post('sj',true);
  2790. }
  2791. else
  2792. {
  2793. $sj = "fullorder";
  2794. }
  2795. **/
  2796. $sj = "fullorder";
  2797. $where = "1=1";
  2798. if($warehouse)
  2799. {
  2800. $where .= " and type = '$warehouse'";
  2801. }
  2802. if($timetk && $timetj)
  2803. {
  2804. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2805. }
  2806. if($orderinfo)
  2807. {
  2808. $where .= " and orderinfo = '$orderinfo'";
  2809. }
  2810. if($number)
  2811. {
  2812. $where .= " and number = '$number'";
  2813. }
  2814. if($express)
  2815. {
  2816. $where .= " and express = '$express'";
  2817. }
  2818. if($waybill)
  2819. {
  2820. $where .= " and waybill = '$waybill'";
  2821. }
  2822. if($library)
  2823. {
  2824. $where .= " and library = '$library'";
  2825. }
  2826. if($print)
  2827. {
  2828. $where .= " and print = '$print'";
  2829. }
  2830. if($libraryconfirm)
  2831. {
  2832. $where .= " and libraryconfirm = '$libraryconfirm'";
  2833. }
  2834. if($state)
  2835. {
  2836. $where .= " and state = '$state'";
  2837. }
  2838. if($shop)
  2839. {
  2840. $where .= " and shop = '$shop'";
  2841. }
  2842. if($country)
  2843. {
  2844. $where .= " and country = '$country'";
  2845. }
  2846. if($sfxh != '')
  2847. {
  2848. $where .= " and sfxh = '$sfxh'";
  2849. }
  2850. if($so)
  2851. {
  2852. $where .= " and shipremarks like '%$so%'";
  2853. }
  2854. if($source)
  2855. {
  2856. if($source == '2d')
  2857. {
  2858. $where .= " and source >= '2'";
  2859. }
  2860. else
  2861. {
  2862. $where .= " and source = '$source'";
  2863. }
  2864. }
  2865. if(isset($_SESSION['api']))
  2866. {
  2867. foreach ($user as $value)
  2868. {
  2869. $fgshop .= " shop = ".$value." or";
  2870. }
  2871. $where .= " and (".rtrim($fgshop,'or').")";
  2872. }
  2873. if($orderurl)
  2874. {
  2875. $url = $this->orderurl->read($orderurl);
  2876. $where .= " and link like '%".$url['url']."%'";
  2877. }
  2878. //数据排序
  2879. $order_str = "librarytime desc";
  2880. if(empty($page))
  2881. {
  2882. $start = 0;
  2883. $perpage = 1;
  2884. }
  2885. else
  2886. {
  2887. $start = ($page - 1)*$perpage;
  2888. }
  2889. //取得信息列表
  2890. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2891. //格式化数据
  2892. foreach ($info_list as $key=>$value)
  2893. {
  2894. $shop = $this->shop->read($value['shop']);
  2895. $info_list[$key]['shop'] = $shop['shopname'];
  2896. $express = $this->express->read($value['express']);
  2897. $info_list[$key]['express'] = $express['servicename'];
  2898. $warehouse = $this->warehouse->read($value['type']);
  2899. $info_list[$key]['type'] = $warehouse['title'];
  2900. if($value['librarytime'] == '0')
  2901. {
  2902. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2903. }
  2904. else
  2905. {
  2906. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2907. }
  2908. }
  2909. $total = $this->$sj->find_count($where);
  2910. $pagenum = ceil($total/$perpage);
  2911. $over = $total-($start+$perpage);
  2912. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2913. echo json_encode($rows);exit;
  2914. }
  2915. $this->data['express'] = $this->express->find_all();
  2916. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2917. $this->data['wlshop'] = $wlshop;
  2918. $user = $this->user->get_api($_SESSION['api']);
  2919. $powerid = $this->power->read($user['power']);
  2920. $powertext = explode('|',trim($powerid['excelid'],'|'));
  2921. $pid = '';
  2922. foreach ($powertext as $v)
  2923. {
  2924. $pid .= " id = ".$v." or";
  2925. }
  2926. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  2927. $this->data['fullorderexcel'] = $fullorderexcel;
  2928. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  2929. $this->data['orderurl'] = $orderurl;
  2930. $this->_Template('whlabel_outorder',$this->data);
  2931. }
  2932. //tt出库
  2933. public function _toutorder()
  2934. {
  2935. if(isset($_SESSION['api']))
  2936. {
  2937. $user = $this->user->get_api($_SESSION['api']);
  2938. $usp = $user;
  2939. $fgshop = "";$sid = "";
  2940. $user = explode('|',trim($user['shop'],'|'));
  2941. foreach ($user as $value)
  2942. {
  2943. $fgshop .= " shop = ".$value." or";
  2944. $sid .= " id = ".$value." or";
  2945. }
  2946. }
  2947. else
  2948. {
  2949. echo "请重新登录";
  2950. }
  2951. $post = $this->input->post(NULL, TRUE);
  2952. if(isset($post['page']))
  2953. {
  2954. $page = $this->input->post('page',true);
  2955. $perpage = $this->input->post('perpage',true);
  2956. $warehouse = $this->input->post('warehouse',true);
  2957. $xztime = $this->input->post('xztime',true);
  2958. $timetk = $this->input->post('timetkk',true);
  2959. $timetj = $this->input->post('timetjj',true);
  2960. $shop = $this->input->post('shop',true);
  2961. $source = $this->input->post('source',true);
  2962. $orderinfo = $this->input->post('orderinfo',true);
  2963. $number = $this->input->post('number',true);
  2964. $sfxh = $this->input->post('sfxh',true);
  2965. $express = $this->input->post('express',true);
  2966. $waybill = $this->input->post('waybill',true);
  2967. $library = $this->input->post('library',true);
  2968. $country = $this->input->post('country',true);
  2969. $so = $this->input->post('so',true);
  2970. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2971. $print = $this->input->post('print',true);
  2972. $state = $this->input->post('state',true);
  2973. $orderurl = $this->input->post('orderurl',true);
  2974. $timetk = strtotime($timetk);
  2975. $timetj = strtotime($timetj);
  2976. /**
  2977. $sj = $this->input->post('sj',true);
  2978. if($sj)
  2979. {
  2980. $sj = $this->input->post('sj',true);
  2981. }
  2982. else
  2983. {
  2984. $sj = "fullorder";
  2985. }
  2986. **/
  2987. $sj = "fullordertt";
  2988. $where = "1=1";
  2989. if($warehouse)
  2990. {
  2991. $where .= " and type = '$warehouse'";
  2992. }
  2993. if($timetk && $timetj)
  2994. {
  2995. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2996. }
  2997. if($orderinfo)
  2998. {
  2999. $where .= " and orderinfo = '$orderinfo'";
  3000. }
  3001. if($number)
  3002. {
  3003. $where .= " and number = '$number'";
  3004. }
  3005. if($express)
  3006. {
  3007. $where .= " and express = '$express'";
  3008. }
  3009. if($waybill)
  3010. {
  3011. $where .= " and waybill = '$waybill'";
  3012. }
  3013. if($library)
  3014. {
  3015. $where .= " and library = '$library'";
  3016. }
  3017. if($print)
  3018. {
  3019. $where .= " and print = '$print'";
  3020. }
  3021. if($libraryconfirm)
  3022. {
  3023. $where .= " and libraryconfirm = '$libraryconfirm'";
  3024. }
  3025. if($state)
  3026. {
  3027. $where .= " and state = '$state'";
  3028. }
  3029. if($shop)
  3030. {
  3031. $where .= " and shop = '$shop'";
  3032. }
  3033. if($country)
  3034. {
  3035. $where .= " and country = '$country'";
  3036. }
  3037. if($sfxh != '')
  3038. {
  3039. $where .= " and sfxh = '$sfxh'";
  3040. }
  3041. if($so)
  3042. {
  3043. $where .= " and shipremarks like '%$so%'";
  3044. }
  3045. if($source)
  3046. {
  3047. if($source == '2d')
  3048. {
  3049. $where .= " and source >= '2'";
  3050. }
  3051. else
  3052. {
  3053. $where .= " and source = '$source'";
  3054. }
  3055. }
  3056. if(isset($_SESSION['api']))
  3057. {
  3058. foreach ($user as $value)
  3059. {
  3060. $fgshop .= " shop = ".$value." or";
  3061. }
  3062. $where .= " and (".rtrim($fgshop,'or').")";
  3063. }
  3064. if($orderurl)
  3065. {
  3066. $url = $this->orderurl->read($orderurl);
  3067. $where .= " and link like '%".$url['url']."%'";
  3068. }
  3069. //数据排序
  3070. $order_str = "librarytime desc";
  3071. if(empty($page))
  3072. {
  3073. $start = 0;
  3074. $perpage = 1;
  3075. }
  3076. else
  3077. {
  3078. $start = ($page - 1)*$perpage;
  3079. }
  3080. //取得信息列表
  3081. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3082. //格式化数据
  3083. foreach ($info_list as $key=>$value)
  3084. {
  3085. $shop = $this->shop->read($value['shop']);
  3086. $info_list[$key]['shop'] = $shop['shopname'];
  3087. $express = $this->express->read($value['express']);
  3088. $info_list[$key]['express'] = $express['servicename'];
  3089. $warehouse = $this->warehouse->read($value['type']);
  3090. $info_list[$key]['type'] = $warehouse['title'];
  3091. if($value['librarytime'] == '0')
  3092. {
  3093. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3094. }
  3095. else
  3096. {
  3097. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3098. }
  3099. }
  3100. $total = $this->$sj->find_count($where);
  3101. $pagenum = ceil($total/$perpage);
  3102. $over = $total-($start+$perpage);
  3103. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3104. echo json_encode($rows);exit;
  3105. }
  3106. $this->data['express'] = $this->express->find_all();
  3107. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3108. $this->data['wlshop'] = $wlshop;
  3109. $user = $this->user->get_api($_SESSION['api']);
  3110. $powerid = $this->power->read($user['power']);
  3111. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3112. $pid = '';
  3113. foreach ($powertext as $v)
  3114. {
  3115. $pid .= " id = ".$v." or";
  3116. }
  3117. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3118. $this->data['fullorderexcel'] = $fullorderexcel;
  3119. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  3120. $this->data['orderurl'] = $orderurl;
  3121. $this->_Template('whlabel_toutorder',$this->data);
  3122. }
  3123. //速卖通出库订单
  3124. public function _soutorder()
  3125. {
  3126. if(isset($_SESSION['api']))
  3127. {
  3128. $user = $this->user->get_api($_SESSION['api']);
  3129. $usp = $user;
  3130. $fgshop = "";$sid = "";
  3131. $user = explode('|',trim($user['shop'],'|'));
  3132. foreach ($user as $value)
  3133. {
  3134. $sid .= " id = ".$value." or";
  3135. }
  3136. }
  3137. $post = $this->input->post(NULL, TRUE);
  3138. if(isset($post['page']))
  3139. {
  3140. $page = $this->input->post('page',true);
  3141. $perpage = $this->input->post('perpage',true);
  3142. $warehouse = $this->input->post('warehouse',true);
  3143. $xztime = $this->input->post('xztime',true);
  3144. $timetk = $this->input->post('timetkk',true);
  3145. $timetj = $this->input->post('timetjj',true);
  3146. $shop = $this->input->post('shop',true);
  3147. $source = $this->input->post('source',true);
  3148. $orderinfo = $this->input->post('orderinfo',true);
  3149. $number = $this->input->post('number',true);
  3150. $express = $this->input->post('express',true);
  3151. $waybill = $this->input->post('waybill',true);
  3152. $library = $this->input->post('library',true);
  3153. $country = $this->input->post('country',true);
  3154. $sfxh = $this->input->post('sfxh',true);
  3155. $libraryconfirm = $this->input->post('libraryconfirm',true);
  3156. $print = $this->input->post('print',true);
  3157. $state = $this->input->post('state',true);
  3158. $so = $this->input->post('so',true);
  3159. $timetk = strtotime($timetk);
  3160. $timetj = strtotime($timetj);
  3161. /**
  3162. $sj = $this->input->post('sj',true);
  3163. if($sj)
  3164. {
  3165. $sj = $this->input->post('sj',true);
  3166. }
  3167. else
  3168. {
  3169. $sj = "fullorder";
  3170. }
  3171. **/
  3172. $sj = "fullordersmt";
  3173. $where = "1=1";
  3174. if($warehouse)
  3175. {
  3176. $where .= " and type = '$warehouse'";
  3177. }
  3178. if($timetk && $timetj)
  3179. {
  3180. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3181. }
  3182. if($orderinfo)
  3183. {
  3184. $where .= " and orderinfo = '$orderinfo'";
  3185. }
  3186. if($number)
  3187. {
  3188. $where .= " and number = '$number'";
  3189. }
  3190. if($express)
  3191. {
  3192. $where .= " and express = '$express'";
  3193. }
  3194. if($waybill)
  3195. {
  3196. $where .= " and waybill = '$waybill'";
  3197. }
  3198. if($library)
  3199. {
  3200. $where .= " and library = '$library'";
  3201. }
  3202. if($print)
  3203. {
  3204. $where .= " and print = '$print'";
  3205. }
  3206. if($libraryconfirm)
  3207. {
  3208. $where .= " and libraryconfirm = '$libraryconfirm'";
  3209. }
  3210. if($state)
  3211. {
  3212. $where .= " and state = '$state'";
  3213. }
  3214. if($shop)
  3215. {
  3216. $where .= " and shop = '$shop'";
  3217. }
  3218. if($sfxh != '')
  3219. {
  3220. $where .= " and sfxh = '$sfxh'";
  3221. }
  3222. if($so)
  3223. {
  3224. $where .= " and shipremarks like '%$so%'";
  3225. }
  3226. if($source)
  3227. {
  3228. $where .= " and source = '$source'";
  3229. }
  3230. if($country)
  3231. {
  3232. $where .= " and country = '$country'";
  3233. }
  3234. else
  3235. {
  3236. if(isset($_SESSION['api']))
  3237. {
  3238. foreach ($user as $value)
  3239. {
  3240. $fgshop .= " shop = ".$value." or";
  3241. }
  3242. $where .= " and (".rtrim($fgshop,'or').")";
  3243. }
  3244. }
  3245. //数据排序
  3246. $order_str = "librarytime desc";
  3247. if(empty($page))
  3248. {
  3249. $start = 0;
  3250. $perpage = 1;
  3251. }
  3252. else
  3253. {
  3254. $start = ($page - 1)*$perpage;
  3255. }
  3256. //取得信息列表
  3257. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3258. //格式化数据
  3259. foreach ($info_list as $key=>$value)
  3260. {
  3261. $shop = $this->shop->read($value['shop']);
  3262. $info_list[$key]['shop'] = $shop['shopname'];
  3263. $express = $this->express->read($value['express']);
  3264. $info_list[$key]['express'] = $express['servicename'];
  3265. $warehouse = $this->warehouse->read($value['type']);
  3266. $info_list[$key]['type'] = $warehouse['title'];
  3267. if($value['librarytime'] == '0')
  3268. {
  3269. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3270. }
  3271. else
  3272. {
  3273. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3274. }
  3275. }
  3276. $total = $this->$sj->find_count($where);
  3277. $pagenum = ceil($total/$perpage);
  3278. $over = $total-($start+$perpage);
  3279. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3280. echo json_encode($rows);exit;
  3281. }
  3282. $this->data['express'] = $this->express->find_all();
  3283. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3284. $this->data['wlshop'] = $wlshop;
  3285. $user = $this->user->get_api($_SESSION['api']);
  3286. $powerid = $this->power->read($user['power']);
  3287. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3288. $pid = '';
  3289. foreach ($powertext as $v)
  3290. {
  3291. $pid .= " id = ".$v." or";
  3292. }
  3293. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3294. $this->data['fullorderexcel'] = $fullorderexcel;
  3295. $this->_Template('whlabel_soutorder',$this->data);
  3296. }
  3297. //订单退库
  3298. public function _retreat()
  3299. {
  3300. $post = $this->input->post(NULL, TRUE);
  3301. if(isset($post['page']))
  3302. {
  3303. $page = $this->input->post('page',true);
  3304. $perpage = $this->input->post('perpage',true);
  3305. $warehouse = $this->input->post('warehouse',true);
  3306. $timetk = $this->input->post('timetk',true);
  3307. $timetj = $this->input->post('timetj',true);
  3308. $shop = $this->input->post('shop',true);
  3309. $source = $this->input->post('source',true);
  3310. $state = $this->input->post('state',true);
  3311. $review = $this->input->post('review',true);
  3312. $state = $this->input->post('state',true);
  3313. $express = $this->input->post('express',true);
  3314. $orderinfo = $this->input->post('orderinfo',true);
  3315. $user = $this->input->post('user',true);
  3316. $name = $this->input->post('name',true);
  3317. $waybill = $this->input->post('waybill',true);
  3318. $timetk = strtotime($timetk);
  3319. $timetj = strtotime($timetj);
  3320. $where = "(state=206 or state=210) and mergeid = 0";
  3321. if($warehouse)
  3322. {
  3323. $where .= " and state = '$warehouse'";
  3324. }
  3325. if($timetk && $timetj)
  3326. {
  3327. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3328. }
  3329. if($shop)
  3330. {
  3331. $where .= " and shop = '$shop'";
  3332. }
  3333. if($source)
  3334. {
  3335. $where .= " and source = '$source'";
  3336. }
  3337. if($state)
  3338. {
  3339. $where .= " and state = '$state'";
  3340. }
  3341. if($review)
  3342. {
  3343. $where .= " and review = '$review'";
  3344. }
  3345. if($state)
  3346. {
  3347. $where .= " and state = '$state'";
  3348. }
  3349. if($express)
  3350. {
  3351. $where .= " and express = '$express'";
  3352. }
  3353. if($orderinfo)
  3354. {
  3355. $where .= " and orderinfo = '$orderinfo'";
  3356. }
  3357. if($user)
  3358. {
  3359. $where .= " and user = '$user'";
  3360. }
  3361. if($name)
  3362. {
  3363. $where .= " and name = '$name'";
  3364. }
  3365. if($waybill)
  3366. {
  3367. $where .= " and waybill = '$waybill'";
  3368. }
  3369. //数据排序
  3370. $order_str = "id desc";
  3371. if(empty($page))
  3372. {
  3373. $start = 0;
  3374. $perpage = 1;
  3375. }
  3376. else
  3377. {
  3378. $start = ($page - 1)*$perpage;
  3379. }
  3380. //取得信息列表
  3381. $info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
  3382. //格式化数据
  3383. foreach ($info_list as $key=>$value)
  3384. {
  3385. $shop = $this->shop->read($value['shop']);
  3386. $info_list[$key]['shop'] = $shop['shopname'];
  3387. $warehouse = $this->warehouse->read($value['warehouse']);
  3388. $info_list[$key]['warehouse'] = $warehouse['title'];
  3389. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/".$value['id']."'>".$value['orderinfo']."</a>";
  3390. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  3391. if($value['waybill'] == 0)
  3392. {
  3393. $info_list[$key]['waybill'] = "";
  3394. }
  3395. $express = $this->express->read($value['express']);
  3396. $info_list[$key]['express'] = $express['title'];
  3397. $typeclass = $this->typeclass->read($value['state']);
  3398. $info_list[$key]['state'] = $typeclass['title'];
  3399. }
  3400. $total = $this->fullorder->find_count($where);
  3401. $pagenum = ceil($total/$perpage);
  3402. $over = $total-($start+$perpage);
  3403. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3404. echo json_encode($rows);exit;
  3405. }
  3406. $this->data['express'] = $this->express->find_all();
  3407. $this->_Template('whlabel_retreat',$this->data);
  3408. }
  3409. //退库标签浏览
  3410. public function _retreatlk()
  3411. {
  3412. $post = $this->input->post(NULL, TRUE);
  3413. if(isset($post['page']))
  3414. {
  3415. $page = $this->input->post('page',true);
  3416. $perpage = $this->input->post('perpage',true);
  3417. $timetk = $this->input->post('timetk',true);
  3418. $timetj = $this->input->post('timetj',true);
  3419. $sku = $this->input->post('sku',true);
  3420. $warehouse = $this->input->post('warehouse',true);
  3421. $purchase = $this->input->post('purchase',true);
  3422. $orderinfo = $this->input->post('orderinfo',true);
  3423. $waybill = $this->input->post('waybill',true);
  3424. $category = $this->input->post('category',true);
  3425. $size = $this->input->post('size',true);
  3426. $grade = $this->input->post('grade',true);
  3427. $color = $this->input->post('color',true);
  3428. $lowe = $this->input->post('lowe',true);
  3429. $state = $this->input->post('state',true);
  3430. $timetk = strtotime($timetk);
  3431. $timetj = strtotime($timetj);
  3432. $where = "state=2";
  3433. if($timetk && $timetj)
  3434. {
  3435. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3436. }
  3437. if($sku)
  3438. {
  3439. $where .= " and sku = '$sku'";
  3440. }
  3441. if($warehouse)
  3442. {
  3443. $where .= " and warehouse = '$warehouse'";
  3444. }
  3445. if($purchase)
  3446. {
  3447. $where .= " and purchase = '$purchase'";
  3448. }
  3449. if($orderinfo)
  3450. {
  3451. $where .= " and orderinfo = '$orderinfo'";
  3452. }
  3453. if($waybill)
  3454. {
  3455. $where .= " and waybill = '$waybill'";
  3456. }
  3457. if($category)
  3458. {
  3459. $where .= " and features like '%-$category-%'";
  3460. }
  3461. if($size)
  3462. {
  3463. $where .= " and features like '%-$size-%'";
  3464. }
  3465. if($grade)
  3466. {
  3467. $where .= " and features like '%-$grade-%'";
  3468. }
  3469. if($color)
  3470. {
  3471. $where .= " and features like '%-$color-%'";
  3472. }
  3473. if($lowe)
  3474. {
  3475. $where .= " and features like '%-$lowe-%'";
  3476. }
  3477. //数据排序
  3478. $order_str = "time desc";
  3479. if(empty($page))
  3480. {
  3481. $start = 0;
  3482. $perpage = 1;
  3483. }
  3484. else
  3485. {
  3486. $start = ($page - 1)*$perpage;
  3487. }
  3488. //取得信息列表
  3489. $info_list = $this->whlabel->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
  3490. foreach ($info_list as $key=>$value)
  3491. {
  3492. $warehouse = $this->warehouse->read($value['warehouse']);
  3493. $info_list[$key]['warehouse'] = $warehouse['title'];
  3494. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3495. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3496. $purchase = $this->purchase->read($value['purchase']);
  3497. $info_list[$key]['purchase'] = $purchase['title'];
  3498. if($value['outk'] != 0)
  3499. {
  3500. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  3501. }
  3502. else
  3503. {
  3504. $info_list[$key]['outk'] = "";
  3505. }
  3506. if($value['retreat'] != 0)
  3507. {
  3508. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
  3509. }
  3510. else
  3511. {
  3512. $info_list[$key]['retreat'] = "";
  3513. }
  3514. if($value['orderinfo'] == 0)
  3515. {
  3516. $info_list[$key]['orderinfo'] = "";
  3517. }
  3518. if($value['waybill'] == 0)
  3519. {
  3520. $info_list[$key]['waybill'] = "";
  3521. }
  3522. }
  3523. $total = $this->whlabel->find_count($where);
  3524. $pagenum = ceil($total/$perpage);
  3525. $over = $total-($start+$perpage);
  3526. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3527. echo json_encode($rows);exit;
  3528. }
  3529. $this->_Template('whlabel_retreatlk',$this->data);
  3530. }
  3531. //更换标签及浏览
  3532. public function _change()
  3533. {
  3534. $post = $this->input->post(NULL, TRUE);
  3535. if(isset($post['page']))
  3536. {
  3537. $page = $this->input->post('page',true);
  3538. $perpage = $this->input->post('perpage',true);
  3539. $timetk = $this->input->post('timetk',true);
  3540. $timetj = $this->input->post('timetj',true);
  3541. $label = $this->input->post('label',true);
  3542. $oldlabel = $this->input->post('oldlabel',true);
  3543. $timetk = strtotime($timetk);
  3544. $timetj = strtotime($timetj);
  3545. $where = "state=10 ";
  3546. if($timetk && $timetj)
  3547. {
  3548. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3549. }
  3550. if($label)
  3551. {
  3552. $where .= " and label = '$label'";
  3553. }
  3554. if($oldlabel)
  3555. {
  3556. $where .= " and oldlabel = '$oldlabel'";
  3557. }
  3558. //数据排序
  3559. $order_str = "time asc";
  3560. if(empty($page))
  3561. {
  3562. $start = 0;
  3563. $perpage = 1;
  3564. }
  3565. else
  3566. {
  3567. $start = ($page - 1)*$perpage;
  3568. }
  3569. //取得信息列表
  3570. $info_list = $this->whlabel->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
  3571. foreach ($info_list as $key=>$value)
  3572. {
  3573. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
  3574. }
  3575. $total = $this->whlabel->find_count($where);
  3576. $pagenum = ceil($total/$perpage);
  3577. $over = $total-($start+$perpage);
  3578. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3579. echo json_encode($rows);exit;
  3580. }
  3581. $this->_Template('whlabel_change',$this->data);
  3582. }
  3583. //产品标签
  3584. public function _cpbqdc()
  3585. {
  3586. if(isset($_GET['excel']))
  3587. {
  3588. $where = "1=1";
  3589. //数据排序
  3590. $order_str = "id desc";
  3591. if(empty($page))
  3592. {
  3593. $start = 0;
  3594. $perpage = 1;
  3595. }
  3596. else
  3597. {
  3598. $start = ($page - 1)*$perpage;
  3599. }
  3600. $warehouse = $this->input->get('warehouse',true);
  3601. $state = $this->input->get('state',true);
  3602. $timetk = $this->input->get('timetkk',true);
  3603. $timetj = $this->input->get('timetjj',true);
  3604. $timetk = strtotime($timetk);
  3605. $timetj = strtotime($timetj);
  3606. if($warehouse)
  3607. {
  3608. $where .= " and warehouse = '$warehouse'";
  3609. }
  3610. if($state || $state == 0)
  3611. {
  3612. $where .= " and state = '$state'";
  3613. }
  3614. if($timetk && $timetj)
  3615. {
  3616. $where .= " and time > '$timetk' and time < '$timetj'";
  3617. }
  3618. //取得信息列表
  3619. $info_list = $this->whlabel->find_all($where,'*');
  3620. $rows = array();$list = array();
  3621. foreach ($info_list as $key=>$value)
  3622. {
  3623. $rows[$value['time']] = $value;//所有数据sku
  3624. }
  3625. foreach ($rows as $value)
  3626. {
  3627. $warehouse = $this->warehouse->read($value['warehouse']);
  3628. $s = $this->whlabel->find_count($where.' and time = "'.$value['time'].'"');
  3629. $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);
  3630. }
  3631. $title = "产品标签统计表";
  3632. $titlename = "<table border=1>
  3633. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  3634. <tr align='center'>
  3635. <td>仓库</td>
  3636. <td>SKU</td>
  3637. <td>产品</td>
  3638. <td>入库时间</td>
  3639. <td>操作时间</td>
  3640. <td>备注</td>
  3641. <td>数量</td>
  3642. </tr>
  3643. </table>";
  3644. $filename = $title.".xls";
  3645. $tail = "";
  3646. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3647. }
  3648. }
  3649. //进销存导出
  3650. public function _exceljxc()
  3651. {
  3652. $classid = $this->classid->sku();
  3653. $pm = $classid;
  3654. $typeclass = array();
  3655. $tc = $this->typeclass->find_all();
  3656. foreach ($tc as $v)
  3657. {
  3658. $typeclass[$v['id']] = $v;
  3659. }
  3660. $prc = array();
  3661. $purchase = $this->purchase->find_all();
  3662. foreach($purchase as $k=>$v)
  3663. {
  3664. $prc[$v['id']] = $v['title'];
  3665. }
  3666. if(isset($_GET['excel']))
  3667. {
  3668. $where = "sku != 'Preset'";
  3669. //数据排序
  3670. $order_str = "id desc";
  3671. if(empty($page))
  3672. {
  3673. $start = 0;
  3674. $perpage = 1;
  3675. }
  3676. else
  3677. {
  3678. $start = ($page - 1)*$perpage;
  3679. }
  3680. $category = $this->input->get('category',true);
  3681. $warehouse = $this->input->get('warehouse',true);
  3682. $excelid = $this->input->get('sid',true);
  3683. if($category)
  3684. {
  3685. $where .= " and features like '%-$category-%'";
  3686. }
  3687. if($warehouse)
  3688. {
  3689. $where .= " and warehouse = '$warehouse'";
  3690. }
  3691. $xzid = '';
  3692. if($excelid)
  3693. {
  3694. $excelid = explode(',',trim($excelid,','));
  3695. foreach ($excelid as $key=>$value)
  3696. {
  3697. $xzid .= " id = ".$value." or";
  3698. }
  3699. $xzid = " and (".rtrim($xzid,'or').")";;
  3700. }
  3701. //取得信息列表
  3702. /**
  3703. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3704. $rows = array();$list = array();
  3705. foreach ($info_list as $key=>$value)
  3706. {
  3707. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3708. }
  3709. **/
  3710. $wt = array();
  3711. $whlabel_type = $this->whlabel_type->find_all();
  3712. foreach ($whlabel_type as $v)
  3713. {
  3714. $wt[$v['id']] = $v['title'];
  3715. }
  3716. $wh = array();
  3717. $w = $this->warehouse->find_all('1=1','id,title');
  3718. foreach ($w as $v)
  3719. {
  3720. $wh[$v['id']] = $v['title'];
  3721. }
  3722. $list = array();
  3723. $rows = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3724. foreach ($rows as $key=>$value)
  3725. {
  3726. if(isset($wt[$value['type']]))
  3727. {
  3728. $rows[$key]['type'] = $wt[$value['type']];
  3729. }
  3730. else
  3731. {
  3732. $rows[$key]['type'] = '未设置';
  3733. }
  3734. $bm = '03';
  3735. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  3736. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  3737. $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');
  3738. $details = array();
  3739. $cpid = array();
  3740. $cpbz = array();
  3741. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  3742. foreach ($sd as $k=>$v)
  3743. {
  3744. if($v['state'] == 0)
  3745. {
  3746. $c++;
  3747. if($v['cpid'] != 0)
  3748. {
  3749. $cpid[$v['cpid']] = $v['cpid'];
  3750. }
  3751. if($v['cpbz'] != '')
  3752. {
  3753. $cpbz[$v['cpbz']] = $v['cpbz'];
  3754. }
  3755. }
  3756. if($v['state'] != 9)
  3757. {
  3758. $g++;
  3759. }
  3760. if($v['state'] == 1)
  3761. {
  3762. $x++;
  3763. }
  3764. if($v['state'] == 2)
  3765. {
  3766. $t++;
  3767. }
  3768. if($v['state'] == 8)
  3769. {
  3770. $s++;
  3771. }
  3772. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  3773. {
  3774. $q++;
  3775. }
  3776. $details[$v['details']] = $v['details'];
  3777. }
  3778. $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'].'"');
  3779. $rows[$key]['details'] = implode("、",$details);
  3780. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  3781. $number = $value['number'];
  3782. $ftime = time()-15*24*3600;
  3783. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3784. $rows[$key]['number'] = $g;
  3785. $rows[$key]['c'] = $c;
  3786. $rows[$key]['x'] = $x;
  3787. $rows[$key]['t'] = $t;
  3788. $rows[$key]['s'] = $s;
  3789. $rows[$key]['q'] = $q;
  3790. $rows[$key]['z'] = $z;
  3791. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  3792. $features = explode('-',trim($features,'-'));
  3793. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3794. $pm = $classid;
  3795. $jm = $classid;
  3796. foreach($features as $k=>$v)
  3797. {
  3798. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3799. {
  3800. if($typeclass[$v]['bm'] != '')
  3801. {
  3802. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3803. }
  3804. }
  3805. if($v != 0)
  3806. {
  3807. if(!isset($typeclass[$v]))
  3808. {
  3809. continue;
  3810. }
  3811. if(isset($pm[$typeclass[$v]['classid']]))
  3812. {
  3813. if(stripos($typeclass[$v]['zh'],'|') !== false)
  3814. {
  3815. $tz = explode('|',$typeclass[$v]['zh']);
  3816. $pm[$typeclass[$v]['classid']] = $tz[0];
  3817. }
  3818. else
  3819. {
  3820. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3821. }
  3822. }
  3823. if(isset($jm[$typeclass[$v]['classid']]))
  3824. {
  3825. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3826. }
  3827. }
  3828. }
  3829. $jm = array_filter($jm);
  3830. $rows[$key]['bs'] = implode("-",$jm);
  3831. $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3832. $zh = implode(" ",$pm);
  3833. $zh = str_replace('自然色 ','',trim($zh,' '));
  3834. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3835. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3836. $rows[$key]['features'] = $zh;
  3837. }
  3838. $title = "总进销存统计表";
  3839. $titlename = "<table border=1>
  3840. <tr><th colspan='20' align='center'><h3>".$title."<h3></th></tr>
  3841. <tr align='center'>
  3842. <td>仓库</td>
  3843. <td>供应商</td>
  3844. <td>位置</td>
  3845. <td>库存编码</td>
  3846. <td>类目</td>
  3847. <td>SKU</td>
  3848. <td>用友编码</td>
  3849. <td>用友料号</td>
  3850. <td>商品名称</td>
  3851. <td>商品中文</td>
  3852. <td>产品备注</td>
  3853. <td>说明</td>
  3854. <td>类型</td>
  3855. <td>入库总量</td>
  3856. <td>库存数量</td>
  3857. <td>销售数量</td>
  3858. <td>退货数量</td>
  3859. <td>删除数量</td>
  3860. <td>其它操作</td>
  3861. <td>占单数量</td>
  3862. </tr>
  3863. </table>";
  3864. $filename = $title.".xls";
  3865. $tail = "";
  3866. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  3867. }
  3868. }
  3869. //入库导出
  3870. public function _excelr()
  3871. {
  3872. if(isset($_GET['excel']))
  3873. {
  3874. $category = $this->input->get('category',true);
  3875. $size = $this->input->get('size',true);
  3876. $grade = $this->input->get('grade',true);
  3877. $color = $this->input->get('color',true);
  3878. $lowe = $this->input->get('lowe',true);
  3879. $sku = $this->input->get('sku',true);
  3880. $warehouse = $this->input->get('warehouse',true);
  3881. $purchase = $this->input->get('purchase',true);
  3882. $ktime = $this->input->get('ktime',true);
  3883. $jtime = $this->input->get('jtime',true);
  3884. $ktime = strtotime($ktime);
  3885. $jtime = strtotime($jtime);
  3886. $where = "1=1";$gj = "";$ck = "";
  3887. if($category)
  3888. {
  3889. $where .= " and features like '%-$category-%'";
  3890. }
  3891. if($size)
  3892. {
  3893. $where .= " and features like '%-$size-%'";
  3894. }
  3895. if($grade)
  3896. {
  3897. $where .= " and features like '%-$grade-%'";
  3898. }
  3899. if($color)
  3900. {
  3901. $where .= " and features like '%-$color-%'";
  3902. }
  3903. if($lowe)
  3904. {
  3905. $where .= " and features like '%-$lowe-%'";
  3906. }
  3907. if($warehouse)
  3908. {
  3909. $where .= " and warehouse = '$warehouse'";
  3910. }
  3911. if($purchase)
  3912. {
  3913. $where .= " and purchase = '$purchase'";
  3914. }
  3915. if($sku)
  3916. {
  3917. $where .= " and sku = '$sku'";
  3918. }
  3919. if($ktime && $jtime)
  3920. {
  3921. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3922. }
  3923. //数据排序
  3924. $order_str = "id desc";
  3925. if(empty($page))
  3926. {
  3927. $start = 0;
  3928. $perpage = 1;
  3929. }
  3930. else
  3931. {
  3932. $start = ($page - 1)*$perpage;
  3933. }
  3934. $list = array();
  3935. $rows = $this->whlabel->find_pc($where,'enter,sku,warehouse','*',$order_str);
  3936. foreach ($rows as $value)
  3937. {
  3938. $ck = $this->warehouse->read($value['warehouse']);
  3939. $warehouse = $ck['title'];
  3940. $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
  3941. $retreatwarehouse = $tkck['title'];
  3942. $gy = $this->purchase->read($value['purchase']);
  3943. $purchase = $gy['title'];
  3944. $g = $this->whlabel->find_count($where.' and enter = "'.$value['enter'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'"');
  3945. $list[] = array('warehouse'=>$warehouse,'sku'=>$value['sku'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
  3946. }
  3947. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
  3948. $titlename = "<table border=1>
  3949. <tr><th colspan='5' align='center'><h3>".$title."<h3></th></tr>
  3950. <tr align='center'>
  3951. <td>仓库</td>
  3952. <td>SKU</td>
  3953. <td>产品</td>
  3954. <td>时间</td>
  3955. <td>数量</td>
  3956. </tr>
  3957. </table>";
  3958. $filename = $title.".xls";
  3959. $tail = "";
  3960. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3961. }
  3962. }
  3963. //出库、退库导出
  3964. public function _excelct()
  3965. {
  3966. $classid = $this->classid->sku();
  3967. $pm = $classid;
  3968. $typeclass = array();
  3969. $tc = $this->typeclass->find_all();
  3970. foreach ($tc as $v)
  3971. {
  3972. $typeclass[$v['id']] = $v;
  3973. }
  3974. $prc = array();
  3975. $purchase = $this->purchase->find_all();
  3976. foreach($purchase as $k=>$v)
  3977. {
  3978. $prc[$v['id']] = $v['title'];
  3979. }
  3980. if(isset($_GET['excel']))
  3981. {
  3982. $wh = array();
  3983. $w = $this->warehouse->find_all('1=1','id,title');
  3984. foreach ($w as $v)
  3985. {
  3986. $wh[$v['id']] = $v['title'];
  3987. }
  3988. $type = $this->input->get('excel',true);
  3989. $category = $this->input->get('category',true);
  3990. $size = $this->input->get('size',true);
  3991. $grade = $this->input->get('grade',true);
  3992. $color = $this->input->get('color',true);
  3993. $lowe = $this->input->get('lowe',true);
  3994. $sku = $this->input->get('sku',true);
  3995. $warehouse = $this->input->get('warehouse',true);
  3996. $lacetype = $this->input->get('lacetype',true);
  3997. $lacecolor = $this->input->get('lacecolor',true);
  3998. $density = $this->input->get('density',true);
  3999. $haircap = $this->input->get('haircap',true);
  4000. $purchase = $this->input->get('purchase',true);
  4001. $title = $this->input->get('title',true);
  4002. $state = $this->input->get('state',true);
  4003. $sid = $this->input->get('sid',true);
  4004. $ktime = $this->input->get('ktime',true);
  4005. $jtime = $this->input->get('jtime',true);
  4006. $ktime = strtotime($ktime);
  4007. $jtime = strtotime($jtime);
  4008. $where = "1=1";$gj = "";$ck = "";
  4009. if($category)
  4010. {
  4011. $where .= " and features like '%-$category-%'";
  4012. }
  4013. if($size)
  4014. {
  4015. $where .= " and features like '%-$size-%'";
  4016. }
  4017. if($grade)
  4018. {
  4019. $where .= " and features like '%-$grade-%'";
  4020. }
  4021. if($color)
  4022. {
  4023. $where .= " and features like '%-$color-%'";
  4024. }
  4025. if($lowe)
  4026. {
  4027. $where .= " and features like '%-$lowe-%'";
  4028. }
  4029. if($warehouse)
  4030. {
  4031. $where .= " and warehouse = '$warehouse'";
  4032. }
  4033. if($purchase)
  4034. {
  4035. $where .= " and purchase = '$purchase'";
  4036. }
  4037. if($state)
  4038. {
  4039. $where .= " and state = '$state'";
  4040. }
  4041. if($lacetype)
  4042. {
  4043. $where .= " and features like '%-$lacetype-%'";
  4044. }
  4045. if($lacecolor)
  4046. {
  4047. $where .= " and features like '%-$lacecolor-%'";
  4048. }
  4049. if($density)
  4050. {
  4051. $where .= " and features like '%-$density-%'";
  4052. }
  4053. if($haircap)
  4054. {
  4055. $where .= " and features like '%-$haircap-%'";
  4056. }
  4057. if($title)
  4058. {
  4059. $title = trim($title,' ');
  4060. $title = trim($title,' ');
  4061. $where .= " and title like '%$title%'";
  4062. }
  4063. if($sku)
  4064. {
  4065. $sku = trim($sku,' ');
  4066. $sku = trim($sku,' ');
  4067. $where .= " and sku like '%$sku%'";
  4068. }
  4069. if($ktime && $jtime)
  4070. {
  4071. if($type == 1)
  4072. {
  4073. $tl = '出库';
  4074. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4075. }
  4076. else if($type == 2)
  4077. {
  4078. $tl = '退库';
  4079. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4080. }
  4081. else if($type == 3)
  4082. {
  4083. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4084. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4085. }
  4086. else if($type == 4)
  4087. {
  4088. $tl = '出库+零售';
  4089. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4090. }
  4091. else if($type == 5)
  4092. {
  4093. $tl = '零售';
  4094. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4095. }
  4096. }
  4097. $sidwhere = '';
  4098. if($sid)
  4099. {
  4100. $sd = "";
  4101. $s = explode(',',trim($sid,','));
  4102. foreach ($s as $value)
  4103. {
  4104. $sd .= " id = ".$value." or";
  4105. }
  4106. $sidwhere = " and (".rtrim($sd,'or').")";
  4107. }
  4108. //数据排序
  4109. $order_str = "time desc";
  4110. if(empty($page))
  4111. {
  4112. $start = 0;
  4113. $perpage = 1;
  4114. }
  4115. else
  4116. {
  4117. $start = ($page - 1)*$perpage;
  4118. }
  4119. //取得信息列表
  4120. if($type != 3 && $type != 5)
  4121. {
  4122. if($type == 1 || $type == 4)
  4123. {
  4124. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk',$order_str);
  4125. foreach ($info_list as $key=>$value)
  4126. {
  4127. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4128. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4129. $warehouse = $this->warehouse->read($value['warehouse']);
  4130. $info_list[$key]['warehouse'] = $warehouse['title'];
  4131. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4132. $features = explode('-',trim($features,'-'));
  4133. $pm = $classid;
  4134. foreach($features as $k=>$v)
  4135. {
  4136. if($v != 0)
  4137. {
  4138. if(!isset($typeclass[$v]))
  4139. {
  4140. continue;
  4141. }
  4142. if(isset($pm[$typeclass[$v]['classid']]))
  4143. {
  4144. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4145. {
  4146. $tz = explode('|',$typeclass[$v]['zh']);
  4147. $pm[$typeclass[$v]['classid']] = $tz[0];
  4148. }
  4149. else
  4150. {
  4151. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4152. }
  4153. }
  4154. }
  4155. }
  4156. $zh = implode(" ",$pm);
  4157. $zh = str_replace('自然色 ','',trim($zh,' '));
  4158. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4159. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4160. $info_list[$key]['features'] = $zh;
  4161. }
  4162. }
  4163. else
  4164. {
  4165. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat',$order_str);
  4166. foreach ($info_list as $key=>$value)
  4167. {
  4168. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4169. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
  4170. $warehouse = $this->warehouse->read($value['warehouse']);
  4171. $info_list[$key]['warehouse'] = $warehouse['title'];
  4172. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4173. $features = explode('-',trim($features,'-'));
  4174. $pm = $classid;
  4175. foreach($features as $k=>$v)
  4176. {
  4177. if($v != 0)
  4178. {
  4179. if(!isset($typeclass[$v]))
  4180. {
  4181. continue;
  4182. }
  4183. if(isset($pm[$typeclass[$v]['classid']]))
  4184. {
  4185. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4186. {
  4187. $tz = explode('|',$typeclass[$v]['zh']);
  4188. $pm[$typeclass[$v]['classid']] = $tz[0];
  4189. }
  4190. else
  4191. {
  4192. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4193. }
  4194. }
  4195. }
  4196. }
  4197. $zh = implode(" ",$pm);
  4198. $zh = str_replace('自然色 ','',trim($zh,' '));
  4199. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4200. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4201. $info_list[$key]['features'] = $zh;
  4202. }
  4203. }
  4204. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4205. $titlename = "<table border=1>
  4206. <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
  4207. <tr align='center'>
  4208. <td>仓库</td>
  4209. <td>供应商</td>
  4210. <td>SKU</td>
  4211. <td>商品名称</td>
  4212. <td>商品中文</td>
  4213. <td>标签</td>
  4214. <td>订单号</td>
  4215. <td>运单号</td>
  4216. <td>".$tl."时间(中国时间)</td>
  4217. </tr>
  4218. </table>";
  4219. $filename = $title.".xls";
  4220. $tail = "";
  4221. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4222. }
  4223. else if($type == 5)
  4224. {
  4225. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,outk',$order_str);
  4226. foreach ($info_list as $key=>$value)
  4227. {
  4228. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4229. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4230. $warehouse = $this->warehouse->read($value['warehouse']);
  4231. $info_list[$key]['warehouse'] = $warehouse['title'];
  4232. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4233. $features = explode('-',trim($features,'-'));
  4234. $pm = $classid;
  4235. foreach($features as $k=>$v)
  4236. {
  4237. if($v != 0)
  4238. {
  4239. if(!isset($typeclass[$v]))
  4240. {
  4241. continue;
  4242. }
  4243. if(isset($pm[$typeclass[$v]['classid']]))
  4244. {
  4245. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4246. {
  4247. $tz = explode('|',$typeclass[$v]['zh']);
  4248. $pm[$typeclass[$v]['classid']] = $tz[0];
  4249. }
  4250. else
  4251. {
  4252. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4253. }
  4254. }
  4255. }
  4256. }
  4257. $zh = implode(" ",$pm);
  4258. $zh = str_replace('自然色 ','',trim($zh,' '));
  4259. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4260. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4261. $info_list[$key]['features'] = $zh;
  4262. }
  4263. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4264. $titlename = "<table border=1>
  4265. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  4266. <tr align='center'>
  4267. <td>仓库</td>
  4268. <td>供应商</td>
  4269. <td>SKU</td>
  4270. <td>商品名称</td>
  4271. <td>商品中文</td>
  4272. <td>标签</td>
  4273. <td>".$tl."时间(中国时间)</td>
  4274. </tr>
  4275. </table>";
  4276. $filename = $title.".xls";
  4277. $tail = "";
  4278. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4279. }
  4280. else
  4281. {
  4282. /**
  4283. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4284. $rows = array();$list = array();
  4285. foreach ($info_list as $key=>$value)
  4286. {
  4287. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4288. }
  4289. **/
  4290. $wh = array();
  4291. $w = $this->warehouse->find_all('1=1','id,title');
  4292. foreach ($w as $v)
  4293. {
  4294. $wh[$v['id']] = $v['title'];
  4295. }
  4296. $wt = array();
  4297. $whlabel_type = $this->whlabel_type->find_all();
  4298. foreach ($whlabel_type as $v)
  4299. {
  4300. $wt[$v['id']] = $v['title'];
  4301. }
  4302. $classid = $this->classid->sku();
  4303. $list = array();
  4304. $rows = $this->whlabel->find_pc($where.$sidwhere,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4305. foreach ($rows as $key=>$value)
  4306. {
  4307. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4308. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4309. $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');
  4310. $details = array();
  4311. $cpid = array();
  4312. $cpbz = array();
  4313. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  4314. foreach ($sd as $k=>$v)
  4315. {
  4316. if($v['state'] == 0)
  4317. {
  4318. $c++;
  4319. }
  4320. if($v['state'] != 9)
  4321. {
  4322. $g++;
  4323. }
  4324. if($v['outk'] > 1)
  4325. {
  4326. $x++;
  4327. }
  4328. if($v['retreat'] > 0)
  4329. {
  4330. $t++;
  4331. }
  4332. if($v['state'] == 8)
  4333. {
  4334. $s++;
  4335. }
  4336. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  4337. {
  4338. $q++;
  4339. }
  4340. $details[$v['details']] = $v['details'];
  4341. if($v['cpid'] != 0)
  4342. {
  4343. $cpid[$v['cpid']] = $v['cpid'];
  4344. }
  4345. if($v['cpbz'] != '')
  4346. {
  4347. $cpbz[$v['cpbz']] = $v['cpbz'];
  4348. }
  4349. }
  4350. if(isset($wt[$value['type']]))
  4351. {
  4352. $rows[$key]['type'] = $wt[$value['type']];
  4353. }
  4354. else
  4355. {
  4356. $rows[$key]['type'] = '未设置';
  4357. }
  4358. $rows[$key]['details'] = implode("、",$details);
  4359. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4360. $ftime = time()-15*24*3600;
  4361. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4362. $rows[$key]['cpbz'] = ($cpbz)?implode(" ",$cpbz):'';
  4363. $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);
  4364. $rows[$key]['c'] = $c;
  4365. $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);
  4366. $rows[$key]['t'] = $t;
  4367. $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'].'"');
  4368. $rows[$key]['z'] = $z;
  4369. $jm = $classid;
  4370. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4371. $features = explode('-',trim($features,'-'));
  4372. $pm = $classid;
  4373. foreach($features as $k=>$v)
  4374. {
  4375. if($v != 0)
  4376. {
  4377. if(!isset($typeclass[$v]))
  4378. {
  4379. continue;
  4380. }
  4381. if(isset($pm[$typeclass[$v]['classid']]))
  4382. {
  4383. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4384. {
  4385. $tz = explode('|',$typeclass[$v]['zh']);
  4386. $pm[$typeclass[$v]['classid']] = $tz[0];
  4387. }
  4388. else
  4389. {
  4390. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4391. }
  4392. if(isset($jm[$typeclass[$v]['classid']]))
  4393. {
  4394. if($typeclass[$v]['jm'])
  4395. {
  4396. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4397. }
  4398. }
  4399. }
  4400. }
  4401. }
  4402. $zh = implode(" ",$pm);
  4403. $zh = str_replace('自然色 ','',trim($zh,' '));
  4404. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4405. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4406. $rows[$key]['features'] = $zh;
  4407. $jm = array_filter($jm);//去除空值
  4408. $jm = implode("-",$jm);
  4409. $rows[$key]['jm'] = $jm;
  4410. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4411. }
  4412. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
  4413. $titlename = "<table border=1>
  4414. <tr><th colspan='17' align='center'><h3>".$title."<h3></th></tr>
  4415. <tr align='center'>
  4416. <td>仓库</td>
  4417. <td>供应商</td>
  4418. <td>位置</td>
  4419. <td>库存编码</td>
  4420. <td>SKU</td>
  4421. <td>商品名称</td>
  4422. <td>商品中文</td>
  4423. <td>产品备注</td>
  4424. <td>说明</td>
  4425. <td>类型</td>
  4426. <td>入库总量</td>
  4427. <td>库存数量</td>
  4428. <td>销售数量</td>
  4429. <td>退货数量</td>
  4430. <td>占单数量</td>
  4431. <td>料号</td>
  4432. <td>类目</td>
  4433. </tr>
  4434. </table>";
  4435. $filename = $title.".xls";
  4436. $tail = "";
  4437. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  4438. }
  4439. }
  4440. }
  4441. //出库+入库数据整合
  4442. public function _excelcr()
  4443. {
  4444. if(isset($_GET['excel']))
  4445. {
  4446. $type = $this->input->get('excel',true);
  4447. $category = $this->input->get('category',true);
  4448. $size = $this->input->get('size',true);
  4449. $grade = $this->input->get('grade',true);
  4450. $color = $this->input->get('color',true);
  4451. $lowe = $this->input->get('lowe',true);
  4452. $sku = $this->input->get('sku',true);
  4453. $warehouse = $this->input->get('warehouse',true);
  4454. $purchase = $this->input->get('purchase',true);
  4455. $state = $this->input->get('state',true);
  4456. $sid = $this->input->get('sid',true);
  4457. $ktime = $this->input->get('ktime',true);
  4458. $jtime = $this->input->get('jtime',true);
  4459. $ktime = strtotime($ktime);
  4460. $jtime = strtotime($jtime);
  4461. $where = "1=1";$gj = "";$ck = "";
  4462. if($category)
  4463. {
  4464. $where .= " and features like '%-$category-%'";
  4465. }
  4466. if($size)
  4467. {
  4468. $where .= " and features like '%-$size-%'";
  4469. }
  4470. if($grade)
  4471. {
  4472. $where .= " and features like '%-$grade-%'";
  4473. }
  4474. if($color)
  4475. {
  4476. $where .= " and features like '%-$color-%'";
  4477. }
  4478. if($lowe)
  4479. {
  4480. $where .= " and features like '%-$lowe-%'";
  4481. }
  4482. if($warehouse)
  4483. {
  4484. $where .= " and warehouse = '$warehouse'";
  4485. }
  4486. if($purchase)
  4487. {
  4488. $where .= " and purchase = '$purchase'";
  4489. }
  4490. if($state)
  4491. {
  4492. $where .= " and state = '$state'";
  4493. }
  4494. if($sku)
  4495. {
  4496. $where .= " and sku like '%$sku%'";
  4497. }
  4498. if($ktime && $jtime)
  4499. {
  4500. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4501. }
  4502. $sidwhere = '';
  4503. if($sid)
  4504. {
  4505. $sd = "";
  4506. $s = explode(',',trim($sid,','));
  4507. foreach ($s as $value)
  4508. {
  4509. $sd .= " id = ".$value." or";
  4510. }
  4511. $sidwhere .= " and (".rtrim($sd,'or').")";
  4512. }
  4513. //取得信息列表
  4514. $timeread = $ktime;
  4515. $timenum = ceil(($jtime - $ktime) / (24*3600));
  4516. $timelist = array();
  4517. for($i=0;$i<$timenum;$i++)
  4518. {
  4519. $timeread = ($i>0)?$ktime+$i*24*3600:$ktime;
  4520. $timelist[date('Y-m-d',$timeread)] = array('c'=>0,'r'=>0);
  4521. }
  4522. $info_list = $this->whlabel->find_all($where.$sidwhere,'outk,enter,sku,state');
  4523. //echo "<pre>";
  4524. //print_r($info_list);
  4525. //exit();
  4526. $rows = array();$list = array();
  4527. foreach ($info_list as $key=>$value)
  4528. {
  4529. $thistime = $timelist;
  4530. if(isset($rows[strtolower($value['sku'])]))
  4531. {
  4532. if($value['outk'] > $ktime && $value['state'] < $jtime)
  4533. {
  4534. $rows[strtolower($value['sku'])][date('Y-m-d',$value['outk'])]['c'] += 1;
  4535. }
  4536. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4537. {
  4538. $rows[strtolower($value['sku'])][date('Y-m-d',$value['enter'])]['r'] += 1;
  4539. }
  4540. }
  4541. else
  4542. {
  4543. if($value['outk'] > $ktime && $value['outk'] < $jtime)
  4544. {
  4545. $thistime[date('Y-m-d',$value['outk'])]['c'] += 1;
  4546. }
  4547. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4548. {
  4549. $thistime[date('Y-m-d',$value['enter'])]['r'] += 1;
  4550. }
  4551. $rows[strtolower($value['sku'])] = $thistime;
  4552. }
  4553. }
  4554. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4555. <head>
  4556. <!--[if gte mso 9]><xml>
  4557. <x:ExcelWorkbook>
  4558. <x:ExcelWorksheets>
  4559. <x:ExcelWorksheet>
  4560. <x:Name>EXCEL</x:Name>
  4561. <x:WorksheetOptions>
  4562. <x:Print>
  4563. <x:ValidPrinterInfo />
  4564. </x:Print>
  4565. </x:WorksheetOptions>
  4566. </x:ExcelWorksheet>
  4567. </x:ExcelWorksheets>
  4568. </x:ExcelWorkbook>
  4569. </xml>
  4570. <![endif]-->
  4571. </head><body>";
  4572. $str .= "<table border=1><tr><td>SKU</td>";
  4573. foreach ($timelist as $k=>$v)
  4574. {
  4575. $str .="<td>".$k."出库</td>";
  4576. $str .="<td>".$k."入库</td>";
  4577. }
  4578. $str .= "</tr></table>";
  4579. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4580. foreach ($rows as $key=>$val)
  4581. {
  4582. $str .= "<tr><td>".strtoupper($key)."</td>";
  4583. foreach ($val as $k=>$v)
  4584. {
  4585. $str .= "<td>".$val[$k]['c']."</td>";
  4586. if($val[$k]['r'] > 0)
  4587. {
  4588. $str .= "<td style='color:#f00'>-".$val[$k]['r']."</td>";
  4589. }
  4590. else
  4591. {
  4592. $str .= "<td>".$val[$k]['r']."</td>";
  4593. }
  4594. }
  4595. $str .= "</tr>";
  4596. }
  4597. $str .= "</table>";
  4598. $str .= "</body></html>";
  4599. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  4600. header( "Content-type: application/octet-stream" );
  4601. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  4602. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  4603. header( "Pragma: no-cache" );
  4604. header( "Expires: 0" );
  4605. exit($str);
  4606. }
  4607. }
  4608. //数量调整模板导出
  4609. public function _presetout()
  4610. {
  4611. if(isset($_GET['excel']))
  4612. {
  4613. $where = "sku != 'Preset' and purchase != 0";
  4614. //数据排序
  4615. $order_str = "id desc";
  4616. if(empty($page))
  4617. {
  4618. $start = 0;
  4619. $perpage = 1;
  4620. }
  4621. else
  4622. {
  4623. $start = ($page - 1)*$perpage;
  4624. }
  4625. //取得信息列表
  4626. $info_list = $this->whlabel->find_pc($where,'warehouse,purchase,sku','*','id desc',0,1);
  4627. $rows = array();$list = array();
  4628. foreach ($info_list as $value)
  4629. {
  4630. $warehouse = $this->warehouse->read($value['warehouse']);
  4631. $number = $value['number'];$ftime = time()-15*24*3600;
  4632. $purchase = $this->purchase->read($value['purchase']);
  4633. $list[] = array($warehouse['title'],$purchase['bm'],$value['sku'],'0','','0','','');
  4634. }
  4635. $title = "库存模板";
  4636. $titlename = "<table border=1>
  4637. <tr align='center'>
  4638. <td>仓库</td>
  4639. <td>供应商编码</td>
  4640. <td>SKU</td>
  4641. <td>增减数量(正数或负数)</td>
  4642. <td>增减备注</td>
  4643. <td>扣减方式:0减少库存1删除库存</td>
  4644. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4645. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4646. </tr>
  4647. </table>";
  4648. $filename = $title.".xls";
  4649. $tail = "";
  4650. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4651. }
  4652. }
  4653. //数量调整模板导入
  4654. public function _presetedit()
  4655. {
  4656. $dir = '/data/excel/'.date('Ymd',time()).'/';
  4657. $config['upload_path'] = '.'.$dir ;
  4658. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  4659. $config['allowed_types'] = 'xls|xlsx|csv';
  4660. $config['max_size'] = 10240;
  4661. $this->load->library('upload', $config);
  4662. $this->upload->initialize($config);
  4663. if ($this->upload->do_upload('userfile'))
  4664. {
  4665. $full_path = $dir.$this->upload->data('file_name');
  4666. $fileName = '.' . $full_path;
  4667. if (!file_exists($fileName))
  4668. {
  4669. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  4670. }
  4671. else
  4672. {
  4673. require_once "./data/excel/PHPExcel/IOFactory.php";
  4674. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  4675. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  4676. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  4677. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  4678. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  4679. ++$column;//如果列数大于26行
  4680. $list = array();
  4681. for ($i = 2; $i <= $row; $i++) // 行数循环
  4682. {
  4683. $data = array();
  4684. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4685. {
  4686. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4687. }
  4688. $list[] = $data;
  4689. }
  4690. }
  4691. $i = 0;$j = 0;$ed = array();
  4692. foreach ($list as $key=>$value)
  4693. {
  4694. $time = time();
  4695. if($value['0'] == "")
  4696. {
  4697. continue;
  4698. }
  4699. $warehouse = $this->warehouse->get_title($value['0']);
  4700. $purchase = $this->purchase->get_bm($value['1']);
  4701. $sku = $value['2'];
  4702. $num = $value['3'];//调整数量
  4703. $text = $value['4'];//扣减说明
  4704. $type = $value['5'];//调整方式0扣减1删除
  4705. $rktype = $value['6']!=''?$value['6']:0;//增加库存
  4706. $cktype = $value['7']!=''?$value['7']:0;//减少库存
  4707. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  4708. if(!$purchase)//如果没有这个SKU
  4709. {
  4710. $ed[] = array($purchase.'-不存在此供应商编码');
  4711. $j++;
  4712. continue;
  4713. }
  4714. if(!$d)//如果没有这个SKU
  4715. {
  4716. $ed[] = array($sku.'-库存中不存在此SKU');
  4717. $j++;
  4718. continue;
  4719. }
  4720. if(!isset($warehouse['id']))
  4721. {
  4722. $ed[] = array($sku.'-仓库名错误!');
  4723. $j++;
  4724. continue;
  4725. }
  4726. if($type != '0' && $type != '1')
  4727. {
  4728. $ed[] = array($sku.'-扣减方式填写错误!');
  4729. $j++;
  4730. continue;
  4731. }
  4732. if($num < 0)//扣减库存
  4733. {
  4734. if($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == '')))
  4735. {
  4736. $ed[] = array($sku.'-扣减必须填写扣减类型,非类型1必须填写备注');
  4737. $j++;
  4738. continue;
  4739. }
  4740. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and zd = "" and state = 0');
  4741. if(count($data) < abs($num))
  4742. {
  4743. $ed[] = array($sku.'-扣减数量大于库存剩余数量!');
  4744. $j++;
  4745. continue;
  4746. }
  4747. if($type == 0)//如果扣减方式为 扣减库存
  4748. {
  4749. for($i=0;$i<abs($num);$i++)
  4750. {
  4751. $this->whlabel->save(array('state'=>8,'textout'=>$text,'deltime'=>$time,'cktype'=>$cktype,'time'=>$time,'outk'=>$time),$data[$i]['id']);
  4752. }
  4753. }
  4754. else if($type == 1)
  4755. {
  4756. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  4757. if(count($zt) > 0)
  4758. {
  4759. $ed[] = array($sku.'-有在途库存无法删除!');
  4760. $j++;
  4761. continue;
  4762. }
  4763. for($i=0;$i<abs($num);$i++)
  4764. {
  4765. $this->whlabel->remove($data[$i]['id']);
  4766. }
  4767. }
  4768. }
  4769. else if($num > 0)//增加库存
  4770. {
  4771. if($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == '')))
  4772. {
  4773. $ed[] = array($sku.'-增加必须填写增加类型,非类型1必须填写备注');
  4774. $j++;
  4775. continue;
  4776. }
  4777. $post['sku'] = $d['sku'];
  4778. $post['shop'] = $d['shop'];
  4779. $post['warehouse'] = $warehouse['id'];
  4780. $post['purchase'] = $purchase['id'];
  4781. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4782. $post['state'] = 0;
  4783. $post['title'] = $d['title'];
  4784. $post['number'] = $d['number'];
  4785. $post['features'] = $d['features'];
  4786. $post['enter'] = $time;
  4787. $post['time'] = $time;//操作时间
  4788. $post['rktype'] = $rktype;
  4789. for($i=0;$i<$num;$i++)
  4790. {
  4791. $post['label'] = time().rand(100,999).$i;
  4792. $this->whlabel->insert($post);
  4793. }
  4794. }
  4795. sleep(1);//防止入库时间一样,需要延迟1秒
  4796. }
  4797. if($j > 0)
  4798. {
  4799. $tt = date('Ymd',time());
  4800. $title = '库存导入错误信息-'.$tt;
  4801. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4802. $tail = "\n";
  4803. $filename = $title.".xls";
  4804. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  4805. $dir = '/data/excel/'.$time.'/';
  4806. $file_name = 'error_'.$time.rand(1000,9999);
  4807. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  4808. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  4809. fwrite($myfile,$ecl);
  4810. fclose($myfile);
  4811. $error = $dir.$file_name.'.xls';
  4812. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  4813. }
  4814. else
  4815. {
  4816. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  4817. }
  4818. }
  4819. }
  4820. //笛卡儿积
  4821. function cp($ps,$sets,$list)
  4822. {
  4823. $result = array();$j=0;
  4824. for($i=0,$count=count($sets); $i<$count-1; $i++)
  4825. {
  4826. if($i==0)
  4827. {
  4828. $result = $sets[$i];
  4829. }
  4830. $tmp = array();
  4831. foreach($result as $res)
  4832. {
  4833. foreach($sets[$i+1] as $set)
  4834. {
  4835. $tmp[] = $res.','.$set;
  4836. }
  4837. }
  4838. $result = $tmp;
  4839. }
  4840. $this->db->trans_begin();
  4841. foreach ($result as $v)
  4842. {
  4843. $post = array();$title = "";$num="";
  4844. $data = explode(',',$v);
  4845. for($i=0;$i<count($list); $i++)
  4846. {
  4847. $post[$list[$i]] = $data[$i];
  4848. $typeclass = $this->typeclass->read($data[$i]);
  4849. $title = $title.$typeclass['title']." ";
  4850. if($data[$i] != 0)
  4851. {
  4852. $num .=$data[$i];//所有数据ID拼接
  4853. }
  4854. }
  4855. foreach ($ps as $kp=>$vp)
  4856. {
  4857. $post[$kp] = $vp;
  4858. }
  4859. $post['number'] = $num;
  4860. $info_list = $this->whlabel->get_number($num);//查询whlabel是否存在此拼接的数据ID
  4861. if($info_list)
  4862. {
  4863. $j++;
  4864. }
  4865. else
  4866. {
  4867. $skunum = $this->whlabel->find_count();
  4868. $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
  4869. $post['title'] = rtrim($title,' ');
  4870. $this->whlabel->insert($post);
  4871. }
  4872. }
  4873. if ($this->db->trans_status() === FALSE)
  4874. {
  4875. $this->db->trans_commit();
  4876. return NULL;
  4877. }
  4878. else
  4879. {
  4880. $this->db->trans_commit();
  4881. return $j;
  4882. }
  4883. }
  4884. public function _kj($arg_array)
  4885. {
  4886. if(isset($_POST['sku']))
  4887. {
  4888. $time = time();
  4889. $sku = $this->input->post('sku',true);
  4890. $warehouse = $this->input->post('warehouse',true);
  4891. $num = $this->input->post('num',true);
  4892. $text = $this->input->post('text',true);
  4893. $purchase = $this->input->post('purchase',true);
  4894. $cktype = $this->input->post('cktype',true);
  4895. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4896. if($cktype != 1 && $text == '')
  4897. {
  4898. echo json_encode(array('msg'=>"非销售出库必须填写备注!",'success'=>false));exit;
  4899. }
  4900. if($num > count($order))
  4901. {
  4902. echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
  4903. }
  4904. else
  4905. {
  4906. for($i=0;$i<$num;$i++)
  4907. {
  4908. $this->whlabel->save(array('state'=>8,'cktype'=>$cktype,'textout'=>$text,'deltime'=>$time,'time'=>$time,'outk'=>$time),$order[$i]['id']);
  4909. }
  4910. }
  4911. echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
  4912. }
  4913. $uid = $this->whlabel->read($arg_array[0]);
  4914. $uid['num'] = $this->whlabel->find_count('purchase = "'.$uid['purchase']. '" and sku = "'.$uid['sku']. '" and warehouse = "'.$uid['warehouse']. '" and zd = "" and state = 0');
  4915. $this->data['data'] = $uid ;
  4916. $this->_Template('whlabel_kj',$this->data);
  4917. }
  4918. public function _summary($arg_array)
  4919. {
  4920. $prc = array();
  4921. $purchase = $this->purchase->find_all();
  4922. foreach($purchase as $k=>$v)
  4923. {
  4924. $prc[$v['id']] = $v['title'];
  4925. }
  4926. if(isset($_GET['excel']))
  4927. {
  4928. $ktime = $this->input->get('ktime',true);
  4929. $jtime = $this->input->get('jtime',true);
  4930. $ktime = strtotime($ktime);
  4931. $jtime = strtotime($jtime);
  4932. $where = "1=1";
  4933. if($ktime && $jtime)
  4934. {
  4935. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4936. }
  4937. //数据排序
  4938. $order_str = "time desc";
  4939. if(empty($page))
  4940. {
  4941. $start = 0;
  4942. $perpage = 1;
  4943. }
  4944. else
  4945. {
  4946. $start = ($page - 1)*$perpage;
  4947. }
  4948. //取得信息列表
  4949. $info_list = $this->whlabel->find_pc($where,'sku','warehouse,purchase,details,cpid,sku,title');
  4950. foreach ($info_list as $key=>$value)
  4951. {
  4952. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4953. $warehouse = $this->warehouse->read($value['warehouse']);
  4954. $info_list[$key]['warehouse'] = $warehouse['title'];
  4955. $x = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'"','details,cpid');
  4956. $details = array();
  4957. $cpid = array();
  4958. foreach ($x as $k=>$v)
  4959. {
  4960. if($v['details'] != '')
  4961. {
  4962. $details[$v['details']] = $v['details'];
  4963. }
  4964. if($v['cpid'] != 0)
  4965. {
  4966. $cpid[$v['cpid']] = $v['cpid'];
  4967. }
  4968. }
  4969. $info_list[$key]['details'] = ($details)?implode(" ",$details):'';
  4970. $info_list[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4971. $s = $this->whlabel->find_count('state = 0 and sku = "'.$value['sku'].'"');
  4972. $info_list[$key]['s'] = $s;
  4973. $info_list[$key]['x'] = count($x);
  4974. }
  4975. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
  4976. $titlename = "<table border=1>
  4977. <tr align='center'>
  4978. <td>仓库</td>
  4979. <td>供应商</td>
  4980. <td>出库位置</td>
  4981. <td>出库编码</td>
  4982. <td>SKU</td>
  4983. <td>产品名</td>
  4984. <td>总剩余库存</td>
  4985. <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
  4986. </tr>
  4987. </table>";
  4988. $filename = $title.".xls";
  4989. $tail = "";
  4990. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4991. }
  4992. }
  4993. //usps发货清单
  4994. public function _manifest()
  4995. {
  4996. if(isset($_POST['manifest']))
  4997. {
  4998. $wltext = $this->input->post('wltext',true);
  4999. $time = time()-16*3600;
  5000. $ptime = strtotime(date('Y-m-d',$time));
  5001. $waybill = array();
  5002. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  5003. foreach ($fullorder as $v)
  5004. {
  5005. $waybill[$v['waybill']] = $v['waybill'];
  5006. }
  5007. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  5008. foreach ($fullordersmt as $v)
  5009. {
  5010. $waybill[$v['waybill']] = $v['waybill'];
  5011. }
  5012. $wltext = explode(';',$wltext);
  5013. foreach ($wltext as $v)
  5014. {
  5015. if(isset($waybill[$v]))
  5016. {
  5017. unset($waybill[$v]);
  5018. }
  5019. }
  5020. $data = $this->usps->get_manifest($waybill);
  5021. if(isset($data['Description']))
  5022. {
  5023. echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
  5024. }
  5025. else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
  5026. {
  5027. $bctime = date('Ymd',time());
  5028. $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
  5029. echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
  5030. }
  5031. else
  5032. {
  5033. echo json_encode(array('msg'=>$data,'success'=>false));exit;
  5034. }
  5035. }
  5036. }
  5037. public function _pdf($pdf,$title,$bctime)
  5038. {
  5039. $pdf_path = './data/pdf/'.$bctime.'/';
  5040. $file_base64 = $pdf;
  5041. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5042. $file_base64 = base64_decode($file_base64);
  5043. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  5044. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  5045. return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
  5046. }
  5047. /**
  5048. *
  5049. *
  5050. *
  5051. 进销存占单异常索引
  5052. *
  5053. *
  5054. *
  5055. **/
  5056. public function _abnormal()
  5057. {
  5058. $post = $this->input->post(NULL, TRUE);
  5059. if(isset($post['page']))
  5060. {
  5061. $page = $this->input->post('page',true);
  5062. $perpage = $this->input->post('perpage',true);
  5063. $sku = $this->input->post('sku',true);
  5064. $where = "1=1";
  5065. //数据排序
  5066. $order_str = "id desc";
  5067. if(empty($page))
  5068. {
  5069. $start = 0;
  5070. $perpage = 1;
  5071. }
  5072. else
  5073. {
  5074. $start = ($page - 1)*$perpage;
  5075. }
  5076. //取得信息列表
  5077. $info_list = $this->whlabel->find_all($where,'*');
  5078. $rows = array();$list = array();
  5079. foreach ($info_list as $key=>$value)
  5080. {
  5081. $rows[strtolower($value['sku'])] = $value;//所有数据sku
  5082. }
  5083. foreach ($rows as $value)
  5084. {
  5085. $warehouse = $this->warehouse->read($value['warehouse']);
  5086. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
  5087. $number = $value['number'];$ftime = time()-15*24*3600;
  5088. if($value['shop'] != '')
  5089. {
  5090. $shop = $value['shop'];
  5091. $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');
  5092. $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');
  5093. $order = array_merge($orderdlz,$ordersmt);
  5094. $od = 0;$a = '';$orid = '';
  5095. foreach ($order as $v)
  5096. {
  5097. $or = explode('|',ltrim($v['whlabel'],'|'));
  5098. for($i=0;$i<count($or);$i++)
  5099. {
  5100. $orod = explode('-',$or[$i]);
  5101. if($orod[0] == $number)
  5102. {
  5103. $od += $orod[1];
  5104. }
  5105. }
  5106. $orid .= $v['number'].'-';
  5107. }
  5108. }
  5109. else
  5110. {
  5111. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5112. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5113. $order = array_merge($orderdlz,$ordersmt);
  5114. $od = 0;$a = '';$orid = '';$qt = array();
  5115. foreach ($order as $v)
  5116. {
  5117. $or = explode('|',ltrim($v['whlabel'],'|'));
  5118. for($i=0;$i<count($or);$i++)
  5119. {
  5120. $orod = explode('-',$or[$i]);
  5121. if($orod[0] == $number)
  5122. {
  5123. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
  5124. if($czzs > 0)
  5125. {
  5126. if(isset($qt[$v['shop']]))
  5127. {
  5128. if($qt[$v['shop']] < $orod[1])
  5129. {
  5130. $od += $orod[1];//专属小于单量不计算剩余直接归入通用
  5131. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5132. }
  5133. else
  5134. {
  5135. $qt[$v['shop']] -= $orod[1];
  5136. }
  5137. }
  5138. else
  5139. {
  5140. $qt[$v['shop']] = $czzs;
  5141. }
  5142. }
  5143. else
  5144. {
  5145. $od += $orod[1];
  5146. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5147. }
  5148. }
  5149. }
  5150. }
  5151. }
  5152. $z = $od.'('.$orid.')';//查看订单号
  5153. //$z = $od;
  5154. if($od > $c)
  5155. {
  5156. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
  5157. }
  5158. }
  5159. $listdata = array_slice($list,$start,$perpage);
  5160. $total = count($list);
  5161. $pagenum = ceil($total/$perpage);
  5162. $over = $total-($start+$perpage);
  5163. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5164. echo json_encode($rows);exit;
  5165. }
  5166. $this->_Template('whlabel_abnormal',$this->data);
  5167. }
  5168. /**
  5169. *
  5170. *
  5171. *
  5172. 进销存占单异常索引
  5173. *
  5174. *
  5175. *
  5176. **/
  5177. public function _error()
  5178. {
  5179. $post = $this->input->post(NULL, TRUE);
  5180. if(isset($post['page']))
  5181. {
  5182. $page = $this->input->post('page',true);
  5183. $perpage = $this->input->post('perpage',true);
  5184. $sku = $this->input->post('sku',true);
  5185. $warehouse = $this->input->post('warehouse',true);
  5186. $ktime = $this->input->post('ktime',true);
  5187. $jtime = $this->input->post('jtime',true);
  5188. $ktime = strtotime($ktime);
  5189. $jtime = strtotime($jtime);
  5190. $where = "sku != 'Preset'";
  5191. $gj = '';
  5192. if($sku)
  5193. {
  5194. $where .= " and sku like '%$sku%'";
  5195. }
  5196. else
  5197. {
  5198. if($ktime && $jtime)
  5199. {
  5200. $gj = " and time > '$ktime' and time < '$jtime'";
  5201. }
  5202. }
  5203. if($warehouse)
  5204. {
  5205. $where .= " and warehouse = '$warehouse'";
  5206. }
  5207. //数据排序
  5208. $order_str = "id desc";
  5209. if(empty($page))
  5210. {
  5211. $start = 0;
  5212. $perpage = 1;
  5213. }
  5214. else
  5215. {
  5216. $start = ($page - 1)*$perpage;
  5217. }
  5218. //取得信息列表
  5219. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5220. $rows = array();$list = array();
  5221. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5222. // foreach ($info_list as $value)
  5223. // {
  5224. // $warehouse = $this->warehouse->read($value['warehouse']);
  5225. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5226. // $number = $value['number'];$ftime = time()-15*24*3600;
  5227. // if($c < 1)
  5228. // {
  5229. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5230. // }
  5231. // }
  5232. $warehouse_list = $this->warehouse->find_all();
  5233. $warehouse_list = array_column($warehouse_list,null,'id');
  5234. foreach ($info_list as $value)
  5235. {
  5236. $warehouse = isset($warehouse_list[$value['warehouse']])?$warehouse_list[$value['warehouse']]:[
  5237. 'title'=>"",
  5238. ];
  5239. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5240. $number = $value['number'];$ftime = time()-15*24*3600;
  5241. if($c < 1)
  5242. {
  5243. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5244. }
  5245. }
  5246. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5247. // $query = $this->db->query($sql);
  5248. // $info_list = $query->result_array();
  5249. // $sql_two = "select title,id from crowd_warehouse";
  5250. // $query_two = $this->db->query($sql_two);
  5251. // $warehouse_list = $query_two->result_array();
  5252. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5253. // foreach ($info_list as $value)
  5254. // {
  5255. // if(isset($warehouse_arr[$value['warehouse']])){
  5256. // $warehouse = $warehouse_arr[$value['warehouse']];
  5257. // }else{
  5258. // $warehouse = [
  5259. // 'id'=>0,
  5260. // 'title'=>"异常",
  5261. // ];
  5262. // }
  5263. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5264. // $number = $value['number'];$ftime = time()-15*24*3600;
  5265. // if($c < 1)
  5266. // {
  5267. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5268. // }
  5269. // }
  5270. $listdata = array_slice($list,$start,$perpage);
  5271. $total = count($list);
  5272. $pagenum = ceil($total/$perpage);
  5273. $over = $total-($start+$perpage);
  5274. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5275. echo json_encode($rows);exit;
  5276. }
  5277. if(isset($post['s']))
  5278. {
  5279. $id_arr = $this->input->post('s');
  5280. $id_arr = explode(',',trim($id_arr,','));
  5281. if(!$id_arr)
  5282. {
  5283. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  5284. }
  5285. //循环删除记录
  5286. foreach ($id_arr as $v)
  5287. {
  5288. $dd = $this->whlabel->read($v);
  5289. if(!isset($dd['id']))
  5290. {
  5291. echo json_encode(array('msg'=>$dd['sku'].'已被删除,请刷新页面','success'=>false));exit;
  5292. }
  5293. $zt = $this->whlabeltransport->find_all('sku = "'.$dd['sku'].'" and warehouse = "'.$dd['warehouse'].'" and features = "'.$dd['features'].'" and cz = "0"');
  5294. if(isset($zt[0]))
  5295. {
  5296. echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
  5297. }
  5298. $deldd = $this->whlabel->find_all("sku = '".$dd['sku']."' and warehouse = '".$dd['warehouse']."'");
  5299. foreach ($deldd as $vv)
  5300. {
  5301. $this->whlabel->remove($vv['id']);
  5302. }
  5303. }
  5304. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  5305. }
  5306. $this->_Template('whlabel_error',$this->data);
  5307. }
  5308. public function _errorexcel()
  5309. {
  5310. $post = $this->input->post(NULL, TRUE);
  5311. if(isset($_GET['page']))
  5312. {
  5313. $page = $this->input->get('page',true);
  5314. $perpage = $this->input->get('perpage',true);
  5315. $sku = $this->input->get('sku',true);
  5316. $warehouse = $this->input->get('warehouse',true);
  5317. $ktime = $this->input->get('ktime',true);
  5318. $jtime = $this->input->get('jtime',true);
  5319. $ktime = strtotime($ktime);
  5320. $jtime = strtotime($jtime);
  5321. $where = "sku != 'Preset'";
  5322. $gj = '';
  5323. if($sku)
  5324. {
  5325. $where .= " and sku like '%$sku%'";
  5326. }
  5327. else
  5328. {
  5329. if($ktime && $jtime)
  5330. {
  5331. $gj = " and time > '$ktime' and time < '$jtime'";
  5332. }
  5333. }
  5334. if($warehouse)
  5335. {
  5336. $where .= " and warehouse = '$warehouse'";
  5337. }
  5338. //数据排序
  5339. $order_str = "id desc";
  5340. if(empty($page))
  5341. {
  5342. $start = 0;
  5343. $perpage = 1;
  5344. }
  5345. else
  5346. {
  5347. $start = ($page - 1)*$perpage;
  5348. }
  5349. //取得信息列表
  5350. $rows = array();$list = array();
  5351. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5352. foreach ($info_list as $value)
  5353. {
  5354. $warehouse = $this->warehouse->read($value['warehouse']);
  5355. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5356. $number = $value['number'];$ftime = time()-15*24*3600;
  5357. if($c < 1)
  5358. {
  5359. $list[] = array('warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5360. }
  5361. }
  5362. $title = "0库存汇总";
  5363. $titlename = "<table border=1>
  5364. <tr align='center'>
  5365. <td>仓库</td>
  5366. <td>SKU</td>
  5367. <td>产品</td>
  5368. <td>当前库存</td>
  5369. </tr>
  5370. </table>";
  5371. $filename = $title.".xls";
  5372. $tail = "";
  5373. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5374. }
  5375. }
  5376. /**
  5377. *
  5378. *
  5379. * 占单
  5380. *
  5381. *
  5382. **/
  5383. public function _kcyz()
  5384. {
  5385. $post = $this->input->post(NULL, TRUE);
  5386. if(isset($post['warehouse']))
  5387. {
  5388. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请更新浏览器缓存!','success'=>false)));exit;//不再使用
  5389. $warehouse = $this->input->post('warehouse',true);
  5390. $whlabel = $this->input->post('whlabel',true);
  5391. $id = $this->input->post('id',true);
  5392. $shop = $this->input->post('shop',true);
  5393. $number = $this->input->post('number',true);
  5394. if(!$whlabel || $whlabel == '|')
  5395. {
  5396. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  5397. }
  5398. $pp = explode('|',trim($whlabel,'|'));
  5399. $x = 0;$save = array();
  5400. foreach ($pp as $va)
  5401. {
  5402. $num = explode('-',$va);
  5403. if($number)
  5404. {
  5405. $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 = '')");//通用
  5406. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  5407. }
  5408. else
  5409. {
  5410. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  5411. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  5412. }
  5413. $x++;
  5414. if(count($whlabel)+count($shopwhlabel) < $num[1])
  5415. {
  5416. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  5417. }
  5418. }
  5419. if(isset($save[0]))
  5420. {
  5421. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
  5422. }
  5423. else
  5424. {
  5425. echo json_encode(array('success'=>true));exit;
  5426. }
  5427. }
  5428. }
  5429. public function _db()
  5430. {
  5431. $post = $this->input->post(NULL, TRUE);
  5432. if(isset($post['page']))
  5433. {
  5434. $page = $this->input->post('page',true);
  5435. $perpage = $this->input->post('perpage',true);
  5436. $sku = $this->input->post('sku',true);
  5437. $number = $this->input->post('number',true);
  5438. $warehouse = $this->input->post('warehouse',true);
  5439. $purchase = $this->input->post('purchase',true);
  5440. $orderinfo = $this->input->post('orderinfo',true);
  5441. $waybill = $this->input->post('waybill',true);
  5442. $category = $this->input->post('category',true);
  5443. $size = $this->input->post('size',true);
  5444. $grade = $this->input->post('grade',true);
  5445. $color = $this->input->post('color',true);
  5446. $lowe = $this->input->post('lowe',true);
  5447. $state = $this->input->post('state',true);
  5448. $label = $this->input->post('label',true);
  5449. $timetk = $this->input->post('timetkk',true);
  5450. $timetj = $this->input->post('timetjj',true);
  5451. $timetk = strtotime($timetk);
  5452. $timetj = strtotime($timetj);
  5453. $where = "dbtime > 0";
  5454. if($timetk && $timetj)
  5455. {
  5456. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5457. }
  5458. if($sku)
  5459. {
  5460. $where .= " and sku = '$sku'";
  5461. }
  5462. if($warehouse)
  5463. {
  5464. $where .= " and warehouse = '$warehouse'";
  5465. if($warehouse == 12)
  5466. {
  5467. $w = 'specialstock';
  5468. }
  5469. else
  5470. {
  5471. $w = 'whlabel';
  5472. }
  5473. }
  5474. if($purchase)
  5475. {
  5476. $where .= " and purchase = '$purchase'";
  5477. }
  5478. if($category)
  5479. {
  5480. $where .= " and features like '%-$category-%'";
  5481. }
  5482. if($size)
  5483. {
  5484. $where .= " and features like '%-$size-%'";
  5485. }
  5486. if($grade)
  5487. {
  5488. $where .= " and features like '%-$grade-%'";
  5489. }
  5490. if($color)
  5491. {
  5492. $where .= " and features like '%-$color-%'";
  5493. }
  5494. if($lowe)
  5495. {
  5496. $where .= " and features like '%-$lowe-%'";
  5497. }
  5498. if($state != '')
  5499. {
  5500. $where .= " and state = '$state'";
  5501. }
  5502. //数据排序
  5503. $order_str = "dbtime desc";
  5504. if(empty($page))
  5505. {
  5506. $start = 0;
  5507. $perpage = 1;
  5508. }
  5509. else
  5510. {
  5511. $start = ($page - 1)*$perpage;
  5512. }
  5513. //取得信息列表
  5514. $info_list = $this->$w->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5515. foreach ($info_list as $key=>$value)
  5516. {
  5517. $warehouse = $this->$w->read($value['warehouse']);
  5518. $info_list[$key]['warehouse'] = $warehouse['title'];
  5519. $purchase = $this->purchase->read($value['purchase']);
  5520. $info_list[$key]['purchase'] = $purchase['title'];
  5521. if($value['enter'] != 0)
  5522. {
  5523. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5524. }
  5525. else
  5526. {
  5527. $info_list[$key]['enter'] = "";
  5528. }
  5529. if($value['dbtime'] != 0)
  5530. {
  5531. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5532. }
  5533. else
  5534. {
  5535. $info_list[$key]['dbtime'] = "";
  5536. }
  5537. if($value['state'] == 0)
  5538. {
  5539. $info_list[$key]['state'] = "在库";
  5540. }
  5541. else if($value['state'] == 1)
  5542. {
  5543. $info_list[$key]['state'] = "出库";
  5544. }
  5545. else if($value['state'] == 2)
  5546. {
  5547. $info_list[$key]['state'] = "退库";
  5548. }
  5549. else if($value['state'] == 3)
  5550. {
  5551. $info_list[$key]['state'] = "调拨中";
  5552. }
  5553. else if($value['state'] == 4)
  5554. {
  5555. $info_list[$key]['state'] = "再加工";
  5556. }
  5557. else if($value['state'] == 5)
  5558. {
  5559. $info_list[$key]['state'] = "维修中";
  5560. }
  5561. else if($value['state'] == 6)
  5562. {
  5563. $info_list[$key]['state'] = "盘亏";
  5564. }
  5565. else if($value['state'] == 7)
  5566. {
  5567. $info_list[$key]['state'] = "更换标签";
  5568. }
  5569. else if($value['state'] == 8)
  5570. {
  5571. $info_list[$key]['state'] = "其它";
  5572. }
  5573. else if($value['state'] == 9)
  5574. {
  5575. $info_list[$key]['state'] = "预设";
  5576. }
  5577. }
  5578. $total = $this->whlabel->find_count($where);
  5579. $pagenum = ceil($total/$perpage);
  5580. $over = $total-($start+$perpage);
  5581. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5582. echo json_encode($rows);exit;
  5583. }
  5584. if(isset($post['outsku']))
  5585. {
  5586. $time = time();
  5587. $cz = $this->input->post('cz',true);
  5588. $label = $this->input->post('outsku',true);
  5589. $sl = $this->input->post('sl',true);
  5590. $num = $this->input->post('num',true);
  5591. //$warehouse = $this->input->post('warehouse',true);
  5592. if(!$sl)
  5593. {
  5594. $sl = 1;
  5595. }
  5596. if(!$warehouse)
  5597. {
  5598. echo json_encode(array('msg'=>'请选择调拨到的仓库','success'=>false));exit;
  5599. }
  5600. $dblabel = $this->whlabellabel->get_label($label);
  5601. if($dblabel)
  5602. {
  5603. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '0' and zd = ''");
  5604. if(count($data) < 1)
  5605. {
  5606. echo json_encode(array('msg'=>'没有此产品数据!','success'=>false));exit;
  5607. }
  5608. if(count($data) < $num)
  5609. {
  5610. echo json_encode(array('msg'=>'库存数量少于调拨数量!','success'=>false));exit;
  5611. }
  5612. for($i=0;$i<$sl;$i++)
  5613. {
  5614. $this->whlabel->save(array('state'=>3,'dbtime'=>$dbtime,'dbcontent'=>$data[$i]['warehouse'].'-'.$time.'|','time'=>$time),$data[$i]['id']);
  5615. }
  5616. echo json_encode(array('success'=>true));exit;
  5617. }
  5618. else
  5619. {
  5620. echo json_encode(array('msg'=>'未找到此条码产品!','success'=>false));exit;
  5621. }
  5622. }
  5623. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5624. $this->_Template('whlabel_db',$this->data);
  5625. }
  5626. public function _dbrk()
  5627. {
  5628. $post = $this->input->post(NULL, TRUE);
  5629. if(isset($post['page']))
  5630. {
  5631. $page = $this->input->post('page',true);
  5632. $perpage = $this->input->post('perpage',true);
  5633. $sku = $this->input->post('sku',true);
  5634. $number = $this->input->post('number',true);
  5635. $warehouse = $this->input->post('warehouse',true);
  5636. $purchase = $this->input->post('purchase',true);
  5637. $orderinfo = $this->input->post('orderinfo',true);
  5638. $waybill = $this->input->post('waybill',true);
  5639. $category = $this->input->post('category',true);
  5640. $size = $this->input->post('size',true);
  5641. $grade = $this->input->post('grade',true);
  5642. $color = $this->input->post('color',true);
  5643. $lowe = $this->input->post('lowe',true);
  5644. $state = $this->input->post('state',true);
  5645. $label = $this->input->post('label',true);
  5646. $ctime = $this->input->post('ctime',true);
  5647. $timetk = $this->input->post('timetkk',true);
  5648. $timetj = $this->input->post('timetjj',true);
  5649. $timetk = strtotime($timetk);
  5650. $timetj = strtotime($timetj);
  5651. $where = "dbtime > 0";
  5652. if($timetk && $timetj)
  5653. {
  5654. $where .= " and ".$ctime." > '$timetk' and ".$ctime." < '$timetj'";
  5655. }
  5656. if($sku)
  5657. {
  5658. $where .= " and sku = '$sku'";
  5659. }
  5660. if($warehouse)
  5661. {
  5662. $where .= " and warehouse = '$warehouse'";
  5663. }
  5664. if($purchase)
  5665. {
  5666. $where .= " and purchase = '$purchase'";
  5667. }
  5668. if($category)
  5669. {
  5670. $where .= " and features like '%-$category-%'";
  5671. }
  5672. if($size)
  5673. {
  5674. $where .= " and features like '%-$size-%'";
  5675. }
  5676. if($grade)
  5677. {
  5678. $where .= " and features like '%-$grade-%'";
  5679. }
  5680. if($color)
  5681. {
  5682. $where .= " and features like '%-$color-%'";
  5683. }
  5684. if($lowe)
  5685. {
  5686. $where .= " and features like '%-$lowe-%'";
  5687. }
  5688. if($state != '')
  5689. {
  5690. $where .= " and state = '$state'";
  5691. }
  5692. //数据排序
  5693. $order_str = "dbtime desc";
  5694. if(empty($page))
  5695. {
  5696. $start = 0;
  5697. $perpage = 1;
  5698. }
  5699. else
  5700. {
  5701. $start = ($page - 1)*$perpage;
  5702. }
  5703. //取得信息列表
  5704. $info_list = $this->whlabel->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5705. foreach ($info_list as $key=>$value)
  5706. {
  5707. $warehouse = $this->warehouse->read($value['warehouse']);
  5708. $info_list[$key]['warehouse'] = $warehouse['title'];
  5709. $purchase = $this->purchase->read($value['purchase']);
  5710. $info_list[$key]['purchase'] = $purchase['title'];
  5711. if($value['enter'] != 0)
  5712. {
  5713. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5714. }
  5715. else
  5716. {
  5717. $info_list[$key]['enter'] = "";
  5718. }
  5719. if($value['dbtime'] != 0)
  5720. {
  5721. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5722. }
  5723. else
  5724. {
  5725. $info_list[$key]['dbtime'] = "";
  5726. }
  5727. if($value['state'] == 0)
  5728. {
  5729. $info_list[$key]['state'] = "在库";
  5730. }
  5731. else if($value['state'] == 1)
  5732. {
  5733. $info_list[$key]['state'] = "出库";
  5734. }
  5735. else if($value['state'] == 2)
  5736. {
  5737. $info_list[$key]['state'] = "退库";
  5738. }
  5739. else if($value['state'] == 3)
  5740. {
  5741. $info_list[$key]['state'] = "调拨中";
  5742. }
  5743. else if($value['state'] == 4)
  5744. {
  5745. $info_list[$key]['state'] = "再加工";
  5746. }
  5747. else if($value['state'] == 5)
  5748. {
  5749. $info_list[$key]['state'] = "维修中";
  5750. }
  5751. else if($value['state'] == 6)
  5752. {
  5753. $info_list[$key]['state'] = "盘亏";
  5754. }
  5755. else if($value['state'] == 7)
  5756. {
  5757. $info_list[$key]['state'] = "更换标签";
  5758. }
  5759. else if($value['state'] == 8)
  5760. {
  5761. $info_list[$key]['state'] = "其它";
  5762. }
  5763. else if($value['state'] == 9)
  5764. {
  5765. $info_list[$key]['state'] = "预设";
  5766. }
  5767. }
  5768. $total = $this->whlabel->find_count($where);
  5769. $pagenum = ceil($total/$perpage);
  5770. $over = $total-($start+$perpage);
  5771. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5772. echo json_encode($rows);exit;
  5773. }
  5774. if(isset($post['rsku']))
  5775. {
  5776. $cz = $this->input->post('cz',true);
  5777. $label = $this->input->post('rsku',true);
  5778. $sl = $this->input->post('sl',true);
  5779. $warehouse = $this->input->post('warehouse',true);
  5780. if(!$sl)
  5781. {
  5782. $sl = 1;
  5783. }
  5784. if(!$warehouse)
  5785. {
  5786. echo json_encode(array('msg'=>'请选择入库仓库','success'=>false));exit;
  5787. }
  5788. $dblabel = $this->whlabellabel->get_label($label);
  5789. if($dblabel)
  5790. {
  5791. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '3' and zd = ''");
  5792. if(count($data) < 1)
  5793. {
  5794. echo json_encode(array('msg'=>'没有此SKU调拨数据!','success'=>false));exit;
  5795. }
  5796. if($sl > count($data))
  5797. {
  5798. echo json_encode(array('msg'=>'入库数量大于调拨数量!','success'=>false));exit;
  5799. }
  5800. $time = time();
  5801. for($i=0;$i<$sl;$i++)
  5802. {
  5803. $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']);
  5804. }
  5805. echo json_encode(array('success'=>true));exit;
  5806. }
  5807. else
  5808. {
  5809. echo json_encode(array('msg'=>'没有此条码的库存信息!','success'=>false));exit;
  5810. }
  5811. }
  5812. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5813. $this->_Template('whlabel_dbrk',$this->data);
  5814. }
  5815. public function _whlabelczdc()
  5816. {
  5817. if(isset($_GET['excel']))
  5818. {
  5819. //数据排序
  5820. $order_str = "id desc";
  5821. if(empty($page))
  5822. {
  5823. $start = 0;
  5824. $perpage = 1;
  5825. }
  5826. else
  5827. {
  5828. $start = ($page - 1)*$perpage;
  5829. }
  5830. $state = $this->input->get('state',true);
  5831. $sku = $this->input->get('sku',true);
  5832. $ctime = $this->input->get('ctime',true);
  5833. $category = $this->input->get('category',true);
  5834. $size = $this->input->get('size',true);
  5835. $grade = $this->input->get('grade',true);
  5836. $color = $this->input->get('color',true);
  5837. $lowe = $this->input->get('lowe',true);
  5838. $timetk = $this->input->get('timetkk',true);
  5839. $timetj = $this->input->get('timetjj',true);
  5840. $timetk = strtotime($timetk);
  5841. $timetj = strtotime($timetj);
  5842. $where = "dbtime > 0";
  5843. if($timetk && $timetj)
  5844. {
  5845. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5846. }
  5847. if($category)
  5848. {
  5849. $where .= " and features like '%-$category-%'";
  5850. }
  5851. if($size)
  5852. {
  5853. $where .= " and features like '%-$size-%'";
  5854. }
  5855. if($grade)
  5856. {
  5857. $where .= " and features like '%-$grade-%'";
  5858. }
  5859. if($color)
  5860. {
  5861. $where .= " and features like '%-$color-%'";
  5862. }
  5863. if($lowe)
  5864. {
  5865. $where .= " and features like '%-$lowe-%'";
  5866. }
  5867. //取得信息列表
  5868. $info_list = $this->whlabel->find_all($where,'*');
  5869. $rows = array();$list = array();
  5870. foreach ($info_list as $key=>$value)
  5871. {
  5872. $rows[$value['sku']] = $value;//所有数据sku
  5873. }
  5874. foreach ($rows as $value)
  5875. {
  5876. $warehouse = $this->warehouse->read($value['warehouse']);
  5877. $db = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'"');
  5878. $rk = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and enter > 0');
  5879. if($value['orderinfo'] == 0)
  5880. {
  5881. $info_list[$key]['orderinfo'] = "";
  5882. }
  5883. if($value['waybill'] == 0)
  5884. {
  5885. $info_list[$key]['waybill'] = "";
  5886. }
  5887. if($value['state'] == 0)
  5888. {
  5889. $value['state'] = "在库";
  5890. }
  5891. else if($value['state'] == 3)
  5892. {
  5893. $value['state'] = "调拨中";
  5894. }
  5895. $list[] = array($value['sku'],$value['title'],$db,$rk);
  5896. }
  5897. $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj)."统计表";
  5898. $titlename = "<table border=1>
  5899. <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
  5900. <tr align='center'>
  5901. <td>SKU</td>
  5902. <td>产品</td>
  5903. <td>调拨数量</td>
  5904. <td>入库数量</td>
  5905. </tr>
  5906. </table>";
  5907. $filename = $title.".xls";
  5908. $tail = "";
  5909. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5910. }
  5911. }
  5912. public function _print($arg_array)
  5913. {
  5914. if(isset($_SESSION['api']))
  5915. {
  5916. $user = $this->user->get_api($_SESSION['api']);
  5917. $usp = $user;
  5918. $fgshop = "";$sid = "";$wid="";$wtype="";
  5919. $usersp = explode('|',trim($user['shop'],'|'));
  5920. $userwh = explode('|',trim($user['warehouse'],'|'));
  5921. foreach ($usersp as $value)
  5922. {
  5923. $fgshop .= " shop = ".$value." or";
  5924. $sid .= " id = ".$value." or";
  5925. }
  5926. foreach ($userwh as $value)
  5927. {
  5928. $wid .= " id = ".$value." or";
  5929. $wtype .= " type = ".$value." or";
  5930. }
  5931. }
  5932. $post = $this->input->post(NULL, TRUE);
  5933. if(isset($post['tmsku']))
  5934. {
  5935. $tmsku = $this->input->post('tmsku',true);
  5936. if(is_numeric($tmsku))
  5937. {
  5938. $yyh = $this->whlabellabel->get_label($tmsku);
  5939. }
  5940. else
  5941. {
  5942. $yyh = $this->whlabellabel->get_sku($tmsku);
  5943. }
  5944. if($yyh)
  5945. {
  5946. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  5947. }
  5948. else
  5949. {
  5950. echo json_encode(array('success'=>false));exit;
  5951. }
  5952. }
  5953. $classid = $this->classid->sku();
  5954. $pm = $classid;
  5955. $scsku = $classid;
  5956. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5957. if(isset($post['warehouse']))
  5958. {
  5959. if($post['warehouse'])
  5960. {
  5961. $list = array();$num = "";$title = "";$features = "";
  5962. $order = 0;
  5963. $post['shop'] = '';
  5964. $brand = $this->input->post('brand',true);
  5965. if($brand != '0,')
  5966. {
  5967. $b = $this->brand->read(rtrim($brand,','));
  5968. if($b)
  5969. {
  5970. $post['shop'] = str_replace('|',',',$b['shop']);
  5971. }
  5972. }
  5973. $post['details'] = $this->input->post('details',true);//打印数量
  5974. $xbqnum = $this->input->post('xbqnum',true);
  5975. $post['purchase'] = $this->input->post('purchase',true);
  5976. $post['warehouse'] = $this->input->post('warehouse',true);
  5977. $post['purchase'] = $this->input->post('purchase',true);
  5978. $post['retreatwarehouse'] = $post['warehouse'];
  5979. $post['cpbz'] = $this->input->post('cpbz',true);
  5980. $post['state'] = 9;
  5981. $category = $this->input->post('category',true);
  5982. $list['category'] = $category;
  5983. $list['hairtype'] = $this->input->post('hairtype',true);
  5984. $list['grade'] = $this->input->post('grade',true);
  5985. $size = $this->input->post('size',true);
  5986. $list['size'] = rtrim($size,',');
  5987. $list['hairnumber'] = $this->input->post('hairnumber',true);
  5988. $list['extension'] = $this->input->post('extension',true);
  5989. if($category == 1297)
  5990. {
  5991. $list['sywignumber'] = $this->input->post('sywignumber',true);
  5992. }
  5993. if($category == 1702)
  5994. {
  5995. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  5996. $list['syother'] = $this->input->post('syother',true);
  5997. }
  5998. if($category == 133)
  5999. {
  6000. $list['fittype'] = $this->input->post('fittype',true);
  6001. $list['acother'] = $this->input->post('acother',true);
  6002. }
  6003. $list['color'] = $this->input->post('color',true);
  6004. $list['lowe'] = $this->input->post('lowe',true);
  6005. if($category == 127)
  6006. {
  6007. $list['type'] = $this->input->post('type',true);
  6008. $list['headroad'] = $this->input->post('headroad',true);
  6009. $list['density'] = $this->input->post('density',true);
  6010. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  6011. {
  6012. $list['lacesize'] = $this->input->post('lacesize',true);
  6013. }
  6014. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6015. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6016. }
  6017. if($category == 128)
  6018. {
  6019. $list['lacetype'] = $this->input->post('lacetype',true);
  6020. $list['haircap'] = $this->input->post('haircap',true);
  6021. $list['density'] = $this->input->post('density',true);
  6022. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6023. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6024. $list['wigother'] = $this->input->post('wigother',true);
  6025. $list['wigother2'] = $this->input->post('wigother2',true);
  6026. }
  6027. if($category == 129)
  6028. {
  6029. $list['wide'] = $this->input->post('wide',true);
  6030. }
  6031. if($category == 131)
  6032. {
  6033. $list['gifttype'] = $this->input->post('gifttype',true);
  6034. $list['giftother'] = $this->input->post('giftother',true);
  6035. }
  6036. if($category == 134)
  6037. {
  6038. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6039. }
  6040. if($category == 1297)
  6041. {
  6042. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6043. $list['sywigother'] = $this->input->post('sywigother',true);
  6044. }
  6045. if($category == 130 || $category == 133 || $category == 1702)
  6046. {
  6047. $list['items'] = $this->input->post('items',true);
  6048. $list['weight'] = $this->input->post('weight',true);
  6049. }
  6050. if($category == 1702)
  6051. {
  6052. $list['syhairther'] = $this->input->post('syhairther',true);
  6053. }
  6054. foreach($list as $k=>$v)
  6055. {
  6056. if($v != 0)
  6057. {
  6058. $num .=$v;
  6059. $features .=$v.'-';
  6060. $post[$k] = $v;
  6061. $typeclass = $this->typeclass->read($v);
  6062. if(isset($pm[$typeclass['classid']]))
  6063. {
  6064. if(stripos($typeclass['zh'],'|') !== false)
  6065. {
  6066. $exzh = explode('|',$typeclass['zh']);
  6067. $pm[$typeclass['classid']] = $exzh[0];
  6068. }
  6069. else
  6070. {
  6071. $pm[$typeclass['classid']] = $typeclass['zh'];
  6072. }
  6073. }
  6074. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6075. if($k != 'size')
  6076. {
  6077. $title .= $typeclass['title']." ";
  6078. }
  6079. }
  6080. }
  6081. $typeclass = $this->typeclass->read($list['size']);
  6082. $title .= $typeclass['title'];
  6083. $time = time();
  6084. $post['title'] = rtrim($title,' ');
  6085. $post['number'] = $num;
  6086. $post['features'] = '-'.$features;
  6087. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6088. $featurespp = explode('-',trim($featurespp,'-'));
  6089. if(isset($featurespp[5]))
  6090. {
  6091. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6092. }
  6093. else
  6094. {
  6095. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6096. }
  6097. $post['enter'] = $time;
  6098. $post['time'] = $time;//操作时间
  6099. $scsku = implode("-",$scsku);
  6100. $zh = implode(" ",$pm);
  6101. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6102. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6103. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6104. $post['sku'] = $bqsku;
  6105. $label = time().rand(0,9);
  6106. $post['label'] = $label;
  6107. $cpid = $this->whlabellabel->find_count();
  6108. $post['cpid'] = $cpid+1;
  6109. $cpid = $post['cpid'];
  6110. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6111. //if($whlabelbarcode)
  6112. //{
  6113. //$post['label'] = $whlabelbarcode['label'];
  6114. //if(!$this->whlabellabel->insert($post))
  6115. //{
  6116. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6117. //}
  6118. //}
  6119. //else
  6120. //{
  6121. $this->db->trans_begin();
  6122. $this->whlabellabel->insert($post);
  6123. //$this->whlabelbarcode->insert($post);
  6124. if ($this->db->trans_status() === TRUE)
  6125. {
  6126. $this->db->trans_commit();
  6127. }
  6128. else
  6129. {
  6130. $this->db->trans_rollback();
  6131. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6132. }
  6133. //}
  6134. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6135. $purchase = $this->purchase->read($post['purchase']);
  6136. 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;//特殊仓目前不需要仓库选项
  6137. }
  6138. }
  6139. if(isset($_SESSION['api']))
  6140. {
  6141. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6142. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6143. $this->data['wlshop'] = $wlshop;
  6144. $this->data['warehouse'] = $warehouse;
  6145. }
  6146. $whlabelwz = $this->whlabelwz->find_all();
  6147. $this->data['whlabelwz'] = $whlabelwz;
  6148. $this->_Template('whlabel_print',$this->data);
  6149. }
  6150. public function _usaprint($arg_array)
  6151. {
  6152. if(isset($_SESSION['api']))
  6153. {
  6154. $user = $this->user->get_api($_SESSION['api']);
  6155. $usp = $user;
  6156. $fgshop = "";$sid = "";$wid="";$wtype="";
  6157. $usersp = explode('|',trim($user['shop'],'|'));
  6158. $userwh = explode('|',trim($user['warehouse'],'|'));
  6159. foreach ($usersp as $value)
  6160. {
  6161. $fgshop .= " shop = ".$value." or";
  6162. $sid .= " id = ".$value." or";
  6163. }
  6164. foreach ($userwh as $value)
  6165. {
  6166. $wid .= " id = ".$value." or";
  6167. $wtype .= " type = ".$value." or";
  6168. }
  6169. }
  6170. $post = $this->input->post(NULL, TRUE);
  6171. if(isset($post['tmsku']))
  6172. {
  6173. $tmsku = $this->input->post('tmsku',true);
  6174. if(is_numeric($tmsku))
  6175. {
  6176. $yyh = $this->whlabellabel->get_label($tmsku);
  6177. }
  6178. else
  6179. {
  6180. $yyh = $this->whlabellabel->get_sku($tmsku);
  6181. }
  6182. if($yyh)
  6183. {
  6184. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  6185. }
  6186. else
  6187. {
  6188. echo json_encode(array('success'=>false));exit;
  6189. }
  6190. }
  6191. $classid = $this->classid->sku();
  6192. $pm = $classid;
  6193. $scsku = $classid;
  6194. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6195. if(isset($post['warehouse']))
  6196. {
  6197. if($post['warehouse'])
  6198. {
  6199. $list = array();$num = "";$title = "";$features = "";
  6200. $order = 0;
  6201. $post['shop'] = '';
  6202. $brand = $this->input->post('brand',true);
  6203. if($brand != '0,')
  6204. {
  6205. $b = $this->brand->read(rtrim($brand,','));
  6206. if($b)
  6207. {
  6208. $post['shop'] = str_replace('|',',',$b['shop']);
  6209. }
  6210. }
  6211. $post['details'] = $this->input->post('details',true);//打印数量
  6212. $xbqnum = $this->input->post('xbqnum',true);
  6213. $post['purchase'] = $this->input->post('purchase',true);
  6214. $post['warehouse'] = $this->input->post('warehouse',true);
  6215. $post['purchase'] = $this->input->post('purchase',true);
  6216. $post['retreatwarehouse'] = $post['warehouse'];
  6217. $post['cpbz'] = $this->input->post('cpbz',true);
  6218. $post['state'] = 9;
  6219. $category = $this->input->post('category',true);
  6220. $list['category'] = $category;
  6221. $list['hairtype'] = $this->input->post('hairtype',true);
  6222. $list['grade'] = $this->input->post('grade',true);
  6223. $size = $this->input->post('size',true);
  6224. $list['size'] = rtrim($size,',');
  6225. $list['hairnumber'] = $this->input->post('hairnumber',true);
  6226. $list['extension'] = $this->input->post('extension',true);
  6227. if($category == 1297)
  6228. {
  6229. $list['sywignumber'] = $this->input->post('sywignumber',true);
  6230. }
  6231. if($category == 1702)
  6232. {
  6233. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  6234. $list['syother'] = $this->input->post('syother',true);
  6235. }
  6236. if($category == 133)
  6237. {
  6238. $list['fittype'] = $this->input->post('fittype',true);
  6239. $list['acother'] = $this->input->post('acother',true);
  6240. }
  6241. $list['color'] = $this->input->post('color',true);
  6242. $list['lowe'] = $this->input->post('lowe',true);
  6243. if($category == 127)
  6244. {
  6245. $list['type'] = $this->input->post('type',true);
  6246. $list['headroad'] = $this->input->post('headroad',true);
  6247. $list['density'] = $this->input->post('density',true);
  6248. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  6249. {
  6250. $list['lacesize'] = $this->input->post('lacesize',true);
  6251. }
  6252. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6253. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6254. }
  6255. if($category == 128)
  6256. {
  6257. $list['lacetype'] = $this->input->post('lacetype',true);
  6258. $list['haircap'] = $this->input->post('haircap',true);
  6259. $list['density'] = $this->input->post('density',true);
  6260. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6261. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6262. $list['wigother'] = $this->input->post('wigother',true);
  6263. $list['wigother2'] = $this->input->post('wigother2',true);
  6264. }
  6265. if($category == 129)
  6266. {
  6267. $list['wide'] = $this->input->post('wide',true);
  6268. }
  6269. if($category == 131)
  6270. {
  6271. $list['gifttype'] = $this->input->post('gifttype',true);
  6272. $list['giftother'] = $this->input->post('giftother',true);
  6273. }
  6274. if($category == 134)
  6275. {
  6276. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6277. }
  6278. if($category == 1297)
  6279. {
  6280. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6281. $list['sywigother'] = $this->input->post('sywigother',true);
  6282. }
  6283. if($category == 130 || $category == 133 || $category == 1702)
  6284. {
  6285. $list['items'] = $this->input->post('items',true);
  6286. $list['weight'] = $this->input->post('weight',true);
  6287. }
  6288. if($category == 1702)
  6289. {
  6290. $list['syhairther'] = $this->input->post('syhairther',true);
  6291. }
  6292. foreach($list as $k=>$v)
  6293. {
  6294. if($v != 0)
  6295. {
  6296. $num .=$v;
  6297. $features .=$v.'-';
  6298. $post[$k] = $v;
  6299. $typeclass = $this->typeclass->read($v);
  6300. if(isset($pm[$typeclass['classid']]))
  6301. {
  6302. if(stripos($typeclass['zh'],'|') !== false)
  6303. {
  6304. $exzh = explode('|',$typeclass['zh']);
  6305. $pm[$typeclass['classid']] = $exzh[0];
  6306. }
  6307. else
  6308. {
  6309. $pm[$typeclass['classid']] = $typeclass['zh'];
  6310. }
  6311. }
  6312. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6313. if($k != 'size')
  6314. {
  6315. $title .= $typeclass['title']." ";
  6316. }
  6317. }
  6318. }
  6319. $typeclass = $this->typeclass->read($list['size']);
  6320. $title .= $typeclass['title'];
  6321. $time = time();
  6322. $post['title'] = rtrim($title,' ');
  6323. $post['number'] = $num;
  6324. $post['features'] = '-'.$features;
  6325. $fp = $this->whlabel->get_features($post['features']);
  6326. if(!$fp)
  6327. {
  6328. echo json_encode(array('msg'=>'美仓无此产品,需要添加后才可打印','success'=>false));exit;
  6329. }
  6330. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6331. $featurespp = explode('-',trim($featurespp,'-'));
  6332. if(isset($featurespp[5]))
  6333. {
  6334. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6335. }
  6336. else
  6337. {
  6338. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6339. }
  6340. $post['enter'] = $time;
  6341. $post['time'] = $time;//操作时间
  6342. $scsku = implode("-",$scsku);
  6343. $zh = implode(" ",$pm);
  6344. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6345. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6346. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6347. $post['sku'] = $fp['sku'];
  6348. $post['label'] = $fp['sku'];
  6349. $cpid = $this->whlabellabel->find_count();
  6350. $post['cpid'] = $cpid+1;
  6351. $cpid = $post['cpid'];
  6352. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6353. //if($whlabelbarcode)
  6354. //{
  6355. //$post['label'] = $whlabelbarcode['label'];
  6356. //if(!$this->whlabellabel->insert($post))
  6357. //{
  6358. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6359. //}
  6360. //}
  6361. //else
  6362. //{
  6363. $this->db->trans_begin();
  6364. $this->whlabellabel->insert($post);
  6365. //$this->whlabelbarcode->insert($post);
  6366. if ($this->db->trans_status() === TRUE)
  6367. {
  6368. $this->db->trans_commit();
  6369. }
  6370. else
  6371. {
  6372. $this->db->trans_rollback();
  6373. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6374. }
  6375. //}
  6376. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6377. $purchase = $this->purchase->read($post['purchase']);
  6378. 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;//特殊仓目前不需要仓库选项
  6379. }
  6380. }
  6381. if(isset($_SESSION['api']))
  6382. {
  6383. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6384. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6385. $this->data['wlshop'] = $wlshop;
  6386. $this->data['warehouse'] = $warehouse;
  6387. }
  6388. $whlabelwz = $this->whlabelwz->find_all();
  6389. $this->data['whlabelwz'] = $whlabelwz;
  6390. $this->_Template('whlabel_usaprint',$this->data);
  6391. }
  6392. public function _printrk($arg_array)
  6393. {
  6394. $prc = array();
  6395. $purchase = $this->purchase->find_all();
  6396. foreach($purchase as $k=>$v)
  6397. {
  6398. $prc[$v['id']] = $v['title'];
  6399. }
  6400. $post = $this->input->post(NULL, TRUE);
  6401. if(isset($post['page']))
  6402. {
  6403. $page = $this->input->post('page',true);
  6404. $perpage = $this->input->post('perpage',true);
  6405. $sku = $this->input->post('sku',true);
  6406. $bs = $this->input->post('bs',true);
  6407. $number = $this->input->post('number',true);
  6408. $warehouse = $this->input->post('warehouse',true);
  6409. $purchase = $this->input->post('purchase',true);
  6410. $orderinfo = $this->input->post('orderinfo',true);
  6411. $waybill = $this->input->post('waybill',true);
  6412. $category = $this->input->post('category',true);
  6413. $size = $this->input->post('size',true);
  6414. $grade = $this->input->post('grade',true);
  6415. $color = $this->input->post('color',true);
  6416. $lowe = $this->input->post('lowe',true);
  6417. $state = $this->input->post('state',true);
  6418. $label = $this->input->post('label',true);
  6419. $timetk = $this->input->post('ktime',true);
  6420. $timetj = $this->input->post('jtime',true);
  6421. $timetk = strtotime($timetk);
  6422. $timetj = strtotime($timetj);
  6423. $where = "1=1 ";
  6424. if($timetk && $timetj)
  6425. {
  6426. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6427. }
  6428. if($sku)
  6429. {
  6430. $where .= " and sku = '$sku'";
  6431. }
  6432. if($bs != '')
  6433. {
  6434. $where .= " and bs = '$bs'";
  6435. }
  6436. if($number)
  6437. {
  6438. $where .= " and number = '$number'";
  6439. }
  6440. if($warehouse)
  6441. {
  6442. $where .= " and warehouse = '$warehouse'";
  6443. }
  6444. if($purchase)
  6445. {
  6446. $where .= " and purchase = '$purchase'";
  6447. }
  6448. if($orderinfo)
  6449. {
  6450. $where .= " and orderinfo = '$orderinfo'";
  6451. }
  6452. if($waybill)
  6453. {
  6454. $where .= " and waybill = '$waybill'";
  6455. }
  6456. if($category)
  6457. {
  6458. $where .= " and features like '%-$category-%'";
  6459. }
  6460. if($size)
  6461. {
  6462. $where .= " and features like '%-$size-%'";
  6463. }
  6464. if($grade)
  6465. {
  6466. $where .= " and features like '%-$grade-%'";
  6467. }
  6468. if($color)
  6469. {
  6470. $where .= " and features like '%-$color-%'";
  6471. }
  6472. if($lowe)
  6473. {
  6474. $where .= " and features like '%-$lowe-%'";
  6475. }
  6476. if($label)
  6477. {
  6478. $where .= " and label = '$label'";
  6479. }
  6480. if($state || $state == 0)
  6481. {
  6482. $where .= " and state = '$state'";
  6483. }
  6484. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6485. //数据排序
  6486. $order_str = "enter desc";
  6487. if(empty($page))
  6488. {
  6489. $start = 0;
  6490. $perpage = 1;
  6491. }
  6492. else
  6493. {
  6494. $start = ($page - 1)*$perpage;
  6495. }
  6496. //取得信息列表
  6497. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,enter,details',$order_str,$start,$perpage);
  6498. foreach ($info_list as $key=>$value)
  6499. {
  6500. $warehouse = $this->warehouse->read($value['warehouse']);
  6501. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6502. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6503. if($value['state'] == 0)
  6504. {
  6505. $info_list[$key]['state'] = "在库";
  6506. }
  6507. else if($value['state'] == 1)
  6508. {
  6509. $info_list[$key]['state'] = "出库";
  6510. }
  6511. else if($value['state'] == 2)
  6512. {
  6513. $info_list[$key]['state'] = "退库";
  6514. }
  6515. else if($value['state'] == 3)
  6516. {
  6517. $info_list[$key]['state'] = "调拨中";
  6518. }
  6519. else if($value['state'] == 4)
  6520. {
  6521. $info_list[$key]['state'] = "再加工";
  6522. }
  6523. else if($value['state'] == 5)
  6524. {
  6525. $info_list[$key]['state'] = "维修中";
  6526. }
  6527. else if($value['state'] == 6)
  6528. {
  6529. $info_list[$key]['state'] = "盘亏";
  6530. }
  6531. else if($value['state'] == 7)
  6532. {
  6533. $info_list[$key]['state'] = "更换标签";
  6534. }
  6535. else if($value['state'] == 8)
  6536. {
  6537. $info_list[$key]['state'] = "其它";
  6538. }
  6539. else if($value['state'] == 9)
  6540. {
  6541. $info_list[$key]['state'] = "预设";
  6542. }
  6543. else if($value['state'] == 10)
  6544. {
  6545. $info_list[$key]['state'] = "美店零售";
  6546. }
  6547. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  6548. }
  6549. $total = $this->$ck->find_count($where);
  6550. $pagenum = ceil($total/$perpage);
  6551. $over = $total-($start+$perpage);
  6552. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6553. echo json_encode($rows);exit;
  6554. }
  6555. if(isset($post['tmsku']))
  6556. {
  6557. $time = time();
  6558. $tmsku = $this->input->post('tmsku',true);
  6559. //$post['shop'] = $this->input->post('shop',true);
  6560. $num = $this->input->post('num',true);
  6561. $rktype = $this->input->post('rktype',true);
  6562. if($num > 200)
  6563. {
  6564. echo json_encode(array('msg'=>'入库数量不允许超过200!','c'=>0,'success'=>false));exit;
  6565. }
  6566. if(!$rktype)
  6567. {
  6568. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6569. }
  6570. $rk = $this->whlabellabel->find_all("label = '$tmsku'","*","id desc");
  6571. /**
  6572. $wz = array();
  6573. foreach ($rk as $key=>$value)
  6574. {
  6575. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6576. }
  6577. if(count($wz) > 1)
  6578. {
  6579. $wz = array_values($wz);
  6580. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6581. }
  6582. **/
  6583. if(isset($rk[0]['purchase']))
  6584. {
  6585. $rk = $rk[0];
  6586. $j = 0;
  6587. $post['purchase'] = $rk['purchase'];
  6588. $post['warehouse'] = $rk['warehouse'];
  6589. $post['retreatwarehouse'] = $rk['warehouse'];
  6590. $post['sku'] = $rk['sku'];
  6591. $post['number'] = $rk['number'];
  6592. $post['features'] = $rk['features'];
  6593. $post['title'] = $rk['title'];
  6594. $post['enter'] = $time;
  6595. $post['time'] = $time;
  6596. $post['bs'] = 1;
  6597. $post['shop'] = $rk['shop'];
  6598. $post['details'] = $rk['details'];
  6599. $post['cpid'] = $rk['cpid'];
  6600. $post['cpbz'] = $rk['cpbz'];
  6601. //$post['rktype'] = $rktype;
  6602. $warehouse = $this->warehouse->read($rk['warehouse']);
  6603. if($warehouse['bdck'] == '')
  6604. {
  6605. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','c'=>0,'success'=>false));exit;
  6606. }
  6607. else
  6608. {
  6609. $bdck = $warehouse['bdck'];
  6610. }
  6611. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'],$post['sku']);
  6612. if(isset($pdwz['details']))
  6613. {
  6614. if($pdwz['details'] != $post['details'])
  6615. {
  6616. echo json_encode(array('msg'=>'此产品位置应为:'.$pdwz['details'],'c'=>0,'cs'=>$pdwz['details'].' - '.$post['details'],'success'=>false));exit;
  6617. }
  6618. }
  6619. $post['featurespp'] = $rk['featurespp'];
  6620. if($post['warehouse'] == '5')
  6621. {
  6622. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6623. if($yza)
  6624. {
  6625. if($post['features'] != $yza[0]['features'])
  6626. {
  6627. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'c'=>0,'success'=>false));exit;
  6628. }
  6629. }
  6630. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6631. if($yzb)
  6632. {
  6633. if($post['sku'] != $yzb[0]['sku'])
  6634. {
  6635. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','c'=>0,'success'=>false));exit;
  6636. }
  6637. }
  6638. }
  6639. for($i=0;$i<$num;$i++)
  6640. {
  6641. $post['label'] = time().rand(100,999).$i;
  6642. if($this->$bdck->insert($post))
  6643. {
  6644. $j++;
  6645. }
  6646. }
  6647. /**
  6648. if($post['warehouse'] != 12)
  6649. {
  6650. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6651. }
  6652. **/
  6653. if($j == $num)
  6654. {
  6655. echo json_encode(array('msg'=>'入库成功!','success'=>true));exit;
  6656. }
  6657. else
  6658. {
  6659. echo json_encode(array('msg'=>'未成功入库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6660. }
  6661. }
  6662. else
  6663. {
  6664. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6665. }
  6666. }
  6667. $this->_Template('whlabel_printrk',$this->data);
  6668. }
  6669. public function _printxzrk($arg_array)
  6670. {
  6671. $post = $this->input->post(NULL, TRUE);
  6672. if(isset($post['wzid']))
  6673. {
  6674. $time = time();
  6675. $id = $this->input->post('wzid',true);
  6676. //$post['shop'] = $this->input->post('shop',true);
  6677. $num = 1;
  6678. $rk = $this->whlabellabel->read($id);
  6679. if(isset($rk['purchase']))
  6680. {
  6681. $x = 0;
  6682. $post['purchase'] = $rk['purchase'];
  6683. $post['warehouse'] = $rk['warehouse'];
  6684. $post['retreatwarehouse'] = $rk['warehouse'];
  6685. $post['sku'] = $rk['sku'];
  6686. $post['number'] = $rk['number'];
  6687. $post['features'] = $rk['features'];
  6688. $post['title'] = $rk['title'];
  6689. $post['enter'] = $time;
  6690. $post['time'] = $time;
  6691. $post['bs'] = 1;
  6692. $post['shop'] = $rk['shop'];
  6693. $post['details'] = $rk['details'];
  6694. $post['cpid'] = $rk['cpid'];
  6695. $post['cpbz'] = $rk['cpbz'];
  6696. $warehouse = $this->warehouse->read($rk['warehouse']);
  6697. if($warehouse['bdck'] == '')
  6698. {
  6699. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','success'=>false));exit;
  6700. }
  6701. else
  6702. {
  6703. $bdck = $warehouse['bdck'];
  6704. }
  6705. $post['featurespp'] = $rk['featurespp'];
  6706. $this->db->trans_begin();
  6707. for($i=0;$i<$num;$i++)
  6708. {
  6709. $post['label'] = time().rand(100,999).$i;
  6710. $this->$bdck->insert($post);
  6711. }
  6712. /**
  6713. if($post['warehouse'] != 12)
  6714. {
  6715. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6716. }
  6717. **/
  6718. if ($this->db->trans_status() === TRUE)
  6719. {
  6720. $this->db->trans_commit();
  6721. echo json_encode(array('msg'=>'入库成功!','cs'=>$post,'cs2'=>$warehouse,'success'=>true));exit;
  6722. }
  6723. else
  6724. {
  6725. $this->db->trans_rollback();
  6726. echo json_encode(array('msg'=>'入库失败,请重试','c'=>0,'success'=>false));exit;
  6727. }
  6728. }
  6729. else
  6730. {
  6731. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6732. }
  6733. }
  6734. }
  6735. public function _printck($arg_array)
  6736. {
  6737. $prc = array();
  6738. $purchase = $this->purchase->find_all();
  6739. foreach($purchase as $k=>$v)
  6740. {
  6741. $prc[$v['id']] = $v['title'];
  6742. }
  6743. $post = $this->input->post(NULL, TRUE);
  6744. if(isset($post['page']))
  6745. {
  6746. $page = $this->input->post('page',true);
  6747. $perpage = $this->input->post('perpage',true);
  6748. $sku = $this->input->post('sku',true);
  6749. $bs = $this->input->post('bs',true);
  6750. $number = $this->input->post('number',true);
  6751. $warehouse = $this->input->post('warehouse',true);
  6752. $purchase = $this->input->post('purchase',true);
  6753. $orderinfo = $this->input->post('orderinfo',true);
  6754. $waybill = $this->input->post('waybill',true);
  6755. $category = $this->input->post('category',true);
  6756. $size = $this->input->post('size',true);
  6757. $grade = $this->input->post('grade',true);
  6758. $color = $this->input->post('color',true);
  6759. $lowe = $this->input->post('lowe',true);
  6760. $state = $this->input->post('state',true);
  6761. $label = $this->input->post('label',true);
  6762. $timetk = $this->input->post('ktime',true);
  6763. $timetj = $this->input->post('jtime',true);
  6764. $timetk = strtotime($timetk);
  6765. $timetj = strtotime($timetj);
  6766. $where = "state=1 ";
  6767. if($timetk && $timetj)
  6768. {
  6769. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6770. }
  6771. if($sku)
  6772. {
  6773. $where .= " and sku = '$sku'";
  6774. }
  6775. if($bs != '')
  6776. {
  6777. $where .= " and bs = '$bs'";
  6778. }
  6779. if($number)
  6780. {
  6781. $where .= " and number = '$number'";
  6782. }
  6783. if($warehouse)
  6784. {
  6785. $where .= " and warehouse = '$warehouse'";
  6786. }
  6787. if($purchase)
  6788. {
  6789. $where .= " and purchase = '$purchase'";
  6790. }
  6791. if($orderinfo)
  6792. {
  6793. $where .= " and orderinfo = '$orderinfo'";
  6794. }
  6795. if($waybill)
  6796. {
  6797. $where .= " and waybill = '$waybill'";
  6798. }
  6799. if($category)
  6800. {
  6801. $where .= " and features like '%-$category-%'";
  6802. }
  6803. if($size)
  6804. {
  6805. $where .= " and features like '%-$size-%'";
  6806. }
  6807. if($grade)
  6808. {
  6809. $where .= " and features like '%-$grade-%'";
  6810. }
  6811. if($color)
  6812. {
  6813. $where .= " and features like '%-$color-%'";
  6814. }
  6815. if($lowe)
  6816. {
  6817. $where .= " and features like '%-$lowe-%'";
  6818. }
  6819. if($label)
  6820. {
  6821. $where .= " and label = '$label'";
  6822. }
  6823. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6824. //数据排序
  6825. $order_str = "outk desc";
  6826. if(empty($page))
  6827. {
  6828. $start = 0;
  6829. $perpage = 1;
  6830. }
  6831. else
  6832. {
  6833. $start = ($page - 1)*$perpage;
  6834. }
  6835. //取得信息列表
  6836. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,outk,details',$order_str,$start,$perpage);
  6837. foreach ($info_list as $key=>$value)
  6838. {
  6839. $warehouse = $this->warehouse->read($value['warehouse']);
  6840. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6841. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6842. if($value['state'] == 0)
  6843. {
  6844. $info_list[$key]['state'] = "在库";
  6845. }
  6846. else if($value['state'] == 1)
  6847. {
  6848. $info_list[$key]['state'] = "出库";
  6849. }
  6850. else if($value['state'] == 2)
  6851. {
  6852. $info_list[$key]['state'] = "退库";
  6853. }
  6854. else if($value['state'] == 3)
  6855. {
  6856. $info_list[$key]['state'] = "调拨中";
  6857. }
  6858. else if($value['state'] == 4)
  6859. {
  6860. $info_list[$key]['state'] = "再加工";
  6861. }
  6862. else if($value['state'] == 5)
  6863. {
  6864. $info_list[$key]['state'] = "维修中";
  6865. }
  6866. else if($value['state'] == 6)
  6867. {
  6868. $info_list[$key]['state'] = "盘亏";
  6869. }
  6870. else if($value['state'] == 7)
  6871. {
  6872. $info_list[$key]['state'] = "更换标签";
  6873. }
  6874. else if($value['state'] == 8)
  6875. {
  6876. $info_list[$key]['state'] = "其它";
  6877. }
  6878. else if($value['state'] == 9)
  6879. {
  6880. $info_list[$key]['state'] = "预设";
  6881. }
  6882. else if($value['state'] == 10)
  6883. {
  6884. $info_list[$key]['state'] = "美店零售";
  6885. }
  6886. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  6887. }
  6888. $total = $this->$ck->find_count($where);
  6889. $pagenum = ceil($total/$perpage);
  6890. $over = $total-($start+$perpage);
  6891. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6892. echo json_encode($rows);exit;
  6893. }
  6894. if(isset($post['tmsku']))
  6895. {
  6896. $time = time();
  6897. $tmsku = $this->input->post('tmsku',true);
  6898. //$post['shop'] = $this->input->post('shop',true);
  6899. $num = $this->input->post('num',true);
  6900. $cktype = $this->input->post('cktype',true);
  6901. $label = $this->whlabellabel->get_label($tmsku);
  6902. if(!$cktype)
  6903. {
  6904. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6905. }
  6906. if(!isset($label['warehouse']))
  6907. {
  6908. echo json_encode(array('msg'=>'没有此条码信息!','success'=>false));exit;
  6909. }
  6910. $xzck = ($label['warehouse'] == '12')?'specialstock':'whlabel';
  6911. if(stripos($label['features'],'-126-') !== false)
  6912. {
  6913. $ck = $this->$xzck->find_all("state = '0' and shop = '".$label['shop']."' and number = '".$label['number']."' and warehouse = '".$label['warehouse']."' and zd = ''");
  6914. }
  6915. else
  6916. {
  6917. $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 = ''");
  6918. }
  6919. $j = 0;
  6920. if(count($ck) >= $num)
  6921. {
  6922. for($i=0;$i<$num;$i++)
  6923. {
  6924. if($this->$xzck->save(array('state'=>1,'outk'=>$time,'time'=>$time),$ck[$i]['id']))//,'cktype'=>$cktype
  6925. {
  6926. $j++;
  6927. }
  6928. }
  6929. if($j == $num)
  6930. {
  6931. echo json_encode(array('msg'=>'出库成功!','success'=>true));exit;
  6932. }
  6933. else
  6934. {
  6935. echo json_encode(array('msg'=>'未成功出库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6936. }
  6937. }
  6938. else
  6939. {
  6940. echo json_encode(array('msg'=>'没有足够的库存!','cs'=>$label['sku'].' - '.$label['purchase'],'success'=>false));exit;
  6941. }
  6942. }
  6943. $this->_Template('whlabel_printck',$this->data);
  6944. }
  6945. public function _printexcel()
  6946. {
  6947. $dir = '/data/excel/'.date('Ymd',time()).'/';
  6948. $config['upload_path'] = '.'.$dir ;
  6949. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  6950. $config['allowed_types'] = 'xls|xlsx|csv';
  6951. $config['max_size'] = 10240;
  6952. $this->load->library('upload', $config);
  6953. $this->upload->initialize($config);
  6954. if ($this->upload->do_upload('userfile'))
  6955. {
  6956. $full_path = $dir.$this->upload->data('file_name');
  6957. $fileName = '.' . $full_path;
  6958. if (!file_exists($fileName))
  6959. {
  6960. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  6961. }
  6962. else
  6963. {
  6964. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6965. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  6966. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  6967. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  6968. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  6969. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  6970. ++$column;//如果列数大于26行
  6971. $list = array();
  6972. for ($i = 2; $i <= $row; $i++) // 行数循环
  6973. {
  6974. $data = array();
  6975. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6976. {
  6977. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6978. }
  6979. $list[] = $data;
  6980. }
  6981. }
  6982. $ed = array();$i = 0;$j = 0;$dcdata = array();$yc = '';
  6983. $cmf_arr = array_column($list, '1');
  6984. array_multisort($cmf_arr, SORT_ASC, $list);
  6985. foreach ($list as $key=>$value)
  6986. {
  6987. $typeclass = $this->typeclass->get_bqsku($value['1'],$value['2']);
  6988. if($typeclass)
  6989. {
  6990. $this->typeclass->save(array('bqsku'=>$value['3']),$typeclass['id']);
  6991. }
  6992. else
  6993. {
  6994. $ed[] = array($value['1'].'-系统未找到此订单信息');
  6995. $i++;
  6996. continue;
  6997. }
  6998. }
  6999. if($i > 0)
  7000. {
  7001. $yc = $i.'条异常';
  7002. }
  7003. echo json_encode(array('msg'=>'操作成功 '.$yc,'yc'=>$ed,'success'=>true));exit;
  7004. }
  7005. }
  7006. public function _uck()
  7007. {
  7008. if(isset($_GET['excel']))
  7009. {
  7010. $tc = array();
  7011. $typeclass = $this->typeclass->find_all();
  7012. foreach ($typeclass as $v)
  7013. {
  7014. $tc[$v['id']] = $v['zh'];
  7015. }
  7016. $data = array();$t = array();$rq = '';
  7017. $ts = strtotime(date("Y-m-d",time()))-strtotime(date("Y-m",time()));
  7018. $ts = $ts/(24*3600);
  7019. for($i=0;$i<$ts;$i++)
  7020. {
  7021. $t[] = date("Y-m-d",strtotime('-'.($ts-$i).' day'));
  7022. $rq .= "<td>".date("Y-m-d",strtotime('-'.($ts-$i).' day'))."</td>";
  7023. }
  7024. $info_list = $this->whlabel->find_pc("warehouse = '5'",'sku','warehouse,sku,features');
  7025. foreach ($info_list as $k=>$v)
  7026. {
  7027. $features = explode('-',trim($v['features'],'-'));
  7028. if(!isset($features[3]) || !isset($features[4]))
  7029. {
  7030. continue;
  7031. }
  7032. $data[$k][0] = $tc[$features[0]];//类型
  7033. $data[$k][1] = ($features[3] != 57)?$tc[$features[3]]:'';//颜色,自然色不显示
  7034. $data[$k][2] = $tc[$features[4]];//曲度
  7035. $data[$k][3] = '';
  7036. if(isset($data[$k][1]))
  7037. {
  7038. $data[$k][3] .= $data[$k][1];
  7039. }
  7040. if(isset($data[$k][2]))
  7041. {
  7042. $data[$k][3] .= $data[$k][2];
  7043. }
  7044. if(isset($features[5]))
  7045. {
  7046. $data[$k][3] .= $tc[$features[5]];
  7047. }
  7048. if(isset($features[2]))
  7049. {
  7050. $data[$k][3] .= $tc[$features[2]];
  7051. }
  7052. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7053. $data[$k][4] = $v['sku'];
  7054. $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())).'))');//月初库存
  7055. $data[$k][] = $this->whlabel->find_count('sku = "'.$v['sku'].'" and state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');//剩余库存
  7056. $zt = $this->whlabeltransport->find_all('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and cz = "0"');
  7057. $ztrq = '';$ztsl = '';
  7058. if(count($zt) > 0)
  7059. {
  7060. foreach ($zt as $vv)
  7061. {
  7062. $ztrq .= date('Y-m-d',$vv['stime']).'<br>';
  7063. $ztsl .= $vv['num'].'<br>';
  7064. }
  7065. }
  7066. $data[$k][] = trim($ztsl,'<br>');
  7067. $data[$k][] = trim($ztrq,'<br>');
  7068. $byck = 0;
  7069. foreach ($t as $vv)
  7070. {
  7071. $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));
  7072. $data[$k][] = ($sl > 0)?'<b>'.$sl.'</b>':'';
  7073. $byck += $sl;
  7074. }
  7075. $data[$k][] = ($byck > 0)?$byck:'';
  7076. }
  7077. $title = "详情 ".date("Y-m-d",time());
  7078. $titlename = "<table border=1>
  7079. <tr align='center'>
  7080. <td>类别</td>
  7081. <td>颜色</td>
  7082. <td>曲度</td>
  7083. <td>名称</td>
  7084. <td>SKU</td>
  7085. <td>月初库存</td>
  7086. <td>剩余库存</td>
  7087. <td>在途数量</td>
  7088. <td>预达日期</td>".
  7089. $rq
  7090. ."<td>本月出库</td></tr>
  7091. </table>";
  7092. $filename = $title.".xls";
  7093. $tail = "";
  7094. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  7095. }
  7096. }
  7097. public function _whlabelexcelzh()
  7098. {
  7099. if(isset($_GET['excel']))
  7100. {
  7101. $where = "sku != 'Preset'";
  7102. //数据排序
  7103. $order_str = "id desc";
  7104. if(empty($page))
  7105. {
  7106. $start = 0;
  7107. $perpage = 1;
  7108. }
  7109. else
  7110. {
  7111. $start = ($page - 1)*$perpage;
  7112. }
  7113. $category = $this->input->get('category',true);
  7114. $warehouse = $this->input->get('warehouse',true);
  7115. $excelid = $this->input->get('sid',true);
  7116. if($category)
  7117. {
  7118. $where .= " and features like '%-$category-%'";
  7119. }
  7120. if($warehouse)
  7121. {
  7122. $where .= " and warehouse = '$warehouse'";
  7123. }
  7124. $xzid = '';
  7125. if($excelid)
  7126. {
  7127. $excelid = explode(',',trim($excelid,','));
  7128. foreach ($excelid as $key=>$value)
  7129. {
  7130. $xzid .= " id = ".$value." or";
  7131. }
  7132. $xzid = " and (".rtrim($xzid,'or').")";;
  7133. }
  7134. //取得信息列表
  7135. /**
  7136. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7137. $rows = array();$list = array();
  7138. foreach ($info_list as $key=>$value)
  7139. {
  7140. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7141. }
  7142. **/
  7143. $list = array();
  7144. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,number,features');
  7145. foreach ($rows as $key=>$value)
  7146. {
  7147. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"');
  7148. $zh = '';
  7149. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and time = "0" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','num,stime');
  7150. foreach ($zt as $v)
  7151. {
  7152. $zh .= $v['num']." / ".date('Y-m-d',$v['stime'])."<br>";
  7153. }
  7154. $zt = array_sum(array_column($zt,'num'));
  7155. $number = $value['number'];
  7156. $ftime = time()-15*24*3600;
  7157. $warehouse = $this->warehouse->read($value['warehouse']);
  7158. $rows[$key]['warehouse'] = $warehouse['title'];
  7159. $rows[$key]['number'] = $c;
  7160. $rows[$key]['features'] = $zh;
  7161. $rows[$key]['hb'] = $c+$zt;
  7162. }
  7163. $title = "导出库存数据及在途中数据".date('Y-m-d',time());
  7164. $titlename = "<table border=1>
  7165. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7166. <tr align='center'>
  7167. <td>仓库</td>
  7168. <td>SKU</td>
  7169. <td>产品</td>
  7170. <td>库存数量</td>
  7171. <td>在途数量及预达日期</td>
  7172. <td>在途+库存数量</td>
  7173. </tr>
  7174. </table>";
  7175. $filename = $title.".xls";
  7176. $tail = "";
  7177. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7178. }
  7179. if(isset($_GET['excel']))
  7180. {
  7181. $warehouse = $this->input->get('warehouse',true);
  7182. $sku = $this->input->get('sku',true);
  7183. $cz = $this->input->get('cz',true);
  7184. $text = $this->input->post('text',true);
  7185. $xztime = $this->input->get('xztime',true);
  7186. $timetk = $this->input->get('timetk',true);
  7187. $timetj = $this->input->get('timetj',true);
  7188. $timetk = strtotime($timetk);
  7189. $timetj = strtotime($timetj);
  7190. $where = "time = '0' ";
  7191. if($warehouse)
  7192. {
  7193. $where .= " and warehouse = '$warehouse'";
  7194. }
  7195. if($sku)
  7196. {
  7197. $where .= " and sku = '$sku'";
  7198. }
  7199. if($text)
  7200. {
  7201. $where .= " and text like '%$text%'";
  7202. }
  7203. if($cz != '')
  7204. {
  7205. $where .= " and cz = '$cz'";
  7206. }
  7207. if($timetk && $timetj)
  7208. {
  7209. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  7210. }
  7211. //数据排序
  7212. $order_str = $xztime." desc";
  7213. //取得信息列表
  7214. $zh = array();
  7215. $info_list = $this->whlabeltransport->find_all($where,'warehouse,sku,title,num,features,enter,stime,text');
  7216. foreach ($info_list as $v)
  7217. {
  7218. $c = $this->whlabel->find_count('state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');
  7219. $warehouse = $this->warehouse->read($v['warehouse']);
  7220. $v['warehouse'] = $warehouse['title'];
  7221. $v['enter'] = date('Y-m-d H:i:s',$v['enter']);
  7222. $v['stime'] = date('Y-m-d',$v['stime']);
  7223. if(isset($zh[$v['features']]))
  7224. {
  7225. $zh[$v['features']]['num'] += $v['num'];
  7226. }
  7227. else
  7228. {
  7229. $zh[$v['features']] = $v;
  7230. }
  7231. $zh[$v['features']]['features'] = $c;
  7232. }
  7233. $title = "在途数据".date('Y-m-d',time());
  7234. $titlename = "<table border=1>
  7235. <tr align='center'>
  7236. <td>仓库</td>
  7237. <td>SKU</td>
  7238. <td>名称</td>
  7239. <td>在途数量</td>
  7240. <td>库存数量</td>
  7241. <td>添加在途日期</td>
  7242. <td>预达日期</td>
  7243. <td>备注</td>
  7244. </tr>
  7245. </table>";
  7246. $filename = $title.".xls";
  7247. $tail = "";
  7248. $this->excel->get_fz2($zh,$titlename,$filename,$tail);
  7249. }
  7250. }
  7251. public function _fc()
  7252. {
  7253. $vip = 0;
  7254. if(isset($_SESSION['api']))
  7255. {
  7256. $user = $this->user->get_api($_SESSION['api']);
  7257. if($user['vip'] == 1)
  7258. {
  7259. $vip = 1;
  7260. }
  7261. }
  7262. else
  7263. {
  7264. header('Location: /');exit;
  7265. }
  7266. $post = $this->input->post(NULL, TRUE);
  7267. if(isset($post['page']))
  7268. {
  7269. $page = $this->input->post('page',true);
  7270. $perpage = $this->input->post('perpage',true);
  7271. $category = $this->input->post('category',true);
  7272. $size = $this->input->post('size',true);
  7273. $grade = $this->input->post('grade',true);
  7274. $color = $this->input->post('color',true);
  7275. $lowe = $this->input->post('lowe',true);
  7276. $sku = $this->input->post('sku');
  7277. $title = $this->input->post('title');
  7278. $warehouse = $this->input->post('warehouse',true);
  7279. $usa = $this->input->post('usa',true);
  7280. $purchase = $this->input->post('purchase',true);
  7281. $lacetype = $this->input->post('lacetype',true);
  7282. $haircap = $this->input->post('haircap',true);
  7283. $density = $this->input->post('density',true);
  7284. $details = $this->input->post('details',true);
  7285. $state = $this->input->post('state',true);
  7286. $ktime = $this->input->post('ktime',true);
  7287. $jtime = $this->input->post('jtime',true);
  7288. $ktime = strtotime($ktime);
  7289. $jtime = strtotime($jtime);
  7290. $where = "state = '11'";$gj = "";$ck = "";
  7291. if($lacetype)
  7292. {
  7293. $where .= " and features like '%-$lacetype-%'";
  7294. }
  7295. if($category)
  7296. {
  7297. $where .= " and features like '%-$category-%'";
  7298. }
  7299. if($size)
  7300. {
  7301. $where .= " and features like '%-$size-%'";
  7302. }
  7303. if($grade)
  7304. {
  7305. $where .= " and features like '%-$grade-%'";
  7306. }
  7307. if($color)
  7308. {
  7309. $where .= " and features like '%-$color-%'";
  7310. }
  7311. if($lowe)
  7312. {
  7313. $where .= " and features like '%-$lowe-%'";
  7314. }
  7315. if($haircap)
  7316. {
  7317. $where .= " and features like '%-$haircap-%'";
  7318. }
  7319. if($density)
  7320. {
  7321. $where .= " and features like '%-$density-%'";
  7322. }
  7323. if($usa)
  7324. {
  7325. if(!$warehouse)
  7326. {
  7327. $where .= " and (warehouse = '5' or warehouse = '8')";
  7328. }
  7329. }
  7330. if($warehouse)
  7331. {
  7332. $where .= " and warehouse = '$warehouse'";
  7333. }
  7334. if($details)
  7335. {
  7336. $where .= " and details = '$details'";
  7337. }
  7338. if($purchase)
  7339. {
  7340. $where .= " and purchase = '$purchase'";
  7341. }
  7342. if($state)
  7343. {
  7344. $where .= " and state = '$state'";
  7345. }
  7346. if($ktime && $jtime)
  7347. {
  7348. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7349. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7350. }
  7351. //数据排序
  7352. $order_str = "id desc";
  7353. if(empty($page))
  7354. {
  7355. $start = 0;
  7356. $perpage = 1;
  7357. }
  7358. else
  7359. {
  7360. $start = ($page - 1)*$perpage;
  7361. }
  7362. if($sku)
  7363. {
  7364. $sku = trim($sku,' ');
  7365. $sku = trim($sku,' ');
  7366. $where .= " and sku like '%$sku%'";
  7367. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7368. }
  7369. else if($title)
  7370. {
  7371. $title = trim($title,' ');
  7372. $title = trim($title,' ');
  7373. $where .= " and title like '%$title%'";
  7374. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7375. }
  7376. else
  7377. {
  7378. //$where .= " and time > '$ktime' and time < '$jtime'";
  7379. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7380. }
  7381. //取得信息列表
  7382. $rows = array();$list = array();
  7383. foreach ($info_list as $key=>$value)
  7384. {
  7385. $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'].'"');
  7386. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7387. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7388. $warehouse = $this->warehouse->read($value['warehouse']);
  7389. $info_list[$key]['warehouse'] = $warehouse['title'];
  7390. $info_list[$key]['number'] = $g;
  7391. $info_list[$key]['features'] = $x;
  7392. $info_list[$key]['x'] = $s;
  7393. }
  7394. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  7395. $pagenum = ceil($total/$perpage);
  7396. $over = $total-($start+$perpage);
  7397. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  7398. echo json_encode($rows);exit;
  7399. }
  7400. $this->data['vip'] = $vip;
  7401. $this->_Template('whlabel_fc',$this->data);
  7402. }
  7403. public function _fcmb()
  7404. {
  7405. $where = "sku != 'Preset'";
  7406. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title');
  7407. foreach ($rows as $k=>$v)
  7408. {
  7409. $warehouse = $this->warehouse->read($v['warehouse']);
  7410. $rows[$k]['warehouse'] = $warehouse['title'];
  7411. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "'.$v['warehouse'].'" and sku = "'.$v['sku'].'" and state = 11');
  7412. $rows[$k]['t'] = '';
  7413. $rows[$k]['n'] = '';
  7414. }
  7415. $title = "封货产品数据导入模板";
  7416. $titlename = "<table border=1>
  7417. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7418. <tr align='center'>
  7419. <td>仓库</td>
  7420. <td>SKU</td>
  7421. <td>产品</td>
  7422. <td>封存产品总数量</td>
  7423. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7424. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7425. </tr>
  7426. </table>";
  7427. $filename = $title.".xls";
  7428. $tail = "";
  7429. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7430. }
  7431. public function _fcexcel()
  7432. {
  7433. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7434. $config['upload_path'] = '.'.$dir ;
  7435. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7436. $config['allowed_types'] = 'xls|xlsx|csv';
  7437. $config['max_size'] = 10240;
  7438. $this->load->library('upload', $config);
  7439. $this->upload->initialize($config);
  7440. if ($this->upload->do_upload('userfile'))
  7441. {
  7442. $full_path = $dir.$this->upload->data('file_name');
  7443. $fileName = '.' . $full_path;
  7444. if (!file_exists($fileName))
  7445. {
  7446. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7447. }
  7448. else
  7449. {
  7450. libxml_use_internal_errors(true);
  7451. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7452. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7453. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7454. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7455. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7456. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7457. ++$column;//如果列数大于26行
  7458. $list = array();
  7459. for ($i = 2; $i <= $row; $i++) // 行数循环
  7460. {
  7461. $data = array();
  7462. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7463. {
  7464. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7465. }
  7466. $list[] = $data;
  7467. }
  7468. }
  7469. $i = 0;$j = 0;$ed = array();
  7470. foreach ($list as $key=>$value)
  7471. {
  7472. $time = time();
  7473. if($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4']))
  7474. {
  7475. continue;
  7476. }
  7477. $warehouse = $this->warehouse->get_title($value['0']);
  7478. $sku = $value['1'];
  7479. $type = $value['4'];//调整方式0扣减1删除
  7480. $num = $value['5'];//调整数量
  7481. //$text = $value['4'];//扣减说明
  7482. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7483. if(!$d)//如果没有这个SKU
  7484. {
  7485. $ed[] = array($sku.'-库存中不存在此SKU');
  7486. $j++;
  7487. continue;
  7488. }
  7489. if(!isset($warehouse['id']))
  7490. {
  7491. $ed[] = array($sku.'-仓库名错误!');
  7492. $j++;
  7493. continue;
  7494. }
  7495. if($type == 1 || $type == 2)//扣减库存
  7496. {
  7497. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and state = 11');
  7498. if(count($data) < abs($num))
  7499. {
  7500. $ed[] = array($sku.'-数量大于封存产品剩余数量!');
  7501. $j++;
  7502. continue;
  7503. }
  7504. if($type == 1)//转入库存
  7505. {
  7506. for($i=0;$i<abs($num);$i++)
  7507. {
  7508. $this->whlabel->save(array('state'=>0,'oldstate'=>11,'time'=>$time),$data[$i]['id']);
  7509. }
  7510. }
  7511. else if($type == 2)//删除
  7512. {
  7513. for($i=0;$i<abs($num);$i++)
  7514. {
  7515. $this->whlabel->remove($data[$i]['id']);
  7516. }
  7517. }
  7518. }
  7519. else if($type == 0)//增加库存
  7520. {
  7521. $post['sku'] = $d['sku'];
  7522. $post['shop'] = '';
  7523. $post['warehouse'] = $warehouse['id'];
  7524. $post['purchase'] = $d['purchase'];
  7525. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7526. $post['state'] = 11;
  7527. $post['title'] = $d['title'];
  7528. $post['number'] = $d['number'];
  7529. $post['features'] = $d['features'];
  7530. $post['enter'] = $time;
  7531. $post['time'] = $time;//操作时间
  7532. for($i=0;$i<$num;$i++)
  7533. {
  7534. $post['label'] = time().rand(100,999).$i;
  7535. $this->whlabel->insert($post);
  7536. }
  7537. }
  7538. sleep(1);//防止入库时间一样,需要延迟1秒
  7539. }
  7540. if($j > 0)
  7541. {
  7542. $tt = date('Ymd',time());
  7543. $title = '库存导入错误信息-'.$tt;
  7544. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7545. $tail = "\n";
  7546. $filename = $title.".xls";
  7547. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7548. $dir = '/data/excel/'.$time.'/';
  7549. $file_name = 'error_'.$time.rand(1000,9999);
  7550. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7551. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7552. fwrite($myfile,$ecl);
  7553. fclose($myfile);
  7554. $error = $dir.$file_name.'.xls';
  7555. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7556. }
  7557. else
  7558. {
  7559. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7560. }
  7561. }
  7562. }
  7563. public function _fcjxc($arg_array)
  7564. {
  7565. if(isset($_GET['excel']))
  7566. {
  7567. $category = $this->input->get('category',true);
  7568. $size = $this->input->get('size',true);
  7569. $grade = $this->input->get('grade',true);
  7570. $color = $this->input->get('color',true);
  7571. $lowe = $this->input->get('lowe',true);
  7572. $sku = $this->input->get('sku');
  7573. $title = $this->input->get('title');
  7574. $warehouse = $arg_array[0];
  7575. $usa = $this->input->get('usa',true);
  7576. $purchase = $this->input->get('purchase',true);
  7577. $lacetype = $this->input->get('lacetype',true);
  7578. $haircap = $this->input->get('haircap',true);
  7579. $density = $this->input->get('density',true);
  7580. $title = $this->input->get('title',true);
  7581. $state = $this->input->get('state',true);
  7582. $ktime = $this->input->get('ktime',true);
  7583. $jtime = $this->input->get('jtime',true);
  7584. $where = "state=11";$gj = "";$ck = "";
  7585. if($lacetype)
  7586. {
  7587. $where .= " and features like '%-$lacetype-%'";
  7588. }
  7589. if($category)
  7590. {
  7591. $where .= " and features like '%-$category-%'";
  7592. }
  7593. if($size)
  7594. {
  7595. $where .= " and features like '%-$size-%'";
  7596. }
  7597. if($grade)
  7598. {
  7599. $where .= " and features like '%-$grade-%'";
  7600. }
  7601. if($color)
  7602. {
  7603. $where .= " and features like '%-$color-%'";
  7604. }
  7605. if($lowe)
  7606. {
  7607. $where .= " and features like '%-$lowe-%'";
  7608. }
  7609. if($haircap)
  7610. {
  7611. $where .= " and features like '%-$haircap-%'";
  7612. }
  7613. if($density)
  7614. {
  7615. $where .= " and features like '%-$density-%'";
  7616. }
  7617. if($usa)
  7618. {
  7619. if(!$warehouse)
  7620. {
  7621. $where .= " and (warehouse = '5' or warehouse = '8')";
  7622. }
  7623. }
  7624. if($warehouse)
  7625. {
  7626. $where .= " and warehouse = '$warehouse'";
  7627. }
  7628. if($purchase)
  7629. {
  7630. $where .= " and purchase = '$purchase'";
  7631. }
  7632. if($state)
  7633. {
  7634. $where .= " and state = '$state'";
  7635. }
  7636. $order_str = "id desc";
  7637. if($sku)
  7638. {
  7639. $sku = trim($sku,' ');
  7640. $sku = trim($sku,' ');
  7641. $where .= " and sku like '%$sku%'";
  7642. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7643. }
  7644. else if($title)
  7645. {
  7646. $title = trim($title,' ');
  7647. $title = trim($title,' ');
  7648. $where .= " and title like '%$title%'";
  7649. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7650. }
  7651. else
  7652. {
  7653. //$where .= " and time > '$ktime' and time < '$jtime'";
  7654. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7655. }
  7656. //取得信息列表
  7657. $rows = array();$list = array();
  7658. foreach ($info_list as $key=>$value)
  7659. {
  7660. $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'].'"');
  7661. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7662. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7663. $rows[$key] = $value;
  7664. $warehouse = $this->warehouse->read($value['warehouse']);
  7665. $rows[$key]['warehouse'] = $warehouse['title'];
  7666. $rows[$key]['features'] = $g;
  7667. $rows[$key]['a'] = $x;
  7668. $rows[$key]['b'] = $s;
  7669. }
  7670. $title = "总统计表";
  7671. $titlename = "<table border=1>
  7672. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7673. <tr align='center'>
  7674. <td>仓库</td>
  7675. <td>SKU</td>
  7676. <td>产品名称</td>
  7677. <td>录入总量</td>
  7678. <td>取出总量</td>
  7679. <td>剩余总量</td>
  7680. </tr>
  7681. </table>";
  7682. $filename = $title.".xls";
  7683. $tail = "";
  7684. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7685. }
  7686. $vip = 0;
  7687. if(isset($_SESSION['api']))
  7688. {
  7689. $user = $this->user->get_api($_SESSION['api']);
  7690. if($user['vip'] == 1)
  7691. {
  7692. $vip = 1;
  7693. }
  7694. }
  7695. else
  7696. {
  7697. header('Location: /');exit;
  7698. }
  7699. $post = $this->input->post(NULL, TRUE);
  7700. if(isset($post['page']))
  7701. {
  7702. $page = $this->input->post('page',true);
  7703. $perpage = $this->input->post('perpage',true);
  7704. $category = $this->input->post('category',true);
  7705. $size = $this->input->post('size',true);
  7706. $grade = $this->input->post('grade',true);
  7707. $color = $this->input->post('color',true);
  7708. $lowe = $this->input->post('lowe',true);
  7709. $sku = $this->input->post('sku');
  7710. $title = $this->input->post('title');
  7711. $warehouse = $arg_array[0];
  7712. $usa = $this->input->post('usa',true);
  7713. $purchase = $this->input->post('purchase',true);
  7714. $lacetype = $this->input->post('lacetype',true);
  7715. $haircap = $this->input->post('haircap',true);
  7716. $density = $this->input->post('density',true);
  7717. $title = $this->input->post('title',true);
  7718. $state = $this->input->post('state',true);
  7719. $ktime = $this->input->post('ktime',true);
  7720. $jtime = $this->input->post('jtime',true);
  7721. $ktime = strtotime($ktime);
  7722. $jtime = strtotime($jtime);
  7723. $where = "state=11";$gj = "";$ck = "";
  7724. if($lacetype)
  7725. {
  7726. $where .= " and features like '%-$lacetype-%'";
  7727. }
  7728. if($category)
  7729. {
  7730. $where .= " and features like '%-$category-%'";
  7731. }
  7732. if($size)
  7733. {
  7734. $where .= " and features like '%-$size-%'";
  7735. }
  7736. if($grade)
  7737. {
  7738. $where .= " and features like '%-$grade-%'";
  7739. }
  7740. if($color)
  7741. {
  7742. $where .= " and features like '%-$color-%'";
  7743. }
  7744. if($lowe)
  7745. {
  7746. $where .= " and features like '%-$lowe-%'";
  7747. }
  7748. if($haircap)
  7749. {
  7750. $where .= " and features like '%-$haircap-%'";
  7751. }
  7752. if($density)
  7753. {
  7754. $where .= " and features like '%-$density-%'";
  7755. }
  7756. if($usa)
  7757. {
  7758. if(!$warehouse)
  7759. {
  7760. $where .= " and (warehouse = '5' or warehouse = '8')";
  7761. }
  7762. }
  7763. if($warehouse)
  7764. {
  7765. $where .= " and warehouse = '$warehouse'";
  7766. }
  7767. if($purchase)
  7768. {
  7769. $where .= " and purchase = '$purchase'";
  7770. }
  7771. if($state)
  7772. {
  7773. $where .= " and state = '$state'";
  7774. }
  7775. if($ktime && $jtime)
  7776. {
  7777. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7778. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7779. }
  7780. //数据排序
  7781. $order_str = "id desc";$xs=0;
  7782. $rows = array();$list = array();
  7783. if(empty($page))
  7784. {
  7785. $start = 0;
  7786. $perpage = 1;
  7787. }
  7788. else
  7789. {
  7790. $start = ($page - 1)*$perpage;
  7791. }
  7792. if($sku || $title)
  7793. {
  7794. if($title)
  7795. {
  7796. $title = trim($title,' ');
  7797. $title = trim($title,' ');
  7798. $where .= " and title like '%$title%'";
  7799. }
  7800. else
  7801. {
  7802. $sku = trim($sku,' ');
  7803. $sku = trim($sku,' ');
  7804. $where .= " and sku like '%$sku%'";
  7805. }
  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. $rows[$key] = $value;
  7813. $warehouse = $this->warehouse->read($value['warehouse']);
  7814. $rows[$key]['warehouse'] = $warehouse['title'];
  7815. $rows[$key]['features'] = $g;
  7816. $rows[$key]['a'] = $x;
  7817. $rows[$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. $rows[$key]['y'] = round($yj).'天销量';
  7824. }
  7825. else
  7826. {
  7827. $rows[$key]['y'] = '正常';
  7828. }
  7829. }
  7830. }
  7831. else
  7832. {
  7833. //$where .= " and time > '$ktime' and time < '$jtime'";
  7834. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7835. foreach ($info_list as $key=>$value)
  7836. {
  7837. $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'].'"');
  7838. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7839. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7840. $zs[$key] = $value;
  7841. $warehouse = $this->warehouse->read($value['warehouse']);
  7842. $zs[$key]['warehouse'] = $warehouse['title'];
  7843. $zs[$key]['features'] = $g;
  7844. $zs[$key]['a'] = $x;
  7845. $zs[$key]['b'] = $s;
  7846. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7847. $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天销量
  7848. $yj = $c/($xl/30);
  7849. if($yj < 7)
  7850. {
  7851. $zs[$key]['y'] = round($yj).'天销量';
  7852. $rows[$key] = $zs[$key];
  7853. }
  7854. }
  7855. }
  7856. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id'));
  7857. $pagenum = ceil($total/$perpage);
  7858. $over = $total-($start+$perpage);
  7859. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
  7860. echo json_encode($rows);exit;
  7861. }
  7862. $this->data['arg_array'] = $arg_array[0];
  7863. $this->_Template('whlabel_fcjxc',$this->data);
  7864. }
  7865. public function _0kcdel()
  7866. {
  7867. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7868. $config['upload_path'] = '.'.$dir ;
  7869. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7870. $config['allowed_types'] = 'xls|xlsx|csv';
  7871. $config['max_size'] = 10240;
  7872. $this->load->library('upload', $config);
  7873. $this->upload->initialize($config);
  7874. if ($this->upload->do_upload('userfile'))
  7875. {
  7876. $full_path = $dir.$this->upload->data('file_name');
  7877. $fileName = '.' . $full_path;
  7878. if (!file_exists($fileName))
  7879. {
  7880. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7881. }
  7882. else
  7883. {
  7884. require_once "./data/excel/PHPExcel/IOFactory.php";
  7885. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7886. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7887. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7888. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7889. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7890. ++$column;//如果列数大于26行
  7891. $list = array();
  7892. for ($i = 2; $i <= $row; $i++) // 行数循环
  7893. {
  7894. $data = array();
  7895. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7896. {
  7897. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7898. }
  7899. $list[] = $data;
  7900. }
  7901. }
  7902. $i = 0;$j = 0;$ed = array();
  7903. foreach ($list as $key=>$value)
  7904. {
  7905. $time = time();
  7906. if($value['0'] == "" || $value['1'] == "")
  7907. {
  7908. continue;
  7909. }
  7910. $warehouse = $this->warehouse->get_title($value['0']);
  7911. $sku = $value['1'];
  7912. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7913. if(!$d)//如果没有这个SKU
  7914. {
  7915. $ed[] = array($sku.'-库存中不存在此SKU');
  7916. $j++;
  7917. continue;
  7918. }
  7919. if(!isset($warehouse['id']))
  7920. {
  7921. $ed[] = array($sku.'-仓库名错误!');
  7922. $j++;
  7923. continue;
  7924. }
  7925. $z = $this->whlabel->find_count('sku = "'.$sku.'" and zd = "" and state = 0 and warehouse = "'.$warehouse['id'].'"');
  7926. if($z < 1)
  7927. {
  7928. $z = $this->whlabel->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'"');
  7929. foreach ($z as $v)
  7930. {
  7931. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  7932. if(count($zt) > 0)
  7933. {
  7934. $ed[] = array($sku.'-有在途库存无法删除!');
  7935. $j++;
  7936. continue;
  7937. }
  7938. $this->whlabel->remove($v['id']);
  7939. }
  7940. }
  7941. else
  7942. {
  7943. $ed[] = array($sku.'-非0库存!');
  7944. $j++;
  7945. continue;
  7946. }
  7947. }
  7948. if($j > 0)
  7949. {
  7950. $tt = date('Ymd',time());
  7951. $title = '删除0库存错误信息-'.$tt;
  7952. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7953. $tail = "\n";
  7954. $filename = $title.".xls";
  7955. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7956. $dir = '/data/excel/'.$time.'/';
  7957. $file_name = 'error_'.$time.rand(1000,9999);
  7958. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7959. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7960. fwrite($myfile,$ecl);
  7961. fclose($myfile);
  7962. $error = $dir.$file_name.'.xls';
  7963. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7964. }
  7965. else
  7966. {
  7967. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7968. }
  7969. }
  7970. }
  7971. public function _gbhtype()
  7972. {
  7973. $post = $this->input->post(NULL, TRUE);
  7974. if(isset($post['s']))
  7975. {
  7976. $n = $this->input->post('n');
  7977. $d = $this->input->post('s');
  7978. if(!$d)
  7979. {
  7980. echo json_encode(array('msg'=>'未选择需要更改的商品','success'=>false));exit;
  7981. }
  7982. $d = explode(',',trim($d,','));
  7983. $t = $this->whlabel_type->read($n);
  7984. //循环删除记录
  7985. foreach ($d as $v)
  7986. {
  7987. $u = $this->whlabel->read($v);
  7988. $data = $this->whlabel->find_all("sku = '".$u['sku']."' and purchase = '".$u['purchase']."' and features = '".$u['features']."' and warehouse = '".$u['warehouse']."'");
  7989. foreach ($data as $val)
  7990. {
  7991. $this->whlabel->save(array('type'=>$n),$val['id']);
  7992. }
  7993. }
  7994. echo json_encode(array('d'=>$d,'t'=>$t['title'],'msg'=>'修改成功!','success'=>true));
  7995. }
  7996. }
  7997. //出库、退库导出
  7998. public function _dccrtype()
  7999. {
  8000. $classid = $this->classid->sku();
  8001. $pm = $classid;
  8002. $typeclass = array();
  8003. $tc = $this->typeclass->find_all();
  8004. foreach ($tc as $v)
  8005. {
  8006. $typeclass[$v['id']] = $v;
  8007. }
  8008. $prc = array();
  8009. $purchase = $this->purchase->find_all();
  8010. foreach($purchase as $k=>$v)
  8011. {
  8012. $prc[$v['id']] = $v['title'];
  8013. }
  8014. if(isset($_GET['sid']))
  8015. {
  8016. $wh = array();
  8017. $w = $this->warehouse->find_all('1=1','id,title');
  8018. foreach ($w as $v)
  8019. {
  8020. $wh[$v['id']] = $v['title'];
  8021. }
  8022. $type = $this->input->get('excel',true);
  8023. $category = $this->input->get('category',true);
  8024. $size = $this->input->get('size',true);
  8025. $grade = $this->input->get('grade',true);
  8026. $color = $this->input->get('color',true);
  8027. $lowe = $this->input->get('lowe',true);
  8028. $sku = $this->input->get('sku',true);
  8029. $warehouse = $this->input->get('warehouse',true);
  8030. $lacetype = $this->input->get('lacetype',true);
  8031. $lacecolor = $this->input->get('lacecolor',true);
  8032. $density = $this->input->get('density',true);
  8033. $haircap = $this->input->get('haircap',true);
  8034. $purchase = $this->input->get('purchase',true);
  8035. $title = $this->input->get('title',true);
  8036. $state = $this->input->get('state',true);
  8037. $sid = $this->input->get('sid',true);
  8038. $ktime = $this->input->get('ktime',true);
  8039. $jtime = $this->input->get('jtime',true);
  8040. $ktime = strtotime($ktime);
  8041. $jtime = strtotime($jtime);
  8042. $where = "1=1";$gj = "";$ck = "";
  8043. if($category)
  8044. {
  8045. $where .= " and features like '%-$category-%'";
  8046. }
  8047. if($size)
  8048. {
  8049. $where .= " and features like '%-$size-%'";
  8050. }
  8051. if($grade)
  8052. {
  8053. $where .= " and features like '%-$grade-%'";
  8054. }
  8055. if($color)
  8056. {
  8057. $where .= " and features like '%-$color-%'";
  8058. }
  8059. if($lowe)
  8060. {
  8061. $where .= " and features like '%-$lowe-%'";
  8062. }
  8063. if($warehouse)
  8064. {
  8065. $where .= " and warehouse = '$warehouse'";
  8066. }
  8067. if($purchase)
  8068. {
  8069. $where .= " and purchase = '$purchase'";
  8070. }
  8071. if($state)
  8072. {
  8073. $where .= " and state = '$state'";
  8074. }
  8075. if($lacetype)
  8076. {
  8077. $where .= " and features like '%-$lacetype-%'";
  8078. }
  8079. if($lacecolor)
  8080. {
  8081. $where .= " and features like '%-$lacecolor-%'";
  8082. }
  8083. if($density)
  8084. {
  8085. $where .= " and features like '%-$density-%'";
  8086. }
  8087. if($haircap)
  8088. {
  8089. $where .= " and features like '%-$haircap-%'";
  8090. }
  8091. if($title)
  8092. {
  8093. $title = trim($title,' ');
  8094. $title = trim($title,' ');
  8095. $where .= " and title like '%$title%'";
  8096. }
  8097. if($sku)
  8098. {
  8099. $sku = trim($sku,' ');
  8100. $sku = trim($sku,' ');
  8101. $where .= " and sku like '%$sku%'";
  8102. }
  8103. if($ktime && $jtime)
  8104. {
  8105. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8106. }
  8107. $sidwhere = '';
  8108. if($sid)
  8109. {
  8110. $sd = "";
  8111. $s = explode(',',trim($sid,','));
  8112. foreach ($s as $value)
  8113. {
  8114. $sd .= " id = ".$value." or";
  8115. }
  8116. $sidwhere = " and (".rtrim($sd,'or').")";
  8117. }
  8118. //数据排序
  8119. $order_str = "time desc";
  8120. if(empty($page))
  8121. {
  8122. $start = 0;
  8123. $perpage = 1;
  8124. }
  8125. else
  8126. {
  8127. $start = ($page - 1)*$perpage;
  8128. }
  8129. $wh = array();
  8130. $w = $this->warehouse->find_all('1=1','id,title');
  8131. foreach ($w as $v)
  8132. {
  8133. $wh[$v['id']] = $v['title'];
  8134. }
  8135. $wt = array();
  8136. $whlabel_type = $this->whlabel_type->find_all();
  8137. foreach ($whlabel_type as $v)
  8138. {
  8139. $wt[$v['id']] = $v['title'];
  8140. }
  8141. $classid = $this->classid->sku();
  8142. $list = array();
  8143. $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');
  8144. foreach ($rows_r as $key=>$value)
  8145. {
  8146. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8147. $pm = $classid;
  8148. $jm = $classid;
  8149. $rows_r[$key]['enter'] = '入库';
  8150. $rows_r[$key]['time'] = $value['enter'];
  8151. if($value['rktype'] == 1)
  8152. {
  8153. $rows_r[$key]['rktype'] = '采购入库';
  8154. }
  8155. else if($value['rktype'] == 2)
  8156. {
  8157. $rows_r[$key]['rktype'] = '盘盈调整';
  8158. }
  8159. else if($value['rktype'] == 3)
  8160. {
  8161. $rows_r[$key]['rktype'] = '其他调整入库';
  8162. }
  8163. else if($value['rktype'] == 4)
  8164. {
  8165. $rows_r[$key]['rktype'] = '其他调整入库';
  8166. }
  8167. else if($value['rktype'] == 5)
  8168. {
  8169. $rows_r[$key]['rktype'] = '退库入库';
  8170. }
  8171. else if($value['rktype'] == 6)
  8172. {
  8173. $rows_r[$key]['rktype'] = '退货可用入库';
  8174. }
  8175. else if($value['rktype'] == 7)
  8176. {
  8177. $rows_r[$key]['rktype'] = '形态转换入库';
  8178. }
  8179. else
  8180. {
  8181. $rows_r[$key]['rktype'] = '';
  8182. }
  8183. $features = explode('-',trim($value['features'],'-'));
  8184. foreach($features as $v)
  8185. {
  8186. if(isset($typeclass[$v]))
  8187. {
  8188. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8189. $pm[$typeclass[$v]['classid']] = $zh[0];
  8190. }
  8191. if(isset($typeclass[$v]))
  8192. {
  8193. if(isset($jm[$typeclass[$v]['classid']]))
  8194. {
  8195. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8196. }
  8197. }
  8198. }
  8199. $zh = implode(" ",$pm);
  8200. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8201. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8202. $rows_r[$key]['zh'] = $zh;
  8203. $jm = array_filter($jm);
  8204. $rows_r[$key]['features'] = implode("-",$jm);
  8205. $rows_r[$key]['number'] = $this->whlabel->find_count($where." and enter = '".$value['enter']."' ".$sidwhere);
  8206. }
  8207. $rows_c = $this->whlabel->find_all($where." and outk > '$ktime' and outk < '$jtime' ".$sidwhere,'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  8208. foreach ($rows_c as $key=>$value)
  8209. {
  8210. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8211. $pm = $classid;
  8212. $jm = $classid;
  8213. $rows_c[$key]['time'] = $value['outk'];
  8214. $rows_c[$key]['outk'] = '出库';
  8215. if($value['cktype'] == 1)
  8216. {
  8217. $rows_c[$key]['cktype'] = '销售出库';
  8218. }
  8219. else if($value['cktype'] == 2)
  8220. {
  8221. $rows_c[$key]['cktype'] = '销售美国出库';
  8222. }
  8223. else if($value['cktype'] == 3)
  8224. {
  8225. $rows_c[$key]['cktype'] = '盘亏调整';
  8226. }
  8227. else if($value['cktype'] == 4)
  8228. {
  8229. $rows_c[$key]['cktype'] = '其他调整出库';
  8230. }
  8231. else if($value['cktype'] == 5)
  8232. {
  8233. $rows_c[$key]['cktype'] = '形态转换出库';
  8234. }
  8235. else
  8236. {
  8237. $rows_c[$key]['cktype'] = '';
  8238. }
  8239. $features = explode('-',trim($value['features'],'-'));
  8240. foreach($features as $v)
  8241. {
  8242. if(isset($typeclass[$v]))
  8243. {
  8244. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8245. $pm[$typeclass[$v]['classid']] = $zh[0];
  8246. }
  8247. if(isset($typeclass[$v]))
  8248. {
  8249. if(isset($jm[$typeclass[$v]['classid']]))
  8250. {
  8251. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8252. }
  8253. }
  8254. }
  8255. $zh = implode(" ",$pm);
  8256. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8257. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8258. $rows_c[$key]['zh'] = $zh;
  8259. $jm = array_filter($jm);
  8260. $rows_c[$key]['features'] = implode("-",$jm);
  8261. $rows_c[$key]['number'] = 1;
  8262. }
  8263. $merged = $rows_r;
  8264. foreach ($rows_c as $key => $value)
  8265. {
  8266. if (isset($merged[$key]))
  8267. {
  8268. $merged[] = $value;
  8269. }
  8270. else
  8271. {
  8272. $merged[$key] = $value;
  8273. }
  8274. }
  8275. usort($merged, function($a, $b)
  8276. {
  8277. return $a['time'] - $b['time'];
  8278. });
  8279. foreach ($merged as $key=>$value)
  8280. {
  8281. $merged[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  8282. }
  8283. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime);
  8284. $titlename = "<table border=1>
  8285. <tr align='center'>
  8286. <td>仓库</td>
  8287. <td>SKU</td>
  8288. <td>商品名称</td>
  8289. <td>仓库品名</td>
  8290. <td>料号</td>
  8291. <td>时间</td>
  8292. <td>操作</td>
  8293. <td>类型</td>
  8294. <td>数量</td>
  8295. <td>备注</td>
  8296. </tr>
  8297. </table>";
  8298. $filename = $title.".xlsx";
  8299. $tail = "";
  8300. $this->excel->get_fz2($merged,$titlename,$filename,$tail);
  8301. }
  8302. }
  8303. }