Whlabel.php 266 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438
  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. $where = "1=1";$gj = "";$ck = "";
  1412. if($usa)
  1413. {
  1414. if(!$warehouse)
  1415. {
  1416. $where .= " and (warehouse = '5' or warehouse = '8')";
  1417. }
  1418. }
  1419. if($warehouse)
  1420. {
  1421. $where .= " and warehouse = '$warehouse'";
  1422. }
  1423. if($details)
  1424. {
  1425. $where .= " and details = '$details'";
  1426. }
  1427. if($purchase)
  1428. {
  1429. $where .= " and purchase = '$purchase'";
  1430. }
  1431. if($state)
  1432. {
  1433. $where .= " and state = '$state'";
  1434. }
  1435. if($shop)
  1436. {
  1437. $where .= " and shop like '%$shop%'";
  1438. }
  1439. if($type)
  1440. {
  1441. $where .= " and type = '$type'";
  1442. }
  1443. if($ktime && $jtime)
  1444. {
  1445. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1446. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1447. }
  1448. if($lacecolor)
  1449. {
  1450. $where .= " and features like '%-$lacecolor-%'";
  1451. }
  1452. if($lacetype)
  1453. {
  1454. $where .= " and features like '%-$lacetype-%'";
  1455. }
  1456. if($category)
  1457. {
  1458. $where .= " and features like '%-$category-%'";
  1459. }
  1460. if($size)
  1461. {
  1462. $where .= " and features like '%-$size-%'";
  1463. }
  1464. if($grade)
  1465. {
  1466. $where .= " and features like '%-$grade-%'";
  1467. }
  1468. if($color)
  1469. {
  1470. $where .= " and features like '%-$color-%'";
  1471. }
  1472. if($lowe)
  1473. {
  1474. $where .= " and features like '%-$lowe-%'";
  1475. }
  1476. if($haircap)
  1477. {
  1478. $where .= " and features like '%-$haircap-%'";
  1479. }
  1480. if($density)
  1481. {
  1482. $where .= " and features like '%-$density-%'";
  1483. }
  1484. if(!empty($hairnumber)){
  1485. $where .= " and features like '%-128-%' ";
  1486. if($hairnumber < 0){
  1487. $class_list = $this->typeclass->find_all('classid = 43');
  1488. foreach($class_list as $v){
  1489. $where .= " and features not like '%-".$v['id']."-%'";
  1490. }
  1491. }else{
  1492. $where .= " and features like '%-$hairnumber-%'";
  1493. }
  1494. }
  1495. //数据排序
  1496. $order_str = "id desc";
  1497. if(empty($page))
  1498. {
  1499. $start = 0;
  1500. $perpage = 1;
  1501. }
  1502. else
  1503. {
  1504. $start = ($page - 1)*$perpage;
  1505. }
  1506. $fjnr = '';
  1507. if($sku)
  1508. {
  1509. $sku = trim($sku,' ');
  1510. $sku = trim($sku,' ');
  1511. $fjnr .= " and sku like '%$sku%'";
  1512. }
  1513. if($title)
  1514. {
  1515. $title = trim($title,' ');
  1516. $title = trim($title,' ');
  1517. $fjnr .= " and title like '%$title%'";
  1518. }
  1519. $wt = array();
  1520. $whlabel_type = $this->whlabel_type->find_all();
  1521. foreach ($whlabel_type as $v)
  1522. {
  1523. $wt[$v['id']] = $v['title'];
  1524. }
  1525. //$where .= " and time > '$ktime' and time < '$jtime'";
  1526. $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
  1527. //取得信息列表
  1528. $rows = array();$list = array();
  1529. foreach ($info_list as $key=>$value)
  1530. {
  1531. if(isset($wt[$value['type']]))
  1532. {
  1533. $info_list[$key]['type'] = $wt[$value['type']];
  1534. }
  1535. else
  1536. {
  1537. $info_list[$key]['type'] = '未设置';
  1538. }
  1539. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1540. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1541. $ztdata = '';
  1542. if(count($zt) > 0)
  1543. {
  1544. foreach ($zt as $vv)
  1545. {
  1546. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1547. }
  1548. }
  1549. $qbdata = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1550. $cdata = array_filter($qbdata, function($item) {
  1551. return $item['state'] < 1;
  1552. });
  1553. $c = array_sum(array_column($cdata, 'jnum'));
  1554. $gdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1555. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1556. });
  1557. $g = array_sum(array_column($gdata, 'jnum'));
  1558. $xdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1559. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1560. });
  1561. $x = array_sum(array_column($xdata, 'jnum'));
  1562. $tdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1563. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1564. });
  1565. $t = array_sum(array_column($tdata, 'jnum'));
  1566. $zdata = array_filter($qbdata, function($item) {
  1567. return $item['zd'] != "" && $item['state'] < 1;
  1568. });
  1569. $z = array_sum(array_column($zdata, '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. //$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');
  1575. //$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'].'"');
  1576. //$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'].'"');
  1577. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1578. //$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'].'"');
  1579. $details = array();
  1580. $cpid = array();
  1581. $od = array();$odid = '';
  1582. $companytitle = '';
  1583. foreach ($qbdata as $v)
  1584. {
  1585. if($v['zd'] != "" && $v['state'] < 1)
  1586. {
  1587. if(!isset($od[$v['zd']]))
  1588. {
  1589. $od[$v['zd']] = 1;//所有数据sku
  1590. }
  1591. else
  1592. {
  1593. $od[$v['zd']] = $od[$v['zd']]+1;
  1594. }
  1595. }
  1596. if($v['state'] < 1)
  1597. {
  1598. $details[$v['details']] = $v['details'];
  1599. if($v['cpid'] != 0)
  1600. {
  1601. $cpid[$v['cpid']] = $v['cpid'];
  1602. }
  1603. }
  1604. if($v['companytitle'] != '' && stripos($companytitle,$company[$v['companytitle']]) === false)
  1605. {
  1606. $companytitle .= '<p>'.$company[$v['companytitle']].'</p>';
  1607. }
  1608. }
  1609. foreach ($od as $k=>$vv)
  1610. {
  1611. $odid .= $k.'数量'.$vv;
  1612. }
  1613. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  1614. $number = $value['number'];$ftime = time()-15*24*3600;
  1615. $z = $z.'('.$odid.')';//查看订单号
  1616. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:'无';
  1617. $info_list[$key]['features'] = $c;
  1618. $info_list[$key]['number'] = $ztdata;
  1619. $info_list[$key]['sm'] = $g;
  1620. $info_list[$key]['x'] = $x;
  1621. $info_list[$key]['t'] = $t;
  1622. $info_list[$key]['z'] = $z;
  1623. /**
  1624. foreach ($cdata as $k=>$v)
  1625. {
  1626. $details[$v['details']] = $v['details'];
  1627. if($v['cpid'] != 0)
  1628. {
  1629. $cpid[$v['cpid']] = $v['cpid'];
  1630. }
  1631. }
  1632. **/
  1633. $info_list[$key]['shop'] = '';
  1634. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1635. if($value['shop'] != '')
  1636. {
  1637. $shop = explode(',',trim($value['shop'],','));
  1638. $info_list[$key]['shop'] = '<p>'.$sp[$shop[0]].'</p>';
  1639. }
  1640. $info_list[$key]['shop'] .= $companytitle;
  1641. /**
  1642. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1643. if(isset($companytitle[0]))
  1644. {
  1645. foreach ($companytitle as $k=>$v)
  1646. {
  1647. if($v['companytitle'] != '')
  1648. {
  1649. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1650. }
  1651. }
  1652. }
  1653. **/
  1654. }
  1655. $total = count($this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,sku,title,features,number'));
  1656. $pagenum = ceil($total/$perpage);
  1657. $over = $total-($start+$perpage);
  1658. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  1659. echo json_encode($rows);exit;
  1660. }
  1661. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1662. $this->data['shop'] = $wlshop;
  1663. $this->data['vip'] = $vip;
  1664. $this->_Template('whlabel_type',$this->data);
  1665. }
  1666. //美仓进销存浏览
  1667. public function _usatype()
  1668. {
  1669. if(isset($_SESSION['api']))
  1670. {
  1671. $user = $this->user->get_api($_SESSION['api']);
  1672. $usp = $user;
  1673. $fgshop = "";$sid = "";$wid="";$wtype="";
  1674. $userwh = explode('|',trim($user['warehouse'],'|'));
  1675. foreach ($userwh as $value)
  1676. {
  1677. $wid .= " id = ".$value." or";
  1678. $wtype .= " type = ".$value." or";
  1679. }
  1680. }
  1681. $prc = array();
  1682. $purchase = $this->purchase->find_all();
  1683. foreach($purchase as $k=>$v)
  1684. {
  1685. $prc[$v['id']] = $v['title'];
  1686. }
  1687. $post = $this->input->post(NULL, TRUE);
  1688. if(isset($post['page']))
  1689. {
  1690. $page = $this->input->post('page',true);
  1691. $perpage = $this->input->post('perpage',true);
  1692. $category = $this->input->post('category',true);
  1693. $size = $this->input->post('size',true);
  1694. $grade = $this->input->post('grade',true);
  1695. $color = $this->input->post('color',true);
  1696. $lowe = $this->input->post('lowe',true);
  1697. $sku = $this->input->post('sku');
  1698. $title = $this->input->post('title');
  1699. $warehouse = $this->input->post('warehouse',true);
  1700. $usa = $this->input->post('usa',true);
  1701. $purchase = $this->input->post('purchase',true);
  1702. $lacetype = $this->input->post('lacetype',true);
  1703. $haircap = $this->input->post('haircap',true);
  1704. $density = $this->input->post('density',true);
  1705. $details = $this->input->post('details',true);
  1706. $state = $this->input->post('state',true);
  1707. $lacecolor = $this->input->post('lacecolor',true);
  1708. $cklx = $this->input->post('cklx',true);
  1709. $ktime = $this->input->post('ktime',true);
  1710. $jtime = $this->input->post('jtime',true);
  1711. $ktime = strtotime($ktime);
  1712. $jtime = strtotime($jtime);
  1713. $where = "1=1";$gj = "";$ck = "";
  1714. if($lacetype)
  1715. {
  1716. $where .= " and features like '%-$lacetype-%'";
  1717. }
  1718. if($category)
  1719. {
  1720. $where .= " and features like '%-$category-%'";
  1721. }
  1722. if($size)
  1723. {
  1724. $where .= " and features like '%-$size-%'";
  1725. }
  1726. if($grade)
  1727. {
  1728. $where .= " and features like '%-$grade-%'";
  1729. }
  1730. if($color)
  1731. {
  1732. $where .= " and features like '%-$color-%'";
  1733. }
  1734. if($lowe)
  1735. {
  1736. $where .= " and features like '%-$lowe-%'";
  1737. }
  1738. if($haircap)
  1739. {
  1740. $where .= " and features like '%-$haircap-%'";
  1741. }
  1742. if($density)
  1743. {
  1744. $where .= " and features like '%-$density-%'";
  1745. }
  1746. if($lacecolor)
  1747. {
  1748. $where .= " and features like '%-$lacecolor-%'";
  1749. }
  1750. if($usa)
  1751. {
  1752. if(!$warehouse)
  1753. {
  1754. $where .= " and (warehouse = '5' or warehouse = '8')";
  1755. }
  1756. }
  1757. if($warehouse)
  1758. {
  1759. $where .= " and warehouse = '$warehouse'";
  1760. }
  1761. if($details)
  1762. {
  1763. $where .= " and details = '$details'";
  1764. }
  1765. if($purchase)
  1766. {
  1767. $where .= " and purchase = '$purchase'";
  1768. }
  1769. if($state)
  1770. {
  1771. $where .= " and state = '$state'";
  1772. }
  1773. $where_add = '';
  1774. if($cklx)
  1775. {
  1776. $shop = $this->shop->read($cklx);
  1777. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  1778. }
  1779. if($ktime && $jtime)
  1780. {
  1781. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1782. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1783. }
  1784. //数据排序
  1785. $order_str = "id desc";
  1786. if(empty($page))
  1787. {
  1788. $start = 0;
  1789. $perpage = 1;
  1790. }
  1791. else
  1792. {
  1793. $start = ($page - 1)*$perpage;
  1794. }
  1795. if($sku)
  1796. {
  1797. $sku = trim($sku,' ');
  1798. $sku = trim($sku,' ');
  1799. $where .= " and sku like '%$sku%'";
  1800. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1801. }
  1802. else if($title)
  1803. {
  1804. $title = trim($title,' ');
  1805. $title = trim($title,' ');
  1806. $where .= " and title like '%$title%'";
  1807. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1808. }
  1809. else
  1810. {
  1811. //$where .= " and time > '$ktime' and time < '$jtime'";
  1812. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1813. }
  1814. //取得信息列表
  1815. $rows = array();$list = array();
  1816. foreach ($info_list as $key=>$value)
  1817. {
  1818. $warehouse = $this->warehouse->read($value['warehouse']);
  1819. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1820. $g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1821. $x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1822. $t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1823. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1824. $od = array();$odid = '';
  1825. foreach ($z as $v)
  1826. {
  1827. if(!isset($od[$v['zd']]))
  1828. {
  1829. $od[$v['zd']] = 1;//所有数据sku
  1830. }
  1831. else
  1832. {
  1833. $od[$v['zd']] = $od[$v['zd']]+1;
  1834. }
  1835. }
  1836. foreach ($od as $k=>$vv)
  1837. {
  1838. $odid .= $k.'数量'.$vv.' ';
  1839. }
  1840. $z = count($z).'('.$odid.')';//查看订单号
  1841. $info_list[$key]['features'] = $c;
  1842. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1843. $ztdata = '';
  1844. if(count($zt) > 0)
  1845. {
  1846. foreach ($zt as $vv)
  1847. {
  1848. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1849. }
  1850. }
  1851. $info_list[$key]['warehouse'] = $ztdata;
  1852. $info_list[$key]['g'] = $g;
  1853. $info_list[$key]['x'] = $x;
  1854. $info_list[$key]['t'] = $t;
  1855. $info_list[$key]['z'] = $z;
  1856. }
  1857. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title'));
  1858. $pagenum = ceil($total/$perpage);
  1859. $over = $total-($start+$perpage);
  1860. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1861. echo json_encode($rows);exit;
  1862. }
  1863. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1864. $this->data['warehouse'] = $warehouse;
  1865. $this->_Template('whlabel_typeusa',$this->data);
  1866. }
  1867. //美仓进销存浏览
  1868. public function _usatypeapp()
  1869. {
  1870. $post = $this->input->post(NULL, TRUE);
  1871. if(isset($post['page']))
  1872. {
  1873. $page = $this->input->post('page',true);
  1874. $perpage = $this->input->post('perpage',true);
  1875. $sku = $this->input->post('sku',true);
  1876. $warehouse = 5;
  1877. $title = $this->input->post('title',true);
  1878. $state = $this->input->post('state',true);
  1879. $ktime = $this->input->post('ktime',true);
  1880. $jtime = $this->input->post('jtime',true);
  1881. $ktime = strtotime($ktime);
  1882. $jtime = strtotime($jtime);
  1883. $where = "1=1";$gj = "";$ck = "";
  1884. if($title)
  1885. {
  1886. $st = explode(' ',trim($title,' '));
  1887. foreach ($st as $v)
  1888. {
  1889. $where .= " and title like '%$v%'";
  1890. }
  1891. }
  1892. if($warehouse)
  1893. {
  1894. $where .= " and warehouse = '$warehouse'";
  1895. }
  1896. if($state)
  1897. {
  1898. $where .= " and state = '$state'";
  1899. }
  1900. if($sku)
  1901. {
  1902. $where .= " and sku like '%$sku%'";
  1903. }
  1904. if($ktime && $jtime)
  1905. {
  1906. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1907. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1908. }
  1909. //数据排序
  1910. $order_str = "id desc";
  1911. if(empty($page))
  1912. {
  1913. $start = 0;
  1914. $perpage = 1;
  1915. }
  1916. else
  1917. {
  1918. $start = ($page - 1)*$perpage;
  1919. }
  1920. //取得信息列表
  1921. $info_list = $this->whlabel->find_all($where.' and '.rtrim($wid,'or'),'*');
  1922. $rows = array();$list = array();
  1923. foreach ($info_list as $key=>$value)
  1924. {
  1925. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1926. }
  1927. $rowsdq = array_slice($rows,$start,$perpage);
  1928. foreach ($rowsdq as $value)
  1929. {
  1930. $warehouse = $this->warehouse->read($value['warehouse']);
  1931. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'"');
  1932. $x = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'"');
  1933. $t = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1934. $od = array();$odid = '';
  1935. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'x'=>$x,'t'=>$t);
  1936. }
  1937. $total = count($rows);
  1938. $pagenum = ceil($total/$perpage);
  1939. $over = $total-($start+$perpage);
  1940. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1941. echo json_encode($rows);exit;
  1942. }
  1943. $this->_Template('phone/p_usatypeapp',$this->data);
  1944. }
  1945. //入库操作
  1946. public function _enteradd()
  1947. {
  1948. $dt = 0;
  1949. if(isset($_SESSION['api']))
  1950. {
  1951. $user = $this->user->get_api($_SESSION['api']);
  1952. $usp = $user;
  1953. $fgshop = "";$sid = "";
  1954. $user = explode('|',trim($user['shop'],'|'));
  1955. foreach ($user as $value)
  1956. {
  1957. $fgshop .= " shop = ".$value." or";
  1958. $sid .= " id = ".$value." or";
  1959. }
  1960. }
  1961. $tc = $this->typeclass->find_all();
  1962. $typeclass = array();
  1963. foreach ($tc as $v)
  1964. {
  1965. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1966. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'bqsku'=>$v['bqsku']);
  1967. }
  1968. $post = $this->input->post(NULL, TRUE);
  1969. if(isset($post['sku']))
  1970. {
  1971. $list = array();$num = "";$title = "";$features = "";
  1972. $order = $this->input->post('order',true);
  1973. $shop = $this->input->post('shop',true);
  1974. $post['shop'] = ($shop!="")?','.$shop:"";
  1975. $sku = $this->input->post('sku',true);
  1976. $post['sm'] = $this->input->post('sm',true);
  1977. $post['warehouse'] = $this->input->post('warehouse',true);
  1978. $post['purchase'] = $this->input->post('purchase',true);
  1979. $post['retreatwarehouse'] = $post['warehouse'];
  1980. $post['state'] = $this->input->post('state',true);
  1981. $post['rktype'] = $this->input->post('rktype',true);
  1982. $post['text'] = $this->input->post('text',true);
  1983. $category = $this->input->post('category',true);
  1984. $list['category'] = $category;
  1985. $list['hairtype'] = $this->input->post('hairtype',true);
  1986. $list['grade'] = $this->input->post('grade',true);
  1987. $size = $this->input->post('size',true);
  1988. $xzsku = $this->input->post('xzsku',true);
  1989. $list['size'] = rtrim($size,',');
  1990. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1991. $list['extension'] = $this->input->post('extension',true);
  1992. if($category == 1297)
  1993. {
  1994. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1995. }
  1996. if($category == 1702)
  1997. {
  1998. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1999. $list['syother'] = $this->input->post('syother',true);
  2000. }
  2001. if($category == 133)
  2002. {
  2003. $list['fittype'] = $this->input->post('fittype',true);
  2004. $list['acother'] = $this->input->post('acother',true);
  2005. }
  2006. $list['color'] = $this->input->post('color',true);
  2007. $list['lowe'] = $this->input->post('lowe',true);
  2008. if(!$post['purchase'])
  2009. {
  2010. $post['purchase'] = 1;
  2011. }
  2012. if($category == 127)
  2013. {
  2014. $list['type'] = $this->input->post('type',true);
  2015. $list['headroad'] = $this->input->post('headroad',true);
  2016. $list['density'] = $this->input->post('density',true);
  2017. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  2018. {
  2019. $list['lacesize'] = $this->input->post('lacesize',true);
  2020. }
  2021. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2022. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2023. }
  2024. if($category == 128)
  2025. {
  2026. $list['lacetype'] = $this->input->post('lacetype',true);
  2027. $list['haircap'] = $this->input->post('haircap',true);
  2028. $list['density'] = $this->input->post('density',true);
  2029. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2030. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2031. $list['wigother'] = $this->input->post('wigother',true);
  2032. $list['wigother2'] = $this->input->post('wigother2',true);
  2033. }
  2034. if($category == 129)
  2035. {
  2036. $list['wide'] = $this->input->post('wide',true);
  2037. }
  2038. if($category == 131)
  2039. {
  2040. $list['gifttype'] = $this->input->post('gifttype',true);
  2041. $list['giftother'] = $this->input->post('giftother',true);
  2042. }
  2043. if($category == 134)
  2044. {
  2045. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2046. }
  2047. if($category == 1297)
  2048. {
  2049. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2050. $list['sywigother'] = $this->input->post('sywigother',true);
  2051. }
  2052. if($category == 130 || $category == 133 || $category == 1702)
  2053. {
  2054. $list['items'] = $this->input->post('items',true);
  2055. $list['weight'] = $this->input->post('weight',true);
  2056. }
  2057. if($category == 1702)
  2058. {
  2059. $list['syhairther'] = $this->input->post('syhairther',true);
  2060. }
  2061. $classid = $this->classid->sku();
  2062. $scsku = $classid;
  2063. $pm = $classid;
  2064. foreach($list as $k=>$v)
  2065. {
  2066. if($v != 0)
  2067. {
  2068. $num .=$v;
  2069. $features .=$v.'-';
  2070. $post[$k] = $v;
  2071. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2072. if($k != 'size')
  2073. {
  2074. $title .= $typeclass[$v]['title']." ";
  2075. }
  2076. if(isset($pm[$typeclass[$v]['classid']]))
  2077. {
  2078. if($typeclass[$v]['title'] == '9A')
  2079. {
  2080. $pm[$typeclass[$v]['classid']] = '9A';
  2081. }
  2082. else if($typeclass[$v]['title'] == '10A')
  2083. {
  2084. $pm[$typeclass[$v]['classid']] = '10A';
  2085. }
  2086. else
  2087. {
  2088. $clzh = $typeclass[$v]['zh'];
  2089. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2090. {
  2091. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2092. $clzh = $clzh[0];
  2093. }
  2094. $pm[$typeclass[$v]['classid']] = $clzh;
  2095. }
  2096. }
  2097. }
  2098. }
  2099. $zh = implode(" ",$pm);
  2100. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2101. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2102. if($list['size'])
  2103. {
  2104. $typeclass = $this->typeclass->read($list['size']);
  2105. $title .= $typeclass['title'];
  2106. }
  2107. $time = time();
  2108. if($xzsku)
  2109. {
  2110. $scsku = implode("-",$scsku);
  2111. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2112. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2113. $post['sku'] = trim($scsku,' ');
  2114. }
  2115. else
  2116. {
  2117. $post['sku'] = $sku;
  2118. }
  2119. //$post['sku'] = trim($sku,' ');
  2120. $post['title'] = rtrim($title,' ');
  2121. $post['number'] = $num;
  2122. $post['features'] = '-'.$features;
  2123. $post['enter'] = $time;
  2124. $post['time'] = $time;//操作时间
  2125. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2126. if($yza)
  2127. {
  2128. if($post['features'] != $yza[0]['features'])
  2129. {
  2130. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'success'=>false));exit;
  2131. }
  2132. }
  2133. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2134. if($yzb)
  2135. {
  2136. if($post['sku'] != $yzb[0]['sku'])
  2137. {
  2138. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','success'=>false));exit;
  2139. }
  2140. }
  2141. if(isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
  2142. {
  2143. echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
  2144. }
  2145. if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
  2146. {
  2147. echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
  2148. }
  2149. if($post['rktype'] == '' && $post['warehouse'] == 5)
  2150. {
  2151. echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
  2152. }
  2153. $yz = $this->whlabel->find_all("sku = '".$post['sku']."' and features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'",'type');
  2154. if(isset($yz[0]['type']))
  2155. {
  2156. $post['type'] = $yz[0]['type'];
  2157. }
  2158. if($post['state'] == 9)//如果选择预设库存
  2159. {
  2160. $this->whlabel->insert($post);
  2161. }
  2162. else
  2163. {
  2164. /**
  2165. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2166. if($ljg == 1)
  2167. {
  2168. for($i=0;$i<$order;$i++)
  2169. {
  2170. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2171. $this->whlabel->insert($post);
  2172. }
  2173. }
  2174. **/
  2175. //if($post['warehouse'] == '5')
  2176. //{
  2177. //}
  2178. $yydata = $post;
  2179. $yydata['zh'] = $zh;
  2180. /**
  2181. $wl = $this->apiyy->get_cjlp($yydata);
  2182. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2183. {
  2184. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2185. }
  2186. if($wl['Data'][0]['m_isSucess'] != 1)
  2187. {
  2188. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2189. }
  2190. **/
  2191. for($i=0;$i<$order;$i++)
  2192. {
  2193. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2194. $this->whlabel->insert($post);
  2195. }
  2196. }
  2197. echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
  2198. }
  2199. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2200. $this->data['wlshop'] = $wlshop;
  2201. $this->_Template('whlabel_enteradd',$this->data);
  2202. }
  2203. //修改产品
  2204. public function _enteredit($arg_array)
  2205. {
  2206. $dt = 0;
  2207. if(isset($_SESSION['api']))
  2208. {
  2209. $user = $this->user->get_api($_SESSION['api']);
  2210. $usp = $user;
  2211. $fgshop = "";$sid = "";
  2212. $user = explode('|',trim($user['shop'],'|'));
  2213. foreach ($user as $value)
  2214. {
  2215. $fgshop .= " shop = ".$value." or";
  2216. $sid .= " id = ".$value." or";
  2217. }
  2218. }
  2219. $post = $this->input->post(NULL, TRUE);
  2220. if(isset($post['sku']))
  2221. {
  2222. $list = array();$num = "";$title = "";$features = "";
  2223. $id = $this->input->post('id',true);
  2224. $order = $this->input->post('order',true);
  2225. $shop = $this->input->post('shop',true);
  2226. $post['shop'] = ($shop!="")?','.$shop:"";
  2227. $post['sku'] = $this->input->post('sku',true);
  2228. $post['sm'] = $this->input->post('sm',true);
  2229. $post['warehouse'] = $this->input->post('warehouse',true);
  2230. $post['purchase'] = $this->input->post('purchase',true);
  2231. $post['retreatwarehouse'] = $post['warehouse'];
  2232. $category = $this->input->post('category',true);
  2233. $list['category'] = $category;
  2234. $list['hairtype'] = $this->input->post('hairtype',true);
  2235. $list['grade'] = $this->input->post('grade',true);
  2236. $size = $this->input->post('size',true);
  2237. $list['size'] = rtrim($size,',');
  2238. $post['rktype'] = $this->input->post('rktype',true);
  2239. $post['text'] = $this->input->post('text',true);
  2240. $list['hairnumber'] = $this->input->post('hairnumber',true);
  2241. $list['extension'] = $this->input->post('extension',true);
  2242. if($category == 1297)
  2243. {
  2244. $list['sywignumber'] = $this->input->post('sywignumber',true);
  2245. }
  2246. if($category == 1702)
  2247. {
  2248. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  2249. $list['syother'] = $this->input->post('syother',true);
  2250. }
  2251. if($category == 133)
  2252. {
  2253. $list['fittype'] = $this->input->post('fittype',true);
  2254. $list['acother'] = $this->input->post('acother',true);
  2255. }
  2256. $list['color'] = $this->input->post('color',true);
  2257. $list['lowe'] = $this->input->post('lowe',true);
  2258. if(!$post['purchase'])
  2259. {
  2260. $post['purchase'] = 1;
  2261. }
  2262. if($category == 127)
  2263. {
  2264. $list['type'] = $this->input->post('type',true);
  2265. $list['headroad'] = $this->input->post('headroad',true);
  2266. $list['density'] = $this->input->post('density',true);
  2267. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  2268. {
  2269. $list['lacesize'] = $this->input->post('lacesize',true);
  2270. }
  2271. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2272. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2273. }
  2274. if($category == 128)
  2275. {
  2276. $list['lacetype'] = $this->input->post('lacetype',true);
  2277. $list['haircap'] = $this->input->post('haircap',true);
  2278. $list['density'] = $this->input->post('density',true);
  2279. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2280. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2281. $list['wigother'] = $this->input->post('wigother',true);
  2282. $list['wigother2'] = $this->input->post('wigother2',true);
  2283. }
  2284. if($category == 129)
  2285. {
  2286. $list['wide'] = $this->input->post('wide',true);
  2287. }
  2288. if($category == 131)
  2289. {
  2290. $list['gifttype'] = $this->input->post('gifttype',true);
  2291. $list['giftother'] = $this->input->post('giftother',true);
  2292. }
  2293. if($category == 134)
  2294. {
  2295. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2296. }
  2297. if($category == 1297)
  2298. {
  2299. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2300. $list['sywigother'] = $this->input->post('sywigother',true);
  2301. }
  2302. if($category == 130 || $category == 133 || $category == 1702)
  2303. {
  2304. $list['items'] = $this->input->post('items',true);
  2305. $list['weight'] = $this->input->post('weight',true);
  2306. }
  2307. if($category == 1702)
  2308. {
  2309. $list['syhairther'] = $this->input->post('syhairther',true);
  2310. }
  2311. foreach($list as $k=>$v)
  2312. {
  2313. if($v != 0)
  2314. {
  2315. $num .=$v;
  2316. $features .=$v.'-';
  2317. $typeclass = $this->typeclass->read($v);
  2318. if($k != 'size')
  2319. {
  2320. $title .= $typeclass['title']." ";
  2321. }
  2322. }
  2323. }
  2324. $typeclass = $this->typeclass->read($list['size']);
  2325. $title .= $typeclass['title'];
  2326. $time = time();
  2327. $post['title'] = rtrim($title,' ');
  2328. $post['number'] = $num;
  2329. $post['features'] = '-'.$features;
  2330. $post['time'] = $time;//操作时间
  2331. if($post['rktype'] == '' && $post['warehouse'] == 5)
  2332. {
  2333. echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
  2334. }
  2335. if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
  2336. {
  2337. echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
  2338. }
  2339. $uid = $this->whlabel->read($id);
  2340. $datanum = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2341. if($datanum > 0)
  2342. {
  2343. echo json_encode(array('msg'=>'此SKU有占单,请解除占单后再修改!','success'=>false));exit;
  2344. }
  2345. if($post['warehouse'] != '99999')//现在所有仓都检测,之前只有美仓5检测
  2346. {
  2347. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."'");
  2348. if($yza)
  2349. {
  2350. if($post['features'] != $yza[0]['features'])
  2351. {
  2352. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','success'=>false));exit;
  2353. }
  2354. }
  2355. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."'");
  2356. if($yzb)
  2357. {
  2358. if($post['sku'] != $yzb[0]['sku'])
  2359. {
  2360. echo json_encode(array('msg'=>'此产品信息的SKU和现有不一致!','success'=>false));exit;
  2361. }
  2362. }
  2363. if($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
  2364. {
  2365. echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
  2366. }
  2367. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2368. foreach ($data as $v)
  2369. {
  2370. $post['id'] = $v['id'];
  2371. $this->whlabel->save($post,$v['id']);
  2372. }
  2373. }
  2374. else
  2375. {
  2376. $data = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2377. if($data > 0)
  2378. {
  2379. echo json_encode(array('msg'=>'此产品有占单,无法修改!','success'=>false));exit;
  2380. }
  2381. else
  2382. {
  2383. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2384. foreach ($data as $v)
  2385. {
  2386. $post['id'] = $v['id'];
  2387. $this->whlabel->save($post,$v['id']);
  2388. }
  2389. }
  2390. }
  2391. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  2392. }
  2393. $uid = $this->whlabel->read($arg_array[0]);
  2394. $uid['order'] = $this->whlabel->find_count('enter = "'.$uid['enter'].'" and sku = "'.$uid['sku'].'" and state = "0"');
  2395. $this->data['enter'] = $uid ;
  2396. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2397. $this->data['wlshop'] = $wlshop;
  2398. $this->_Template('whlabel_enteredit',$this->data);
  2399. }
  2400. //入库浏览
  2401. public function _enter()
  2402. {
  2403. $post = $this->input->post(NULL, TRUE);
  2404. if(isset($post['s']))
  2405. {
  2406. $id_arr = $this->input->post('s');
  2407. $id_arr = explode(',',$id_arr);
  2408. if(!$id_arr)
  2409. {
  2410. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2411. }
  2412. //循环删除记录
  2413. foreach ($id_arr as $v)
  2414. {
  2415. $sid = $this->whlabel->read($v);
  2416. $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
  2417. if($count > 0)
  2418. {
  2419. echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
  2420. }
  2421. $info_list = $this->whlabel->find_all('enter ='.$sid['enter']);
  2422. foreach ($info_list as $va)
  2423. {
  2424. $this->whlabel->remove($va['id']);
  2425. }
  2426. }
  2427. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  2428. }
  2429. $sp = array();
  2430. $s = $this->shop->find_all('1=1','id,shopname');
  2431. foreach ($s as $v)
  2432. {
  2433. $sp[$v['id']] = $v['shopname'];
  2434. }
  2435. $wh = array();
  2436. $w = $this->warehouse->find_all('1=1','id,title');
  2437. foreach ($w as $v)
  2438. {
  2439. $wh[$v['id']] = $v['title'];
  2440. }
  2441. if(isset($post['page']))
  2442. {
  2443. $page = $this->input->post('page',true);
  2444. $perpage = $this->input->post('perpage',true);
  2445. $category = $this->input->post('category',true);
  2446. $size = $this->input->post('size',true);
  2447. $grade = $this->input->post('grade',true);
  2448. $color = $this->input->post('color',true);
  2449. $lowe = $this->input->post('lowe',true);
  2450. $sku = $this->input->post('sku',true);
  2451. $warehouse = $this->input->post('warehouse',true);
  2452. $purchase = $this->input->post('purchase',true);
  2453. $ktime = $this->input->post('ktime',true);
  2454. $jtime = $this->input->post('jtime',true);
  2455. $ktime = strtotime($ktime);
  2456. $jtime = strtotime($jtime);
  2457. $where = "1=1";$gj = "";$ck = "";
  2458. if($category)
  2459. {
  2460. $where .= " and features like '%-$category-%'";
  2461. }
  2462. if($size)
  2463. {
  2464. $where .= " and features like '%-$size-%'";
  2465. }
  2466. if($grade)
  2467. {
  2468. $where .= " and features like '%-$grade-%'";
  2469. }
  2470. if($color)
  2471. {
  2472. $where .= " and features like '%-$color-%'";
  2473. }
  2474. if($lowe)
  2475. {
  2476. $where .= " and features like '%-$lowe-%'";
  2477. }
  2478. if($warehouse)
  2479. {
  2480. $where .= " and warehouse = '$warehouse'";
  2481. }
  2482. if($purchase)
  2483. {
  2484. $where .= " and purchase = '$purchase'";
  2485. }
  2486. if($sku)
  2487. {
  2488. $where .= " and sku like '%$sku%'";
  2489. }
  2490. if($ktime && $jtime)
  2491. {
  2492. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2493. }
  2494. //数据排序
  2495. $order_str = "enter desc";
  2496. if(empty($page))
  2497. {
  2498. $start = 0;
  2499. $perpage = 1;
  2500. }
  2501. else
  2502. {
  2503. $start = ($page - 1)*$perpage;
  2504. }
  2505. //取得信息列表
  2506. $info_list = $this->whlabel->find_pc($where,'enter,warehouse,sku','id,warehouse,shop,sku,title,enter',$order_str,$start,$perpage);
  2507. foreach ($info_list as $k=>$v)
  2508. {
  2509. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2510. if($v['shop']=='')
  2511. {
  2512. $s = '通用';
  2513. }
  2514. else
  2515. {
  2516. $info_list[$k]['shop'] = '';
  2517. foreach (explode(',',trim($v['shop'],',')) as $val)
  2518. {
  2519. $info_list[$k]['shop'] .= $sp[$val].'</br>';
  2520. }
  2521. }
  2522. $info_list[$k]['enter'] = date('Y-m-d H:i:s',$v['enter']);
  2523. $g = $this->whlabel->find_count($where.' and enter = "'.$v['enter'].'" and sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'"');
  2524. $info_list[$k]['g'] = $g;
  2525. }
  2526. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  2527. $pagenum = ceil($total/$perpage);
  2528. $over = $total-($start+$perpage);
  2529. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2530. echo json_encode($rows);exit;
  2531. }
  2532. $this->_Template('whlabel_enter',$this->data);
  2533. }
  2534. //出库浏览
  2535. public function _out()
  2536. {
  2537. $post = $this->input->post(NULL, TRUE);
  2538. if(isset($post['page']))
  2539. {
  2540. $page = $this->input->post('page',true);
  2541. $perpage = $this->input->post('perpage',true);
  2542. $category = $this->input->post('category',true);
  2543. $size = $this->input->post('size',true);
  2544. $grade = $this->input->post('grade',true);
  2545. $color = $this->input->post('color',true);
  2546. $lowe = $this->input->post('lowe',true);
  2547. $sku = $this->input->post('sku',true);
  2548. $warehouse = $this->input->post('warehouse',true);
  2549. $purchase = $this->input->post('purchase',true);
  2550. $state = $this->input->post('state',true);
  2551. $ktime = $this->input->post('ktime',true);
  2552. $jtime = $this->input->post('jtime',true);
  2553. $ktime = strtotime($ktime);
  2554. $jtime = strtotime($jtime);
  2555. $where = "state=3";$gj = "";$ck = "";
  2556. if($category)
  2557. {
  2558. $where .= " and features like '%-$category-%'";
  2559. }
  2560. if($size)
  2561. {
  2562. $where .= " and features like '%-$size-%'";
  2563. }
  2564. if($grade)
  2565. {
  2566. $where .= " and features like '%-$grade-%'";
  2567. }
  2568. if($color)
  2569. {
  2570. $where .= " and features like '%-$color-%'";
  2571. }
  2572. if($lowe)
  2573. {
  2574. $where .= " and features like '%-$lowe-%'";
  2575. }
  2576. if($state)
  2577. {
  2578. $where .= " and state = '$state'";
  2579. }
  2580. if($warehouse)
  2581. {
  2582. $where .= " and warehouse = '$warehouse'";
  2583. }
  2584. if($purchase)
  2585. {
  2586. $where .= " and purchase = '$purchase'";
  2587. }
  2588. if($sku)
  2589. {
  2590. $where .= " and sku = '$sku'";
  2591. }
  2592. if($ktime && $jtime)
  2593. {
  2594. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2595. }
  2596. //数据排序
  2597. $order_str = "id desc";
  2598. if(empty($page))
  2599. {
  2600. $start = 0;
  2601. $perpage = 1;
  2602. }
  2603. else
  2604. {
  2605. $start = ($page - 1)*$perpage;
  2606. }
  2607. //取得信息列表
  2608. $info_list = $this->whlabel->find_all($where,'sku');
  2609. $rows = array();$list = array();
  2610. foreach ($info_list as $key=>$value)
  2611. {
  2612. $rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
  2613. }
  2614. $rows = array_unique($rows);//删除重复记录
  2615. foreach ($rows as $key=>$value)
  2616. {
  2617. $data = $this->whlabel->get_sku($value);//获取目前sku的所有数据
  2618. $ck = $this->warehouse->read($data['warehouse']);
  2619. $warehouse = $ck['title'];
  2620. $gy = $this->purchase->read($data['purchase']);
  2621. $purchase = $gy['purchase'];
  2622. $g = $this->whlabel->find_count($where.' and sku = "'.$value.'" and state = 3');
  2623. $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);
  2624. }
  2625. $total = count($list);
  2626. $pagenum = ceil($total/$perpage);
  2627. $over = $total-($start+$perpage);
  2628. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  2629. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  2630. echo json_encode($rows);exit;
  2631. }
  2632. $this->_Template('whlabel_out',$this->data);
  2633. }
  2634. //出库标签浏览
  2635. public function _label()
  2636. {
  2637. $post = $this->input->post(NULL, TRUE);
  2638. if(isset($post['page']))
  2639. {
  2640. $page = $this->input->post('page',true);
  2641. $perpage = $this->input->post('perpage',true);
  2642. $sku = $this->input->post('sku',true);
  2643. $warehouse = $this->input->post('warehouse',true);
  2644. $purchase = $this->input->post('purchase',true);
  2645. $orderinfo = $this->input->post('orderinfo',true);
  2646. $waybill = $this->input->post('waybill',true);
  2647. $category = $this->input->post('category',true);
  2648. $size = $this->input->post('size',true);
  2649. $grade = $this->input->post('grade',true);
  2650. $color = $this->input->post('color',true);
  2651. $lowe = $this->input->post('lowe',true);
  2652. $where = "state=1";
  2653. if($sku)
  2654. {
  2655. $where .= " and sku = '$sku'";
  2656. }
  2657. if($warehouse)
  2658. {
  2659. $where .= " and warehouse = '$warehouse'";
  2660. }
  2661. if($purchase)
  2662. {
  2663. $where .= " and purchase = '$purchase'";
  2664. }
  2665. if($orderinfo)
  2666. {
  2667. $where .= " and orderinfo = '$orderinfo'";
  2668. }
  2669. if($waybill)
  2670. {
  2671. $where .= " and waybill = '$waybill'";
  2672. }
  2673. if($category)
  2674. {
  2675. $where .= " and features like '%-$category-%'";
  2676. }
  2677. if($size)
  2678. {
  2679. $where .= " and features like '%-$size-%'";
  2680. }
  2681. if($grade)
  2682. {
  2683. $where .= " and features like '%-$grade-%'";
  2684. }
  2685. if($color)
  2686. {
  2687. $where .= " and features like '%-$color-%'";
  2688. }
  2689. if($lowe)
  2690. {
  2691. $where .= " and features like '%-$lowe-%'";
  2692. }
  2693. //数据排序
  2694. $order_str = "outk desc";
  2695. if(empty($page))
  2696. {
  2697. $start = 0;
  2698. $perpage = 1;
  2699. }
  2700. else
  2701. {
  2702. $start = ($page - 1)*$perpage;
  2703. }
  2704. //取得信息列表
  2705. $info_list = $this->whlabel->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
  2706. foreach ($info_list as $key=>$value)
  2707. {
  2708. $warehouse = $this->warehouse->read($value['warehouse']);
  2709. $info_list[$key]['warehouse'] = $warehouse['title'];
  2710. $purchase = $this->purchase->read($value['purchase']);
  2711. $info_list[$key]['purchase'] = $purchase['title'];
  2712. if($value['outk'] != 0)
  2713. {
  2714. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  2715. }
  2716. else
  2717. {
  2718. $info_list[$key]['outk'] = "";
  2719. }
  2720. if($value['orderinfo'] == 0)
  2721. {
  2722. $info_list[$key]['orderinfo'] = "";
  2723. }
  2724. if($value['waybill'] == 0)
  2725. {
  2726. $info_list[$key]['waybill'] = "";
  2727. }
  2728. }
  2729. $total = $this->whlabel->find_count($where);
  2730. $pagenum = ceil($total/$perpage);
  2731. $over = $total-($start+$perpage);
  2732. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2733. echo json_encode($rows);exit;
  2734. }
  2735. $this->_Template('whlabel_label',$this->data);
  2736. }
  2737. //独立站出库订单
  2738. public function _outorder()
  2739. {
  2740. if(isset($_SESSION['api']))
  2741. {
  2742. $user = $this->user->get_api($_SESSION['api']);
  2743. $usp = $user;
  2744. $fgshop = "";$sid = "";
  2745. $user = explode('|',trim($user['shop'],'|'));
  2746. foreach ($user as $value)
  2747. {
  2748. $fgshop .= " shop = ".$value." or";
  2749. $sid .= " id = ".$value." or";
  2750. }
  2751. }
  2752. else
  2753. {
  2754. echo "请重新登录";
  2755. }
  2756. $post = $this->input->post(NULL, TRUE);
  2757. if(isset($post['page']))
  2758. {
  2759. $page = $this->input->post('page',true);
  2760. $perpage = $this->input->post('perpage',true);
  2761. $warehouse = $this->input->post('warehouse',true);
  2762. $xztime = $this->input->post('xztime',true);
  2763. $timetk = $this->input->post('timetkk',true);
  2764. $timetj = $this->input->post('timetjj',true);
  2765. $shop = $this->input->post('shop',true);
  2766. $source = $this->input->post('source',true);
  2767. $orderinfo = $this->input->post('orderinfo',true);
  2768. $number = $this->input->post('number',true);
  2769. $sfxh = $this->input->post('sfxh',true);
  2770. $express = $this->input->post('express',true);
  2771. $waybill = $this->input->post('waybill',true);
  2772. $library = $this->input->post('library',true);
  2773. $country = $this->input->post('country',true);
  2774. $so = $this->input->post('so',true);
  2775. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2776. $print = $this->input->post('print',true);
  2777. $state = $this->input->post('state',true);
  2778. $orderurl = $this->input->post('orderurl',true);
  2779. $timetk = strtotime($timetk);
  2780. $timetj = strtotime($timetj);
  2781. /**
  2782. $sj = $this->input->post('sj',true);
  2783. if($sj)
  2784. {
  2785. $sj = $this->input->post('sj',true);
  2786. }
  2787. else
  2788. {
  2789. $sj = "fullorder";
  2790. }
  2791. **/
  2792. $sj = "fullorder";
  2793. $where = "1=1";
  2794. if($warehouse)
  2795. {
  2796. $where .= " and type = '$warehouse'";
  2797. }
  2798. if($timetk && $timetj)
  2799. {
  2800. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2801. }
  2802. if($orderinfo)
  2803. {
  2804. $where .= " and orderinfo = '$orderinfo'";
  2805. }
  2806. if($number)
  2807. {
  2808. $where .= " and number = '$number'";
  2809. }
  2810. if($express)
  2811. {
  2812. $where .= " and express = '$express'";
  2813. }
  2814. if($waybill)
  2815. {
  2816. $where .= " and waybill = '$waybill'";
  2817. }
  2818. if($library)
  2819. {
  2820. $where .= " and library = '$library'";
  2821. }
  2822. if($print)
  2823. {
  2824. $where .= " and print = '$print'";
  2825. }
  2826. if($libraryconfirm)
  2827. {
  2828. $where .= " and libraryconfirm = '$libraryconfirm'";
  2829. }
  2830. if($state)
  2831. {
  2832. $where .= " and state = '$state'";
  2833. }
  2834. if($shop)
  2835. {
  2836. $where .= " and shop = '$shop'";
  2837. }
  2838. if($country)
  2839. {
  2840. $where .= " and country = '$country'";
  2841. }
  2842. if($sfxh != '')
  2843. {
  2844. $where .= " and sfxh = '$sfxh'";
  2845. }
  2846. if($so)
  2847. {
  2848. $where .= " and shipremarks like '%$so%'";
  2849. }
  2850. if($source)
  2851. {
  2852. if($source == '2d')
  2853. {
  2854. $where .= " and source >= '2'";
  2855. }
  2856. else
  2857. {
  2858. $where .= " and source = '$source'";
  2859. }
  2860. }
  2861. if(isset($_SESSION['api']))
  2862. {
  2863. foreach ($user as $value)
  2864. {
  2865. $fgshop .= " shop = ".$value." or";
  2866. }
  2867. $where .= " and (".rtrim($fgshop,'or').")";
  2868. }
  2869. if($orderurl)
  2870. {
  2871. $url = $this->orderurl->read($orderurl);
  2872. $where .= " and link like '%".$url['url']."%'";
  2873. }
  2874. //数据排序
  2875. $order_str = "librarytime desc";
  2876. if(empty($page))
  2877. {
  2878. $start = 0;
  2879. $perpage = 1;
  2880. }
  2881. else
  2882. {
  2883. $start = ($page - 1)*$perpage;
  2884. }
  2885. //取得信息列表
  2886. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2887. //格式化数据
  2888. foreach ($info_list as $key=>$value)
  2889. {
  2890. $shop = $this->shop->read($value['shop']);
  2891. $info_list[$key]['shop'] = $shop['shopname'];
  2892. $express = $this->express->read($value['express']);
  2893. $info_list[$key]['express'] = $express['servicename'];
  2894. $warehouse = $this->warehouse->read($value['type']);
  2895. $info_list[$key]['type'] = $warehouse['title'];
  2896. if($value['librarytime'] == '0')
  2897. {
  2898. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2899. }
  2900. else
  2901. {
  2902. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2903. }
  2904. }
  2905. $total = $this->$sj->find_count($where);
  2906. $pagenum = ceil($total/$perpage);
  2907. $over = $total-($start+$perpage);
  2908. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2909. echo json_encode($rows);exit;
  2910. }
  2911. $this->data['express'] = $this->express->find_all();
  2912. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2913. $this->data['wlshop'] = $wlshop;
  2914. $user = $this->user->get_api($_SESSION['api']);
  2915. $powerid = $this->power->read($user['power']);
  2916. $powertext = explode('|',trim($powerid['excelid'],'|'));
  2917. $pid = '';
  2918. foreach ($powertext as $v)
  2919. {
  2920. $pid .= " id = ".$v." or";
  2921. }
  2922. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  2923. $this->data['fullorderexcel'] = $fullorderexcel;
  2924. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  2925. $this->data['orderurl'] = $orderurl;
  2926. $this->_Template('whlabel_outorder',$this->data);
  2927. }
  2928. //tt出库
  2929. public function _toutorder()
  2930. {
  2931. if(isset($_SESSION['api']))
  2932. {
  2933. $user = $this->user->get_api($_SESSION['api']);
  2934. $usp = $user;
  2935. $fgshop = "";$sid = "";
  2936. $user = explode('|',trim($user['shop'],'|'));
  2937. foreach ($user as $value)
  2938. {
  2939. $fgshop .= " shop = ".$value." or";
  2940. $sid .= " id = ".$value." or";
  2941. }
  2942. }
  2943. else
  2944. {
  2945. echo "请重新登录";
  2946. }
  2947. $post = $this->input->post(NULL, TRUE);
  2948. if(isset($post['page']))
  2949. {
  2950. $page = $this->input->post('page',true);
  2951. $perpage = $this->input->post('perpage',true);
  2952. $warehouse = $this->input->post('warehouse',true);
  2953. $xztime = $this->input->post('xztime',true);
  2954. $timetk = $this->input->post('timetkk',true);
  2955. $timetj = $this->input->post('timetjj',true);
  2956. $shop = $this->input->post('shop',true);
  2957. $source = $this->input->post('source',true);
  2958. $orderinfo = $this->input->post('orderinfo',true);
  2959. $number = $this->input->post('number',true);
  2960. $sfxh = $this->input->post('sfxh',true);
  2961. $express = $this->input->post('express',true);
  2962. $waybill = $this->input->post('waybill',true);
  2963. $library = $this->input->post('library',true);
  2964. $country = $this->input->post('country',true);
  2965. $so = $this->input->post('so',true);
  2966. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2967. $print = $this->input->post('print',true);
  2968. $state = $this->input->post('state',true);
  2969. $orderurl = $this->input->post('orderurl',true);
  2970. $timetk = strtotime($timetk);
  2971. $timetj = strtotime($timetj);
  2972. /**
  2973. $sj = $this->input->post('sj',true);
  2974. if($sj)
  2975. {
  2976. $sj = $this->input->post('sj',true);
  2977. }
  2978. else
  2979. {
  2980. $sj = "fullorder";
  2981. }
  2982. **/
  2983. $sj = "fullordertt";
  2984. $where = "1=1";
  2985. if($warehouse)
  2986. {
  2987. $where .= " and type = '$warehouse'";
  2988. }
  2989. if($timetk && $timetj)
  2990. {
  2991. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2992. }
  2993. if($orderinfo)
  2994. {
  2995. $where .= " and orderinfo = '$orderinfo'";
  2996. }
  2997. if($number)
  2998. {
  2999. $where .= " and number = '$number'";
  3000. }
  3001. if($express)
  3002. {
  3003. $where .= " and express = '$express'";
  3004. }
  3005. if($waybill)
  3006. {
  3007. $where .= " and waybill = '$waybill'";
  3008. }
  3009. if($library)
  3010. {
  3011. $where .= " and library = '$library'";
  3012. }
  3013. if($print)
  3014. {
  3015. $where .= " and print = '$print'";
  3016. }
  3017. if($libraryconfirm)
  3018. {
  3019. $where .= " and libraryconfirm = '$libraryconfirm'";
  3020. }
  3021. if($state)
  3022. {
  3023. $where .= " and state = '$state'";
  3024. }
  3025. if($shop)
  3026. {
  3027. $where .= " and shop = '$shop'";
  3028. }
  3029. if($country)
  3030. {
  3031. $where .= " and country = '$country'";
  3032. }
  3033. if($sfxh != '')
  3034. {
  3035. $where .= " and sfxh = '$sfxh'";
  3036. }
  3037. if($so)
  3038. {
  3039. $where .= " and shipremarks like '%$so%'";
  3040. }
  3041. if($source)
  3042. {
  3043. if($source == '2d')
  3044. {
  3045. $where .= " and source >= '2'";
  3046. }
  3047. else
  3048. {
  3049. $where .= " and source = '$source'";
  3050. }
  3051. }
  3052. if(isset($_SESSION['api']))
  3053. {
  3054. foreach ($user as $value)
  3055. {
  3056. $fgshop .= " shop = ".$value." or";
  3057. }
  3058. $where .= " and (".rtrim($fgshop,'or').")";
  3059. }
  3060. if($orderurl)
  3061. {
  3062. $url = $this->orderurl->read($orderurl);
  3063. $where .= " and link like '%".$url['url']."%'";
  3064. }
  3065. //数据排序
  3066. $order_str = "librarytime desc";
  3067. if(empty($page))
  3068. {
  3069. $start = 0;
  3070. $perpage = 1;
  3071. }
  3072. else
  3073. {
  3074. $start = ($page - 1)*$perpage;
  3075. }
  3076. //取得信息列表
  3077. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3078. //格式化数据
  3079. foreach ($info_list as $key=>$value)
  3080. {
  3081. $shop = $this->shop->read($value['shop']);
  3082. $info_list[$key]['shop'] = $shop['shopname'];
  3083. $express = $this->express->read($value['express']);
  3084. $info_list[$key]['express'] = $express['servicename'];
  3085. $warehouse = $this->warehouse->read($value['type']);
  3086. $info_list[$key]['type'] = $warehouse['title'];
  3087. if($value['librarytime'] == '0')
  3088. {
  3089. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3090. }
  3091. else
  3092. {
  3093. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3094. }
  3095. }
  3096. $total = $this->$sj->find_count($where);
  3097. $pagenum = ceil($total/$perpage);
  3098. $over = $total-($start+$perpage);
  3099. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3100. echo json_encode($rows);exit;
  3101. }
  3102. $this->data['express'] = $this->express->find_all();
  3103. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3104. $this->data['wlshop'] = $wlshop;
  3105. $user = $this->user->get_api($_SESSION['api']);
  3106. $powerid = $this->power->read($user['power']);
  3107. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3108. $pid = '';
  3109. foreach ($powertext as $v)
  3110. {
  3111. $pid .= " id = ".$v." or";
  3112. }
  3113. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3114. $this->data['fullorderexcel'] = $fullorderexcel;
  3115. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  3116. $this->data['orderurl'] = $orderurl;
  3117. $this->_Template('whlabel_toutorder',$this->data);
  3118. }
  3119. //速卖通出库订单
  3120. public function _soutorder()
  3121. {
  3122. if(isset($_SESSION['api']))
  3123. {
  3124. $user = $this->user->get_api($_SESSION['api']);
  3125. $usp = $user;
  3126. $fgshop = "";$sid = "";
  3127. $user = explode('|',trim($user['shop'],'|'));
  3128. foreach ($user as $value)
  3129. {
  3130. $sid .= " id = ".$value." or";
  3131. }
  3132. }
  3133. $post = $this->input->post(NULL, TRUE);
  3134. if(isset($post['page']))
  3135. {
  3136. $page = $this->input->post('page',true);
  3137. $perpage = $this->input->post('perpage',true);
  3138. $warehouse = $this->input->post('warehouse',true);
  3139. $xztime = $this->input->post('xztime',true);
  3140. $timetk = $this->input->post('timetkk',true);
  3141. $timetj = $this->input->post('timetjj',true);
  3142. $shop = $this->input->post('shop',true);
  3143. $source = $this->input->post('source',true);
  3144. $orderinfo = $this->input->post('orderinfo',true);
  3145. $number = $this->input->post('number',true);
  3146. $express = $this->input->post('express',true);
  3147. $waybill = $this->input->post('waybill',true);
  3148. $library = $this->input->post('library',true);
  3149. $country = $this->input->post('country',true);
  3150. $sfxh = $this->input->post('sfxh',true);
  3151. $libraryconfirm = $this->input->post('libraryconfirm',true);
  3152. $print = $this->input->post('print',true);
  3153. $state = $this->input->post('state',true);
  3154. $so = $this->input->post('so',true);
  3155. $timetk = strtotime($timetk);
  3156. $timetj = strtotime($timetj);
  3157. /**
  3158. $sj = $this->input->post('sj',true);
  3159. if($sj)
  3160. {
  3161. $sj = $this->input->post('sj',true);
  3162. }
  3163. else
  3164. {
  3165. $sj = "fullorder";
  3166. }
  3167. **/
  3168. $sj = "fullordersmt";
  3169. $where = "1=1";
  3170. if($warehouse)
  3171. {
  3172. $where .= " and type = '$warehouse'";
  3173. }
  3174. if($timetk && $timetj)
  3175. {
  3176. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3177. }
  3178. if($orderinfo)
  3179. {
  3180. $where .= " and orderinfo = '$orderinfo'";
  3181. }
  3182. if($number)
  3183. {
  3184. $where .= " and number = '$number'";
  3185. }
  3186. if($express)
  3187. {
  3188. $where .= " and express = '$express'";
  3189. }
  3190. if($waybill)
  3191. {
  3192. $where .= " and waybill = '$waybill'";
  3193. }
  3194. if($library)
  3195. {
  3196. $where .= " and library = '$library'";
  3197. }
  3198. if($print)
  3199. {
  3200. $where .= " and print = '$print'";
  3201. }
  3202. if($libraryconfirm)
  3203. {
  3204. $where .= " and libraryconfirm = '$libraryconfirm'";
  3205. }
  3206. if($state)
  3207. {
  3208. $where .= " and state = '$state'";
  3209. }
  3210. if($shop)
  3211. {
  3212. $where .= " and shop = '$shop'";
  3213. }
  3214. if($sfxh != '')
  3215. {
  3216. $where .= " and sfxh = '$sfxh'";
  3217. }
  3218. if($so)
  3219. {
  3220. $where .= " and shipremarks like '%$so%'";
  3221. }
  3222. if($source)
  3223. {
  3224. $where .= " and source = '$source'";
  3225. }
  3226. if($country)
  3227. {
  3228. $where .= " and country = '$country'";
  3229. }
  3230. else
  3231. {
  3232. if(isset($_SESSION['api']))
  3233. {
  3234. foreach ($user as $value)
  3235. {
  3236. $fgshop .= " shop = ".$value." or";
  3237. }
  3238. $where .= " and (".rtrim($fgshop,'or').")";
  3239. }
  3240. }
  3241. //数据排序
  3242. $order_str = "librarytime desc";
  3243. if(empty($page))
  3244. {
  3245. $start = 0;
  3246. $perpage = 1;
  3247. }
  3248. else
  3249. {
  3250. $start = ($page - 1)*$perpage;
  3251. }
  3252. //取得信息列表
  3253. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3254. //格式化数据
  3255. foreach ($info_list as $key=>$value)
  3256. {
  3257. $shop = $this->shop->read($value['shop']);
  3258. $info_list[$key]['shop'] = $shop['shopname'];
  3259. $express = $this->express->read($value['express']);
  3260. $info_list[$key]['express'] = $express['servicename'];
  3261. $warehouse = $this->warehouse->read($value['type']);
  3262. $info_list[$key]['type'] = $warehouse['title'];
  3263. if($value['librarytime'] == '0')
  3264. {
  3265. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3266. }
  3267. else
  3268. {
  3269. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3270. }
  3271. }
  3272. $total = $this->$sj->find_count($where);
  3273. $pagenum = ceil($total/$perpage);
  3274. $over = $total-($start+$perpage);
  3275. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3276. echo json_encode($rows);exit;
  3277. }
  3278. $this->data['express'] = $this->express->find_all();
  3279. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3280. $this->data['wlshop'] = $wlshop;
  3281. $user = $this->user->get_api($_SESSION['api']);
  3282. $powerid = $this->power->read($user['power']);
  3283. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3284. $pid = '';
  3285. foreach ($powertext as $v)
  3286. {
  3287. $pid .= " id = ".$v." or";
  3288. }
  3289. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3290. $this->data['fullorderexcel'] = $fullorderexcel;
  3291. $this->_Template('whlabel_soutorder',$this->data);
  3292. }
  3293. //订单退库
  3294. public function _retreat()
  3295. {
  3296. $post = $this->input->post(NULL, TRUE);
  3297. if(isset($post['page']))
  3298. {
  3299. $page = $this->input->post('page',true);
  3300. $perpage = $this->input->post('perpage',true);
  3301. $warehouse = $this->input->post('warehouse',true);
  3302. $timetk = $this->input->post('timetk',true);
  3303. $timetj = $this->input->post('timetj',true);
  3304. $shop = $this->input->post('shop',true);
  3305. $source = $this->input->post('source',true);
  3306. $state = $this->input->post('state',true);
  3307. $review = $this->input->post('review',true);
  3308. $state = $this->input->post('state',true);
  3309. $express = $this->input->post('express',true);
  3310. $orderinfo = $this->input->post('orderinfo',true);
  3311. $user = $this->input->post('user',true);
  3312. $name = $this->input->post('name',true);
  3313. $waybill = $this->input->post('waybill',true);
  3314. $timetk = strtotime($timetk);
  3315. $timetj = strtotime($timetj);
  3316. $where = "(state=206 or state=210) and mergeid = 0";
  3317. if($warehouse)
  3318. {
  3319. $where .= " and state = '$warehouse'";
  3320. }
  3321. if($timetk && $timetj)
  3322. {
  3323. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3324. }
  3325. if($shop)
  3326. {
  3327. $where .= " and shop = '$shop'";
  3328. }
  3329. if($source)
  3330. {
  3331. $where .= " and source = '$source'";
  3332. }
  3333. if($state)
  3334. {
  3335. $where .= " and state = '$state'";
  3336. }
  3337. if($review)
  3338. {
  3339. $where .= " and review = '$review'";
  3340. }
  3341. if($state)
  3342. {
  3343. $where .= " and state = '$state'";
  3344. }
  3345. if($express)
  3346. {
  3347. $where .= " and express = '$express'";
  3348. }
  3349. if($orderinfo)
  3350. {
  3351. $where .= " and orderinfo = '$orderinfo'";
  3352. }
  3353. if($user)
  3354. {
  3355. $where .= " and user = '$user'";
  3356. }
  3357. if($name)
  3358. {
  3359. $where .= " and name = '$name'";
  3360. }
  3361. if($waybill)
  3362. {
  3363. $where .= " and waybill = '$waybill'";
  3364. }
  3365. //数据排序
  3366. $order_str = "id desc";
  3367. if(empty($page))
  3368. {
  3369. $start = 0;
  3370. $perpage = 1;
  3371. }
  3372. else
  3373. {
  3374. $start = ($page - 1)*$perpage;
  3375. }
  3376. //取得信息列表
  3377. $info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
  3378. //格式化数据
  3379. foreach ($info_list as $key=>$value)
  3380. {
  3381. $shop = $this->shop->read($value['shop']);
  3382. $info_list[$key]['shop'] = $shop['shopname'];
  3383. $warehouse = $this->warehouse->read($value['warehouse']);
  3384. $info_list[$key]['warehouse'] = $warehouse['title'];
  3385. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/".$value['id']."'>".$value['orderinfo']."</a>";
  3386. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  3387. if($value['waybill'] == 0)
  3388. {
  3389. $info_list[$key]['waybill'] = "";
  3390. }
  3391. $express = $this->express->read($value['express']);
  3392. $info_list[$key]['express'] = $express['title'];
  3393. $typeclass = $this->typeclass->read($value['state']);
  3394. $info_list[$key]['state'] = $typeclass['title'];
  3395. }
  3396. $total = $this->fullorder->find_count($where);
  3397. $pagenum = ceil($total/$perpage);
  3398. $over = $total-($start+$perpage);
  3399. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3400. echo json_encode($rows);exit;
  3401. }
  3402. $this->data['express'] = $this->express->find_all();
  3403. $this->_Template('whlabel_retreat',$this->data);
  3404. }
  3405. //退库标签浏览
  3406. public function _retreatlk()
  3407. {
  3408. $post = $this->input->post(NULL, TRUE);
  3409. if(isset($post['page']))
  3410. {
  3411. $page = $this->input->post('page',true);
  3412. $perpage = $this->input->post('perpage',true);
  3413. $timetk = $this->input->post('timetk',true);
  3414. $timetj = $this->input->post('timetj',true);
  3415. $sku = $this->input->post('sku',true);
  3416. $warehouse = $this->input->post('warehouse',true);
  3417. $purchase = $this->input->post('purchase',true);
  3418. $orderinfo = $this->input->post('orderinfo',true);
  3419. $waybill = $this->input->post('waybill',true);
  3420. $category = $this->input->post('category',true);
  3421. $size = $this->input->post('size',true);
  3422. $grade = $this->input->post('grade',true);
  3423. $color = $this->input->post('color',true);
  3424. $lowe = $this->input->post('lowe',true);
  3425. $state = $this->input->post('state',true);
  3426. $timetk = strtotime($timetk);
  3427. $timetj = strtotime($timetj);
  3428. $where = "state=2";
  3429. if($timetk && $timetj)
  3430. {
  3431. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3432. }
  3433. if($sku)
  3434. {
  3435. $where .= " and sku = '$sku'";
  3436. }
  3437. if($warehouse)
  3438. {
  3439. $where .= " and warehouse = '$warehouse'";
  3440. }
  3441. if($purchase)
  3442. {
  3443. $where .= " and purchase = '$purchase'";
  3444. }
  3445. if($orderinfo)
  3446. {
  3447. $where .= " and orderinfo = '$orderinfo'";
  3448. }
  3449. if($waybill)
  3450. {
  3451. $where .= " and waybill = '$waybill'";
  3452. }
  3453. if($category)
  3454. {
  3455. $where .= " and features like '%-$category-%'";
  3456. }
  3457. if($size)
  3458. {
  3459. $where .= " and features like '%-$size-%'";
  3460. }
  3461. if($grade)
  3462. {
  3463. $where .= " and features like '%-$grade-%'";
  3464. }
  3465. if($color)
  3466. {
  3467. $where .= " and features like '%-$color-%'";
  3468. }
  3469. if($lowe)
  3470. {
  3471. $where .= " and features like '%-$lowe-%'";
  3472. }
  3473. //数据排序
  3474. $order_str = "time desc";
  3475. if(empty($page))
  3476. {
  3477. $start = 0;
  3478. $perpage = 1;
  3479. }
  3480. else
  3481. {
  3482. $start = ($page - 1)*$perpage;
  3483. }
  3484. //取得信息列表
  3485. $info_list = $this->whlabel->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
  3486. foreach ($info_list as $key=>$value)
  3487. {
  3488. $warehouse = $this->warehouse->read($value['warehouse']);
  3489. $info_list[$key]['warehouse'] = $warehouse['title'];
  3490. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3491. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3492. $purchase = $this->purchase->read($value['purchase']);
  3493. $info_list[$key]['purchase'] = $purchase['title'];
  3494. if($value['outk'] != 0)
  3495. {
  3496. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  3497. }
  3498. else
  3499. {
  3500. $info_list[$key]['outk'] = "";
  3501. }
  3502. if($value['retreat'] != 0)
  3503. {
  3504. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
  3505. }
  3506. else
  3507. {
  3508. $info_list[$key]['retreat'] = "";
  3509. }
  3510. if($value['orderinfo'] == 0)
  3511. {
  3512. $info_list[$key]['orderinfo'] = "";
  3513. }
  3514. if($value['waybill'] == 0)
  3515. {
  3516. $info_list[$key]['waybill'] = "";
  3517. }
  3518. }
  3519. $total = $this->whlabel->find_count($where);
  3520. $pagenum = ceil($total/$perpage);
  3521. $over = $total-($start+$perpage);
  3522. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3523. echo json_encode($rows);exit;
  3524. }
  3525. $this->_Template('whlabel_retreatlk',$this->data);
  3526. }
  3527. //更换标签及浏览
  3528. public function _change()
  3529. {
  3530. $post = $this->input->post(NULL, TRUE);
  3531. if(isset($post['page']))
  3532. {
  3533. $page = $this->input->post('page',true);
  3534. $perpage = $this->input->post('perpage',true);
  3535. $timetk = $this->input->post('timetk',true);
  3536. $timetj = $this->input->post('timetj',true);
  3537. $label = $this->input->post('label',true);
  3538. $oldlabel = $this->input->post('oldlabel',true);
  3539. $timetk = strtotime($timetk);
  3540. $timetj = strtotime($timetj);
  3541. $where = "state=10 ";
  3542. if($timetk && $timetj)
  3543. {
  3544. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3545. }
  3546. if($label)
  3547. {
  3548. $where .= " and label = '$label'";
  3549. }
  3550. if($oldlabel)
  3551. {
  3552. $where .= " and oldlabel = '$oldlabel'";
  3553. }
  3554. //数据排序
  3555. $order_str = "time asc";
  3556. if(empty($page))
  3557. {
  3558. $start = 0;
  3559. $perpage = 1;
  3560. }
  3561. else
  3562. {
  3563. $start = ($page - 1)*$perpage;
  3564. }
  3565. //取得信息列表
  3566. $info_list = $this->whlabel->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
  3567. foreach ($info_list as $key=>$value)
  3568. {
  3569. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
  3570. }
  3571. $total = $this->whlabel->find_count($where);
  3572. $pagenum = ceil($total/$perpage);
  3573. $over = $total-($start+$perpage);
  3574. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3575. echo json_encode($rows);exit;
  3576. }
  3577. $this->_Template('whlabel_change',$this->data);
  3578. }
  3579. //产品标签
  3580. public function _cpbqdc()
  3581. {
  3582. if(isset($_GET['excel']))
  3583. {
  3584. $where = "1=1";
  3585. //数据排序
  3586. $order_str = "id desc";
  3587. if(empty($page))
  3588. {
  3589. $start = 0;
  3590. $perpage = 1;
  3591. }
  3592. else
  3593. {
  3594. $start = ($page - 1)*$perpage;
  3595. }
  3596. $warehouse = $this->input->get('warehouse',true);
  3597. $state = $this->input->get('state',true);
  3598. $timetk = $this->input->get('timetkk',true);
  3599. $timetj = $this->input->get('timetjj',true);
  3600. $timetk = strtotime($timetk);
  3601. $timetj = strtotime($timetj);
  3602. if($warehouse)
  3603. {
  3604. $where .= " and warehouse = '$warehouse'";
  3605. }
  3606. if($state || $state == 0)
  3607. {
  3608. $where .= " and state = '$state'";
  3609. }
  3610. if($timetk && $timetj)
  3611. {
  3612. $where .= " and time > '$timetk' and time < '$timetj'";
  3613. }
  3614. //取得信息列表
  3615. $info_list = $this->whlabel->find_all($where,'*');
  3616. $rows = array();$list = array();
  3617. foreach ($info_list as $key=>$value)
  3618. {
  3619. $rows[$value['time']] = $value;//所有数据sku
  3620. }
  3621. foreach ($rows as $value)
  3622. {
  3623. $warehouse = $this->warehouse->read($value['warehouse']);
  3624. $s = $this->whlabel->find_count($where.' and time = "'.$value['time'].'"');
  3625. $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);
  3626. }
  3627. $title = "产品标签统计表";
  3628. $titlename = "<table border=1>
  3629. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  3630. <tr align='center'>
  3631. <td>仓库</td>
  3632. <td>SKU</td>
  3633. <td>产品</td>
  3634. <td>入库时间</td>
  3635. <td>操作时间</td>
  3636. <td>备注</td>
  3637. <td>数量</td>
  3638. </tr>
  3639. </table>";
  3640. $filename = $title.".xls";
  3641. $tail = "";
  3642. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3643. }
  3644. }
  3645. //进销存导出
  3646. public function _exceljxc()
  3647. {
  3648. $classid = $this->classid->sku();
  3649. $pm = $classid;
  3650. $typeclass = array();
  3651. $tc = $this->typeclass->find_all();
  3652. foreach ($tc as $v)
  3653. {
  3654. $typeclass[$v['id']] = $v;
  3655. }
  3656. $prc = array();
  3657. $purchase = $this->purchase->find_all();
  3658. foreach($purchase as $k=>$v)
  3659. {
  3660. $prc[$v['id']] = $v['title'];
  3661. }
  3662. if(isset($_GET['excel']))
  3663. {
  3664. $where = "sku != 'Preset'";
  3665. //数据排序
  3666. $order_str = "id desc";
  3667. if(empty($page))
  3668. {
  3669. $start = 0;
  3670. $perpage = 1;
  3671. }
  3672. else
  3673. {
  3674. $start = ($page - 1)*$perpage;
  3675. }
  3676. $category = $this->input->get('category',true);
  3677. $warehouse = $this->input->get('warehouse',true);
  3678. $excelid = $this->input->get('sid',true);
  3679. if($category)
  3680. {
  3681. $where .= " and features like '%-$category-%'";
  3682. }
  3683. if($warehouse)
  3684. {
  3685. $where .= " and warehouse = '$warehouse'";
  3686. }
  3687. $xzid = '';
  3688. if($excelid)
  3689. {
  3690. $excelid = explode(',',trim($excelid,','));
  3691. foreach ($excelid as $key=>$value)
  3692. {
  3693. $xzid .= " id = ".$value." or";
  3694. }
  3695. $xzid = " and (".rtrim($xzid,'or').")";;
  3696. }
  3697. //取得信息列表
  3698. /**
  3699. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3700. $rows = array();$list = array();
  3701. foreach ($info_list as $key=>$value)
  3702. {
  3703. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3704. }
  3705. **/
  3706. $wt = array();
  3707. $whlabel_type = $this->whlabel_type->find_all();
  3708. foreach ($whlabel_type as $v)
  3709. {
  3710. $wt[$v['id']] = $v['title'];
  3711. }
  3712. $wh = array();
  3713. $w = $this->warehouse->find_all('1=1','id,title');
  3714. foreach ($w as $v)
  3715. {
  3716. $wh[$v['id']] = $v['title'];
  3717. }
  3718. $list = array();
  3719. $rows = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3720. foreach ($rows as $key=>$value)
  3721. {
  3722. if(isset($wt[$value['type']]))
  3723. {
  3724. $rows[$key]['type'] = $wt[$value['type']];
  3725. }
  3726. else
  3727. {
  3728. $rows[$key]['type'] = '未设置';
  3729. }
  3730. $bm = '03';
  3731. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  3732. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  3733. $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');
  3734. $details = array();
  3735. $cpid = array();
  3736. $cpbz = array();
  3737. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  3738. foreach ($sd as $k=>$v)
  3739. {
  3740. if($v['state'] == 0)
  3741. {
  3742. $c++;
  3743. if($v['cpid'] != 0)
  3744. {
  3745. $cpid[$v['cpid']] = $v['cpid'];
  3746. }
  3747. if($v['cpbz'] != '')
  3748. {
  3749. $cpbz[$v['cpbz']] = $v['cpbz'];
  3750. }
  3751. }
  3752. if($v['state'] != 9)
  3753. {
  3754. $g++;
  3755. }
  3756. if($v['state'] == 1)
  3757. {
  3758. $x++;
  3759. }
  3760. if($v['state'] == 2)
  3761. {
  3762. $t++;
  3763. }
  3764. if($v['state'] == 8)
  3765. {
  3766. $s++;
  3767. }
  3768. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  3769. {
  3770. $q++;
  3771. }
  3772. $details[$v['details']] = $v['details'];
  3773. }
  3774. $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'].'"');
  3775. $rows[$key]['details'] = implode("、",$details);
  3776. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  3777. $number = $value['number'];
  3778. $ftime = time()-15*24*3600;
  3779. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3780. $rows[$key]['number'] = $g;
  3781. $rows[$key]['c'] = $c;
  3782. $rows[$key]['x'] = $x;
  3783. $rows[$key]['t'] = $t;
  3784. $rows[$key]['s'] = $s;
  3785. $rows[$key]['q'] = $q;
  3786. $rows[$key]['z'] = $z;
  3787. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  3788. $features = explode('-',trim($features,'-'));
  3789. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3790. $pm = $classid;
  3791. $jm = $classid;
  3792. foreach($features as $k=>$v)
  3793. {
  3794. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3795. {
  3796. if($typeclass[$v]['bm'] != '')
  3797. {
  3798. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3799. }
  3800. }
  3801. if($v != 0)
  3802. {
  3803. if(!isset($typeclass[$v]))
  3804. {
  3805. continue;
  3806. }
  3807. if(isset($pm[$typeclass[$v]['classid']]))
  3808. {
  3809. if(stripos($typeclass[$v]['zh'],'|') !== false)
  3810. {
  3811. $tz = explode('|',$typeclass[$v]['zh']);
  3812. $pm[$typeclass[$v]['classid']] = $tz[0];
  3813. }
  3814. else
  3815. {
  3816. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3817. }
  3818. }
  3819. if(isset($jm[$typeclass[$v]['classid']]))
  3820. {
  3821. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3822. }
  3823. }
  3824. }
  3825. $jm = array_filter($jm);
  3826. $rows[$key]['bs'] = implode("-",$jm);
  3827. $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3828. $zh = implode(" ",$pm);
  3829. $zh = str_replace('自然色 ','',trim($zh,' '));
  3830. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3831. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3832. $rows[$key]['features'] = $zh;
  3833. }
  3834. $title = "总进销存统计表";
  3835. $titlename = "<table border=1>
  3836. <tr><th colspan='20' align='center'><h3>".$title."<h3></th></tr>
  3837. <tr align='center'>
  3838. <td>仓库</td>
  3839. <td>供应商</td>
  3840. <td>位置</td>
  3841. <td>库存编码</td>
  3842. <td>类目</td>
  3843. <td>SKU</td>
  3844. <td>用友编码</td>
  3845. <td>用友料号</td>
  3846. <td>商品名称</td>
  3847. <td>商品中文</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. </tr>
  3859. </table>";
  3860. $filename = $title.".xls";
  3861. $tail = "";
  3862. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  3863. }
  3864. }
  3865. //入库导出
  3866. public function _excelr()
  3867. {
  3868. if(isset($_GET['excel']))
  3869. {
  3870. $category = $this->input->get('category',true);
  3871. $size = $this->input->get('size',true);
  3872. $grade = $this->input->get('grade',true);
  3873. $color = $this->input->get('color',true);
  3874. $lowe = $this->input->get('lowe',true);
  3875. $sku = $this->input->get('sku',true);
  3876. $warehouse = $this->input->get('warehouse',true);
  3877. $purchase = $this->input->get('purchase',true);
  3878. $ktime = $this->input->get('ktime',true);
  3879. $jtime = $this->input->get('jtime',true);
  3880. $ktime = strtotime($ktime);
  3881. $jtime = strtotime($jtime);
  3882. $where = "1=1";$gj = "";$ck = "";
  3883. if($category)
  3884. {
  3885. $where .= " and features like '%-$category-%'";
  3886. }
  3887. if($size)
  3888. {
  3889. $where .= " and features like '%-$size-%'";
  3890. }
  3891. if($grade)
  3892. {
  3893. $where .= " and features like '%-$grade-%'";
  3894. }
  3895. if($color)
  3896. {
  3897. $where .= " and features like '%-$color-%'";
  3898. }
  3899. if($lowe)
  3900. {
  3901. $where .= " and features like '%-$lowe-%'";
  3902. }
  3903. if($warehouse)
  3904. {
  3905. $where .= " and warehouse = '$warehouse'";
  3906. }
  3907. if($purchase)
  3908. {
  3909. $where .= " and purchase = '$purchase'";
  3910. }
  3911. if($sku)
  3912. {
  3913. $where .= " and sku = '$sku'";
  3914. }
  3915. if($ktime && $jtime)
  3916. {
  3917. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3918. }
  3919. //数据排序
  3920. $order_str = "id desc";
  3921. if(empty($page))
  3922. {
  3923. $start = 0;
  3924. $perpage = 1;
  3925. }
  3926. else
  3927. {
  3928. $start = ($page - 1)*$perpage;
  3929. }
  3930. $list = array();
  3931. $rows = $this->whlabel->find_pc($where,'enter,sku,warehouse','*',$order_str);
  3932. foreach ($rows as $value)
  3933. {
  3934. $ck = $this->warehouse->read($value['warehouse']);
  3935. $warehouse = $ck['title'];
  3936. $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
  3937. $retreatwarehouse = $tkck['title'];
  3938. $gy = $this->purchase->read($value['purchase']);
  3939. $purchase = $gy['title'];
  3940. $g = $this->whlabel->find_count($where.' and enter = "'.$value['enter'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'"');
  3941. $list[] = array('warehouse'=>$warehouse,'sku'=>$value['sku'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
  3942. }
  3943. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
  3944. $titlename = "<table border=1>
  3945. <tr><th colspan='5' align='center'><h3>".$title."<h3></th></tr>
  3946. <tr align='center'>
  3947. <td>仓库</td>
  3948. <td>SKU</td>
  3949. <td>产品</td>
  3950. <td>时间</td>
  3951. <td>数量</td>
  3952. </tr>
  3953. </table>";
  3954. $filename = $title.".xls";
  3955. $tail = "";
  3956. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3957. }
  3958. }
  3959. //出库、退库导出
  3960. public function _excelct()
  3961. {
  3962. $classid = $this->classid->sku();
  3963. $pm = $classid;
  3964. $typeclass = array();
  3965. $tc = $this->typeclass->find_all();
  3966. foreach ($tc as $v)
  3967. {
  3968. $typeclass[$v['id']] = $v;
  3969. }
  3970. $prc = array();
  3971. $purchase = $this->purchase->find_all();
  3972. foreach($purchase as $k=>$v)
  3973. {
  3974. $prc[$v['id']] = $v['title'];
  3975. }
  3976. if(isset($_GET['excel']))
  3977. {
  3978. $wh = array();
  3979. $w = $this->warehouse->find_all('1=1','id,title');
  3980. foreach ($w as $v)
  3981. {
  3982. $wh[$v['id']] = $v['title'];
  3983. }
  3984. $type = $this->input->get('excel',true);
  3985. $category = $this->input->get('category',true);
  3986. $size = $this->input->get('size',true);
  3987. $grade = $this->input->get('grade',true);
  3988. $color = $this->input->get('color',true);
  3989. $lowe = $this->input->get('lowe',true);
  3990. $sku = $this->input->get('sku',true);
  3991. $warehouse = $this->input->get('warehouse',true);
  3992. $lacetype = $this->input->get('lacetype',true);
  3993. $lacecolor = $this->input->get('lacecolor',true);
  3994. $density = $this->input->get('density',true);
  3995. $haircap = $this->input->get('haircap',true);
  3996. $purchase = $this->input->get('purchase',true);
  3997. $title = $this->input->get('title',true);
  3998. $state = $this->input->get('state',true);
  3999. $sid = $this->input->get('sid',true);
  4000. $ktime = $this->input->get('ktime',true);
  4001. $jtime = $this->input->get('jtime',true);
  4002. $ktime = strtotime($ktime);
  4003. $jtime = strtotime($jtime);
  4004. $where = "1=1";$gj = "";$ck = "";
  4005. if($category)
  4006. {
  4007. $where .= " and features like '%-$category-%'";
  4008. }
  4009. if($size)
  4010. {
  4011. $where .= " and features like '%-$size-%'";
  4012. }
  4013. if($grade)
  4014. {
  4015. $where .= " and features like '%-$grade-%'";
  4016. }
  4017. if($color)
  4018. {
  4019. $where .= " and features like '%-$color-%'";
  4020. }
  4021. if($lowe)
  4022. {
  4023. $where .= " and features like '%-$lowe-%'";
  4024. }
  4025. if($warehouse)
  4026. {
  4027. $where .= " and warehouse = '$warehouse'";
  4028. }
  4029. if($purchase)
  4030. {
  4031. $where .= " and purchase = '$purchase'";
  4032. }
  4033. if($state)
  4034. {
  4035. $where .= " and state = '$state'";
  4036. }
  4037. if($lacetype)
  4038. {
  4039. $where .= " and features like '%-$lacetype-%'";
  4040. }
  4041. if($lacecolor)
  4042. {
  4043. $where .= " and features like '%-$lacecolor-%'";
  4044. }
  4045. if($density)
  4046. {
  4047. $where .= " and features like '%-$density-%'";
  4048. }
  4049. if($haircap)
  4050. {
  4051. $where .= " and features like '%-$haircap-%'";
  4052. }
  4053. if($title)
  4054. {
  4055. $title = trim($title,' ');
  4056. $title = trim($title,' ');
  4057. $where .= " and title like '%$title%'";
  4058. }
  4059. if($sku)
  4060. {
  4061. $sku = trim($sku,' ');
  4062. $sku = trim($sku,' ');
  4063. $where .= " and sku like '%$sku%'";
  4064. }
  4065. if($ktime && $jtime)
  4066. {
  4067. if($type == 1)
  4068. {
  4069. $tl = '出库';
  4070. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4071. }
  4072. else if($type == 2)
  4073. {
  4074. $tl = '退库';
  4075. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4076. }
  4077. else if($type == 3)
  4078. {
  4079. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4080. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4081. }
  4082. else if($type == 4)
  4083. {
  4084. $tl = '出库+零售';
  4085. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4086. }
  4087. else if($type == 5)
  4088. {
  4089. $tl = '零售';
  4090. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4091. }
  4092. }
  4093. $sidwhere = '';
  4094. if($sid)
  4095. {
  4096. $sd = "";
  4097. $s = explode(',',trim($sid,','));
  4098. foreach ($s as $value)
  4099. {
  4100. $sd .= " id = ".$value." or";
  4101. }
  4102. $sidwhere = " and (".rtrim($sd,'or').")";
  4103. }
  4104. //数据排序
  4105. $order_str = "time desc";
  4106. if(empty($page))
  4107. {
  4108. $start = 0;
  4109. $perpage = 1;
  4110. }
  4111. else
  4112. {
  4113. $start = ($page - 1)*$perpage;
  4114. }
  4115. //取得信息列表
  4116. if($type != 3 && $type != 5)
  4117. {
  4118. if($type == 1 || $type == 4)
  4119. {
  4120. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk',$order_str);
  4121. foreach ($info_list as $key=>$value)
  4122. {
  4123. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4124. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4125. $warehouse = $this->warehouse->read($value['warehouse']);
  4126. $info_list[$key]['warehouse'] = $warehouse['title'];
  4127. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4128. $features = explode('-',trim($features,'-'));
  4129. $pm = $classid;
  4130. foreach($features as $k=>$v)
  4131. {
  4132. if($v != 0)
  4133. {
  4134. if(!isset($typeclass[$v]))
  4135. {
  4136. continue;
  4137. }
  4138. if(isset($pm[$typeclass[$v]['classid']]))
  4139. {
  4140. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4141. {
  4142. $tz = explode('|',$typeclass[$v]['zh']);
  4143. $pm[$typeclass[$v]['classid']] = $tz[0];
  4144. }
  4145. else
  4146. {
  4147. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4148. }
  4149. }
  4150. }
  4151. }
  4152. $zh = implode(" ",$pm);
  4153. $zh = str_replace('自然色 ','',trim($zh,' '));
  4154. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4155. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4156. $info_list[$key]['features'] = $zh;
  4157. }
  4158. }
  4159. else
  4160. {
  4161. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat',$order_str);
  4162. foreach ($info_list as $key=>$value)
  4163. {
  4164. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4165. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
  4166. $warehouse = $this->warehouse->read($value['warehouse']);
  4167. $info_list[$key]['warehouse'] = $warehouse['title'];
  4168. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4169. $features = explode('-',trim($features,'-'));
  4170. $pm = $classid;
  4171. foreach($features as $k=>$v)
  4172. {
  4173. if($v != 0)
  4174. {
  4175. if(!isset($typeclass[$v]))
  4176. {
  4177. continue;
  4178. }
  4179. if(isset($pm[$typeclass[$v]['classid']]))
  4180. {
  4181. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4182. {
  4183. $tz = explode('|',$typeclass[$v]['zh']);
  4184. $pm[$typeclass[$v]['classid']] = $tz[0];
  4185. }
  4186. else
  4187. {
  4188. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4189. }
  4190. }
  4191. }
  4192. }
  4193. $zh = implode(" ",$pm);
  4194. $zh = str_replace('自然色 ','',trim($zh,' '));
  4195. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4196. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4197. $info_list[$key]['features'] = $zh;
  4198. }
  4199. }
  4200. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4201. $titlename = "<table border=1>
  4202. <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
  4203. <tr align='center'>
  4204. <td>仓库</td>
  4205. <td>供应商</td>
  4206. <td>SKU</td>
  4207. <td>商品名称</td>
  4208. <td>商品中文</td>
  4209. <td>标签</td>
  4210. <td>订单号</td>
  4211. <td>运单号</td>
  4212. <td>".$tl."时间(中国时间)</td>
  4213. </tr>
  4214. </table>";
  4215. $filename = $title.".xls";
  4216. $tail = "";
  4217. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4218. }
  4219. else if($type == 5)
  4220. {
  4221. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,outk',$order_str);
  4222. foreach ($info_list as $key=>$value)
  4223. {
  4224. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4225. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4226. $warehouse = $this->warehouse->read($value['warehouse']);
  4227. $info_list[$key]['warehouse'] = $warehouse['title'];
  4228. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4229. $features = explode('-',trim($features,'-'));
  4230. $pm = $classid;
  4231. foreach($features as $k=>$v)
  4232. {
  4233. if($v != 0)
  4234. {
  4235. if(!isset($typeclass[$v]))
  4236. {
  4237. continue;
  4238. }
  4239. if(isset($pm[$typeclass[$v]['classid']]))
  4240. {
  4241. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4242. {
  4243. $tz = explode('|',$typeclass[$v]['zh']);
  4244. $pm[$typeclass[$v]['classid']] = $tz[0];
  4245. }
  4246. else
  4247. {
  4248. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4249. }
  4250. }
  4251. }
  4252. }
  4253. $zh = implode(" ",$pm);
  4254. $zh = str_replace('自然色 ','',trim($zh,' '));
  4255. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4256. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4257. $info_list[$key]['features'] = $zh;
  4258. }
  4259. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4260. $titlename = "<table border=1>
  4261. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  4262. <tr align='center'>
  4263. <td>仓库</td>
  4264. <td>供应商</td>
  4265. <td>SKU</td>
  4266. <td>商品名称</td>
  4267. <td>商品中文</td>
  4268. <td>标签</td>
  4269. <td>".$tl."时间(中国时间)</td>
  4270. </tr>
  4271. </table>";
  4272. $filename = $title.".xls";
  4273. $tail = "";
  4274. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4275. }
  4276. else
  4277. {
  4278. /**
  4279. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4280. $rows = array();$list = array();
  4281. foreach ($info_list as $key=>$value)
  4282. {
  4283. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4284. }
  4285. **/
  4286. $wh = array();
  4287. $w = $this->warehouse->find_all('1=1','id,title');
  4288. foreach ($w as $v)
  4289. {
  4290. $wh[$v['id']] = $v['title'];
  4291. }
  4292. $wt = array();
  4293. $whlabel_type = $this->whlabel_type->find_all();
  4294. foreach ($whlabel_type as $v)
  4295. {
  4296. $wt[$v['id']] = $v['title'];
  4297. }
  4298. $classid = $this->classid->sku();
  4299. $list = array();
  4300. $rows = $this->whlabel->find_pc($where.$sidwhere,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4301. foreach ($rows as $key=>$value)
  4302. {
  4303. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4304. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4305. $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');
  4306. $details = array();
  4307. $cpid = array();
  4308. $cpbz = array();
  4309. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  4310. foreach ($sd as $k=>$v)
  4311. {
  4312. if($v['state'] == 0)
  4313. {
  4314. $c++;
  4315. }
  4316. if($v['state'] != 9)
  4317. {
  4318. $g++;
  4319. }
  4320. if($v['outk'] > 1)
  4321. {
  4322. $x++;
  4323. }
  4324. if($v['retreat'] > 0)
  4325. {
  4326. $t++;
  4327. }
  4328. if($v['state'] == 8)
  4329. {
  4330. $s++;
  4331. }
  4332. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  4333. {
  4334. $q++;
  4335. }
  4336. $details[$v['details']] = $v['details'];
  4337. if($v['cpid'] != 0)
  4338. {
  4339. $cpid[$v['cpid']] = $v['cpid'];
  4340. }
  4341. if($v['cpbz'] != '')
  4342. {
  4343. $cpbz[$v['cpbz']] = $v['cpbz'];
  4344. }
  4345. }
  4346. if(isset($wt[$value['type']]))
  4347. {
  4348. $rows[$key]['type'] = $wt[$value['type']];
  4349. }
  4350. else
  4351. {
  4352. $rows[$key]['type'] = '未设置';
  4353. }
  4354. $rows[$key]['details'] = implode("、",$details);
  4355. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4356. $ftime = time()-15*24*3600;
  4357. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4358. $rows[$key]['cpbz'] = ($cpbz)?implode(" ",$cpbz):'';
  4359. $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);
  4360. $rows[$key]['c'] = $c;
  4361. $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);
  4362. $rows[$key]['t'] = $t;
  4363. $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'].'"');
  4364. $rows[$key]['z'] = $z;
  4365. $jm = $classid;
  4366. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4367. $features = explode('-',trim($features,'-'));
  4368. $pm = $classid;
  4369. foreach($features as $k=>$v)
  4370. {
  4371. if($v != 0)
  4372. {
  4373. if(!isset($typeclass[$v]))
  4374. {
  4375. continue;
  4376. }
  4377. if(isset($pm[$typeclass[$v]['classid']]))
  4378. {
  4379. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4380. {
  4381. $tz = explode('|',$typeclass[$v]['zh']);
  4382. $pm[$typeclass[$v]['classid']] = $tz[0];
  4383. }
  4384. else
  4385. {
  4386. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4387. }
  4388. if(isset($jm[$typeclass[$v]['classid']]))
  4389. {
  4390. if($typeclass[$v]['jm'])
  4391. {
  4392. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4393. }
  4394. }
  4395. }
  4396. }
  4397. }
  4398. $zh = implode(" ",$pm);
  4399. $zh = str_replace('自然色 ','',trim($zh,' '));
  4400. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4401. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4402. $rows[$key]['features'] = $zh;
  4403. $jm = array_filter($jm);//去除空值
  4404. $jm = implode("-",$jm);
  4405. $rows[$key]['jm'] = $jm;
  4406. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4407. }
  4408. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
  4409. $titlename = "<table border=1>
  4410. <tr><th colspan='17' align='center'><h3>".$title."<h3></th></tr>
  4411. <tr align='center'>
  4412. <td>仓库</td>
  4413. <td>供应商</td>
  4414. <td>位置</td>
  4415. <td>库存编码</td>
  4416. <td>SKU</td>
  4417. <td>商品名称</td>
  4418. <td>商品中文</td>
  4419. <td>产品备注</td>
  4420. <td>说明</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. </tr>
  4430. </table>";
  4431. $filename = $title.".xls";
  4432. $tail = "";
  4433. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  4434. }
  4435. }
  4436. }
  4437. //出库+入库数据整合
  4438. public function _excelcr()
  4439. {
  4440. if(isset($_GET['excel']))
  4441. {
  4442. $type = $this->input->get('excel',true);
  4443. $category = $this->input->get('category',true);
  4444. $size = $this->input->get('size',true);
  4445. $grade = $this->input->get('grade',true);
  4446. $color = $this->input->get('color',true);
  4447. $lowe = $this->input->get('lowe',true);
  4448. $sku = $this->input->get('sku',true);
  4449. $warehouse = $this->input->get('warehouse',true);
  4450. $purchase = $this->input->get('purchase',true);
  4451. $state = $this->input->get('state',true);
  4452. $sid = $this->input->get('sid',true);
  4453. $ktime = $this->input->get('ktime',true);
  4454. $jtime = $this->input->get('jtime',true);
  4455. $ktime = strtotime($ktime);
  4456. $jtime = strtotime($jtime);
  4457. $where = "1=1";$gj = "";$ck = "";
  4458. if($category)
  4459. {
  4460. $where .= " and features like '%-$category-%'";
  4461. }
  4462. if($size)
  4463. {
  4464. $where .= " and features like '%-$size-%'";
  4465. }
  4466. if($grade)
  4467. {
  4468. $where .= " and features like '%-$grade-%'";
  4469. }
  4470. if($color)
  4471. {
  4472. $where .= " and features like '%-$color-%'";
  4473. }
  4474. if($lowe)
  4475. {
  4476. $where .= " and features like '%-$lowe-%'";
  4477. }
  4478. if($warehouse)
  4479. {
  4480. $where .= " and warehouse = '$warehouse'";
  4481. }
  4482. if($purchase)
  4483. {
  4484. $where .= " and purchase = '$purchase'";
  4485. }
  4486. if($state)
  4487. {
  4488. $where .= " and state = '$state'";
  4489. }
  4490. if($sku)
  4491. {
  4492. $where .= " and sku like '%$sku%'";
  4493. }
  4494. if($ktime && $jtime)
  4495. {
  4496. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4497. }
  4498. $sidwhere = '';
  4499. if($sid)
  4500. {
  4501. $sd = "";
  4502. $s = explode(',',trim($sid,','));
  4503. foreach ($s as $value)
  4504. {
  4505. $sd .= " id = ".$value." or";
  4506. }
  4507. $sidwhere .= " and (".rtrim($sd,'or').")";
  4508. }
  4509. //取得信息列表
  4510. $timeread = $ktime;
  4511. $timenum = ceil(($jtime - $ktime) / (24*3600));
  4512. $timelist = array();
  4513. for($i=0;$i<$timenum;$i++)
  4514. {
  4515. $timeread = ($i>0)?$ktime+$i*24*3600:$ktime;
  4516. $timelist[date('Y-m-d',$timeread)] = array('c'=>0,'r'=>0);
  4517. }
  4518. $info_list = $this->whlabel->find_all($where.$sidwhere,'outk,enter,sku,state');
  4519. //echo "<pre>";
  4520. //print_r($info_list);
  4521. //exit();
  4522. $rows = array();$list = array();
  4523. foreach ($info_list as $key=>$value)
  4524. {
  4525. $thistime = $timelist;
  4526. if(isset($rows[strtolower($value['sku'])]))
  4527. {
  4528. if($value['outk'] > $ktime && $value['state'] < $jtime)
  4529. {
  4530. $rows[strtolower($value['sku'])][date('Y-m-d',$value['outk'])]['c'] += 1;
  4531. }
  4532. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4533. {
  4534. $rows[strtolower($value['sku'])][date('Y-m-d',$value['enter'])]['r'] += 1;
  4535. }
  4536. }
  4537. else
  4538. {
  4539. if($value['outk'] > $ktime && $value['outk'] < $jtime)
  4540. {
  4541. $thistime[date('Y-m-d',$value['outk'])]['c'] += 1;
  4542. }
  4543. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4544. {
  4545. $thistime[date('Y-m-d',$value['enter'])]['r'] += 1;
  4546. }
  4547. $rows[strtolower($value['sku'])] = $thistime;
  4548. }
  4549. }
  4550. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4551. <head>
  4552. <!--[if gte mso 9]><xml>
  4553. <x:ExcelWorkbook>
  4554. <x:ExcelWorksheets>
  4555. <x:ExcelWorksheet>
  4556. <x:Name>EXCEL</x:Name>
  4557. <x:WorksheetOptions>
  4558. <x:Print>
  4559. <x:ValidPrinterInfo />
  4560. </x:Print>
  4561. </x:WorksheetOptions>
  4562. </x:ExcelWorksheet>
  4563. </x:ExcelWorksheets>
  4564. </x:ExcelWorkbook>
  4565. </xml>
  4566. <![endif]-->
  4567. </head><body>";
  4568. $str .= "<table border=1><tr><td>SKU</td>";
  4569. foreach ($timelist as $k=>$v)
  4570. {
  4571. $str .="<td>".$k."出库</td>";
  4572. $str .="<td>".$k."入库</td>";
  4573. }
  4574. $str .= "</tr></table>";
  4575. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4576. foreach ($rows as $key=>$val)
  4577. {
  4578. $str .= "<tr><td>".strtoupper($key)."</td>";
  4579. foreach ($val as $k=>$v)
  4580. {
  4581. $str .= "<td>".$val[$k]['c']."</td>";
  4582. if($val[$k]['r'] > 0)
  4583. {
  4584. $str .= "<td style='color:#f00'>-".$val[$k]['r']."</td>";
  4585. }
  4586. else
  4587. {
  4588. $str .= "<td>".$val[$k]['r']."</td>";
  4589. }
  4590. }
  4591. $str .= "</tr>";
  4592. }
  4593. $str .= "</table>";
  4594. $str .= "</body></html>";
  4595. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  4596. header( "Content-type: application/octet-stream" );
  4597. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  4598. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  4599. header( "Pragma: no-cache" );
  4600. header( "Expires: 0" );
  4601. exit($str);
  4602. }
  4603. }
  4604. //数量调整模板导出
  4605. public function _presetout()
  4606. {
  4607. if(isset($_GET['excel']))
  4608. {
  4609. $where = "sku != 'Preset' and purchase != 0";
  4610. //数据排序
  4611. $order_str = "id desc";
  4612. if(empty($page))
  4613. {
  4614. $start = 0;
  4615. $perpage = 1;
  4616. }
  4617. else
  4618. {
  4619. $start = ($page - 1)*$perpage;
  4620. }
  4621. //取得信息列表
  4622. $info_list = $this->whlabel->find_pc($where,'warehouse,purchase,sku','*','id desc',0,1);
  4623. $rows = array();$list = array();
  4624. foreach ($info_list as $value)
  4625. {
  4626. $warehouse = $this->warehouse->read($value['warehouse']);
  4627. $number = $value['number'];$ftime = time()-15*24*3600;
  4628. $purchase = $this->purchase->read($value['purchase']);
  4629. $list[] = array($warehouse['title'],$purchase['bm'],$value['sku'],'0','','0','','');
  4630. }
  4631. $title = "库存模板";
  4632. $titlename = "<table border=1>
  4633. <tr align='center'>
  4634. <td>仓库</td>
  4635. <td>供应商编码</td>
  4636. <td>SKU</td>
  4637. <td>增减数量(正数或负数)</td>
  4638. <td>增减备注</td>
  4639. <td>扣减方式:0减少库存1删除库存</td>
  4640. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4641. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4642. </tr>
  4643. </table>";
  4644. $filename = $title.".xls";
  4645. $tail = "";
  4646. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4647. }
  4648. }
  4649. //数量调整模板导入
  4650. public function _presetedit()
  4651. {
  4652. $dir = '/data/excel/'.date('Ymd',time()).'/';
  4653. $config['upload_path'] = '.'.$dir ;
  4654. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  4655. $config['allowed_types'] = 'xls|xlsx|csv';
  4656. $config['max_size'] = 10240;
  4657. $this->load->library('upload', $config);
  4658. $this->upload->initialize($config);
  4659. if ($this->upload->do_upload('userfile'))
  4660. {
  4661. $full_path = $dir.$this->upload->data('file_name');
  4662. $fileName = '.' . $full_path;
  4663. if (!file_exists($fileName))
  4664. {
  4665. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  4666. }
  4667. else
  4668. {
  4669. require_once "./data/excel/PHPExcel/IOFactory.php";
  4670. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  4671. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  4672. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  4673. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  4674. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  4675. ++$column;//如果列数大于26行
  4676. $list = array();
  4677. for ($i = 2; $i <= $row; $i++) // 行数循环
  4678. {
  4679. $data = array();
  4680. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4681. {
  4682. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4683. }
  4684. $list[] = $data;
  4685. }
  4686. }
  4687. $i = 0;$j = 0;$ed = array();
  4688. foreach ($list as $key=>$value)
  4689. {
  4690. $time = time();
  4691. if($value['0'] == "")
  4692. {
  4693. continue;
  4694. }
  4695. $warehouse = $this->warehouse->get_title($value['0']);
  4696. $purchase = $this->purchase->get_bm($value['1']);
  4697. $sku = $value['2'];
  4698. $num = $value['3'];//调整数量
  4699. $text = $value['4'];//扣减说明
  4700. $type = $value['5'];//调整方式0扣减1删除
  4701. $rktype = $value['6']!=''?$value['6']:0;//增加库存
  4702. $cktype = $value['7']!=''?$value['7']:0;//减少库存
  4703. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  4704. if(!$purchase)//如果没有这个SKU
  4705. {
  4706. $ed[] = array($purchase.'-不存在此供应商编码');
  4707. $j++;
  4708. continue;
  4709. }
  4710. if(!$d)//如果没有这个SKU
  4711. {
  4712. $ed[] = array($sku.'-库存中不存在此SKU');
  4713. $j++;
  4714. continue;
  4715. }
  4716. if(!isset($warehouse['id']))
  4717. {
  4718. $ed[] = array($sku.'-仓库名错误!');
  4719. $j++;
  4720. continue;
  4721. }
  4722. if($type != '0' && $type != '1')
  4723. {
  4724. $ed[] = array($sku.'-扣减方式填写错误!');
  4725. $j++;
  4726. continue;
  4727. }
  4728. if($num < 0)//扣减库存
  4729. {
  4730. if($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == '')))
  4731. {
  4732. $ed[] = array($sku.'-扣减必须填写扣减类型,非类型1必须填写备注');
  4733. $j++;
  4734. continue;
  4735. }
  4736. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and zd = "" and state = 0');
  4737. if(count($data) < abs($num))
  4738. {
  4739. $ed[] = array($sku.'-扣减数量大于库存剩余数量!');
  4740. $j++;
  4741. continue;
  4742. }
  4743. if($type == 0)//如果扣减方式为 扣减库存
  4744. {
  4745. for($i=0;$i<abs($num);$i++)
  4746. {
  4747. $this->whlabel->save(array('state'=>8,'textout'=>$text,'deltime'=>$time,'cktype'=>$cktype,'time'=>$time,'outk'=>$time),$data[$i]['id']);
  4748. }
  4749. }
  4750. else if($type == 1)
  4751. {
  4752. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  4753. if(count($zt) > 0)
  4754. {
  4755. $ed[] = array($sku.'-有在途库存无法删除!');
  4756. $j++;
  4757. continue;
  4758. }
  4759. for($i=0;$i<abs($num);$i++)
  4760. {
  4761. $this->whlabel->remove($data[$i]['id']);
  4762. }
  4763. }
  4764. }
  4765. else if($num > 0)//增加库存
  4766. {
  4767. if($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == '')))
  4768. {
  4769. $ed[] = array($sku.'-增加必须填写增加类型,非类型1必须填写备注');
  4770. $j++;
  4771. continue;
  4772. }
  4773. $post['sku'] = $d['sku'];
  4774. $post['shop'] = $d['shop'];
  4775. $post['warehouse'] = $warehouse['id'];
  4776. $post['purchase'] = $purchase['id'];
  4777. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4778. $post['state'] = 0;
  4779. $post['title'] = $d['title'];
  4780. $post['number'] = $d['number'];
  4781. $post['features'] = $d['features'];
  4782. $post['enter'] = $time;
  4783. $post['time'] = $time;//操作时间
  4784. $post['rktype'] = $rktype;
  4785. for($i=0;$i<$num;$i++)
  4786. {
  4787. $post['label'] = time().rand(100,999).$i;
  4788. $this->whlabel->insert($post);
  4789. }
  4790. }
  4791. sleep(1);//防止入库时间一样,需要延迟1秒
  4792. }
  4793. if($j > 0)
  4794. {
  4795. $tt = date('Ymd',time());
  4796. $title = '库存导入错误信息-'.$tt;
  4797. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4798. $tail = "\n";
  4799. $filename = $title.".xls";
  4800. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  4801. $dir = '/data/excel/'.$time.'/';
  4802. $file_name = 'error_'.$time.rand(1000,9999);
  4803. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  4804. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  4805. fwrite($myfile,$ecl);
  4806. fclose($myfile);
  4807. $error = $dir.$file_name.'.xls';
  4808. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  4809. }
  4810. else
  4811. {
  4812. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  4813. }
  4814. }
  4815. }
  4816. //笛卡儿积
  4817. function cp($ps,$sets,$list)
  4818. {
  4819. $result = array();$j=0;
  4820. for($i=0,$count=count($sets); $i<$count-1; $i++)
  4821. {
  4822. if($i==0)
  4823. {
  4824. $result = $sets[$i];
  4825. }
  4826. $tmp = array();
  4827. foreach($result as $res)
  4828. {
  4829. foreach($sets[$i+1] as $set)
  4830. {
  4831. $tmp[] = $res.','.$set;
  4832. }
  4833. }
  4834. $result = $tmp;
  4835. }
  4836. $this->db->trans_begin();
  4837. foreach ($result as $v)
  4838. {
  4839. $post = array();$title = "";$num="";
  4840. $data = explode(',',$v);
  4841. for($i=0;$i<count($list); $i++)
  4842. {
  4843. $post[$list[$i]] = $data[$i];
  4844. $typeclass = $this->typeclass->read($data[$i]);
  4845. $title = $title.$typeclass['title']." ";
  4846. if($data[$i] != 0)
  4847. {
  4848. $num .=$data[$i];//所有数据ID拼接
  4849. }
  4850. }
  4851. foreach ($ps as $kp=>$vp)
  4852. {
  4853. $post[$kp] = $vp;
  4854. }
  4855. $post['number'] = $num;
  4856. $info_list = $this->whlabel->get_number($num);//查询whlabel是否存在此拼接的数据ID
  4857. if($info_list)
  4858. {
  4859. $j++;
  4860. }
  4861. else
  4862. {
  4863. $skunum = $this->whlabel->find_count();
  4864. $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
  4865. $post['title'] = rtrim($title,' ');
  4866. $this->whlabel->insert($post);
  4867. }
  4868. }
  4869. if ($this->db->trans_status() === FALSE)
  4870. {
  4871. $this->db->trans_commit();
  4872. return NULL;
  4873. }
  4874. else
  4875. {
  4876. $this->db->trans_commit();
  4877. return $j;
  4878. }
  4879. }
  4880. public function _kj($arg_array)
  4881. {
  4882. if(isset($_POST['sku']))
  4883. {
  4884. $time = time();
  4885. $sku = $this->input->post('sku',true);
  4886. $warehouse = $this->input->post('warehouse',true);
  4887. $num = $this->input->post('num',true);
  4888. $text = $this->input->post('text',true);
  4889. $purchase = $this->input->post('purchase',true);
  4890. $cktype = $this->input->post('cktype',true);
  4891. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4892. if($cktype != 1 && $text == '')
  4893. {
  4894. echo json_encode(array('msg'=>"非销售出库必须填写备注!",'success'=>false));exit;
  4895. }
  4896. if($num > count($order))
  4897. {
  4898. echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
  4899. }
  4900. else
  4901. {
  4902. for($i=0;$i<$num;$i++)
  4903. {
  4904. $this->whlabel->save(array('state'=>8,'cktype'=>$cktype,'textout'=>$text,'deltime'=>$time,'time'=>$time,'outk'=>$time),$order[$i]['id']);
  4905. }
  4906. }
  4907. echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
  4908. }
  4909. $uid = $this->whlabel->read($arg_array[0]);
  4910. $uid['num'] = $this->whlabel->find_count('purchase = "'.$uid['purchase']. '" and sku = "'.$uid['sku']. '" and warehouse = "'.$uid['warehouse']. '" and zd = "" and state = 0');
  4911. $this->data['data'] = $uid ;
  4912. $this->_Template('whlabel_kj',$this->data);
  4913. }
  4914. public function _summary($arg_array)
  4915. {
  4916. $prc = array();
  4917. $purchase = $this->purchase->find_all();
  4918. foreach($purchase as $k=>$v)
  4919. {
  4920. $prc[$v['id']] = $v['title'];
  4921. }
  4922. if(isset($_GET['excel']))
  4923. {
  4924. $ktime = $this->input->get('ktime',true);
  4925. $jtime = $this->input->get('jtime',true);
  4926. $ktime = strtotime($ktime);
  4927. $jtime = strtotime($jtime);
  4928. $where = "1=1";
  4929. if($ktime && $jtime)
  4930. {
  4931. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4932. }
  4933. //数据排序
  4934. $order_str = "time desc";
  4935. if(empty($page))
  4936. {
  4937. $start = 0;
  4938. $perpage = 1;
  4939. }
  4940. else
  4941. {
  4942. $start = ($page - 1)*$perpage;
  4943. }
  4944. //取得信息列表
  4945. $info_list = $this->whlabel->find_pc($where,'sku','warehouse,purchase,details,cpid,sku,title');
  4946. foreach ($info_list as $key=>$value)
  4947. {
  4948. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4949. $warehouse = $this->warehouse->read($value['warehouse']);
  4950. $info_list[$key]['warehouse'] = $warehouse['title'];
  4951. $x = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'"','details,cpid');
  4952. $details = array();
  4953. $cpid = array();
  4954. foreach ($x as $k=>$v)
  4955. {
  4956. if($v['details'] != '')
  4957. {
  4958. $details[$v['details']] = $v['details'];
  4959. }
  4960. if($v['cpid'] != 0)
  4961. {
  4962. $cpid[$v['cpid']] = $v['cpid'];
  4963. }
  4964. }
  4965. $info_list[$key]['details'] = ($details)?implode(" ",$details):'';
  4966. $info_list[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4967. $s = $this->whlabel->find_count('state = 0 and sku = "'.$value['sku'].'"');
  4968. $info_list[$key]['s'] = $s;
  4969. $info_list[$key]['x'] = count($x);
  4970. }
  4971. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
  4972. $titlename = "<table border=1>
  4973. <tr align='center'>
  4974. <td>仓库</td>
  4975. <td>供应商</td>
  4976. <td>出库位置</td>
  4977. <td>出库编码</td>
  4978. <td>SKU</td>
  4979. <td>产品名</td>
  4980. <td>总剩余库存</td>
  4981. <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
  4982. </tr>
  4983. </table>";
  4984. $filename = $title.".xls";
  4985. $tail = "";
  4986. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4987. }
  4988. }
  4989. //usps发货清单
  4990. public function _manifest()
  4991. {
  4992. if(isset($_POST['manifest']))
  4993. {
  4994. $wltext = $this->input->post('wltext',true);
  4995. $time = time()-16*3600;
  4996. $ptime = strtotime(date('Y-m-d',$time));
  4997. $waybill = array();
  4998. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  4999. foreach ($fullorder as $v)
  5000. {
  5001. $waybill[$v['waybill']] = $v['waybill'];
  5002. }
  5003. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  5004. foreach ($fullordersmt as $v)
  5005. {
  5006. $waybill[$v['waybill']] = $v['waybill'];
  5007. }
  5008. $wltext = explode(';',$wltext);
  5009. foreach ($wltext as $v)
  5010. {
  5011. if(isset($waybill[$v]))
  5012. {
  5013. unset($waybill[$v]);
  5014. }
  5015. }
  5016. $data = $this->usps->get_manifest($waybill);
  5017. if(isset($data['Description']))
  5018. {
  5019. echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
  5020. }
  5021. else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
  5022. {
  5023. $bctime = date('Ymd',time());
  5024. $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
  5025. echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
  5026. }
  5027. else
  5028. {
  5029. echo json_encode(array('msg'=>$data,'success'=>false));exit;
  5030. }
  5031. }
  5032. }
  5033. public function _pdf($pdf,$title,$bctime)
  5034. {
  5035. $pdf_path = './data/pdf/'.$bctime.'/';
  5036. $file_base64 = $pdf;
  5037. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5038. $file_base64 = base64_decode($file_base64);
  5039. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  5040. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  5041. return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
  5042. }
  5043. /**
  5044. *
  5045. *
  5046. *
  5047. 进销存占单异常索引
  5048. *
  5049. *
  5050. *
  5051. **/
  5052. public function _abnormal()
  5053. {
  5054. $post = $this->input->post(NULL, TRUE);
  5055. if(isset($post['page']))
  5056. {
  5057. $page = $this->input->post('page',true);
  5058. $perpage = $this->input->post('perpage',true);
  5059. $sku = $this->input->post('sku',true);
  5060. $where = "1=1";
  5061. //数据排序
  5062. $order_str = "id desc";
  5063. if(empty($page))
  5064. {
  5065. $start = 0;
  5066. $perpage = 1;
  5067. }
  5068. else
  5069. {
  5070. $start = ($page - 1)*$perpage;
  5071. }
  5072. //取得信息列表
  5073. $info_list = $this->whlabel->find_all($where,'*');
  5074. $rows = array();$list = array();
  5075. foreach ($info_list as $key=>$value)
  5076. {
  5077. $rows[strtolower($value['sku'])] = $value;//所有数据sku
  5078. }
  5079. foreach ($rows as $value)
  5080. {
  5081. $warehouse = $this->warehouse->read($value['warehouse']);
  5082. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
  5083. $number = $value['number'];$ftime = time()-15*24*3600;
  5084. if($value['shop'] != '')
  5085. {
  5086. $shop = $value['shop'];
  5087. $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');
  5088. $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');
  5089. $order = array_merge($orderdlz,$ordersmt);
  5090. $od = 0;$a = '';$orid = '';
  5091. foreach ($order as $v)
  5092. {
  5093. $or = explode('|',ltrim($v['whlabel'],'|'));
  5094. for($i=0;$i<count($or);$i++)
  5095. {
  5096. $orod = explode('-',$or[$i]);
  5097. if($orod[0] == $number)
  5098. {
  5099. $od += $orod[1];
  5100. }
  5101. }
  5102. $orid .= $v['number'].'-';
  5103. }
  5104. }
  5105. else
  5106. {
  5107. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5108. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5109. $order = array_merge($orderdlz,$ordersmt);
  5110. $od = 0;$a = '';$orid = '';$qt = array();
  5111. foreach ($order as $v)
  5112. {
  5113. $or = explode('|',ltrim($v['whlabel'],'|'));
  5114. for($i=0;$i<count($or);$i++)
  5115. {
  5116. $orod = explode('-',$or[$i]);
  5117. if($orod[0] == $number)
  5118. {
  5119. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
  5120. if($czzs > 0)
  5121. {
  5122. if(isset($qt[$v['shop']]))
  5123. {
  5124. if($qt[$v['shop']] < $orod[1])
  5125. {
  5126. $od += $orod[1];//专属小于单量不计算剩余直接归入通用
  5127. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5128. }
  5129. else
  5130. {
  5131. $qt[$v['shop']] -= $orod[1];
  5132. }
  5133. }
  5134. else
  5135. {
  5136. $qt[$v['shop']] = $czzs;
  5137. }
  5138. }
  5139. else
  5140. {
  5141. $od += $orod[1];
  5142. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5143. }
  5144. }
  5145. }
  5146. }
  5147. }
  5148. $z = $od.'('.$orid.')';//查看订单号
  5149. //$z = $od;
  5150. if($od > $c)
  5151. {
  5152. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
  5153. }
  5154. }
  5155. $listdata = array_slice($list,$start,$perpage);
  5156. $total = count($list);
  5157. $pagenum = ceil($total/$perpage);
  5158. $over = $total-($start+$perpage);
  5159. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5160. echo json_encode($rows);exit;
  5161. }
  5162. $this->_Template('whlabel_abnormal',$this->data);
  5163. }
  5164. /**
  5165. *
  5166. *
  5167. *
  5168. 进销存占单异常索引
  5169. *
  5170. *
  5171. *
  5172. **/
  5173. public function _error()
  5174. {
  5175. $post = $this->input->post(NULL, TRUE);
  5176. if(isset($post['page']))
  5177. {
  5178. $page = $this->input->post('page',true);
  5179. $perpage = $this->input->post('perpage',true);
  5180. $sku = $this->input->post('sku',true);
  5181. $warehouse = $this->input->post('warehouse',true);
  5182. $ktime = $this->input->post('ktime',true);
  5183. $jtime = $this->input->post('jtime',true);
  5184. $ktime = strtotime($ktime);
  5185. $jtime = strtotime($jtime);
  5186. $where = "sku != 'Preset'";
  5187. $gj = '';
  5188. if($sku)
  5189. {
  5190. $where .= " and sku like '%$sku%'";
  5191. }
  5192. else
  5193. {
  5194. if($ktime && $jtime)
  5195. {
  5196. $gj = " and time > '$ktime' and time < '$jtime'";
  5197. }
  5198. }
  5199. if($warehouse)
  5200. {
  5201. $where .= " and warehouse = '$warehouse'";
  5202. }
  5203. //数据排序
  5204. $order_str = "id desc";
  5205. if(empty($page))
  5206. {
  5207. $start = 0;
  5208. $perpage = 1;
  5209. }
  5210. else
  5211. {
  5212. $start = ($page - 1)*$perpage;
  5213. }
  5214. //取得信息列表
  5215. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5216. $rows = array();$list = array();
  5217. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5218. // foreach ($info_list as $value)
  5219. // {
  5220. // $warehouse = $this->warehouse->read($value['warehouse']);
  5221. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5222. // $number = $value['number'];$ftime = time()-15*24*3600;
  5223. // if($c < 1)
  5224. // {
  5225. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5226. // }
  5227. // }
  5228. $warehouse_list = $this->warehouse->find_all();
  5229. $warehouse_list = array_column($warehouse_list,null,'id');
  5230. foreach ($info_list as $value)
  5231. {
  5232. $warehouse = isset($warehouse_list[$value['warehouse']])?$warehouse_list[$value['warehouse']]:[
  5233. 'title'=>"",
  5234. ];
  5235. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5236. $number = $value['number'];$ftime = time()-15*24*3600;
  5237. if($c < 1)
  5238. {
  5239. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5240. }
  5241. }
  5242. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5243. // $query = $this->db->query($sql);
  5244. // $info_list = $query->result_array();
  5245. // $sql_two = "select title,id from crowd_warehouse";
  5246. // $query_two = $this->db->query($sql_two);
  5247. // $warehouse_list = $query_two->result_array();
  5248. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5249. // foreach ($info_list as $value)
  5250. // {
  5251. // if(isset($warehouse_arr[$value['warehouse']])){
  5252. // $warehouse = $warehouse_arr[$value['warehouse']];
  5253. // }else{
  5254. // $warehouse = [
  5255. // 'id'=>0,
  5256. // 'title'=>"异常",
  5257. // ];
  5258. // }
  5259. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5260. // $number = $value['number'];$ftime = time()-15*24*3600;
  5261. // if($c < 1)
  5262. // {
  5263. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5264. // }
  5265. // }
  5266. $listdata = array_slice($list,$start,$perpage);
  5267. $total = count($list);
  5268. $pagenum = ceil($total/$perpage);
  5269. $over = $total-($start+$perpage);
  5270. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5271. echo json_encode($rows);exit;
  5272. }
  5273. if(isset($post['s']))
  5274. {
  5275. $id_arr = $this->input->post('s');
  5276. $id_arr = explode(',',trim($id_arr,','));
  5277. if(!$id_arr)
  5278. {
  5279. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  5280. }
  5281. //循环删除记录
  5282. foreach ($id_arr as $v)
  5283. {
  5284. $dd = $this->whlabel->read($v);
  5285. if(!isset($dd['id']))
  5286. {
  5287. echo json_encode(array('msg'=>$dd['sku'].'已被删除,请刷新页面','success'=>false));exit;
  5288. }
  5289. $zt = $this->whlabeltransport->find_all('sku = "'.$dd['sku'].'" and warehouse = "'.$dd['warehouse'].'" and features = "'.$dd['features'].'" and cz = "0"');
  5290. if(isset($zt[0]))
  5291. {
  5292. echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
  5293. }
  5294. $deldd = $this->whlabel->find_all("sku = '".$dd['sku']."' and warehouse = '".$dd['warehouse']."'");
  5295. foreach ($deldd as $vv)
  5296. {
  5297. $this->whlabel->remove($vv['id']);
  5298. }
  5299. }
  5300. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  5301. }
  5302. $this->_Template('whlabel_error',$this->data);
  5303. }
  5304. public function _errorexcel()
  5305. {
  5306. $post = $this->input->post(NULL, TRUE);
  5307. if(isset($_GET['page']))
  5308. {
  5309. $page = $this->input->get('page',true);
  5310. $perpage = $this->input->get('perpage',true);
  5311. $sku = $this->input->get('sku',true);
  5312. $warehouse = $this->input->get('warehouse',true);
  5313. $ktime = $this->input->get('ktime',true);
  5314. $jtime = $this->input->get('jtime',true);
  5315. $ktime = strtotime($ktime);
  5316. $jtime = strtotime($jtime);
  5317. $where = "sku != 'Preset'";
  5318. $gj = '';
  5319. if($sku)
  5320. {
  5321. $where .= " and sku like '%$sku%'";
  5322. }
  5323. else
  5324. {
  5325. if($ktime && $jtime)
  5326. {
  5327. $gj = " and time > '$ktime' and time < '$jtime'";
  5328. }
  5329. }
  5330. if($warehouse)
  5331. {
  5332. $where .= " and warehouse = '$warehouse'";
  5333. }
  5334. //数据排序
  5335. $order_str = "id desc";
  5336. if(empty($page))
  5337. {
  5338. $start = 0;
  5339. $perpage = 1;
  5340. }
  5341. else
  5342. {
  5343. $start = ($page - 1)*$perpage;
  5344. }
  5345. //取得信息列表
  5346. $rows = array();$list = array();
  5347. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5348. foreach ($info_list as $value)
  5349. {
  5350. $warehouse = $this->warehouse->read($value['warehouse']);
  5351. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5352. $number = $value['number'];$ftime = time()-15*24*3600;
  5353. if($c < 1)
  5354. {
  5355. $list[] = array('warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5356. }
  5357. }
  5358. $title = "0库存汇总";
  5359. $titlename = "<table border=1>
  5360. <tr align='center'>
  5361. <td>仓库</td>
  5362. <td>SKU</td>
  5363. <td>产品</td>
  5364. <td>当前库存</td>
  5365. </tr>
  5366. </table>";
  5367. $filename = $title.".xls";
  5368. $tail = "";
  5369. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5370. }
  5371. }
  5372. /**
  5373. *
  5374. *
  5375. * 占单
  5376. *
  5377. *
  5378. **/
  5379. public function _kcyz()
  5380. {
  5381. $post = $this->input->post(NULL, TRUE);
  5382. if(isset($post['warehouse']))
  5383. {
  5384. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请更新浏览器缓存!','success'=>false)));exit;//不再使用
  5385. $warehouse = $this->input->post('warehouse',true);
  5386. $whlabel = $this->input->post('whlabel',true);
  5387. $id = $this->input->post('id',true);
  5388. $shop = $this->input->post('shop',true);
  5389. $number = $this->input->post('number',true);
  5390. if(!$whlabel || $whlabel == '|')
  5391. {
  5392. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  5393. }
  5394. $pp = explode('|',trim($whlabel,'|'));
  5395. $x = 0;$save = array();
  5396. foreach ($pp as $va)
  5397. {
  5398. $num = explode('-',$va);
  5399. if($number)
  5400. {
  5401. $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 = '')");//通用
  5402. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  5403. }
  5404. else
  5405. {
  5406. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  5407. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  5408. }
  5409. $x++;
  5410. if(count($whlabel)+count($shopwhlabel) < $num[1])
  5411. {
  5412. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  5413. }
  5414. }
  5415. if(isset($save[0]))
  5416. {
  5417. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
  5418. }
  5419. else
  5420. {
  5421. echo json_encode(array('success'=>true));exit;
  5422. }
  5423. }
  5424. }
  5425. public function _db()
  5426. {
  5427. $post = $this->input->post(NULL, TRUE);
  5428. if(isset($post['page']))
  5429. {
  5430. $page = $this->input->post('page',true);
  5431. $perpage = $this->input->post('perpage',true);
  5432. $sku = $this->input->post('sku',true);
  5433. $number = $this->input->post('number',true);
  5434. $warehouse = $this->input->post('warehouse',true);
  5435. $purchase = $this->input->post('purchase',true);
  5436. $orderinfo = $this->input->post('orderinfo',true);
  5437. $waybill = $this->input->post('waybill',true);
  5438. $category = $this->input->post('category',true);
  5439. $size = $this->input->post('size',true);
  5440. $grade = $this->input->post('grade',true);
  5441. $color = $this->input->post('color',true);
  5442. $lowe = $this->input->post('lowe',true);
  5443. $state = $this->input->post('state',true);
  5444. $label = $this->input->post('label',true);
  5445. $timetk = $this->input->post('timetkk',true);
  5446. $timetj = $this->input->post('timetjj',true);
  5447. $timetk = strtotime($timetk);
  5448. $timetj = strtotime($timetj);
  5449. $where = "dbtime > 0";
  5450. if($timetk && $timetj)
  5451. {
  5452. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5453. }
  5454. if($sku)
  5455. {
  5456. $where .= " and sku = '$sku'";
  5457. }
  5458. if($warehouse)
  5459. {
  5460. $where .= " and warehouse = '$warehouse'";
  5461. if($warehouse == 12)
  5462. {
  5463. $w = 'specialstock';
  5464. }
  5465. else
  5466. {
  5467. $w = 'whlabel';
  5468. }
  5469. }
  5470. if($purchase)
  5471. {
  5472. $where .= " and purchase = '$purchase'";
  5473. }
  5474. if($category)
  5475. {
  5476. $where .= " and features like '%-$category-%'";
  5477. }
  5478. if($size)
  5479. {
  5480. $where .= " and features like '%-$size-%'";
  5481. }
  5482. if($grade)
  5483. {
  5484. $where .= " and features like '%-$grade-%'";
  5485. }
  5486. if($color)
  5487. {
  5488. $where .= " and features like '%-$color-%'";
  5489. }
  5490. if($lowe)
  5491. {
  5492. $where .= " and features like '%-$lowe-%'";
  5493. }
  5494. if($state != '')
  5495. {
  5496. $where .= " and state = '$state'";
  5497. }
  5498. //数据排序
  5499. $order_str = "dbtime desc";
  5500. if(empty($page))
  5501. {
  5502. $start = 0;
  5503. $perpage = 1;
  5504. }
  5505. else
  5506. {
  5507. $start = ($page - 1)*$perpage;
  5508. }
  5509. //取得信息列表
  5510. $info_list = $this->$w->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5511. foreach ($info_list as $key=>$value)
  5512. {
  5513. $warehouse = $this->$w->read($value['warehouse']);
  5514. $info_list[$key]['warehouse'] = $warehouse['title'];
  5515. $purchase = $this->purchase->read($value['purchase']);
  5516. $info_list[$key]['purchase'] = $purchase['title'];
  5517. if($value['enter'] != 0)
  5518. {
  5519. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5520. }
  5521. else
  5522. {
  5523. $info_list[$key]['enter'] = "";
  5524. }
  5525. if($value['dbtime'] != 0)
  5526. {
  5527. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5528. }
  5529. else
  5530. {
  5531. $info_list[$key]['dbtime'] = "";
  5532. }
  5533. if($value['state'] == 0)
  5534. {
  5535. $info_list[$key]['state'] = "在库";
  5536. }
  5537. else if($value['state'] == 1)
  5538. {
  5539. $info_list[$key]['state'] = "出库";
  5540. }
  5541. else if($value['state'] == 2)
  5542. {
  5543. $info_list[$key]['state'] = "退库";
  5544. }
  5545. else if($value['state'] == 3)
  5546. {
  5547. $info_list[$key]['state'] = "调拨中";
  5548. }
  5549. else if($value['state'] == 4)
  5550. {
  5551. $info_list[$key]['state'] = "再加工";
  5552. }
  5553. else if($value['state'] == 5)
  5554. {
  5555. $info_list[$key]['state'] = "维修中";
  5556. }
  5557. else if($value['state'] == 6)
  5558. {
  5559. $info_list[$key]['state'] = "盘亏";
  5560. }
  5561. else if($value['state'] == 7)
  5562. {
  5563. $info_list[$key]['state'] = "更换标签";
  5564. }
  5565. else if($value['state'] == 8)
  5566. {
  5567. $info_list[$key]['state'] = "其它";
  5568. }
  5569. else if($value['state'] == 9)
  5570. {
  5571. $info_list[$key]['state'] = "预设";
  5572. }
  5573. }
  5574. $total = $this->whlabel->find_count($where);
  5575. $pagenum = ceil($total/$perpage);
  5576. $over = $total-($start+$perpage);
  5577. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5578. echo json_encode($rows);exit;
  5579. }
  5580. if(isset($post['outsku']))
  5581. {
  5582. $time = time();
  5583. $cz = $this->input->post('cz',true);
  5584. $label = $this->input->post('outsku',true);
  5585. $sl = $this->input->post('sl',true);
  5586. $num = $this->input->post('num',true);
  5587. //$warehouse = $this->input->post('warehouse',true);
  5588. if(!$sl)
  5589. {
  5590. $sl = 1;
  5591. }
  5592. if(!$warehouse)
  5593. {
  5594. echo json_encode(array('msg'=>'请选择调拨到的仓库','success'=>false));exit;
  5595. }
  5596. $dblabel = $this->whlabellabel->get_label($label);
  5597. if($dblabel)
  5598. {
  5599. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '0' and zd = ''");
  5600. if(count($data) < 1)
  5601. {
  5602. echo json_encode(array('msg'=>'没有此产品数据!','success'=>false));exit;
  5603. }
  5604. if(count($data) < $num)
  5605. {
  5606. echo json_encode(array('msg'=>'库存数量少于调拨数量!','success'=>false));exit;
  5607. }
  5608. for($i=0;$i<$sl;$i++)
  5609. {
  5610. $this->whlabel->save(array('state'=>3,'dbtime'=>$dbtime,'dbcontent'=>$data[$i]['warehouse'].'-'.$time.'|','time'=>$time),$data[$i]['id']);
  5611. }
  5612. echo json_encode(array('success'=>true));exit;
  5613. }
  5614. else
  5615. {
  5616. echo json_encode(array('msg'=>'未找到此条码产品!','success'=>false));exit;
  5617. }
  5618. }
  5619. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5620. $this->_Template('whlabel_db',$this->data);
  5621. }
  5622. public function _dbrk()
  5623. {
  5624. $post = $this->input->post(NULL, TRUE);
  5625. if(isset($post['page']))
  5626. {
  5627. $page = $this->input->post('page',true);
  5628. $perpage = $this->input->post('perpage',true);
  5629. $sku = $this->input->post('sku',true);
  5630. $number = $this->input->post('number',true);
  5631. $warehouse = $this->input->post('warehouse',true);
  5632. $purchase = $this->input->post('purchase',true);
  5633. $orderinfo = $this->input->post('orderinfo',true);
  5634. $waybill = $this->input->post('waybill',true);
  5635. $category = $this->input->post('category',true);
  5636. $size = $this->input->post('size',true);
  5637. $grade = $this->input->post('grade',true);
  5638. $color = $this->input->post('color',true);
  5639. $lowe = $this->input->post('lowe',true);
  5640. $state = $this->input->post('state',true);
  5641. $label = $this->input->post('label',true);
  5642. $ctime = $this->input->post('ctime',true);
  5643. $timetk = $this->input->post('timetkk',true);
  5644. $timetj = $this->input->post('timetjj',true);
  5645. $timetk = strtotime($timetk);
  5646. $timetj = strtotime($timetj);
  5647. $where = "dbtime > 0";
  5648. if($timetk && $timetj)
  5649. {
  5650. $where .= " and ".$ctime." > '$timetk' and ".$ctime." < '$timetj'";
  5651. }
  5652. if($sku)
  5653. {
  5654. $where .= " and sku = '$sku'";
  5655. }
  5656. if($warehouse)
  5657. {
  5658. $where .= " and warehouse = '$warehouse'";
  5659. }
  5660. if($purchase)
  5661. {
  5662. $where .= " and purchase = '$purchase'";
  5663. }
  5664. if($category)
  5665. {
  5666. $where .= " and features like '%-$category-%'";
  5667. }
  5668. if($size)
  5669. {
  5670. $where .= " and features like '%-$size-%'";
  5671. }
  5672. if($grade)
  5673. {
  5674. $where .= " and features like '%-$grade-%'";
  5675. }
  5676. if($color)
  5677. {
  5678. $where .= " and features like '%-$color-%'";
  5679. }
  5680. if($lowe)
  5681. {
  5682. $where .= " and features like '%-$lowe-%'";
  5683. }
  5684. if($state != '')
  5685. {
  5686. $where .= " and state = '$state'";
  5687. }
  5688. //数据排序
  5689. $order_str = "dbtime desc";
  5690. if(empty($page))
  5691. {
  5692. $start = 0;
  5693. $perpage = 1;
  5694. }
  5695. else
  5696. {
  5697. $start = ($page - 1)*$perpage;
  5698. }
  5699. //取得信息列表
  5700. $info_list = $this->whlabel->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5701. foreach ($info_list as $key=>$value)
  5702. {
  5703. $warehouse = $this->warehouse->read($value['warehouse']);
  5704. $info_list[$key]['warehouse'] = $warehouse['title'];
  5705. $purchase = $this->purchase->read($value['purchase']);
  5706. $info_list[$key]['purchase'] = $purchase['title'];
  5707. if($value['enter'] != 0)
  5708. {
  5709. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5710. }
  5711. else
  5712. {
  5713. $info_list[$key]['enter'] = "";
  5714. }
  5715. if($value['dbtime'] != 0)
  5716. {
  5717. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5718. }
  5719. else
  5720. {
  5721. $info_list[$key]['dbtime'] = "";
  5722. }
  5723. if($value['state'] == 0)
  5724. {
  5725. $info_list[$key]['state'] = "在库";
  5726. }
  5727. else if($value['state'] == 1)
  5728. {
  5729. $info_list[$key]['state'] = "出库";
  5730. }
  5731. else if($value['state'] == 2)
  5732. {
  5733. $info_list[$key]['state'] = "退库";
  5734. }
  5735. else if($value['state'] == 3)
  5736. {
  5737. $info_list[$key]['state'] = "调拨中";
  5738. }
  5739. else if($value['state'] == 4)
  5740. {
  5741. $info_list[$key]['state'] = "再加工";
  5742. }
  5743. else if($value['state'] == 5)
  5744. {
  5745. $info_list[$key]['state'] = "维修中";
  5746. }
  5747. else if($value['state'] == 6)
  5748. {
  5749. $info_list[$key]['state'] = "盘亏";
  5750. }
  5751. else if($value['state'] == 7)
  5752. {
  5753. $info_list[$key]['state'] = "更换标签";
  5754. }
  5755. else if($value['state'] == 8)
  5756. {
  5757. $info_list[$key]['state'] = "其它";
  5758. }
  5759. else if($value['state'] == 9)
  5760. {
  5761. $info_list[$key]['state'] = "预设";
  5762. }
  5763. }
  5764. $total = $this->whlabel->find_count($where);
  5765. $pagenum = ceil($total/$perpage);
  5766. $over = $total-($start+$perpage);
  5767. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5768. echo json_encode($rows);exit;
  5769. }
  5770. if(isset($post['rsku']))
  5771. {
  5772. $cz = $this->input->post('cz',true);
  5773. $label = $this->input->post('rsku',true);
  5774. $sl = $this->input->post('sl',true);
  5775. $warehouse = $this->input->post('warehouse',true);
  5776. if(!$sl)
  5777. {
  5778. $sl = 1;
  5779. }
  5780. if(!$warehouse)
  5781. {
  5782. echo json_encode(array('msg'=>'请选择入库仓库','success'=>false));exit;
  5783. }
  5784. $dblabel = $this->whlabellabel->get_label($label);
  5785. if($dblabel)
  5786. {
  5787. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '3' and zd = ''");
  5788. if(count($data) < 1)
  5789. {
  5790. echo json_encode(array('msg'=>'没有此SKU调拨数据!','success'=>false));exit;
  5791. }
  5792. if($sl > count($data))
  5793. {
  5794. echo json_encode(array('msg'=>'入库数量大于调拨数量!','success'=>false));exit;
  5795. }
  5796. $time = time();
  5797. for($i=0;$i<$sl;$i++)
  5798. {
  5799. $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']);
  5800. }
  5801. echo json_encode(array('success'=>true));exit;
  5802. }
  5803. else
  5804. {
  5805. echo json_encode(array('msg'=>'没有此条码的库存信息!','success'=>false));exit;
  5806. }
  5807. }
  5808. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5809. $this->_Template('whlabel_dbrk',$this->data);
  5810. }
  5811. public function _whlabelczdc()
  5812. {
  5813. if(isset($_GET['excel']))
  5814. {
  5815. //数据排序
  5816. $order_str = "id desc";
  5817. if(empty($page))
  5818. {
  5819. $start = 0;
  5820. $perpage = 1;
  5821. }
  5822. else
  5823. {
  5824. $start = ($page - 1)*$perpage;
  5825. }
  5826. $state = $this->input->get('state',true);
  5827. $sku = $this->input->get('sku',true);
  5828. $ctime = $this->input->get('ctime',true);
  5829. $category = $this->input->get('category',true);
  5830. $size = $this->input->get('size',true);
  5831. $grade = $this->input->get('grade',true);
  5832. $color = $this->input->get('color',true);
  5833. $lowe = $this->input->get('lowe',true);
  5834. $timetk = $this->input->get('timetkk',true);
  5835. $timetj = $this->input->get('timetjj',true);
  5836. $timetk = strtotime($timetk);
  5837. $timetj = strtotime($timetj);
  5838. $where = "dbtime > 0";
  5839. if($timetk && $timetj)
  5840. {
  5841. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5842. }
  5843. if($category)
  5844. {
  5845. $where .= " and features like '%-$category-%'";
  5846. }
  5847. if($size)
  5848. {
  5849. $where .= " and features like '%-$size-%'";
  5850. }
  5851. if($grade)
  5852. {
  5853. $where .= " and features like '%-$grade-%'";
  5854. }
  5855. if($color)
  5856. {
  5857. $where .= " and features like '%-$color-%'";
  5858. }
  5859. if($lowe)
  5860. {
  5861. $where .= " and features like '%-$lowe-%'";
  5862. }
  5863. //取得信息列表
  5864. $info_list = $this->whlabel->find_all($where,'*');
  5865. $rows = array();$list = array();
  5866. foreach ($info_list as $key=>$value)
  5867. {
  5868. $rows[$value['sku']] = $value;//所有数据sku
  5869. }
  5870. foreach ($rows as $value)
  5871. {
  5872. $warehouse = $this->warehouse->read($value['warehouse']);
  5873. $db = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'"');
  5874. $rk = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and enter > 0');
  5875. if($value['orderinfo'] == 0)
  5876. {
  5877. $info_list[$key]['orderinfo'] = "";
  5878. }
  5879. if($value['waybill'] == 0)
  5880. {
  5881. $info_list[$key]['waybill'] = "";
  5882. }
  5883. if($value['state'] == 0)
  5884. {
  5885. $value['state'] = "在库";
  5886. }
  5887. else if($value['state'] == 3)
  5888. {
  5889. $value['state'] = "调拨中";
  5890. }
  5891. $list[] = array($value['sku'],$value['title'],$db,$rk);
  5892. }
  5893. $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj)."统计表";
  5894. $titlename = "<table border=1>
  5895. <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
  5896. <tr align='center'>
  5897. <td>SKU</td>
  5898. <td>产品</td>
  5899. <td>调拨数量</td>
  5900. <td>入库数量</td>
  5901. </tr>
  5902. </table>";
  5903. $filename = $title.".xls";
  5904. $tail = "";
  5905. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5906. }
  5907. }
  5908. public function _print($arg_array)
  5909. {
  5910. if(isset($_SESSION['api']))
  5911. {
  5912. $user = $this->user->get_api($_SESSION['api']);
  5913. $usp = $user;
  5914. $fgshop = "";$sid = "";$wid="";$wtype="";
  5915. $usersp = explode('|',trim($user['shop'],'|'));
  5916. $userwh = explode('|',trim($user['warehouse'],'|'));
  5917. foreach ($usersp as $value)
  5918. {
  5919. $fgshop .= " shop = ".$value." or";
  5920. $sid .= " id = ".$value." or";
  5921. }
  5922. foreach ($userwh as $value)
  5923. {
  5924. $wid .= " id = ".$value." or";
  5925. $wtype .= " type = ".$value." or";
  5926. }
  5927. }
  5928. $post = $this->input->post(NULL, TRUE);
  5929. if(isset($post['tmsku']))
  5930. {
  5931. $tmsku = $this->input->post('tmsku',true);
  5932. if(is_numeric($tmsku))
  5933. {
  5934. $yyh = $this->whlabellabel->get_label($tmsku);
  5935. }
  5936. else
  5937. {
  5938. $yyh = $this->whlabellabel->get_sku($tmsku);
  5939. }
  5940. if($yyh)
  5941. {
  5942. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  5943. }
  5944. else
  5945. {
  5946. echo json_encode(array('success'=>false));exit;
  5947. }
  5948. }
  5949. $classid = $this->classid->sku();
  5950. $pm = $classid;
  5951. $scsku = $classid;
  5952. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5953. if(isset($post['warehouse']))
  5954. {
  5955. if($post['warehouse'])
  5956. {
  5957. $list = array();$num = "";$title = "";$features = "";
  5958. $order = 0;
  5959. $post['shop'] = '';
  5960. $brand = $this->input->post('brand',true);
  5961. if($brand != '0,')
  5962. {
  5963. $b = $this->brand->read(rtrim($brand,','));
  5964. if($b)
  5965. {
  5966. $post['shop'] = str_replace('|',',',$b['shop']);
  5967. }
  5968. }
  5969. $post['details'] = $this->input->post('details',true);//打印数量
  5970. $xbqnum = $this->input->post('xbqnum',true);
  5971. $post['purchase'] = $this->input->post('purchase',true);
  5972. $post['warehouse'] = $this->input->post('warehouse',true);
  5973. $post['purchase'] = $this->input->post('purchase',true);
  5974. $post['retreatwarehouse'] = $post['warehouse'];
  5975. $post['cpbz'] = $this->input->post('cpbz',true);
  5976. $post['state'] = 9;
  5977. $category = $this->input->post('category',true);
  5978. $list['category'] = $category;
  5979. $list['hairtype'] = $this->input->post('hairtype',true);
  5980. $list['grade'] = $this->input->post('grade',true);
  5981. $size = $this->input->post('size',true);
  5982. $list['size'] = rtrim($size,',');
  5983. $list['hairnumber'] = $this->input->post('hairnumber',true);
  5984. $list['extension'] = $this->input->post('extension',true);
  5985. if($category == 1297)
  5986. {
  5987. $list['sywignumber'] = $this->input->post('sywignumber',true);
  5988. }
  5989. if($category == 1702)
  5990. {
  5991. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  5992. $list['syother'] = $this->input->post('syother',true);
  5993. }
  5994. if($category == 133)
  5995. {
  5996. $list['fittype'] = $this->input->post('fittype',true);
  5997. $list['acother'] = $this->input->post('acother',true);
  5998. }
  5999. $list['color'] = $this->input->post('color',true);
  6000. $list['lowe'] = $this->input->post('lowe',true);
  6001. if($category == 127)
  6002. {
  6003. $list['type'] = $this->input->post('type',true);
  6004. $list['headroad'] = $this->input->post('headroad',true);
  6005. $list['density'] = $this->input->post('density',true);
  6006. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  6007. {
  6008. $list['lacesize'] = $this->input->post('lacesize',true);
  6009. }
  6010. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6011. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6012. }
  6013. if($category == 128)
  6014. {
  6015. $list['lacetype'] = $this->input->post('lacetype',true);
  6016. $list['haircap'] = $this->input->post('haircap',true);
  6017. $list['density'] = $this->input->post('density',true);
  6018. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6019. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6020. $list['wigother'] = $this->input->post('wigother',true);
  6021. $list['wigother2'] = $this->input->post('wigother2',true);
  6022. }
  6023. if($category == 129)
  6024. {
  6025. $list['wide'] = $this->input->post('wide',true);
  6026. }
  6027. if($category == 131)
  6028. {
  6029. $list['gifttype'] = $this->input->post('gifttype',true);
  6030. $list['giftother'] = $this->input->post('giftother',true);
  6031. }
  6032. if($category == 134)
  6033. {
  6034. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6035. }
  6036. if($category == 1297)
  6037. {
  6038. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6039. $list['sywigother'] = $this->input->post('sywigother',true);
  6040. }
  6041. if($category == 130 || $category == 133 || $category == 1702)
  6042. {
  6043. $list['items'] = $this->input->post('items',true);
  6044. $list['weight'] = $this->input->post('weight',true);
  6045. }
  6046. if($category == 1702)
  6047. {
  6048. $list['syhairther'] = $this->input->post('syhairther',true);
  6049. }
  6050. foreach($list as $k=>$v)
  6051. {
  6052. if($v != 0)
  6053. {
  6054. $num .=$v;
  6055. $features .=$v.'-';
  6056. $post[$k] = $v;
  6057. $typeclass = $this->typeclass->read($v);
  6058. if(isset($pm[$typeclass['classid']]))
  6059. {
  6060. if(stripos($typeclass['zh'],'|') !== false)
  6061. {
  6062. $exzh = explode('|',$typeclass['zh']);
  6063. $pm[$typeclass['classid']] = $exzh[0];
  6064. }
  6065. else
  6066. {
  6067. $pm[$typeclass['classid']] = $typeclass['zh'];
  6068. }
  6069. }
  6070. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6071. if($k != 'size')
  6072. {
  6073. $title .= $typeclass['title']." ";
  6074. }
  6075. }
  6076. }
  6077. $typeclass = $this->typeclass->read($list['size']);
  6078. $title .= $typeclass['title'];
  6079. $time = time();
  6080. $post['title'] = rtrim($title,' ');
  6081. $post['number'] = $num;
  6082. $post['features'] = '-'.$features;
  6083. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6084. $featurespp = explode('-',trim($featurespp,'-'));
  6085. if(isset($featurespp[5]))
  6086. {
  6087. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6088. }
  6089. else
  6090. {
  6091. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6092. }
  6093. $post['enter'] = $time;
  6094. $post['time'] = $time;//操作时间
  6095. $scsku = implode("-",$scsku);
  6096. $zh = implode(" ",$pm);
  6097. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6098. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6099. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6100. $post['sku'] = $bqsku;
  6101. $label = time().rand(0,9);
  6102. $post['label'] = $label;
  6103. $cpid = $this->whlabellabel->find_count();
  6104. $post['cpid'] = $cpid+1;
  6105. $cpid = $post['cpid'];
  6106. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6107. //if($whlabelbarcode)
  6108. //{
  6109. //$post['label'] = $whlabelbarcode['label'];
  6110. //if(!$this->whlabellabel->insert($post))
  6111. //{
  6112. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6113. //}
  6114. //}
  6115. //else
  6116. //{
  6117. $this->db->trans_begin();
  6118. $this->whlabellabel->insert($post);
  6119. //$this->whlabelbarcode->insert($post);
  6120. if ($this->db->trans_status() === TRUE)
  6121. {
  6122. $this->db->trans_commit();
  6123. }
  6124. else
  6125. {
  6126. $this->db->trans_rollback();
  6127. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6128. }
  6129. //}
  6130. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6131. $purchase = $this->purchase->read($post['purchase']);
  6132. 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;//特殊仓目前不需要仓库选项
  6133. }
  6134. }
  6135. if(isset($_SESSION['api']))
  6136. {
  6137. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6138. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6139. $this->data['wlshop'] = $wlshop;
  6140. $this->data['warehouse'] = $warehouse;
  6141. }
  6142. $whlabelwz = $this->whlabelwz->find_all();
  6143. $this->data['whlabelwz'] = $whlabelwz;
  6144. $this->_Template('whlabel_print',$this->data);
  6145. }
  6146. public function _usaprint($arg_array)
  6147. {
  6148. if(isset($_SESSION['api']))
  6149. {
  6150. $user = $this->user->get_api($_SESSION['api']);
  6151. $usp = $user;
  6152. $fgshop = "";$sid = "";$wid="";$wtype="";
  6153. $usersp = explode('|',trim($user['shop'],'|'));
  6154. $userwh = explode('|',trim($user['warehouse'],'|'));
  6155. foreach ($usersp as $value)
  6156. {
  6157. $fgshop .= " shop = ".$value." or";
  6158. $sid .= " id = ".$value." or";
  6159. }
  6160. foreach ($userwh as $value)
  6161. {
  6162. $wid .= " id = ".$value." or";
  6163. $wtype .= " type = ".$value." or";
  6164. }
  6165. }
  6166. $post = $this->input->post(NULL, TRUE);
  6167. if(isset($post['tmsku']))
  6168. {
  6169. $tmsku = $this->input->post('tmsku',true);
  6170. if(is_numeric($tmsku))
  6171. {
  6172. $yyh = $this->whlabellabel->get_label($tmsku);
  6173. }
  6174. else
  6175. {
  6176. $yyh = $this->whlabellabel->get_sku($tmsku);
  6177. }
  6178. if($yyh)
  6179. {
  6180. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  6181. }
  6182. else
  6183. {
  6184. echo json_encode(array('success'=>false));exit;
  6185. }
  6186. }
  6187. $classid = $this->classid->sku();
  6188. $pm = $classid;
  6189. $scsku = $classid;
  6190. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6191. if(isset($post['warehouse']))
  6192. {
  6193. if($post['warehouse'])
  6194. {
  6195. $list = array();$num = "";$title = "";$features = "";
  6196. $order = 0;
  6197. $post['shop'] = '';
  6198. $brand = $this->input->post('brand',true);
  6199. if($brand != '0,')
  6200. {
  6201. $b = $this->brand->read(rtrim($brand,','));
  6202. if($b)
  6203. {
  6204. $post['shop'] = str_replace('|',',',$b['shop']);
  6205. }
  6206. }
  6207. $post['details'] = $this->input->post('details',true);//打印数量
  6208. $xbqnum = $this->input->post('xbqnum',true);
  6209. $post['purchase'] = $this->input->post('purchase',true);
  6210. $post['warehouse'] = $this->input->post('warehouse',true);
  6211. $post['purchase'] = $this->input->post('purchase',true);
  6212. $post['retreatwarehouse'] = $post['warehouse'];
  6213. $post['cpbz'] = $this->input->post('cpbz',true);
  6214. $post['state'] = 9;
  6215. $category = $this->input->post('category',true);
  6216. $list['category'] = $category;
  6217. $list['hairtype'] = $this->input->post('hairtype',true);
  6218. $list['grade'] = $this->input->post('grade',true);
  6219. $size = $this->input->post('size',true);
  6220. $list['size'] = rtrim($size,',');
  6221. $list['hairnumber'] = $this->input->post('hairnumber',true);
  6222. $list['extension'] = $this->input->post('extension',true);
  6223. if($category == 1297)
  6224. {
  6225. $list['sywignumber'] = $this->input->post('sywignumber',true);
  6226. }
  6227. if($category == 1702)
  6228. {
  6229. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  6230. $list['syother'] = $this->input->post('syother',true);
  6231. }
  6232. if($category == 133)
  6233. {
  6234. $list['fittype'] = $this->input->post('fittype',true);
  6235. $list['acother'] = $this->input->post('acother',true);
  6236. }
  6237. $list['color'] = $this->input->post('color',true);
  6238. $list['lowe'] = $this->input->post('lowe',true);
  6239. if($category == 127)
  6240. {
  6241. $list['type'] = $this->input->post('type',true);
  6242. $list['headroad'] = $this->input->post('headroad',true);
  6243. $list['density'] = $this->input->post('density',true);
  6244. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  6245. {
  6246. $list['lacesize'] = $this->input->post('lacesize',true);
  6247. }
  6248. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6249. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6250. }
  6251. if($category == 128)
  6252. {
  6253. $list['lacetype'] = $this->input->post('lacetype',true);
  6254. $list['haircap'] = $this->input->post('haircap',true);
  6255. $list['density'] = $this->input->post('density',true);
  6256. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6257. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6258. $list['wigother'] = $this->input->post('wigother',true);
  6259. $list['wigother2'] = $this->input->post('wigother2',true);
  6260. }
  6261. if($category == 129)
  6262. {
  6263. $list['wide'] = $this->input->post('wide',true);
  6264. }
  6265. if($category == 131)
  6266. {
  6267. $list['gifttype'] = $this->input->post('gifttype',true);
  6268. $list['giftother'] = $this->input->post('giftother',true);
  6269. }
  6270. if($category == 134)
  6271. {
  6272. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6273. }
  6274. if($category == 1297)
  6275. {
  6276. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6277. $list['sywigother'] = $this->input->post('sywigother',true);
  6278. }
  6279. if($category == 130 || $category == 133 || $category == 1702)
  6280. {
  6281. $list['items'] = $this->input->post('items',true);
  6282. $list['weight'] = $this->input->post('weight',true);
  6283. }
  6284. if($category == 1702)
  6285. {
  6286. $list['syhairther'] = $this->input->post('syhairther',true);
  6287. }
  6288. foreach($list as $k=>$v)
  6289. {
  6290. if($v != 0)
  6291. {
  6292. $num .=$v;
  6293. $features .=$v.'-';
  6294. $post[$k] = $v;
  6295. $typeclass = $this->typeclass->read($v);
  6296. if(isset($pm[$typeclass['classid']]))
  6297. {
  6298. if(stripos($typeclass['zh'],'|') !== false)
  6299. {
  6300. $exzh = explode('|',$typeclass['zh']);
  6301. $pm[$typeclass['classid']] = $exzh[0];
  6302. }
  6303. else
  6304. {
  6305. $pm[$typeclass['classid']] = $typeclass['zh'];
  6306. }
  6307. }
  6308. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6309. if($k != 'size')
  6310. {
  6311. $title .= $typeclass['title']." ";
  6312. }
  6313. }
  6314. }
  6315. $typeclass = $this->typeclass->read($list['size']);
  6316. $title .= $typeclass['title'];
  6317. $time = time();
  6318. $post['title'] = rtrim($title,' ');
  6319. $post['number'] = $num;
  6320. $post['features'] = '-'.$features;
  6321. $fp = $this->whlabel->get_features($post['features']);
  6322. if(!$fp)
  6323. {
  6324. echo json_encode(array('msg'=>'美仓无此产品,需要添加后才可打印','success'=>false));exit;
  6325. }
  6326. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6327. $featurespp = explode('-',trim($featurespp,'-'));
  6328. if(isset($featurespp[5]))
  6329. {
  6330. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6331. }
  6332. else
  6333. {
  6334. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6335. }
  6336. $post['enter'] = $time;
  6337. $post['time'] = $time;//操作时间
  6338. $scsku = implode("-",$scsku);
  6339. $zh = implode(" ",$pm);
  6340. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6341. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6342. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6343. $post['sku'] = $fp['sku'];
  6344. $post['label'] = $fp['sku'];
  6345. $cpid = $this->whlabellabel->find_count();
  6346. $post['cpid'] = $cpid+1;
  6347. $cpid = $post['cpid'];
  6348. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6349. //if($whlabelbarcode)
  6350. //{
  6351. //$post['label'] = $whlabelbarcode['label'];
  6352. //if(!$this->whlabellabel->insert($post))
  6353. //{
  6354. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6355. //}
  6356. //}
  6357. //else
  6358. //{
  6359. $this->db->trans_begin();
  6360. $this->whlabellabel->insert($post);
  6361. //$this->whlabelbarcode->insert($post);
  6362. if ($this->db->trans_status() === TRUE)
  6363. {
  6364. $this->db->trans_commit();
  6365. }
  6366. else
  6367. {
  6368. $this->db->trans_rollback();
  6369. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6370. }
  6371. //}
  6372. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6373. $purchase = $this->purchase->read($post['purchase']);
  6374. 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;//特殊仓目前不需要仓库选项
  6375. }
  6376. }
  6377. if(isset($_SESSION['api']))
  6378. {
  6379. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6380. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6381. $this->data['wlshop'] = $wlshop;
  6382. $this->data['warehouse'] = $warehouse;
  6383. }
  6384. $whlabelwz = $this->whlabelwz->find_all();
  6385. $this->data['whlabelwz'] = $whlabelwz;
  6386. $this->_Template('whlabel_usaprint',$this->data);
  6387. }
  6388. public function _printrk($arg_array)
  6389. {
  6390. $prc = array();
  6391. $purchase = $this->purchase->find_all();
  6392. foreach($purchase as $k=>$v)
  6393. {
  6394. $prc[$v['id']] = $v['title'];
  6395. }
  6396. $post = $this->input->post(NULL, TRUE);
  6397. if(isset($post['page']))
  6398. {
  6399. $page = $this->input->post('page',true);
  6400. $perpage = $this->input->post('perpage',true);
  6401. $sku = $this->input->post('sku',true);
  6402. $bs = $this->input->post('bs',true);
  6403. $number = $this->input->post('number',true);
  6404. $warehouse = $this->input->post('warehouse',true);
  6405. $purchase = $this->input->post('purchase',true);
  6406. $orderinfo = $this->input->post('orderinfo',true);
  6407. $waybill = $this->input->post('waybill',true);
  6408. $category = $this->input->post('category',true);
  6409. $size = $this->input->post('size',true);
  6410. $grade = $this->input->post('grade',true);
  6411. $color = $this->input->post('color',true);
  6412. $lowe = $this->input->post('lowe',true);
  6413. $state = $this->input->post('state',true);
  6414. $label = $this->input->post('label',true);
  6415. $timetk = $this->input->post('ktime',true);
  6416. $timetj = $this->input->post('jtime',true);
  6417. $timetk = strtotime($timetk);
  6418. $timetj = strtotime($timetj);
  6419. $where = "1=1 ";
  6420. if($timetk && $timetj)
  6421. {
  6422. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6423. }
  6424. if($sku)
  6425. {
  6426. $where .= " and sku = '$sku'";
  6427. }
  6428. if($bs != '')
  6429. {
  6430. $where .= " and bs = '$bs'";
  6431. }
  6432. if($number)
  6433. {
  6434. $where .= " and number = '$number'";
  6435. }
  6436. if($warehouse)
  6437. {
  6438. $where .= " and warehouse = '$warehouse'";
  6439. }
  6440. if($purchase)
  6441. {
  6442. $where .= " and purchase = '$purchase'";
  6443. }
  6444. if($orderinfo)
  6445. {
  6446. $where .= " and orderinfo = '$orderinfo'";
  6447. }
  6448. if($waybill)
  6449. {
  6450. $where .= " and waybill = '$waybill'";
  6451. }
  6452. if($category)
  6453. {
  6454. $where .= " and features like '%-$category-%'";
  6455. }
  6456. if($size)
  6457. {
  6458. $where .= " and features like '%-$size-%'";
  6459. }
  6460. if($grade)
  6461. {
  6462. $where .= " and features like '%-$grade-%'";
  6463. }
  6464. if($color)
  6465. {
  6466. $where .= " and features like '%-$color-%'";
  6467. }
  6468. if($lowe)
  6469. {
  6470. $where .= " and features like '%-$lowe-%'";
  6471. }
  6472. if($label)
  6473. {
  6474. $where .= " and label = '$label'";
  6475. }
  6476. if($state || $state == 0)
  6477. {
  6478. $where .= " and state = '$state'";
  6479. }
  6480. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6481. //数据排序
  6482. $order_str = "enter desc";
  6483. if(empty($page))
  6484. {
  6485. $start = 0;
  6486. $perpage = 1;
  6487. }
  6488. else
  6489. {
  6490. $start = ($page - 1)*$perpage;
  6491. }
  6492. //取得信息列表
  6493. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,enter,details',$order_str,$start,$perpage);
  6494. foreach ($info_list as $key=>$value)
  6495. {
  6496. $warehouse = $this->warehouse->read($value['warehouse']);
  6497. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6498. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6499. if($value['state'] == 0)
  6500. {
  6501. $info_list[$key]['state'] = "在库";
  6502. }
  6503. else if($value['state'] == 1)
  6504. {
  6505. $info_list[$key]['state'] = "出库";
  6506. }
  6507. else if($value['state'] == 2)
  6508. {
  6509. $info_list[$key]['state'] = "退库";
  6510. }
  6511. else if($value['state'] == 3)
  6512. {
  6513. $info_list[$key]['state'] = "调拨中";
  6514. }
  6515. else if($value['state'] == 4)
  6516. {
  6517. $info_list[$key]['state'] = "再加工";
  6518. }
  6519. else if($value['state'] == 5)
  6520. {
  6521. $info_list[$key]['state'] = "维修中";
  6522. }
  6523. else if($value['state'] == 6)
  6524. {
  6525. $info_list[$key]['state'] = "盘亏";
  6526. }
  6527. else if($value['state'] == 7)
  6528. {
  6529. $info_list[$key]['state'] = "更换标签";
  6530. }
  6531. else if($value['state'] == 8)
  6532. {
  6533. $info_list[$key]['state'] = "其它";
  6534. }
  6535. else if($value['state'] == 9)
  6536. {
  6537. $info_list[$key]['state'] = "预设";
  6538. }
  6539. else if($value['state'] == 10)
  6540. {
  6541. $info_list[$key]['state'] = "美店零售";
  6542. }
  6543. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  6544. }
  6545. $total = $this->$ck->find_count($where);
  6546. $pagenum = ceil($total/$perpage);
  6547. $over = $total-($start+$perpage);
  6548. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6549. echo json_encode($rows);exit;
  6550. }
  6551. if(isset($post['tmsku']))
  6552. {
  6553. $time = time();
  6554. $tmsku = $this->input->post('tmsku',true);
  6555. //$post['shop'] = $this->input->post('shop',true);
  6556. $num = $this->input->post('num',true);
  6557. $rktype = $this->input->post('rktype',true);
  6558. if($num > 200)
  6559. {
  6560. echo json_encode(array('msg'=>'入库数量不允许超过200!','c'=>0,'success'=>false));exit;
  6561. }
  6562. if(!$rktype)
  6563. {
  6564. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6565. }
  6566. $rk = $this->whlabellabel->find_all("label = '$tmsku'","*","id desc");
  6567. /**
  6568. $wz = array();
  6569. foreach ($rk as $key=>$value)
  6570. {
  6571. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6572. }
  6573. if(count($wz) > 1)
  6574. {
  6575. $wz = array_values($wz);
  6576. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6577. }
  6578. **/
  6579. if(isset($rk[0]['purchase']))
  6580. {
  6581. $rk = $rk[0];
  6582. $j = 0;
  6583. $post['purchase'] = $rk['purchase'];
  6584. $post['warehouse'] = $rk['warehouse'];
  6585. $post['retreatwarehouse'] = $rk['warehouse'];
  6586. $post['sku'] = $rk['sku'];
  6587. $post['number'] = $rk['number'];
  6588. $post['features'] = $rk['features'];
  6589. $post['title'] = $rk['title'];
  6590. $post['enter'] = $time;
  6591. $post['time'] = $time;
  6592. $post['bs'] = 1;
  6593. $post['shop'] = $rk['shop'];
  6594. $post['details'] = $rk['details'];
  6595. $post['cpid'] = $rk['cpid'];
  6596. $post['cpbz'] = $rk['cpbz'];
  6597. //$post['rktype'] = $rktype;
  6598. $warehouse = $this->warehouse->read($rk['warehouse']);
  6599. if($warehouse['bdck'] == '')
  6600. {
  6601. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','c'=>0,'success'=>false));exit;
  6602. }
  6603. else
  6604. {
  6605. $bdck = $warehouse['bdck'];
  6606. }
  6607. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'],$post['sku']);
  6608. if(isset($pdwz['details']))
  6609. {
  6610. if($pdwz['details'] != $post['details'])
  6611. {
  6612. echo json_encode(array('msg'=>'此产品位置应为:'.$pdwz['details'],'c'=>0,'cs'=>$pdwz['details'].' - '.$post['details'],'success'=>false));exit;
  6613. }
  6614. }
  6615. $post['featurespp'] = $rk['featurespp'];
  6616. if($post['warehouse'] == '5')
  6617. {
  6618. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6619. if($yza)
  6620. {
  6621. if($post['features'] != $yza[0]['features'])
  6622. {
  6623. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'c'=>0,'success'=>false));exit;
  6624. }
  6625. }
  6626. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6627. if($yzb)
  6628. {
  6629. if($post['sku'] != $yzb[0]['sku'])
  6630. {
  6631. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','c'=>0,'success'=>false));exit;
  6632. }
  6633. }
  6634. }
  6635. for($i=0;$i<$num;$i++)
  6636. {
  6637. $post['label'] = time().rand(100,999).$i;
  6638. if($this->$bdck->insert($post))
  6639. {
  6640. $j++;
  6641. }
  6642. }
  6643. /**
  6644. if($post['warehouse'] != 12)
  6645. {
  6646. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6647. }
  6648. **/
  6649. if($j == $num)
  6650. {
  6651. echo json_encode(array('msg'=>'入库成功!','success'=>true));exit;
  6652. }
  6653. else
  6654. {
  6655. echo json_encode(array('msg'=>'未成功入库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6656. }
  6657. }
  6658. else
  6659. {
  6660. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6661. }
  6662. }
  6663. $this->_Template('whlabel_printrk',$this->data);
  6664. }
  6665. public function _printxzrk($arg_array)
  6666. {
  6667. $post = $this->input->post(NULL, TRUE);
  6668. if(isset($post['wzid']))
  6669. {
  6670. $time = time();
  6671. $id = $this->input->post('wzid',true);
  6672. //$post['shop'] = $this->input->post('shop',true);
  6673. $num = 1;
  6674. $rk = $this->whlabellabel->read($id);
  6675. if(isset($rk['purchase']))
  6676. {
  6677. $x = 0;
  6678. $post['purchase'] = $rk['purchase'];
  6679. $post['warehouse'] = $rk['warehouse'];
  6680. $post['retreatwarehouse'] = $rk['warehouse'];
  6681. $post['sku'] = $rk['sku'];
  6682. $post['number'] = $rk['number'];
  6683. $post['features'] = $rk['features'];
  6684. $post['title'] = $rk['title'];
  6685. $post['enter'] = $time;
  6686. $post['time'] = $time;
  6687. $post['bs'] = 1;
  6688. $post['shop'] = $rk['shop'];
  6689. $post['details'] = $rk['details'];
  6690. $post['cpid'] = $rk['cpid'];
  6691. $post['cpbz'] = $rk['cpbz'];
  6692. $warehouse = $this->warehouse->read($rk['warehouse']);
  6693. if($warehouse['bdck'] == '')
  6694. {
  6695. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','success'=>false));exit;
  6696. }
  6697. else
  6698. {
  6699. $bdck = $warehouse['bdck'];
  6700. }
  6701. $post['featurespp'] = $rk['featurespp'];
  6702. $this->db->trans_begin();
  6703. for($i=0;$i<$num;$i++)
  6704. {
  6705. $post['label'] = time().rand(100,999).$i;
  6706. $this->$bdck->insert($post);
  6707. }
  6708. /**
  6709. if($post['warehouse'] != 12)
  6710. {
  6711. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6712. }
  6713. **/
  6714. if ($this->db->trans_status() === TRUE)
  6715. {
  6716. $this->db->trans_commit();
  6717. echo json_encode(array('msg'=>'入库成功!','cs'=>$post,'cs2'=>$warehouse,'success'=>true));exit;
  6718. }
  6719. else
  6720. {
  6721. $this->db->trans_rollback();
  6722. echo json_encode(array('msg'=>'入库失败,请重试','c'=>0,'success'=>false));exit;
  6723. }
  6724. }
  6725. else
  6726. {
  6727. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6728. }
  6729. }
  6730. }
  6731. public function _printck($arg_array)
  6732. {
  6733. $prc = array();
  6734. $purchase = $this->purchase->find_all();
  6735. foreach($purchase as $k=>$v)
  6736. {
  6737. $prc[$v['id']] = $v['title'];
  6738. }
  6739. $post = $this->input->post(NULL, TRUE);
  6740. if(isset($post['page']))
  6741. {
  6742. $page = $this->input->post('page',true);
  6743. $perpage = $this->input->post('perpage',true);
  6744. $sku = $this->input->post('sku',true);
  6745. $bs = $this->input->post('bs',true);
  6746. $number = $this->input->post('number',true);
  6747. $warehouse = $this->input->post('warehouse',true);
  6748. $purchase = $this->input->post('purchase',true);
  6749. $orderinfo = $this->input->post('orderinfo',true);
  6750. $waybill = $this->input->post('waybill',true);
  6751. $category = $this->input->post('category',true);
  6752. $size = $this->input->post('size',true);
  6753. $grade = $this->input->post('grade',true);
  6754. $color = $this->input->post('color',true);
  6755. $lowe = $this->input->post('lowe',true);
  6756. $state = $this->input->post('state',true);
  6757. $label = $this->input->post('label',true);
  6758. $timetk = $this->input->post('ktime',true);
  6759. $timetj = $this->input->post('jtime',true);
  6760. $timetk = strtotime($timetk);
  6761. $timetj = strtotime($timetj);
  6762. $where = "state=1 ";
  6763. if($timetk && $timetj)
  6764. {
  6765. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6766. }
  6767. if($sku)
  6768. {
  6769. $where .= " and sku = '$sku'";
  6770. }
  6771. if($bs != '')
  6772. {
  6773. $where .= " and bs = '$bs'";
  6774. }
  6775. if($number)
  6776. {
  6777. $where .= " and number = '$number'";
  6778. }
  6779. if($warehouse)
  6780. {
  6781. $where .= " and warehouse = '$warehouse'";
  6782. }
  6783. if($purchase)
  6784. {
  6785. $where .= " and purchase = '$purchase'";
  6786. }
  6787. if($orderinfo)
  6788. {
  6789. $where .= " and orderinfo = '$orderinfo'";
  6790. }
  6791. if($waybill)
  6792. {
  6793. $where .= " and waybill = '$waybill'";
  6794. }
  6795. if($category)
  6796. {
  6797. $where .= " and features like '%-$category-%'";
  6798. }
  6799. if($size)
  6800. {
  6801. $where .= " and features like '%-$size-%'";
  6802. }
  6803. if($grade)
  6804. {
  6805. $where .= " and features like '%-$grade-%'";
  6806. }
  6807. if($color)
  6808. {
  6809. $where .= " and features like '%-$color-%'";
  6810. }
  6811. if($lowe)
  6812. {
  6813. $where .= " and features like '%-$lowe-%'";
  6814. }
  6815. if($label)
  6816. {
  6817. $where .= " and label = '$label'";
  6818. }
  6819. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6820. //数据排序
  6821. $order_str = "outk desc";
  6822. if(empty($page))
  6823. {
  6824. $start = 0;
  6825. $perpage = 1;
  6826. }
  6827. else
  6828. {
  6829. $start = ($page - 1)*$perpage;
  6830. }
  6831. //取得信息列表
  6832. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,outk,details',$order_str,$start,$perpage);
  6833. foreach ($info_list as $key=>$value)
  6834. {
  6835. $warehouse = $this->warehouse->read($value['warehouse']);
  6836. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6837. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6838. if($value['state'] == 0)
  6839. {
  6840. $info_list[$key]['state'] = "在库";
  6841. }
  6842. else if($value['state'] == 1)
  6843. {
  6844. $info_list[$key]['state'] = "出库";
  6845. }
  6846. else if($value['state'] == 2)
  6847. {
  6848. $info_list[$key]['state'] = "退库";
  6849. }
  6850. else if($value['state'] == 3)
  6851. {
  6852. $info_list[$key]['state'] = "调拨中";
  6853. }
  6854. else if($value['state'] == 4)
  6855. {
  6856. $info_list[$key]['state'] = "再加工";
  6857. }
  6858. else if($value['state'] == 5)
  6859. {
  6860. $info_list[$key]['state'] = "维修中";
  6861. }
  6862. else if($value['state'] == 6)
  6863. {
  6864. $info_list[$key]['state'] = "盘亏";
  6865. }
  6866. else if($value['state'] == 7)
  6867. {
  6868. $info_list[$key]['state'] = "更换标签";
  6869. }
  6870. else if($value['state'] == 8)
  6871. {
  6872. $info_list[$key]['state'] = "其它";
  6873. }
  6874. else if($value['state'] == 9)
  6875. {
  6876. $info_list[$key]['state'] = "预设";
  6877. }
  6878. else if($value['state'] == 10)
  6879. {
  6880. $info_list[$key]['state'] = "美店零售";
  6881. }
  6882. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  6883. }
  6884. $total = $this->$ck->find_count($where);
  6885. $pagenum = ceil($total/$perpage);
  6886. $over = $total-($start+$perpage);
  6887. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6888. echo json_encode($rows);exit;
  6889. }
  6890. if(isset($post['tmsku']))
  6891. {
  6892. $time = time();
  6893. $tmsku = $this->input->post('tmsku',true);
  6894. //$post['shop'] = $this->input->post('shop',true);
  6895. $num = $this->input->post('num',true);
  6896. $cktype = $this->input->post('cktype',true);
  6897. $label = $this->whlabellabel->get_label($tmsku);
  6898. if(!$cktype)
  6899. {
  6900. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6901. }
  6902. if(!isset($label['warehouse']))
  6903. {
  6904. echo json_encode(array('msg'=>'没有此条码信息!','success'=>false));exit;
  6905. }
  6906. $xzck = ($label['warehouse'] == '12')?'specialstock':'whlabel';
  6907. if(stripos($label['features'],'-126-') !== false)
  6908. {
  6909. $ck = $this->$xzck->find_all("state = '0' and shop = '".$label['shop']."' and number = '".$label['number']."' and warehouse = '".$label['warehouse']."' and zd = ''");
  6910. }
  6911. else
  6912. {
  6913. $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 = ''");
  6914. }
  6915. $j = 0;
  6916. if(count($ck) >= $num)
  6917. {
  6918. for($i=0;$i<$num;$i++)
  6919. {
  6920. if($this->$xzck->save(array('state'=>1,'outk'=>$time,'time'=>$time),$ck[$i]['id']))//,'cktype'=>$cktype
  6921. {
  6922. $j++;
  6923. }
  6924. }
  6925. if($j == $num)
  6926. {
  6927. echo json_encode(array('msg'=>'出库成功!','success'=>true));exit;
  6928. }
  6929. else
  6930. {
  6931. echo json_encode(array('msg'=>'未成功出库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6932. }
  6933. }
  6934. else
  6935. {
  6936. echo json_encode(array('msg'=>'没有足够的库存!','cs'=>$label['sku'].' - '.$label['purchase'],'success'=>false));exit;
  6937. }
  6938. }
  6939. $this->_Template('whlabel_printck',$this->data);
  6940. }
  6941. public function _printexcel()
  6942. {
  6943. $dir = '/data/excel/'.date('Ymd',time()).'/';
  6944. $config['upload_path'] = '.'.$dir ;
  6945. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  6946. $config['allowed_types'] = 'xls|xlsx|csv';
  6947. $config['max_size'] = 10240;
  6948. $this->load->library('upload', $config);
  6949. $this->upload->initialize($config);
  6950. if ($this->upload->do_upload('userfile'))
  6951. {
  6952. $full_path = $dir.$this->upload->data('file_name');
  6953. $fileName = '.' . $full_path;
  6954. if (!file_exists($fileName))
  6955. {
  6956. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  6957. }
  6958. else
  6959. {
  6960. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6961. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  6962. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  6963. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  6964. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  6965. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  6966. ++$column;//如果列数大于26行
  6967. $list = array();
  6968. for ($i = 2; $i <= $row; $i++) // 行数循环
  6969. {
  6970. $data = array();
  6971. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6972. {
  6973. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6974. }
  6975. $list[] = $data;
  6976. }
  6977. }
  6978. $ed = array();$i = 0;$j = 0;$dcdata = array();$yc = '';
  6979. $cmf_arr = array_column($list, '1');
  6980. array_multisort($cmf_arr, SORT_ASC, $list);
  6981. foreach ($list as $key=>$value)
  6982. {
  6983. $typeclass = $this->typeclass->get_bqsku($value['1'],$value['2']);
  6984. if($typeclass)
  6985. {
  6986. $this->typeclass->save(array('bqsku'=>$value['3']),$typeclass['id']);
  6987. }
  6988. else
  6989. {
  6990. $ed[] = array($value['1'].'-系统未找到此订单信息');
  6991. $i++;
  6992. continue;
  6993. }
  6994. }
  6995. if($i > 0)
  6996. {
  6997. $yc = $i.'条异常';
  6998. }
  6999. echo json_encode(array('msg'=>'操作成功 '.$yc,'yc'=>$ed,'success'=>true));exit;
  7000. }
  7001. }
  7002. public function _uck()
  7003. {
  7004. if(isset($_GET['excel']))
  7005. {
  7006. $tc = array();
  7007. $typeclass = $this->typeclass->find_all();
  7008. foreach ($typeclass as $v)
  7009. {
  7010. $tc[$v['id']] = $v['zh'];
  7011. }
  7012. $data = array();$t = array();$rq = '';
  7013. $ts = strtotime(date("Y-m-d",time()))-strtotime(date("Y-m",time()));
  7014. $ts = $ts/(24*3600);
  7015. for($i=0;$i<$ts;$i++)
  7016. {
  7017. $t[] = date("Y-m-d",strtotime('-'.($ts-$i).' day'));
  7018. $rq .= "<td>".date("Y-m-d",strtotime('-'.($ts-$i).' day'))."</td>";
  7019. }
  7020. $info_list = $this->whlabel->find_pc("warehouse = '5'",'sku','warehouse,sku,features');
  7021. foreach ($info_list as $k=>$v)
  7022. {
  7023. $features = explode('-',trim($v['features'],'-'));
  7024. if(!isset($features[3]) || !isset($features[4]))
  7025. {
  7026. continue;
  7027. }
  7028. $data[$k][0] = $tc[$features[0]];//类型
  7029. $data[$k][1] = ($features[3] != 57)?$tc[$features[3]]:'';//颜色,自然色不显示
  7030. $data[$k][2] = $tc[$features[4]];//曲度
  7031. $data[$k][3] = '';
  7032. if(isset($data[$k][1]))
  7033. {
  7034. $data[$k][3] .= $data[$k][1];
  7035. }
  7036. if(isset($data[$k][2]))
  7037. {
  7038. $data[$k][3] .= $data[$k][2];
  7039. }
  7040. if(isset($features[5]))
  7041. {
  7042. $data[$k][3] .= $tc[$features[5]];
  7043. }
  7044. if(isset($features[2]))
  7045. {
  7046. $data[$k][3] .= $tc[$features[2]];
  7047. }
  7048. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7049. $data[$k][4] = $v['sku'];
  7050. $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())).'))');//月初库存
  7051. $data[$k][] = $this->whlabel->find_count('sku = "'.$v['sku'].'" and state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');//剩余库存
  7052. $zt = $this->whlabeltransport->find_all('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and cz = "0"');
  7053. $ztrq = '';$ztsl = '';
  7054. if(count($zt) > 0)
  7055. {
  7056. foreach ($zt as $vv)
  7057. {
  7058. $ztrq .= date('Y-m-d',$vv['stime']).'<br>';
  7059. $ztsl .= $vv['num'].'<br>';
  7060. }
  7061. }
  7062. $data[$k][] = trim($ztsl,'<br>');
  7063. $data[$k][] = trim($ztrq,'<br>');
  7064. $byck = 0;
  7065. foreach ($t as $vv)
  7066. {
  7067. $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));
  7068. $data[$k][] = ($sl > 0)?'<b>'.$sl.'</b>':'';
  7069. $byck += $sl;
  7070. }
  7071. $data[$k][] = ($byck > 0)?$byck:'';
  7072. }
  7073. $title = "详情 ".date("Y-m-d",time());
  7074. $titlename = "<table border=1>
  7075. <tr align='center'>
  7076. <td>类别</td>
  7077. <td>颜色</td>
  7078. <td>曲度</td>
  7079. <td>名称</td>
  7080. <td>SKU</td>
  7081. <td>月初库存</td>
  7082. <td>剩余库存</td>
  7083. <td>在途数量</td>
  7084. <td>预达日期</td>".
  7085. $rq
  7086. ."<td>本月出库</td></tr>
  7087. </table>";
  7088. $filename = $title.".xls";
  7089. $tail = "";
  7090. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  7091. }
  7092. }
  7093. public function _whlabelexcelzh()
  7094. {
  7095. if(isset($_GET['excel']))
  7096. {
  7097. $where = "sku != 'Preset'";
  7098. //数据排序
  7099. $order_str = "id desc";
  7100. if(empty($page))
  7101. {
  7102. $start = 0;
  7103. $perpage = 1;
  7104. }
  7105. else
  7106. {
  7107. $start = ($page - 1)*$perpage;
  7108. }
  7109. $category = $this->input->get('category',true);
  7110. $warehouse = $this->input->get('warehouse',true);
  7111. $excelid = $this->input->get('sid',true);
  7112. if($category)
  7113. {
  7114. $where .= " and features like '%-$category-%'";
  7115. }
  7116. if($warehouse)
  7117. {
  7118. $where .= " and warehouse = '$warehouse'";
  7119. }
  7120. $xzid = '';
  7121. if($excelid)
  7122. {
  7123. $excelid = explode(',',trim($excelid,','));
  7124. foreach ($excelid as $key=>$value)
  7125. {
  7126. $xzid .= " id = ".$value." or";
  7127. }
  7128. $xzid = " and (".rtrim($xzid,'or').")";;
  7129. }
  7130. //取得信息列表
  7131. /**
  7132. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7133. $rows = array();$list = array();
  7134. foreach ($info_list as $key=>$value)
  7135. {
  7136. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7137. }
  7138. **/
  7139. $list = array();
  7140. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,number,features');
  7141. foreach ($rows as $key=>$value)
  7142. {
  7143. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"');
  7144. $zh = '';
  7145. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and time = "0" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','num,stime');
  7146. foreach ($zt as $v)
  7147. {
  7148. $zh .= $v['num']." / ".date('Y-m-d',$v['stime'])."<br>";
  7149. }
  7150. $zt = array_sum(array_column($zt,'num'));
  7151. $number = $value['number'];
  7152. $ftime = time()-15*24*3600;
  7153. $warehouse = $this->warehouse->read($value['warehouse']);
  7154. $rows[$key]['warehouse'] = $warehouse['title'];
  7155. $rows[$key]['number'] = $c;
  7156. $rows[$key]['features'] = $zh;
  7157. $rows[$key]['hb'] = $c+$zt;
  7158. }
  7159. $title = "导出库存数据及在途中数据".date('Y-m-d',time());
  7160. $titlename = "<table border=1>
  7161. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7162. <tr align='center'>
  7163. <td>仓库</td>
  7164. <td>SKU</td>
  7165. <td>产品</td>
  7166. <td>库存数量</td>
  7167. <td>在途数量及预达日期</td>
  7168. <td>在途+库存数量</td>
  7169. </tr>
  7170. </table>";
  7171. $filename = $title.".xls";
  7172. $tail = "";
  7173. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7174. }
  7175. if(isset($_GET['excel']))
  7176. {
  7177. $warehouse = $this->input->get('warehouse',true);
  7178. $sku = $this->input->get('sku',true);
  7179. $cz = $this->input->get('cz',true);
  7180. $text = $this->input->post('text',true);
  7181. $xztime = $this->input->get('xztime',true);
  7182. $timetk = $this->input->get('timetk',true);
  7183. $timetj = $this->input->get('timetj',true);
  7184. $timetk = strtotime($timetk);
  7185. $timetj = strtotime($timetj);
  7186. $where = "time = '0' ";
  7187. if($warehouse)
  7188. {
  7189. $where .= " and warehouse = '$warehouse'";
  7190. }
  7191. if($sku)
  7192. {
  7193. $where .= " and sku = '$sku'";
  7194. }
  7195. if($text)
  7196. {
  7197. $where .= " and text like '%$text%'";
  7198. }
  7199. if($cz != '')
  7200. {
  7201. $where .= " and cz = '$cz'";
  7202. }
  7203. if($timetk && $timetj)
  7204. {
  7205. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  7206. }
  7207. //数据排序
  7208. $order_str = $xztime." desc";
  7209. //取得信息列表
  7210. $zh = array();
  7211. $info_list = $this->whlabeltransport->find_all($where,'warehouse,sku,title,num,features,enter,stime,text');
  7212. foreach ($info_list as $v)
  7213. {
  7214. $c = $this->whlabel->find_count('state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');
  7215. $warehouse = $this->warehouse->read($v['warehouse']);
  7216. $v['warehouse'] = $warehouse['title'];
  7217. $v['enter'] = date('Y-m-d H:i:s',$v['enter']);
  7218. $v['stime'] = date('Y-m-d',$v['stime']);
  7219. if(isset($zh[$v['features']]))
  7220. {
  7221. $zh[$v['features']]['num'] += $v['num'];
  7222. }
  7223. else
  7224. {
  7225. $zh[$v['features']] = $v;
  7226. }
  7227. $zh[$v['features']]['features'] = $c;
  7228. }
  7229. $title = "在途数据".date('Y-m-d',time());
  7230. $titlename = "<table border=1>
  7231. <tr align='center'>
  7232. <td>仓库</td>
  7233. <td>SKU</td>
  7234. <td>名称</td>
  7235. <td>在途数量</td>
  7236. <td>库存数量</td>
  7237. <td>添加在途日期</td>
  7238. <td>预达日期</td>
  7239. <td>备注</td>
  7240. </tr>
  7241. </table>";
  7242. $filename = $title.".xls";
  7243. $tail = "";
  7244. $this->excel->get_fz2($zh,$titlename,$filename,$tail);
  7245. }
  7246. }
  7247. public function _fc()
  7248. {
  7249. $vip = 0;
  7250. if(isset($_SESSION['api']))
  7251. {
  7252. $user = $this->user->get_api($_SESSION['api']);
  7253. if($user['vip'] == 1)
  7254. {
  7255. $vip = 1;
  7256. }
  7257. }
  7258. else
  7259. {
  7260. header('Location: /');exit;
  7261. }
  7262. $post = $this->input->post(NULL, TRUE);
  7263. if(isset($post['page']))
  7264. {
  7265. $page = $this->input->post('page',true);
  7266. $perpage = $this->input->post('perpage',true);
  7267. $category = $this->input->post('category',true);
  7268. $size = $this->input->post('size',true);
  7269. $grade = $this->input->post('grade',true);
  7270. $color = $this->input->post('color',true);
  7271. $lowe = $this->input->post('lowe',true);
  7272. $sku = $this->input->post('sku');
  7273. $title = $this->input->post('title');
  7274. $warehouse = $this->input->post('warehouse',true);
  7275. $usa = $this->input->post('usa',true);
  7276. $purchase = $this->input->post('purchase',true);
  7277. $lacetype = $this->input->post('lacetype',true);
  7278. $haircap = $this->input->post('haircap',true);
  7279. $density = $this->input->post('density',true);
  7280. $details = $this->input->post('details',true);
  7281. $state = $this->input->post('state',true);
  7282. $ktime = $this->input->post('ktime',true);
  7283. $jtime = $this->input->post('jtime',true);
  7284. $ktime = strtotime($ktime);
  7285. $jtime = strtotime($jtime);
  7286. $where = "state = '11'";$gj = "";$ck = "";
  7287. if($lacetype)
  7288. {
  7289. $where .= " and features like '%-$lacetype-%'";
  7290. }
  7291. if($category)
  7292. {
  7293. $where .= " and features like '%-$category-%'";
  7294. }
  7295. if($size)
  7296. {
  7297. $where .= " and features like '%-$size-%'";
  7298. }
  7299. if($grade)
  7300. {
  7301. $where .= " and features like '%-$grade-%'";
  7302. }
  7303. if($color)
  7304. {
  7305. $where .= " and features like '%-$color-%'";
  7306. }
  7307. if($lowe)
  7308. {
  7309. $where .= " and features like '%-$lowe-%'";
  7310. }
  7311. if($haircap)
  7312. {
  7313. $where .= " and features like '%-$haircap-%'";
  7314. }
  7315. if($density)
  7316. {
  7317. $where .= " and features like '%-$density-%'";
  7318. }
  7319. if($usa)
  7320. {
  7321. if(!$warehouse)
  7322. {
  7323. $where .= " and (warehouse = '5' or warehouse = '8')";
  7324. }
  7325. }
  7326. if($warehouse)
  7327. {
  7328. $where .= " and warehouse = '$warehouse'";
  7329. }
  7330. if($details)
  7331. {
  7332. $where .= " and details = '$details'";
  7333. }
  7334. if($purchase)
  7335. {
  7336. $where .= " and purchase = '$purchase'";
  7337. }
  7338. if($state)
  7339. {
  7340. $where .= " and state = '$state'";
  7341. }
  7342. if($ktime && $jtime)
  7343. {
  7344. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7345. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7346. }
  7347. //数据排序
  7348. $order_str = "id desc";
  7349. if(empty($page))
  7350. {
  7351. $start = 0;
  7352. $perpage = 1;
  7353. }
  7354. else
  7355. {
  7356. $start = ($page - 1)*$perpage;
  7357. }
  7358. if($sku)
  7359. {
  7360. $sku = trim($sku,' ');
  7361. $sku = trim($sku,' ');
  7362. $where .= " and sku like '%$sku%'";
  7363. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7364. }
  7365. else if($title)
  7366. {
  7367. $title = trim($title,' ');
  7368. $title = trim($title,' ');
  7369. $where .= " and title like '%$title%'";
  7370. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7371. }
  7372. else
  7373. {
  7374. //$where .= " and time > '$ktime' and time < '$jtime'";
  7375. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7376. }
  7377. //取得信息列表
  7378. $rows = array();$list = array();
  7379. foreach ($info_list as $key=>$value)
  7380. {
  7381. $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'].'"');
  7382. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7383. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7384. $warehouse = $this->warehouse->read($value['warehouse']);
  7385. $info_list[$key]['warehouse'] = $warehouse['title'];
  7386. $info_list[$key]['number'] = $g;
  7387. $info_list[$key]['features'] = $x;
  7388. $info_list[$key]['x'] = $s;
  7389. }
  7390. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  7391. $pagenum = ceil($total/$perpage);
  7392. $over = $total-($start+$perpage);
  7393. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  7394. echo json_encode($rows);exit;
  7395. }
  7396. $this->data['vip'] = $vip;
  7397. $this->_Template('whlabel_fc',$this->data);
  7398. }
  7399. public function _fcmb()
  7400. {
  7401. $where = "sku != 'Preset'";
  7402. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title');
  7403. foreach ($rows as $k=>$v)
  7404. {
  7405. $warehouse = $this->warehouse->read($v['warehouse']);
  7406. $rows[$k]['warehouse'] = $warehouse['title'];
  7407. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "'.$v['warehouse'].'" and sku = "'.$v['sku'].'" and state = 11');
  7408. $rows[$k]['t'] = '';
  7409. $rows[$k]['n'] = '';
  7410. }
  7411. $title = "封货产品数据导入模板";
  7412. $titlename = "<table border=1>
  7413. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7414. <tr align='center'>
  7415. <td>仓库</td>
  7416. <td>SKU</td>
  7417. <td>产品</td>
  7418. <td>封存产品总数量</td>
  7419. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7420. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7421. </tr>
  7422. </table>";
  7423. $filename = $title.".xls";
  7424. $tail = "";
  7425. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7426. }
  7427. public function _fcexcel()
  7428. {
  7429. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7430. $config['upload_path'] = '.'.$dir ;
  7431. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7432. $config['allowed_types'] = 'xls|xlsx|csv';
  7433. $config['max_size'] = 10240;
  7434. $this->load->library('upload', $config);
  7435. $this->upload->initialize($config);
  7436. if ($this->upload->do_upload('userfile'))
  7437. {
  7438. $full_path = $dir.$this->upload->data('file_name');
  7439. $fileName = '.' . $full_path;
  7440. if (!file_exists($fileName))
  7441. {
  7442. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7443. }
  7444. else
  7445. {
  7446. libxml_use_internal_errors(true);
  7447. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7448. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7449. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7450. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7451. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7452. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7453. ++$column;//如果列数大于26行
  7454. $list = array();
  7455. for ($i = 2; $i <= $row; $i++) // 行数循环
  7456. {
  7457. $data = array();
  7458. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7459. {
  7460. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7461. }
  7462. $list[] = $data;
  7463. }
  7464. }
  7465. $i = 0;$j = 0;$ed = array();
  7466. foreach ($list as $key=>$value)
  7467. {
  7468. $time = time();
  7469. if($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4']))
  7470. {
  7471. continue;
  7472. }
  7473. $warehouse = $this->warehouse->get_title($value['0']);
  7474. $sku = $value['1'];
  7475. $type = $value['4'];//调整方式0扣减1删除
  7476. $num = $value['5'];//调整数量
  7477. //$text = $value['4'];//扣减说明
  7478. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7479. if(!$d)//如果没有这个SKU
  7480. {
  7481. $ed[] = array($sku.'-库存中不存在此SKU');
  7482. $j++;
  7483. continue;
  7484. }
  7485. if(!isset($warehouse['id']))
  7486. {
  7487. $ed[] = array($sku.'-仓库名错误!');
  7488. $j++;
  7489. continue;
  7490. }
  7491. if($type == 1 || $type == 2)//扣减库存
  7492. {
  7493. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and state = 11');
  7494. if(count($data) < abs($num))
  7495. {
  7496. $ed[] = array($sku.'-数量大于封存产品剩余数量!');
  7497. $j++;
  7498. continue;
  7499. }
  7500. if($type == 1)//转入库存
  7501. {
  7502. for($i=0;$i<abs($num);$i++)
  7503. {
  7504. $this->whlabel->save(array('state'=>0,'oldstate'=>11,'time'=>$time),$data[$i]['id']);
  7505. }
  7506. }
  7507. else if($type == 2)//删除
  7508. {
  7509. for($i=0;$i<abs($num);$i++)
  7510. {
  7511. $this->whlabel->remove($data[$i]['id']);
  7512. }
  7513. }
  7514. }
  7515. else if($type == 0)//增加库存
  7516. {
  7517. $post['sku'] = $d['sku'];
  7518. $post['shop'] = '';
  7519. $post['warehouse'] = $warehouse['id'];
  7520. $post['purchase'] = $d['purchase'];
  7521. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7522. $post['state'] = 11;
  7523. $post['title'] = $d['title'];
  7524. $post['number'] = $d['number'];
  7525. $post['features'] = $d['features'];
  7526. $post['enter'] = $time;
  7527. $post['time'] = $time;//操作时间
  7528. for($i=0;$i<$num;$i++)
  7529. {
  7530. $post['label'] = time().rand(100,999).$i;
  7531. $this->whlabel->insert($post);
  7532. }
  7533. }
  7534. sleep(1);//防止入库时间一样,需要延迟1秒
  7535. }
  7536. if($j > 0)
  7537. {
  7538. $tt = date('Ymd',time());
  7539. $title = '库存导入错误信息-'.$tt;
  7540. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7541. $tail = "\n";
  7542. $filename = $title.".xls";
  7543. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7544. $dir = '/data/excel/'.$time.'/';
  7545. $file_name = 'error_'.$time.rand(1000,9999);
  7546. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7547. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7548. fwrite($myfile,$ecl);
  7549. fclose($myfile);
  7550. $error = $dir.$file_name.'.xls';
  7551. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7552. }
  7553. else
  7554. {
  7555. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7556. }
  7557. }
  7558. }
  7559. public function _fcjxc($arg_array)
  7560. {
  7561. if(isset($_GET['excel']))
  7562. {
  7563. $category = $this->input->get('category',true);
  7564. $size = $this->input->get('size',true);
  7565. $grade = $this->input->get('grade',true);
  7566. $color = $this->input->get('color',true);
  7567. $lowe = $this->input->get('lowe',true);
  7568. $sku = $this->input->get('sku');
  7569. $title = $this->input->get('title');
  7570. $warehouse = $arg_array[0];
  7571. $usa = $this->input->get('usa',true);
  7572. $purchase = $this->input->get('purchase',true);
  7573. $lacetype = $this->input->get('lacetype',true);
  7574. $haircap = $this->input->get('haircap',true);
  7575. $density = $this->input->get('density',true);
  7576. $title = $this->input->get('title',true);
  7577. $state = $this->input->get('state',true);
  7578. $ktime = $this->input->get('ktime',true);
  7579. $jtime = $this->input->get('jtime',true);
  7580. $where = "state=11";$gj = "";$ck = "";
  7581. if($lacetype)
  7582. {
  7583. $where .= " and features like '%-$lacetype-%'";
  7584. }
  7585. if($category)
  7586. {
  7587. $where .= " and features like '%-$category-%'";
  7588. }
  7589. if($size)
  7590. {
  7591. $where .= " and features like '%-$size-%'";
  7592. }
  7593. if($grade)
  7594. {
  7595. $where .= " and features like '%-$grade-%'";
  7596. }
  7597. if($color)
  7598. {
  7599. $where .= " and features like '%-$color-%'";
  7600. }
  7601. if($lowe)
  7602. {
  7603. $where .= " and features like '%-$lowe-%'";
  7604. }
  7605. if($haircap)
  7606. {
  7607. $where .= " and features like '%-$haircap-%'";
  7608. }
  7609. if($density)
  7610. {
  7611. $where .= " and features like '%-$density-%'";
  7612. }
  7613. if($usa)
  7614. {
  7615. if(!$warehouse)
  7616. {
  7617. $where .= " and (warehouse = '5' or warehouse = '8')";
  7618. }
  7619. }
  7620. if($warehouse)
  7621. {
  7622. $where .= " and warehouse = '$warehouse'";
  7623. }
  7624. if($purchase)
  7625. {
  7626. $where .= " and purchase = '$purchase'";
  7627. }
  7628. if($state)
  7629. {
  7630. $where .= " and state = '$state'";
  7631. }
  7632. $order_str = "id desc";
  7633. if($sku)
  7634. {
  7635. $sku = trim($sku,' ');
  7636. $sku = trim($sku,' ');
  7637. $where .= " and sku like '%$sku%'";
  7638. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7639. }
  7640. else if($title)
  7641. {
  7642. $title = trim($title,' ');
  7643. $title = trim($title,' ');
  7644. $where .= " and title like '%$title%'";
  7645. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7646. }
  7647. else
  7648. {
  7649. //$where .= " and time > '$ktime' and time < '$jtime'";
  7650. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7651. }
  7652. //取得信息列表
  7653. $rows = array();$list = array();
  7654. foreach ($info_list as $key=>$value)
  7655. {
  7656. $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'].'"');
  7657. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7658. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7659. $rows[$key] = $value;
  7660. $warehouse = $this->warehouse->read($value['warehouse']);
  7661. $rows[$key]['warehouse'] = $warehouse['title'];
  7662. $rows[$key]['features'] = $g;
  7663. $rows[$key]['a'] = $x;
  7664. $rows[$key]['b'] = $s;
  7665. }
  7666. $title = "总统计表";
  7667. $titlename = "<table border=1>
  7668. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7669. <tr align='center'>
  7670. <td>仓库</td>
  7671. <td>SKU</td>
  7672. <td>产品名称</td>
  7673. <td>录入总量</td>
  7674. <td>取出总量</td>
  7675. <td>剩余总量</td>
  7676. </tr>
  7677. </table>";
  7678. $filename = $title.".xls";
  7679. $tail = "";
  7680. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7681. }
  7682. $vip = 0;
  7683. if(isset($_SESSION['api']))
  7684. {
  7685. $user = $this->user->get_api($_SESSION['api']);
  7686. if($user['vip'] == 1)
  7687. {
  7688. $vip = 1;
  7689. }
  7690. }
  7691. else
  7692. {
  7693. header('Location: /');exit;
  7694. }
  7695. $post = $this->input->post(NULL, TRUE);
  7696. if(isset($post['page']))
  7697. {
  7698. $page = $this->input->post('page',true);
  7699. $perpage = $this->input->post('perpage',true);
  7700. $category = $this->input->post('category',true);
  7701. $size = $this->input->post('size',true);
  7702. $grade = $this->input->post('grade',true);
  7703. $color = $this->input->post('color',true);
  7704. $lowe = $this->input->post('lowe',true);
  7705. $sku = $this->input->post('sku');
  7706. $title = $this->input->post('title');
  7707. $warehouse = $arg_array[0];
  7708. $usa = $this->input->post('usa',true);
  7709. $purchase = $this->input->post('purchase',true);
  7710. $lacetype = $this->input->post('lacetype',true);
  7711. $haircap = $this->input->post('haircap',true);
  7712. $density = $this->input->post('density',true);
  7713. $title = $this->input->post('title',true);
  7714. $state = $this->input->post('state',true);
  7715. $ktime = $this->input->post('ktime',true);
  7716. $jtime = $this->input->post('jtime',true);
  7717. $ktime = strtotime($ktime);
  7718. $jtime = strtotime($jtime);
  7719. $where = "state=11";$gj = "";$ck = "";
  7720. if($lacetype)
  7721. {
  7722. $where .= " and features like '%-$lacetype-%'";
  7723. }
  7724. if($category)
  7725. {
  7726. $where .= " and features like '%-$category-%'";
  7727. }
  7728. if($size)
  7729. {
  7730. $where .= " and features like '%-$size-%'";
  7731. }
  7732. if($grade)
  7733. {
  7734. $where .= " and features like '%-$grade-%'";
  7735. }
  7736. if($color)
  7737. {
  7738. $where .= " and features like '%-$color-%'";
  7739. }
  7740. if($lowe)
  7741. {
  7742. $where .= " and features like '%-$lowe-%'";
  7743. }
  7744. if($haircap)
  7745. {
  7746. $where .= " and features like '%-$haircap-%'";
  7747. }
  7748. if($density)
  7749. {
  7750. $where .= " and features like '%-$density-%'";
  7751. }
  7752. if($usa)
  7753. {
  7754. if(!$warehouse)
  7755. {
  7756. $where .= " and (warehouse = '5' or warehouse = '8')";
  7757. }
  7758. }
  7759. if($warehouse)
  7760. {
  7761. $where .= " and warehouse = '$warehouse'";
  7762. }
  7763. if($purchase)
  7764. {
  7765. $where .= " and purchase = '$purchase'";
  7766. }
  7767. if($state)
  7768. {
  7769. $where .= " and state = '$state'";
  7770. }
  7771. if($ktime && $jtime)
  7772. {
  7773. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7774. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7775. }
  7776. //数据排序
  7777. $order_str = "id desc";$xs=0;
  7778. $rows = array();$list = array();
  7779. if(empty($page))
  7780. {
  7781. $start = 0;
  7782. $perpage = 1;
  7783. }
  7784. else
  7785. {
  7786. $start = ($page - 1)*$perpage;
  7787. }
  7788. if($sku || $title)
  7789. {
  7790. if($title)
  7791. {
  7792. $title = trim($title,' ');
  7793. $title = trim($title,' ');
  7794. $where .= " and title like '%$title%'";
  7795. }
  7796. else
  7797. {
  7798. $sku = trim($sku,' ');
  7799. $sku = trim($sku,' ');
  7800. $where .= " and sku like '%$sku%'";
  7801. }
  7802. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7803. foreach ($info_list as $key=>$value)
  7804. {
  7805. $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'].'"');
  7806. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7807. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7808. $rows[$key] = $value;
  7809. $warehouse = $this->warehouse->read($value['warehouse']);
  7810. $rows[$key]['warehouse'] = $warehouse['title'];
  7811. $rows[$key]['features'] = $g;
  7812. $rows[$key]['a'] = $x;
  7813. $rows[$key]['b'] = $s;
  7814. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7815. $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天销量
  7816. $yj = $c/($xl/30);
  7817. if($yj < 7)
  7818. {
  7819. $rows[$key]['y'] = round($yj).'天销量';
  7820. }
  7821. else
  7822. {
  7823. $rows[$key]['y'] = '正常';
  7824. }
  7825. }
  7826. }
  7827. else
  7828. {
  7829. //$where .= " and time > '$ktime' and time < '$jtime'";
  7830. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7831. foreach ($info_list as $key=>$value)
  7832. {
  7833. $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'].'"');
  7834. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7835. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7836. $zs[$key] = $value;
  7837. $warehouse = $this->warehouse->read($value['warehouse']);
  7838. $zs[$key]['warehouse'] = $warehouse['title'];
  7839. $zs[$key]['features'] = $g;
  7840. $zs[$key]['a'] = $x;
  7841. $zs[$key]['b'] = $s;
  7842. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7843. $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天销量
  7844. $yj = $c/($xl/30);
  7845. if($yj < 7)
  7846. {
  7847. $zs[$key]['y'] = round($yj).'天销量';
  7848. $rows[$key] = $zs[$key];
  7849. }
  7850. }
  7851. }
  7852. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id'));
  7853. $pagenum = ceil($total/$perpage);
  7854. $over = $total-($start+$perpage);
  7855. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
  7856. echo json_encode($rows);exit;
  7857. }
  7858. $this->data['arg_array'] = $arg_array[0];
  7859. $this->_Template('whlabel_fcjxc',$this->data);
  7860. }
  7861. public function _0kcdel()
  7862. {
  7863. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7864. $config['upload_path'] = '.'.$dir ;
  7865. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7866. $config['allowed_types'] = 'xls|xlsx|csv';
  7867. $config['max_size'] = 10240;
  7868. $this->load->library('upload', $config);
  7869. $this->upload->initialize($config);
  7870. if ($this->upload->do_upload('userfile'))
  7871. {
  7872. $full_path = $dir.$this->upload->data('file_name');
  7873. $fileName = '.' . $full_path;
  7874. if (!file_exists($fileName))
  7875. {
  7876. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7877. }
  7878. else
  7879. {
  7880. require_once "./data/excel/PHPExcel/IOFactory.php";
  7881. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7882. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7883. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7884. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7885. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7886. ++$column;//如果列数大于26行
  7887. $list = array();
  7888. for ($i = 2; $i <= $row; $i++) // 行数循环
  7889. {
  7890. $data = array();
  7891. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7892. {
  7893. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7894. }
  7895. $list[] = $data;
  7896. }
  7897. }
  7898. $i = 0;$j = 0;$ed = array();
  7899. foreach ($list as $key=>$value)
  7900. {
  7901. $time = time();
  7902. if($value['0'] == "" || $value['1'] == "")
  7903. {
  7904. continue;
  7905. }
  7906. $warehouse = $this->warehouse->get_title($value['0']);
  7907. $sku = $value['1'];
  7908. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7909. if(!$d)//如果没有这个SKU
  7910. {
  7911. $ed[] = array($sku.'-库存中不存在此SKU');
  7912. $j++;
  7913. continue;
  7914. }
  7915. if(!isset($warehouse['id']))
  7916. {
  7917. $ed[] = array($sku.'-仓库名错误!');
  7918. $j++;
  7919. continue;
  7920. }
  7921. $z = $this->whlabel->find_count('sku = "'.$sku.'" and zd = "" and state = 0 and warehouse = "'.$warehouse['id'].'"');
  7922. if($z < 1)
  7923. {
  7924. $z = $this->whlabel->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'"');
  7925. foreach ($z as $v)
  7926. {
  7927. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  7928. if(count($zt) > 0)
  7929. {
  7930. $ed[] = array($sku.'-有在途库存无法删除!');
  7931. $j++;
  7932. continue;
  7933. }
  7934. $this->whlabel->remove($v['id']);
  7935. }
  7936. }
  7937. else
  7938. {
  7939. $ed[] = array($sku.'-非0库存!');
  7940. $j++;
  7941. continue;
  7942. }
  7943. }
  7944. if($j > 0)
  7945. {
  7946. $tt = date('Ymd',time());
  7947. $title = '删除0库存错误信息-'.$tt;
  7948. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7949. $tail = "\n";
  7950. $filename = $title.".xls";
  7951. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7952. $dir = '/data/excel/'.$time.'/';
  7953. $file_name = 'error_'.$time.rand(1000,9999);
  7954. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7955. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7956. fwrite($myfile,$ecl);
  7957. fclose($myfile);
  7958. $error = $dir.$file_name.'.xls';
  7959. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7960. }
  7961. else
  7962. {
  7963. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7964. }
  7965. }
  7966. }
  7967. public function _gbhtype()
  7968. {
  7969. $post = $this->input->post(NULL, TRUE);
  7970. if(isset($post['s']))
  7971. {
  7972. $n = $this->input->post('n');
  7973. $d = $this->input->post('s');
  7974. if(!$d)
  7975. {
  7976. echo json_encode(array('msg'=>'未选择需要更改的商品','success'=>false));exit;
  7977. }
  7978. $d = explode(',',trim($d,','));
  7979. $t = $this->whlabel_type->read($n);
  7980. //循环删除记录
  7981. foreach ($d as $v)
  7982. {
  7983. $u = $this->whlabel->read($v);
  7984. $data = $this->whlabel->find_all("sku = '".$u['sku']."' and purchase = '".$u['purchase']."' and features = '".$u['features']."' and warehouse = '".$u['warehouse']."'");
  7985. foreach ($data as $val)
  7986. {
  7987. $this->whlabel->save(array('type'=>$n),$val['id']);
  7988. }
  7989. }
  7990. echo json_encode(array('d'=>$d,'t'=>$t['title'],'msg'=>'修改成功!','success'=>true));
  7991. }
  7992. }
  7993. //出库、退库导出
  7994. public function _dccrtype()
  7995. {
  7996. $classid = $this->classid->sku();
  7997. $pm = $classid;
  7998. $typeclass = array();
  7999. $tc = $this->typeclass->find_all();
  8000. foreach ($tc as $v)
  8001. {
  8002. $typeclass[$v['id']] = $v;
  8003. }
  8004. $prc = array();
  8005. $purchase = $this->purchase->find_all();
  8006. foreach($purchase as $k=>$v)
  8007. {
  8008. $prc[$v['id']] = $v['title'];
  8009. }
  8010. if(isset($_GET['sid']))
  8011. {
  8012. $wh = array();
  8013. $w = $this->warehouse->find_all('1=1','id,title');
  8014. foreach ($w as $v)
  8015. {
  8016. $wh[$v['id']] = $v['title'];
  8017. }
  8018. $type = $this->input->get('excel',true);
  8019. $category = $this->input->get('category',true);
  8020. $size = $this->input->get('size',true);
  8021. $grade = $this->input->get('grade',true);
  8022. $color = $this->input->get('color',true);
  8023. $lowe = $this->input->get('lowe',true);
  8024. $sku = $this->input->get('sku',true);
  8025. $warehouse = $this->input->get('warehouse',true);
  8026. $lacetype = $this->input->get('lacetype',true);
  8027. $lacecolor = $this->input->get('lacecolor',true);
  8028. $density = $this->input->get('density',true);
  8029. $haircap = $this->input->get('haircap',true);
  8030. $purchase = $this->input->get('purchase',true);
  8031. $title = $this->input->get('title',true);
  8032. $state = $this->input->get('state',true);
  8033. $sid = $this->input->get('sid',true);
  8034. $ktime = $this->input->get('ktime',true);
  8035. $jtime = $this->input->get('jtime',true);
  8036. $ktime = strtotime($ktime);
  8037. $jtime = strtotime($jtime);
  8038. $where = "1=1";$gj = "";$ck = "";
  8039. if($category)
  8040. {
  8041. $where .= " and features like '%-$category-%'";
  8042. }
  8043. if($size)
  8044. {
  8045. $where .= " and features like '%-$size-%'";
  8046. }
  8047. if($grade)
  8048. {
  8049. $where .= " and features like '%-$grade-%'";
  8050. }
  8051. if($color)
  8052. {
  8053. $where .= " and features like '%-$color-%'";
  8054. }
  8055. if($lowe)
  8056. {
  8057. $where .= " and features like '%-$lowe-%'";
  8058. }
  8059. if($warehouse)
  8060. {
  8061. $where .= " and warehouse = '$warehouse'";
  8062. }
  8063. if($purchase)
  8064. {
  8065. $where .= " and purchase = '$purchase'";
  8066. }
  8067. if($state)
  8068. {
  8069. $where .= " and state = '$state'";
  8070. }
  8071. if($lacetype)
  8072. {
  8073. $where .= " and features like '%-$lacetype-%'";
  8074. }
  8075. if($lacecolor)
  8076. {
  8077. $where .= " and features like '%-$lacecolor-%'";
  8078. }
  8079. if($density)
  8080. {
  8081. $where .= " and features like '%-$density-%'";
  8082. }
  8083. if($haircap)
  8084. {
  8085. $where .= " and features like '%-$haircap-%'";
  8086. }
  8087. if($title)
  8088. {
  8089. $title = trim($title,' ');
  8090. $title = trim($title,' ');
  8091. $where .= " and title like '%$title%'";
  8092. }
  8093. if($sku)
  8094. {
  8095. $sku = trim($sku,' ');
  8096. $sku = trim($sku,' ');
  8097. $where .= " and sku like '%$sku%'";
  8098. }
  8099. if($ktime && $jtime)
  8100. {
  8101. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8102. }
  8103. $sidwhere = '';
  8104. if($sid)
  8105. {
  8106. $sd = "";
  8107. $s = explode(',',trim($sid,','));
  8108. foreach ($s as $value)
  8109. {
  8110. $sd .= " id = ".$value." or";
  8111. }
  8112. $sidwhere = " and (".rtrim($sd,'or').")";
  8113. }
  8114. //数据排序
  8115. $order_str = "time desc";
  8116. if(empty($page))
  8117. {
  8118. $start = 0;
  8119. $perpage = 1;
  8120. }
  8121. else
  8122. {
  8123. $start = ($page - 1)*$perpage;
  8124. }
  8125. $wh = array();
  8126. $w = $this->warehouse->find_all('1=1','id,title');
  8127. foreach ($w as $v)
  8128. {
  8129. $wh[$v['id']] = $v['title'];
  8130. }
  8131. $wt = array();
  8132. $whlabel_type = $this->whlabel_type->find_all();
  8133. foreach ($whlabel_type as $v)
  8134. {
  8135. $wt[$v['id']] = $v['title'];
  8136. }
  8137. $classid = $this->classid->sku();
  8138. $list = array();
  8139. $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');
  8140. foreach ($rows_r as $key=>$value)
  8141. {
  8142. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8143. $pm = $classid;
  8144. $jm = $classid;
  8145. $rows_r[$key]['enter'] = '入库';
  8146. $rows_r[$key]['time'] = $value['enter'];
  8147. if($value['rktype'] == 1)
  8148. {
  8149. $rows_r[$key]['rktype'] = '采购入库';
  8150. }
  8151. else if($value['rktype'] == 2)
  8152. {
  8153. $rows_r[$key]['rktype'] = '盘盈调整';
  8154. }
  8155. else if($value['rktype'] == 3)
  8156. {
  8157. $rows_r[$key]['rktype'] = '其他调整入库';
  8158. }
  8159. else if($value['rktype'] == 4)
  8160. {
  8161. $rows_r[$key]['rktype'] = '其他调整入库';
  8162. }
  8163. else if($value['rktype'] == 5)
  8164. {
  8165. $rows_r[$key]['rktype'] = '退库入库';
  8166. }
  8167. else if($value['rktype'] == 6)
  8168. {
  8169. $rows_r[$key]['rktype'] = '退货可用入库';
  8170. }
  8171. else if($value['rktype'] == 7)
  8172. {
  8173. $rows_r[$key]['rktype'] = '形态转换入库';
  8174. }
  8175. else
  8176. {
  8177. $rows_r[$key]['rktype'] = '';
  8178. }
  8179. $features = explode('-',trim($value['features'],'-'));
  8180. foreach($features as $v)
  8181. {
  8182. if(isset($typeclass[$v]))
  8183. {
  8184. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8185. $pm[$typeclass[$v]['classid']] = $zh[0];
  8186. }
  8187. if(isset($typeclass[$v]))
  8188. {
  8189. if(isset($jm[$typeclass[$v]['classid']]))
  8190. {
  8191. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8192. }
  8193. }
  8194. }
  8195. $zh = implode(" ",$pm);
  8196. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8197. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8198. $rows_r[$key]['zh'] = $zh;
  8199. $jm = array_filter($jm);
  8200. $rows_r[$key]['features'] = implode("-",$jm);
  8201. $rows_r[$key]['number'] = $this->whlabel->find_count($where." and enter = '".$value['enter']."' ".$sidwhere);
  8202. }
  8203. $rows_c = $this->whlabel->find_all($where." and outk > '$ktime' and outk < '$jtime' ".$sidwhere,'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  8204. foreach ($rows_c as $key=>$value)
  8205. {
  8206. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8207. $pm = $classid;
  8208. $jm = $classid;
  8209. $rows_c[$key]['time'] = $value['outk'];
  8210. $rows_c[$key]['outk'] = '出库';
  8211. if($value['cktype'] == 1)
  8212. {
  8213. $rows_c[$key]['cktype'] = '销售出库';
  8214. }
  8215. else if($value['cktype'] == 2)
  8216. {
  8217. $rows_c[$key]['cktype'] = '销售美国出库';
  8218. }
  8219. else if($value['cktype'] == 3)
  8220. {
  8221. $rows_c[$key]['cktype'] = '盘亏调整';
  8222. }
  8223. else if($value['cktype'] == 4)
  8224. {
  8225. $rows_c[$key]['cktype'] = '其他调整出库';
  8226. }
  8227. else if($value['cktype'] == 5)
  8228. {
  8229. $rows_c[$key]['cktype'] = '形态转换出库';
  8230. }
  8231. else
  8232. {
  8233. $rows_c[$key]['cktype'] = '';
  8234. }
  8235. $features = explode('-',trim($value['features'],'-'));
  8236. foreach($features as $v)
  8237. {
  8238. if(isset($typeclass[$v]))
  8239. {
  8240. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8241. $pm[$typeclass[$v]['classid']] = $zh[0];
  8242. }
  8243. if(isset($typeclass[$v]))
  8244. {
  8245. if(isset($jm[$typeclass[$v]['classid']]))
  8246. {
  8247. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8248. }
  8249. }
  8250. }
  8251. $zh = implode(" ",$pm);
  8252. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8253. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8254. $rows_c[$key]['zh'] = $zh;
  8255. $jm = array_filter($jm);
  8256. $rows_c[$key]['features'] = implode("-",$jm);
  8257. $rows_c[$key]['number'] = 1;
  8258. }
  8259. $merged = $rows_r;
  8260. foreach ($rows_c as $key => $value)
  8261. {
  8262. if (isset($merged[$key]))
  8263. {
  8264. $merged[] = $value;
  8265. }
  8266. else
  8267. {
  8268. $merged[$key] = $value;
  8269. }
  8270. }
  8271. usort($merged, function($a, $b)
  8272. {
  8273. return $a['time'] - $b['time'];
  8274. });
  8275. foreach ($merged as $key=>$value)
  8276. {
  8277. $merged[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  8278. }
  8279. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime);
  8280. $titlename = "<table border=1>
  8281. <tr align='center'>
  8282. <td>仓库</td>
  8283. <td>SKU</td>
  8284. <td>商品名称</td>
  8285. <td>仓库品名</td>
  8286. <td>料号</td>
  8287. <td>时间</td>
  8288. <td>操作</td>
  8289. <td>类型</td>
  8290. <td>数量</td>
  8291. <td>备注</td>
  8292. </tr>
  8293. </table>";
  8294. $filename = $title.".xlsx";
  8295. $tail = "";
  8296. $this->excel->get_fz2($merged,$titlename,$filename,$tail);
  8297. }
  8298. }
  8299. }