Whlabel.php 268 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507
  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. $this->load->_model("Model_logic_whlabel","logic_whlabel");
  40. }
  41. //定义方法的调用规则 获取URI第二段值
  42. public function _remap($arg,$arg_array)
  43. {
  44. if($arg == 'existence')//在库标签
  45. {
  46. $this->_existence();
  47. }
  48. else if($arg == 'cpbqdc')//在库标签
  49. {
  50. $this->_cpbqdc();
  51. }
  52. else if($arg == 'type')//进销存浏览
  53. {
  54. $this->_type();
  55. }
  56. else if($arg == 'typedy')//进销存浏览店员页面
  57. {
  58. $this->_typedy($arg_array);
  59. }
  60. else if($arg == 'typedy_ck')//进销存浏览店员页面
  61. {
  62. $this->_typedy_ck($arg_array);
  63. }
  64. else if($arg == 'typeck')
  65. {
  66. $this->_typeck($arg_array);
  67. }
  68. else if($arg == 'whlabeckdc')
  69. {
  70. $this->_whlabeckdc($arg_array);
  71. }
  72. else if($arg == 'usatype')//美仓进销存浏览
  73. {
  74. $this->_usatype();
  75. }
  76. else if($arg == 'usatypeapp')//美仓APP进销存浏览
  77. {
  78. $this->_usatypeapp();
  79. }
  80. else if($arg == 'enteradd')//入库操作
  81. {
  82. $this->_enteradd();
  83. }
  84. else if($arg == 'enteredit')//修改
  85. {
  86. $this->_enteredit($arg_array);
  87. }
  88. else if($arg == 'enter')//入库浏览
  89. {
  90. $this->_enter();
  91. }
  92. else if($arg == 'out')//出库浏览
  93. {
  94. $this->_out();
  95. }
  96. else if($arg == 'label')//出库标签浏览
  97. {
  98. $this->_label();
  99. }
  100. else if($arg == 'outorder')//独立站出库订单
  101. {
  102. $this->_outorder();
  103. }
  104. else if($arg == 'soutorder')//速卖通出库订单
  105. {
  106. $this->_soutorder();
  107. }
  108. else if($arg == 'toutorder')//TT出库订单
  109. {
  110. $this->_toutorder();
  111. }
  112. else if($arg == 'retreat')//退库订单
  113. {
  114. $this->_retreat();
  115. }
  116. else if($arg == 'retreatlk')//退库订单
  117. {
  118. $this->_retreatlk();
  119. }
  120. else if($arg == 'change')//更换标签
  121. {
  122. $this->_change();
  123. }
  124. else if($arg == 'del')//删除
  125. {
  126. $this->_del();
  127. }
  128. else if($arg == 'exceljxc')//进销存信息导出
  129. {
  130. $this->_exceljxc();
  131. }
  132. else if($arg == 'excelr')//入库信息导出
  133. {
  134. $this->_excelr();
  135. }
  136. else if($arg == 'excelct')//出库、退库信息导出
  137. {
  138. $this->_excelct();
  139. }
  140. else if($arg == 'dccrtype')//根据出入库类型导出
  141. {
  142. $this->_dccrtype();
  143. }
  144. else if($arg == 'excelcr')//出库、退库信息导出
  145. {
  146. $this->_excelcr();
  147. }
  148. else if($arg == 'kcyz')//库存验证
  149. {
  150. $this->_kcyz();
  151. }
  152. else if($arg == 'kj')//库存扣减
  153. {
  154. $this->_kj($arg_array);
  155. }
  156. else if($arg == 'presetout')//预设库存导入
  157. {
  158. $this->_presetout($arg_array);
  159. }
  160. else if($arg == 'presetedit')//预设库存导入
  161. {
  162. $this->_presetedit($arg_array);
  163. }
  164. else if($arg == 'summary')//汇总导出
  165. {
  166. $this->_summary($arg_array);
  167. }
  168. else if($arg == 'manifest')//usps发货清单
  169. {
  170. $this->_manifest();
  171. }
  172. else if($arg == 'abnormal')//占单异常
  173. {
  174. $this->_abnormal();
  175. }
  176. else if($arg == 'error')//0库存SKU
  177. {
  178. $this->_error();
  179. }
  180. else if($arg == 'errorexcel')//0库存SKU导出
  181. {
  182. $this->_errorexcel();
  183. }
  184. else if($arg == 'db')
  185. {
  186. $this->_db();
  187. }
  188. else if($arg == 'dbrk')
  189. {
  190. $this->_dbrk();
  191. }
  192. else if($arg == 'whlabelczdc')
  193. {
  194. $this->_whlabelczdc();
  195. }
  196. else if($arg == 'print')
  197. {
  198. $this->_print($arg_array);
  199. }
  200. else if($arg == 'usaprint')
  201. {
  202. $this->_usaprint($arg_array);
  203. }
  204. else if($arg == 'printck')
  205. {
  206. $this->_printck($arg_array);
  207. }
  208. else if($arg == 'printrk')
  209. {
  210. $this->_printrk($arg_array);
  211. }
  212. else if($arg == 'printxzrk')
  213. {
  214. $this->_printxzrk($arg_array);
  215. }
  216. else if($arg == 'printexcel')
  217. {
  218. $this->_printexcel($arg_array);
  219. }
  220. else if($arg == 'uck')
  221. {
  222. $this->_uck();
  223. }
  224. else if($arg == 'whlabelexcelzh')
  225. {
  226. $this->_whlabelexcelzh();
  227. }
  228. else if($arg == 'fc')
  229. {
  230. $this->_fc();
  231. }
  232. else if($arg == 'fcmb')
  233. {
  234. $this->_fcmb();
  235. }
  236. else if($arg == 'fcexcel')
  237. {
  238. $this->_fcexcel();
  239. }
  240. else if($arg == 'fcjxc')
  241. {
  242. $this->_fcjxc($arg_array);
  243. }
  244. else if($arg == '0kcdel')
  245. {
  246. $this->_0kcdel();//导表删除0库存
  247. }
  248. else if($arg == 'gbhtype')
  249. {
  250. $this->_gbhtype();//更改备货状态
  251. }
  252. else
  253. {
  254. $this->_index();
  255. }
  256. }
  257. //管理
  258. public function _index()
  259. {
  260. $post = $this->input->post(NULL, TRUE);
  261. if(isset($post['page']))
  262. {
  263. $page = $this->input->post('page',true);
  264. $perpage = $this->input->post('perpage',true);
  265. $sku = $this->input->post('sku',true);
  266. $number = $this->input->post('number',true);
  267. $warehouse = $this->input->post('warehouse',true);
  268. $purchase = $this->input->post('purchase',true);
  269. $orderinfo = $this->input->post('orderinfo',true);
  270. $waybill = $this->input->post('waybill',true);
  271. $category = $this->input->post('category',true);
  272. $size = $this->input->post('size',true);
  273. $grade = $this->input->post('grade',true);
  274. $color = $this->input->post('color',true);
  275. $lowe = $this->input->post('lowe',true);
  276. $state = $this->input->post('state',true);
  277. $label = $this->input->post('label',true);
  278. $timetk = $this->input->post('timetkk',true);
  279. $timetj = $this->input->post('timetjj',true);
  280. $timetk = strtotime($timetk);
  281. $timetj = strtotime($timetj);
  282. $where = "1=1 ";
  283. if($timetk && $timetj)
  284. {
  285. $where .= " and time > '$timetk' and time < '$timetj'";
  286. }
  287. if($sku)
  288. {
  289. $where .= " and sku = '$sku'";
  290. }
  291. if($number)
  292. {
  293. $where .= " and number = '$number'";
  294. }
  295. if($warehouse)
  296. {
  297. $where .= " and warehouse = '$warehouse'";
  298. }
  299. if($purchase)
  300. {
  301. $where .= " and purchase = '$purchase'";
  302. }
  303. if($orderinfo)
  304. {
  305. $where .= " and orderinfo = '$orderinfo'";
  306. }
  307. if($waybill)
  308. {
  309. $where .= " and waybill = '$waybill'";
  310. }
  311. if($category)
  312. {
  313. $where .= " and features like '%-$category-%'";
  314. }
  315. if($size)
  316. {
  317. $where .= " and features like '%-$size-%'";
  318. }
  319. if($grade)
  320. {
  321. $where .= " and features like '%-$grade-%'";
  322. }
  323. if($color)
  324. {
  325. $where .= " and features like '%-$color-%'";
  326. }
  327. if($lowe)
  328. {
  329. $where .= " and features like '%-$lowe-%'";
  330. }
  331. if($label)
  332. {
  333. $where .= " and label = '$label'";
  334. }
  335. if($state != '')
  336. {
  337. $where .= " and state = '$state'";
  338. }
  339. //数据排序
  340. $order_str = "time desc";
  341. if(empty($page))
  342. {
  343. $start = 0;
  344. $perpage = 1;
  345. }
  346. else
  347. {
  348. $start = ($page - 1)*$perpage;
  349. }
  350. //取得信息列表
  351. $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);
  352. foreach ($info_list as $key=>$value)
  353. {
  354. $warehouse = $this->warehouse->read($value['warehouse']);
  355. $info_list[$key]['warehouse'] = $warehouse['title'];
  356. $purchase = $this->purchase->read($value['purchase']);
  357. $info_list[$key]['purchase'] = $purchase['title'];
  358. if($value['enter'] != 0)
  359. {
  360. $info_list[$key]['enter'] = '<p>'.date('Y-m-d',$value['enter']).'</p><p>'.date('H:i:s',$value['enter']).'</p>';
  361. }
  362. else
  363. {
  364. $info_list[$key]['enter'] = "";
  365. }
  366. if($value['outk'] != 0)
  367. {
  368. $info_list[$key]['outk'] = '<p>'.date('Y-m-d',$value['outk']).'</p><p>'.date('H:i:s',$value['outk']).'</p>';
  369. }
  370. else
  371. {
  372. $info_list[$key]['outk'] = "";
  373. }
  374. if($value['printing'] != 0)
  375. {
  376. $info_list[$key]['printing'] = '<p>'.date('Y-m-d',$value['printing']).'</p><p>'.date('H:i:s',$value['printing']).'</p>';
  377. }
  378. else
  379. {
  380. $info_list[$key]['printing'] = "";
  381. }
  382. if($value['orderinfo'] == 0)
  383. {
  384. $info_list[$key]['orderinfo'] = "";
  385. }
  386. if($value['waybill'] == 0)
  387. {
  388. $info_list[$key]['waybill'] = "";
  389. }
  390. if($value['state'] == 0)
  391. {
  392. $info_list[$key]['state'] = "在库";
  393. }
  394. else if($value['state'] == 1)
  395. {
  396. $info_list[$key]['state'] = "出库";
  397. }
  398. else if($value['state'] == 2)
  399. {
  400. $info_list[$key]['state'] = "退库";
  401. }
  402. else if($value['state'] == 3)
  403. {
  404. $info_list[$key]['state'] = "调拨中";
  405. }
  406. else if($value['state'] == 4)
  407. {
  408. $info_list[$key]['state'] = "再加工";
  409. }
  410. else if($value['state'] == 5)
  411. {
  412. $info_list[$key]['state'] = "维修中";
  413. }
  414. else if($value['state'] == 6)
  415. {
  416. $info_list[$key]['state'] = "盘亏";
  417. }
  418. else if($value['state'] == 7)
  419. {
  420. $info_list[$key]['state'] = "更换标签";
  421. }
  422. else if($value['state'] == 8)
  423. {
  424. $info_list[$key]['state'] = "其它";
  425. }
  426. else if($value['state'] == 9)
  427. {
  428. $info_list[$key]['state'] = "预设";
  429. }
  430. else if($value['state'] == 10)
  431. {
  432. $info_list[$key]['state'] = "美店零售";
  433. }
  434. if($value['text'] == "")
  435. {
  436. $info_list[$key]['text'] = "";
  437. }
  438. $info_list[$key]['time'] = '<p>'.date('Y-m-d',$value['time']).'</p><p>'.date('H:i:s',$value['time']).'</p>';
  439. }
  440. $total = $this->whlabel->find_count($where);
  441. $pagenum = ceil($total/$perpage);
  442. $over = $total-($start+$perpage);
  443. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  444. echo json_encode($rows);exit;
  445. }
  446. if(isset($post['outsku']))
  447. {
  448. $cz = $this->input->post('cz',true);
  449. if($cz == '1')
  450. {
  451. $sku = $this->input->post('outsku',true);
  452. if($sku)
  453. {
  454. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  455. if(count($data) < 1)
  456. {
  457. echo json_encode(array('msg'=>'库存不足!','success'=>false));exit;
  458. }
  459. $this->whlabel->save(array('state'=>10,'outk'=>time(),'time'=>time(),'cktype'=>1),$data[0]['id']);
  460. echo json_encode(array('success'=>true));exit;
  461. }
  462. }
  463. else
  464. {
  465. $sku = $this->input->post('outsku',true);
  466. if($sku)
  467. {
  468. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  469. if(count($data) < 1)
  470. {
  471. echo json_encode(array('msg'=>'没有此SKU出库数据!','success'=>false));exit;
  472. }
  473. $this->whlabel->save(array('state'=>0,'outk'=>0,'time'=>time()),$data[0]['id']);
  474. echo json_encode(array('success'=>true));exit;
  475. }
  476. }
  477. }
  478. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  479. $this->_Template('whlabel',$this->data);
  480. }
  481. //在库标签
  482. public function _existence()
  483. {
  484. $post = $this->input->post(NULL, TRUE);
  485. if(isset($post['s']))
  486. {
  487. $id_arr = $this->input->post('s');
  488. $id_arr = explode(',',$id_arr);
  489. if(!$id_arr)
  490. {
  491. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  492. }
  493. //循环删除记录
  494. foreach ($id_arr as $v)
  495. {
  496. $sid = $this->whlabel->read($v);
  497. $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
  498. if($count > 0)
  499. {
  500. echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
  501. }
  502. $zt = $this->whlabeltransport->find_all('sku = "'.$sid['sku'].'" and warehouse = "'.$sid['warehouse'].'" and features = "'.$sid['features'].'" and cz = "0"');
  503. if(count($zt) > 0)
  504. {
  505. echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
  506. }
  507. $this->whlabel->remove($v);
  508. }
  509. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  510. }
  511. if(isset($post['page']))
  512. {
  513. $page = $this->input->post('page',true);
  514. $perpage = $this->input->post('perpage',true);
  515. $warehouse = $this->input->post('warehouse',true);
  516. $label = $this->input->post('label',true);
  517. $where = "1=1 and state = 0";
  518. if($warehouse)
  519. {
  520. $where .= " and warehouse = '$warehouse'";
  521. }
  522. if($label)
  523. {
  524. $where .= " and label = '$label'";
  525. }
  526. //数据排序
  527. $order_str = "time asc";
  528. if(empty($page))
  529. {
  530. $start = 0;
  531. $perpage = 1;
  532. }
  533. else
  534. {
  535. $start = ($page - 1)*$perpage;
  536. }
  537. //取得信息列表
  538. $info_list = $this->whlabel->find_all($where,'id,sku,title,label,printing,enter',$order_str,$start,$perpage);
  539. foreach ($info_list as $key=>$value)
  540. {
  541. if($value['enter'] != 0)
  542. {
  543. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  544. }
  545. else
  546. {
  547. $info_list[$key]['enter'] = "";
  548. }
  549. if($value['printing'] != 0)
  550. {
  551. $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']);
  552. }
  553. else
  554. {
  555. $info_list[$key]['printing'] = "";
  556. }
  557. }
  558. $total = $this->whlabel->find_count($where);
  559. $pagenum = ceil($total/$perpage);
  560. $over = $total-($start+$perpage);
  561. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  562. echo json_encode($rows);exit;
  563. }
  564. $this->_Template('whlabel_existence',$this->data);
  565. }
  566. //进销存浏览
  567. public function _typedy($arg_array)
  568. {
  569. $prc = array();
  570. $purchase = $this->purchase->find_all();
  571. foreach($purchase as $k=>$v)
  572. {
  573. $prc[$v['id']] = $v['title'];
  574. }
  575. $post = $this->input->post(NULL, TRUE);
  576. if(isset($post['page']))
  577. {
  578. $page = $this->input->post('page',true);
  579. $perpage = $this->input->post('perpage',true);
  580. $category = $this->input->post('category',true);
  581. $size = $this->input->post('size',true);
  582. $grade = $this->input->post('grade',true);
  583. $color = $this->input->post('color',true);
  584. $lowe = $this->input->post('lowe',true);
  585. $sku = $this->input->post('sku');
  586. $title = $this->input->post('title');
  587. $warehouse = $this->input->post('warehouse',true);
  588. $usa = $this->input->post('usa',true);
  589. $purchase = $this->input->post('purchase',true);
  590. $lacetype = $this->input->post('lacetype',true);
  591. $haircap = $this->input->post('haircap',true);
  592. $density = $this->input->post('density',true);
  593. $details = $this->input->post('details',true);
  594. $state = $this->input->post('state',true);
  595. $lacecolor = $this->input->post('lacecolor',true);
  596. $hairnumber = $this->input->post('hairnumber',true);
  597. $cklx = $this->input->post('cklx',true);
  598. $ktime = $this->input->post('ktime',true);
  599. $jtime = $this->input->post('jtime',true);
  600. $ktime = strtotime($ktime);
  601. $jtime = strtotime($jtime);
  602. $where = "1=1";$gj = "";$ck = "";
  603. if($usa)
  604. {
  605. if(!$warehouse)
  606. {
  607. $where .= " and (warehouse = '5' or warehouse = '8')";
  608. }
  609. }
  610. if($warehouse)
  611. {
  612. $where .= " and warehouse = '$warehouse'";
  613. }
  614. if($details)
  615. {
  616. $where .= " and details = '$details'";
  617. }
  618. if($purchase)
  619. {
  620. $where .= " and purchase = '$purchase'";
  621. }
  622. if($state)
  623. {
  624. $where .= " and state = '$state'";
  625. }
  626. if($lacetype)
  627. {
  628. $where .= " and features like '%-$lacetype-%'";
  629. }
  630. if($category)
  631. {
  632. $where .= " and features like '%-$category-%'";
  633. }
  634. if($size)
  635. {
  636. $where .= " and features like '%-$size-%'";
  637. }
  638. if($grade)
  639. {
  640. $where .= " and features like '%-$grade-%'";
  641. }
  642. if($color)
  643. {
  644. $where .= " and features like '%-$color-%'";
  645. }
  646. if($lowe)
  647. {
  648. $where .= " and features like '%-$lowe-%'";
  649. }
  650. if($haircap)
  651. {
  652. $where .= " and features like '%-$haircap-%'";
  653. }
  654. if($density)
  655. {
  656. $where .= " and features like '%-$density-%'";
  657. }
  658. if($lacecolor)
  659. {
  660. $where .= " and features like '%-$lacecolor-%'";
  661. }
  662. if(!empty($hairnumber)){
  663. $where .= " and features like '%-128-%' ";
  664. if($hairnumber < 0){
  665. $class_list = $this->typeclass->find_all('classid = 43');
  666. foreach($class_list as $v){
  667. $where .= " and features not like '%-".$v['id']."-%'";
  668. }
  669. }else{
  670. $where .= " and features like '%-$hairnumber-%'";
  671. }
  672. }
  673. $where_add = '';
  674. if($cklx)
  675. {
  676. $shop = $this->shop->read($cklx);
  677. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  678. }
  679. if($ktime && $jtime)
  680. {
  681. $gj = " and enter > '$ktime' and enter < '$jtime'";
  682. $ck = " and outk > '$ktime' and outk < '$jtime'";
  683. }
  684. //数据排序
  685. $order_str = "id desc";
  686. if(empty($page))
  687. {
  688. $start = 0;
  689. $perpage = 1;
  690. }
  691. else
  692. {
  693. $start = ($page - 1)*$perpage;
  694. }
  695. if($sku)
  696. {
  697. $sku = trim($sku,' ');
  698. $sku = trim($sku,' ');
  699. $where .= " and sku like '%$sku%'";
  700. $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);
  701. }
  702. else if($title)
  703. {
  704. $title = trim($title,' ');
  705. $title = trim($title,' ');
  706. $where .= " and title like '%$title%'";
  707. $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);
  708. }
  709. else
  710. {
  711. //$where .= " and time > '$ktime' and time < '$jtime'";
  712. $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);
  713. }
  714. $info_list = $this->logic_whlabel->dataTran($info_list,['pm']);
  715. foreach($info_list as $k=>$v){
  716. $info_list[$k]['title'] = $v['title']."<br/>".$v['pm'];
  717. unset($info_list[$k]['pm']);
  718. unset($info_list[$k]['jm']);
  719. unset($info_list[$k]['bm']);
  720. }
  721. //取得信息列表
  722. $rows = array();$list = array();
  723. foreach ($info_list as $key=>$value)
  724. {
  725. $warehouse = $this->warehouse->read($value['warehouse']);
  726. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  727. $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  728. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  729. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  730. $number = $value['number'];$ftime = time()-15*24*3600;
  731. $info_list[$key]['warehouse'] = $warehouse['title'];
  732. $info_list[$key]['features'] = count($c);
  733. $z = count($z);//查看订单号
  734. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  735. $ztdata = '';
  736. if(count($zt) > 0)
  737. {
  738. foreach ($zt as $vv)
  739. {
  740. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  741. }
  742. }
  743. $info_list[$key]['number'] = $ztdata;
  744. $info_list[$key]['sm'] = $z;
  745. $details = array();
  746. $cpid = array();
  747. foreach ($c as $k=>$v)
  748. {
  749. $details[$v['details']] = $v['details'];
  750. if($v['cpid'] != 0)
  751. {
  752. $cpid[$v['cpid']] = $v['cpid'];
  753. }
  754. }
  755. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  756. if($value['shop'] != '')
  757. {
  758. $shop = explode(',',trim($value['shop'],','));
  759. $shop = $this->shop->read($shop[0]);
  760. $info_list[$key]['shop'] = $shop['shopname'];
  761. }
  762. }
  763. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  764. $pagenum = ceil($total/$perpage);
  765. $over = $total-($start+$perpage);
  766. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  767. echo json_encode($rows);exit;
  768. }
  769. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  770. $this->_Template('whlabel_typedy',$this->data);
  771. }
  772. //进销存浏览
  773. public function _typedy_ck($arg_array)
  774. {
  775. $prc = array();
  776. $purchase = $this->purchase->find_all();
  777. foreach($purchase as $k=>$v)
  778. {
  779. $prc[$v['id']] = $v['title'];
  780. }
  781. $post = $this->input->post(NULL, TRUE);
  782. if(isset($post['page']))
  783. {
  784. $page = $this->input->post('page',true);
  785. $perpage = $this->input->post('perpage',true);
  786. $category = $this->input->post('category',true);
  787. $size = $this->input->post('size',true);
  788. $grade = $this->input->post('grade',true);
  789. $color = $this->input->post('color',true);
  790. $lowe = $this->input->post('lowe',true);
  791. $sku = $this->input->post('sku');
  792. $title = $this->input->post('title');
  793. $warehouse = $this->input->post('warehouse',true);
  794. $usa = $this->input->post('usa',true);
  795. $purchase = $this->input->post('purchase',true);
  796. $lacetype = $this->input->post('lacetype',true);
  797. $haircap = $this->input->post('haircap',true);
  798. $density = $this->input->post('density',true);
  799. $details = $this->input->post('details',true);
  800. $state = $this->input->post('state',true);
  801. $lacecolor = $this->input->post('lacecolor',true);
  802. $cklx = $this->input->post('cklx',true);
  803. $ktime = $this->input->post('ktime',true);
  804. $jtime = $this->input->post('jtime',true);
  805. $ktime = strtotime($ktime);
  806. $jtime = strtotime($jtime);
  807. $where = "1=1";$gj = "";$ck = "";
  808. if($lacetype)
  809. {
  810. $where .= " and features like '%-$lacetype-%'";
  811. }
  812. if($category)
  813. {
  814. $where .= " and features like '%-$category-%'";
  815. }
  816. if($size)
  817. {
  818. $where .= " and features like '%-$size-%'";
  819. }
  820. if($grade)
  821. {
  822. $where .= " and features like '%-$grade-%'";
  823. }
  824. if($color)
  825. {
  826. $where .= " and features like '%-$color-%'";
  827. }
  828. if($lowe)
  829. {
  830. $where .= " and features like '%-$lowe-%'";
  831. }
  832. if($haircap)
  833. {
  834. $where .= " and features like '%-$haircap-%'";
  835. }
  836. if($density)
  837. {
  838. $where .= " and features like '%-$density-%'";
  839. }
  840. if($lacecolor)
  841. {
  842. $where .= " and features like '%-$lacecolor-%'";
  843. }
  844. if($usa)
  845. {
  846. if(!$warehouse)
  847. {
  848. $where .= " and (warehouse = '5' or warehouse = '8')";
  849. }
  850. }
  851. if($warehouse)
  852. {
  853. $where .= " and warehouse = '$warehouse'";
  854. }
  855. if($details)
  856. {
  857. $where .= " and details = '$details'";
  858. }
  859. if($purchase)
  860. {
  861. $where .= " and purchase = '$purchase'";
  862. }
  863. if($state)
  864. {
  865. $where .= " and state = '$state'";
  866. }
  867. $where_add = '';
  868. if($cklx)
  869. {
  870. $shop = $this->shop->read($cklx);
  871. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  872. }
  873. if($ktime && $jtime)
  874. {
  875. $gj = " and enter > '$ktime' and enter < '$jtime'";
  876. $ck = " and outk > '$ktime' and outk < '$jtime'";
  877. }
  878. //数据排序
  879. $order_str = "id desc";
  880. if(empty($page))
  881. {
  882. $start = 0;
  883. $perpage = 1;
  884. }
  885. else
  886. {
  887. $start = ($page - 1)*$perpage;
  888. }
  889. if($sku)
  890. {
  891. $sku = trim($sku,' ');
  892. $sku = trim($sku,' ');
  893. $where .= " and sku like '%$sku%'";
  894. $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);
  895. }
  896. else if($title)
  897. {
  898. $title = trim($title,' ');
  899. $title = trim($title,' ');
  900. $where .= " and title like '%$title%'";
  901. $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);
  902. }
  903. else
  904. {
  905. //$where .= " and time > '$ktime' and time < '$jtime'";
  906. $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);
  907. }
  908. //取得信息列表
  909. $rows = array();$list = array();
  910. foreach ($info_list as $key=>$value)
  911. {
  912. $warehouse = $this->warehouse->read($value['warehouse']);
  913. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  914. $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,text');
  915. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  916. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$c[0]['text'].'</p>';
  917. $ftime = time()-15*24*3600;
  918. $info_list[$key]['warehouse'] = $warehouse['title'];
  919. $info_list[$key]['features'] = count($c)<10?"<em style='color:#F00'>".count($c)."</em>":count($c);
  920. //$z = count($z);//查看订单号
  921. //$info_list[$key]['zd'] = $z;
  922. $details = array();
  923. $cpid = array();
  924. foreach ($c as $k=>$v)
  925. {
  926. $details[$v['details']] = $v['details'];
  927. if($v['cpid'] != 0)
  928. {
  929. $cpid[$v['cpid']] = $v['cpid'];
  930. }
  931. }
  932. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  933. if($value['shop'] != '')
  934. {
  935. $shop = explode(',',trim($value['shop'],','));
  936. $shop = $this->shop->read($shop[0]);
  937. $info_list[$key]['shop'] = $shop['shopname'];
  938. }
  939. }
  940. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  941. $pagenum = ceil($total/$perpage);
  942. $over = $total-($start+$perpage);
  943. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  944. echo json_encode($rows);exit;
  945. }
  946. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  947. $this->_Template('whlabel_typedy_ck',$this->data);
  948. }
  949. public function _typeck($arg_array)
  950. {
  951. $prc = array();
  952. $purchase = $this->purchase->find_all();
  953. foreach($purchase as $k=>$v)
  954. {
  955. $prc[$v['id']] = $v['title'];
  956. }
  957. $post = $this->input->post(NULL, TRUE);
  958. if(isset($post['page']))
  959. {
  960. $page = $this->input->post('page',true);
  961. $perpage = $this->input->post('perpage',true);
  962. $category = $this->input->post('category',true);
  963. $size = $this->input->post('size',true);
  964. $grade = $this->input->post('grade',true);
  965. $color = $this->input->post('color',true);
  966. $lacecolor = $this->input->post('lacecolor',true);
  967. $lowe = $this->input->post('lowe',true);
  968. $sku = $this->input->post('sku');
  969. $title = $this->input->post('title');
  970. $warehouse = 13;
  971. $usa = $this->input->post('usa',true);
  972. $purchase = $this->input->post('purchase',true);
  973. $lacetype = $this->input->post('lacetype',true);
  974. $haircap = $this->input->post('haircap',true);
  975. $density = $this->input->post('density',true);
  976. $details = $this->input->post('details',true);
  977. $state = $this->input->post('state',true);
  978. $ktime = $this->input->post('ktime',true);
  979. $jtime = $this->input->post('jtime',true);
  980. $ktime = strtotime($ktime);
  981. $jtime = strtotime($jtime);
  982. $where = "1=1";$gj = "";$ck = "";
  983. if($lacetype)
  984. {
  985. $where .= " and features like '%-$lacetype-%'";
  986. }
  987. if($category)
  988. {
  989. $where .= " and features like '%-$category-%'";
  990. }
  991. if($size)
  992. {
  993. $where .= " and features like '%-$size-%'";
  994. }
  995. if($grade)
  996. {
  997. $where .= " and features like '%-$grade-%'";
  998. }
  999. if($color)
  1000. {
  1001. $where .= " and features like '%-$color-%'";
  1002. }
  1003. if($lacecolor)
  1004. {
  1005. $where .= " and features like '%-$lacecolor-%'";
  1006. }
  1007. if($lowe)
  1008. {
  1009. $where .= " and features like '%-$lowe-%'";
  1010. }
  1011. if($haircap)
  1012. {
  1013. $where .= " and features like '%-$haircap-%'";
  1014. }
  1015. if($density)
  1016. {
  1017. $where .= " and features like '%-$density-%'";
  1018. }
  1019. if($warehouse)
  1020. {
  1021. $where .= " and warehouse = '$warehouse'";
  1022. }
  1023. if($details)
  1024. {
  1025. $where .= " and details = '$details'";
  1026. }
  1027. if($purchase)
  1028. {
  1029. $where .= " and purchase = '$purchase'";
  1030. }
  1031. if($state)
  1032. {
  1033. $where .= " and state = '$state'";
  1034. }
  1035. if($ktime && $jtime)
  1036. {
  1037. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1038. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1039. }
  1040. //数据排序
  1041. $order_str = "id desc";
  1042. if(empty($page))
  1043. {
  1044. $start = 0;
  1045. $perpage = 1;
  1046. }
  1047. else
  1048. {
  1049. $start = ($page - 1)*$perpage;
  1050. }
  1051. if($sku)
  1052. {
  1053. $sku = trim($sku,' ');
  1054. $sku = trim($sku,' ');
  1055. $where .= " and sku like '%$sku%'";
  1056. }
  1057. else if($title)
  1058. {
  1059. $title = trim($title,' ');
  1060. $title = trim($title,' ');
  1061. $where .= " and title like '%$title%'";
  1062. }
  1063. $info_list = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,sm,details,cpbz,features,number,',$order_str,$start,$perpage);
  1064. //取得信息列表
  1065. $t = array();
  1066. $typeclass = $this->typeclass->find_all();
  1067. foreach ($typeclass as $v)
  1068. {
  1069. $t[$v['id']] = $v;
  1070. }
  1071. $rows = array();$list = array();
  1072. foreach ($info_list as $key=>$value)
  1073. {
  1074. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1075. $mc = $this->whlabel->find_all("sku = '".$value['sku']."' and features = '".$value['features']."' and warehouse = '".$value['warehouse']."'",'cpbz','id desc',0,1);
  1076. $warehouse = $this->warehouse->read($value['warehouse']);
  1077. $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');
  1078. $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'].'"');
  1079. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  1080. $number = $value['number'];$ftime = time()-15*24*3600;
  1081. $z = count($z);//查看订单号
  1082. $info_list[$key]['warehouse'] = $warehouse['title'];
  1083. $info_list[$key]['features'] = count($c);
  1084. $info_list[$key]['number'] = $z;
  1085. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  1086. $details = array();
  1087. $cpid = array();
  1088. foreach ($c as $k=>$v)
  1089. {
  1090. $details[$v['details']] = $v['details'];
  1091. if($v['cpid'] != 0)
  1092. {
  1093. $cpid[$v['cpid']] = $v['cpid'];
  1094. }
  1095. }
  1096. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1097. $classid = $this->classid->sku();
  1098. $pm = $classid;
  1099. $features = explode('-',trim($value['features'],'-'));
  1100. foreach($features as $v)
  1101. {
  1102. $zh = explode('|',trim($t[$v]['zh'],'|'));
  1103. $pm[$t[$v]['classid']] = $zh[0];
  1104. }
  1105. $zh = implode(" ",$pm);
  1106. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1107. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1108. $info_list[$key]['sm'] = $zh;
  1109. }
  1110. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  1111. $pagenum = ceil($total/$perpage);
  1112. $over = $total-($start+$perpage);
  1113. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1114. echo json_encode($rows);exit;
  1115. }
  1116. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  1117. $this->_Template('whlabel_typeck',$this->data);
  1118. }
  1119. //进销存导出
  1120. public function _whlabeckdc()
  1121. {
  1122. $prc = array();
  1123. $purchase = $this->purchase->find_all();
  1124. foreach($purchase as $k=>$v)
  1125. {
  1126. $prc[$v['id']] = $v['title'];
  1127. }
  1128. if(isset($_GET['excel']))
  1129. {
  1130. $where = "sku != 'Preset'";
  1131. //数据排序
  1132. $order_str = "id desc";
  1133. if(empty($page))
  1134. {
  1135. $start = 0;
  1136. $perpage = 1;
  1137. }
  1138. else
  1139. {
  1140. $start = ($page - 1)*$perpage;
  1141. }
  1142. $category = $this->input->get('category',true);
  1143. $color = $this->input->get('color',true);
  1144. $lowe = $this->input->get('lowe',true);
  1145. $lacetype = $this->input->get('lacetype',true);
  1146. $size = $this->input->get('size',true);
  1147. $density = $this->input->get('density',true);
  1148. $haircap = $this->input->get('haircap',true);
  1149. $sku = $this->input->get('sku',true);
  1150. $details = $this->input->get('details',true);
  1151. $warehouse = 13;
  1152. $excelid = $this->input->get('sid',true);
  1153. if($category)
  1154. {
  1155. $where .= " and features like '%-$category-%'";
  1156. }
  1157. if($color)
  1158. {
  1159. $where .= " and features like '%-$color-%'";
  1160. }
  1161. if($lowe)
  1162. {
  1163. $where .= " and features like '%-$lowe-%'";
  1164. }
  1165. if($lacetype)
  1166. {
  1167. $where .= " and features like '%-$lacetype-%'";
  1168. }
  1169. if($size)
  1170. {
  1171. $where .= " and features like '%-$size-%'";
  1172. }
  1173. if($density)
  1174. {
  1175. $where .= " and features like '%-$density-%'";
  1176. }
  1177. if($haircap)
  1178. {
  1179. $where .= " and features like '%-$haircap-%'";
  1180. }
  1181. if($warehouse)
  1182. {
  1183. $where .= " and warehouse = '$warehouse'";
  1184. }
  1185. if($sku)
  1186. {
  1187. $where .= " and sku like '%$sku%'";
  1188. }
  1189. if($details)
  1190. {
  1191. $where .= " and details = '$details'";
  1192. }
  1193. $xzid = '';
  1194. if($excelid)
  1195. {
  1196. $excelid = explode(',',trim($excelid,','));
  1197. foreach ($excelid as $key=>$value)
  1198. {
  1199. $xzid .= " id = ".$value." or";
  1200. }
  1201. $xzid = " and (".rtrim($xzid,'or').")";;
  1202. }
  1203. //取得信息列表
  1204. /**
  1205. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1206. $rows = array();$list = array();
  1207. foreach ($info_list as $key=>$value)
  1208. {
  1209. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1210. }
  1211. **/
  1212. $wh = array();
  1213. $w = $this->warehouse->find_all('1=1','id,title');
  1214. foreach ($w as $v)
  1215. {
  1216. $wh[$v['id']] = $v['title'];
  1217. }
  1218. $tc = array();$tcdata = array();
  1219. $typeclass = $this->typeclass->find_all();
  1220. foreach ($typeclass as $v)
  1221. {
  1222. $tc[$v['id']] = $v;
  1223. }
  1224. $list = array();
  1225. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1226. foreach ($rows as $key=>$value)
  1227. {
  1228. $bm = '03';
  1229. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1230. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1231. $classid = $this->classid->sku();
  1232. $pm = $classid;
  1233. $jm = $classid;
  1234. $features = explode('-',trim($value['features'],'-'));
  1235. foreach($features as $v)
  1236. {
  1237. if(isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']]))
  1238. {
  1239. if($tc[$v]['bm'] != '')
  1240. {
  1241. $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
  1242. }
  1243. }
  1244. if(isset($tc[$v]))
  1245. {
  1246. $zh = explode('|',trim($tc[$v]['zh'],'|'));
  1247. $pm[$tc[$v]['classid']] = $zh[0];
  1248. }
  1249. if(isset($tc[$v]))
  1250. {
  1251. if(isset($jm[$tc[$v]['classid']]))
  1252. {
  1253. $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
  1254. }
  1255. }
  1256. }
  1257. $zh = implode(" ",$pm);
  1258. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1259. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1260. $rows[$key]['dbcontent'] = $zh;
  1261. $rows[$key]['cpbz'] = $bm.implode("",$bmpx);
  1262. $jm = array_filter($jm);
  1263. $rows[$key]['cs'] = implode("-",$jm);
  1264. $sd = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,cpbz,state');
  1265. $details = array();
  1266. $cpid = array();
  1267. $cpbz = array();
  1268. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  1269. foreach ($sd as $k=>$v)
  1270. {
  1271. if($v['state'] == 0)
  1272. {
  1273. $c++;
  1274. }
  1275. if($v['state'] != 9)
  1276. {
  1277. $g++;
  1278. }
  1279. if($v['state'] == 1)
  1280. {
  1281. $x++;
  1282. }
  1283. if($v['state'] == 2)
  1284. {
  1285. $t++;
  1286. }
  1287. if($v['state'] == 8)
  1288. {
  1289. $s++;
  1290. }
  1291. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  1292. {
  1293. $q++;
  1294. }
  1295. $details[$v['details']] = $v['details'];
  1296. if($v['cpid'] != 0)
  1297. {
  1298. $cpid[$v['cpid']] = $v['cpid'];
  1299. }
  1300. if($v['cpbz'] != '')
  1301. {
  1302. $cpbz[$v['cpbz']] = $v['cpbz'];
  1303. }
  1304. }
  1305. $rows[$key]['details'] = implode("、",$details);
  1306. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  1307. $number = $value['number'];
  1308. $ftime = time()-15*24*3600;
  1309. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1310. $rows[$key]['number'] = $g;
  1311. $rows[$key]['features'] = $c;
  1312. $rows[$key]['x'] = $x;
  1313. $rows[$key]['t'] = $t;
  1314. $rows[$key]['s'] = $s;
  1315. $rows[$key]['q'] = $q;
  1316. $rows[$key]['wzsl'] = count($details);
  1317. }
  1318. $title = "进销存统计表".date('Y-m-d',time());
  1319. $titlename = "<table border=1>
  1320. <tr><th colspan='12' align='center'><h3>".$title."<h3></th></tr>
  1321. <tr align='center'>
  1322. <td>仓库</td>
  1323. <td>供应商</td>
  1324. <td>位置</td>
  1325. <td>库存编码</td>
  1326. <td>SKU</td>
  1327. <td>用友编码</td>
  1328. <td>用友料号</td>
  1329. <td>产品英文名</td>
  1330. <td>产品中文名</td>
  1331. <td>入库总量</td>
  1332. <td>库存数量</td>
  1333. <td>销售数量</td>
  1334. <td>退货数量</td>
  1335. <td>删除数量</td>
  1336. <td>其它操作</td>
  1337. <td>位置数量</td>
  1338. </tr>
  1339. </table>";
  1340. $filename = $title.".xls";
  1341. $tail = "";
  1342. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1343. }
  1344. }
  1345. public function _type()
  1346. {
  1347. $vip = 0;
  1348. if(isset($_SESSION['api']))
  1349. {
  1350. $user = $this->user->get_api($_SESSION['api']);
  1351. $fgshop = "";$sid = "";
  1352. $usersp = explode('|',trim($user['shop'],'|'));
  1353. foreach ($usersp as $value)
  1354. {
  1355. $fgshop .= " shop = ".$value." or";
  1356. $sid .= " id = ".$value." or";
  1357. }
  1358. if($user['vip'] == 1)
  1359. {
  1360. $vip = 1;
  1361. }
  1362. }
  1363. else
  1364. {
  1365. header('Location: /');exit;
  1366. }
  1367. $prc = array();
  1368. $purchase = $this->purchase->find_all();
  1369. foreach($purchase as $k=>$v)
  1370. {
  1371. $prc[$v['id']] = $v['title'];
  1372. }
  1373. $company = array();
  1374. $ct = $this->company->find_all();
  1375. foreach($ct as $k=>$v)
  1376. {
  1377. $company[$v['id']] = $v['title'];
  1378. }
  1379. $sp = array();
  1380. $s = $this->shop->find_all('1=1','id,shopname');
  1381. foreach ($s as $v)
  1382. {
  1383. $sp[$v['id']] = $v['shopname'];
  1384. }
  1385. $wh = array();
  1386. $w = $this->warehouse->find_all('1=1','id,title');
  1387. foreach ($w as $v)
  1388. {
  1389. $wh[$v['id']] = $v['title'];
  1390. }
  1391. $post = $this->input->post(NULL, TRUE);
  1392. if(isset($post['page']))
  1393. {
  1394. $page = $this->input->post('page',true);
  1395. $perpage = $this->input->post('perpage',true);
  1396. $category = $this->input->post('category',true);
  1397. $size = $this->input->post('size',true);
  1398. $grade = $this->input->post('grade',true);
  1399. $color = $this->input->post('color',true);
  1400. $lowe = $this->input->post('lowe',true);
  1401. $sku = $this->input->post('sku');
  1402. $title = $this->input->post('title');
  1403. $warehouse = $this->input->post('warehouse',true);
  1404. $usa = $this->input->post('usa',true);
  1405. $purchase = $this->input->post('purchase',true);
  1406. $lacetype = $this->input->post('lacetype',true);
  1407. $haircap = $this->input->post('haircap',true);
  1408. $density = $this->input->post('density',true);
  1409. $details = $this->input->post('details',true);
  1410. $state = $this->input->post('state',true);
  1411. $shop = $this->input->post('shop',true);
  1412. $lacecolor = $this->input->post('lacecolor',true);
  1413. $hairnumber = $this->input->post('hairnumber',true);
  1414. $type = $this->input->post('type',true);
  1415. $ktime = $this->input->post('ktime',true);
  1416. $jtime = $this->input->post('jtime',true);
  1417. $ktime = strtotime($ktime);
  1418. $jtime = strtotime($jtime);
  1419. $cpbz = $this->input->post('cpbz',true);
  1420. $where = "1=1";$gj = "";$ck = "";
  1421. if($usa)
  1422. {
  1423. if(!$warehouse)
  1424. {
  1425. $where .= " and (warehouse = '5' or warehouse = '8')";
  1426. }
  1427. }
  1428. if($warehouse)
  1429. {
  1430. $where .= " and warehouse = '$warehouse'";
  1431. }
  1432. if($details)
  1433. {
  1434. $where .= " and details = '$details'";
  1435. }
  1436. if($purchase)
  1437. {
  1438. $where .= " and purchase = '$purchase'";
  1439. }
  1440. if($state)
  1441. {
  1442. $where .= " and state = '$state'";
  1443. }
  1444. if($shop)
  1445. {
  1446. $where .= " and shop like '%$shop%'";
  1447. }
  1448. if($type)
  1449. {
  1450. $where .= " and type = '$type'";
  1451. }
  1452. if($ktime && $jtime)
  1453. {
  1454. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1455. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1456. }
  1457. if($cpbz){
  1458. $where .= " and cpbz like '%$cpbz%' ";
  1459. }
  1460. if($lacecolor)
  1461. {
  1462. $where .= " and features like '%-$lacecolor-%'";
  1463. }
  1464. if($lacetype)
  1465. {
  1466. $where .= " and features like '%-$lacetype-%'";
  1467. }
  1468. if($category)
  1469. {
  1470. $where .= " and features like '%-$category-%'";
  1471. }
  1472. if($size)
  1473. {
  1474. $where .= " and features like '%-$size-%'";
  1475. }
  1476. if($grade)
  1477. {
  1478. $where .= " and features like '%-$grade-%'";
  1479. }
  1480. if($color)
  1481. {
  1482. $where .= " and features like '%-$color-%'";
  1483. }
  1484. if($lowe)
  1485. {
  1486. $where .= " and features like '%-$lowe-%'";
  1487. }
  1488. if($haircap)
  1489. {
  1490. $where .= " and features like '%-$haircap-%'";
  1491. }
  1492. if($density)
  1493. {
  1494. $where .= " and features like '%-$density-%'";
  1495. }
  1496. if(!empty($hairnumber)){
  1497. $where .= " and features like '%-128-%' ";
  1498. if($hairnumber < 0){
  1499. $class_list = $this->typeclass->find_all('classid = 43');
  1500. foreach($class_list as $v){
  1501. $where .= " and features not like '%-".$v['id']."-%'";
  1502. }
  1503. }else{
  1504. $where .= " and features like '%-$hairnumber-%'";
  1505. }
  1506. }
  1507. //数据排序
  1508. $order_str = "id desc";
  1509. if(empty($page))
  1510. {
  1511. $start = 0;
  1512. $perpage = 1;
  1513. }
  1514. else
  1515. {
  1516. $start = ($page - 1)*$perpage;
  1517. }
  1518. $fjnr = '';
  1519. if($sku)
  1520. {
  1521. $sku = trim($sku,' ');
  1522. $sku = trim($sku,' ');
  1523. $fjnr .= " and sku like '%$sku%'";
  1524. }
  1525. if($title)
  1526. {
  1527. $title = trim($title,' ');
  1528. $title = trim($title,' ');
  1529. $fjnr .= " and title like '%$title%'";
  1530. }
  1531. $wt = array();
  1532. $whlabel_type = $this->whlabel_type->find_all();
  1533. foreach ($whlabel_type as $v)
  1534. {
  1535. $wt[$v['id']] = $v['title'];
  1536. }
  1537. //$where .= " and time > '$ktime' and time < '$jtime'";
  1538. $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
  1539. //取得信息列表
  1540. $info_list = $this->logic_whlabel->dataTran($info_list,['pm']);
  1541. $rows = array();$list = array();
  1542. foreach ($info_list as $key=>$value)
  1543. {
  1544. if(isset($wt[$value['type']]))
  1545. {
  1546. $info_list[$key]['type'] = $wt[$value['type']];
  1547. }
  1548. else
  1549. {
  1550. $info_list[$key]['type'] = '未设置';
  1551. }
  1552. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1553. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1554. $ztdata = '';
  1555. if(count($zt) > 0)
  1556. {
  1557. foreach ($zt as $vv)
  1558. {
  1559. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1560. }
  1561. }
  1562. $qbdata = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1563. $cdata = array_filter($qbdata, function($item) {
  1564. return $item['state'] < 1;
  1565. });
  1566. $c = array_sum(array_column($cdata, 'jnum'));
  1567. $gdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1568. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1569. });
  1570. $g = array_sum(array_column($gdata, 'jnum'));
  1571. $xdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1572. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1573. });
  1574. $x = array_sum(array_column($xdata, 'jnum'));
  1575. $tdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1576. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1577. });
  1578. $t = array_sum(array_column($tdata, 'jnum'));
  1579. $zdata = array_filter($qbdata, function($item) {
  1580. return $item['zd'] != "" && $item['state'] < 1;
  1581. });
  1582. $z = array_sum(array_column($zdata, 'jnum'));
  1583. $zdata = array_filter($qbdata, function($item) {
  1584. return $item['zd'] != "" && $item['state'] < 1;
  1585. });
  1586. $z = array_sum(array_column($zdata, 'jnum'));
  1587. //$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');
  1588. //$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'].'"');
  1589. //$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'].'"');
  1590. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1591. //$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'].'"');
  1592. $details = array();
  1593. $cpid = array();
  1594. $od = array();$odid = '';
  1595. $companytitle = '';
  1596. foreach ($qbdata as $v)
  1597. {
  1598. if($v['zd'] != "" && $v['state'] < 1)
  1599. {
  1600. if(!isset($od[$v['zd']]))
  1601. {
  1602. $od[$v['zd']] = 1;//所有数据sku
  1603. }
  1604. else
  1605. {
  1606. $od[$v['zd']] = $od[$v['zd']]+1;
  1607. }
  1608. }
  1609. if($v['state'] < 1)
  1610. {
  1611. $details[$v['details']] = $v['details'];
  1612. if($v['cpid'] != 0)
  1613. {
  1614. $cpid[$v['cpid']] = $v['cpid'];
  1615. }
  1616. }
  1617. if($v['companytitle'] != '' && stripos($companytitle,$company[$v['companytitle']]) === false)
  1618. {
  1619. $companytitle .= '<p>'.$company[$v['companytitle']].'</p>';
  1620. }
  1621. }
  1622. foreach ($od as $k=>$vv)
  1623. {
  1624. $odid .= $k.'数量'.$vv;
  1625. }
  1626. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  1627. $number = $value['number'];$ftime = time()-15*24*3600;
  1628. $z = $z.'('.$odid.')';//查看订单号
  1629. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:'无';
  1630. $info_list[$key]['features'] = $c;
  1631. $info_list[$key]['number'] = $ztdata;
  1632. $info_list[$key]['sm'] = $g;
  1633. $info_list[$key]['x'] = $x;
  1634. $info_list[$key]['t'] = $t;
  1635. $info_list[$key]['z'] = $z;
  1636. /**
  1637. foreach ($cdata as $k=>$v)
  1638. {
  1639. $details[$v['details']] = $v['details'];
  1640. if($v['cpid'] != 0)
  1641. {
  1642. $cpid[$v['cpid']] = $v['cpid'];
  1643. }
  1644. }
  1645. **/
  1646. $info_list[$key]['shop'] = '';
  1647. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1648. if($value['shop'] != '')
  1649. {
  1650. $shop = explode(',',trim($value['shop'],','));
  1651. $info_list[$key]['shop'] = '<p>'.$sp[$shop[0]].'</p>';
  1652. }
  1653. $info_list[$key]['shop'] .= $companytitle;
  1654. /**
  1655. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1656. if(isset($companytitle[0]))
  1657. {
  1658. foreach ($companytitle as $k=>$v)
  1659. {
  1660. if($v['companytitle'] != '')
  1661. {
  1662. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1663. }
  1664. }
  1665. }
  1666. **/
  1667. }
  1668. $final_all_list = [];
  1669. foreach($info_list as $k=>$v){
  1670. $final_all_list[] = [
  1671. 'id'=>$v['id'],
  1672. "warehouse"=>$v["warehouse"],
  1673. "purchase"=>$v["purchase"],
  1674. "sku"=>$v["sku"],
  1675. "title"=>$v["title"]."<br/>".$v["pm"],
  1676. "details"=>$v["details"],
  1677. "shop"=>$v["shop"],
  1678. "cpbz"=>$v["cpbz"],
  1679. "type"=>$v["type"],
  1680. "features"=>$v["features"],
  1681. "number"=>$v["number"],
  1682. "sm"=>$v["sm"],
  1683. "x"=>$v["x"],
  1684. "t"=>$v["t"],
  1685. "z"=>$v["z"]
  1686. ];
  1687. }
  1688. $total = count($this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,sku,title,features,number'));
  1689. $pagenum = ceil($total/$perpage);
  1690. $over = $total-($start+$perpage);
  1691. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_all_list));
  1692. echo json_encode($rows);exit;
  1693. }
  1694. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1695. $this->data['shop'] = $wlshop;
  1696. $this->data['vip'] = $vip;
  1697. $this->_Template('whlabel_type',$this->data);
  1698. }
  1699. //美仓进销存浏览
  1700. public function _usatype()
  1701. {
  1702. if(isset($_SESSION['api']))
  1703. {
  1704. $user = $this->user->get_api($_SESSION['api']);
  1705. $usp = $user;
  1706. $fgshop = "";$sid = "";$wid="";$wtype="";
  1707. $userwh = explode('|',trim($user['warehouse'],'|'));
  1708. foreach ($userwh as $value)
  1709. {
  1710. $wid .= " id = ".$value." or";
  1711. $wtype .= " type = ".$value." or";
  1712. }
  1713. }
  1714. $prc = array();
  1715. $purchase = $this->purchase->find_all();
  1716. foreach($purchase as $k=>$v)
  1717. {
  1718. $prc[$v['id']] = $v['title'];
  1719. }
  1720. $post = $this->input->post(NULL, TRUE);
  1721. if(isset($post['page']))
  1722. {
  1723. $page = $this->input->post('page',true);
  1724. $perpage = $this->input->post('perpage',true);
  1725. $category = $this->input->post('category',true);
  1726. $size = $this->input->post('size',true);
  1727. $grade = $this->input->post('grade',true);
  1728. $color = $this->input->post('color',true);
  1729. $lowe = $this->input->post('lowe',true);
  1730. $sku = $this->input->post('sku');
  1731. $title = $this->input->post('title');
  1732. $warehouse = $this->input->post('warehouse',true);
  1733. $usa = $this->input->post('usa',true);
  1734. $purchase = $this->input->post('purchase',true);
  1735. $lacetype = $this->input->post('lacetype',true);
  1736. $haircap = $this->input->post('haircap',true);
  1737. $density = $this->input->post('density',true);
  1738. $details = $this->input->post('details',true);
  1739. $state = $this->input->post('state',true);
  1740. $lacecolor = $this->input->post('lacecolor',true);
  1741. $cklx = $this->input->post('cklx',true);
  1742. $ktime = $this->input->post('ktime',true);
  1743. $jtime = $this->input->post('jtime',true);
  1744. $ktime = strtotime($ktime);
  1745. $jtime = strtotime($jtime);
  1746. $where = "1=1";$gj = "";$ck = "";
  1747. if($lacetype)
  1748. {
  1749. $where .= " and features like '%-$lacetype-%'";
  1750. }
  1751. if($category)
  1752. {
  1753. $where .= " and features like '%-$category-%'";
  1754. }
  1755. if($size)
  1756. {
  1757. $where .= " and features like '%-$size-%'";
  1758. }
  1759. if($grade)
  1760. {
  1761. $where .= " and features like '%-$grade-%'";
  1762. }
  1763. if($color)
  1764. {
  1765. $where .= " and features like '%-$color-%'";
  1766. }
  1767. if($lowe)
  1768. {
  1769. $where .= " and features like '%-$lowe-%'";
  1770. }
  1771. if($haircap)
  1772. {
  1773. $where .= " and features like '%-$haircap-%'";
  1774. }
  1775. if($density)
  1776. {
  1777. $where .= " and features like '%-$density-%'";
  1778. }
  1779. if($lacecolor)
  1780. {
  1781. $where .= " and features like '%-$lacecolor-%'";
  1782. }
  1783. if($usa)
  1784. {
  1785. if(!$warehouse)
  1786. {
  1787. $where .= " and (warehouse = '5' or warehouse = '8')";
  1788. }
  1789. }
  1790. if($warehouse)
  1791. {
  1792. $where .= " and warehouse = '$warehouse'";
  1793. }
  1794. if($details)
  1795. {
  1796. $where .= " and details = '$details'";
  1797. }
  1798. if($purchase)
  1799. {
  1800. $where .= " and purchase = '$purchase'";
  1801. }
  1802. if($state)
  1803. {
  1804. $where .= " and state = '$state'";
  1805. }
  1806. $where_add = '';
  1807. if($cklx)
  1808. {
  1809. $shop = $this->shop->read($cklx);
  1810. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  1811. }
  1812. if($ktime && $jtime)
  1813. {
  1814. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1815. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1816. }
  1817. //数据排序
  1818. $order_str = "id desc";
  1819. if(empty($page))
  1820. {
  1821. $start = 0;
  1822. $perpage = 1;
  1823. }
  1824. else
  1825. {
  1826. $start = ($page - 1)*$perpage;
  1827. }
  1828. if($sku)
  1829. {
  1830. $sku = trim($sku,' ');
  1831. $sku = trim($sku,' ');
  1832. $where .= " and sku like '%$sku%'";
  1833. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1834. }
  1835. else if($title)
  1836. {
  1837. $title = trim($title,' ');
  1838. $title = trim($title,' ');
  1839. $where .= " and title like '%$title%'";
  1840. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1841. }
  1842. else
  1843. {
  1844. //$where .= " and time > '$ktime' and time < '$jtime'";
  1845. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1846. }
  1847. //取得信息列表
  1848. $rows = array();$list = array();
  1849. foreach ($info_list as $key=>$value)
  1850. {
  1851. $warehouse = $this->warehouse->read($value['warehouse']);
  1852. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1853. $g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1854. $x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1855. $t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1856. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1857. $od = array();$odid = '';
  1858. foreach ($z as $v)
  1859. {
  1860. if(!isset($od[$v['zd']]))
  1861. {
  1862. $od[$v['zd']] = 1;//所有数据sku
  1863. }
  1864. else
  1865. {
  1866. $od[$v['zd']] = $od[$v['zd']]+1;
  1867. }
  1868. }
  1869. foreach ($od as $k=>$vv)
  1870. {
  1871. $odid .= $k.'数量'.$vv.' ';
  1872. }
  1873. $z = count($z).'('.$odid.')';//查看订单号
  1874. $info_list[$key]['features'] = $c;
  1875. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1876. $ztdata = '';
  1877. if(count($zt) > 0)
  1878. {
  1879. foreach ($zt as $vv)
  1880. {
  1881. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1882. }
  1883. }
  1884. $info_list[$key]['warehouse'] = $ztdata;
  1885. $info_list[$key]['g'] = $g;
  1886. $info_list[$key]['x'] = $x;
  1887. $info_list[$key]['t'] = $t;
  1888. $info_list[$key]['z'] = $z;
  1889. }
  1890. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title'));
  1891. $pagenum = ceil($total/$perpage);
  1892. $over = $total-($start+$perpage);
  1893. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1894. echo json_encode($rows);exit;
  1895. }
  1896. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1897. $this->data['warehouse'] = $warehouse;
  1898. $this->_Template('whlabel_typeusa',$this->data);
  1899. }
  1900. //美仓进销存浏览
  1901. public function _usatypeapp()
  1902. {
  1903. $post = $this->input->post(NULL, TRUE);
  1904. if(isset($post['page']))
  1905. {
  1906. $page = $this->input->post('page',true);
  1907. $perpage = $this->input->post('perpage',true);
  1908. $sku = $this->input->post('sku',true);
  1909. $warehouse = 5;
  1910. $title = $this->input->post('title',true);
  1911. $state = $this->input->post('state',true);
  1912. $ktime = $this->input->post('ktime',true);
  1913. $jtime = $this->input->post('jtime',true);
  1914. $ktime = strtotime($ktime);
  1915. $jtime = strtotime($jtime);
  1916. $where = "1=1";$gj = "";$ck = "";
  1917. if($title)
  1918. {
  1919. $st = explode(' ',trim($title,' '));
  1920. foreach ($st as $v)
  1921. {
  1922. $where .= " and title like '%$v%'";
  1923. }
  1924. }
  1925. if($warehouse)
  1926. {
  1927. $where .= " and warehouse = '$warehouse'";
  1928. }
  1929. if($state)
  1930. {
  1931. $where .= " and state = '$state'";
  1932. }
  1933. if($sku)
  1934. {
  1935. $where .= " and sku like '%$sku%'";
  1936. }
  1937. if($ktime && $jtime)
  1938. {
  1939. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1940. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1941. }
  1942. //数据排序
  1943. $order_str = "id desc";
  1944. if(empty($page))
  1945. {
  1946. $start = 0;
  1947. $perpage = 1;
  1948. }
  1949. else
  1950. {
  1951. $start = ($page - 1)*$perpage;
  1952. }
  1953. //取得信息列表
  1954. $info_list = $this->whlabel->find_all($where.' and '.rtrim($wid,'or'),'*');
  1955. $rows = array();$list = array();
  1956. foreach ($info_list as $key=>$value)
  1957. {
  1958. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1959. }
  1960. $rowsdq = array_slice($rows,$start,$perpage);
  1961. foreach ($rowsdq as $value)
  1962. {
  1963. $warehouse = $this->warehouse->read($value['warehouse']);
  1964. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'"');
  1965. $x = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'"');
  1966. $t = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1967. $od = array();$odid = '';
  1968. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'x'=>$x,'t'=>$t);
  1969. }
  1970. $total = count($rows);
  1971. $pagenum = ceil($total/$perpage);
  1972. $over = $total-($start+$perpage);
  1973. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1974. echo json_encode($rows);exit;
  1975. }
  1976. $this->_Template('phone/p_usatypeapp',$this->data);
  1977. }
  1978. //入库操作
  1979. public function _enteradd()
  1980. {
  1981. $dt = 0;
  1982. if(isset($_SESSION['api']))
  1983. {
  1984. $user = $this->user->get_api($_SESSION['api']);
  1985. $usp = $user;
  1986. $fgshop = "";$sid = "";
  1987. $user = explode('|',trim($user['shop'],'|'));
  1988. foreach ($user as $value)
  1989. {
  1990. $fgshop .= " shop = ".$value." or";
  1991. $sid .= " id = ".$value." or";
  1992. }
  1993. }
  1994. $tc = $this->typeclass->find_all();
  1995. $typeclass = array();
  1996. foreach ($tc as $v)
  1997. {
  1998. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1999. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'bqsku'=>$v['bqsku']);
  2000. }
  2001. $post = $this->input->post(NULL, TRUE);
  2002. if(isset($post['sku']))
  2003. {
  2004. $list = array();$num = "";$title = "";$features = "";
  2005. $order = $this->input->post('order',true);
  2006. $shop = $this->input->post('shop',true);
  2007. $post['shop'] = ($shop!="")?','.$shop:"";
  2008. $sku = $this->input->post('sku',true);
  2009. $post['sm'] = $this->input->post('sm',true);
  2010. $post['warehouse'] = $this->input->post('warehouse',true);
  2011. $post['purchase'] = $this->input->post('purchase',true);
  2012. $post['retreatwarehouse'] = $post['warehouse'];
  2013. $post['state'] = $this->input->post('state',true);
  2014. $post['rktype'] = $this->input->post('rktype',true);
  2015. $post['text'] = $this->input->post('text',true);
  2016. $category = $this->input->post('category',true);
  2017. $list['category'] = $category;
  2018. $list['hairtype'] = $this->input->post('hairtype',true);
  2019. $list['grade'] = $this->input->post('grade',true);
  2020. $size = $this->input->post('size',true);
  2021. $xzsku = $this->input->post('xzsku',true);
  2022. $list['size'] = rtrim($size,',');
  2023. $list['hairnumber'] = $this->input->post('hairnumber',true);
  2024. $list['extension'] = $this->input->post('extension',true);
  2025. if($category == 1297)
  2026. {
  2027. $list['sywignumber'] = $this->input->post('sywignumber',true);
  2028. }
  2029. if($category == 1702)
  2030. {
  2031. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  2032. $list['syother'] = $this->input->post('syother',true);
  2033. }
  2034. if($category == 133)
  2035. {
  2036. $list['fittype'] = $this->input->post('fittype',true);
  2037. $list['acother'] = $this->input->post('acother',true);
  2038. }
  2039. $list['color'] = $this->input->post('color',true);
  2040. $list['lowe'] = $this->input->post('lowe',true);
  2041. if(!$post['purchase'])
  2042. {
  2043. $post['purchase'] = 1;
  2044. }
  2045. if($category == 127)
  2046. {
  2047. $list['type'] = $this->input->post('type',true);
  2048. $list['headroad'] = $this->input->post('headroad',true);
  2049. $list['density'] = $this->input->post('density',true);
  2050. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  2051. {
  2052. $list['lacesize'] = $this->input->post('lacesize',true);
  2053. }
  2054. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2055. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2056. }
  2057. if($category == 128)
  2058. {
  2059. $list['lacetype'] = $this->input->post('lacetype',true);
  2060. $list['haircap'] = $this->input->post('haircap',true);
  2061. $list['density'] = $this->input->post('density',true);
  2062. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2063. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2064. $list['wigother'] = $this->input->post('wigother',true);
  2065. $list['wigother2'] = $this->input->post('wigother2',true);
  2066. }
  2067. if($category == 129)
  2068. {
  2069. $list['wide'] = $this->input->post('wide',true);
  2070. }
  2071. if($category == 131)
  2072. {
  2073. $list['gifttype'] = $this->input->post('gifttype',true);
  2074. $list['giftother'] = $this->input->post('giftother',true);
  2075. }
  2076. if($category == 134)
  2077. {
  2078. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2079. }
  2080. if($category == 1297)
  2081. {
  2082. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2083. $list['sywigother'] = $this->input->post('sywigother',true);
  2084. }
  2085. if($category == 130 || $category == 133 || $category == 1702)
  2086. {
  2087. $list['items'] = $this->input->post('items',true);
  2088. $list['weight'] = $this->input->post('weight',true);
  2089. }
  2090. if($category == 1702)
  2091. {
  2092. $list['syhairther'] = $this->input->post('syhairther',true);
  2093. }
  2094. $classid = $this->classid->sku();
  2095. $scsku = $classid;
  2096. $pm = $classid;
  2097. foreach($list as $k=>$v)
  2098. {
  2099. if($v != 0)
  2100. {
  2101. $num .=$v;
  2102. $features .=$v.'-';
  2103. $post[$k] = $v;
  2104. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2105. if($k != 'size')
  2106. {
  2107. $title .= $typeclass[$v]['title']." ";
  2108. }
  2109. if(isset($pm[$typeclass[$v]['classid']]))
  2110. {
  2111. if($typeclass[$v]['title'] == '9A')
  2112. {
  2113. $pm[$typeclass[$v]['classid']] = '9A';
  2114. }
  2115. else if($typeclass[$v]['title'] == '10A')
  2116. {
  2117. $pm[$typeclass[$v]['classid']] = '10A';
  2118. }
  2119. else
  2120. {
  2121. $clzh = $typeclass[$v]['zh'];
  2122. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2123. {
  2124. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2125. $clzh = $clzh[0];
  2126. }
  2127. $pm[$typeclass[$v]['classid']] = $clzh;
  2128. }
  2129. }
  2130. }
  2131. }
  2132. $zh = implode(" ",$pm);
  2133. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2134. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2135. if($list['size'])
  2136. {
  2137. $typeclass = $this->typeclass->read($list['size']);
  2138. $title .= $typeclass['title'];
  2139. }
  2140. $time = time();
  2141. if($xzsku)
  2142. {
  2143. $scsku = implode("-",$scsku);
  2144. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2145. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2146. $post['sku'] = trim($scsku,' ');
  2147. }
  2148. else
  2149. {
  2150. $post['sku'] = $sku;
  2151. }
  2152. //$post['sku'] = trim($sku,' ');
  2153. $post['title'] = rtrim($title,' ');
  2154. $post['number'] = $num;
  2155. $post['features'] = '-'.$features;
  2156. $post['enter'] = $time;
  2157. $post['time'] = $time;//操作时间
  2158. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2159. if($yza)
  2160. {
  2161. if($post['features'] != $yza[0]['features'])
  2162. {
  2163. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'success'=>false));exit;
  2164. }
  2165. }
  2166. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2167. if($yzb)
  2168. {
  2169. if($post['sku'] != $yzb[0]['sku'])
  2170. {
  2171. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','success'=>false));exit;
  2172. }
  2173. }
  2174. if(isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
  2175. {
  2176. echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
  2177. }
  2178. if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
  2179. {
  2180. echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
  2181. }
  2182. if($post['rktype'] == '' && $post['warehouse'] == 5)
  2183. {
  2184. echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
  2185. }
  2186. $yz = $this->whlabel->find_all("sku = '".$post['sku']."' and features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'",'type');
  2187. if(isset($yz[0]['type']))
  2188. {
  2189. $post['type'] = $yz[0]['type'];
  2190. }
  2191. if($post['state'] == 9)//如果选择预设库存
  2192. {
  2193. $this->whlabel->insert($post);
  2194. }
  2195. else
  2196. {
  2197. /**
  2198. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2199. if($ljg == 1)
  2200. {
  2201. for($i=0;$i<$order;$i++)
  2202. {
  2203. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2204. $this->whlabel->insert($post);
  2205. }
  2206. }
  2207. **/
  2208. //if($post['warehouse'] == '5')
  2209. //{
  2210. //}
  2211. $yydata = $post;
  2212. $yydata['zh'] = $zh;
  2213. /**
  2214. $wl = $this->apiyy->get_cjlp($yydata);
  2215. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2216. {
  2217. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2218. }
  2219. if($wl['Data'][0]['m_isSucess'] != 1)
  2220. {
  2221. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2222. }
  2223. **/
  2224. for($i=0;$i<$order;$i++)
  2225. {
  2226. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2227. $this->whlabel->insert($post);
  2228. }
  2229. }
  2230. echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
  2231. }
  2232. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2233. $this->data['wlshop'] = $wlshop;
  2234. $this->_Template('whlabel_enteradd',$this->data);
  2235. }
  2236. //修改产品
  2237. public function _enteredit($arg_array)
  2238. {
  2239. $dt = 0;
  2240. if(isset($_SESSION['api']))
  2241. {
  2242. $user = $this->user->get_api($_SESSION['api']);
  2243. $usp = $user;
  2244. $fgshop = "";$sid = "";
  2245. $user = explode('|',trim($user['shop'],'|'));
  2246. foreach ($user as $value)
  2247. {
  2248. $fgshop .= " shop = ".$value." or";
  2249. $sid .= " id = ".$value." or";
  2250. }
  2251. }
  2252. $post = $this->input->post(NULL, TRUE);
  2253. if(isset($post['sku']))
  2254. {
  2255. $list = array();$num = "";$title = "";$features = "";
  2256. $id = $this->input->post('id',true);
  2257. $order = $this->input->post('order',true);
  2258. $shop = $this->input->post('shop',true);
  2259. $post['shop'] = ($shop!="")?','.$shop:"";
  2260. $post['sku'] = $this->input->post('sku',true);
  2261. $post['sm'] = $this->input->post('sm',true);
  2262. $post['warehouse'] = $this->input->post('warehouse',true);
  2263. $post['purchase'] = $this->input->post('purchase',true);
  2264. $post['retreatwarehouse'] = $post['warehouse'];
  2265. $category = $this->input->post('category',true);
  2266. $list['category'] = $category;
  2267. $list['hairtype'] = $this->input->post('hairtype',true);
  2268. $list['grade'] = $this->input->post('grade',true);
  2269. $size = $this->input->post('size',true);
  2270. $list['size'] = rtrim($size,',');
  2271. $post['rktype'] = $this->input->post('rktype',true);
  2272. $post['text'] = $this->input->post('text',true);
  2273. $list['hairnumber'] = $this->input->post('hairnumber',true);
  2274. $list['extension'] = $this->input->post('extension',true);
  2275. if($category == 1297)
  2276. {
  2277. $list['sywignumber'] = $this->input->post('sywignumber',true);
  2278. }
  2279. if($category == 1702)
  2280. {
  2281. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  2282. $list['syother'] = $this->input->post('syother',true);
  2283. }
  2284. if($category == 133)
  2285. {
  2286. $list['fittype'] = $this->input->post('fittype',true);
  2287. $list['acother'] = $this->input->post('acother',true);
  2288. }
  2289. $list['color'] = $this->input->post('color',true);
  2290. $list['lowe'] = $this->input->post('lowe',true);
  2291. if(!$post['purchase'])
  2292. {
  2293. $post['purchase'] = 1;
  2294. }
  2295. if($category == 127)
  2296. {
  2297. $list['type'] = $this->input->post('type',true);
  2298. $list['headroad'] = $this->input->post('headroad',true);
  2299. $list['density'] = $this->input->post('density',true);
  2300. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  2301. {
  2302. $list['lacesize'] = $this->input->post('lacesize',true);
  2303. }
  2304. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2305. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2306. }
  2307. if($category == 128)
  2308. {
  2309. $list['lacetype'] = $this->input->post('lacetype',true);
  2310. $list['haircap'] = $this->input->post('haircap',true);
  2311. $list['density'] = $this->input->post('density',true);
  2312. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2313. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2314. $list['wigother'] = $this->input->post('wigother',true);
  2315. $list['wigother2'] = $this->input->post('wigother2',true);
  2316. }
  2317. if($category == 129)
  2318. {
  2319. $list['wide'] = $this->input->post('wide',true);
  2320. }
  2321. if($category == 131)
  2322. {
  2323. $list['gifttype'] = $this->input->post('gifttype',true);
  2324. $list['giftother'] = $this->input->post('giftother',true);
  2325. }
  2326. if($category == 134)
  2327. {
  2328. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2329. }
  2330. if($category == 1297)
  2331. {
  2332. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2333. $list['sywigother'] = $this->input->post('sywigother',true);
  2334. }
  2335. if($category == 130 || $category == 133 || $category == 1702)
  2336. {
  2337. $list['items'] = $this->input->post('items',true);
  2338. $list['weight'] = $this->input->post('weight',true);
  2339. }
  2340. if($category == 1702)
  2341. {
  2342. $list['syhairther'] = $this->input->post('syhairther',true);
  2343. }
  2344. foreach($list as $k=>$v)
  2345. {
  2346. if($v != 0)
  2347. {
  2348. $num .=$v;
  2349. $features .=$v.'-';
  2350. $typeclass = $this->typeclass->read($v);
  2351. if($k != 'size')
  2352. {
  2353. $title .= $typeclass['title']." ";
  2354. }
  2355. }
  2356. }
  2357. $typeclass = $this->typeclass->read($list['size']);
  2358. $title .= $typeclass['title'];
  2359. $time = time();
  2360. $post['title'] = rtrim($title,' ');
  2361. $post['number'] = $num;
  2362. $post['features'] = '-'.$features;
  2363. $post['time'] = $time;//操作时间
  2364. if($post['rktype'] == '' && $post['warehouse'] == 5)
  2365. {
  2366. echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
  2367. }
  2368. if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
  2369. {
  2370. echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
  2371. }
  2372. $uid = $this->whlabel->read($id);
  2373. $datanum = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2374. if($datanum > 0)
  2375. {
  2376. echo json_encode(array('msg'=>'此SKU有占单,请解除占单后再修改!','success'=>false));exit;
  2377. }
  2378. if($post['warehouse'] != '99999')//现在所有仓都检测,之前只有美仓5检测
  2379. {
  2380. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."'");
  2381. if($yza)
  2382. {
  2383. if($post['features'] != $yza[0]['features'])
  2384. {
  2385. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','success'=>false));exit;
  2386. }
  2387. }
  2388. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."'");
  2389. if($yzb)
  2390. {
  2391. if($post['sku'] != $yzb[0]['sku'])
  2392. {
  2393. echo json_encode(array('msg'=>'此产品信息的SKU和现有不一致!','success'=>false));exit;
  2394. }
  2395. }
  2396. if($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
  2397. {
  2398. echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
  2399. }
  2400. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2401. foreach ($data as $v)
  2402. {
  2403. $post['id'] = $v['id'];
  2404. $this->whlabel->save($post,$v['id']);
  2405. }
  2406. }
  2407. else
  2408. {
  2409. $data = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2410. if($data > 0)
  2411. {
  2412. echo json_encode(array('msg'=>'此产品有占单,无法修改!','success'=>false));exit;
  2413. }
  2414. else
  2415. {
  2416. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2417. foreach ($data as $v)
  2418. {
  2419. $post['id'] = $v['id'];
  2420. $this->whlabel->save($post,$v['id']);
  2421. }
  2422. }
  2423. }
  2424. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  2425. }
  2426. $uid = $this->whlabel->read($arg_array[0]);
  2427. $uid['order'] = $this->whlabel->find_count('enter = "'.$uid['enter'].'" and sku = "'.$uid['sku'].'" and state = "0"');
  2428. $this->data['enter'] = $uid ;
  2429. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2430. $this->data['wlshop'] = $wlshop;
  2431. $this->_Template('whlabel_enteredit',$this->data);
  2432. }
  2433. //入库浏览
  2434. public function _enter()
  2435. {
  2436. $post = $this->input->post(NULL, TRUE);
  2437. if(isset($post['s']))
  2438. {
  2439. $id_arr = $this->input->post('s');
  2440. $id_arr = explode(',',$id_arr);
  2441. if(!$id_arr)
  2442. {
  2443. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2444. }
  2445. //循环删除记录
  2446. foreach ($id_arr as $v)
  2447. {
  2448. $sid = $this->whlabel->read($v);
  2449. $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
  2450. if($count > 0)
  2451. {
  2452. echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
  2453. }
  2454. $info_list = $this->whlabel->find_all('enter ='.$sid['enter']);
  2455. foreach ($info_list as $va)
  2456. {
  2457. $this->whlabel->remove($va['id']);
  2458. }
  2459. }
  2460. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  2461. }
  2462. $sp = array();
  2463. $s = $this->shop->find_all('1=1','id,shopname');
  2464. foreach ($s as $v)
  2465. {
  2466. $sp[$v['id']] = $v['shopname'];
  2467. }
  2468. $wh = array();
  2469. $w = $this->warehouse->find_all('1=1','id,title');
  2470. foreach ($w as $v)
  2471. {
  2472. $wh[$v['id']] = $v['title'];
  2473. }
  2474. if(isset($post['page']))
  2475. {
  2476. $page = $this->input->post('page',true);
  2477. $perpage = $this->input->post('perpage',true);
  2478. $category = $this->input->post('category',true);
  2479. $size = $this->input->post('size',true);
  2480. $grade = $this->input->post('grade',true);
  2481. $color = $this->input->post('color',true);
  2482. $lowe = $this->input->post('lowe',true);
  2483. $sku = $this->input->post('sku',true);
  2484. $warehouse = $this->input->post('warehouse',true);
  2485. $purchase = $this->input->post('purchase',true);
  2486. $ktime = $this->input->post('ktime',true);
  2487. $jtime = $this->input->post('jtime',true);
  2488. $ktime = strtotime($ktime);
  2489. $jtime = strtotime($jtime);
  2490. $where = "1=1";$gj = "";$ck = "";
  2491. if($category)
  2492. {
  2493. $where .= " and features like '%-$category-%'";
  2494. }
  2495. if($size)
  2496. {
  2497. $where .= " and features like '%-$size-%'";
  2498. }
  2499. if($grade)
  2500. {
  2501. $where .= " and features like '%-$grade-%'";
  2502. }
  2503. if($color)
  2504. {
  2505. $where .= " and features like '%-$color-%'";
  2506. }
  2507. if($lowe)
  2508. {
  2509. $where .= " and features like '%-$lowe-%'";
  2510. }
  2511. if($warehouse)
  2512. {
  2513. $where .= " and warehouse = '$warehouse'";
  2514. }
  2515. if($purchase)
  2516. {
  2517. $where .= " and purchase = '$purchase'";
  2518. }
  2519. if($sku)
  2520. {
  2521. $where .= " and sku like '%$sku%'";
  2522. }
  2523. if($ktime && $jtime)
  2524. {
  2525. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2526. }
  2527. //数据排序
  2528. $order_str = "enter desc";
  2529. if(empty($page))
  2530. {
  2531. $start = 0;
  2532. $perpage = 1;
  2533. }
  2534. else
  2535. {
  2536. $start = ($page - 1)*$perpage;
  2537. }
  2538. //取得信息列表
  2539. $info_list = $this->whlabel->find_pc($where,'enter,warehouse,sku','id,warehouse,shop,sku,title,enter',$order_str,$start,$perpage);
  2540. foreach ($info_list as $k=>$v)
  2541. {
  2542. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2543. if($v['shop']=='')
  2544. {
  2545. $s = '通用';
  2546. }
  2547. else
  2548. {
  2549. $info_list[$k]['shop'] = '';
  2550. foreach (explode(',',trim($v['shop'],',')) as $val)
  2551. {
  2552. $info_list[$k]['shop'] .= $sp[$val].'</br>';
  2553. }
  2554. }
  2555. $info_list[$k]['enter'] = date('Y-m-d H:i:s',$v['enter']);
  2556. $g = $this->whlabel->find_count($where.' and enter = "'.$v['enter'].'" and sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'"');
  2557. $info_list[$k]['g'] = $g;
  2558. }
  2559. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  2560. $pagenum = ceil($total/$perpage);
  2561. $over = $total-($start+$perpage);
  2562. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2563. echo json_encode($rows);exit;
  2564. }
  2565. $this->_Template('whlabel_enter',$this->data);
  2566. }
  2567. //出库浏览
  2568. public function _out()
  2569. {
  2570. $post = $this->input->post(NULL, TRUE);
  2571. if(isset($post['page']))
  2572. {
  2573. $page = $this->input->post('page',true);
  2574. $perpage = $this->input->post('perpage',true);
  2575. $category = $this->input->post('category',true);
  2576. $size = $this->input->post('size',true);
  2577. $grade = $this->input->post('grade',true);
  2578. $color = $this->input->post('color',true);
  2579. $lowe = $this->input->post('lowe',true);
  2580. $sku = $this->input->post('sku',true);
  2581. $warehouse = $this->input->post('warehouse',true);
  2582. $purchase = $this->input->post('purchase',true);
  2583. $state = $this->input->post('state',true);
  2584. $ktime = $this->input->post('ktime',true);
  2585. $jtime = $this->input->post('jtime',true);
  2586. $ktime = strtotime($ktime);
  2587. $jtime = strtotime($jtime);
  2588. $where = "state=3";$gj = "";$ck = "";
  2589. if($category)
  2590. {
  2591. $where .= " and features like '%-$category-%'";
  2592. }
  2593. if($size)
  2594. {
  2595. $where .= " and features like '%-$size-%'";
  2596. }
  2597. if($grade)
  2598. {
  2599. $where .= " and features like '%-$grade-%'";
  2600. }
  2601. if($color)
  2602. {
  2603. $where .= " and features like '%-$color-%'";
  2604. }
  2605. if($lowe)
  2606. {
  2607. $where .= " and features like '%-$lowe-%'";
  2608. }
  2609. if($state)
  2610. {
  2611. $where .= " and state = '$state'";
  2612. }
  2613. if($warehouse)
  2614. {
  2615. $where .= " and warehouse = '$warehouse'";
  2616. }
  2617. if($purchase)
  2618. {
  2619. $where .= " and purchase = '$purchase'";
  2620. }
  2621. if($sku)
  2622. {
  2623. $where .= " and sku = '$sku'";
  2624. }
  2625. if($ktime && $jtime)
  2626. {
  2627. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2628. }
  2629. //数据排序
  2630. $order_str = "id desc";
  2631. if(empty($page))
  2632. {
  2633. $start = 0;
  2634. $perpage = 1;
  2635. }
  2636. else
  2637. {
  2638. $start = ($page - 1)*$perpage;
  2639. }
  2640. //取得信息列表
  2641. $info_list = $this->whlabel->find_all($where,'sku');
  2642. $rows = array();$list = array();
  2643. foreach ($info_list as $key=>$value)
  2644. {
  2645. $rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
  2646. }
  2647. $rows = array_unique($rows);//删除重复记录
  2648. foreach ($rows as $key=>$value)
  2649. {
  2650. $data = $this->whlabel->get_sku($value);//获取目前sku的所有数据
  2651. $ck = $this->warehouse->read($data['warehouse']);
  2652. $warehouse = $ck['title'];
  2653. $gy = $this->purchase->read($data['purchase']);
  2654. $purchase = $gy['purchase'];
  2655. $g = $this->whlabel->find_count($where.' and sku = "'.$value.'" and state = 3');
  2656. $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);
  2657. }
  2658. $total = count($list);
  2659. $pagenum = ceil($total/$perpage);
  2660. $over = $total-($start+$perpage);
  2661. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  2662. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  2663. echo json_encode($rows);exit;
  2664. }
  2665. $this->_Template('whlabel_out',$this->data);
  2666. }
  2667. //出库标签浏览
  2668. public function _label()
  2669. {
  2670. $post = $this->input->post(NULL, TRUE);
  2671. if(isset($post['page']))
  2672. {
  2673. $page = $this->input->post('page',true);
  2674. $perpage = $this->input->post('perpage',true);
  2675. $sku = $this->input->post('sku',true);
  2676. $warehouse = $this->input->post('warehouse',true);
  2677. $purchase = $this->input->post('purchase',true);
  2678. $orderinfo = $this->input->post('orderinfo',true);
  2679. $waybill = $this->input->post('waybill',true);
  2680. $category = $this->input->post('category',true);
  2681. $size = $this->input->post('size',true);
  2682. $grade = $this->input->post('grade',true);
  2683. $color = $this->input->post('color',true);
  2684. $lowe = $this->input->post('lowe',true);
  2685. $where = "state=1";
  2686. if($sku)
  2687. {
  2688. $where .= " and sku = '$sku'";
  2689. }
  2690. if($warehouse)
  2691. {
  2692. $where .= " and warehouse = '$warehouse'";
  2693. }
  2694. if($purchase)
  2695. {
  2696. $where .= " and purchase = '$purchase'";
  2697. }
  2698. if($orderinfo)
  2699. {
  2700. $where .= " and orderinfo = '$orderinfo'";
  2701. }
  2702. if($waybill)
  2703. {
  2704. $where .= " and waybill = '$waybill'";
  2705. }
  2706. if($category)
  2707. {
  2708. $where .= " and features like '%-$category-%'";
  2709. }
  2710. if($size)
  2711. {
  2712. $where .= " and features like '%-$size-%'";
  2713. }
  2714. if($grade)
  2715. {
  2716. $where .= " and features like '%-$grade-%'";
  2717. }
  2718. if($color)
  2719. {
  2720. $where .= " and features like '%-$color-%'";
  2721. }
  2722. if($lowe)
  2723. {
  2724. $where .= " and features like '%-$lowe-%'";
  2725. }
  2726. //数据排序
  2727. $order_str = "outk desc";
  2728. if(empty($page))
  2729. {
  2730. $start = 0;
  2731. $perpage = 1;
  2732. }
  2733. else
  2734. {
  2735. $start = ($page - 1)*$perpage;
  2736. }
  2737. //取得信息列表
  2738. $info_list = $this->whlabel->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
  2739. foreach ($info_list as $key=>$value)
  2740. {
  2741. $warehouse = $this->warehouse->read($value['warehouse']);
  2742. $info_list[$key]['warehouse'] = $warehouse['title'];
  2743. $purchase = $this->purchase->read($value['purchase']);
  2744. $info_list[$key]['purchase'] = $purchase['title'];
  2745. if($value['outk'] != 0)
  2746. {
  2747. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  2748. }
  2749. else
  2750. {
  2751. $info_list[$key]['outk'] = "";
  2752. }
  2753. if($value['orderinfo'] == 0)
  2754. {
  2755. $info_list[$key]['orderinfo'] = "";
  2756. }
  2757. if($value['waybill'] == 0)
  2758. {
  2759. $info_list[$key]['waybill'] = "";
  2760. }
  2761. }
  2762. $total = $this->whlabel->find_count($where);
  2763. $pagenum = ceil($total/$perpage);
  2764. $over = $total-($start+$perpage);
  2765. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2766. echo json_encode($rows);exit;
  2767. }
  2768. $this->_Template('whlabel_label',$this->data);
  2769. }
  2770. //独立站出库订单
  2771. public function _outorder()
  2772. {
  2773. if(isset($_SESSION['api']))
  2774. {
  2775. $user = $this->user->get_api($_SESSION['api']);
  2776. $usp = $user;
  2777. $fgshop = "";$sid = "";
  2778. $user = explode('|',trim($user['shop'],'|'));
  2779. foreach ($user as $value)
  2780. {
  2781. $fgshop .= " shop = ".$value." or";
  2782. $sid .= " id = ".$value." or";
  2783. }
  2784. }
  2785. else
  2786. {
  2787. echo "请重新登录";
  2788. }
  2789. $post = $this->input->post(NULL, TRUE);
  2790. if(isset($post['page']))
  2791. {
  2792. $page = $this->input->post('page',true);
  2793. $perpage = $this->input->post('perpage',true);
  2794. $warehouse = $this->input->post('warehouse',true);
  2795. $xztime = $this->input->post('xztime',true);
  2796. $timetk = $this->input->post('timetkk',true);
  2797. $timetj = $this->input->post('timetjj',true);
  2798. $shop = $this->input->post('shop',true);
  2799. $source = $this->input->post('source',true);
  2800. $orderinfo = $this->input->post('orderinfo',true);
  2801. $number = $this->input->post('number',true);
  2802. $sfxh = $this->input->post('sfxh',true);
  2803. $express = $this->input->post('express',true);
  2804. $waybill = $this->input->post('waybill',true);
  2805. $library = $this->input->post('library',true);
  2806. $country = $this->input->post('country',true);
  2807. $so = $this->input->post('so',true);
  2808. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2809. $print = $this->input->post('print',true);
  2810. $state = $this->input->post('state',true);
  2811. $orderurl = $this->input->post('orderurl',true);
  2812. $timetk = strtotime($timetk);
  2813. $timetj = strtotime($timetj);
  2814. /**
  2815. $sj = $this->input->post('sj',true);
  2816. if($sj)
  2817. {
  2818. $sj = $this->input->post('sj',true);
  2819. }
  2820. else
  2821. {
  2822. $sj = "fullorder";
  2823. }
  2824. **/
  2825. $sj = "fullorder";
  2826. $where = "1=1";
  2827. if($warehouse)
  2828. {
  2829. $where .= " and type = '$warehouse'";
  2830. }
  2831. if($timetk && $timetj)
  2832. {
  2833. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2834. }
  2835. if($orderinfo)
  2836. {
  2837. $where .= " and orderinfo = '$orderinfo'";
  2838. }
  2839. if($number)
  2840. {
  2841. $where .= " and number = '$number'";
  2842. }
  2843. if($express)
  2844. {
  2845. $where .= " and express = '$express'";
  2846. }
  2847. if($waybill)
  2848. {
  2849. $where .= " and waybill = '$waybill'";
  2850. }
  2851. if($library)
  2852. {
  2853. $where .= " and library = '$library'";
  2854. }
  2855. if($print)
  2856. {
  2857. $where .= " and print = '$print'";
  2858. }
  2859. if($libraryconfirm)
  2860. {
  2861. $where .= " and libraryconfirm = '$libraryconfirm'";
  2862. }
  2863. if($state)
  2864. {
  2865. $where .= " and state = '$state'";
  2866. }
  2867. if($shop)
  2868. {
  2869. $where .= " and shop = '$shop'";
  2870. }
  2871. if($country)
  2872. {
  2873. $where .= " and country = '$country'";
  2874. }
  2875. if($sfxh != '')
  2876. {
  2877. $where .= " and sfxh = '$sfxh'";
  2878. }
  2879. if($so)
  2880. {
  2881. $where .= " and shipremarks like '%$so%'";
  2882. }
  2883. if($source)
  2884. {
  2885. if($source == '2d')
  2886. {
  2887. $where .= " and source >= '2'";
  2888. }
  2889. else
  2890. {
  2891. $where .= " and source = '$source'";
  2892. }
  2893. }
  2894. if(isset($_SESSION['api']))
  2895. {
  2896. foreach ($user as $value)
  2897. {
  2898. $fgshop .= " shop = ".$value." or";
  2899. }
  2900. $where .= " and (".rtrim($fgshop,'or').")";
  2901. }
  2902. if($orderurl)
  2903. {
  2904. $url = $this->orderurl->read($orderurl);
  2905. $where .= " and link like '%".$url['url']."%'";
  2906. }
  2907. //数据排序
  2908. $order_str = "librarytime desc";
  2909. if(empty($page))
  2910. {
  2911. $start = 0;
  2912. $perpage = 1;
  2913. }
  2914. else
  2915. {
  2916. $start = ($page - 1)*$perpage;
  2917. }
  2918. //取得信息列表
  2919. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2920. //格式化数据
  2921. foreach ($info_list as $key=>$value)
  2922. {
  2923. $shop = $this->shop->read($value['shop']);
  2924. $info_list[$key]['shop'] = $shop['shopname'];
  2925. $express = $this->express->read($value['express']);
  2926. $info_list[$key]['express'] = $express['servicename'];
  2927. $warehouse = $this->warehouse->read($value['type']);
  2928. $info_list[$key]['type'] = $warehouse['title'];
  2929. if($value['librarytime'] == '0')
  2930. {
  2931. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2932. }
  2933. else
  2934. {
  2935. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2936. }
  2937. }
  2938. $total = $this->$sj->find_count($where);
  2939. $pagenum = ceil($total/$perpage);
  2940. $over = $total-($start+$perpage);
  2941. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2942. echo json_encode($rows);exit;
  2943. }
  2944. $this->data['express'] = $this->express->find_all();
  2945. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2946. $this->data['wlshop'] = $wlshop;
  2947. $user = $this->user->get_api($_SESSION['api']);
  2948. $powerid = $this->power->read($user['power']);
  2949. $powertext = explode('|',trim($powerid['excelid'],'|'));
  2950. $pid = '';
  2951. foreach ($powertext as $v)
  2952. {
  2953. $pid .= " id = ".$v." or";
  2954. }
  2955. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  2956. $this->data['fullorderexcel'] = $fullorderexcel;
  2957. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  2958. $this->data['orderurl'] = $orderurl;
  2959. $this->_Template('whlabel_outorder',$this->data);
  2960. }
  2961. //tt出库
  2962. public function _toutorder()
  2963. {
  2964. if(isset($_SESSION['api']))
  2965. {
  2966. $user = $this->user->get_api($_SESSION['api']);
  2967. $usp = $user;
  2968. $fgshop = "";$sid = "";
  2969. $user = explode('|',trim($user['shop'],'|'));
  2970. foreach ($user as $value)
  2971. {
  2972. $fgshop .= " shop = ".$value." or";
  2973. $sid .= " id = ".$value." or";
  2974. }
  2975. }
  2976. else
  2977. {
  2978. echo "请重新登录";
  2979. }
  2980. $post = $this->input->post(NULL, TRUE);
  2981. if(isset($post['page']))
  2982. {
  2983. $page = $this->input->post('page',true);
  2984. $perpage = $this->input->post('perpage',true);
  2985. $warehouse = $this->input->post('warehouse',true);
  2986. $xztime = $this->input->post('xztime',true);
  2987. $timetk = $this->input->post('timetkk',true);
  2988. $timetj = $this->input->post('timetjj',true);
  2989. $shop = $this->input->post('shop',true);
  2990. $source = $this->input->post('source',true);
  2991. $orderinfo = $this->input->post('orderinfo',true);
  2992. $number = $this->input->post('number',true);
  2993. $sfxh = $this->input->post('sfxh',true);
  2994. $express = $this->input->post('express',true);
  2995. $waybill = $this->input->post('waybill',true);
  2996. $library = $this->input->post('library',true);
  2997. $country = $this->input->post('country',true);
  2998. $so = $this->input->post('so',true);
  2999. $libraryconfirm = $this->input->post('libraryconfirm',true);
  3000. $print = $this->input->post('print',true);
  3001. $state = $this->input->post('state',true);
  3002. $orderurl = $this->input->post('orderurl',true);
  3003. $timetk = strtotime($timetk);
  3004. $timetj = strtotime($timetj);
  3005. /**
  3006. $sj = $this->input->post('sj',true);
  3007. if($sj)
  3008. {
  3009. $sj = $this->input->post('sj',true);
  3010. }
  3011. else
  3012. {
  3013. $sj = "fullorder";
  3014. }
  3015. **/
  3016. $sj = "fullordertt";
  3017. $where = "1=1";
  3018. if($warehouse)
  3019. {
  3020. $where .= " and type = '$warehouse'";
  3021. }
  3022. if($timetk && $timetj)
  3023. {
  3024. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3025. }
  3026. if($orderinfo)
  3027. {
  3028. $where .= " and orderinfo = '$orderinfo'";
  3029. }
  3030. if($number)
  3031. {
  3032. $where .= " and number = '$number'";
  3033. }
  3034. if($express)
  3035. {
  3036. $where .= " and express = '$express'";
  3037. }
  3038. if($waybill)
  3039. {
  3040. $where .= " and waybill = '$waybill'";
  3041. }
  3042. if($library)
  3043. {
  3044. $where .= " and library = '$library'";
  3045. }
  3046. if($print)
  3047. {
  3048. $where .= " and print = '$print'";
  3049. }
  3050. if($libraryconfirm)
  3051. {
  3052. $where .= " and libraryconfirm = '$libraryconfirm'";
  3053. }
  3054. if($state)
  3055. {
  3056. $where .= " and state = '$state'";
  3057. }
  3058. if($shop)
  3059. {
  3060. $where .= " and shop = '$shop'";
  3061. }
  3062. if($country)
  3063. {
  3064. $where .= " and country = '$country'";
  3065. }
  3066. if($sfxh != '')
  3067. {
  3068. $where .= " and sfxh = '$sfxh'";
  3069. }
  3070. if($so)
  3071. {
  3072. $where .= " and shipremarks like '%$so%'";
  3073. }
  3074. if($source)
  3075. {
  3076. if($source == '2d')
  3077. {
  3078. $where .= " and source >= '2'";
  3079. }
  3080. else
  3081. {
  3082. $where .= " and source = '$source'";
  3083. }
  3084. }
  3085. if(isset($_SESSION['api']))
  3086. {
  3087. foreach ($user as $value)
  3088. {
  3089. $fgshop .= " shop = ".$value." or";
  3090. }
  3091. $where .= " and (".rtrim($fgshop,'or').")";
  3092. }
  3093. if($orderurl)
  3094. {
  3095. $url = $this->orderurl->read($orderurl);
  3096. $where .= " and link like '%".$url['url']."%'";
  3097. }
  3098. //数据排序
  3099. $order_str = "librarytime desc";
  3100. if(empty($page))
  3101. {
  3102. $start = 0;
  3103. $perpage = 1;
  3104. }
  3105. else
  3106. {
  3107. $start = ($page - 1)*$perpage;
  3108. }
  3109. //取得信息列表
  3110. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3111. //格式化数据
  3112. foreach ($info_list as $key=>$value)
  3113. {
  3114. $shop = $this->shop->read($value['shop']);
  3115. $info_list[$key]['shop'] = $shop['shopname'];
  3116. $express = $this->express->read($value['express']);
  3117. $info_list[$key]['express'] = $express['servicename'];
  3118. $warehouse = $this->warehouse->read($value['type']);
  3119. $info_list[$key]['type'] = $warehouse['title'];
  3120. if($value['librarytime'] == '0')
  3121. {
  3122. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3123. }
  3124. else
  3125. {
  3126. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3127. }
  3128. }
  3129. $total = $this->$sj->find_count($where);
  3130. $pagenum = ceil($total/$perpage);
  3131. $over = $total-($start+$perpage);
  3132. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3133. echo json_encode($rows);exit;
  3134. }
  3135. $this->data['express'] = $this->express->find_all();
  3136. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3137. $this->data['wlshop'] = $wlshop;
  3138. $user = $this->user->get_api($_SESSION['api']);
  3139. $powerid = $this->power->read($user['power']);
  3140. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3141. $pid = '';
  3142. foreach ($powertext as $v)
  3143. {
  3144. $pid .= " id = ".$v." or";
  3145. }
  3146. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3147. $this->data['fullorderexcel'] = $fullorderexcel;
  3148. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  3149. $this->data['orderurl'] = $orderurl;
  3150. $this->_Template('whlabel_toutorder',$this->data);
  3151. }
  3152. //速卖通出库订单
  3153. public function _soutorder()
  3154. {
  3155. if(isset($_SESSION['api']))
  3156. {
  3157. $user = $this->user->get_api($_SESSION['api']);
  3158. $usp = $user;
  3159. $fgshop = "";$sid = "";
  3160. $user = explode('|',trim($user['shop'],'|'));
  3161. foreach ($user as $value)
  3162. {
  3163. $sid .= " id = ".$value." or";
  3164. }
  3165. }
  3166. $post = $this->input->post(NULL, TRUE);
  3167. if(isset($post['page']))
  3168. {
  3169. $page = $this->input->post('page',true);
  3170. $perpage = $this->input->post('perpage',true);
  3171. $warehouse = $this->input->post('warehouse',true);
  3172. $xztime = $this->input->post('xztime',true);
  3173. $timetk = $this->input->post('timetkk',true);
  3174. $timetj = $this->input->post('timetjj',true);
  3175. $shop = $this->input->post('shop',true);
  3176. $source = $this->input->post('source',true);
  3177. $orderinfo = $this->input->post('orderinfo',true);
  3178. $number = $this->input->post('number',true);
  3179. $express = $this->input->post('express',true);
  3180. $waybill = $this->input->post('waybill',true);
  3181. $library = $this->input->post('library',true);
  3182. $country = $this->input->post('country',true);
  3183. $sfxh = $this->input->post('sfxh',true);
  3184. $libraryconfirm = $this->input->post('libraryconfirm',true);
  3185. $print = $this->input->post('print',true);
  3186. $state = $this->input->post('state',true);
  3187. $so = $this->input->post('so',true);
  3188. $timetk = strtotime($timetk);
  3189. $timetj = strtotime($timetj);
  3190. /**
  3191. $sj = $this->input->post('sj',true);
  3192. if($sj)
  3193. {
  3194. $sj = $this->input->post('sj',true);
  3195. }
  3196. else
  3197. {
  3198. $sj = "fullorder";
  3199. }
  3200. **/
  3201. $sj = "fullordersmt";
  3202. $where = "1=1";
  3203. if($warehouse)
  3204. {
  3205. $where .= " and type = '$warehouse'";
  3206. }
  3207. if($timetk && $timetj)
  3208. {
  3209. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3210. }
  3211. if($orderinfo)
  3212. {
  3213. $where .= " and orderinfo = '$orderinfo'";
  3214. }
  3215. if($number)
  3216. {
  3217. $where .= " and number = '$number'";
  3218. }
  3219. if($express)
  3220. {
  3221. $where .= " and express = '$express'";
  3222. }
  3223. if($waybill)
  3224. {
  3225. $where .= " and waybill = '$waybill'";
  3226. }
  3227. if($library)
  3228. {
  3229. $where .= " and library = '$library'";
  3230. }
  3231. if($print)
  3232. {
  3233. $where .= " and print = '$print'";
  3234. }
  3235. if($libraryconfirm)
  3236. {
  3237. $where .= " and libraryconfirm = '$libraryconfirm'";
  3238. }
  3239. if($state)
  3240. {
  3241. $where .= " and state = '$state'";
  3242. }
  3243. if($shop)
  3244. {
  3245. $where .= " and shop = '$shop'";
  3246. }
  3247. if($sfxh != '')
  3248. {
  3249. $where .= " and sfxh = '$sfxh'";
  3250. }
  3251. if($so)
  3252. {
  3253. $where .= " and shipremarks like '%$so%'";
  3254. }
  3255. if($source)
  3256. {
  3257. $where .= " and source = '$source'";
  3258. }
  3259. if($country)
  3260. {
  3261. $where .= " and country = '$country'";
  3262. }
  3263. else
  3264. {
  3265. if(isset($_SESSION['api']))
  3266. {
  3267. foreach ($user as $value)
  3268. {
  3269. $fgshop .= " shop = ".$value." or";
  3270. }
  3271. $where .= " and (".rtrim($fgshop,'or').")";
  3272. }
  3273. }
  3274. //数据排序
  3275. $order_str = "librarytime desc";
  3276. if(empty($page))
  3277. {
  3278. $start = 0;
  3279. $perpage = 1;
  3280. }
  3281. else
  3282. {
  3283. $start = ($page - 1)*$perpage;
  3284. }
  3285. //取得信息列表
  3286. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3287. //格式化数据
  3288. foreach ($info_list as $key=>$value)
  3289. {
  3290. $shop = $this->shop->read($value['shop']);
  3291. $info_list[$key]['shop'] = $shop['shopname'];
  3292. $express = $this->express->read($value['express']);
  3293. $info_list[$key]['express'] = $express['servicename'];
  3294. $warehouse = $this->warehouse->read($value['type']);
  3295. $info_list[$key]['type'] = $warehouse['title'];
  3296. if($value['librarytime'] == '0')
  3297. {
  3298. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3299. }
  3300. else
  3301. {
  3302. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3303. }
  3304. }
  3305. $total = $this->$sj->find_count($where);
  3306. $pagenum = ceil($total/$perpage);
  3307. $over = $total-($start+$perpage);
  3308. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3309. echo json_encode($rows);exit;
  3310. }
  3311. $this->data['express'] = $this->express->find_all();
  3312. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3313. $this->data['wlshop'] = $wlshop;
  3314. $user = $this->user->get_api($_SESSION['api']);
  3315. $powerid = $this->power->read($user['power']);
  3316. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3317. $pid = '';
  3318. foreach ($powertext as $v)
  3319. {
  3320. $pid .= " id = ".$v." or";
  3321. }
  3322. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3323. $this->data['fullorderexcel'] = $fullorderexcel;
  3324. $this->_Template('whlabel_soutorder',$this->data);
  3325. }
  3326. //订单退库
  3327. public function _retreat()
  3328. {
  3329. $post = $this->input->post(NULL, TRUE);
  3330. if(isset($post['page']))
  3331. {
  3332. $page = $this->input->post('page',true);
  3333. $perpage = $this->input->post('perpage',true);
  3334. $warehouse = $this->input->post('warehouse',true);
  3335. $timetk = $this->input->post('timetk',true);
  3336. $timetj = $this->input->post('timetj',true);
  3337. $shop = $this->input->post('shop',true);
  3338. $source = $this->input->post('source',true);
  3339. $state = $this->input->post('state',true);
  3340. $review = $this->input->post('review',true);
  3341. $state = $this->input->post('state',true);
  3342. $express = $this->input->post('express',true);
  3343. $orderinfo = $this->input->post('orderinfo',true);
  3344. $user = $this->input->post('user',true);
  3345. $name = $this->input->post('name',true);
  3346. $waybill = $this->input->post('waybill',true);
  3347. $timetk = strtotime($timetk);
  3348. $timetj = strtotime($timetj);
  3349. $where = "(state=206 or state=210) and mergeid = 0";
  3350. if($warehouse)
  3351. {
  3352. $where .= " and state = '$warehouse'";
  3353. }
  3354. if($timetk && $timetj)
  3355. {
  3356. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3357. }
  3358. if($shop)
  3359. {
  3360. $where .= " and shop = '$shop'";
  3361. }
  3362. if($source)
  3363. {
  3364. $where .= " and source = '$source'";
  3365. }
  3366. if($state)
  3367. {
  3368. $where .= " and state = '$state'";
  3369. }
  3370. if($review)
  3371. {
  3372. $where .= " and review = '$review'";
  3373. }
  3374. if($state)
  3375. {
  3376. $where .= " and state = '$state'";
  3377. }
  3378. if($express)
  3379. {
  3380. $where .= " and express = '$express'";
  3381. }
  3382. if($orderinfo)
  3383. {
  3384. $where .= " and orderinfo = '$orderinfo'";
  3385. }
  3386. if($user)
  3387. {
  3388. $where .= " and user = '$user'";
  3389. }
  3390. if($name)
  3391. {
  3392. $where .= " and name = '$name'";
  3393. }
  3394. if($waybill)
  3395. {
  3396. $where .= " and waybill = '$waybill'";
  3397. }
  3398. //数据排序
  3399. $order_str = "id desc";
  3400. if(empty($page))
  3401. {
  3402. $start = 0;
  3403. $perpage = 1;
  3404. }
  3405. else
  3406. {
  3407. $start = ($page - 1)*$perpage;
  3408. }
  3409. //取得信息列表
  3410. $info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
  3411. //格式化数据
  3412. foreach ($info_list as $key=>$value)
  3413. {
  3414. $shop = $this->shop->read($value['shop']);
  3415. $info_list[$key]['shop'] = $shop['shopname'];
  3416. $warehouse = $this->warehouse->read($value['warehouse']);
  3417. $info_list[$key]['warehouse'] = $warehouse['title'];
  3418. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/".$value['id']."'>".$value['orderinfo']."</a>";
  3419. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  3420. if($value['waybill'] == 0)
  3421. {
  3422. $info_list[$key]['waybill'] = "";
  3423. }
  3424. $express = $this->express->read($value['express']);
  3425. $info_list[$key]['express'] = $express['title'];
  3426. $typeclass = $this->typeclass->read($value['state']);
  3427. $info_list[$key]['state'] = $typeclass['title'];
  3428. }
  3429. $total = $this->fullorder->find_count($where);
  3430. $pagenum = ceil($total/$perpage);
  3431. $over = $total-($start+$perpage);
  3432. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3433. echo json_encode($rows);exit;
  3434. }
  3435. $this->data['express'] = $this->express->find_all();
  3436. $this->_Template('whlabel_retreat',$this->data);
  3437. }
  3438. //退库标签浏览
  3439. public function _retreatlk()
  3440. {
  3441. $post = $this->input->post(NULL, TRUE);
  3442. if(isset($post['page']))
  3443. {
  3444. $page = $this->input->post('page',true);
  3445. $perpage = $this->input->post('perpage',true);
  3446. $timetk = $this->input->post('timetk',true);
  3447. $timetj = $this->input->post('timetj',true);
  3448. $sku = $this->input->post('sku',true);
  3449. $warehouse = $this->input->post('warehouse',true);
  3450. $purchase = $this->input->post('purchase',true);
  3451. $orderinfo = $this->input->post('orderinfo',true);
  3452. $waybill = $this->input->post('waybill',true);
  3453. $category = $this->input->post('category',true);
  3454. $size = $this->input->post('size',true);
  3455. $grade = $this->input->post('grade',true);
  3456. $color = $this->input->post('color',true);
  3457. $lowe = $this->input->post('lowe',true);
  3458. $state = $this->input->post('state',true);
  3459. $timetk = strtotime($timetk);
  3460. $timetj = strtotime($timetj);
  3461. $where = "state=2";
  3462. if($timetk && $timetj)
  3463. {
  3464. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3465. }
  3466. if($sku)
  3467. {
  3468. $where .= " and sku = '$sku'";
  3469. }
  3470. if($warehouse)
  3471. {
  3472. $where .= " and warehouse = '$warehouse'";
  3473. }
  3474. if($purchase)
  3475. {
  3476. $where .= " and purchase = '$purchase'";
  3477. }
  3478. if($orderinfo)
  3479. {
  3480. $where .= " and orderinfo = '$orderinfo'";
  3481. }
  3482. if($waybill)
  3483. {
  3484. $where .= " and waybill = '$waybill'";
  3485. }
  3486. if($category)
  3487. {
  3488. $where .= " and features like '%-$category-%'";
  3489. }
  3490. if($size)
  3491. {
  3492. $where .= " and features like '%-$size-%'";
  3493. }
  3494. if($grade)
  3495. {
  3496. $where .= " and features like '%-$grade-%'";
  3497. }
  3498. if($color)
  3499. {
  3500. $where .= " and features like '%-$color-%'";
  3501. }
  3502. if($lowe)
  3503. {
  3504. $where .= " and features like '%-$lowe-%'";
  3505. }
  3506. //数据排序
  3507. $order_str = "time desc";
  3508. if(empty($page))
  3509. {
  3510. $start = 0;
  3511. $perpage = 1;
  3512. }
  3513. else
  3514. {
  3515. $start = ($page - 1)*$perpage;
  3516. }
  3517. //取得信息列表
  3518. $info_list = $this->whlabel->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
  3519. foreach ($info_list as $key=>$value)
  3520. {
  3521. $warehouse = $this->warehouse->read($value['warehouse']);
  3522. $info_list[$key]['warehouse'] = $warehouse['title'];
  3523. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3524. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3525. $purchase = $this->purchase->read($value['purchase']);
  3526. $info_list[$key]['purchase'] = $purchase['title'];
  3527. if($value['outk'] != 0)
  3528. {
  3529. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  3530. }
  3531. else
  3532. {
  3533. $info_list[$key]['outk'] = "";
  3534. }
  3535. if($value['retreat'] != 0)
  3536. {
  3537. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
  3538. }
  3539. else
  3540. {
  3541. $info_list[$key]['retreat'] = "";
  3542. }
  3543. if($value['orderinfo'] == 0)
  3544. {
  3545. $info_list[$key]['orderinfo'] = "";
  3546. }
  3547. if($value['waybill'] == 0)
  3548. {
  3549. $info_list[$key]['waybill'] = "";
  3550. }
  3551. }
  3552. $total = $this->whlabel->find_count($where);
  3553. $pagenum = ceil($total/$perpage);
  3554. $over = $total-($start+$perpage);
  3555. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3556. echo json_encode($rows);exit;
  3557. }
  3558. $this->_Template('whlabel_retreatlk',$this->data);
  3559. }
  3560. //更换标签及浏览
  3561. public function _change()
  3562. {
  3563. $post = $this->input->post(NULL, TRUE);
  3564. if(isset($post['page']))
  3565. {
  3566. $page = $this->input->post('page',true);
  3567. $perpage = $this->input->post('perpage',true);
  3568. $timetk = $this->input->post('timetk',true);
  3569. $timetj = $this->input->post('timetj',true);
  3570. $label = $this->input->post('label',true);
  3571. $oldlabel = $this->input->post('oldlabel',true);
  3572. $timetk = strtotime($timetk);
  3573. $timetj = strtotime($timetj);
  3574. $where = "state=10 ";
  3575. if($timetk && $timetj)
  3576. {
  3577. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3578. }
  3579. if($label)
  3580. {
  3581. $where .= " and label = '$label'";
  3582. }
  3583. if($oldlabel)
  3584. {
  3585. $where .= " and oldlabel = '$oldlabel'";
  3586. }
  3587. //数据排序
  3588. $order_str = "time asc";
  3589. if(empty($page))
  3590. {
  3591. $start = 0;
  3592. $perpage = 1;
  3593. }
  3594. else
  3595. {
  3596. $start = ($page - 1)*$perpage;
  3597. }
  3598. //取得信息列表
  3599. $info_list = $this->whlabel->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
  3600. foreach ($info_list as $key=>$value)
  3601. {
  3602. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
  3603. }
  3604. $total = $this->whlabel->find_count($where);
  3605. $pagenum = ceil($total/$perpage);
  3606. $over = $total-($start+$perpage);
  3607. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3608. echo json_encode($rows);exit;
  3609. }
  3610. $this->_Template('whlabel_change',$this->data);
  3611. }
  3612. //产品标签
  3613. public function _cpbqdc()
  3614. {
  3615. if(isset($_GET['excel']))
  3616. {
  3617. $where = "1=1";
  3618. //数据排序
  3619. $order_str = "id desc";
  3620. if(empty($page))
  3621. {
  3622. $start = 0;
  3623. $perpage = 1;
  3624. }
  3625. else
  3626. {
  3627. $start = ($page - 1)*$perpage;
  3628. }
  3629. $warehouse = $this->input->get('warehouse',true);
  3630. $state = $this->input->get('state',true);
  3631. $timetk = $this->input->get('timetkk',true);
  3632. $timetj = $this->input->get('timetjj',true);
  3633. $timetk = strtotime($timetk);
  3634. $timetj = strtotime($timetj);
  3635. if($warehouse)
  3636. {
  3637. $where .= " and warehouse = '$warehouse'";
  3638. }
  3639. if($state || $state == 0)
  3640. {
  3641. $where .= " and state = '$state'";
  3642. }
  3643. if($timetk && $timetj)
  3644. {
  3645. $where .= " and time > '$timetk' and time < '$timetj'";
  3646. }
  3647. //取得信息列表
  3648. $info_list = $this->whlabel->find_all($where,'*');
  3649. $rows = array();$list = array();
  3650. foreach ($info_list as $key=>$value)
  3651. {
  3652. $rows[$value['time']] = $value;//所有数据sku
  3653. }
  3654. foreach ($rows as $value)
  3655. {
  3656. $warehouse = $this->warehouse->read($value['warehouse']);
  3657. $s = $this->whlabel->find_count($where.' and time = "'.$value['time'].'"');
  3658. $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);
  3659. }
  3660. $title = "产品标签统计表";
  3661. $titlename = "<table border=1>
  3662. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  3663. <tr align='center'>
  3664. <td>仓库</td>
  3665. <td>SKU</td>
  3666. <td>产品</td>
  3667. <td>入库时间</td>
  3668. <td>操作时间</td>
  3669. <td>备注</td>
  3670. <td>数量</td>
  3671. </tr>
  3672. </table>";
  3673. $filename = $title.".xls";
  3674. $tail = "";
  3675. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3676. }
  3677. }
  3678. //进销存导出
  3679. public function _exceljxc()
  3680. {
  3681. $classid = $this->classid->sku();
  3682. $pm = $classid;
  3683. $typeclass = array();
  3684. $tc = $this->typeclass->find_all();
  3685. foreach ($tc as $v)
  3686. {
  3687. $typeclass[$v['id']] = $v;
  3688. }
  3689. $prc = array();
  3690. $purchase = $this->purchase->find_all();
  3691. foreach($purchase as $k=>$v)
  3692. {
  3693. $prc[$v['id']] = $v['title'];
  3694. }
  3695. if(isset($_GET['excel']))
  3696. {
  3697. $where = "sku != 'Preset'";
  3698. //数据排序
  3699. $order_str = "id desc";
  3700. if(empty($page))
  3701. {
  3702. $start = 0;
  3703. $perpage = 1;
  3704. }
  3705. else
  3706. {
  3707. $start = ($page - 1)*$perpage;
  3708. }
  3709. $category = $this->input->get('category',true);
  3710. $warehouse = $this->input->get('warehouse',true);
  3711. $excelid = $this->input->get('sid',true);
  3712. if($category)
  3713. {
  3714. $where .= " and features like '%-$category-%'";
  3715. }
  3716. if($warehouse)
  3717. {
  3718. $where .= " and warehouse = '$warehouse'";
  3719. }
  3720. $xzid = '';
  3721. if($excelid)
  3722. {
  3723. $excelid = explode(',',trim($excelid,','));
  3724. foreach ($excelid as $key=>$value)
  3725. {
  3726. $xzid .= " id = ".$value." or";
  3727. }
  3728. $xzid = " and (".rtrim($xzid,'or').")";;
  3729. }
  3730. //取得信息列表
  3731. /**
  3732. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3733. $rows = array();$list = array();
  3734. foreach ($info_list as $key=>$value)
  3735. {
  3736. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3737. }
  3738. **/
  3739. $wt = array();
  3740. $whlabel_type = $this->whlabel_type->find_all();
  3741. foreach ($whlabel_type as $v)
  3742. {
  3743. $wt[$v['id']] = $v['title'];
  3744. }
  3745. $wh = array();
  3746. $w = $this->warehouse->find_all('1=1','id,title');
  3747. foreach ($w as $v)
  3748. {
  3749. $wh[$v['id']] = $v['title'];
  3750. }
  3751. $list = array();
  3752. $rows = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3753. foreach ($rows as $key=>$value)
  3754. {
  3755. if(isset($wt[$value['type']]))
  3756. {
  3757. $rows[$key]['type'] = $wt[$value['type']];
  3758. }
  3759. else
  3760. {
  3761. $rows[$key]['type'] = '未设置';
  3762. }
  3763. $bm = '03';
  3764. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  3765. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  3766. $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');
  3767. $details = array();
  3768. $cpid = array();
  3769. $cpbz = array();
  3770. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  3771. foreach ($sd as $k=>$v)
  3772. {
  3773. if($v['state'] == 0)
  3774. {
  3775. $c++;
  3776. if($v['cpid'] != 0)
  3777. {
  3778. $cpid[$v['cpid']] = $v['cpid'];
  3779. }
  3780. if($v['cpbz'] != '')
  3781. {
  3782. $cpbz[$v['cpbz']] = $v['cpbz'];
  3783. }
  3784. }
  3785. if($v['state'] != 9)
  3786. {
  3787. $g++;
  3788. }
  3789. if($v['state'] == 1)
  3790. {
  3791. $x++;
  3792. }
  3793. if($v['state'] == 2)
  3794. {
  3795. $t++;
  3796. }
  3797. if($v['state'] == 8)
  3798. {
  3799. $s++;
  3800. }
  3801. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  3802. {
  3803. $q++;
  3804. }
  3805. $details[$v['details']] = $v['details'];
  3806. }
  3807. $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'].'"');
  3808. $rows[$key]['details'] = implode("、",$details);
  3809. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  3810. $number = $value['number'];
  3811. $ftime = time()-15*24*3600;
  3812. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3813. $rows[$key]['number'] = $g;
  3814. $rows[$key]['c'] = $c;
  3815. $rows[$key]['x'] = $x;
  3816. $rows[$key]['t'] = $t;
  3817. $rows[$key]['s'] = $s;
  3818. $rows[$key]['q'] = $q;
  3819. $rows[$key]['z'] = $z;
  3820. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  3821. $features = explode('-',trim($features,'-'));
  3822. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3823. // $pm = $classid;
  3824. // $jm = $classid;
  3825. // foreach($features as $k=>$v)
  3826. // {
  3827. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3828. // {
  3829. // if($typeclass[$v]['bm'] != '')
  3830. // {
  3831. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3832. // }
  3833. // }
  3834. // if($v != 0)
  3835. // {
  3836. // if(!isset($typeclass[$v]))
  3837. // {
  3838. // continue;
  3839. // }
  3840. // if(isset($pm[$typeclass[$v]['classid']]))
  3841. // {
  3842. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3843. // {
  3844. // $tz = explode('|',$typeclass[$v]['zh']);
  3845. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3846. // }
  3847. // else
  3848. // {
  3849. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3850. // }
  3851. // }
  3852. // if(isset($jm[$typeclass[$v]['classid']]))
  3853. // {
  3854. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3855. // }
  3856. // }
  3857. // }
  3858. // $jm = array_filter($jm);
  3859. // $rows[$key]['bs'] = implode("-",$jm);
  3860. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3861. // $zh = implode(" ",$pm);
  3862. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3863. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3864. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3865. // $rows[$key]['features'] = $zh;
  3866. }
  3867. $list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  3868. $final_list = [];
  3869. foreach($list as $k=>$v){
  3870. if(empty($v['sku'])){
  3871. continue;
  3872. }
  3873. $final_list[] = [
  3874. "warehouse"=>$v["warehouse"],
  3875. "purchase"=>$v["purchase"],
  3876. "details"=>$v["details"],
  3877. "cpid"=>$v["cpid"],
  3878. "dbcontent"=>$v["dbcontent"],
  3879. "sku"=>$v["sku"],
  3880. "cs"=>$v["bm"],
  3881. "bs"=>$v["jm"],
  3882. "title"=>$v["title"],
  3883. "features"=>$v["pm"],
  3884. "cpbz"=>$v["cpbz"],
  3885. "sm"=>$v["sm"],
  3886. "type"=>$v["type"],
  3887. "number"=>$v["number"],
  3888. "c"=>$v["c"],
  3889. "x"=>$v["x"],
  3890. "t"=>$v["t"],
  3891. "s"=>$v["s"],
  3892. "q"=>$v["q"],
  3893. "z"=>$v["z"],
  3894. "weight"=>$v['weight'],
  3895. ];
  3896. }
  3897. $title = "总进销存统计表";
  3898. $titlename = "<table border=1>
  3899. <tr><th colspan='21' align='center'><h3>".$title."<h3></th></tr>
  3900. <tr align='center'>
  3901. <td>仓库</td>
  3902. <td>供应商</td>
  3903. <td>位置</td>
  3904. <td>库存编码</td>
  3905. <td>类目</td>
  3906. <td>SKU</td>
  3907. <td>用友编码</td>
  3908. <td>用友料号</td>
  3909. <td>商品名称</td>
  3910. <td>商品中文</td>
  3911. <td>产品备注</td>
  3912. <td>说明</td>
  3913. <td>类型</td>
  3914. <td>入库总量</td>
  3915. <td>库存数量</td>
  3916. <td>销售数量</td>
  3917. <td>退货数量</td>
  3918. <td>删除数量</td>
  3919. <td>其它操作</td>
  3920. <td>占单数量</td>
  3921. <td>重量(g)</td>
  3922. </tr>
  3923. </table>";
  3924. $filename = $title.".xls";
  3925. $tail = "";
  3926. $this->excel->get_fz2($final_list,$titlename,$filename,$tail);
  3927. }
  3928. }
  3929. //入库导出
  3930. public function _excelr()
  3931. {
  3932. if(isset($_GET['excel']))
  3933. {
  3934. $category = $this->input->get('category',true);
  3935. $size = $this->input->get('size',true);
  3936. $grade = $this->input->get('grade',true);
  3937. $color = $this->input->get('color',true);
  3938. $lowe = $this->input->get('lowe',true);
  3939. $sku = $this->input->get('sku',true);
  3940. $warehouse = $this->input->get('warehouse',true);
  3941. $purchase = $this->input->get('purchase',true);
  3942. $ktime = $this->input->get('ktime',true);
  3943. $jtime = $this->input->get('jtime',true);
  3944. $ktime = strtotime($ktime);
  3945. $jtime = strtotime($jtime);
  3946. $where = "1=1";$gj = "";$ck = "";
  3947. if($category)
  3948. {
  3949. $where .= " and features like '%-$category-%'";
  3950. }
  3951. if($size)
  3952. {
  3953. $where .= " and features like '%-$size-%'";
  3954. }
  3955. if($grade)
  3956. {
  3957. $where .= " and features like '%-$grade-%'";
  3958. }
  3959. if($color)
  3960. {
  3961. $where .= " and features like '%-$color-%'";
  3962. }
  3963. if($lowe)
  3964. {
  3965. $where .= " and features like '%-$lowe-%'";
  3966. }
  3967. if($warehouse)
  3968. {
  3969. $where .= " and warehouse = '$warehouse'";
  3970. }
  3971. if($purchase)
  3972. {
  3973. $where .= " and purchase = '$purchase'";
  3974. }
  3975. if($sku)
  3976. {
  3977. $where .= " and sku = '$sku'";
  3978. }
  3979. if($ktime && $jtime)
  3980. {
  3981. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3982. }
  3983. //数据排序
  3984. $order_str = "id desc";
  3985. if(empty($page))
  3986. {
  3987. $start = 0;
  3988. $perpage = 1;
  3989. }
  3990. else
  3991. {
  3992. $start = ($page - 1)*$perpage;
  3993. }
  3994. $list = array();
  3995. $rows = $this->whlabel->find_pc($where,'enter,sku,warehouse','*',$order_str);
  3996. foreach ($rows as $value)
  3997. {
  3998. $ck = $this->warehouse->read($value['warehouse']);
  3999. $warehouse = $ck['title'];
  4000. $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
  4001. $retreatwarehouse = $tkck['title'];
  4002. $gy = $this->purchase->read($value['purchase']);
  4003. $purchase = $gy['title'];
  4004. $g = $this->whlabel->find_count($where.' and enter = "'.$value['enter'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'"');
  4005. $list[] = array('warehouse'=>$warehouse,'sku'=>$value['sku'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
  4006. }
  4007. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
  4008. $titlename = "<table border=1>
  4009. <tr><th colspan='5' align='center'><h3>".$title."<h3></th></tr>
  4010. <tr align='center'>
  4011. <td>仓库</td>
  4012. <td>SKU</td>
  4013. <td>产品</td>
  4014. <td>时间</td>
  4015. <td>数量</td>
  4016. </tr>
  4017. </table>";
  4018. $filename = $title.".xls";
  4019. $tail = "";
  4020. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4021. }
  4022. }
  4023. //出库、退库导出
  4024. public function _excelct()
  4025. {
  4026. $classid = $this->classid->sku();
  4027. $pm = $classid;
  4028. $typeclass = array();
  4029. $tc = $this->typeclass->find_all();
  4030. foreach ($tc as $v)
  4031. {
  4032. $typeclass[$v['id']] = $v;
  4033. }
  4034. $prc = array();
  4035. $purchase = $this->purchase->find_all();
  4036. foreach($purchase as $k=>$v)
  4037. {
  4038. $prc[$v['id']] = $v['title'];
  4039. }
  4040. if(isset($_GET['excel']))
  4041. {
  4042. $wh = array();
  4043. $w = $this->warehouse->find_all('1=1','id,title');
  4044. foreach ($w as $v)
  4045. {
  4046. $wh[$v['id']] = $v['title'];
  4047. }
  4048. $type = $this->input->get('excel',true);
  4049. $category = $this->input->get('category',true);
  4050. $size = $this->input->get('size',true);
  4051. $grade = $this->input->get('grade',true);
  4052. $color = $this->input->get('color',true);
  4053. $lowe = $this->input->get('lowe',true);
  4054. $sku = $this->input->get('sku',true);
  4055. $warehouse = $this->input->get('warehouse',true);
  4056. $lacetype = $this->input->get('lacetype',true);
  4057. $lacecolor = $this->input->get('lacecolor',true);
  4058. $density = $this->input->get('density',true);
  4059. $haircap = $this->input->get('haircap',true);
  4060. $purchase = $this->input->get('purchase',true);
  4061. $title = $this->input->get('title',true);
  4062. $state = $this->input->get('state',true);
  4063. $sid = $this->input->get('sid',true);
  4064. $ktime = $this->input->get('ktime',true);
  4065. $jtime = $this->input->get('jtime',true);
  4066. $ktime = strtotime($ktime);
  4067. $jtime = strtotime($jtime);
  4068. $where = "1=1";$gj = "";$ck = "";
  4069. if($category)
  4070. {
  4071. $where .= " and features like '%-$category-%'";
  4072. }
  4073. if($size)
  4074. {
  4075. $where .= " and features like '%-$size-%'";
  4076. }
  4077. if($grade)
  4078. {
  4079. $where .= " and features like '%-$grade-%'";
  4080. }
  4081. if($color)
  4082. {
  4083. $where .= " and features like '%-$color-%'";
  4084. }
  4085. if($lowe)
  4086. {
  4087. $where .= " and features like '%-$lowe-%'";
  4088. }
  4089. if($warehouse)
  4090. {
  4091. $where .= " and warehouse = '$warehouse'";
  4092. }
  4093. if($purchase)
  4094. {
  4095. $where .= " and purchase = '$purchase'";
  4096. }
  4097. if($state)
  4098. {
  4099. $where .= " and state = '$state'";
  4100. }
  4101. if($lacetype)
  4102. {
  4103. $where .= " and features like '%-$lacetype-%'";
  4104. }
  4105. if($lacecolor)
  4106. {
  4107. $where .= " and features like '%-$lacecolor-%'";
  4108. }
  4109. if($density)
  4110. {
  4111. $where .= " and features like '%-$density-%'";
  4112. }
  4113. if($haircap)
  4114. {
  4115. $where .= " and features like '%-$haircap-%'";
  4116. }
  4117. if($title)
  4118. {
  4119. $title = trim($title,' ');
  4120. $title = trim($title,' ');
  4121. $where .= " and title like '%$title%'";
  4122. }
  4123. if($sku)
  4124. {
  4125. $sku = trim($sku,' ');
  4126. $sku = trim($sku,' ');
  4127. $where .= " and sku like '%$sku%'";
  4128. }
  4129. if($ktime && $jtime)
  4130. {
  4131. if($type == 1)
  4132. {
  4133. $tl = '出库';
  4134. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4135. }
  4136. else if($type == 2)
  4137. {
  4138. $tl = '退库';
  4139. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4140. }
  4141. else if($type == 3)
  4142. {
  4143. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4144. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4145. }
  4146. else if($type == 4)
  4147. {
  4148. $tl = '出库+零售';
  4149. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4150. }
  4151. else if($type == 5)
  4152. {
  4153. $tl = '零售';
  4154. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4155. }
  4156. }
  4157. $sidwhere = '';
  4158. if($sid)
  4159. {
  4160. $sd = "";
  4161. $s = explode(',',trim($sid,','));
  4162. foreach ($s as $value)
  4163. {
  4164. $sd .= " id = ".$value." or";
  4165. }
  4166. $sidwhere = " and (".rtrim($sd,'or').")";
  4167. }
  4168. //数据排序
  4169. $order_str = "time desc";
  4170. if(empty($page))
  4171. {
  4172. $start = 0;
  4173. $perpage = 1;
  4174. }
  4175. else
  4176. {
  4177. $start = ($page - 1)*$perpage;
  4178. }
  4179. //取得信息列表
  4180. if($type != 3 && $type != 5)
  4181. {
  4182. if($type == 1 || $type == 4)
  4183. {
  4184. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk',$order_str);
  4185. foreach ($info_list as $key=>$value)
  4186. {
  4187. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4188. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4189. $warehouse = $this->warehouse->read($value['warehouse']);
  4190. $info_list[$key]['warehouse'] = $warehouse['title'];
  4191. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4192. $features = explode('-',trim($features,'-'));
  4193. $pm = $classid;
  4194. foreach($features as $k=>$v)
  4195. {
  4196. if($v != 0)
  4197. {
  4198. if(!isset($typeclass[$v]))
  4199. {
  4200. continue;
  4201. }
  4202. if(isset($pm[$typeclass[$v]['classid']]))
  4203. {
  4204. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4205. {
  4206. $tz = explode('|',$typeclass[$v]['zh']);
  4207. $pm[$typeclass[$v]['classid']] = $tz[0];
  4208. }
  4209. else
  4210. {
  4211. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4212. }
  4213. }
  4214. }
  4215. }
  4216. $zh = implode(" ",$pm);
  4217. $zh = str_replace('自然色 ','',trim($zh,' '));
  4218. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4219. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4220. $info_list[$key]['features'] = $zh;
  4221. }
  4222. }
  4223. else
  4224. {
  4225. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat',$order_str);
  4226. foreach ($info_list as $key=>$value)
  4227. {
  4228. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4229. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
  4230. $warehouse = $this->warehouse->read($value['warehouse']);
  4231. $info_list[$key]['warehouse'] = $warehouse['title'];
  4232. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4233. $features = explode('-',trim($features,'-'));
  4234. $pm = $classid;
  4235. foreach($features as $k=>$v)
  4236. {
  4237. if($v != 0)
  4238. {
  4239. if(!isset($typeclass[$v]))
  4240. {
  4241. continue;
  4242. }
  4243. if(isset($pm[$typeclass[$v]['classid']]))
  4244. {
  4245. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4246. {
  4247. $tz = explode('|',$typeclass[$v]['zh']);
  4248. $pm[$typeclass[$v]['classid']] = $tz[0];
  4249. }
  4250. else
  4251. {
  4252. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4253. }
  4254. }
  4255. }
  4256. }
  4257. $zh = implode(" ",$pm);
  4258. $zh = str_replace('自然色 ','',trim($zh,' '));
  4259. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4260. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4261. $info_list[$key]['features'] = $zh;
  4262. }
  4263. }
  4264. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4265. $titlename = "<table border=1>
  4266. <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
  4267. <tr align='center'>
  4268. <td>仓库</td>
  4269. <td>供应商</td>
  4270. <td>SKU</td>
  4271. <td>商品名称</td>
  4272. <td>商品中文</td>
  4273. <td>标签</td>
  4274. <td>订单号</td>
  4275. <td>运单号</td>
  4276. <td>".$tl."时间(中国时间)</td>
  4277. </tr>
  4278. </table>";
  4279. $filename = $title.".xls";
  4280. $tail = "";
  4281. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4282. }
  4283. else if($type == 5)
  4284. {
  4285. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,outk',$order_str);
  4286. foreach ($info_list as $key=>$value)
  4287. {
  4288. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4289. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4290. $warehouse = $this->warehouse->read($value['warehouse']);
  4291. $info_list[$key]['warehouse'] = $warehouse['title'];
  4292. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4293. $features = explode('-',trim($features,'-'));
  4294. $pm = $classid;
  4295. foreach($features as $k=>$v)
  4296. {
  4297. if($v != 0)
  4298. {
  4299. if(!isset($typeclass[$v]))
  4300. {
  4301. continue;
  4302. }
  4303. if(isset($pm[$typeclass[$v]['classid']]))
  4304. {
  4305. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4306. {
  4307. $tz = explode('|',$typeclass[$v]['zh']);
  4308. $pm[$typeclass[$v]['classid']] = $tz[0];
  4309. }
  4310. else
  4311. {
  4312. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4313. }
  4314. }
  4315. }
  4316. }
  4317. $zh = implode(" ",$pm);
  4318. $zh = str_replace('自然色 ','',trim($zh,' '));
  4319. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4320. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4321. $info_list[$key]['features'] = $zh;
  4322. }
  4323. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4324. $titlename = "<table border=1>
  4325. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  4326. <tr align='center'>
  4327. <td>仓库</td>
  4328. <td>供应商</td>
  4329. <td>SKU</td>
  4330. <td>商品名称</td>
  4331. <td>商品中文</td>
  4332. <td>标签</td>
  4333. <td>".$tl."时间(中国时间)</td>
  4334. </tr>
  4335. </table>";
  4336. $filename = $title.".xls";
  4337. $tail = "";
  4338. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4339. }
  4340. else
  4341. {
  4342. /**
  4343. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4344. $rows = array();$list = array();
  4345. foreach ($info_list as $key=>$value)
  4346. {
  4347. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4348. }
  4349. **/
  4350. $wh = array();
  4351. $w = $this->warehouse->find_all('1=1','id,title');
  4352. foreach ($w as $v)
  4353. {
  4354. $wh[$v['id']] = $v['title'];
  4355. }
  4356. $wt = array();
  4357. $whlabel_type = $this->whlabel_type->find_all();
  4358. foreach ($whlabel_type as $v)
  4359. {
  4360. $wt[$v['id']] = $v['title'];
  4361. }
  4362. $classid = $this->classid->sku();
  4363. $list = array();
  4364. $rows = $this->whlabel->find_pc($where.$sidwhere,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4365. foreach ($rows as $key=>$value)
  4366. {
  4367. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4368. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4369. $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');
  4370. $details = array();
  4371. $cpid = array();
  4372. $cpbz = array();
  4373. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  4374. foreach ($sd as $k=>$v)
  4375. {
  4376. if($v['state'] == 0)
  4377. {
  4378. $c++;
  4379. }
  4380. if($v['state'] != 9)
  4381. {
  4382. $g++;
  4383. }
  4384. if($v['outk'] > 1)
  4385. {
  4386. $x++;
  4387. }
  4388. if($v['retreat'] > 0)
  4389. {
  4390. $t++;
  4391. }
  4392. if($v['state'] == 8)
  4393. {
  4394. $s++;
  4395. }
  4396. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  4397. {
  4398. $q++;
  4399. }
  4400. $details[$v['details']] = $v['details'];
  4401. if($v['cpid'] != 0)
  4402. {
  4403. $cpid[$v['cpid']] = $v['cpid'];
  4404. }
  4405. if($v['cpbz'] != '')
  4406. {
  4407. $cpbz[$v['cpbz']] = $v['cpbz'];
  4408. }
  4409. }
  4410. if(isset($wt[$value['type']]))
  4411. {
  4412. $rows[$key]['type'] = $wt[$value['type']];
  4413. }
  4414. else
  4415. {
  4416. $rows[$key]['type'] = '未设置';
  4417. }
  4418. $rows[$key]['details'] = implode("、",$details);
  4419. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4420. $ftime = time()-15*24*3600;
  4421. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4422. $rows[$key]['cpbz'] = ($cpbz)?implode(" ",$cpbz):'';
  4423. $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);
  4424. $rows[$key]['c'] = $c;
  4425. $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);
  4426. $rows[$key]['t'] = $t;
  4427. $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'].'"');
  4428. $rows[$key]['z'] = $z;
  4429. $jm = $classid;
  4430. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4431. $features = explode('-',trim($features,'-'));
  4432. $pm = $classid;
  4433. foreach($features as $k=>$v)
  4434. {
  4435. if($v != 0)
  4436. {
  4437. if(!isset($typeclass[$v]))
  4438. {
  4439. continue;
  4440. }
  4441. if(isset($pm[$typeclass[$v]['classid']]))
  4442. {
  4443. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4444. {
  4445. $tz = explode('|',$typeclass[$v]['zh']);
  4446. $pm[$typeclass[$v]['classid']] = $tz[0];
  4447. }
  4448. else
  4449. {
  4450. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4451. }
  4452. if(isset($jm[$typeclass[$v]['classid']]))
  4453. {
  4454. if($typeclass[$v]['jm'])
  4455. {
  4456. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4457. }
  4458. }
  4459. }
  4460. }
  4461. }
  4462. $zh = implode(" ",$pm);
  4463. $zh = str_replace('自然色 ','',trim($zh,' '));
  4464. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4465. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4466. $rows[$key]['features'] = $zh;
  4467. $jm = array_filter($jm);//去除空值
  4468. $jm = implode("-",$jm);
  4469. $rows[$key]['jm'] = $jm;
  4470. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4471. }
  4472. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
  4473. $titlename = "<table border=1>
  4474. <tr><th colspan='17' align='center'><h3>".$title."<h3></th></tr>
  4475. <tr align='center'>
  4476. <td>仓库</td>
  4477. <td>供应商</td>
  4478. <td>位置</td>
  4479. <td>库存编码</td>
  4480. <td>SKU</td>
  4481. <td>商品名称</td>
  4482. <td>商品中文</td>
  4483. <td>产品备注</td>
  4484. <td>说明</td>
  4485. <td>类型</td>
  4486. <td>入库总量</td>
  4487. <td>库存数量</td>
  4488. <td>销售数量</td>
  4489. <td>退货数量</td>
  4490. <td>占单数量</td>
  4491. <td>料号</td>
  4492. <td>类目</td>
  4493. </tr>
  4494. </table>";
  4495. $filename = $title.".xls";
  4496. $tail = "";
  4497. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  4498. }
  4499. }
  4500. }
  4501. //出库+入库数据整合
  4502. public function _excelcr()
  4503. {
  4504. if(isset($_GET['excel']))
  4505. {
  4506. $type = $this->input->get('excel',true);
  4507. $category = $this->input->get('category',true);
  4508. $size = $this->input->get('size',true);
  4509. $grade = $this->input->get('grade',true);
  4510. $color = $this->input->get('color',true);
  4511. $lowe = $this->input->get('lowe',true);
  4512. $sku = $this->input->get('sku',true);
  4513. $warehouse = $this->input->get('warehouse',true);
  4514. $purchase = $this->input->get('purchase',true);
  4515. $state = $this->input->get('state',true);
  4516. $sid = $this->input->get('sid',true);
  4517. $ktime = $this->input->get('ktime',true);
  4518. $jtime = $this->input->get('jtime',true);
  4519. $ktime = strtotime($ktime);
  4520. $jtime = strtotime($jtime);
  4521. $where = "1=1";$gj = "";$ck = "";
  4522. if($category)
  4523. {
  4524. $where .= " and features like '%-$category-%'";
  4525. }
  4526. if($size)
  4527. {
  4528. $where .= " and features like '%-$size-%'";
  4529. }
  4530. if($grade)
  4531. {
  4532. $where .= " and features like '%-$grade-%'";
  4533. }
  4534. if($color)
  4535. {
  4536. $where .= " and features like '%-$color-%'";
  4537. }
  4538. if($lowe)
  4539. {
  4540. $where .= " and features like '%-$lowe-%'";
  4541. }
  4542. if($warehouse)
  4543. {
  4544. $where .= " and warehouse = '$warehouse'";
  4545. }
  4546. if($purchase)
  4547. {
  4548. $where .= " and purchase = '$purchase'";
  4549. }
  4550. if($state)
  4551. {
  4552. $where .= " and state = '$state'";
  4553. }
  4554. if($sku)
  4555. {
  4556. $where .= " and sku like '%$sku%'";
  4557. }
  4558. if($ktime && $jtime)
  4559. {
  4560. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4561. }
  4562. $sidwhere = '';
  4563. if($sid)
  4564. {
  4565. $sd = "";
  4566. $s = explode(',',trim($sid,','));
  4567. foreach ($s as $value)
  4568. {
  4569. $sd .= " id = ".$value." or";
  4570. }
  4571. $sidwhere .= " and (".rtrim($sd,'or').")";
  4572. }
  4573. //取得信息列表
  4574. $timeread = $ktime;
  4575. $timenum = ceil(($jtime - $ktime) / (24*3600));
  4576. $timelist = array();
  4577. for($i=0;$i<$timenum;$i++)
  4578. {
  4579. $timeread = ($i>0)?$ktime+$i*24*3600:$ktime;
  4580. $timelist[date('Y-m-d',$timeread)] = array('c'=>0,'r'=>0);
  4581. }
  4582. $info_list = $this->whlabel->find_all($where.$sidwhere,'outk,enter,sku,state');
  4583. //echo "<pre>";
  4584. //print_r($info_list);
  4585. //exit();
  4586. $rows = array();$list = array();
  4587. foreach ($info_list as $key=>$value)
  4588. {
  4589. $thistime = $timelist;
  4590. if(isset($rows[strtolower($value['sku'])]))
  4591. {
  4592. if($value['outk'] > $ktime && $value['state'] < $jtime)
  4593. {
  4594. $rows[strtolower($value['sku'])][date('Y-m-d',$value['outk'])]['c'] += 1;
  4595. }
  4596. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4597. {
  4598. $rows[strtolower($value['sku'])][date('Y-m-d',$value['enter'])]['r'] += 1;
  4599. }
  4600. }
  4601. else
  4602. {
  4603. if($value['outk'] > $ktime && $value['outk'] < $jtime)
  4604. {
  4605. $thistime[date('Y-m-d',$value['outk'])]['c'] += 1;
  4606. }
  4607. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4608. {
  4609. $thistime[date('Y-m-d',$value['enter'])]['r'] += 1;
  4610. }
  4611. $rows[strtolower($value['sku'])] = $thistime;
  4612. }
  4613. }
  4614. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4615. <head>
  4616. <!--[if gte mso 9]><xml>
  4617. <x:ExcelWorkbook>
  4618. <x:ExcelWorksheets>
  4619. <x:ExcelWorksheet>
  4620. <x:Name>EXCEL</x:Name>
  4621. <x:WorksheetOptions>
  4622. <x:Print>
  4623. <x:ValidPrinterInfo />
  4624. </x:Print>
  4625. </x:WorksheetOptions>
  4626. </x:ExcelWorksheet>
  4627. </x:ExcelWorksheets>
  4628. </x:ExcelWorkbook>
  4629. </xml>
  4630. <![endif]-->
  4631. </head><body>";
  4632. $str .= "<table border=1><tr><td>SKU</td>";
  4633. foreach ($timelist as $k=>$v)
  4634. {
  4635. $str .="<td>".$k."出库</td>";
  4636. $str .="<td>".$k."入库</td>";
  4637. }
  4638. $str .= "</tr></table>";
  4639. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4640. foreach ($rows as $key=>$val)
  4641. {
  4642. $str .= "<tr><td>".strtoupper($key)."</td>";
  4643. foreach ($val as $k=>$v)
  4644. {
  4645. $str .= "<td>".$val[$k]['c']."</td>";
  4646. if($val[$k]['r'] > 0)
  4647. {
  4648. $str .= "<td style='color:#f00'>-".$val[$k]['r']."</td>";
  4649. }
  4650. else
  4651. {
  4652. $str .= "<td>".$val[$k]['r']."</td>";
  4653. }
  4654. }
  4655. $str .= "</tr>";
  4656. }
  4657. $str .= "</table>";
  4658. $str .= "</body></html>";
  4659. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  4660. header( "Content-type: application/octet-stream" );
  4661. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  4662. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  4663. header( "Pragma: no-cache" );
  4664. header( "Expires: 0" );
  4665. exit($str);
  4666. }
  4667. }
  4668. //数量调整模板导出
  4669. public function _presetout()
  4670. {
  4671. if(isset($_GET['excel']))
  4672. {
  4673. $where = "sku != 'Preset' and purchase != 0";
  4674. //数据排序
  4675. $order_str = "id desc";
  4676. if(empty($page))
  4677. {
  4678. $start = 0;
  4679. $perpage = 1;
  4680. }
  4681. else
  4682. {
  4683. $start = ($page - 1)*$perpage;
  4684. }
  4685. //取得信息列表
  4686. $info_list = $this->whlabel->find_pc($where,'warehouse,purchase,sku','*','id desc',0,1);
  4687. $rows = array();$list = array();
  4688. foreach ($info_list as $value)
  4689. {
  4690. $warehouse = $this->warehouse->read($value['warehouse']);
  4691. $number = $value['number'];$ftime = time()-15*24*3600;
  4692. $purchase = $this->purchase->read($value['purchase']);
  4693. $list[] = array($warehouse['title'],$purchase['bm'],$value['sku'],'0','','0','','');
  4694. }
  4695. $title = "库存模板";
  4696. $titlename = "<table border=1>
  4697. <tr align='center'>
  4698. <td>仓库</td>
  4699. <td>供应商编码</td>
  4700. <td>SKU</td>
  4701. <td>增减数量(正数或负数)</td>
  4702. <td>增减备注</td>
  4703. <td>扣减方式:0减少库存1删除库存</td>
  4704. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4705. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4706. </tr>
  4707. </table>";
  4708. $filename = $title.".xls";
  4709. $tail = "";
  4710. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4711. }
  4712. }
  4713. //数量调整模板导入
  4714. public function _presetedit()
  4715. {
  4716. $dir = '/data/excel/'.date('Ymd',time()).'/';
  4717. $config['upload_path'] = '.'.$dir ;
  4718. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  4719. $config['allowed_types'] = 'xls|xlsx|csv';
  4720. $config['max_size'] = 10240;
  4721. $this->load->library('upload', $config);
  4722. $this->upload->initialize($config);
  4723. if ($this->upload->do_upload('userfile'))
  4724. {
  4725. $full_path = $dir.$this->upload->data('file_name');
  4726. $fileName = '.' . $full_path;
  4727. if (!file_exists($fileName))
  4728. {
  4729. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  4730. }
  4731. else
  4732. {
  4733. require_once "./data/excel/PHPExcel/IOFactory.php";
  4734. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  4735. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  4736. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  4737. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  4738. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  4739. ++$column;//如果列数大于26行
  4740. $list = array();
  4741. for ($i = 2; $i <= $row; $i++) // 行数循环
  4742. {
  4743. $data = array();
  4744. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4745. {
  4746. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4747. }
  4748. $list[] = $data;
  4749. }
  4750. }
  4751. $i = 0;$j = 0;$ed = array();
  4752. foreach ($list as $key=>$value)
  4753. {
  4754. $time = time();
  4755. if($value['0'] == "")
  4756. {
  4757. continue;
  4758. }
  4759. $warehouse = $this->warehouse->get_title($value['0']);
  4760. $purchase = $this->purchase->get_bm($value['1']);
  4761. $sku = $value['2'];
  4762. $num = $value['3'];//调整数量
  4763. $text = $value['4'];//扣减说明
  4764. $type = $value['5'];//调整方式0扣减1删除
  4765. $rktype = $value['6']!=''?$value['6']:0;//增加库存
  4766. $cktype = $value['7']!=''?$value['7']:0;//减少库存
  4767. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  4768. if(!$purchase)//如果没有这个SKU
  4769. {
  4770. $ed[] = array($purchase.'-不存在此供应商编码');
  4771. $j++;
  4772. continue;
  4773. }
  4774. if(!$d)//如果没有这个SKU
  4775. {
  4776. $ed[] = array($sku.'-库存中不存在此SKU');
  4777. $j++;
  4778. continue;
  4779. }
  4780. if(!isset($warehouse['id']))
  4781. {
  4782. $ed[] = array($sku.'-仓库名错误!');
  4783. $j++;
  4784. continue;
  4785. }
  4786. if($type != '0' && $type != '1')
  4787. {
  4788. $ed[] = array($sku.'-扣减方式填写错误!');
  4789. $j++;
  4790. continue;
  4791. }
  4792. if($num < 0)//扣减库存
  4793. {
  4794. if($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == '')))
  4795. {
  4796. $ed[] = array($sku.'-扣减必须填写扣减类型,非类型1必须填写备注');
  4797. $j++;
  4798. continue;
  4799. }
  4800. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and zd = "" and state = 0');
  4801. if(count($data) < abs($num))
  4802. {
  4803. $ed[] = array($sku.'-扣减数量大于库存剩余数量!');
  4804. $j++;
  4805. continue;
  4806. }
  4807. if($type == 0)//如果扣减方式为 扣减库存
  4808. {
  4809. for($i=0;$i<abs($num);$i++)
  4810. {
  4811. $this->whlabel->save(array('state'=>8,'textout'=>$text,'deltime'=>$time,'cktype'=>$cktype,'time'=>$time,'outk'=>$time),$data[$i]['id']);
  4812. }
  4813. }
  4814. else if($type == 1)
  4815. {
  4816. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  4817. if(count($zt) > 0)
  4818. {
  4819. $ed[] = array($sku.'-有在途库存无法删除!');
  4820. $j++;
  4821. continue;
  4822. }
  4823. for($i=0;$i<abs($num);$i++)
  4824. {
  4825. $this->whlabel->remove($data[$i]['id']);
  4826. }
  4827. }
  4828. }
  4829. else if($num > 0)//增加库存
  4830. {
  4831. if($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == '')))
  4832. {
  4833. $ed[] = array($sku.'-增加必须填写增加类型,非类型1必须填写备注');
  4834. $j++;
  4835. continue;
  4836. }
  4837. $post['sku'] = $d['sku'];
  4838. $post['shop'] = $d['shop'];
  4839. $post['warehouse'] = $warehouse['id'];
  4840. $post['purchase'] = $purchase['id'];
  4841. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4842. $post['state'] = 0;
  4843. $post['title'] = $d['title'];
  4844. $post['number'] = $d['number'];
  4845. $post['features'] = $d['features'];
  4846. $post['enter'] = $time;
  4847. $post['time'] = $time;//操作时间
  4848. $post['rktype'] = $rktype;
  4849. for($i=0;$i<$num;$i++)
  4850. {
  4851. $post['label'] = time().rand(100,999).$i;
  4852. $this->whlabel->insert($post);
  4853. }
  4854. }
  4855. sleep(1);//防止入库时间一样,需要延迟1秒
  4856. }
  4857. if($j > 0)
  4858. {
  4859. $tt = date('Ymd',time());
  4860. $title = '库存导入错误信息-'.$tt;
  4861. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4862. $tail = "\n";
  4863. $filename = $title.".xls";
  4864. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  4865. $dir = '/data/excel/'.$time.'/';
  4866. $file_name = 'error_'.$time.rand(1000,9999);
  4867. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  4868. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  4869. fwrite($myfile,$ecl);
  4870. fclose($myfile);
  4871. $error = $dir.$file_name.'.xls';
  4872. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  4873. }
  4874. else
  4875. {
  4876. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  4877. }
  4878. }
  4879. }
  4880. //笛卡儿积
  4881. function cp($ps,$sets,$list)
  4882. {
  4883. $result = array();$j=0;
  4884. for($i=0,$count=count($sets); $i<$count-1; $i++)
  4885. {
  4886. if($i==0)
  4887. {
  4888. $result = $sets[$i];
  4889. }
  4890. $tmp = array();
  4891. foreach($result as $res)
  4892. {
  4893. foreach($sets[$i+1] as $set)
  4894. {
  4895. $tmp[] = $res.','.$set;
  4896. }
  4897. }
  4898. $result = $tmp;
  4899. }
  4900. $this->db->trans_begin();
  4901. foreach ($result as $v)
  4902. {
  4903. $post = array();$title = "";$num="";
  4904. $data = explode(',',$v);
  4905. for($i=0;$i<count($list); $i++)
  4906. {
  4907. $post[$list[$i]] = $data[$i];
  4908. $typeclass = $this->typeclass->read($data[$i]);
  4909. $title = $title.$typeclass['title']." ";
  4910. if($data[$i] != 0)
  4911. {
  4912. $num .=$data[$i];//所有数据ID拼接
  4913. }
  4914. }
  4915. foreach ($ps as $kp=>$vp)
  4916. {
  4917. $post[$kp] = $vp;
  4918. }
  4919. $post['number'] = $num;
  4920. $info_list = $this->whlabel->get_number($num);//查询whlabel是否存在此拼接的数据ID
  4921. if($info_list)
  4922. {
  4923. $j++;
  4924. }
  4925. else
  4926. {
  4927. $skunum = $this->whlabel->find_count();
  4928. $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
  4929. $post['title'] = rtrim($title,' ');
  4930. $this->whlabel->insert($post);
  4931. }
  4932. }
  4933. if ($this->db->trans_status() === FALSE)
  4934. {
  4935. $this->db->trans_commit();
  4936. return NULL;
  4937. }
  4938. else
  4939. {
  4940. $this->db->trans_commit();
  4941. return $j;
  4942. }
  4943. }
  4944. public function _kj($arg_array)
  4945. {
  4946. if(isset($_POST['sku']))
  4947. {
  4948. $time = time();
  4949. $sku = $this->input->post('sku',true);
  4950. $warehouse = $this->input->post('warehouse',true);
  4951. $num = $this->input->post('num',true);
  4952. $text = $this->input->post('text',true);
  4953. $purchase = $this->input->post('purchase',true);
  4954. $cktype = $this->input->post('cktype',true);
  4955. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4956. if($cktype != 1 && $text == '')
  4957. {
  4958. echo json_encode(array('msg'=>"非销售出库必须填写备注!",'success'=>false));exit;
  4959. }
  4960. if($num > count($order))
  4961. {
  4962. echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
  4963. }
  4964. else
  4965. {
  4966. for($i=0;$i<$num;$i++)
  4967. {
  4968. $this->whlabel->save(array('state'=>8,'cktype'=>$cktype,'textout'=>$text,'deltime'=>$time,'time'=>$time,'outk'=>$time),$order[$i]['id']);
  4969. }
  4970. }
  4971. echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
  4972. }
  4973. $uid = $this->whlabel->read($arg_array[0]);
  4974. $uid['num'] = $this->whlabel->find_count('purchase = "'.$uid['purchase']. '" and sku = "'.$uid['sku']. '" and warehouse = "'.$uid['warehouse']. '" and zd = "" and state = 0');
  4975. $this->data['data'] = $uid ;
  4976. $this->_Template('whlabel_kj',$this->data);
  4977. }
  4978. public function _summary($arg_array)
  4979. {
  4980. $prc = array();
  4981. $purchase = $this->purchase->find_all();
  4982. foreach($purchase as $k=>$v)
  4983. {
  4984. $prc[$v['id']] = $v['title'];
  4985. }
  4986. if(isset($_GET['excel']))
  4987. {
  4988. $ktime = $this->input->get('ktime',true);
  4989. $jtime = $this->input->get('jtime',true);
  4990. $ktime = strtotime($ktime);
  4991. $jtime = strtotime($jtime);
  4992. $where = "1=1";
  4993. if($ktime && $jtime)
  4994. {
  4995. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4996. }
  4997. //数据排序
  4998. $order_str = "time desc";
  4999. if(empty($page))
  5000. {
  5001. $start = 0;
  5002. $perpage = 1;
  5003. }
  5004. else
  5005. {
  5006. $start = ($page - 1)*$perpage;
  5007. }
  5008. //取得信息列表
  5009. $info_list = $this->whlabel->find_pc($where,'sku','warehouse,purchase,details,cpid,sku,title');
  5010. foreach ($info_list as $key=>$value)
  5011. {
  5012. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  5013. $warehouse = $this->warehouse->read($value['warehouse']);
  5014. $info_list[$key]['warehouse'] = $warehouse['title'];
  5015. $x = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'"','details,cpid');
  5016. $details = array();
  5017. $cpid = array();
  5018. foreach ($x as $k=>$v)
  5019. {
  5020. if($v['details'] != '')
  5021. {
  5022. $details[$v['details']] = $v['details'];
  5023. }
  5024. if($v['cpid'] != 0)
  5025. {
  5026. $cpid[$v['cpid']] = $v['cpid'];
  5027. }
  5028. }
  5029. $info_list[$key]['details'] = ($details)?implode(" ",$details):'';
  5030. $info_list[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  5031. $s = $this->whlabel->find_count('state = 0 and sku = "'.$value['sku'].'"');
  5032. $info_list[$key]['s'] = $s;
  5033. $info_list[$key]['x'] = count($x);
  5034. }
  5035. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
  5036. $titlename = "<table border=1>
  5037. <tr align='center'>
  5038. <td>仓库</td>
  5039. <td>供应商</td>
  5040. <td>出库位置</td>
  5041. <td>出库编码</td>
  5042. <td>SKU</td>
  5043. <td>产品名</td>
  5044. <td>总剩余库存</td>
  5045. <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
  5046. </tr>
  5047. </table>";
  5048. $filename = $title.".xls";
  5049. $tail = "";
  5050. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5051. }
  5052. }
  5053. //usps发货清单
  5054. public function _manifest()
  5055. {
  5056. if(isset($_POST['manifest']))
  5057. {
  5058. $wltext = $this->input->post('wltext',true);
  5059. $time = time()-16*3600;
  5060. $ptime = strtotime(date('Y-m-d',$time));
  5061. $waybill = array();
  5062. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  5063. foreach ($fullorder as $v)
  5064. {
  5065. $waybill[$v['waybill']] = $v['waybill'];
  5066. }
  5067. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  5068. foreach ($fullordersmt as $v)
  5069. {
  5070. $waybill[$v['waybill']] = $v['waybill'];
  5071. }
  5072. $wltext = explode(';',$wltext);
  5073. foreach ($wltext as $v)
  5074. {
  5075. if(isset($waybill[$v]))
  5076. {
  5077. unset($waybill[$v]);
  5078. }
  5079. }
  5080. $data = $this->usps->get_manifest($waybill);
  5081. if(isset($data['Description']))
  5082. {
  5083. echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
  5084. }
  5085. else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
  5086. {
  5087. $bctime = date('Ymd',time());
  5088. $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
  5089. echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
  5090. }
  5091. else
  5092. {
  5093. echo json_encode(array('msg'=>$data,'success'=>false));exit;
  5094. }
  5095. }
  5096. }
  5097. public function _pdf($pdf,$title,$bctime)
  5098. {
  5099. $pdf_path = './data/pdf/'.$bctime.'/';
  5100. $file_base64 = $pdf;
  5101. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5102. $file_base64 = base64_decode($file_base64);
  5103. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  5104. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  5105. return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
  5106. }
  5107. /**
  5108. *
  5109. *
  5110. *
  5111. 进销存占单异常索引
  5112. *
  5113. *
  5114. *
  5115. **/
  5116. public function _abnormal()
  5117. {
  5118. $post = $this->input->post(NULL, TRUE);
  5119. if(isset($post['page']))
  5120. {
  5121. $page = $this->input->post('page',true);
  5122. $perpage = $this->input->post('perpage',true);
  5123. $sku = $this->input->post('sku',true);
  5124. $where = "1=1";
  5125. //数据排序
  5126. $order_str = "id desc";
  5127. if(empty($page))
  5128. {
  5129. $start = 0;
  5130. $perpage = 1;
  5131. }
  5132. else
  5133. {
  5134. $start = ($page - 1)*$perpage;
  5135. }
  5136. //取得信息列表
  5137. $info_list = $this->whlabel->find_all($where,'*');
  5138. $rows = array();$list = array();
  5139. foreach ($info_list as $key=>$value)
  5140. {
  5141. $rows[strtolower($value['sku'])] = $value;//所有数据sku
  5142. }
  5143. foreach ($rows as $value)
  5144. {
  5145. $warehouse = $this->warehouse->read($value['warehouse']);
  5146. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
  5147. $number = $value['number'];$ftime = time()-15*24*3600;
  5148. if($value['shop'] != '')
  5149. {
  5150. $shop = $value['shop'];
  5151. $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');
  5152. $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');
  5153. $order = array_merge($orderdlz,$ordersmt);
  5154. $od = 0;$a = '';$orid = '';
  5155. foreach ($order as $v)
  5156. {
  5157. $or = explode('|',ltrim($v['whlabel'],'|'));
  5158. for($i=0;$i<count($or);$i++)
  5159. {
  5160. $orod = explode('-',$or[$i]);
  5161. if($orod[0] == $number)
  5162. {
  5163. $od += $orod[1];
  5164. }
  5165. }
  5166. $orid .= $v['number'].'-';
  5167. }
  5168. }
  5169. else
  5170. {
  5171. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5172. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5173. $order = array_merge($orderdlz,$ordersmt);
  5174. $od = 0;$a = '';$orid = '';$qt = array();
  5175. foreach ($order as $v)
  5176. {
  5177. $or = explode('|',ltrim($v['whlabel'],'|'));
  5178. for($i=0;$i<count($or);$i++)
  5179. {
  5180. $orod = explode('-',$or[$i]);
  5181. if($orod[0] == $number)
  5182. {
  5183. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
  5184. if($czzs > 0)
  5185. {
  5186. if(isset($qt[$v['shop']]))
  5187. {
  5188. if($qt[$v['shop']] < $orod[1])
  5189. {
  5190. $od += $orod[1];//专属小于单量不计算剩余直接归入通用
  5191. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5192. }
  5193. else
  5194. {
  5195. $qt[$v['shop']] -= $orod[1];
  5196. }
  5197. }
  5198. else
  5199. {
  5200. $qt[$v['shop']] = $czzs;
  5201. }
  5202. }
  5203. else
  5204. {
  5205. $od += $orod[1];
  5206. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5207. }
  5208. }
  5209. }
  5210. }
  5211. }
  5212. $z = $od.'('.$orid.')';//查看订单号
  5213. //$z = $od;
  5214. if($od > $c)
  5215. {
  5216. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
  5217. }
  5218. }
  5219. $listdata = array_slice($list,$start,$perpage);
  5220. $total = count($list);
  5221. $pagenum = ceil($total/$perpage);
  5222. $over = $total-($start+$perpage);
  5223. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5224. echo json_encode($rows);exit;
  5225. }
  5226. $this->_Template('whlabel_abnormal',$this->data);
  5227. }
  5228. /**
  5229. *
  5230. *
  5231. *
  5232. 进销存占单异常索引
  5233. *
  5234. *
  5235. *
  5236. **/
  5237. public function _error()
  5238. {
  5239. $post = $this->input->post(NULL, TRUE);
  5240. if(isset($post['page']))
  5241. {
  5242. $page = $this->input->post('page',true);
  5243. $perpage = $this->input->post('perpage',true);
  5244. $sku = $this->input->post('sku',true);
  5245. $warehouse = $this->input->post('warehouse',true);
  5246. $ktime = $this->input->post('ktime',true);
  5247. $jtime = $this->input->post('jtime',true);
  5248. $ktime = strtotime($ktime);
  5249. $jtime = strtotime($jtime);
  5250. $where = "sku != 'Preset'";
  5251. $gj = '';
  5252. if($sku)
  5253. {
  5254. $where .= " and sku like '%$sku%'";
  5255. }
  5256. else
  5257. {
  5258. if($ktime && $jtime)
  5259. {
  5260. $gj = " and time > '$ktime' and time < '$jtime'";
  5261. }
  5262. }
  5263. if($warehouse)
  5264. {
  5265. $where .= " and warehouse = '$warehouse'";
  5266. }
  5267. //数据排序
  5268. $order_str = "id desc";
  5269. if(empty($page))
  5270. {
  5271. $start = 0;
  5272. $perpage = 1;
  5273. }
  5274. else
  5275. {
  5276. $start = ($page - 1)*$perpage;
  5277. }
  5278. //取得信息列表
  5279. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5280. $rows = array();$list = array();
  5281. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5282. // foreach ($info_list as $value)
  5283. // {
  5284. // $warehouse = $this->warehouse->read($value['warehouse']);
  5285. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5286. // $number = $value['number'];$ftime = time()-15*24*3600;
  5287. // if($c < 1)
  5288. // {
  5289. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5290. // }
  5291. // }
  5292. $warehouse_list = $this->warehouse->find_all();
  5293. $warehouse_list = array_column($warehouse_list,null,'id');
  5294. foreach ($info_list as $value)
  5295. {
  5296. $warehouse = isset($warehouse_list[$value['warehouse']])?$warehouse_list[$value['warehouse']]:[
  5297. 'title'=>"",
  5298. ];
  5299. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5300. $number = $value['number'];$ftime = time()-15*24*3600;
  5301. if($c < 1)
  5302. {
  5303. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5304. }
  5305. }
  5306. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5307. // $query = $this->db->query($sql);
  5308. // $info_list = $query->result_array();
  5309. // $sql_two = "select title,id from crowd_warehouse";
  5310. // $query_two = $this->db->query($sql_two);
  5311. // $warehouse_list = $query_two->result_array();
  5312. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5313. // foreach ($info_list as $value)
  5314. // {
  5315. // if(isset($warehouse_arr[$value['warehouse']])){
  5316. // $warehouse = $warehouse_arr[$value['warehouse']];
  5317. // }else{
  5318. // $warehouse = [
  5319. // 'id'=>0,
  5320. // 'title'=>"异常",
  5321. // ];
  5322. // }
  5323. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5324. // $number = $value['number'];$ftime = time()-15*24*3600;
  5325. // if($c < 1)
  5326. // {
  5327. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5328. // }
  5329. // }
  5330. $listdata = array_slice($list,$start,$perpage);
  5331. $total = count($list);
  5332. $pagenum = ceil($total/$perpage);
  5333. $over = $total-($start+$perpage);
  5334. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5335. echo json_encode($rows);exit;
  5336. }
  5337. if(isset($post['s']))
  5338. {
  5339. $id_arr = $this->input->post('s');
  5340. $id_arr = explode(',',trim($id_arr,','));
  5341. if(!$id_arr)
  5342. {
  5343. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  5344. }
  5345. //循环删除记录
  5346. foreach ($id_arr as $v)
  5347. {
  5348. $dd = $this->whlabel->read($v);
  5349. if(!isset($dd['id']))
  5350. {
  5351. echo json_encode(array('msg'=>$dd['sku'].'已被删除,请刷新页面','success'=>false));exit;
  5352. }
  5353. $zt = $this->whlabeltransport->find_all('sku = "'.$dd['sku'].'" and warehouse = "'.$dd['warehouse'].'" and features = "'.$dd['features'].'" and cz = "0"');
  5354. if(isset($zt[0]))
  5355. {
  5356. echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
  5357. }
  5358. $deldd = $this->whlabel->find_all("sku = '".$dd['sku']."' and warehouse = '".$dd['warehouse']."'");
  5359. foreach ($deldd as $vv)
  5360. {
  5361. $this->whlabel->remove($vv['id']);
  5362. }
  5363. }
  5364. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  5365. }
  5366. $this->_Template('whlabel_error',$this->data);
  5367. }
  5368. public function _errorexcel()
  5369. {
  5370. $post = $this->input->post(NULL, TRUE);
  5371. if(isset($_GET['page']))
  5372. {
  5373. $page = $this->input->get('page',true);
  5374. $perpage = $this->input->get('perpage',true);
  5375. $sku = $this->input->get('sku',true);
  5376. $warehouse = $this->input->get('warehouse',true);
  5377. $ktime = $this->input->get('ktime',true);
  5378. $jtime = $this->input->get('jtime',true);
  5379. $ktime = strtotime($ktime);
  5380. $jtime = strtotime($jtime);
  5381. $where = "sku != 'Preset'";
  5382. $gj = '';
  5383. if($sku)
  5384. {
  5385. $where .= " and sku like '%$sku%'";
  5386. }
  5387. else
  5388. {
  5389. if($ktime && $jtime)
  5390. {
  5391. $gj = " and time > '$ktime' and time < '$jtime'";
  5392. }
  5393. }
  5394. if($warehouse)
  5395. {
  5396. $where .= " and warehouse = '$warehouse'";
  5397. }
  5398. //数据排序
  5399. $order_str = "id desc";
  5400. if(empty($page))
  5401. {
  5402. $start = 0;
  5403. $perpage = 1;
  5404. }
  5405. else
  5406. {
  5407. $start = ($page - 1)*$perpage;
  5408. }
  5409. //取得信息列表
  5410. $rows = array();$list = array();
  5411. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5412. foreach ($info_list as $value)
  5413. {
  5414. $warehouse = $this->warehouse->read($value['warehouse']);
  5415. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5416. $number = $value['number'];$ftime = time()-15*24*3600;
  5417. if($c < 1)
  5418. {
  5419. $list[] = array('warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5420. }
  5421. }
  5422. $title = "0库存汇总";
  5423. $titlename = "<table border=1>
  5424. <tr align='center'>
  5425. <td>仓库</td>
  5426. <td>SKU</td>
  5427. <td>产品</td>
  5428. <td>当前库存</td>
  5429. </tr>
  5430. </table>";
  5431. $filename = $title.".xls";
  5432. $tail = "";
  5433. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5434. }
  5435. }
  5436. /**
  5437. *
  5438. *
  5439. * 占单
  5440. *
  5441. *
  5442. **/
  5443. public function _kcyz()
  5444. {
  5445. $post = $this->input->post(NULL, TRUE);
  5446. if(isset($post['warehouse']))
  5447. {
  5448. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请更新浏览器缓存!','success'=>false)));exit;//不再使用
  5449. $warehouse = $this->input->post('warehouse',true);
  5450. $whlabel = $this->input->post('whlabel',true);
  5451. $id = $this->input->post('id',true);
  5452. $shop = $this->input->post('shop',true);
  5453. $number = $this->input->post('number',true);
  5454. if(!$whlabel || $whlabel == '|')
  5455. {
  5456. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  5457. }
  5458. $pp = explode('|',trim($whlabel,'|'));
  5459. $x = 0;$save = array();
  5460. foreach ($pp as $va)
  5461. {
  5462. $num = explode('-',$va);
  5463. if($number)
  5464. {
  5465. $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 = '')");//通用
  5466. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  5467. }
  5468. else
  5469. {
  5470. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  5471. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  5472. }
  5473. $x++;
  5474. if(count($whlabel)+count($shopwhlabel) < $num[1])
  5475. {
  5476. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  5477. }
  5478. }
  5479. if(isset($save[0]))
  5480. {
  5481. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
  5482. }
  5483. else
  5484. {
  5485. echo json_encode(array('success'=>true));exit;
  5486. }
  5487. }
  5488. }
  5489. public function _db()
  5490. {
  5491. $post = $this->input->post(NULL, TRUE);
  5492. if(isset($post['page']))
  5493. {
  5494. $page = $this->input->post('page',true);
  5495. $perpage = $this->input->post('perpage',true);
  5496. $sku = $this->input->post('sku',true);
  5497. $number = $this->input->post('number',true);
  5498. $warehouse = $this->input->post('warehouse',true);
  5499. $purchase = $this->input->post('purchase',true);
  5500. $orderinfo = $this->input->post('orderinfo',true);
  5501. $waybill = $this->input->post('waybill',true);
  5502. $category = $this->input->post('category',true);
  5503. $size = $this->input->post('size',true);
  5504. $grade = $this->input->post('grade',true);
  5505. $color = $this->input->post('color',true);
  5506. $lowe = $this->input->post('lowe',true);
  5507. $state = $this->input->post('state',true);
  5508. $label = $this->input->post('label',true);
  5509. $timetk = $this->input->post('timetkk',true);
  5510. $timetj = $this->input->post('timetjj',true);
  5511. $timetk = strtotime($timetk);
  5512. $timetj = strtotime($timetj);
  5513. $where = "dbtime > 0";
  5514. if($timetk && $timetj)
  5515. {
  5516. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5517. }
  5518. if($sku)
  5519. {
  5520. $where .= " and sku = '$sku'";
  5521. }
  5522. if($warehouse)
  5523. {
  5524. $where .= " and warehouse = '$warehouse'";
  5525. if($warehouse == 12)
  5526. {
  5527. $w = 'specialstock';
  5528. }
  5529. else
  5530. {
  5531. $w = 'whlabel';
  5532. }
  5533. }
  5534. if($purchase)
  5535. {
  5536. $where .= " and purchase = '$purchase'";
  5537. }
  5538. if($category)
  5539. {
  5540. $where .= " and features like '%-$category-%'";
  5541. }
  5542. if($size)
  5543. {
  5544. $where .= " and features like '%-$size-%'";
  5545. }
  5546. if($grade)
  5547. {
  5548. $where .= " and features like '%-$grade-%'";
  5549. }
  5550. if($color)
  5551. {
  5552. $where .= " and features like '%-$color-%'";
  5553. }
  5554. if($lowe)
  5555. {
  5556. $where .= " and features like '%-$lowe-%'";
  5557. }
  5558. if($state != '')
  5559. {
  5560. $where .= " and state = '$state'";
  5561. }
  5562. //数据排序
  5563. $order_str = "dbtime desc";
  5564. if(empty($page))
  5565. {
  5566. $start = 0;
  5567. $perpage = 1;
  5568. }
  5569. else
  5570. {
  5571. $start = ($page - 1)*$perpage;
  5572. }
  5573. //取得信息列表
  5574. $info_list = $this->$w->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5575. foreach ($info_list as $key=>$value)
  5576. {
  5577. $warehouse = $this->$w->read($value['warehouse']);
  5578. $info_list[$key]['warehouse'] = $warehouse['title'];
  5579. $purchase = $this->purchase->read($value['purchase']);
  5580. $info_list[$key]['purchase'] = $purchase['title'];
  5581. if($value['enter'] != 0)
  5582. {
  5583. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5584. }
  5585. else
  5586. {
  5587. $info_list[$key]['enter'] = "";
  5588. }
  5589. if($value['dbtime'] != 0)
  5590. {
  5591. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5592. }
  5593. else
  5594. {
  5595. $info_list[$key]['dbtime'] = "";
  5596. }
  5597. if($value['state'] == 0)
  5598. {
  5599. $info_list[$key]['state'] = "在库";
  5600. }
  5601. else if($value['state'] == 1)
  5602. {
  5603. $info_list[$key]['state'] = "出库";
  5604. }
  5605. else if($value['state'] == 2)
  5606. {
  5607. $info_list[$key]['state'] = "退库";
  5608. }
  5609. else if($value['state'] == 3)
  5610. {
  5611. $info_list[$key]['state'] = "调拨中";
  5612. }
  5613. else if($value['state'] == 4)
  5614. {
  5615. $info_list[$key]['state'] = "再加工";
  5616. }
  5617. else if($value['state'] == 5)
  5618. {
  5619. $info_list[$key]['state'] = "维修中";
  5620. }
  5621. else if($value['state'] == 6)
  5622. {
  5623. $info_list[$key]['state'] = "盘亏";
  5624. }
  5625. else if($value['state'] == 7)
  5626. {
  5627. $info_list[$key]['state'] = "更换标签";
  5628. }
  5629. else if($value['state'] == 8)
  5630. {
  5631. $info_list[$key]['state'] = "其它";
  5632. }
  5633. else if($value['state'] == 9)
  5634. {
  5635. $info_list[$key]['state'] = "预设";
  5636. }
  5637. }
  5638. $total = $this->whlabel->find_count($where);
  5639. $pagenum = ceil($total/$perpage);
  5640. $over = $total-($start+$perpage);
  5641. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5642. echo json_encode($rows);exit;
  5643. }
  5644. if(isset($post['outsku']))
  5645. {
  5646. $time = time();
  5647. $cz = $this->input->post('cz',true);
  5648. $label = $this->input->post('outsku',true);
  5649. $sl = $this->input->post('sl',true);
  5650. $num = $this->input->post('num',true);
  5651. //$warehouse = $this->input->post('warehouse',true);
  5652. if(!$sl)
  5653. {
  5654. $sl = 1;
  5655. }
  5656. if(!$warehouse)
  5657. {
  5658. echo json_encode(array('msg'=>'请选择调拨到的仓库','success'=>false));exit;
  5659. }
  5660. $dblabel = $this->whlabellabel->get_label($label);
  5661. if($dblabel)
  5662. {
  5663. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '0' and zd = ''");
  5664. if(count($data) < 1)
  5665. {
  5666. echo json_encode(array('msg'=>'没有此产品数据!','success'=>false));exit;
  5667. }
  5668. if(count($data) < $num)
  5669. {
  5670. echo json_encode(array('msg'=>'库存数量少于调拨数量!','success'=>false));exit;
  5671. }
  5672. for($i=0;$i<$sl;$i++)
  5673. {
  5674. $this->whlabel->save(array('state'=>3,'dbtime'=>$dbtime,'dbcontent'=>$data[$i]['warehouse'].'-'.$time.'|','time'=>$time),$data[$i]['id']);
  5675. }
  5676. echo json_encode(array('success'=>true));exit;
  5677. }
  5678. else
  5679. {
  5680. echo json_encode(array('msg'=>'未找到此条码产品!','success'=>false));exit;
  5681. }
  5682. }
  5683. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5684. $this->_Template('whlabel_db',$this->data);
  5685. }
  5686. public function _dbrk()
  5687. {
  5688. $post = $this->input->post(NULL, TRUE);
  5689. if(isset($post['page']))
  5690. {
  5691. $page = $this->input->post('page',true);
  5692. $perpage = $this->input->post('perpage',true);
  5693. $sku = $this->input->post('sku',true);
  5694. $number = $this->input->post('number',true);
  5695. $warehouse = $this->input->post('warehouse',true);
  5696. $purchase = $this->input->post('purchase',true);
  5697. $orderinfo = $this->input->post('orderinfo',true);
  5698. $waybill = $this->input->post('waybill',true);
  5699. $category = $this->input->post('category',true);
  5700. $size = $this->input->post('size',true);
  5701. $grade = $this->input->post('grade',true);
  5702. $color = $this->input->post('color',true);
  5703. $lowe = $this->input->post('lowe',true);
  5704. $state = $this->input->post('state',true);
  5705. $label = $this->input->post('label',true);
  5706. $ctime = $this->input->post('ctime',true);
  5707. $timetk = $this->input->post('timetkk',true);
  5708. $timetj = $this->input->post('timetjj',true);
  5709. $timetk = strtotime($timetk);
  5710. $timetj = strtotime($timetj);
  5711. $where = "dbtime > 0";
  5712. if($timetk && $timetj)
  5713. {
  5714. $where .= " and ".$ctime." > '$timetk' and ".$ctime." < '$timetj'";
  5715. }
  5716. if($sku)
  5717. {
  5718. $where .= " and sku = '$sku'";
  5719. }
  5720. if($warehouse)
  5721. {
  5722. $where .= " and warehouse = '$warehouse'";
  5723. }
  5724. if($purchase)
  5725. {
  5726. $where .= " and purchase = '$purchase'";
  5727. }
  5728. if($category)
  5729. {
  5730. $where .= " and features like '%-$category-%'";
  5731. }
  5732. if($size)
  5733. {
  5734. $where .= " and features like '%-$size-%'";
  5735. }
  5736. if($grade)
  5737. {
  5738. $where .= " and features like '%-$grade-%'";
  5739. }
  5740. if($color)
  5741. {
  5742. $where .= " and features like '%-$color-%'";
  5743. }
  5744. if($lowe)
  5745. {
  5746. $where .= " and features like '%-$lowe-%'";
  5747. }
  5748. if($state != '')
  5749. {
  5750. $where .= " and state = '$state'";
  5751. }
  5752. //数据排序
  5753. $order_str = "dbtime desc";
  5754. if(empty($page))
  5755. {
  5756. $start = 0;
  5757. $perpage = 1;
  5758. }
  5759. else
  5760. {
  5761. $start = ($page - 1)*$perpage;
  5762. }
  5763. //取得信息列表
  5764. $info_list = $this->whlabel->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5765. foreach ($info_list as $key=>$value)
  5766. {
  5767. $warehouse = $this->warehouse->read($value['warehouse']);
  5768. $info_list[$key]['warehouse'] = $warehouse['title'];
  5769. $purchase = $this->purchase->read($value['purchase']);
  5770. $info_list[$key]['purchase'] = $purchase['title'];
  5771. if($value['enter'] != 0)
  5772. {
  5773. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5774. }
  5775. else
  5776. {
  5777. $info_list[$key]['enter'] = "";
  5778. }
  5779. if($value['dbtime'] != 0)
  5780. {
  5781. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5782. }
  5783. else
  5784. {
  5785. $info_list[$key]['dbtime'] = "";
  5786. }
  5787. if($value['state'] == 0)
  5788. {
  5789. $info_list[$key]['state'] = "在库";
  5790. }
  5791. else if($value['state'] == 1)
  5792. {
  5793. $info_list[$key]['state'] = "出库";
  5794. }
  5795. else if($value['state'] == 2)
  5796. {
  5797. $info_list[$key]['state'] = "退库";
  5798. }
  5799. else if($value['state'] == 3)
  5800. {
  5801. $info_list[$key]['state'] = "调拨中";
  5802. }
  5803. else if($value['state'] == 4)
  5804. {
  5805. $info_list[$key]['state'] = "再加工";
  5806. }
  5807. else if($value['state'] == 5)
  5808. {
  5809. $info_list[$key]['state'] = "维修中";
  5810. }
  5811. else if($value['state'] == 6)
  5812. {
  5813. $info_list[$key]['state'] = "盘亏";
  5814. }
  5815. else if($value['state'] == 7)
  5816. {
  5817. $info_list[$key]['state'] = "更换标签";
  5818. }
  5819. else if($value['state'] == 8)
  5820. {
  5821. $info_list[$key]['state'] = "其它";
  5822. }
  5823. else if($value['state'] == 9)
  5824. {
  5825. $info_list[$key]['state'] = "预设";
  5826. }
  5827. }
  5828. $total = $this->whlabel->find_count($where);
  5829. $pagenum = ceil($total/$perpage);
  5830. $over = $total-($start+$perpage);
  5831. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5832. echo json_encode($rows);exit;
  5833. }
  5834. if(isset($post['rsku']))
  5835. {
  5836. $cz = $this->input->post('cz',true);
  5837. $label = $this->input->post('rsku',true);
  5838. $sl = $this->input->post('sl',true);
  5839. $warehouse = $this->input->post('warehouse',true);
  5840. if(!$sl)
  5841. {
  5842. $sl = 1;
  5843. }
  5844. if(!$warehouse)
  5845. {
  5846. echo json_encode(array('msg'=>'请选择入库仓库','success'=>false));exit;
  5847. }
  5848. $dblabel = $this->whlabellabel->get_label($label);
  5849. if($dblabel)
  5850. {
  5851. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '3' and zd = ''");
  5852. if(count($data) < 1)
  5853. {
  5854. echo json_encode(array('msg'=>'没有此SKU调拨数据!','success'=>false));exit;
  5855. }
  5856. if($sl > count($data))
  5857. {
  5858. echo json_encode(array('msg'=>'入库数量大于调拨数量!','success'=>false));exit;
  5859. }
  5860. $time = time();
  5861. for($i=0;$i<$sl;$i++)
  5862. {
  5863. $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']);
  5864. }
  5865. echo json_encode(array('success'=>true));exit;
  5866. }
  5867. else
  5868. {
  5869. echo json_encode(array('msg'=>'没有此条码的库存信息!','success'=>false));exit;
  5870. }
  5871. }
  5872. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5873. $this->_Template('whlabel_dbrk',$this->data);
  5874. }
  5875. public function _whlabelczdc()
  5876. {
  5877. if(isset($_GET['excel']))
  5878. {
  5879. //数据排序
  5880. $order_str = "id desc";
  5881. if(empty($page))
  5882. {
  5883. $start = 0;
  5884. $perpage = 1;
  5885. }
  5886. else
  5887. {
  5888. $start = ($page - 1)*$perpage;
  5889. }
  5890. $state = $this->input->get('state',true);
  5891. $sku = $this->input->get('sku',true);
  5892. $ctime = $this->input->get('ctime',true);
  5893. $category = $this->input->get('category',true);
  5894. $size = $this->input->get('size',true);
  5895. $grade = $this->input->get('grade',true);
  5896. $color = $this->input->get('color',true);
  5897. $lowe = $this->input->get('lowe',true);
  5898. $timetk = $this->input->get('timetkk',true);
  5899. $timetj = $this->input->get('timetjj',true);
  5900. $timetk = strtotime($timetk);
  5901. $timetj = strtotime($timetj);
  5902. $where = "dbtime > 0";
  5903. if($timetk && $timetj)
  5904. {
  5905. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5906. }
  5907. if($category)
  5908. {
  5909. $where .= " and features like '%-$category-%'";
  5910. }
  5911. if($size)
  5912. {
  5913. $where .= " and features like '%-$size-%'";
  5914. }
  5915. if($grade)
  5916. {
  5917. $where .= " and features like '%-$grade-%'";
  5918. }
  5919. if($color)
  5920. {
  5921. $where .= " and features like '%-$color-%'";
  5922. }
  5923. if($lowe)
  5924. {
  5925. $where .= " and features like '%-$lowe-%'";
  5926. }
  5927. //取得信息列表
  5928. $info_list = $this->whlabel->find_all($where,'*');
  5929. $rows = array();$list = array();
  5930. foreach ($info_list as $key=>$value)
  5931. {
  5932. $rows[$value['sku']] = $value;//所有数据sku
  5933. }
  5934. foreach ($rows as $value)
  5935. {
  5936. $warehouse = $this->warehouse->read($value['warehouse']);
  5937. $db = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'"');
  5938. $rk = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and enter > 0');
  5939. if($value['orderinfo'] == 0)
  5940. {
  5941. $info_list[$key]['orderinfo'] = "";
  5942. }
  5943. if($value['waybill'] == 0)
  5944. {
  5945. $info_list[$key]['waybill'] = "";
  5946. }
  5947. if($value['state'] == 0)
  5948. {
  5949. $value['state'] = "在库";
  5950. }
  5951. else if($value['state'] == 3)
  5952. {
  5953. $value['state'] = "调拨中";
  5954. }
  5955. $list[] = array($value['sku'],$value['title'],$db,$rk);
  5956. }
  5957. $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj)."统计表";
  5958. $titlename = "<table border=1>
  5959. <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
  5960. <tr align='center'>
  5961. <td>SKU</td>
  5962. <td>产品</td>
  5963. <td>调拨数量</td>
  5964. <td>入库数量</td>
  5965. </tr>
  5966. </table>";
  5967. $filename = $title.".xls";
  5968. $tail = "";
  5969. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5970. }
  5971. }
  5972. public function _print($arg_array)
  5973. {
  5974. if(isset($_SESSION['api']))
  5975. {
  5976. $user = $this->user->get_api($_SESSION['api']);
  5977. $usp = $user;
  5978. $fgshop = "";$sid = "";$wid="";$wtype="";
  5979. $usersp = explode('|',trim($user['shop'],'|'));
  5980. $userwh = explode('|',trim($user['warehouse'],'|'));
  5981. foreach ($usersp as $value)
  5982. {
  5983. $fgshop .= " shop = ".$value." or";
  5984. $sid .= " id = ".$value." or";
  5985. }
  5986. foreach ($userwh as $value)
  5987. {
  5988. $wid .= " id = ".$value." or";
  5989. $wtype .= " type = ".$value." or";
  5990. }
  5991. }
  5992. $post = $this->input->post(NULL, TRUE);
  5993. if(isset($post['tmsku']))
  5994. {
  5995. $tmsku = $this->input->post('tmsku',true);
  5996. if(is_numeric($tmsku))
  5997. {
  5998. $yyh = $this->whlabellabel->get_label($tmsku);
  5999. }
  6000. else
  6001. {
  6002. $yyh = $this->whlabellabel->get_sku($tmsku);
  6003. }
  6004. if($yyh)
  6005. {
  6006. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  6007. }
  6008. else
  6009. {
  6010. echo json_encode(array('success'=>false));exit;
  6011. }
  6012. }
  6013. $classid = $this->classid->sku();
  6014. $pm = $classid;
  6015. $scsku = $classid;
  6016. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6017. if(isset($post['warehouse']))
  6018. {
  6019. if($post['warehouse'])
  6020. {
  6021. $list = array();$num = "";$title = "";$features = "";
  6022. $order = 0;
  6023. $post['shop'] = '';
  6024. $brand = $this->input->post('brand',true);
  6025. if($brand != '0,')
  6026. {
  6027. $b = $this->brand->read(rtrim($brand,','));
  6028. if($b)
  6029. {
  6030. $post['shop'] = str_replace('|',',',$b['shop']);
  6031. }
  6032. }
  6033. $post['details'] = $this->input->post('details',true);//打印数量
  6034. $xbqnum = $this->input->post('xbqnum',true);
  6035. $post['purchase'] = $this->input->post('purchase',true);
  6036. $post['warehouse'] = $this->input->post('warehouse',true);
  6037. $post['purchase'] = $this->input->post('purchase',true);
  6038. $post['retreatwarehouse'] = $post['warehouse'];
  6039. $post['cpbz'] = $this->input->post('cpbz',true);
  6040. $post['state'] = 9;
  6041. $category = $this->input->post('category',true);
  6042. $list['category'] = $category;
  6043. $list['hairtype'] = $this->input->post('hairtype',true);
  6044. $list['grade'] = $this->input->post('grade',true);
  6045. $size = $this->input->post('size',true);
  6046. $list['size'] = rtrim($size,',');
  6047. $list['hairnumber'] = $this->input->post('hairnumber',true);
  6048. $list['extension'] = $this->input->post('extension',true);
  6049. if($category == 1297)
  6050. {
  6051. $list['sywignumber'] = $this->input->post('sywignumber',true);
  6052. }
  6053. if($category == 1702)
  6054. {
  6055. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  6056. $list['syother'] = $this->input->post('syother',true);
  6057. }
  6058. if($category == 133)
  6059. {
  6060. $list['fittype'] = $this->input->post('fittype',true);
  6061. $list['acother'] = $this->input->post('acother',true);
  6062. }
  6063. $list['color'] = $this->input->post('color',true);
  6064. $list['lowe'] = $this->input->post('lowe',true);
  6065. if($category == 127)
  6066. {
  6067. $list['type'] = $this->input->post('type',true);
  6068. $list['headroad'] = $this->input->post('headroad',true);
  6069. $list['density'] = $this->input->post('density',true);
  6070. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  6071. {
  6072. $list['lacesize'] = $this->input->post('lacesize',true);
  6073. }
  6074. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6075. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6076. }
  6077. if($category == 128)
  6078. {
  6079. $list['lacetype'] = $this->input->post('lacetype',true);
  6080. $list['haircap'] = $this->input->post('haircap',true);
  6081. $list['density'] = $this->input->post('density',true);
  6082. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6083. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6084. $list['wigother'] = $this->input->post('wigother',true);
  6085. $list['wigother2'] = $this->input->post('wigother2',true);
  6086. }
  6087. if($category == 129)
  6088. {
  6089. $list['wide'] = $this->input->post('wide',true);
  6090. }
  6091. if($category == 131)
  6092. {
  6093. $list['gifttype'] = $this->input->post('gifttype',true);
  6094. $list['giftother'] = $this->input->post('giftother',true);
  6095. }
  6096. if($category == 134)
  6097. {
  6098. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6099. }
  6100. if($category == 1297)
  6101. {
  6102. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6103. $list['sywigother'] = $this->input->post('sywigother',true);
  6104. }
  6105. if($category == 130 || $category == 133 || $category == 1702)
  6106. {
  6107. $list['items'] = $this->input->post('items',true);
  6108. $list['weight'] = $this->input->post('weight',true);
  6109. }
  6110. if($category == 1702)
  6111. {
  6112. $list['syhairther'] = $this->input->post('syhairther',true);
  6113. }
  6114. foreach($list as $k=>$v)
  6115. {
  6116. if($v != 0)
  6117. {
  6118. $num .=$v;
  6119. $features .=$v.'-';
  6120. $post[$k] = $v;
  6121. $typeclass = $this->typeclass->read($v);
  6122. if(isset($pm[$typeclass['classid']]))
  6123. {
  6124. if(stripos($typeclass['zh'],'|') !== false)
  6125. {
  6126. $exzh = explode('|',$typeclass['zh']);
  6127. $pm[$typeclass['classid']] = $exzh[0];
  6128. }
  6129. else
  6130. {
  6131. $pm[$typeclass['classid']] = $typeclass['zh'];
  6132. }
  6133. }
  6134. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6135. if($k != 'size')
  6136. {
  6137. $title .= $typeclass['title']." ";
  6138. }
  6139. }
  6140. }
  6141. $typeclass = $this->typeclass->read($list['size']);
  6142. $title .= $typeclass['title'];
  6143. $time = time();
  6144. $post['title'] = rtrim($title,' ');
  6145. $post['number'] = $num;
  6146. $post['features'] = '-'.$features;
  6147. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6148. $featurespp = explode('-',trim($featurespp,'-'));
  6149. if(isset($featurespp[5]))
  6150. {
  6151. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6152. }
  6153. else
  6154. {
  6155. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6156. }
  6157. $post['enter'] = $time;
  6158. $post['time'] = $time;//操作时间
  6159. $scsku = implode("-",$scsku);
  6160. $zh = implode(" ",$pm);
  6161. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6162. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6163. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6164. $post['sku'] = $bqsku;
  6165. $label = time().rand(0,9);
  6166. $post['label'] = $label;
  6167. $cpid = $this->whlabellabel->find_count();
  6168. $post['cpid'] = $cpid+1;
  6169. $cpid = $post['cpid'];
  6170. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6171. //if($whlabelbarcode)
  6172. //{
  6173. //$post['label'] = $whlabelbarcode['label'];
  6174. //if(!$this->whlabellabel->insert($post))
  6175. //{
  6176. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6177. //}
  6178. //}
  6179. //else
  6180. //{
  6181. $this->db->trans_begin();
  6182. $this->whlabellabel->insert($post);
  6183. //$this->whlabelbarcode->insert($post);
  6184. if ($this->db->trans_status() === TRUE)
  6185. {
  6186. $this->db->trans_commit();
  6187. }
  6188. else
  6189. {
  6190. $this->db->trans_rollback();
  6191. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6192. }
  6193. //}
  6194. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6195. $purchase = $this->purchase->read($post['purchase']);
  6196. 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;//特殊仓目前不需要仓库选项
  6197. }
  6198. }
  6199. if(isset($_SESSION['api']))
  6200. {
  6201. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6202. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6203. $this->data['wlshop'] = $wlshop;
  6204. $this->data['warehouse'] = $warehouse;
  6205. }
  6206. $whlabelwz = $this->whlabelwz->find_all();
  6207. $this->data['whlabelwz'] = $whlabelwz;
  6208. $this->_Template('whlabel_print',$this->data);
  6209. }
  6210. public function _usaprint($arg_array)
  6211. {
  6212. if(isset($_SESSION['api']))
  6213. {
  6214. $user = $this->user->get_api($_SESSION['api']);
  6215. $usp = $user;
  6216. $fgshop = "";$sid = "";$wid="";$wtype="";
  6217. $usersp = explode('|',trim($user['shop'],'|'));
  6218. $userwh = explode('|',trim($user['warehouse'],'|'));
  6219. foreach ($usersp as $value)
  6220. {
  6221. $fgshop .= " shop = ".$value." or";
  6222. $sid .= " id = ".$value." or";
  6223. }
  6224. foreach ($userwh as $value)
  6225. {
  6226. $wid .= " id = ".$value." or";
  6227. $wtype .= " type = ".$value." or";
  6228. }
  6229. }
  6230. $post = $this->input->post(NULL, TRUE);
  6231. if(isset($post['tmsku']))
  6232. {
  6233. $tmsku = $this->input->post('tmsku',true);
  6234. if(is_numeric($tmsku))
  6235. {
  6236. $yyh = $this->whlabellabel->get_label($tmsku);
  6237. }
  6238. else
  6239. {
  6240. $yyh = $this->whlabellabel->get_sku($tmsku);
  6241. }
  6242. if($yyh)
  6243. {
  6244. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  6245. }
  6246. else
  6247. {
  6248. echo json_encode(array('success'=>false));exit;
  6249. }
  6250. }
  6251. $classid = $this->classid->sku();
  6252. $pm = $classid;
  6253. $scsku = $classid;
  6254. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6255. if(isset($post['warehouse']))
  6256. {
  6257. if($post['warehouse'])
  6258. {
  6259. $list = array();$num = "";$title = "";$features = "";
  6260. $order = 0;
  6261. $post['shop'] = '';
  6262. $brand = $this->input->post('brand',true);
  6263. if($brand != '0,')
  6264. {
  6265. $b = $this->brand->read(rtrim($brand,','));
  6266. if($b)
  6267. {
  6268. $post['shop'] = str_replace('|',',',$b['shop']);
  6269. }
  6270. }
  6271. $post['details'] = $this->input->post('details',true);//打印数量
  6272. $xbqnum = $this->input->post('xbqnum',true);
  6273. $post['purchase'] = $this->input->post('purchase',true);
  6274. $post['warehouse'] = $this->input->post('warehouse',true);
  6275. $post['purchase'] = $this->input->post('purchase',true);
  6276. $post['retreatwarehouse'] = $post['warehouse'];
  6277. $post['cpbz'] = $this->input->post('cpbz',true);
  6278. $post['state'] = 9;
  6279. $category = $this->input->post('category',true);
  6280. $list['category'] = $category;
  6281. $list['hairtype'] = $this->input->post('hairtype',true);
  6282. $list['grade'] = $this->input->post('grade',true);
  6283. $size = $this->input->post('size',true);
  6284. $list['size'] = rtrim($size,',');
  6285. $list['hairnumber'] = $this->input->post('hairnumber',true);
  6286. $list['extension'] = $this->input->post('extension',true);
  6287. if($category == 1297)
  6288. {
  6289. $list['sywignumber'] = $this->input->post('sywignumber',true);
  6290. }
  6291. if($category == 1702)
  6292. {
  6293. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  6294. $list['syother'] = $this->input->post('syother',true);
  6295. }
  6296. if($category == 133)
  6297. {
  6298. $list['fittype'] = $this->input->post('fittype',true);
  6299. $list['acother'] = $this->input->post('acother',true);
  6300. }
  6301. $list['color'] = $this->input->post('color',true);
  6302. $list['lowe'] = $this->input->post('lowe',true);
  6303. if($category == 127)
  6304. {
  6305. $list['type'] = $this->input->post('type',true);
  6306. $list['headroad'] = $this->input->post('headroad',true);
  6307. $list['density'] = $this->input->post('density',true);
  6308. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  6309. {
  6310. $list['lacesize'] = $this->input->post('lacesize',true);
  6311. }
  6312. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6313. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6314. }
  6315. if($category == 128)
  6316. {
  6317. $list['lacetype'] = $this->input->post('lacetype',true);
  6318. $list['haircap'] = $this->input->post('haircap',true);
  6319. $list['density'] = $this->input->post('density',true);
  6320. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6321. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6322. $list['wigother'] = $this->input->post('wigother',true);
  6323. $list['wigother2'] = $this->input->post('wigother2',true);
  6324. }
  6325. if($category == 129)
  6326. {
  6327. $list['wide'] = $this->input->post('wide',true);
  6328. }
  6329. if($category == 131)
  6330. {
  6331. $list['gifttype'] = $this->input->post('gifttype',true);
  6332. $list['giftother'] = $this->input->post('giftother',true);
  6333. }
  6334. if($category == 134)
  6335. {
  6336. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6337. }
  6338. if($category == 1297)
  6339. {
  6340. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6341. $list['sywigother'] = $this->input->post('sywigother',true);
  6342. }
  6343. if($category == 130 || $category == 133 || $category == 1702)
  6344. {
  6345. $list['items'] = $this->input->post('items',true);
  6346. $list['weight'] = $this->input->post('weight',true);
  6347. }
  6348. if($category == 1702)
  6349. {
  6350. $list['syhairther'] = $this->input->post('syhairther',true);
  6351. }
  6352. foreach($list as $k=>$v)
  6353. {
  6354. if($v != 0)
  6355. {
  6356. $num .=$v;
  6357. $features .=$v.'-';
  6358. $post[$k] = $v;
  6359. $typeclass = $this->typeclass->read($v);
  6360. if(isset($pm[$typeclass['classid']]))
  6361. {
  6362. if(stripos($typeclass['zh'],'|') !== false)
  6363. {
  6364. $exzh = explode('|',$typeclass['zh']);
  6365. $pm[$typeclass['classid']] = $exzh[0];
  6366. }
  6367. else
  6368. {
  6369. $pm[$typeclass['classid']] = $typeclass['zh'];
  6370. }
  6371. }
  6372. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6373. if($k != 'size')
  6374. {
  6375. $title .= $typeclass['title']." ";
  6376. }
  6377. }
  6378. }
  6379. $typeclass = $this->typeclass->read($list['size']);
  6380. $title .= $typeclass['title'];
  6381. $time = time();
  6382. $post['title'] = rtrim($title,' ');
  6383. $post['number'] = $num;
  6384. $post['features'] = '-'.$features;
  6385. $fp = $this->whlabel->get_features($post['features']);
  6386. if(!$fp)
  6387. {
  6388. echo json_encode(array('msg'=>'美仓无此产品,需要添加后才可打印','success'=>false));exit;
  6389. }
  6390. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6391. $featurespp = explode('-',trim($featurespp,'-'));
  6392. if(isset($featurespp[5]))
  6393. {
  6394. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6395. }
  6396. else
  6397. {
  6398. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6399. }
  6400. $post['enter'] = $time;
  6401. $post['time'] = $time;//操作时间
  6402. $scsku = implode("-",$scsku);
  6403. $zh = implode(" ",$pm);
  6404. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6405. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6406. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6407. $post['sku'] = $fp['sku'];
  6408. $post['label'] = $fp['sku'];
  6409. $cpid = $this->whlabellabel->find_count();
  6410. $post['cpid'] = $cpid+1;
  6411. $cpid = $post['cpid'];
  6412. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6413. //if($whlabelbarcode)
  6414. //{
  6415. //$post['label'] = $whlabelbarcode['label'];
  6416. //if(!$this->whlabellabel->insert($post))
  6417. //{
  6418. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6419. //}
  6420. //}
  6421. //else
  6422. //{
  6423. $this->db->trans_begin();
  6424. $this->whlabellabel->insert($post);
  6425. //$this->whlabelbarcode->insert($post);
  6426. if ($this->db->trans_status() === TRUE)
  6427. {
  6428. $this->db->trans_commit();
  6429. }
  6430. else
  6431. {
  6432. $this->db->trans_rollback();
  6433. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6434. }
  6435. //}
  6436. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6437. $purchase = $this->purchase->read($post['purchase']);
  6438. 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;//特殊仓目前不需要仓库选项
  6439. }
  6440. }
  6441. if(isset($_SESSION['api']))
  6442. {
  6443. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6444. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6445. $this->data['wlshop'] = $wlshop;
  6446. $this->data['warehouse'] = $warehouse;
  6447. }
  6448. $whlabelwz = $this->whlabelwz->find_all();
  6449. $this->data['whlabelwz'] = $whlabelwz;
  6450. $this->_Template('whlabel_usaprint',$this->data);
  6451. }
  6452. public function _printrk($arg_array)
  6453. {
  6454. $prc = array();
  6455. $purchase = $this->purchase->find_all();
  6456. foreach($purchase as $k=>$v)
  6457. {
  6458. $prc[$v['id']] = $v['title'];
  6459. }
  6460. $post = $this->input->post(NULL, TRUE);
  6461. if(isset($post['page']))
  6462. {
  6463. $page = $this->input->post('page',true);
  6464. $perpage = $this->input->post('perpage',true);
  6465. $sku = $this->input->post('sku',true);
  6466. $bs = $this->input->post('bs',true);
  6467. $number = $this->input->post('number',true);
  6468. $warehouse = $this->input->post('warehouse',true);
  6469. $purchase = $this->input->post('purchase',true);
  6470. $orderinfo = $this->input->post('orderinfo',true);
  6471. $waybill = $this->input->post('waybill',true);
  6472. $category = $this->input->post('category',true);
  6473. $size = $this->input->post('size',true);
  6474. $grade = $this->input->post('grade',true);
  6475. $color = $this->input->post('color',true);
  6476. $lowe = $this->input->post('lowe',true);
  6477. $state = $this->input->post('state',true);
  6478. $label = $this->input->post('label',true);
  6479. $timetk = $this->input->post('ktime',true);
  6480. $timetj = $this->input->post('jtime',true);
  6481. $timetk = strtotime($timetk);
  6482. $timetj = strtotime($timetj);
  6483. $where = "1=1 ";
  6484. if($timetk && $timetj)
  6485. {
  6486. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6487. }
  6488. if($sku)
  6489. {
  6490. $where .= " and sku = '$sku'";
  6491. }
  6492. if($bs != '')
  6493. {
  6494. $where .= " and bs = '$bs'";
  6495. }
  6496. if($number)
  6497. {
  6498. $where .= " and number = '$number'";
  6499. }
  6500. if($warehouse)
  6501. {
  6502. $where .= " and warehouse = '$warehouse'";
  6503. }
  6504. if($purchase)
  6505. {
  6506. $where .= " and purchase = '$purchase'";
  6507. }
  6508. if($orderinfo)
  6509. {
  6510. $where .= " and orderinfo = '$orderinfo'";
  6511. }
  6512. if($waybill)
  6513. {
  6514. $where .= " and waybill = '$waybill'";
  6515. }
  6516. if($category)
  6517. {
  6518. $where .= " and features like '%-$category-%'";
  6519. }
  6520. if($size)
  6521. {
  6522. $where .= " and features like '%-$size-%'";
  6523. }
  6524. if($grade)
  6525. {
  6526. $where .= " and features like '%-$grade-%'";
  6527. }
  6528. if($color)
  6529. {
  6530. $where .= " and features like '%-$color-%'";
  6531. }
  6532. if($lowe)
  6533. {
  6534. $where .= " and features like '%-$lowe-%'";
  6535. }
  6536. if($label)
  6537. {
  6538. $where .= " and label = '$label'";
  6539. }
  6540. if($state || $state == 0)
  6541. {
  6542. $where .= " and state = '$state'";
  6543. }
  6544. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6545. //数据排序
  6546. $order_str = "enter desc";
  6547. if(empty($page))
  6548. {
  6549. $start = 0;
  6550. $perpage = 1;
  6551. }
  6552. else
  6553. {
  6554. $start = ($page - 1)*$perpage;
  6555. }
  6556. //取得信息列表
  6557. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,enter,details',$order_str,$start,$perpage);
  6558. foreach ($info_list as $key=>$value)
  6559. {
  6560. $warehouse = $this->warehouse->read($value['warehouse']);
  6561. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6562. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6563. if($value['state'] == 0)
  6564. {
  6565. $info_list[$key]['state'] = "在库";
  6566. }
  6567. else if($value['state'] == 1)
  6568. {
  6569. $info_list[$key]['state'] = "出库";
  6570. }
  6571. else if($value['state'] == 2)
  6572. {
  6573. $info_list[$key]['state'] = "退库";
  6574. }
  6575. else if($value['state'] == 3)
  6576. {
  6577. $info_list[$key]['state'] = "调拨中";
  6578. }
  6579. else if($value['state'] == 4)
  6580. {
  6581. $info_list[$key]['state'] = "再加工";
  6582. }
  6583. else if($value['state'] == 5)
  6584. {
  6585. $info_list[$key]['state'] = "维修中";
  6586. }
  6587. else if($value['state'] == 6)
  6588. {
  6589. $info_list[$key]['state'] = "盘亏";
  6590. }
  6591. else if($value['state'] == 7)
  6592. {
  6593. $info_list[$key]['state'] = "更换标签";
  6594. }
  6595. else if($value['state'] == 8)
  6596. {
  6597. $info_list[$key]['state'] = "其它";
  6598. }
  6599. else if($value['state'] == 9)
  6600. {
  6601. $info_list[$key]['state'] = "预设";
  6602. }
  6603. else if($value['state'] == 10)
  6604. {
  6605. $info_list[$key]['state'] = "美店零售";
  6606. }
  6607. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  6608. }
  6609. $total = $this->$ck->find_count($where);
  6610. $pagenum = ceil($total/$perpage);
  6611. $over = $total-($start+$perpage);
  6612. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6613. echo json_encode($rows);exit;
  6614. }
  6615. if(isset($post['tmsku']))
  6616. {
  6617. $time = time();
  6618. $tmsku = $this->input->post('tmsku',true);
  6619. //$post['shop'] = $this->input->post('shop',true);
  6620. $num = $this->input->post('num',true);
  6621. $rktype = $this->input->post('rktype',true);
  6622. if($num > 200)
  6623. {
  6624. echo json_encode(array('msg'=>'入库数量不允许超过200!','c'=>0,'success'=>false));exit;
  6625. }
  6626. if(!$rktype)
  6627. {
  6628. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6629. }
  6630. $rk = $this->whlabellabel->find_all("label = '$tmsku'","*","id desc");
  6631. /**
  6632. $wz = array();
  6633. foreach ($rk as $key=>$value)
  6634. {
  6635. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6636. }
  6637. if(count($wz) > 1)
  6638. {
  6639. $wz = array_values($wz);
  6640. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6641. }
  6642. **/
  6643. if(isset($rk[0]['purchase']))
  6644. {
  6645. $rk = $rk[0];
  6646. $j = 0;
  6647. $post['purchase'] = $rk['purchase'];
  6648. $post['warehouse'] = $rk['warehouse'];
  6649. $post['retreatwarehouse'] = $rk['warehouse'];
  6650. $post['sku'] = $rk['sku'];
  6651. $post['number'] = $rk['number'];
  6652. $post['features'] = $rk['features'];
  6653. $post['title'] = $rk['title'];
  6654. $post['enter'] = $time;
  6655. $post['time'] = $time;
  6656. $post['bs'] = 1;
  6657. $post['shop'] = $rk['shop'];
  6658. $post['details'] = $rk['details'];
  6659. $post['cpid'] = $rk['cpid'];
  6660. $post['cpbz'] = $rk['cpbz'];
  6661. //$post['rktype'] = $rktype;
  6662. $warehouse = $this->warehouse->read($rk['warehouse']);
  6663. if($warehouse['bdck'] == '')
  6664. {
  6665. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','c'=>0,'success'=>false));exit;
  6666. }
  6667. else
  6668. {
  6669. $bdck = $warehouse['bdck'];
  6670. }
  6671. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'],$post['sku']);
  6672. if(isset($pdwz['details']))
  6673. {
  6674. if($pdwz['details'] != $post['details'])
  6675. {
  6676. echo json_encode(array('msg'=>'此产品位置应为:'.$pdwz['details'],'c'=>0,'cs'=>$pdwz['details'].' - '.$post['details'],'success'=>false));exit;
  6677. }
  6678. }
  6679. $post['featurespp'] = $rk['featurespp'];
  6680. if($post['warehouse'] == '5')
  6681. {
  6682. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6683. if($yza)
  6684. {
  6685. if($post['features'] != $yza[0]['features'])
  6686. {
  6687. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'c'=>0,'success'=>false));exit;
  6688. }
  6689. }
  6690. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6691. if($yzb)
  6692. {
  6693. if($post['sku'] != $yzb[0]['sku'])
  6694. {
  6695. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','c'=>0,'success'=>false));exit;
  6696. }
  6697. }
  6698. }
  6699. for($i=0;$i<$num;$i++)
  6700. {
  6701. $post['label'] = time().rand(100,999).$i;
  6702. if($this->$bdck->insert($post))
  6703. {
  6704. $j++;
  6705. }
  6706. }
  6707. /**
  6708. if($post['warehouse'] != 12)
  6709. {
  6710. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6711. }
  6712. **/
  6713. if($j == $num)
  6714. {
  6715. echo json_encode(array('msg'=>'入库成功!','success'=>true));exit;
  6716. }
  6717. else
  6718. {
  6719. echo json_encode(array('msg'=>'未成功入库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6720. }
  6721. }
  6722. else
  6723. {
  6724. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6725. }
  6726. }
  6727. $this->_Template('whlabel_printrk',$this->data);
  6728. }
  6729. public function _printxzrk($arg_array)
  6730. {
  6731. $post = $this->input->post(NULL, TRUE);
  6732. if(isset($post['wzid']))
  6733. {
  6734. $time = time();
  6735. $id = $this->input->post('wzid',true);
  6736. //$post['shop'] = $this->input->post('shop',true);
  6737. $num = 1;
  6738. $rk = $this->whlabellabel->read($id);
  6739. if(isset($rk['purchase']))
  6740. {
  6741. $x = 0;
  6742. $post['purchase'] = $rk['purchase'];
  6743. $post['warehouse'] = $rk['warehouse'];
  6744. $post['retreatwarehouse'] = $rk['warehouse'];
  6745. $post['sku'] = $rk['sku'];
  6746. $post['number'] = $rk['number'];
  6747. $post['features'] = $rk['features'];
  6748. $post['title'] = $rk['title'];
  6749. $post['enter'] = $time;
  6750. $post['time'] = $time;
  6751. $post['bs'] = 1;
  6752. $post['shop'] = $rk['shop'];
  6753. $post['details'] = $rk['details'];
  6754. $post['cpid'] = $rk['cpid'];
  6755. $post['cpbz'] = $rk['cpbz'];
  6756. $warehouse = $this->warehouse->read($rk['warehouse']);
  6757. if($warehouse['bdck'] == '')
  6758. {
  6759. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','success'=>false));exit;
  6760. }
  6761. else
  6762. {
  6763. $bdck = $warehouse['bdck'];
  6764. }
  6765. $post['featurespp'] = $rk['featurespp'];
  6766. $this->db->trans_begin();
  6767. for($i=0;$i<$num;$i++)
  6768. {
  6769. $post['label'] = time().rand(100,999).$i;
  6770. $this->$bdck->insert($post);
  6771. }
  6772. /**
  6773. if($post['warehouse'] != 12)
  6774. {
  6775. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6776. }
  6777. **/
  6778. if ($this->db->trans_status() === TRUE)
  6779. {
  6780. $this->db->trans_commit();
  6781. echo json_encode(array('msg'=>'入库成功!','cs'=>$post,'cs2'=>$warehouse,'success'=>true));exit;
  6782. }
  6783. else
  6784. {
  6785. $this->db->trans_rollback();
  6786. echo json_encode(array('msg'=>'入库失败,请重试','c'=>0,'success'=>false));exit;
  6787. }
  6788. }
  6789. else
  6790. {
  6791. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6792. }
  6793. }
  6794. }
  6795. public function _printck($arg_array)
  6796. {
  6797. $prc = array();
  6798. $purchase = $this->purchase->find_all();
  6799. foreach($purchase as $k=>$v)
  6800. {
  6801. $prc[$v['id']] = $v['title'];
  6802. }
  6803. $post = $this->input->post(NULL, TRUE);
  6804. if(isset($post['page']))
  6805. {
  6806. $page = $this->input->post('page',true);
  6807. $perpage = $this->input->post('perpage',true);
  6808. $sku = $this->input->post('sku',true);
  6809. $bs = $this->input->post('bs',true);
  6810. $number = $this->input->post('number',true);
  6811. $warehouse = $this->input->post('warehouse',true);
  6812. $purchase = $this->input->post('purchase',true);
  6813. $orderinfo = $this->input->post('orderinfo',true);
  6814. $waybill = $this->input->post('waybill',true);
  6815. $category = $this->input->post('category',true);
  6816. $size = $this->input->post('size',true);
  6817. $grade = $this->input->post('grade',true);
  6818. $color = $this->input->post('color',true);
  6819. $lowe = $this->input->post('lowe',true);
  6820. $state = $this->input->post('state',true);
  6821. $label = $this->input->post('label',true);
  6822. $timetk = $this->input->post('ktime',true);
  6823. $timetj = $this->input->post('jtime',true);
  6824. $timetk = strtotime($timetk);
  6825. $timetj = strtotime($timetj);
  6826. $where = "state=1 ";
  6827. if($timetk && $timetj)
  6828. {
  6829. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6830. }
  6831. if($sku)
  6832. {
  6833. $where .= " and sku = '$sku'";
  6834. }
  6835. if($bs != '')
  6836. {
  6837. $where .= " and bs = '$bs'";
  6838. }
  6839. if($number)
  6840. {
  6841. $where .= " and number = '$number'";
  6842. }
  6843. if($warehouse)
  6844. {
  6845. $where .= " and warehouse = '$warehouse'";
  6846. }
  6847. if($purchase)
  6848. {
  6849. $where .= " and purchase = '$purchase'";
  6850. }
  6851. if($orderinfo)
  6852. {
  6853. $where .= " and orderinfo = '$orderinfo'";
  6854. }
  6855. if($waybill)
  6856. {
  6857. $where .= " and waybill = '$waybill'";
  6858. }
  6859. if($category)
  6860. {
  6861. $where .= " and features like '%-$category-%'";
  6862. }
  6863. if($size)
  6864. {
  6865. $where .= " and features like '%-$size-%'";
  6866. }
  6867. if($grade)
  6868. {
  6869. $where .= " and features like '%-$grade-%'";
  6870. }
  6871. if($color)
  6872. {
  6873. $where .= " and features like '%-$color-%'";
  6874. }
  6875. if($lowe)
  6876. {
  6877. $where .= " and features like '%-$lowe-%'";
  6878. }
  6879. if($label)
  6880. {
  6881. $where .= " and label = '$label'";
  6882. }
  6883. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6884. //数据排序
  6885. $order_str = "outk desc";
  6886. if(empty($page))
  6887. {
  6888. $start = 0;
  6889. $perpage = 1;
  6890. }
  6891. else
  6892. {
  6893. $start = ($page - 1)*$perpage;
  6894. }
  6895. //取得信息列表
  6896. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,outk,details',$order_str,$start,$perpage);
  6897. foreach ($info_list as $key=>$value)
  6898. {
  6899. $warehouse = $this->warehouse->read($value['warehouse']);
  6900. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6901. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6902. if($value['state'] == 0)
  6903. {
  6904. $info_list[$key]['state'] = "在库";
  6905. }
  6906. else if($value['state'] == 1)
  6907. {
  6908. $info_list[$key]['state'] = "出库";
  6909. }
  6910. else if($value['state'] == 2)
  6911. {
  6912. $info_list[$key]['state'] = "退库";
  6913. }
  6914. else if($value['state'] == 3)
  6915. {
  6916. $info_list[$key]['state'] = "调拨中";
  6917. }
  6918. else if($value['state'] == 4)
  6919. {
  6920. $info_list[$key]['state'] = "再加工";
  6921. }
  6922. else if($value['state'] == 5)
  6923. {
  6924. $info_list[$key]['state'] = "维修中";
  6925. }
  6926. else if($value['state'] == 6)
  6927. {
  6928. $info_list[$key]['state'] = "盘亏";
  6929. }
  6930. else if($value['state'] == 7)
  6931. {
  6932. $info_list[$key]['state'] = "更换标签";
  6933. }
  6934. else if($value['state'] == 8)
  6935. {
  6936. $info_list[$key]['state'] = "其它";
  6937. }
  6938. else if($value['state'] == 9)
  6939. {
  6940. $info_list[$key]['state'] = "预设";
  6941. }
  6942. else if($value['state'] == 10)
  6943. {
  6944. $info_list[$key]['state'] = "美店零售";
  6945. }
  6946. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  6947. }
  6948. $total = $this->$ck->find_count($where);
  6949. $pagenum = ceil($total/$perpage);
  6950. $over = $total-($start+$perpage);
  6951. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6952. echo json_encode($rows);exit;
  6953. }
  6954. if(isset($post['tmsku']))
  6955. {
  6956. $time = time();
  6957. $tmsku = $this->input->post('tmsku',true);
  6958. //$post['shop'] = $this->input->post('shop',true);
  6959. $num = $this->input->post('num',true);
  6960. $cktype = $this->input->post('cktype',true);
  6961. $label = $this->whlabellabel->get_label($tmsku);
  6962. if(!$cktype)
  6963. {
  6964. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6965. }
  6966. if(!isset($label['warehouse']))
  6967. {
  6968. echo json_encode(array('msg'=>'没有此条码信息!','success'=>false));exit;
  6969. }
  6970. $xzck = ($label['warehouse'] == '12')?'specialstock':'whlabel';
  6971. if(stripos($label['features'],'-126-') !== false)
  6972. {
  6973. $ck = $this->$xzck->find_all("state = '0' and shop = '".$label['shop']."' and number = '".$label['number']."' and warehouse = '".$label['warehouse']."' and zd = ''");
  6974. }
  6975. else
  6976. {
  6977. $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 = ''");
  6978. }
  6979. $j = 0;
  6980. if(count($ck) >= $num)
  6981. {
  6982. for($i=0;$i<$num;$i++)
  6983. {
  6984. if($this->$xzck->save(array('state'=>1,'outk'=>$time,'time'=>$time),$ck[$i]['id']))//,'cktype'=>$cktype
  6985. {
  6986. $j++;
  6987. }
  6988. }
  6989. if($j == $num)
  6990. {
  6991. echo json_encode(array('msg'=>'出库成功!','success'=>true));exit;
  6992. }
  6993. else
  6994. {
  6995. echo json_encode(array('msg'=>'未成功出库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6996. }
  6997. }
  6998. else
  6999. {
  7000. echo json_encode(array('msg'=>'没有足够的库存!','cs'=>$label['sku'].' - '.$label['purchase'],'success'=>false));exit;
  7001. }
  7002. }
  7003. $this->_Template('whlabel_printck',$this->data);
  7004. }
  7005. public function _printexcel()
  7006. {
  7007. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7008. $config['upload_path'] = '.'.$dir ;
  7009. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7010. $config['allowed_types'] = 'xls|xlsx|csv';
  7011. $config['max_size'] = 10240;
  7012. $this->load->library('upload', $config);
  7013. $this->upload->initialize($config);
  7014. if ($this->upload->do_upload('userfile'))
  7015. {
  7016. $full_path = $dir.$this->upload->data('file_name');
  7017. $fileName = '.' . $full_path;
  7018. if (!file_exists($fileName))
  7019. {
  7020. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7021. }
  7022. else
  7023. {
  7024. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7025. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7026. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7027. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7028. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7029. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7030. ++$column;//如果列数大于26行
  7031. $list = array();
  7032. for ($i = 2; $i <= $row; $i++) // 行数循环
  7033. {
  7034. $data = array();
  7035. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7036. {
  7037. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7038. }
  7039. $list[] = $data;
  7040. }
  7041. }
  7042. $ed = array();$i = 0;$j = 0;$dcdata = array();$yc = '';
  7043. $cmf_arr = array_column($list, '1');
  7044. array_multisort($cmf_arr, SORT_ASC, $list);
  7045. foreach ($list as $key=>$value)
  7046. {
  7047. $typeclass = $this->typeclass->get_bqsku($value['1'],$value['2']);
  7048. if($typeclass)
  7049. {
  7050. $this->typeclass->save(array('bqsku'=>$value['3']),$typeclass['id']);
  7051. }
  7052. else
  7053. {
  7054. $ed[] = array($value['1'].'-系统未找到此订单信息');
  7055. $i++;
  7056. continue;
  7057. }
  7058. }
  7059. if($i > 0)
  7060. {
  7061. $yc = $i.'条异常';
  7062. }
  7063. echo json_encode(array('msg'=>'操作成功 '.$yc,'yc'=>$ed,'success'=>true));exit;
  7064. }
  7065. }
  7066. public function _uck()
  7067. {
  7068. if(isset($_GET['excel']))
  7069. {
  7070. $tc = array();
  7071. $typeclass = $this->typeclass->find_all();
  7072. foreach ($typeclass as $v)
  7073. {
  7074. $tc[$v['id']] = $v['zh'];
  7075. }
  7076. $data = array();$t = array();$rq = '';
  7077. $ts = strtotime(date("Y-m-d",time()))-strtotime(date("Y-m",time()));
  7078. $ts = $ts/(24*3600);
  7079. for($i=0;$i<$ts;$i++)
  7080. {
  7081. $t[] = date("Y-m-d",strtotime('-'.($ts-$i).' day'));
  7082. $rq .= "<td>".date("Y-m-d",strtotime('-'.($ts-$i).' day'))."</td>";
  7083. }
  7084. $info_list = $this->whlabel->find_pc("warehouse = '5'",'sku','warehouse,sku,features');
  7085. foreach ($info_list as $k=>$v)
  7086. {
  7087. $features = explode('-',trim($v['features'],'-'));
  7088. if(!isset($features[3]) || !isset($features[4]))
  7089. {
  7090. continue;
  7091. }
  7092. $data[$k][0] = $tc[$features[0]];//类型
  7093. $data[$k][1] = ($features[3] != 57)?$tc[$features[3]]:'';//颜色,自然色不显示
  7094. $data[$k][2] = $tc[$features[4]];//曲度
  7095. $data[$k][3] = '';
  7096. if(isset($data[$k][1]))
  7097. {
  7098. $data[$k][3] .= $data[$k][1];
  7099. }
  7100. if(isset($data[$k][2]))
  7101. {
  7102. $data[$k][3] .= $data[$k][2];
  7103. }
  7104. if(isset($features[5]))
  7105. {
  7106. $data[$k][3] .= $tc[$features[5]];
  7107. }
  7108. if(isset($features[2]))
  7109. {
  7110. $data[$k][3] .= $tc[$features[2]];
  7111. }
  7112. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7113. $data[$k][4] = $v['sku'];
  7114. $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())).'))');//月初库存
  7115. $data[$k][] = $this->whlabel->find_count('sku = "'.$v['sku'].'" and state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');//剩余库存
  7116. $zt = $this->whlabeltransport->find_all('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and cz = "0"');
  7117. $ztrq = '';$ztsl = '';
  7118. if(count($zt) > 0)
  7119. {
  7120. foreach ($zt as $vv)
  7121. {
  7122. $ztrq .= date('Y-m-d',$vv['stime']).'<br>';
  7123. $ztsl .= $vv['num'].'<br>';
  7124. }
  7125. }
  7126. $data[$k][] = trim($ztsl,'<br>');
  7127. $data[$k][] = trim($ztrq,'<br>');
  7128. $byck = 0;
  7129. foreach ($t as $vv)
  7130. {
  7131. $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));
  7132. $data[$k][] = ($sl > 0)?'<b>'.$sl.'</b>':'';
  7133. $byck += $sl;
  7134. }
  7135. $data[$k][] = ($byck > 0)?$byck:'';
  7136. }
  7137. $title = "详情 ".date("Y-m-d",time());
  7138. $titlename = "<table border=1>
  7139. <tr align='center'>
  7140. <td>类别</td>
  7141. <td>颜色</td>
  7142. <td>曲度</td>
  7143. <td>名称</td>
  7144. <td>SKU</td>
  7145. <td>月初库存</td>
  7146. <td>剩余库存</td>
  7147. <td>在途数量</td>
  7148. <td>预达日期</td>".
  7149. $rq
  7150. ."<td>本月出库</td></tr>
  7151. </table>";
  7152. $filename = $title.".xls";
  7153. $tail = "";
  7154. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  7155. }
  7156. }
  7157. public function _whlabelexcelzh()
  7158. {
  7159. if(isset($_GET['excel']))
  7160. {
  7161. $where = "sku != 'Preset'";
  7162. //数据排序
  7163. $order_str = "id desc";
  7164. if(empty($page))
  7165. {
  7166. $start = 0;
  7167. $perpage = 1;
  7168. }
  7169. else
  7170. {
  7171. $start = ($page - 1)*$perpage;
  7172. }
  7173. $category = $this->input->get('category',true);
  7174. $warehouse = $this->input->get('warehouse',true);
  7175. $excelid = $this->input->get('sid',true);
  7176. if($category)
  7177. {
  7178. $where .= " and features like '%-$category-%'";
  7179. }
  7180. if($warehouse)
  7181. {
  7182. $where .= " and warehouse = '$warehouse'";
  7183. }
  7184. $xzid = '';
  7185. if($excelid)
  7186. {
  7187. $excelid = explode(',',trim($excelid,','));
  7188. foreach ($excelid as $key=>$value)
  7189. {
  7190. $xzid .= " id = ".$value." or";
  7191. }
  7192. $xzid = " and (".rtrim($xzid,'or').")";;
  7193. }
  7194. //取得信息列表
  7195. /**
  7196. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7197. $rows = array();$list = array();
  7198. foreach ($info_list as $key=>$value)
  7199. {
  7200. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7201. }
  7202. **/
  7203. $list = array();
  7204. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,number,features');
  7205. foreach ($rows as $key=>$value)
  7206. {
  7207. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"');
  7208. $zh = '';
  7209. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and time = "0" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','num,stime');
  7210. foreach ($zt as $v)
  7211. {
  7212. $zh .= $v['num']." / ".date('Y-m-d',$v['stime'])."<br>";
  7213. }
  7214. $zt = array_sum(array_column($zt,'num'));
  7215. $number = $value['number'];
  7216. $ftime = time()-15*24*3600;
  7217. $warehouse = $this->warehouse->read($value['warehouse']);
  7218. $rows[$key]['warehouse'] = $warehouse['title'];
  7219. $rows[$key]['number'] = $c;
  7220. $rows[$key]['features'] = $zh;
  7221. $rows[$key]['hb'] = $c+$zt;
  7222. }
  7223. $title = "导出库存数据及在途中数据".date('Y-m-d',time());
  7224. $titlename = "<table border=1>
  7225. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7226. <tr align='center'>
  7227. <td>仓库</td>
  7228. <td>SKU</td>
  7229. <td>产品</td>
  7230. <td>库存数量</td>
  7231. <td>在途数量及预达日期</td>
  7232. <td>在途+库存数量</td>
  7233. </tr>
  7234. </table>";
  7235. $filename = $title.".xls";
  7236. $tail = "";
  7237. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7238. }
  7239. if(isset($_GET['excel']))
  7240. {
  7241. $warehouse = $this->input->get('warehouse',true);
  7242. $sku = $this->input->get('sku',true);
  7243. $cz = $this->input->get('cz',true);
  7244. $text = $this->input->post('text',true);
  7245. $xztime = $this->input->get('xztime',true);
  7246. $timetk = $this->input->get('timetk',true);
  7247. $timetj = $this->input->get('timetj',true);
  7248. $timetk = strtotime($timetk);
  7249. $timetj = strtotime($timetj);
  7250. $where = "time = '0' ";
  7251. if($warehouse)
  7252. {
  7253. $where .= " and warehouse = '$warehouse'";
  7254. }
  7255. if($sku)
  7256. {
  7257. $where .= " and sku = '$sku'";
  7258. }
  7259. if($text)
  7260. {
  7261. $where .= " and text like '%$text%'";
  7262. }
  7263. if($cz != '')
  7264. {
  7265. $where .= " and cz = '$cz'";
  7266. }
  7267. if($timetk && $timetj)
  7268. {
  7269. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  7270. }
  7271. //数据排序
  7272. $order_str = $xztime." desc";
  7273. //取得信息列表
  7274. $zh = array();
  7275. $info_list = $this->whlabeltransport->find_all($where,'warehouse,sku,title,num,features,enter,stime,text');
  7276. foreach ($info_list as $v)
  7277. {
  7278. $c = $this->whlabel->find_count('state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');
  7279. $warehouse = $this->warehouse->read($v['warehouse']);
  7280. $v['warehouse'] = $warehouse['title'];
  7281. $v['enter'] = date('Y-m-d H:i:s',$v['enter']);
  7282. $v['stime'] = date('Y-m-d',$v['stime']);
  7283. if(isset($zh[$v['features']]))
  7284. {
  7285. $zh[$v['features']]['num'] += $v['num'];
  7286. }
  7287. else
  7288. {
  7289. $zh[$v['features']] = $v;
  7290. }
  7291. $zh[$v['features']]['features'] = $c;
  7292. }
  7293. $title = "在途数据".date('Y-m-d',time());
  7294. $titlename = "<table border=1>
  7295. <tr align='center'>
  7296. <td>仓库</td>
  7297. <td>SKU</td>
  7298. <td>名称</td>
  7299. <td>在途数量</td>
  7300. <td>库存数量</td>
  7301. <td>添加在途日期</td>
  7302. <td>预达日期</td>
  7303. <td>备注</td>
  7304. </tr>
  7305. </table>";
  7306. $filename = $title.".xls";
  7307. $tail = "";
  7308. $this->excel->get_fz2($zh,$titlename,$filename,$tail);
  7309. }
  7310. }
  7311. public function _fc()
  7312. {
  7313. $vip = 0;
  7314. if(isset($_SESSION['api']))
  7315. {
  7316. $user = $this->user->get_api($_SESSION['api']);
  7317. if($user['vip'] == 1)
  7318. {
  7319. $vip = 1;
  7320. }
  7321. }
  7322. else
  7323. {
  7324. header('Location: /');exit;
  7325. }
  7326. $post = $this->input->post(NULL, TRUE);
  7327. if(isset($post['page']))
  7328. {
  7329. $page = $this->input->post('page',true);
  7330. $perpage = $this->input->post('perpage',true);
  7331. $category = $this->input->post('category',true);
  7332. $size = $this->input->post('size',true);
  7333. $grade = $this->input->post('grade',true);
  7334. $color = $this->input->post('color',true);
  7335. $lowe = $this->input->post('lowe',true);
  7336. $sku = $this->input->post('sku');
  7337. $title = $this->input->post('title');
  7338. $warehouse = $this->input->post('warehouse',true);
  7339. $usa = $this->input->post('usa',true);
  7340. $purchase = $this->input->post('purchase',true);
  7341. $lacetype = $this->input->post('lacetype',true);
  7342. $haircap = $this->input->post('haircap',true);
  7343. $density = $this->input->post('density',true);
  7344. $details = $this->input->post('details',true);
  7345. $state = $this->input->post('state',true);
  7346. $ktime = $this->input->post('ktime',true);
  7347. $jtime = $this->input->post('jtime',true);
  7348. $ktime = strtotime($ktime);
  7349. $jtime = strtotime($jtime);
  7350. $where = "state = '11'";$gj = "";$ck = "";
  7351. if($lacetype)
  7352. {
  7353. $where .= " and features like '%-$lacetype-%'";
  7354. }
  7355. if($category)
  7356. {
  7357. $where .= " and features like '%-$category-%'";
  7358. }
  7359. if($size)
  7360. {
  7361. $where .= " and features like '%-$size-%'";
  7362. }
  7363. if($grade)
  7364. {
  7365. $where .= " and features like '%-$grade-%'";
  7366. }
  7367. if($color)
  7368. {
  7369. $where .= " and features like '%-$color-%'";
  7370. }
  7371. if($lowe)
  7372. {
  7373. $where .= " and features like '%-$lowe-%'";
  7374. }
  7375. if($haircap)
  7376. {
  7377. $where .= " and features like '%-$haircap-%'";
  7378. }
  7379. if($density)
  7380. {
  7381. $where .= " and features like '%-$density-%'";
  7382. }
  7383. if($usa)
  7384. {
  7385. if(!$warehouse)
  7386. {
  7387. $where .= " and (warehouse = '5' or warehouse = '8')";
  7388. }
  7389. }
  7390. if($warehouse)
  7391. {
  7392. $where .= " and warehouse = '$warehouse'";
  7393. }
  7394. if($details)
  7395. {
  7396. $where .= " and details = '$details'";
  7397. }
  7398. if($purchase)
  7399. {
  7400. $where .= " and purchase = '$purchase'";
  7401. }
  7402. if($state)
  7403. {
  7404. $where .= " and state = '$state'";
  7405. }
  7406. if($ktime && $jtime)
  7407. {
  7408. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7409. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7410. }
  7411. //数据排序
  7412. $order_str = "id desc";
  7413. if(empty($page))
  7414. {
  7415. $start = 0;
  7416. $perpage = 1;
  7417. }
  7418. else
  7419. {
  7420. $start = ($page - 1)*$perpage;
  7421. }
  7422. if($sku)
  7423. {
  7424. $sku = trim($sku,' ');
  7425. $sku = trim($sku,' ');
  7426. $where .= " and sku like '%$sku%'";
  7427. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7428. }
  7429. else if($title)
  7430. {
  7431. $title = trim($title,' ');
  7432. $title = trim($title,' ');
  7433. $where .= " and title like '%$title%'";
  7434. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7435. }
  7436. else
  7437. {
  7438. //$where .= " and time > '$ktime' and time < '$jtime'";
  7439. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7440. }
  7441. //取得信息列表
  7442. $rows = array();$list = array();
  7443. foreach ($info_list as $key=>$value)
  7444. {
  7445. $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'].'"');
  7446. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7447. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7448. $warehouse = $this->warehouse->read($value['warehouse']);
  7449. $info_list[$key]['warehouse'] = $warehouse['title'];
  7450. $info_list[$key]['number'] = $g;
  7451. $info_list[$key]['features'] = $x;
  7452. $info_list[$key]['x'] = $s;
  7453. }
  7454. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  7455. $pagenum = ceil($total/$perpage);
  7456. $over = $total-($start+$perpage);
  7457. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  7458. echo json_encode($rows);exit;
  7459. }
  7460. $this->data['vip'] = $vip;
  7461. $this->_Template('whlabel_fc',$this->data);
  7462. }
  7463. public function _fcmb()
  7464. {
  7465. $where = "sku != 'Preset'";
  7466. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title');
  7467. foreach ($rows as $k=>$v)
  7468. {
  7469. $warehouse = $this->warehouse->read($v['warehouse']);
  7470. $rows[$k]['warehouse'] = $warehouse['title'];
  7471. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "'.$v['warehouse'].'" and sku = "'.$v['sku'].'" and state = 11');
  7472. $rows[$k]['t'] = '';
  7473. $rows[$k]['n'] = '';
  7474. }
  7475. $title = "封货产品数据导入模板";
  7476. $titlename = "<table border=1>
  7477. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7478. <tr align='center'>
  7479. <td>仓库</td>
  7480. <td>SKU</td>
  7481. <td>产品</td>
  7482. <td>封存产品总数量</td>
  7483. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7484. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7485. </tr>
  7486. </table>";
  7487. $filename = $title.".xls";
  7488. $tail = "";
  7489. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7490. }
  7491. public function _fcexcel()
  7492. {
  7493. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7494. $config['upload_path'] = '.'.$dir ;
  7495. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7496. $config['allowed_types'] = 'xls|xlsx|csv';
  7497. $config['max_size'] = 10240;
  7498. $this->load->library('upload', $config);
  7499. $this->upload->initialize($config);
  7500. if ($this->upload->do_upload('userfile'))
  7501. {
  7502. $full_path = $dir.$this->upload->data('file_name');
  7503. $fileName = '.' . $full_path;
  7504. if (!file_exists($fileName))
  7505. {
  7506. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7507. }
  7508. else
  7509. {
  7510. libxml_use_internal_errors(true);
  7511. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7512. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7513. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7514. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7515. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7516. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7517. ++$column;//如果列数大于26行
  7518. $list = array();
  7519. for ($i = 2; $i <= $row; $i++) // 行数循环
  7520. {
  7521. $data = array();
  7522. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7523. {
  7524. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7525. }
  7526. $list[] = $data;
  7527. }
  7528. }
  7529. $i = 0;$j = 0;$ed = array();
  7530. foreach ($list as $key=>$value)
  7531. {
  7532. $time = time();
  7533. if($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4']))
  7534. {
  7535. continue;
  7536. }
  7537. $warehouse = $this->warehouse->get_title($value['0']);
  7538. $sku = $value['1'];
  7539. $type = $value['4'];//调整方式0扣减1删除
  7540. $num = $value['5'];//调整数量
  7541. //$text = $value['4'];//扣减说明
  7542. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7543. if(!$d)//如果没有这个SKU
  7544. {
  7545. $ed[] = array($sku.'-库存中不存在此SKU');
  7546. $j++;
  7547. continue;
  7548. }
  7549. if(!isset($warehouse['id']))
  7550. {
  7551. $ed[] = array($sku.'-仓库名错误!');
  7552. $j++;
  7553. continue;
  7554. }
  7555. if($type == 1 || $type == 2)//扣减库存
  7556. {
  7557. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and state = 11');
  7558. if(count($data) < abs($num))
  7559. {
  7560. $ed[] = array($sku.'-数量大于封存产品剩余数量!');
  7561. $j++;
  7562. continue;
  7563. }
  7564. if($type == 1)//转入库存
  7565. {
  7566. for($i=0;$i<abs($num);$i++)
  7567. {
  7568. $this->whlabel->save(array('state'=>0,'oldstate'=>11,'time'=>$time),$data[$i]['id']);
  7569. }
  7570. }
  7571. else if($type == 2)//删除
  7572. {
  7573. for($i=0;$i<abs($num);$i++)
  7574. {
  7575. $this->whlabel->remove($data[$i]['id']);
  7576. }
  7577. }
  7578. }
  7579. else if($type == 0)//增加库存
  7580. {
  7581. $post['sku'] = $d['sku'];
  7582. $post['shop'] = '';
  7583. $post['warehouse'] = $warehouse['id'];
  7584. $post['purchase'] = $d['purchase'];
  7585. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7586. $post['state'] = 11;
  7587. $post['title'] = $d['title'];
  7588. $post['number'] = $d['number'];
  7589. $post['features'] = $d['features'];
  7590. $post['enter'] = $time;
  7591. $post['time'] = $time;//操作时间
  7592. for($i=0;$i<$num;$i++)
  7593. {
  7594. $post['label'] = time().rand(100,999).$i;
  7595. $this->whlabel->insert($post);
  7596. }
  7597. }
  7598. sleep(1);//防止入库时间一样,需要延迟1秒
  7599. }
  7600. if($j > 0)
  7601. {
  7602. $tt = date('Ymd',time());
  7603. $title = '库存导入错误信息-'.$tt;
  7604. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7605. $tail = "\n";
  7606. $filename = $title.".xls";
  7607. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7608. $dir = '/data/excel/'.$time.'/';
  7609. $file_name = 'error_'.$time.rand(1000,9999);
  7610. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7611. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7612. fwrite($myfile,$ecl);
  7613. fclose($myfile);
  7614. $error = $dir.$file_name.'.xls';
  7615. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7616. }
  7617. else
  7618. {
  7619. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7620. }
  7621. }
  7622. }
  7623. public function _fcjxc($arg_array)
  7624. {
  7625. if(isset($_GET['excel']))
  7626. {
  7627. $category = $this->input->get('category',true);
  7628. $size = $this->input->get('size',true);
  7629. $grade = $this->input->get('grade',true);
  7630. $color = $this->input->get('color',true);
  7631. $lowe = $this->input->get('lowe',true);
  7632. $sku = $this->input->get('sku');
  7633. $title = $this->input->get('title');
  7634. $warehouse = $arg_array[0];
  7635. $usa = $this->input->get('usa',true);
  7636. $purchase = $this->input->get('purchase',true);
  7637. $lacetype = $this->input->get('lacetype',true);
  7638. $haircap = $this->input->get('haircap',true);
  7639. $density = $this->input->get('density',true);
  7640. $title = $this->input->get('title',true);
  7641. $state = $this->input->get('state',true);
  7642. $ktime = $this->input->get('ktime',true);
  7643. $jtime = $this->input->get('jtime',true);
  7644. $where = "state=11";$gj = "";$ck = "";
  7645. if($lacetype)
  7646. {
  7647. $where .= " and features like '%-$lacetype-%'";
  7648. }
  7649. if($category)
  7650. {
  7651. $where .= " and features like '%-$category-%'";
  7652. }
  7653. if($size)
  7654. {
  7655. $where .= " and features like '%-$size-%'";
  7656. }
  7657. if($grade)
  7658. {
  7659. $where .= " and features like '%-$grade-%'";
  7660. }
  7661. if($color)
  7662. {
  7663. $where .= " and features like '%-$color-%'";
  7664. }
  7665. if($lowe)
  7666. {
  7667. $where .= " and features like '%-$lowe-%'";
  7668. }
  7669. if($haircap)
  7670. {
  7671. $where .= " and features like '%-$haircap-%'";
  7672. }
  7673. if($density)
  7674. {
  7675. $where .= " and features like '%-$density-%'";
  7676. }
  7677. if($usa)
  7678. {
  7679. if(!$warehouse)
  7680. {
  7681. $where .= " and (warehouse = '5' or warehouse = '8')";
  7682. }
  7683. }
  7684. if($warehouse)
  7685. {
  7686. $where .= " and warehouse = '$warehouse'";
  7687. }
  7688. if($purchase)
  7689. {
  7690. $where .= " and purchase = '$purchase'";
  7691. }
  7692. if($state)
  7693. {
  7694. $where .= " and state = '$state'";
  7695. }
  7696. $order_str = "id desc";
  7697. if($sku)
  7698. {
  7699. $sku = trim($sku,' ');
  7700. $sku = trim($sku,' ');
  7701. $where .= " and sku like '%$sku%'";
  7702. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7703. }
  7704. else if($title)
  7705. {
  7706. $title = trim($title,' ');
  7707. $title = trim($title,' ');
  7708. $where .= " and title like '%$title%'";
  7709. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7710. }
  7711. else
  7712. {
  7713. //$where .= " and time > '$ktime' and time < '$jtime'";
  7714. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7715. }
  7716. //取得信息列表
  7717. $rows = array();$list = array();
  7718. foreach ($info_list as $key=>$value)
  7719. {
  7720. $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'].'"');
  7721. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7722. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7723. $rows[$key] = $value;
  7724. $warehouse = $this->warehouse->read($value['warehouse']);
  7725. $rows[$key]['warehouse'] = $warehouse['title'];
  7726. $rows[$key]['features'] = $g;
  7727. $rows[$key]['a'] = $x;
  7728. $rows[$key]['b'] = $s;
  7729. }
  7730. $title = "总统计表";
  7731. $titlename = "<table border=1>
  7732. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7733. <tr align='center'>
  7734. <td>仓库</td>
  7735. <td>SKU</td>
  7736. <td>产品名称</td>
  7737. <td>录入总量</td>
  7738. <td>取出总量</td>
  7739. <td>剩余总量</td>
  7740. </tr>
  7741. </table>";
  7742. $filename = $title.".xls";
  7743. $tail = "";
  7744. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7745. }
  7746. $vip = 0;
  7747. if(isset($_SESSION['api']))
  7748. {
  7749. $user = $this->user->get_api($_SESSION['api']);
  7750. if($user['vip'] == 1)
  7751. {
  7752. $vip = 1;
  7753. }
  7754. }
  7755. else
  7756. {
  7757. header('Location: /');exit;
  7758. }
  7759. $post = $this->input->post(NULL, TRUE);
  7760. if(isset($post['page']))
  7761. {
  7762. $page = $this->input->post('page',true);
  7763. $perpage = $this->input->post('perpage',true);
  7764. $category = $this->input->post('category',true);
  7765. $size = $this->input->post('size',true);
  7766. $grade = $this->input->post('grade',true);
  7767. $color = $this->input->post('color',true);
  7768. $lowe = $this->input->post('lowe',true);
  7769. $sku = $this->input->post('sku');
  7770. $title = $this->input->post('title');
  7771. $warehouse = $arg_array[0];
  7772. $usa = $this->input->post('usa',true);
  7773. $purchase = $this->input->post('purchase',true);
  7774. $lacetype = $this->input->post('lacetype',true);
  7775. $haircap = $this->input->post('haircap',true);
  7776. $density = $this->input->post('density',true);
  7777. $title = $this->input->post('title',true);
  7778. $state = $this->input->post('state',true);
  7779. $ktime = $this->input->post('ktime',true);
  7780. $jtime = $this->input->post('jtime',true);
  7781. $ktime = strtotime($ktime);
  7782. $jtime = strtotime($jtime);
  7783. $where = "state=11";$gj = "";$ck = "";
  7784. if($lacetype)
  7785. {
  7786. $where .= " and features like '%-$lacetype-%'";
  7787. }
  7788. if($category)
  7789. {
  7790. $where .= " and features like '%-$category-%'";
  7791. }
  7792. if($size)
  7793. {
  7794. $where .= " and features like '%-$size-%'";
  7795. }
  7796. if($grade)
  7797. {
  7798. $where .= " and features like '%-$grade-%'";
  7799. }
  7800. if($color)
  7801. {
  7802. $where .= " and features like '%-$color-%'";
  7803. }
  7804. if($lowe)
  7805. {
  7806. $where .= " and features like '%-$lowe-%'";
  7807. }
  7808. if($haircap)
  7809. {
  7810. $where .= " and features like '%-$haircap-%'";
  7811. }
  7812. if($density)
  7813. {
  7814. $where .= " and features like '%-$density-%'";
  7815. }
  7816. if($usa)
  7817. {
  7818. if(!$warehouse)
  7819. {
  7820. $where .= " and (warehouse = '5' or warehouse = '8')";
  7821. }
  7822. }
  7823. if($warehouse)
  7824. {
  7825. $where .= " and warehouse = '$warehouse'";
  7826. }
  7827. if($purchase)
  7828. {
  7829. $where .= " and purchase = '$purchase'";
  7830. }
  7831. if($state)
  7832. {
  7833. $where .= " and state = '$state'";
  7834. }
  7835. if($ktime && $jtime)
  7836. {
  7837. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7838. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7839. }
  7840. //数据排序
  7841. $order_str = "id desc";$xs=0;
  7842. $rows = array();$list = array();
  7843. if(empty($page))
  7844. {
  7845. $start = 0;
  7846. $perpage = 1;
  7847. }
  7848. else
  7849. {
  7850. $start = ($page - 1)*$perpage;
  7851. }
  7852. if($sku || $title)
  7853. {
  7854. if($title)
  7855. {
  7856. $title = trim($title,' ');
  7857. $title = trim($title,' ');
  7858. $where .= " and title like '%$title%'";
  7859. }
  7860. else
  7861. {
  7862. $sku = trim($sku,' ');
  7863. $sku = trim($sku,' ');
  7864. $where .= " and sku like '%$sku%'";
  7865. }
  7866. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7867. foreach ($info_list as $key=>$value)
  7868. {
  7869. $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'].'"');
  7870. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7871. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7872. $rows[$key] = $value;
  7873. $warehouse = $this->warehouse->read($value['warehouse']);
  7874. $rows[$key]['warehouse'] = $warehouse['title'];
  7875. $rows[$key]['features'] = $g;
  7876. $rows[$key]['a'] = $x;
  7877. $rows[$key]['b'] = $s;
  7878. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7879. $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天销量
  7880. $yj = $c/($xl/30);
  7881. if($yj < 7)
  7882. {
  7883. $rows[$key]['y'] = round($yj).'天销量';
  7884. }
  7885. else
  7886. {
  7887. $rows[$key]['y'] = '正常';
  7888. }
  7889. }
  7890. }
  7891. else
  7892. {
  7893. //$where .= " and time > '$ktime' and time < '$jtime'";
  7894. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7895. foreach ($info_list as $key=>$value)
  7896. {
  7897. $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'].'"');
  7898. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7899. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7900. $zs[$key] = $value;
  7901. $warehouse = $this->warehouse->read($value['warehouse']);
  7902. $zs[$key]['warehouse'] = $warehouse['title'];
  7903. $zs[$key]['features'] = $g;
  7904. $zs[$key]['a'] = $x;
  7905. $zs[$key]['b'] = $s;
  7906. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7907. $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天销量
  7908. $yj = $c/($xl/30);
  7909. if($yj < 7)
  7910. {
  7911. $zs[$key]['y'] = round($yj).'天销量';
  7912. $rows[$key] = $zs[$key];
  7913. }
  7914. }
  7915. }
  7916. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id'));
  7917. $pagenum = ceil($total/$perpage);
  7918. $over = $total-($start+$perpage);
  7919. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
  7920. echo json_encode($rows);exit;
  7921. }
  7922. $this->data['arg_array'] = $arg_array[0];
  7923. $this->_Template('whlabel_fcjxc',$this->data);
  7924. }
  7925. public function _0kcdel()
  7926. {
  7927. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7928. $config['upload_path'] = '.'.$dir ;
  7929. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7930. $config['allowed_types'] = 'xls|xlsx|csv';
  7931. $config['max_size'] = 10240;
  7932. $this->load->library('upload', $config);
  7933. $this->upload->initialize($config);
  7934. if ($this->upload->do_upload('userfile'))
  7935. {
  7936. $full_path = $dir.$this->upload->data('file_name');
  7937. $fileName = '.' . $full_path;
  7938. if (!file_exists($fileName))
  7939. {
  7940. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7941. }
  7942. else
  7943. {
  7944. require_once "./data/excel/PHPExcel/IOFactory.php";
  7945. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7946. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7947. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7948. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7949. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7950. ++$column;//如果列数大于26行
  7951. $list = array();
  7952. for ($i = 2; $i <= $row; $i++) // 行数循环
  7953. {
  7954. $data = array();
  7955. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7956. {
  7957. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7958. }
  7959. $list[] = $data;
  7960. }
  7961. }
  7962. $i = 0;$j = 0;$ed = array();
  7963. foreach ($list as $key=>$value)
  7964. {
  7965. $time = time();
  7966. if($value['0'] == "" || $value['1'] == "")
  7967. {
  7968. continue;
  7969. }
  7970. $warehouse = $this->warehouse->get_title($value['0']);
  7971. $sku = $value['1'];
  7972. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7973. if(!$d)//如果没有这个SKU
  7974. {
  7975. $ed[] = array($sku.'-库存中不存在此SKU');
  7976. $j++;
  7977. continue;
  7978. }
  7979. if(!isset($warehouse['id']))
  7980. {
  7981. $ed[] = array($sku.'-仓库名错误!');
  7982. $j++;
  7983. continue;
  7984. }
  7985. $z = $this->whlabel->find_count('sku = "'.$sku.'" and zd = "" and state = 0 and warehouse = "'.$warehouse['id'].'"');
  7986. if($z < 1)
  7987. {
  7988. $z = $this->whlabel->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'"');
  7989. foreach ($z as $v)
  7990. {
  7991. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  7992. if(count($zt) > 0)
  7993. {
  7994. $ed[] = array($sku.'-有在途库存无法删除!');
  7995. $j++;
  7996. continue;
  7997. }
  7998. $this->whlabel->remove($v['id']);
  7999. }
  8000. }
  8001. else
  8002. {
  8003. $ed[] = array($sku.'-非0库存!');
  8004. $j++;
  8005. continue;
  8006. }
  8007. }
  8008. if($j > 0)
  8009. {
  8010. $tt = date('Ymd',time());
  8011. $title = '删除0库存错误信息-'.$tt;
  8012. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  8013. $tail = "\n";
  8014. $filename = $title.".xls";
  8015. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  8016. $dir = '/data/excel/'.$time.'/';
  8017. $file_name = 'error_'.$time.rand(1000,9999);
  8018. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  8019. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  8020. fwrite($myfile,$ecl);
  8021. fclose($myfile);
  8022. $error = $dir.$file_name.'.xls';
  8023. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  8024. }
  8025. else
  8026. {
  8027. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  8028. }
  8029. }
  8030. }
  8031. public function _gbhtype()
  8032. {
  8033. $post = $this->input->post(NULL, TRUE);
  8034. if(isset($post['s']))
  8035. {
  8036. $n = $this->input->post('n');
  8037. $d = $this->input->post('s');
  8038. if(!$d)
  8039. {
  8040. echo json_encode(array('msg'=>'未选择需要更改的商品','success'=>false));exit;
  8041. }
  8042. $d = explode(',',trim($d,','));
  8043. $t = $this->whlabel_type->read($n);
  8044. //循环删除记录
  8045. foreach ($d as $v)
  8046. {
  8047. $u = $this->whlabel->read($v);
  8048. $data = $this->whlabel->find_all("sku = '".$u['sku']."' and purchase = '".$u['purchase']."' and features = '".$u['features']."' and warehouse = '".$u['warehouse']."'");
  8049. foreach ($data as $val)
  8050. {
  8051. $this->whlabel->save(array('type'=>$n),$val['id']);
  8052. }
  8053. }
  8054. echo json_encode(array('d'=>$d,'t'=>$t['title'],'msg'=>'修改成功!','success'=>true));
  8055. }
  8056. }
  8057. //出库、退库导出
  8058. public function _dccrtype()
  8059. {
  8060. $classid = $this->classid->sku();
  8061. $pm = $classid;
  8062. $typeclass = array();
  8063. $tc = $this->typeclass->find_all();
  8064. foreach ($tc as $v)
  8065. {
  8066. $typeclass[$v['id']] = $v;
  8067. }
  8068. $prc = array();
  8069. $purchase = $this->purchase->find_all();
  8070. foreach($purchase as $k=>$v)
  8071. {
  8072. $prc[$v['id']] = $v['title'];
  8073. }
  8074. if(isset($_GET['sid']))
  8075. {
  8076. $wh = array();
  8077. $w = $this->warehouse->find_all('1=1','id,title');
  8078. foreach ($w as $v)
  8079. {
  8080. $wh[$v['id']] = $v['title'];
  8081. }
  8082. $type = $this->input->get('excel',true);
  8083. $category = $this->input->get('category',true);
  8084. $size = $this->input->get('size',true);
  8085. $grade = $this->input->get('grade',true);
  8086. $color = $this->input->get('color',true);
  8087. $lowe = $this->input->get('lowe',true);
  8088. $sku = $this->input->get('sku',true);
  8089. $warehouse = $this->input->get('warehouse',true);
  8090. $lacetype = $this->input->get('lacetype',true);
  8091. $lacecolor = $this->input->get('lacecolor',true);
  8092. $density = $this->input->get('density',true);
  8093. $haircap = $this->input->get('haircap',true);
  8094. $purchase = $this->input->get('purchase',true);
  8095. $title = $this->input->get('title',true);
  8096. $state = $this->input->get('state',true);
  8097. $sid = $this->input->get('sid',true);
  8098. $ktime = $this->input->get('ktime',true);
  8099. $jtime = $this->input->get('jtime',true);
  8100. $ktime = strtotime($ktime);
  8101. $jtime = strtotime($jtime);
  8102. $where = "1=1";$gj = "";$ck = "";
  8103. if($category)
  8104. {
  8105. $where .= " and features like '%-$category-%'";
  8106. }
  8107. if($size)
  8108. {
  8109. $where .= " and features like '%-$size-%'";
  8110. }
  8111. if($grade)
  8112. {
  8113. $where .= " and features like '%-$grade-%'";
  8114. }
  8115. if($color)
  8116. {
  8117. $where .= " and features like '%-$color-%'";
  8118. }
  8119. if($lowe)
  8120. {
  8121. $where .= " and features like '%-$lowe-%'";
  8122. }
  8123. if($warehouse)
  8124. {
  8125. $where .= " and warehouse = '$warehouse'";
  8126. }
  8127. if($purchase)
  8128. {
  8129. $where .= " and purchase = '$purchase'";
  8130. }
  8131. if($state)
  8132. {
  8133. $where .= " and state = '$state'";
  8134. }
  8135. if($lacetype)
  8136. {
  8137. $where .= " and features like '%-$lacetype-%'";
  8138. }
  8139. if($lacecolor)
  8140. {
  8141. $where .= " and features like '%-$lacecolor-%'";
  8142. }
  8143. if($density)
  8144. {
  8145. $where .= " and features like '%-$density-%'";
  8146. }
  8147. if($haircap)
  8148. {
  8149. $where .= " and features like '%-$haircap-%'";
  8150. }
  8151. if($title)
  8152. {
  8153. $title = trim($title,' ');
  8154. $title = trim($title,' ');
  8155. $where .= " and title like '%$title%'";
  8156. }
  8157. if($sku)
  8158. {
  8159. $sku = trim($sku,' ');
  8160. $sku = trim($sku,' ');
  8161. $where .= " and sku like '%$sku%'";
  8162. }
  8163. if($ktime && $jtime)
  8164. {
  8165. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8166. }
  8167. $sidwhere = '';
  8168. if($sid)
  8169. {
  8170. $sd = "";
  8171. $s = explode(',',trim($sid,','));
  8172. foreach ($s as $value)
  8173. {
  8174. $sd .= " id = ".$value." or";
  8175. }
  8176. $sidwhere = " and (".rtrim($sd,'or').")";
  8177. }
  8178. //数据排序
  8179. $order_str = "time desc";
  8180. if(empty($page))
  8181. {
  8182. $start = 0;
  8183. $perpage = 1;
  8184. }
  8185. else
  8186. {
  8187. $start = ($page - 1)*$perpage;
  8188. }
  8189. $wh = array();
  8190. $w = $this->warehouse->find_all('1=1','id,title');
  8191. foreach ($w as $v)
  8192. {
  8193. $wh[$v['id']] = $v['title'];
  8194. }
  8195. $wt = array();
  8196. $whlabel_type = $this->whlabel_type->find_all();
  8197. foreach ($whlabel_type as $v)
  8198. {
  8199. $wt[$v['id']] = $v['title'];
  8200. }
  8201. $classid = $this->classid->sku();
  8202. $list = array();
  8203. $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');
  8204. foreach ($rows_r as $key=>$value)
  8205. {
  8206. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8207. $pm = $classid;
  8208. $jm = $classid;
  8209. $rows_r[$key]['enter'] = '入库';
  8210. $rows_r[$key]['time'] = $value['enter'];
  8211. if($value['rktype'] == 1)
  8212. {
  8213. $rows_r[$key]['rktype'] = '采购入库';
  8214. }
  8215. else if($value['rktype'] == 2)
  8216. {
  8217. $rows_r[$key]['rktype'] = '盘盈调整';
  8218. }
  8219. else if($value['rktype'] == 3)
  8220. {
  8221. $rows_r[$key]['rktype'] = '其他调整入库';
  8222. }
  8223. else if($value['rktype'] == 4)
  8224. {
  8225. $rows_r[$key]['rktype'] = '其他调整入库';
  8226. }
  8227. else if($value['rktype'] == 5)
  8228. {
  8229. $rows_r[$key]['rktype'] = '退库入库';
  8230. }
  8231. else if($value['rktype'] == 6)
  8232. {
  8233. $rows_r[$key]['rktype'] = '退货可用入库';
  8234. }
  8235. else if($value['rktype'] == 7)
  8236. {
  8237. $rows_r[$key]['rktype'] = '形态转换入库';
  8238. }
  8239. else
  8240. {
  8241. $rows_r[$key]['rktype'] = '';
  8242. }
  8243. $features = explode('-',trim($value['features'],'-'));
  8244. foreach($features as $v)
  8245. {
  8246. if(isset($typeclass[$v]))
  8247. {
  8248. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8249. $pm[$typeclass[$v]['classid']] = $zh[0];
  8250. }
  8251. if(isset($typeclass[$v]))
  8252. {
  8253. if(isset($jm[$typeclass[$v]['classid']]))
  8254. {
  8255. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8256. }
  8257. }
  8258. }
  8259. $zh = implode(" ",$pm);
  8260. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8261. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8262. $rows_r[$key]['zh'] = $zh;
  8263. $jm = array_filter($jm);
  8264. $rows_r[$key]['features'] = implode("-",$jm);
  8265. $rows_r[$key]['number'] = $this->whlabel->find_count($where." and enter = '".$value['enter']."' ".$sidwhere);
  8266. }
  8267. $rows_c = $this->whlabel->find_all($where." and outk > '$ktime' and outk < '$jtime' ".$sidwhere,'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  8268. foreach ($rows_c as $key=>$value)
  8269. {
  8270. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8271. $pm = $classid;
  8272. $jm = $classid;
  8273. $rows_c[$key]['time'] = $value['outk'];
  8274. $rows_c[$key]['outk'] = '出库';
  8275. if($value['cktype'] == 1)
  8276. {
  8277. $rows_c[$key]['cktype'] = '销售出库';
  8278. }
  8279. else if($value['cktype'] == 2)
  8280. {
  8281. $rows_c[$key]['cktype'] = '销售美国出库';
  8282. }
  8283. else if($value['cktype'] == 3)
  8284. {
  8285. $rows_c[$key]['cktype'] = '盘亏调整';
  8286. }
  8287. else if($value['cktype'] == 4)
  8288. {
  8289. $rows_c[$key]['cktype'] = '其他调整出库';
  8290. }
  8291. else if($value['cktype'] == 5)
  8292. {
  8293. $rows_c[$key]['cktype'] = '形态转换出库';
  8294. }
  8295. else
  8296. {
  8297. $rows_c[$key]['cktype'] = '';
  8298. }
  8299. $features = explode('-',trim($value['features'],'-'));
  8300. foreach($features as $v)
  8301. {
  8302. if(isset($typeclass[$v]))
  8303. {
  8304. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8305. $pm[$typeclass[$v]['classid']] = $zh[0];
  8306. }
  8307. if(isset($typeclass[$v]))
  8308. {
  8309. if(isset($jm[$typeclass[$v]['classid']]))
  8310. {
  8311. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8312. }
  8313. }
  8314. }
  8315. $zh = implode(" ",$pm);
  8316. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8317. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8318. $rows_c[$key]['zh'] = $zh;
  8319. $jm = array_filter($jm);
  8320. $rows_c[$key]['features'] = implode("-",$jm);
  8321. $rows_c[$key]['number'] = 1;
  8322. }
  8323. $merged = $rows_r;
  8324. foreach ($rows_c as $key => $value)
  8325. {
  8326. if (isset($merged[$key]))
  8327. {
  8328. $merged[] = $value;
  8329. }
  8330. else
  8331. {
  8332. $merged[$key] = $value;
  8333. }
  8334. }
  8335. usort($merged, function($a, $b)
  8336. {
  8337. return $a['time'] - $b['time'];
  8338. });
  8339. foreach ($merged as $key=>$value)
  8340. {
  8341. $merged[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  8342. }
  8343. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime);
  8344. $titlename = "<table border=1>
  8345. <tr align='center'>
  8346. <td>仓库</td>
  8347. <td>SKU</td>
  8348. <td>商品名称</td>
  8349. <td>仓库品名</td>
  8350. <td>料号</td>
  8351. <td>时间</td>
  8352. <td>操作</td>
  8353. <td>类型</td>
  8354. <td>数量</td>
  8355. <td>备注</td>
  8356. </tr>
  8357. </table>";
  8358. $filename = $title.".xlsx";
  8359. $tail = "";
  8360. $this->excel->get_fz2($merged,$titlename,$filename,$tail);
  8361. }
  8362. }
  8363. }