Whlabel.php 317 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350
  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. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  46. $this->load->_model("Model_whlabelscanlog","whlabelscanlog");
  47. }
  48. //定义方法的调用规则 获取URI第二段值
  49. public function _remap($arg, $arg_array)
  50. {
  51. if ($arg == 'existence') //在库标签
  52. {
  53. $this->_existence();
  54. } else if ($arg == 'cpbqdc') //在库标签
  55. {
  56. $this->_cpbqdc();
  57. } else if ($arg == 'type') //进销存浏览
  58. {
  59. $this->_type();
  60. } else if ($arg == 'typedy') //进销存浏览店员页面
  61. {
  62. $this->_typedy($arg_array);
  63. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  64. {
  65. $this->_typedy_ck($arg_array);
  66. } else if ($arg == 'typeck') {
  67. $this->_typeck($arg_array);
  68. } else if ($arg == 'whlabeckdc') {
  69. $this->_whlabeckdc($arg_array);
  70. } else if ($arg == 'usatype') //美仓进销存浏览
  71. {
  72. $this->_usatype();
  73. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  74. {
  75. $this->_usatypeapp();
  76. } else if ($arg == 'enteradd') //入库操作
  77. {
  78. $this->_enteradd();
  79. } else if ($arg == 'enteredit') //修改
  80. {
  81. $this->_enteredit($arg_array);
  82. } else if ($arg == 'enter') //入库浏览
  83. {
  84. $this->_enter();
  85. } else if ($arg == 'out') //出库浏览
  86. {
  87. $this->_out();
  88. } else if ($arg == 'label') //出库标签浏览
  89. {
  90. $this->_label();
  91. } else if ($arg == 'outorder') //独立站出库订单
  92. {
  93. $this->_outorder();
  94. } else if ($arg == 'soutorder') //速卖通出库订单
  95. {
  96. $this->_soutorder();
  97. } else if ($arg == 'toutorder') //TT出库订单
  98. {
  99. $this->_toutorder();
  100. }else if ($arg == 'aoutorder') //amz出库订单
  101. {
  102. $this->_aoutorder();
  103. } else if ($arg == 'retreat') //退库订单
  104. {
  105. $this->_retreat();
  106. } else if ($arg == 'retreatlk') //退库订单
  107. {
  108. $this->_retreatlk();
  109. } else if ($arg == 'change') //更换标签
  110. {
  111. $this->_change();
  112. } else if ($arg == 'del') //删除
  113. {
  114. $this->_del();
  115. } else if ($arg == 'exceljxc') //进销存信息导出
  116. {
  117. $this->_exceljxc();
  118. } else if ($arg == 'excelr') //入库信息导出
  119. {
  120. $this->_excelr();
  121. } else if ($arg == 'excelct') //出库、退库信息导出
  122. {
  123. $this->_excelct();
  124. } else if ($arg == 'dccrtype') //根据出入库类型导出
  125. {
  126. $this->_dccrtype();
  127. } else if ($arg == 'excelcr') //出库、退库信息导出
  128. {
  129. $this->_excelcr();
  130. } else if ($arg == 'kcyz') //库存验证
  131. {
  132. $this->_kcyz();
  133. } else if ($arg == 'kj') //库存扣减
  134. {
  135. $this->_kj($arg_array);
  136. } else if ($arg == 'presetout') //预设库存导入
  137. {
  138. $this->_presetout($arg_array);
  139. } else if ($arg == 'presetedit') //预设库存导入
  140. {
  141. $this->_presetedit($arg_array);
  142. }else if ($arg == 'presetedittwo') //预设库存导入
  143. {
  144. $this->_presetedittwo($arg_array);
  145. } else if ($arg == 'summary') //汇总导出
  146. {
  147. $this->_summary($arg_array);
  148. } else if ($arg == 'manifest') //usps发货清单
  149. {
  150. $this->_manifest();
  151. } else if ($arg == 'abnormal') //占单异常
  152. {
  153. $this->_abnormal();
  154. } else if ($arg == 'error') //0库存SKU
  155. {
  156. $this->_error();
  157. } else if ($arg == 'errorexcel') //0库存SKU导出
  158. {
  159. $this->_errorexcel();
  160. } else if ($arg == 'db') {
  161. $this->_db();
  162. } else if ($arg == 'dbrk') {
  163. $this->_dbrk();
  164. } else if ($arg == 'whlabelczdc') {
  165. $this->_whlabelczdc();
  166. } else if ($arg == 'print') {
  167. $this->_print($arg_array);
  168. } else if ($arg == 'usaprint') {
  169. $this->_usaprint($arg_array);
  170. } else if ($arg == 'printck') {
  171. $this->_printck($arg_array);
  172. } else if ($arg == 'printrk') {
  173. $this->_printrk($arg_array);
  174. } else if ($arg == 'printxzrk') {
  175. $this->_printxzrk($arg_array);
  176. } else if ($arg == 'printexcel') {
  177. $this->_printexcel($arg_array);
  178. } else if ($arg == 'uck') {
  179. $this->_uck();
  180. } else if ($arg == 'whlabelexcelzh') {
  181. $this->_whlabelexcelzh();
  182. } else if ($arg == 'fc') {
  183. $this->_fc();
  184. } else if ($arg == 'fcmb') {
  185. $this->_fcmb();
  186. } else if ($arg == 'fcexcel') {
  187. $this->_fcexcel();
  188. } else if ($arg == 'fcjxc') {
  189. $this->_fcjxc($arg_array);
  190. } else if ($arg == '0kcdel') {
  191. $this->_0kcdel(); //导表删除0库存
  192. } else if ($arg == 'gbhtype') {
  193. $this->_gbhtype(); //更改备货状态
  194. } else if($arg == 'excelrjs'){
  195. $this->_excelrjs();
  196. } else if($arg == 'excelctjs'){
  197. $this->_excelctjs();
  198. }else if ($arg == 'exceljxcjs') //进销存信息导出
  199. {
  200. $this->_exceljxcjs();
  201. } else if ($arg == 'summaryjs') //汇总导出
  202. {
  203. $this->_summaryjs($arg_array);
  204. }else if($arg == 'uckjs'){
  205. $this->_uckjs();
  206. }else if ($arg == 'whlabelexcelzhjs') {
  207. $this->_whlabelexcelzhjs();
  208. }else if($arg == 'dccrtypejs'){
  209. $this->_dccrtypejs();
  210. }else if($arg == 'errorexceljs'){
  211. $this->_errorexceljs();
  212. }else if($arg == "w_t_cs"){
  213. $this->_w_t_cs(); //首页
  214. }else {
  215. $this->_index();
  216. }
  217. }
  218. public function _w_t_cs(){
  219. $vip = 0;
  220. if (isset($_SESSION['api'])) {
  221. $user = $this->user->get_api($_SESSION['api']);
  222. $fgshop = "";
  223. $sid = "";
  224. $usersp = explode('|', trim($user['shop'], '|'));
  225. foreach ($usersp as $value) {
  226. $fgshop .= " shop = " . $value . " or";
  227. $sid .= " id = " . $value . " or";
  228. }
  229. if ($user['vip'] == 1) {
  230. $vip = 1;
  231. }
  232. } else {
  233. header('Location: /');
  234. exit;
  235. }
  236. $prc = array();
  237. $purchase = $this->purchase->find_all();
  238. foreach ($purchase as $k => $v) {
  239. $prc[$v['id']] = $v['title'];
  240. }
  241. $company = array();
  242. $ct = $this->company->find_all();
  243. foreach ($ct as $k => $v) {
  244. $company[$v['id']] = $v['title'];
  245. }
  246. $sp = array();
  247. $s = $this->shop->find_all('1=1', 'id,shopname');
  248. foreach ($s as $v) {
  249. $sp[$v['id']] = $v['shopname'];
  250. }
  251. $wh = array();
  252. $w = $this->warehouse->find_all('1=1', 'id,title');
  253. foreach ($w as $v) {
  254. $wh[$v['id']] = $v['title'];
  255. }
  256. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  257. $this->data['shop'] = $wlshop;
  258. $this->data['vip'] = $vip;
  259. $this->_Template('whlabel_typejs', $this->data);
  260. }
  261. //管理
  262. public function _index()
  263. {
  264. $post = $this->input->post(NULL, TRUE);
  265. if (isset($post['page'])) {
  266. $page = $this->input->post('page', true);
  267. $perpage = $this->input->post('perpage', true);
  268. $sku = $this->input->post('sku', true);
  269. $number = $this->input->post('number', true);
  270. $warehouse = $this->input->post('warehouse', true);
  271. $purchase = $this->input->post('purchase', true);
  272. $orderinfo = $this->input->post('orderinfo', true);
  273. $waybill = $this->input->post('waybill', true);
  274. $category = $this->input->post('category', true);
  275. $size = $this->input->post('size', true);
  276. $grade = $this->input->post('grade', true);
  277. $color = $this->input->post('color', true);
  278. $lowe = $this->input->post('lowe', true);
  279. $state = $this->input->post('state', true);
  280. $label = $this->input->post('label', true);
  281. $timetk = $this->input->post('timetkk', true);
  282. $timetj = $this->input->post('timetjj', true);
  283. $timetk = strtotime($timetk);
  284. $timetj = strtotime($timetj);
  285. $where = "1=1 ";
  286. if ($timetk && $timetj) {
  287. $where .= " and time > '$timetk' and time < '$timetj'";
  288. }
  289. if ($sku) {
  290. $where .= " and sku = '$sku'";
  291. }
  292. if ($number) {
  293. $where .= " and number = '$number'";
  294. }
  295. if ($warehouse) {
  296. $where .= " and warehouse = '$warehouse'";
  297. }
  298. if ($purchase) {
  299. $where .= " and purchase = '$purchase'";
  300. }
  301. if ($orderinfo) {
  302. $where .= " and orderinfo = '$orderinfo'";
  303. }
  304. if ($waybill) {
  305. $where .= " and waybill = '$waybill'";
  306. }
  307. if ($category) {
  308. $where .= " and features like '%-$category-%'";
  309. }
  310. if ($size) {
  311. $where .= " and features like '%-$size-%'";
  312. }
  313. if ($grade) {
  314. $where .= " and features like '%-$grade-%'";
  315. }
  316. if ($color) {
  317. $where .= " and features like '%-$color-%'";
  318. }
  319. if ($lowe) {
  320. $where .= " and features like '%-$lowe-%'";
  321. }
  322. if ($label) {
  323. $where .= " and label = '$label'";
  324. }
  325. if ($state != '') {
  326. $where .= " and state = '$state'";
  327. }
  328. //数据排序
  329. $order_str = "time desc";
  330. if (empty($page)) {
  331. $start = 0;
  332. $perpage = 1;
  333. } else {
  334. $start = ($page - 1) * $perpage;
  335. }
  336. //取得信息列表
  337. $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);
  338. foreach ($info_list as $key => $value) {
  339. $warehouse = $this->warehouse->read($value['warehouse']);
  340. $info_list[$key]['warehouse'] = $warehouse['title'];
  341. $purchase = $this->purchase->read($value['purchase']);
  342. $info_list[$key]['purchase'] = $purchase['title'];
  343. if ($value['enter'] != 0) {
  344. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  345. } else {
  346. $info_list[$key]['enter'] = "";
  347. }
  348. if ($value['outk'] != 0) {
  349. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  350. } else {
  351. $info_list[$key]['outk'] = "";
  352. }
  353. if ($value['printing'] != 0) {
  354. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  355. } else {
  356. $info_list[$key]['printing'] = "";
  357. }
  358. if ($value['orderinfo'] == 0) {
  359. $info_list[$key]['orderinfo'] = "";
  360. }
  361. if ($value['waybill'] == 0) {
  362. $info_list[$key]['waybill'] = "";
  363. }
  364. if ($value['state'] == 0) {
  365. $info_list[$key]['state'] = "在库";
  366. } else if ($value['state'] == 1) {
  367. $info_list[$key]['state'] = "出库";
  368. } else if ($value['state'] == 2) {
  369. $info_list[$key]['state'] = "退库";
  370. } else if ($value['state'] == 3) {
  371. $info_list[$key]['state'] = "调拨中";
  372. } else if ($value['state'] == 4) {
  373. $info_list[$key]['state'] = "再加工";
  374. } else if ($value['state'] == 5) {
  375. $info_list[$key]['state'] = "维修中";
  376. } else if ($value['state'] == 6) {
  377. $info_list[$key]['state'] = "盘亏";
  378. } else if ($value['state'] == 7) {
  379. $info_list[$key]['state'] = "更换标签";
  380. } else if ($value['state'] == 8) {
  381. $info_list[$key]['state'] = "其它";
  382. } else if ($value['state'] == 9) {
  383. $info_list[$key]['state'] = "预设";
  384. } else if ($value['state'] == 10) {
  385. $info_list[$key]['state'] = "美店零售";
  386. }
  387. if ($value['text'] == "") {
  388. $info_list[$key]['text'] = "";
  389. }
  390. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  391. }
  392. $total = $this->whlabel->find_count($where);
  393. $pagenum = ceil($total / $perpage);
  394. $over = $total - ($start + $perpage);
  395. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  396. echo json_encode($rows);
  397. exit;
  398. }
  399. if (isset($post['outsku'])) {
  400. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  401. $cz = $this->input->post('cz', true);
  402. if ($cz == '1') {
  403. $sku = $this->input->post('outsku', true);
  404. if ($sku) {
  405. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  406. if (count($data) < 1) {
  407. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  408. exit;
  409. }
  410. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  411. echo json_encode(array('success' => true));
  412. exit;
  413. }
  414. } else {
  415. $sku = $this->input->post('outsku', true);
  416. if ($sku) {
  417. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  418. if (count($data) < 1) {
  419. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  420. exit;
  421. }
  422. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  423. echo json_encode(array('success' => true));
  424. exit;
  425. }
  426. }
  427. }
  428. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  429. $this->_Template('whlabel', $this->data);
  430. }
  431. //在库标签
  432. public function _existence()
  433. {
  434. $post = $this->input->post(NULL, TRUE);
  435. if (isset($post['s'])) {
  436. $id_arr = $this->input->post('s');
  437. $id_arr = explode(',', $id_arr);
  438. if (!$id_arr) {
  439. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  440. exit;
  441. }
  442. //循环删除记录
  443. foreach ($id_arr as $v) {
  444. $sid = $this->whlabel->read($v);
  445. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  446. if ($count > 0) {
  447. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  448. exit;
  449. }
  450. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  451. if (count($zt) > 0) {
  452. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  453. exit;
  454. }
  455. $this->whlabel->remove($v);
  456. }
  457. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  458. exit;
  459. }
  460. if (isset($post['page'])) {
  461. $page = $this->input->post('page', true);
  462. $perpage = $this->input->post('perpage', true);
  463. $warehouse = $this->input->post('warehouse', true);
  464. $label = $this->input->post('label', true);
  465. $where = "1=1 and state = 0";
  466. if ($warehouse) {
  467. $where .= " and warehouse = '$warehouse'";
  468. }
  469. if ($label) {
  470. $where .= " and label = '$label'";
  471. }
  472. //数据排序
  473. $order_str = "time asc";
  474. if (empty($page)) {
  475. $start = 0;
  476. $perpage = 1;
  477. } else {
  478. $start = ($page - 1) * $perpage;
  479. }
  480. //取得信息列表
  481. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  482. foreach ($info_list as $key => $value) {
  483. if ($value['enter'] != 0) {
  484. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  485. } else {
  486. $info_list[$key]['enter'] = "";
  487. }
  488. if ($value['printing'] != 0) {
  489. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  490. } else {
  491. $info_list[$key]['printing'] = "";
  492. }
  493. }
  494. $total = $this->whlabel->find_count($where);
  495. $pagenum = ceil($total / $perpage);
  496. $over = $total - ($start + $perpage);
  497. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  498. echo json_encode($rows);
  499. exit;
  500. }
  501. $this->_Template('whlabel_existence', $this->data);
  502. }
  503. //进销存浏览
  504. public function _typedy($arg_array)
  505. {
  506. $prc = array();
  507. $purchase = $this->purchase->find_all();
  508. foreach ($purchase as $k => $v) {
  509. $prc[$v['id']] = $v['title'];
  510. }
  511. $post = $this->input->post(NULL, TRUE);
  512. if (isset($post['page'])) {
  513. $page = $this->input->post('page', true);
  514. $perpage = $this->input->post('perpage', true);
  515. $category = $this->input->post('category', true);
  516. $size = $this->input->post('size', true);
  517. $grade = $this->input->post('grade', true);
  518. $color = $this->input->post('color', true);
  519. $lowe = $this->input->post('lowe', true);
  520. $sku = $this->input->post('sku');
  521. $title = $this->input->post('title');
  522. $warehouse = $this->input->post('warehouse', true);
  523. $usa = $this->input->post('usa', true);
  524. $purchase = $this->input->post('purchase', true);
  525. $lacetype = $this->input->post('lacetype', true);
  526. $haircap = $this->input->post('haircap', true);
  527. $density = $this->input->post('density', true);
  528. $details = $this->input->post('details', true);
  529. $state = $this->input->post('state', true);
  530. $lacecolor = $this->input->post('lacecolor', true);
  531. $hairnumber = $this->input->post('hairnumber', true);
  532. $cklx = $this->input->post('cklx', true);
  533. $ktime = $this->input->post('ktime', true);
  534. $jtime = $this->input->post('jtime', true);
  535. $sm = $this->input->post('sm', true);
  536. $cpbz = $this->input->post('cpbz', true);
  537. $type = $this->input->post('type', true);
  538. $ktime = strtotime($ktime);
  539. $jtime = strtotime($jtime);
  540. $where = "1=1";
  541. $gj = "";
  542. $ck = "";
  543. if ($usa) {
  544. if (!$warehouse) {
  545. $where .= " and (warehouse = '5' or warehouse = '8')";
  546. }
  547. }
  548. if ($warehouse) {
  549. $where .= " and warehouse = '$warehouse'";
  550. }
  551. if ($details) {
  552. $where .= " and details = '$details'";
  553. }
  554. if ($purchase) {
  555. $where .= " and purchase = '$purchase'";
  556. }
  557. if (isset($state)) {
  558. if($state >-1){
  559. $where .= " and state = '$state'";
  560. }
  561. }
  562. if ($lacetype) {
  563. $where .= " and features like '%-$lacetype-%'";
  564. }
  565. if ($category) {
  566. $where .= " and features like '%-$category-%'";
  567. }
  568. if ($size) {
  569. $where .= " and features like '%-$size-%'";
  570. }
  571. if ($grade) {
  572. $where .= " and features like '%-$grade-%'";
  573. }
  574. if ($color) {
  575. $where .= " and features like '%-$color-%'";
  576. }
  577. if ($lowe) {
  578. $where .= " and features like '%-$lowe-%'";
  579. }
  580. if ($haircap) {
  581. $where .= " and features like '%-$haircap-%'";
  582. }
  583. if ($density) {
  584. $where .= " and features like '%-$density-%'";
  585. }
  586. if ($lacecolor) {
  587. $where .= " and features like '%-$lacecolor-%'";
  588. }
  589. if($sm){
  590. $where .= " and sm like '%".$sm."%'";
  591. }
  592. if($cpbz){
  593. $where .= " and cpbz like '%".$cpbz."%'";
  594. }
  595. if($type){
  596. $where .= " and type = ".$type."";
  597. }
  598. if (!empty($hairnumber)) {
  599. $where .= " and features like '%-128-%' ";
  600. if ($hairnumber < 0) {
  601. $class_list = $this->typeclass->find_all('classid = 43');
  602. foreach ($class_list as $v) {
  603. $where .= " and features not like '%-" . $v['id'] . "-%'";
  604. }
  605. } else {
  606. $where .= " and features like '%-$hairnumber-%'";
  607. }
  608. }
  609. $where_add = '';
  610. if ($cklx) {
  611. $shop = $this->shop->read($cklx);
  612. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  613. }
  614. if ($ktime && $jtime) {
  615. $gj = " and enter > '$ktime' and enter < '$jtime'";
  616. $ck = " and outk > '$ktime' and outk < '$jtime'";
  617. }
  618. //数据排序
  619. $order_str = "id desc";
  620. if (empty($page)) {
  621. $start = 0;
  622. $perpage = 1;
  623. } else {
  624. $start = ($page - 1) * $perpage;
  625. }
  626. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  627. if ($sku) {
  628. $sku = trim($sku, ' ');
  629. $sku = trim($sku, ' ');
  630. $where .= " and sku like '%$sku%'";
  631. $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);
  632. } else if ($title) {
  633. $title = trim($title, ' ');
  634. $title = trim($title, ' ');
  635. $where .= " and title like '%$title%'";
  636. $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);
  637. } else {
  638. //$where .= " and time > '$ktime' and time < '$jtime'";
  639. $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);
  640. }
  641. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  642. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  643. foreach ($info_list as $k => $v) {
  644. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  645. unset($info_list[$k]['pm']);
  646. unset($info_list[$k]['jm']);
  647. unset($info_list[$k]['bm']);
  648. }
  649. //取得信息列表
  650. $rows = array();
  651. $list = array();
  652. foreach ($info_list as $key => $value) {
  653. $warehouse = $this->warehouse->read($value['warehouse']);
  654. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  655. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  656. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  657. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  658. $info_list[$key]['label'] = $value['sm'];
  659. $number = $value['number'];
  660. $ftime = time() - 15 * 24 * 3600;
  661. $info_list[$key]['warehouse'] = $warehouse['title'];
  662. $info_list[$key]['features'] = count($c);
  663. $z = count($z); //查看订单号
  664. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  665. $ztdata = '';
  666. if (count($zt) > 0) {
  667. foreach ($zt as $vv) {
  668. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  669. }
  670. }
  671. $info_list[$key]['number'] = $ztdata;
  672. $info_list[$key]['sm'] = $z;
  673. $details = array();
  674. $cpid = array();
  675. foreach ($c as $k => $v) {
  676. $details[$v['details']] = $v['details'];
  677. if ($v['cpid'] != 0) {
  678. $cpid[$v['cpid']] = $v['cpid'];
  679. }
  680. }
  681. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  682. if ($value['shop'] != '') {
  683. $shop = explode(',', trim($value['shop'], ','));
  684. $shop = $this->shop->read($shop[0]);
  685. $info_list[$key]['shop'] = $shop['shopname'];
  686. }
  687. }
  688. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  689. $pagenum = ceil($total / $perpage);
  690. $over = $total - ($start + $perpage);
  691. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  692. echo json_encode($rows);
  693. exit;
  694. }
  695. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  696. $this->_Template('whlabel_typedy', $this->data);
  697. }
  698. //进销存浏览
  699. public function _typedy_ck($arg_array)
  700. {
  701. $prc = array();
  702. $purchase = $this->purchase->find_all();
  703. foreach ($purchase as $k => $v) {
  704. $prc[$v['id']] = $v['title'];
  705. }
  706. $post = $this->input->post(NULL, TRUE);
  707. if (isset($post['page'])) {
  708. $page = $this->input->post('page', true);
  709. $perpage = $this->input->post('perpage', true);
  710. $category = $this->input->post('category', true);
  711. $size = $this->input->post('size', true);
  712. $grade = $this->input->post('grade', true);
  713. $color = $this->input->post('color', true);
  714. $lowe = $this->input->post('lowe', true);
  715. $sku = $this->input->post('sku');
  716. $title = $this->input->post('title');
  717. $warehouse = $this->input->post('warehouse', true);
  718. $usa = $this->input->post('usa', true);
  719. $purchase = $this->input->post('purchase', true);
  720. $lacetype = $this->input->post('lacetype', true);
  721. $haircap = $this->input->post('haircap', true);
  722. $density = $this->input->post('density', true);
  723. $details = $this->input->post('details', true);
  724. $state = $this->input->post('state', true);
  725. $lacecolor = $this->input->post('lacecolor', true);
  726. $cklx = $this->input->post('cklx', true);
  727. $ktime = $this->input->post('ktime', true);
  728. $jtime = $this->input->post('jtime', true);
  729. $ktime = strtotime($ktime);
  730. $jtime = strtotime($jtime);
  731. $where = "1=1";
  732. $gj = "";
  733. $ck = "";
  734. if ($lacetype) {
  735. $where .= " and features like '%-$lacetype-%'";
  736. }
  737. if ($category) {
  738. $where .= " and features like '%-$category-%'";
  739. }
  740. if ($size) {
  741. $where .= " and features like '%-$size-%'";
  742. }
  743. if ($grade) {
  744. $where .= " and features like '%-$grade-%'";
  745. }
  746. if ($color) {
  747. $where .= " and features like '%-$color-%'";
  748. }
  749. if ($lowe) {
  750. $where .= " and features like '%-$lowe-%'";
  751. }
  752. if ($haircap) {
  753. $where .= " and features like '%-$haircap-%'";
  754. }
  755. if ($density) {
  756. $where .= " and features like '%-$density-%'";
  757. }
  758. if ($lacecolor) {
  759. $where .= " and features like '%-$lacecolor-%'";
  760. }
  761. if ($usa) {
  762. if (!$warehouse) {
  763. $where .= " and (warehouse = '5' or warehouse = '8')";
  764. }
  765. }
  766. if ($warehouse) {
  767. $where .= " and warehouse = '$warehouse'";
  768. }
  769. if ($details) {
  770. $where .= " and details = '$details'";
  771. }
  772. if ($purchase) {
  773. $where .= " and purchase = '$purchase'";
  774. }
  775. if ($state) {
  776. $where .= " and state = '$state'";
  777. }
  778. $where_add = '';
  779. if ($cklx) {
  780. $shop = $this->shop->read($cklx);
  781. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  782. }
  783. if ($ktime && $jtime) {
  784. $gj = " and enter > '$ktime' and enter < '$jtime'";
  785. $ck = " and outk > '$ktime' and outk < '$jtime'";
  786. }
  787. //数据排序
  788. $order_str = "id desc";
  789. if (empty($page)) {
  790. $start = 0;
  791. $perpage = 1;
  792. } else {
  793. $start = ($page - 1) * $perpage;
  794. }
  795. if ($sku) {
  796. $sku = trim($sku, ' ');
  797. $sku = trim($sku, ' ');
  798. $where .= " and sku like '%$sku%'";
  799. $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);
  800. } else if ($title) {
  801. $title = trim($title, ' ');
  802. $title = trim($title, ' ');
  803. $where .= " and title like '%$title%'";
  804. $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);
  805. } else {
  806. //$where .= " and time > '$ktime' and time < '$jtime'";
  807. $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);
  808. }
  809. //取得信息列表
  810. $rows = array();
  811. $list = array();
  812. foreach ($info_list as $key => $value) {
  813. $warehouse = $this->warehouse->read($value['warehouse']);
  814. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  815. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  816. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  817. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  818. $ftime = time() - 15 * 24 * 3600;
  819. $info_list[$key]['warehouse'] = $warehouse['title'];
  820. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  821. //$z = count($z);//查看订单号
  822. //$info_list[$key]['zd'] = $z;
  823. $details = array();
  824. $cpid = array();
  825. foreach ($c as $k => $v) {
  826. $details[$v['details']] = $v['details'];
  827. if ($v['cpid'] != 0) {
  828. $cpid[$v['cpid']] = $v['cpid'];
  829. }
  830. }
  831. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  832. if ($value['shop'] != '') {
  833. $shop = explode(',', trim($value['shop'], ','));
  834. $shop = $this->shop->read($shop[0]);
  835. $info_list[$key]['shop'] = $shop['shopname'];
  836. }
  837. }
  838. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  839. $pagenum = ceil($total / $perpage);
  840. $over = $total - ($start + $perpage);
  841. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  842. echo json_encode($rows);
  843. exit;
  844. }
  845. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  846. $this->_Template('whlabel_typedy_ck', $this->data);
  847. }
  848. public function _typeck($arg_array)
  849. {
  850. $prc = array();
  851. $purchase = $this->purchase->find_all();
  852. foreach ($purchase as $k => $v) {
  853. $prc[$v['id']] = $v['title'];
  854. }
  855. $post = $this->input->post(NULL, TRUE);
  856. if (isset($post['page'])) {
  857. $page = $this->input->post('page', true);
  858. $perpage = $this->input->post('perpage', true);
  859. $category = $this->input->post('category', true);
  860. $size = $this->input->post('size', true);
  861. $grade = $this->input->post('grade', true);
  862. $color = $this->input->post('color', true);
  863. $lacecolor = $this->input->post('lacecolor', true);
  864. $lowe = $this->input->post('lowe', true);
  865. $sku = $this->input->post('sku');
  866. $title = $this->input->post('title');
  867. $warehouse = 13;
  868. $usa = $this->input->post('usa', true);
  869. $purchase = $this->input->post('purchase', true);
  870. $lacetype = $this->input->post('lacetype', true);
  871. $haircap = $this->input->post('haircap', true);
  872. $density = $this->input->post('density', true);
  873. $details = $this->input->post('details', true);
  874. $state = $this->input->post('state', true);
  875. $ktime = $this->input->post('ktime', true);
  876. $jtime = $this->input->post('jtime', true);
  877. $ktime = strtotime($ktime);
  878. $jtime = strtotime($jtime);
  879. $where = "1=1";
  880. $gj = "";
  881. $ck = "";
  882. if ($lacetype) {
  883. $where .= " and features like '%-$lacetype-%'";
  884. }
  885. if ($category) {
  886. $where .= " and features like '%-$category-%'";
  887. }
  888. if ($size) {
  889. $where .= " and features like '%-$size-%'";
  890. }
  891. if ($grade) {
  892. $where .= " and features like '%-$grade-%'";
  893. }
  894. if ($color) {
  895. $where .= " and features like '%-$color-%'";
  896. }
  897. if ($lacecolor) {
  898. $where .= " and features like '%-$lacecolor-%'";
  899. }
  900. if ($lowe) {
  901. $where .= " and features like '%-$lowe-%'";
  902. }
  903. if ($haircap) {
  904. $where .= " and features like '%-$haircap-%'";
  905. }
  906. if ($density) {
  907. $where .= " and features like '%-$density-%'";
  908. }
  909. if ($warehouse) {
  910. $where .= " and warehouse = '$warehouse'";
  911. }
  912. if ($details) {
  913. $where .= " and details = '$details'";
  914. }
  915. if ($purchase) {
  916. $where .= " and purchase = '$purchase'";
  917. }
  918. if ($state) {
  919. $where .= " and state = '$state'";
  920. }
  921. if ($ktime && $jtime) {
  922. $gj = " and enter > '$ktime' and enter < '$jtime'";
  923. $ck = " and outk > '$ktime' and outk < '$jtime'";
  924. }
  925. //数据排序
  926. $order_str = "id desc";
  927. if (empty($page)) {
  928. $start = 0;
  929. $perpage = 1;
  930. } else {
  931. $start = ($page - 1) * $perpage;
  932. }
  933. if ($sku) {
  934. $sku = trim($sku, ' ');
  935. $sku = trim($sku, ' ');
  936. $where .= " and sku like '%$sku%'";
  937. } else if ($title) {
  938. $title = trim($title, ' ');
  939. $title = trim($title, ' ');
  940. $where .= " and title like '%$title%'";
  941. }
  942. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  943. //取得信息列表
  944. $t = array();
  945. $typeclass = $this->typeclass->find_all();
  946. foreach ($typeclass as $v) {
  947. $t[$v['id']] = $v;
  948. }
  949. $rows = array();
  950. $list = array();
  951. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  952. foreach ($info_list as $key => $value) {
  953. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  954. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  955. $warehouse = $this->warehouse->read($value['warehouse']);
  956. $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');
  957. $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'] . '"');
  958. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  959. $number = $value['number'];
  960. $ftime = time() - 15 * 24 * 3600;
  961. $z = count($z); //查看订单号
  962. $info_list[$key]['warehouse'] = $warehouse['title'];
  963. $info_list[$key]['features'] = count($c);
  964. $info_list[$key]['number'] = $z;
  965. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  966. $details = array();
  967. $cpid = array();
  968. foreach ($c as $k => $v) {
  969. $details[$v['details']] = $v['details'];
  970. if ($v['cpid'] != 0) {
  971. $cpid[$v['cpid']] = $v['cpid'];
  972. }
  973. }
  974. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  975. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  976. unset($info_list[$key]['pm']);
  977. unset($info_list[$key]['jm']);
  978. unset($info_list[$key]['bm']);
  979. }
  980. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  981. $pagenum = ceil($total / $perpage);
  982. $over = $total - ($start + $perpage);
  983. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  984. echo json_encode($rows);
  985. exit;
  986. }
  987. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  988. $this->_Template('whlabel_typeck', $this->data);
  989. }
  990. //进销存导出
  991. public function _whlabeckdc()
  992. {
  993. $prc = array();
  994. $purchase = $this->purchase->find_all();
  995. foreach ($purchase as $k => $v) {
  996. $prc[$v['id']] = $v['title'];
  997. }
  998. if (isset($_GET['excel'])) {
  999. $where = "sku != 'Preset'";
  1000. //数据排序
  1001. $order_str = "id desc";
  1002. if (empty($page)) {
  1003. $start = 0;
  1004. $perpage = 1;
  1005. } else {
  1006. $start = ($page - 1) * $perpage;
  1007. }
  1008. $category = $this->input->get('category', true);
  1009. $color = $this->input->get('color', true);
  1010. $lowe = $this->input->get('lowe', true);
  1011. $lacetype = $this->input->get('lacetype', true);
  1012. $size = $this->input->get('size', true);
  1013. $density = $this->input->get('density', true);
  1014. $haircap = $this->input->get('haircap', true);
  1015. $sku = $this->input->get('sku', true);
  1016. $details = $this->input->get('details', true);
  1017. $warehouse = 13;
  1018. $excelid = $this->input->get('sid', true);
  1019. if ($category) {
  1020. $where .= " and features like '%-$category-%'";
  1021. }
  1022. if ($color) {
  1023. $where .= " and features like '%-$color-%'";
  1024. }
  1025. if ($lowe) {
  1026. $where .= " and features like '%-$lowe-%'";
  1027. }
  1028. if ($lacetype) {
  1029. $where .= " and features like '%-$lacetype-%'";
  1030. }
  1031. if ($size) {
  1032. $where .= " and features like '%-$size-%'";
  1033. }
  1034. if ($density) {
  1035. $where .= " and features like '%-$density-%'";
  1036. }
  1037. if ($haircap) {
  1038. $where .= " and features like '%-$haircap-%'";
  1039. }
  1040. if ($warehouse) {
  1041. $where .= " and warehouse = '$warehouse'";
  1042. }
  1043. if ($sku) {
  1044. $where .= " and sku like '%$sku%'";
  1045. }
  1046. if ($details) {
  1047. $where .= " and details = '$details'";
  1048. }
  1049. $xzid = '';
  1050. if ($excelid) {
  1051. $excelid = explode(',', trim($excelid, ','));
  1052. foreach ($excelid as $key => $value) {
  1053. $xzid .= " id = " . $value . " or";
  1054. }
  1055. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1056. }
  1057. //取得信息列表
  1058. /**
  1059. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1060. $rows = array();$list = array();
  1061. foreach ($info_list as $key=>$value)
  1062. {
  1063. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1064. }
  1065. **/
  1066. $wh = array();
  1067. $w = $this->warehouse->find_all('1=1', 'id,title');
  1068. foreach ($w as $v) {
  1069. $wh[$v['id']] = $v['title'];
  1070. }
  1071. $tc = array();
  1072. $tcdata = array();
  1073. $list = array();
  1074. $classid = $this->classid->sku();
  1075. $tcall = $this->typeclass->find_all();
  1076. $typeclass = array();
  1077. foreach ($tcall as $v)
  1078. {
  1079. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1080. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1081. }
  1082. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1083. foreach ($rows as $key => $value) {
  1084. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1085. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1086. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1087. $rows[$key]['cpbz'] = $u9_info['bm'];
  1088. $rows[$key]['cs'] = $u9_info['jm'];
  1089. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1090. $details = array();
  1091. $cpid = array();
  1092. $cpbz = array();
  1093. $c = 0;
  1094. $g = 0;
  1095. $x = 0;
  1096. $t = 0;
  1097. $s = 0;
  1098. $q = 0;
  1099. foreach ($sd as $k => $v) {
  1100. if ($v['state'] == 0) {
  1101. $c++;
  1102. }
  1103. if ($v['state'] != 9) {
  1104. $g++;
  1105. }
  1106. if ($v['state'] == 1) {
  1107. $x++;
  1108. }
  1109. if ($v['state'] == 2) {
  1110. $t++;
  1111. }
  1112. if ($v['state'] == 8) {
  1113. $s++;
  1114. }
  1115. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1116. $q++;
  1117. }
  1118. $details[$v['details']] = $v['details'];
  1119. if ($v['cpid'] != 0) {
  1120. $cpid[$v['cpid']] = $v['cpid'];
  1121. }
  1122. if ($v['cpbz'] != '') {
  1123. $cpbz[$v['cpbz']] = $v['cpbz'];
  1124. }
  1125. }
  1126. $rows[$key]['details'] = implode("、", $details);
  1127. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1128. $number = $value['number'];
  1129. $ftime = time() - 15 * 24 * 3600;
  1130. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1131. $rows[$key]['number'] = $g;
  1132. $rows[$key]['features'] = $c;
  1133. $rows[$key]['x'] = $x;
  1134. $rows[$key]['t'] = $t;
  1135. $rows[$key]['s'] = $s;
  1136. $rows[$key]['q'] = $q;
  1137. $rows[$key]['wzsl'] = count($details);
  1138. }
  1139. $title = "进销存统计表" . date('Y-m-d', time());
  1140. $titlename = "<table border=1>
  1141. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1142. <tr align='center'>
  1143. <td>仓库</td>
  1144. <td>供应商</td>
  1145. <td>位置</td>
  1146. <td>库存编码</td>
  1147. <td>SKU</td>
  1148. <td>用友编码</td>
  1149. <td>用友料号</td>
  1150. <td>产品英文名</td>
  1151. <td>产品中文名</td>
  1152. <td>入库总量</td>
  1153. <td>库存数量</td>
  1154. <td>销售数量</td>
  1155. <td>退货数量</td>
  1156. <td>删除数量</td>
  1157. <td>其它操作</td>
  1158. <td>位置数量</td>
  1159. </tr>
  1160. </table>";
  1161. $filename = $title . ".xls";
  1162. $tail = "";
  1163. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1164. }
  1165. }
  1166. public function _type()
  1167. {
  1168. $vip = 0;
  1169. if (isset($_SESSION['api'])) {
  1170. $user = $this->user->get_api($_SESSION['api']);
  1171. $fgshop = "";
  1172. $sid = "";
  1173. $usersp = explode('|', trim($user['shop'], '|'));
  1174. foreach ($usersp as $value) {
  1175. $fgshop .= " shop = " . $value . " or";
  1176. $sid .= " id = " . $value . " or";
  1177. }
  1178. if ($user['vip'] == 1) {
  1179. $vip = 1;
  1180. }
  1181. } else {
  1182. header('Location: /');
  1183. exit;
  1184. }
  1185. $prc = array();
  1186. $purchase = $this->purchase->find_all();
  1187. foreach ($purchase as $k => $v) {
  1188. $prc[$v['id']] = $v['title'];
  1189. }
  1190. $company = array();
  1191. $ct = $this->company->find_all();
  1192. foreach ($ct as $k => $v) {
  1193. $company[$v['id']] = $v['title'];
  1194. }
  1195. $sp = array();
  1196. $s = $this->shop->find_all('1=1', 'id,shopname');
  1197. foreach ($s as $v) {
  1198. $sp[$v['id']] = $v['shopname'];
  1199. }
  1200. $wh = array();
  1201. $w = $this->warehouse->find_all('1=1', 'id,title');
  1202. foreach ($w as $v) {
  1203. $wh[$v['id']] = $v['title'];
  1204. }
  1205. $post = $this->input->post(NULL, TRUE);
  1206. if (isset($post['page'])) {
  1207. $page = $this->input->post('page', true);
  1208. $perpage = $this->input->post('perpage', true);
  1209. $category = $this->input->post('category', true);
  1210. $size = $this->input->post('size', true);
  1211. $grade = $this->input->post('grade', true);
  1212. $color = $this->input->post('color', true);
  1213. $lowe = $this->input->post('lowe', true);
  1214. $sku = $this->input->post('sku');
  1215. $title = $this->input->post('title');
  1216. $warehouse = $this->input->post('warehouse', true);
  1217. $usa = $this->input->post('usa', true);
  1218. $purchase = $this->input->post('purchase', true);
  1219. $lacetype = $this->input->post('lacetype', true);
  1220. $haircap = $this->input->post('haircap', true);
  1221. $density = $this->input->post('density', true);
  1222. $details = $this->input->post('details', true);
  1223. $state = $this->input->post('state', true);
  1224. $shop = $this->input->post('shop', true);
  1225. $lacecolor = $this->input->post('lacecolor', true);
  1226. $hairnumber = $this->input->post('hairnumber', true);
  1227. $type = $this->input->post('type', true);
  1228. $ktime = $this->input->post('ktime', true);
  1229. $jtime = $this->input->post('jtime', true);
  1230. $ktime = strtotime($ktime);
  1231. $jtime = strtotime($jtime);
  1232. $cpbz = $this->input->post('cpbz', true);
  1233. $sm = $this->input->post('sm', true);
  1234. $where = "1=1";
  1235. $gj = "";
  1236. $ck = "";
  1237. if ($usa) {
  1238. if (!$warehouse) {
  1239. $where .= " and (warehouse = '5' or warehouse = '8')";
  1240. }
  1241. }
  1242. if ($warehouse) {
  1243. $where .= " and warehouse = '$warehouse'";
  1244. }
  1245. if ($details) {
  1246. $where .= " and details = '$details'";
  1247. }
  1248. if ($purchase) {
  1249. $where .= " and purchase = '$purchase'";
  1250. }
  1251. if ($state) {
  1252. $where .= " and state = '$state'";
  1253. }
  1254. if ($shop) {
  1255. $where .= " and shop like '%$shop%'";
  1256. }
  1257. if ($type) {
  1258. $where .= " and type = '$type'";
  1259. }
  1260. if ($ktime && $jtime) {
  1261. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1262. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1263. }
  1264. if ($cpbz) {
  1265. $where .= " and cpbz like '%$cpbz%' ";
  1266. }
  1267. if ($sm) {
  1268. $where .= " and sm like '%$sm%' ";
  1269. }
  1270. if ($lacecolor) {
  1271. $where .= " and features like '%-$lacecolor-%'";
  1272. }
  1273. if ($lacetype) {
  1274. $where .= " and features like '%-$lacetype-%'";
  1275. }
  1276. if ($category) {
  1277. $where .= " and features like '%-$category-%'";
  1278. }
  1279. if ($size) {
  1280. $where .= " and features like '%-$size-%'";
  1281. }
  1282. if ($grade) {
  1283. $where .= " and features like '%-$grade-%'";
  1284. }
  1285. if ($color) {
  1286. $where .= " and features like '%-$color-%'";
  1287. }
  1288. if ($lowe) {
  1289. $where .= " and features like '%-$lowe-%'";
  1290. }
  1291. if ($haircap) {
  1292. $where .= " and features like '%-$haircap-%'";
  1293. }
  1294. if ($density) {
  1295. $where .= " and features like '%-$density-%'";
  1296. }
  1297. if (!empty($hairnumber)) {
  1298. $where .= " and features like '%-128-%' ";
  1299. if ($hairnumber < 0) {
  1300. $class_list = $this->typeclass->find_all('classid = 43');
  1301. foreach ($class_list as $v) {
  1302. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1303. }
  1304. } else {
  1305. $where .= " and features like '%-$hairnumber-%'";
  1306. }
  1307. }
  1308. //数据排序
  1309. $order_str = "id desc";
  1310. if (empty($page)) {
  1311. $start = 0;
  1312. $perpage = 1;
  1313. } else {
  1314. $start = ($page - 1) * $perpage;
  1315. }
  1316. $fjnr = '';
  1317. if ($sku) {
  1318. $sku = trim($sku, ' ');
  1319. $sku = trim($sku, ' ');
  1320. $fjnr .= " and sku like '%$sku%'";
  1321. }
  1322. if ($title) {
  1323. $title = trim($title, ' ');
  1324. $title = trim($title, ' ');
  1325. $fjnr .= " and title like '%$title%'";
  1326. }
  1327. $wt = array();
  1328. $whlabel_type = $this->whlabel_type->find_all();
  1329. foreach ($whlabel_type as $v) {
  1330. $wt[$v['id']] = $v['title'];
  1331. }
  1332. //$where .= " and time > '$ktime' and time < '$jtime'";
  1333. $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
  1334. //取得信息列表
  1335. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1336. $rows = array();
  1337. $list = array();
  1338. foreach ($info_list as $key => $value) {
  1339. if (isset($wt[$value['type']])) {
  1340. $info_list[$key]['type'] = $wt[$value['type']];
  1341. } else {
  1342. $info_list[$key]['type'] = '未设置';
  1343. }
  1344. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1345. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1346. $ztdata = '';
  1347. if (count($zt) > 0) {
  1348. foreach ($zt as $vv) {
  1349. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1350. }
  1351. }
  1352. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1353. $cdata = array_filter($qbdata, function ($item) {
  1354. return $item['state'] < 1;
  1355. });
  1356. $c = array_sum(array_column($cdata, 'jnum'));
  1357. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1358. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1359. });
  1360. $g = array_sum(array_column($gdata, 'jnum'));
  1361. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1362. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1363. });
  1364. $x = array_sum(array_column($xdata, 'jnum'));
  1365. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1366. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1367. });
  1368. $t = array_sum(array_column($tdata, 'jnum'));
  1369. // $zdata = array_filter($qbdata, function ($item) {
  1370. // return $item['zd'] != "" && $item['state'] < 1;
  1371. // });
  1372. // $z = array_sum(array_column($zdata, 'jnum'));
  1373. $zdata = array_filter($qbdata, function ($item) {
  1374. return $item['zd'] != "" && $item['state'] < 1;
  1375. });
  1376. $z = array_sum(array_column($zdata, 'jnum'));
  1377. //$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');
  1378. //$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'].'"');
  1379. //$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'].'"');
  1380. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1381. //$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'].'"');
  1382. $details = array();
  1383. $cpid = array();
  1384. $od = array();
  1385. $odid = '';
  1386. $companytitle = '';
  1387. $shop_list = [];
  1388. foreach ($qbdata as $v) {
  1389. if ($v['zd'] != "" && $v['state'] < 1) {
  1390. if (!isset($od[$v['zd']])) {
  1391. $od[$v['zd']] = 1; //所有数据sku
  1392. } else {
  1393. $od[$v['zd']] = $od[$v['zd']] + 1;
  1394. }
  1395. }
  1396. $details[$v['details']] = $v['details'];
  1397. if ($v['state'] < 1) {
  1398. //$details[$v['details']] = $v['details'];
  1399. if ($v['cpid'] != 0) {
  1400. $cpid[$v['cpid']] = $v['cpid'];
  1401. }
  1402. }
  1403. if($v['state'] == 0){
  1404. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1405. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1406. }
  1407. if ($v['shop'] != '') {
  1408. $shop = explode(',', trim($v['shop'], ','));
  1409. foreach ($shop as $vv) {
  1410. if (!in_array($vv, $shop_list)) {
  1411. $shop_list[] = $vv;
  1412. }
  1413. }
  1414. }
  1415. }
  1416. }
  1417. foreach ($od as $k => $vv) {
  1418. $odid .= $k . '数量' . $vv;
  1419. }
  1420. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1421. $info_list[$key]['label'] = $value['sm'];
  1422. $number = $value['number'];
  1423. $ftime = time() - 15 * 24 * 3600;
  1424. $z = $z . '(' . $odid . ')'; //查看订单号
  1425. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1426. $info_list[$key]['features'] = $c;
  1427. $info_list[$key]['number'] = $ztdata;
  1428. $info_list[$key]['sm'] = $g;
  1429. $info_list[$key]['x'] = $x;
  1430. $info_list[$key]['t'] = $t;
  1431. $info_list[$key]['z'] = $z;
  1432. /**
  1433. foreach ($cdata as $k=>$v)
  1434. {
  1435. $details[$v['details']] = $v['details'];
  1436. if($v['cpid'] != 0)
  1437. {
  1438. $cpid[$v['cpid']] = $v['cpid'];
  1439. }
  1440. }
  1441. **/
  1442. $info_list[$key]['shop'] = '';
  1443. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1444. // if ($value['shop'] != '') {
  1445. // $shop = explode(',', trim($value['shop'], ','));
  1446. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1447. // }
  1448. $shop_list = array_unique($shop_list);
  1449. $shop_str = '';
  1450. foreach ($shop_list as $v) {
  1451. if(isset($sp[$v])){
  1452. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1453. }
  1454. }
  1455. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1456. /**
  1457. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1458. if(isset($companytitle[0]))
  1459. {
  1460. foreach ($companytitle as $k=>$v)
  1461. {
  1462. if($v['companytitle'] != '')
  1463. {
  1464. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1465. }
  1466. }
  1467. }
  1468. **/
  1469. }
  1470. $final_all_list = [];
  1471. foreach ($info_list as $k => $v) {
  1472. $final_all_list[] = [
  1473. 'id' => $v['id'],
  1474. "warehouse" => $v["warehouse"],
  1475. "purchase" => $v["purchase"],
  1476. "sku" => $v["sku"],
  1477. "title" => $v["title"] . "<br/>" . $v["pm"],
  1478. "details" => $v["details"],
  1479. "shop" => $v["shop"],
  1480. "cpbz" => $v["cpbz"],
  1481. 'label' => $v['label'],
  1482. "type" => $v["type"],
  1483. "features" => $v["features"],
  1484. "number" => $v["number"],
  1485. "sm" => $v["sm"],
  1486. "x" => $v["x"],
  1487. "t" => $v["t"],
  1488. "z" => $v["z"]
  1489. ];
  1490. }
  1491. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1492. $pagenum = ceil($total / $perpage);
  1493. $over = $total - ($start + $perpage);
  1494. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1495. echo json_encode($rows);
  1496. exit;
  1497. }
  1498. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1499. $this->data['shop'] = $wlshop;
  1500. $this->data['vip'] = $vip;
  1501. $this->_Template('whlabel_type', $this->data);
  1502. }
  1503. //美仓进销存浏览
  1504. public function _usatype()
  1505. {
  1506. if (isset($_SESSION['api'])) {
  1507. $user = $this->user->get_api($_SESSION['api']);
  1508. $usp = $user;
  1509. $fgshop = "";
  1510. $sid = "";
  1511. $wid = "";
  1512. $wtype = "";
  1513. $userwh = explode('|', trim($user['warehouse'], '|'));
  1514. foreach ($userwh as $value) {
  1515. $wid .= " id = " . $value . " or";
  1516. $wtype .= " type = " . $value . " or";
  1517. }
  1518. }
  1519. $prc = array();
  1520. $purchase = $this->purchase->find_all();
  1521. foreach ($purchase as $k => $v) {
  1522. $prc[$v['id']] = $v['title'];
  1523. }
  1524. $post = $this->input->post(NULL, TRUE);
  1525. if (isset($post['page'])) {
  1526. $page = $this->input->post('page', true);
  1527. $perpage = $this->input->post('perpage', true);
  1528. $category = $this->input->post('category', true);
  1529. $size = $this->input->post('size', true);
  1530. $grade = $this->input->post('grade', true);
  1531. $color = $this->input->post('color', true);
  1532. $lowe = $this->input->post('lowe', true);
  1533. $sku = $this->input->post('sku');
  1534. $title = $this->input->post('title');
  1535. $warehouse = $this->input->post('warehouse', true);
  1536. $usa = $this->input->post('usa', true);
  1537. $purchase = $this->input->post('purchase', true);
  1538. $lacetype = $this->input->post('lacetype', true);
  1539. $haircap = $this->input->post('haircap', true);
  1540. $density = $this->input->post('density', true);
  1541. $details = $this->input->post('details', true);
  1542. $state = $this->input->post('state', true);
  1543. $lacecolor = $this->input->post('lacecolor', true);
  1544. $cklx = $this->input->post('cklx', true);
  1545. $ktime = $this->input->post('ktime', true);
  1546. $jtime = $this->input->post('jtime', true);
  1547. $ktime = strtotime($ktime);
  1548. $jtime = strtotime($jtime);
  1549. $where = "1=1";
  1550. $gj = "";
  1551. $ck = "";
  1552. if ($lacetype) {
  1553. $where .= " and features like '%-$lacetype-%'";
  1554. }
  1555. if ($category) {
  1556. $where .= " and features like '%-$category-%'";
  1557. }
  1558. if ($size) {
  1559. $where .= " and features like '%-$size-%'";
  1560. }
  1561. if ($grade) {
  1562. $where .= " and features like '%-$grade-%'";
  1563. }
  1564. if ($color) {
  1565. $where .= " and features like '%-$color-%'";
  1566. }
  1567. if ($lowe) {
  1568. $where .= " and features like '%-$lowe-%'";
  1569. }
  1570. if ($haircap) {
  1571. $where .= " and features like '%-$haircap-%'";
  1572. }
  1573. if ($density) {
  1574. $where .= " and features like '%-$density-%'";
  1575. }
  1576. if ($lacecolor) {
  1577. $where .= " and features like '%-$lacecolor-%'";
  1578. }
  1579. if ($usa) {
  1580. if (!$warehouse) {
  1581. $where .= " and (warehouse = '5' or warehouse = '8')";
  1582. }
  1583. }
  1584. if ($warehouse) {
  1585. $where .= " and warehouse = '$warehouse'";
  1586. }
  1587. if ($details) {
  1588. $where .= " and details = '$details'";
  1589. }
  1590. if ($purchase) {
  1591. $where .= " and purchase = '$purchase'";
  1592. }
  1593. if ($state) {
  1594. $where .= " and state = '$state'";
  1595. }
  1596. $where_add = '';
  1597. if ($cklx) {
  1598. $shop = $this->shop->read($cklx);
  1599. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1600. }
  1601. if ($ktime && $jtime) {
  1602. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1603. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1604. }
  1605. //数据排序
  1606. $order_str = "id desc";
  1607. if (empty($page)) {
  1608. $start = 0;
  1609. $perpage = 1;
  1610. } else {
  1611. $start = ($page - 1) * $perpage;
  1612. }
  1613. if ($sku) {
  1614. $sku = trim($sku, ' ');
  1615. $sku = trim($sku, ' ');
  1616. $where .= " and sku like '%$sku%'";
  1617. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1618. } else if ($title) {
  1619. $title = trim($title, ' ');
  1620. $title = trim($title, ' ');
  1621. $where .= " and title like '%$title%'";
  1622. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1623. } else {
  1624. //$where .= " and time > '$ktime' and time < '$jtime'";
  1625. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1626. }
  1627. //取得信息列表
  1628. $rows = array();
  1629. $list = array();
  1630. foreach ($info_list as $key => $value) {
  1631. $warehouse = $this->warehouse->read($value['warehouse']);
  1632. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1633. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1634. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1635. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1636. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1637. $od = array();
  1638. $odid = '';
  1639. foreach ($z as $v) {
  1640. if (!isset($od[$v['zd']])) {
  1641. $od[$v['zd']] = 1; //所有数据sku
  1642. } else {
  1643. $od[$v['zd']] = $od[$v['zd']] + 1;
  1644. }
  1645. }
  1646. foreach ($od as $k => $vv) {
  1647. $odid .= $k . '数量' . $vv . ' ';
  1648. }
  1649. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1650. $info_list[$key]['features'] = $c;
  1651. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1652. $ztdata = '';
  1653. if (count($zt) > 0) {
  1654. foreach ($zt as $vv) {
  1655. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1656. }
  1657. }
  1658. $info_list[$key]['warehouse'] = $ztdata;
  1659. $info_list[$key]['g'] = $g;
  1660. $info_list[$key]['x'] = $x;
  1661. $info_list[$key]['t'] = $t;
  1662. $info_list[$key]['z'] = $z;
  1663. }
  1664. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1665. $pagenum = ceil($total / $perpage);
  1666. $over = $total - ($start + $perpage);
  1667. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1668. echo json_encode($rows);
  1669. exit;
  1670. }
  1671. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1672. $this->data['warehouse'] = $warehouse;
  1673. $this->_Template('whlabel_typeusa', $this->data);
  1674. }
  1675. //美仓进销存浏览
  1676. public function _usatypeapp()
  1677. {
  1678. $post = $this->input->post(NULL, TRUE);
  1679. if (isset($post['page'])) {
  1680. $page = $this->input->post('page', true);
  1681. $perpage = $this->input->post('perpage', true);
  1682. $sku = $this->input->post('sku', true);
  1683. $warehouse = 5;
  1684. $title = $this->input->post('title', true);
  1685. $state = $this->input->post('state', true);
  1686. $ktime = $this->input->post('ktime', true);
  1687. $jtime = $this->input->post('jtime', true);
  1688. $ktime = strtotime($ktime);
  1689. $jtime = strtotime($jtime);
  1690. $where = "1=1";
  1691. $gj = "";
  1692. $ck = "";
  1693. if ($title) {
  1694. $st = explode(' ', trim($title, ' '));
  1695. foreach ($st as $v) {
  1696. $where .= " and title like '%$v%'";
  1697. }
  1698. }
  1699. if ($warehouse) {
  1700. $where .= " and warehouse = '$warehouse'";
  1701. }
  1702. if ($state) {
  1703. $where .= " and state = '$state'";
  1704. }
  1705. if ($sku) {
  1706. $where .= " and sku like '%$sku%'";
  1707. }
  1708. if ($ktime && $jtime) {
  1709. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1710. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1711. }
  1712. //数据排序
  1713. $order_str = "id desc";
  1714. if (empty($page)) {
  1715. $start = 0;
  1716. $perpage = 1;
  1717. } else {
  1718. $start = ($page - 1) * $perpage;
  1719. }
  1720. //取得信息列表
  1721. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1722. $rows = array();
  1723. $list = array();
  1724. foreach ($info_list as $key => $value) {
  1725. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1726. }
  1727. $rowsdq = array_slice($rows, $start, $perpage);
  1728. foreach ($rowsdq as $value) {
  1729. $warehouse = $this->warehouse->read($value['warehouse']);
  1730. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1731. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1732. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1733. $od = array();
  1734. $odid = '';
  1735. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1736. }
  1737. $total = count($rows);
  1738. $pagenum = ceil($total / $perpage);
  1739. $over = $total - ($start + $perpage);
  1740. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1741. echo json_encode($rows);
  1742. exit;
  1743. }
  1744. $this->_Template('phone/p_usatypeapp', $this->data);
  1745. }
  1746. //入库操作
  1747. public function _enteradd()
  1748. {
  1749. $dt = 0;
  1750. if (isset($_SESSION['api'])) {
  1751. $user = $this->user->get_api($_SESSION['api']);
  1752. $usp = $user;
  1753. $fgshop = "";
  1754. $sid = "";
  1755. $user = explode('|', trim($user['shop'], '|'));
  1756. foreach ($user as $value) {
  1757. $fgshop .= " shop = " . $value . " or";
  1758. $sid .= " id = " . $value . " or";
  1759. }
  1760. }
  1761. $tc = $this->typeclass->find_all();
  1762. $typeclass = array();
  1763. foreach ($tc as $v) {
  1764. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1765. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1766. }
  1767. $post = $this->input->post(NULL, TRUE);
  1768. if (isset($post['sku'])) {
  1769. $list = array();
  1770. $num = "";
  1771. $title = "";
  1772. $features = "";
  1773. $order = $this->input->post('order', true);
  1774. $shop = $this->input->post('shop', true);
  1775. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1776. $sku = $this->input->post('sku', true);
  1777. $post['sm'] = $this->input->post('sm', true);
  1778. $post['warehouse'] = $this->input->post('warehouse', true);
  1779. $post['purchase'] = $this->input->post('purchase', true);
  1780. $post['retreatwarehouse'] = $post['warehouse'];
  1781. $post['state'] = $this->input->post('state', true);
  1782. $post['rktype'] = $this->input->post('rktype', true);
  1783. $post['text'] = $this->input->post('text', true);
  1784. $category = $this->input->post('category', true);
  1785. $list['category'] = $category;
  1786. $list['hairtype'] = $this->input->post('hairtype', true);
  1787. $list['grade'] = $this->input->post('grade', true);
  1788. $size = $this->input->post('size', true);
  1789. $xzsku = $this->input->post('xzsku', true);
  1790. $list['size'] = rtrim($size, ',');
  1791. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1792. $list['extension'] = $this->input->post('extension', true);
  1793. if ($category == 1297) {
  1794. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1795. }
  1796. if ($category == 1702) {
  1797. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1798. $list['syother'] = $this->input->post('syother', true);
  1799. }
  1800. if ($category == 133) {
  1801. $list['fittype'] = $this->input->post('fittype', true);
  1802. $list['acother'] = $this->input->post('acother', true);
  1803. }
  1804. $list['color'] = $this->input->post('color', true);
  1805. $list['lowe'] = $this->input->post('lowe', true);
  1806. if (!$post['purchase']) {
  1807. $post['purchase'] = 1;
  1808. }
  1809. if ($category == 127) {
  1810. $list['type'] = $this->input->post('type', true);
  1811. $list['headroad'] = $this->input->post('headroad', true);
  1812. $list['density'] = $this->input->post('density', true);
  1813. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1814. $list['lacesize'] = $this->input->post('lacesize', true);
  1815. }
  1816. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1817. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1818. }
  1819. if ($category == 128) {
  1820. $list['lacetype'] = $this->input->post('lacetype', true);
  1821. $list['haircap'] = $this->input->post('haircap', true);
  1822. $list['density'] = $this->input->post('density', true);
  1823. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1824. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1825. $list['wigother'] = $this->input->post('wigother', true);
  1826. $list['wigother1'] = $this->input->post('wigother1', true);
  1827. $list['wigother2'] = $this->input->post('wigother2', true);
  1828. }
  1829. if ($category == 129) {
  1830. $list['wide'] = $this->input->post('wide', true);
  1831. }
  1832. if ($category == 131) {
  1833. $list['gifttype'] = $this->input->post('gifttype', true);
  1834. $list['giftother'] = $this->input->post('giftother', true);
  1835. }
  1836. if ($category == 134) {
  1837. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1838. }
  1839. if ($category == 1297) {
  1840. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1841. $list['sywigother'] = $this->input->post('sywigother', true);
  1842. }
  1843. if ($category == 130 || $category == 133 || $category == 1702) {
  1844. $list['items'] = $this->input->post('items', true);
  1845. $list['weight'] = $this->input->post('weight', true);
  1846. }
  1847. if($category == 130){
  1848. $list['jfother'] = $this->input->post('jfother', true);
  1849. }
  1850. if ($category == 1702) {
  1851. $list['syhairther'] = $this->input->post('syhairther', true);
  1852. }
  1853. $classid = $this->classid->sku();
  1854. $scsku = $classid;
  1855. $pm = $classid;
  1856. foreach ($list as $k => $v) {
  1857. if ($v != 0) {
  1858. $num .= $v;
  1859. $features .= $v . '-';
  1860. $post[$k] = $v;
  1861. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1862. if ($k != 'size') {
  1863. $title .= $typeclass[$v]['title'] . " ";
  1864. }
  1865. if (isset($pm[$typeclass[$v]['classid']])) {
  1866. if ($typeclass[$v]['title'] == '9A') {
  1867. $pm[$typeclass[$v]['classid']] = '9A';
  1868. } else if ($typeclass[$v]['title'] == '10A') {
  1869. $pm[$typeclass[$v]['classid']] = '10A';
  1870. } else {
  1871. $clzh = $typeclass[$v]['zh'];
  1872. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1873. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1874. $clzh = $clzh[0];
  1875. }
  1876. $pm[$typeclass[$v]['classid']] = $clzh;
  1877. }
  1878. }
  1879. }
  1880. }
  1881. $zh = implode(" ", $pm);
  1882. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1883. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1884. if ($list['size']) {
  1885. $typeclass = $this->typeclass->read($list['size']);
  1886. $title .= $typeclass['title'];
  1887. }
  1888. $time = time();
  1889. if ($xzsku) {
  1890. $scsku = implode("-", $scsku);
  1891. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1892. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1893. $post['sku'] = trim($scsku, ' ');
  1894. } else {
  1895. $post['sku'] = $sku;
  1896. }
  1897. //$post['sku'] = trim($sku,' ');
  1898. $post['title'] = rtrim($title, ' ');
  1899. $post['number'] = $num;
  1900. $post['features'] = '-' . $features;
  1901. $post['enter'] = $time;
  1902. $post['time'] = $time; //操作时间
  1903. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1904. if ($yza) {
  1905. if ($post['features'] != $yza[0]['features']) {
  1906. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1907. exit;
  1908. }
  1909. }
  1910. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1911. if ($yzb) {
  1912. if ($post['sku'] != $yzb[0]['sku']) {
  1913. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1914. exit;
  1915. }
  1916. }
  1917. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1918. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1919. exit;
  1920. }
  1921. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1922. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1923. exit;
  1924. }
  1925. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1926. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1927. exit;
  1928. }
  1929. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1930. if (isset($yz[0]['type'])) {
  1931. $post['type'] = $yz[0]['type'];
  1932. }
  1933. if ($post['state'] == 9) //如果选择预设库存
  1934. {
  1935. $this->whlabel->insert($post);
  1936. } else {
  1937. /**
  1938. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1939. if($ljg == 1)
  1940. {
  1941. for($i=0;$i<$order;$i++)
  1942. {
  1943. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1944. $this->whlabel->insert($post);
  1945. }
  1946. }
  1947. **/
  1948. //if($post['warehouse'] == '5')
  1949. //{
  1950. //}
  1951. $yydata = $post;
  1952. $yydata['zh'] = $zh;
  1953. /**
  1954. $wl = $this->apiyy->get_cjlp($yydata);
  1955. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1956. {
  1957. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1958. }
  1959. if($wl['Data'][0]['m_isSucess'] != 1)
  1960. {
  1961. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1962. }
  1963. **/
  1964. for ($i = 0; $i < $order; $i++) {
  1965. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1966. $this->whlabel->insert($post);
  1967. }
  1968. }
  1969. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1970. exit;
  1971. }
  1972. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1973. $this->data['wlshop'] = $wlshop;
  1974. $this->_Template('whlabel_enteradd', $this->data);
  1975. }
  1976. //修改产品
  1977. public function _enteredit($arg_array)
  1978. {
  1979. $dt = 0;
  1980. if (isset($_SESSION['api'])) {
  1981. $user = $this->user->get_api($_SESSION['api']);
  1982. $usp = $user;
  1983. $fgshop = "";
  1984. $sid = "";
  1985. $user = explode('|', trim($user['shop'], '|'));
  1986. foreach ($user as $value) {
  1987. $fgshop .= " shop = " . $value . " or";
  1988. $sid .= " id = " . $value . " or";
  1989. }
  1990. }
  1991. $post = $this->input->post(NULL, TRUE);
  1992. if (isset($post['sku'])) {
  1993. $list = array();
  1994. $num = "";
  1995. $title = "";
  1996. $features = "";
  1997. $id = $this->input->post('id', true);
  1998. $order = $this->input->post('order', true);
  1999. $shop = $this->input->post('shop', true);
  2000. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2001. $post['sku'] = $this->input->post('sku', true);
  2002. $post['sm'] = $this->input->post('sm', true);
  2003. $post['warehouse'] = $this->input->post('warehouse', true);
  2004. $post['purchase'] = $this->input->post('purchase', true);
  2005. $post['retreatwarehouse'] = $post['warehouse'];
  2006. $category = $this->input->post('category', true);
  2007. $list['category'] = $category;
  2008. $list['hairtype'] = $this->input->post('hairtype', true);
  2009. $list['grade'] = $this->input->post('grade', true);
  2010. $size = $this->input->post('size', true);
  2011. $list['size'] = rtrim($size, ',');
  2012. $post['rktype'] = $this->input->post('rktype', true);
  2013. $post['text'] = $this->input->post('text', true);
  2014. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2015. $list['extension'] = $this->input->post('extension', true);
  2016. if ($category == 1297) {
  2017. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2018. }
  2019. if ($category == 1702) {
  2020. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2021. $list['syother'] = $this->input->post('syother', true);
  2022. }
  2023. if ($category == 133) {
  2024. $list['fittype'] = $this->input->post('fittype', true);
  2025. $list['acother'] = $this->input->post('acother', true);
  2026. }
  2027. $list['color'] = $this->input->post('color', true);
  2028. $list['lowe'] = $this->input->post('lowe', true);
  2029. if (!$post['purchase']) {
  2030. $post['purchase'] = 1;
  2031. }
  2032. if ($category == 127) {
  2033. $list['type'] = $this->input->post('type', true);
  2034. $list['headroad'] = $this->input->post('headroad', true);
  2035. $list['density'] = $this->input->post('density', true);
  2036. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2037. $list['lacesize'] = $this->input->post('lacesize', true);
  2038. }
  2039. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2040. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2041. }
  2042. if ($category == 128) {
  2043. $list['lacetype'] = $this->input->post('lacetype', true);
  2044. $list['haircap'] = $this->input->post('haircap', true);
  2045. $list['density'] = $this->input->post('density', true);
  2046. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2047. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2048. $list['wigother'] = $this->input->post('wigother', true);
  2049. $list['wigother1'] = $this->input->post('wigother1', true);
  2050. $list['wigother2'] = $this->input->post('wigother2', true);
  2051. }
  2052. if ($category == 129) {
  2053. $list['wide'] = $this->input->post('wide', true);
  2054. }
  2055. if ($category == 131) {
  2056. $list['gifttype'] = $this->input->post('gifttype', true);
  2057. $list['giftother'] = $this->input->post('giftother', true);
  2058. }
  2059. if ($category == 134) {
  2060. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2061. }
  2062. if ($category == 1297) {
  2063. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2064. $list['sywigother'] = $this->input->post('sywigother', true);
  2065. }
  2066. if ($category == 130 || $category == 133 || $category == 1702) {
  2067. $list['items'] = $this->input->post('items', true);
  2068. $list['weight'] = $this->input->post('weight', true);
  2069. }
  2070. if($category == 130){
  2071. $list['jfother'] = $this->input->post('jfother', true);
  2072. }
  2073. if ($category == 1702) {
  2074. $list['syhairther'] = $this->input->post('syhairther', true);
  2075. }
  2076. foreach ($list as $k => $v) {
  2077. if ($v != 0) {
  2078. $num .= $v;
  2079. $features .= $v . '-';
  2080. $typeclass = $this->typeclass->read($v);
  2081. if ($k != 'size') {
  2082. $title .= $typeclass['title'] . " ";
  2083. }
  2084. }
  2085. }
  2086. $typeclass = $this->typeclass->read($list['size']);
  2087. $title .= $typeclass['title'];
  2088. $time = time();
  2089. $post['title'] = rtrim($title, ' ');
  2090. $post['number'] = $num;
  2091. $post['features'] = '-' . $features;
  2092. $post['time'] = $time; //操作时间
  2093. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2094. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2095. exit;
  2096. }
  2097. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2098. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2099. exit;
  2100. }
  2101. $uid = $this->whlabel->read($id);
  2102. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2103. if ($datanum > 0) {
  2104. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2105. exit;
  2106. }
  2107. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2108. {
  2109. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2110. if ($yza) {
  2111. if ($post['features'] != $yza[0]['features']) {
  2112. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2113. exit;
  2114. }
  2115. }
  2116. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2117. if ($yzb) {
  2118. if ($post['sku'] != $yzb[0]['sku']) {
  2119. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2120. exit;
  2121. }
  2122. }
  2123. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2124. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2125. exit;
  2126. }
  2127. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2128. foreach ($data as $v) {
  2129. $post['id'] = $v['id'];
  2130. $this->whlabel->save($post, $v['id']);
  2131. }
  2132. } else {
  2133. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2134. if ($data > 0) {
  2135. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2136. exit;
  2137. } else {
  2138. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2139. foreach ($data as $v) {
  2140. $post['id'] = $v['id'];
  2141. $this->whlabel->save($post, $v['id']);
  2142. }
  2143. }
  2144. }
  2145. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2146. exit;
  2147. }
  2148. $uid = $this->whlabel->read($arg_array[0]);
  2149. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2150. $this->data['enter'] = $uid;
  2151. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2152. $this->data['wlshop'] = $wlshop;
  2153. $this->_Template('whlabel_enteredit', $this->data);
  2154. }
  2155. //入库浏览
  2156. public function _enter()
  2157. {
  2158. $post = $this->input->post(NULL, TRUE);
  2159. if (isset($post['s'])) {
  2160. $id_arr = $this->input->post('s');
  2161. $id_arr = explode(',', $id_arr);
  2162. if (!$id_arr) {
  2163. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2164. exit;
  2165. }
  2166. //循环删除记录
  2167. foreach ($id_arr as $v) {
  2168. $sid = $this->whlabel->read($v);
  2169. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2170. if ($count > 0) {
  2171. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2172. exit;
  2173. }
  2174. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2175. foreach ($info_list as $va) {
  2176. $this->whlabel->remove($va['id']);
  2177. }
  2178. }
  2179. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2180. exit;
  2181. }
  2182. $sp = array();
  2183. $s = $this->shop->find_all('1=1', 'id,shopname');
  2184. foreach ($s as $v) {
  2185. $sp[$v['id']] = $v['shopname'];
  2186. }
  2187. $wh = array();
  2188. $w = $this->warehouse->find_all('1=1', 'id,title');
  2189. foreach ($w as $v) {
  2190. $wh[$v['id']] = $v['title'];
  2191. }
  2192. if (isset($post['page'])) {
  2193. $page = $this->input->post('page', true);
  2194. $perpage = $this->input->post('perpage', true);
  2195. $category = $this->input->post('category', true);
  2196. $size = $this->input->post('size', true);
  2197. $grade = $this->input->post('grade', true);
  2198. $color = $this->input->post('color', true);
  2199. $lowe = $this->input->post('lowe', true);
  2200. $sku = $this->input->post('sku', true);
  2201. $warehouse = $this->input->post('warehouse', true);
  2202. $purchase = $this->input->post('purchase', true);
  2203. $ktime = $this->input->post('ktime', true);
  2204. $jtime = $this->input->post('jtime', true);
  2205. $ktime = strtotime($ktime);
  2206. $jtime = strtotime($jtime);
  2207. $where = "1=1";
  2208. $gj = "";
  2209. $ck = "";
  2210. if ($category) {
  2211. $where .= " and features like '%-$category-%'";
  2212. }
  2213. if ($size) {
  2214. $where .= " and features like '%-$size-%'";
  2215. }
  2216. if ($grade) {
  2217. $where .= " and features like '%-$grade-%'";
  2218. }
  2219. if ($color) {
  2220. $where .= " and features like '%-$color-%'";
  2221. }
  2222. if ($lowe) {
  2223. $where .= " and features like '%-$lowe-%'";
  2224. }
  2225. if ($warehouse) {
  2226. $where .= " and warehouse = '$warehouse'";
  2227. }
  2228. if ($purchase) {
  2229. $where .= " and purchase = '$purchase'";
  2230. }
  2231. if ($sku) {
  2232. $where .= " and sku like '%$sku%'";
  2233. }
  2234. if ($ktime && $jtime) {
  2235. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2236. }
  2237. //数据排序
  2238. $order_str = "enter desc";
  2239. if (empty($page)) {
  2240. $start = 0;
  2241. $perpage = 1;
  2242. } else {
  2243. $start = ($page - 1) * $perpage;
  2244. }
  2245. //取得信息列表
  2246. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2247. foreach ($info_list as $k => $v) {
  2248. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2249. if ($v['shop'] == '') {
  2250. $s = '通用';
  2251. } else {
  2252. $info_list[$k]['shop'] = '';
  2253. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2254. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2255. }
  2256. }
  2257. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2258. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2259. $info_list[$k]['g'] = $g;
  2260. }
  2261. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2262. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2263. $pagenum = ceil($total / $perpage);
  2264. $over = $total - ($start + $perpage);
  2265. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2266. echo json_encode($rows);
  2267. exit;
  2268. }
  2269. $this->_Template('whlabel_enter', $this->data);
  2270. }
  2271. //出库浏览
  2272. public function _out()
  2273. {
  2274. $post = $this->input->post(NULL, TRUE);
  2275. if (isset($post['page'])) {
  2276. $page = $this->input->post('page', true);
  2277. $perpage = $this->input->post('perpage', true);
  2278. $category = $this->input->post('category', true);
  2279. $size = $this->input->post('size', true);
  2280. $grade = $this->input->post('grade', true);
  2281. $color = $this->input->post('color', true);
  2282. $lowe = $this->input->post('lowe', true);
  2283. $sku = $this->input->post('sku', true);
  2284. $warehouse = $this->input->post('warehouse', true);
  2285. $purchase = $this->input->post('purchase', true);
  2286. $state = $this->input->post('state', true);
  2287. $ktime = $this->input->post('ktime', true);
  2288. $jtime = $this->input->post('jtime', true);
  2289. $ktime = strtotime($ktime);
  2290. $jtime = strtotime($jtime);
  2291. $where = "state=3";
  2292. $gj = "";
  2293. $ck = "";
  2294. if ($category) {
  2295. $where .= " and features like '%-$category-%'";
  2296. }
  2297. if ($size) {
  2298. $where .= " and features like '%-$size-%'";
  2299. }
  2300. if ($grade) {
  2301. $where .= " and features like '%-$grade-%'";
  2302. }
  2303. if ($color) {
  2304. $where .= " and features like '%-$color-%'";
  2305. }
  2306. if ($lowe) {
  2307. $where .= " and features like '%-$lowe-%'";
  2308. }
  2309. if ($state) {
  2310. $where .= " and state = '$state'";
  2311. }
  2312. if ($warehouse) {
  2313. $where .= " and warehouse = '$warehouse'";
  2314. }
  2315. if ($purchase) {
  2316. $where .= " and purchase = '$purchase'";
  2317. }
  2318. if ($sku) {
  2319. $where .= " and sku = '$sku'";
  2320. }
  2321. if ($ktime && $jtime) {
  2322. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2323. }
  2324. //数据排序
  2325. $order_str = "id desc";
  2326. if (empty($page)) {
  2327. $start = 0;
  2328. $perpage = 1;
  2329. } else {
  2330. $start = ($page - 1) * $perpage;
  2331. }
  2332. //取得信息列表
  2333. $info_list = $this->whlabel->find_all($where, 'sku');
  2334. $rows = array();
  2335. $list = array();
  2336. foreach ($info_list as $key => $value) {
  2337. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2338. }
  2339. $rows = array_unique($rows); //删除重复记录
  2340. foreach ($rows as $key => $value) {
  2341. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2342. $ck = $this->warehouse->read($data['warehouse']);
  2343. $warehouse = $ck['title'];
  2344. $gy = $this->purchase->read($data['purchase']);
  2345. $purchase = $gy['purchase'];
  2346. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2347. $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);
  2348. }
  2349. $total = count($list);
  2350. $pagenum = ceil($total / $perpage);
  2351. $over = $total - ($start + $perpage);
  2352. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2353. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2354. echo json_encode($rows);
  2355. exit;
  2356. }
  2357. $this->_Template('whlabel_out', $this->data);
  2358. }
  2359. //出库标签浏览
  2360. public function _label()
  2361. {
  2362. $post = $this->input->post(NULL, TRUE);
  2363. if (isset($post['page'])) {
  2364. $page = $this->input->post('page', true);
  2365. $perpage = $this->input->post('perpage', true);
  2366. $sku = $this->input->post('sku', true);
  2367. $warehouse = $this->input->post('warehouse', true);
  2368. $purchase = $this->input->post('purchase', true);
  2369. $orderinfo = $this->input->post('orderinfo', true);
  2370. $waybill = $this->input->post('waybill', true);
  2371. $category = $this->input->post('category', true);
  2372. $size = $this->input->post('size', true);
  2373. $grade = $this->input->post('grade', true);
  2374. $color = $this->input->post('color', true);
  2375. $lowe = $this->input->post('lowe', true);
  2376. $where = "state=1";
  2377. if ($sku) {
  2378. $where .= " and sku = '$sku'";
  2379. }
  2380. if ($warehouse) {
  2381. $where .= " and warehouse = '$warehouse'";
  2382. }
  2383. if ($purchase) {
  2384. $where .= " and purchase = '$purchase'";
  2385. }
  2386. if ($orderinfo) {
  2387. $where .= " and orderinfo = '$orderinfo'";
  2388. }
  2389. if ($waybill) {
  2390. $where .= " and waybill = '$waybill'";
  2391. }
  2392. if ($category) {
  2393. $where .= " and features like '%-$category-%'";
  2394. }
  2395. if ($size) {
  2396. $where .= " and features like '%-$size-%'";
  2397. }
  2398. if ($grade) {
  2399. $where .= " and features like '%-$grade-%'";
  2400. }
  2401. if ($color) {
  2402. $where .= " and features like '%-$color-%'";
  2403. }
  2404. if ($lowe) {
  2405. $where .= " and features like '%-$lowe-%'";
  2406. }
  2407. //数据排序
  2408. $order_str = "outk desc";
  2409. if (empty($page)) {
  2410. $start = 0;
  2411. $perpage = 1;
  2412. } else {
  2413. $start = ($page - 1) * $perpage;
  2414. }
  2415. //取得信息列表
  2416. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2417. foreach ($info_list as $key => $value) {
  2418. $warehouse = $this->warehouse->read($value['warehouse']);
  2419. $info_list[$key]['warehouse'] = $warehouse['title'];
  2420. $purchase = $this->purchase->read($value['purchase']);
  2421. $info_list[$key]['purchase'] = $purchase['title'];
  2422. if ($value['outk'] != 0) {
  2423. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2424. } else {
  2425. $info_list[$key]['outk'] = "";
  2426. }
  2427. if ($value['orderinfo'] == 0) {
  2428. $info_list[$key]['orderinfo'] = "";
  2429. }
  2430. if ($value['waybill'] == 0) {
  2431. $info_list[$key]['waybill'] = "";
  2432. }
  2433. }
  2434. $total = $this->whlabel->find_count($where);
  2435. $pagenum = ceil($total / $perpage);
  2436. $over = $total - ($start + $perpage);
  2437. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2438. echo json_encode($rows);
  2439. exit;
  2440. }
  2441. $this->_Template('whlabel_label', $this->data);
  2442. }
  2443. //独立站出库订单
  2444. public function _outorder()
  2445. {
  2446. if (isset($_SESSION['api'])) {
  2447. $user = $this->user->get_api($_SESSION['api']);
  2448. $usp = $user;
  2449. $fgshop = "";
  2450. $sid = "";
  2451. $user = explode('|', trim($user['shop'], '|'));
  2452. foreach ($user as $value) {
  2453. $fgshop .= " shop = " . $value . " or";
  2454. $sid .= " id = " . $value . " or";
  2455. }
  2456. } else {
  2457. echo "请重新登录";
  2458. }
  2459. $post = $this->input->post(NULL, TRUE);
  2460. if (isset($post['page'])) {
  2461. $page = $this->input->post('page', true);
  2462. $perpage = $this->input->post('perpage', true);
  2463. $warehouse = $this->input->post('warehouse', true);
  2464. $xztime = $this->input->post('xztime', true);
  2465. $timetk = $this->input->post('timetkk', true);
  2466. $timetj = $this->input->post('timetjj', true);
  2467. $shop = $this->input->post('shop', true);
  2468. $source = $this->input->post('source', true);
  2469. $orderinfo = $this->input->post('orderinfo', true);
  2470. $number = $this->input->post('number', true);
  2471. $sfxh = $this->input->post('sfxh', true);
  2472. $express = $this->input->post('express', true);
  2473. $waybill = $this->input->post('waybill', true);
  2474. $library = $this->input->post('library', true);
  2475. $country = $this->input->post('country', true);
  2476. $so = $this->input->post('so', true);
  2477. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2478. $print = $this->input->post('print', true);
  2479. $state = $this->input->post('state', true);
  2480. $orderurl = $this->input->post('orderurl', true);
  2481. $productid = $this->input->post('productid', true);
  2482. $timetk = strtotime($timetk);
  2483. $timetj = strtotime($timetj);
  2484. /**
  2485. $sj = $this->input->post('sj',true);
  2486. if($sj)
  2487. {
  2488. $sj = $this->input->post('sj',true);
  2489. }
  2490. else
  2491. {
  2492. $sj = "fullorder";
  2493. }
  2494. **/
  2495. $sj = "fullorder";
  2496. $where = "1=1";
  2497. if ($warehouse) {
  2498. $where .= " and type = '$warehouse'";
  2499. }
  2500. if ($timetk && $timetj) {
  2501. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2502. }
  2503. if ($orderinfo) {
  2504. $where .= " and orderinfo = '$orderinfo'";
  2505. }
  2506. if ($number) {
  2507. $where .= " and number = '$number'";
  2508. }
  2509. if ($express) {
  2510. $where .= " and express = '$express'";
  2511. }
  2512. if ($waybill) {
  2513. $where .= " and waybill = '$waybill'";
  2514. }
  2515. if ($library) {
  2516. $where .= " and library = '$library'";
  2517. }
  2518. if ($print) {
  2519. $where .= " and print = '$print'";
  2520. }
  2521. if ($libraryconfirm) {
  2522. $where .= " and libraryconfirm = '$libraryconfirm'";
  2523. }
  2524. if ($state) {
  2525. $where .= " and state = '$state'";
  2526. }
  2527. if ($shop) {
  2528. $where .= " and shop = '$shop'";
  2529. }
  2530. if ($country) {
  2531. $where .= " and country = '$country'";
  2532. }
  2533. if ($sfxh != '') {
  2534. $where .= " and sfxh = '$sfxh'";
  2535. }
  2536. if ($so) {
  2537. $where .= " and shipremarks like '%$so%'";
  2538. }
  2539. if ($source) {
  2540. if ($source == '2d') {
  2541. $where .= " and source >= '2'";
  2542. } else {
  2543. $where .= " and source = '$source'";
  2544. }
  2545. }
  2546. if (isset($_SESSION['api'])) {
  2547. foreach ($user as $value) {
  2548. $fgshop .= " shop = " . $value . " or";
  2549. }
  2550. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2551. }
  2552. if ($orderurl) {
  2553. $url = $this->orderurl->read($orderurl);
  2554. $where .= " and link like '%" . $url['url'] . "%'";
  2555. }
  2556. if($productid){
  2557. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2558. }
  2559. //数据排序
  2560. $order_str = "librarytime desc";
  2561. if (empty($page)) {
  2562. $start = 0;
  2563. $perpage = 1;
  2564. } else {
  2565. $start = ($page - 1) * $perpage;
  2566. }
  2567. //取得信息列表
  2568. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2569. //格式化数据
  2570. foreach ($info_list as $key => $value) {
  2571. $shop = $this->shop->read($value['shop']);
  2572. $info_list[$key]['shop'] = $shop['shopname'];
  2573. $express = $this->express->read($value['express']);
  2574. $info_list[$key]['express'] = $express['servicename'];
  2575. $warehouse = $this->warehouse->read($value['type']);
  2576. $info_list[$key]['type'] = $warehouse['title'];
  2577. if ($value['librarytime'] == '0') {
  2578. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2579. } else {
  2580. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2581. }
  2582. }
  2583. $total = $this->$sj->find_count($where);
  2584. $pagenum = ceil($total / $perpage);
  2585. $over = $total - ($start + $perpage);
  2586. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2587. echo json_encode($rows);
  2588. exit;
  2589. }
  2590. $this->data['express'] = $this->express->find_all();
  2591. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2592. $this->data['wlshop'] = $wlshop;
  2593. $user = $this->user->get_api($_SESSION['api']);
  2594. $powerid = $this->power->read($user['power']);
  2595. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2596. $pid = '';
  2597. foreach ($powertext as $v) {
  2598. $pid .= " id = " . $v . " or";
  2599. }
  2600. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2601. $this->data['fullorderexcel'] = $fullorderexcel;
  2602. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2603. $this->data['orderurl'] = $orderurl;
  2604. $this->_Template('whlabel_outorder', $this->data);
  2605. }
  2606. //tt出库
  2607. public function _toutorder()
  2608. {
  2609. $fgshop = "";
  2610. $sid = "";
  2611. if (isset($_SESSION['api'])) {
  2612. $user = $this->user->get_api($_SESSION['api']);
  2613. $usp = $user;
  2614. $user = explode('|', trim($user['shop'], '|'));
  2615. foreach ($user as $value) {
  2616. $fgshop .= " shop = " . $value . " or";
  2617. $sid .= " id = " . $value . " or";
  2618. }
  2619. } else {
  2620. echo "请重新登录";
  2621. die;
  2622. }
  2623. $post = $this->input->post(NULL, TRUE);
  2624. if (isset($post['page'])) {
  2625. $page = $this->input->post('page', true);
  2626. $perpage = $this->input->post('perpage', true);
  2627. $warehouse = $this->input->post('warehouse', true);
  2628. $xztime = $this->input->post('xztime', true);
  2629. $timetk = $this->input->post('timetkk', true);
  2630. $timetj = $this->input->post('timetjj', true);
  2631. $shop = $this->input->post('shop', true);
  2632. $source = $this->input->post('source', true);
  2633. $orderinfo = $this->input->post('orderinfo', true);
  2634. $number = $this->input->post('number', true);
  2635. $sfxh = $this->input->post('sfxh', true);
  2636. $express = $this->input->post('express', true);
  2637. $waybill = $this->input->post('waybill', true);
  2638. $library = $this->input->post('library', true);
  2639. $country = $this->input->post('country', true);
  2640. $so = $this->input->post('so', true);
  2641. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2642. $print = $this->input->post('print', true);
  2643. $state = $this->input->post('state', true);
  2644. $orderurl = $this->input->post('orderurl', true);
  2645. $timetk = strtotime($timetk);
  2646. $timetj = strtotime($timetj);
  2647. /**
  2648. $sj = $this->input->post('sj',true);
  2649. if($sj)
  2650. {
  2651. $sj = $this->input->post('sj',true);
  2652. }
  2653. else
  2654. {
  2655. $sj = "fullorder";
  2656. }
  2657. **/
  2658. $sj = "fullordertt";
  2659. $where = "1=1";
  2660. if ($warehouse) {
  2661. $where .= " and type = '$warehouse'";
  2662. }
  2663. if ($timetk && $timetj) {
  2664. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2665. }
  2666. if ($orderinfo) {
  2667. $where .= " and orderinfo = '$orderinfo'";
  2668. }
  2669. if ($number) {
  2670. $where .= " and number = '$number'";
  2671. }
  2672. if ($express) {
  2673. $where .= " and express = '$express'";
  2674. }
  2675. if ($waybill) {
  2676. $where .= " and waybill = '$waybill'";
  2677. }
  2678. if ($library) {
  2679. $where .= " and library = '$library'";
  2680. }
  2681. if ($print) {
  2682. $where .= " and print = '$print'";
  2683. }
  2684. if ($libraryconfirm) {
  2685. $where .= " and libraryconfirm = '$libraryconfirm'";
  2686. }
  2687. if ($state) {
  2688. $where .= " and state = '$state'";
  2689. }
  2690. if ($shop) {
  2691. $where .= " and shop = '$shop'";
  2692. }
  2693. if ($country) {
  2694. $where .= " and country = '$country'";
  2695. }
  2696. if ($sfxh != '') {
  2697. $where .= " and sfxh = '$sfxh'";
  2698. }
  2699. if ($so) {
  2700. $where .= " and shipremarks like '%$so%'";
  2701. }
  2702. if ($source) {
  2703. if ($source == '2d') {
  2704. $where .= " and source >= '2'";
  2705. } else {
  2706. $where .= " and source = '$source'";
  2707. }
  2708. }
  2709. if (isset($_SESSION['api'])) {
  2710. foreach ($user as $value) {
  2711. $fgshop .= " shop = " . $value . " or";
  2712. }
  2713. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2714. }
  2715. if ($orderurl) {
  2716. $url = $this->orderurl->read($orderurl);
  2717. $where .= " and link like '%" . $url['url'] . "%'";
  2718. }
  2719. //数据排序
  2720. $order_str = "librarytime desc";
  2721. if (empty($page)) {
  2722. $start = 0;
  2723. $perpage = 1;
  2724. } else {
  2725. $start = ($page - 1) * $perpage;
  2726. }
  2727. //取得信息列表
  2728. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2729. //格式化数据
  2730. foreach ($info_list as $key => $value) {
  2731. $shop = $this->shop->read($value['shop']);
  2732. $info_list[$key]['shop'] = $shop['shopname'];
  2733. $express = $this->express->read($value['express']);
  2734. $info_list[$key]['express'] = $express['servicename'];
  2735. $warehouse = $this->warehouse->read($value['type']);
  2736. $info_list[$key]['type'] = $warehouse['title'];
  2737. if ($value['librarytime'] == '0') {
  2738. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2739. } else {
  2740. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2741. }
  2742. }
  2743. $total = $this->$sj->find_count($where);
  2744. $pagenum = ceil($total / $perpage);
  2745. $over = $total - ($start + $perpage);
  2746. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2747. echo json_encode($rows);
  2748. exit;
  2749. }
  2750. $this->data['express'] = $this->express->find_all();
  2751. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2752. $this->data['wlshop'] = $wlshop;
  2753. $user = $this->user->get_api($_SESSION['api']);
  2754. $powerid = $this->power->read($user['power']);
  2755. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2756. $pid = '';
  2757. foreach ($powertext as $v) {
  2758. $pid .= " id = " . $v . " or";
  2759. }
  2760. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2761. $this->data['fullorderexcel'] = $fullorderexcel;
  2762. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2763. $this->data['orderurl'] = $orderurl;
  2764. $this->_Template('whlabel_toutorder', $this->data);
  2765. }
  2766. //tt出库
  2767. public function _aoutorder()
  2768. {
  2769. if (isset($_SESSION['api'])) {
  2770. $user = $this->user->get_api($_SESSION['api']);
  2771. $usp = $user;
  2772. $fgshop = "";
  2773. $sid = "";
  2774. $user = explode('|', trim($user['shop'], '|'));
  2775. foreach ($user as $value) {
  2776. $fgshop .= " shop = " . $value . " or";
  2777. $sid .= " id = " . $value . " or";
  2778. }
  2779. } else {
  2780. echo "请重新登录";
  2781. }
  2782. $post = $this->input->post(NULL, TRUE);
  2783. if (isset($post['page'])) {
  2784. $page = $this->input->post('page', true);
  2785. $perpage = $this->input->post('perpage', true);
  2786. $warehouse = $this->input->post('warehouse', true);
  2787. $xztime = $this->input->post('xztime', true);
  2788. $timetk = $this->input->post('timetkk', true);
  2789. $timetj = $this->input->post('timetjj', true);
  2790. $shop = $this->input->post('shop', true);
  2791. $source = $this->input->post('source', true);
  2792. $orderinfo = $this->input->post('orderinfo', true);
  2793. $number = $this->input->post('number', true);
  2794. $sfxh = $this->input->post('sfxh', true);
  2795. $express = $this->input->post('express', true);
  2796. $waybill = $this->input->post('waybill', true);
  2797. $library = $this->input->post('library', true);
  2798. $country = $this->input->post('country', true);
  2799. $so = $this->input->post('so', true);
  2800. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2801. $print = $this->input->post('print', true);
  2802. $state = $this->input->post('state', true);
  2803. $orderurl = $this->input->post('orderurl', true);
  2804. $timetk = strtotime($timetk);
  2805. $timetj = strtotime($timetj);
  2806. /**
  2807. $sj = $this->input->post('sj',true);
  2808. if($sj)
  2809. {
  2810. $sj = $this->input->post('sj',true);
  2811. }
  2812. else
  2813. {
  2814. $sj = "fullorder";
  2815. }
  2816. **/
  2817. $sj = "fullorderamz";
  2818. $where = "1=1";
  2819. if ($warehouse) {
  2820. $where .= " and type = '$warehouse'";
  2821. }
  2822. if ($timetk && $timetj) {
  2823. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2824. }
  2825. if ($orderinfo) {
  2826. $where .= " and orderinfo = '$orderinfo'";
  2827. }
  2828. if ($number) {
  2829. $where .= " and number = '$number'";
  2830. }
  2831. if ($express) {
  2832. $where .= " and express = '$express'";
  2833. }
  2834. if ($waybill) {
  2835. $where .= " and waybill = '$waybill'";
  2836. }
  2837. if ($library) {
  2838. $where .= " and library = '$library'";
  2839. }
  2840. if ($print) {
  2841. $where .= " and print = '$print'";
  2842. }
  2843. if ($libraryconfirm) {
  2844. $where .= " and libraryconfirm = '$libraryconfirm'";
  2845. }
  2846. if ($state) {
  2847. $where .= " and state = '$state'";
  2848. }
  2849. if ($shop) {
  2850. $where .= " and shop = '$shop'";
  2851. }
  2852. if ($country) {
  2853. $where .= " and country = '$country'";
  2854. }
  2855. if ($sfxh != '') {
  2856. $where .= " and sfxh = '$sfxh'";
  2857. }
  2858. if ($so) {
  2859. $where .= " and shipremarks like '%$so%'";
  2860. }
  2861. if ($source) {
  2862. if ($source == '2d') {
  2863. $where .= " and source >= '2'";
  2864. } else {
  2865. $where .= " and source = '$source'";
  2866. }
  2867. }
  2868. if (isset($_SESSION['api'])) {
  2869. foreach ($user as $value) {
  2870. $fgshop .= " shop = " . $value . " or";
  2871. }
  2872. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2873. }
  2874. if ($orderurl) {
  2875. $url = $this->orderurl->read($orderurl);
  2876. $where .= " and link like '%" . $url['url'] . "%'";
  2877. }
  2878. //数据排序
  2879. $order_str = "librarytime desc";
  2880. if (empty($page)) {
  2881. $start = 0;
  2882. $perpage = 1;
  2883. } else {
  2884. $start = ($page - 1) * $perpage;
  2885. }
  2886. //取得信息列表
  2887. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2888. //格式化数据
  2889. foreach ($info_list as $key => $value) {
  2890. $shop = $this->shop->read($value['shop']);
  2891. $info_list[$key]['shop'] = $shop['shopname'];
  2892. $express = $this->express->read($value['express']);
  2893. $info_list[$key]['express'] = $express['servicename'];
  2894. $warehouse = $this->warehouse->read($value['type']);
  2895. $info_list[$key]['type'] = $warehouse['title'];
  2896. if ($value['librarytime'] == '0') {
  2897. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2898. } else {
  2899. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2900. }
  2901. }
  2902. $total = $this->$sj->find_count($where);
  2903. $pagenum = ceil($total / $perpage);
  2904. $over = $total - ($start + $perpage);
  2905. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2906. echo json_encode($rows);
  2907. exit;
  2908. }
  2909. $this->data['express'] = $this->express->find_all();
  2910. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2911. $this->data['wlshop'] = $wlshop;
  2912. $user = $this->user->get_api($_SESSION['api']);
  2913. $powerid = $this->power->read($user['power']);
  2914. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2915. $pid = '';
  2916. foreach ($powertext as $v) {
  2917. $pid .= " id = " . $v . " or";
  2918. }
  2919. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2920. $this->data['fullorderexcel'] = $fullorderexcel;
  2921. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2922. $this->data['orderurl'] = $orderurl;
  2923. $this->_Template('whlabel_aoutorder', $this->data);
  2924. }
  2925. //速卖通出库订单
  2926. public function _soutorder()
  2927. {
  2928. if (isset($_SESSION['api'])) {
  2929. $user = $this->user->get_api($_SESSION['api']);
  2930. $usp = $user;
  2931. $fgshop = "";
  2932. $sid = "";
  2933. $user = explode('|', trim($user['shop'], '|'));
  2934. foreach ($user as $value) {
  2935. $sid .= " id = " . $value . " or";
  2936. }
  2937. }
  2938. $post = $this->input->post(NULL, TRUE);
  2939. if (isset($post['page'])) {
  2940. $page = $this->input->post('page', true);
  2941. $perpage = $this->input->post('perpage', true);
  2942. $warehouse = $this->input->post('warehouse', true);
  2943. $xztime = $this->input->post('xztime', true);
  2944. $timetk = $this->input->post('timetkk', true);
  2945. $timetj = $this->input->post('timetjj', true);
  2946. $shop = $this->input->post('shop', true);
  2947. $source = $this->input->post('source', true);
  2948. $orderinfo = $this->input->post('orderinfo', true);
  2949. $number = $this->input->post('number', true);
  2950. $express = $this->input->post('express', true);
  2951. $waybill = $this->input->post('waybill', true);
  2952. $library = $this->input->post('library', true);
  2953. $country = $this->input->post('country', true);
  2954. $sfxh = $this->input->post('sfxh', true);
  2955. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2956. $print = $this->input->post('print', true);
  2957. $state = $this->input->post('state', true);
  2958. $so = $this->input->post('so', true);
  2959. $timetk = strtotime($timetk);
  2960. $timetj = strtotime($timetj);
  2961. /**
  2962. $sj = $this->input->post('sj',true);
  2963. if($sj)
  2964. {
  2965. $sj = $this->input->post('sj',true);
  2966. }
  2967. else
  2968. {
  2969. $sj = "fullorder";
  2970. }
  2971. **/
  2972. $sj = "fullordersmt";
  2973. $where = "1=1";
  2974. if ($warehouse) {
  2975. $where .= " and type = '$warehouse'";
  2976. }
  2977. if ($timetk && $timetj) {
  2978. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2979. }
  2980. if ($orderinfo) {
  2981. $where .= " and orderinfo = '$orderinfo'";
  2982. }
  2983. if ($number) {
  2984. $where .= " and number = '$number'";
  2985. }
  2986. if ($express) {
  2987. $where .= " and express = '$express'";
  2988. }
  2989. if ($waybill) {
  2990. $where .= " and waybill = '$waybill'";
  2991. }
  2992. if ($library) {
  2993. $where .= " and library = '$library'";
  2994. }
  2995. if ($print) {
  2996. $where .= " and print = '$print'";
  2997. }
  2998. if ($libraryconfirm) {
  2999. $where .= " and libraryconfirm = '$libraryconfirm'";
  3000. }
  3001. if ($state) {
  3002. $where .= " and state = '$state'";
  3003. }
  3004. if ($shop) {
  3005. $where .= " and shop = '$shop'";
  3006. }
  3007. if ($sfxh != '') {
  3008. $where .= " and sfxh = '$sfxh'";
  3009. }
  3010. if ($so) {
  3011. $where .= " and shipremarks like '%$so%'";
  3012. }
  3013. if ($source) {
  3014. $where .= " and source = '$source'";
  3015. }
  3016. if ($country) {
  3017. $where .= " and country = '$country'";
  3018. } else {
  3019. if (isset($_SESSION['api'])) {
  3020. foreach ($user as $value) {
  3021. $fgshop .= " shop = " . $value . " or";
  3022. }
  3023. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3024. }
  3025. }
  3026. //数据排序
  3027. $order_str = "librarytime desc";
  3028. if (empty($page)) {
  3029. $start = 0;
  3030. $perpage = 1;
  3031. } else {
  3032. $start = ($page - 1) * $perpage;
  3033. }
  3034. //取得信息列表
  3035. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3036. //格式化数据
  3037. foreach ($info_list as $key => $value) {
  3038. $shop = $this->shop->read($value['shop']);
  3039. $info_list[$key]['shop'] = $shop['shopname'];
  3040. $express = $this->express->read($value['express']);
  3041. $info_list[$key]['express'] = $express['servicename'];
  3042. $warehouse = $this->warehouse->read($value['type']);
  3043. $info_list[$key]['type'] = $warehouse['title'];
  3044. if ($value['librarytime'] == '0') {
  3045. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3046. } else {
  3047. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3048. }
  3049. }
  3050. $total = $this->$sj->find_count($where);
  3051. $pagenum = ceil($total / $perpage);
  3052. $over = $total - ($start + $perpage);
  3053. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3054. echo json_encode($rows);
  3055. exit;
  3056. }
  3057. $this->data['express'] = $this->express->find_all();
  3058. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3059. $this->data['wlshop'] = $wlshop;
  3060. $user = $this->user->get_api($_SESSION['api']);
  3061. $powerid = $this->power->read($user['power']);
  3062. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3063. $pid = '';
  3064. foreach ($powertext as $v) {
  3065. $pid .= " id = " . $v . " or";
  3066. }
  3067. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3068. $this->data['fullorderexcel'] = $fullorderexcel;
  3069. $this->_Template('whlabel_soutorder', $this->data);
  3070. }
  3071. //订单退库
  3072. public function _retreat()
  3073. {
  3074. $post = $this->input->post(NULL, TRUE);
  3075. if (isset($post['page'])) {
  3076. $page = $this->input->post('page', true);
  3077. $perpage = $this->input->post('perpage', true);
  3078. $warehouse = $this->input->post('warehouse', true);
  3079. $timetk = $this->input->post('timetk', true);
  3080. $timetj = $this->input->post('timetj', true);
  3081. $shop = $this->input->post('shop', true);
  3082. $source = $this->input->post('source', true);
  3083. $state = $this->input->post('state', true);
  3084. $review = $this->input->post('review', true);
  3085. $state = $this->input->post('state', true);
  3086. $express = $this->input->post('express', true);
  3087. $orderinfo = $this->input->post('orderinfo', true);
  3088. $user = $this->input->post('user', true);
  3089. $name = $this->input->post('name', true);
  3090. $waybill = $this->input->post('waybill', true);
  3091. $timetk = strtotime($timetk);
  3092. $timetj = strtotime($timetj);
  3093. $where = "(state=206 or state=210) and mergeid = 0";
  3094. if ($warehouse) {
  3095. $where .= " and state = '$warehouse'";
  3096. }
  3097. if ($timetk && $timetj) {
  3098. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3099. }
  3100. if ($shop) {
  3101. $where .= " and shop = '$shop'";
  3102. }
  3103. if ($source) {
  3104. $where .= " and source = '$source'";
  3105. }
  3106. if ($state) {
  3107. $where .= " and state = '$state'";
  3108. }
  3109. if ($review) {
  3110. $where .= " and review = '$review'";
  3111. }
  3112. if ($state) {
  3113. $where .= " and state = '$state'";
  3114. }
  3115. if ($express) {
  3116. $where .= " and express = '$express'";
  3117. }
  3118. if ($orderinfo) {
  3119. $where .= " and orderinfo = '$orderinfo'";
  3120. }
  3121. if ($user) {
  3122. $where .= " and user = '$user'";
  3123. }
  3124. if ($name) {
  3125. $where .= " and name = '$name'";
  3126. }
  3127. if ($waybill) {
  3128. $where .= " and waybill = '$waybill'";
  3129. }
  3130. //数据排序
  3131. $order_str = "id desc";
  3132. if (empty($page)) {
  3133. $start = 0;
  3134. $perpage = 1;
  3135. } else {
  3136. $start = ($page - 1) * $perpage;
  3137. }
  3138. //取得信息列表
  3139. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3140. //格式化数据
  3141. foreach ($info_list as $key => $value) {
  3142. $shop = $this->shop->read($value['shop']);
  3143. $info_list[$key]['shop'] = $shop['shopname'];
  3144. $warehouse = $this->warehouse->read($value['warehouse']);
  3145. $info_list[$key]['warehouse'] = $warehouse['title'];
  3146. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3147. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3148. if ($value['waybill'] == 0) {
  3149. $info_list[$key]['waybill'] = "";
  3150. }
  3151. $express = $this->express->read($value['express']);
  3152. $info_list[$key]['express'] = $express['title'];
  3153. $typeclass = $this->typeclass->read($value['state']);
  3154. $info_list[$key]['state'] = $typeclass['title'];
  3155. }
  3156. $total = $this->fullorder->find_count($where);
  3157. $pagenum = ceil($total / $perpage);
  3158. $over = $total - ($start + $perpage);
  3159. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3160. echo json_encode($rows);
  3161. exit;
  3162. }
  3163. $this->data['express'] = $this->express->find_all();
  3164. $this->_Template('whlabel_retreat', $this->data);
  3165. }
  3166. //退库标签浏览
  3167. public function _retreatlk()
  3168. {
  3169. $post = $this->input->post(NULL, TRUE);
  3170. if (isset($post['page'])) {
  3171. $page = $this->input->post('page', true);
  3172. $perpage = $this->input->post('perpage', true);
  3173. $timetk = $this->input->post('timetk', true);
  3174. $timetj = $this->input->post('timetj', true);
  3175. $sku = $this->input->post('sku', true);
  3176. $warehouse = $this->input->post('warehouse', true);
  3177. $purchase = $this->input->post('purchase', true);
  3178. $orderinfo = $this->input->post('orderinfo', true);
  3179. $waybill = $this->input->post('waybill', true);
  3180. $category = $this->input->post('category', true);
  3181. $size = $this->input->post('size', true);
  3182. $grade = $this->input->post('grade', true);
  3183. $color = $this->input->post('color', true);
  3184. $lowe = $this->input->post('lowe', true);
  3185. $state = $this->input->post('state', true);
  3186. $timetk = strtotime($timetk);
  3187. $timetj = strtotime($timetj);
  3188. $where = "state=2";
  3189. if ($timetk && $timetj) {
  3190. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3191. }
  3192. if ($sku) {
  3193. $where .= " and sku = '$sku'";
  3194. }
  3195. if ($warehouse) {
  3196. $where .= " and warehouse = '$warehouse'";
  3197. }
  3198. if ($purchase) {
  3199. $where .= " and purchase = '$purchase'";
  3200. }
  3201. if ($orderinfo) {
  3202. $where .= " and orderinfo = '$orderinfo'";
  3203. }
  3204. if ($waybill) {
  3205. $where .= " and waybill = '$waybill'";
  3206. }
  3207. if ($category) {
  3208. $where .= " and features like '%-$category-%'";
  3209. }
  3210. if ($size) {
  3211. $where .= " and features like '%-$size-%'";
  3212. }
  3213. if ($grade) {
  3214. $where .= " and features like '%-$grade-%'";
  3215. }
  3216. if ($color) {
  3217. $where .= " and features like '%-$color-%'";
  3218. }
  3219. if ($lowe) {
  3220. $where .= " and features like '%-$lowe-%'";
  3221. }
  3222. //数据排序
  3223. $order_str = "time desc";
  3224. if (empty($page)) {
  3225. $start = 0;
  3226. $perpage = 1;
  3227. } else {
  3228. $start = ($page - 1) * $perpage;
  3229. }
  3230. //取得信息列表
  3231. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3232. foreach ($info_list as $key => $value) {
  3233. $warehouse = $this->warehouse->read($value['warehouse']);
  3234. $info_list[$key]['warehouse'] = $warehouse['title'];
  3235. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3236. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3237. $purchase = $this->purchase->read($value['purchase']);
  3238. $info_list[$key]['purchase'] = $purchase['title'];
  3239. if ($value['outk'] != 0) {
  3240. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3241. } else {
  3242. $info_list[$key]['outk'] = "";
  3243. }
  3244. if ($value['retreat'] != 0) {
  3245. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3246. } else {
  3247. $info_list[$key]['retreat'] = "";
  3248. }
  3249. if ($value['orderinfo'] == 0) {
  3250. $info_list[$key]['orderinfo'] = "";
  3251. }
  3252. if ($value['waybill'] == 0) {
  3253. $info_list[$key]['waybill'] = "";
  3254. }
  3255. }
  3256. $total = $this->whlabel->find_count($where);
  3257. $pagenum = ceil($total / $perpage);
  3258. $over = $total - ($start + $perpage);
  3259. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3260. echo json_encode($rows);
  3261. exit;
  3262. }
  3263. $this->_Template('whlabel_retreatlk', $this->data);
  3264. }
  3265. //更换标签及浏览
  3266. public function _change()
  3267. {
  3268. $post = $this->input->post(NULL, TRUE);
  3269. if (isset($post['page'])) {
  3270. $page = $this->input->post('page', true);
  3271. $perpage = $this->input->post('perpage', true);
  3272. $timetk = $this->input->post('timetk', true);
  3273. $timetj = $this->input->post('timetj', true);
  3274. $label = $this->input->post('label', true);
  3275. $oldlabel = $this->input->post('oldlabel', true);
  3276. $timetk = strtotime($timetk);
  3277. $timetj = strtotime($timetj);
  3278. $where = "state=10 ";
  3279. if ($timetk && $timetj) {
  3280. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3281. }
  3282. if ($label) {
  3283. $where .= " and label = '$label'";
  3284. }
  3285. if ($oldlabel) {
  3286. $where .= " and oldlabel = '$oldlabel'";
  3287. }
  3288. //数据排序
  3289. $order_str = "time asc";
  3290. if (empty($page)) {
  3291. $start = 0;
  3292. $perpage = 1;
  3293. } else {
  3294. $start = ($page - 1) * $perpage;
  3295. }
  3296. //取得信息列表
  3297. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3298. foreach ($info_list as $key => $value) {
  3299. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3300. }
  3301. $total = $this->whlabel->find_count($where);
  3302. $pagenum = ceil($total / $perpage);
  3303. $over = $total - ($start + $perpage);
  3304. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3305. echo json_encode($rows);
  3306. exit;
  3307. }
  3308. $this->_Template('whlabel_change', $this->data);
  3309. }
  3310. //产品标签
  3311. public function _cpbqdc()
  3312. {
  3313. if (isset($_GET['excel'])) {
  3314. $where = "1=1";
  3315. //数据排序
  3316. $order_str = "id desc";
  3317. if (empty($page)) {
  3318. $start = 0;
  3319. $perpage = 1;
  3320. } else {
  3321. $start = ($page - 1) * $perpage;
  3322. }
  3323. $warehouse = $this->input->get('warehouse', true);
  3324. $state = $this->input->get('state', true);
  3325. $timetk = $this->input->get('timetkk', true);
  3326. $timetj = $this->input->get('timetjj', true);
  3327. $timetk = strtotime($timetk);
  3328. $timetj = strtotime($timetj);
  3329. if ($warehouse) {
  3330. $where .= " and warehouse = '$warehouse'";
  3331. }
  3332. if ($state || $state == 0) {
  3333. $where .= " and state = '$state'";
  3334. }
  3335. if ($timetk && $timetj) {
  3336. $where .= " and time > '$timetk' and time < '$timetj'";
  3337. }
  3338. //取得信息列表
  3339. $info_list = $this->whlabel->find_all($where, '*');
  3340. $rows = array();
  3341. $list = array();
  3342. foreach ($info_list as $key => $value) {
  3343. $rows[$value['time']] = $value; //所有数据sku
  3344. }
  3345. foreach ($rows as $value) {
  3346. $warehouse = $this->warehouse->read($value['warehouse']);
  3347. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3348. $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);
  3349. }
  3350. $title = "产品标签统计表";
  3351. $titlename = "<table border=1>
  3352. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3353. <tr align='center'>
  3354. <td>仓库</td>
  3355. <td>SKU</td>
  3356. <td>产品</td>
  3357. <td>入库时间</td>
  3358. <td>操作时间</td>
  3359. <td>备注</td>
  3360. <td>数量</td>
  3361. </tr>
  3362. </table>";
  3363. $filename = $title . ".xls";
  3364. $tail = "";
  3365. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3366. }
  3367. }
  3368. //进销存导出
  3369. public function _exceljxc()
  3370. {
  3371. $classid = $this->classid->sku();
  3372. $pm = $classid;
  3373. $typeclass = array();
  3374. $tc = $this->typeclass->find_all();
  3375. foreach ($tc as $v) {
  3376. $typeclass[$v['id']] = $v;
  3377. }
  3378. $prc = array();
  3379. $purchase = $this->purchase->find_all();
  3380. foreach ($purchase as $k => $v) {
  3381. $prc[$v['id']] = $v['title'];
  3382. }
  3383. if (isset($_GET['excel'])) {
  3384. $where = "sku != 'Preset'";
  3385. //数据排序
  3386. $order_str = "id desc";
  3387. if (empty($page)) {
  3388. $start = 0;
  3389. $perpage = 1;
  3390. } else {
  3391. $start = ($page - 1) * $perpage;
  3392. }
  3393. $category = $this->input->get('category', true);
  3394. $warehouse = $this->input->get('warehouse', true);
  3395. $excelid = $this->input->get('sid', true);
  3396. if ($category) {
  3397. $where .= " and features like '%-$category-%'";
  3398. }
  3399. if ($warehouse) {
  3400. $where .= " and warehouse = '$warehouse'";
  3401. }
  3402. $xzid = '';
  3403. if ($excelid) {
  3404. $excelid = explode(',', trim($excelid, ','));
  3405. foreach ($excelid as $key => $value) {
  3406. $xzid .= " id = " . $value . " or";
  3407. }
  3408. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3409. }
  3410. //取得信息列表
  3411. /**
  3412. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3413. $rows = array();$list = array();
  3414. foreach ($info_list as $key=>$value)
  3415. {
  3416. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3417. }
  3418. **/
  3419. $wt = array();
  3420. $whlabel_type = $this->whlabel_type->find_all();
  3421. foreach ($whlabel_type as $v) {
  3422. $wt[$v['id']] = $v['title'];
  3423. }
  3424. $wh = array();
  3425. $w = $this->warehouse->find_all('1=1', 'id,title');
  3426. foreach ($w as $v) {
  3427. $wh[$v['id']] = $v['title'];
  3428. }
  3429. $list = array();
  3430. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3431. foreach ($rows as $key => $value) {
  3432. if (isset($wt[$value['type']])) {
  3433. $rows[$key]['type'] = $wt[$value['type']];
  3434. } else {
  3435. $rows[$key]['type'] = '未设置';
  3436. }
  3437. $bm = '03';
  3438. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3439. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3440. $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');
  3441. $details = array();
  3442. $cpid = array();
  3443. $cpbz = array();
  3444. $c = 0;
  3445. $g = 0;
  3446. $x = 0;
  3447. $t = 0;
  3448. $s = 0;
  3449. $q = 0;
  3450. foreach ($sd as $k => $v) {
  3451. if ($v['state'] == 0) {
  3452. $c++;
  3453. if ($v['cpid'] != 0) {
  3454. $cpid[$v['cpid']] = $v['cpid'];
  3455. }
  3456. if ($v['cpbz'] != '') {
  3457. $cpbz[$v['cpbz']] = $v['cpbz'];
  3458. }
  3459. }
  3460. if ($v['state'] != 9) {
  3461. $g++;
  3462. }
  3463. if ($v['state'] == 1) {
  3464. $x++;
  3465. }
  3466. if ($v['state'] == 2) {
  3467. $t++;
  3468. }
  3469. if ($v['state'] == 8) {
  3470. $s++;
  3471. }
  3472. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3473. $q++;
  3474. }
  3475. $details[$v['details']] = $v['details'];
  3476. }
  3477. $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'] . '"');
  3478. $rows[$key]['details'] = implode("、", $details);
  3479. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3480. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3481. $number = $value['number'];
  3482. $ftime = time() - 15 * 24 * 3600;
  3483. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3484. $rows[$key]['number'] = $g;
  3485. $rows[$key]['c'] = $c;
  3486. $rows[$key]['x'] = $x;
  3487. $rows[$key]['t'] = $t;
  3488. $rows[$key]['s'] = $s;
  3489. $rows[$key]['q'] = $q;
  3490. $rows[$key]['z'] = $z;
  3491. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3492. $features = explode('-', trim($features, '-'));
  3493. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3494. // $pm = $classid;
  3495. // $jm = $classid;
  3496. // foreach($features as $k=>$v)
  3497. // {
  3498. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3499. // {
  3500. // if($typeclass[$v]['bm'] != '')
  3501. // {
  3502. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3503. // }
  3504. // }
  3505. // if($v != 0)
  3506. // {
  3507. // if(!isset($typeclass[$v]))
  3508. // {
  3509. // continue;
  3510. // }
  3511. // if(isset($pm[$typeclass[$v]['classid']]))
  3512. // {
  3513. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3514. // {
  3515. // $tz = explode('|',$typeclass[$v]['zh']);
  3516. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3517. // }
  3518. // else
  3519. // {
  3520. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3521. // }
  3522. // }
  3523. // if(isset($jm[$typeclass[$v]['classid']]))
  3524. // {
  3525. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3526. // }
  3527. // }
  3528. // }
  3529. // $jm = array_filter($jm);
  3530. // $rows[$key]['bs'] = implode("-",$jm);
  3531. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3532. // $zh = implode(" ",$pm);
  3533. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3534. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3535. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3536. // $rows[$key]['features'] = $zh;
  3537. }
  3538. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3539. $final_list = [];
  3540. foreach ($list as $k => $v) {
  3541. if (empty($v['sku'])) {
  3542. continue;
  3543. }
  3544. $final_list[] = [
  3545. "warehouse" => $v["warehouse"],
  3546. "purchase" => $v["purchase"],
  3547. "details" => $v["details"],
  3548. "cpid" => $v["cpid"],
  3549. "dbcontent" => $v["dbcontent"],
  3550. "sku" => $v["sku"],
  3551. "cs" => $v["bm"],
  3552. "bs" => $v["jm"],
  3553. "title" => $v["title"],
  3554. "features" => $v["pm"],
  3555. "cpbz" => $v["cpbz"],
  3556. "sm" => $v["sm"],
  3557. "type" => $v["type"],
  3558. "number" => $v["number"],
  3559. "c" => $v["c"],
  3560. "x" => $v["x"],
  3561. "t" => $v["t"],
  3562. "s" => $v["s"],
  3563. "q" => $v["q"],
  3564. "z" => $v["z"],
  3565. "weight" => $v['weight'],
  3566. ];
  3567. }
  3568. $title = "总进销存统计表";
  3569. $titlename = "<table border=1>
  3570. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3571. <tr align='center'>
  3572. <td>仓库</td>
  3573. <td>供应商</td>
  3574. <td>位置</td>
  3575. <td>库存编码</td>
  3576. <td>类目</td>
  3577. <td>SKU</td>
  3578. <td>用友编码</td>
  3579. <td>用友料号</td>
  3580. <td>商品名称</td>
  3581. <td>商品中文</td>
  3582. <td>产品备注</td>
  3583. <td>库位负责人</td>
  3584. <td>类型</td>
  3585. <td>入库总量</td>
  3586. <td>库存数量</td>
  3587. <td>销售数量</td>
  3588. <td>退货数量</td>
  3589. <td>删除数量</td>
  3590. <td>其它操作</td>
  3591. <td>占单数量</td>
  3592. <td>重量(g)</td>
  3593. </tr>
  3594. </table>";
  3595. $filename = $title . ".xls";
  3596. $tail = "";
  3597. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3598. }
  3599. }
  3600. //入库导出
  3601. public function _excelr()
  3602. {
  3603. if (isset($_GET['excel'])) {
  3604. $category = $this->input->get('category', true);
  3605. $size = $this->input->get('size', true);
  3606. $grade = $this->input->get('grade', true);
  3607. $color = $this->input->get('color', true);
  3608. $lowe = $this->input->get('lowe', true);
  3609. $sku = $this->input->get('sku', true);
  3610. $warehouse = $this->input->get('warehouse', true);
  3611. $purchase = $this->input->get('purchase', true);
  3612. $ktime = $this->input->get('ktime', true);
  3613. $jtime = $this->input->get('jtime', true);
  3614. $ktime = strtotime($ktime);
  3615. $jtime = strtotime($jtime);
  3616. $where = "1=1";
  3617. $gj = "";
  3618. $ck = "";
  3619. if ($category) {
  3620. $where .= " and features like '%-$category-%'";
  3621. }
  3622. if ($size) {
  3623. $where .= " and features like '%-$size-%'";
  3624. }
  3625. if ($grade) {
  3626. $where .= " and features like '%-$grade-%'";
  3627. }
  3628. if ($color) {
  3629. $where .= " and features like '%-$color-%'";
  3630. }
  3631. if ($lowe) {
  3632. $where .= " and features like '%-$lowe-%'";
  3633. }
  3634. if ($warehouse) {
  3635. $where .= " and warehouse = '$warehouse'";
  3636. }
  3637. if ($purchase) {
  3638. $where .= " and purchase = '$purchase'";
  3639. }
  3640. if ($sku) {
  3641. $where .= " and sku = '$sku'";
  3642. }
  3643. if ($ktime && $jtime) {
  3644. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3645. }
  3646. //数据排序
  3647. $order_str = "id desc";
  3648. if (empty($page)) {
  3649. $start = 0;
  3650. $perpage = 1;
  3651. } else {
  3652. $start = ($page - 1) * $perpage;
  3653. }
  3654. $list = array();
  3655. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3656. foreach ($rows as $value) {
  3657. $ck = $this->warehouse->read($value['warehouse']);
  3658. $warehouse = $ck['title'];
  3659. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3660. $retreatwarehouse = $tkck['title'];
  3661. $gy = $this->purchase->read($value['purchase']);
  3662. $purchase = $gy['title'];
  3663. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3664. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3665. }
  3666. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3667. $titlename = "<table border=1>
  3668. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3669. <tr align='center'>
  3670. <td>仓库</td>
  3671. <td>SKU</td>
  3672. <td>产品</td>
  3673. <td>时间</td>
  3674. <td>数量</td>
  3675. </tr>
  3676. </table>";
  3677. $filename = $title . ".xls";
  3678. $tail = "";
  3679. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3680. }
  3681. }
  3682. //出库、退库导出
  3683. public function _excelct()
  3684. {
  3685. $classid = $this->classid->sku();
  3686. $pm = $classid;
  3687. $typeclass = array();
  3688. $tc = $this->typeclass->find_all();
  3689. foreach ($tc as $v) {
  3690. $typeclass[$v['id']] = $v;
  3691. }
  3692. $prc = array();
  3693. $purchase = $this->purchase->find_all();
  3694. foreach ($purchase as $k => $v) {
  3695. $prc[$v['id']] = $v['title'];
  3696. }
  3697. if (isset($_GET['excel'])) {
  3698. $wh = array();
  3699. $w = $this->warehouse->find_all('1=1', 'id,title');
  3700. foreach ($w as $v) {
  3701. $wh[$v['id']] = $v['title'];
  3702. }
  3703. $type = $this->input->get('excel', true);
  3704. $category = $this->input->get('category', true);
  3705. $size = $this->input->get('size', true);
  3706. $grade = $this->input->get('grade', true);
  3707. $color = $this->input->get('color', true);
  3708. $lowe = $this->input->get('lowe', true);
  3709. $sku = $this->input->get('sku', true);
  3710. $title = $this->input->get('title', true);
  3711. $warehouse = $this->input->get('warehouse', true);
  3712. $purchase = $this->input->get('purchase', true);
  3713. $lacetype = $this->input->get('lacetype', true);
  3714. $haircap = $this->input->get('haircap', true);
  3715. $lacecolor = $this->input->get('lacecolor', true);
  3716. $density = $this->input->get('density', true);
  3717. $details = $this->input->get('details', true);
  3718. $state = $this->input->get('state', true);
  3719. $shop = $this->input->get('shop', true);
  3720. $hairnumber = $this->input->get('hairnumber', true);
  3721. $type_leixi = $this->input->get('type', true);
  3722. $cpbz = $this->input->get('cpbz', true);
  3723. $sm = $this->input->get('sm', true);
  3724. $sid = $this->input->get('sid', true);
  3725. $ktime = $this->input->get('ktime', true);
  3726. $jtime = $this->input->get('jtime', true);
  3727. $ktime = strtotime($ktime);
  3728. $jtime = strtotime($jtime);
  3729. //$where = " 1=1 ";
  3730. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3731. $where = " sku != '' ";
  3732. $gj = "";
  3733. $ck = "";
  3734. if ($category) {
  3735. $where .= " and features like '%-$category-%'";
  3736. }
  3737. if ($size) {
  3738. $where .= " and features like '%-$size-%'";
  3739. }
  3740. if ($grade) {
  3741. $where .= " and features like '%-$grade-%'";
  3742. }
  3743. if ($color) {
  3744. $where .= " and features like '%-$color-%'";
  3745. }
  3746. if ($lowe) {
  3747. $where .= " and features like '%-$lowe-%'";
  3748. }
  3749. if ($warehouse) {
  3750. $where .= " and warehouse = '$warehouse'";
  3751. }
  3752. if ($purchase) {
  3753. $where .= " and purchase = '$purchase'";
  3754. }
  3755. if ($state) {
  3756. $where .= " and state = '$state'";
  3757. }
  3758. if ($lacetype) {
  3759. $where .= " and features like '%-$lacetype-%'";
  3760. }
  3761. if ($lacecolor) {
  3762. $where .= " and features like '%-$lacecolor-%'";
  3763. }
  3764. if ($density) {
  3765. $where .= " and features like '%-$density-%'";
  3766. }
  3767. if ($haircap) {
  3768. $where .= " and features like '%-$haircap-%'";
  3769. }
  3770. if ($details) {
  3771. $where .= " and details = '$details'";
  3772. }
  3773. if ($shop) {
  3774. $where .= " and shop like '%$shop%'";
  3775. }
  3776. if ($title) {
  3777. $title = trim($title, ' ');
  3778. $title = trim($title, ' ');
  3779. $where .= " and title like '%$title%'";
  3780. }
  3781. if (!empty($hairnumber)) {
  3782. $where .= " and features like '%-128-%' ";
  3783. if ($hairnumber < 0) {
  3784. $class_list = $this->typeclass->find_all('classid = 43');
  3785. foreach ($class_list as $v) {
  3786. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3787. }
  3788. } else {
  3789. $where .= " and features like '%-$hairnumber-%'";
  3790. }
  3791. }
  3792. if ($type_leixi) {
  3793. $where .= " and type = '$type_leixi'";
  3794. }
  3795. if ($cpbz) {
  3796. $where .= " and cpbz like '%$cpbz%' ";
  3797. }
  3798. if ($sm) {
  3799. $where .= " and sm like '%$sm%' ";
  3800. }
  3801. if ($sku) {
  3802. $sku = trim($sku, ' ');
  3803. $sku = trim($sku, ' ');
  3804. $where .= " and sku like '%$sku%'";
  3805. }
  3806. if ($ktime && $jtime) {
  3807. if ($type == 1) {
  3808. $tl = '出库';
  3809. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3810. } else if ($type == 2) {
  3811. $tl = '退库';
  3812. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3813. } else if ($type == 3) {
  3814. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3815. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3816. } else if ($type == 4) {
  3817. $tl = '出库+零售';
  3818. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3819. } else if ($type == 5) {
  3820. $tl = '零售';
  3821. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3822. }
  3823. }
  3824. $sidwhere = '';
  3825. if ($sid) {
  3826. $sd = "";
  3827. $s = explode(',', trim($sid, ','));
  3828. foreach ($s as $value) {
  3829. $sd .= " id = " . $value . " or";
  3830. }
  3831. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3832. }
  3833. //数据排序
  3834. $order_str = "time desc";
  3835. if (empty($page)) {
  3836. $start = 0;
  3837. $perpage = 1;
  3838. } else {
  3839. $start = ($page - 1) * $perpage;
  3840. }
  3841. //取得信息列表
  3842. if ($type != 3 && $type != 5) {
  3843. if ($type == 1 || $type == 4) {
  3844. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3845. foreach ($info_list as $key => $value) {
  3846. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3847. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3848. $warehouse = $this->warehouse->read($value['warehouse']);
  3849. $info_list[$key]['warehouse'] = $warehouse['title'];
  3850. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3851. $features = explode('-', trim($features, '-'));
  3852. $pm = $classid;
  3853. foreach ($features as $k => $v) {
  3854. if ($v != 0) {
  3855. if (!isset($typeclass[$v])) {
  3856. continue;
  3857. }
  3858. if (isset($pm[$typeclass[$v]['classid']])) {
  3859. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3860. $tz = explode('|', $typeclass[$v]['zh']);
  3861. $pm[$typeclass[$v]['classid']] = $tz[0];
  3862. } else {
  3863. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3864. }
  3865. }
  3866. }
  3867. }
  3868. $zh = implode(" ", $pm);
  3869. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3870. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3871. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3872. $info_list[$key]['features'] = $zh;
  3873. }
  3874. $final_list = [];
  3875. foreach($info_list as $k=>$v){
  3876. $number = "";
  3877. if(!empty($v['orderinfo'])){
  3878. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3879. if(!empty($tmp_info['number'])){
  3880. $number = $tmp_info['number'];
  3881. }
  3882. }
  3883. $final_list[] = [
  3884. 'warehouse'=>$v['warehouse'],
  3885. 'purchase'=>$v['purchase'],
  3886. 'sku'=>$v['sku'],
  3887. 'title'=>$v['title'],
  3888. 'features'=>$v['features'],
  3889. 'label'=>$v['label'],
  3890. 'orderinfo'=>$v['orderinfo'],
  3891. 'number'=>$number,
  3892. 'waybill'=>$v['waybill'],
  3893. 'outk'=>$v['outk'],
  3894. ];
  3895. }
  3896. } else {
  3897. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3898. foreach ($info_list as $key => $value) {
  3899. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3900. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3901. $warehouse = $this->warehouse->read($value['warehouse']);
  3902. $info_list[$key]['warehouse'] = $warehouse['title'];
  3903. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3904. $features = explode('-', trim($features, '-'));
  3905. $pm = $classid;
  3906. foreach ($features as $k => $v) {
  3907. if ($v != 0) {
  3908. if (!isset($typeclass[$v])) {
  3909. continue;
  3910. }
  3911. if (isset($pm[$typeclass[$v]['classid']])) {
  3912. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3913. $tz = explode('|', $typeclass[$v]['zh']);
  3914. $pm[$typeclass[$v]['classid']] = $tz[0];
  3915. } else {
  3916. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3917. }
  3918. }
  3919. }
  3920. }
  3921. $zh = implode(" ", $pm);
  3922. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3923. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3924. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3925. $info_list[$key]['features'] = $zh;
  3926. }
  3927. $final_list = [];
  3928. foreach($info_list as $k=>$v){
  3929. $number = "";
  3930. if(!empty($v['orderinfo'])){
  3931. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3932. if(!empty($tmp_info['number'])){
  3933. $number = $tmp_info['number'];
  3934. }
  3935. }
  3936. $final_list[] = [
  3937. 'warehouse'=>$v['warehouse'],
  3938. 'purchase'=>$v['purchase'],
  3939. 'sku'=>$v['sku'],
  3940. 'title'=>$v['title'],
  3941. 'features'=>$v['features'],
  3942. 'label'=>$v['label'],
  3943. 'orderinfo'=>$v['orderinfo'],
  3944. 'number'=>$number,
  3945. 'waybill'=>$v['waybill'],
  3946. 'retreat'=>$v['retreat'],
  3947. ];
  3948. }
  3949. }
  3950. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3951. $titlename = "<table border=1>
  3952. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3953. <tr align='center'>
  3954. <td>仓库</td>
  3955. <td>供应商</td>
  3956. <td>SKU</td>
  3957. <td>商品名称</td>
  3958. <td>商品中文</td>
  3959. <td>标签</td>
  3960. <td>订单号</td>
  3961. <td>订单编码</td>
  3962. <td>运单号</td>
  3963. <td>" . $tl . "时间(中国时间)</td>
  3964. </tr>
  3965. </table>";
  3966. $filename = $title . ".xls";
  3967. $tail = "";
  3968. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3969. } else if ($type == 5) {
  3970. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3971. foreach ($info_list as $key => $value) {
  3972. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3973. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3974. $warehouse = $this->warehouse->read($value['warehouse']);
  3975. $info_list[$key]['warehouse'] = $warehouse['title'];
  3976. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3977. $features = explode('-', trim($features, '-'));
  3978. $pm = $classid;
  3979. foreach ($features as $k => $v) {
  3980. if ($v != 0) {
  3981. if (!isset($typeclass[$v])) {
  3982. continue;
  3983. }
  3984. if (isset($pm[$typeclass[$v]['classid']])) {
  3985. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3986. $tz = explode('|', $typeclass[$v]['zh']);
  3987. $pm[$typeclass[$v]['classid']] = $tz[0];
  3988. } else {
  3989. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3990. }
  3991. }
  3992. }
  3993. }
  3994. $zh = implode(" ", $pm);
  3995. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3996. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3997. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3998. $info_list[$key]['features'] = $zh;
  3999. }
  4000. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4001. $titlename = "<table border=1>
  4002. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4003. <tr align='center'>
  4004. <td>仓库</td>
  4005. <td>供应商</td>
  4006. <td>SKU</td>
  4007. <td>商品名称</td>
  4008. <td>商品中文</td>
  4009. <td>标签</td>
  4010. <td>" . $tl . "时间(中国时间)</td>
  4011. </tr>
  4012. </table>";
  4013. $filename = $title . ".xls";
  4014. $tail = "";
  4015. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4016. } else {
  4017. /**
  4018. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4019. $rows = array();$list = array();
  4020. foreach ($info_list as $key=>$value)
  4021. {
  4022. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4023. }
  4024. **/
  4025. $wh = array();
  4026. $w = $this->warehouse->find_all('1=1', 'id,title');
  4027. foreach ($w as $v) {
  4028. $wh[$v['id']] = $v['title'];
  4029. }
  4030. $wt = array();
  4031. $whlabel_type = $this->whlabel_type->find_all();
  4032. foreach ($whlabel_type as $v) {
  4033. $wt[$v['id']] = $v['title'];
  4034. }
  4035. $classid = $this->classid->sku();
  4036. $list = array();
  4037. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4038. foreach ($rows as $key => $value) {
  4039. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4040. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4041. $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');
  4042. $details = array();
  4043. $cpid = array();
  4044. $cpbz = array();
  4045. $c = 0;
  4046. $g = 0;
  4047. $x = 0;
  4048. $t = 0;
  4049. $s = 0;
  4050. $q = 0;
  4051. foreach ($sd as $k => $v) {
  4052. if ($v['state'] == 0) {
  4053. $c++;
  4054. }
  4055. if ($v['state'] != 9) {
  4056. $g++;
  4057. }
  4058. if ($v['outk'] > 1) {
  4059. $x++;
  4060. }
  4061. if ($v['retreat'] > 0) {
  4062. $t++;
  4063. }
  4064. if ($v['state'] == 8) {
  4065. $s++;
  4066. }
  4067. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4068. $q++;
  4069. }
  4070. $details[$v['details']] = $v['details'];
  4071. if ($v['cpid'] != 0) {
  4072. $cpid[$v['cpid']] = $v['cpid'];
  4073. }
  4074. if ($v['cpbz'] != '') {
  4075. $cpbz[$v['cpbz']] = $v['cpbz'];
  4076. }
  4077. }
  4078. if (isset($wt[$value['type']])) {
  4079. $rows[$key]['type'] = $wt[$value['type']];
  4080. } else {
  4081. $rows[$key]['type'] = '未设置';
  4082. }
  4083. $rows[$key]['details'] = implode("、", $details);
  4084. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4085. $ftime = time() - 15 * 24 * 3600;
  4086. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4087. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4088. $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);
  4089. $rows[$key]['c'] = $c;
  4090. $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);
  4091. $rows[$key]['t'] = $t;
  4092. $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'] . '"');
  4093. $rows[$key]['z'] = $z;
  4094. // $jm = $classid;
  4095. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4096. $features = explode('-', trim($features, '-'));
  4097. // $pm = $classid;
  4098. // foreach ($features as $k => $v) {
  4099. // if ($v != 0) {
  4100. // if (!isset($typeclass[$v])) {
  4101. // continue;
  4102. // }
  4103. // if (isset($pm[$typeclass[$v]['classid']])) {
  4104. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4105. // $tz = explode('|', $typeclass[$v]['zh']);
  4106. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4107. // } else {
  4108. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4109. // }
  4110. // if (isset($jm[$typeclass[$v]['classid']])) {
  4111. // if ($typeclass[$v]['jm']) {
  4112. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4113. // }
  4114. // }
  4115. // }
  4116. // }
  4117. // }
  4118. // $zh = implode(" ", $pm);
  4119. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4120. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4121. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4122. // $rows[$key]['features'] = $zh;
  4123. // $jm = array_filter($jm); //去除空值
  4124. // $jm = implode("-", $jm);
  4125. // $rows[$key]['jm'] = $jm;
  4126. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4127. }
  4128. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4129. // echo "<pre>";
  4130. // print_r($tmp_list);
  4131. // die;
  4132. $final_list =[];
  4133. foreach($tmp_list as $k=>$v){
  4134. $final_list[] = [
  4135. "warehouse"=>$v['warehouse'],
  4136. "purchase"=>$v['purchase'],
  4137. "details"=>trim($v['details'],'、'),
  4138. "cpid"=>$v['cpid'],
  4139. "sku"=>$v['sku'],
  4140. "title"=>$v['title'],
  4141. "features"=>$v['pm'],
  4142. "cpbz"=>$v['cpbz'],
  4143. "sm"=>$v['sm'],
  4144. "type"=>$v['type'],
  4145. "g"=>$v["g"],
  4146. "c"=>$v["c"],
  4147. "x"=>$v["x"],
  4148. "t"=>$v["t"],
  4149. "z"=>$v["z"],
  4150. "jm"=>$v["jm"],
  4151. "weight"=>$v["weight"],
  4152. "asd"=>$v["asd"],
  4153. ];
  4154. }
  4155. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4156. $titlename = "<table border=1>
  4157. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4158. <tr align='center'>
  4159. <td>仓库</td>
  4160. <td>供应商</td>
  4161. <td>位置</td>
  4162. <td>库存编码</td>
  4163. <td>SKU</td>
  4164. <td>商品名称</td>
  4165. <td>商品中文</td>
  4166. <td>产品备注</td>
  4167. <td>说明</td>
  4168. <td>类型</td>
  4169. <td>入库总量</td>
  4170. <td>库存数量</td>
  4171. <td>销售数量</td>
  4172. <td>退货数量</td>
  4173. <td>占单数量</td>
  4174. <td>料号</td>
  4175. <td>重量</td>
  4176. <td>类目</td>
  4177. </tr>
  4178. </table>";
  4179. $filename = $title . ".xls";
  4180. $tail = "";
  4181. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4182. }
  4183. }
  4184. }
  4185. //出库+入库数据整合
  4186. public function _excelcr()
  4187. {
  4188. if (isset($_GET['excel'])) {
  4189. $type = $this->input->get('excel', true);
  4190. $category = $this->input->get('category', true);
  4191. $size = $this->input->get('size', true);
  4192. $grade = $this->input->get('grade', true);
  4193. $color = $this->input->get('color', true);
  4194. $lowe = $this->input->get('lowe', true);
  4195. $sku = $this->input->get('sku', true);
  4196. $warehouse = $this->input->get('warehouse', true);
  4197. $purchase = $this->input->get('purchase', true);
  4198. $state = $this->input->get('state', true);
  4199. $sid = $this->input->get('sid', true);
  4200. $ktime = $this->input->get('ktime', true);
  4201. $jtime = $this->input->get('jtime', true);
  4202. $ktime = strtotime($ktime);
  4203. $jtime = strtotime($jtime);
  4204. $where = "1=1";
  4205. $gj = "";
  4206. $ck = "";
  4207. if ($category) {
  4208. $where .= " and features like '%-$category-%'";
  4209. }
  4210. if ($size) {
  4211. $where .= " and features like '%-$size-%'";
  4212. }
  4213. if ($grade) {
  4214. $where .= " and features like '%-$grade-%'";
  4215. }
  4216. if ($color) {
  4217. $where .= " and features like '%-$color-%'";
  4218. }
  4219. if ($lowe) {
  4220. $where .= " and features like '%-$lowe-%'";
  4221. }
  4222. if ($warehouse) {
  4223. $where .= " and warehouse = '$warehouse'";
  4224. }
  4225. if ($purchase) {
  4226. $where .= " and purchase = '$purchase'";
  4227. }
  4228. if ($state) {
  4229. $where .= " and state = '$state'";
  4230. }
  4231. if ($sku) {
  4232. $where .= " and sku like '%$sku%'";
  4233. }
  4234. if ($ktime && $jtime) {
  4235. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4236. }
  4237. $sidwhere = '';
  4238. if ($sid) {
  4239. $sd = "";
  4240. $s = explode(',', trim($sid, ','));
  4241. foreach ($s as $value) {
  4242. $sd .= " id = " . $value . " or";
  4243. }
  4244. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4245. }
  4246. //取得信息列表
  4247. $timeread = $ktime;
  4248. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4249. $timelist = array();
  4250. for ($i = 0; $i < $timenum; $i++) {
  4251. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4252. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4253. }
  4254. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4255. //echo "<pre>";
  4256. //print_r($info_list);
  4257. //exit();
  4258. $rows = array();
  4259. $list = array();
  4260. foreach ($info_list as $key => $value) {
  4261. $thistime = $timelist;
  4262. if (isset($rows[strtolower($value['sku'])])) {
  4263. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4264. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4265. }
  4266. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4267. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4268. }
  4269. } else {
  4270. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4271. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4272. }
  4273. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4274. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4275. }
  4276. $rows[strtolower($value['sku'])] = $thistime;
  4277. }
  4278. }
  4279. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4280. <head>
  4281. <!--[if gte mso 9]><xml>
  4282. <x:ExcelWorkbook>
  4283. <x:ExcelWorksheets>
  4284. <x:ExcelWorksheet>
  4285. <x:Name>EXCEL</x:Name>
  4286. <x:WorksheetOptions>
  4287. <x:Print>
  4288. <x:ValidPrinterInfo />
  4289. </x:Print>
  4290. </x:WorksheetOptions>
  4291. </x:ExcelWorksheet>
  4292. </x:ExcelWorksheets>
  4293. </x:ExcelWorkbook>
  4294. </xml>
  4295. <![endif]-->
  4296. </head><body>";
  4297. $str .= "<table border=1><tr><td>SKU</td>";
  4298. foreach ($timelist as $k => $v) {
  4299. $str .= "<td>" . $k . "出库</td>";
  4300. $str .= "<td>" . $k . "入库</td>";
  4301. }
  4302. $str .= "</tr></table>";
  4303. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4304. foreach ($rows as $key => $val) {
  4305. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4306. foreach ($val as $k => $v) {
  4307. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4308. if ($val[$k]['r'] > 0) {
  4309. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4310. } else {
  4311. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4312. }
  4313. }
  4314. $str .= "</tr>";
  4315. }
  4316. $str .= "</table>";
  4317. $str .= "</body></html>";
  4318. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4319. header("Content-type: application/octet-stream");
  4320. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4321. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4322. header("Pragma: no-cache");
  4323. header("Expires: 0");
  4324. exit($str);
  4325. }
  4326. }
  4327. //数量调整模板导出
  4328. public function _presetout()
  4329. {
  4330. if (isset($_GET['excel'])) {
  4331. $where = "sku != 'Preset' and purchase != 0";
  4332. //数据排序
  4333. $order_str = "id desc";
  4334. if (empty($page)) {
  4335. $start = 0;
  4336. $perpage = 1;
  4337. } else {
  4338. $start = ($page - 1) * $perpage;
  4339. }
  4340. //取得信息列表
  4341. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4342. $rows = array();
  4343. $list = array();
  4344. foreach ($info_list as $value) {
  4345. $warehouse = $this->warehouse->read($value['warehouse']);
  4346. $number = $value['number'];
  4347. $ftime = time() - 15 * 24 * 3600;
  4348. $purchase = $this->purchase->read($value['purchase']);
  4349. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4350. }
  4351. $title = "库存模板";
  4352. $titlename = "<table border=1>
  4353. <tr align='center'>
  4354. <td>仓库</td>
  4355. <td>供应商编码</td>
  4356. <td>SKU</td>
  4357. <td>增减数量(正数或负数)</td>
  4358. <td>增减备注</td>
  4359. <td>扣减方式:0减少库存1删除库存</td>
  4360. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4361. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4362. </tr>
  4363. </table>";
  4364. $filename = $title . ".xls";
  4365. $tail = "";
  4366. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4367. }
  4368. }
  4369. //数量调整模板导入
  4370. public function _presetedit()
  4371. {
  4372. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4373. $config['upload_path'] = '.' . $dir;
  4374. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4375. $config['allowed_types'] = 'xls|xlsx|csv';
  4376. $config['max_size'] = 10240;
  4377. $this->load->library('upload', $config);
  4378. $this->upload->initialize($config);
  4379. if ($this->upload->do_upload('userfile')) {
  4380. $full_path = $dir . $this->upload->data('file_name');
  4381. $fileName = '.' . $full_path;
  4382. if (!file_exists($fileName)) {
  4383. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4384. exit;
  4385. } else {
  4386. require_once "./data/excel/PHPExcel/IOFactory.php";
  4387. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4388. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4389. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4390. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4391. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4392. ++$column; //如果列数大于26行
  4393. $list = array();
  4394. for ($i = 2; $i <= $row; $i++) // 行数循环
  4395. {
  4396. $data = array();
  4397. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4398. {
  4399. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4400. }
  4401. $list[] = $data;
  4402. }
  4403. }
  4404. $i = 0;
  4405. $j = 0;
  4406. $ed = array();
  4407. foreach ($list as $key => $value) {
  4408. $time = time();
  4409. if ($value['0'] == "") {
  4410. continue;
  4411. }
  4412. $warehouse = $this->warehouse->get_title($value['0']);
  4413. $purchase = $this->purchase->get_bm($value['1']);
  4414. $sku = $value['2'];
  4415. $num = $value['3']; //调整数量
  4416. $text = $value['4']; //扣减说明
  4417. $type = $value['5']; //调整方式0扣减1删除
  4418. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4419. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4420. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4421. if (!$purchase) //如果没有这个SKU
  4422. {
  4423. $ed[] = array($purchase . '-不存在此供应商编码');
  4424. $j++;
  4425. continue;
  4426. }
  4427. if (!$d) //如果没有这个SKU
  4428. {
  4429. $ed[] = array($sku . '-库存中不存在此SKU');
  4430. $j++;
  4431. continue;
  4432. }
  4433. if (!isset($warehouse['id'])) {
  4434. $ed[] = array($sku . '-仓库名错误!');
  4435. $j++;
  4436. continue;
  4437. }
  4438. if ($type != '0' && $type != '1') {
  4439. $ed[] = array($sku . '-扣减方式填写错误!');
  4440. $j++;
  4441. continue;
  4442. }
  4443. if ($num < 0) //扣减库存
  4444. {
  4445. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4446. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4447. $j++;
  4448. continue;
  4449. }
  4450. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4451. if (count($data) < abs($num)) {
  4452. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4453. $j++;
  4454. continue;
  4455. }
  4456. if ($type == 0) //如果扣减方式为 扣减库存
  4457. {
  4458. for ($i = 0; $i < abs($num); $i++) {
  4459. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4460. }
  4461. } else if ($type == 1) {
  4462. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4463. if (count($zt) > 0) {
  4464. $ed[] = array($sku . '-有在途库存无法删除!');
  4465. $j++;
  4466. continue;
  4467. }
  4468. for ($i = 0; $i < abs($num); $i++) {
  4469. $this->whlabel->remove($data[$i]['id']);
  4470. }
  4471. }
  4472. } else if ($num > 0) //增加库存
  4473. {
  4474. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4475. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4476. $j++;
  4477. continue;
  4478. }
  4479. $post['sku'] = $d['sku'];
  4480. $post['shop'] = $d['shop'];
  4481. $post['warehouse'] = $warehouse['id'];
  4482. $post['purchase'] = $purchase['id'];
  4483. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4484. $post['state'] = 0;
  4485. $post['title'] = $d['title'];
  4486. $post['number'] = $d['number'];
  4487. $post['features'] = $d['features'];
  4488. $post['enter'] = $time;
  4489. $post['time'] = $time; //操作时间
  4490. $post['rktype'] = $rktype;
  4491. for ($i = 0; $i < $num; $i++) {
  4492. $post['label'] = time() . rand(100, 999) . $i;
  4493. $this->whlabel->insert($post);
  4494. }
  4495. }
  4496. sleep(1); //防止入库时间一样,需要延迟1秒
  4497. }
  4498. if ($j > 0) {
  4499. $tt = date('Ymd', time());
  4500. $title = '库存导入错误信息-' . $tt;
  4501. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4502. $tail = "\n";
  4503. $filename = $title . ".xls";
  4504. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4505. $dir = '/data/excel/' . $time . '/';
  4506. $file_name = 'error_' . $time . rand(1000, 9999);
  4507. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4508. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4509. fwrite($myfile, $ecl);
  4510. fclose($myfile);
  4511. $error = $dir . $file_name . '.xls';
  4512. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4513. exit;
  4514. } else {
  4515. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4516. exit;
  4517. }
  4518. }
  4519. }
  4520. public function _presetedittwo(){
  4521. $data = $this->input->post(NULL, TRUE);
  4522. if(empty($list)){
  4523. $raw_data = $this->input->raw_input_stream;
  4524. // 解码 JSON
  4525. $data = json_decode($raw_data, true);
  4526. }
  4527. if(empty($data)){
  4528. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4529. }
  4530. $list = [];
  4531. if(isset($data['list'])){
  4532. $list = $data['list'];
  4533. }
  4534. $i = 0;
  4535. $j = 0;
  4536. $ed = array();
  4537. foreach ($list as $key => $value) {
  4538. $time = time();
  4539. if ($value['0'] == "") {
  4540. continue;
  4541. }
  4542. $warehouse = $this->warehouse->get_title($value['0']);
  4543. $purchase = $this->purchase->get_bm($value['1']);
  4544. $sku = $value['2'];
  4545. $num = $value['3']; //调整数量
  4546. $text = $value['4']; //扣减说明
  4547. $type = $value['5']; //调整方式0扣减1删除
  4548. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4549. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4550. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4551. if (!$purchase) //如果没有这个SKU
  4552. {
  4553. $ed[] = array($value['1'] . '-不存在此供应商编码');
  4554. $j++;
  4555. continue;
  4556. }
  4557. if (!$d) //如果没有这个SKU
  4558. {
  4559. $ed[] = array($sku . '-库存中不存在此SKU');
  4560. $j++;
  4561. continue;
  4562. }
  4563. if (!isset($warehouse['id'])) {
  4564. $ed[] = array($sku . '-仓库名错误!');
  4565. $j++;
  4566. continue;
  4567. }
  4568. if ($type != '0' && $type != '1') {
  4569. $ed[] = array($sku . '-扣减方式填写错误!');
  4570. $j++;
  4571. continue;
  4572. }
  4573. if ($num < 0) //扣减库存
  4574. {
  4575. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4576. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4577. $j++;
  4578. continue;
  4579. }
  4580. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4581. if (count($data) < abs($num)) {
  4582. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4583. $j++;
  4584. continue;
  4585. }
  4586. if ($type == 0) //如果扣减方式为 扣减库存
  4587. {
  4588. for ($i = 0; $i < abs($num); $i++) {
  4589. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4590. }
  4591. } else if ($type == 1) {
  4592. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4593. if (count($zt) > 0) {
  4594. $ed[] = array($sku . '-有在途库存无法删除!');
  4595. $j++;
  4596. continue;
  4597. }
  4598. for ($i = 0; $i < abs($num); $i++) {
  4599. $this->whlabel->remove($data[$i]['id']);
  4600. }
  4601. }
  4602. } else if ($num > 0) //增加库存
  4603. {
  4604. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4605. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4606. $j++;
  4607. continue;
  4608. }
  4609. $post['sku'] = $d['sku'];
  4610. $post['shop'] = $d['shop'];
  4611. $post['warehouse'] = $warehouse['id'];
  4612. $post['purchase'] = $purchase['id'];
  4613. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4614. $post['state'] = 0;
  4615. $post['title'] = $d['title'];
  4616. $post['number'] = $d['number'];
  4617. $post['features'] = $d['features'];
  4618. $post['enter'] = $time;
  4619. $post['time'] = $time; //操作时间
  4620. $post['rktype'] = $rktype;
  4621. $post['sku_master_id'] = $d['sku_master_id'];
  4622. $post['sku_shop_id'] = $d['sku_shop_id'];
  4623. for ($i = 0; $i < $num; $i++) {
  4624. $post['label'] = time() . rand(100, 999) . $i;
  4625. $this->whlabel->insert($post);
  4626. }
  4627. }
  4628. sleep(1); //防止入库时间一样,需要延迟1秒
  4629. }
  4630. if ($j > 0) {
  4631. $tt = date('Ymd', time());
  4632. $title = '库存导入错误信息-' . $tt;
  4633. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4634. $tail = "\n";
  4635. $filename = $title . ".xls";
  4636. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4637. $dir = '/data/excel/' . $time . '/';
  4638. $file_name = 'error_' . $time . rand(1000, 9999);
  4639. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4640. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4641. fwrite($myfile, $ecl);
  4642. fclose($myfile);
  4643. $error = $dir . $file_name . '.xls';
  4644. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4645. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4646. exit;
  4647. } else {
  4648. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4649. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4650. exit;
  4651. }
  4652. }
  4653. //笛卡儿积
  4654. function cp($ps, $sets, $list)
  4655. {
  4656. $result = array();
  4657. $j = 0;
  4658. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4659. if ($i == 0) {
  4660. $result = $sets[$i];
  4661. }
  4662. $tmp = array();
  4663. foreach ($result as $res) {
  4664. foreach ($sets[$i + 1] as $set) {
  4665. $tmp[] = $res . ',' . $set;
  4666. }
  4667. }
  4668. $result = $tmp;
  4669. }
  4670. $this->db->trans_begin();
  4671. foreach ($result as $v) {
  4672. $post = array();
  4673. $title = "";
  4674. $num = "";
  4675. $data = explode(',', $v);
  4676. for ($i = 0; $i < count($list); $i++) {
  4677. $post[$list[$i]] = $data[$i];
  4678. $typeclass = $this->typeclass->read($data[$i]);
  4679. $title = $title . $typeclass['title'] . " ";
  4680. if ($data[$i] != 0) {
  4681. $num .= $data[$i]; //所有数据ID拼接
  4682. }
  4683. }
  4684. foreach ($ps as $kp => $vp) {
  4685. $post[$kp] = $vp;
  4686. }
  4687. $post['number'] = $num;
  4688. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4689. if ($info_list) {
  4690. $j++;
  4691. } else {
  4692. $skunum = $this->whlabel->find_count();
  4693. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4694. $post['title'] = rtrim($title, ' ');
  4695. $this->whlabel->insert($post);
  4696. }
  4697. }
  4698. if ($this->db->trans_status() === FALSE) {
  4699. $this->db->trans_commit();
  4700. return NULL;
  4701. } else {
  4702. $this->db->trans_commit();
  4703. return $j;
  4704. }
  4705. }
  4706. public function _kj($arg_array)
  4707. {
  4708. if (isset($_POST['sku'])) {
  4709. $time = time();
  4710. $sku = $this->input->post('sku', true);
  4711. $warehouse = $this->input->post('warehouse', true);
  4712. $num = $this->input->post('num', true);
  4713. $text = $this->input->post('text', true);
  4714. $purchase = $this->input->post('purchase', true);
  4715. $cktype = $this->input->post('cktype', true);
  4716. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4717. if ($cktype != 1 && $text == '') {
  4718. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4719. exit;
  4720. }
  4721. if ($num > count($order)) {
  4722. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4723. exit;
  4724. } else {
  4725. for ($i = 0; $i < $num; $i++) {
  4726. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4727. }
  4728. }
  4729. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4730. exit;
  4731. }
  4732. $uid = $this->whlabel->read($arg_array[0]);
  4733. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4734. $this->data['data'] = $uid;
  4735. $this->_Template('whlabel_kj', $this->data);
  4736. }
  4737. public function _summary($arg_array)
  4738. {
  4739. $prc = array();
  4740. $purchase = $this->purchase->find_all();
  4741. foreach ($purchase as $k => $v) {
  4742. $prc[$v['id']] = $v['title'];
  4743. }
  4744. if (isset($_GET['excel'])) {
  4745. $ktime = $this->input->get('ktime', true);
  4746. $jtime = $this->input->get('jtime', true);
  4747. $ktime = strtotime($ktime);
  4748. $jtime = strtotime($jtime);
  4749. $where = "1=1";
  4750. if ($ktime && $jtime) {
  4751. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4752. }
  4753. //数据排序
  4754. $order_str = "time desc";
  4755. if (empty($page)) {
  4756. $start = 0;
  4757. $perpage = 1;
  4758. } else {
  4759. $start = ($page - 1) * $perpage;
  4760. }
  4761. //取得信息列表
  4762. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4763. foreach ($info_list as $key => $value) {
  4764. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4765. $warehouse = $this->warehouse->read($value['warehouse']);
  4766. $info_list[$key]['warehouse'] = $warehouse['title'];
  4767. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4768. $details = array();
  4769. $cpid = array();
  4770. foreach ($x as $k => $v) {
  4771. if ($v['details'] != '') {
  4772. $details[$v['details']] = $v['details'];
  4773. }
  4774. if ($v['cpid'] != 0) {
  4775. $cpid[$v['cpid']] = $v['cpid'];
  4776. }
  4777. }
  4778. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4779. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4780. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4781. $info_list[$key]['s'] = $s;
  4782. $info_list[$key]['x'] = count($x);
  4783. }
  4784. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4785. $titlename = "<table border=1>
  4786. <tr align='center'>
  4787. <td>仓库</td>
  4788. <td>供应商</td>
  4789. <td>出库位置</td>
  4790. <td>出库编码</td>
  4791. <td>SKU</td>
  4792. <td>产品名</td>
  4793. <td>总剩余库存</td>
  4794. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4795. </tr>
  4796. </table>";
  4797. $filename = $title . ".xls";
  4798. $tail = "";
  4799. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4800. }
  4801. }
  4802. //usps发货清单
  4803. public function _manifest()
  4804. {
  4805. if (isset($_POST['manifest'])) {
  4806. $wltext = $this->input->post('wltext', true);
  4807. $time = time() - 16 * 3600;
  4808. $ptime = strtotime(date('Y-m-d', $time));
  4809. $waybill = array();
  4810. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4811. foreach ($fullorder as $v) {
  4812. $waybill[$v['waybill']] = $v['waybill'];
  4813. }
  4814. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4815. foreach ($fullordersmt as $v) {
  4816. $waybill[$v['waybill']] = $v['waybill'];
  4817. }
  4818. $wltext = explode(';', $wltext);
  4819. foreach ($wltext as $v) {
  4820. if (isset($waybill[$v])) {
  4821. unset($waybill[$v]);
  4822. }
  4823. }
  4824. $data = $this->usps->get_manifest($waybill);
  4825. if (isset($data['Description'])) {
  4826. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4827. exit;
  4828. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4829. $bctime = date('Ymd', time());
  4830. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4831. echo json_encode(array('msg' => $pdf, 'success' => true));
  4832. exit;
  4833. } else {
  4834. echo json_encode(array('msg' => $data, 'success' => false));
  4835. exit;
  4836. }
  4837. }
  4838. }
  4839. public function _pdf($pdf, $title, $bctime)
  4840. {
  4841. $pdf_path = './data/pdf/' . $bctime . '/';
  4842. $file_base64 = $pdf;
  4843. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4844. $file_base64 = base64_decode($file_base64);
  4845. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4846. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4847. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4848. }
  4849. /**
  4850. *
  4851. *
  4852. *
  4853. 进销存占单异常索引
  4854. *
  4855. *
  4856. *
  4857. **/
  4858. public function _abnormal()
  4859. {
  4860. $post = $this->input->post(NULL, TRUE);
  4861. if (isset($post['page'])) {
  4862. $page = $this->input->post('page', true);
  4863. $perpage = $this->input->post('perpage', true);
  4864. $sku = $this->input->post('sku', true);
  4865. $where = "1=1";
  4866. //数据排序
  4867. $order_str = "id desc";
  4868. if (empty($page)) {
  4869. $start = 0;
  4870. $perpage = 1;
  4871. } else {
  4872. $start = ($page - 1) * $perpage;
  4873. }
  4874. //取得信息列表
  4875. $info_list = $this->whlabel->find_all($where, '*');
  4876. $rows = array();
  4877. $list = array();
  4878. foreach ($info_list as $key => $value) {
  4879. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4880. }
  4881. foreach ($rows as $value) {
  4882. $warehouse = $this->warehouse->read($value['warehouse']);
  4883. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4884. $number = $value['number'];
  4885. $ftime = time() - 15 * 24 * 3600;
  4886. if ($value['shop'] != '') {
  4887. $shop = $value['shop'];
  4888. $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');
  4889. $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');
  4890. $order = array_merge($orderdlz, $ordersmt);
  4891. $od = 0;
  4892. $a = '';
  4893. $orid = '';
  4894. foreach ($order as $v) {
  4895. $or = explode('|', ltrim($v['whlabel'], '|'));
  4896. for ($i = 0; $i < count($or); $i++) {
  4897. $orod = explode('-', $or[$i]);
  4898. if ($orod[0] == $number) {
  4899. $od += $orod[1];
  4900. }
  4901. }
  4902. $orid .= $v['number'] . '-';
  4903. }
  4904. } else {
  4905. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4906. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4907. $order = array_merge($orderdlz, $ordersmt);
  4908. $od = 0;
  4909. $a = '';
  4910. $orid = '';
  4911. $qt = array();
  4912. foreach ($order as $v) {
  4913. $or = explode('|', ltrim($v['whlabel'], '|'));
  4914. for ($i = 0; $i < count($or); $i++) {
  4915. $orod = explode('-', $or[$i]);
  4916. if ($orod[0] == $number) {
  4917. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4918. if ($czzs > 0) {
  4919. if (isset($qt[$v['shop']])) {
  4920. if ($qt[$v['shop']] < $orod[1]) {
  4921. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4922. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4923. } else {
  4924. $qt[$v['shop']] -= $orod[1];
  4925. }
  4926. } else {
  4927. $qt[$v['shop']] = $czzs;
  4928. }
  4929. } else {
  4930. $od += $orod[1];
  4931. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4932. }
  4933. }
  4934. }
  4935. }
  4936. }
  4937. $z = $od . '(' . $orid . ')'; //查看订单号
  4938. //$z = $od;
  4939. if ($od > $c) {
  4940. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4941. }
  4942. }
  4943. $listdata = array_slice($list, $start, $perpage);
  4944. $total = count($list);
  4945. $pagenum = ceil($total / $perpage);
  4946. $over = $total - ($start + $perpage);
  4947. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4948. echo json_encode($rows);
  4949. exit;
  4950. }
  4951. $this->_Template('whlabel_abnormal', $this->data);
  4952. }
  4953. /**
  4954. *
  4955. *
  4956. *
  4957. 进销存占单异常索引
  4958. *
  4959. *
  4960. *
  4961. **/
  4962. public function _error()
  4963. {
  4964. $post = $this->input->post(NULL, TRUE);
  4965. if (isset($post['page'])) {
  4966. $page = $this->input->post('page', true);
  4967. $perpage = $this->input->post('perpage', true);
  4968. $sku = $this->input->post('sku', true);
  4969. $warehouse = $this->input->post('warehouse', true);
  4970. $ktime = $this->input->post('ktime', true);
  4971. $jtime = $this->input->post('jtime', true);
  4972. $ktime = strtotime($ktime);
  4973. $jtime = strtotime($jtime);
  4974. $where = "sku != 'Preset'";
  4975. $gj = '';
  4976. if ($sku) {
  4977. $where .= " and sku like '%$sku%'";
  4978. } else {
  4979. if ($ktime && $jtime) {
  4980. $gj = " and time > '$ktime' and time < '$jtime'";
  4981. }
  4982. }
  4983. if ($warehouse) {
  4984. $where .= " and warehouse = '$warehouse'";
  4985. }
  4986. //数据排序
  4987. $order_str = "id desc";
  4988. if (empty($page)) {
  4989. $start = 0;
  4990. $perpage = 1;
  4991. } else {
  4992. $start = ($page - 1) * $perpage;
  4993. }
  4994. //取得信息列表
  4995. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4996. $rows = array();
  4997. $list = array();
  4998. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4999. // foreach ($info_list as $value)
  5000. // {
  5001. // $warehouse = $this->warehouse->read($value['warehouse']);
  5002. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5003. // $number = $value['number'];$ftime = time()-15*24*3600;
  5004. // if($c < 1)
  5005. // {
  5006. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5007. // }
  5008. // }
  5009. $warehouse_list = $this->warehouse->find_all();
  5010. $warehouse_list = array_column($warehouse_list, null, 'id');
  5011. foreach ($info_list as $value) {
  5012. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5013. 'title' => "",
  5014. ];
  5015. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5016. $number = $value['number'];
  5017. $ftime = time() - 15 * 24 * 3600;
  5018. if ($c < 1) {
  5019. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5020. }
  5021. }
  5022. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5023. // $query = $this->db->query($sql);
  5024. // $info_list = $query->result_array();
  5025. // $sql_two = "select title,id from crowd_warehouse";
  5026. // $query_two = $this->db->query($sql_two);
  5027. // $warehouse_list = $query_two->result_array();
  5028. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5029. // foreach ($info_list as $value)
  5030. // {
  5031. // if(isset($warehouse_arr[$value['warehouse']])){
  5032. // $warehouse = $warehouse_arr[$value['warehouse']];
  5033. // }else{
  5034. // $warehouse = [
  5035. // 'id'=>0,
  5036. // 'title'=>"异常",
  5037. // ];
  5038. // }
  5039. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5040. // $number = $value['number'];$ftime = time()-15*24*3600;
  5041. // if($c < 1)
  5042. // {
  5043. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5044. // }
  5045. // }
  5046. $listdata = array_slice($list, $start, $perpage);
  5047. $total = count($list);
  5048. $pagenum = ceil($total / $perpage);
  5049. $over = $total - ($start + $perpage);
  5050. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5051. echo json_encode($rows);
  5052. exit;
  5053. }
  5054. if (isset($post['s'])) {
  5055. $id_arr = $this->input->post('s');
  5056. $id_arr = explode(',', trim($id_arr, ','));
  5057. if (!$id_arr) {
  5058. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5059. exit;
  5060. }
  5061. //循环删除记录
  5062. foreach ($id_arr as $v) {
  5063. $dd = $this->whlabel->read($v);
  5064. if (!isset($dd['id'])) {
  5065. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5066. exit;
  5067. }
  5068. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5069. if (isset($zt[0])) {
  5070. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5071. exit;
  5072. }
  5073. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5074. foreach ($deldd as $vv) {
  5075. $this->whlabel->remove($vv['id']);
  5076. }
  5077. }
  5078. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5079. exit;
  5080. }
  5081. $this->_Template('whlabel_error', $this->data);
  5082. }
  5083. public function _errorexcel()
  5084. {
  5085. $post = $this->input->post(NULL, TRUE);
  5086. if (isset($_GET['page'])) {
  5087. $page = $this->input->get('page', true);
  5088. $perpage = $this->input->get('perpage', true);
  5089. $sku = $this->input->get('sku', true);
  5090. $warehouse = $this->input->get('warehouse', true);
  5091. $ktime = $this->input->get('ktime', true);
  5092. $jtime = $this->input->get('jtime', true);
  5093. $ktime = strtotime($ktime);
  5094. $jtime = strtotime($jtime);
  5095. $where = "sku != 'Preset'";
  5096. $gj = '';
  5097. if ($sku) {
  5098. $where .= " and sku like '%$sku%'";
  5099. } else {
  5100. if ($ktime && $jtime) {
  5101. $gj = " and time > '$ktime' and time < '$jtime'";
  5102. }
  5103. }
  5104. if ($warehouse) {
  5105. $where .= " and warehouse = '$warehouse'";
  5106. }
  5107. //数据排序
  5108. $order_str = "id desc";
  5109. if (empty($page)) {
  5110. $start = 0;
  5111. $perpage = 1;
  5112. } else {
  5113. $start = ($page - 1) * $perpage;
  5114. }
  5115. //取得信息列表
  5116. $rows = array();
  5117. $list = array();
  5118. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5119. foreach ($info_list as $value) {
  5120. $warehouse = $this->warehouse->read($value['warehouse']);
  5121. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5122. $number = $value['number'];
  5123. $ftime = time() - 15 * 24 * 3600;
  5124. if ($c < 1) {
  5125. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5126. }
  5127. }
  5128. $title = "0库存汇总";
  5129. $titlename = "<table border=1>
  5130. <tr align='center'>
  5131. <td>仓库</td>
  5132. <td>SKU</td>
  5133. <td>产品</td>
  5134. <td>当前库存</td>
  5135. </tr>
  5136. </table>";
  5137. $filename = $title . ".xls";
  5138. $tail = "";
  5139. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5140. }
  5141. }
  5142. /**
  5143. *
  5144. *
  5145. * 占单
  5146. *
  5147. *
  5148. **/
  5149. public function _kcyz()
  5150. {
  5151. $post = $this->input->post(NULL, TRUE);
  5152. if (isset($post['warehouse'])) {
  5153. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5154. exit; //不再使用
  5155. $warehouse = $this->input->post('warehouse', true);
  5156. $whlabel = $this->input->post('whlabel', true);
  5157. $id = $this->input->post('id', true);
  5158. $shop = $this->input->post('shop', true);
  5159. $number = $this->input->post('number', true);
  5160. if (!$whlabel || $whlabel == '|') {
  5161. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5162. exit;
  5163. }
  5164. $pp = explode('|', trim($whlabel, '|'));
  5165. $x = 0;
  5166. $save = array();
  5167. foreach ($pp as $va) {
  5168. $num = explode('-', $va);
  5169. if ($number) {
  5170. $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 = '')"); //通用
  5171. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5172. } else {
  5173. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5174. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5175. }
  5176. $x++;
  5177. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5178. $save[] = $x - 1;
  5179. continue; //提前先加X不然出错,所以要减1
  5180. }
  5181. }
  5182. if (isset($save[0])) {
  5183. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5184. exit;
  5185. } else {
  5186. echo json_encode(array('success' => true));
  5187. exit;
  5188. }
  5189. }
  5190. }
  5191. public function _db()
  5192. {
  5193. $post = $this->input->post(NULL, TRUE);
  5194. if (isset($post['page'])) {
  5195. $page = $this->input->post('page', true);
  5196. $perpage = $this->input->post('perpage', true);
  5197. $sku = $this->input->post('sku', true);
  5198. $number = $this->input->post('number', true);
  5199. $warehouse = $this->input->post('warehouse', true);
  5200. $purchase = $this->input->post('purchase', true);
  5201. $orderinfo = $this->input->post('orderinfo', true);
  5202. $waybill = $this->input->post('waybill', true);
  5203. $category = $this->input->post('category', true);
  5204. $size = $this->input->post('size', true);
  5205. $grade = $this->input->post('grade', true);
  5206. $color = $this->input->post('color', true);
  5207. $lowe = $this->input->post('lowe', true);
  5208. $state = $this->input->post('state', true);
  5209. $label = $this->input->post('label', 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 dbtime > '$timetk' and dbtime < '$timetj'";
  5217. }
  5218. if ($sku) {
  5219. $where .= " and sku = '$sku'";
  5220. }
  5221. if ($warehouse) {
  5222. $where .= " and warehouse = '$warehouse'";
  5223. if ($warehouse == 12) {
  5224. $w = 'specialstock';
  5225. } else {
  5226. $w = 'whlabel';
  5227. }
  5228. }
  5229. if ($purchase) {
  5230. $where .= " and purchase = '$purchase'";
  5231. }
  5232. if ($category) {
  5233. $where .= " and features like '%-$category-%'";
  5234. }
  5235. if ($size) {
  5236. $where .= " and features like '%-$size-%'";
  5237. }
  5238. if ($grade) {
  5239. $where .= " and features like '%-$grade-%'";
  5240. }
  5241. if ($color) {
  5242. $where .= " and features like '%-$color-%'";
  5243. }
  5244. if ($lowe) {
  5245. $where .= " and features like '%-$lowe-%'";
  5246. }
  5247. if ($state != '') {
  5248. $where .= " and state = '$state'";
  5249. }
  5250. //数据排序
  5251. $order_str = "dbtime desc";
  5252. if (empty($page)) {
  5253. $start = 0;
  5254. $perpage = 1;
  5255. } else {
  5256. $start = ($page - 1) * $perpage;
  5257. }
  5258. //取得信息列表
  5259. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5260. foreach ($info_list as $key => $value) {
  5261. $warehouse = $this->$w->read($value['warehouse']);
  5262. $info_list[$key]['warehouse'] = $warehouse['title'];
  5263. $purchase = $this->purchase->read($value['purchase']);
  5264. $info_list[$key]['purchase'] = $purchase['title'];
  5265. if ($value['enter'] != 0) {
  5266. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5267. } else {
  5268. $info_list[$key]['enter'] = "";
  5269. }
  5270. if ($value['dbtime'] != 0) {
  5271. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5272. } else {
  5273. $info_list[$key]['dbtime'] = "";
  5274. }
  5275. if ($value['state'] == 0) {
  5276. $info_list[$key]['state'] = "在库";
  5277. } else if ($value['state'] == 1) {
  5278. $info_list[$key]['state'] = "出库";
  5279. } else if ($value['state'] == 2) {
  5280. $info_list[$key]['state'] = "退库";
  5281. } else if ($value['state'] == 3) {
  5282. $info_list[$key]['state'] = "调拨中";
  5283. } else if ($value['state'] == 4) {
  5284. $info_list[$key]['state'] = "再加工";
  5285. } else if ($value['state'] == 5) {
  5286. $info_list[$key]['state'] = "维修中";
  5287. } else if ($value['state'] == 6) {
  5288. $info_list[$key]['state'] = "盘亏";
  5289. } else if ($value['state'] == 7) {
  5290. $info_list[$key]['state'] = "更换标签";
  5291. } else if ($value['state'] == 8) {
  5292. $info_list[$key]['state'] = "其它";
  5293. } else if ($value['state'] == 9) {
  5294. $info_list[$key]['state'] = "预设";
  5295. }
  5296. }
  5297. $total = $this->whlabel->find_count($where);
  5298. $pagenum = ceil($total / $perpage);
  5299. $over = $total - ($start + $perpage);
  5300. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5301. echo json_encode($rows);
  5302. exit;
  5303. }
  5304. if (isset($post['outsku'])) {
  5305. $time = time();
  5306. $cz = $this->input->post('cz', true);
  5307. $label = $this->input->post('outsku', true);
  5308. $sl = $this->input->post('sl', true);
  5309. $num = $this->input->post('num', true);
  5310. //$warehouse = $this->input->post('warehouse',true);
  5311. if (!$sl) {
  5312. $sl = 1;
  5313. }
  5314. if (!$warehouse) {
  5315. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5316. exit;
  5317. }
  5318. $dblabel = $this->whlabellabel->get_label($label);
  5319. if ($dblabel) {
  5320. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5321. if (count($data) < 1) {
  5322. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5323. exit;
  5324. }
  5325. if (count($data) < $num) {
  5326. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5327. exit;
  5328. }
  5329. for ($i = 0; $i < $sl; $i++) {
  5330. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5331. }
  5332. echo json_encode(array('success' => true));
  5333. exit;
  5334. } else {
  5335. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5336. exit;
  5337. }
  5338. }
  5339. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5340. $this->_Template('whlabel_db', $this->data);
  5341. }
  5342. public function _dbrk()
  5343. {
  5344. $post = $this->input->post(NULL, TRUE);
  5345. if (isset($post['page'])) {
  5346. $page = $this->input->post('page', true);
  5347. $perpage = $this->input->post('perpage', true);
  5348. $sku = $this->input->post('sku', true);
  5349. $number = $this->input->post('number', true);
  5350. $warehouse = $this->input->post('warehouse', true);
  5351. $purchase = $this->input->post('purchase', true);
  5352. $orderinfo = $this->input->post('orderinfo', true);
  5353. $waybill = $this->input->post('waybill', true);
  5354. $category = $this->input->post('category', true);
  5355. $size = $this->input->post('size', true);
  5356. $grade = $this->input->post('grade', true);
  5357. $color = $this->input->post('color', true);
  5358. $lowe = $this->input->post('lowe', true);
  5359. $state = $this->input->post('state', true);
  5360. $label = $this->input->post('label', true);
  5361. $ctime = $this->input->post('ctime', true);
  5362. $timetk = $this->input->post('timetkk', true);
  5363. $timetj = $this->input->post('timetjj', true);
  5364. $timetk = strtotime($timetk);
  5365. $timetj = strtotime($timetj);
  5366. $where = "dbtime > 0";
  5367. if ($timetk && $timetj) {
  5368. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5369. }
  5370. if ($sku) {
  5371. $where .= " and sku = '$sku'";
  5372. }
  5373. if ($warehouse) {
  5374. $where .= " and warehouse = '$warehouse'";
  5375. }
  5376. if ($purchase) {
  5377. $where .= " and purchase = '$purchase'";
  5378. }
  5379. if ($category) {
  5380. $where .= " and features like '%-$category-%'";
  5381. }
  5382. if ($size) {
  5383. $where .= " and features like '%-$size-%'";
  5384. }
  5385. if ($grade) {
  5386. $where .= " and features like '%-$grade-%'";
  5387. }
  5388. if ($color) {
  5389. $where .= " and features like '%-$color-%'";
  5390. }
  5391. if ($lowe) {
  5392. $where .= " and features like '%-$lowe-%'";
  5393. }
  5394. if ($state != '') {
  5395. $where .= " and state = '$state'";
  5396. }
  5397. //数据排序
  5398. $order_str = "dbtime desc";
  5399. if (empty($page)) {
  5400. $start = 0;
  5401. $perpage = 1;
  5402. } else {
  5403. $start = ($page - 1) * $perpage;
  5404. }
  5405. //取得信息列表
  5406. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5407. foreach ($info_list as $key => $value) {
  5408. $warehouse = $this->warehouse->read($value['warehouse']);
  5409. $info_list[$key]['warehouse'] = $warehouse['title'];
  5410. $purchase = $this->purchase->read($value['purchase']);
  5411. $info_list[$key]['purchase'] = $purchase['title'];
  5412. if ($value['enter'] != 0) {
  5413. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5414. } else {
  5415. $info_list[$key]['enter'] = "";
  5416. }
  5417. if ($value['dbtime'] != 0) {
  5418. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5419. } else {
  5420. $info_list[$key]['dbtime'] = "";
  5421. }
  5422. if ($value['state'] == 0) {
  5423. $info_list[$key]['state'] = "在库";
  5424. } else if ($value['state'] == 1) {
  5425. $info_list[$key]['state'] = "出库";
  5426. } else if ($value['state'] == 2) {
  5427. $info_list[$key]['state'] = "退库";
  5428. } else if ($value['state'] == 3) {
  5429. $info_list[$key]['state'] = "调拨中";
  5430. } else if ($value['state'] == 4) {
  5431. $info_list[$key]['state'] = "再加工";
  5432. } else if ($value['state'] == 5) {
  5433. $info_list[$key]['state'] = "维修中";
  5434. } else if ($value['state'] == 6) {
  5435. $info_list[$key]['state'] = "盘亏";
  5436. } else if ($value['state'] == 7) {
  5437. $info_list[$key]['state'] = "更换标签";
  5438. } else if ($value['state'] == 8) {
  5439. $info_list[$key]['state'] = "其它";
  5440. } else if ($value['state'] == 9) {
  5441. $info_list[$key]['state'] = "预设";
  5442. }
  5443. }
  5444. $total = $this->whlabel->find_count($where);
  5445. $pagenum = ceil($total / $perpage);
  5446. $over = $total - ($start + $perpage);
  5447. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5448. echo json_encode($rows);
  5449. exit;
  5450. }
  5451. if (isset($post['rsku'])) {
  5452. $cz = $this->input->post('cz', true);
  5453. $label = $this->input->post('rsku', true);
  5454. $sl = $this->input->post('sl', true);
  5455. $warehouse = $this->input->post('warehouse', true);
  5456. if (!$sl) {
  5457. $sl = 1;
  5458. }
  5459. if (!$warehouse) {
  5460. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5461. exit;
  5462. }
  5463. $dblabel = $this->whlabellabel->get_label($label);
  5464. if ($dblabel) {
  5465. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5466. if (count($data) < 1) {
  5467. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5468. exit;
  5469. }
  5470. if ($sl > count($data)) {
  5471. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5472. exit;
  5473. }
  5474. $time = time();
  5475. for ($i = 0; $i < $sl; $i++) {
  5476. $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']);
  5477. }
  5478. echo json_encode(array('success' => true));
  5479. exit;
  5480. } else {
  5481. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5482. exit;
  5483. }
  5484. }
  5485. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5486. $this->_Template('whlabel_dbrk', $this->data);
  5487. }
  5488. public function _whlabelczdc()
  5489. {
  5490. if (isset($_GET['excel'])) {
  5491. //数据排序
  5492. $order_str = "id desc";
  5493. if (empty($page)) {
  5494. $start = 0;
  5495. $perpage = 1;
  5496. } else {
  5497. $start = ($page - 1) * $perpage;
  5498. }
  5499. $state = $this->input->get('state', true);
  5500. $sku = $this->input->get('sku', true);
  5501. $ctime = $this->input->get('ctime', true);
  5502. $category = $this->input->get('category', true);
  5503. $size = $this->input->get('size', true);
  5504. $grade = $this->input->get('grade', true);
  5505. $color = $this->input->get('color', true);
  5506. $lowe = $this->input->get('lowe', true);
  5507. $timetk = $this->input->get('timetkk', true);
  5508. $timetj = $this->input->get('timetjj', true);
  5509. $timetk = strtotime($timetk);
  5510. $timetj = strtotime($timetj);
  5511. $where = "dbtime > 0";
  5512. if ($timetk && $timetj) {
  5513. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5514. }
  5515. if ($category) {
  5516. $where .= " and features like '%-$category-%'";
  5517. }
  5518. if ($size) {
  5519. $where .= " and features like '%-$size-%'";
  5520. }
  5521. if ($grade) {
  5522. $where .= " and features like '%-$grade-%'";
  5523. }
  5524. if ($color) {
  5525. $where .= " and features like '%-$color-%'";
  5526. }
  5527. if ($lowe) {
  5528. $where .= " and features like '%-$lowe-%'";
  5529. }
  5530. //取得信息列表
  5531. $info_list = $this->whlabel->find_all($where, '*');
  5532. $rows = array();
  5533. $list = array();
  5534. foreach ($info_list as $key => $value) {
  5535. $rows[$value['sku']] = $value; //所有数据sku
  5536. }
  5537. foreach ($rows as $value) {
  5538. $warehouse = $this->warehouse->read($value['warehouse']);
  5539. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5540. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5541. if ($value['orderinfo'] == 0) {
  5542. $info_list[$key]['orderinfo'] = "";
  5543. }
  5544. if ($value['waybill'] == 0) {
  5545. $info_list[$key]['waybill'] = "";
  5546. }
  5547. if ($value['state'] == 0) {
  5548. $value['state'] = "在库";
  5549. } else if ($value['state'] == 3) {
  5550. $value['state'] = "调拨中";
  5551. }
  5552. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5553. }
  5554. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5555. $titlename = "<table border=1>
  5556. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5557. <tr align='center'>
  5558. <td>SKU</td>
  5559. <td>产品</td>
  5560. <td>调拨数量</td>
  5561. <td>入库数量</td>
  5562. </tr>
  5563. </table>";
  5564. $filename = $title . ".xls";
  5565. $tail = "";
  5566. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5567. }
  5568. }
  5569. public function _print($arg_array)
  5570. {
  5571. if (isset($_SESSION['api'])) {
  5572. $user = $this->user->get_api($_SESSION['api']);
  5573. $usp = $user;
  5574. $fgshop = "";
  5575. $sid = "";
  5576. $wid = "";
  5577. $wtype = "";
  5578. $usersp = explode('|', trim($user['shop'], '|'));
  5579. $userwh = explode('|', trim($user['warehouse'], '|'));
  5580. foreach ($usersp as $value) {
  5581. $fgshop .= " shop = " . $value . " or";
  5582. $sid .= " id = " . $value . " or";
  5583. }
  5584. foreach ($userwh as $value) {
  5585. $wid .= " id = " . $value . " or";
  5586. $wtype .= " type = " . $value . " or";
  5587. }
  5588. }
  5589. $post = $this->input->post(NULL, TRUE);
  5590. if (isset($post['tmsku'])) {
  5591. $tmsku = $this->input->post('tmsku', true);
  5592. if (is_numeric($tmsku)) {
  5593. $yyh = $this->whlabellabel->get_label($tmsku);
  5594. } else {
  5595. $yyh = $this->whlabellabel->get_sku($tmsku);
  5596. if(empty($yyh)){
  5597. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  5598. if($r['code'] == -1 ){
  5599. echo json_encode(array('success' => false));
  5600. exit;
  5601. }else{
  5602. echo json_encode(array('features' => $r['data'], 'success' => true));
  5603. exit;
  5604. }
  5605. }
  5606. }
  5607. if ($yyh) {
  5608. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5609. exit;
  5610. } else {
  5611. echo json_encode(array('success' => false));
  5612. exit;
  5613. }
  5614. }
  5615. $classid = $this->classid->sku();
  5616. $pm = $classid;
  5617. $scsku = $classid;
  5618. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5619. if (isset($post['warehouse'])) {
  5620. if ($post['warehouse']) {
  5621. $list = array();
  5622. $num = "";
  5623. $title = "";
  5624. $features = "";
  5625. $order = 0;
  5626. $post['shop'] = '';
  5627. $brand = $this->input->post('brand', true);
  5628. if ($brand != '0,') {
  5629. $b = $this->brand->read(rtrim($brand, ','));
  5630. if ($b) {
  5631. $post['shop'] = str_replace('|', ',', $b['shop']);
  5632. }
  5633. }
  5634. $post['details'] = $this->input->post('details', true); //打印数量
  5635. $xbqnum = $this->input->post('xbqnum', true);
  5636. $post['purchase'] = $this->input->post('purchase', true);
  5637. $post['warehouse'] = $this->input->post('warehouse', true);
  5638. $post['purchase'] = $this->input->post('purchase', true);
  5639. $post['retreatwarehouse'] = $post['warehouse'];
  5640. $post['cpbz'] = $this->input->post('cpbz', true);
  5641. $post['state'] = 9;
  5642. $category = $this->input->post('category', true);
  5643. $list['category'] = $category;
  5644. $list['hairtype'] = $this->input->post('hairtype', true);
  5645. $list['grade'] = $this->input->post('grade', true);
  5646. $size = $this->input->post('size', true);
  5647. $list['size'] = rtrim($size, ',');
  5648. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5649. $list['extension'] = $this->input->post('extension', true);
  5650. if ($category == 1297) {
  5651. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5652. }
  5653. if ($category == 1702) {
  5654. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5655. $list['syother'] = $this->input->post('syother', true);
  5656. }
  5657. if ($category == 133) {
  5658. $list['fittype'] = $this->input->post('fittype', true);
  5659. $list['acother'] = $this->input->post('acother', true);
  5660. }
  5661. $list['color'] = $this->input->post('color', true);
  5662. $list['lowe'] = $this->input->post('lowe', true);
  5663. if ($category == 127) {
  5664. $list['type'] = $this->input->post('type', true);
  5665. $list['headroad'] = $this->input->post('headroad', true);
  5666. $list['density'] = $this->input->post('density', true);
  5667. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5668. $list['lacesize'] = $this->input->post('lacesize', true);
  5669. }
  5670. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5671. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5672. }
  5673. if ($category == 128) {
  5674. $list['lacetype'] = $this->input->post('lacetype', true);
  5675. $list['haircap'] = $this->input->post('haircap', true);
  5676. $list['density'] = $this->input->post('density', true);
  5677. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5678. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5679. $list['wigother'] = $this->input->post('wigother', true);
  5680. $list['wigother1'] = $this->input->post('wigother1', true);
  5681. $list['wigother2'] = $this->input->post('wigother2', true);
  5682. }
  5683. if ($category == 129) {
  5684. $list['wide'] = $this->input->post('wide', true);
  5685. }
  5686. if ($category == 131) {
  5687. $list['gifttype'] = $this->input->post('gifttype', true);
  5688. $list['giftother'] = $this->input->post('giftother', true);
  5689. }
  5690. if ($category == 134) {
  5691. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5692. }
  5693. if ($category == 1297) {
  5694. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5695. $list['sywigother'] = $this->input->post('sywigother', true);
  5696. }
  5697. if ($category == 130 || $category == 133 || $category == 1702) {
  5698. $list['items'] = $this->input->post('items', true);
  5699. $list['weight'] = $this->input->post('weight', true);
  5700. }
  5701. if ($category == 1702) {
  5702. $list['syhairther'] = $this->input->post('syhairther', true);
  5703. }
  5704. if($category == 130){
  5705. $list['jfother'] = $this->input->post('jfother', true);
  5706. }
  5707. foreach ($list as $k => $v) {
  5708. if ($v != 0) {
  5709. $num .= $v;
  5710. $features .= $v . '-';
  5711. $post[$k] = $v;
  5712. $typeclass = $this->typeclass->read($v);
  5713. if (isset($pm[$typeclass['classid']])) {
  5714. if (stripos($typeclass['zh'], '|') !== false) {
  5715. $exzh = explode('|', $typeclass['zh']);
  5716. $pm[$typeclass['classid']] = $exzh[0];
  5717. } else {
  5718. $pm[$typeclass['classid']] = $typeclass['zh'];
  5719. }
  5720. }
  5721. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5722. if ($k != 'size') {
  5723. $title .= $typeclass['title'] . " ";
  5724. }
  5725. }
  5726. }
  5727. $typeclass = $this->typeclass->read($list['size']);
  5728. $title .= $typeclass['title'];
  5729. $time = time();
  5730. $post['title'] = rtrim($title, ' ');
  5731. $post['number'] = $num;
  5732. $post['features'] = '-' . $features;
  5733. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5734. $featurespp = explode('-', trim($featurespp, '-'));
  5735. if (isset($featurespp[5])) {
  5736. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5737. } else {
  5738. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5739. }
  5740. $post['enter'] = $time;
  5741. $post['time'] = $time; //操作时间
  5742. $scsku = implode("-", $scsku);
  5743. $zh = implode(" ", $pm);
  5744. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5745. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5746. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5747. $post['sku'] = $bqsku;
  5748. $label = time() . rand(0, 9);
  5749. $post['label'] = $label;
  5750. $cpid = $this->whlabellabel->find_count();
  5751. $post['cpid'] = $cpid + 1;
  5752. $cpid = $post['cpid'];
  5753. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5754. //if($whlabelbarcode)
  5755. //{
  5756. //$post['label'] = $whlabelbarcode['label'];
  5757. //if(!$this->whlabellabel->insert($post))
  5758. //{
  5759. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5760. //}
  5761. //}
  5762. //else
  5763. //{
  5764. $this->db->trans_begin();
  5765. $this->whlabellabel->insert($post);
  5766. //$this->whlabelbarcode->insert($post);
  5767. if ($this->db->trans_status() === TRUE) {
  5768. $this->db->trans_commit();
  5769. } else {
  5770. $this->db->trans_rollback();
  5771. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5772. exit;
  5773. }
  5774. //}
  5775. $warehouse_name = "";
  5776. $warehouse = $post['warehouse'];
  5777. if($warehouse == 12){
  5778. $warehouse_name = "特殊库存库";
  5779. }
  5780. // if($warehouse == 13){
  5781. // $warehouse_name = "许昌仓";
  5782. // }
  5783. // if($warehouse == 5){
  5784. // $warehouse_name = "美国店";
  5785. // }
  5786. // if($warehouse == 16){
  5787. // $warehouse_name = "定制头套仓";
  5788. // }
  5789. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5790. if(!empty($warehouse_name)){
  5791. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5792. }
  5793. $purchase = $this->purchase->read($post['purchase']);
  5794. 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));
  5795. exit; //特殊仓目前不需要仓库选项
  5796. }
  5797. }
  5798. if (isset($_SESSION['api'])) {
  5799. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5800. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5801. $this->data['wlshop'] = $wlshop;
  5802. $this->data['warehouse'] = $warehouse;
  5803. }
  5804. $whlabelwz = $this->whlabelwz->find_all();
  5805. $this->data['whlabelwz'] = $whlabelwz;
  5806. $this->_Template('whlabel_print', $this->data);
  5807. }
  5808. public function _usaprint($arg_array)
  5809. {
  5810. if (isset($_SESSION['api'])) {
  5811. $user = $this->user->get_api($_SESSION['api']);
  5812. $usp = $user;
  5813. $fgshop = "";
  5814. $sid = "";
  5815. $wid = "";
  5816. $wtype = "";
  5817. $usersp = explode('|', trim($user['shop'], '|'));
  5818. $userwh = explode('|', trim($user['warehouse'], '|'));
  5819. foreach ($usersp as $value) {
  5820. $fgshop .= " shop = " . $value . " or";
  5821. $sid .= " id = " . $value . " or";
  5822. }
  5823. foreach ($userwh as $value) {
  5824. $wid .= " id = " . $value . " or";
  5825. $wtype .= " type = " . $value . " or";
  5826. }
  5827. }
  5828. $post = $this->input->post(NULL, TRUE);
  5829. if (isset($post['tmsku'])) {
  5830. $tmsku = $this->input->post('tmsku', true);
  5831. if (is_numeric($tmsku)) {
  5832. $yyh = $this->whlabellabel->get_label($tmsku);
  5833. } else {
  5834. $yyh = $this->whlabellabel->get_sku($tmsku);
  5835. }
  5836. if ($yyh) {
  5837. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5838. exit;
  5839. } else {
  5840. echo json_encode(array('success' => false));
  5841. exit;
  5842. }
  5843. }
  5844. $classid = $this->classid->sku();
  5845. $pm = $classid;
  5846. $scsku = $classid;
  5847. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5848. if (isset($post['warehouse'])) {
  5849. if ($post['warehouse']) {
  5850. $list = array();
  5851. $num = "";
  5852. $title = "";
  5853. $features = "";
  5854. $order = 0;
  5855. $post['shop'] = '';
  5856. $brand = $this->input->post('brand', true);
  5857. if ($brand != '0,') {
  5858. $b = $this->brand->read(rtrim($brand, ','));
  5859. if ($b) {
  5860. $post['shop'] = str_replace('|', ',', $b['shop']);
  5861. }
  5862. }
  5863. $post['details'] = $this->input->post('details', true); //打印数量
  5864. $xbqnum = $this->input->post('xbqnum', true);
  5865. $post['purchase'] = $this->input->post('purchase', true);
  5866. $post['warehouse'] = $this->input->post('warehouse', true);
  5867. $post['purchase'] = $this->input->post('purchase', true);
  5868. $post['retreatwarehouse'] = $post['warehouse'];
  5869. $post['cpbz'] = $this->input->post('cpbz', true);
  5870. $post['state'] = 9;
  5871. $category = $this->input->post('category', true);
  5872. $list['category'] = $category;
  5873. $list['hairtype'] = $this->input->post('hairtype', true);
  5874. $list['grade'] = $this->input->post('grade', true);
  5875. $size = $this->input->post('size', true);
  5876. $list['size'] = rtrim($size, ',');
  5877. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5878. $list['extension'] = $this->input->post('extension', true);
  5879. if ($category == 1297) {
  5880. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5881. }
  5882. if ($category == 1702) {
  5883. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5884. $list['syother'] = $this->input->post('syother', true);
  5885. }
  5886. if ($category == 133) {
  5887. $list['fittype'] = $this->input->post('fittype', true);
  5888. $list['acother'] = $this->input->post('acother', true);
  5889. }
  5890. $list['color'] = $this->input->post('color', true);
  5891. $list['lowe'] = $this->input->post('lowe', true);
  5892. if ($category == 127) {
  5893. $list['type'] = $this->input->post('type', true);
  5894. $list['headroad'] = $this->input->post('headroad', true);
  5895. $list['density'] = $this->input->post('density', true);
  5896. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5897. $list['lacesize'] = $this->input->post('lacesize', true);
  5898. }
  5899. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5900. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5901. }
  5902. if ($category == 128) {
  5903. $list['lacetype'] = $this->input->post('lacetype', true);
  5904. $list['haircap'] = $this->input->post('haircap', true);
  5905. $list['density'] = $this->input->post('density', true);
  5906. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5907. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5908. $list['wigother'] = $this->input->post('wigother', true);
  5909. $list['wigother1'] = $this->input->post('wigother1', true);
  5910. $list['wigother2'] = $this->input->post('wigother2', true);
  5911. }
  5912. if ($category == 129) {
  5913. $list['wide'] = $this->input->post('wide', true);
  5914. }
  5915. if ($category == 131) {
  5916. $list['gifttype'] = $this->input->post('gifttype', true);
  5917. $list['giftother'] = $this->input->post('giftother', true);
  5918. }
  5919. if ($category == 134) {
  5920. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5921. }
  5922. if ($category == 1297) {
  5923. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5924. $list['sywigother'] = $this->input->post('sywigother', true);
  5925. }
  5926. if ($category == 130 || $category == 133 || $category == 1702) {
  5927. $list['items'] = $this->input->post('items', true);
  5928. $list['weight'] = $this->input->post('weight', true);
  5929. }
  5930. if ($category == 1702) {
  5931. $list['syhairther'] = $this->input->post('syhairther', true);
  5932. }
  5933. foreach ($list as $k => $v) {
  5934. if ($v != 0) {
  5935. $num .= $v;
  5936. $features .= $v . '-';
  5937. $post[$k] = $v;
  5938. $typeclass = $this->typeclass->read($v);
  5939. if (isset($pm[$typeclass['classid']])) {
  5940. if (stripos($typeclass['zh'], '|') !== false) {
  5941. $exzh = explode('|', $typeclass['zh']);
  5942. $pm[$typeclass['classid']] = $exzh[0];
  5943. } else {
  5944. $pm[$typeclass['classid']] = $typeclass['zh'];
  5945. }
  5946. }
  5947. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5948. if ($k != 'size') {
  5949. $title .= $typeclass['title'] . " ";
  5950. }
  5951. }
  5952. }
  5953. $typeclass = $this->typeclass->read($list['size']);
  5954. $title .= $typeclass['title'];
  5955. $time = time();
  5956. $post['title'] = rtrim($title, ' ');
  5957. $post['number'] = $num;
  5958. $post['features'] = '-' . $features;
  5959. $fp = $this->whlabel->get_features($post['features']);
  5960. if (!$fp) {
  5961. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5962. exit;
  5963. }
  5964. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5965. $featurespp = explode('-', trim($featurespp, '-'));
  5966. if (isset($featurespp[5])) {
  5967. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5968. } else {
  5969. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5970. }
  5971. $post['enter'] = $time;
  5972. $post['time'] = $time; //操作时间
  5973. $scsku = implode("-", $scsku);
  5974. $zh = implode(" ", $pm);
  5975. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5976. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5977. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5978. $post['sku'] = $fp['sku'];
  5979. $post['label'] = $fp['sku'];
  5980. $cpid = $this->whlabellabel->find_count();
  5981. $post['cpid'] = $cpid + 1;
  5982. $cpid = $post['cpid'];
  5983. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5984. //if($whlabelbarcode)
  5985. //{
  5986. //$post['label'] = $whlabelbarcode['label'];
  5987. //if(!$this->whlabellabel->insert($post))
  5988. //{
  5989. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5990. //}
  5991. //}
  5992. //else
  5993. //{
  5994. $this->db->trans_begin();
  5995. $this->whlabellabel->insert($post);
  5996. //$this->whlabelbarcode->insert($post);
  5997. if ($this->db->trans_status() === TRUE) {
  5998. $this->db->trans_commit();
  5999. } else {
  6000. $this->db->trans_rollback();
  6001. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6002. exit;
  6003. }
  6004. //}
  6005. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6006. $purchase = $this->purchase->read($post['purchase']);
  6007. 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));
  6008. exit; //特殊仓目前不需要仓库选项
  6009. }
  6010. }
  6011. if (isset($_SESSION['api'])) {
  6012. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6013. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6014. $this->data['wlshop'] = $wlshop;
  6015. $this->data['warehouse'] = $warehouse;
  6016. }
  6017. $whlabelwz = $this->whlabelwz->find_all();
  6018. $this->data['whlabelwz'] = $whlabelwz;
  6019. $this->_Template('whlabel_usaprint', $this->data);
  6020. }
  6021. public function _printrk($arg_array)
  6022. {
  6023. $prc = array();
  6024. $purchase = $this->purchase->find_all();
  6025. foreach ($purchase as $k => $v) {
  6026. $prc[$v['id']] = $v['title'];
  6027. }
  6028. $post = $this->input->post(NULL, TRUE);
  6029. if (isset($post['page'])) {
  6030. $page = $this->input->post('page', true);
  6031. $perpage = $this->input->post('perpage', true);
  6032. $sku = $this->input->post('sku', true);
  6033. $bs = $this->input->post('bs', true);
  6034. $number = $this->input->post('number', true);
  6035. $warehouse = $this->input->post('warehouse', true);
  6036. $purchase = $this->input->post('purchase', true);
  6037. $orderinfo = $this->input->post('orderinfo', true);
  6038. $waybill = $this->input->post('waybill', true);
  6039. $category = $this->input->post('category', true);
  6040. $size = $this->input->post('size', true);
  6041. $grade = $this->input->post('grade', true);
  6042. $color = $this->input->post('color', true);
  6043. $lowe = $this->input->post('lowe', true);
  6044. $state = $this->input->post('state', true);
  6045. $label = $this->input->post('label', true);
  6046. $timetk = $this->input->post('ktime', true);
  6047. $timetj = $this->input->post('jtime', true);
  6048. $timetk = strtotime($timetk);
  6049. $timetj = strtotime($timetj);
  6050. $where = "1=1 ";
  6051. if ($timetk && $timetj) {
  6052. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6053. }
  6054. if ($sku) {
  6055. $where .= " and sku = '$sku'";
  6056. }
  6057. if ($bs != '') {
  6058. $where .= " and bs = '$bs'";
  6059. }
  6060. if ($number) {
  6061. $where .= " and number = '$number'";
  6062. }
  6063. if ($warehouse) {
  6064. $where .= " and warehouse = '$warehouse'";
  6065. }
  6066. if ($purchase) {
  6067. $where .= " and purchase = '$purchase'";
  6068. }
  6069. if ($orderinfo) {
  6070. $where .= " and orderinfo = '$orderinfo'";
  6071. }
  6072. if ($waybill) {
  6073. $where .= " and waybill = '$waybill'";
  6074. }
  6075. if ($category) {
  6076. $where .= " and features like '%-$category-%'";
  6077. }
  6078. if ($size) {
  6079. $where .= " and features like '%-$size-%'";
  6080. }
  6081. if ($grade) {
  6082. $where .= " and features like '%-$grade-%'";
  6083. }
  6084. if ($color) {
  6085. $where .= " and features like '%-$color-%'";
  6086. }
  6087. if ($lowe) {
  6088. $where .= " and features like '%-$lowe-%'";
  6089. }
  6090. if ($label) {
  6091. $where .= " and label = '$label'";
  6092. }
  6093. if ($state || $state == 0) {
  6094. $where .= " and state = '$state'";
  6095. }
  6096. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6097. //数据排序
  6098. $order_str = "enter desc";
  6099. if (empty($page)) {
  6100. $start = 0;
  6101. $perpage = 1;
  6102. } else {
  6103. $start = ($page - 1) * $perpage;
  6104. }
  6105. //取得信息列表
  6106. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6107. foreach ($info_list as $key => $value) {
  6108. $warehouse = $this->warehouse->read($value['warehouse']);
  6109. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6110. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6111. if ($value['state'] == 0) {
  6112. $info_list[$key]['state'] = "在库";
  6113. } else if ($value['state'] == 1) {
  6114. $info_list[$key]['state'] = "出库";
  6115. } else if ($value['state'] == 2) {
  6116. $info_list[$key]['state'] = "退库";
  6117. } else if ($value['state'] == 3) {
  6118. $info_list[$key]['state'] = "调拨中";
  6119. } else if ($value['state'] == 4) {
  6120. $info_list[$key]['state'] = "再加工";
  6121. } else if ($value['state'] == 5) {
  6122. $info_list[$key]['state'] = "维修中";
  6123. } else if ($value['state'] == 6) {
  6124. $info_list[$key]['state'] = "盘亏";
  6125. } else if ($value['state'] == 7) {
  6126. $info_list[$key]['state'] = "更换标签";
  6127. } else if ($value['state'] == 8) {
  6128. $info_list[$key]['state'] = "其它";
  6129. } else if ($value['state'] == 9) {
  6130. $info_list[$key]['state'] = "预设";
  6131. } else if ($value['state'] == 10) {
  6132. $info_list[$key]['state'] = "美店零售";
  6133. }
  6134. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6135. }
  6136. $total = $this->$ck->find_count($where);
  6137. $pagenum = ceil($total / $perpage);
  6138. $over = $total - ($start + $perpage);
  6139. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6140. echo json_encode($rows);
  6141. exit;
  6142. }
  6143. if (isset($post['tmsku'])) {
  6144. $time = time();
  6145. $tmsku = $this->input->post('tmsku', true);
  6146. //$post['shop'] = $this->input->post('shop',true);
  6147. $num = $this->input->post('num', true);
  6148. $rktype = $this->input->post('rktype', true);
  6149. if ($num > 200) {
  6150. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6151. exit;
  6152. }
  6153. if (!$rktype) {
  6154. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6155. }
  6156. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6157. /**
  6158. $wz = array();
  6159. foreach ($rk as $key=>$value)
  6160. {
  6161. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6162. }
  6163. if(count($wz) > 1)
  6164. {
  6165. $wz = array_values($wz);
  6166. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6167. }
  6168. **/
  6169. if (isset($rk[0]['purchase'])) {
  6170. $rk = $rk[0];
  6171. $j = 0;
  6172. $post['purchase'] = $rk['purchase'];
  6173. $post['warehouse'] = $rk['warehouse'];
  6174. $post['retreatwarehouse'] = $rk['warehouse'];
  6175. $post['sku'] = $rk['sku'];
  6176. $post['number'] = $rk['number'];
  6177. $post['features'] = $rk['features'];
  6178. $post['title'] = $rk['title'];
  6179. $post['enter'] = $time;
  6180. $post['time'] = $time;
  6181. $post['bs'] = 1;
  6182. $post['shop'] = $rk['shop'];
  6183. $post['details'] = $rk['details'];
  6184. $post['cpid'] = $rk['cpid'];
  6185. $post['cpbz'] = $rk['cpbz'];
  6186. $post['rktype'] = $rktype;
  6187. $warehouse = $this->warehouse->read($rk['warehouse']);
  6188. if ($warehouse['bdck'] == '') {
  6189. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6190. exit;
  6191. } else {
  6192. $bdck = $warehouse['bdck'];
  6193. }
  6194. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6195. if (isset($pdwz['details'])) {
  6196. if ($pdwz['details'] != $post['details']) {
  6197. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6198. exit;
  6199. }
  6200. }
  6201. $post['featurespp'] = $rk['featurespp'];
  6202. if ($post['warehouse'] == '5') {
  6203. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6204. if ($yza) {
  6205. if ($post['features'] != $yza[0]['features']) {
  6206. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6207. exit;
  6208. }
  6209. }
  6210. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6211. if ($yzb) {
  6212. if ($post['sku'] != $yzb[0]['sku']) {
  6213. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6214. exit;
  6215. }
  6216. }
  6217. }
  6218. for ($i = 0; $i < $num; $i++) {
  6219. $post['label'] = time() . rand(100, 999) . $i;
  6220. if ($this->$bdck->insert($post)) {
  6221. $j++;
  6222. }
  6223. }
  6224. /**
  6225. if($post['warehouse'] != 12)
  6226. {
  6227. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6228. }
  6229. **/
  6230. $this->whlabelscanlog->insert([
  6231. 'shop'=>$rk['shop'],
  6232. 'type'=>1,
  6233. 'purchase'=>$rk['purchase'],
  6234. 'sku'=>$rk['sku'],
  6235. 'features'=>$rk['features'],
  6236. 'title'=>$rk['title'],
  6237. 'label'=>$rk['label'],
  6238. 'warehouse'=>$rk['warehouse'],
  6239. 'wlid'=>$rk['id'],
  6240. 'num'=>$num,
  6241. 'addtime'=>time()
  6242. ]);
  6243. if ($j == $num) {
  6244. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6245. exit;
  6246. } else {
  6247. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6248. exit;
  6249. }
  6250. } else {
  6251. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6252. exit;
  6253. }
  6254. }
  6255. $this->_Template('whlabel_printrk', $this->data);
  6256. }
  6257. public function _printxzrk($arg_array)
  6258. {
  6259. $post = $this->input->post(NULL, TRUE);
  6260. if (isset($post['wzid'])) {
  6261. $time = time();
  6262. $id = $this->input->post('wzid', true);
  6263. //$post['shop'] = $this->input->post('shop',true);
  6264. $num = 1;
  6265. $rk = $this->whlabellabel->read($id);
  6266. if (isset($rk['purchase'])) {
  6267. $x = 0;
  6268. $post['purchase'] = $rk['purchase'];
  6269. $post['warehouse'] = $rk['warehouse'];
  6270. $post['retreatwarehouse'] = $rk['warehouse'];
  6271. $post['sku'] = $rk['sku'];
  6272. $post['number'] = $rk['number'];
  6273. $post['features'] = $rk['features'];
  6274. $post['title'] = $rk['title'];
  6275. $post['enter'] = $time;
  6276. $post['time'] = $time;
  6277. $post['bs'] = 1;
  6278. $post['shop'] = $rk['shop'];
  6279. $post['details'] = $rk['details'];
  6280. $post['cpid'] = $rk['cpid'];
  6281. $post['cpbz'] = $rk['cpbz'];
  6282. $warehouse = $this->warehouse->read($rk['warehouse']);
  6283. if ($warehouse['bdck'] == '') {
  6284. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6285. exit;
  6286. } else {
  6287. $bdck = $warehouse['bdck'];
  6288. }
  6289. $post['featurespp'] = $rk['featurespp'];
  6290. $this->db->trans_begin();
  6291. for ($i = 0; $i < $num; $i++) {
  6292. $post['label'] = time() . rand(100, 999) . $i;
  6293. $this->$bdck->insert($post);
  6294. }
  6295. /**
  6296. if($post['warehouse'] != 12)
  6297. {
  6298. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6299. }
  6300. **/
  6301. if ($this->db->trans_status() === TRUE) {
  6302. $this->db->trans_commit();
  6303. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6304. exit;
  6305. } else {
  6306. $this->db->trans_rollback();
  6307. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6308. exit;
  6309. }
  6310. } else {
  6311. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6312. exit;
  6313. }
  6314. }
  6315. }
  6316. public function _printck($arg_array)
  6317. {
  6318. $prc = array();
  6319. $purchase = $this->purchase->find_all();
  6320. foreach ($purchase as $k => $v) {
  6321. $prc[$v['id']] = $v['title'];
  6322. }
  6323. $post = $this->input->post(NULL, TRUE);
  6324. if (isset($post['page'])) {
  6325. $page = $this->input->post('page', true);
  6326. $perpage = $this->input->post('perpage', true);
  6327. $sku = $this->input->post('sku', true);
  6328. $bs = $this->input->post('bs', true);
  6329. $number = $this->input->post('number', true);
  6330. $warehouse = $this->input->post('warehouse', true);
  6331. $purchase = $this->input->post('purchase', true);
  6332. $orderinfo = $this->input->post('orderinfo', true);
  6333. $waybill = $this->input->post('waybill', true);
  6334. $category = $this->input->post('category', true);
  6335. $size = $this->input->post('size', true);
  6336. $grade = $this->input->post('grade', true);
  6337. $color = $this->input->post('color', true);
  6338. $lowe = $this->input->post('lowe', true);
  6339. $state = $this->input->post('state', true);
  6340. $label = $this->input->post('label', true);
  6341. $timetk = $this->input->post('ktime', true);
  6342. $timetj = $this->input->post('jtime', true);
  6343. $timetk = strtotime($timetk);
  6344. $timetj = strtotime($timetj);
  6345. $where = "state=1 ";
  6346. if ($timetk && $timetj) {
  6347. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6348. }
  6349. if ($sku) {
  6350. $where .= " and sku = '$sku'";
  6351. }
  6352. if ($bs != '') {
  6353. $where .= " and bs = '$bs'";
  6354. }
  6355. if ($number) {
  6356. $where .= " and number = '$number'";
  6357. }
  6358. if ($warehouse) {
  6359. $where .= " and warehouse = '$warehouse'";
  6360. }
  6361. if ($purchase) {
  6362. $where .= " and purchase = '$purchase'";
  6363. }
  6364. if ($orderinfo) {
  6365. $where .= " and orderinfo = '$orderinfo'";
  6366. }
  6367. if ($waybill) {
  6368. $where .= " and waybill = '$waybill'";
  6369. }
  6370. if ($category) {
  6371. $where .= " and features like '%-$category-%'";
  6372. }
  6373. if ($size) {
  6374. $where .= " and features like '%-$size-%'";
  6375. }
  6376. if ($grade) {
  6377. $where .= " and features like '%-$grade-%'";
  6378. }
  6379. if ($color) {
  6380. $where .= " and features like '%-$color-%'";
  6381. }
  6382. if ($lowe) {
  6383. $where .= " and features like '%-$lowe-%'";
  6384. }
  6385. if ($label) {
  6386. $where .= " and label = '$label'";
  6387. }
  6388. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6389. //数据排序
  6390. $order_str = "outk desc";
  6391. if (empty($page)) {
  6392. $start = 0;
  6393. $perpage = 1;
  6394. } else {
  6395. $start = ($page - 1) * $perpage;
  6396. }
  6397. //取得信息列表
  6398. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6399. foreach ($info_list as $key => $value) {
  6400. $warehouse = $this->warehouse->read($value['warehouse']);
  6401. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6402. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6403. if ($value['state'] == 0) {
  6404. $info_list[$key]['state'] = "在库";
  6405. } else if ($value['state'] == 1) {
  6406. $info_list[$key]['state'] = "出库";
  6407. } else if ($value['state'] == 2) {
  6408. $info_list[$key]['state'] = "退库";
  6409. } else if ($value['state'] == 3) {
  6410. $info_list[$key]['state'] = "调拨中";
  6411. } else if ($value['state'] == 4) {
  6412. $info_list[$key]['state'] = "再加工";
  6413. } else if ($value['state'] == 5) {
  6414. $info_list[$key]['state'] = "维修中";
  6415. } else if ($value['state'] == 6) {
  6416. $info_list[$key]['state'] = "盘亏";
  6417. } else if ($value['state'] == 7) {
  6418. $info_list[$key]['state'] = "更换标签";
  6419. } else if ($value['state'] == 8) {
  6420. $info_list[$key]['state'] = "其它";
  6421. } else if ($value['state'] == 9) {
  6422. $info_list[$key]['state'] = "预设";
  6423. } else if ($value['state'] == 10) {
  6424. $info_list[$key]['state'] = "美店零售";
  6425. }
  6426. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6427. }
  6428. $total = $this->$ck->find_count($where);
  6429. $pagenum = ceil($total / $perpage);
  6430. $over = $total - ($start + $perpage);
  6431. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6432. echo json_encode($rows);
  6433. exit;
  6434. }
  6435. if (isset($post['tmsku'])) {
  6436. $time = time();
  6437. $tmsku = $this->input->post('tmsku', true);
  6438. //$post['shop'] = $this->input->post('shop',true);
  6439. $num = $this->input->post('num', true);
  6440. $cktype = $this->input->post('cktype', true);
  6441. $label = $this->whlabellabel->get_label($tmsku);
  6442. if (!$cktype) {
  6443. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6444. }
  6445. if (!isset($label['warehouse'])) {
  6446. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6447. exit;
  6448. }
  6449. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6450. if (stripos($label['features'], '-126-') !== false) {
  6451. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and ( zd = '' or zd is null )");
  6452. } else {
  6453. $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 = '' or zd is null ) ");
  6454. }
  6455. $j = 0;
  6456. if (count($ck) >= $num) {
  6457. for ($i = 0; $i < $num; $i++) {
  6458. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6459. {
  6460. $j++;
  6461. }
  6462. }
  6463. $this->whlabelscanlog->insert([
  6464. 'shop'=>$label['shop'],
  6465. 'type'=>2,
  6466. 'purchase'=>$label['purchase'],
  6467. 'sku'=>$label['sku'],
  6468. 'features'=>$label['features'],
  6469. 'title'=>$label['title'],
  6470. 'label'=>$label['label'],
  6471. 'warehouse'=>$label['warehouse'],
  6472. 'wlid'=>$label['id'],
  6473. 'num'=>$num,
  6474. 'addtime'=>time()
  6475. ]);
  6476. if ($j == $num) {
  6477. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6478. exit;
  6479. } else {
  6480. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6481. exit;
  6482. }
  6483. } else {
  6484. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6485. exit;
  6486. }
  6487. }
  6488. if(isset($_SESSION['api']))
  6489. {
  6490. $user = $this->user->get_api($_SESSION['api']);
  6491. if(in_array($user['power'],[1,27])){
  6492. $vip = 1;
  6493. }
  6494. }
  6495. else
  6496. {
  6497. $vip = 0;
  6498. header('Location: /');exit;
  6499. }
  6500. $this->data['vip'] = $vip;
  6501. $this->_Template('whlabel_printck', $this->data);
  6502. }
  6503. public function _printexcel()
  6504. {
  6505. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6506. $config['upload_path'] = '.' . $dir;
  6507. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6508. $config['allowed_types'] = 'xls|xlsx|csv';
  6509. $config['max_size'] = 10240;
  6510. $this->load->library('upload', $config);
  6511. $this->upload->initialize($config);
  6512. if ($this->upload->do_upload('userfile')) {
  6513. $full_path = $dir . $this->upload->data('file_name');
  6514. $fileName = '.' . $full_path;
  6515. if (!file_exists($fileName)) {
  6516. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6517. exit;
  6518. } else {
  6519. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6520. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6521. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6522. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6523. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6524. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6525. ++$column; //如果列数大于26行
  6526. $list = array();
  6527. for ($i = 2; $i <= $row; $i++) // 行数循环
  6528. {
  6529. $data = array();
  6530. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6531. {
  6532. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6533. }
  6534. $list[] = $data;
  6535. }
  6536. }
  6537. $ed = array();
  6538. $i = 0;
  6539. $j = 0;
  6540. $dcdata = array();
  6541. $yc = '';
  6542. $cmf_arr = array_column($list, '1');
  6543. array_multisort($cmf_arr, SORT_ASC, $list);
  6544. foreach ($list as $key => $value) {
  6545. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6546. if ($typeclass) {
  6547. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6548. } else {
  6549. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6550. $i++;
  6551. continue;
  6552. }
  6553. }
  6554. if ($i > 0) {
  6555. $yc = $i . '条异常';
  6556. }
  6557. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6558. exit;
  6559. }
  6560. }
  6561. public function _uck()
  6562. {
  6563. if (isset($_GET['excel'])) {
  6564. $tc = array();
  6565. $typeclass = $this->typeclass->find_all();
  6566. foreach ($typeclass as $v) {
  6567. $tc[$v['id']] = $v['zh'];
  6568. }
  6569. $data = array();
  6570. $t = array();
  6571. $rq = '';
  6572. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6573. $ts = $ts / (24 * 3600);
  6574. for ($i = 0; $i < $ts; $i++) {
  6575. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6576. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6577. }
  6578. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6579. foreach ($info_list as $k => $v) {
  6580. $features = explode('-', trim($v['features'], '-'));
  6581. if (!isset($features[3]) || !isset($features[4])) {
  6582. continue;
  6583. }
  6584. $data[$k][0] = $tc[$features[0]]; //类型
  6585. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6586. $data[$k][2] = $tc[$features[4]]; //曲度
  6587. $data[$k][3] = '';
  6588. if (isset($data[$k][1])) {
  6589. $data[$k][3] .= $data[$k][1];
  6590. }
  6591. if (isset($data[$k][2])) {
  6592. $data[$k][3] .= $data[$k][2];
  6593. }
  6594. if (isset($features[5])) {
  6595. $data[$k][3] .= $tc[$features[5]];
  6596. }
  6597. if (isset($features[2])) {
  6598. $data[$k][3] .= $tc[$features[2]];
  6599. }
  6600. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6601. $data[$k][4] = $v['sku'];
  6602. $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())) . '))'); //月初库存
  6603. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6604. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6605. $ztrq = '';
  6606. $ztsl = '';
  6607. if (count($zt) > 0) {
  6608. foreach ($zt as $vv) {
  6609. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6610. $ztsl .= $vv['num'] . '<br>';
  6611. }
  6612. }
  6613. $data[$k][] = trim($ztsl, '<br>');
  6614. $data[$k][] = trim($ztrq, '<br>');
  6615. $byck = 0;
  6616. foreach ($t as $vv) {
  6617. $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));
  6618. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6619. $byck += $sl;
  6620. }
  6621. $data[$k][] = ($byck > 0) ? $byck : '';
  6622. }
  6623. $title = "详情 " . date("Y-m-d", time());
  6624. $titlename = "<table border=1>
  6625. <tr align='center'>
  6626. <td>类别</td>
  6627. <td>颜色</td>
  6628. <td>曲度</td>
  6629. <td>名称</td>
  6630. <td>SKU</td>
  6631. <td>月初库存</td>
  6632. <td>剩余库存</td>
  6633. <td>在途数量</td>
  6634. <td>预达日期</td>" .
  6635. $rq
  6636. . "<td>本月出库</td></tr>
  6637. </table>";
  6638. $filename = $title . ".xls";
  6639. $tail = "";
  6640. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6641. }
  6642. }
  6643. public function _whlabelexcelzh()
  6644. {
  6645. if (isset($_GET['excel'])) {
  6646. $where = "sku != 'Preset'";
  6647. //数据排序
  6648. $order_str = "id desc";
  6649. if (empty($page)) {
  6650. $start = 0;
  6651. $perpage = 1;
  6652. } else {
  6653. $start = ($page - 1) * $perpage;
  6654. }
  6655. $category = $this->input->get('category', true);
  6656. $warehouse = $this->input->get('warehouse', true);
  6657. $excelid = $this->input->get('sid', true);
  6658. if ($category) {
  6659. $where .= " and features like '%-$category-%'";
  6660. }
  6661. if ($warehouse) {
  6662. $where .= " and warehouse = '$warehouse'";
  6663. }
  6664. $xzid = '';
  6665. if ($excelid) {
  6666. $excelid = explode(',', trim($excelid, ','));
  6667. foreach ($excelid as $key => $value) {
  6668. $xzid .= " id = " . $value . " or";
  6669. }
  6670. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6671. }
  6672. //取得信息列表
  6673. /**
  6674. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6675. $rows = array();$list = array();
  6676. foreach ($info_list as $key=>$value)
  6677. {
  6678. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6679. }
  6680. **/
  6681. $list = array();
  6682. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6683. foreach ($rows as $key => $value) {
  6684. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6685. $zh = '';
  6686. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6687. foreach ($zt as $v) {
  6688. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6689. }
  6690. $zt = array_sum(array_column($zt, 'num'));
  6691. $number = $value['number'];
  6692. $ftime = time() - 15 * 24 * 3600;
  6693. $warehouse = $this->warehouse->read($value['warehouse']);
  6694. $rows[$key]['warehouse'] = $warehouse['title'];
  6695. $rows[$key]['number'] = $c;
  6696. $rows[$key]['features'] = $zh;
  6697. $rows[$key]['hb'] = $c + $zt;
  6698. }
  6699. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6700. $titlename = "<table border=1>
  6701. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6702. <tr align='center'>
  6703. <td>仓库</td>
  6704. <td>SKU</td>
  6705. <td>产品</td>
  6706. <td>库存数量</td>
  6707. <td>在途数量及预达日期</td>
  6708. <td>在途+库存数量</td>
  6709. </tr>
  6710. </table>";
  6711. $filename = $title . ".xls";
  6712. $tail = "";
  6713. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6714. }
  6715. if (isset($_GET['excel'])) {
  6716. $warehouse = $this->input->get('warehouse', true);
  6717. $sku = $this->input->get('sku', true);
  6718. $cz = $this->input->get('cz', true);
  6719. $text = $this->input->post('text', true);
  6720. $xztime = $this->input->get('xztime', true);
  6721. $timetk = $this->input->get('timetk', true);
  6722. $timetj = $this->input->get('timetj', true);
  6723. $timetk = strtotime($timetk);
  6724. $timetj = strtotime($timetj);
  6725. $where = "time = '0' ";
  6726. if ($warehouse) {
  6727. $where .= " and warehouse = '$warehouse'";
  6728. }
  6729. if ($sku) {
  6730. $where .= " and sku = '$sku'";
  6731. }
  6732. if ($text) {
  6733. $where .= " and text like '%$text%'";
  6734. }
  6735. if ($cz != '') {
  6736. $where .= " and cz = '$cz'";
  6737. }
  6738. if ($timetk && $timetj) {
  6739. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6740. }
  6741. //数据排序
  6742. $order_str = $xztime . " desc";
  6743. //取得信息列表
  6744. $zh = array();
  6745. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6746. foreach ($info_list as $v) {
  6747. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6748. $warehouse = $this->warehouse->read($v['warehouse']);
  6749. $v['warehouse'] = $warehouse['title'];
  6750. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6751. $v['stime'] = date('Y-m-d', $v['stime']);
  6752. if (isset($zh[$v['features']])) {
  6753. $zh[$v['features']]['num'] += $v['num'];
  6754. } else {
  6755. $zh[$v['features']] = $v;
  6756. }
  6757. $zh[$v['features']]['features'] = $c;
  6758. }
  6759. $title = "在途数据" . date('Y-m-d', time());
  6760. $titlename = "<table border=1>
  6761. <tr align='center'>
  6762. <td>仓库</td>
  6763. <td>SKU</td>
  6764. <td>名称</td>
  6765. <td>在途数量</td>
  6766. <td>库存数量</td>
  6767. <td>添加在途日期</td>
  6768. <td>预达日期</td>
  6769. <td>备注</td>
  6770. </tr>
  6771. </table>";
  6772. $filename = $title . ".xls";
  6773. $tail = "";
  6774. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6775. }
  6776. }
  6777. public function _fc()
  6778. {
  6779. $vip = 0;
  6780. if (isset($_SESSION['api'])) {
  6781. $user = $this->user->get_api($_SESSION['api']);
  6782. if ($user['vip'] == 1) {
  6783. $vip = 1;
  6784. }
  6785. } else {
  6786. header('Location: /');
  6787. exit;
  6788. }
  6789. $post = $this->input->post(NULL, TRUE);
  6790. if (isset($post['page'])) {
  6791. $page = $this->input->post('page', true);
  6792. $perpage = $this->input->post('perpage', true);
  6793. $category = $this->input->post('category', true);
  6794. $size = $this->input->post('size', true);
  6795. $grade = $this->input->post('grade', true);
  6796. $color = $this->input->post('color', true);
  6797. $lowe = $this->input->post('lowe', true);
  6798. $sku = $this->input->post('sku');
  6799. $title = $this->input->post('title');
  6800. $warehouse = $this->input->post('warehouse', true);
  6801. $usa = $this->input->post('usa', true);
  6802. $purchase = $this->input->post('purchase', true);
  6803. $lacetype = $this->input->post('lacetype', true);
  6804. $haircap = $this->input->post('haircap', true);
  6805. $density = $this->input->post('density', true);
  6806. $details = $this->input->post('details', true);
  6807. $state = $this->input->post('state', true);
  6808. $ktime = $this->input->post('ktime', true);
  6809. $jtime = $this->input->post('jtime', true);
  6810. $ktime = strtotime($ktime);
  6811. $jtime = strtotime($jtime);
  6812. $where = "state = '11'";
  6813. $gj = "";
  6814. $ck = "";
  6815. if ($lacetype) {
  6816. $where .= " and features like '%-$lacetype-%'";
  6817. }
  6818. if ($category) {
  6819. $where .= " and features like '%-$category-%'";
  6820. }
  6821. if ($size) {
  6822. $where .= " and features like '%-$size-%'";
  6823. }
  6824. if ($grade) {
  6825. $where .= " and features like '%-$grade-%'";
  6826. }
  6827. if ($color) {
  6828. $where .= " and features like '%-$color-%'";
  6829. }
  6830. if ($lowe) {
  6831. $where .= " and features like '%-$lowe-%'";
  6832. }
  6833. if ($haircap) {
  6834. $where .= " and features like '%-$haircap-%'";
  6835. }
  6836. if ($density) {
  6837. $where .= " and features like '%-$density-%'";
  6838. }
  6839. if ($usa) {
  6840. if (!$warehouse) {
  6841. $where .= " and (warehouse = '5' or warehouse = '8')";
  6842. }
  6843. }
  6844. if ($warehouse) {
  6845. $where .= " and warehouse = '$warehouse'";
  6846. }
  6847. if ($details) {
  6848. $where .= " and details = '$details'";
  6849. }
  6850. if ($purchase) {
  6851. $where .= " and purchase = '$purchase'";
  6852. }
  6853. if ($state) {
  6854. $where .= " and state = '$state'";
  6855. }
  6856. if ($ktime && $jtime) {
  6857. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6858. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6859. }
  6860. //数据排序
  6861. $order_str = "id desc";
  6862. if (empty($page)) {
  6863. $start = 0;
  6864. $perpage = 1;
  6865. } else {
  6866. $start = ($page - 1) * $perpage;
  6867. }
  6868. if ($sku) {
  6869. $sku = trim($sku, ' ');
  6870. $sku = trim($sku, ' ');
  6871. $where .= " and sku like '%$sku%'";
  6872. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6873. } else if ($title) {
  6874. $title = trim($title, ' ');
  6875. $title = trim($title, ' ');
  6876. $where .= " and title like '%$title%'";
  6877. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6878. } else {
  6879. //$where .= " and time > '$ktime' and time < '$jtime'";
  6880. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6881. }
  6882. //取得信息列表
  6883. $rows = array();
  6884. $list = array();
  6885. foreach ($info_list as $key => $value) {
  6886. $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'] . '"');
  6887. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6888. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6889. $warehouse = $this->warehouse->read($value['warehouse']);
  6890. $info_list[$key]['warehouse'] = $warehouse['title'];
  6891. $info_list[$key]['number'] = $g;
  6892. $info_list[$key]['features'] = $x;
  6893. $info_list[$key]['x'] = $s;
  6894. }
  6895. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6896. $pagenum = ceil($total / $perpage);
  6897. $over = $total - ($start + $perpage);
  6898. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6899. echo json_encode($rows);
  6900. exit;
  6901. }
  6902. $this->data['vip'] = $vip;
  6903. $this->_Template('whlabel_fc', $this->data);
  6904. }
  6905. public function _fcmb()
  6906. {
  6907. $where = "sku != 'Preset'";
  6908. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6909. foreach ($rows as $k => $v) {
  6910. $warehouse = $this->warehouse->read($v['warehouse']);
  6911. $rows[$k]['warehouse'] = $warehouse['title'];
  6912. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6913. $rows[$k]['t'] = '';
  6914. $rows[$k]['n'] = '';
  6915. }
  6916. $title = "封货产品数据导入模板";
  6917. $titlename = "<table border=1>
  6918. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6919. <tr align='center'>
  6920. <td>仓库</td>
  6921. <td>SKU</td>
  6922. <td>产品</td>
  6923. <td>封存产品总数量</td>
  6924. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6925. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6926. </tr>
  6927. </table>";
  6928. $filename = $title . ".xls";
  6929. $tail = "";
  6930. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6931. }
  6932. public function _fcexcel()
  6933. {
  6934. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6935. $config['upload_path'] = '.' . $dir;
  6936. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6937. $config['allowed_types'] = 'xls|xlsx|csv';
  6938. $config['max_size'] = 10240;
  6939. $this->load->library('upload', $config);
  6940. $this->upload->initialize($config);
  6941. if ($this->upload->do_upload('userfile')) {
  6942. $full_path = $dir . $this->upload->data('file_name');
  6943. $fileName = '.' . $full_path;
  6944. if (!file_exists($fileName)) {
  6945. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6946. exit;
  6947. } else {
  6948. libxml_use_internal_errors(true);
  6949. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6950. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6951. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6952. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6953. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6954. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6955. ++$column; //如果列数大于26行
  6956. $list = array();
  6957. for ($i = 2; $i <= $row; $i++) // 行数循环
  6958. {
  6959. $data = array();
  6960. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6961. {
  6962. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6963. }
  6964. $list[] = $data;
  6965. }
  6966. }
  6967. $i = 0;
  6968. $j = 0;
  6969. $ed = array();
  6970. foreach ($list as $key => $value) {
  6971. $time = time();
  6972. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6973. continue;
  6974. }
  6975. $warehouse = $this->warehouse->get_title($value['0']);
  6976. $sku = $value['1'];
  6977. $type = $value['4']; //调整方式0扣减1删除
  6978. $num = $value['5']; //调整数量
  6979. //$text = $value['4'];//扣减说明
  6980. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6981. if (!$d) //如果没有这个SKU
  6982. {
  6983. $ed[] = array($sku . '-库存中不存在此SKU');
  6984. $j++;
  6985. continue;
  6986. }
  6987. if (!isset($warehouse['id'])) {
  6988. $ed[] = array($sku . '-仓库名错误!');
  6989. $j++;
  6990. continue;
  6991. }
  6992. if ($type == 1 || $type == 2) //扣减库存
  6993. {
  6994. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6995. if (count($data) < abs($num)) {
  6996. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6997. $j++;
  6998. continue;
  6999. }
  7000. if ($type == 1) //转入库存
  7001. {
  7002. for ($i = 0; $i < abs($num); $i++) {
  7003. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7004. }
  7005. } else if ($type == 2) //删除
  7006. {
  7007. for ($i = 0; $i < abs($num); $i++) {
  7008. $this->whlabel->remove($data[$i]['id']);
  7009. }
  7010. }
  7011. } else if ($type == 0) //增加库存
  7012. {
  7013. $post['sku'] = $d['sku'];
  7014. $post['shop'] = '';
  7015. $post['warehouse'] = $warehouse['id'];
  7016. $post['purchase'] = $d['purchase'];
  7017. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7018. $post['state'] = 11;
  7019. $post['title'] = $d['title'];
  7020. $post['number'] = $d['number'];
  7021. $post['features'] = $d['features'];
  7022. $post['enter'] = $time;
  7023. $post['time'] = $time; //操作时间
  7024. for ($i = 0; $i < $num; $i++) {
  7025. $post['label'] = time() . rand(100, 999) . $i;
  7026. $this->whlabel->insert($post);
  7027. }
  7028. }
  7029. sleep(1); //防止入库时间一样,需要延迟1秒
  7030. }
  7031. if ($j > 0) {
  7032. $tt = date('Ymd', time());
  7033. $title = '库存导入错误信息-' . $tt;
  7034. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7035. $tail = "\n";
  7036. $filename = $title . ".xls";
  7037. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7038. $dir = '/data/excel/' . $time . '/';
  7039. $file_name = 'error_' . $time . rand(1000, 9999);
  7040. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7041. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7042. fwrite($myfile, $ecl);
  7043. fclose($myfile);
  7044. $error = $dir . $file_name . '.xls';
  7045. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7046. exit;
  7047. } else {
  7048. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7049. exit;
  7050. }
  7051. }
  7052. }
  7053. public function _fcjxc($arg_array)
  7054. {
  7055. if (isset($_GET['excel'])) {
  7056. $category = $this->input->get('category', true);
  7057. $size = $this->input->get('size', true);
  7058. $grade = $this->input->get('grade', true);
  7059. $color = $this->input->get('color', true);
  7060. $lowe = $this->input->get('lowe', true);
  7061. $sku = $this->input->get('sku');
  7062. $title = $this->input->get('title');
  7063. $warehouse = $arg_array[0];
  7064. $usa = $this->input->get('usa', true);
  7065. $purchase = $this->input->get('purchase', true);
  7066. $lacetype = $this->input->get('lacetype', true);
  7067. $haircap = $this->input->get('haircap', true);
  7068. $density = $this->input->get('density', true);
  7069. $title = $this->input->get('title', true);
  7070. $state = $this->input->get('state', true);
  7071. $ktime = $this->input->get('ktime', true);
  7072. $jtime = $this->input->get('jtime', true);
  7073. $where = "state=11";
  7074. $gj = "";
  7075. $ck = "";
  7076. if ($lacetype) {
  7077. $where .= " and features like '%-$lacetype-%'";
  7078. }
  7079. if ($category) {
  7080. $where .= " and features like '%-$category-%'";
  7081. }
  7082. if ($size) {
  7083. $where .= " and features like '%-$size-%'";
  7084. }
  7085. if ($grade) {
  7086. $where .= " and features like '%-$grade-%'";
  7087. }
  7088. if ($color) {
  7089. $where .= " and features like '%-$color-%'";
  7090. }
  7091. if ($lowe) {
  7092. $where .= " and features like '%-$lowe-%'";
  7093. }
  7094. if ($haircap) {
  7095. $where .= " and features like '%-$haircap-%'";
  7096. }
  7097. if ($density) {
  7098. $where .= " and features like '%-$density-%'";
  7099. }
  7100. if ($usa) {
  7101. if (!$warehouse) {
  7102. $where .= " and (warehouse = '5' or warehouse = '8')";
  7103. }
  7104. }
  7105. if ($warehouse) {
  7106. $where .= " and warehouse = '$warehouse'";
  7107. }
  7108. if ($purchase) {
  7109. $where .= " and purchase = '$purchase'";
  7110. }
  7111. if ($state) {
  7112. $where .= " and state = '$state'";
  7113. }
  7114. $order_str = "id desc";
  7115. if ($sku) {
  7116. $sku = trim($sku, ' ');
  7117. $sku = trim($sku, ' ');
  7118. $where .= " and sku like '%$sku%'";
  7119. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7120. } else if ($title) {
  7121. $title = trim($title, ' ');
  7122. $title = trim($title, ' ');
  7123. $where .= " and title like '%$title%'";
  7124. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7125. } else {
  7126. //$where .= " and time > '$ktime' and time < '$jtime'";
  7127. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7128. }
  7129. //取得信息列表
  7130. $rows = array();
  7131. $list = array();
  7132. foreach ($info_list as $key => $value) {
  7133. $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'] . '"');
  7134. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7135. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7136. $rows[$key] = $value;
  7137. $warehouse = $this->warehouse->read($value['warehouse']);
  7138. $rows[$key]['warehouse'] = $warehouse['title'];
  7139. $rows[$key]['features'] = $g;
  7140. $rows[$key]['a'] = $x;
  7141. $rows[$key]['b'] = $s;
  7142. }
  7143. $title = "总统计表";
  7144. $titlename = "<table border=1>
  7145. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7146. <tr align='center'>
  7147. <td>仓库</td>
  7148. <td>SKU</td>
  7149. <td>产品名称</td>
  7150. <td>录入总量</td>
  7151. <td>取出总量</td>
  7152. <td>剩余总量</td>
  7153. </tr>
  7154. </table>";
  7155. $filename = $title . ".xls";
  7156. $tail = "";
  7157. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7158. }
  7159. $vip = 0;
  7160. if (isset($_SESSION['api'])) {
  7161. $user = $this->user->get_api($_SESSION['api']);
  7162. if ($user['vip'] == 1) {
  7163. $vip = 1;
  7164. }
  7165. } else {
  7166. header('Location: /');
  7167. exit;
  7168. }
  7169. $post = $this->input->post(NULL, TRUE);
  7170. if (isset($post['page'])) {
  7171. $page = $this->input->post('page', true);
  7172. $perpage = $this->input->post('perpage', true);
  7173. $category = $this->input->post('category', true);
  7174. $size = $this->input->post('size', true);
  7175. $grade = $this->input->post('grade', true);
  7176. $color = $this->input->post('color', true);
  7177. $lowe = $this->input->post('lowe', true);
  7178. $sku = $this->input->post('sku');
  7179. $title = $this->input->post('title');
  7180. $warehouse = $arg_array[0];
  7181. $usa = $this->input->post('usa', true);
  7182. $purchase = $this->input->post('purchase', true);
  7183. $lacetype = $this->input->post('lacetype', true);
  7184. $haircap = $this->input->post('haircap', true);
  7185. $density = $this->input->post('density', true);
  7186. $title = $this->input->post('title', true);
  7187. $state = $this->input->post('state', true);
  7188. $ktime = $this->input->post('ktime', true);
  7189. $jtime = $this->input->post('jtime', true);
  7190. $ktime = strtotime($ktime);
  7191. $jtime = strtotime($jtime);
  7192. $where = "state=11";
  7193. $gj = "";
  7194. $ck = "";
  7195. if ($lacetype) {
  7196. $where .= " and features like '%-$lacetype-%'";
  7197. }
  7198. if ($category) {
  7199. $where .= " and features like '%-$category-%'";
  7200. }
  7201. if ($size) {
  7202. $where .= " and features like '%-$size-%'";
  7203. }
  7204. if ($grade) {
  7205. $where .= " and features like '%-$grade-%'";
  7206. }
  7207. if ($color) {
  7208. $where .= " and features like '%-$color-%'";
  7209. }
  7210. if ($lowe) {
  7211. $where .= " and features like '%-$lowe-%'";
  7212. }
  7213. if ($haircap) {
  7214. $where .= " and features like '%-$haircap-%'";
  7215. }
  7216. if ($density) {
  7217. $where .= " and features like '%-$density-%'";
  7218. }
  7219. if ($usa) {
  7220. if (!$warehouse) {
  7221. $where .= " and (warehouse = '5' or warehouse = '8')";
  7222. }
  7223. }
  7224. if ($warehouse) {
  7225. $where .= " and warehouse = '$warehouse'";
  7226. }
  7227. if ($purchase) {
  7228. $where .= " and purchase = '$purchase'";
  7229. }
  7230. if ($state) {
  7231. $where .= " and state = '$state'";
  7232. }
  7233. if ($ktime && $jtime) {
  7234. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7235. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7236. }
  7237. //数据排序
  7238. $order_str = "id desc";
  7239. $xs = 0;
  7240. $rows = array();
  7241. $list = array();
  7242. if (empty($page)) {
  7243. $start = 0;
  7244. $perpage = 1;
  7245. } else {
  7246. $start = ($page - 1) * $perpage;
  7247. }
  7248. if ($sku || $title) {
  7249. if ($title) {
  7250. $title = trim($title, ' ');
  7251. $title = trim($title, ' ');
  7252. $where .= " and title like '%$title%'";
  7253. } else {
  7254. $sku = trim($sku, ' ');
  7255. $sku = trim($sku, ' ');
  7256. $where .= " and sku like '%$sku%'";
  7257. }
  7258. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7259. foreach ($info_list as $key => $value) {
  7260. $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'] . '"');
  7261. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7262. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7263. $rows[$key] = $value;
  7264. $warehouse = $this->warehouse->read($value['warehouse']);
  7265. $rows[$key]['warehouse'] = $warehouse['title'];
  7266. $rows[$key]['features'] = $g;
  7267. $rows[$key]['a'] = $x;
  7268. $rows[$key]['b'] = $s;
  7269. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7270. $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天销量
  7271. $yj = $c / ($xl / 30);
  7272. if ($yj < 7) {
  7273. $rows[$key]['y'] = round($yj) . '天销量';
  7274. } else {
  7275. $rows[$key]['y'] = '正常';
  7276. }
  7277. }
  7278. } else {
  7279. //$where .= " and time > '$ktime' and time < '$jtime'";
  7280. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7281. foreach ($info_list as $key => $value) {
  7282. $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'] . '"');
  7283. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7284. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7285. $zs[$key] = $value;
  7286. $warehouse = $this->warehouse->read($value['warehouse']);
  7287. $zs[$key]['warehouse'] = $warehouse['title'];
  7288. $zs[$key]['features'] = $g;
  7289. $zs[$key]['a'] = $x;
  7290. $zs[$key]['b'] = $s;
  7291. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7292. $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天销量
  7293. $yj = $c / ($xl / 30);
  7294. if ($yj < 7) {
  7295. $zs[$key]['y'] = round($yj) . '天销量';
  7296. $rows[$key] = $zs[$key];
  7297. }
  7298. }
  7299. }
  7300. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7301. $pagenum = ceil($total / $perpage);
  7302. $over = $total - ($start + $perpage);
  7303. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7304. echo json_encode($rows);
  7305. exit;
  7306. }
  7307. $this->data['arg_array'] = $arg_array[0];
  7308. $this->_Template('whlabel_fcjxc', $this->data);
  7309. }
  7310. public function _0kcdel()
  7311. {
  7312. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7313. $config['upload_path'] = '.' . $dir;
  7314. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7315. $config['allowed_types'] = 'xls|xlsx|csv';
  7316. $config['max_size'] = 10240;
  7317. $this->load->library('upload', $config);
  7318. $this->upload->initialize($config);
  7319. if ($this->upload->do_upload('userfile')) {
  7320. $full_path = $dir . $this->upload->data('file_name');
  7321. $fileName = '.' . $full_path;
  7322. if (!file_exists($fileName)) {
  7323. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7324. exit;
  7325. } else {
  7326. require_once "./data/excel/PHPExcel/IOFactory.php";
  7327. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7328. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7329. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7330. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7331. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7332. ++$column; //如果列数大于26行
  7333. $list = array();
  7334. for ($i = 2; $i <= $row; $i++) // 行数循环
  7335. {
  7336. $data = array();
  7337. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7338. {
  7339. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7340. }
  7341. $list[] = $data;
  7342. }
  7343. }
  7344. $i = 0;
  7345. $j = 0;
  7346. $ed = array();
  7347. foreach ($list as $key => $value) {
  7348. $time = time();
  7349. if ($value['0'] == "" || $value['1'] == "") {
  7350. continue;
  7351. }
  7352. $warehouse = $this->warehouse->get_title($value['0']);
  7353. $sku = $value['1'];
  7354. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7355. if (!$d) //如果没有这个SKU
  7356. {
  7357. $ed[] = array($sku . '-库存中不存在此SKU');
  7358. $j++;
  7359. continue;
  7360. }
  7361. if (!isset($warehouse['id'])) {
  7362. $ed[] = array($sku . '-仓库名错误!');
  7363. $j++;
  7364. continue;
  7365. }
  7366. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7367. if ($z < 1) {
  7368. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7369. foreach ($z as $v) {
  7370. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7371. if (count($zt) > 0) {
  7372. $ed[] = array($sku . '-有在途库存无法删除!');
  7373. $j++;
  7374. continue;
  7375. }
  7376. $this->whlabel->remove($v['id']);
  7377. }
  7378. } else {
  7379. $ed[] = array($sku . '-非0库存!');
  7380. $j++;
  7381. continue;
  7382. }
  7383. }
  7384. if ($j > 0) {
  7385. $tt = date('Ymd', time());
  7386. $title = '删除0库存错误信息-' . $tt;
  7387. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7388. $tail = "\n";
  7389. $filename = $title . ".xls";
  7390. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7391. $dir = '/data/excel/' . $time . '/';
  7392. $file_name = 'error_' . $time . rand(1000, 9999);
  7393. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7394. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7395. fwrite($myfile, $ecl);
  7396. fclose($myfile);
  7397. $error = $dir . $file_name . '.xls';
  7398. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7399. exit;
  7400. } else {
  7401. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7402. exit;
  7403. }
  7404. }
  7405. }
  7406. public function _gbhtype()
  7407. {
  7408. $post = $this->input->post(NULL, TRUE);
  7409. if (isset($post['s'])) {
  7410. $n = $this->input->post('n');
  7411. $d = $this->input->post('s');
  7412. if (!$d) {
  7413. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7414. exit;
  7415. }
  7416. $d = explode(',', trim($d, ','));
  7417. $t = $this->whlabel_type->read($n);
  7418. //循环删除记录
  7419. foreach ($d as $v) {
  7420. $u = $this->whlabel->read($v);
  7421. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7422. foreach ($data as $val) {
  7423. $this->whlabel->save(array('type' => $n), $val['id']);
  7424. }
  7425. }
  7426. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7427. }
  7428. }
  7429. //出库、退库导出
  7430. public function _dccrtype()
  7431. {
  7432. $classid = $this->classid->sku();
  7433. $pm = $classid;
  7434. $typeclass = array();
  7435. $tc = $this->typeclass->find_all();
  7436. foreach ($tc as $v) {
  7437. $typeclass[$v['id']] = $v;
  7438. }
  7439. $prc = array();
  7440. $purchase = $this->purchase->find_all();
  7441. foreach ($purchase as $k => $v) {
  7442. $prc[$v['id']] = $v['title'];
  7443. }
  7444. if (isset($_GET['sid'])) {
  7445. $wh = array();
  7446. $w = $this->warehouse->find_all('1=1', 'id,title');
  7447. foreach ($w as $v) {
  7448. $wh[$v['id']] = $v['title'];
  7449. }
  7450. $type = $this->input->get('excel', true);
  7451. $category = $this->input->get('category', true);
  7452. $size = $this->input->get('size', true);
  7453. $grade = $this->input->get('grade', true);
  7454. $color = $this->input->get('color', true);
  7455. $lowe = $this->input->get('lowe', true);
  7456. $sku = $this->input->get('sku', true);
  7457. $warehouse = $this->input->get('warehouse', true);
  7458. $lacetype = $this->input->get('lacetype', true);
  7459. $lacecolor = $this->input->get('lacecolor', true);
  7460. $density = $this->input->get('density', true);
  7461. $haircap = $this->input->get('haircap', true);
  7462. $purchase = $this->input->get('purchase', true);
  7463. $title = $this->input->get('title', true);
  7464. $state = $this->input->get('state', true);
  7465. $sid = $this->input->get('sid', true);
  7466. $ktime = $this->input->get('ktime', true);
  7467. $jtime = $this->input->get('jtime', true);
  7468. $ktime = strtotime($ktime);
  7469. $jtime = strtotime($jtime);
  7470. $where = "1=1";
  7471. $gj = "";
  7472. $ck = "";
  7473. if ($category) {
  7474. $where .= " and features like '%-$category-%'";
  7475. }
  7476. if ($size) {
  7477. $where .= " and features like '%-$size-%'";
  7478. }
  7479. if ($grade) {
  7480. $where .= " and features like '%-$grade-%'";
  7481. }
  7482. if ($color) {
  7483. $where .= " and features like '%-$color-%'";
  7484. }
  7485. if ($lowe) {
  7486. $where .= " and features like '%-$lowe-%'";
  7487. }
  7488. if ($warehouse) {
  7489. $where .= " and warehouse = '$warehouse'";
  7490. }
  7491. if ($purchase) {
  7492. $where .= " and purchase = '$purchase'";
  7493. }
  7494. if ($state) {
  7495. $where .= " and state = '$state'";
  7496. }
  7497. if ($lacetype) {
  7498. $where .= " and features like '%-$lacetype-%'";
  7499. }
  7500. if ($lacecolor) {
  7501. $where .= " and features like '%-$lacecolor-%'";
  7502. }
  7503. if ($density) {
  7504. $where .= " and features like '%-$density-%'";
  7505. }
  7506. if ($haircap) {
  7507. $where .= " and features like '%-$haircap-%'";
  7508. }
  7509. if ($title) {
  7510. $title = trim($title, ' ');
  7511. $title = trim($title, ' ');
  7512. $where .= " and title like '%$title%'";
  7513. }
  7514. if ($sku) {
  7515. $sku = trim($sku, ' ');
  7516. $sku = trim($sku, ' ');
  7517. $where .= " and sku like '%$sku%'";
  7518. }
  7519. if ($ktime && $jtime) {
  7520. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7521. }
  7522. $sidwhere = '';
  7523. if ($sid) {
  7524. $sd = "";
  7525. $s = explode(',', trim($sid, ','));
  7526. foreach ($s as $value) {
  7527. $sd .= " id = " . $value . " or";
  7528. }
  7529. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7530. }
  7531. //数据排序
  7532. $order_str = "time desc";
  7533. if (empty($page)) {
  7534. $start = 0;
  7535. $perpage = 1;
  7536. } else {
  7537. $start = ($page - 1) * $perpage;
  7538. }
  7539. $wh = array();
  7540. $w = $this->warehouse->find_all('1=1', 'id,title');
  7541. foreach ($w as $v) {
  7542. $wh[$v['id']] = $v['title'];
  7543. }
  7544. $wt = array();
  7545. $whlabel_type = $this->whlabel_type->find_all();
  7546. foreach ($whlabel_type as $v) {
  7547. $wt[$v['id']] = $v['title'];
  7548. }
  7549. $classid = $this->classid->sku();
  7550. $list = array();
  7551. $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');
  7552. foreach ($rows_r as $key => $value) {
  7553. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7554. $pm = $classid;
  7555. $jm = $classid;
  7556. $rows_r[$key]['enter'] = '入库';
  7557. $rows_r[$key]['time'] = $value['enter'];
  7558. if ($value['rktype'] == 1) {
  7559. $rows_r[$key]['rktype'] = '采购入库';
  7560. } else if ($value['rktype'] == 2) {
  7561. $rows_r[$key]['rktype'] = '盘盈调整';
  7562. } else if ($value['rktype'] == 3) {
  7563. $rows_r[$key]['rktype'] = '其他调整入库';
  7564. } else if ($value['rktype'] == 4) {
  7565. $rows_r[$key]['rktype'] = '其他调整入库';
  7566. } else if ($value['rktype'] == 5) {
  7567. $rows_r[$key]['rktype'] = '退库入库';
  7568. } else if ($value['rktype'] == 6) {
  7569. $rows_r[$key]['rktype'] = '退货可用入库';
  7570. } else if ($value['rktype'] == 7) {
  7571. $rows_r[$key]['rktype'] = '形态转换入库';
  7572. } else {
  7573. $rows_r[$key]['rktype'] = '';
  7574. }
  7575. $features = explode('-', trim($value['features'], '-'));
  7576. foreach ($features as $v) {
  7577. if (isset($typeclass[$v])) {
  7578. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7579. $pm[$typeclass[$v]['classid']] = $zh[0];
  7580. }
  7581. if (isset($typeclass[$v])) {
  7582. if (isset($jm[$typeclass[$v]['classid']])) {
  7583. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7584. }
  7585. }
  7586. }
  7587. $zh = implode(" ", $pm);
  7588. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7589. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7590. $rows_r[$key]['zh'] = $zh;
  7591. $jm = array_filter($jm);
  7592. $rows_r[$key]['features'] = implode("-", $jm);
  7593. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7594. }
  7595. $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');
  7596. foreach ($rows_c as $key => $value) {
  7597. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7598. $pm = $classid;
  7599. $jm = $classid;
  7600. $rows_c[$key]['time'] = $value['outk'];
  7601. $rows_c[$key]['outk'] = '出库';
  7602. if ($value['cktype'] == 1) {
  7603. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7604. } else if ($value['cktype'] == 2) {
  7605. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7606. } else if ($value['cktype'] == 3) {
  7607. $rows_c[$key]['cktype'] = '盘亏调整';
  7608. } else if ($value['cktype'] == 4) {
  7609. $rows_c[$key]['cktype'] = '其他调整出库';
  7610. } else if ($value['cktype'] == 5) {
  7611. $rows_c[$key]['cktype'] = '形态转换出库';
  7612. } else {
  7613. $rows_c[$key]['cktype'] = '';
  7614. }
  7615. unset($rows_c[$key]['state']);
  7616. $features = explode('-', trim($value['features'], '-'));
  7617. foreach ($features as $v) {
  7618. if (isset($typeclass[$v])) {
  7619. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7620. $pm[$typeclass[$v]['classid']] = $zh[0];
  7621. }
  7622. if (isset($typeclass[$v])) {
  7623. if (isset($jm[$typeclass[$v]['classid']])) {
  7624. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7625. }
  7626. }
  7627. }
  7628. $zh = implode(" ", $pm);
  7629. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7630. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7631. $rows_c[$key]['zh'] = $zh;
  7632. $jm = array_filter($jm);
  7633. $rows_c[$key]['features'] = implode("-", $jm);
  7634. $rows_c[$key]['number'] = 1;
  7635. }
  7636. $merged = $rows_r;
  7637. foreach ($rows_c as $key => $value) {
  7638. if (isset($merged[$key])) {
  7639. $merged[] = $value;
  7640. } else {
  7641. $merged[$key] = $value;
  7642. }
  7643. }
  7644. usort($merged, function ($a, $b) {
  7645. return $a['time'] - $b['time'];
  7646. });
  7647. foreach ($merged as $key => $value) {
  7648. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7649. }
  7650. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7651. $titlename = "<table border=1>
  7652. <tr align='center'>
  7653. <td>仓库</td>
  7654. <td>SKU</td>
  7655. <td>商品名称</td>
  7656. <td>仓库品名</td>
  7657. <td>料号</td>
  7658. <td>时间</td>
  7659. <td>操作</td>
  7660. <td>类型</td>
  7661. <td>数量</td>
  7662. <td>备注</td>
  7663. </tr>
  7664. </table>";
  7665. $filename = $title . ".xlsx";
  7666. $tail = "";
  7667. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7668. }
  7669. }
  7670. /*************************************处理exceljs导出****************************************************/
  7671. public function _excelrjs(){
  7672. if (isset($_GET['excel'])) {
  7673. $category = $this->input->get('category', true);
  7674. $size = $this->input->get('size', true);
  7675. $grade = $this->input->get('grade', true);
  7676. $color = $this->input->get('color', true);
  7677. $lowe = $this->input->get('lowe', true);
  7678. $sku = $this->input->get('sku', true);
  7679. $warehouse = $this->input->get('warehouse', true);
  7680. $purchase = $this->input->get('purchase', true);
  7681. $ktime = $this->input->get('ktime', true);
  7682. $jtime = $this->input->get('jtime', true);
  7683. $ktime = strtotime($ktime);
  7684. $jtime = strtotime($jtime);
  7685. $where = "1=1";
  7686. $gj = "";
  7687. $ck = "";
  7688. if ($category) {
  7689. $where .= " and features like '%-$category-%'";
  7690. }
  7691. if ($size) {
  7692. $where .= " and features like '%-$size-%'";
  7693. }
  7694. if ($grade) {
  7695. $where .= " and features like '%-$grade-%'";
  7696. }
  7697. if ($color) {
  7698. $where .= " and features like '%-$color-%'";
  7699. }
  7700. if ($lowe) {
  7701. $where .= " and features like '%-$lowe-%'";
  7702. }
  7703. if ($warehouse) {
  7704. $where .= " and warehouse = '$warehouse'";
  7705. }
  7706. if ($purchase) {
  7707. $where .= " and purchase = '$purchase'";
  7708. }
  7709. if ($sku) {
  7710. $where .= " and sku = '$sku'";
  7711. }
  7712. if ($ktime && $jtime) {
  7713. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7714. }
  7715. //数据排序
  7716. $order_str = "id desc";
  7717. if (empty($page)) {
  7718. $start = 0;
  7719. $perpage = 1;
  7720. } else {
  7721. $start = ($page - 1) * $perpage;
  7722. }
  7723. $list = array();
  7724. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7725. foreach ($rows as $value) {
  7726. $ck = $this->warehouse->read($value['warehouse']);
  7727. $warehouse = $ck['title'];
  7728. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7729. $retreatwarehouse = $tkck['title'];
  7730. $gy = $this->purchase->read($value['purchase']);
  7731. $purchase = $gy['title'];
  7732. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7733. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7734. }
  7735. if(empty($list)){
  7736. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7737. }else{
  7738. $final_list = [];
  7739. foreach($list as $v){
  7740. $final_list[] = array_values($v);
  7741. }
  7742. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7743. array_unshift($final_list,[
  7744. "仓库","SKU","商品名称","时间","数量"
  7745. ]);
  7746. array_unshift($final_list,[
  7747. $title,"","","",""
  7748. ]);
  7749. $merges = [
  7750. [
  7751. "s"=>["r"=>0,"c"=>0],
  7752. "e"=>["r"=>0,"c"=>4]
  7753. ]
  7754. ];
  7755. $cols = [
  7756. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7757. ];
  7758. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7759. }
  7760. }
  7761. }
  7762. //出库、退库导出
  7763. public function _excelctjs()
  7764. {
  7765. $classid = $this->classid->sku();
  7766. $pm = $classid;
  7767. $typeclass = array();
  7768. $tc = $this->typeclass->find_all();
  7769. foreach ($tc as $v) {
  7770. $typeclass[$v['id']] = $v;
  7771. }
  7772. $prc = array();
  7773. $purchase = $this->purchase->find_all();
  7774. foreach ($purchase as $k => $v) {
  7775. $prc[$v['id']] = $v['title'];
  7776. }
  7777. if (isset($_GET['excel'])) {
  7778. $wh = array();
  7779. $w = $this->warehouse->find_all('1=1', 'id,title');
  7780. foreach ($w as $v) {
  7781. $wh[$v['id']] = $v['title'];
  7782. }
  7783. $type = $this->input->get('excel', true);
  7784. $category = $this->input->get('category', true);
  7785. $size = $this->input->get('size', true);
  7786. $grade = $this->input->get('grade', true);
  7787. $color = $this->input->get('color', true);
  7788. $lowe = $this->input->get('lowe', true);
  7789. $sku = $this->input->get('sku', true);
  7790. $title = $this->input->get('title', true);
  7791. $warehouse = $this->input->get('warehouse', true);
  7792. $purchase = $this->input->get('purchase', true);
  7793. $lacetype = $this->input->get('lacetype', true);
  7794. $haircap = $this->input->get('haircap', true);
  7795. $lacecolor = $this->input->get('lacecolor', true);
  7796. $density = $this->input->get('density', true);
  7797. $details = $this->input->get('details', true);
  7798. $state = $this->input->get('state', true);
  7799. $shop = $this->input->get('shop', true);
  7800. $hairnumber = $this->input->get('hairnumber', true);
  7801. $type_leixi = $this->input->get('type', true);
  7802. $cpbz = $this->input->get('cpbz', true);
  7803. $sm = $this->input->get('sm', true);
  7804. $sid = $this->input->get('sid', true);
  7805. $ktime = $this->input->get('ktime', true);
  7806. $jtime = $this->input->get('jtime', true);
  7807. $ktime = strtotime($ktime);
  7808. $jtime = strtotime($jtime);
  7809. //$where = " 1=1 ";
  7810. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7811. $where = " sku != '' ";
  7812. $gj = "";
  7813. $ck = "";
  7814. if ($category) {
  7815. $where .= " and features like '%-$category-%'";
  7816. }
  7817. if ($size) {
  7818. $where .= " and features like '%-$size-%'";
  7819. }
  7820. if ($grade) {
  7821. $where .= " and features like '%-$grade-%'";
  7822. }
  7823. if ($color) {
  7824. $where .= " and features like '%-$color-%'";
  7825. }
  7826. if ($lowe) {
  7827. $where .= " and features like '%-$lowe-%'";
  7828. }
  7829. if ($warehouse) {
  7830. $where .= " and warehouse = '$warehouse'";
  7831. }
  7832. if ($purchase) {
  7833. $where .= " and purchase = '$purchase'";
  7834. }
  7835. if ($state) {
  7836. $where .= " and state = '$state'";
  7837. }
  7838. if ($lacetype) {
  7839. $where .= " and features like '%-$lacetype-%'";
  7840. }
  7841. if ($lacecolor) {
  7842. $where .= " and features like '%-$lacecolor-%'";
  7843. }
  7844. if ($density) {
  7845. $where .= " and features like '%-$density-%'";
  7846. }
  7847. if ($haircap) {
  7848. $where .= " and features like '%-$haircap-%'";
  7849. }
  7850. if ($details) {
  7851. $where .= " and details = '$details'";
  7852. }
  7853. if ($shop) {
  7854. $where .= " and shop like '%$shop%'";
  7855. }
  7856. if ($title) {
  7857. $title = trim($title, ' ');
  7858. $title = trim($title, ' ');
  7859. $where .= " and title like '%$title%'";
  7860. }
  7861. if (!empty($hairnumber)) {
  7862. $where .= " and features like '%-128-%' ";
  7863. if ($hairnumber < 0) {
  7864. $class_list = $this->typeclass->find_all('classid = 43');
  7865. foreach ($class_list as $v) {
  7866. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7867. }
  7868. } else {
  7869. $where .= " and features like '%-$hairnumber-%'";
  7870. }
  7871. }
  7872. if ($type_leixi) {
  7873. $where .= " and type = '$type_leixi'";
  7874. }
  7875. if ($cpbz) {
  7876. $where .= " and cpbz like '%$cpbz%' ";
  7877. }
  7878. if ($sm) {
  7879. $where .= " and sm like '%$sm%' ";
  7880. }
  7881. if ($sku) {
  7882. $sku = trim($sku, ' ');
  7883. $sku = trim($sku, ' ');
  7884. $where .= " and sku like '%$sku%'";
  7885. }
  7886. if ($ktime && $jtime) {
  7887. if ($type == 1) {
  7888. $tl = '出库';
  7889. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7890. } else if ($type == 2) {
  7891. $tl = '退库';
  7892. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7893. } else if ($type == 3) {
  7894. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7895. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7896. } else if ($type == 4) {
  7897. $tl = '出库+零售';
  7898. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7899. } else if ($type == 5) {
  7900. $tl = '零售';
  7901. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7902. }
  7903. }
  7904. $sidwhere = '';
  7905. if ($sid) {
  7906. $sd = "";
  7907. $s = explode(',', trim($sid, ','));
  7908. foreach ($s as $value) {
  7909. $sd .= " id = " . $value . " or";
  7910. }
  7911. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7912. }
  7913. //数据排序
  7914. $order_str = "time desc";
  7915. if (empty($page)) {
  7916. $start = 0;
  7917. $perpage = 1;
  7918. } else {
  7919. $start = ($page - 1) * $perpage;
  7920. }
  7921. //取得信息列表
  7922. if ($type != 3 && $type != 5) {
  7923. if ($type == 1 || $type == 4) {
  7924. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7925. foreach ($info_list as $key => $value) {
  7926. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7927. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7928. $warehouse = $this->warehouse->read($value['warehouse']);
  7929. $info_list[$key]['warehouse'] = $warehouse['title'];
  7930. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7931. $features = explode('-', trim($features, '-'));
  7932. $pm = $classid;
  7933. foreach ($features as $k => $v) {
  7934. if ($v != 0) {
  7935. if (!isset($typeclass[$v])) {
  7936. continue;
  7937. }
  7938. if (isset($pm[$typeclass[$v]['classid']])) {
  7939. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7940. $tz = explode('|', $typeclass[$v]['zh']);
  7941. $pm[$typeclass[$v]['classid']] = $tz[0];
  7942. } else {
  7943. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7944. }
  7945. }
  7946. }
  7947. }
  7948. $zh = implode(" ", $pm);
  7949. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7950. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7951. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7952. $info_list[$key]['features'] = $zh;
  7953. }
  7954. $final_list = [];
  7955. foreach($info_list as $k=>$v){
  7956. $number = "";
  7957. if(!empty($v['orderinfo'])){
  7958. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7959. if(!empty($tmp_info['number'])){
  7960. $number = $tmp_info['number'];
  7961. }
  7962. }
  7963. $final_list[] = [
  7964. 'warehouse'=>$v['warehouse'],
  7965. 'purchase'=>$v['purchase'],
  7966. 'sku'=>$v['sku'],
  7967. 'title'=>$v['title'],
  7968. 'features'=>$v['features'],
  7969. 'label'=>$v['label'],
  7970. 'orderinfo'=>$v['orderinfo'],
  7971. 'number'=>$number,
  7972. 'waybill'=>$v['waybill'],
  7973. 'outk'=>$v['outk'],
  7974. ];
  7975. }
  7976. } else {
  7977. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7978. foreach ($info_list as $key => $value) {
  7979. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7980. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7981. $warehouse = $this->warehouse->read($value['warehouse']);
  7982. $info_list[$key]['warehouse'] = $warehouse['title'];
  7983. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7984. $features = explode('-', trim($features, '-'));
  7985. $pm = $classid;
  7986. foreach ($features as $k => $v) {
  7987. if ($v != 0) {
  7988. if (!isset($typeclass[$v])) {
  7989. continue;
  7990. }
  7991. if (isset($pm[$typeclass[$v]['classid']])) {
  7992. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7993. $tz = explode('|', $typeclass[$v]['zh']);
  7994. $pm[$typeclass[$v]['classid']] = $tz[0];
  7995. } else {
  7996. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7997. }
  7998. }
  7999. }
  8000. }
  8001. $zh = implode(" ", $pm);
  8002. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8003. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8004. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8005. $info_list[$key]['features'] = $zh;
  8006. }
  8007. $final_list = [];
  8008. foreach($info_list as $k=>$v){
  8009. $number = "";
  8010. if(!empty($v['orderinfo'])){
  8011. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8012. if(!empty($tmp_info['number'])){
  8013. $number = $tmp_info['number'];
  8014. }
  8015. }
  8016. $final_list[] = [
  8017. 'warehouse'=>$v['warehouse'],
  8018. 'purchase'=>$v['purchase'],
  8019. 'sku'=>$v['sku'],
  8020. 'title'=>$v['title'],
  8021. 'features'=>$v['features'],
  8022. 'label'=>$v['label'],
  8023. 'orderinfo'=>$v['orderinfo'],
  8024. 'number'=>$number,
  8025. 'waybill'=>$v['waybill'],
  8026. 'retreat'=>$v['retreat'],
  8027. ];
  8028. }
  8029. }
  8030. if(empty($final_list)){
  8031. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8032. }else{
  8033. $end_list = [];
  8034. foreach($final_list as $v){
  8035. $end_list[] = array_values($v);
  8036. }
  8037. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8038. array_unshift($end_list,[
  8039. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8040. ]);
  8041. array_unshift($end_list,[
  8042. $title,"","","","","","","","",""
  8043. ]);
  8044. $merges = [
  8045. [
  8046. "s"=>["r"=>0,"c"=>0],
  8047. "e"=>["r"=>0,"c"=>9]
  8048. ]
  8049. ];
  8050. $cols = [
  8051. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8052. ];
  8053. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8054. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8055. ] )));
  8056. }
  8057. } else if ($type == 5) {
  8058. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8059. foreach ($info_list as $key => $value) {
  8060. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8061. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8062. $warehouse = $this->warehouse->read($value['warehouse']);
  8063. $info_list[$key]['warehouse'] = $warehouse['title'];
  8064. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8065. $features = explode('-', trim($features, '-'));
  8066. $pm = $classid;
  8067. foreach ($features as $k => $v) {
  8068. if ($v != 0) {
  8069. if (!isset($typeclass[$v])) {
  8070. continue;
  8071. }
  8072. if (isset($pm[$typeclass[$v]['classid']])) {
  8073. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8074. $tz = explode('|', $typeclass[$v]['zh']);
  8075. $pm[$typeclass[$v]['classid']] = $tz[0];
  8076. } else {
  8077. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8078. }
  8079. }
  8080. }
  8081. }
  8082. $zh = implode(" ", $pm);
  8083. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8084. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8085. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8086. $info_list[$key]['features'] = $zh;
  8087. }
  8088. if(empty($info_list)){
  8089. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8090. }else{
  8091. $final_list = [];
  8092. foreach($info_list as $v){
  8093. $final_list[] = array_values($v);
  8094. }
  8095. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8096. array_unshift($final_list,[
  8097. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8098. ]);
  8099. array_unshift($final_list,[
  8100. $title,"","","","","","",
  8101. ]);
  8102. $merges = [
  8103. [
  8104. "s"=>["r"=>0,"c"=>0],
  8105. "e"=>["r"=>0,"c"=>6]
  8106. ]
  8107. ];
  8108. $cols = [
  8109. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8110. ];
  8111. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8112. }
  8113. } else {
  8114. $wh = array();
  8115. $w = $this->warehouse->find_all('1=1', 'id,title');
  8116. foreach ($w as $v) {
  8117. $wh[$v['id']] = $v['title'];
  8118. }
  8119. $wt = array();
  8120. $whlabel_type = $this->whlabel_type->find_all();
  8121. foreach ($whlabel_type as $v) {
  8122. $wt[$v['id']] = $v['title'];
  8123. }
  8124. $classid = $this->classid->sku();
  8125. $list = array();
  8126. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8127. foreach ($rows as $key => $value) {
  8128. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8129. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8130. $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');
  8131. $details = array();
  8132. $cpid = array();
  8133. $cpbz = array();
  8134. $c = 0;
  8135. $g = 0;
  8136. $x = 0;
  8137. $t = 0;
  8138. $s = 0;
  8139. $q = 0;
  8140. foreach ($sd as $k => $v) {
  8141. if ($v['state'] == 0) {
  8142. $c++;
  8143. }
  8144. if ($v['state'] != 9) {
  8145. $g++;
  8146. }
  8147. if ($v['outk'] > 1) {
  8148. $x++;
  8149. }
  8150. if ($v['retreat'] > 0) {
  8151. $t++;
  8152. }
  8153. if ($v['state'] == 8) {
  8154. $s++;
  8155. }
  8156. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8157. $q++;
  8158. }
  8159. $details[$v['details']] = $v['details'];
  8160. if ($v['cpid'] != 0) {
  8161. $cpid[$v['cpid']] = $v['cpid'];
  8162. }
  8163. if ($v['cpbz'] != '') {
  8164. $cpbz[$v['cpbz']] = $v['cpbz'];
  8165. }
  8166. }
  8167. if (isset($wt[$value['type']])) {
  8168. $rows[$key]['type'] = $wt[$value['type']];
  8169. } else {
  8170. $rows[$key]['type'] = '未设置';
  8171. }
  8172. $rows[$key]['details'] = implode("、", $details);
  8173. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8174. $ftime = time() - 15 * 24 * 3600;
  8175. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8176. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8177. $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);
  8178. $rows[$key]['c'] = $c;
  8179. $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);
  8180. $rows[$key]['t'] = $t;
  8181. $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'] . '"');
  8182. $rows[$key]['z'] = $z;
  8183. // $jm = $classid;
  8184. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8185. $features = explode('-', trim($features, '-'));
  8186. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8187. }
  8188. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8189. $final_list =[];
  8190. foreach($tmp_list as $k=>$v){
  8191. $final_list[] = [
  8192. "warehouse"=>$v['warehouse'],
  8193. "purchase"=>$v['purchase'],
  8194. "details"=>$v['details'],
  8195. "cpid"=>$v['cpid'],
  8196. "sku"=>$v['sku'],
  8197. "title"=>$v['title'],
  8198. "features"=>$v['pm'],
  8199. "cpbz"=>$v['cpbz'],
  8200. "sm"=>$v['sm'],
  8201. "type"=>$v['type'],
  8202. "g"=>$v["g"],
  8203. "c"=>$v["c"],
  8204. "x"=>$v["x"],
  8205. "t"=>$v["t"],
  8206. "z"=>$v["z"],
  8207. "jm"=>$v["jm"],
  8208. "weight"=>$v["weight"],
  8209. "asd"=>$v["asd"],
  8210. ];
  8211. }
  8212. if(empty($final_list)){
  8213. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8214. }else{
  8215. $end_list = [];
  8216. foreach($final_list as $v){
  8217. $end_list[] = array_values($v);
  8218. }
  8219. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8220. array_unshift($end_list,[
  8221. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8222. ]);
  8223. array_unshift($end_list,[
  8224. $title,"","","","","","","","","","","","","","","","","",""
  8225. ]);
  8226. $merges = [
  8227. [
  8228. "s"=>["r"=>0,"c"=>0],
  8229. "e"=>["r"=>0,"c"=>6]
  8230. ]
  8231. ];
  8232. $cols = [
  8233. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8234. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8235. ];
  8236. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8237. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8238. ])));
  8239. }
  8240. }
  8241. }
  8242. }
  8243. public function _exceljxcjs(){
  8244. $classid = $this->classid->sku();
  8245. $pm = $classid;
  8246. $typeclass = array();
  8247. $tc = $this->typeclass->find_all();
  8248. foreach ($tc as $v) {
  8249. $typeclass[$v['id']] = $v;
  8250. }
  8251. $prc = array();
  8252. $purchase = $this->purchase->find_all();
  8253. foreach ($purchase as $k => $v) {
  8254. $prc[$v['id']] = $v['title'];
  8255. }
  8256. if(!isset($_GET['excel'])){
  8257. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8258. }
  8259. $where = "sku != 'Preset'";
  8260. //数据排序
  8261. $order_str = "id desc";
  8262. if (empty($page)) {
  8263. $start = 0;
  8264. $perpage = 1;
  8265. } else {
  8266. $start = ($page - 1) * $perpage;
  8267. }
  8268. $category = $this->input->get('category', true);
  8269. $warehouse = $this->input->get('warehouse', true);
  8270. $excelid = $this->input->get('sid', true);
  8271. if ($category) {
  8272. $where .= " and features like '%-$category-%'";
  8273. }
  8274. if ($warehouse) {
  8275. $where .= " and warehouse = '$warehouse'";
  8276. }
  8277. $xzid = '';
  8278. if ($excelid) {
  8279. $excelid = explode(',', trim($excelid, ','));
  8280. foreach ($excelid as $key => $value) {
  8281. $xzid .= " id = " . $value . " or";
  8282. }
  8283. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8284. }
  8285. $wt = array();
  8286. $whlabel_type = $this->whlabel_type->find_all();
  8287. foreach ($whlabel_type as $v) {
  8288. $wt[$v['id']] = $v['title'];
  8289. }
  8290. $wh = array();
  8291. $w = $this->warehouse->find_all('1=1', 'id,title');
  8292. foreach ($w as $v) {
  8293. $wh[$v['id']] = $v['title'];
  8294. }
  8295. $list = array();
  8296. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8297. foreach ($rows as $key => $value) {
  8298. if (isset($wt[$value['type']])) {
  8299. $rows[$key]['type'] = $wt[$value['type']];
  8300. } else {
  8301. $rows[$key]['type'] = '未设置';
  8302. }
  8303. $bm = '03';
  8304. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8305. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8306. $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');
  8307. $details = array();
  8308. $cpid = array();
  8309. $cpbz = array();
  8310. $c = 0;
  8311. $g = 0;
  8312. $x = 0;
  8313. $t = 0;
  8314. $s = 0;
  8315. $q = 0;
  8316. foreach ($sd as $k => $v) {
  8317. if ($v['state'] == 0) {
  8318. $c++;
  8319. if ($v['cpid'] != 0) {
  8320. $cpid[$v['cpid']] = $v['cpid'];
  8321. }
  8322. if ($v['cpbz'] != '') {
  8323. $cpbz[$v['cpbz']] = $v['cpbz'];
  8324. }
  8325. }
  8326. if ($v['state'] != 9) {
  8327. $g++;
  8328. }
  8329. if ($v['state'] == 1) {
  8330. $x++;
  8331. }
  8332. if ($v['state'] == 2) {
  8333. $t++;
  8334. }
  8335. if ($v['state'] == 8) {
  8336. $s++;
  8337. }
  8338. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8339. $q++;
  8340. }
  8341. $details[$v['details']] = $v['details'];
  8342. }
  8343. $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'] . '"');
  8344. $rows[$key]['details'] = implode("、", $details);
  8345. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8346. $number = $value['number'];
  8347. $ftime = time() - 15 * 24 * 3600;
  8348. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8349. $rows[$key]['number'] = $g;
  8350. $rows[$key]['c'] = $c;
  8351. $rows[$key]['x'] = $x;
  8352. $rows[$key]['t'] = $t;
  8353. $rows[$key]['s'] = $s;
  8354. $rows[$key]['q'] = $q;
  8355. $rows[$key]['z'] = $z;
  8356. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8357. $features = explode('-', trim($features, '-'));
  8358. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8359. }
  8360. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8361. $final_list = [];
  8362. foreach ($list as $k => $v) {
  8363. if (empty($v['sku'])) {
  8364. continue;
  8365. }
  8366. $final_list[] = [
  8367. $v["warehouse"],
  8368. $v["purchase"],
  8369. $v["details"],
  8370. $v["cpid"],
  8371. $v["dbcontent"],
  8372. $v["sku"],
  8373. $v["bm"],
  8374. $v["jm"],
  8375. $v["title"],
  8376. $v["pm"],
  8377. $v["cpbz"],
  8378. $v["sm"],
  8379. $v["type"],
  8380. $v["number"],
  8381. $v["c"],
  8382. $v["x"],
  8383. $v["t"],
  8384. $v["s"],
  8385. $v["q"],
  8386. $v["z"],
  8387. $v['weight'],
  8388. ];
  8389. }
  8390. if(empty($final_list)){
  8391. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8392. }
  8393. $title = "总进销存统计表";
  8394. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8395. $merges = [
  8396. [
  8397. "s"=>["r"=>0,"c"=>0],
  8398. "e"=>["r"=>0,"c"=>21]
  8399. ]
  8400. ];
  8401. $cols = [
  8402. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8403. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8404. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8405. ];
  8406. array_unshift($final_list, $first_row);
  8407. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8408. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8409. }
  8410. public function _summaryjs($arg_array)
  8411. {
  8412. $prc = array();
  8413. $purchase = $this->purchase->find_all();
  8414. foreach ($purchase as $k => $v) {
  8415. $prc[$v['id']] = $v['title'];
  8416. }
  8417. if (isset($_GET['excel'])) {
  8418. $ktime = $this->input->get('ktime', true);
  8419. $jtime = $this->input->get('jtime', true);
  8420. $ktime = strtotime($ktime);
  8421. $jtime = strtotime($jtime);
  8422. $where = "1=1";
  8423. if ($ktime && $jtime) {
  8424. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8425. }
  8426. //数据排序
  8427. $order_str = "time desc";
  8428. if (empty($page)) {
  8429. $start = 0;
  8430. $perpage = 1;
  8431. } else {
  8432. $start = ($page - 1) * $perpage;
  8433. }
  8434. //取得信息列表
  8435. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8436. foreach ($info_list as $key => $value) {
  8437. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8438. $warehouse = $this->warehouse->read($value['warehouse']);
  8439. $info_list[$key]['warehouse'] = $warehouse['title'];
  8440. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8441. $details = array();
  8442. $cpid = array();
  8443. foreach ($x as $k => $v) {
  8444. if ($v['details'] != '') {
  8445. $details[$v['details']] = $v['details'];
  8446. }
  8447. if ($v['cpid'] != 0) {
  8448. $cpid[$v['cpid']] = $v['cpid'];
  8449. }
  8450. }
  8451. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8452. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8453. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8454. $info_list[$key]['s'] = $s;
  8455. $info_list[$key]['x'] = count($x);
  8456. }
  8457. if(empty($info_list)){
  8458. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8459. }
  8460. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8461. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8462. $merges = [
  8463. [
  8464. "s"=>["r"=>0,"c"=>0],
  8465. "e"=>["r"=>0,"c"=>7]
  8466. ]
  8467. ];
  8468. $cols = [
  8469. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8470. ];
  8471. $final_list = [];
  8472. foreach($info_list as $k => $v){
  8473. $final_list[] = array_values($v);
  8474. }
  8475. array_unshift($final_list, $first_row);
  8476. array_unshift($final_list,[
  8477. $title,"","","","","","","","",
  8478. ]);
  8479. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8480. $titlename = "<table border=1>
  8481. <tr align='center'>
  8482. <td>仓库</td>
  8483. <td>供应商</td>
  8484. <td>出库位置</td>
  8485. <td>出库编码</td>
  8486. <td>SKU</td>
  8487. <td>产品名</td>
  8488. <td>总剩余库存</td>
  8489. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8490. </tr>
  8491. </table>";
  8492. $filename = $title . ".xls";
  8493. $tail = "";
  8494. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8495. }
  8496. }
  8497. public function _uckjs()
  8498. {
  8499. if (isset($_GET['excel'])) {
  8500. $tc = array();
  8501. $typeclass = $this->typeclass->find_all();
  8502. foreach ($typeclass as $v) {
  8503. $tc[$v['id']] = $v['zh'];
  8504. }
  8505. $first_row = [
  8506. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8507. ];
  8508. $t = array();
  8509. $rq = '';
  8510. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8511. $ts = $ts / (24 * 3600);
  8512. for ($i = 0; $i < $ts; $i++) {
  8513. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8514. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8515. }
  8516. $day_len = count($t);
  8517. $first_row[] = "本月出库";
  8518. $merges = [
  8519. ];
  8520. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8521. $excel_key = 1;
  8522. $final_list = [];
  8523. foreach ($info_list as $k => $v) {
  8524. $features = explode('-', trim($v['features'], '-'));
  8525. if (!isset($features[3]) || !isset($features[4])) {
  8526. continue;
  8527. }
  8528. $tmp = [];
  8529. $tmp[0] = $tc[$features[0]]; //类型
  8530. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8531. $tmp[2] = $tc[$features[4]]; //曲度
  8532. $tmp[3] = '';
  8533. if (isset($data[$k][1])) {
  8534. $tmp[3] .=$tmp[1];
  8535. }
  8536. if (isset($data[$k][2])) {
  8537. $tmp[3] .= $tmp[2];
  8538. }
  8539. if (isset($features[5])) {
  8540. $tmp[3] .= $tc[$features[5]];
  8541. }
  8542. if (isset($features[2])) {
  8543. $tmp[3] .= $tc[$features[2]];
  8544. }
  8545. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8546. $tmp[4] = $v['sku'];
  8547. $tmp[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())) . '))'); //月初库存
  8548. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8549. $tmp[7] ="";
  8550. $tmp[8] ="";
  8551. $byck = 0;
  8552. foreach ($t as $vv) {
  8553. $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));
  8554. $tmp[] = ($sl > 0) ? $sl : '';
  8555. $byck += $sl;
  8556. }
  8557. $tmp[] = ($byck > 0) ? $byck : '';
  8558. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8559. // $ztrq = '';
  8560. // $ztsl = '';
  8561. // if (count($zt) > 0) {
  8562. // foreach ($zt as $vv) {
  8563. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8564. // $ztsl .= $vv['num'] . '<br>';
  8565. // }
  8566. // }
  8567. if(empty($zt)){
  8568. $final_list[] = $tmp;
  8569. $excel_key = $excel_key + 1;
  8570. }else{
  8571. $len = count($zt);
  8572. if($len == 1){
  8573. $tmp[7] = $zt[0]['num'] ;
  8574. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8575. $final_list[] = $tmp;
  8576. $excel_key = $excel_key + 1;
  8577. }else{
  8578. foreach($zt as $vv){
  8579. $tmp[7] = "";
  8580. $tmp[8] = "";
  8581. $tmp[7] = $vv['num'];
  8582. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8583. $final_list[] = $tmp;
  8584. }
  8585. $merges[] = [
  8586. "s"=>["r"=>$excel_key,"c"=>0],
  8587. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8588. ];
  8589. $merges[] = [
  8590. "s"=>["r"=>$excel_key,"c"=>1],
  8591. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8592. ];
  8593. $merges[] = [
  8594. "s"=>["r"=>$excel_key,"c"=>2],
  8595. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8596. ];
  8597. $merges[] = [
  8598. "s"=>["r"=>$excel_key,"c"=>3],
  8599. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8600. ];
  8601. $merges[] = [
  8602. "s"=>["r"=>$excel_key,"c"=>4],
  8603. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8604. ];
  8605. $merges[] = [
  8606. "s"=>["r"=>$excel_key,"c"=>5],
  8607. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8608. ];
  8609. $merges[] = [
  8610. "s"=>["r"=>$excel_key,"c"=>6],
  8611. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8612. ];
  8613. for($i=1;$i<=$day_len;$i++){
  8614. $merges[] = [
  8615. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8616. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8617. ];
  8618. }
  8619. $merges[] = [
  8620. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8621. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8622. ];
  8623. $excel_key = $excel_key + $len;
  8624. }
  8625. }
  8626. }
  8627. $title = "详情 " . date("Y-m-d", time());
  8628. if(empty($final_list)){
  8629. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8630. }
  8631. $cols = [
  8632. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8633. ];
  8634. array_unshift($final_list, $first_row);
  8635. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8636. }
  8637. }
  8638. public function _whlabelexcelzhjs(){
  8639. if(empty($_GET['excel'])){
  8640. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8641. }
  8642. $where = "sku != 'Preset' and sku != '' ";
  8643. //数据排序
  8644. $order_str = "id desc";
  8645. if (empty($page)) {
  8646. $start = 0;
  8647. $perpage = 1;
  8648. } else {
  8649. $start = ($page - 1) * $perpage;
  8650. }
  8651. $category = $this->input->get('category', true);
  8652. $warehouse = $this->input->get('warehouse', true);
  8653. $excelid = $this->input->get('sid', true);
  8654. if ($category) {
  8655. $where .= " and features like '%-$category-%'";
  8656. }
  8657. if ($warehouse) {
  8658. $where .= " and warehouse = '$warehouse'";
  8659. }
  8660. $xzid = '';
  8661. if ($excelid) {
  8662. $excelid = explode(',', trim($excelid, ','));
  8663. foreach ($excelid as $key => $value) {
  8664. $xzid .= " id = " . $value . " or";
  8665. }
  8666. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8667. }
  8668. $merges = [
  8669. [
  8670. "s"=>["r"=>0,"c"=>0],
  8671. "e"=>["r"=>0,"c"=>6]
  8672. ]
  8673. ];
  8674. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8675. $excel_index = 2;
  8676. $final_list = [];
  8677. foreach ($rows as $key => $value) {
  8678. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8679. $zh = '';
  8680. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8681. // foreach ($zt_list as $v) {
  8682. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8683. // }
  8684. $zt = array_sum(array_column($zt_list, 'num'));
  8685. $number = $value['number'];
  8686. $ftime = time() - 15 * 24 * 3600;
  8687. $warehouse = $this->warehouse->read($value['warehouse']);
  8688. // $rows[$key]['warehouse'] = $warehouse['title'];
  8689. // $rows[$key]['number'] = $c;
  8690. // $rows[$key]['features'] = $zh;
  8691. //$rows[$key]['hb'] = $c + $zt;
  8692. $tmp = [];
  8693. $tmp[0] = $warehouse['title'];
  8694. $tmp[1] = $value['sku'];
  8695. $tmp[2] = $value['title'];
  8696. $tmp[3] = $c;
  8697. $tmp[4] = "";
  8698. $tmp[5] = $c + $zt;
  8699. if(empty($zt_list)){
  8700. $tmp[4] = "";
  8701. $final_list[] = $tmp;
  8702. $excel_index = $excel_index + 1;
  8703. }else{
  8704. if(count($zt_list) == 1){
  8705. $tmp[4] = "";
  8706. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8707. $final_list[] = $tmp;
  8708. $excel_index = $excel_index + 1;
  8709. }else{
  8710. $len = count($zt_list);
  8711. foreach ($zt_list as $v){
  8712. $tmp[4] = "";
  8713. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8714. $final_list[] = $tmp;
  8715. }
  8716. $merges[] = [
  8717. "s"=>["r"=>$excel_index,"c"=>0],
  8718. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8719. ];
  8720. $merges[] = [
  8721. "s"=>["r"=>$excel_index,"c"=>1],
  8722. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8723. ];
  8724. $merges[] = [
  8725. "s"=>["r"=>$excel_index,"c"=>2],
  8726. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8727. ];
  8728. $merges[] = [
  8729. "s"=>["r"=>$excel_index,"c"=>3],
  8730. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8731. ];
  8732. $merges[] = [
  8733. "s"=>["r"=>$excel_index,"c"=>5],
  8734. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8735. ];
  8736. $excel_index = $excel_index + $len;
  8737. }
  8738. }
  8739. }
  8740. $first_row = [
  8741. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8742. ];
  8743. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8744. if(empty($final_list)){
  8745. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8746. }
  8747. $cols = [
  8748. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8749. ];
  8750. array_unshift($final_list, $first_row);
  8751. array_unshift($final_list, [
  8752. $title,"","","","",""
  8753. ]);
  8754. $end_list = [];
  8755. foreach ($final_list as $key => $value) {
  8756. $end_list[] = array_values($value);
  8757. }
  8758. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8759. }
  8760. //出库、退库导出
  8761. public function _dccrtypejs()
  8762. {
  8763. $classid = $this->classid->sku();
  8764. $pm = $classid;
  8765. $typeclass = array();
  8766. $tc = $this->typeclass->find_all();
  8767. foreach ($tc as $v) {
  8768. $typeclass[$v['id']] = $v;
  8769. }
  8770. $prc = array();
  8771. $purchase = $this->purchase->find_all();
  8772. foreach ($purchase as $k => $v) {
  8773. $prc[$v['id']] = $v['title'];
  8774. }
  8775. if (isset($_GET['sid'])) {
  8776. $wh = array();
  8777. $w = $this->warehouse->find_all('1=1', 'id,title');
  8778. foreach ($w as $v) {
  8779. $wh[$v['id']] = $v['title'];
  8780. }
  8781. $type = $this->input->get('excel', true);
  8782. $category = $this->input->get('category', true);
  8783. $size = $this->input->get('size', true);
  8784. $grade = $this->input->get('grade', true);
  8785. $color = $this->input->get('color', true);
  8786. $lowe = $this->input->get('lowe', true);
  8787. $sku = $this->input->get('sku', true);
  8788. $warehouse = $this->input->get('warehouse', true);
  8789. $lacetype = $this->input->get('lacetype', true);
  8790. $lacecolor = $this->input->get('lacecolor', true);
  8791. $density = $this->input->get('density', true);
  8792. $haircap = $this->input->get('haircap', true);
  8793. $purchase = $this->input->get('purchase', true);
  8794. $title = $this->input->get('title', true);
  8795. $state = $this->input->get('state', true);
  8796. $sid = $this->input->get('sid', true);
  8797. $ktime = $this->input->get('ktime', true);
  8798. $jtime = $this->input->get('jtime', true);
  8799. $ktime = strtotime($ktime);
  8800. $jtime = strtotime($jtime);
  8801. $where = "1=1";
  8802. $gj = "";
  8803. $ck = "";
  8804. if ($category) {
  8805. $where .= " and features like '%-$category-%'";
  8806. }
  8807. if ($size) {
  8808. $where .= " and features like '%-$size-%'";
  8809. }
  8810. if ($grade) {
  8811. $where .= " and features like '%-$grade-%'";
  8812. }
  8813. if ($color) {
  8814. $where .= " and features like '%-$color-%'";
  8815. }
  8816. if ($lowe) {
  8817. $where .= " and features like '%-$lowe-%'";
  8818. }
  8819. if ($warehouse) {
  8820. $where .= " and warehouse = '$warehouse'";
  8821. }
  8822. if ($purchase) {
  8823. $where .= " and purchase = '$purchase'";
  8824. }
  8825. if ($state) {
  8826. $where .= " and state = '$state'";
  8827. }
  8828. if ($lacetype) {
  8829. $where .= " and features like '%-$lacetype-%'";
  8830. }
  8831. if ($lacecolor) {
  8832. $where .= " and features like '%-$lacecolor-%'";
  8833. }
  8834. if ($density) {
  8835. $where .= " and features like '%-$density-%'";
  8836. }
  8837. if ($haircap) {
  8838. $where .= " and features like '%-$haircap-%'";
  8839. }
  8840. if ($title) {
  8841. $title = trim($title, ' ');
  8842. $title = trim($title, ' ');
  8843. $where .= " and title like '%$title%'";
  8844. }
  8845. if ($sku) {
  8846. $sku = trim($sku, ' ');
  8847. $sku = trim($sku, ' ');
  8848. $where .= " and sku like '%$sku%'";
  8849. }
  8850. if ($ktime && $jtime) {
  8851. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8852. }
  8853. $sidwhere = '';
  8854. if ($sid) {
  8855. $sd = "";
  8856. $s = explode(',', trim($sid, ','));
  8857. foreach ($s as $value) {
  8858. $sd .= " id = " . $value . " or";
  8859. }
  8860. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8861. }
  8862. //数据排序
  8863. $order_str = "time desc";
  8864. if (empty($page)) {
  8865. $start = 0;
  8866. $perpage = 1;
  8867. } else {
  8868. $start = ($page - 1) * $perpage;
  8869. }
  8870. $wh = array();
  8871. $w = $this->warehouse->find_all('1=1', 'id,title');
  8872. foreach ($w as $v) {
  8873. $wh[$v['id']] = $v['title'];
  8874. }
  8875. $wt = array();
  8876. $whlabel_type = $this->whlabel_type->find_all();
  8877. foreach ($whlabel_type as $v) {
  8878. $wt[$v['id']] = $v['title'];
  8879. }
  8880. $classid = $this->classid->sku();
  8881. $list = array();
  8882. $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');
  8883. foreach ($rows_r as $key => $value) {
  8884. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8885. $pm = $classid;
  8886. $jm = $classid;
  8887. $rows_r[$key]['enter'] = '入库';
  8888. $rows_r[$key]['time'] = $value['enter'];
  8889. if ($value['rktype'] == 1) {
  8890. $rows_r[$key]['rktype'] = '采购入库';
  8891. } else if ($value['rktype'] == 2) {
  8892. $rows_r[$key]['rktype'] = '盘盈调整';
  8893. } else if ($value['rktype'] == 3) {
  8894. $rows_r[$key]['rktype'] = '其他调整入库';
  8895. } else if ($value['rktype'] == 4) {
  8896. $rows_r[$key]['rktype'] = '其他调整入库';
  8897. } else if ($value['rktype'] == 5) {
  8898. $rows_r[$key]['rktype'] = '退库入库';
  8899. } else if ($value['rktype'] == 6) {
  8900. $rows_r[$key]['rktype'] = '退货可用入库';
  8901. } else if ($value['rktype'] == 7) {
  8902. $rows_r[$key]['rktype'] = '形态转换入库';
  8903. } else {
  8904. $rows_r[$key]['rktype'] = '';
  8905. }
  8906. $features = explode('-', trim($value['features'], '-'));
  8907. foreach ($features as $v) {
  8908. if (isset($typeclass[$v])) {
  8909. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8910. $pm[$typeclass[$v]['classid']] = $zh[0];
  8911. }
  8912. if (isset($typeclass[$v])) {
  8913. if (isset($jm[$typeclass[$v]['classid']])) {
  8914. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8915. }
  8916. }
  8917. }
  8918. $zh = implode(" ", $pm);
  8919. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8920. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8921. $rows_r[$key]['zh'] = $zh;
  8922. $jm = array_filter($jm);
  8923. $rows_r[$key]['features'] = implode("-", $jm);
  8924. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8925. }
  8926. $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');
  8927. foreach ($rows_c as $key => $value) {
  8928. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8929. $pm = $classid;
  8930. $jm = $classid;
  8931. $rows_c[$key]['time'] = $value['outk'];
  8932. $rows_c[$key]['outk'] = '出库';
  8933. if ($value['cktype'] == 1) {
  8934. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8935. } else if ($value['cktype'] == 2) {
  8936. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8937. } else if ($value['cktype'] == 3) {
  8938. $rows_c[$key]['cktype'] = '盘亏调整';
  8939. } else if ($value['cktype'] == 4) {
  8940. $rows_c[$key]['cktype'] = '其他调整出库';
  8941. } else if ($value['cktype'] == 5) {
  8942. $rows_c[$key]['cktype'] = '形态转换出库';
  8943. } else {
  8944. $rows_c[$key]['cktype'] = '';
  8945. }
  8946. unset($rows_c[$key]['state']);
  8947. $features = explode('-', trim($value['features'], '-'));
  8948. foreach ($features as $v) {
  8949. if (isset($typeclass[$v])) {
  8950. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8951. $pm[$typeclass[$v]['classid']] = $zh[0];
  8952. }
  8953. if (isset($typeclass[$v])) {
  8954. if (isset($jm[$typeclass[$v]['classid']])) {
  8955. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8956. }
  8957. }
  8958. }
  8959. $zh = implode(" ", $pm);
  8960. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8961. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8962. $rows_c[$key]['zh'] = $zh;
  8963. $jm = array_filter($jm);
  8964. $rows_c[$key]['features'] = implode("-", $jm);
  8965. $rows_c[$key]['number'] = 1;
  8966. }
  8967. $merged = $rows_r;
  8968. foreach ($rows_c as $key => $value) {
  8969. if (isset($merged[$key])) {
  8970. $merged[] = $value;
  8971. } else {
  8972. $merged[$key] = $value;
  8973. }
  8974. }
  8975. usort($merged, function ($a, $b) {
  8976. return $a['time'] - $b['time'];
  8977. });
  8978. foreach ($merged as $key => $value) {
  8979. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8980. }
  8981. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8982. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  8983. $cols = [
  8984. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8985. ];
  8986. $final_list= [];
  8987. foreach($merged as $key => $value){
  8988. $final_list[] = array_values($value) ;
  8989. }
  8990. if(empty($merged)){
  8991. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8992. }
  8993. array_unshift($final_list, $first_row);
  8994. $end_list = [];
  8995. foreach ($final_list as $key => $value) {
  8996. $end_list[] = array_values($value);
  8997. }
  8998. $merges = [];
  8999. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9000. }
  9001. }
  9002. public function _errorexceljs()
  9003. {
  9004. $post = $this->input->post(NULL, TRUE);
  9005. if (isset($_GET['page'])) {
  9006. $page = $this->input->get('page', true);
  9007. $perpage = $this->input->get('perpage', true);
  9008. $sku = $this->input->get('sku', true);
  9009. $warehouse = $this->input->get('warehouse', true);
  9010. $ktime = $this->input->get('ktime', true);
  9011. $jtime = $this->input->get('jtime', true);
  9012. $ktime = strtotime($ktime);
  9013. $jtime = strtotime($jtime);
  9014. $where = "sku != 'Preset'";
  9015. $gj = '';
  9016. if ($sku) {
  9017. $where .= " and sku like '%$sku%'";
  9018. } else {
  9019. if ($ktime && $jtime) {
  9020. $gj = " and time > '$ktime' and time < '$jtime'";
  9021. }
  9022. }
  9023. if ($warehouse) {
  9024. $where .= " and warehouse = '$warehouse'";
  9025. }
  9026. //数据排序
  9027. $order_str = "id desc";
  9028. if (empty($page)) {
  9029. $start = 0;
  9030. $perpage = 1;
  9031. } else {
  9032. $start = ($page - 1) * $perpage;
  9033. }
  9034. //取得信息列表
  9035. $rows = array();
  9036. $list = array();
  9037. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9038. foreach ($info_list as $value) {
  9039. $warehouse = $this->warehouse->read($value['warehouse']);
  9040. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9041. $number = $value['number'];
  9042. $ftime = time() - 15 * 24 * 3600;
  9043. if ($c < 1) {
  9044. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9045. }
  9046. }
  9047. $title = "0库存汇总";
  9048. $first_row = ["仓库","SKU","产品","当前库存"];
  9049. $cols = [
  9050. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9051. ];
  9052. $final_list= [];
  9053. foreach($list as $key => $value){
  9054. $final_list[] = array_values($value) ;
  9055. }
  9056. if(empty($final_list)){
  9057. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9058. }
  9059. array_unshift($final_list, $first_row);
  9060. $merges = [];
  9061. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9062. }
  9063. }
  9064. }