Whlabel.php 291 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. } else if ($arg == 'summary') //汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. } else if ($arg == 'manifest') //usps发货清单
  144. {
  145. $this->_manifest();
  146. } else if ($arg == 'abnormal') //占单异常
  147. {
  148. $this->_abnormal();
  149. } else if ($arg == 'error') //0库存SKU
  150. {
  151. $this->_error();
  152. } else if ($arg == 'errorexcel') //0库存SKU导出
  153. {
  154. $this->_errorexcel();
  155. } else if ($arg == 'db') {
  156. $this->_db();
  157. } else if ($arg == 'dbrk') {
  158. $this->_dbrk();
  159. } else if ($arg == 'whlabelczdc') {
  160. $this->_whlabelczdc();
  161. } else if ($arg == 'print') {
  162. $this->_print($arg_array);
  163. } else if ($arg == 'usaprint') {
  164. $this->_usaprint($arg_array);
  165. } else if ($arg == 'printck') {
  166. $this->_printck($arg_array);
  167. } else if ($arg == 'printrk') {
  168. $this->_printrk($arg_array);
  169. } else if ($arg == 'printxzrk') {
  170. $this->_printxzrk($arg_array);
  171. } else if ($arg == 'printexcel') {
  172. $this->_printexcel($arg_array);
  173. } else if ($arg == 'uck') {
  174. $this->_uck();
  175. } else if ($arg == 'whlabelexcelzh') {
  176. $this->_whlabelexcelzh();
  177. } else if ($arg == 'fc') {
  178. $this->_fc();
  179. } else if ($arg == 'fcmb') {
  180. $this->_fcmb();
  181. } else if ($arg == 'fcexcel') {
  182. $this->_fcexcel();
  183. } else if ($arg == 'fcjxc') {
  184. $this->_fcjxc($arg_array);
  185. } else if ($arg == '0kcdel') {
  186. $this->_0kcdel(); //导表删除0库存
  187. } else if ($arg == 'gbhtype') {
  188. $this->_gbhtype(); //更改备货状态
  189. } else if($arg == 'excelrjs'){
  190. $this->_excelrjs();
  191. } else if($arg == 'excelctjs'){
  192. $this->_excelctjs();
  193. }else if ($arg == 'exceljxcjs') //进销存信息导出
  194. {
  195. $this->_exceljxcjs();
  196. } else if ($arg == 'summaryjs') //汇总导出
  197. {
  198. $this->_summaryjs($arg_array);
  199. }else if($arg == "w_t_cs"){
  200. $this->_w_t_cs(); //首页
  201. }else {
  202. $this->_index();
  203. }
  204. }
  205. public function _w_t_cs(){
  206. $vip = 0;
  207. if (isset($_SESSION['api'])) {
  208. $user = $this->user->get_api($_SESSION['api']);
  209. $fgshop = "";
  210. $sid = "";
  211. $usersp = explode('|', trim($user['shop'], '|'));
  212. foreach ($usersp as $value) {
  213. $fgshop .= " shop = " . $value . " or";
  214. $sid .= " id = " . $value . " or";
  215. }
  216. if ($user['vip'] == 1) {
  217. $vip = 1;
  218. }
  219. } else {
  220. header('Location: /');
  221. exit;
  222. }
  223. $prc = array();
  224. $purchase = $this->purchase->find_all();
  225. foreach ($purchase as $k => $v) {
  226. $prc[$v['id']] = $v['title'];
  227. }
  228. $company = array();
  229. $ct = $this->company->find_all();
  230. foreach ($ct as $k => $v) {
  231. $company[$v['id']] = $v['title'];
  232. }
  233. $sp = array();
  234. $s = $this->shop->find_all('1=1', 'id,shopname');
  235. foreach ($s as $v) {
  236. $sp[$v['id']] = $v['shopname'];
  237. }
  238. $wh = array();
  239. $w = $this->warehouse->find_all('1=1', 'id,title');
  240. foreach ($w as $v) {
  241. $wh[$v['id']] = $v['title'];
  242. }
  243. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  244. $this->data['shop'] = $wlshop;
  245. $this->data['vip'] = $vip;
  246. $this->_Template('whlabel_typejs', $this->data);
  247. }
  248. //管理
  249. public function _index()
  250. {
  251. $post = $this->input->post(NULL, TRUE);
  252. if (isset($post['page'])) {
  253. $page = $this->input->post('page', true);
  254. $perpage = $this->input->post('perpage', true);
  255. $sku = $this->input->post('sku', true);
  256. $number = $this->input->post('number', true);
  257. $warehouse = $this->input->post('warehouse', true);
  258. $purchase = $this->input->post('purchase', true);
  259. $orderinfo = $this->input->post('orderinfo', true);
  260. $waybill = $this->input->post('waybill', true);
  261. $category = $this->input->post('category', true);
  262. $size = $this->input->post('size', true);
  263. $grade = $this->input->post('grade', true);
  264. $color = $this->input->post('color', true);
  265. $lowe = $this->input->post('lowe', true);
  266. $state = $this->input->post('state', true);
  267. $label = $this->input->post('label', true);
  268. $timetk = $this->input->post('timetkk', true);
  269. $timetj = $this->input->post('timetjj', true);
  270. $timetk = strtotime($timetk);
  271. $timetj = strtotime($timetj);
  272. $where = "1=1 ";
  273. if ($timetk && $timetj) {
  274. $where .= " and time > '$timetk' and time < '$timetj'";
  275. }
  276. if ($sku) {
  277. $where .= " and sku = '$sku'";
  278. }
  279. if ($number) {
  280. $where .= " and number = '$number'";
  281. }
  282. if ($warehouse) {
  283. $where .= " and warehouse = '$warehouse'";
  284. }
  285. if ($purchase) {
  286. $where .= " and purchase = '$purchase'";
  287. }
  288. if ($orderinfo) {
  289. $where .= " and orderinfo = '$orderinfo'";
  290. }
  291. if ($waybill) {
  292. $where .= " and waybill = '$waybill'";
  293. }
  294. if ($category) {
  295. $where .= " and features like '%-$category-%'";
  296. }
  297. if ($size) {
  298. $where .= " and features like '%-$size-%'";
  299. }
  300. if ($grade) {
  301. $where .= " and features like '%-$grade-%'";
  302. }
  303. if ($color) {
  304. $where .= " and features like '%-$color-%'";
  305. }
  306. if ($lowe) {
  307. $where .= " and features like '%-$lowe-%'";
  308. }
  309. if ($label) {
  310. $where .= " and label = '$label'";
  311. }
  312. if ($state != '') {
  313. $where .= " and state = '$state'";
  314. }
  315. //数据排序
  316. $order_str = "time desc";
  317. if (empty($page)) {
  318. $start = 0;
  319. $perpage = 1;
  320. } else {
  321. $start = ($page - 1) * $perpage;
  322. }
  323. //取得信息列表
  324. $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);
  325. foreach ($info_list as $key => $value) {
  326. $warehouse = $this->warehouse->read($value['warehouse']);
  327. $info_list[$key]['warehouse'] = $warehouse['title'];
  328. $purchase = $this->purchase->read($value['purchase']);
  329. $info_list[$key]['purchase'] = $purchase['title'];
  330. if ($value['enter'] != 0) {
  331. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  332. } else {
  333. $info_list[$key]['enter'] = "";
  334. }
  335. if ($value['outk'] != 0) {
  336. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  337. } else {
  338. $info_list[$key]['outk'] = "";
  339. }
  340. if ($value['printing'] != 0) {
  341. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  342. } else {
  343. $info_list[$key]['printing'] = "";
  344. }
  345. if ($value['orderinfo'] == 0) {
  346. $info_list[$key]['orderinfo'] = "";
  347. }
  348. if ($value['waybill'] == 0) {
  349. $info_list[$key]['waybill'] = "";
  350. }
  351. if ($value['state'] == 0) {
  352. $info_list[$key]['state'] = "在库";
  353. } else if ($value['state'] == 1) {
  354. $info_list[$key]['state'] = "出库";
  355. } else if ($value['state'] == 2) {
  356. $info_list[$key]['state'] = "退库";
  357. } else if ($value['state'] == 3) {
  358. $info_list[$key]['state'] = "调拨中";
  359. } else if ($value['state'] == 4) {
  360. $info_list[$key]['state'] = "再加工";
  361. } else if ($value['state'] == 5) {
  362. $info_list[$key]['state'] = "维修中";
  363. } else if ($value['state'] == 6) {
  364. $info_list[$key]['state'] = "盘亏";
  365. } else if ($value['state'] == 7) {
  366. $info_list[$key]['state'] = "更换标签";
  367. } else if ($value['state'] == 8) {
  368. $info_list[$key]['state'] = "其它";
  369. } else if ($value['state'] == 9) {
  370. $info_list[$key]['state'] = "预设";
  371. } else if ($value['state'] == 10) {
  372. $info_list[$key]['state'] = "美店零售";
  373. }
  374. if ($value['text'] == "") {
  375. $info_list[$key]['text'] = "";
  376. }
  377. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  378. }
  379. $total = $this->whlabel->find_count($where);
  380. $pagenum = ceil($total / $perpage);
  381. $over = $total - ($start + $perpage);
  382. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  383. echo json_encode($rows);
  384. exit;
  385. }
  386. if (isset($post['outsku'])) {
  387. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  388. $cz = $this->input->post('cz', true);
  389. if ($cz == '1') {
  390. $sku = $this->input->post('outsku', true);
  391. if ($sku) {
  392. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  393. if (count($data) < 1) {
  394. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  395. exit;
  396. }
  397. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  398. echo json_encode(array('success' => true));
  399. exit;
  400. }
  401. } else {
  402. echo json_encode(array('msg' => '此方法禁用!', 'success' => false));
  403. exit;
  404. $sku = $this->input->post('outsku', true);
  405. if ($sku) {
  406. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  407. if (count($data) < 1) {
  408. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  409. exit;
  410. }
  411. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  412. echo json_encode(array('success' => true));
  413. exit;
  414. }
  415. }
  416. }
  417. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  418. $this->_Template('whlabel', $this->data);
  419. }
  420. //在库标签
  421. public function _existence()
  422. {
  423. $post = $this->input->post(NULL, TRUE);
  424. if (isset($post['s'])) {
  425. $id_arr = $this->input->post('s');
  426. $id_arr = explode(',', $id_arr);
  427. if (!$id_arr) {
  428. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  429. exit;
  430. }
  431. //循环删除记录
  432. foreach ($id_arr as $v) {
  433. $sid = $this->whlabel->read($v);
  434. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  435. if ($count > 0) {
  436. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  437. exit;
  438. }
  439. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  440. if (count($zt) > 0) {
  441. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  442. exit;
  443. }
  444. $this->whlabel->remove($v);
  445. }
  446. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  447. exit;
  448. }
  449. if (isset($post['page'])) {
  450. $page = $this->input->post('page', true);
  451. $perpage = $this->input->post('perpage', true);
  452. $warehouse = $this->input->post('warehouse', true);
  453. $label = $this->input->post('label', true);
  454. $where = "1=1 and state = 0";
  455. if ($warehouse) {
  456. $where .= " and warehouse = '$warehouse'";
  457. }
  458. if ($label) {
  459. $where .= " and label = '$label'";
  460. }
  461. //数据排序
  462. $order_str = "time asc";
  463. if (empty($page)) {
  464. $start = 0;
  465. $perpage = 1;
  466. } else {
  467. $start = ($page - 1) * $perpage;
  468. }
  469. //取得信息列表
  470. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  471. foreach ($info_list as $key => $value) {
  472. if ($value['enter'] != 0) {
  473. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  474. } else {
  475. $info_list[$key]['enter'] = "";
  476. }
  477. if ($value['printing'] != 0) {
  478. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  479. } else {
  480. $info_list[$key]['printing'] = "";
  481. }
  482. }
  483. $total = $this->whlabel->find_count($where);
  484. $pagenum = ceil($total / $perpage);
  485. $over = $total - ($start + $perpage);
  486. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  487. echo json_encode($rows);
  488. exit;
  489. }
  490. $this->_Template('whlabel_existence', $this->data);
  491. }
  492. //进销存浏览
  493. public function _typedy($arg_array)
  494. {
  495. $prc = array();
  496. $purchase = $this->purchase->find_all();
  497. foreach ($purchase as $k => $v) {
  498. $prc[$v['id']] = $v['title'];
  499. }
  500. $post = $this->input->post(NULL, TRUE);
  501. if (isset($post['page'])) {
  502. $page = $this->input->post('page', true);
  503. $perpage = $this->input->post('perpage', true);
  504. $category = $this->input->post('category', true);
  505. $size = $this->input->post('size', true);
  506. $grade = $this->input->post('grade', true);
  507. $color = $this->input->post('color', true);
  508. $lowe = $this->input->post('lowe', true);
  509. $sku = $this->input->post('sku');
  510. $title = $this->input->post('title');
  511. $warehouse = $this->input->post('warehouse', true);
  512. $usa = $this->input->post('usa', true);
  513. $purchase = $this->input->post('purchase', true);
  514. $lacetype = $this->input->post('lacetype', true);
  515. $haircap = $this->input->post('haircap', true);
  516. $density = $this->input->post('density', true);
  517. $details = $this->input->post('details', true);
  518. $state = $this->input->post('state', true);
  519. $lacecolor = $this->input->post('lacecolor', true);
  520. $hairnumber = $this->input->post('hairnumber', true);
  521. $cklx = $this->input->post('cklx', true);
  522. $ktime = $this->input->post('ktime', true);
  523. $jtime = $this->input->post('jtime', true);
  524. $sm = $this->input->post('sm', true);
  525. $cpbz = $this->input->post('cpbz', true);
  526. $type = $this->input->post('type', true);
  527. $ktime = strtotime($ktime);
  528. $jtime = strtotime($jtime);
  529. $where = "1=1";
  530. $gj = "";
  531. $ck = "";
  532. if ($usa) {
  533. if (!$warehouse) {
  534. $where .= " and (warehouse = '5' or warehouse = '8')";
  535. }
  536. }
  537. if ($warehouse) {
  538. $where .= " and warehouse = '$warehouse'";
  539. }
  540. if ($details) {
  541. $where .= " and details = '$details'";
  542. }
  543. if ($purchase) {
  544. $where .= " and purchase = '$purchase'";
  545. }
  546. if (isset($state)) {
  547. if($state >-1){
  548. $where .= " and state = '$state'";
  549. }
  550. }
  551. if ($lacetype) {
  552. $where .= " and features like '%-$lacetype-%'";
  553. }
  554. if ($category) {
  555. $where .= " and features like '%-$category-%'";
  556. }
  557. if ($size) {
  558. $where .= " and features like '%-$size-%'";
  559. }
  560. if ($grade) {
  561. $where .= " and features like '%-$grade-%'";
  562. }
  563. if ($color) {
  564. $where .= " and features like '%-$color-%'";
  565. }
  566. if ($lowe) {
  567. $where .= " and features like '%-$lowe-%'";
  568. }
  569. if ($haircap) {
  570. $where .= " and features like '%-$haircap-%'";
  571. }
  572. if ($density) {
  573. $where .= " and features like '%-$density-%'";
  574. }
  575. if ($lacecolor) {
  576. $where .= " and features like '%-$lacecolor-%'";
  577. }
  578. if($sm){
  579. $where .= " and sm like '%".$sm."%'";
  580. }
  581. if($cpbz){
  582. $where .= " and cpbz like '%".$cpbz."%'";
  583. }
  584. if($type){
  585. $where .= " and type = ".$type."";
  586. }
  587. if (!empty($hairnumber)) {
  588. $where .= " and features like '%-128-%' ";
  589. if ($hairnumber < 0) {
  590. $class_list = $this->typeclass->find_all('classid = 43');
  591. foreach ($class_list as $v) {
  592. $where .= " and features not like '%-" . $v['id'] . "-%'";
  593. }
  594. } else {
  595. $where .= " and features like '%-$hairnumber-%'";
  596. }
  597. }
  598. $where_add = '';
  599. if ($cklx) {
  600. $shop = $this->shop->read($cklx);
  601. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  602. }
  603. if ($ktime && $jtime) {
  604. $gj = " and enter > '$ktime' and enter < '$jtime'";
  605. $ck = " and outk > '$ktime' and outk < '$jtime'";
  606. }
  607. //数据排序
  608. $order_str = "id desc";
  609. if (empty($page)) {
  610. $start = 0;
  611. $perpage = 1;
  612. } else {
  613. $start = ($page - 1) * $perpage;
  614. }
  615. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  616. if ($sku) {
  617. $sku = trim($sku, ' ');
  618. $sku = trim($sku, ' ');
  619. $where .= " and sku like '%$sku%'";
  620. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  621. } else if ($title) {
  622. $title = trim($title, ' ');
  623. $title = trim($title, ' ');
  624. $where .= " and title like '%$title%'";
  625. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  626. } else {
  627. //$where .= " and time > '$ktime' and time < '$jtime'";
  628. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  629. }
  630. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  631. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  632. foreach ($info_list as $k => $v) {
  633. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  634. unset($info_list[$k]['pm']);
  635. unset($info_list[$k]['jm']);
  636. unset($info_list[$k]['bm']);
  637. }
  638. //取得信息列表
  639. $rows = array();
  640. $list = array();
  641. foreach ($info_list as $key => $value) {
  642. $warehouse = $this->warehouse->read($value['warehouse']);
  643. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  644. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  645. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  646. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  647. $info_list[$key]['label'] = $value['sm'];
  648. $number = $value['number'];
  649. $ftime = time() - 15 * 24 * 3600;
  650. $info_list[$key]['warehouse'] = $warehouse['title'];
  651. $info_list[$key]['features'] = count($c);
  652. $z = count($z); //查看订单号
  653. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  654. $ztdata = '';
  655. if (count($zt) > 0) {
  656. foreach ($zt as $vv) {
  657. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  658. }
  659. }
  660. $info_list[$key]['number'] = $ztdata;
  661. $info_list[$key]['sm'] = $z;
  662. $details = array();
  663. $cpid = array();
  664. foreach ($c as $k => $v) {
  665. $details[$v['details']] = $v['details'];
  666. if ($v['cpid'] != 0) {
  667. $cpid[$v['cpid']] = $v['cpid'];
  668. }
  669. }
  670. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  671. if ($value['shop'] != '') {
  672. $shop = explode(',', trim($value['shop'], ','));
  673. $shop = $this->shop->read($shop[0]);
  674. $info_list[$key]['shop'] = $shop['shopname'];
  675. }
  676. }
  677. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  678. $pagenum = ceil($total / $perpage);
  679. $over = $total - ($start + $perpage);
  680. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  681. echo json_encode($rows);
  682. exit;
  683. }
  684. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  685. $this->_Template('whlabel_typedy', $this->data);
  686. }
  687. //进销存浏览
  688. public function _typedy_ck($arg_array)
  689. {
  690. $prc = array();
  691. $purchase = $this->purchase->find_all();
  692. foreach ($purchase as $k => $v) {
  693. $prc[$v['id']] = $v['title'];
  694. }
  695. $post = $this->input->post(NULL, TRUE);
  696. if (isset($post['page'])) {
  697. $page = $this->input->post('page', true);
  698. $perpage = $this->input->post('perpage', true);
  699. $category = $this->input->post('category', true);
  700. $size = $this->input->post('size', true);
  701. $grade = $this->input->post('grade', true);
  702. $color = $this->input->post('color', true);
  703. $lowe = $this->input->post('lowe', true);
  704. $sku = $this->input->post('sku');
  705. $title = $this->input->post('title');
  706. $warehouse = $this->input->post('warehouse', true);
  707. $usa = $this->input->post('usa', true);
  708. $purchase = $this->input->post('purchase', true);
  709. $lacetype = $this->input->post('lacetype', true);
  710. $haircap = $this->input->post('haircap', true);
  711. $density = $this->input->post('density', true);
  712. $details = $this->input->post('details', true);
  713. $state = $this->input->post('state', true);
  714. $lacecolor = $this->input->post('lacecolor', true);
  715. $cklx = $this->input->post('cklx', true);
  716. $ktime = $this->input->post('ktime', true);
  717. $jtime = $this->input->post('jtime', true);
  718. $ktime = strtotime($ktime);
  719. $jtime = strtotime($jtime);
  720. $where = "1=1";
  721. $gj = "";
  722. $ck = "";
  723. if ($lacetype) {
  724. $where .= " and features like '%-$lacetype-%'";
  725. }
  726. if ($category) {
  727. $where .= " and features like '%-$category-%'";
  728. }
  729. if ($size) {
  730. $where .= " and features like '%-$size-%'";
  731. }
  732. if ($grade) {
  733. $where .= " and features like '%-$grade-%'";
  734. }
  735. if ($color) {
  736. $where .= " and features like '%-$color-%'";
  737. }
  738. if ($lowe) {
  739. $where .= " and features like '%-$lowe-%'";
  740. }
  741. if ($haircap) {
  742. $where .= " and features like '%-$haircap-%'";
  743. }
  744. if ($density) {
  745. $where .= " and features like '%-$density-%'";
  746. }
  747. if ($lacecolor) {
  748. $where .= " and features like '%-$lacecolor-%'";
  749. }
  750. if ($usa) {
  751. if (!$warehouse) {
  752. $where .= " and (warehouse = '5' or warehouse = '8')";
  753. }
  754. }
  755. if ($warehouse) {
  756. $where .= " and warehouse = '$warehouse'";
  757. }
  758. if ($details) {
  759. $where .= " and details = '$details'";
  760. }
  761. if ($purchase) {
  762. $where .= " and purchase = '$purchase'";
  763. }
  764. if ($state) {
  765. $where .= " and state = '$state'";
  766. }
  767. $where_add = '';
  768. if ($cklx) {
  769. $shop = $this->shop->read($cklx);
  770. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  771. }
  772. if ($ktime && $jtime) {
  773. $gj = " and enter > '$ktime' and enter < '$jtime'";
  774. $ck = " and outk > '$ktime' and outk < '$jtime'";
  775. }
  776. //数据排序
  777. $order_str = "id desc";
  778. if (empty($page)) {
  779. $start = 0;
  780. $perpage = 1;
  781. } else {
  782. $start = ($page - 1) * $perpage;
  783. }
  784. if ($sku) {
  785. $sku = trim($sku, ' ');
  786. $sku = trim($sku, ' ');
  787. $where .= " and sku like '%$sku%'";
  788. $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);
  789. } else if ($title) {
  790. $title = trim($title, ' ');
  791. $title = trim($title, ' ');
  792. $where .= " and title like '%$title%'";
  793. $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);
  794. } else {
  795. //$where .= " and time > '$ktime' and time < '$jtime'";
  796. $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);
  797. }
  798. //取得信息列表
  799. $rows = array();
  800. $list = array();
  801. foreach ($info_list as $key => $value) {
  802. $warehouse = $this->warehouse->read($value['warehouse']);
  803. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  804. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  805. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  806. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  807. $ftime = time() - 15 * 24 * 3600;
  808. $info_list[$key]['warehouse'] = $warehouse['title'];
  809. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  810. //$z = count($z);//查看订单号
  811. //$info_list[$key]['zd'] = $z;
  812. $details = array();
  813. $cpid = array();
  814. foreach ($c as $k => $v) {
  815. $details[$v['details']] = $v['details'];
  816. if ($v['cpid'] != 0) {
  817. $cpid[$v['cpid']] = $v['cpid'];
  818. }
  819. }
  820. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  821. if ($value['shop'] != '') {
  822. $shop = explode(',', trim($value['shop'], ','));
  823. $shop = $this->shop->read($shop[0]);
  824. $info_list[$key]['shop'] = $shop['shopname'];
  825. }
  826. }
  827. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  828. $pagenum = ceil($total / $perpage);
  829. $over = $total - ($start + $perpage);
  830. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  831. echo json_encode($rows);
  832. exit;
  833. }
  834. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  835. $this->_Template('whlabel_typedy_ck', $this->data);
  836. }
  837. public function _typeck($arg_array)
  838. {
  839. $prc = array();
  840. $purchase = $this->purchase->find_all();
  841. foreach ($purchase as $k => $v) {
  842. $prc[$v['id']] = $v['title'];
  843. }
  844. $post = $this->input->post(NULL, TRUE);
  845. if (isset($post['page'])) {
  846. $page = $this->input->post('page', true);
  847. $perpage = $this->input->post('perpage', true);
  848. $category = $this->input->post('category', true);
  849. $size = $this->input->post('size', true);
  850. $grade = $this->input->post('grade', true);
  851. $color = $this->input->post('color', true);
  852. $lacecolor = $this->input->post('lacecolor', true);
  853. $lowe = $this->input->post('lowe', true);
  854. $sku = $this->input->post('sku');
  855. $title = $this->input->post('title');
  856. $warehouse = 13;
  857. $usa = $this->input->post('usa', true);
  858. $purchase = $this->input->post('purchase', true);
  859. $lacetype = $this->input->post('lacetype', true);
  860. $haircap = $this->input->post('haircap', true);
  861. $density = $this->input->post('density', true);
  862. $details = $this->input->post('details', true);
  863. $state = $this->input->post('state', true);
  864. $ktime = $this->input->post('ktime', true);
  865. $jtime = $this->input->post('jtime', true);
  866. $ktime = strtotime($ktime);
  867. $jtime = strtotime($jtime);
  868. $where = "1=1";
  869. $gj = "";
  870. $ck = "";
  871. if ($lacetype) {
  872. $where .= " and features like '%-$lacetype-%'";
  873. }
  874. if ($category) {
  875. $where .= " and features like '%-$category-%'";
  876. }
  877. if ($size) {
  878. $where .= " and features like '%-$size-%'";
  879. }
  880. if ($grade) {
  881. $where .= " and features like '%-$grade-%'";
  882. }
  883. if ($color) {
  884. $where .= " and features like '%-$color-%'";
  885. }
  886. if ($lacecolor) {
  887. $where .= " and features like '%-$lacecolor-%'";
  888. }
  889. if ($lowe) {
  890. $where .= " and features like '%-$lowe-%'";
  891. }
  892. if ($haircap) {
  893. $where .= " and features like '%-$haircap-%'";
  894. }
  895. if ($density) {
  896. $where .= " and features like '%-$density-%'";
  897. }
  898. if ($warehouse) {
  899. $where .= " and warehouse = '$warehouse'";
  900. }
  901. if ($details) {
  902. $where .= " and details = '$details'";
  903. }
  904. if ($purchase) {
  905. $where .= " and purchase = '$purchase'";
  906. }
  907. if ($state) {
  908. $where .= " and state = '$state'";
  909. }
  910. if ($ktime && $jtime) {
  911. $gj = " and enter > '$ktime' and enter < '$jtime'";
  912. $ck = " and outk > '$ktime' and outk < '$jtime'";
  913. }
  914. //数据排序
  915. $order_str = "id desc";
  916. if (empty($page)) {
  917. $start = 0;
  918. $perpage = 1;
  919. } else {
  920. $start = ($page - 1) * $perpage;
  921. }
  922. if ($sku) {
  923. $sku = trim($sku, ' ');
  924. $sku = trim($sku, ' ');
  925. $where .= " and sku like '%$sku%'";
  926. } else if ($title) {
  927. $title = trim($title, ' ');
  928. $title = trim($title, ' ');
  929. $where .= " and title like '%$title%'";
  930. }
  931. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  932. //取得信息列表
  933. $t = array();
  934. $typeclass = $this->typeclass->find_all();
  935. foreach ($typeclass as $v) {
  936. $t[$v['id']] = $v;
  937. }
  938. $rows = array();
  939. $list = array();
  940. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  941. foreach ($info_list as $key => $value) {
  942. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  943. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  944. $warehouse = $this->warehouse->read($value['warehouse']);
  945. $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');
  946. $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'] . '"');
  947. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  948. $number = $value['number'];
  949. $ftime = time() - 15 * 24 * 3600;
  950. $z = count($z); //查看订单号
  951. $info_list[$key]['warehouse'] = $warehouse['title'];
  952. $info_list[$key]['features'] = count($c);
  953. $info_list[$key]['number'] = $z;
  954. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  955. $details = array();
  956. $cpid = array();
  957. foreach ($c as $k => $v) {
  958. $details[$v['details']] = $v['details'];
  959. if ($v['cpid'] != 0) {
  960. $cpid[$v['cpid']] = $v['cpid'];
  961. }
  962. }
  963. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  964. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  965. unset($info_list[$key]['pm']);
  966. unset($info_list[$key]['jm']);
  967. unset($info_list[$key]['bm']);
  968. }
  969. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  970. $pagenum = ceil($total / $perpage);
  971. $over = $total - ($start + $perpage);
  972. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  973. echo json_encode($rows);
  974. exit;
  975. }
  976. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  977. $this->_Template('whlabel_typeck', $this->data);
  978. }
  979. //进销存导出
  980. public function _whlabeckdc()
  981. {
  982. $prc = array();
  983. $purchase = $this->purchase->find_all();
  984. foreach ($purchase as $k => $v) {
  985. $prc[$v['id']] = $v['title'];
  986. }
  987. if (isset($_GET['excel'])) {
  988. $where = "sku != 'Preset'";
  989. //数据排序
  990. $order_str = "id desc";
  991. if (empty($page)) {
  992. $start = 0;
  993. $perpage = 1;
  994. } else {
  995. $start = ($page - 1) * $perpage;
  996. }
  997. $category = $this->input->get('category', true);
  998. $color = $this->input->get('color', true);
  999. $lowe = $this->input->get('lowe', true);
  1000. $lacetype = $this->input->get('lacetype', true);
  1001. $size = $this->input->get('size', true);
  1002. $density = $this->input->get('density', true);
  1003. $haircap = $this->input->get('haircap', true);
  1004. $sku = $this->input->get('sku', true);
  1005. $details = $this->input->get('details', true);
  1006. $warehouse = 13;
  1007. $excelid = $this->input->get('sid', true);
  1008. if ($category) {
  1009. $where .= " and features like '%-$category-%'";
  1010. }
  1011. if ($color) {
  1012. $where .= " and features like '%-$color-%'";
  1013. }
  1014. if ($lowe) {
  1015. $where .= " and features like '%-$lowe-%'";
  1016. }
  1017. if ($lacetype) {
  1018. $where .= " and features like '%-$lacetype-%'";
  1019. }
  1020. if ($size) {
  1021. $where .= " and features like '%-$size-%'";
  1022. }
  1023. if ($density) {
  1024. $where .= " and features like '%-$density-%'";
  1025. }
  1026. if ($haircap) {
  1027. $where .= " and features like '%-$haircap-%'";
  1028. }
  1029. if ($warehouse) {
  1030. $where .= " and warehouse = '$warehouse'";
  1031. }
  1032. if ($sku) {
  1033. $where .= " and sku like '%$sku%'";
  1034. }
  1035. if ($details) {
  1036. $where .= " and details = '$details'";
  1037. }
  1038. $xzid = '';
  1039. if ($excelid) {
  1040. $excelid = explode(',', trim($excelid, ','));
  1041. foreach ($excelid as $key => $value) {
  1042. $xzid .= " id = " . $value . " or";
  1043. }
  1044. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1045. }
  1046. //取得信息列表
  1047. /**
  1048. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1049. $rows = array();$list = array();
  1050. foreach ($info_list as $key=>$value)
  1051. {
  1052. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1053. }
  1054. **/
  1055. $wh = array();
  1056. $w = $this->warehouse->find_all('1=1', 'id,title');
  1057. foreach ($w as $v) {
  1058. $wh[$v['id']] = $v['title'];
  1059. }
  1060. $tc = array();
  1061. $tcdata = array();
  1062. $list = array();
  1063. $classid = $this->classid->sku();
  1064. $tcall = $this->typeclass->find_all();
  1065. $typeclass = array();
  1066. foreach ($tcall as $v)
  1067. {
  1068. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1069. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1070. }
  1071. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1072. foreach ($rows as $key => $value) {
  1073. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1074. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1075. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1076. $rows[$key]['cpbz'] = $u9_info['bm'];
  1077. $rows[$key]['cs'] = $u9_info['jm'];
  1078. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1079. $details = array();
  1080. $cpid = array();
  1081. $cpbz = array();
  1082. $c = 0;
  1083. $g = 0;
  1084. $x = 0;
  1085. $t = 0;
  1086. $s = 0;
  1087. $q = 0;
  1088. foreach ($sd as $k => $v) {
  1089. if ($v['state'] == 0) {
  1090. $c++;
  1091. }
  1092. if ($v['state'] != 9) {
  1093. $g++;
  1094. }
  1095. if ($v['state'] == 1) {
  1096. $x++;
  1097. }
  1098. if ($v['state'] == 2) {
  1099. $t++;
  1100. }
  1101. if ($v['state'] == 8) {
  1102. $s++;
  1103. }
  1104. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1105. $q++;
  1106. }
  1107. $details[$v['details']] = $v['details'];
  1108. if ($v['cpid'] != 0) {
  1109. $cpid[$v['cpid']] = $v['cpid'];
  1110. }
  1111. if ($v['cpbz'] != '') {
  1112. $cpbz[$v['cpbz']] = $v['cpbz'];
  1113. }
  1114. }
  1115. $rows[$key]['details'] = implode("、", $details);
  1116. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1117. $number = $value['number'];
  1118. $ftime = time() - 15 * 24 * 3600;
  1119. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1120. $rows[$key]['number'] = $g;
  1121. $rows[$key]['features'] = $c;
  1122. $rows[$key]['x'] = $x;
  1123. $rows[$key]['t'] = $t;
  1124. $rows[$key]['s'] = $s;
  1125. $rows[$key]['q'] = $q;
  1126. $rows[$key]['wzsl'] = count($details);
  1127. }
  1128. $title = "进销存统计表" . date('Y-m-d', time());
  1129. $titlename = "<table border=1>
  1130. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1131. <tr align='center'>
  1132. <td>仓库</td>
  1133. <td>供应商</td>
  1134. <td>位置</td>
  1135. <td>库存编码</td>
  1136. <td>SKU</td>
  1137. <td>用友编码</td>
  1138. <td>用友料号</td>
  1139. <td>产品英文名</td>
  1140. <td>产品中文名</td>
  1141. <td>入库总量</td>
  1142. <td>库存数量</td>
  1143. <td>销售数量</td>
  1144. <td>退货数量</td>
  1145. <td>删除数量</td>
  1146. <td>其它操作</td>
  1147. <td>位置数量</td>
  1148. </tr>
  1149. </table>";
  1150. $filename = $title . ".xls";
  1151. $tail = "";
  1152. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1153. }
  1154. }
  1155. public function _type()
  1156. {
  1157. $vip = 0;
  1158. if (isset($_SESSION['api'])) {
  1159. $user = $this->user->get_api($_SESSION['api']);
  1160. $fgshop = "";
  1161. $sid = "";
  1162. $usersp = explode('|', trim($user['shop'], '|'));
  1163. foreach ($usersp as $value) {
  1164. $fgshop .= " shop = " . $value . " or";
  1165. $sid .= " id = " . $value . " or";
  1166. }
  1167. if ($user['vip'] == 1) {
  1168. $vip = 1;
  1169. }
  1170. } else {
  1171. header('Location: /');
  1172. exit;
  1173. }
  1174. $prc = array();
  1175. $purchase = $this->purchase->find_all();
  1176. foreach ($purchase as $k => $v) {
  1177. $prc[$v['id']] = $v['title'];
  1178. }
  1179. $company = array();
  1180. $ct = $this->company->find_all();
  1181. foreach ($ct as $k => $v) {
  1182. $company[$v['id']] = $v['title'];
  1183. }
  1184. $sp = array();
  1185. $s = $this->shop->find_all('1=1', 'id,shopname');
  1186. foreach ($s as $v) {
  1187. $sp[$v['id']] = $v['shopname'];
  1188. }
  1189. $wh = array();
  1190. $w = $this->warehouse->find_all('1=1', 'id,title');
  1191. foreach ($w as $v) {
  1192. $wh[$v['id']] = $v['title'];
  1193. }
  1194. $post = $this->input->post(NULL, TRUE);
  1195. if (isset($post['page'])) {
  1196. $page = $this->input->post('page', true);
  1197. $perpage = $this->input->post('perpage', true);
  1198. $category = $this->input->post('category', true);
  1199. $size = $this->input->post('size', true);
  1200. $grade = $this->input->post('grade', true);
  1201. $color = $this->input->post('color', true);
  1202. $lowe = $this->input->post('lowe', true);
  1203. $sku = $this->input->post('sku');
  1204. $title = $this->input->post('title');
  1205. $warehouse = $this->input->post('warehouse', true);
  1206. $usa = $this->input->post('usa', true);
  1207. $purchase = $this->input->post('purchase', true);
  1208. $lacetype = $this->input->post('lacetype', true);
  1209. $haircap = $this->input->post('haircap', true);
  1210. $density = $this->input->post('density', true);
  1211. $details = $this->input->post('details', true);
  1212. $state = $this->input->post('state', true);
  1213. $shop = $this->input->post('shop', true);
  1214. $lacecolor = $this->input->post('lacecolor', true);
  1215. $hairnumber = $this->input->post('hairnumber', true);
  1216. $type = $this->input->post('type', true);
  1217. $ktime = $this->input->post('ktime', true);
  1218. $jtime = $this->input->post('jtime', true);
  1219. $ktime = strtotime($ktime);
  1220. $jtime = strtotime($jtime);
  1221. $cpbz = $this->input->post('cpbz', true);
  1222. $sm = $this->input->post('sm', true);
  1223. $where = "1=1";
  1224. $gj = "";
  1225. $ck = "";
  1226. if ($usa) {
  1227. if (!$warehouse) {
  1228. $where .= " and (warehouse = '5' or warehouse = '8')";
  1229. }
  1230. }
  1231. if ($warehouse) {
  1232. $where .= " and warehouse = '$warehouse'";
  1233. }
  1234. if ($details) {
  1235. $where .= " and details = '$details'";
  1236. }
  1237. if ($purchase) {
  1238. $where .= " and purchase = '$purchase'";
  1239. }
  1240. if ($state) {
  1241. $where .= " and state = '$state'";
  1242. }
  1243. if ($shop) {
  1244. $where .= " and shop like '%$shop%'";
  1245. }
  1246. if ($type) {
  1247. $where .= " and type = '$type'";
  1248. }
  1249. if ($ktime && $jtime) {
  1250. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1251. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1252. }
  1253. if ($cpbz) {
  1254. $where .= " and cpbz like '%$cpbz%' ";
  1255. }
  1256. if ($sm) {
  1257. $where .= " and sm like '%$sm%' ";
  1258. }
  1259. if ($lacecolor) {
  1260. $where .= " and features like '%-$lacecolor-%'";
  1261. }
  1262. if ($lacetype) {
  1263. $where .= " and features like '%-$lacetype-%'";
  1264. }
  1265. if ($category) {
  1266. $where .= " and features like '%-$category-%'";
  1267. }
  1268. if ($size) {
  1269. $where .= " and features like '%-$size-%'";
  1270. }
  1271. if ($grade) {
  1272. $where .= " and features like '%-$grade-%'";
  1273. }
  1274. if ($color) {
  1275. $where .= " and features like '%-$color-%'";
  1276. }
  1277. if ($lowe) {
  1278. $where .= " and features like '%-$lowe-%'";
  1279. }
  1280. if ($haircap) {
  1281. $where .= " and features like '%-$haircap-%'";
  1282. }
  1283. if ($density) {
  1284. $where .= " and features like '%-$density-%'";
  1285. }
  1286. if (!empty($hairnumber)) {
  1287. $where .= " and features like '%-128-%' ";
  1288. if ($hairnumber < 0) {
  1289. $class_list = $this->typeclass->find_all('classid = 43');
  1290. foreach ($class_list as $v) {
  1291. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1292. }
  1293. } else {
  1294. $where .= " and features like '%-$hairnumber-%'";
  1295. }
  1296. }
  1297. //数据排序
  1298. $order_str = "id desc";
  1299. if (empty($page)) {
  1300. $start = 0;
  1301. $perpage = 1;
  1302. } else {
  1303. $start = ($page - 1) * $perpage;
  1304. }
  1305. $fjnr = '';
  1306. if ($sku) {
  1307. $sku = trim($sku, ' ');
  1308. $sku = trim($sku, ' ');
  1309. $fjnr .= " and sku like '%$sku%'";
  1310. }
  1311. if ($title) {
  1312. $title = trim($title, ' ');
  1313. $title = trim($title, ' ');
  1314. $fjnr .= " and title like '%$title%'";
  1315. }
  1316. $wt = array();
  1317. $whlabel_type = $this->whlabel_type->find_all();
  1318. foreach ($whlabel_type as $v) {
  1319. $wt[$v['id']] = $v['title'];
  1320. }
  1321. //$where .= " and time > '$ktime' and time < '$jtime'";
  1322. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1323. //取得信息列表
  1324. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1325. $rows = array();
  1326. $list = array();
  1327. foreach ($info_list as $key => $value) {
  1328. if (isset($wt[$value['type']])) {
  1329. $info_list[$key]['type'] = $wt[$value['type']];
  1330. } else {
  1331. $info_list[$key]['type'] = '未设置';
  1332. }
  1333. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1334. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1335. $ztdata = '';
  1336. if (count($zt) > 0) {
  1337. foreach ($zt as $vv) {
  1338. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1339. }
  1340. }
  1341. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1342. $cdata = array_filter($qbdata, function ($item) {
  1343. return $item['state'] < 1;
  1344. });
  1345. $c = array_sum(array_column($cdata, 'jnum'));
  1346. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1347. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1348. });
  1349. $g = array_sum(array_column($gdata, 'jnum'));
  1350. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1351. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1352. });
  1353. $x = array_sum(array_column($xdata, 'jnum'));
  1354. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1355. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1356. });
  1357. $t = array_sum(array_column($tdata, 'jnum'));
  1358. // $zdata = array_filter($qbdata, function ($item) {
  1359. // return $item['zd'] != "" && $item['state'] < 1;
  1360. // });
  1361. // $z = array_sum(array_column($zdata, 'jnum'));
  1362. $zdata = array_filter($qbdata, function ($item) {
  1363. return $item['zd'] != "" && $item['state'] < 1;
  1364. });
  1365. $z = array_sum(array_column($zdata, 'jnum'));
  1366. //$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');
  1367. //$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'].'"');
  1368. //$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'].'"');
  1369. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1370. //$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'].'"');
  1371. $details = array();
  1372. $cpid = array();
  1373. $od = array();
  1374. $odid = '';
  1375. $companytitle = '';
  1376. $shop_list = [];
  1377. foreach ($qbdata as $v) {
  1378. if ($v['zd'] != "" && $v['state'] < 1) {
  1379. if (!isset($od[$v['zd']])) {
  1380. $od[$v['zd']] = 1; //所有数据sku
  1381. } else {
  1382. $od[$v['zd']] = $od[$v['zd']] + 1;
  1383. }
  1384. }
  1385. if ($v['state'] < 1) {
  1386. $details[$v['details']] = $v['details'];
  1387. if ($v['cpid'] != 0) {
  1388. $cpid[$v['cpid']] = $v['cpid'];
  1389. }
  1390. }
  1391. if($v['state'] == 0){
  1392. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1393. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1394. }
  1395. if ($v['shop'] != '') {
  1396. $shop = explode(',', trim($v['shop'], ','));
  1397. foreach ($shop as $vv) {
  1398. if (!in_array($vv, $shop_list)) {
  1399. $shop_list[] = $vv;
  1400. }
  1401. }
  1402. }
  1403. }
  1404. }
  1405. foreach ($od as $k => $vv) {
  1406. $odid .= $k . '数量' . $vv;
  1407. }
  1408. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1409. $info_list[$key]['label'] = $value['sm'];
  1410. $number = $value['number'];
  1411. $ftime = time() - 15 * 24 * 3600;
  1412. $z = $z . '(' . $odid . ')'; //查看订单号
  1413. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1414. $info_list[$key]['features'] = $c;
  1415. $info_list[$key]['number'] = $ztdata;
  1416. $info_list[$key]['sm'] = $g;
  1417. $info_list[$key]['x'] = $x;
  1418. $info_list[$key]['t'] = $t;
  1419. $info_list[$key]['z'] = $z;
  1420. /**
  1421. foreach ($cdata as $k=>$v)
  1422. {
  1423. $details[$v['details']] = $v['details'];
  1424. if($v['cpid'] != 0)
  1425. {
  1426. $cpid[$v['cpid']] = $v['cpid'];
  1427. }
  1428. }
  1429. **/
  1430. $info_list[$key]['shop'] = '';
  1431. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1432. // if ($value['shop'] != '') {
  1433. // $shop = explode(',', trim($value['shop'], ','));
  1434. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1435. // }
  1436. $shop_list = array_unique($shop_list);
  1437. $shop_str = '';
  1438. foreach ($shop_list as $v) {
  1439. if(isset($sp[$v])){
  1440. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1441. }
  1442. }
  1443. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1444. /**
  1445. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1446. if(isset($companytitle[0]))
  1447. {
  1448. foreach ($companytitle as $k=>$v)
  1449. {
  1450. if($v['companytitle'] != '')
  1451. {
  1452. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1453. }
  1454. }
  1455. }
  1456. **/
  1457. }
  1458. $final_all_list = [];
  1459. foreach ($info_list as $k => $v) {
  1460. $final_all_list[] = [
  1461. 'id' => $v['id'],
  1462. "warehouse" => $v["warehouse"],
  1463. "purchase" => $v["purchase"],
  1464. "sku" => $v["sku"],
  1465. "title" => $v["title"] . "<br/>" . $v["pm"],
  1466. "details" => $v["details"],
  1467. "shop" => $v["shop"],
  1468. "cpbz" => $v["cpbz"],
  1469. 'label' => $v['label'],
  1470. "type" => $v["type"],
  1471. "features" => $v["features"],
  1472. "number" => $v["number"],
  1473. "sm" => $v["sm"],
  1474. "x" => $v["x"],
  1475. "t" => $v["t"],
  1476. "z" => $v["z"]
  1477. ];
  1478. }
  1479. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1480. $pagenum = ceil($total / $perpage);
  1481. $over = $total - ($start + $perpage);
  1482. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1483. echo json_encode($rows);
  1484. exit;
  1485. }
  1486. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1487. $this->data['shop'] = $wlshop;
  1488. $this->data['vip'] = $vip;
  1489. $this->_Template('whlabel_type', $this->data);
  1490. }
  1491. //美仓进销存浏览
  1492. public function _usatype()
  1493. {
  1494. if (isset($_SESSION['api'])) {
  1495. $user = $this->user->get_api($_SESSION['api']);
  1496. $usp = $user;
  1497. $fgshop = "";
  1498. $sid = "";
  1499. $wid = "";
  1500. $wtype = "";
  1501. $userwh = explode('|', trim($user['warehouse'], '|'));
  1502. foreach ($userwh as $value) {
  1503. $wid .= " id = " . $value . " or";
  1504. $wtype .= " type = " . $value . " or";
  1505. }
  1506. }
  1507. $prc = array();
  1508. $purchase = $this->purchase->find_all();
  1509. foreach ($purchase as $k => $v) {
  1510. $prc[$v['id']] = $v['title'];
  1511. }
  1512. $post = $this->input->post(NULL, TRUE);
  1513. if (isset($post['page'])) {
  1514. $page = $this->input->post('page', true);
  1515. $perpage = $this->input->post('perpage', true);
  1516. $category = $this->input->post('category', true);
  1517. $size = $this->input->post('size', true);
  1518. $grade = $this->input->post('grade', true);
  1519. $color = $this->input->post('color', true);
  1520. $lowe = $this->input->post('lowe', true);
  1521. $sku = $this->input->post('sku');
  1522. $title = $this->input->post('title');
  1523. $warehouse = $this->input->post('warehouse', true);
  1524. $usa = $this->input->post('usa', true);
  1525. $purchase = $this->input->post('purchase', true);
  1526. $lacetype = $this->input->post('lacetype', true);
  1527. $haircap = $this->input->post('haircap', true);
  1528. $density = $this->input->post('density', true);
  1529. $details = $this->input->post('details', true);
  1530. $state = $this->input->post('state', true);
  1531. $lacecolor = $this->input->post('lacecolor', true);
  1532. $cklx = $this->input->post('cklx', true);
  1533. $ktime = $this->input->post('ktime', true);
  1534. $jtime = $this->input->post('jtime', true);
  1535. $ktime = strtotime($ktime);
  1536. $jtime = strtotime($jtime);
  1537. $where = "1=1";
  1538. $gj = "";
  1539. $ck = "";
  1540. if ($lacetype) {
  1541. $where .= " and features like '%-$lacetype-%'";
  1542. }
  1543. if ($category) {
  1544. $where .= " and features like '%-$category-%'";
  1545. }
  1546. if ($size) {
  1547. $where .= " and features like '%-$size-%'";
  1548. }
  1549. if ($grade) {
  1550. $where .= " and features like '%-$grade-%'";
  1551. }
  1552. if ($color) {
  1553. $where .= " and features like '%-$color-%'";
  1554. }
  1555. if ($lowe) {
  1556. $where .= " and features like '%-$lowe-%'";
  1557. }
  1558. if ($haircap) {
  1559. $where .= " and features like '%-$haircap-%'";
  1560. }
  1561. if ($density) {
  1562. $where .= " and features like '%-$density-%'";
  1563. }
  1564. if ($lacecolor) {
  1565. $where .= " and features like '%-$lacecolor-%'";
  1566. }
  1567. if ($usa) {
  1568. if (!$warehouse) {
  1569. $where .= " and (warehouse = '5' or warehouse = '8')";
  1570. }
  1571. }
  1572. if ($warehouse) {
  1573. $where .= " and warehouse = '$warehouse'";
  1574. }
  1575. if ($details) {
  1576. $where .= " and details = '$details'";
  1577. }
  1578. if ($purchase) {
  1579. $where .= " and purchase = '$purchase'";
  1580. }
  1581. if ($state) {
  1582. $where .= " and state = '$state'";
  1583. }
  1584. $where_add = '';
  1585. if ($cklx) {
  1586. $shop = $this->shop->read($cklx);
  1587. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1588. }
  1589. if ($ktime && $jtime) {
  1590. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1591. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1592. }
  1593. //数据排序
  1594. $order_str = "id desc";
  1595. if (empty($page)) {
  1596. $start = 0;
  1597. $perpage = 1;
  1598. } else {
  1599. $start = ($page - 1) * $perpage;
  1600. }
  1601. if ($sku) {
  1602. $sku = trim($sku, ' ');
  1603. $sku = trim($sku, ' ');
  1604. $where .= " and sku like '%$sku%'";
  1605. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1606. } else if ($title) {
  1607. $title = trim($title, ' ');
  1608. $title = trim($title, ' ');
  1609. $where .= " and title like '%$title%'";
  1610. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1611. } else {
  1612. //$where .= " and time > '$ktime' and time < '$jtime'";
  1613. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1614. }
  1615. //取得信息列表
  1616. $rows = array();
  1617. $list = array();
  1618. foreach ($info_list as $key => $value) {
  1619. $warehouse = $this->warehouse->read($value['warehouse']);
  1620. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1621. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1622. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1623. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1624. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1625. $od = array();
  1626. $odid = '';
  1627. foreach ($z as $v) {
  1628. if (!isset($od[$v['zd']])) {
  1629. $od[$v['zd']] = 1; //所有数据sku
  1630. } else {
  1631. $od[$v['zd']] = $od[$v['zd']] + 1;
  1632. }
  1633. }
  1634. foreach ($od as $k => $vv) {
  1635. $odid .= $k . '数量' . $vv . ' ';
  1636. }
  1637. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1638. $info_list[$key]['features'] = $c;
  1639. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1640. $ztdata = '';
  1641. if (count($zt) > 0) {
  1642. foreach ($zt as $vv) {
  1643. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1644. }
  1645. }
  1646. $info_list[$key]['warehouse'] = $ztdata;
  1647. $info_list[$key]['g'] = $g;
  1648. $info_list[$key]['x'] = $x;
  1649. $info_list[$key]['t'] = $t;
  1650. $info_list[$key]['z'] = $z;
  1651. }
  1652. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1653. $pagenum = ceil($total / $perpage);
  1654. $over = $total - ($start + $perpage);
  1655. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1656. echo json_encode($rows);
  1657. exit;
  1658. }
  1659. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1660. $this->data['warehouse'] = $warehouse;
  1661. $this->_Template('whlabel_typeusa', $this->data);
  1662. }
  1663. //美仓进销存浏览
  1664. public function _usatypeapp()
  1665. {
  1666. $post = $this->input->post(NULL, TRUE);
  1667. if (isset($post['page'])) {
  1668. $page = $this->input->post('page', true);
  1669. $perpage = $this->input->post('perpage', true);
  1670. $sku = $this->input->post('sku', true);
  1671. $warehouse = 5;
  1672. $title = $this->input->post('title', true);
  1673. $state = $this->input->post('state', true);
  1674. $ktime = $this->input->post('ktime', true);
  1675. $jtime = $this->input->post('jtime', true);
  1676. $ktime = strtotime($ktime);
  1677. $jtime = strtotime($jtime);
  1678. $where = "1=1";
  1679. $gj = "";
  1680. $ck = "";
  1681. if ($title) {
  1682. $st = explode(' ', trim($title, ' '));
  1683. foreach ($st as $v) {
  1684. $where .= " and title like '%$v%'";
  1685. }
  1686. }
  1687. if ($warehouse) {
  1688. $where .= " and warehouse = '$warehouse'";
  1689. }
  1690. if ($state) {
  1691. $where .= " and state = '$state'";
  1692. }
  1693. if ($sku) {
  1694. $where .= " and sku like '%$sku%'";
  1695. }
  1696. if ($ktime && $jtime) {
  1697. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1698. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1699. }
  1700. //数据排序
  1701. $order_str = "id desc";
  1702. if (empty($page)) {
  1703. $start = 0;
  1704. $perpage = 1;
  1705. } else {
  1706. $start = ($page - 1) * $perpage;
  1707. }
  1708. //取得信息列表
  1709. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1710. $rows = array();
  1711. $list = array();
  1712. foreach ($info_list as $key => $value) {
  1713. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1714. }
  1715. $rowsdq = array_slice($rows, $start, $perpage);
  1716. foreach ($rowsdq as $value) {
  1717. $warehouse = $this->warehouse->read($value['warehouse']);
  1718. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1719. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1720. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1721. $od = array();
  1722. $odid = '';
  1723. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1724. }
  1725. $total = count($rows);
  1726. $pagenum = ceil($total / $perpage);
  1727. $over = $total - ($start + $perpage);
  1728. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1729. echo json_encode($rows);
  1730. exit;
  1731. }
  1732. $this->_Template('phone/p_usatypeapp', $this->data);
  1733. }
  1734. //入库操作
  1735. public function _enteradd()
  1736. {
  1737. $dt = 0;
  1738. if (isset($_SESSION['api'])) {
  1739. $user = $this->user->get_api($_SESSION['api']);
  1740. $usp = $user;
  1741. $fgshop = "";
  1742. $sid = "";
  1743. $user = explode('|', trim($user['shop'], '|'));
  1744. foreach ($user as $value) {
  1745. $fgshop .= " shop = " . $value . " or";
  1746. $sid .= " id = " . $value . " or";
  1747. }
  1748. }
  1749. $tc = $this->typeclass->find_all();
  1750. $typeclass = array();
  1751. foreach ($tc as $v) {
  1752. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1753. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1754. }
  1755. $post = $this->input->post(NULL, TRUE);
  1756. if (isset($post['sku'])) {
  1757. $list = array();
  1758. $num = "";
  1759. $title = "";
  1760. $features = "";
  1761. $order = $this->input->post('order', true);
  1762. $shop = $this->input->post('shop', true);
  1763. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1764. $sku = $this->input->post('sku', true);
  1765. $post['sm'] = $this->input->post('sm', true);
  1766. $post['warehouse'] = $this->input->post('warehouse', true);
  1767. $post['purchase'] = $this->input->post('purchase', true);
  1768. $post['retreatwarehouse'] = $post['warehouse'];
  1769. $post['state'] = $this->input->post('state', true);
  1770. $post['rktype'] = $this->input->post('rktype', true);
  1771. $post['text'] = $this->input->post('text', true);
  1772. $category = $this->input->post('category', true);
  1773. $list['category'] = $category;
  1774. $list['hairtype'] = $this->input->post('hairtype', true);
  1775. $list['grade'] = $this->input->post('grade', true);
  1776. $size = $this->input->post('size', true);
  1777. $xzsku = $this->input->post('xzsku', true);
  1778. $list['size'] = rtrim($size, ',');
  1779. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1780. $list['extension'] = $this->input->post('extension', true);
  1781. if ($category == 1297) {
  1782. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1783. }
  1784. if ($category == 1702) {
  1785. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1786. $list['syother'] = $this->input->post('syother', true);
  1787. }
  1788. if ($category == 133) {
  1789. $list['fittype'] = $this->input->post('fittype', true);
  1790. $list['acother'] = $this->input->post('acother', true);
  1791. }
  1792. $list['color'] = $this->input->post('color', true);
  1793. $list['lowe'] = $this->input->post('lowe', true);
  1794. if (!$post['purchase']) {
  1795. $post['purchase'] = 1;
  1796. }
  1797. if ($category == 127) {
  1798. $list['type'] = $this->input->post('type', true);
  1799. $list['headroad'] = $this->input->post('headroad', true);
  1800. $list['density'] = $this->input->post('density', true);
  1801. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1802. $list['lacesize'] = $this->input->post('lacesize', true);
  1803. }
  1804. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1805. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1806. }
  1807. if ($category == 128) {
  1808. $list['lacetype'] = $this->input->post('lacetype', true);
  1809. $list['haircap'] = $this->input->post('haircap', true);
  1810. $list['density'] = $this->input->post('density', true);
  1811. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1812. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1813. $list['wigother'] = $this->input->post('wigother', true);
  1814. $list['wigother1'] = $this->input->post('wigother1', true);
  1815. $list['wigother2'] = $this->input->post('wigother2', true);
  1816. }
  1817. if ($category == 129) {
  1818. $list['wide'] = $this->input->post('wide', true);
  1819. }
  1820. if ($category == 131) {
  1821. $list['gifttype'] = $this->input->post('gifttype', true);
  1822. $list['giftother'] = $this->input->post('giftother', true);
  1823. }
  1824. if ($category == 134) {
  1825. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1826. }
  1827. if ($category == 1297) {
  1828. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1829. $list['sywigother'] = $this->input->post('sywigother', true);
  1830. }
  1831. if ($category == 130 || $category == 133 || $category == 1702) {
  1832. $list['items'] = $this->input->post('items', true);
  1833. $list['weight'] = $this->input->post('weight', true);
  1834. }
  1835. if ($category == 1702) {
  1836. $list['syhairther'] = $this->input->post('syhairther', true);
  1837. }
  1838. $classid = $this->classid->sku();
  1839. $scsku = $classid;
  1840. $pm = $classid;
  1841. foreach ($list as $k => $v) {
  1842. if ($v != 0) {
  1843. $num .= $v;
  1844. $features .= $v . '-';
  1845. $post[$k] = $v;
  1846. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1847. if ($k != 'size') {
  1848. $title .= $typeclass[$v]['title'] . " ";
  1849. }
  1850. if (isset($pm[$typeclass[$v]['classid']])) {
  1851. if ($typeclass[$v]['title'] == '9A') {
  1852. $pm[$typeclass[$v]['classid']] = '9A';
  1853. } else if ($typeclass[$v]['title'] == '10A') {
  1854. $pm[$typeclass[$v]['classid']] = '10A';
  1855. } else {
  1856. $clzh = $typeclass[$v]['zh'];
  1857. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1858. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1859. $clzh = $clzh[0];
  1860. }
  1861. $pm[$typeclass[$v]['classid']] = $clzh;
  1862. }
  1863. }
  1864. }
  1865. }
  1866. $zh = implode(" ", $pm);
  1867. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1868. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1869. if ($list['size']) {
  1870. $typeclass = $this->typeclass->read($list['size']);
  1871. $title .= $typeclass['title'];
  1872. }
  1873. $time = time();
  1874. if ($xzsku) {
  1875. $scsku = implode("-", $scsku);
  1876. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1877. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1878. $post['sku'] = trim($scsku, ' ');
  1879. } else {
  1880. $post['sku'] = $sku;
  1881. }
  1882. //$post['sku'] = trim($sku,' ');
  1883. $post['title'] = rtrim($title, ' ');
  1884. $post['number'] = $num;
  1885. $post['features'] = '-' . $features;
  1886. $post['enter'] = $time;
  1887. $post['time'] = $time; //操作时间
  1888. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1889. if ($yza) {
  1890. if ($post['features'] != $yza[0]['features']) {
  1891. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1892. exit;
  1893. }
  1894. }
  1895. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1896. if ($yzb) {
  1897. if ($post['sku'] != $yzb[0]['sku']) {
  1898. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1899. exit;
  1900. }
  1901. }
  1902. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1903. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1904. exit;
  1905. }
  1906. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1907. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1908. exit;
  1909. }
  1910. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1911. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1912. exit;
  1913. }
  1914. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1915. if (isset($yz[0]['type'])) {
  1916. $post['type'] = $yz[0]['type'];
  1917. }
  1918. if ($post['state'] == 9) //如果选择预设库存
  1919. {
  1920. $this->whlabel->insert($post);
  1921. } else {
  1922. /**
  1923. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1924. if($ljg == 1)
  1925. {
  1926. for($i=0;$i<$order;$i++)
  1927. {
  1928. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1929. $this->whlabel->insert($post);
  1930. }
  1931. }
  1932. **/
  1933. //if($post['warehouse'] == '5')
  1934. //{
  1935. //}
  1936. $yydata = $post;
  1937. $yydata['zh'] = $zh;
  1938. /**
  1939. $wl = $this->apiyy->get_cjlp($yydata);
  1940. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1941. {
  1942. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1943. }
  1944. if($wl['Data'][0]['m_isSucess'] != 1)
  1945. {
  1946. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1947. }
  1948. **/
  1949. for ($i = 0; $i < $order; $i++) {
  1950. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1951. $this->whlabel->insert($post);
  1952. }
  1953. }
  1954. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1955. exit;
  1956. }
  1957. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1958. $this->data['wlshop'] = $wlshop;
  1959. $this->_Template('whlabel_enteradd', $this->data);
  1960. }
  1961. //修改产品
  1962. public function _enteredit($arg_array)
  1963. {
  1964. $dt = 0;
  1965. if (isset($_SESSION['api'])) {
  1966. $user = $this->user->get_api($_SESSION['api']);
  1967. $usp = $user;
  1968. $fgshop = "";
  1969. $sid = "";
  1970. $user = explode('|', trim($user['shop'], '|'));
  1971. foreach ($user as $value) {
  1972. $fgshop .= " shop = " . $value . " or";
  1973. $sid .= " id = " . $value . " or";
  1974. }
  1975. }
  1976. $post = $this->input->post(NULL, TRUE);
  1977. if (isset($post['sku'])) {
  1978. $list = array();
  1979. $num = "";
  1980. $title = "";
  1981. $features = "";
  1982. $id = $this->input->post('id', true);
  1983. $order = $this->input->post('order', true);
  1984. $shop = $this->input->post('shop', true);
  1985. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1986. $post['sku'] = $this->input->post('sku', true);
  1987. $post['sm'] = $this->input->post('sm', true);
  1988. $post['warehouse'] = $this->input->post('warehouse', true);
  1989. $post['purchase'] = $this->input->post('purchase', true);
  1990. $post['retreatwarehouse'] = $post['warehouse'];
  1991. $category = $this->input->post('category', true);
  1992. $list['category'] = $category;
  1993. $list['hairtype'] = $this->input->post('hairtype', true);
  1994. $list['grade'] = $this->input->post('grade', true);
  1995. $size = $this->input->post('size', true);
  1996. $list['size'] = rtrim($size, ',');
  1997. $post['rktype'] = $this->input->post('rktype', true);
  1998. $post['text'] = $this->input->post('text', true);
  1999. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2000. $list['extension'] = $this->input->post('extension', true);
  2001. if ($category == 1297) {
  2002. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2003. }
  2004. if ($category == 1702) {
  2005. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2006. $list['syother'] = $this->input->post('syother', true);
  2007. }
  2008. if ($category == 133) {
  2009. $list['fittype'] = $this->input->post('fittype', true);
  2010. $list['acother'] = $this->input->post('acother', true);
  2011. }
  2012. $list['color'] = $this->input->post('color', true);
  2013. $list['lowe'] = $this->input->post('lowe', true);
  2014. if (!$post['purchase']) {
  2015. $post['purchase'] = 1;
  2016. }
  2017. if ($category == 127) {
  2018. $list['type'] = $this->input->post('type', true);
  2019. $list['headroad'] = $this->input->post('headroad', true);
  2020. $list['density'] = $this->input->post('density', true);
  2021. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2022. $list['lacesize'] = $this->input->post('lacesize', true);
  2023. }
  2024. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2025. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2026. }
  2027. if ($category == 128) {
  2028. $list['lacetype'] = $this->input->post('lacetype', true);
  2029. $list['haircap'] = $this->input->post('haircap', true);
  2030. $list['density'] = $this->input->post('density', true);
  2031. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2032. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2033. $list['wigother'] = $this->input->post('wigother', true);
  2034. $list['wigother1'] = $this->input->post('wigother1', true);
  2035. $list['wigother2'] = $this->input->post('wigother2', true);
  2036. }
  2037. if ($category == 129) {
  2038. $list['wide'] = $this->input->post('wide', true);
  2039. }
  2040. if ($category == 131) {
  2041. $list['gifttype'] = $this->input->post('gifttype', true);
  2042. $list['giftother'] = $this->input->post('giftother', true);
  2043. }
  2044. if ($category == 134) {
  2045. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2046. }
  2047. if ($category == 1297) {
  2048. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2049. $list['sywigother'] = $this->input->post('sywigother', true);
  2050. }
  2051. if ($category == 130 || $category == 133 || $category == 1702) {
  2052. $list['items'] = $this->input->post('items', true);
  2053. $list['weight'] = $this->input->post('weight', true);
  2054. }
  2055. if ($category == 1702) {
  2056. $list['syhairther'] = $this->input->post('syhairther', true);
  2057. }
  2058. foreach ($list as $k => $v) {
  2059. if ($v != 0) {
  2060. $num .= $v;
  2061. $features .= $v . '-';
  2062. $typeclass = $this->typeclass->read($v);
  2063. if ($k != 'size') {
  2064. $title .= $typeclass['title'] . " ";
  2065. }
  2066. }
  2067. }
  2068. $typeclass = $this->typeclass->read($list['size']);
  2069. $title .= $typeclass['title'];
  2070. $time = time();
  2071. $post['title'] = rtrim($title, ' ');
  2072. $post['number'] = $num;
  2073. $post['features'] = '-' . $features;
  2074. $post['time'] = $time; //操作时间
  2075. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2076. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2077. exit;
  2078. }
  2079. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2080. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2081. exit;
  2082. }
  2083. $uid = $this->whlabel->read($id);
  2084. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2085. if ($datanum > 0) {
  2086. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2087. exit;
  2088. }
  2089. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2090. {
  2091. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2092. if ($yza) {
  2093. if ($post['features'] != $yza[0]['features']) {
  2094. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2095. exit;
  2096. }
  2097. }
  2098. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2099. if ($yzb) {
  2100. if ($post['sku'] != $yzb[0]['sku']) {
  2101. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2102. exit;
  2103. }
  2104. }
  2105. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2106. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2107. exit;
  2108. }
  2109. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2110. foreach ($data as $v) {
  2111. $post['id'] = $v['id'];
  2112. $this->whlabel->save($post, $v['id']);
  2113. }
  2114. } else {
  2115. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2116. if ($data > 0) {
  2117. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2118. exit;
  2119. } else {
  2120. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2121. foreach ($data as $v) {
  2122. $post['id'] = $v['id'];
  2123. $this->whlabel->save($post, $v['id']);
  2124. }
  2125. }
  2126. }
  2127. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2128. exit;
  2129. }
  2130. $uid = $this->whlabel->read($arg_array[0]);
  2131. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2132. $this->data['enter'] = $uid;
  2133. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2134. $this->data['wlshop'] = $wlshop;
  2135. $this->_Template('whlabel_enteredit', $this->data);
  2136. }
  2137. //入库浏览
  2138. public function _enter()
  2139. {
  2140. $post = $this->input->post(NULL, TRUE);
  2141. if (isset($post['s'])) {
  2142. $id_arr = $this->input->post('s');
  2143. $id_arr = explode(',', $id_arr);
  2144. if (!$id_arr) {
  2145. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2146. exit;
  2147. }
  2148. //循环删除记录
  2149. foreach ($id_arr as $v) {
  2150. $sid = $this->whlabel->read($v);
  2151. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2152. if ($count > 0) {
  2153. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2154. exit;
  2155. }
  2156. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2157. foreach ($info_list as $va) {
  2158. $this->whlabel->remove($va['id']);
  2159. }
  2160. }
  2161. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2162. exit;
  2163. }
  2164. $sp = array();
  2165. $s = $this->shop->find_all('1=1', 'id,shopname');
  2166. foreach ($s as $v) {
  2167. $sp[$v['id']] = $v['shopname'];
  2168. }
  2169. $wh = array();
  2170. $w = $this->warehouse->find_all('1=1', 'id,title');
  2171. foreach ($w as $v) {
  2172. $wh[$v['id']] = $v['title'];
  2173. }
  2174. if (isset($post['page'])) {
  2175. $page = $this->input->post('page', true);
  2176. $perpage = $this->input->post('perpage', true);
  2177. $category = $this->input->post('category', true);
  2178. $size = $this->input->post('size', true);
  2179. $grade = $this->input->post('grade', true);
  2180. $color = $this->input->post('color', true);
  2181. $lowe = $this->input->post('lowe', true);
  2182. $sku = $this->input->post('sku', true);
  2183. $warehouse = $this->input->post('warehouse', true);
  2184. $purchase = $this->input->post('purchase', true);
  2185. $ktime = $this->input->post('ktime', true);
  2186. $jtime = $this->input->post('jtime', true);
  2187. $ktime = strtotime($ktime);
  2188. $jtime = strtotime($jtime);
  2189. $where = "1=1";
  2190. $gj = "";
  2191. $ck = "";
  2192. if ($category) {
  2193. $where .= " and features like '%-$category-%'";
  2194. }
  2195. if ($size) {
  2196. $where .= " and features like '%-$size-%'";
  2197. }
  2198. if ($grade) {
  2199. $where .= " and features like '%-$grade-%'";
  2200. }
  2201. if ($color) {
  2202. $where .= " and features like '%-$color-%'";
  2203. }
  2204. if ($lowe) {
  2205. $where .= " and features like '%-$lowe-%'";
  2206. }
  2207. if ($warehouse) {
  2208. $where .= " and warehouse = '$warehouse'";
  2209. }
  2210. if ($purchase) {
  2211. $where .= " and purchase = '$purchase'";
  2212. }
  2213. if ($sku) {
  2214. $where .= " and sku like '%$sku%'";
  2215. }
  2216. if ($ktime && $jtime) {
  2217. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2218. }
  2219. //数据排序
  2220. $order_str = "enter desc";
  2221. if (empty($page)) {
  2222. $start = 0;
  2223. $perpage = 1;
  2224. } else {
  2225. $start = ($page - 1) * $perpage;
  2226. }
  2227. //取得信息列表
  2228. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2229. foreach ($info_list as $k => $v) {
  2230. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2231. if ($v['shop'] == '') {
  2232. $s = '通用';
  2233. } else {
  2234. $info_list[$k]['shop'] = '';
  2235. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2236. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2237. }
  2238. }
  2239. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2240. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2241. $info_list[$k]['g'] = $g;
  2242. }
  2243. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2244. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2245. $pagenum = ceil($total / $perpage);
  2246. $over = $total - ($start + $perpage);
  2247. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2248. echo json_encode($rows);
  2249. exit;
  2250. }
  2251. $this->_Template('whlabel_enter', $this->data);
  2252. }
  2253. //出库浏览
  2254. public function _out()
  2255. {
  2256. $post = $this->input->post(NULL, TRUE);
  2257. if (isset($post['page'])) {
  2258. $page = $this->input->post('page', true);
  2259. $perpage = $this->input->post('perpage', true);
  2260. $category = $this->input->post('category', true);
  2261. $size = $this->input->post('size', true);
  2262. $grade = $this->input->post('grade', true);
  2263. $color = $this->input->post('color', true);
  2264. $lowe = $this->input->post('lowe', true);
  2265. $sku = $this->input->post('sku', true);
  2266. $warehouse = $this->input->post('warehouse', true);
  2267. $purchase = $this->input->post('purchase', true);
  2268. $state = $this->input->post('state', true);
  2269. $ktime = $this->input->post('ktime', true);
  2270. $jtime = $this->input->post('jtime', true);
  2271. $ktime = strtotime($ktime);
  2272. $jtime = strtotime($jtime);
  2273. $where = "state=3";
  2274. $gj = "";
  2275. $ck = "";
  2276. if ($category) {
  2277. $where .= " and features like '%-$category-%'";
  2278. }
  2279. if ($size) {
  2280. $where .= " and features like '%-$size-%'";
  2281. }
  2282. if ($grade) {
  2283. $where .= " and features like '%-$grade-%'";
  2284. }
  2285. if ($color) {
  2286. $where .= " and features like '%-$color-%'";
  2287. }
  2288. if ($lowe) {
  2289. $where .= " and features like '%-$lowe-%'";
  2290. }
  2291. if ($state) {
  2292. $where .= " and state = '$state'";
  2293. }
  2294. if ($warehouse) {
  2295. $where .= " and warehouse = '$warehouse'";
  2296. }
  2297. if ($purchase) {
  2298. $where .= " and purchase = '$purchase'";
  2299. }
  2300. if ($sku) {
  2301. $where .= " and sku = '$sku'";
  2302. }
  2303. if ($ktime && $jtime) {
  2304. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2305. }
  2306. //数据排序
  2307. $order_str = "id desc";
  2308. if (empty($page)) {
  2309. $start = 0;
  2310. $perpage = 1;
  2311. } else {
  2312. $start = ($page - 1) * $perpage;
  2313. }
  2314. //取得信息列表
  2315. $info_list = $this->whlabel->find_all($where, 'sku');
  2316. $rows = array();
  2317. $list = array();
  2318. foreach ($info_list as $key => $value) {
  2319. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2320. }
  2321. $rows = array_unique($rows); //删除重复记录
  2322. foreach ($rows as $key => $value) {
  2323. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2324. $ck = $this->warehouse->read($data['warehouse']);
  2325. $warehouse = $ck['title'];
  2326. $gy = $this->purchase->read($data['purchase']);
  2327. $purchase = $gy['purchase'];
  2328. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2329. $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);
  2330. }
  2331. $total = count($list);
  2332. $pagenum = ceil($total / $perpage);
  2333. $over = $total - ($start + $perpage);
  2334. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2335. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2336. echo json_encode($rows);
  2337. exit;
  2338. }
  2339. $this->_Template('whlabel_out', $this->data);
  2340. }
  2341. //出库标签浏览
  2342. public function _label()
  2343. {
  2344. $post = $this->input->post(NULL, TRUE);
  2345. if (isset($post['page'])) {
  2346. $page = $this->input->post('page', true);
  2347. $perpage = $this->input->post('perpage', true);
  2348. $sku = $this->input->post('sku', true);
  2349. $warehouse = $this->input->post('warehouse', true);
  2350. $purchase = $this->input->post('purchase', true);
  2351. $orderinfo = $this->input->post('orderinfo', true);
  2352. $waybill = $this->input->post('waybill', true);
  2353. $category = $this->input->post('category', true);
  2354. $size = $this->input->post('size', true);
  2355. $grade = $this->input->post('grade', true);
  2356. $color = $this->input->post('color', true);
  2357. $lowe = $this->input->post('lowe', true);
  2358. $where = "state=1";
  2359. if ($sku) {
  2360. $where .= " and sku = '$sku'";
  2361. }
  2362. if ($warehouse) {
  2363. $where .= " and warehouse = '$warehouse'";
  2364. }
  2365. if ($purchase) {
  2366. $where .= " and purchase = '$purchase'";
  2367. }
  2368. if ($orderinfo) {
  2369. $where .= " and orderinfo = '$orderinfo'";
  2370. }
  2371. if ($waybill) {
  2372. $where .= " and waybill = '$waybill'";
  2373. }
  2374. if ($category) {
  2375. $where .= " and features like '%-$category-%'";
  2376. }
  2377. if ($size) {
  2378. $where .= " and features like '%-$size-%'";
  2379. }
  2380. if ($grade) {
  2381. $where .= " and features like '%-$grade-%'";
  2382. }
  2383. if ($color) {
  2384. $where .= " and features like '%-$color-%'";
  2385. }
  2386. if ($lowe) {
  2387. $where .= " and features like '%-$lowe-%'";
  2388. }
  2389. //数据排序
  2390. $order_str = "outk desc";
  2391. if (empty($page)) {
  2392. $start = 0;
  2393. $perpage = 1;
  2394. } else {
  2395. $start = ($page - 1) * $perpage;
  2396. }
  2397. //取得信息列表
  2398. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2399. foreach ($info_list as $key => $value) {
  2400. $warehouse = $this->warehouse->read($value['warehouse']);
  2401. $info_list[$key]['warehouse'] = $warehouse['title'];
  2402. $purchase = $this->purchase->read($value['purchase']);
  2403. $info_list[$key]['purchase'] = $purchase['title'];
  2404. if ($value['outk'] != 0) {
  2405. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2406. } else {
  2407. $info_list[$key]['outk'] = "";
  2408. }
  2409. if ($value['orderinfo'] == 0) {
  2410. $info_list[$key]['orderinfo'] = "";
  2411. }
  2412. if ($value['waybill'] == 0) {
  2413. $info_list[$key]['waybill'] = "";
  2414. }
  2415. }
  2416. $total = $this->whlabel->find_count($where);
  2417. $pagenum = ceil($total / $perpage);
  2418. $over = $total - ($start + $perpage);
  2419. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2420. echo json_encode($rows);
  2421. exit;
  2422. }
  2423. $this->_Template('whlabel_label', $this->data);
  2424. }
  2425. //独立站出库订单
  2426. public function _outorder()
  2427. {
  2428. if (isset($_SESSION['api'])) {
  2429. $user = $this->user->get_api($_SESSION['api']);
  2430. $usp = $user;
  2431. $fgshop = "";
  2432. $sid = "";
  2433. $user = explode('|', trim($user['shop'], '|'));
  2434. foreach ($user as $value) {
  2435. $fgshop .= " shop = " . $value . " or";
  2436. $sid .= " id = " . $value . " or";
  2437. }
  2438. } else {
  2439. echo "请重新登录";
  2440. }
  2441. $post = $this->input->post(NULL, TRUE);
  2442. if (isset($post['page'])) {
  2443. $page = $this->input->post('page', true);
  2444. $perpage = $this->input->post('perpage', true);
  2445. $warehouse = $this->input->post('warehouse', true);
  2446. $xztime = $this->input->post('xztime', true);
  2447. $timetk = $this->input->post('timetkk', true);
  2448. $timetj = $this->input->post('timetjj', true);
  2449. $shop = $this->input->post('shop', true);
  2450. $source = $this->input->post('source', true);
  2451. $orderinfo = $this->input->post('orderinfo', true);
  2452. $number = $this->input->post('number', true);
  2453. $sfxh = $this->input->post('sfxh', true);
  2454. $express = $this->input->post('express', true);
  2455. $waybill = $this->input->post('waybill', true);
  2456. $library = $this->input->post('library', true);
  2457. $country = $this->input->post('country', true);
  2458. $so = $this->input->post('so', true);
  2459. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2460. $print = $this->input->post('print', true);
  2461. $state = $this->input->post('state', true);
  2462. $orderurl = $this->input->post('orderurl', true);
  2463. $productid = $this->input->post('productid', true);
  2464. $timetk = strtotime($timetk);
  2465. $timetj = strtotime($timetj);
  2466. /**
  2467. $sj = $this->input->post('sj',true);
  2468. if($sj)
  2469. {
  2470. $sj = $this->input->post('sj',true);
  2471. }
  2472. else
  2473. {
  2474. $sj = "fullorder";
  2475. }
  2476. **/
  2477. $sj = "fullorder";
  2478. $where = "1=1";
  2479. if ($warehouse) {
  2480. $where .= " and type = '$warehouse'";
  2481. }
  2482. if ($timetk && $timetj) {
  2483. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2484. }
  2485. if ($orderinfo) {
  2486. $where .= " and orderinfo = '$orderinfo'";
  2487. }
  2488. if ($number) {
  2489. $where .= " and number = '$number'";
  2490. }
  2491. if ($express) {
  2492. $where .= " and express = '$express'";
  2493. }
  2494. if ($waybill) {
  2495. $where .= " and waybill = '$waybill'";
  2496. }
  2497. if ($library) {
  2498. $where .= " and library = '$library'";
  2499. }
  2500. if ($print) {
  2501. $where .= " and print = '$print'";
  2502. }
  2503. if ($libraryconfirm) {
  2504. $where .= " and libraryconfirm = '$libraryconfirm'";
  2505. }
  2506. if ($state) {
  2507. $where .= " and state = '$state'";
  2508. }
  2509. if ($shop) {
  2510. $where .= " and shop = '$shop'";
  2511. }
  2512. if ($country) {
  2513. $where .= " and country = '$country'";
  2514. }
  2515. if ($sfxh != '') {
  2516. $where .= " and sfxh = '$sfxh'";
  2517. }
  2518. if ($so) {
  2519. $where .= " and shipremarks like '%$so%'";
  2520. }
  2521. if ($source) {
  2522. if ($source == '2d') {
  2523. $where .= " and source >= '2'";
  2524. } else {
  2525. $where .= " and source = '$source'";
  2526. }
  2527. }
  2528. if (isset($_SESSION['api'])) {
  2529. foreach ($user as $value) {
  2530. $fgshop .= " shop = " . $value . " or";
  2531. }
  2532. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2533. }
  2534. if ($orderurl) {
  2535. $url = $this->orderurl->read($orderurl);
  2536. $where .= " and link like '%" . $url['url'] . "%'";
  2537. }
  2538. if($productid){
  2539. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2540. }
  2541. //数据排序
  2542. $order_str = "librarytime desc";
  2543. if (empty($page)) {
  2544. $start = 0;
  2545. $perpage = 1;
  2546. } else {
  2547. $start = ($page - 1) * $perpage;
  2548. }
  2549. //取得信息列表
  2550. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2551. //格式化数据
  2552. foreach ($info_list as $key => $value) {
  2553. $shop = $this->shop->read($value['shop']);
  2554. $info_list[$key]['shop'] = $shop['shopname'];
  2555. $express = $this->express->read($value['express']);
  2556. $info_list[$key]['express'] = $express['servicename'];
  2557. $warehouse = $this->warehouse->read($value['type']);
  2558. $info_list[$key]['type'] = $warehouse['title'];
  2559. if ($value['librarytime'] == '0') {
  2560. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2561. } else {
  2562. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2563. }
  2564. }
  2565. $total = $this->$sj->find_count($where);
  2566. $pagenum = ceil($total / $perpage);
  2567. $over = $total - ($start + $perpage);
  2568. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2569. echo json_encode($rows);
  2570. exit;
  2571. }
  2572. $this->data['express'] = $this->express->find_all();
  2573. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2574. $this->data['wlshop'] = $wlshop;
  2575. $user = $this->user->get_api($_SESSION['api']);
  2576. $powerid = $this->power->read($user['power']);
  2577. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2578. $pid = '';
  2579. foreach ($powertext as $v) {
  2580. $pid .= " id = " . $v . " or";
  2581. }
  2582. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2583. $this->data['fullorderexcel'] = $fullorderexcel;
  2584. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2585. $this->data['orderurl'] = $orderurl;
  2586. $this->_Template('whlabel_outorder', $this->data);
  2587. }
  2588. //tt出库
  2589. public function _toutorder()
  2590. {
  2591. $fgshop = "";
  2592. $sid = "";
  2593. if (isset($_SESSION['api'])) {
  2594. $user = $this->user->get_api($_SESSION['api']);
  2595. $usp = $user;
  2596. $user = explode('|', trim($user['shop'], '|'));
  2597. foreach ($user as $value) {
  2598. $fgshop .= " shop = " . $value . " or";
  2599. $sid .= " id = " . $value . " or";
  2600. }
  2601. } else {
  2602. echo "请重新登录";
  2603. die;
  2604. }
  2605. $post = $this->input->post(NULL, TRUE);
  2606. if (isset($post['page'])) {
  2607. $page = $this->input->post('page', true);
  2608. $perpage = $this->input->post('perpage', true);
  2609. $warehouse = $this->input->post('warehouse', true);
  2610. $xztime = $this->input->post('xztime', true);
  2611. $timetk = $this->input->post('timetkk', true);
  2612. $timetj = $this->input->post('timetjj', true);
  2613. $shop = $this->input->post('shop', true);
  2614. $source = $this->input->post('source', true);
  2615. $orderinfo = $this->input->post('orderinfo', true);
  2616. $number = $this->input->post('number', true);
  2617. $sfxh = $this->input->post('sfxh', true);
  2618. $express = $this->input->post('express', true);
  2619. $waybill = $this->input->post('waybill', true);
  2620. $library = $this->input->post('library', true);
  2621. $country = $this->input->post('country', true);
  2622. $so = $this->input->post('so', true);
  2623. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2624. $print = $this->input->post('print', true);
  2625. $state = $this->input->post('state', true);
  2626. $orderurl = $this->input->post('orderurl', true);
  2627. $timetk = strtotime($timetk);
  2628. $timetj = strtotime($timetj);
  2629. /**
  2630. $sj = $this->input->post('sj',true);
  2631. if($sj)
  2632. {
  2633. $sj = $this->input->post('sj',true);
  2634. }
  2635. else
  2636. {
  2637. $sj = "fullorder";
  2638. }
  2639. **/
  2640. $sj = "fullordertt";
  2641. $where = "1=1";
  2642. if ($warehouse) {
  2643. $where .= " and type = '$warehouse'";
  2644. }
  2645. if ($timetk && $timetj) {
  2646. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2647. }
  2648. if ($orderinfo) {
  2649. $where .= " and orderinfo = '$orderinfo'";
  2650. }
  2651. if ($number) {
  2652. $where .= " and number = '$number'";
  2653. }
  2654. if ($express) {
  2655. $where .= " and express = '$express'";
  2656. }
  2657. if ($waybill) {
  2658. $where .= " and waybill = '$waybill'";
  2659. }
  2660. if ($library) {
  2661. $where .= " and library = '$library'";
  2662. }
  2663. if ($print) {
  2664. $where .= " and print = '$print'";
  2665. }
  2666. if ($libraryconfirm) {
  2667. $where .= " and libraryconfirm = '$libraryconfirm'";
  2668. }
  2669. if ($state) {
  2670. $where .= " and state = '$state'";
  2671. }
  2672. if ($shop) {
  2673. $where .= " and shop = '$shop'";
  2674. }
  2675. if ($country) {
  2676. $where .= " and country = '$country'";
  2677. }
  2678. if ($sfxh != '') {
  2679. $where .= " and sfxh = '$sfxh'";
  2680. }
  2681. if ($so) {
  2682. $where .= " and shipremarks like '%$so%'";
  2683. }
  2684. if ($source) {
  2685. if ($source == '2d') {
  2686. $where .= " and source >= '2'";
  2687. } else {
  2688. $where .= " and source = '$source'";
  2689. }
  2690. }
  2691. if (isset($_SESSION['api'])) {
  2692. foreach ($user as $value) {
  2693. $fgshop .= " shop = " . $value . " or";
  2694. }
  2695. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2696. }
  2697. if ($orderurl) {
  2698. $url = $this->orderurl->read($orderurl);
  2699. $where .= " and link like '%" . $url['url'] . "%'";
  2700. }
  2701. //数据排序
  2702. $order_str = "librarytime desc";
  2703. if (empty($page)) {
  2704. $start = 0;
  2705. $perpage = 1;
  2706. } else {
  2707. $start = ($page - 1) * $perpage;
  2708. }
  2709. //取得信息列表
  2710. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2711. //格式化数据
  2712. foreach ($info_list as $key => $value) {
  2713. $shop = $this->shop->read($value['shop']);
  2714. $info_list[$key]['shop'] = $shop['shopname'];
  2715. $express = $this->express->read($value['express']);
  2716. $info_list[$key]['express'] = $express['servicename'];
  2717. $warehouse = $this->warehouse->read($value['type']);
  2718. $info_list[$key]['type'] = $warehouse['title'];
  2719. if ($value['librarytime'] == '0') {
  2720. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2721. } else {
  2722. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2723. }
  2724. }
  2725. $total = $this->$sj->find_count($where);
  2726. $pagenum = ceil($total / $perpage);
  2727. $over = $total - ($start + $perpage);
  2728. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2729. echo json_encode($rows);
  2730. exit;
  2731. }
  2732. $this->data['express'] = $this->express->find_all();
  2733. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2734. $this->data['wlshop'] = $wlshop;
  2735. $user = $this->user->get_api($_SESSION['api']);
  2736. $powerid = $this->power->read($user['power']);
  2737. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2738. $pid = '';
  2739. foreach ($powertext as $v) {
  2740. $pid .= " id = " . $v . " or";
  2741. }
  2742. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2743. $this->data['fullorderexcel'] = $fullorderexcel;
  2744. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2745. $this->data['orderurl'] = $orderurl;
  2746. $this->_Template('whlabel_toutorder', $this->data);
  2747. }
  2748. //tt出库
  2749. public function _aoutorder()
  2750. {
  2751. if (isset($_SESSION['api'])) {
  2752. $user = $this->user->get_api($_SESSION['api']);
  2753. $usp = $user;
  2754. $fgshop = "";
  2755. $sid = "";
  2756. $user = explode('|', trim($user['shop'], '|'));
  2757. foreach ($user as $value) {
  2758. $fgshop .= " shop = " . $value . " or";
  2759. $sid .= " id = " . $value . " or";
  2760. }
  2761. } else {
  2762. echo "请重新登录";
  2763. }
  2764. $post = $this->input->post(NULL, TRUE);
  2765. if (isset($post['page'])) {
  2766. $page = $this->input->post('page', true);
  2767. $perpage = $this->input->post('perpage', true);
  2768. $warehouse = $this->input->post('warehouse', true);
  2769. $xztime = $this->input->post('xztime', true);
  2770. $timetk = $this->input->post('timetkk', true);
  2771. $timetj = $this->input->post('timetjj', true);
  2772. $shop = $this->input->post('shop', true);
  2773. $source = $this->input->post('source', true);
  2774. $orderinfo = $this->input->post('orderinfo', true);
  2775. $number = $this->input->post('number', true);
  2776. $sfxh = $this->input->post('sfxh', true);
  2777. $express = $this->input->post('express', true);
  2778. $waybill = $this->input->post('waybill', true);
  2779. $library = $this->input->post('library', true);
  2780. $country = $this->input->post('country', true);
  2781. $so = $this->input->post('so', true);
  2782. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2783. $print = $this->input->post('print', true);
  2784. $state = $this->input->post('state', true);
  2785. $orderurl = $this->input->post('orderurl', true);
  2786. $timetk = strtotime($timetk);
  2787. $timetj = strtotime($timetj);
  2788. /**
  2789. $sj = $this->input->post('sj',true);
  2790. if($sj)
  2791. {
  2792. $sj = $this->input->post('sj',true);
  2793. }
  2794. else
  2795. {
  2796. $sj = "fullorder";
  2797. }
  2798. **/
  2799. $sj = "fullorderamz";
  2800. $where = "1=1";
  2801. if ($warehouse) {
  2802. $where .= " and type = '$warehouse'";
  2803. }
  2804. if ($timetk && $timetj) {
  2805. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2806. }
  2807. if ($orderinfo) {
  2808. $where .= " and orderinfo = '$orderinfo'";
  2809. }
  2810. if ($number) {
  2811. $where .= " and number = '$number'";
  2812. }
  2813. if ($express) {
  2814. $where .= " and express = '$express'";
  2815. }
  2816. if ($waybill) {
  2817. $where .= " and waybill = '$waybill'";
  2818. }
  2819. if ($library) {
  2820. $where .= " and library = '$library'";
  2821. }
  2822. if ($print) {
  2823. $where .= " and print = '$print'";
  2824. }
  2825. if ($libraryconfirm) {
  2826. $where .= " and libraryconfirm = '$libraryconfirm'";
  2827. }
  2828. if ($state) {
  2829. $where .= " and state = '$state'";
  2830. }
  2831. if ($shop) {
  2832. $where .= " and shop = '$shop'";
  2833. }
  2834. if ($country) {
  2835. $where .= " and country = '$country'";
  2836. }
  2837. if ($sfxh != '') {
  2838. $where .= " and sfxh = '$sfxh'";
  2839. }
  2840. if ($so) {
  2841. $where .= " and shipremarks like '%$so%'";
  2842. }
  2843. if ($source) {
  2844. if ($source == '2d') {
  2845. $where .= " and source >= '2'";
  2846. } else {
  2847. $where .= " and source = '$source'";
  2848. }
  2849. }
  2850. if (isset($_SESSION['api'])) {
  2851. foreach ($user as $value) {
  2852. $fgshop .= " shop = " . $value . " or";
  2853. }
  2854. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2855. }
  2856. if ($orderurl) {
  2857. $url = $this->orderurl->read($orderurl);
  2858. $where .= " and link like '%" . $url['url'] . "%'";
  2859. }
  2860. //数据排序
  2861. $order_str = "librarytime desc";
  2862. if (empty($page)) {
  2863. $start = 0;
  2864. $perpage = 1;
  2865. } else {
  2866. $start = ($page - 1) * $perpage;
  2867. }
  2868. //取得信息列表
  2869. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2870. //格式化数据
  2871. foreach ($info_list as $key => $value) {
  2872. $shop = $this->shop->read($value['shop']);
  2873. $info_list[$key]['shop'] = $shop['shopname'];
  2874. $express = $this->express->read($value['express']);
  2875. $info_list[$key]['express'] = $express['servicename'];
  2876. $warehouse = $this->warehouse->read($value['type']);
  2877. $info_list[$key]['type'] = $warehouse['title'];
  2878. if ($value['librarytime'] == '0') {
  2879. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2880. } else {
  2881. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2882. }
  2883. }
  2884. $total = $this->$sj->find_count($where);
  2885. $pagenum = ceil($total / $perpage);
  2886. $over = $total - ($start + $perpage);
  2887. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2888. echo json_encode($rows);
  2889. exit;
  2890. }
  2891. $this->data['express'] = $this->express->find_all();
  2892. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2893. $this->data['wlshop'] = $wlshop;
  2894. $user = $this->user->get_api($_SESSION['api']);
  2895. $powerid = $this->power->read($user['power']);
  2896. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2897. $pid = '';
  2898. foreach ($powertext as $v) {
  2899. $pid .= " id = " . $v . " or";
  2900. }
  2901. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2902. $this->data['fullorderexcel'] = $fullorderexcel;
  2903. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2904. $this->data['orderurl'] = $orderurl;
  2905. $this->_Template('whlabel_aoutorder', $this->data);
  2906. }
  2907. //速卖通出库订单
  2908. public function _soutorder()
  2909. {
  2910. if (isset($_SESSION['api'])) {
  2911. $user = $this->user->get_api($_SESSION['api']);
  2912. $usp = $user;
  2913. $fgshop = "";
  2914. $sid = "";
  2915. $user = explode('|', trim($user['shop'], '|'));
  2916. foreach ($user as $value) {
  2917. $sid .= " id = " . $value . " or";
  2918. }
  2919. }
  2920. $post = $this->input->post(NULL, TRUE);
  2921. if (isset($post['page'])) {
  2922. $page = $this->input->post('page', true);
  2923. $perpage = $this->input->post('perpage', true);
  2924. $warehouse = $this->input->post('warehouse', true);
  2925. $xztime = $this->input->post('xztime', true);
  2926. $timetk = $this->input->post('timetkk', true);
  2927. $timetj = $this->input->post('timetjj', true);
  2928. $shop = $this->input->post('shop', true);
  2929. $source = $this->input->post('source', true);
  2930. $orderinfo = $this->input->post('orderinfo', true);
  2931. $number = $this->input->post('number', true);
  2932. $express = $this->input->post('express', true);
  2933. $waybill = $this->input->post('waybill', true);
  2934. $library = $this->input->post('library', true);
  2935. $country = $this->input->post('country', true);
  2936. $sfxh = $this->input->post('sfxh', true);
  2937. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2938. $print = $this->input->post('print', true);
  2939. $state = $this->input->post('state', true);
  2940. $so = $this->input->post('so', true);
  2941. $timetk = strtotime($timetk);
  2942. $timetj = strtotime($timetj);
  2943. /**
  2944. $sj = $this->input->post('sj',true);
  2945. if($sj)
  2946. {
  2947. $sj = $this->input->post('sj',true);
  2948. }
  2949. else
  2950. {
  2951. $sj = "fullorder";
  2952. }
  2953. **/
  2954. $sj = "fullordersmt";
  2955. $where = "1=1";
  2956. if ($warehouse) {
  2957. $where .= " and type = '$warehouse'";
  2958. }
  2959. if ($timetk && $timetj) {
  2960. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2961. }
  2962. if ($orderinfo) {
  2963. $where .= " and orderinfo = '$orderinfo'";
  2964. }
  2965. if ($number) {
  2966. $where .= " and number = '$number'";
  2967. }
  2968. if ($express) {
  2969. $where .= " and express = '$express'";
  2970. }
  2971. if ($waybill) {
  2972. $where .= " and waybill = '$waybill'";
  2973. }
  2974. if ($library) {
  2975. $where .= " and library = '$library'";
  2976. }
  2977. if ($print) {
  2978. $where .= " and print = '$print'";
  2979. }
  2980. if ($libraryconfirm) {
  2981. $where .= " and libraryconfirm = '$libraryconfirm'";
  2982. }
  2983. if ($state) {
  2984. $where .= " and state = '$state'";
  2985. }
  2986. if ($shop) {
  2987. $where .= " and shop = '$shop'";
  2988. }
  2989. if ($sfxh != '') {
  2990. $where .= " and sfxh = '$sfxh'";
  2991. }
  2992. if ($so) {
  2993. $where .= " and shipremarks like '%$so%'";
  2994. }
  2995. if ($source) {
  2996. $where .= " and source = '$source'";
  2997. }
  2998. if ($country) {
  2999. $where .= " and country = '$country'";
  3000. } else {
  3001. if (isset($_SESSION['api'])) {
  3002. foreach ($user as $value) {
  3003. $fgshop .= " shop = " . $value . " or";
  3004. }
  3005. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3006. }
  3007. }
  3008. //数据排序
  3009. $order_str = "librarytime desc";
  3010. if (empty($page)) {
  3011. $start = 0;
  3012. $perpage = 1;
  3013. } else {
  3014. $start = ($page - 1) * $perpage;
  3015. }
  3016. //取得信息列表
  3017. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3018. //格式化数据
  3019. foreach ($info_list as $key => $value) {
  3020. $shop = $this->shop->read($value['shop']);
  3021. $info_list[$key]['shop'] = $shop['shopname'];
  3022. $express = $this->express->read($value['express']);
  3023. $info_list[$key]['express'] = $express['servicename'];
  3024. $warehouse = $this->warehouse->read($value['type']);
  3025. $info_list[$key]['type'] = $warehouse['title'];
  3026. if ($value['librarytime'] == '0') {
  3027. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3028. } else {
  3029. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3030. }
  3031. }
  3032. $total = $this->$sj->find_count($where);
  3033. $pagenum = ceil($total / $perpage);
  3034. $over = $total - ($start + $perpage);
  3035. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3036. echo json_encode($rows);
  3037. exit;
  3038. }
  3039. $this->data['express'] = $this->express->find_all();
  3040. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3041. $this->data['wlshop'] = $wlshop;
  3042. $user = $this->user->get_api($_SESSION['api']);
  3043. $powerid = $this->power->read($user['power']);
  3044. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3045. $pid = '';
  3046. foreach ($powertext as $v) {
  3047. $pid .= " id = " . $v . " or";
  3048. }
  3049. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3050. $this->data['fullorderexcel'] = $fullorderexcel;
  3051. $this->_Template('whlabel_soutorder', $this->data);
  3052. }
  3053. //订单退库
  3054. public function _retreat()
  3055. {
  3056. $post = $this->input->post(NULL, TRUE);
  3057. if (isset($post['page'])) {
  3058. $page = $this->input->post('page', true);
  3059. $perpage = $this->input->post('perpage', true);
  3060. $warehouse = $this->input->post('warehouse', true);
  3061. $timetk = $this->input->post('timetk', true);
  3062. $timetj = $this->input->post('timetj', true);
  3063. $shop = $this->input->post('shop', true);
  3064. $source = $this->input->post('source', true);
  3065. $state = $this->input->post('state', true);
  3066. $review = $this->input->post('review', true);
  3067. $state = $this->input->post('state', true);
  3068. $express = $this->input->post('express', true);
  3069. $orderinfo = $this->input->post('orderinfo', true);
  3070. $user = $this->input->post('user', true);
  3071. $name = $this->input->post('name', true);
  3072. $waybill = $this->input->post('waybill', true);
  3073. $timetk = strtotime($timetk);
  3074. $timetj = strtotime($timetj);
  3075. $where = "(state=206 or state=210) and mergeid = 0";
  3076. if ($warehouse) {
  3077. $where .= " and state = '$warehouse'";
  3078. }
  3079. if ($timetk && $timetj) {
  3080. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3081. }
  3082. if ($shop) {
  3083. $where .= " and shop = '$shop'";
  3084. }
  3085. if ($source) {
  3086. $where .= " and source = '$source'";
  3087. }
  3088. if ($state) {
  3089. $where .= " and state = '$state'";
  3090. }
  3091. if ($review) {
  3092. $where .= " and review = '$review'";
  3093. }
  3094. if ($state) {
  3095. $where .= " and state = '$state'";
  3096. }
  3097. if ($express) {
  3098. $where .= " and express = '$express'";
  3099. }
  3100. if ($orderinfo) {
  3101. $where .= " and orderinfo = '$orderinfo'";
  3102. }
  3103. if ($user) {
  3104. $where .= " and user = '$user'";
  3105. }
  3106. if ($name) {
  3107. $where .= " and name = '$name'";
  3108. }
  3109. if ($waybill) {
  3110. $where .= " and waybill = '$waybill'";
  3111. }
  3112. //数据排序
  3113. $order_str = "id desc";
  3114. if (empty($page)) {
  3115. $start = 0;
  3116. $perpage = 1;
  3117. } else {
  3118. $start = ($page - 1) * $perpage;
  3119. }
  3120. //取得信息列表
  3121. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3122. //格式化数据
  3123. foreach ($info_list as $key => $value) {
  3124. $shop = $this->shop->read($value['shop']);
  3125. $info_list[$key]['shop'] = $shop['shopname'];
  3126. $warehouse = $this->warehouse->read($value['warehouse']);
  3127. $info_list[$key]['warehouse'] = $warehouse['title'];
  3128. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3129. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3130. if ($value['waybill'] == 0) {
  3131. $info_list[$key]['waybill'] = "";
  3132. }
  3133. $express = $this->express->read($value['express']);
  3134. $info_list[$key]['express'] = $express['title'];
  3135. $typeclass = $this->typeclass->read($value['state']);
  3136. $info_list[$key]['state'] = $typeclass['title'];
  3137. }
  3138. $total = $this->fullorder->find_count($where);
  3139. $pagenum = ceil($total / $perpage);
  3140. $over = $total - ($start + $perpage);
  3141. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3142. echo json_encode($rows);
  3143. exit;
  3144. }
  3145. $this->data['express'] = $this->express->find_all();
  3146. $this->_Template('whlabel_retreat', $this->data);
  3147. }
  3148. //退库标签浏览
  3149. public function _retreatlk()
  3150. {
  3151. $post = $this->input->post(NULL, TRUE);
  3152. if (isset($post['page'])) {
  3153. $page = $this->input->post('page', true);
  3154. $perpage = $this->input->post('perpage', true);
  3155. $timetk = $this->input->post('timetk', true);
  3156. $timetj = $this->input->post('timetj', true);
  3157. $sku = $this->input->post('sku', true);
  3158. $warehouse = $this->input->post('warehouse', true);
  3159. $purchase = $this->input->post('purchase', true);
  3160. $orderinfo = $this->input->post('orderinfo', true);
  3161. $waybill = $this->input->post('waybill', true);
  3162. $category = $this->input->post('category', true);
  3163. $size = $this->input->post('size', true);
  3164. $grade = $this->input->post('grade', true);
  3165. $color = $this->input->post('color', true);
  3166. $lowe = $this->input->post('lowe', true);
  3167. $state = $this->input->post('state', true);
  3168. $timetk = strtotime($timetk);
  3169. $timetj = strtotime($timetj);
  3170. $where = "state=2";
  3171. if ($timetk && $timetj) {
  3172. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3173. }
  3174. if ($sku) {
  3175. $where .= " and sku = '$sku'";
  3176. }
  3177. if ($warehouse) {
  3178. $where .= " and warehouse = '$warehouse'";
  3179. }
  3180. if ($purchase) {
  3181. $where .= " and purchase = '$purchase'";
  3182. }
  3183. if ($orderinfo) {
  3184. $where .= " and orderinfo = '$orderinfo'";
  3185. }
  3186. if ($waybill) {
  3187. $where .= " and waybill = '$waybill'";
  3188. }
  3189. if ($category) {
  3190. $where .= " and features like '%-$category-%'";
  3191. }
  3192. if ($size) {
  3193. $where .= " and features like '%-$size-%'";
  3194. }
  3195. if ($grade) {
  3196. $where .= " and features like '%-$grade-%'";
  3197. }
  3198. if ($color) {
  3199. $where .= " and features like '%-$color-%'";
  3200. }
  3201. if ($lowe) {
  3202. $where .= " and features like '%-$lowe-%'";
  3203. }
  3204. //数据排序
  3205. $order_str = "time desc";
  3206. if (empty($page)) {
  3207. $start = 0;
  3208. $perpage = 1;
  3209. } else {
  3210. $start = ($page - 1) * $perpage;
  3211. }
  3212. //取得信息列表
  3213. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3214. foreach ($info_list as $key => $value) {
  3215. $warehouse = $this->warehouse->read($value['warehouse']);
  3216. $info_list[$key]['warehouse'] = $warehouse['title'];
  3217. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3218. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3219. $purchase = $this->purchase->read($value['purchase']);
  3220. $info_list[$key]['purchase'] = $purchase['title'];
  3221. if ($value['outk'] != 0) {
  3222. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3223. } else {
  3224. $info_list[$key]['outk'] = "";
  3225. }
  3226. if ($value['retreat'] != 0) {
  3227. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3228. } else {
  3229. $info_list[$key]['retreat'] = "";
  3230. }
  3231. if ($value['orderinfo'] == 0) {
  3232. $info_list[$key]['orderinfo'] = "";
  3233. }
  3234. if ($value['waybill'] == 0) {
  3235. $info_list[$key]['waybill'] = "";
  3236. }
  3237. }
  3238. $total = $this->whlabel->find_count($where);
  3239. $pagenum = ceil($total / $perpage);
  3240. $over = $total - ($start + $perpage);
  3241. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3242. echo json_encode($rows);
  3243. exit;
  3244. }
  3245. $this->_Template('whlabel_retreatlk', $this->data);
  3246. }
  3247. //更换标签及浏览
  3248. public function _change()
  3249. {
  3250. $post = $this->input->post(NULL, TRUE);
  3251. if (isset($post['page'])) {
  3252. $page = $this->input->post('page', true);
  3253. $perpage = $this->input->post('perpage', true);
  3254. $timetk = $this->input->post('timetk', true);
  3255. $timetj = $this->input->post('timetj', true);
  3256. $label = $this->input->post('label', true);
  3257. $oldlabel = $this->input->post('oldlabel', true);
  3258. $timetk = strtotime($timetk);
  3259. $timetj = strtotime($timetj);
  3260. $where = "state=10 ";
  3261. if ($timetk && $timetj) {
  3262. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3263. }
  3264. if ($label) {
  3265. $where .= " and label = '$label'";
  3266. }
  3267. if ($oldlabel) {
  3268. $where .= " and oldlabel = '$oldlabel'";
  3269. }
  3270. //数据排序
  3271. $order_str = "time asc";
  3272. if (empty($page)) {
  3273. $start = 0;
  3274. $perpage = 1;
  3275. } else {
  3276. $start = ($page - 1) * $perpage;
  3277. }
  3278. //取得信息列表
  3279. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3280. foreach ($info_list as $key => $value) {
  3281. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3282. }
  3283. $total = $this->whlabel->find_count($where);
  3284. $pagenum = ceil($total / $perpage);
  3285. $over = $total - ($start + $perpage);
  3286. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3287. echo json_encode($rows);
  3288. exit;
  3289. }
  3290. $this->_Template('whlabel_change', $this->data);
  3291. }
  3292. //产品标签
  3293. public function _cpbqdc()
  3294. {
  3295. if (isset($_GET['excel'])) {
  3296. $where = "1=1";
  3297. //数据排序
  3298. $order_str = "id desc";
  3299. if (empty($page)) {
  3300. $start = 0;
  3301. $perpage = 1;
  3302. } else {
  3303. $start = ($page - 1) * $perpage;
  3304. }
  3305. $warehouse = $this->input->get('warehouse', true);
  3306. $state = $this->input->get('state', true);
  3307. $timetk = $this->input->get('timetkk', true);
  3308. $timetj = $this->input->get('timetjj', true);
  3309. $timetk = strtotime($timetk);
  3310. $timetj = strtotime($timetj);
  3311. if ($warehouse) {
  3312. $where .= " and warehouse = '$warehouse'";
  3313. }
  3314. if ($state || $state == 0) {
  3315. $where .= " and state = '$state'";
  3316. }
  3317. if ($timetk && $timetj) {
  3318. $where .= " and time > '$timetk' and time < '$timetj'";
  3319. }
  3320. //取得信息列表
  3321. $info_list = $this->whlabel->find_all($where, '*');
  3322. $rows = array();
  3323. $list = array();
  3324. foreach ($info_list as $key => $value) {
  3325. $rows[$value['time']] = $value; //所有数据sku
  3326. }
  3327. foreach ($rows as $value) {
  3328. $warehouse = $this->warehouse->read($value['warehouse']);
  3329. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3330. $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);
  3331. }
  3332. $title = "产品标签统计表";
  3333. $titlename = "<table border=1>
  3334. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3335. <tr align='center'>
  3336. <td>仓库</td>
  3337. <td>SKU</td>
  3338. <td>产品</td>
  3339. <td>入库时间</td>
  3340. <td>操作时间</td>
  3341. <td>备注</td>
  3342. <td>数量</td>
  3343. </tr>
  3344. </table>";
  3345. $filename = $title . ".xls";
  3346. $tail = "";
  3347. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3348. }
  3349. }
  3350. //进销存导出
  3351. public function _exceljxc()
  3352. {
  3353. $classid = $this->classid->sku();
  3354. $pm = $classid;
  3355. $typeclass = array();
  3356. $tc = $this->typeclass->find_all();
  3357. foreach ($tc as $v) {
  3358. $typeclass[$v['id']] = $v;
  3359. }
  3360. $prc = array();
  3361. $purchase = $this->purchase->find_all();
  3362. foreach ($purchase as $k => $v) {
  3363. $prc[$v['id']] = $v['title'];
  3364. }
  3365. if (isset($_GET['excel'])) {
  3366. $where = "sku != 'Preset'";
  3367. //数据排序
  3368. $order_str = "id desc";
  3369. if (empty($page)) {
  3370. $start = 0;
  3371. $perpage = 1;
  3372. } else {
  3373. $start = ($page - 1) * $perpage;
  3374. }
  3375. $category = $this->input->get('category', true);
  3376. $warehouse = $this->input->get('warehouse', true);
  3377. $excelid = $this->input->get('sid', true);
  3378. if ($category) {
  3379. $where .= " and features like '%-$category-%'";
  3380. }
  3381. if ($warehouse) {
  3382. $where .= " and warehouse = '$warehouse'";
  3383. }
  3384. $xzid = '';
  3385. if ($excelid) {
  3386. $excelid = explode(',', trim($excelid, ','));
  3387. foreach ($excelid as $key => $value) {
  3388. $xzid .= " id = " . $value . " or";
  3389. }
  3390. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3391. }
  3392. //取得信息列表
  3393. /**
  3394. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3395. $rows = array();$list = array();
  3396. foreach ($info_list as $key=>$value)
  3397. {
  3398. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3399. }
  3400. **/
  3401. $wt = array();
  3402. $whlabel_type = $this->whlabel_type->find_all();
  3403. foreach ($whlabel_type as $v) {
  3404. $wt[$v['id']] = $v['title'];
  3405. }
  3406. $wh = array();
  3407. $w = $this->warehouse->find_all('1=1', 'id,title');
  3408. foreach ($w as $v) {
  3409. $wh[$v['id']] = $v['title'];
  3410. }
  3411. $list = array();
  3412. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3413. foreach ($rows as $key => $value) {
  3414. if (isset($wt[$value['type']])) {
  3415. $rows[$key]['type'] = $wt[$value['type']];
  3416. } else {
  3417. $rows[$key]['type'] = '未设置';
  3418. }
  3419. $bm = '03';
  3420. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3421. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3422. $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');
  3423. $details = array();
  3424. $cpid = array();
  3425. $cpbz = array();
  3426. $c = 0;
  3427. $g = 0;
  3428. $x = 0;
  3429. $t = 0;
  3430. $s = 0;
  3431. $q = 0;
  3432. foreach ($sd as $k => $v) {
  3433. if ($v['state'] == 0) {
  3434. $c++;
  3435. if ($v['cpid'] != 0) {
  3436. $cpid[$v['cpid']] = $v['cpid'];
  3437. }
  3438. if ($v['cpbz'] != '') {
  3439. $cpbz[$v['cpbz']] = $v['cpbz'];
  3440. }
  3441. }
  3442. if ($v['state'] != 9) {
  3443. $g++;
  3444. }
  3445. if ($v['state'] == 1) {
  3446. $x++;
  3447. }
  3448. if ($v['state'] == 2) {
  3449. $t++;
  3450. }
  3451. if ($v['state'] == 8) {
  3452. $s++;
  3453. }
  3454. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3455. $q++;
  3456. }
  3457. $details[$v['details']] = $v['details'];
  3458. }
  3459. $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'] . '"');
  3460. $rows[$key]['details'] = implode("、", $details);
  3461. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3462. $number = $value['number'];
  3463. $ftime = time() - 15 * 24 * 3600;
  3464. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3465. $rows[$key]['number'] = $g;
  3466. $rows[$key]['c'] = $c;
  3467. $rows[$key]['x'] = $x;
  3468. $rows[$key]['t'] = $t;
  3469. $rows[$key]['s'] = $s;
  3470. $rows[$key]['q'] = $q;
  3471. $rows[$key]['z'] = $z;
  3472. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3473. $features = explode('-', trim($features, '-'));
  3474. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3475. // $pm = $classid;
  3476. // $jm = $classid;
  3477. // foreach($features as $k=>$v)
  3478. // {
  3479. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3480. // {
  3481. // if($typeclass[$v]['bm'] != '')
  3482. // {
  3483. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3484. // }
  3485. // }
  3486. // if($v != 0)
  3487. // {
  3488. // if(!isset($typeclass[$v]))
  3489. // {
  3490. // continue;
  3491. // }
  3492. // if(isset($pm[$typeclass[$v]['classid']]))
  3493. // {
  3494. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3495. // {
  3496. // $tz = explode('|',$typeclass[$v]['zh']);
  3497. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3498. // }
  3499. // else
  3500. // {
  3501. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3502. // }
  3503. // }
  3504. // if(isset($jm[$typeclass[$v]['classid']]))
  3505. // {
  3506. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3507. // }
  3508. // }
  3509. // }
  3510. // $jm = array_filter($jm);
  3511. // $rows[$key]['bs'] = implode("-",$jm);
  3512. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3513. // $zh = implode(" ",$pm);
  3514. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3515. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3516. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3517. // $rows[$key]['features'] = $zh;
  3518. }
  3519. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3520. $final_list = [];
  3521. foreach ($list as $k => $v) {
  3522. if (empty($v['sku'])) {
  3523. continue;
  3524. }
  3525. $final_list[] = [
  3526. "warehouse" => $v["warehouse"],
  3527. "purchase" => $v["purchase"],
  3528. "details" => $v["details"],
  3529. "cpid" => $v["cpid"],
  3530. "dbcontent" => $v["dbcontent"],
  3531. "sku" => $v["sku"],
  3532. "cs" => $v["bm"],
  3533. "bs" => $v["jm"],
  3534. "title" => $v["title"],
  3535. "features" => $v["pm"],
  3536. "cpbz" => $v["cpbz"],
  3537. "sm" => $v["sm"],
  3538. "type" => $v["type"],
  3539. "number" => $v["number"],
  3540. "c" => $v["c"],
  3541. "x" => $v["x"],
  3542. "t" => $v["t"],
  3543. "s" => $v["s"],
  3544. "q" => $v["q"],
  3545. "z" => $v["z"],
  3546. "weight" => $v['weight'],
  3547. ];
  3548. }
  3549. $title = "总进销存统计表";
  3550. $titlename = "<table border=1>
  3551. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3552. <tr align='center'>
  3553. <td>仓库</td>
  3554. <td>供应商</td>
  3555. <td>位置</td>
  3556. <td>库存编码</td>
  3557. <td>类目</td>
  3558. <td>SKU</td>
  3559. <td>用友编码</td>
  3560. <td>用友料号</td>
  3561. <td>商品名称</td>
  3562. <td>商品中文</td>
  3563. <td>产品备注</td>
  3564. <td>说明</td>
  3565. <td>类型</td>
  3566. <td>入库总量</td>
  3567. <td>库存数量</td>
  3568. <td>销售数量</td>
  3569. <td>退货数量</td>
  3570. <td>删除数量</td>
  3571. <td>其它操作</td>
  3572. <td>占单数量</td>
  3573. <td>重量(g)</td>
  3574. </tr>
  3575. </table>";
  3576. $filename = $title . ".xls";
  3577. $tail = "";
  3578. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3579. }
  3580. }
  3581. //入库导出
  3582. public function _excelr()
  3583. {
  3584. if (isset($_GET['excel'])) {
  3585. $category = $this->input->get('category', true);
  3586. $size = $this->input->get('size', true);
  3587. $grade = $this->input->get('grade', true);
  3588. $color = $this->input->get('color', true);
  3589. $lowe = $this->input->get('lowe', true);
  3590. $sku = $this->input->get('sku', true);
  3591. $warehouse = $this->input->get('warehouse', true);
  3592. $purchase = $this->input->get('purchase', true);
  3593. $ktime = $this->input->get('ktime', true);
  3594. $jtime = $this->input->get('jtime', true);
  3595. $ktime = strtotime($ktime);
  3596. $jtime = strtotime($jtime);
  3597. $where = "1=1";
  3598. $gj = "";
  3599. $ck = "";
  3600. if ($category) {
  3601. $where .= " and features like '%-$category-%'";
  3602. }
  3603. if ($size) {
  3604. $where .= " and features like '%-$size-%'";
  3605. }
  3606. if ($grade) {
  3607. $where .= " and features like '%-$grade-%'";
  3608. }
  3609. if ($color) {
  3610. $where .= " and features like '%-$color-%'";
  3611. }
  3612. if ($lowe) {
  3613. $where .= " and features like '%-$lowe-%'";
  3614. }
  3615. if ($warehouse) {
  3616. $where .= " and warehouse = '$warehouse'";
  3617. }
  3618. if ($purchase) {
  3619. $where .= " and purchase = '$purchase'";
  3620. }
  3621. if ($sku) {
  3622. $where .= " and sku = '$sku'";
  3623. }
  3624. if ($ktime && $jtime) {
  3625. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3626. }
  3627. //数据排序
  3628. $order_str = "id desc";
  3629. if (empty($page)) {
  3630. $start = 0;
  3631. $perpage = 1;
  3632. } else {
  3633. $start = ($page - 1) * $perpage;
  3634. }
  3635. $list = array();
  3636. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3637. foreach ($rows as $value) {
  3638. $ck = $this->warehouse->read($value['warehouse']);
  3639. $warehouse = $ck['title'];
  3640. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3641. $retreatwarehouse = $tkck['title'];
  3642. $gy = $this->purchase->read($value['purchase']);
  3643. $purchase = $gy['title'];
  3644. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3645. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3646. }
  3647. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3648. $titlename = "<table border=1>
  3649. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3650. <tr align='center'>
  3651. <td>仓库</td>
  3652. <td>SKU</td>
  3653. <td>产品</td>
  3654. <td>时间</td>
  3655. <td>数量</td>
  3656. </tr>
  3657. </table>";
  3658. $filename = $title . ".xls";
  3659. $tail = "";
  3660. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3661. }
  3662. }
  3663. //出库、退库导出
  3664. public function _excelct()
  3665. {
  3666. $classid = $this->classid->sku();
  3667. $pm = $classid;
  3668. $typeclass = array();
  3669. $tc = $this->typeclass->find_all();
  3670. foreach ($tc as $v) {
  3671. $typeclass[$v['id']] = $v;
  3672. }
  3673. $prc = array();
  3674. $purchase = $this->purchase->find_all();
  3675. foreach ($purchase as $k => $v) {
  3676. $prc[$v['id']] = $v['title'];
  3677. }
  3678. if (isset($_GET['excel'])) {
  3679. $wh = array();
  3680. $w = $this->warehouse->find_all('1=1', 'id,title');
  3681. foreach ($w as $v) {
  3682. $wh[$v['id']] = $v['title'];
  3683. }
  3684. $type = $this->input->get('excel', true);
  3685. $category = $this->input->get('category', true);
  3686. $size = $this->input->get('size', true);
  3687. $grade = $this->input->get('grade', true);
  3688. $color = $this->input->get('color', true);
  3689. $lowe = $this->input->get('lowe', true);
  3690. $sku = $this->input->get('sku', true);
  3691. $title = $this->input->get('title', true);
  3692. $warehouse = $this->input->get('warehouse', true);
  3693. $purchase = $this->input->get('purchase', true);
  3694. $lacetype = $this->input->get('lacetype', true);
  3695. $haircap = $this->input->get('haircap', true);
  3696. $lacecolor = $this->input->get('lacecolor', true);
  3697. $density = $this->input->get('density', true);
  3698. $details = $this->input->get('details', true);
  3699. $state = $this->input->get('state', true);
  3700. $shop = $this->input->get('shop', true);
  3701. $hairnumber = $this->input->get('hairnumber', true);
  3702. $type_leixi = $this->input->get('type', true);
  3703. $cpbz = $this->input->get('cpbz', true);
  3704. $sm = $this->input->get('sm', true);
  3705. $sid = $this->input->get('sid', true);
  3706. $ktime = $this->input->get('ktime', true);
  3707. $jtime = $this->input->get('jtime', true);
  3708. $ktime = strtotime($ktime);
  3709. $jtime = strtotime($jtime);
  3710. //$where = " 1=1 ";
  3711. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3712. $where = " sku != '' ";
  3713. $gj = "";
  3714. $ck = "";
  3715. if ($category) {
  3716. $where .= " and features like '%-$category-%'";
  3717. }
  3718. if ($size) {
  3719. $where .= " and features like '%-$size-%'";
  3720. }
  3721. if ($grade) {
  3722. $where .= " and features like '%-$grade-%'";
  3723. }
  3724. if ($color) {
  3725. $where .= " and features like '%-$color-%'";
  3726. }
  3727. if ($lowe) {
  3728. $where .= " and features like '%-$lowe-%'";
  3729. }
  3730. if ($warehouse) {
  3731. $where .= " and warehouse = '$warehouse'";
  3732. }
  3733. if ($purchase) {
  3734. $where .= " and purchase = '$purchase'";
  3735. }
  3736. if ($state) {
  3737. $where .= " and state = '$state'";
  3738. }
  3739. if ($lacetype) {
  3740. $where .= " and features like '%-$lacetype-%'";
  3741. }
  3742. if ($lacecolor) {
  3743. $where .= " and features like '%-$lacecolor-%'";
  3744. }
  3745. if ($density) {
  3746. $where .= " and features like '%-$density-%'";
  3747. }
  3748. if ($haircap) {
  3749. $where .= " and features like '%-$haircap-%'";
  3750. }
  3751. if ($details) {
  3752. $where .= " and details = '$details'";
  3753. }
  3754. if ($shop) {
  3755. $where .= " and shop like '%$shop%'";
  3756. }
  3757. if ($title) {
  3758. $title = trim($title, ' ');
  3759. $title = trim($title, ' ');
  3760. $where .= " and title like '%$title%'";
  3761. }
  3762. if (!empty($hairnumber)) {
  3763. $where .= " and features like '%-128-%' ";
  3764. if ($hairnumber < 0) {
  3765. $class_list = $this->typeclass->find_all('classid = 43');
  3766. foreach ($class_list as $v) {
  3767. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3768. }
  3769. } else {
  3770. $where .= " and features like '%-$hairnumber-%'";
  3771. }
  3772. }
  3773. if ($type_leixi) {
  3774. $where .= " and type = '$type_leixi'";
  3775. }
  3776. if ($cpbz) {
  3777. $where .= " and cpbz like '%$cpbz%' ";
  3778. }
  3779. if ($sm) {
  3780. $where .= " and sm like '%$sm%' ";
  3781. }
  3782. if ($sku) {
  3783. $sku = trim($sku, ' ');
  3784. $sku = trim($sku, ' ');
  3785. $where .= " and sku like '%$sku%'";
  3786. }
  3787. if ($ktime && $jtime) {
  3788. if ($type == 1) {
  3789. $tl = '出库';
  3790. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3791. } else if ($type == 2) {
  3792. $tl = '退库';
  3793. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3794. } else if ($type == 3) {
  3795. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3796. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3797. } else if ($type == 4) {
  3798. $tl = '出库+零售';
  3799. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3800. } else if ($type == 5) {
  3801. $tl = '零售';
  3802. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3803. }
  3804. }
  3805. $sidwhere = '';
  3806. if ($sid) {
  3807. $sd = "";
  3808. $s = explode(',', trim($sid, ','));
  3809. foreach ($s as $value) {
  3810. $sd .= " id = " . $value . " or";
  3811. }
  3812. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3813. }
  3814. //数据排序
  3815. $order_str = "time desc";
  3816. if (empty($page)) {
  3817. $start = 0;
  3818. $perpage = 1;
  3819. } else {
  3820. $start = ($page - 1) * $perpage;
  3821. }
  3822. //取得信息列表
  3823. if ($type != 3 && $type != 5) {
  3824. if ($type == 1 || $type == 4) {
  3825. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3826. foreach ($info_list as $key => $value) {
  3827. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3828. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3829. $warehouse = $this->warehouse->read($value['warehouse']);
  3830. $info_list[$key]['warehouse'] = $warehouse['title'];
  3831. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3832. $features = explode('-', trim($features, '-'));
  3833. $pm = $classid;
  3834. foreach ($features as $k => $v) {
  3835. if ($v != 0) {
  3836. if (!isset($typeclass[$v])) {
  3837. continue;
  3838. }
  3839. if (isset($pm[$typeclass[$v]['classid']])) {
  3840. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3841. $tz = explode('|', $typeclass[$v]['zh']);
  3842. $pm[$typeclass[$v]['classid']] = $tz[0];
  3843. } else {
  3844. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3845. }
  3846. }
  3847. }
  3848. }
  3849. $zh = implode(" ", $pm);
  3850. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3851. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3852. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3853. $info_list[$key]['features'] = $zh;
  3854. }
  3855. $final_list = [];
  3856. foreach($info_list as $k=>$v){
  3857. $number = "";
  3858. if(!empty($v['orderinfo'])){
  3859. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3860. if(!empty($tmp_info['number'])){
  3861. $number = $tmp_info['number'];
  3862. }
  3863. }
  3864. $final_list[] = [
  3865. 'warehouse'=>$v['warehouse'],
  3866. 'purchase'=>$v['purchase'],
  3867. 'sku'=>$v['sku'],
  3868. 'title'=>$v['title'],
  3869. 'features'=>$v['features'],
  3870. 'label'=>$v['label'],
  3871. 'orderinfo'=>$v['orderinfo'],
  3872. 'number'=>$number,
  3873. 'waybill'=>$v['waybill'],
  3874. 'outk'=>$v['outk'],
  3875. ];
  3876. }
  3877. } else {
  3878. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3879. foreach ($info_list as $key => $value) {
  3880. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3881. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3882. $warehouse = $this->warehouse->read($value['warehouse']);
  3883. $info_list[$key]['warehouse'] = $warehouse['title'];
  3884. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3885. $features = explode('-', trim($features, '-'));
  3886. $pm = $classid;
  3887. foreach ($features as $k => $v) {
  3888. if ($v != 0) {
  3889. if (!isset($typeclass[$v])) {
  3890. continue;
  3891. }
  3892. if (isset($pm[$typeclass[$v]['classid']])) {
  3893. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3894. $tz = explode('|', $typeclass[$v]['zh']);
  3895. $pm[$typeclass[$v]['classid']] = $tz[0];
  3896. } else {
  3897. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3898. }
  3899. }
  3900. }
  3901. }
  3902. $zh = implode(" ", $pm);
  3903. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3904. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3905. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3906. $info_list[$key]['features'] = $zh;
  3907. }
  3908. $final_list = [];
  3909. foreach($info_list as $k=>$v){
  3910. $number = "";
  3911. if(!empty($v['orderinfo'])){
  3912. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3913. if(!empty($tmp_info['number'])){
  3914. $number = $tmp_info['number'];
  3915. }
  3916. }
  3917. $final_list[] = [
  3918. 'warehouse'=>$v['warehouse'],
  3919. 'purchase'=>$v['purchase'],
  3920. 'sku'=>$v['sku'],
  3921. 'title'=>$v['title'],
  3922. 'features'=>$v['features'],
  3923. 'label'=>$v['label'],
  3924. 'orderinfo'=>$v['orderinfo'],
  3925. 'number'=>$number,
  3926. 'waybill'=>$v['waybill'],
  3927. 'retreat'=>$v['retreat'],
  3928. ];
  3929. }
  3930. }
  3931. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3932. $titlename = "<table border=1>
  3933. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3934. <tr align='center'>
  3935. <td>仓库</td>
  3936. <td>供应商</td>
  3937. <td>SKU</td>
  3938. <td>商品名称</td>
  3939. <td>商品中文</td>
  3940. <td>标签</td>
  3941. <td>订单号</td>
  3942. <td>订单编码</td>
  3943. <td>运单号</td>
  3944. <td>" . $tl . "时间(中国时间)</td>
  3945. </tr>
  3946. </table>";
  3947. $filename = $title . ".xls";
  3948. $tail = "";
  3949. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3950. } else if ($type == 5) {
  3951. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3952. foreach ($info_list as $key => $value) {
  3953. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3954. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3955. $warehouse = $this->warehouse->read($value['warehouse']);
  3956. $info_list[$key]['warehouse'] = $warehouse['title'];
  3957. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3958. $features = explode('-', trim($features, '-'));
  3959. $pm = $classid;
  3960. foreach ($features as $k => $v) {
  3961. if ($v != 0) {
  3962. if (!isset($typeclass[$v])) {
  3963. continue;
  3964. }
  3965. if (isset($pm[$typeclass[$v]['classid']])) {
  3966. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3967. $tz = explode('|', $typeclass[$v]['zh']);
  3968. $pm[$typeclass[$v]['classid']] = $tz[0];
  3969. } else {
  3970. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3971. }
  3972. }
  3973. }
  3974. }
  3975. $zh = implode(" ", $pm);
  3976. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3977. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3978. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3979. $info_list[$key]['features'] = $zh;
  3980. }
  3981. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3982. $titlename = "<table border=1>
  3983. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3984. <tr align='center'>
  3985. <td>仓库</td>
  3986. <td>供应商</td>
  3987. <td>SKU</td>
  3988. <td>商品名称</td>
  3989. <td>商品中文</td>
  3990. <td>标签</td>
  3991. <td>" . $tl . "时间(中国时间)</td>
  3992. </tr>
  3993. </table>";
  3994. $filename = $title . ".xls";
  3995. $tail = "";
  3996. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3997. } else {
  3998. /**
  3999. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4000. $rows = array();$list = array();
  4001. foreach ($info_list as $key=>$value)
  4002. {
  4003. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4004. }
  4005. **/
  4006. $wh = array();
  4007. $w = $this->warehouse->find_all('1=1', 'id,title');
  4008. foreach ($w as $v) {
  4009. $wh[$v['id']] = $v['title'];
  4010. }
  4011. $wt = array();
  4012. $whlabel_type = $this->whlabel_type->find_all();
  4013. foreach ($whlabel_type as $v) {
  4014. $wt[$v['id']] = $v['title'];
  4015. }
  4016. $classid = $this->classid->sku();
  4017. $list = array();
  4018. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4019. foreach ($rows as $key => $value) {
  4020. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4021. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4022. $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');
  4023. $details = array();
  4024. $cpid = array();
  4025. $cpbz = array();
  4026. $c = 0;
  4027. $g = 0;
  4028. $x = 0;
  4029. $t = 0;
  4030. $s = 0;
  4031. $q = 0;
  4032. foreach ($sd as $k => $v) {
  4033. if ($v['state'] == 0) {
  4034. $c++;
  4035. }
  4036. if ($v['state'] != 9) {
  4037. $g++;
  4038. }
  4039. if ($v['outk'] > 1) {
  4040. $x++;
  4041. }
  4042. if ($v['retreat'] > 0) {
  4043. $t++;
  4044. }
  4045. if ($v['state'] == 8) {
  4046. $s++;
  4047. }
  4048. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4049. $q++;
  4050. }
  4051. $details[$v['details']] = $v['details'];
  4052. if ($v['cpid'] != 0) {
  4053. $cpid[$v['cpid']] = $v['cpid'];
  4054. }
  4055. if ($v['cpbz'] != '') {
  4056. $cpbz[$v['cpbz']] = $v['cpbz'];
  4057. }
  4058. }
  4059. if (isset($wt[$value['type']])) {
  4060. $rows[$key]['type'] = $wt[$value['type']];
  4061. } else {
  4062. $rows[$key]['type'] = '未设置';
  4063. }
  4064. $rows[$key]['details'] = implode("、", $details);
  4065. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4066. $ftime = time() - 15 * 24 * 3600;
  4067. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4068. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4069. $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);
  4070. $rows[$key]['c'] = $c;
  4071. $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);
  4072. $rows[$key]['t'] = $t;
  4073. $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'] . '"');
  4074. $rows[$key]['z'] = $z;
  4075. // $jm = $classid;
  4076. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4077. $features = explode('-', trim($features, '-'));
  4078. // $pm = $classid;
  4079. // foreach ($features as $k => $v) {
  4080. // if ($v != 0) {
  4081. // if (!isset($typeclass[$v])) {
  4082. // continue;
  4083. // }
  4084. // if (isset($pm[$typeclass[$v]['classid']])) {
  4085. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4086. // $tz = explode('|', $typeclass[$v]['zh']);
  4087. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4088. // } else {
  4089. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4090. // }
  4091. // if (isset($jm[$typeclass[$v]['classid']])) {
  4092. // if ($typeclass[$v]['jm']) {
  4093. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4094. // }
  4095. // }
  4096. // }
  4097. // }
  4098. // }
  4099. // $zh = implode(" ", $pm);
  4100. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4101. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4102. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4103. // $rows[$key]['features'] = $zh;
  4104. // $jm = array_filter($jm); //去除空值
  4105. // $jm = implode("-", $jm);
  4106. // $rows[$key]['jm'] = $jm;
  4107. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4108. }
  4109. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4110. // echo "<pre>";
  4111. // print_r($tmp_list);
  4112. // die;
  4113. $final_list =[];
  4114. foreach($tmp_list as $k=>$v){
  4115. $final_list[] = [
  4116. "warehouse"=>$v['warehouse'],
  4117. "purchase"=>$v['purchase'],
  4118. "details"=>$v['details'],
  4119. "cpid"=>$v['cpid'],
  4120. "sku"=>$v['sku'],
  4121. "title"=>$v['title'],
  4122. "features"=>$v['pm'],
  4123. "cpbz"=>$v['cpbz'],
  4124. "sm"=>$v['sm'],
  4125. "type"=>$v['type'],
  4126. "g"=>$v["g"],
  4127. "c"=>$v["c"],
  4128. "x"=>$v["x"],
  4129. "t"=>$v["t"],
  4130. "z"=>$v["z"],
  4131. "jm"=>$v["jm"],
  4132. "weight"=>$v["weight"],
  4133. "asd"=>$v["asd"],
  4134. ];
  4135. }
  4136. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4137. $titlename = "<table border=1>
  4138. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4139. <tr align='center'>
  4140. <td>仓库</td>
  4141. <td>供应商</td>
  4142. <td>位置</td>
  4143. <td>库存编码</td>
  4144. <td>SKU</td>
  4145. <td>商品名称</td>
  4146. <td>商品中文</td>
  4147. <td>产品备注</td>
  4148. <td>说明</td>
  4149. <td>类型</td>
  4150. <td>入库总量</td>
  4151. <td>库存数量</td>
  4152. <td>销售数量</td>
  4153. <td>退货数量</td>
  4154. <td>占单数量</td>
  4155. <td>料号</td>
  4156. <td>重量</td>
  4157. <td>类目</td>
  4158. </tr>
  4159. </table>";
  4160. $filename = $title . ".xls";
  4161. $tail = "";
  4162. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4163. }
  4164. }
  4165. }
  4166. //出库+入库数据整合
  4167. public function _excelcr()
  4168. {
  4169. if (isset($_GET['excel'])) {
  4170. $type = $this->input->get('excel', true);
  4171. $category = $this->input->get('category', true);
  4172. $size = $this->input->get('size', true);
  4173. $grade = $this->input->get('grade', true);
  4174. $color = $this->input->get('color', true);
  4175. $lowe = $this->input->get('lowe', true);
  4176. $sku = $this->input->get('sku', true);
  4177. $warehouse = $this->input->get('warehouse', true);
  4178. $purchase = $this->input->get('purchase', true);
  4179. $state = $this->input->get('state', true);
  4180. $sid = $this->input->get('sid', true);
  4181. $ktime = $this->input->get('ktime', true);
  4182. $jtime = $this->input->get('jtime', true);
  4183. $ktime = strtotime($ktime);
  4184. $jtime = strtotime($jtime);
  4185. $where = "1=1";
  4186. $gj = "";
  4187. $ck = "";
  4188. if ($category) {
  4189. $where .= " and features like '%-$category-%'";
  4190. }
  4191. if ($size) {
  4192. $where .= " and features like '%-$size-%'";
  4193. }
  4194. if ($grade) {
  4195. $where .= " and features like '%-$grade-%'";
  4196. }
  4197. if ($color) {
  4198. $where .= " and features like '%-$color-%'";
  4199. }
  4200. if ($lowe) {
  4201. $where .= " and features like '%-$lowe-%'";
  4202. }
  4203. if ($warehouse) {
  4204. $where .= " and warehouse = '$warehouse'";
  4205. }
  4206. if ($purchase) {
  4207. $where .= " and purchase = '$purchase'";
  4208. }
  4209. if ($state) {
  4210. $where .= " and state = '$state'";
  4211. }
  4212. if ($sku) {
  4213. $where .= " and sku like '%$sku%'";
  4214. }
  4215. if ($ktime && $jtime) {
  4216. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4217. }
  4218. $sidwhere = '';
  4219. if ($sid) {
  4220. $sd = "";
  4221. $s = explode(',', trim($sid, ','));
  4222. foreach ($s as $value) {
  4223. $sd .= " id = " . $value . " or";
  4224. }
  4225. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4226. }
  4227. //取得信息列表
  4228. $timeread = $ktime;
  4229. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4230. $timelist = array();
  4231. for ($i = 0; $i < $timenum; $i++) {
  4232. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4233. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4234. }
  4235. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4236. //echo "<pre>";
  4237. //print_r($info_list);
  4238. //exit();
  4239. $rows = array();
  4240. $list = array();
  4241. foreach ($info_list as $key => $value) {
  4242. $thistime = $timelist;
  4243. if (isset($rows[strtolower($value['sku'])])) {
  4244. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4245. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4246. }
  4247. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4248. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4249. }
  4250. } else {
  4251. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4252. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4253. }
  4254. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4255. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4256. }
  4257. $rows[strtolower($value['sku'])] = $thistime;
  4258. }
  4259. }
  4260. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4261. <head>
  4262. <!--[if gte mso 9]><xml>
  4263. <x:ExcelWorkbook>
  4264. <x:ExcelWorksheets>
  4265. <x:ExcelWorksheet>
  4266. <x:Name>EXCEL</x:Name>
  4267. <x:WorksheetOptions>
  4268. <x:Print>
  4269. <x:ValidPrinterInfo />
  4270. </x:Print>
  4271. </x:WorksheetOptions>
  4272. </x:ExcelWorksheet>
  4273. </x:ExcelWorksheets>
  4274. </x:ExcelWorkbook>
  4275. </xml>
  4276. <![endif]-->
  4277. </head><body>";
  4278. $str .= "<table border=1><tr><td>SKU</td>";
  4279. foreach ($timelist as $k => $v) {
  4280. $str .= "<td>" . $k . "出库</td>";
  4281. $str .= "<td>" . $k . "入库</td>";
  4282. }
  4283. $str .= "</tr></table>";
  4284. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4285. foreach ($rows as $key => $val) {
  4286. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4287. foreach ($val as $k => $v) {
  4288. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4289. if ($val[$k]['r'] > 0) {
  4290. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4291. } else {
  4292. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4293. }
  4294. }
  4295. $str .= "</tr>";
  4296. }
  4297. $str .= "</table>";
  4298. $str .= "</body></html>";
  4299. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4300. header("Content-type: application/octet-stream");
  4301. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4302. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4303. header("Pragma: no-cache");
  4304. header("Expires: 0");
  4305. exit($str);
  4306. }
  4307. }
  4308. //数量调整模板导出
  4309. public function _presetout()
  4310. {
  4311. if (isset($_GET['excel'])) {
  4312. $where = "sku != 'Preset' and purchase != 0";
  4313. //数据排序
  4314. $order_str = "id desc";
  4315. if (empty($page)) {
  4316. $start = 0;
  4317. $perpage = 1;
  4318. } else {
  4319. $start = ($page - 1) * $perpage;
  4320. }
  4321. //取得信息列表
  4322. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4323. $rows = array();
  4324. $list = array();
  4325. foreach ($info_list as $value) {
  4326. $warehouse = $this->warehouse->read($value['warehouse']);
  4327. $number = $value['number'];
  4328. $ftime = time() - 15 * 24 * 3600;
  4329. $purchase = $this->purchase->read($value['purchase']);
  4330. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4331. }
  4332. $title = "库存模板";
  4333. $titlename = "<table border=1>
  4334. <tr align='center'>
  4335. <td>仓库</td>
  4336. <td>供应商编码</td>
  4337. <td>SKU</td>
  4338. <td>增减数量(正数或负数)</td>
  4339. <td>增减备注</td>
  4340. <td>扣减方式:0减少库存1删除库存</td>
  4341. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4342. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4343. </tr>
  4344. </table>";
  4345. $filename = $title . ".xls";
  4346. $tail = "";
  4347. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4348. }
  4349. }
  4350. //数量调整模板导入
  4351. public function _presetedit()
  4352. {
  4353. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4354. $config['upload_path'] = '.' . $dir;
  4355. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4356. $config['allowed_types'] = 'xls|xlsx|csv';
  4357. $config['max_size'] = 10240;
  4358. $this->load->library('upload', $config);
  4359. $this->upload->initialize($config);
  4360. if ($this->upload->do_upload('userfile')) {
  4361. $full_path = $dir . $this->upload->data('file_name');
  4362. $fileName = '.' . $full_path;
  4363. if (!file_exists($fileName)) {
  4364. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4365. exit;
  4366. } else {
  4367. require_once "./data/excel/PHPExcel/IOFactory.php";
  4368. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4369. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4370. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4371. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4372. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4373. ++$column; //如果列数大于26行
  4374. $list = array();
  4375. for ($i = 2; $i <= $row; $i++) // 行数循环
  4376. {
  4377. $data = array();
  4378. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4379. {
  4380. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4381. }
  4382. $list[] = $data;
  4383. }
  4384. }
  4385. $i = 0;
  4386. $j = 0;
  4387. $ed = array();
  4388. foreach ($list as $key => $value) {
  4389. $time = time();
  4390. if ($value['0'] == "") {
  4391. continue;
  4392. }
  4393. $warehouse = $this->warehouse->get_title($value['0']);
  4394. $purchase = $this->purchase->get_bm($value['1']);
  4395. $sku = $value['2'];
  4396. $num = $value['3']; //调整数量
  4397. $text = $value['4']; //扣减说明
  4398. $type = $value['5']; //调整方式0扣减1删除
  4399. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4400. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4401. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4402. if (!$purchase) //如果没有这个SKU
  4403. {
  4404. $ed[] = array($purchase . '-不存在此供应商编码');
  4405. $j++;
  4406. continue;
  4407. }
  4408. if (!$d) //如果没有这个SKU
  4409. {
  4410. $ed[] = array($sku . '-库存中不存在此SKU');
  4411. $j++;
  4412. continue;
  4413. }
  4414. if (!isset($warehouse['id'])) {
  4415. $ed[] = array($sku . '-仓库名错误!');
  4416. $j++;
  4417. continue;
  4418. }
  4419. if ($type != '0' && $type != '1') {
  4420. $ed[] = array($sku . '-扣减方式填写错误!');
  4421. $j++;
  4422. continue;
  4423. }
  4424. if ($num < 0) //扣减库存
  4425. {
  4426. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4427. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4428. $j++;
  4429. continue;
  4430. }
  4431. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4432. if (count($data) < abs($num)) {
  4433. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4434. $j++;
  4435. continue;
  4436. }
  4437. if ($type == 0) //如果扣减方式为 扣减库存
  4438. {
  4439. for ($i = 0; $i < abs($num); $i++) {
  4440. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4441. }
  4442. } else if ($type == 1) {
  4443. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4444. if (count($zt) > 0) {
  4445. $ed[] = array($sku . '-有在途库存无法删除!');
  4446. $j++;
  4447. continue;
  4448. }
  4449. for ($i = 0; $i < abs($num); $i++) {
  4450. $this->whlabel->remove($data[$i]['id']);
  4451. }
  4452. }
  4453. } else if ($num > 0) //增加库存
  4454. {
  4455. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4456. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4457. $j++;
  4458. continue;
  4459. }
  4460. $post['sku'] = $d['sku'];
  4461. $post['shop'] = $d['shop'];
  4462. $post['warehouse'] = $warehouse['id'];
  4463. $post['purchase'] = $purchase['id'];
  4464. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4465. $post['state'] = 0;
  4466. $post['title'] = $d['title'];
  4467. $post['number'] = $d['number'];
  4468. $post['features'] = $d['features'];
  4469. $post['enter'] = $time;
  4470. $post['time'] = $time; //操作时间
  4471. $post['rktype'] = $rktype;
  4472. for ($i = 0; $i < $num; $i++) {
  4473. $post['label'] = time() . rand(100, 999) . $i;
  4474. $this->whlabel->insert($post);
  4475. }
  4476. }
  4477. sleep(1); //防止入库时间一样,需要延迟1秒
  4478. }
  4479. if ($j > 0) {
  4480. $tt = date('Ymd', time());
  4481. $title = '库存导入错误信息-' . $tt;
  4482. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4483. $tail = "\n";
  4484. $filename = $title . ".xls";
  4485. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4486. $dir = '/data/excel/' . $time . '/';
  4487. $file_name = 'error_' . $time . rand(1000, 9999);
  4488. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4489. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4490. fwrite($myfile, $ecl);
  4491. fclose($myfile);
  4492. $error = $dir . $file_name . '.xls';
  4493. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4494. exit;
  4495. } else {
  4496. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4497. exit;
  4498. }
  4499. }
  4500. }
  4501. //笛卡儿积
  4502. function cp($ps, $sets, $list)
  4503. {
  4504. $result = array();
  4505. $j = 0;
  4506. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4507. if ($i == 0) {
  4508. $result = $sets[$i];
  4509. }
  4510. $tmp = array();
  4511. foreach ($result as $res) {
  4512. foreach ($sets[$i + 1] as $set) {
  4513. $tmp[] = $res . ',' . $set;
  4514. }
  4515. }
  4516. $result = $tmp;
  4517. }
  4518. $this->db->trans_begin();
  4519. foreach ($result as $v) {
  4520. $post = array();
  4521. $title = "";
  4522. $num = "";
  4523. $data = explode(',', $v);
  4524. for ($i = 0; $i < count($list); $i++) {
  4525. $post[$list[$i]] = $data[$i];
  4526. $typeclass = $this->typeclass->read($data[$i]);
  4527. $title = $title . $typeclass['title'] . " ";
  4528. if ($data[$i] != 0) {
  4529. $num .= $data[$i]; //所有数据ID拼接
  4530. }
  4531. }
  4532. foreach ($ps as $kp => $vp) {
  4533. $post[$kp] = $vp;
  4534. }
  4535. $post['number'] = $num;
  4536. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4537. if ($info_list) {
  4538. $j++;
  4539. } else {
  4540. $skunum = $this->whlabel->find_count();
  4541. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4542. $post['title'] = rtrim($title, ' ');
  4543. $this->whlabel->insert($post);
  4544. }
  4545. }
  4546. if ($this->db->trans_status() === FALSE) {
  4547. $this->db->trans_commit();
  4548. return NULL;
  4549. } else {
  4550. $this->db->trans_commit();
  4551. return $j;
  4552. }
  4553. }
  4554. public function _kj($arg_array)
  4555. {
  4556. if (isset($_POST['sku'])) {
  4557. $time = time();
  4558. $sku = $this->input->post('sku', true);
  4559. $warehouse = $this->input->post('warehouse', true);
  4560. $num = $this->input->post('num', true);
  4561. $text = $this->input->post('text', true);
  4562. $purchase = $this->input->post('purchase', true);
  4563. $cktype = $this->input->post('cktype', true);
  4564. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4565. if ($cktype != 1 && $text == '') {
  4566. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4567. exit;
  4568. }
  4569. if ($num > count($order)) {
  4570. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4571. exit;
  4572. } else {
  4573. for ($i = 0; $i < $num; $i++) {
  4574. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4575. }
  4576. }
  4577. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4578. exit;
  4579. }
  4580. $uid = $this->whlabel->read($arg_array[0]);
  4581. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4582. $this->data['data'] = $uid;
  4583. $this->_Template('whlabel_kj', $this->data);
  4584. }
  4585. public function _summary($arg_array)
  4586. {
  4587. $prc = array();
  4588. $purchase = $this->purchase->find_all();
  4589. foreach ($purchase as $k => $v) {
  4590. $prc[$v['id']] = $v['title'];
  4591. }
  4592. if (isset($_GET['excel'])) {
  4593. $ktime = $this->input->get('ktime', true);
  4594. $jtime = $this->input->get('jtime', true);
  4595. $ktime = strtotime($ktime);
  4596. $jtime = strtotime($jtime);
  4597. $where = "1=1";
  4598. if ($ktime && $jtime) {
  4599. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4600. }
  4601. //数据排序
  4602. $order_str = "time desc";
  4603. if (empty($page)) {
  4604. $start = 0;
  4605. $perpage = 1;
  4606. } else {
  4607. $start = ($page - 1) * $perpage;
  4608. }
  4609. //取得信息列表
  4610. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4611. foreach ($info_list as $key => $value) {
  4612. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4613. $warehouse = $this->warehouse->read($value['warehouse']);
  4614. $info_list[$key]['warehouse'] = $warehouse['title'];
  4615. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4616. $details = array();
  4617. $cpid = array();
  4618. foreach ($x as $k => $v) {
  4619. if ($v['details'] != '') {
  4620. $details[$v['details']] = $v['details'];
  4621. }
  4622. if ($v['cpid'] != 0) {
  4623. $cpid[$v['cpid']] = $v['cpid'];
  4624. }
  4625. }
  4626. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4627. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4628. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4629. $info_list[$key]['s'] = $s;
  4630. $info_list[$key]['x'] = count($x);
  4631. }
  4632. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4633. $titlename = "<table border=1>
  4634. <tr align='center'>
  4635. <td>仓库</td>
  4636. <td>供应商</td>
  4637. <td>出库位置</td>
  4638. <td>出库编码</td>
  4639. <td>SKU</td>
  4640. <td>产品名</td>
  4641. <td>总剩余库存</td>
  4642. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4643. </tr>
  4644. </table>";
  4645. $filename = $title . ".xls";
  4646. $tail = "";
  4647. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4648. }
  4649. }
  4650. //usps发货清单
  4651. public function _manifest()
  4652. {
  4653. if (isset($_POST['manifest'])) {
  4654. $wltext = $this->input->post('wltext', true);
  4655. $time = time() - 16 * 3600;
  4656. $ptime = strtotime(date('Y-m-d', $time));
  4657. $waybill = array();
  4658. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4659. foreach ($fullorder as $v) {
  4660. $waybill[$v['waybill']] = $v['waybill'];
  4661. }
  4662. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4663. foreach ($fullordersmt as $v) {
  4664. $waybill[$v['waybill']] = $v['waybill'];
  4665. }
  4666. $wltext = explode(';', $wltext);
  4667. foreach ($wltext as $v) {
  4668. if (isset($waybill[$v])) {
  4669. unset($waybill[$v]);
  4670. }
  4671. }
  4672. $data = $this->usps->get_manifest($waybill);
  4673. if (isset($data['Description'])) {
  4674. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4675. exit;
  4676. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4677. $bctime = date('Ymd', time());
  4678. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4679. echo json_encode(array('msg' => $pdf, 'success' => true));
  4680. exit;
  4681. } else {
  4682. echo json_encode(array('msg' => $data, 'success' => false));
  4683. exit;
  4684. }
  4685. }
  4686. }
  4687. public function _pdf($pdf, $title, $bctime)
  4688. {
  4689. $pdf_path = './data/pdf/' . $bctime . '/';
  4690. $file_base64 = $pdf;
  4691. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4692. $file_base64 = base64_decode($file_base64);
  4693. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4694. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4695. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4696. }
  4697. /**
  4698. *
  4699. *
  4700. *
  4701. 进销存占单异常索引
  4702. *
  4703. *
  4704. *
  4705. **/
  4706. public function _abnormal()
  4707. {
  4708. $post = $this->input->post(NULL, TRUE);
  4709. if (isset($post['page'])) {
  4710. $page = $this->input->post('page', true);
  4711. $perpage = $this->input->post('perpage', true);
  4712. $sku = $this->input->post('sku', true);
  4713. $where = "1=1";
  4714. //数据排序
  4715. $order_str = "id desc";
  4716. if (empty($page)) {
  4717. $start = 0;
  4718. $perpage = 1;
  4719. } else {
  4720. $start = ($page - 1) * $perpage;
  4721. }
  4722. //取得信息列表
  4723. $info_list = $this->whlabel->find_all($where, '*');
  4724. $rows = array();
  4725. $list = array();
  4726. foreach ($info_list as $key => $value) {
  4727. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4728. }
  4729. foreach ($rows as $value) {
  4730. $warehouse = $this->warehouse->read($value['warehouse']);
  4731. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4732. $number = $value['number'];
  4733. $ftime = time() - 15 * 24 * 3600;
  4734. if ($value['shop'] != '') {
  4735. $shop = $value['shop'];
  4736. $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');
  4737. $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');
  4738. $order = array_merge($orderdlz, $ordersmt);
  4739. $od = 0;
  4740. $a = '';
  4741. $orid = '';
  4742. foreach ($order as $v) {
  4743. $or = explode('|', ltrim($v['whlabel'], '|'));
  4744. for ($i = 0; $i < count($or); $i++) {
  4745. $orod = explode('-', $or[$i]);
  4746. if ($orod[0] == $number) {
  4747. $od += $orod[1];
  4748. }
  4749. }
  4750. $orid .= $v['number'] . '-';
  4751. }
  4752. } else {
  4753. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4754. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4755. $order = array_merge($orderdlz, $ordersmt);
  4756. $od = 0;
  4757. $a = '';
  4758. $orid = '';
  4759. $qt = array();
  4760. foreach ($order as $v) {
  4761. $or = explode('|', ltrim($v['whlabel'], '|'));
  4762. for ($i = 0; $i < count($or); $i++) {
  4763. $orod = explode('-', $or[$i]);
  4764. if ($orod[0] == $number) {
  4765. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4766. if ($czzs > 0) {
  4767. if (isset($qt[$v['shop']])) {
  4768. if ($qt[$v['shop']] < $orod[1]) {
  4769. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4770. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4771. } else {
  4772. $qt[$v['shop']] -= $orod[1];
  4773. }
  4774. } else {
  4775. $qt[$v['shop']] = $czzs;
  4776. }
  4777. } else {
  4778. $od += $orod[1];
  4779. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4780. }
  4781. }
  4782. }
  4783. }
  4784. }
  4785. $z = $od . '(' . $orid . ')'; //查看订单号
  4786. //$z = $od;
  4787. if ($od > $c) {
  4788. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4789. }
  4790. }
  4791. $listdata = array_slice($list, $start, $perpage);
  4792. $total = count($list);
  4793. $pagenum = ceil($total / $perpage);
  4794. $over = $total - ($start + $perpage);
  4795. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4796. echo json_encode($rows);
  4797. exit;
  4798. }
  4799. $this->_Template('whlabel_abnormal', $this->data);
  4800. }
  4801. /**
  4802. *
  4803. *
  4804. *
  4805. 进销存占单异常索引
  4806. *
  4807. *
  4808. *
  4809. **/
  4810. public function _error()
  4811. {
  4812. $post = $this->input->post(NULL, TRUE);
  4813. if (isset($post['page'])) {
  4814. $page = $this->input->post('page', true);
  4815. $perpage = $this->input->post('perpage', true);
  4816. $sku = $this->input->post('sku', true);
  4817. $warehouse = $this->input->post('warehouse', true);
  4818. $ktime = $this->input->post('ktime', true);
  4819. $jtime = $this->input->post('jtime', true);
  4820. $ktime = strtotime($ktime);
  4821. $jtime = strtotime($jtime);
  4822. $where = "sku != 'Preset'";
  4823. $gj = '';
  4824. if ($sku) {
  4825. $where .= " and sku like '%$sku%'";
  4826. } else {
  4827. if ($ktime && $jtime) {
  4828. $gj = " and time > '$ktime' and time < '$jtime'";
  4829. }
  4830. }
  4831. if ($warehouse) {
  4832. $where .= " and warehouse = '$warehouse'";
  4833. }
  4834. //数据排序
  4835. $order_str = "id desc";
  4836. if (empty($page)) {
  4837. $start = 0;
  4838. $perpage = 1;
  4839. } else {
  4840. $start = ($page - 1) * $perpage;
  4841. }
  4842. //取得信息列表
  4843. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4844. $rows = array();
  4845. $list = array();
  4846. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4847. // foreach ($info_list as $value)
  4848. // {
  4849. // $warehouse = $this->warehouse->read($value['warehouse']);
  4850. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4851. // $number = $value['number'];$ftime = time()-15*24*3600;
  4852. // if($c < 1)
  4853. // {
  4854. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4855. // }
  4856. // }
  4857. $warehouse_list = $this->warehouse->find_all();
  4858. $warehouse_list = array_column($warehouse_list, null, 'id');
  4859. foreach ($info_list as $value) {
  4860. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4861. 'title' => "",
  4862. ];
  4863. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4864. $number = $value['number'];
  4865. $ftime = time() - 15 * 24 * 3600;
  4866. if ($c < 1) {
  4867. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4868. }
  4869. }
  4870. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4871. // $query = $this->db->query($sql);
  4872. // $info_list = $query->result_array();
  4873. // $sql_two = "select title,id from crowd_warehouse";
  4874. // $query_two = $this->db->query($sql_two);
  4875. // $warehouse_list = $query_two->result_array();
  4876. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4877. // foreach ($info_list as $value)
  4878. // {
  4879. // if(isset($warehouse_arr[$value['warehouse']])){
  4880. // $warehouse = $warehouse_arr[$value['warehouse']];
  4881. // }else{
  4882. // $warehouse = [
  4883. // 'id'=>0,
  4884. // 'title'=>"异常",
  4885. // ];
  4886. // }
  4887. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4888. // $number = $value['number'];$ftime = time()-15*24*3600;
  4889. // if($c < 1)
  4890. // {
  4891. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4892. // }
  4893. // }
  4894. $listdata = array_slice($list, $start, $perpage);
  4895. $total = count($list);
  4896. $pagenum = ceil($total / $perpage);
  4897. $over = $total - ($start + $perpage);
  4898. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4899. echo json_encode($rows);
  4900. exit;
  4901. }
  4902. if (isset($post['s'])) {
  4903. $id_arr = $this->input->post('s');
  4904. $id_arr = explode(',', trim($id_arr, ','));
  4905. if (!$id_arr) {
  4906. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4907. exit;
  4908. }
  4909. //循环删除记录
  4910. foreach ($id_arr as $v) {
  4911. $dd = $this->whlabel->read($v);
  4912. if (!isset($dd['id'])) {
  4913. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4914. exit;
  4915. }
  4916. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4917. if (isset($zt[0])) {
  4918. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4919. exit;
  4920. }
  4921. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4922. foreach ($deldd as $vv) {
  4923. $this->whlabel->remove($vv['id']);
  4924. }
  4925. }
  4926. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4927. exit;
  4928. }
  4929. $this->_Template('whlabel_error', $this->data);
  4930. }
  4931. public function _errorexcel()
  4932. {
  4933. $post = $this->input->post(NULL, TRUE);
  4934. if (isset($_GET['page'])) {
  4935. $page = $this->input->get('page', true);
  4936. $perpage = $this->input->get('perpage', true);
  4937. $sku = $this->input->get('sku', true);
  4938. $warehouse = $this->input->get('warehouse', true);
  4939. $ktime = $this->input->get('ktime', true);
  4940. $jtime = $this->input->get('jtime', true);
  4941. $ktime = strtotime($ktime);
  4942. $jtime = strtotime($jtime);
  4943. $where = "sku != 'Preset'";
  4944. $gj = '';
  4945. if ($sku) {
  4946. $where .= " and sku like '%$sku%'";
  4947. } else {
  4948. if ($ktime && $jtime) {
  4949. $gj = " and time > '$ktime' and time < '$jtime'";
  4950. }
  4951. }
  4952. if ($warehouse) {
  4953. $where .= " and warehouse = '$warehouse'";
  4954. }
  4955. //数据排序
  4956. $order_str = "id desc";
  4957. if (empty($page)) {
  4958. $start = 0;
  4959. $perpage = 1;
  4960. } else {
  4961. $start = ($page - 1) * $perpage;
  4962. }
  4963. //取得信息列表
  4964. $rows = array();
  4965. $list = array();
  4966. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4967. foreach ($info_list as $value) {
  4968. $warehouse = $this->warehouse->read($value['warehouse']);
  4969. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4970. $number = $value['number'];
  4971. $ftime = time() - 15 * 24 * 3600;
  4972. if ($c < 1) {
  4973. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4974. }
  4975. }
  4976. $title = "0库存汇总";
  4977. $titlename = "<table border=1>
  4978. <tr align='center'>
  4979. <td>仓库</td>
  4980. <td>SKU</td>
  4981. <td>产品</td>
  4982. <td>当前库存</td>
  4983. </tr>
  4984. </table>";
  4985. $filename = $title . ".xls";
  4986. $tail = "";
  4987. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4988. }
  4989. }
  4990. /**
  4991. *
  4992. *
  4993. * 占单
  4994. *
  4995. *
  4996. **/
  4997. public function _kcyz()
  4998. {
  4999. $post = $this->input->post(NULL, TRUE);
  5000. if (isset($post['warehouse'])) {
  5001. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5002. exit; //不再使用
  5003. $warehouse = $this->input->post('warehouse', true);
  5004. $whlabel = $this->input->post('whlabel', true);
  5005. $id = $this->input->post('id', true);
  5006. $shop = $this->input->post('shop', true);
  5007. $number = $this->input->post('number', true);
  5008. if (!$whlabel || $whlabel == '|') {
  5009. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5010. exit;
  5011. }
  5012. $pp = explode('|', trim($whlabel, '|'));
  5013. $x = 0;
  5014. $save = array();
  5015. foreach ($pp as $va) {
  5016. $num = explode('-', $va);
  5017. if ($number) {
  5018. $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 = '')"); //通用
  5019. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5020. } else {
  5021. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5022. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5023. }
  5024. $x++;
  5025. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5026. $save[] = $x - 1;
  5027. continue; //提前先加X不然出错,所以要减1
  5028. }
  5029. }
  5030. if (isset($save[0])) {
  5031. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5032. exit;
  5033. } else {
  5034. echo json_encode(array('success' => true));
  5035. exit;
  5036. }
  5037. }
  5038. }
  5039. public function _db()
  5040. {
  5041. $post = $this->input->post(NULL, TRUE);
  5042. if (isset($post['page'])) {
  5043. $page = $this->input->post('page', true);
  5044. $perpage = $this->input->post('perpage', true);
  5045. $sku = $this->input->post('sku', true);
  5046. $number = $this->input->post('number', true);
  5047. $warehouse = $this->input->post('warehouse', true);
  5048. $purchase = $this->input->post('purchase', true);
  5049. $orderinfo = $this->input->post('orderinfo', true);
  5050. $waybill = $this->input->post('waybill', true);
  5051. $category = $this->input->post('category', true);
  5052. $size = $this->input->post('size', true);
  5053. $grade = $this->input->post('grade', true);
  5054. $color = $this->input->post('color', true);
  5055. $lowe = $this->input->post('lowe', true);
  5056. $state = $this->input->post('state', true);
  5057. $label = $this->input->post('label', true);
  5058. $timetk = $this->input->post('timetkk', true);
  5059. $timetj = $this->input->post('timetjj', true);
  5060. $timetk = strtotime($timetk);
  5061. $timetj = strtotime($timetj);
  5062. $where = "dbtime > 0";
  5063. if ($timetk && $timetj) {
  5064. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5065. }
  5066. if ($sku) {
  5067. $where .= " and sku = '$sku'";
  5068. }
  5069. if ($warehouse) {
  5070. $where .= " and warehouse = '$warehouse'";
  5071. if ($warehouse == 12) {
  5072. $w = 'specialstock';
  5073. } else {
  5074. $w = 'whlabel';
  5075. }
  5076. }
  5077. if ($purchase) {
  5078. $where .= " and purchase = '$purchase'";
  5079. }
  5080. if ($category) {
  5081. $where .= " and features like '%-$category-%'";
  5082. }
  5083. if ($size) {
  5084. $where .= " and features like '%-$size-%'";
  5085. }
  5086. if ($grade) {
  5087. $where .= " and features like '%-$grade-%'";
  5088. }
  5089. if ($color) {
  5090. $where .= " and features like '%-$color-%'";
  5091. }
  5092. if ($lowe) {
  5093. $where .= " and features like '%-$lowe-%'";
  5094. }
  5095. if ($state != '') {
  5096. $where .= " and state = '$state'";
  5097. }
  5098. //数据排序
  5099. $order_str = "dbtime desc";
  5100. if (empty($page)) {
  5101. $start = 0;
  5102. $perpage = 1;
  5103. } else {
  5104. $start = ($page - 1) * $perpage;
  5105. }
  5106. //取得信息列表
  5107. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5108. foreach ($info_list as $key => $value) {
  5109. $warehouse = $this->$w->read($value['warehouse']);
  5110. $info_list[$key]['warehouse'] = $warehouse['title'];
  5111. $purchase = $this->purchase->read($value['purchase']);
  5112. $info_list[$key]['purchase'] = $purchase['title'];
  5113. if ($value['enter'] != 0) {
  5114. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5115. } else {
  5116. $info_list[$key]['enter'] = "";
  5117. }
  5118. if ($value['dbtime'] != 0) {
  5119. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5120. } else {
  5121. $info_list[$key]['dbtime'] = "";
  5122. }
  5123. if ($value['state'] == 0) {
  5124. $info_list[$key]['state'] = "在库";
  5125. } else if ($value['state'] == 1) {
  5126. $info_list[$key]['state'] = "出库";
  5127. } else if ($value['state'] == 2) {
  5128. $info_list[$key]['state'] = "退库";
  5129. } else if ($value['state'] == 3) {
  5130. $info_list[$key]['state'] = "调拨中";
  5131. } else if ($value['state'] == 4) {
  5132. $info_list[$key]['state'] = "再加工";
  5133. } else if ($value['state'] == 5) {
  5134. $info_list[$key]['state'] = "维修中";
  5135. } else if ($value['state'] == 6) {
  5136. $info_list[$key]['state'] = "盘亏";
  5137. } else if ($value['state'] == 7) {
  5138. $info_list[$key]['state'] = "更换标签";
  5139. } else if ($value['state'] == 8) {
  5140. $info_list[$key]['state'] = "其它";
  5141. } else if ($value['state'] == 9) {
  5142. $info_list[$key]['state'] = "预设";
  5143. }
  5144. }
  5145. $total = $this->whlabel->find_count($where);
  5146. $pagenum = ceil($total / $perpage);
  5147. $over = $total - ($start + $perpage);
  5148. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5149. echo json_encode($rows);
  5150. exit;
  5151. }
  5152. if (isset($post['outsku'])) {
  5153. $time = time();
  5154. $cz = $this->input->post('cz', true);
  5155. $label = $this->input->post('outsku', true);
  5156. $sl = $this->input->post('sl', true);
  5157. $num = $this->input->post('num', true);
  5158. //$warehouse = $this->input->post('warehouse',true);
  5159. if (!$sl) {
  5160. $sl = 1;
  5161. }
  5162. if (!$warehouse) {
  5163. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5164. exit;
  5165. }
  5166. $dblabel = $this->whlabellabel->get_label($label);
  5167. if ($dblabel) {
  5168. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5169. if (count($data) < 1) {
  5170. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5171. exit;
  5172. }
  5173. if (count($data) < $num) {
  5174. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5175. exit;
  5176. }
  5177. for ($i = 0; $i < $sl; $i++) {
  5178. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5179. }
  5180. echo json_encode(array('success' => true));
  5181. exit;
  5182. } else {
  5183. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5184. exit;
  5185. }
  5186. }
  5187. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5188. $this->_Template('whlabel_db', $this->data);
  5189. }
  5190. public function _dbrk()
  5191. {
  5192. $post = $this->input->post(NULL, TRUE);
  5193. if (isset($post['page'])) {
  5194. $page = $this->input->post('page', true);
  5195. $perpage = $this->input->post('perpage', true);
  5196. $sku = $this->input->post('sku', true);
  5197. $number = $this->input->post('number', true);
  5198. $warehouse = $this->input->post('warehouse', true);
  5199. $purchase = $this->input->post('purchase', true);
  5200. $orderinfo = $this->input->post('orderinfo', true);
  5201. $waybill = $this->input->post('waybill', true);
  5202. $category = $this->input->post('category', true);
  5203. $size = $this->input->post('size', true);
  5204. $grade = $this->input->post('grade', true);
  5205. $color = $this->input->post('color', true);
  5206. $lowe = $this->input->post('lowe', true);
  5207. $state = $this->input->post('state', true);
  5208. $label = $this->input->post('label', true);
  5209. $ctime = $this->input->post('ctime', true);
  5210. $timetk = $this->input->post('timetkk', true);
  5211. $timetj = $this->input->post('timetjj', true);
  5212. $timetk = strtotime($timetk);
  5213. $timetj = strtotime($timetj);
  5214. $where = "dbtime > 0";
  5215. if ($timetk && $timetj) {
  5216. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5217. }
  5218. if ($sku) {
  5219. $where .= " and sku = '$sku'";
  5220. }
  5221. if ($warehouse) {
  5222. $where .= " and warehouse = '$warehouse'";
  5223. }
  5224. if ($purchase) {
  5225. $where .= " and purchase = '$purchase'";
  5226. }
  5227. if ($category) {
  5228. $where .= " and features like '%-$category-%'";
  5229. }
  5230. if ($size) {
  5231. $where .= " and features like '%-$size-%'";
  5232. }
  5233. if ($grade) {
  5234. $where .= " and features like '%-$grade-%'";
  5235. }
  5236. if ($color) {
  5237. $where .= " and features like '%-$color-%'";
  5238. }
  5239. if ($lowe) {
  5240. $where .= " and features like '%-$lowe-%'";
  5241. }
  5242. if ($state != '') {
  5243. $where .= " and state = '$state'";
  5244. }
  5245. //数据排序
  5246. $order_str = "dbtime desc";
  5247. if (empty($page)) {
  5248. $start = 0;
  5249. $perpage = 1;
  5250. } else {
  5251. $start = ($page - 1) * $perpage;
  5252. }
  5253. //取得信息列表
  5254. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5255. foreach ($info_list as $key => $value) {
  5256. $warehouse = $this->warehouse->read($value['warehouse']);
  5257. $info_list[$key]['warehouse'] = $warehouse['title'];
  5258. $purchase = $this->purchase->read($value['purchase']);
  5259. $info_list[$key]['purchase'] = $purchase['title'];
  5260. if ($value['enter'] != 0) {
  5261. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5262. } else {
  5263. $info_list[$key]['enter'] = "";
  5264. }
  5265. if ($value['dbtime'] != 0) {
  5266. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5267. } else {
  5268. $info_list[$key]['dbtime'] = "";
  5269. }
  5270. if ($value['state'] == 0) {
  5271. $info_list[$key]['state'] = "在库";
  5272. } else if ($value['state'] == 1) {
  5273. $info_list[$key]['state'] = "出库";
  5274. } else if ($value['state'] == 2) {
  5275. $info_list[$key]['state'] = "退库";
  5276. } else if ($value['state'] == 3) {
  5277. $info_list[$key]['state'] = "调拨中";
  5278. } else if ($value['state'] == 4) {
  5279. $info_list[$key]['state'] = "再加工";
  5280. } else if ($value['state'] == 5) {
  5281. $info_list[$key]['state'] = "维修中";
  5282. } else if ($value['state'] == 6) {
  5283. $info_list[$key]['state'] = "盘亏";
  5284. } else if ($value['state'] == 7) {
  5285. $info_list[$key]['state'] = "更换标签";
  5286. } else if ($value['state'] == 8) {
  5287. $info_list[$key]['state'] = "其它";
  5288. } else if ($value['state'] == 9) {
  5289. $info_list[$key]['state'] = "预设";
  5290. }
  5291. }
  5292. $total = $this->whlabel->find_count($where);
  5293. $pagenum = ceil($total / $perpage);
  5294. $over = $total - ($start + $perpage);
  5295. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5296. echo json_encode($rows);
  5297. exit;
  5298. }
  5299. if (isset($post['rsku'])) {
  5300. $cz = $this->input->post('cz', true);
  5301. $label = $this->input->post('rsku', true);
  5302. $sl = $this->input->post('sl', true);
  5303. $warehouse = $this->input->post('warehouse', true);
  5304. if (!$sl) {
  5305. $sl = 1;
  5306. }
  5307. if (!$warehouse) {
  5308. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5309. exit;
  5310. }
  5311. $dblabel = $this->whlabellabel->get_label($label);
  5312. if ($dblabel) {
  5313. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5314. if (count($data) < 1) {
  5315. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5316. exit;
  5317. }
  5318. if ($sl > count($data)) {
  5319. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5320. exit;
  5321. }
  5322. $time = time();
  5323. for ($i = 0; $i < $sl; $i++) {
  5324. $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']);
  5325. }
  5326. echo json_encode(array('success' => true));
  5327. exit;
  5328. } else {
  5329. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5330. exit;
  5331. }
  5332. }
  5333. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5334. $this->_Template('whlabel_dbrk', $this->data);
  5335. }
  5336. public function _whlabelczdc()
  5337. {
  5338. if (isset($_GET['excel'])) {
  5339. //数据排序
  5340. $order_str = "id desc";
  5341. if (empty($page)) {
  5342. $start = 0;
  5343. $perpage = 1;
  5344. } else {
  5345. $start = ($page - 1) * $perpage;
  5346. }
  5347. $state = $this->input->get('state', true);
  5348. $sku = $this->input->get('sku', true);
  5349. $ctime = $this->input->get('ctime', true);
  5350. $category = $this->input->get('category', true);
  5351. $size = $this->input->get('size', true);
  5352. $grade = $this->input->get('grade', true);
  5353. $color = $this->input->get('color', true);
  5354. $lowe = $this->input->get('lowe', true);
  5355. $timetk = $this->input->get('timetkk', true);
  5356. $timetj = $this->input->get('timetjj', true);
  5357. $timetk = strtotime($timetk);
  5358. $timetj = strtotime($timetj);
  5359. $where = "dbtime > 0";
  5360. if ($timetk && $timetj) {
  5361. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5362. }
  5363. if ($category) {
  5364. $where .= " and features like '%-$category-%'";
  5365. }
  5366. if ($size) {
  5367. $where .= " and features like '%-$size-%'";
  5368. }
  5369. if ($grade) {
  5370. $where .= " and features like '%-$grade-%'";
  5371. }
  5372. if ($color) {
  5373. $where .= " and features like '%-$color-%'";
  5374. }
  5375. if ($lowe) {
  5376. $where .= " and features like '%-$lowe-%'";
  5377. }
  5378. //取得信息列表
  5379. $info_list = $this->whlabel->find_all($where, '*');
  5380. $rows = array();
  5381. $list = array();
  5382. foreach ($info_list as $key => $value) {
  5383. $rows[$value['sku']] = $value; //所有数据sku
  5384. }
  5385. foreach ($rows as $value) {
  5386. $warehouse = $this->warehouse->read($value['warehouse']);
  5387. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5388. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5389. if ($value['orderinfo'] == 0) {
  5390. $info_list[$key]['orderinfo'] = "";
  5391. }
  5392. if ($value['waybill'] == 0) {
  5393. $info_list[$key]['waybill'] = "";
  5394. }
  5395. if ($value['state'] == 0) {
  5396. $value['state'] = "在库";
  5397. } else if ($value['state'] == 3) {
  5398. $value['state'] = "调拨中";
  5399. }
  5400. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5401. }
  5402. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5403. $titlename = "<table border=1>
  5404. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5405. <tr align='center'>
  5406. <td>SKU</td>
  5407. <td>产品</td>
  5408. <td>调拨数量</td>
  5409. <td>入库数量</td>
  5410. </tr>
  5411. </table>";
  5412. $filename = $title . ".xls";
  5413. $tail = "";
  5414. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5415. }
  5416. }
  5417. public function _print($arg_array)
  5418. {
  5419. if (isset($_SESSION['api'])) {
  5420. $user = $this->user->get_api($_SESSION['api']);
  5421. $usp = $user;
  5422. $fgshop = "";
  5423. $sid = "";
  5424. $wid = "";
  5425. $wtype = "";
  5426. $usersp = explode('|', trim($user['shop'], '|'));
  5427. $userwh = explode('|', trim($user['warehouse'], '|'));
  5428. foreach ($usersp as $value) {
  5429. $fgshop .= " shop = " . $value . " or";
  5430. $sid .= " id = " . $value . " or";
  5431. }
  5432. foreach ($userwh as $value) {
  5433. $wid .= " id = " . $value . " or";
  5434. $wtype .= " type = " . $value . " or";
  5435. }
  5436. }
  5437. $post = $this->input->post(NULL, TRUE);
  5438. if (isset($post['tmsku'])) {
  5439. $tmsku = $this->input->post('tmsku', true);
  5440. if (is_numeric($tmsku)) {
  5441. $yyh = $this->whlabellabel->get_label($tmsku);
  5442. } else {
  5443. $yyh = $this->whlabellabel->get_sku($tmsku);
  5444. }
  5445. if ($yyh) {
  5446. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5447. exit;
  5448. } else {
  5449. echo json_encode(array('success' => false));
  5450. exit;
  5451. }
  5452. }
  5453. $classid = $this->classid->sku();
  5454. $pm = $classid;
  5455. $scsku = $classid;
  5456. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5457. if (isset($post['warehouse'])) {
  5458. if ($post['warehouse']) {
  5459. $list = array();
  5460. $num = "";
  5461. $title = "";
  5462. $features = "";
  5463. $order = 0;
  5464. $post['shop'] = '';
  5465. $brand = $this->input->post('brand', true);
  5466. if ($brand != '0,') {
  5467. $b = $this->brand->read(rtrim($brand, ','));
  5468. if ($b) {
  5469. $post['shop'] = str_replace('|', ',', $b['shop']);
  5470. }
  5471. }
  5472. $post['details'] = $this->input->post('details', true); //打印数量
  5473. $xbqnum = $this->input->post('xbqnum', true);
  5474. $post['purchase'] = $this->input->post('purchase', true);
  5475. $post['warehouse'] = $this->input->post('warehouse', true);
  5476. $post['purchase'] = $this->input->post('purchase', true);
  5477. $post['retreatwarehouse'] = $post['warehouse'];
  5478. $post['cpbz'] = $this->input->post('cpbz', true);
  5479. $post['state'] = 9;
  5480. $category = $this->input->post('category', true);
  5481. $list['category'] = $category;
  5482. $list['hairtype'] = $this->input->post('hairtype', true);
  5483. $list['grade'] = $this->input->post('grade', true);
  5484. $size = $this->input->post('size', true);
  5485. $list['size'] = rtrim($size, ',');
  5486. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5487. $list['extension'] = $this->input->post('extension', true);
  5488. if ($category == 1297) {
  5489. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5490. }
  5491. if ($category == 1702) {
  5492. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5493. $list['syother'] = $this->input->post('syother', true);
  5494. }
  5495. if ($category == 133) {
  5496. $list['fittype'] = $this->input->post('fittype', true);
  5497. $list['acother'] = $this->input->post('acother', true);
  5498. }
  5499. $list['color'] = $this->input->post('color', true);
  5500. $list['lowe'] = $this->input->post('lowe', true);
  5501. if ($category == 127) {
  5502. $list['type'] = $this->input->post('type', true);
  5503. $list['headroad'] = $this->input->post('headroad', true);
  5504. $list['density'] = $this->input->post('density', true);
  5505. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5506. $list['lacesize'] = $this->input->post('lacesize', true);
  5507. }
  5508. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5509. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5510. }
  5511. if ($category == 128) {
  5512. $list['lacetype'] = $this->input->post('lacetype', true);
  5513. $list['haircap'] = $this->input->post('haircap', true);
  5514. $list['density'] = $this->input->post('density', true);
  5515. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5516. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5517. $list['wigother'] = $this->input->post('wigother', true);
  5518. $list['wigother1'] = $this->input->post('wigother1', true);
  5519. $list['wigother2'] = $this->input->post('wigother2', true);
  5520. }
  5521. if ($category == 129) {
  5522. $list['wide'] = $this->input->post('wide', true);
  5523. }
  5524. if ($category == 131) {
  5525. $list['gifttype'] = $this->input->post('gifttype', true);
  5526. $list['giftother'] = $this->input->post('giftother', true);
  5527. }
  5528. if ($category == 134) {
  5529. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5530. }
  5531. if ($category == 1297) {
  5532. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5533. $list['sywigother'] = $this->input->post('sywigother', true);
  5534. }
  5535. if ($category == 130 || $category == 133 || $category == 1702) {
  5536. $list['items'] = $this->input->post('items', true);
  5537. $list['weight'] = $this->input->post('weight', true);
  5538. }
  5539. if ($category == 1702) {
  5540. $list['syhairther'] = $this->input->post('syhairther', true);
  5541. }
  5542. foreach ($list as $k => $v) {
  5543. if ($v != 0) {
  5544. $num .= $v;
  5545. $features .= $v . '-';
  5546. $post[$k] = $v;
  5547. $typeclass = $this->typeclass->read($v);
  5548. if (isset($pm[$typeclass['classid']])) {
  5549. if (stripos($typeclass['zh'], '|') !== false) {
  5550. $exzh = explode('|', $typeclass['zh']);
  5551. $pm[$typeclass['classid']] = $exzh[0];
  5552. } else {
  5553. $pm[$typeclass['classid']] = $typeclass['zh'];
  5554. }
  5555. }
  5556. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5557. if ($k != 'size') {
  5558. $title .= $typeclass['title'] . " ";
  5559. }
  5560. }
  5561. }
  5562. $typeclass = $this->typeclass->read($list['size']);
  5563. $title .= $typeclass['title'];
  5564. $time = time();
  5565. $post['title'] = rtrim($title, ' ');
  5566. $post['number'] = $num;
  5567. $post['features'] = '-' . $features;
  5568. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5569. $featurespp = explode('-', trim($featurespp, '-'));
  5570. if (isset($featurespp[5])) {
  5571. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5572. } else {
  5573. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5574. }
  5575. $post['enter'] = $time;
  5576. $post['time'] = $time; //操作时间
  5577. $scsku = implode("-", $scsku);
  5578. $zh = implode(" ", $pm);
  5579. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5580. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5581. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5582. $post['sku'] = $bqsku;
  5583. $label = time() . rand(0, 9);
  5584. $post['label'] = $label;
  5585. $cpid = $this->whlabellabel->find_count();
  5586. $post['cpid'] = $cpid + 1;
  5587. $cpid = $post['cpid'];
  5588. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5589. //if($whlabelbarcode)
  5590. //{
  5591. //$post['label'] = $whlabelbarcode['label'];
  5592. //if(!$this->whlabellabel->insert($post))
  5593. //{
  5594. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5595. //}
  5596. //}
  5597. //else
  5598. //{
  5599. $this->db->trans_begin();
  5600. $this->whlabellabel->insert($post);
  5601. //$this->whlabelbarcode->insert($post);
  5602. if ($this->db->trans_status() === TRUE) {
  5603. $this->db->trans_commit();
  5604. } else {
  5605. $this->db->trans_rollback();
  5606. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5607. exit;
  5608. }
  5609. //}
  5610. $warehouse_name = "";
  5611. $warehouse = $post['warehouse'];
  5612. if($warehouse == 12){
  5613. $warehouse_name = "特殊库存库";
  5614. }
  5615. // if($warehouse == 13){
  5616. // $warehouse_name = "许昌仓";
  5617. // }
  5618. // if($warehouse == 5){
  5619. // $warehouse_name = "美国店";
  5620. // }
  5621. // if($warehouse == 16){
  5622. // $warehouse_name = "定制头套仓";
  5623. // }
  5624. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5625. if(!empty($warehouse_name)){
  5626. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5627. }
  5628. $purchase = $this->purchase->read($post['purchase']);
  5629. 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));
  5630. exit; //特殊仓目前不需要仓库选项
  5631. }
  5632. }
  5633. if (isset($_SESSION['api'])) {
  5634. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5635. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5636. $this->data['wlshop'] = $wlshop;
  5637. $this->data['warehouse'] = $warehouse;
  5638. }
  5639. $whlabelwz = $this->whlabelwz->find_all();
  5640. $this->data['whlabelwz'] = $whlabelwz;
  5641. $this->_Template('whlabel_print', $this->data);
  5642. }
  5643. public function _usaprint($arg_array)
  5644. {
  5645. if (isset($_SESSION['api'])) {
  5646. $user = $this->user->get_api($_SESSION['api']);
  5647. $usp = $user;
  5648. $fgshop = "";
  5649. $sid = "";
  5650. $wid = "";
  5651. $wtype = "";
  5652. $usersp = explode('|', trim($user['shop'], '|'));
  5653. $userwh = explode('|', trim($user['warehouse'], '|'));
  5654. foreach ($usersp as $value) {
  5655. $fgshop .= " shop = " . $value . " or";
  5656. $sid .= " id = " . $value . " or";
  5657. }
  5658. foreach ($userwh as $value) {
  5659. $wid .= " id = " . $value . " or";
  5660. $wtype .= " type = " . $value . " or";
  5661. }
  5662. }
  5663. $post = $this->input->post(NULL, TRUE);
  5664. if (isset($post['tmsku'])) {
  5665. $tmsku = $this->input->post('tmsku', true);
  5666. if (is_numeric($tmsku)) {
  5667. $yyh = $this->whlabellabel->get_label($tmsku);
  5668. } else {
  5669. $yyh = $this->whlabellabel->get_sku($tmsku);
  5670. }
  5671. if ($yyh) {
  5672. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5673. exit;
  5674. } else {
  5675. echo json_encode(array('success' => false));
  5676. exit;
  5677. }
  5678. }
  5679. $classid = $this->classid->sku();
  5680. $pm = $classid;
  5681. $scsku = $classid;
  5682. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5683. if (isset($post['warehouse'])) {
  5684. if ($post['warehouse']) {
  5685. $list = array();
  5686. $num = "";
  5687. $title = "";
  5688. $features = "";
  5689. $order = 0;
  5690. $post['shop'] = '';
  5691. $brand = $this->input->post('brand', true);
  5692. if ($brand != '0,') {
  5693. $b = $this->brand->read(rtrim($brand, ','));
  5694. if ($b) {
  5695. $post['shop'] = str_replace('|', ',', $b['shop']);
  5696. }
  5697. }
  5698. $post['details'] = $this->input->post('details', true); //打印数量
  5699. $xbqnum = $this->input->post('xbqnum', true);
  5700. $post['purchase'] = $this->input->post('purchase', true);
  5701. $post['warehouse'] = $this->input->post('warehouse', true);
  5702. $post['purchase'] = $this->input->post('purchase', true);
  5703. $post['retreatwarehouse'] = $post['warehouse'];
  5704. $post['cpbz'] = $this->input->post('cpbz', true);
  5705. $post['state'] = 9;
  5706. $category = $this->input->post('category', true);
  5707. $list['category'] = $category;
  5708. $list['hairtype'] = $this->input->post('hairtype', true);
  5709. $list['grade'] = $this->input->post('grade', true);
  5710. $size = $this->input->post('size', true);
  5711. $list['size'] = rtrim($size, ',');
  5712. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5713. $list['extension'] = $this->input->post('extension', true);
  5714. if ($category == 1297) {
  5715. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5716. }
  5717. if ($category == 1702) {
  5718. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5719. $list['syother'] = $this->input->post('syother', true);
  5720. }
  5721. if ($category == 133) {
  5722. $list['fittype'] = $this->input->post('fittype', true);
  5723. $list['acother'] = $this->input->post('acother', true);
  5724. }
  5725. $list['color'] = $this->input->post('color', true);
  5726. $list['lowe'] = $this->input->post('lowe', true);
  5727. if ($category == 127) {
  5728. $list['type'] = $this->input->post('type', true);
  5729. $list['headroad'] = $this->input->post('headroad', true);
  5730. $list['density'] = $this->input->post('density', true);
  5731. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5732. $list['lacesize'] = $this->input->post('lacesize', true);
  5733. }
  5734. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5735. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5736. }
  5737. if ($category == 128) {
  5738. $list['lacetype'] = $this->input->post('lacetype', true);
  5739. $list['haircap'] = $this->input->post('haircap', true);
  5740. $list['density'] = $this->input->post('density', true);
  5741. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5742. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5743. $list['wigother'] = $this->input->post('wigother', true);
  5744. $list['wigother1'] = $this->input->post('wigother1', true);
  5745. $list['wigother2'] = $this->input->post('wigother2', true);
  5746. }
  5747. if ($category == 129) {
  5748. $list['wide'] = $this->input->post('wide', true);
  5749. }
  5750. if ($category == 131) {
  5751. $list['gifttype'] = $this->input->post('gifttype', true);
  5752. $list['giftother'] = $this->input->post('giftother', true);
  5753. }
  5754. if ($category == 134) {
  5755. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5756. }
  5757. if ($category == 1297) {
  5758. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5759. $list['sywigother'] = $this->input->post('sywigother', true);
  5760. }
  5761. if ($category == 130 || $category == 133 || $category == 1702) {
  5762. $list['items'] = $this->input->post('items', true);
  5763. $list['weight'] = $this->input->post('weight', true);
  5764. }
  5765. if ($category == 1702) {
  5766. $list['syhairther'] = $this->input->post('syhairther', true);
  5767. }
  5768. foreach ($list as $k => $v) {
  5769. if ($v != 0) {
  5770. $num .= $v;
  5771. $features .= $v . '-';
  5772. $post[$k] = $v;
  5773. $typeclass = $this->typeclass->read($v);
  5774. if (isset($pm[$typeclass['classid']])) {
  5775. if (stripos($typeclass['zh'], '|') !== false) {
  5776. $exzh = explode('|', $typeclass['zh']);
  5777. $pm[$typeclass['classid']] = $exzh[0];
  5778. } else {
  5779. $pm[$typeclass['classid']] = $typeclass['zh'];
  5780. }
  5781. }
  5782. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5783. if ($k != 'size') {
  5784. $title .= $typeclass['title'] . " ";
  5785. }
  5786. }
  5787. }
  5788. $typeclass = $this->typeclass->read($list['size']);
  5789. $title .= $typeclass['title'];
  5790. $time = time();
  5791. $post['title'] = rtrim($title, ' ');
  5792. $post['number'] = $num;
  5793. $post['features'] = '-' . $features;
  5794. $fp = $this->whlabel->get_features($post['features']);
  5795. if (!$fp) {
  5796. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5797. exit;
  5798. }
  5799. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5800. $featurespp = explode('-', trim($featurespp, '-'));
  5801. if (isset($featurespp[5])) {
  5802. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5803. } else {
  5804. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5805. }
  5806. $post['enter'] = $time;
  5807. $post['time'] = $time; //操作时间
  5808. $scsku = implode("-", $scsku);
  5809. $zh = implode(" ", $pm);
  5810. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5811. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5812. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5813. $post['sku'] = $fp['sku'];
  5814. $post['label'] = $fp['sku'];
  5815. $cpid = $this->whlabellabel->find_count();
  5816. $post['cpid'] = $cpid + 1;
  5817. $cpid = $post['cpid'];
  5818. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5819. //if($whlabelbarcode)
  5820. //{
  5821. //$post['label'] = $whlabelbarcode['label'];
  5822. //if(!$this->whlabellabel->insert($post))
  5823. //{
  5824. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5825. //}
  5826. //}
  5827. //else
  5828. //{
  5829. $this->db->trans_begin();
  5830. $this->whlabellabel->insert($post);
  5831. //$this->whlabelbarcode->insert($post);
  5832. if ($this->db->trans_status() === TRUE) {
  5833. $this->db->trans_commit();
  5834. } else {
  5835. $this->db->trans_rollback();
  5836. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5837. exit;
  5838. }
  5839. //}
  5840. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5841. $purchase = $this->purchase->read($post['purchase']);
  5842. 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));
  5843. exit; //特殊仓目前不需要仓库选项
  5844. }
  5845. }
  5846. if (isset($_SESSION['api'])) {
  5847. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5848. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5849. $this->data['wlshop'] = $wlshop;
  5850. $this->data['warehouse'] = $warehouse;
  5851. }
  5852. $whlabelwz = $this->whlabelwz->find_all();
  5853. $this->data['whlabelwz'] = $whlabelwz;
  5854. $this->_Template('whlabel_usaprint', $this->data);
  5855. }
  5856. public function _printrk($arg_array)
  5857. {
  5858. $prc = array();
  5859. $purchase = $this->purchase->find_all();
  5860. foreach ($purchase as $k => $v) {
  5861. $prc[$v['id']] = $v['title'];
  5862. }
  5863. $post = $this->input->post(NULL, TRUE);
  5864. if (isset($post['page'])) {
  5865. $page = $this->input->post('page', true);
  5866. $perpage = $this->input->post('perpage', true);
  5867. $sku = $this->input->post('sku', true);
  5868. $bs = $this->input->post('bs', true);
  5869. $number = $this->input->post('number', true);
  5870. $warehouse = $this->input->post('warehouse', true);
  5871. $purchase = $this->input->post('purchase', true);
  5872. $orderinfo = $this->input->post('orderinfo', true);
  5873. $waybill = $this->input->post('waybill', true);
  5874. $category = $this->input->post('category', true);
  5875. $size = $this->input->post('size', true);
  5876. $grade = $this->input->post('grade', true);
  5877. $color = $this->input->post('color', true);
  5878. $lowe = $this->input->post('lowe', true);
  5879. $state = $this->input->post('state', true);
  5880. $label = $this->input->post('label', true);
  5881. $timetk = $this->input->post('ktime', true);
  5882. $timetj = $this->input->post('jtime', true);
  5883. $timetk = strtotime($timetk);
  5884. $timetj = strtotime($timetj);
  5885. $where = "1=1 ";
  5886. if ($timetk && $timetj) {
  5887. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5888. }
  5889. if ($sku) {
  5890. $where .= " and sku = '$sku'";
  5891. }
  5892. if ($bs != '') {
  5893. $where .= " and bs = '$bs'";
  5894. }
  5895. if ($number) {
  5896. $where .= " and number = '$number'";
  5897. }
  5898. if ($warehouse) {
  5899. $where .= " and warehouse = '$warehouse'";
  5900. }
  5901. if ($purchase) {
  5902. $where .= " and purchase = '$purchase'";
  5903. }
  5904. if ($orderinfo) {
  5905. $where .= " and orderinfo = '$orderinfo'";
  5906. }
  5907. if ($waybill) {
  5908. $where .= " and waybill = '$waybill'";
  5909. }
  5910. if ($category) {
  5911. $where .= " and features like '%-$category-%'";
  5912. }
  5913. if ($size) {
  5914. $where .= " and features like '%-$size-%'";
  5915. }
  5916. if ($grade) {
  5917. $where .= " and features like '%-$grade-%'";
  5918. }
  5919. if ($color) {
  5920. $where .= " and features like '%-$color-%'";
  5921. }
  5922. if ($lowe) {
  5923. $where .= " and features like '%-$lowe-%'";
  5924. }
  5925. if ($label) {
  5926. $where .= " and label = '$label'";
  5927. }
  5928. if ($state || $state == 0) {
  5929. $where .= " and state = '$state'";
  5930. }
  5931. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5932. //数据排序
  5933. $order_str = "enter desc";
  5934. if (empty($page)) {
  5935. $start = 0;
  5936. $perpage = 1;
  5937. } else {
  5938. $start = ($page - 1) * $perpage;
  5939. }
  5940. //取得信息列表
  5941. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5942. foreach ($info_list as $key => $value) {
  5943. $warehouse = $this->warehouse->read($value['warehouse']);
  5944. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5945. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5946. if ($value['state'] == 0) {
  5947. $info_list[$key]['state'] = "在库";
  5948. } else if ($value['state'] == 1) {
  5949. $info_list[$key]['state'] = "出库";
  5950. } else if ($value['state'] == 2) {
  5951. $info_list[$key]['state'] = "退库";
  5952. } else if ($value['state'] == 3) {
  5953. $info_list[$key]['state'] = "调拨中";
  5954. } else if ($value['state'] == 4) {
  5955. $info_list[$key]['state'] = "再加工";
  5956. } else if ($value['state'] == 5) {
  5957. $info_list[$key]['state'] = "维修中";
  5958. } else if ($value['state'] == 6) {
  5959. $info_list[$key]['state'] = "盘亏";
  5960. } else if ($value['state'] == 7) {
  5961. $info_list[$key]['state'] = "更换标签";
  5962. } else if ($value['state'] == 8) {
  5963. $info_list[$key]['state'] = "其它";
  5964. } else if ($value['state'] == 9) {
  5965. $info_list[$key]['state'] = "预设";
  5966. } else if ($value['state'] == 10) {
  5967. $info_list[$key]['state'] = "美店零售";
  5968. }
  5969. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5970. }
  5971. $total = $this->$ck->find_count($where);
  5972. $pagenum = ceil($total / $perpage);
  5973. $over = $total - ($start + $perpage);
  5974. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5975. echo json_encode($rows);
  5976. exit;
  5977. }
  5978. if (isset($post['tmsku'])) {
  5979. $time = time();
  5980. $tmsku = $this->input->post('tmsku', true);
  5981. //$post['shop'] = $this->input->post('shop',true);
  5982. $num = $this->input->post('num', true);
  5983. $rktype = $this->input->post('rktype', true);
  5984. if ($num > 200) {
  5985. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5986. exit;
  5987. }
  5988. if (!$rktype) {
  5989. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5990. }
  5991. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5992. /**
  5993. $wz = array();
  5994. foreach ($rk as $key=>$value)
  5995. {
  5996. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5997. }
  5998. if(count($wz) > 1)
  5999. {
  6000. $wz = array_values($wz);
  6001. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6002. }
  6003. **/
  6004. if (isset($rk[0]['purchase'])) {
  6005. $rk = $rk[0];
  6006. $j = 0;
  6007. $post['purchase'] = $rk['purchase'];
  6008. $post['warehouse'] = $rk['warehouse'];
  6009. $post['retreatwarehouse'] = $rk['warehouse'];
  6010. $post['sku'] = $rk['sku'];
  6011. $post['number'] = $rk['number'];
  6012. $post['features'] = $rk['features'];
  6013. $post['title'] = $rk['title'];
  6014. $post['enter'] = $time;
  6015. $post['time'] = $time;
  6016. $post['bs'] = 1;
  6017. $post['shop'] = $rk['shop'];
  6018. $post['details'] = $rk['details'];
  6019. $post['cpid'] = $rk['cpid'];
  6020. $post['cpbz'] = $rk['cpbz'];
  6021. //$post['rktype'] = $rktype;
  6022. $warehouse = $this->warehouse->read($rk['warehouse']);
  6023. if ($warehouse['bdck'] == '') {
  6024. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6025. exit;
  6026. } else {
  6027. $bdck = $warehouse['bdck'];
  6028. }
  6029. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6030. if (isset($pdwz['details'])) {
  6031. if ($pdwz['details'] != $post['details']) {
  6032. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6033. exit;
  6034. }
  6035. }
  6036. $post['featurespp'] = $rk['featurespp'];
  6037. if ($post['warehouse'] == '5') {
  6038. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6039. if ($yza) {
  6040. if ($post['features'] != $yza[0]['features']) {
  6041. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6042. exit;
  6043. }
  6044. }
  6045. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6046. if ($yzb) {
  6047. if ($post['sku'] != $yzb[0]['sku']) {
  6048. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6049. exit;
  6050. }
  6051. }
  6052. }
  6053. for ($i = 0; $i < $num; $i++) {
  6054. $post['label'] = time() . rand(100, 999) . $i;
  6055. if ($this->$bdck->insert($post)) {
  6056. $j++;
  6057. }
  6058. }
  6059. /**
  6060. if($post['warehouse'] != 12)
  6061. {
  6062. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6063. }
  6064. **/
  6065. if ($j == $num) {
  6066. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6067. exit;
  6068. } else {
  6069. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6070. exit;
  6071. }
  6072. } else {
  6073. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6074. exit;
  6075. }
  6076. }
  6077. $this->_Template('whlabel_printrk', $this->data);
  6078. }
  6079. public function _printxzrk($arg_array)
  6080. {
  6081. $post = $this->input->post(NULL, TRUE);
  6082. if (isset($post['wzid'])) {
  6083. $time = time();
  6084. $id = $this->input->post('wzid', true);
  6085. //$post['shop'] = $this->input->post('shop',true);
  6086. $num = 1;
  6087. $rk = $this->whlabellabel->read($id);
  6088. if (isset($rk['purchase'])) {
  6089. $x = 0;
  6090. $post['purchase'] = $rk['purchase'];
  6091. $post['warehouse'] = $rk['warehouse'];
  6092. $post['retreatwarehouse'] = $rk['warehouse'];
  6093. $post['sku'] = $rk['sku'];
  6094. $post['number'] = $rk['number'];
  6095. $post['features'] = $rk['features'];
  6096. $post['title'] = $rk['title'];
  6097. $post['enter'] = $time;
  6098. $post['time'] = $time;
  6099. $post['bs'] = 1;
  6100. $post['shop'] = $rk['shop'];
  6101. $post['details'] = $rk['details'];
  6102. $post['cpid'] = $rk['cpid'];
  6103. $post['cpbz'] = $rk['cpbz'];
  6104. $warehouse = $this->warehouse->read($rk['warehouse']);
  6105. if ($warehouse['bdck'] == '') {
  6106. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6107. exit;
  6108. } else {
  6109. $bdck = $warehouse['bdck'];
  6110. }
  6111. $post['featurespp'] = $rk['featurespp'];
  6112. $this->db->trans_begin();
  6113. for ($i = 0; $i < $num; $i++) {
  6114. $post['label'] = time() . rand(100, 999) . $i;
  6115. $this->$bdck->insert($post);
  6116. }
  6117. /**
  6118. if($post['warehouse'] != 12)
  6119. {
  6120. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6121. }
  6122. **/
  6123. if ($this->db->trans_status() === TRUE) {
  6124. $this->db->trans_commit();
  6125. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6126. exit;
  6127. } else {
  6128. $this->db->trans_rollback();
  6129. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6130. exit;
  6131. }
  6132. } else {
  6133. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6134. exit;
  6135. }
  6136. }
  6137. }
  6138. public function _printck($arg_array)
  6139. {
  6140. $prc = array();
  6141. $purchase = $this->purchase->find_all();
  6142. foreach ($purchase as $k => $v) {
  6143. $prc[$v['id']] = $v['title'];
  6144. }
  6145. $post = $this->input->post(NULL, TRUE);
  6146. if (isset($post['page'])) {
  6147. $page = $this->input->post('page', true);
  6148. $perpage = $this->input->post('perpage', true);
  6149. $sku = $this->input->post('sku', true);
  6150. $bs = $this->input->post('bs', true);
  6151. $number = $this->input->post('number', true);
  6152. $warehouse = $this->input->post('warehouse', true);
  6153. $purchase = $this->input->post('purchase', true);
  6154. $orderinfo = $this->input->post('orderinfo', true);
  6155. $waybill = $this->input->post('waybill', true);
  6156. $category = $this->input->post('category', true);
  6157. $size = $this->input->post('size', true);
  6158. $grade = $this->input->post('grade', true);
  6159. $color = $this->input->post('color', true);
  6160. $lowe = $this->input->post('lowe', true);
  6161. $state = $this->input->post('state', true);
  6162. $label = $this->input->post('label', true);
  6163. $timetk = $this->input->post('ktime', true);
  6164. $timetj = $this->input->post('jtime', true);
  6165. $timetk = strtotime($timetk);
  6166. $timetj = strtotime($timetj);
  6167. $where = "state=1 ";
  6168. if ($timetk && $timetj) {
  6169. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6170. }
  6171. if ($sku) {
  6172. $where .= " and sku = '$sku'";
  6173. }
  6174. if ($bs != '') {
  6175. $where .= " and bs = '$bs'";
  6176. }
  6177. if ($number) {
  6178. $where .= " and number = '$number'";
  6179. }
  6180. if ($warehouse) {
  6181. $where .= " and warehouse = '$warehouse'";
  6182. }
  6183. if ($purchase) {
  6184. $where .= " and purchase = '$purchase'";
  6185. }
  6186. if ($orderinfo) {
  6187. $where .= " and orderinfo = '$orderinfo'";
  6188. }
  6189. if ($waybill) {
  6190. $where .= " and waybill = '$waybill'";
  6191. }
  6192. if ($category) {
  6193. $where .= " and features like '%-$category-%'";
  6194. }
  6195. if ($size) {
  6196. $where .= " and features like '%-$size-%'";
  6197. }
  6198. if ($grade) {
  6199. $where .= " and features like '%-$grade-%'";
  6200. }
  6201. if ($color) {
  6202. $where .= " and features like '%-$color-%'";
  6203. }
  6204. if ($lowe) {
  6205. $where .= " and features like '%-$lowe-%'";
  6206. }
  6207. if ($label) {
  6208. $where .= " and label = '$label'";
  6209. }
  6210. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6211. //数据排序
  6212. $order_str = "outk desc";
  6213. if (empty($page)) {
  6214. $start = 0;
  6215. $perpage = 1;
  6216. } else {
  6217. $start = ($page - 1) * $perpage;
  6218. }
  6219. //取得信息列表
  6220. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6221. foreach ($info_list as $key => $value) {
  6222. $warehouse = $this->warehouse->read($value['warehouse']);
  6223. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6224. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6225. if ($value['state'] == 0) {
  6226. $info_list[$key]['state'] = "在库";
  6227. } else if ($value['state'] == 1) {
  6228. $info_list[$key]['state'] = "出库";
  6229. } else if ($value['state'] == 2) {
  6230. $info_list[$key]['state'] = "退库";
  6231. } else if ($value['state'] == 3) {
  6232. $info_list[$key]['state'] = "调拨中";
  6233. } else if ($value['state'] == 4) {
  6234. $info_list[$key]['state'] = "再加工";
  6235. } else if ($value['state'] == 5) {
  6236. $info_list[$key]['state'] = "维修中";
  6237. } else if ($value['state'] == 6) {
  6238. $info_list[$key]['state'] = "盘亏";
  6239. } else if ($value['state'] == 7) {
  6240. $info_list[$key]['state'] = "更换标签";
  6241. } else if ($value['state'] == 8) {
  6242. $info_list[$key]['state'] = "其它";
  6243. } else if ($value['state'] == 9) {
  6244. $info_list[$key]['state'] = "预设";
  6245. } else if ($value['state'] == 10) {
  6246. $info_list[$key]['state'] = "美店零售";
  6247. }
  6248. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6249. }
  6250. $total = $this->$ck->find_count($where);
  6251. $pagenum = ceil($total / $perpage);
  6252. $over = $total - ($start + $perpage);
  6253. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6254. echo json_encode($rows);
  6255. exit;
  6256. }
  6257. if (isset($post['tmsku'])) {
  6258. $time = time();
  6259. $tmsku = $this->input->post('tmsku', true);
  6260. //$post['shop'] = $this->input->post('shop',true);
  6261. $num = $this->input->post('num', true);
  6262. $cktype = $this->input->post('cktype', true);
  6263. $label = $this->whlabellabel->get_label($tmsku);
  6264. if (!$cktype) {
  6265. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6266. }
  6267. if (!isset($label['warehouse'])) {
  6268. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6269. exit;
  6270. }
  6271. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6272. if (stripos($label['features'], '-126-') !== false) {
  6273. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6274. } else {
  6275. $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 = ''");
  6276. }
  6277. $j = 0;
  6278. if (count($ck) >= $num) {
  6279. for ($i = 0; $i < $num; $i++) {
  6280. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6281. {
  6282. $j++;
  6283. }
  6284. }
  6285. if ($j == $num) {
  6286. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6287. exit;
  6288. } else {
  6289. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6290. exit;
  6291. }
  6292. } else {
  6293. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6294. exit;
  6295. }
  6296. }
  6297. if(isset($_SESSION['api']))
  6298. {
  6299. $user = $this->user->get_api($_SESSION['api']);
  6300. if(in_array($user['power'],[1,27])){
  6301. $vip = 1;
  6302. }
  6303. }
  6304. else
  6305. {
  6306. $vip = 0;
  6307. header('Location: /');exit;
  6308. }
  6309. $this->data['vip'] = $vip;
  6310. $this->_Template('whlabel_printck', $this->data);
  6311. }
  6312. public function _printexcel()
  6313. {
  6314. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6315. $config['upload_path'] = '.' . $dir;
  6316. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6317. $config['allowed_types'] = 'xls|xlsx|csv';
  6318. $config['max_size'] = 10240;
  6319. $this->load->library('upload', $config);
  6320. $this->upload->initialize($config);
  6321. if ($this->upload->do_upload('userfile')) {
  6322. $full_path = $dir . $this->upload->data('file_name');
  6323. $fileName = '.' . $full_path;
  6324. if (!file_exists($fileName)) {
  6325. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6326. exit;
  6327. } else {
  6328. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6329. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6330. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6331. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6332. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6333. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6334. ++$column; //如果列数大于26行
  6335. $list = array();
  6336. for ($i = 2; $i <= $row; $i++) // 行数循环
  6337. {
  6338. $data = array();
  6339. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6340. {
  6341. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6342. }
  6343. $list[] = $data;
  6344. }
  6345. }
  6346. $ed = array();
  6347. $i = 0;
  6348. $j = 0;
  6349. $dcdata = array();
  6350. $yc = '';
  6351. $cmf_arr = array_column($list, '1');
  6352. array_multisort($cmf_arr, SORT_ASC, $list);
  6353. foreach ($list as $key => $value) {
  6354. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6355. if ($typeclass) {
  6356. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6357. } else {
  6358. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6359. $i++;
  6360. continue;
  6361. }
  6362. }
  6363. if ($i > 0) {
  6364. $yc = $i . '条异常';
  6365. }
  6366. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6367. exit;
  6368. }
  6369. }
  6370. public function _uck()
  6371. {
  6372. if (isset($_GET['excel'])) {
  6373. $tc = array();
  6374. $typeclass = $this->typeclass->find_all();
  6375. foreach ($typeclass as $v) {
  6376. $tc[$v['id']] = $v['zh'];
  6377. }
  6378. $data = array();
  6379. $t = array();
  6380. $rq = '';
  6381. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6382. $ts = $ts / (24 * 3600);
  6383. for ($i = 0; $i < $ts; $i++) {
  6384. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6385. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6386. }
  6387. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6388. foreach ($info_list as $k => $v) {
  6389. $features = explode('-', trim($v['features'], '-'));
  6390. if (!isset($features[3]) || !isset($features[4])) {
  6391. continue;
  6392. }
  6393. $data[$k][0] = $tc[$features[0]]; //类型
  6394. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6395. $data[$k][2] = $tc[$features[4]]; //曲度
  6396. $data[$k][3] = '';
  6397. if (isset($data[$k][1])) {
  6398. $data[$k][3] .= $data[$k][1];
  6399. }
  6400. if (isset($data[$k][2])) {
  6401. $data[$k][3] .= $data[$k][2];
  6402. }
  6403. if (isset($features[5])) {
  6404. $data[$k][3] .= $tc[$features[5]];
  6405. }
  6406. if (isset($features[2])) {
  6407. $data[$k][3] .= $tc[$features[2]];
  6408. }
  6409. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6410. $data[$k][4] = $v['sku'];
  6411. $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())) . '))'); //月初库存
  6412. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6413. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6414. $ztrq = '';
  6415. $ztsl = '';
  6416. if (count($zt) > 0) {
  6417. foreach ($zt as $vv) {
  6418. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6419. $ztsl .= $vv['num'] . '<br>';
  6420. }
  6421. }
  6422. $data[$k][] = trim($ztsl, '<br>');
  6423. $data[$k][] = trim($ztrq, '<br>');
  6424. $byck = 0;
  6425. foreach ($t as $vv) {
  6426. $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));
  6427. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6428. $byck += $sl;
  6429. }
  6430. $data[$k][] = ($byck > 0) ? $byck : '';
  6431. }
  6432. $title = "详情 " . date("Y-m-d", time());
  6433. $titlename = "<table border=1>
  6434. <tr align='center'>
  6435. <td>类别</td>
  6436. <td>颜色</td>
  6437. <td>曲度</td>
  6438. <td>名称</td>
  6439. <td>SKU</td>
  6440. <td>月初库存</td>
  6441. <td>剩余库存</td>
  6442. <td>在途数量</td>
  6443. <td>预达日期</td>" .
  6444. $rq
  6445. . "<td>本月出库</td></tr>
  6446. </table>";
  6447. $filename = $title . ".xls";
  6448. $tail = "";
  6449. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6450. }
  6451. }
  6452. public function _whlabelexcelzh()
  6453. {
  6454. if (isset($_GET['excel'])) {
  6455. $where = "sku != 'Preset'";
  6456. //数据排序
  6457. $order_str = "id desc";
  6458. if (empty($page)) {
  6459. $start = 0;
  6460. $perpage = 1;
  6461. } else {
  6462. $start = ($page - 1) * $perpage;
  6463. }
  6464. $category = $this->input->get('category', true);
  6465. $warehouse = $this->input->get('warehouse', true);
  6466. $excelid = $this->input->get('sid', true);
  6467. if ($category) {
  6468. $where .= " and features like '%-$category-%'";
  6469. }
  6470. if ($warehouse) {
  6471. $where .= " and warehouse = '$warehouse'";
  6472. }
  6473. $xzid = '';
  6474. if ($excelid) {
  6475. $excelid = explode(',', trim($excelid, ','));
  6476. foreach ($excelid as $key => $value) {
  6477. $xzid .= " id = " . $value . " or";
  6478. }
  6479. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6480. }
  6481. //取得信息列表
  6482. /**
  6483. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6484. $rows = array();$list = array();
  6485. foreach ($info_list as $key=>$value)
  6486. {
  6487. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6488. }
  6489. **/
  6490. $list = array();
  6491. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6492. foreach ($rows as $key => $value) {
  6493. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6494. $zh = '';
  6495. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6496. foreach ($zt as $v) {
  6497. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6498. }
  6499. $zt = array_sum(array_column($zt, 'num'));
  6500. $number = $value['number'];
  6501. $ftime = time() - 15 * 24 * 3600;
  6502. $warehouse = $this->warehouse->read($value['warehouse']);
  6503. $rows[$key]['warehouse'] = $warehouse['title'];
  6504. $rows[$key]['number'] = $c;
  6505. $rows[$key]['features'] = $zh;
  6506. $rows[$key]['hb'] = $c + $zt;
  6507. }
  6508. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6509. $titlename = "<table border=1>
  6510. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6511. <tr align='center'>
  6512. <td>仓库</td>
  6513. <td>SKU</td>
  6514. <td>产品</td>
  6515. <td>库存数量</td>
  6516. <td>在途数量及预达日期</td>
  6517. <td>在途+库存数量</td>
  6518. </tr>
  6519. </table>";
  6520. $filename = $title . ".xls";
  6521. $tail = "";
  6522. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6523. }
  6524. if (isset($_GET['excel'])) {
  6525. $warehouse = $this->input->get('warehouse', true);
  6526. $sku = $this->input->get('sku', true);
  6527. $cz = $this->input->get('cz', true);
  6528. $text = $this->input->post('text', true);
  6529. $xztime = $this->input->get('xztime', true);
  6530. $timetk = $this->input->get('timetk', true);
  6531. $timetj = $this->input->get('timetj', true);
  6532. $timetk = strtotime($timetk);
  6533. $timetj = strtotime($timetj);
  6534. $where = "time = '0' ";
  6535. if ($warehouse) {
  6536. $where .= " and warehouse = '$warehouse'";
  6537. }
  6538. if ($sku) {
  6539. $where .= " and sku = '$sku'";
  6540. }
  6541. if ($text) {
  6542. $where .= " and text like '%$text%'";
  6543. }
  6544. if ($cz != '') {
  6545. $where .= " and cz = '$cz'";
  6546. }
  6547. if ($timetk && $timetj) {
  6548. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6549. }
  6550. //数据排序
  6551. $order_str = $xztime . " desc";
  6552. //取得信息列表
  6553. $zh = array();
  6554. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6555. foreach ($info_list as $v) {
  6556. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6557. $warehouse = $this->warehouse->read($v['warehouse']);
  6558. $v['warehouse'] = $warehouse['title'];
  6559. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6560. $v['stime'] = date('Y-m-d', $v['stime']);
  6561. if (isset($zh[$v['features']])) {
  6562. $zh[$v['features']]['num'] += $v['num'];
  6563. } else {
  6564. $zh[$v['features']] = $v;
  6565. }
  6566. $zh[$v['features']]['features'] = $c;
  6567. }
  6568. $title = "在途数据" . date('Y-m-d', time());
  6569. $titlename = "<table border=1>
  6570. <tr align='center'>
  6571. <td>仓库</td>
  6572. <td>SKU</td>
  6573. <td>名称</td>
  6574. <td>在途数量</td>
  6575. <td>库存数量</td>
  6576. <td>添加在途日期</td>
  6577. <td>预达日期</td>
  6578. <td>备注</td>
  6579. </tr>
  6580. </table>";
  6581. $filename = $title . ".xls";
  6582. $tail = "";
  6583. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6584. }
  6585. }
  6586. public function _fc()
  6587. {
  6588. $vip = 0;
  6589. if (isset($_SESSION['api'])) {
  6590. $user = $this->user->get_api($_SESSION['api']);
  6591. if ($user['vip'] == 1) {
  6592. $vip = 1;
  6593. }
  6594. } else {
  6595. header('Location: /');
  6596. exit;
  6597. }
  6598. $post = $this->input->post(NULL, TRUE);
  6599. if (isset($post['page'])) {
  6600. $page = $this->input->post('page', true);
  6601. $perpage = $this->input->post('perpage', true);
  6602. $category = $this->input->post('category', true);
  6603. $size = $this->input->post('size', true);
  6604. $grade = $this->input->post('grade', true);
  6605. $color = $this->input->post('color', true);
  6606. $lowe = $this->input->post('lowe', true);
  6607. $sku = $this->input->post('sku');
  6608. $title = $this->input->post('title');
  6609. $warehouse = $this->input->post('warehouse', true);
  6610. $usa = $this->input->post('usa', true);
  6611. $purchase = $this->input->post('purchase', true);
  6612. $lacetype = $this->input->post('lacetype', true);
  6613. $haircap = $this->input->post('haircap', true);
  6614. $density = $this->input->post('density', true);
  6615. $details = $this->input->post('details', true);
  6616. $state = $this->input->post('state', true);
  6617. $ktime = $this->input->post('ktime', true);
  6618. $jtime = $this->input->post('jtime', true);
  6619. $ktime = strtotime($ktime);
  6620. $jtime = strtotime($jtime);
  6621. $where = "state = '11'";
  6622. $gj = "";
  6623. $ck = "";
  6624. if ($lacetype) {
  6625. $where .= " and features like '%-$lacetype-%'";
  6626. }
  6627. if ($category) {
  6628. $where .= " and features like '%-$category-%'";
  6629. }
  6630. if ($size) {
  6631. $where .= " and features like '%-$size-%'";
  6632. }
  6633. if ($grade) {
  6634. $where .= " and features like '%-$grade-%'";
  6635. }
  6636. if ($color) {
  6637. $where .= " and features like '%-$color-%'";
  6638. }
  6639. if ($lowe) {
  6640. $where .= " and features like '%-$lowe-%'";
  6641. }
  6642. if ($haircap) {
  6643. $where .= " and features like '%-$haircap-%'";
  6644. }
  6645. if ($density) {
  6646. $where .= " and features like '%-$density-%'";
  6647. }
  6648. if ($usa) {
  6649. if (!$warehouse) {
  6650. $where .= " and (warehouse = '5' or warehouse = '8')";
  6651. }
  6652. }
  6653. if ($warehouse) {
  6654. $where .= " and warehouse = '$warehouse'";
  6655. }
  6656. if ($details) {
  6657. $where .= " and details = '$details'";
  6658. }
  6659. if ($purchase) {
  6660. $where .= " and purchase = '$purchase'";
  6661. }
  6662. if ($state) {
  6663. $where .= " and state = '$state'";
  6664. }
  6665. if ($ktime && $jtime) {
  6666. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6667. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6668. }
  6669. //数据排序
  6670. $order_str = "id desc";
  6671. if (empty($page)) {
  6672. $start = 0;
  6673. $perpage = 1;
  6674. } else {
  6675. $start = ($page - 1) * $perpage;
  6676. }
  6677. if ($sku) {
  6678. $sku = trim($sku, ' ');
  6679. $sku = trim($sku, ' ');
  6680. $where .= " and sku like '%$sku%'";
  6681. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6682. } else if ($title) {
  6683. $title = trim($title, ' ');
  6684. $title = trim($title, ' ');
  6685. $where .= " and title like '%$title%'";
  6686. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6687. } else {
  6688. //$where .= " and time > '$ktime' and time < '$jtime'";
  6689. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6690. }
  6691. //取得信息列表
  6692. $rows = array();
  6693. $list = array();
  6694. foreach ($info_list as $key => $value) {
  6695. $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'] . '"');
  6696. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6697. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6698. $warehouse = $this->warehouse->read($value['warehouse']);
  6699. $info_list[$key]['warehouse'] = $warehouse['title'];
  6700. $info_list[$key]['number'] = $g;
  6701. $info_list[$key]['features'] = $x;
  6702. $info_list[$key]['x'] = $s;
  6703. }
  6704. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6705. $pagenum = ceil($total / $perpage);
  6706. $over = $total - ($start + $perpage);
  6707. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6708. echo json_encode($rows);
  6709. exit;
  6710. }
  6711. $this->data['vip'] = $vip;
  6712. $this->_Template('whlabel_fc', $this->data);
  6713. }
  6714. public function _fcmb()
  6715. {
  6716. $where = "sku != 'Preset'";
  6717. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6718. foreach ($rows as $k => $v) {
  6719. $warehouse = $this->warehouse->read($v['warehouse']);
  6720. $rows[$k]['warehouse'] = $warehouse['title'];
  6721. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6722. $rows[$k]['t'] = '';
  6723. $rows[$k]['n'] = '';
  6724. }
  6725. $title = "封货产品数据导入模板";
  6726. $titlename = "<table border=1>
  6727. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6728. <tr align='center'>
  6729. <td>仓库</td>
  6730. <td>SKU</td>
  6731. <td>产品</td>
  6732. <td>封存产品总数量</td>
  6733. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6734. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6735. </tr>
  6736. </table>";
  6737. $filename = $title . ".xls";
  6738. $tail = "";
  6739. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6740. }
  6741. public function _fcexcel()
  6742. {
  6743. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6744. $config['upload_path'] = '.' . $dir;
  6745. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6746. $config['allowed_types'] = 'xls|xlsx|csv';
  6747. $config['max_size'] = 10240;
  6748. $this->load->library('upload', $config);
  6749. $this->upload->initialize($config);
  6750. if ($this->upload->do_upload('userfile')) {
  6751. $full_path = $dir . $this->upload->data('file_name');
  6752. $fileName = '.' . $full_path;
  6753. if (!file_exists($fileName)) {
  6754. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6755. exit;
  6756. } else {
  6757. libxml_use_internal_errors(true);
  6758. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6759. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6760. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6761. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6762. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6763. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6764. ++$column; //如果列数大于26行
  6765. $list = array();
  6766. for ($i = 2; $i <= $row; $i++) // 行数循环
  6767. {
  6768. $data = array();
  6769. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6770. {
  6771. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6772. }
  6773. $list[] = $data;
  6774. }
  6775. }
  6776. $i = 0;
  6777. $j = 0;
  6778. $ed = array();
  6779. foreach ($list as $key => $value) {
  6780. $time = time();
  6781. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6782. continue;
  6783. }
  6784. $warehouse = $this->warehouse->get_title($value['0']);
  6785. $sku = $value['1'];
  6786. $type = $value['4']; //调整方式0扣减1删除
  6787. $num = $value['5']; //调整数量
  6788. //$text = $value['4'];//扣减说明
  6789. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6790. if (!$d) //如果没有这个SKU
  6791. {
  6792. $ed[] = array($sku . '-库存中不存在此SKU');
  6793. $j++;
  6794. continue;
  6795. }
  6796. if (!isset($warehouse['id'])) {
  6797. $ed[] = array($sku . '-仓库名错误!');
  6798. $j++;
  6799. continue;
  6800. }
  6801. if ($type == 1 || $type == 2) //扣减库存
  6802. {
  6803. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6804. if (count($data) < abs($num)) {
  6805. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6806. $j++;
  6807. continue;
  6808. }
  6809. if ($type == 1) //转入库存
  6810. {
  6811. for ($i = 0; $i < abs($num); $i++) {
  6812. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6813. }
  6814. } else if ($type == 2) //删除
  6815. {
  6816. for ($i = 0; $i < abs($num); $i++) {
  6817. $this->whlabel->remove($data[$i]['id']);
  6818. }
  6819. }
  6820. } else if ($type == 0) //增加库存
  6821. {
  6822. $post['sku'] = $d['sku'];
  6823. $post['shop'] = '';
  6824. $post['warehouse'] = $warehouse['id'];
  6825. $post['purchase'] = $d['purchase'];
  6826. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6827. $post['state'] = 11;
  6828. $post['title'] = $d['title'];
  6829. $post['number'] = $d['number'];
  6830. $post['features'] = $d['features'];
  6831. $post['enter'] = $time;
  6832. $post['time'] = $time; //操作时间
  6833. for ($i = 0; $i < $num; $i++) {
  6834. $post['label'] = time() . rand(100, 999) . $i;
  6835. $this->whlabel->insert($post);
  6836. }
  6837. }
  6838. sleep(1); //防止入库时间一样,需要延迟1秒
  6839. }
  6840. if ($j > 0) {
  6841. $tt = date('Ymd', time());
  6842. $title = '库存导入错误信息-' . $tt;
  6843. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6844. $tail = "\n";
  6845. $filename = $title . ".xls";
  6846. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6847. $dir = '/data/excel/' . $time . '/';
  6848. $file_name = 'error_' . $time . rand(1000, 9999);
  6849. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6850. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6851. fwrite($myfile, $ecl);
  6852. fclose($myfile);
  6853. $error = $dir . $file_name . '.xls';
  6854. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6855. exit;
  6856. } else {
  6857. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6858. exit;
  6859. }
  6860. }
  6861. }
  6862. public function _fcjxc($arg_array)
  6863. {
  6864. if (isset($_GET['excel'])) {
  6865. $category = $this->input->get('category', true);
  6866. $size = $this->input->get('size', true);
  6867. $grade = $this->input->get('grade', true);
  6868. $color = $this->input->get('color', true);
  6869. $lowe = $this->input->get('lowe', true);
  6870. $sku = $this->input->get('sku');
  6871. $title = $this->input->get('title');
  6872. $warehouse = $arg_array[0];
  6873. $usa = $this->input->get('usa', true);
  6874. $purchase = $this->input->get('purchase', true);
  6875. $lacetype = $this->input->get('lacetype', true);
  6876. $haircap = $this->input->get('haircap', true);
  6877. $density = $this->input->get('density', true);
  6878. $title = $this->input->get('title', true);
  6879. $state = $this->input->get('state', true);
  6880. $ktime = $this->input->get('ktime', true);
  6881. $jtime = $this->input->get('jtime', true);
  6882. $where = "state=11";
  6883. $gj = "";
  6884. $ck = "";
  6885. if ($lacetype) {
  6886. $where .= " and features like '%-$lacetype-%'";
  6887. }
  6888. if ($category) {
  6889. $where .= " and features like '%-$category-%'";
  6890. }
  6891. if ($size) {
  6892. $where .= " and features like '%-$size-%'";
  6893. }
  6894. if ($grade) {
  6895. $where .= " and features like '%-$grade-%'";
  6896. }
  6897. if ($color) {
  6898. $where .= " and features like '%-$color-%'";
  6899. }
  6900. if ($lowe) {
  6901. $where .= " and features like '%-$lowe-%'";
  6902. }
  6903. if ($haircap) {
  6904. $where .= " and features like '%-$haircap-%'";
  6905. }
  6906. if ($density) {
  6907. $where .= " and features like '%-$density-%'";
  6908. }
  6909. if ($usa) {
  6910. if (!$warehouse) {
  6911. $where .= " and (warehouse = '5' or warehouse = '8')";
  6912. }
  6913. }
  6914. if ($warehouse) {
  6915. $where .= " and warehouse = '$warehouse'";
  6916. }
  6917. if ($purchase) {
  6918. $where .= " and purchase = '$purchase'";
  6919. }
  6920. if ($state) {
  6921. $where .= " and state = '$state'";
  6922. }
  6923. $order_str = "id desc";
  6924. if ($sku) {
  6925. $sku = trim($sku, ' ');
  6926. $sku = trim($sku, ' ');
  6927. $where .= " and sku like '%$sku%'";
  6928. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6929. } else if ($title) {
  6930. $title = trim($title, ' ');
  6931. $title = trim($title, ' ');
  6932. $where .= " and title like '%$title%'";
  6933. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6934. } else {
  6935. //$where .= " and time > '$ktime' and time < '$jtime'";
  6936. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6937. }
  6938. //取得信息列表
  6939. $rows = array();
  6940. $list = array();
  6941. foreach ($info_list as $key => $value) {
  6942. $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'] . '"');
  6943. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6944. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6945. $rows[$key] = $value;
  6946. $warehouse = $this->warehouse->read($value['warehouse']);
  6947. $rows[$key]['warehouse'] = $warehouse['title'];
  6948. $rows[$key]['features'] = $g;
  6949. $rows[$key]['a'] = $x;
  6950. $rows[$key]['b'] = $s;
  6951. }
  6952. $title = "总统计表";
  6953. $titlename = "<table border=1>
  6954. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6955. <tr align='center'>
  6956. <td>仓库</td>
  6957. <td>SKU</td>
  6958. <td>产品名称</td>
  6959. <td>录入总量</td>
  6960. <td>取出总量</td>
  6961. <td>剩余总量</td>
  6962. </tr>
  6963. </table>";
  6964. $filename = $title . ".xls";
  6965. $tail = "";
  6966. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6967. }
  6968. $vip = 0;
  6969. if (isset($_SESSION['api'])) {
  6970. $user = $this->user->get_api($_SESSION['api']);
  6971. if ($user['vip'] == 1) {
  6972. $vip = 1;
  6973. }
  6974. } else {
  6975. header('Location: /');
  6976. exit;
  6977. }
  6978. $post = $this->input->post(NULL, TRUE);
  6979. if (isset($post['page'])) {
  6980. $page = $this->input->post('page', true);
  6981. $perpage = $this->input->post('perpage', true);
  6982. $category = $this->input->post('category', true);
  6983. $size = $this->input->post('size', true);
  6984. $grade = $this->input->post('grade', true);
  6985. $color = $this->input->post('color', true);
  6986. $lowe = $this->input->post('lowe', true);
  6987. $sku = $this->input->post('sku');
  6988. $title = $this->input->post('title');
  6989. $warehouse = $arg_array[0];
  6990. $usa = $this->input->post('usa', true);
  6991. $purchase = $this->input->post('purchase', true);
  6992. $lacetype = $this->input->post('lacetype', true);
  6993. $haircap = $this->input->post('haircap', true);
  6994. $density = $this->input->post('density', true);
  6995. $title = $this->input->post('title', true);
  6996. $state = $this->input->post('state', true);
  6997. $ktime = $this->input->post('ktime', true);
  6998. $jtime = $this->input->post('jtime', true);
  6999. $ktime = strtotime($ktime);
  7000. $jtime = strtotime($jtime);
  7001. $where = "state=11";
  7002. $gj = "";
  7003. $ck = "";
  7004. if ($lacetype) {
  7005. $where .= " and features like '%-$lacetype-%'";
  7006. }
  7007. if ($category) {
  7008. $where .= " and features like '%-$category-%'";
  7009. }
  7010. if ($size) {
  7011. $where .= " and features like '%-$size-%'";
  7012. }
  7013. if ($grade) {
  7014. $where .= " and features like '%-$grade-%'";
  7015. }
  7016. if ($color) {
  7017. $where .= " and features like '%-$color-%'";
  7018. }
  7019. if ($lowe) {
  7020. $where .= " and features like '%-$lowe-%'";
  7021. }
  7022. if ($haircap) {
  7023. $where .= " and features like '%-$haircap-%'";
  7024. }
  7025. if ($density) {
  7026. $where .= " and features like '%-$density-%'";
  7027. }
  7028. if ($usa) {
  7029. if (!$warehouse) {
  7030. $where .= " and (warehouse = '5' or warehouse = '8')";
  7031. }
  7032. }
  7033. if ($warehouse) {
  7034. $where .= " and warehouse = '$warehouse'";
  7035. }
  7036. if ($purchase) {
  7037. $where .= " and purchase = '$purchase'";
  7038. }
  7039. if ($state) {
  7040. $where .= " and state = '$state'";
  7041. }
  7042. if ($ktime && $jtime) {
  7043. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7044. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7045. }
  7046. //数据排序
  7047. $order_str = "id desc";
  7048. $xs = 0;
  7049. $rows = array();
  7050. $list = array();
  7051. if (empty($page)) {
  7052. $start = 0;
  7053. $perpage = 1;
  7054. } else {
  7055. $start = ($page - 1) * $perpage;
  7056. }
  7057. if ($sku || $title) {
  7058. if ($title) {
  7059. $title = trim($title, ' ');
  7060. $title = trim($title, ' ');
  7061. $where .= " and title like '%$title%'";
  7062. } else {
  7063. $sku = trim($sku, ' ');
  7064. $sku = trim($sku, ' ');
  7065. $where .= " and sku like '%$sku%'";
  7066. }
  7067. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7068. foreach ($info_list as $key => $value) {
  7069. $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'] . '"');
  7070. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7071. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7072. $rows[$key] = $value;
  7073. $warehouse = $this->warehouse->read($value['warehouse']);
  7074. $rows[$key]['warehouse'] = $warehouse['title'];
  7075. $rows[$key]['features'] = $g;
  7076. $rows[$key]['a'] = $x;
  7077. $rows[$key]['b'] = $s;
  7078. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7079. $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天销量
  7080. $yj = $c / ($xl / 30);
  7081. if ($yj < 7) {
  7082. $rows[$key]['y'] = round($yj) . '天销量';
  7083. } else {
  7084. $rows[$key]['y'] = '正常';
  7085. }
  7086. }
  7087. } else {
  7088. //$where .= " and time > '$ktime' and time < '$jtime'";
  7089. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7090. foreach ($info_list as $key => $value) {
  7091. $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'] . '"');
  7092. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7093. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7094. $zs[$key] = $value;
  7095. $warehouse = $this->warehouse->read($value['warehouse']);
  7096. $zs[$key]['warehouse'] = $warehouse['title'];
  7097. $zs[$key]['features'] = $g;
  7098. $zs[$key]['a'] = $x;
  7099. $zs[$key]['b'] = $s;
  7100. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7101. $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天销量
  7102. $yj = $c / ($xl / 30);
  7103. if ($yj < 7) {
  7104. $zs[$key]['y'] = round($yj) . '天销量';
  7105. $rows[$key] = $zs[$key];
  7106. }
  7107. }
  7108. }
  7109. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7110. $pagenum = ceil($total / $perpage);
  7111. $over = $total - ($start + $perpage);
  7112. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7113. echo json_encode($rows);
  7114. exit;
  7115. }
  7116. $this->data['arg_array'] = $arg_array[0];
  7117. $this->_Template('whlabel_fcjxc', $this->data);
  7118. }
  7119. public function _0kcdel()
  7120. {
  7121. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7122. $config['upload_path'] = '.' . $dir;
  7123. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7124. $config['allowed_types'] = 'xls|xlsx|csv';
  7125. $config['max_size'] = 10240;
  7126. $this->load->library('upload', $config);
  7127. $this->upload->initialize($config);
  7128. if ($this->upload->do_upload('userfile')) {
  7129. $full_path = $dir . $this->upload->data('file_name');
  7130. $fileName = '.' . $full_path;
  7131. if (!file_exists($fileName)) {
  7132. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7133. exit;
  7134. } else {
  7135. require_once "./data/excel/PHPExcel/IOFactory.php";
  7136. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7137. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7138. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7139. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7140. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7141. ++$column; //如果列数大于26行
  7142. $list = array();
  7143. for ($i = 2; $i <= $row; $i++) // 行数循环
  7144. {
  7145. $data = array();
  7146. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7147. {
  7148. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7149. }
  7150. $list[] = $data;
  7151. }
  7152. }
  7153. $i = 0;
  7154. $j = 0;
  7155. $ed = array();
  7156. foreach ($list as $key => $value) {
  7157. $time = time();
  7158. if ($value['0'] == "" || $value['1'] == "") {
  7159. continue;
  7160. }
  7161. $warehouse = $this->warehouse->get_title($value['0']);
  7162. $sku = $value['1'];
  7163. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7164. if (!$d) //如果没有这个SKU
  7165. {
  7166. $ed[] = array($sku . '-库存中不存在此SKU');
  7167. $j++;
  7168. continue;
  7169. }
  7170. if (!isset($warehouse['id'])) {
  7171. $ed[] = array($sku . '-仓库名错误!');
  7172. $j++;
  7173. continue;
  7174. }
  7175. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7176. if ($z < 1) {
  7177. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7178. foreach ($z as $v) {
  7179. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7180. if (count($zt) > 0) {
  7181. $ed[] = array($sku . '-有在途库存无法删除!');
  7182. $j++;
  7183. continue;
  7184. }
  7185. $this->whlabel->remove($v['id']);
  7186. }
  7187. } else {
  7188. $ed[] = array($sku . '-非0库存!');
  7189. $j++;
  7190. continue;
  7191. }
  7192. }
  7193. if ($j > 0) {
  7194. $tt = date('Ymd', time());
  7195. $title = '删除0库存错误信息-' . $tt;
  7196. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7197. $tail = "\n";
  7198. $filename = $title . ".xls";
  7199. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7200. $dir = '/data/excel/' . $time . '/';
  7201. $file_name = 'error_' . $time . rand(1000, 9999);
  7202. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7203. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7204. fwrite($myfile, $ecl);
  7205. fclose($myfile);
  7206. $error = $dir . $file_name . '.xls';
  7207. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7208. exit;
  7209. } else {
  7210. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7211. exit;
  7212. }
  7213. }
  7214. }
  7215. public function _gbhtype()
  7216. {
  7217. $post = $this->input->post(NULL, TRUE);
  7218. if (isset($post['s'])) {
  7219. $n = $this->input->post('n');
  7220. $d = $this->input->post('s');
  7221. if (!$d) {
  7222. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7223. exit;
  7224. }
  7225. $d = explode(',', trim($d, ','));
  7226. $t = $this->whlabel_type->read($n);
  7227. //循环删除记录
  7228. foreach ($d as $v) {
  7229. $u = $this->whlabel->read($v);
  7230. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7231. foreach ($data as $val) {
  7232. $this->whlabel->save(array('type' => $n), $val['id']);
  7233. }
  7234. }
  7235. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7236. }
  7237. }
  7238. //出库、退库导出
  7239. public function _dccrtype()
  7240. {
  7241. $classid = $this->classid->sku();
  7242. $pm = $classid;
  7243. $typeclass = array();
  7244. $tc = $this->typeclass->find_all();
  7245. foreach ($tc as $v) {
  7246. $typeclass[$v['id']] = $v;
  7247. }
  7248. $prc = array();
  7249. $purchase = $this->purchase->find_all();
  7250. foreach ($purchase as $k => $v) {
  7251. $prc[$v['id']] = $v['title'];
  7252. }
  7253. if (isset($_GET['sid'])) {
  7254. $wh = array();
  7255. $w = $this->warehouse->find_all('1=1', 'id,title');
  7256. foreach ($w as $v) {
  7257. $wh[$v['id']] = $v['title'];
  7258. }
  7259. $type = $this->input->get('excel', true);
  7260. $category = $this->input->get('category', true);
  7261. $size = $this->input->get('size', true);
  7262. $grade = $this->input->get('grade', true);
  7263. $color = $this->input->get('color', true);
  7264. $lowe = $this->input->get('lowe', true);
  7265. $sku = $this->input->get('sku', true);
  7266. $warehouse = $this->input->get('warehouse', true);
  7267. $lacetype = $this->input->get('lacetype', true);
  7268. $lacecolor = $this->input->get('lacecolor', true);
  7269. $density = $this->input->get('density', true);
  7270. $haircap = $this->input->get('haircap', true);
  7271. $purchase = $this->input->get('purchase', true);
  7272. $title = $this->input->get('title', true);
  7273. $state = $this->input->get('state', true);
  7274. $sid = $this->input->get('sid', true);
  7275. $ktime = $this->input->get('ktime', true);
  7276. $jtime = $this->input->get('jtime', true);
  7277. $ktime = strtotime($ktime);
  7278. $jtime = strtotime($jtime);
  7279. $where = "1=1";
  7280. $gj = "";
  7281. $ck = "";
  7282. if ($category) {
  7283. $where .= " and features like '%-$category-%'";
  7284. }
  7285. if ($size) {
  7286. $where .= " and features like '%-$size-%'";
  7287. }
  7288. if ($grade) {
  7289. $where .= " and features like '%-$grade-%'";
  7290. }
  7291. if ($color) {
  7292. $where .= " and features like '%-$color-%'";
  7293. }
  7294. if ($lowe) {
  7295. $where .= " and features like '%-$lowe-%'";
  7296. }
  7297. if ($warehouse) {
  7298. $where .= " and warehouse = '$warehouse'";
  7299. }
  7300. if ($purchase) {
  7301. $where .= " and purchase = '$purchase'";
  7302. }
  7303. if ($state) {
  7304. $where .= " and state = '$state'";
  7305. }
  7306. if ($lacetype) {
  7307. $where .= " and features like '%-$lacetype-%'";
  7308. }
  7309. if ($lacecolor) {
  7310. $where .= " and features like '%-$lacecolor-%'";
  7311. }
  7312. if ($density) {
  7313. $where .= " and features like '%-$density-%'";
  7314. }
  7315. if ($haircap) {
  7316. $where .= " and features like '%-$haircap-%'";
  7317. }
  7318. if ($title) {
  7319. $title = trim($title, ' ');
  7320. $title = trim($title, ' ');
  7321. $where .= " and title like '%$title%'";
  7322. }
  7323. if ($sku) {
  7324. $sku = trim($sku, ' ');
  7325. $sku = trim($sku, ' ');
  7326. $where .= " and sku like '%$sku%'";
  7327. }
  7328. if ($ktime && $jtime) {
  7329. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7330. }
  7331. $sidwhere = '';
  7332. if ($sid) {
  7333. $sd = "";
  7334. $s = explode(',', trim($sid, ','));
  7335. foreach ($s as $value) {
  7336. $sd .= " id = " . $value . " or";
  7337. }
  7338. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7339. }
  7340. //数据排序
  7341. $order_str = "time desc";
  7342. if (empty($page)) {
  7343. $start = 0;
  7344. $perpage = 1;
  7345. } else {
  7346. $start = ($page - 1) * $perpage;
  7347. }
  7348. $wh = array();
  7349. $w = $this->warehouse->find_all('1=1', 'id,title');
  7350. foreach ($w as $v) {
  7351. $wh[$v['id']] = $v['title'];
  7352. }
  7353. $wt = array();
  7354. $whlabel_type = $this->whlabel_type->find_all();
  7355. foreach ($whlabel_type as $v) {
  7356. $wt[$v['id']] = $v['title'];
  7357. }
  7358. $classid = $this->classid->sku();
  7359. $list = array();
  7360. $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');
  7361. foreach ($rows_r as $key => $value) {
  7362. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7363. $pm = $classid;
  7364. $jm = $classid;
  7365. $rows_r[$key]['enter'] = '入库';
  7366. $rows_r[$key]['time'] = $value['enter'];
  7367. if ($value['rktype'] == 1) {
  7368. $rows_r[$key]['rktype'] = '采购入库';
  7369. } else if ($value['rktype'] == 2) {
  7370. $rows_r[$key]['rktype'] = '盘盈调整';
  7371. } else if ($value['rktype'] == 3) {
  7372. $rows_r[$key]['rktype'] = '其他调整入库';
  7373. } else if ($value['rktype'] == 4) {
  7374. $rows_r[$key]['rktype'] = '其他调整入库';
  7375. } else if ($value['rktype'] == 5) {
  7376. $rows_r[$key]['rktype'] = '退库入库';
  7377. } else if ($value['rktype'] == 6) {
  7378. $rows_r[$key]['rktype'] = '退货可用入库';
  7379. } else if ($value['rktype'] == 7) {
  7380. $rows_r[$key]['rktype'] = '形态转换入库';
  7381. } else {
  7382. $rows_r[$key]['rktype'] = '';
  7383. }
  7384. $features = explode('-', trim($value['features'], '-'));
  7385. foreach ($features as $v) {
  7386. if (isset($typeclass[$v])) {
  7387. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7388. $pm[$typeclass[$v]['classid']] = $zh[0];
  7389. }
  7390. if (isset($typeclass[$v])) {
  7391. if (isset($jm[$typeclass[$v]['classid']])) {
  7392. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7393. }
  7394. }
  7395. }
  7396. $zh = implode(" ", $pm);
  7397. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7398. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7399. $rows_r[$key]['zh'] = $zh;
  7400. $jm = array_filter($jm);
  7401. $rows_r[$key]['features'] = implode("-", $jm);
  7402. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7403. }
  7404. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout,state');
  7405. foreach ($rows_c as $key => $value) {
  7406. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7407. $pm = $classid;
  7408. $jm = $classid;
  7409. $rows_c[$key]['time'] = $value['outk'];
  7410. $rows_c[$key]['outk'] = '出库';
  7411. if ($value['cktype'] == 1) {
  7412. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7413. } else if ($value['cktype'] == 2) {
  7414. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7415. } else if ($value['cktype'] == 3) {
  7416. $rows_c[$key]['cktype'] = '盘亏调整';
  7417. } else if ($value['cktype'] == 4) {
  7418. $rows_c[$key]['cktype'] = '其他调整出库';
  7419. } else if ($value['cktype'] == 5) {
  7420. $rows_c[$key]['cktype'] = '形态转换出库';
  7421. } else {
  7422. $rows_c[$key]['cktype'] = '';
  7423. }
  7424. unset($rows_c[$key]['state']);
  7425. $features = explode('-', trim($value['features'], '-'));
  7426. foreach ($features as $v) {
  7427. if (isset($typeclass[$v])) {
  7428. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7429. $pm[$typeclass[$v]['classid']] = $zh[0];
  7430. }
  7431. if (isset($typeclass[$v])) {
  7432. if (isset($jm[$typeclass[$v]['classid']])) {
  7433. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7434. }
  7435. }
  7436. }
  7437. $zh = implode(" ", $pm);
  7438. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7439. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7440. $rows_c[$key]['zh'] = $zh;
  7441. $jm = array_filter($jm);
  7442. $rows_c[$key]['features'] = implode("-", $jm);
  7443. $rows_c[$key]['number'] = 1;
  7444. }
  7445. $merged = $rows_r;
  7446. foreach ($rows_c as $key => $value) {
  7447. if (isset($merged[$key])) {
  7448. $merged[] = $value;
  7449. } else {
  7450. $merged[$key] = $value;
  7451. }
  7452. }
  7453. usort($merged, function ($a, $b) {
  7454. return $a['time'] - $b['time'];
  7455. });
  7456. foreach ($merged as $key => $value) {
  7457. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7458. }
  7459. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7460. $titlename = "<table border=1>
  7461. <tr align='center'>
  7462. <td>仓库</td>
  7463. <td>SKU</td>
  7464. <td>商品名称</td>
  7465. <td>仓库品名</td>
  7466. <td>料号</td>
  7467. <td>时间</td>
  7468. <td>操作</td>
  7469. <td>类型</td>
  7470. <td>数量</td>
  7471. <td>备注</td>
  7472. </tr>
  7473. </table>";
  7474. $filename = $title . ".xlsx";
  7475. $tail = "";
  7476. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7477. }
  7478. }
  7479. /*************************************处理exceljs导出****************************************************/
  7480. public function _excelrjs(){
  7481. if (isset($_GET['excel'])) {
  7482. $category = $this->input->get('category', true);
  7483. $size = $this->input->get('size', true);
  7484. $grade = $this->input->get('grade', true);
  7485. $color = $this->input->get('color', true);
  7486. $lowe = $this->input->get('lowe', true);
  7487. $sku = $this->input->get('sku', true);
  7488. $warehouse = $this->input->get('warehouse', true);
  7489. $purchase = $this->input->get('purchase', true);
  7490. $ktime = $this->input->get('ktime', true);
  7491. $jtime = $this->input->get('jtime', true);
  7492. $ktime = strtotime($ktime);
  7493. $jtime = strtotime($jtime);
  7494. $where = "1=1";
  7495. $gj = "";
  7496. $ck = "";
  7497. if ($category) {
  7498. $where .= " and features like '%-$category-%'";
  7499. }
  7500. if ($size) {
  7501. $where .= " and features like '%-$size-%'";
  7502. }
  7503. if ($grade) {
  7504. $where .= " and features like '%-$grade-%'";
  7505. }
  7506. if ($color) {
  7507. $where .= " and features like '%-$color-%'";
  7508. }
  7509. if ($lowe) {
  7510. $where .= " and features like '%-$lowe-%'";
  7511. }
  7512. if ($warehouse) {
  7513. $where .= " and warehouse = '$warehouse'";
  7514. }
  7515. if ($purchase) {
  7516. $where .= " and purchase = '$purchase'";
  7517. }
  7518. if ($sku) {
  7519. $where .= " and sku = '$sku'";
  7520. }
  7521. if ($ktime && $jtime) {
  7522. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7523. }
  7524. //数据排序
  7525. $order_str = "id desc";
  7526. if (empty($page)) {
  7527. $start = 0;
  7528. $perpage = 1;
  7529. } else {
  7530. $start = ($page - 1) * $perpage;
  7531. }
  7532. $list = array();
  7533. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7534. foreach ($rows as $value) {
  7535. $ck = $this->warehouse->read($value['warehouse']);
  7536. $warehouse = $ck['title'];
  7537. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7538. $retreatwarehouse = $tkck['title'];
  7539. $gy = $this->purchase->read($value['purchase']);
  7540. $purchase = $gy['title'];
  7541. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7542. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7543. }
  7544. if(empty($list)){
  7545. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7546. }else{
  7547. $final_list = [];
  7548. foreach($list as $v){
  7549. $final_list[] = array_values($v);
  7550. }
  7551. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7552. array_unshift($final_list,[
  7553. "仓库","SKU","商品名称","时间","数量"
  7554. ]);
  7555. array_unshift($final_list,[
  7556. $title,"","","",""
  7557. ]);
  7558. $merges = [
  7559. [
  7560. "s"=>["r"=>0,"c"=>0],
  7561. "e"=>["r"=>0,"c"=>4]
  7562. ]
  7563. ];
  7564. $cols = [
  7565. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7566. ];
  7567. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7568. }
  7569. }
  7570. }
  7571. //出库、退库导出
  7572. public function _excelctjs()
  7573. {
  7574. $classid = $this->classid->sku();
  7575. $pm = $classid;
  7576. $typeclass = array();
  7577. $tc = $this->typeclass->find_all();
  7578. foreach ($tc as $v) {
  7579. $typeclass[$v['id']] = $v;
  7580. }
  7581. $prc = array();
  7582. $purchase = $this->purchase->find_all();
  7583. foreach ($purchase as $k => $v) {
  7584. $prc[$v['id']] = $v['title'];
  7585. }
  7586. if (isset($_GET['excel'])) {
  7587. $wh = array();
  7588. $w = $this->warehouse->find_all('1=1', 'id,title');
  7589. foreach ($w as $v) {
  7590. $wh[$v['id']] = $v['title'];
  7591. }
  7592. $type = $this->input->get('excel', true);
  7593. $category = $this->input->get('category', true);
  7594. $size = $this->input->get('size', true);
  7595. $grade = $this->input->get('grade', true);
  7596. $color = $this->input->get('color', true);
  7597. $lowe = $this->input->get('lowe', true);
  7598. $sku = $this->input->get('sku', true);
  7599. $title = $this->input->get('title', true);
  7600. $warehouse = $this->input->get('warehouse', true);
  7601. $purchase = $this->input->get('purchase', true);
  7602. $lacetype = $this->input->get('lacetype', true);
  7603. $haircap = $this->input->get('haircap', true);
  7604. $lacecolor = $this->input->get('lacecolor', true);
  7605. $density = $this->input->get('density', true);
  7606. $details = $this->input->get('details', true);
  7607. $state = $this->input->get('state', true);
  7608. $shop = $this->input->get('shop', true);
  7609. $hairnumber = $this->input->get('hairnumber', true);
  7610. $type_leixi = $this->input->get('type', true);
  7611. $cpbz = $this->input->get('cpbz', true);
  7612. $sm = $this->input->get('sm', true);
  7613. $sid = $this->input->get('sid', true);
  7614. $ktime = $this->input->get('ktime', true);
  7615. $jtime = $this->input->get('jtime', true);
  7616. $ktime = strtotime($ktime);
  7617. $jtime = strtotime($jtime);
  7618. //$where = " 1=1 ";
  7619. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7620. $where = " sku != '' ";
  7621. $gj = "";
  7622. $ck = "";
  7623. if ($category) {
  7624. $where .= " and features like '%-$category-%'";
  7625. }
  7626. if ($size) {
  7627. $where .= " and features like '%-$size-%'";
  7628. }
  7629. if ($grade) {
  7630. $where .= " and features like '%-$grade-%'";
  7631. }
  7632. if ($color) {
  7633. $where .= " and features like '%-$color-%'";
  7634. }
  7635. if ($lowe) {
  7636. $where .= " and features like '%-$lowe-%'";
  7637. }
  7638. if ($warehouse) {
  7639. $where .= " and warehouse = '$warehouse'";
  7640. }
  7641. if ($purchase) {
  7642. $where .= " and purchase = '$purchase'";
  7643. }
  7644. if ($state) {
  7645. $where .= " and state = '$state'";
  7646. }
  7647. if ($lacetype) {
  7648. $where .= " and features like '%-$lacetype-%'";
  7649. }
  7650. if ($lacecolor) {
  7651. $where .= " and features like '%-$lacecolor-%'";
  7652. }
  7653. if ($density) {
  7654. $where .= " and features like '%-$density-%'";
  7655. }
  7656. if ($haircap) {
  7657. $where .= " and features like '%-$haircap-%'";
  7658. }
  7659. if ($details) {
  7660. $where .= " and details = '$details'";
  7661. }
  7662. if ($shop) {
  7663. $where .= " and shop like '%$shop%'";
  7664. }
  7665. if ($title) {
  7666. $title = trim($title, ' ');
  7667. $title = trim($title, ' ');
  7668. $where .= " and title like '%$title%'";
  7669. }
  7670. if (!empty($hairnumber)) {
  7671. $where .= " and features like '%-128-%' ";
  7672. if ($hairnumber < 0) {
  7673. $class_list = $this->typeclass->find_all('classid = 43');
  7674. foreach ($class_list as $v) {
  7675. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7676. }
  7677. } else {
  7678. $where .= " and features like '%-$hairnumber-%'";
  7679. }
  7680. }
  7681. if ($type_leixi) {
  7682. $where .= " and type = '$type_leixi'";
  7683. }
  7684. if ($cpbz) {
  7685. $where .= " and cpbz like '%$cpbz%' ";
  7686. }
  7687. if ($sm) {
  7688. $where .= " and sm like '%$sm%' ";
  7689. }
  7690. if ($sku) {
  7691. $sku = trim($sku, ' ');
  7692. $sku = trim($sku, ' ');
  7693. $where .= " and sku like '%$sku%'";
  7694. }
  7695. if ($ktime && $jtime) {
  7696. if ($type == 1) {
  7697. $tl = '出库';
  7698. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7699. } else if ($type == 2) {
  7700. $tl = '退库';
  7701. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7702. } else if ($type == 3) {
  7703. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7704. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7705. } else if ($type == 4) {
  7706. $tl = '出库+零售';
  7707. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7708. } else if ($type == 5) {
  7709. $tl = '零售';
  7710. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7711. }
  7712. }
  7713. $sidwhere = '';
  7714. if ($sid) {
  7715. $sd = "";
  7716. $s = explode(',', trim($sid, ','));
  7717. foreach ($s as $value) {
  7718. $sd .= " id = " . $value . " or";
  7719. }
  7720. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7721. }
  7722. //数据排序
  7723. $order_str = "time desc";
  7724. if (empty($page)) {
  7725. $start = 0;
  7726. $perpage = 1;
  7727. } else {
  7728. $start = ($page - 1) * $perpage;
  7729. }
  7730. //取得信息列表
  7731. if ($type != 3 && $type != 5) {
  7732. if ($type == 1 || $type == 4) {
  7733. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7734. foreach ($info_list as $key => $value) {
  7735. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7736. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7737. $warehouse = $this->warehouse->read($value['warehouse']);
  7738. $info_list[$key]['warehouse'] = $warehouse['title'];
  7739. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7740. $features = explode('-', trim($features, '-'));
  7741. $pm = $classid;
  7742. foreach ($features as $k => $v) {
  7743. if ($v != 0) {
  7744. if (!isset($typeclass[$v])) {
  7745. continue;
  7746. }
  7747. if (isset($pm[$typeclass[$v]['classid']])) {
  7748. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7749. $tz = explode('|', $typeclass[$v]['zh']);
  7750. $pm[$typeclass[$v]['classid']] = $tz[0];
  7751. } else {
  7752. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7753. }
  7754. }
  7755. }
  7756. }
  7757. $zh = implode(" ", $pm);
  7758. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7759. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7760. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7761. $info_list[$key]['features'] = $zh;
  7762. }
  7763. $final_list = [];
  7764. foreach($info_list as $k=>$v){
  7765. $number = "";
  7766. if(!empty($v['orderinfo'])){
  7767. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7768. if(!empty($tmp_info['number'])){
  7769. $number = $tmp_info['number'];
  7770. }
  7771. }
  7772. $final_list[] = [
  7773. 'warehouse'=>$v['warehouse'],
  7774. 'purchase'=>$v['purchase'],
  7775. 'sku'=>$v['sku'],
  7776. 'title'=>$v['title'],
  7777. 'features'=>$v['features'],
  7778. 'label'=>$v['label'],
  7779. 'orderinfo'=>$v['orderinfo'],
  7780. 'number'=>$number,
  7781. 'waybill'=>$v['waybill'],
  7782. 'outk'=>$v['outk'],
  7783. ];
  7784. }
  7785. } else {
  7786. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7787. foreach ($info_list as $key => $value) {
  7788. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7789. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7790. $warehouse = $this->warehouse->read($value['warehouse']);
  7791. $info_list[$key]['warehouse'] = $warehouse['title'];
  7792. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7793. $features = explode('-', trim($features, '-'));
  7794. $pm = $classid;
  7795. foreach ($features as $k => $v) {
  7796. if ($v != 0) {
  7797. if (!isset($typeclass[$v])) {
  7798. continue;
  7799. }
  7800. if (isset($pm[$typeclass[$v]['classid']])) {
  7801. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7802. $tz = explode('|', $typeclass[$v]['zh']);
  7803. $pm[$typeclass[$v]['classid']] = $tz[0];
  7804. } else {
  7805. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7806. }
  7807. }
  7808. }
  7809. }
  7810. $zh = implode(" ", $pm);
  7811. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7812. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7813. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7814. $info_list[$key]['features'] = $zh;
  7815. }
  7816. $final_list = [];
  7817. foreach($info_list as $k=>$v){
  7818. $number = "";
  7819. if(!empty($v['orderinfo'])){
  7820. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7821. if(!empty($tmp_info['number'])){
  7822. $number = $tmp_info['number'];
  7823. }
  7824. }
  7825. $final_list[] = [
  7826. 'warehouse'=>$v['warehouse'],
  7827. 'purchase'=>$v['purchase'],
  7828. 'sku'=>$v['sku'],
  7829. 'title'=>$v['title'],
  7830. 'features'=>$v['features'],
  7831. 'label'=>$v['label'],
  7832. 'orderinfo'=>$v['orderinfo'],
  7833. 'number'=>$number,
  7834. 'waybill'=>$v['waybill'],
  7835. 'retreat'=>$v['retreat'],
  7836. ];
  7837. }
  7838. }
  7839. if(empty($final_list)){
  7840. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7841. }else{
  7842. $end_list = [];
  7843. foreach($final_list as $v){
  7844. $end_list[] = array_values($v);
  7845. }
  7846. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  7847. array_unshift($end_list,[
  7848. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  7849. ]);
  7850. array_unshift($end_list,[
  7851. $title,"","","","","","","","",""
  7852. ]);
  7853. $merges = [
  7854. [
  7855. "s"=>["r"=>0,"c"=>0],
  7856. "e"=>["r"=>0,"c"=>9]
  7857. ]
  7858. ];
  7859. $cols = [
  7860. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  7861. ];
  7862. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  7863. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  7864. ] )));
  7865. }
  7866. } else if ($type == 5) {
  7867. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  7868. foreach ($info_list as $key => $value) {
  7869. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7870. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7871. $warehouse = $this->warehouse->read($value['warehouse']);
  7872. $info_list[$key]['warehouse'] = $warehouse['title'];
  7873. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7874. $features = explode('-', trim($features, '-'));
  7875. $pm = $classid;
  7876. foreach ($features as $k => $v) {
  7877. if ($v != 0) {
  7878. if (!isset($typeclass[$v])) {
  7879. continue;
  7880. }
  7881. if (isset($pm[$typeclass[$v]['classid']])) {
  7882. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7883. $tz = explode('|', $typeclass[$v]['zh']);
  7884. $pm[$typeclass[$v]['classid']] = $tz[0];
  7885. } else {
  7886. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7887. }
  7888. }
  7889. }
  7890. }
  7891. $zh = implode(" ", $pm);
  7892. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7893. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7894. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7895. $info_list[$key]['features'] = $zh;
  7896. }
  7897. if(empty($info_list)){
  7898. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7899. }else{
  7900. $final_list = [];
  7901. foreach($info_list as $v){
  7902. $final_list[] = array_values($v);
  7903. }
  7904. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  7905. array_unshift($final_list,[
  7906. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  7907. ]);
  7908. array_unshift($final_list,[
  7909. $title,"","","","","","",
  7910. ]);
  7911. $merges = [
  7912. [
  7913. "s"=>["r"=>0,"c"=>0],
  7914. "e"=>["r"=>0,"c"=>6]
  7915. ]
  7916. ];
  7917. $cols = [
  7918. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  7919. ];
  7920. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  7921. }
  7922. } else {
  7923. $wh = array();
  7924. $w = $this->warehouse->find_all('1=1', 'id,title');
  7925. foreach ($w as $v) {
  7926. $wh[$v['id']] = $v['title'];
  7927. }
  7928. $wt = array();
  7929. $whlabel_type = $this->whlabel_type->find_all();
  7930. foreach ($whlabel_type as $v) {
  7931. $wt[$v['id']] = $v['title'];
  7932. }
  7933. $classid = $this->classid->sku();
  7934. $list = array();
  7935. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  7936. foreach ($rows as $key => $value) {
  7937. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7938. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7939. $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');
  7940. $details = array();
  7941. $cpid = array();
  7942. $cpbz = array();
  7943. $c = 0;
  7944. $g = 0;
  7945. $x = 0;
  7946. $t = 0;
  7947. $s = 0;
  7948. $q = 0;
  7949. foreach ($sd as $k => $v) {
  7950. if ($v['state'] == 0) {
  7951. $c++;
  7952. }
  7953. if ($v['state'] != 9) {
  7954. $g++;
  7955. }
  7956. if ($v['outk'] > 1) {
  7957. $x++;
  7958. }
  7959. if ($v['retreat'] > 0) {
  7960. $t++;
  7961. }
  7962. if ($v['state'] == 8) {
  7963. $s++;
  7964. }
  7965. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  7966. $q++;
  7967. }
  7968. $details[$v['details']] = $v['details'];
  7969. if ($v['cpid'] != 0) {
  7970. $cpid[$v['cpid']] = $v['cpid'];
  7971. }
  7972. if ($v['cpbz'] != '') {
  7973. $cpbz[$v['cpbz']] = $v['cpbz'];
  7974. }
  7975. }
  7976. if (isset($wt[$value['type']])) {
  7977. $rows[$key]['type'] = $wt[$value['type']];
  7978. } else {
  7979. $rows[$key]['type'] = '未设置';
  7980. }
  7981. $rows[$key]['details'] = implode("、", $details);
  7982. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  7983. $ftime = time() - 15 * 24 * 3600;
  7984. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  7985. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  7986. $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);
  7987. $rows[$key]['c'] = $c;
  7988. $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);
  7989. $rows[$key]['t'] = $t;
  7990. $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'] . '"');
  7991. $rows[$key]['z'] = $z;
  7992. // $jm = $classid;
  7993. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7994. $features = explode('-', trim($features, '-'));
  7995. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  7996. }
  7997. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  7998. $final_list =[];
  7999. foreach($tmp_list as $k=>$v){
  8000. $final_list[] = [
  8001. "warehouse"=>$v['warehouse'],
  8002. "purchase"=>$v['purchase'],
  8003. "details"=>$v['details'],
  8004. "cpid"=>$v['cpid'],
  8005. "sku"=>$v['sku'],
  8006. "title"=>$v['title'],
  8007. "features"=>$v['pm'],
  8008. "cpbz"=>$v['cpbz'],
  8009. "sm"=>$v['sm'],
  8010. "type"=>$v['type'],
  8011. "g"=>$v["g"],
  8012. "c"=>$v["c"],
  8013. "x"=>$v["x"],
  8014. "t"=>$v["t"],
  8015. "z"=>$v["z"],
  8016. "jm"=>$v["jm"],
  8017. "weight"=>$v["weight"],
  8018. "asd"=>$v["asd"],
  8019. ];
  8020. }
  8021. if(empty($final_list)){
  8022. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8023. }else{
  8024. $end_list = [];
  8025. foreach($final_list as $v){
  8026. $end_list[] = array_values($v);
  8027. }
  8028. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8029. array_unshift($end_list,[
  8030. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8031. ]);
  8032. array_unshift($end_list,[
  8033. $title,"","","","","","","","","","","","","","","","","",""
  8034. ]);
  8035. $merges = [
  8036. [
  8037. "s"=>["r"=>0,"c"=>0],
  8038. "e"=>["r"=>0,"c"=>6]
  8039. ]
  8040. ];
  8041. $cols = [
  8042. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8043. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8044. ];
  8045. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8046. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8047. ])));
  8048. }
  8049. }
  8050. }
  8051. }
  8052. public function _exceljxcjs(){
  8053. $classid = $this->classid->sku();
  8054. $pm = $classid;
  8055. $typeclass = array();
  8056. $tc = $this->typeclass->find_all();
  8057. foreach ($tc as $v) {
  8058. $typeclass[$v['id']] = $v;
  8059. }
  8060. $prc = array();
  8061. $purchase = $this->purchase->find_all();
  8062. foreach ($purchase as $k => $v) {
  8063. $prc[$v['id']] = $v['title'];
  8064. }
  8065. if(!isset($_GET['excel'])){
  8066. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8067. }
  8068. $where = "sku != 'Preset'";
  8069. //数据排序
  8070. $order_str = "id desc";
  8071. if (empty($page)) {
  8072. $start = 0;
  8073. $perpage = 1;
  8074. } else {
  8075. $start = ($page - 1) * $perpage;
  8076. }
  8077. $category = $this->input->get('category', true);
  8078. $warehouse = $this->input->get('warehouse', true);
  8079. $excelid = $this->input->get('sid', true);
  8080. if ($category) {
  8081. $where .= " and features like '%-$category-%'";
  8082. }
  8083. if ($warehouse) {
  8084. $where .= " and warehouse = '$warehouse'";
  8085. }
  8086. $xzid = '';
  8087. if ($excelid) {
  8088. $excelid = explode(',', trim($excelid, ','));
  8089. foreach ($excelid as $key => $value) {
  8090. $xzid .= " id = " . $value . " or";
  8091. }
  8092. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8093. }
  8094. $wt = array();
  8095. $whlabel_type = $this->whlabel_type->find_all();
  8096. foreach ($whlabel_type as $v) {
  8097. $wt[$v['id']] = $v['title'];
  8098. }
  8099. $wh = array();
  8100. $w = $this->warehouse->find_all('1=1', 'id,title');
  8101. foreach ($w as $v) {
  8102. $wh[$v['id']] = $v['title'];
  8103. }
  8104. $list = array();
  8105. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8106. foreach ($rows as $key => $value) {
  8107. if (isset($wt[$value['type']])) {
  8108. $rows[$key]['type'] = $wt[$value['type']];
  8109. } else {
  8110. $rows[$key]['type'] = '未设置';
  8111. }
  8112. $bm = '03';
  8113. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8114. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8115. $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');
  8116. $details = array();
  8117. $cpid = array();
  8118. $cpbz = array();
  8119. $c = 0;
  8120. $g = 0;
  8121. $x = 0;
  8122. $t = 0;
  8123. $s = 0;
  8124. $q = 0;
  8125. foreach ($sd as $k => $v) {
  8126. if ($v['state'] == 0) {
  8127. $c++;
  8128. if ($v['cpid'] != 0) {
  8129. $cpid[$v['cpid']] = $v['cpid'];
  8130. }
  8131. if ($v['cpbz'] != '') {
  8132. $cpbz[$v['cpbz']] = $v['cpbz'];
  8133. }
  8134. }
  8135. if ($v['state'] != 9) {
  8136. $g++;
  8137. }
  8138. if ($v['state'] == 1) {
  8139. $x++;
  8140. }
  8141. if ($v['state'] == 2) {
  8142. $t++;
  8143. }
  8144. if ($v['state'] == 8) {
  8145. $s++;
  8146. }
  8147. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8148. $q++;
  8149. }
  8150. $details[$v['details']] = $v['details'];
  8151. }
  8152. $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'] . '"');
  8153. $rows[$key]['details'] = implode("、", $details);
  8154. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8155. $number = $value['number'];
  8156. $ftime = time() - 15 * 24 * 3600;
  8157. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8158. $rows[$key]['number'] = $g;
  8159. $rows[$key]['c'] = $c;
  8160. $rows[$key]['x'] = $x;
  8161. $rows[$key]['t'] = $t;
  8162. $rows[$key]['s'] = $s;
  8163. $rows[$key]['q'] = $q;
  8164. $rows[$key]['z'] = $z;
  8165. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8166. $features = explode('-', trim($features, '-'));
  8167. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8168. }
  8169. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8170. $final_list = [];
  8171. foreach ($list as $k => $v) {
  8172. if (empty($v['sku'])) {
  8173. continue;
  8174. }
  8175. $final_list[] = [
  8176. $v["warehouse"],
  8177. $v["purchase"],
  8178. $v["details"],
  8179. $v["cpid"],
  8180. $v["dbcontent"],
  8181. $v["sku"],
  8182. $v["bm"],
  8183. $v["jm"],
  8184. $v["title"],
  8185. $v["pm"],
  8186. $v["cpbz"],
  8187. $v["sm"],
  8188. $v["type"],
  8189. $v["number"],
  8190. $v["c"],
  8191. $v["x"],
  8192. $v["t"],
  8193. $v["s"],
  8194. $v["q"],
  8195. $v["z"],
  8196. $v['weight'],
  8197. ];
  8198. }
  8199. if(empty($final_list)){
  8200. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8201. }
  8202. $title = "总进销存统计表";
  8203. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8204. $merges = [
  8205. [
  8206. "s"=>["r"=>0,"c"=>0],
  8207. "e"=>["r"=>0,"c"=>21]
  8208. ]
  8209. ];
  8210. $cols = [
  8211. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8212. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8213. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8214. ];
  8215. array_unshift($final_list, $first_row);
  8216. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8217. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8218. }
  8219. public function _summaryjs($arg_array)
  8220. {
  8221. $prc = array();
  8222. $purchase = $this->purchase->find_all();
  8223. foreach ($purchase as $k => $v) {
  8224. $prc[$v['id']] = $v['title'];
  8225. }
  8226. if (isset($_GET['excel'])) {
  8227. $ktime = $this->input->get('ktime', true);
  8228. $jtime = $this->input->get('jtime', true);
  8229. $ktime = strtotime($ktime);
  8230. $jtime = strtotime($jtime);
  8231. $where = "1=1";
  8232. if ($ktime && $jtime) {
  8233. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8234. }
  8235. //数据排序
  8236. $order_str = "time desc";
  8237. if (empty($page)) {
  8238. $start = 0;
  8239. $perpage = 1;
  8240. } else {
  8241. $start = ($page - 1) * $perpage;
  8242. }
  8243. //取得信息列表
  8244. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8245. foreach ($info_list as $key => $value) {
  8246. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8247. $warehouse = $this->warehouse->read($value['warehouse']);
  8248. $info_list[$key]['warehouse'] = $warehouse['title'];
  8249. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8250. $details = array();
  8251. $cpid = array();
  8252. foreach ($x as $k => $v) {
  8253. if ($v['details'] != '') {
  8254. $details[$v['details']] = $v['details'];
  8255. }
  8256. if ($v['cpid'] != 0) {
  8257. $cpid[$v['cpid']] = $v['cpid'];
  8258. }
  8259. }
  8260. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8261. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8262. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8263. $info_list[$key]['s'] = $s;
  8264. $info_list[$key]['x'] = count($x);
  8265. }
  8266. if(empty($info_list)){
  8267. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8268. }
  8269. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8270. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8271. $merges = [
  8272. [
  8273. "s"=>["r"=>0,"c"=>0],
  8274. "e"=>["r"=>0,"c"=>7]
  8275. ]
  8276. ];
  8277. $cols = [
  8278. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8279. ];
  8280. $final_list = [];
  8281. foreach($info_list as $k => $v){
  8282. $final_list[] = array_values($v);
  8283. }
  8284. array_unshift($final_list, $first_row);
  8285. array_unshift($final_list,[
  8286. $title,"","","","","","","","",
  8287. ]);
  8288. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8289. $titlename = "<table border=1>
  8290. <tr align='center'>
  8291. <td>仓库</td>
  8292. <td>供应商</td>
  8293. <td>出库位置</td>
  8294. <td>出库编码</td>
  8295. <td>SKU</td>
  8296. <td>产品名</td>
  8297. <td>总剩余库存</td>
  8298. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8299. </tr>
  8300. </table>";
  8301. $filename = $title . ".xls";
  8302. $tail = "";
  8303. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8304. }
  8305. }
  8306. }