Whlabel.php 318 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377
  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. $this->load->_model("Model_excel","excelxh");
  48. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg, $arg_array)
  51. {
  52. if ($arg == 'existence') //在库标签
  53. {
  54. $this->_existence();
  55. } else if ($arg == 'cpbqdc') //在库标签
  56. {
  57. $this->_cpbqdc();
  58. } else if ($arg == 'type') //进销存浏览
  59. {
  60. $this->_type();
  61. } else if ($arg == 'typedy') //进销存浏览店员页面
  62. {
  63. $this->_typedy($arg_array);
  64. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  65. {
  66. $this->_typedy_ck($arg_array);
  67. } else if ($arg == 'typeck') {
  68. $this->_typeck($arg_array);
  69. } else if ($arg == 'whlabeckdc') {
  70. $this->_whlabeckdc($arg_array);
  71. } else if ($arg == 'usatype') //美仓进销存浏览
  72. {
  73. $this->_usatype();
  74. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  75. {
  76. $this->_usatypeapp();
  77. } else if ($arg == 'enteradd') //入库操作
  78. {
  79. $this->_enteradd();
  80. } else if ($arg == 'enteredit') //修改
  81. {
  82. $this->_enteredit($arg_array);
  83. } else if ($arg == 'enter') //入库浏览
  84. {
  85. $this->_enter();
  86. } else if ($arg == 'out') //出库浏览
  87. {
  88. $this->_out();
  89. } else if ($arg == 'label') //出库标签浏览
  90. {
  91. $this->_label();
  92. } else if ($arg == 'outorder') //独立站出库订单
  93. {
  94. $this->_outorder();
  95. } else if ($arg == 'soutorder') //速卖通出库订单
  96. {
  97. $this->_soutorder();
  98. } else if ($arg == 'toutorder') //TT出库订单
  99. {
  100. $this->_toutorder();
  101. }else if ($arg == 'aoutorder') //amz出库订单
  102. {
  103. $this->_aoutorder();
  104. } else if ($arg == 'retreat') //退库订单
  105. {
  106. $this->_retreat();
  107. } else if ($arg == 'retreatlk') //退库订单
  108. {
  109. $this->_retreatlk();
  110. } else if ($arg == 'change') //更换标签
  111. {
  112. $this->_change();
  113. } else if ($arg == 'del') //删除
  114. {
  115. $this->_del();
  116. } else if ($arg == 'exceljxc') //进销存信息导出
  117. {
  118. $this->_exceljxc();
  119. } else if ($arg == 'excelr') //入库信息导出
  120. {
  121. $this->_excelr();
  122. } else if ($arg == 'excelct') //出库、退库信息导出
  123. {
  124. $this->_excelct();
  125. } else if ($arg == 'dccrtype') //根据出入库类型导出
  126. {
  127. $this->_dccrtype();
  128. } else if ($arg == 'excelcr') //出库、退库信息导出
  129. {
  130. $this->_excelcr();
  131. } else if ($arg == 'kcyz') //库存验证
  132. {
  133. $this->_kcyz();
  134. } else if ($arg == 'kj') //库存扣减
  135. {
  136. $this->_kj($arg_array);
  137. } else if ($arg == 'presetout') //预设库存导入
  138. {
  139. $this->_presetout($arg_array);
  140. } else if ($arg == 'presetedit') //预设库存导入
  141. {
  142. $this->_presetedit($arg_array);
  143. }else if ($arg == 'presetedittwo') //预设库存导入
  144. {
  145. $this->_presetedittwo($arg_array);
  146. } else if ($arg == 'summary') //汇总导出
  147. {
  148. $this->_summary($arg_array);
  149. } else if ($arg == 'manifest') //usps发货清单
  150. {
  151. $this->_manifest();
  152. } else if ($arg == 'abnormal') //占单异常
  153. {
  154. $this->_abnormal();
  155. } else if ($arg == 'error') //0库存SKU
  156. {
  157. $this->_error();
  158. } else if ($arg == 'errorexcel') //0库存SKU导出
  159. {
  160. $this->_errorexcel();
  161. } else if ($arg == 'db') {
  162. $this->_db();
  163. } else if ($arg == 'dbrk') {
  164. $this->_dbrk();
  165. } else if ($arg == 'whlabelczdc') {
  166. $this->_whlabelczdc();
  167. } else if ($arg == 'print') {
  168. $this->_print($arg_array);
  169. } else if ($arg == 'usaprint') {
  170. $this->_usaprint($arg_array);
  171. } else if ($arg == 'printck') {
  172. $this->_printck($arg_array);
  173. } else if ($arg == 'printrk') {
  174. $this->_printrk($arg_array);
  175. } else if ($arg == 'printxzrk') {
  176. $this->_printxzrk($arg_array);
  177. } else if ($arg == 'printexcel') {
  178. $this->_printexcel($arg_array);
  179. } else if ($arg == 'uck') {
  180. $this->_uck();
  181. } else if ($arg == 'whlabelexcelzh') {
  182. $this->_whlabelexcelzh();
  183. } else if ($arg == 'fc') {
  184. $this->_fc();
  185. } else if ($arg == 'fcmb') {
  186. $this->_fcmb();
  187. } else if ($arg == 'fcexcel') {
  188. $this->_fcexcel();
  189. } else if ($arg == 'fcjxc') {
  190. $this->_fcjxc($arg_array);
  191. } else if ($arg == '0kcdel') {
  192. $this->_0kcdel(); //导表删除0库存
  193. } else if ($arg == 'gbhtype') {
  194. $this->_gbhtype(); //更改备货状态
  195. } else if($arg == 'excelrjs'){
  196. $this->_excelrjs();
  197. } else if($arg == 'excelctjs'){
  198. $this->_excelctjs();
  199. }else if ($arg == 'exceljxcjs') //进销存信息导出
  200. {
  201. $this->_exceljxcjs();
  202. } else if ($arg == 'summaryjs') //汇总导出
  203. {
  204. $this->_summaryjs($arg_array);
  205. }else if($arg == 'uckjs'){
  206. $this->_uckjs();
  207. }else if ($arg == 'whlabelexcelzhjs') {
  208. $this->_whlabelexcelzhjs();
  209. }else if($arg == 'dccrtypejs'){
  210. $this->_dccrtypejs();
  211. }else if($arg == 'errorexceljs'){
  212. $this->_errorexceljs();
  213. }else if($arg == "w_t_cs"){
  214. $this->_w_t_cs(); //首页
  215. }else {
  216. $this->_index();
  217. }
  218. }
  219. public function _w_t_cs(){
  220. $vip = 0;
  221. if (isset($_SESSION['api'])) {
  222. $user = $this->user->get_api($_SESSION['api']);
  223. $fgshop = "";
  224. $sid = "";
  225. $usersp = explode('|', trim($user['shop'], '|'));
  226. foreach ($usersp as $value) {
  227. $fgshop .= " shop = " . $value . " or";
  228. $sid .= " id = " . $value . " or";
  229. }
  230. if ($user['vip'] == 1) {
  231. $vip = 1;
  232. }
  233. } else {
  234. header('Location: /');
  235. exit;
  236. }
  237. $prc = array();
  238. $purchase = $this->purchase->find_all();
  239. foreach ($purchase as $k => $v) {
  240. $prc[$v['id']] = $v['title'];
  241. }
  242. $company = array();
  243. $ct = $this->company->find_all();
  244. foreach ($ct as $k => $v) {
  245. $company[$v['id']] = $v['title'];
  246. }
  247. $sp = array();
  248. $s = $this->shop->find_all('1=1', 'id,shopname');
  249. foreach ($s as $v) {
  250. $sp[$v['id']] = $v['shopname'];
  251. }
  252. $wh = array();
  253. $w = $this->warehouse->find_all('1=1', 'id,title');
  254. foreach ($w as $v) {
  255. $wh[$v['id']] = $v['title'];
  256. }
  257. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  258. $this->data['shop'] = $wlshop;
  259. $this->data['vip'] = $vip;
  260. $this->_Template('whlabel_typejs', $this->data);
  261. }
  262. //管理
  263. public function _index()
  264. {
  265. $post = $this->input->post(NULL, TRUE);
  266. if (isset($post['page'])) {
  267. $page = $this->input->post('page', true);
  268. $perpage = $this->input->post('perpage', true);
  269. $sku = $this->input->post('sku', true);
  270. $number = $this->input->post('number', true);
  271. $warehouse = $this->input->post('warehouse', true);
  272. $purchase = $this->input->post('purchase', true);
  273. $orderinfo = $this->input->post('orderinfo', true);
  274. $waybill = $this->input->post('waybill', true);
  275. $category = $this->input->post('category', true);
  276. $size = $this->input->post('size', true);
  277. $grade = $this->input->post('grade', true);
  278. $color = $this->input->post('color', true);
  279. $lowe = $this->input->post('lowe', true);
  280. $state = $this->input->post('state', true);
  281. $label = $this->input->post('label', true);
  282. $timetk = $this->input->post('timetkk', true);
  283. $timetj = $this->input->post('timetjj', true);
  284. $timetk = strtotime($timetk);
  285. $timetj = strtotime($timetj);
  286. $where = "1=1 ";
  287. if ($timetk && $timetj) {
  288. $where .= " and time > '$timetk' and time < '$timetj'";
  289. }
  290. if ($sku) {
  291. $where .= " and sku = '$sku'";
  292. }
  293. if ($number) {
  294. $where .= " and number = '$number'";
  295. }
  296. if ($warehouse) {
  297. $where .= " and warehouse = '$warehouse'";
  298. }
  299. if ($purchase) {
  300. $where .= " and purchase = '$purchase'";
  301. }
  302. if ($orderinfo) {
  303. $where .= " and orderinfo = '$orderinfo'";
  304. }
  305. if ($waybill) {
  306. $where .= " and waybill = '$waybill'";
  307. }
  308. if ($category) {
  309. $where .= " and features like '%-$category-%'";
  310. }
  311. if ($size) {
  312. $where .= " and features like '%-$size-%'";
  313. }
  314. if ($grade) {
  315. $where .= " and features like '%-$grade-%'";
  316. }
  317. if ($color) {
  318. $where .= " and features like '%-$color-%'";
  319. }
  320. if ($lowe) {
  321. $where .= " and features like '%-$lowe-%'";
  322. }
  323. if ($label) {
  324. $where .= " and label = '$label'";
  325. }
  326. if ($state != '') {
  327. $where .= " and state = '$state'";
  328. }
  329. //数据排序
  330. $order_str = "time desc";
  331. if (empty($page)) {
  332. $start = 0;
  333. $perpage = 1;
  334. } else {
  335. $start = ($page - 1) * $perpage;
  336. }
  337. //取得信息列表
  338. $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);
  339. foreach ($info_list as $key => $value) {
  340. $warehouse = $this->warehouse->read($value['warehouse']);
  341. $info_list[$key]['warehouse'] = $warehouse['title'];
  342. $purchase = $this->purchase->read($value['purchase']);
  343. $info_list[$key]['purchase'] = $purchase['title'];
  344. if ($value['enter'] != 0) {
  345. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  346. } else {
  347. $info_list[$key]['enter'] = "";
  348. }
  349. if ($value['outk'] != 0) {
  350. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  351. } else {
  352. $info_list[$key]['outk'] = "";
  353. }
  354. if ($value['printing'] != 0) {
  355. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  356. } else {
  357. $info_list[$key]['printing'] = "";
  358. }
  359. if ($value['orderinfo'] == 0) {
  360. $info_list[$key]['orderinfo'] = "";
  361. }
  362. if ($value['waybill'] == 0) {
  363. $info_list[$key]['waybill'] = "";
  364. }
  365. if ($value['state'] == 0) {
  366. $info_list[$key]['state'] = "在库";
  367. } else if ($value['state'] == 1) {
  368. $info_list[$key]['state'] = "出库";
  369. } else if ($value['state'] == 2) {
  370. $info_list[$key]['state'] = "退库";
  371. } else if ($value['state'] == 3) {
  372. $info_list[$key]['state'] = "调拨中";
  373. } else if ($value['state'] == 4) {
  374. $info_list[$key]['state'] = "再加工";
  375. } else if ($value['state'] == 5) {
  376. $info_list[$key]['state'] = "维修中";
  377. } else if ($value['state'] == 6) {
  378. $info_list[$key]['state'] = "盘亏";
  379. } else if ($value['state'] == 7) {
  380. $info_list[$key]['state'] = "更换标签";
  381. } else if ($value['state'] == 8) {
  382. $info_list[$key]['state'] = "其它";
  383. } else if ($value['state'] == 9) {
  384. $info_list[$key]['state'] = "预设";
  385. } else if ($value['state'] == 10) {
  386. $info_list[$key]['state'] = "美店零售";
  387. }
  388. if ($value['text'] == "") {
  389. $info_list[$key]['text'] = "";
  390. }
  391. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  392. }
  393. $total = $this->whlabel->find_count($where);
  394. $pagenum = ceil($total / $perpage);
  395. $over = $total - ($start + $perpage);
  396. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  397. echo json_encode($rows);
  398. exit;
  399. }
  400. if (isset($post['outsku'])) {
  401. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  402. $cz = $this->input->post('cz', true);
  403. if ($cz == '1') {
  404. $sku = $this->input->post('outsku', true);
  405. if ($sku) {
  406. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  407. if (count($data) < 1) {
  408. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  409. exit;
  410. }
  411. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  412. echo json_encode(array('success' => true));
  413. exit;
  414. }
  415. } else {
  416. $sku = $this->input->post('outsku', true);
  417. if ($sku) {
  418. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  419. if (count($data) < 1) {
  420. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  421. exit;
  422. }
  423. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  424. echo json_encode(array('success' => true));
  425. exit;
  426. }
  427. }
  428. }
  429. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  430. $this->_Template('whlabel', $this->data);
  431. }
  432. //在库标签
  433. public function _existence()
  434. {
  435. $post = $this->input->post(NULL, TRUE);
  436. if (isset($post['s'])) {
  437. $id_arr = $this->input->post('s');
  438. $id_arr = explode(',', $id_arr);
  439. if (!$id_arr) {
  440. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  441. exit;
  442. }
  443. //循环删除记录
  444. foreach ($id_arr as $v) {
  445. $sid = $this->whlabel->read($v);
  446. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  447. if ($count > 0) {
  448. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  449. exit;
  450. }
  451. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  452. if (count($zt) > 0) {
  453. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  454. exit;
  455. }
  456. $this->whlabel->remove($v);
  457. }
  458. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  459. exit;
  460. }
  461. if (isset($post['page'])) {
  462. $page = $this->input->post('page', true);
  463. $perpage = $this->input->post('perpage', true);
  464. $warehouse = $this->input->post('warehouse', true);
  465. $label = $this->input->post('label', true);
  466. $where = "1=1 and state = 0";
  467. if ($warehouse) {
  468. $where .= " and warehouse = '$warehouse'";
  469. }
  470. if ($label) {
  471. $where .= " and label = '$label'";
  472. }
  473. //数据排序
  474. $order_str = "time asc";
  475. if (empty($page)) {
  476. $start = 0;
  477. $perpage = 1;
  478. } else {
  479. $start = ($page - 1) * $perpage;
  480. }
  481. //取得信息列表
  482. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  483. foreach ($info_list as $key => $value) {
  484. if ($value['enter'] != 0) {
  485. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  486. } else {
  487. $info_list[$key]['enter'] = "";
  488. }
  489. if ($value['printing'] != 0) {
  490. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  491. } else {
  492. $info_list[$key]['printing'] = "";
  493. }
  494. }
  495. $total = $this->whlabel->find_count($where);
  496. $pagenum = ceil($total / $perpage);
  497. $over = $total - ($start + $perpage);
  498. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  499. echo json_encode($rows);
  500. exit;
  501. }
  502. $this->_Template('whlabel_existence', $this->data);
  503. }
  504. //进销存浏览
  505. public function _typedy($arg_array)
  506. {
  507. $prc = array();
  508. $purchase = $this->purchase->find_all();
  509. foreach ($purchase as $k => $v) {
  510. $prc[$v['id']] = $v['title'];
  511. }
  512. $post = $this->input->post(NULL, TRUE);
  513. if (isset($post['page'])) {
  514. $page = $this->input->post('page', true);
  515. $perpage = $this->input->post('perpage', true);
  516. $category = $this->input->post('category', true);
  517. $size = $this->input->post('size', true);
  518. $grade = $this->input->post('grade', true);
  519. $color = $this->input->post('color', true);
  520. $lowe = $this->input->post('lowe', true);
  521. $sku = $this->input->post('sku');
  522. $title = $this->input->post('title');
  523. $warehouse = $this->input->post('warehouse', true);
  524. $usa = $this->input->post('usa', true);
  525. $purchase = $this->input->post('purchase', true);
  526. $lacetype = $this->input->post('lacetype', true);
  527. $haircap = $this->input->post('haircap', true);
  528. $density = $this->input->post('density', true);
  529. $details = $this->input->post('details', true);
  530. $state = $this->input->post('state', true);
  531. $lacecolor = $this->input->post('lacecolor', true);
  532. $hairnumber = $this->input->post('hairnumber', true);
  533. $cklx = $this->input->post('cklx', true);
  534. $ktime = $this->input->post('ktime', true);
  535. $jtime = $this->input->post('jtime', true);
  536. $sm = $this->input->post('sm', true);
  537. $cpbz = $this->input->post('cpbz', true);
  538. $type = $this->input->post('type', true);
  539. $ktime = strtotime($ktime);
  540. $jtime = strtotime($jtime);
  541. $where = "1=1";
  542. $gj = "";
  543. $ck = "";
  544. if ($usa) {
  545. if (!$warehouse) {
  546. $where .= " and (warehouse = '5' or warehouse = '8')";
  547. }
  548. }
  549. if ($warehouse) {
  550. $where .= " and warehouse = '$warehouse'";
  551. }
  552. if ($details) {
  553. $where .= " and details = '$details'";
  554. }
  555. if ($purchase) {
  556. $where .= " and purchase = '$purchase'";
  557. }
  558. if (isset($state)) {
  559. if($state >-1){
  560. $where .= " and state = '$state'";
  561. }
  562. }
  563. if ($lacetype) {
  564. $where .= " and features like '%-$lacetype-%'";
  565. }
  566. if ($category) {
  567. $where .= " and features like '%-$category-%'";
  568. }
  569. if ($size) {
  570. $where .= " and features like '%-$size-%'";
  571. }
  572. if ($grade) {
  573. $where .= " and features like '%-$grade-%'";
  574. }
  575. if ($color) {
  576. $where .= " and features like '%-$color-%'";
  577. }
  578. if ($lowe) {
  579. $where .= " and features like '%-$lowe-%'";
  580. }
  581. if ($haircap) {
  582. $where .= " and features like '%-$haircap-%'";
  583. }
  584. if ($density) {
  585. $where .= " and features like '%-$density-%'";
  586. }
  587. if ($lacecolor) {
  588. $where .= " and features like '%-$lacecolor-%'";
  589. }
  590. if($sm){
  591. $where .= " and sm like '%".$sm."%'";
  592. }
  593. if($cpbz){
  594. $where .= " and cpbz like '%".$cpbz."%'";
  595. }
  596. if($type){
  597. $where .= " and type = ".$type."";
  598. }
  599. if (!empty($hairnumber)) {
  600. $where .= " and features like '%-128-%' ";
  601. if ($hairnumber < 0) {
  602. $class_list = $this->typeclass->find_all('classid = 43');
  603. foreach ($class_list as $v) {
  604. $where .= " and features not like '%-" . $v['id'] . "-%'";
  605. }
  606. } else {
  607. $where .= " and features like '%-$hairnumber-%'";
  608. }
  609. }
  610. $where_add = '';
  611. if ($cklx) {
  612. $shop = $this->shop->read($cklx);
  613. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  614. }
  615. if ($ktime && $jtime) {
  616. $gj = " and enter > '$ktime' and enter < '$jtime'";
  617. $ck = " and outk > '$ktime' and outk < '$jtime'";
  618. }
  619. //数据排序
  620. $order_str = "id desc";
  621. if (empty($page)) {
  622. $start = 0;
  623. $perpage = 1;
  624. } else {
  625. $start = ($page - 1) * $perpage;
  626. }
  627. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  628. if ($sku) {
  629. $sku = trim($sku, ' ');
  630. $sku = trim($sku, ' ');
  631. $where .= " and sku like '%$sku%'";
  632. $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);
  633. } else if ($title) {
  634. $title = trim($title, ' ');
  635. $title = trim($title, ' ');
  636. $where .= " and title like '%$title%'";
  637. $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);
  638. } else {
  639. //$where .= " and time > '$ktime' and time < '$jtime'";
  640. $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);
  641. }
  642. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  643. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  644. foreach ($info_list as $k => $v) {
  645. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  646. unset($info_list[$k]['pm']);
  647. unset($info_list[$k]['jm']);
  648. unset($info_list[$k]['bm']);
  649. }
  650. //取得信息列表
  651. $rows = array();
  652. $list = array();
  653. foreach ($info_list as $key => $value) {
  654. $warehouse = $this->warehouse->read($value['warehouse']);
  655. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  656. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  657. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  658. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  659. $info_list[$key]['label'] = $value['sm'];
  660. $number = $value['number'];
  661. $ftime = time() - 15 * 24 * 3600;
  662. $info_list[$key]['warehouse'] = $warehouse['title'];
  663. $info_list[$key]['features'] = count($c);
  664. $z = count($z); //查看订单号
  665. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  666. $ztdata = '';
  667. if (count($zt) > 0) {
  668. foreach ($zt as $vv) {
  669. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  670. }
  671. }
  672. $info_list[$key]['number'] = $ztdata;
  673. $info_list[$key]['sm'] = $z;
  674. $details = array();
  675. $cpid = array();
  676. foreach ($c as $k => $v) {
  677. $details[$v['details']] = $v['details'];
  678. if ($v['cpid'] != 0) {
  679. $cpid[$v['cpid']] = $v['cpid'];
  680. }
  681. }
  682. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  683. if ($value['shop'] != '') {
  684. $shop = explode(',', trim($value['shop'], ','));
  685. $shop = $this->shop->read($shop[0]);
  686. $info_list[$key]['shop'] = $shop['shopname'];
  687. }
  688. }
  689. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  690. $pagenum = ceil($total / $perpage);
  691. $over = $total - ($start + $perpage);
  692. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  693. echo json_encode($rows);
  694. exit;
  695. }
  696. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  697. $this->_Template('whlabel_typedy', $this->data);
  698. }
  699. //进销存浏览
  700. public function _typedy_ck($arg_array)
  701. {
  702. $prc = array();
  703. $purchase = $this->purchase->find_all();
  704. foreach ($purchase as $k => $v) {
  705. $prc[$v['id']] = $v['title'];
  706. }
  707. $post = $this->input->post(NULL, TRUE);
  708. if (isset($post['page'])) {
  709. $page = $this->input->post('page', true);
  710. $perpage = $this->input->post('perpage', true);
  711. $category = $this->input->post('category', true);
  712. $size = $this->input->post('size', true);
  713. $grade = $this->input->post('grade', true);
  714. $color = $this->input->post('color', true);
  715. $lowe = $this->input->post('lowe', true);
  716. $sku = $this->input->post('sku');
  717. $title = $this->input->post('title');
  718. $warehouse = $this->input->post('warehouse', true);
  719. $usa = $this->input->post('usa', true);
  720. $purchase = $this->input->post('purchase', true);
  721. $lacetype = $this->input->post('lacetype', true);
  722. $haircap = $this->input->post('haircap', true);
  723. $density = $this->input->post('density', true);
  724. $details = $this->input->post('details', true);
  725. $state = $this->input->post('state', true);
  726. $lacecolor = $this->input->post('lacecolor', true);
  727. $cklx = $this->input->post('cklx', true);
  728. $ktime = $this->input->post('ktime', true);
  729. $jtime = $this->input->post('jtime', true);
  730. $ktime = strtotime($ktime);
  731. $jtime = strtotime($jtime);
  732. $where = "1=1";
  733. $gj = "";
  734. $ck = "";
  735. if ($lacetype) {
  736. $where .= " and features like '%-$lacetype-%'";
  737. }
  738. if ($category) {
  739. $where .= " and features like '%-$category-%'";
  740. }
  741. if ($size) {
  742. $where .= " and features like '%-$size-%'";
  743. }
  744. if ($grade) {
  745. $where .= " and features like '%-$grade-%'";
  746. }
  747. if ($color) {
  748. $where .= " and features like '%-$color-%'";
  749. }
  750. if ($lowe) {
  751. $where .= " and features like '%-$lowe-%'";
  752. }
  753. if ($haircap) {
  754. $where .= " and features like '%-$haircap-%'";
  755. }
  756. if ($density) {
  757. $where .= " and features like '%-$density-%'";
  758. }
  759. if ($lacecolor) {
  760. $where .= " and features like '%-$lacecolor-%'";
  761. }
  762. if ($usa) {
  763. if (!$warehouse) {
  764. $where .= " and (warehouse = '5' or warehouse = '8')";
  765. }
  766. }
  767. if ($warehouse) {
  768. $where .= " and warehouse = '$warehouse'";
  769. }
  770. if ($details) {
  771. $where .= " and details = '$details'";
  772. }
  773. if ($purchase) {
  774. $where .= " and purchase = '$purchase'";
  775. }
  776. if ($state) {
  777. $where .= " and state = '$state'";
  778. }
  779. $where_add = '';
  780. if ($cklx) {
  781. $shop = $this->shop->read($cklx);
  782. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  783. }
  784. if ($ktime && $jtime) {
  785. $gj = " and enter > '$ktime' and enter < '$jtime'";
  786. $ck = " and outk > '$ktime' and outk < '$jtime'";
  787. }
  788. //数据排序
  789. $order_str = "id desc";
  790. if (empty($page)) {
  791. $start = 0;
  792. $perpage = 1;
  793. } else {
  794. $start = ($page - 1) * $perpage;
  795. }
  796. if ($sku) {
  797. $sku = trim($sku, ' ');
  798. $sku = trim($sku, ' ');
  799. $where .= " and sku like '%$sku%'";
  800. $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);
  801. } else if ($title) {
  802. $title = trim($title, ' ');
  803. $title = trim($title, ' ');
  804. $where .= " and title like '%$title%'";
  805. $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);
  806. } else {
  807. //$where .= " and time > '$ktime' and time < '$jtime'";
  808. $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);
  809. }
  810. //取得信息列表
  811. $rows = array();
  812. $list = array();
  813. foreach ($info_list as $key => $value) {
  814. $warehouse = $this->warehouse->read($value['warehouse']);
  815. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  816. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  817. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  818. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  819. $ftime = time() - 15 * 24 * 3600;
  820. $info_list[$key]['warehouse'] = $warehouse['title'];
  821. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  822. //$z = count($z);//查看订单号
  823. //$info_list[$key]['zd'] = $z;
  824. $details = array();
  825. $cpid = array();
  826. foreach ($c as $k => $v) {
  827. $details[$v['details']] = $v['details'];
  828. if ($v['cpid'] != 0) {
  829. $cpid[$v['cpid']] = $v['cpid'];
  830. }
  831. }
  832. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  833. if ($value['shop'] != '') {
  834. $shop = explode(',', trim($value['shop'], ','));
  835. $shop = $this->shop->read($shop[0]);
  836. $info_list[$key]['shop'] = $shop['shopname'];
  837. }
  838. }
  839. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  840. $pagenum = ceil($total / $perpage);
  841. $over = $total - ($start + $perpage);
  842. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  843. echo json_encode($rows);
  844. exit;
  845. }
  846. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  847. $this->_Template('whlabel_typedy_ck', $this->data);
  848. }
  849. public function _typeck($arg_array)
  850. {
  851. $prc = array();
  852. $purchase = $this->purchase->find_all();
  853. foreach ($purchase as $k => $v) {
  854. $prc[$v['id']] = $v['title'];
  855. }
  856. $post = $this->input->post(NULL, TRUE);
  857. if (isset($post['page'])) {
  858. $page = $this->input->post('page', true);
  859. $perpage = $this->input->post('perpage', true);
  860. $category = $this->input->post('category', true);
  861. $size = $this->input->post('size', true);
  862. $grade = $this->input->post('grade', true);
  863. $color = $this->input->post('color', true);
  864. $lacecolor = $this->input->post('lacecolor', true);
  865. $lowe = $this->input->post('lowe', true);
  866. $sku = $this->input->post('sku');
  867. $title = $this->input->post('title');
  868. $warehouse = 13;
  869. $usa = $this->input->post('usa', true);
  870. $purchase = $this->input->post('purchase', true);
  871. $lacetype = $this->input->post('lacetype', true);
  872. $haircap = $this->input->post('haircap', true);
  873. $density = $this->input->post('density', true);
  874. $details = $this->input->post('details', true);
  875. $state = $this->input->post('state', true);
  876. $ktime = $this->input->post('ktime', true);
  877. $jtime = $this->input->post('jtime', true);
  878. $ktime = strtotime($ktime);
  879. $jtime = strtotime($jtime);
  880. $where = "1=1";
  881. $gj = "";
  882. $ck = "";
  883. if ($lacetype) {
  884. $where .= " and features like '%-$lacetype-%'";
  885. }
  886. if ($category) {
  887. $where .= " and features like '%-$category-%'";
  888. }
  889. if ($size) {
  890. $where .= " and features like '%-$size-%'";
  891. }
  892. if ($grade) {
  893. $where .= " and features like '%-$grade-%'";
  894. }
  895. if ($color) {
  896. $where .= " and features like '%-$color-%'";
  897. }
  898. if ($lacecolor) {
  899. $where .= " and features like '%-$lacecolor-%'";
  900. }
  901. if ($lowe) {
  902. $where .= " and features like '%-$lowe-%'";
  903. }
  904. if ($haircap) {
  905. $where .= " and features like '%-$haircap-%'";
  906. }
  907. if ($density) {
  908. $where .= " and features like '%-$density-%'";
  909. }
  910. if ($warehouse) {
  911. $where .= " and warehouse = '$warehouse'";
  912. }
  913. if ($details) {
  914. $where .= " and details = '$details'";
  915. }
  916. if ($purchase) {
  917. $where .= " and purchase = '$purchase'";
  918. }
  919. if ($state) {
  920. $where .= " and state = '$state'";
  921. }
  922. if ($ktime && $jtime) {
  923. $gj = " and enter > '$ktime' and enter < '$jtime'";
  924. $ck = " and outk > '$ktime' and outk < '$jtime'";
  925. }
  926. //数据排序
  927. $order_str = "id desc";
  928. if (empty($page)) {
  929. $start = 0;
  930. $perpage = 1;
  931. } else {
  932. $start = ($page - 1) * $perpage;
  933. }
  934. if ($sku) {
  935. $sku = trim($sku, ' ');
  936. $sku = trim($sku, ' ');
  937. $where .= " and sku like '%$sku%'";
  938. } else if ($title) {
  939. $title = trim($title, ' ');
  940. $title = trim($title, ' ');
  941. $where .= " and title like '%$title%'";
  942. }
  943. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  944. //取得信息列表
  945. $t = array();
  946. $typeclass = $this->typeclass->find_all();
  947. foreach ($typeclass as $v) {
  948. $t[$v['id']] = $v;
  949. }
  950. $rows = array();
  951. $list = array();
  952. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  953. foreach ($info_list as $key => $value) {
  954. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  955. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  956. $warehouse = $this->warehouse->read($value['warehouse']);
  957. $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');
  958. $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'] . '"');
  959. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  960. $number = $value['number'];
  961. $ftime = time() - 15 * 24 * 3600;
  962. $z = count($z); //查看订单号
  963. $info_list[$key]['warehouse'] = $warehouse['title'];
  964. $info_list[$key]['features'] = count($c);
  965. $info_list[$key]['number'] = $z;
  966. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  967. $details = array();
  968. $cpid = array();
  969. foreach ($c as $k => $v) {
  970. $details[$v['details']] = $v['details'];
  971. if ($v['cpid'] != 0) {
  972. $cpid[$v['cpid']] = $v['cpid'];
  973. }
  974. }
  975. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  976. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  977. unset($info_list[$key]['pm']);
  978. unset($info_list[$key]['jm']);
  979. unset($info_list[$key]['bm']);
  980. }
  981. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  982. $pagenum = ceil($total / $perpage);
  983. $over = $total - ($start + $perpage);
  984. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  985. echo json_encode($rows);
  986. exit;
  987. }
  988. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  989. $this->_Template('whlabel_typeck', $this->data);
  990. }
  991. //进销存导出
  992. public function _whlabeckdc()
  993. {
  994. $prc = array();
  995. $purchase = $this->purchase->find_all();
  996. foreach ($purchase as $k => $v) {
  997. $prc[$v['id']] = $v['title'];
  998. }
  999. if (isset($_GET['excel'])) {
  1000. $where = "sku != 'Preset'";
  1001. //数据排序
  1002. $order_str = "id desc";
  1003. if (empty($page)) {
  1004. $start = 0;
  1005. $perpage = 1;
  1006. } else {
  1007. $start = ($page - 1) * $perpage;
  1008. }
  1009. $category = $this->input->get('category', true);
  1010. $color = $this->input->get('color', true);
  1011. $lowe = $this->input->get('lowe', true);
  1012. $lacetype = $this->input->get('lacetype', true);
  1013. $size = $this->input->get('size', true);
  1014. $density = $this->input->get('density', true);
  1015. $haircap = $this->input->get('haircap', true);
  1016. $sku = $this->input->get('sku', true);
  1017. $details = $this->input->get('details', true);
  1018. $warehouse = 13;
  1019. $excelid = $this->input->get('sid', true);
  1020. if ($category) {
  1021. $where .= " and features like '%-$category-%'";
  1022. }
  1023. if ($color) {
  1024. $where .= " and features like '%-$color-%'";
  1025. }
  1026. if ($lowe) {
  1027. $where .= " and features like '%-$lowe-%'";
  1028. }
  1029. if ($lacetype) {
  1030. $where .= " and features like '%-$lacetype-%'";
  1031. }
  1032. if ($size) {
  1033. $where .= " and features like '%-$size-%'";
  1034. }
  1035. if ($density) {
  1036. $where .= " and features like '%-$density-%'";
  1037. }
  1038. if ($haircap) {
  1039. $where .= " and features like '%-$haircap-%'";
  1040. }
  1041. if ($warehouse) {
  1042. $where .= " and warehouse = '$warehouse'";
  1043. }
  1044. if ($sku) {
  1045. $where .= " and sku like '%$sku%'";
  1046. }
  1047. if ($details) {
  1048. $where .= " and details = '$details'";
  1049. }
  1050. $xzid = '';
  1051. if ($excelid) {
  1052. $excelid = explode(',', trim($excelid, ','));
  1053. foreach ($excelid as $key => $value) {
  1054. $xzid .= " id = " . $value . " or";
  1055. }
  1056. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1057. }
  1058. //取得信息列表
  1059. /**
  1060. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1061. $rows = array();$list = array();
  1062. foreach ($info_list as $key=>$value)
  1063. {
  1064. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1065. }
  1066. **/
  1067. $wh = array();
  1068. $w = $this->warehouse->find_all('1=1', 'id,title');
  1069. foreach ($w as $v) {
  1070. $wh[$v['id']] = $v['title'];
  1071. }
  1072. $tc = array();
  1073. $tcdata = array();
  1074. $list = array();
  1075. $classid = $this->classid->sku();
  1076. $tcall = $this->typeclass->find_all();
  1077. $typeclass = array();
  1078. foreach ($tcall as $v)
  1079. {
  1080. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1081. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1082. }
  1083. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse,details', "warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,GROUP_CONCAT(NULLIF(cpbz, '') ORDER BY cpbz ASC SEPARATOR ', ') AS cpbzs,number,features ");
  1084. foreach ($rows as $key => $value) {
  1085. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1086. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1087. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1088. $rows[$key]['cpbz'] = $u9_info['bm'];
  1089. $rows[$key]['cs'] = $u9_info['jm'];
  1090. if(empty($value['details'])){
  1091. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = ""', 'details,cpid,cpbz,state');
  1092. }else{
  1093. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = "' . $value['details'] . '"', 'details,cpid,cpbz,state');
  1094. }
  1095. $details = array();
  1096. $cpid = array();
  1097. $cpbz = array();
  1098. $c = 0;
  1099. $g = 0;
  1100. $x = 0;
  1101. $t = 0;
  1102. $s = 0;
  1103. $q = 0;
  1104. foreach ($sd as $k => $v) {
  1105. if ($v['state'] == 0) {
  1106. $c++;
  1107. }
  1108. if ($v['state'] != 9) {
  1109. $g++;
  1110. }
  1111. if ($v['state'] == 1) {
  1112. $x++;
  1113. }
  1114. if ($v['state'] == 2) {
  1115. $t++;
  1116. }
  1117. if ($v['state'] == 8) {
  1118. $s++;
  1119. }
  1120. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1121. $q++;
  1122. }
  1123. $details[$v['details']] = $v['details'];
  1124. if ($v['cpid'] != 0) {
  1125. $cpid[$v['cpid']] = $v['cpid'];
  1126. }
  1127. if ($v['cpbz'] != '') {
  1128. $cpbz[$v['cpbz']] = $v['cpbz'];
  1129. }
  1130. }
  1131. $rows[$key]['details'] = implode("、", $details);
  1132. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1133. $number = $value['number'];
  1134. $ftime = time() - 15 * 24 * 3600;
  1135. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1136. $rows[$key]['number'] = $g;
  1137. $rows[$key]['features'] = $c;
  1138. $rows[$key]['x'] = $x;
  1139. $rows[$key]['t'] = $t;
  1140. $rows[$key]['s'] = $s;
  1141. $rows[$key]['q'] = $q;
  1142. $rows[$key]['wzsl'] = count($details);
  1143. //cpbzs
  1144. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1145. $unique_arr = array_unique($tmp_cpbzs);
  1146. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1147. }
  1148. $title = "进销存统计表" . date('Y-m-d', time());
  1149. $titlename = "<table border=1>
  1150. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1151. <tr align='center'>
  1152. <td>仓库</td>
  1153. <td>供应商</td>
  1154. <td>位置</td>
  1155. <td>库存编码</td>
  1156. <td>SKU</td>
  1157. <td>用友编码</td>
  1158. <td>用友料号</td>
  1159. <td>产品英文名</td>
  1160. <td>产品中文名</td>
  1161. <td>备注</td>
  1162. <td>入库总量</td>
  1163. <td>库存数量</td>
  1164. <td>销售数量</td>
  1165. <td>退货数量</td>
  1166. <td>删除数量</td>
  1167. <td>其它操作</td>
  1168. <td>位置数量</td>
  1169. </tr>
  1170. </table>";
  1171. $filename = $title . ".xls";
  1172. $tail = "";
  1173. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1174. }
  1175. }
  1176. public function _type()
  1177. {
  1178. $vip = 0;
  1179. if (isset($_SESSION['api'])) {
  1180. $user = $this->user->get_api($_SESSION['api']);
  1181. $fgshop = "";
  1182. $sid = "";
  1183. $usersp = explode('|', trim($user['shop'], '|'));
  1184. foreach ($usersp as $value) {
  1185. $fgshop .= " shop = " . $value . " or";
  1186. $sid .= " id = " . $value . " or";
  1187. }
  1188. if ($user['vip'] == 1) {
  1189. $vip = 1;
  1190. }
  1191. } else {
  1192. header('Location: /');
  1193. exit;
  1194. }
  1195. $prc = array();
  1196. $purchase = $this->purchase->find_all();
  1197. foreach ($purchase as $k => $v) {
  1198. $prc[$v['id']] = $v['title'];
  1199. }
  1200. $company = array();
  1201. $ct = $this->company->find_all();
  1202. foreach ($ct as $k => $v) {
  1203. $company[$v['id']] = $v['title'];
  1204. }
  1205. $sp = array();
  1206. $s = $this->shop->find_all('1=1', 'id,shopname');
  1207. foreach ($s as $v) {
  1208. $sp[$v['id']] = $v['shopname'];
  1209. }
  1210. $wh = array();
  1211. $w = $this->warehouse->find_all('1=1', 'id,title');
  1212. foreach ($w as $v) {
  1213. $wh[$v['id']] = $v['title'];
  1214. }
  1215. $post = $this->input->post(NULL, TRUE);
  1216. if (isset($post['page'])) {
  1217. $page = $this->input->post('page', true);
  1218. $perpage = $this->input->post('perpage', true);
  1219. $category = $this->input->post('category', true);
  1220. $size = $this->input->post('size', true);
  1221. $grade = $this->input->post('grade', true);
  1222. $color = $this->input->post('color', true);
  1223. $lowe = $this->input->post('lowe', true);
  1224. $sku = $this->input->post('sku');
  1225. $title = $this->input->post('title');
  1226. $warehouse = $this->input->post('warehouse', true);
  1227. $usa = $this->input->post('usa', true);
  1228. $purchase = $this->input->post('purchase', true);
  1229. $lacetype = $this->input->post('lacetype', true);
  1230. $haircap = $this->input->post('haircap', true);
  1231. $density = $this->input->post('density', true);
  1232. $details = $this->input->post('details', true);
  1233. $state = $this->input->post('state', true);
  1234. $shop = $this->input->post('shop', true);
  1235. $lacecolor = $this->input->post('lacecolor', true);
  1236. $hairnumber = $this->input->post('hairnumber', true);
  1237. $type = $this->input->post('type', true);
  1238. $ktime = $this->input->post('ktime', true);
  1239. $jtime = $this->input->post('jtime', true);
  1240. $ktime = strtotime($ktime);
  1241. $jtime = strtotime($jtime);
  1242. $cpbz = $this->input->post('cpbz', true);
  1243. $sm = $this->input->post('sm', true);
  1244. $where = "1=1";
  1245. $gj = "";
  1246. $ck = "";
  1247. if ($usa) {
  1248. if (!$warehouse) {
  1249. $where .= " and (warehouse = '5' or warehouse = '8')";
  1250. }
  1251. }
  1252. if ($warehouse) {
  1253. $where .= " and warehouse = '$warehouse'";
  1254. }
  1255. if ($details) {
  1256. $where .= " and details = '$details'";
  1257. }
  1258. if ($purchase) {
  1259. $where .= " and purchase = '$purchase'";
  1260. }
  1261. if ($state) {
  1262. $where .= " and state = '$state'";
  1263. }
  1264. if ($shop) {
  1265. $where .= " and shop like '%$shop%'";
  1266. }
  1267. if ($type) {
  1268. $where .= " and type = '$type'";
  1269. }
  1270. if ($ktime && $jtime) {
  1271. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1272. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1273. }
  1274. if ($cpbz) {
  1275. $where .= " and cpbz like '%$cpbz%' ";
  1276. }
  1277. if ($sm) {
  1278. $where .= " and sm like '%$sm%' ";
  1279. }
  1280. if ($lacecolor) {
  1281. $where .= " and features like '%-$lacecolor-%'";
  1282. }
  1283. if ($lacetype) {
  1284. $where .= " and features like '%-$lacetype-%'";
  1285. }
  1286. if ($category) {
  1287. $where .= " and features like '%-$category-%'";
  1288. }
  1289. if ($size) {
  1290. $where .= " and features like '%-$size-%'";
  1291. }
  1292. if ($grade) {
  1293. $where .= " and features like '%-$grade-%'";
  1294. }
  1295. if ($color) {
  1296. $where .= " and features like '%-$color-%'";
  1297. }
  1298. if ($lowe) {
  1299. $where .= " and features like '%-$lowe-%'";
  1300. }
  1301. if ($haircap) {
  1302. $where .= " and features like '%-$haircap-%'";
  1303. }
  1304. if ($density) {
  1305. $where .= " and features like '%-$density-%'";
  1306. }
  1307. if (!empty($hairnumber)) {
  1308. $where .= " and features like '%-128-%' ";
  1309. if ($hairnumber < 0) {
  1310. $class_list = $this->typeclass->find_all('classid = 43');
  1311. foreach ($class_list as $v) {
  1312. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1313. }
  1314. } else {
  1315. $where .= " and features like '%-$hairnumber-%'";
  1316. }
  1317. }
  1318. //数据排序
  1319. $order_str = "id desc";
  1320. if (empty($page)) {
  1321. $start = 0;
  1322. $perpage = 1;
  1323. } else {
  1324. $start = ($page - 1) * $perpage;
  1325. }
  1326. $fjnr = '';
  1327. if ($sku) {
  1328. $sku = trim($sku, ' ');
  1329. $sku = trim($sku, ' ');
  1330. $fjnr .= " and sku like '%$sku%'";
  1331. }
  1332. if ($title) {
  1333. $title = trim($title, ' ');
  1334. $title = trim($title, ' ');
  1335. $fjnr .= " and title like '%$title%'";
  1336. }
  1337. $wt = array();
  1338. $whlabel_type = $this->whlabel_type->find_all();
  1339. foreach ($whlabel_type as $v) {
  1340. $wt[$v['id']] = $v['title'];
  1341. }
  1342. //$where .= " and time > '$ktime' and time < '$jtime'";
  1343. $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
  1344. //取得信息列表
  1345. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1346. $rows = array();
  1347. $list = array();
  1348. foreach ($info_list as $key => $value) {
  1349. if (isset($wt[$value['type']])) {
  1350. $info_list[$key]['type'] = $wt[$value['type']];
  1351. } else {
  1352. $info_list[$key]['type'] = '未设置';
  1353. }
  1354. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1355. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1356. $ztdata = '';
  1357. if (count($zt) > 0) {
  1358. foreach ($zt as $vv) {
  1359. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1360. }
  1361. }
  1362. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1363. $cdata = array_filter($qbdata, function ($item) {
  1364. return $item['state'] < 1;
  1365. });
  1366. $c = array_sum(array_column($cdata, 'jnum'));
  1367. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1368. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1369. });
  1370. $g = array_sum(array_column($gdata, 'jnum'));
  1371. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1372. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1373. });
  1374. $x = array_sum(array_column($xdata, 'jnum'));
  1375. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1376. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1377. });
  1378. $t = array_sum(array_column($tdata, 'jnum'));
  1379. // $zdata = array_filter($qbdata, function ($item) {
  1380. // return $item['zd'] != "" && $item['state'] < 1;
  1381. // });
  1382. // $z = array_sum(array_column($zdata, 'jnum'));
  1383. $zdata = array_filter($qbdata, function ($item) {
  1384. return $item['zd'] != "" && $item['state'] < 1;
  1385. });
  1386. $z = array_sum(array_column($zdata, 'jnum'));
  1387. //$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');
  1388. //$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'].'"');
  1389. //$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'].'"');
  1390. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1391. //$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'].'"');
  1392. $details = array();
  1393. $cpid = array();
  1394. $od = array();
  1395. $odid = '';
  1396. $companytitle = '';
  1397. $shop_list = [];
  1398. foreach ($qbdata as $v) {
  1399. if ($v['zd'] != "" && $v['state'] < 1) {
  1400. if (!isset($od[$v['zd']])) {
  1401. $od[$v['zd']] = 1; //所有数据sku
  1402. } else {
  1403. $od[$v['zd']] = $od[$v['zd']] + 1;
  1404. }
  1405. }
  1406. $details[$v['details']] = $v['details'];
  1407. if ($v['state'] < 1) {
  1408. //$details[$v['details']] = $v['details'];
  1409. if ($v['cpid'] != 0) {
  1410. $cpid[$v['cpid']] = $v['cpid'];
  1411. }
  1412. }
  1413. if($v['state'] == 0){
  1414. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1415. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1416. }
  1417. if ($v['shop'] != '') {
  1418. $shop = explode(',', trim($v['shop'], ','));
  1419. foreach ($shop as $vv) {
  1420. if (!in_array($vv, $shop_list)) {
  1421. $shop_list[] = $vv;
  1422. }
  1423. }
  1424. }
  1425. }
  1426. }
  1427. foreach ($od as $k => $vv) {
  1428. $odid .= $k . '数量' . $vv;
  1429. }
  1430. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1431. $info_list[$key]['label'] = $value['sm'];
  1432. $number = $value['number'];
  1433. $ftime = time() - 15 * 24 * 3600;
  1434. $z = $z . '(' . $odid . ')'; //查看订单号
  1435. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1436. $info_list[$key]['features'] = $c;
  1437. $info_list[$key]['number'] = $ztdata;
  1438. $info_list[$key]['sm'] = $g;
  1439. $info_list[$key]['x'] = $x;
  1440. $info_list[$key]['t'] = $t;
  1441. $info_list[$key]['z'] = $z;
  1442. /**
  1443. foreach ($cdata as $k=>$v)
  1444. {
  1445. $details[$v['details']] = $v['details'];
  1446. if($v['cpid'] != 0)
  1447. {
  1448. $cpid[$v['cpid']] = $v['cpid'];
  1449. }
  1450. }
  1451. **/
  1452. $info_list[$key]['shop'] = '';
  1453. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1454. // if ($value['shop'] != '') {
  1455. // $shop = explode(',', trim($value['shop'], ','));
  1456. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1457. // }
  1458. $shop_list = array_unique($shop_list);
  1459. $shop_str = '';
  1460. foreach ($shop_list as $v) {
  1461. if(isset($sp[$v])){
  1462. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1463. }
  1464. }
  1465. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1466. /**
  1467. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1468. if(isset($companytitle[0]))
  1469. {
  1470. foreach ($companytitle as $k=>$v)
  1471. {
  1472. if($v['companytitle'] != '')
  1473. {
  1474. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1475. }
  1476. }
  1477. }
  1478. **/
  1479. }
  1480. $final_all_list = [];
  1481. foreach ($info_list as $k => $v) {
  1482. $final_all_list[] = [
  1483. 'id' => $v['id'],
  1484. "warehouse" => $v["warehouse"],
  1485. "purchase" => $v["purchase"],
  1486. "sku" => $v["sku"],
  1487. "title" => $v["title"] . "<br/>" . $v["pm"],
  1488. "details" => $v["details"],
  1489. "shop" => $v["shop"],
  1490. "cpbz" => $v["cpbz"],
  1491. 'label' => $v['label'],
  1492. "type" => $v["type"],
  1493. "features" => $v["features"],
  1494. "number" => $v["number"],
  1495. "sm" => $v["sm"],
  1496. "x" => $v["x"],
  1497. "t" => $v["t"],
  1498. "z" => $v["z"]
  1499. ];
  1500. }
  1501. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1502. $pagenum = ceil($total / $perpage);
  1503. $over = $total - ($start + $perpage);
  1504. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1505. echo json_encode($rows);
  1506. exit;
  1507. }
  1508. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1509. $this->data['shop'] = $wlshop;
  1510. $this->data['vip'] = $vip;
  1511. $this->_Template('whlabel_type', $this->data);
  1512. }
  1513. //美仓进销存浏览
  1514. public function _usatype()
  1515. {
  1516. if (isset($_SESSION['api'])) {
  1517. $user = $this->user->get_api($_SESSION['api']);
  1518. $usp = $user;
  1519. $fgshop = "";
  1520. $sid = "";
  1521. $wid = "";
  1522. $wtype = "";
  1523. $userwh = explode('|', trim($user['warehouse'], '|'));
  1524. foreach ($userwh as $value) {
  1525. $wid .= " id = " . $value . " or";
  1526. $wtype .= " type = " . $value . " or";
  1527. }
  1528. }
  1529. $prc = array();
  1530. $purchase = $this->purchase->find_all();
  1531. foreach ($purchase as $k => $v) {
  1532. $prc[$v['id']] = $v['title'];
  1533. }
  1534. $post = $this->input->post(NULL, TRUE);
  1535. if (isset($post['page'])) {
  1536. $page = $this->input->post('page', true);
  1537. $perpage = $this->input->post('perpage', true);
  1538. $category = $this->input->post('category', true);
  1539. $size = $this->input->post('size', true);
  1540. $grade = $this->input->post('grade', true);
  1541. $color = $this->input->post('color', true);
  1542. $lowe = $this->input->post('lowe', true);
  1543. $sku = $this->input->post('sku');
  1544. $title = $this->input->post('title');
  1545. $warehouse = $this->input->post('warehouse', true);
  1546. $usa = $this->input->post('usa', true);
  1547. $purchase = $this->input->post('purchase', true);
  1548. $lacetype = $this->input->post('lacetype', true);
  1549. $haircap = $this->input->post('haircap', true);
  1550. $density = $this->input->post('density', true);
  1551. $details = $this->input->post('details', true);
  1552. $state = $this->input->post('state', true);
  1553. $lacecolor = $this->input->post('lacecolor', true);
  1554. $cklx = $this->input->post('cklx', true);
  1555. $ktime = $this->input->post('ktime', true);
  1556. $jtime = $this->input->post('jtime', true);
  1557. $ktime = strtotime($ktime);
  1558. $jtime = strtotime($jtime);
  1559. $where = "1=1";
  1560. $gj = "";
  1561. $ck = "";
  1562. if ($lacetype) {
  1563. $where .= " and features like '%-$lacetype-%'";
  1564. }
  1565. if ($category) {
  1566. $where .= " and features like '%-$category-%'";
  1567. }
  1568. if ($size) {
  1569. $where .= " and features like '%-$size-%'";
  1570. }
  1571. if ($grade) {
  1572. $where .= " and features like '%-$grade-%'";
  1573. }
  1574. if ($color) {
  1575. $where .= " and features like '%-$color-%'";
  1576. }
  1577. if ($lowe) {
  1578. $where .= " and features like '%-$lowe-%'";
  1579. }
  1580. if ($haircap) {
  1581. $where .= " and features like '%-$haircap-%'";
  1582. }
  1583. if ($density) {
  1584. $where .= " and features like '%-$density-%'";
  1585. }
  1586. if ($lacecolor) {
  1587. $where .= " and features like '%-$lacecolor-%'";
  1588. }
  1589. if ($usa) {
  1590. if (!$warehouse) {
  1591. $where .= " and (warehouse = '5' or warehouse = '8')";
  1592. }
  1593. }
  1594. if ($warehouse) {
  1595. $where .= " and warehouse = '$warehouse'";
  1596. }
  1597. if ($details) {
  1598. $where .= " and details = '$details'";
  1599. }
  1600. if ($purchase) {
  1601. $where .= " and purchase = '$purchase'";
  1602. }
  1603. if ($state) {
  1604. $where .= " and state = '$state'";
  1605. }
  1606. $where_add = '';
  1607. if ($cklx) {
  1608. $shop = $this->shop->read($cklx);
  1609. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1610. }
  1611. if ($ktime && $jtime) {
  1612. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1613. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1614. }
  1615. //数据排序
  1616. $order_str = "id desc";
  1617. if (empty($page)) {
  1618. $start = 0;
  1619. $perpage = 1;
  1620. } else {
  1621. $start = ($page - 1) * $perpage;
  1622. }
  1623. if ($sku) {
  1624. $sku = trim($sku, ' ');
  1625. $sku = trim($sku, ' ');
  1626. $where .= " and sku like '%$sku%'";
  1627. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1628. } else if ($title) {
  1629. $title = trim($title, ' ');
  1630. $title = trim($title, ' ');
  1631. $where .= " and title like '%$title%'";
  1632. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1633. } else {
  1634. //$where .= " and time > '$ktime' and time < '$jtime'";
  1635. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1636. }
  1637. //取得信息列表
  1638. $rows = array();
  1639. $list = array();
  1640. foreach ($info_list as $key => $value) {
  1641. $warehouse = $this->warehouse->read($value['warehouse']);
  1642. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1643. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1644. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1645. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1646. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1647. $od = array();
  1648. $odid = '';
  1649. foreach ($z as $v) {
  1650. if (!isset($od[$v['zd']])) {
  1651. $od[$v['zd']] = 1; //所有数据sku
  1652. } else {
  1653. $od[$v['zd']] = $od[$v['zd']] + 1;
  1654. }
  1655. }
  1656. foreach ($od as $k => $vv) {
  1657. $odid .= $k . '数量' . $vv . ' ';
  1658. }
  1659. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1660. $info_list[$key]['features'] = $c;
  1661. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1662. $ztdata = '';
  1663. if (count($zt) > 0) {
  1664. foreach ($zt as $vv) {
  1665. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1666. }
  1667. }
  1668. $info_list[$key]['warehouse'] = $ztdata;
  1669. $info_list[$key]['g'] = $g;
  1670. $info_list[$key]['x'] = $x;
  1671. $info_list[$key]['t'] = $t;
  1672. $info_list[$key]['z'] = $z;
  1673. }
  1674. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1675. $pagenum = ceil($total / $perpage);
  1676. $over = $total - ($start + $perpage);
  1677. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1678. echo json_encode($rows);
  1679. exit;
  1680. }
  1681. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1682. $this->data['warehouse'] = $warehouse;
  1683. $this->_Template('whlabel_typeusa', $this->data);
  1684. }
  1685. //美仓进销存浏览
  1686. public function _usatypeapp()
  1687. {
  1688. $post = $this->input->post(NULL, TRUE);
  1689. if (isset($post['page'])) {
  1690. $page = $this->input->post('page', true);
  1691. $perpage = $this->input->post('perpage', true);
  1692. $sku = $this->input->post('sku', true);
  1693. $warehouse = 5;
  1694. $title = $this->input->post('title', true);
  1695. $state = $this->input->post('state', true);
  1696. $ktime = $this->input->post('ktime', true);
  1697. $jtime = $this->input->post('jtime', true);
  1698. $ktime = strtotime($ktime);
  1699. $jtime = strtotime($jtime);
  1700. $where = "1=1";
  1701. $gj = "";
  1702. $ck = "";
  1703. if ($title) {
  1704. $st = explode(' ', trim($title, ' '));
  1705. foreach ($st as $v) {
  1706. $where .= " and title like '%$v%'";
  1707. }
  1708. }
  1709. if ($warehouse) {
  1710. $where .= " and warehouse = '$warehouse'";
  1711. }
  1712. if ($state) {
  1713. $where .= " and state = '$state'";
  1714. }
  1715. if ($sku) {
  1716. $where .= " and sku like '%$sku%'";
  1717. }
  1718. if ($ktime && $jtime) {
  1719. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1720. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1721. }
  1722. //数据排序
  1723. $order_str = "id desc";
  1724. if (empty($page)) {
  1725. $start = 0;
  1726. $perpage = 1;
  1727. } else {
  1728. $start = ($page - 1) * $perpage;
  1729. }
  1730. //取得信息列表
  1731. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1732. $rows = array();
  1733. $list = array();
  1734. foreach ($info_list as $key => $value) {
  1735. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1736. }
  1737. $rowsdq = array_slice($rows, $start, $perpage);
  1738. foreach ($rowsdq as $value) {
  1739. $warehouse = $this->warehouse->read($value['warehouse']);
  1740. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1741. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1742. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1743. $od = array();
  1744. $odid = '';
  1745. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1746. }
  1747. $total = count($rows);
  1748. $pagenum = ceil($total / $perpage);
  1749. $over = $total - ($start + $perpage);
  1750. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1751. echo json_encode($rows);
  1752. exit;
  1753. }
  1754. $this->_Template('phone/p_usatypeapp', $this->data);
  1755. }
  1756. //入库操作
  1757. public function _enteradd()
  1758. {
  1759. $dt = 0;
  1760. if (isset($_SESSION['api'])) {
  1761. $user = $this->user->get_api($_SESSION['api']);
  1762. $usp = $user;
  1763. $fgshop = "";
  1764. $sid = "";
  1765. $user = explode('|', trim($user['shop'], '|'));
  1766. foreach ($user as $value) {
  1767. $fgshop .= " shop = " . $value . " or";
  1768. $sid .= " id = " . $value . " or";
  1769. }
  1770. }
  1771. $tc = $this->typeclass->find_all();
  1772. $typeclass = array();
  1773. foreach ($tc as $v) {
  1774. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1775. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1776. }
  1777. $post = $this->input->post(NULL, TRUE);
  1778. if (isset($post['sku'])) {
  1779. $list = array();
  1780. $num = "";
  1781. $title = "";
  1782. $features = "";
  1783. $order = $this->input->post('order', true);
  1784. $shop = $this->input->post('shop', true);
  1785. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1786. $sku = $this->input->post('sku', true);
  1787. $post['sm'] = $this->input->post('sm', true);
  1788. $post['warehouse'] = $this->input->post('warehouse', true);
  1789. $post['purchase'] = $this->input->post('purchase', true);
  1790. $post['retreatwarehouse'] = $post['warehouse'];
  1791. $post['state'] = $this->input->post('state', true);
  1792. $post['rktype'] = $this->input->post('rktype', true);
  1793. $post['text'] = $this->input->post('text', true);
  1794. $category = $this->input->post('category', true);
  1795. $list['category'] = $category;
  1796. $list['hairtype'] = $this->input->post('hairtype', true);
  1797. $list['grade'] = $this->input->post('grade', true);
  1798. $size = $this->input->post('size', true);
  1799. $xzsku = $this->input->post('xzsku', true);
  1800. $list['size'] = rtrim($size, ',');
  1801. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1802. $list['extension'] = $this->input->post('extension', true);
  1803. if ($category == 1297) {
  1804. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1805. }
  1806. if ($category == 1702) {
  1807. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1808. $list['syother'] = $this->input->post('syother', true);
  1809. }
  1810. if ($category == 133) {
  1811. $list['fittype'] = $this->input->post('fittype', true);
  1812. $list['acother'] = $this->input->post('acother', true);
  1813. }
  1814. $list['color'] = $this->input->post('color', true);
  1815. $list['lowe'] = $this->input->post('lowe', true);
  1816. if (!$post['purchase']) {
  1817. $post['purchase'] = 1;
  1818. }
  1819. if ($category == 127) {
  1820. $list['type'] = $this->input->post('type', true);
  1821. $list['headroad'] = $this->input->post('headroad', true);
  1822. $list['density'] = $this->input->post('density', true);
  1823. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1824. $list['lacesize'] = $this->input->post('lacesize', true);
  1825. }
  1826. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1827. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1828. }
  1829. if ($category == 128) {
  1830. $list['lacetype'] = $this->input->post('lacetype', true);
  1831. $list['haircap'] = $this->input->post('haircap', true);
  1832. $list['density'] = $this->input->post('density', true);
  1833. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1834. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1835. $list['wigother'] = $this->input->post('wigother', true);
  1836. $list['wigother1'] = $this->input->post('wigother1', true);
  1837. $list['wigother2'] = $this->input->post('wigother2', true);
  1838. $list['product_related'] = $this->input->post('product_related', true);
  1839. }
  1840. if ($category == 129) {
  1841. $list['wide'] = $this->input->post('wide', true);
  1842. }
  1843. if ($category == 131) {
  1844. $list['gifttype'] = $this->input->post('gifttype', true);
  1845. $list['giftother'] = $this->input->post('giftother', true);
  1846. }
  1847. if ($category == 134) {
  1848. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1849. }
  1850. if ($category == 1297) {
  1851. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1852. $list['sywigother'] = $this->input->post('sywigother', true);
  1853. }
  1854. if ($category == 130 || $category == 133 || $category == 1702) {
  1855. $list['items'] = $this->input->post('items', true);
  1856. $list['weight'] = $this->input->post('weight', true);
  1857. }
  1858. if($category == 130){
  1859. $list['jfother'] = $this->input->post('jfother', true);
  1860. }
  1861. if ($category == 1702) {
  1862. $list['syhairther'] = $this->input->post('syhairther', true);
  1863. }
  1864. $classid = $this->classid->sku();
  1865. $scsku = $classid;
  1866. $pm = $classid;
  1867. foreach ($list as $k => $v) {
  1868. if ($v != 0) {
  1869. $num .= $v;
  1870. $features .= $v . '-';
  1871. $post[$k] = $v;
  1872. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1873. if ($k != 'size') {
  1874. $title .= $typeclass[$v]['title'] . " ";
  1875. }
  1876. if (isset($pm[$typeclass[$v]['classid']])) {
  1877. if ($typeclass[$v]['title'] == '9A') {
  1878. $pm[$typeclass[$v]['classid']] = '9A';
  1879. } else if ($typeclass[$v]['title'] == '10A') {
  1880. $pm[$typeclass[$v]['classid']] = '10A';
  1881. } else {
  1882. $clzh = $typeclass[$v]['zh'];
  1883. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1884. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1885. $clzh = $clzh[0];
  1886. }
  1887. $pm[$typeclass[$v]['classid']] = $clzh;
  1888. }
  1889. }
  1890. }
  1891. }
  1892. $zh = implode(" ", $pm);
  1893. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1894. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1895. if ($list['size']) {
  1896. $typeclass = $this->typeclass->read($list['size']);
  1897. $title .= $typeclass['title'];
  1898. }
  1899. $time = time();
  1900. if ($xzsku) {
  1901. $scsku = implode("-", $scsku);
  1902. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1903. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1904. $post['sku'] = trim($scsku, ' ');
  1905. } else {
  1906. $post['sku'] = $sku;
  1907. }
  1908. //$post['sku'] = trim($sku,' ');
  1909. $post['title'] = rtrim($title, ' ');
  1910. $post['number'] = $num;
  1911. $post['features'] = '-' . $features;
  1912. $post['enter'] = $time;
  1913. $post['time'] = $time; //操作时间
  1914. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1915. if ($yza) {
  1916. if ($post['features'] != $yza[0]['features']) {
  1917. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1918. exit;
  1919. }
  1920. }
  1921. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1922. if ($yzb) {
  1923. if ($post['sku'] != $yzb[0]['sku']) {
  1924. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1925. exit;
  1926. }
  1927. }
  1928. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1929. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1930. exit;
  1931. }
  1932. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1933. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1934. exit;
  1935. }
  1936. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1937. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1938. exit;
  1939. }
  1940. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1941. if (isset($yz[0]['type'])) {
  1942. $post['type'] = $yz[0]['type'];
  1943. }
  1944. if ($post['state'] == 9) //如果选择预设库存
  1945. {
  1946. $this->whlabel->insert($post);
  1947. } else {
  1948. /**
  1949. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1950. if($ljg == 1)
  1951. {
  1952. for($i=0;$i<$order;$i++)
  1953. {
  1954. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1955. $this->whlabel->insert($post);
  1956. }
  1957. }
  1958. **/
  1959. //if($post['warehouse'] == '5')
  1960. //{
  1961. //}
  1962. $yydata = $post;
  1963. $yydata['zh'] = $zh;
  1964. /**
  1965. $wl = $this->apiyy->get_cjlp($yydata);
  1966. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1967. {
  1968. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1969. }
  1970. if($wl['Data'][0]['m_isSucess'] != 1)
  1971. {
  1972. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1973. }
  1974. **/
  1975. for ($i = 0; $i < $order; $i++) {
  1976. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1977. $this->whlabel->insert($post);
  1978. }
  1979. }
  1980. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1981. exit;
  1982. }
  1983. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1984. $this->data['wlshop'] = $wlshop;
  1985. $this->_Template('whlabel_enteradd', $this->data);
  1986. }
  1987. //修改产品
  1988. public function _enteredit($arg_array)
  1989. {
  1990. $dt = 0;
  1991. if (isset($_SESSION['api'])) {
  1992. $user = $this->user->get_api($_SESSION['api']);
  1993. $usp = $user;
  1994. $fgshop = "";
  1995. $sid = "";
  1996. $user = explode('|', trim($user['shop'], '|'));
  1997. foreach ($user as $value) {
  1998. $fgshop .= " shop = " . $value . " or";
  1999. $sid .= " id = " . $value . " or";
  2000. }
  2001. }
  2002. $post = $this->input->post(NULL, TRUE);
  2003. if (isset($post['sku'])) {
  2004. $list = array();
  2005. $num = "";
  2006. $title = "";
  2007. $features = "";
  2008. $id = $this->input->post('id', true);
  2009. $order = $this->input->post('order', true);
  2010. $shop = $this->input->post('shop', true);
  2011. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2012. $post['sku'] = $this->input->post('sku', true);
  2013. $post['sm'] = $this->input->post('sm', true);
  2014. $post['warehouse'] = $this->input->post('warehouse', true);
  2015. $post['purchase'] = $this->input->post('purchase', true);
  2016. $post['retreatwarehouse'] = $post['warehouse'];
  2017. $category = $this->input->post('category', true);
  2018. $list['category'] = $category;
  2019. $list['hairtype'] = $this->input->post('hairtype', true);
  2020. $list['grade'] = $this->input->post('grade', true);
  2021. $size = $this->input->post('size', true);
  2022. $list['size'] = rtrim($size, ',');
  2023. $post['rktype'] = $this->input->post('rktype', true);
  2024. $post['text'] = $this->input->post('text', true);
  2025. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2026. $list['extension'] = $this->input->post('extension', true);
  2027. if ($category == 1297) {
  2028. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2029. }
  2030. if ($category == 1702) {
  2031. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2032. $list['syother'] = $this->input->post('syother', true);
  2033. }
  2034. if ($category == 133) {
  2035. $list['fittype'] = $this->input->post('fittype', true);
  2036. $list['acother'] = $this->input->post('acother', true);
  2037. }
  2038. $list['color'] = $this->input->post('color', true);
  2039. $list['lowe'] = $this->input->post('lowe', true);
  2040. if (!$post['purchase']) {
  2041. $post['purchase'] = 1;
  2042. }
  2043. if ($category == 127) {
  2044. $list['type'] = $this->input->post('type', true);
  2045. $list['headroad'] = $this->input->post('headroad', true);
  2046. $list['density'] = $this->input->post('density', true);
  2047. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2048. $list['lacesize'] = $this->input->post('lacesize', true);
  2049. }
  2050. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2051. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2052. }
  2053. if ($category == 128) {
  2054. $list['lacetype'] = $this->input->post('lacetype', true);
  2055. $list['haircap'] = $this->input->post('haircap', true);
  2056. $list['density'] = $this->input->post('density', true);
  2057. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2058. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2059. $list['wigother'] = $this->input->post('wigother', true);
  2060. $list['wigother1'] = $this->input->post('wigother1', true);
  2061. $list['wigother2'] = $this->input->post('wigother2', true);
  2062. $list['product_related'] = $this->input->post('product_related', true);
  2063. }
  2064. if ($category == 129) {
  2065. $list['wide'] = $this->input->post('wide', true);
  2066. }
  2067. if ($category == 131) {
  2068. $list['gifttype'] = $this->input->post('gifttype', true);
  2069. $list['giftother'] = $this->input->post('giftother', true);
  2070. }
  2071. if ($category == 134) {
  2072. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2073. }
  2074. if ($category == 1297) {
  2075. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2076. $list['sywigother'] = $this->input->post('sywigother', true);
  2077. }
  2078. if ($category == 130 || $category == 133 || $category == 1702) {
  2079. $list['items'] = $this->input->post('items', true);
  2080. $list['weight'] = $this->input->post('weight', true);
  2081. }
  2082. if($category == 130){
  2083. $list['jfother'] = $this->input->post('jfother', true);
  2084. }
  2085. if ($category == 1702) {
  2086. $list['syhairther'] = $this->input->post('syhairther', true);
  2087. }
  2088. foreach ($list as $k => $v) {
  2089. if ($v != 0) {
  2090. $num .= $v;
  2091. $features .= $v . '-';
  2092. $typeclass = $this->typeclass->read($v);
  2093. if ($k != 'size') {
  2094. $title .= $typeclass['title'] . " ";
  2095. }
  2096. }
  2097. }
  2098. $typeclass = $this->typeclass->read($list['size']);
  2099. $title .= $typeclass['title'];
  2100. $time = time();
  2101. $post['title'] = rtrim($title, ' ');
  2102. $post['number'] = $num;
  2103. $post['features'] = '-' . $features;
  2104. $post['time'] = $time; //操作时间
  2105. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2106. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2107. exit;
  2108. }
  2109. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2110. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2111. exit;
  2112. }
  2113. $uid = $this->whlabel->read($id);
  2114. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2115. if ($datanum > 0) {
  2116. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2117. exit;
  2118. }
  2119. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2120. {
  2121. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2122. if ($yza) {
  2123. if ($post['features'] != $yza[0]['features']) {
  2124. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2125. exit;
  2126. }
  2127. }
  2128. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2129. if ($yzb) {
  2130. if ($post['sku'] != $yzb[0]['sku']) {
  2131. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2132. exit;
  2133. }
  2134. }
  2135. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2136. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2137. exit;
  2138. }
  2139. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2140. foreach ($data as $v) {
  2141. $post['id'] = $v['id'];
  2142. $this->whlabel->save($post, $v['id']);
  2143. }
  2144. } else {
  2145. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2146. if ($data > 0) {
  2147. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2148. exit;
  2149. } else {
  2150. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2151. foreach ($data as $v) {
  2152. $post['id'] = $v['id'];
  2153. $this->whlabel->save($post, $v['id']);
  2154. }
  2155. }
  2156. }
  2157. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2158. exit;
  2159. }
  2160. $uid = $this->whlabel->read($arg_array[0]);
  2161. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2162. $this->data['enter'] = $uid;
  2163. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2164. $this->data['wlshop'] = $wlshop;
  2165. $this->_Template('whlabel_enteredit', $this->data);
  2166. }
  2167. //入库浏览
  2168. public function _enter()
  2169. {
  2170. $post = $this->input->post(NULL, TRUE);
  2171. if (isset($post['s'])) {
  2172. $id_arr = $this->input->post('s');
  2173. $id_arr = explode(',', $id_arr);
  2174. if (!$id_arr) {
  2175. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2176. exit;
  2177. }
  2178. //循环删除记录
  2179. foreach ($id_arr as $v) {
  2180. $sid = $this->whlabel->read($v);
  2181. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2182. if ($count > 0) {
  2183. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2184. exit;
  2185. }
  2186. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2187. foreach ($info_list as $va) {
  2188. $this->whlabel->remove($va['id']);
  2189. }
  2190. }
  2191. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2192. exit;
  2193. }
  2194. $sp = array();
  2195. $s = $this->shop->find_all('1=1', 'id,shopname');
  2196. foreach ($s as $v) {
  2197. $sp[$v['id']] = $v['shopname'];
  2198. }
  2199. $wh = array();
  2200. $w = $this->warehouse->find_all('1=1', 'id,title');
  2201. foreach ($w as $v) {
  2202. $wh[$v['id']] = $v['title'];
  2203. }
  2204. if (isset($post['page'])) {
  2205. $page = $this->input->post('page', true);
  2206. $perpage = $this->input->post('perpage', true);
  2207. $category = $this->input->post('category', true);
  2208. $size = $this->input->post('size', true);
  2209. $grade = $this->input->post('grade', true);
  2210. $color = $this->input->post('color', true);
  2211. $lowe = $this->input->post('lowe', true);
  2212. $sku = $this->input->post('sku', true);
  2213. $warehouse = $this->input->post('warehouse', true);
  2214. $purchase = $this->input->post('purchase', true);
  2215. $ktime = $this->input->post('ktime', true);
  2216. $jtime = $this->input->post('jtime', true);
  2217. $ktime = strtotime($ktime);
  2218. $jtime = strtotime($jtime);
  2219. $where = "1=1";
  2220. $gj = "";
  2221. $ck = "";
  2222. if ($category) {
  2223. $where .= " and features like '%-$category-%'";
  2224. }
  2225. if ($size) {
  2226. $where .= " and features like '%-$size-%'";
  2227. }
  2228. if ($grade) {
  2229. $where .= " and features like '%-$grade-%'";
  2230. }
  2231. if ($color) {
  2232. $where .= " and features like '%-$color-%'";
  2233. }
  2234. if ($lowe) {
  2235. $where .= " and features like '%-$lowe-%'";
  2236. }
  2237. if ($warehouse) {
  2238. $where .= " and warehouse = '$warehouse'";
  2239. }
  2240. if ($purchase) {
  2241. $where .= " and purchase = '$purchase'";
  2242. }
  2243. if ($sku) {
  2244. $where .= " and sku like '%$sku%'";
  2245. }
  2246. if ($ktime && $jtime) {
  2247. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2248. }
  2249. //数据排序
  2250. $order_str = "enter desc";
  2251. if (empty($page)) {
  2252. $start = 0;
  2253. $perpage = 1;
  2254. } else {
  2255. $start = ($page - 1) * $perpage;
  2256. }
  2257. //取得信息列表
  2258. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2259. foreach ($info_list as $k => $v) {
  2260. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2261. if ($v['shop'] == '') {
  2262. $s = '通用';
  2263. } else {
  2264. $info_list[$k]['shop'] = '';
  2265. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2266. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2267. }
  2268. }
  2269. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2270. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2271. $info_list[$k]['g'] = $g;
  2272. }
  2273. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2274. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2275. $pagenum = ceil($total / $perpage);
  2276. $over = $total - ($start + $perpage);
  2277. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2278. echo json_encode($rows);
  2279. exit;
  2280. }
  2281. $this->_Template('whlabel_enter', $this->data);
  2282. }
  2283. //出库浏览
  2284. public function _out()
  2285. {
  2286. $post = $this->input->post(NULL, TRUE);
  2287. if (isset($post['page'])) {
  2288. $page = $this->input->post('page', true);
  2289. $perpage = $this->input->post('perpage', true);
  2290. $category = $this->input->post('category', true);
  2291. $size = $this->input->post('size', true);
  2292. $grade = $this->input->post('grade', true);
  2293. $color = $this->input->post('color', true);
  2294. $lowe = $this->input->post('lowe', true);
  2295. $sku = $this->input->post('sku', true);
  2296. $warehouse = $this->input->post('warehouse', true);
  2297. $purchase = $this->input->post('purchase', true);
  2298. $state = $this->input->post('state', true);
  2299. $ktime = $this->input->post('ktime', true);
  2300. $jtime = $this->input->post('jtime', true);
  2301. $ktime = strtotime($ktime);
  2302. $jtime = strtotime($jtime);
  2303. $where = "state=3";
  2304. $gj = "";
  2305. $ck = "";
  2306. if ($category) {
  2307. $where .= " and features like '%-$category-%'";
  2308. }
  2309. if ($size) {
  2310. $where .= " and features like '%-$size-%'";
  2311. }
  2312. if ($grade) {
  2313. $where .= " and features like '%-$grade-%'";
  2314. }
  2315. if ($color) {
  2316. $where .= " and features like '%-$color-%'";
  2317. }
  2318. if ($lowe) {
  2319. $where .= " and features like '%-$lowe-%'";
  2320. }
  2321. if ($state) {
  2322. $where .= " and state = '$state'";
  2323. }
  2324. if ($warehouse) {
  2325. $where .= " and warehouse = '$warehouse'";
  2326. }
  2327. if ($purchase) {
  2328. $where .= " and purchase = '$purchase'";
  2329. }
  2330. if ($sku) {
  2331. $where .= " and sku = '$sku'";
  2332. }
  2333. if ($ktime && $jtime) {
  2334. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2335. }
  2336. //数据排序
  2337. $order_str = "id desc";
  2338. if (empty($page)) {
  2339. $start = 0;
  2340. $perpage = 1;
  2341. } else {
  2342. $start = ($page - 1) * $perpage;
  2343. }
  2344. //取得信息列表
  2345. $info_list = $this->whlabel->find_all($where, 'sku');
  2346. $rows = array();
  2347. $list = array();
  2348. foreach ($info_list as $key => $value) {
  2349. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2350. }
  2351. $rows = array_unique($rows); //删除重复记录
  2352. foreach ($rows as $key => $value) {
  2353. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2354. $ck = $this->warehouse->read($data['warehouse']);
  2355. $warehouse = $ck['title'];
  2356. $gy = $this->purchase->read($data['purchase']);
  2357. $purchase = $gy['purchase'];
  2358. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2359. $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);
  2360. }
  2361. $total = count($list);
  2362. $pagenum = ceil($total / $perpage);
  2363. $over = $total - ($start + $perpage);
  2364. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2365. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2366. echo json_encode($rows);
  2367. exit;
  2368. }
  2369. $this->_Template('whlabel_out', $this->data);
  2370. }
  2371. //出库标签浏览
  2372. public function _label()
  2373. {
  2374. $post = $this->input->post(NULL, TRUE);
  2375. if (isset($post['page'])) {
  2376. $page = $this->input->post('page', true);
  2377. $perpage = $this->input->post('perpage', true);
  2378. $sku = $this->input->post('sku', true);
  2379. $warehouse = $this->input->post('warehouse', true);
  2380. $purchase = $this->input->post('purchase', true);
  2381. $orderinfo = $this->input->post('orderinfo', true);
  2382. $waybill = $this->input->post('waybill', true);
  2383. $category = $this->input->post('category', true);
  2384. $size = $this->input->post('size', true);
  2385. $grade = $this->input->post('grade', true);
  2386. $color = $this->input->post('color', true);
  2387. $lowe = $this->input->post('lowe', true);
  2388. $where = "state=1";
  2389. if ($sku) {
  2390. $where .= " and sku = '$sku'";
  2391. }
  2392. if ($warehouse) {
  2393. $where .= " and warehouse = '$warehouse'";
  2394. }
  2395. if ($purchase) {
  2396. $where .= " and purchase = '$purchase'";
  2397. }
  2398. if ($orderinfo) {
  2399. $where .= " and orderinfo = '$orderinfo'";
  2400. }
  2401. if ($waybill) {
  2402. $where .= " and waybill = '$waybill'";
  2403. }
  2404. if ($category) {
  2405. $where .= " and features like '%-$category-%'";
  2406. }
  2407. if ($size) {
  2408. $where .= " and features like '%-$size-%'";
  2409. }
  2410. if ($grade) {
  2411. $where .= " and features like '%-$grade-%'";
  2412. }
  2413. if ($color) {
  2414. $where .= " and features like '%-$color-%'";
  2415. }
  2416. if ($lowe) {
  2417. $where .= " and features like '%-$lowe-%'";
  2418. }
  2419. //数据排序
  2420. $order_str = "outk desc";
  2421. if (empty($page)) {
  2422. $start = 0;
  2423. $perpage = 1;
  2424. } else {
  2425. $start = ($page - 1) * $perpage;
  2426. }
  2427. //取得信息列表
  2428. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2429. foreach ($info_list as $key => $value) {
  2430. $warehouse = $this->warehouse->read($value['warehouse']);
  2431. $info_list[$key]['warehouse'] = $warehouse['title'];
  2432. $purchase = $this->purchase->read($value['purchase']);
  2433. $info_list[$key]['purchase'] = $purchase['title'];
  2434. if ($value['outk'] != 0) {
  2435. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2436. } else {
  2437. $info_list[$key]['outk'] = "";
  2438. }
  2439. if ($value['orderinfo'] == 0) {
  2440. $info_list[$key]['orderinfo'] = "";
  2441. }
  2442. if ($value['waybill'] == 0) {
  2443. $info_list[$key]['waybill'] = "";
  2444. }
  2445. }
  2446. $total = $this->whlabel->find_count($where);
  2447. $pagenum = ceil($total / $perpage);
  2448. $over = $total - ($start + $perpage);
  2449. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2450. echo json_encode($rows);
  2451. exit;
  2452. }
  2453. $this->_Template('whlabel_label', $this->data);
  2454. }
  2455. //独立站出库订单
  2456. public function _outorder()
  2457. {
  2458. if (isset($_SESSION['api'])) {
  2459. $user = $this->user->get_api($_SESSION['api']);
  2460. $usp = $user;
  2461. $fgshop = "";
  2462. $sid = "";
  2463. $user = explode('|', trim($user['shop'], '|'));
  2464. foreach ($user as $value) {
  2465. $fgshop .= " shop = " . $value . " or";
  2466. $sid .= " id = " . $value . " or";
  2467. }
  2468. } else {
  2469. echo "请重新登录";
  2470. }
  2471. $post = $this->input->post(NULL, TRUE);
  2472. if (isset($post['page'])) {
  2473. $page = $this->input->post('page', true);
  2474. $perpage = $this->input->post('perpage', true);
  2475. $warehouse = $this->input->post('warehouse', true);
  2476. $xztime = $this->input->post('xztime', true);
  2477. $timetk = $this->input->post('timetkk', true);
  2478. $timetj = $this->input->post('timetjj', true);
  2479. $shop = $this->input->post('shop', true);
  2480. $source = $this->input->post('source', true);
  2481. $orderinfo = $this->input->post('orderinfo', true);
  2482. $number = $this->input->post('number', true);
  2483. $sfxh = $this->input->post('sfxh', true);
  2484. $express = $this->input->post('express', true);
  2485. $waybill = $this->input->post('waybill', true);
  2486. $library = $this->input->post('library', true);
  2487. $country = $this->input->post('country', true);
  2488. $so = $this->input->post('so', true);
  2489. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2490. $print = $this->input->post('print', true);
  2491. $state = $this->input->post('state', true);
  2492. $orderurl = $this->input->post('orderurl', true);
  2493. $productid = $this->input->post('productid', true);
  2494. $timetk = strtotime($timetk);
  2495. $timetj = strtotime($timetj);
  2496. /**
  2497. $sj = $this->input->post('sj',true);
  2498. if($sj)
  2499. {
  2500. $sj = $this->input->post('sj',true);
  2501. }
  2502. else
  2503. {
  2504. $sj = "fullorder";
  2505. }
  2506. **/
  2507. $sj = "fullorder";
  2508. $where = "1=1";
  2509. if ($warehouse) {
  2510. $where .= " and type = '$warehouse'";
  2511. }
  2512. if ($timetk && $timetj) {
  2513. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2514. }
  2515. if ($orderinfo) {
  2516. $where .= " and orderinfo = '$orderinfo'";
  2517. }
  2518. if ($number) {
  2519. $where .= " and number = '$number'";
  2520. }
  2521. if ($express) {
  2522. $where .= " and express = '$express'";
  2523. }
  2524. if ($waybill) {
  2525. $where .= " and waybill = '$waybill'";
  2526. }
  2527. if ($library) {
  2528. $where .= " and library = '$library'";
  2529. }
  2530. if ($print) {
  2531. $where .= " and print = '$print'";
  2532. }
  2533. if ($libraryconfirm) {
  2534. $where .= " and libraryconfirm = '$libraryconfirm'";
  2535. }
  2536. if ($state) {
  2537. $where .= " and state = '$state'";
  2538. }
  2539. if ($shop) {
  2540. $where .= " and shop = '$shop'";
  2541. }
  2542. if ($country) {
  2543. $where .= " and country = '$country'";
  2544. }
  2545. if ($sfxh != '') {
  2546. $where .= " and sfxh = '$sfxh'";
  2547. }
  2548. if ($so) {
  2549. $where .= " and shipremarks like '%$so%'";
  2550. }
  2551. if ($source) {
  2552. if ($source == '2d') {
  2553. $where .= " and source >= '2'";
  2554. } else {
  2555. $where .= " and source = '$source'";
  2556. }
  2557. }
  2558. if (isset($_SESSION['api'])) {
  2559. foreach ($user as $value) {
  2560. $fgshop .= " shop = " . $value . " or";
  2561. }
  2562. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2563. }
  2564. if ($orderurl) {
  2565. $url = $this->orderurl->read($orderurl);
  2566. $where .= " and link like '%" . $url['url'] . "%'";
  2567. }
  2568. if($productid){
  2569. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2570. }
  2571. //数据排序
  2572. $order_str = "librarytime desc";
  2573. if (empty($page)) {
  2574. $start = 0;
  2575. $perpage = 1;
  2576. } else {
  2577. $start = ($page - 1) * $perpage;
  2578. }
  2579. //取得信息列表
  2580. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2581. //格式化数据
  2582. foreach ($info_list as $key => $value) {
  2583. $shop = $this->shop->read($value['shop']);
  2584. $info_list[$key]['shop'] = $shop['shopname'];
  2585. $express = $this->express->read($value['express']);
  2586. $info_list[$key]['express'] = $express['servicename'];
  2587. $warehouse = $this->warehouse->read($value['type']);
  2588. $info_list[$key]['type'] = $warehouse['title'];
  2589. if ($value['librarytime'] == '0') {
  2590. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2591. } else {
  2592. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2593. }
  2594. }
  2595. $total = $this->$sj->find_count($where);
  2596. $pagenum = ceil($total / $perpage);
  2597. $over = $total - ($start + $perpage);
  2598. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2599. echo json_encode($rows);
  2600. exit;
  2601. }
  2602. $this->data['express'] = $this->express->find_all();
  2603. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2604. $this->data['wlshop'] = $wlshop;
  2605. $user = $this->user->get_api($_SESSION['api']);
  2606. $powerid = $this->power->read($user['power']);
  2607. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2608. $pid = '';
  2609. foreach ($powertext as $v) {
  2610. $pid .= " id = " . $v . " or";
  2611. }
  2612. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2613. $this->data['fullorderexcel'] = $fullorderexcel;
  2614. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2615. $this->data['orderurl'] = $orderurl;
  2616. $this->_Template('whlabel_outorder', $this->data);
  2617. }
  2618. //tt出库
  2619. public function _toutorder()
  2620. {
  2621. $fgshop = "";
  2622. $sid = "";
  2623. if (isset($_SESSION['api'])) {
  2624. $user = $this->user->get_api($_SESSION['api']);
  2625. $usp = $user;
  2626. $user = explode('|', trim($user['shop'], '|'));
  2627. foreach ($user as $value) {
  2628. $fgshop .= " shop = " . $value . " or";
  2629. $sid .= " id = " . $value . " or";
  2630. }
  2631. } else {
  2632. echo "请重新登录";
  2633. die;
  2634. }
  2635. $post = $this->input->post(NULL, TRUE);
  2636. if (isset($post['page'])) {
  2637. $page = $this->input->post('page', true);
  2638. $perpage = $this->input->post('perpage', true);
  2639. $warehouse = $this->input->post('warehouse', true);
  2640. $xztime = $this->input->post('xztime', true);
  2641. $timetk = $this->input->post('timetkk', true);
  2642. $timetj = $this->input->post('timetjj', true);
  2643. $shop = $this->input->post('shop', true);
  2644. $source = $this->input->post('source', true);
  2645. $orderinfo = $this->input->post('orderinfo', true);
  2646. $number = $this->input->post('number', true);
  2647. $sfxh = $this->input->post('sfxh', true);
  2648. $express = $this->input->post('express', true);
  2649. $waybill = $this->input->post('waybill', true);
  2650. $library = $this->input->post('library', true);
  2651. $country = $this->input->post('country', true);
  2652. $so = $this->input->post('so', true);
  2653. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2654. $print = $this->input->post('print', true);
  2655. $state = $this->input->post('state', true);
  2656. $orderurl = $this->input->post('orderurl', true);
  2657. $timetk = strtotime($timetk);
  2658. $timetj = strtotime($timetj);
  2659. /**
  2660. $sj = $this->input->post('sj',true);
  2661. if($sj)
  2662. {
  2663. $sj = $this->input->post('sj',true);
  2664. }
  2665. else
  2666. {
  2667. $sj = "fullorder";
  2668. }
  2669. **/
  2670. $sj = "fullordertt";
  2671. $where = "1=1";
  2672. if ($warehouse) {
  2673. $where .= " and type = '$warehouse'";
  2674. }
  2675. if ($timetk && $timetj) {
  2676. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2677. }
  2678. if ($orderinfo) {
  2679. $where .= " and orderinfo = '$orderinfo'";
  2680. }
  2681. if ($number) {
  2682. $where .= " and number = '$number'";
  2683. }
  2684. if ($express) {
  2685. $where .= " and express = '$express'";
  2686. }
  2687. if ($waybill) {
  2688. $where .= " and waybill = '$waybill'";
  2689. }
  2690. if ($library) {
  2691. $where .= " and library = '$library'";
  2692. }
  2693. if ($print) {
  2694. $where .= " and print = '$print'";
  2695. }
  2696. if ($libraryconfirm) {
  2697. $where .= " and libraryconfirm = '$libraryconfirm'";
  2698. }
  2699. if ($state) {
  2700. $where .= " and state = '$state'";
  2701. }
  2702. if ($shop) {
  2703. $where .= " and shop = '$shop'";
  2704. }
  2705. if ($country) {
  2706. $where .= " and country = '$country'";
  2707. }
  2708. if ($sfxh != '') {
  2709. $where .= " and sfxh = '$sfxh'";
  2710. }
  2711. if ($so) {
  2712. $where .= " and shipremarks like '%$so%'";
  2713. }
  2714. if ($source) {
  2715. if ($source == '2d') {
  2716. $where .= " and source >= '2'";
  2717. } else {
  2718. $where .= " and source = '$source'";
  2719. }
  2720. }
  2721. if (isset($_SESSION['api'])) {
  2722. foreach ($user as $value) {
  2723. $fgshop .= " shop = " . $value . " or";
  2724. }
  2725. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2726. }
  2727. if ($orderurl) {
  2728. $url = $this->orderurl->read($orderurl);
  2729. $where .= " and link like '%" . $url['url'] . "%'";
  2730. }
  2731. //数据排序
  2732. $order_str = "librarytime desc";
  2733. if (empty($page)) {
  2734. $start = 0;
  2735. $perpage = 1;
  2736. } else {
  2737. $start = ($page - 1) * $perpage;
  2738. }
  2739. //取得信息列表
  2740. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2741. //格式化数据
  2742. foreach ($info_list as $key => $value) {
  2743. $shop = $this->shop->read($value['shop']);
  2744. $info_list[$key]['shop'] = $shop['shopname'];
  2745. $express = $this->express->read($value['express']);
  2746. $info_list[$key]['express'] = $express['servicename'];
  2747. $warehouse = $this->warehouse->read($value['type']);
  2748. $info_list[$key]['type'] = $warehouse['title'];
  2749. if ($value['librarytime'] == '0') {
  2750. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2751. } else {
  2752. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2753. }
  2754. }
  2755. $total = $this->$sj->find_count($where);
  2756. $pagenum = ceil($total / $perpage);
  2757. $over = $total - ($start + $perpage);
  2758. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2759. echo json_encode($rows);
  2760. exit;
  2761. }
  2762. $this->data['express'] = $this->express->find_all();
  2763. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2764. $this->data['wlshop'] = $wlshop;
  2765. $user = $this->user->get_api($_SESSION['api']);
  2766. $powerid = $this->power->read($user['power']);
  2767. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2768. $pid = '';
  2769. foreach ($powertext as $v) {
  2770. $pid .= " id = " . $v . " or";
  2771. }
  2772. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2773. $this->data['fullorderexcel'] = $fullorderexcel;
  2774. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2775. $this->data['orderurl'] = $orderurl;
  2776. $this->_Template('whlabel_toutorder', $this->data);
  2777. }
  2778. //tt出库
  2779. public function _aoutorder()
  2780. {
  2781. if (isset($_SESSION['api'])) {
  2782. $user = $this->user->get_api($_SESSION['api']);
  2783. $usp = $user;
  2784. $fgshop = "";
  2785. $sid = "";
  2786. $user = explode('|', trim($user['shop'], '|'));
  2787. foreach ($user as $value) {
  2788. $fgshop .= " shop = " . $value . " or";
  2789. $sid .= " id = " . $value . " or";
  2790. }
  2791. } else {
  2792. echo "请重新登录";
  2793. }
  2794. $post = $this->input->post(NULL, TRUE);
  2795. if (isset($post['page'])) {
  2796. $page = $this->input->post('page', true);
  2797. $perpage = $this->input->post('perpage', true);
  2798. $warehouse = $this->input->post('warehouse', true);
  2799. $xztime = $this->input->post('xztime', true);
  2800. $timetk = $this->input->post('timetkk', true);
  2801. $timetj = $this->input->post('timetjj', true);
  2802. $shop = $this->input->post('shop', true);
  2803. $source = $this->input->post('source', true);
  2804. $orderinfo = $this->input->post('orderinfo', true);
  2805. $number = $this->input->post('number', true);
  2806. $sfxh = $this->input->post('sfxh', true);
  2807. $express = $this->input->post('express', true);
  2808. $waybill = $this->input->post('waybill', true);
  2809. $library = $this->input->post('library', true);
  2810. $country = $this->input->post('country', true);
  2811. $so = $this->input->post('so', true);
  2812. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2813. $print = $this->input->post('print', true);
  2814. $state = $this->input->post('state', true);
  2815. $orderurl = $this->input->post('orderurl', true);
  2816. $timetk = strtotime($timetk);
  2817. $timetj = strtotime($timetj);
  2818. /**
  2819. $sj = $this->input->post('sj',true);
  2820. if($sj)
  2821. {
  2822. $sj = $this->input->post('sj',true);
  2823. }
  2824. else
  2825. {
  2826. $sj = "fullorder";
  2827. }
  2828. **/
  2829. $sj = "fullorderamz";
  2830. $where = "1=1";
  2831. if ($warehouse) {
  2832. $where .= " and type = '$warehouse'";
  2833. }
  2834. if ($timetk && $timetj) {
  2835. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2836. }
  2837. if ($orderinfo) {
  2838. $where .= " and orderinfo = '$orderinfo'";
  2839. }
  2840. if ($number) {
  2841. $where .= " and number = '$number'";
  2842. }
  2843. if ($express) {
  2844. $where .= " and express = '$express'";
  2845. }
  2846. if ($waybill) {
  2847. $where .= " and waybill = '$waybill'";
  2848. }
  2849. if ($library) {
  2850. $where .= " and library = '$library'";
  2851. }
  2852. if ($print) {
  2853. $where .= " and print = '$print'";
  2854. }
  2855. if ($libraryconfirm) {
  2856. $where .= " and libraryconfirm = '$libraryconfirm'";
  2857. }
  2858. if ($state) {
  2859. $where .= " and state = '$state'";
  2860. }
  2861. if ($shop) {
  2862. $where .= " and shop = '$shop'";
  2863. }
  2864. if ($country) {
  2865. $where .= " and country = '$country'";
  2866. }
  2867. if ($sfxh != '') {
  2868. $where .= " and sfxh = '$sfxh'";
  2869. }
  2870. if ($so) {
  2871. $where .= " and shipremarks like '%$so%'";
  2872. }
  2873. if ($source) {
  2874. if ($source == '2d') {
  2875. $where .= " and source >= '2'";
  2876. } else {
  2877. $where .= " and source = '$source'";
  2878. }
  2879. }
  2880. if (isset($_SESSION['api'])) {
  2881. foreach ($user as $value) {
  2882. $fgshop .= " shop = " . $value . " or";
  2883. }
  2884. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2885. }
  2886. if ($orderurl) {
  2887. $url = $this->orderurl->read($orderurl);
  2888. $where .= " and link like '%" . $url['url'] . "%'";
  2889. }
  2890. //数据排序
  2891. $order_str = "librarytime desc";
  2892. if (empty($page)) {
  2893. $start = 0;
  2894. $perpage = 1;
  2895. } else {
  2896. $start = ($page - 1) * $perpage;
  2897. }
  2898. //取得信息列表
  2899. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2900. //格式化数据
  2901. foreach ($info_list as $key => $value) {
  2902. $shop = $this->shop->read($value['shop']);
  2903. $info_list[$key]['shop'] = $shop['shopname'];
  2904. $express = $this->express->read($value['express']);
  2905. $info_list[$key]['express'] = $express['servicename'];
  2906. $warehouse = $this->warehouse->read($value['type']);
  2907. $info_list[$key]['type'] = $warehouse['title'];
  2908. if ($value['librarytime'] == '0') {
  2909. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2910. } else {
  2911. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2912. }
  2913. }
  2914. $total = $this->$sj->find_count($where);
  2915. $pagenum = ceil($total / $perpage);
  2916. $over = $total - ($start + $perpage);
  2917. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2918. echo json_encode($rows);
  2919. exit;
  2920. }
  2921. $this->data['express'] = $this->express->find_all();
  2922. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2923. $this->data['wlshop'] = $wlshop;
  2924. $user = $this->user->get_api($_SESSION['api']);
  2925. $powerid = $this->power->read($user['power']);
  2926. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2927. $pid = '';
  2928. foreach ($powertext as $v) {
  2929. $pid .= " id = " . $v . " or";
  2930. }
  2931. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2932. $this->data['fullorderexcel'] = $fullorderexcel;
  2933. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2934. $this->data['orderurl'] = $orderurl;
  2935. $this->_Template('whlabel_aoutorder', $this->data);
  2936. }
  2937. //速卖通出库订单
  2938. public function _soutorder()
  2939. {
  2940. if (isset($_SESSION['api'])) {
  2941. $user = $this->user->get_api($_SESSION['api']);
  2942. $usp = $user;
  2943. $fgshop = "";
  2944. $sid = "";
  2945. $user = explode('|', trim($user['shop'], '|'));
  2946. foreach ($user as $value) {
  2947. $sid .= " id = " . $value . " or";
  2948. }
  2949. }
  2950. $post = $this->input->post(NULL, TRUE);
  2951. if (isset($post['page'])) {
  2952. $page = $this->input->post('page', true);
  2953. $perpage = $this->input->post('perpage', true);
  2954. $warehouse = $this->input->post('warehouse', true);
  2955. $xztime = $this->input->post('xztime', true);
  2956. $timetk = $this->input->post('timetkk', true);
  2957. $timetj = $this->input->post('timetjj', true);
  2958. $shop = $this->input->post('shop', true);
  2959. $source = $this->input->post('source', true);
  2960. $orderinfo = $this->input->post('orderinfo', true);
  2961. $number = $this->input->post('number', true);
  2962. $express = $this->input->post('express', true);
  2963. $waybill = $this->input->post('waybill', true);
  2964. $library = $this->input->post('library', true);
  2965. $country = $this->input->post('country', true);
  2966. $sfxh = $this->input->post('sfxh', true);
  2967. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2968. $print = $this->input->post('print', true);
  2969. $state = $this->input->post('state', true);
  2970. $so = $this->input->post('so', true);
  2971. $timetk = strtotime($timetk);
  2972. $timetj = strtotime($timetj);
  2973. /**
  2974. $sj = $this->input->post('sj',true);
  2975. if($sj)
  2976. {
  2977. $sj = $this->input->post('sj',true);
  2978. }
  2979. else
  2980. {
  2981. $sj = "fullorder";
  2982. }
  2983. **/
  2984. $sj = "fullordersmt";
  2985. $where = "1=1";
  2986. if ($warehouse) {
  2987. $where .= " and type = '$warehouse'";
  2988. }
  2989. if ($timetk && $timetj) {
  2990. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2991. }
  2992. if ($orderinfo) {
  2993. $where .= " and orderinfo = '$orderinfo'";
  2994. }
  2995. if ($number) {
  2996. $where .= " and number = '$number'";
  2997. }
  2998. if ($express) {
  2999. $where .= " and express = '$express'";
  3000. }
  3001. if ($waybill) {
  3002. $where .= " and waybill = '$waybill'";
  3003. }
  3004. if ($library) {
  3005. $where .= " and library = '$library'";
  3006. }
  3007. if ($print) {
  3008. $where .= " and print = '$print'";
  3009. }
  3010. if ($libraryconfirm) {
  3011. $where .= " and libraryconfirm = '$libraryconfirm'";
  3012. }
  3013. if ($state) {
  3014. $where .= " and state = '$state'";
  3015. }
  3016. if ($shop) {
  3017. $where .= " and shop = '$shop'";
  3018. }
  3019. if ($sfxh != '') {
  3020. $where .= " and sfxh = '$sfxh'";
  3021. }
  3022. if ($so) {
  3023. $where .= " and shipremarks like '%$so%'";
  3024. }
  3025. if ($source) {
  3026. $where .= " and source = '$source'";
  3027. }
  3028. if ($country) {
  3029. $where .= " and country = '$country'";
  3030. } else {
  3031. if (isset($_SESSION['api'])) {
  3032. foreach ($user as $value) {
  3033. $fgshop .= " shop = " . $value . " or";
  3034. }
  3035. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3036. }
  3037. }
  3038. //数据排序
  3039. $order_str = "librarytime desc";
  3040. if (empty($page)) {
  3041. $start = 0;
  3042. $perpage = 1;
  3043. } else {
  3044. $start = ($page - 1) * $perpage;
  3045. }
  3046. //取得信息列表
  3047. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3048. //格式化数据
  3049. foreach ($info_list as $key => $value) {
  3050. $shop = $this->shop->read($value['shop']);
  3051. $info_list[$key]['shop'] = $shop['shopname'];
  3052. $express = $this->express->read($value['express']);
  3053. $info_list[$key]['express'] = $express['servicename'];
  3054. $warehouse = $this->warehouse->read($value['type']);
  3055. $info_list[$key]['type'] = $warehouse['title'];
  3056. if ($value['librarytime'] == '0') {
  3057. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3058. } else {
  3059. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3060. }
  3061. }
  3062. $total = $this->$sj->find_count($where);
  3063. $pagenum = ceil($total / $perpage);
  3064. $over = $total - ($start + $perpage);
  3065. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3066. echo json_encode($rows);
  3067. exit;
  3068. }
  3069. $this->data['express'] = $this->express->find_all();
  3070. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3071. $this->data['wlshop'] = $wlshop;
  3072. $user = $this->user->get_api($_SESSION['api']);
  3073. $powerid = $this->power->read($user['power']);
  3074. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3075. $pid = '';
  3076. foreach ($powertext as $v) {
  3077. $pid .= " id = " . $v . " or";
  3078. }
  3079. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3080. $this->data['fullorderexcel'] = $fullorderexcel;
  3081. $this->_Template('whlabel_soutorder', $this->data);
  3082. }
  3083. //订单退库
  3084. public function _retreat()
  3085. {
  3086. $post = $this->input->post(NULL, TRUE);
  3087. if (isset($post['page'])) {
  3088. $page = $this->input->post('page', true);
  3089. $perpage = $this->input->post('perpage', true);
  3090. $warehouse = $this->input->post('warehouse', true);
  3091. $timetk = $this->input->post('timetk', true);
  3092. $timetj = $this->input->post('timetj', true);
  3093. $shop = $this->input->post('shop', true);
  3094. $source = $this->input->post('source', true);
  3095. $state = $this->input->post('state', true);
  3096. $review = $this->input->post('review', true);
  3097. $state = $this->input->post('state', true);
  3098. $express = $this->input->post('express', true);
  3099. $orderinfo = $this->input->post('orderinfo', true);
  3100. $user = $this->input->post('user', true);
  3101. $name = $this->input->post('name', true);
  3102. $waybill = $this->input->post('waybill', true);
  3103. $timetk = strtotime($timetk);
  3104. $timetj = strtotime($timetj);
  3105. $where = "(state=206 or state=210) and mergeid = 0";
  3106. if ($warehouse) {
  3107. $where .= " and state = '$warehouse'";
  3108. }
  3109. if ($timetk && $timetj) {
  3110. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3111. }
  3112. if ($shop) {
  3113. $where .= " and shop = '$shop'";
  3114. }
  3115. if ($source) {
  3116. $where .= " and source = '$source'";
  3117. }
  3118. if ($state) {
  3119. $where .= " and state = '$state'";
  3120. }
  3121. if ($review) {
  3122. $where .= " and review = '$review'";
  3123. }
  3124. if ($state) {
  3125. $where .= " and state = '$state'";
  3126. }
  3127. if ($express) {
  3128. $where .= " and express = '$express'";
  3129. }
  3130. if ($orderinfo) {
  3131. $where .= " and orderinfo = '$orderinfo'";
  3132. }
  3133. if ($user) {
  3134. $where .= " and user = '$user'";
  3135. }
  3136. if ($name) {
  3137. $where .= " and name = '$name'";
  3138. }
  3139. if ($waybill) {
  3140. $where .= " and waybill = '$waybill'";
  3141. }
  3142. //数据排序
  3143. $order_str = "id desc";
  3144. if (empty($page)) {
  3145. $start = 0;
  3146. $perpage = 1;
  3147. } else {
  3148. $start = ($page - 1) * $perpage;
  3149. }
  3150. //取得信息列表
  3151. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3152. //格式化数据
  3153. foreach ($info_list as $key => $value) {
  3154. $shop = $this->shop->read($value['shop']);
  3155. $info_list[$key]['shop'] = $shop['shopname'];
  3156. $warehouse = $this->warehouse->read($value['warehouse']);
  3157. $info_list[$key]['warehouse'] = $warehouse['title'];
  3158. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3159. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3160. if ($value['waybill'] == 0) {
  3161. $info_list[$key]['waybill'] = "";
  3162. }
  3163. $express = $this->express->read($value['express']);
  3164. $info_list[$key]['express'] = $express['title'];
  3165. $typeclass = $this->typeclass->read($value['state']);
  3166. $info_list[$key]['state'] = $typeclass['title'];
  3167. }
  3168. $total = $this->fullorder->find_count($where);
  3169. $pagenum = ceil($total / $perpage);
  3170. $over = $total - ($start + $perpage);
  3171. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3172. echo json_encode($rows);
  3173. exit;
  3174. }
  3175. $this->data['express'] = $this->express->find_all();
  3176. $this->_Template('whlabel_retreat', $this->data);
  3177. }
  3178. //退库标签浏览
  3179. public function _retreatlk()
  3180. {
  3181. $post = $this->input->post(NULL, TRUE);
  3182. if (isset($post['page'])) {
  3183. $page = $this->input->post('page', true);
  3184. $perpage = $this->input->post('perpage', true);
  3185. $timetk = $this->input->post('timetk', true);
  3186. $timetj = $this->input->post('timetj', true);
  3187. $sku = $this->input->post('sku', true);
  3188. $warehouse = $this->input->post('warehouse', true);
  3189. $purchase = $this->input->post('purchase', true);
  3190. $orderinfo = $this->input->post('orderinfo', true);
  3191. $waybill = $this->input->post('waybill', true);
  3192. $category = $this->input->post('category', true);
  3193. $size = $this->input->post('size', true);
  3194. $grade = $this->input->post('grade', true);
  3195. $color = $this->input->post('color', true);
  3196. $lowe = $this->input->post('lowe', true);
  3197. $state = $this->input->post('state', true);
  3198. $timetk = strtotime($timetk);
  3199. $timetj = strtotime($timetj);
  3200. $where = "state=2";
  3201. if ($timetk && $timetj) {
  3202. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3203. }
  3204. if ($sku) {
  3205. $where .= " and sku = '$sku'";
  3206. }
  3207. if ($warehouse) {
  3208. $where .= " and warehouse = '$warehouse'";
  3209. }
  3210. if ($purchase) {
  3211. $where .= " and purchase = '$purchase'";
  3212. }
  3213. if ($orderinfo) {
  3214. $where .= " and orderinfo = '$orderinfo'";
  3215. }
  3216. if ($waybill) {
  3217. $where .= " and waybill = '$waybill'";
  3218. }
  3219. if ($category) {
  3220. $where .= " and features like '%-$category-%'";
  3221. }
  3222. if ($size) {
  3223. $where .= " and features like '%-$size-%'";
  3224. }
  3225. if ($grade) {
  3226. $where .= " and features like '%-$grade-%'";
  3227. }
  3228. if ($color) {
  3229. $where .= " and features like '%-$color-%'";
  3230. }
  3231. if ($lowe) {
  3232. $where .= " and features like '%-$lowe-%'";
  3233. }
  3234. //数据排序
  3235. $order_str = "time desc";
  3236. if (empty($page)) {
  3237. $start = 0;
  3238. $perpage = 1;
  3239. } else {
  3240. $start = ($page - 1) * $perpage;
  3241. }
  3242. //取得信息列表
  3243. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3244. foreach ($info_list as $key => $value) {
  3245. $warehouse = $this->warehouse->read($value['warehouse']);
  3246. $info_list[$key]['warehouse'] = $warehouse['title'];
  3247. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3248. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3249. $purchase = $this->purchase->read($value['purchase']);
  3250. $info_list[$key]['purchase'] = $purchase['title'];
  3251. if ($value['outk'] != 0) {
  3252. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3253. } else {
  3254. $info_list[$key]['outk'] = "";
  3255. }
  3256. if ($value['retreat'] != 0) {
  3257. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3258. } else {
  3259. $info_list[$key]['retreat'] = "";
  3260. }
  3261. if ($value['orderinfo'] == 0) {
  3262. $info_list[$key]['orderinfo'] = "";
  3263. }
  3264. if ($value['waybill'] == 0) {
  3265. $info_list[$key]['waybill'] = "";
  3266. }
  3267. }
  3268. $total = $this->whlabel->find_count($where);
  3269. $pagenum = ceil($total / $perpage);
  3270. $over = $total - ($start + $perpage);
  3271. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3272. echo json_encode($rows);
  3273. exit;
  3274. }
  3275. $this->_Template('whlabel_retreatlk', $this->data);
  3276. }
  3277. //更换标签及浏览
  3278. public function _change()
  3279. {
  3280. $post = $this->input->post(NULL, TRUE);
  3281. if (isset($post['page'])) {
  3282. $page = $this->input->post('page', true);
  3283. $perpage = $this->input->post('perpage', true);
  3284. $timetk = $this->input->post('timetk', true);
  3285. $timetj = $this->input->post('timetj', true);
  3286. $label = $this->input->post('label', true);
  3287. $oldlabel = $this->input->post('oldlabel', true);
  3288. $timetk = strtotime($timetk);
  3289. $timetj = strtotime($timetj);
  3290. $where = "state=10 ";
  3291. if ($timetk && $timetj) {
  3292. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3293. }
  3294. if ($label) {
  3295. $where .= " and label = '$label'";
  3296. }
  3297. if ($oldlabel) {
  3298. $where .= " and oldlabel = '$oldlabel'";
  3299. }
  3300. //数据排序
  3301. $order_str = "time asc";
  3302. if (empty($page)) {
  3303. $start = 0;
  3304. $perpage = 1;
  3305. } else {
  3306. $start = ($page - 1) * $perpage;
  3307. }
  3308. //取得信息列表
  3309. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3310. foreach ($info_list as $key => $value) {
  3311. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3312. }
  3313. $total = $this->whlabel->find_count($where);
  3314. $pagenum = ceil($total / $perpage);
  3315. $over = $total - ($start + $perpage);
  3316. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3317. echo json_encode($rows);
  3318. exit;
  3319. }
  3320. $this->_Template('whlabel_change', $this->data);
  3321. }
  3322. //产品标签
  3323. public function _cpbqdc()
  3324. {
  3325. if (isset($_GET['excel'])) {
  3326. $where = "1=1";
  3327. //数据排序
  3328. $order_str = "id desc";
  3329. if (empty($page)) {
  3330. $start = 0;
  3331. $perpage = 1;
  3332. } else {
  3333. $start = ($page - 1) * $perpage;
  3334. }
  3335. $warehouse = $this->input->get('warehouse', true);
  3336. $state = $this->input->get('state', true);
  3337. $timetk = $this->input->get('timetkk', true);
  3338. $timetj = $this->input->get('timetjj', true);
  3339. $timetk = strtotime($timetk);
  3340. $timetj = strtotime($timetj);
  3341. if ($warehouse) {
  3342. $where .= " and warehouse = '$warehouse'";
  3343. }
  3344. if ($state || $state == 0) {
  3345. $where .= " and state = '$state'";
  3346. }
  3347. if ($timetk && $timetj) {
  3348. $where .= " and time > '$timetk' and time < '$timetj'";
  3349. }
  3350. //取得信息列表
  3351. $info_list = $this->whlabel->find_all($where, '*');
  3352. $rows = array();
  3353. $list = array();
  3354. foreach ($info_list as $key => $value) {
  3355. $rows[$value['time']] = $value; //所有数据sku
  3356. }
  3357. foreach ($rows as $value) {
  3358. $warehouse = $this->warehouse->read($value['warehouse']);
  3359. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3360. $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);
  3361. }
  3362. $title = "产品标签统计表";
  3363. $titlename = "<table border=1>
  3364. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3365. <tr align='center'>
  3366. <td>仓库</td>
  3367. <td>SKU</td>
  3368. <td>产品</td>
  3369. <td>入库时间</td>
  3370. <td>操作时间</td>
  3371. <td>备注</td>
  3372. <td>数量</td>
  3373. </tr>
  3374. </table>";
  3375. $filename = $title . ".xls";
  3376. $tail = "";
  3377. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3378. }
  3379. }
  3380. //进销存导出
  3381. public function _exceljxc()
  3382. {
  3383. $classid = $this->classid->sku();
  3384. $pm = $classid;
  3385. $typeclass = array();
  3386. $tc = $this->typeclass->find_all();
  3387. foreach ($tc as $v) {
  3388. $typeclass[$v['id']] = $v;
  3389. }
  3390. $prc = array();
  3391. $purchase = $this->purchase->find_all();
  3392. foreach ($purchase as $k => $v) {
  3393. $prc[$v['id']] = $v['title'];
  3394. }
  3395. if (isset($_GET['excel'])) {
  3396. $where = "sku != 'Preset'";
  3397. //数据排序
  3398. $order_str = "id desc";
  3399. if (empty($page)) {
  3400. $start = 0;
  3401. $perpage = 1;
  3402. } else {
  3403. $start = ($page - 1) * $perpage;
  3404. }
  3405. $category = $this->input->get('category', true);
  3406. $warehouse = $this->input->get('warehouse', true);
  3407. $excelid = $this->input->get('sid', true);
  3408. if ($category) {
  3409. $where .= " and features like '%-$category-%'";
  3410. }
  3411. if ($warehouse) {
  3412. $where .= " and warehouse = '$warehouse'";
  3413. }
  3414. $xzid = '';
  3415. if ($excelid) {
  3416. $excelid = explode(',', trim($excelid, ','));
  3417. foreach ($excelid as $key => $value) {
  3418. $xzid .= " id = " . $value . " or";
  3419. }
  3420. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3421. }
  3422. //取得信息列表
  3423. /**
  3424. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3425. $rows = array();$list = array();
  3426. foreach ($info_list as $key=>$value)
  3427. {
  3428. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3429. }
  3430. **/
  3431. $wt = array();
  3432. $whlabel_type = $this->whlabel_type->find_all();
  3433. foreach ($whlabel_type as $v) {
  3434. $wt[$v['id']] = $v['title'];
  3435. }
  3436. $wh = array();
  3437. $w = $this->warehouse->find_all('1=1', 'id,title');
  3438. foreach ($w as $v) {
  3439. $wh[$v['id']] = $v['title'];
  3440. }
  3441. $list = array();
  3442. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3443. foreach ($rows as $key => $value) {
  3444. if (isset($wt[$value['type']])) {
  3445. $rows[$key]['type'] = $wt[$value['type']];
  3446. } else {
  3447. $rows[$key]['type'] = '未设置';
  3448. }
  3449. $bm = '03';
  3450. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3451. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3452. $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');
  3453. $details = array();
  3454. $cpid = array();
  3455. $cpbz = array();
  3456. $c = 0;
  3457. $g = 0;
  3458. $x = 0;
  3459. $t = 0;
  3460. $s = 0;
  3461. $q = 0;
  3462. foreach ($sd as $k => $v) {
  3463. if ($v['state'] == 0) {
  3464. $c++;
  3465. if ($v['cpid'] != 0) {
  3466. $cpid[$v['cpid']] = $v['cpid'];
  3467. }
  3468. if ($v['cpbz'] != '') {
  3469. $cpbz[$v['cpbz']] = $v['cpbz'];
  3470. }
  3471. }
  3472. if ($v['state'] != 9) {
  3473. $g++;
  3474. }
  3475. if ($v['state'] == 1) {
  3476. $x++;
  3477. }
  3478. if ($v['state'] == 2) {
  3479. $t++;
  3480. }
  3481. if ($v['state'] == 8) {
  3482. $s++;
  3483. }
  3484. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3485. $q++;
  3486. }
  3487. $details[$v['details']] = $v['details'];
  3488. }
  3489. $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'] . '"');
  3490. $rows[$key]['details'] = implode("、", $details);
  3491. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3492. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3493. $number = $value['number'];
  3494. $ftime = time() - 15 * 24 * 3600;
  3495. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3496. $rows[$key]['number'] = $g;
  3497. $rows[$key]['c'] = $c;
  3498. $rows[$key]['x'] = $x;
  3499. $rows[$key]['t'] = $t;
  3500. $rows[$key]['s'] = $s;
  3501. $rows[$key]['q'] = $q;
  3502. $rows[$key]['z'] = $z;
  3503. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3504. $features = explode('-', trim($features, '-'));
  3505. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3506. // $pm = $classid;
  3507. // $jm = $classid;
  3508. // foreach($features as $k=>$v)
  3509. // {
  3510. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3511. // {
  3512. // if($typeclass[$v]['bm'] != '')
  3513. // {
  3514. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3515. // }
  3516. // }
  3517. // if($v != 0)
  3518. // {
  3519. // if(!isset($typeclass[$v]))
  3520. // {
  3521. // continue;
  3522. // }
  3523. // if(isset($pm[$typeclass[$v]['classid']]))
  3524. // {
  3525. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3526. // {
  3527. // $tz = explode('|',$typeclass[$v]['zh']);
  3528. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3529. // }
  3530. // else
  3531. // {
  3532. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3533. // }
  3534. // }
  3535. // if(isset($jm[$typeclass[$v]['classid']]))
  3536. // {
  3537. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3538. // }
  3539. // }
  3540. // }
  3541. // $jm = array_filter($jm);
  3542. // $rows[$key]['bs'] = implode("-",$jm);
  3543. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3544. // $zh = implode(" ",$pm);
  3545. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3546. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3547. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3548. // $rows[$key]['features'] = $zh;
  3549. }
  3550. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3551. $final_list = [];
  3552. foreach ($list as $k => $v) {
  3553. if (empty($v['sku'])) {
  3554. continue;
  3555. }
  3556. $final_list[] = [
  3557. "warehouse" => $v["warehouse"],
  3558. "purchase" => $v["purchase"],
  3559. "details" => $v["details"],
  3560. "cpid" => $v["cpid"],
  3561. "dbcontent" => $v["dbcontent"],
  3562. "sku" => $v["sku"],
  3563. "cs" => $v["bm"],
  3564. "bs" => $v["jm"],
  3565. "title" => $v["title"],
  3566. "features" => $v["pm"],
  3567. "cpbz" => $v["cpbz"],
  3568. "sm" => $v["sm"],
  3569. "type" => $v["type"],
  3570. "number" => $v["number"],
  3571. "c" => $v["c"],
  3572. "x" => $v["x"],
  3573. "t" => $v["t"],
  3574. "s" => $v["s"],
  3575. "q" => $v["q"],
  3576. "z" => $v["z"],
  3577. "weight" => $v['weight'],
  3578. ];
  3579. }
  3580. $title = "总进销存统计表";
  3581. $titlename = "<table border=1>
  3582. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3583. <tr align='center'>
  3584. <td>仓库</td>
  3585. <td>供应商</td>
  3586. <td>位置</td>
  3587. <td>库存编码</td>
  3588. <td>类目</td>
  3589. <td>SKU</td>
  3590. <td>用友编码</td>
  3591. <td>用友料号</td>
  3592. <td>商品名称</td>
  3593. <td>商品中文</td>
  3594. <td>产品备注</td>
  3595. <td>库位负责人</td>
  3596. <td>类型</td>
  3597. <td>入库总量</td>
  3598. <td>库存数量</td>
  3599. <td>销售数量</td>
  3600. <td>退货数量</td>
  3601. <td>删除数量</td>
  3602. <td>其它操作</td>
  3603. <td>占单数量</td>
  3604. <td>重量(g)</td>
  3605. </tr>
  3606. </table>";
  3607. $filename = $title . ".xls";
  3608. $tail = "";
  3609. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3610. }
  3611. }
  3612. //入库导出
  3613. public function _excelr()
  3614. {
  3615. if (isset($_GET['excel'])) {
  3616. $category = $this->input->get('category', true);
  3617. $size = $this->input->get('size', true);
  3618. $grade = $this->input->get('grade', true);
  3619. $color = $this->input->get('color', true);
  3620. $lowe = $this->input->get('lowe', true);
  3621. $sku = $this->input->get('sku', true);
  3622. $warehouse = $this->input->get('warehouse', true);
  3623. $purchase = $this->input->get('purchase', true);
  3624. $ktime = $this->input->get('ktime', true);
  3625. $jtime = $this->input->get('jtime', true);
  3626. $ktime = strtotime($ktime);
  3627. $jtime = strtotime($jtime);
  3628. $where = "1=1";
  3629. $gj = "";
  3630. $ck = "";
  3631. if ($category) {
  3632. $where .= " and features like '%-$category-%'";
  3633. }
  3634. if ($size) {
  3635. $where .= " and features like '%-$size-%'";
  3636. }
  3637. if ($grade) {
  3638. $where .= " and features like '%-$grade-%'";
  3639. }
  3640. if ($color) {
  3641. $where .= " and features like '%-$color-%'";
  3642. }
  3643. if ($lowe) {
  3644. $where .= " and features like '%-$lowe-%'";
  3645. }
  3646. if ($warehouse) {
  3647. $where .= " and warehouse = '$warehouse'";
  3648. }
  3649. if ($purchase) {
  3650. $where .= " and purchase = '$purchase'";
  3651. }
  3652. if ($sku) {
  3653. $where .= " and sku = '$sku'";
  3654. }
  3655. if ($ktime && $jtime) {
  3656. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3657. }
  3658. //数据排序
  3659. $order_str = "id desc";
  3660. if (empty($page)) {
  3661. $start = 0;
  3662. $perpage = 1;
  3663. } else {
  3664. $start = ($page - 1) * $perpage;
  3665. }
  3666. $list = array();
  3667. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3668. foreach ($rows as $value) {
  3669. $ck = $this->warehouse->read($value['warehouse']);
  3670. $warehouse = $ck['title'];
  3671. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3672. $retreatwarehouse = $tkck['title'];
  3673. $gy = $this->purchase->read($value['purchase']);
  3674. $purchase = $gy['title'];
  3675. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3676. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3677. }
  3678. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3679. $titlename = "<table border=1>
  3680. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3681. <tr align='center'>
  3682. <td>仓库</td>
  3683. <td>SKU</td>
  3684. <td>产品</td>
  3685. <td>时间</td>
  3686. <td>数量</td>
  3687. </tr>
  3688. </table>";
  3689. $filename = $title . ".xls";
  3690. $tail = "";
  3691. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  3692. }
  3693. }
  3694. //出库、退库导出
  3695. public function _excelct()
  3696. {
  3697. $classid = $this->classid->sku();
  3698. $pm = $classid;
  3699. $typeclass = array();
  3700. $tc = $this->typeclass->find_all();
  3701. foreach ($tc as $v) {
  3702. $typeclass[$v['id']] = $v;
  3703. }
  3704. $prc = array();
  3705. $purchase = $this->purchase->find_all();
  3706. foreach ($purchase as $k => $v) {
  3707. $prc[$v['id']] = $v['title'];
  3708. }
  3709. if (isset($_GET['excel'])) {
  3710. $wh = array();
  3711. $w = $this->warehouse->find_all('1=1', 'id,title');
  3712. foreach ($w as $v) {
  3713. $wh[$v['id']] = $v['title'];
  3714. }
  3715. $type = $this->input->get('excel', true);
  3716. $category = $this->input->get('category', true);
  3717. $size = $this->input->get('size', true);
  3718. $grade = $this->input->get('grade', true);
  3719. $color = $this->input->get('color', true);
  3720. $lowe = $this->input->get('lowe', true);
  3721. $sku = $this->input->get('sku', true);
  3722. $title = $this->input->get('title', true);
  3723. $warehouse = $this->input->get('warehouse', true);
  3724. $purchase = $this->input->get('purchase', true);
  3725. $lacetype = $this->input->get('lacetype', true);
  3726. $haircap = $this->input->get('haircap', true);
  3727. $lacecolor = $this->input->get('lacecolor', true);
  3728. $density = $this->input->get('density', true);
  3729. $details = $this->input->get('details', true);
  3730. $state = $this->input->get('state', true);
  3731. $shop = $this->input->get('shop', true);
  3732. $hairnumber = $this->input->get('hairnumber', true);
  3733. $type_leixi = $this->input->get('type', true);
  3734. $cpbz = $this->input->get('cpbz', true);
  3735. $sm = $this->input->get('sm', true);
  3736. $sid = $this->input->get('sid', true);
  3737. $ktime = $this->input->get('ktime', true);
  3738. $jtime = $this->input->get('jtime', true);
  3739. $ktime = strtotime($ktime);
  3740. $jtime = strtotime($jtime);
  3741. //$where = " 1=1 ";
  3742. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3743. $where = " sku != '' ";
  3744. $gj = "";
  3745. $ck = "";
  3746. if ($category) {
  3747. $where .= " and features like '%-$category-%'";
  3748. }
  3749. if ($size) {
  3750. $where .= " and features like '%-$size-%'";
  3751. }
  3752. if ($grade) {
  3753. $where .= " and features like '%-$grade-%'";
  3754. }
  3755. if ($color) {
  3756. $where .= " and features like '%-$color-%'";
  3757. }
  3758. if ($lowe) {
  3759. $where .= " and features like '%-$lowe-%'";
  3760. }
  3761. if ($warehouse) {
  3762. $where .= " and warehouse = '$warehouse'";
  3763. }
  3764. if ($purchase) {
  3765. $where .= " and purchase = '$purchase'";
  3766. }
  3767. if ($state) {
  3768. $where .= " and state = '$state'";
  3769. }
  3770. if ($lacetype) {
  3771. $where .= " and features like '%-$lacetype-%'";
  3772. }
  3773. if ($lacecolor) {
  3774. $where .= " and features like '%-$lacecolor-%'";
  3775. }
  3776. if ($density) {
  3777. $where .= " and features like '%-$density-%'";
  3778. }
  3779. if ($haircap) {
  3780. $where .= " and features like '%-$haircap-%'";
  3781. }
  3782. if ($details) {
  3783. $where .= " and details = '$details'";
  3784. }
  3785. if ($shop) {
  3786. $where .= " and shop like '%$shop%'";
  3787. }
  3788. if ($title) {
  3789. $title = trim($title, ' ');
  3790. $title = trim($title, ' ');
  3791. $where .= " and title like '%$title%'";
  3792. }
  3793. if (!empty($hairnumber)) {
  3794. $where .= " and features like '%-128-%' ";
  3795. if ($hairnumber < 0) {
  3796. $class_list = $this->typeclass->find_all('classid = 43');
  3797. foreach ($class_list as $v) {
  3798. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3799. }
  3800. } else {
  3801. $where .= " and features like '%-$hairnumber-%'";
  3802. }
  3803. }
  3804. if ($type_leixi) {
  3805. $where .= " and type = '$type_leixi'";
  3806. }
  3807. if ($cpbz) {
  3808. $where .= " and cpbz like '%$cpbz%' ";
  3809. }
  3810. if ($sm) {
  3811. $where .= " and sm like '%$sm%' ";
  3812. }
  3813. if ($sku) {
  3814. $sku = trim($sku, ' ');
  3815. $sku = trim($sku, ' ');
  3816. $where .= " and sku like '%$sku%'";
  3817. }
  3818. if ($ktime && $jtime) {
  3819. if ($type == 1) {
  3820. $tl = '出库';
  3821. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3822. } else if ($type == 2) {
  3823. $tl = '退库';
  3824. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3825. } else if ($type == 3) {
  3826. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3827. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3828. } else if ($type == 4) {
  3829. $tl = '出库+零售';
  3830. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3831. } else if ($type == 5) {
  3832. $tl = '零售';
  3833. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3834. }
  3835. }
  3836. $sidwhere = '';
  3837. if ($sid) {
  3838. $sd = "";
  3839. $s = explode(',', trim($sid, ','));
  3840. foreach ($s as $value) {
  3841. $sd .= " id = " . $value . " or";
  3842. }
  3843. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3844. }
  3845. //数据排序
  3846. $order_str = "time desc";
  3847. if (empty($page)) {
  3848. $start = 0;
  3849. $perpage = 1;
  3850. } else {
  3851. $start = ($page - 1) * $perpage;
  3852. }
  3853. //取得信息列表
  3854. if ($type != 3 && $type != 5) {
  3855. if ($type == 1 || $type == 4) {
  3856. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3857. foreach ($info_list as $key => $value) {
  3858. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3859. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3860. $warehouse = $this->warehouse->read($value['warehouse']);
  3861. $info_list[$key]['warehouse'] = $warehouse['title'];
  3862. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3863. $features = explode('-', trim($features, '-'));
  3864. $pm = $classid;
  3865. foreach ($features as $k => $v) {
  3866. if ($v != 0) {
  3867. if (!isset($typeclass[$v])) {
  3868. continue;
  3869. }
  3870. if (isset($pm[$typeclass[$v]['classid']])) {
  3871. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3872. $tz = explode('|', $typeclass[$v]['zh']);
  3873. $pm[$typeclass[$v]['classid']] = $tz[0];
  3874. } else {
  3875. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3876. }
  3877. }
  3878. }
  3879. }
  3880. $zh = implode(" ", $pm);
  3881. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3882. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3883. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3884. $info_list[$key]['features'] = $zh;
  3885. }
  3886. $final_list = [];
  3887. foreach($info_list as $k=>$v){
  3888. $number = "";
  3889. if(!empty($v['orderinfo'])){
  3890. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3891. if(!empty($tmp_info['number'])){
  3892. $number = $tmp_info['number'];
  3893. }
  3894. }
  3895. $final_list[] = [
  3896. 'warehouse'=>$v['warehouse'],
  3897. 'purchase'=>$v['purchase'],
  3898. 'sku'=>$v['sku'],
  3899. 'title'=>$v['title'],
  3900. 'features'=>$v['features'],
  3901. 'label'=>$v['label'],
  3902. 'orderinfo'=>$v['orderinfo'],
  3903. 'number'=>$number,
  3904. 'waybill'=>$v['waybill'],
  3905. 'outk'=>$v['outk'],
  3906. ];
  3907. }
  3908. } else {
  3909. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3910. foreach ($info_list as $key => $value) {
  3911. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3912. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3913. $warehouse = $this->warehouse->read($value['warehouse']);
  3914. $info_list[$key]['warehouse'] = $warehouse['title'];
  3915. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3916. $features = explode('-', trim($features, '-'));
  3917. $pm = $classid;
  3918. foreach ($features as $k => $v) {
  3919. if ($v != 0) {
  3920. if (!isset($typeclass[$v])) {
  3921. continue;
  3922. }
  3923. if (isset($pm[$typeclass[$v]['classid']])) {
  3924. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3925. $tz = explode('|', $typeclass[$v]['zh']);
  3926. $pm[$typeclass[$v]['classid']] = $tz[0];
  3927. } else {
  3928. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3929. }
  3930. }
  3931. }
  3932. }
  3933. $zh = implode(" ", $pm);
  3934. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3935. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3936. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3937. $info_list[$key]['features'] = $zh;
  3938. }
  3939. $final_list = [];
  3940. foreach($info_list as $k=>$v){
  3941. $number = "";
  3942. if(!empty($v['orderinfo'])){
  3943. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3944. if(!empty($tmp_info['number'])){
  3945. $number = $tmp_info['number'];
  3946. }
  3947. }
  3948. $final_list[] = [
  3949. 'warehouse'=>$v['warehouse'],
  3950. 'purchase'=>$v['purchase'],
  3951. 'sku'=>$v['sku'],
  3952. 'title'=>$v['title'],
  3953. 'features'=>$v['features'],
  3954. 'label'=>$v['label'],
  3955. 'orderinfo'=>$v['orderinfo'],
  3956. 'number'=>$number,
  3957. 'waybill'=>$v['waybill'],
  3958. 'retreat'=>$v['retreat'],
  3959. ];
  3960. }
  3961. }
  3962. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3963. $titlename = "<table border=1>
  3964. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3965. <tr align='center'>
  3966. <td>仓库</td>
  3967. <td>供应商</td>
  3968. <td>SKU</td>
  3969. <td>商品名称</td>
  3970. <td>商品中文</td>
  3971. <td>标签</td>
  3972. <td>订单号</td>
  3973. <td>订单编码</td>
  3974. <td>运单号</td>
  3975. <td>" . $tl . "时间(中国时间)</td>
  3976. </tr>
  3977. </table>";
  3978. $filename = $title . ".xls";
  3979. $tail = "";
  3980. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3981. } else if ($type == 5) {
  3982. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3983. foreach ($info_list as $key => $value) {
  3984. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3985. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3986. $warehouse = $this->warehouse->read($value['warehouse']);
  3987. $info_list[$key]['warehouse'] = $warehouse['title'];
  3988. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3989. $features = explode('-', trim($features, '-'));
  3990. $pm = $classid;
  3991. foreach ($features as $k => $v) {
  3992. if ($v != 0) {
  3993. if (!isset($typeclass[$v])) {
  3994. continue;
  3995. }
  3996. if (isset($pm[$typeclass[$v]['classid']])) {
  3997. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3998. $tz = explode('|', $typeclass[$v]['zh']);
  3999. $pm[$typeclass[$v]['classid']] = $tz[0];
  4000. } else {
  4001. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4002. }
  4003. }
  4004. }
  4005. }
  4006. $zh = implode(" ", $pm);
  4007. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4008. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4009. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4010. $info_list[$key]['features'] = $zh;
  4011. }
  4012. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4013. $titlename = "<table border=1>
  4014. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4015. <tr align='center'>
  4016. <td>仓库</td>
  4017. <td>供应商</td>
  4018. <td>SKU</td>
  4019. <td>商品名称</td>
  4020. <td>商品中文</td>
  4021. <td>标签</td>
  4022. <td>" . $tl . "时间(中国时间)</td>
  4023. </tr>
  4024. </table>";
  4025. $filename = $title . ".xls";
  4026. $tail = "";
  4027. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4028. } else {
  4029. /**
  4030. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4031. $rows = array();$list = array();
  4032. foreach ($info_list as $key=>$value)
  4033. {
  4034. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4035. }
  4036. **/
  4037. $wh = array();
  4038. $w = $this->warehouse->find_all('1=1', 'id,title');
  4039. foreach ($w as $v) {
  4040. $wh[$v['id']] = $v['title'];
  4041. }
  4042. $wt = array();
  4043. $whlabel_type = $this->whlabel_type->find_all();
  4044. foreach ($whlabel_type as $v) {
  4045. $wt[$v['id']] = $v['title'];
  4046. }
  4047. $classid = $this->classid->sku();
  4048. $list = array();
  4049. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4050. foreach ($rows as $key => $value) {
  4051. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4052. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4053. $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');
  4054. $details = array();
  4055. $cpid = array();
  4056. $cpbz = array();
  4057. $c = 0;
  4058. $g = 0;
  4059. $x = 0;
  4060. $t = 0;
  4061. $s = 0;
  4062. $q = 0;
  4063. foreach ($sd as $k => $v) {
  4064. if ($v['state'] == 0) {
  4065. $c++;
  4066. }
  4067. if ($v['state'] != 9) {
  4068. $g++;
  4069. }
  4070. if ($v['outk'] > 1) {
  4071. $x++;
  4072. }
  4073. if ($v['retreat'] > 0) {
  4074. $t++;
  4075. }
  4076. if ($v['state'] == 8) {
  4077. $s++;
  4078. }
  4079. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4080. $q++;
  4081. }
  4082. $details[$v['details']] = $v['details'];
  4083. if ($v['cpid'] != 0) {
  4084. $cpid[$v['cpid']] = $v['cpid'];
  4085. }
  4086. if ($v['cpbz'] != '') {
  4087. $cpbz[$v['cpbz']] = $v['cpbz'];
  4088. }
  4089. }
  4090. if (isset($wt[$value['type']])) {
  4091. $rows[$key]['type'] = $wt[$value['type']];
  4092. } else {
  4093. $rows[$key]['type'] = '未设置';
  4094. }
  4095. $rows[$key]['details'] = implode("、", $details);
  4096. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4097. $ftime = time() - 15 * 24 * 3600;
  4098. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4099. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4100. $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);
  4101. $rows[$key]['c'] = $c;
  4102. $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);
  4103. $rows[$key]['t'] = $t;
  4104. $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'] . '"');
  4105. $rows[$key]['z'] = $z;
  4106. // $jm = $classid;
  4107. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4108. $features = explode('-', trim($features, '-'));
  4109. // $pm = $classid;
  4110. // foreach ($features as $k => $v) {
  4111. // if ($v != 0) {
  4112. // if (!isset($typeclass[$v])) {
  4113. // continue;
  4114. // }
  4115. // if (isset($pm[$typeclass[$v]['classid']])) {
  4116. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4117. // $tz = explode('|', $typeclass[$v]['zh']);
  4118. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4119. // } else {
  4120. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4121. // }
  4122. // if (isset($jm[$typeclass[$v]['classid']])) {
  4123. // if ($typeclass[$v]['jm']) {
  4124. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4125. // }
  4126. // }
  4127. // }
  4128. // }
  4129. // }
  4130. // $zh = implode(" ", $pm);
  4131. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4132. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4133. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4134. // $rows[$key]['features'] = $zh;
  4135. // $jm = array_filter($jm); //去除空值
  4136. // $jm = implode("-", $jm);
  4137. // $rows[$key]['jm'] = $jm;
  4138. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4139. }
  4140. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4141. // echo "<pre>";
  4142. // print_r($tmp_list);
  4143. // die;
  4144. $final_list =[];
  4145. foreach($tmp_list as $k=>$v){
  4146. $final_list[] = [
  4147. "warehouse"=>$v['warehouse'],
  4148. "purchase"=>$v['purchase'],
  4149. "details"=>trim($v['details'],'、'),
  4150. "cpid"=>$v['cpid'],
  4151. "sku"=>$v['sku'],
  4152. "title"=>$v['title'],
  4153. "features"=>$v['pm'],
  4154. "cpbz"=>$v['cpbz'],
  4155. "sm"=>$v['sm'],
  4156. "type"=>$v['type'],
  4157. "g"=>$v["g"],
  4158. "c"=>$v["c"],
  4159. "x"=>$v["x"],
  4160. "t"=>$v["t"],
  4161. "z"=>$v["z"],
  4162. "jm"=>$v["jm"],
  4163. "weight"=>$v["weight"],
  4164. "asd"=>$v["asd"],
  4165. ];
  4166. }
  4167. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4168. $titlename = "<table border=1>
  4169. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4170. <tr align='center'>
  4171. <td>仓库</td>
  4172. <td>供应商</td>
  4173. <td>位置</td>
  4174. <td>库存编码</td>
  4175. <td>SKU</td>
  4176. <td>商品名称</td>
  4177. <td>商品中文</td>
  4178. <td>产品备注</td>
  4179. <td>说明</td>
  4180. <td>类型</td>
  4181. <td>入库总量</td>
  4182. <td>库存数量</td>
  4183. <td>销售数量</td>
  4184. <td>退货数量</td>
  4185. <td>占单数量</td>
  4186. <td>料号</td>
  4187. <td>重量</td>
  4188. <td>类目</td>
  4189. </tr>
  4190. </table>";
  4191. $filename = $title . ".xls";
  4192. $tail = "";
  4193. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4194. }
  4195. }
  4196. }
  4197. //出库+入库数据整合
  4198. public function _excelcr()
  4199. {
  4200. if (isset($_GET['excel'])) {
  4201. $type = $this->input->get('excel', true);
  4202. $category = $this->input->get('category', true);
  4203. $size = $this->input->get('size', true);
  4204. $grade = $this->input->get('grade', true);
  4205. $color = $this->input->get('color', true);
  4206. $lowe = $this->input->get('lowe', true);
  4207. $sku = $this->input->get('sku', true);
  4208. $warehouse = $this->input->get('warehouse', true);
  4209. $purchase = $this->input->get('purchase', true);
  4210. $state = $this->input->get('state', true);
  4211. $sid = $this->input->get('sid', true);
  4212. $ktime = $this->input->get('ktime', true);
  4213. $jtime = $this->input->get('jtime', true);
  4214. $ktime = strtotime($ktime);
  4215. $jtime = strtotime($jtime);
  4216. $where = "1=1";
  4217. $gj = "";
  4218. $ck = "";
  4219. if ($category) {
  4220. $where .= " and features like '%-$category-%'";
  4221. }
  4222. if ($size) {
  4223. $where .= " and features like '%-$size-%'";
  4224. }
  4225. if ($grade) {
  4226. $where .= " and features like '%-$grade-%'";
  4227. }
  4228. if ($color) {
  4229. $where .= " and features like '%-$color-%'";
  4230. }
  4231. if ($lowe) {
  4232. $where .= " and features like '%-$lowe-%'";
  4233. }
  4234. if ($warehouse) {
  4235. $where .= " and warehouse = '$warehouse'";
  4236. }
  4237. if ($purchase) {
  4238. $where .= " and purchase = '$purchase'";
  4239. }
  4240. if ($state) {
  4241. $where .= " and state = '$state'";
  4242. }
  4243. if ($sku) {
  4244. $where .= " and sku like '%$sku%'";
  4245. }
  4246. if ($ktime && $jtime) {
  4247. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4248. }
  4249. $sidwhere = '';
  4250. if ($sid) {
  4251. $sd = "";
  4252. $s = explode(',', trim($sid, ','));
  4253. foreach ($s as $value) {
  4254. $sd .= " id = " . $value . " or";
  4255. }
  4256. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4257. }
  4258. //取得信息列表
  4259. $timeread = $ktime;
  4260. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4261. $timelist = array();
  4262. for ($i = 0; $i < $timenum; $i++) {
  4263. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4264. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4265. }
  4266. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4267. //echo "<pre>";
  4268. //print_r($info_list);
  4269. //exit();
  4270. $rows = array();
  4271. $list = array();
  4272. foreach ($info_list as $key => $value) {
  4273. $thistime = $timelist;
  4274. if (isset($rows[strtolower($value['sku'])])) {
  4275. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4276. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4277. }
  4278. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4279. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4280. }
  4281. } else {
  4282. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4283. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4284. }
  4285. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4286. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4287. }
  4288. $rows[strtolower($value['sku'])] = $thistime;
  4289. }
  4290. }
  4291. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4292. <head>
  4293. <!--[if gte mso 9]><xml>
  4294. <x:ExcelWorkbook>
  4295. <x:ExcelWorksheets>
  4296. <x:ExcelWorksheet>
  4297. <x:Name>EXCEL</x:Name>
  4298. <x:WorksheetOptions>
  4299. <x:Print>
  4300. <x:ValidPrinterInfo />
  4301. </x:Print>
  4302. </x:WorksheetOptions>
  4303. </x:ExcelWorksheet>
  4304. </x:ExcelWorksheets>
  4305. </x:ExcelWorkbook>
  4306. </xml>
  4307. <![endif]-->
  4308. </head><body>";
  4309. $str .= "<table border=1><tr><td>SKU</td>";
  4310. foreach ($timelist as $k => $v) {
  4311. $str .= "<td>" . $k . "出库</td>";
  4312. $str .= "<td>" . $k . "入库</td>";
  4313. }
  4314. $str .= "</tr></table>";
  4315. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4316. foreach ($rows as $key => $val) {
  4317. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4318. foreach ($val as $k => $v) {
  4319. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4320. if ($val[$k]['r'] > 0) {
  4321. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4322. } else {
  4323. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4324. }
  4325. }
  4326. $str .= "</tr>";
  4327. }
  4328. $str .= "</table>";
  4329. $str .= "</body></html>";
  4330. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4331. header("Content-type: application/octet-stream");
  4332. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4333. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4334. header("Pragma: no-cache");
  4335. header("Expires: 0");
  4336. exit($str);
  4337. }
  4338. }
  4339. //数量调整模板导出
  4340. public function _presetout()
  4341. {
  4342. if (isset($_GET['excel'])) {
  4343. $where = "sku != 'Preset' and purchase != 0";
  4344. //数据排序
  4345. $order_str = "id desc";
  4346. if (empty($page)) {
  4347. $start = 0;
  4348. $perpage = 1;
  4349. } else {
  4350. $start = ($page - 1) * $perpage;
  4351. }
  4352. //取得信息列表
  4353. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4354. $rows = array();
  4355. $list = array();
  4356. foreach ($info_list as $value) {
  4357. $warehouse = $this->warehouse->read($value['warehouse']);
  4358. $number = $value['number'];
  4359. $ftime = time() - 15 * 24 * 3600;
  4360. $purchase = $this->purchase->read($value['purchase']);
  4361. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4362. }
  4363. $title = "库存模板";
  4364. $titlename = "<table border=1>
  4365. <tr align='center'>
  4366. <td>仓库</td>
  4367. <td>供应商编码</td>
  4368. <td>SKU</td>
  4369. <td>增减数量(正数或负数)</td>
  4370. <td>增减备注</td>
  4371. <td>扣减方式:0减少库存1删除库存</td>
  4372. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4373. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4374. </tr>
  4375. </table>";
  4376. $filename = $title . ".xls";
  4377. $tail = "";
  4378. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4379. }
  4380. }
  4381. //数量调整模板导入
  4382. public function _presetedit()
  4383. {
  4384. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4385. $config['upload_path'] = '.' . $dir;
  4386. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4387. $config['allowed_types'] = 'xls|xlsx|csv';
  4388. $config['max_size'] = 10240;
  4389. $this->load->library('upload', $config);
  4390. $this->upload->initialize($config);
  4391. if ($this->upload->do_upload('userfile')) {
  4392. $full_path = $dir . $this->upload->data('file_name');
  4393. $fileName = '.' . $full_path;
  4394. if (!file_exists($fileName)) {
  4395. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4396. exit;
  4397. } else {
  4398. require_once "./data/excel/PHPExcel/IOFactory.php";
  4399. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4400. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4401. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4402. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4403. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4404. ++$column; //如果列数大于26行
  4405. $list = array();
  4406. for ($i = 2; $i <= $row; $i++) // 行数循环
  4407. {
  4408. $data = array();
  4409. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4410. {
  4411. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4412. }
  4413. $list[] = $data;
  4414. }
  4415. }
  4416. $i = 0;
  4417. $j = 0;
  4418. $ed = array();
  4419. foreach ($list as $key => $value) {
  4420. $time = time();
  4421. if ($value['0'] == "") {
  4422. continue;
  4423. }
  4424. $warehouse = $this->warehouse->get_title($value['0']);
  4425. $purchase = $this->purchase->get_bm($value['1']);
  4426. $sku = $value['2'];
  4427. $num = $value['3']; //调整数量
  4428. $text = $value['4']; //扣减说明
  4429. $type = $value['5']; //调整方式0扣减1删除
  4430. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4431. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4432. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4433. if (!$purchase) //如果没有这个SKU
  4434. {
  4435. $ed[] = array($purchase . '-不存在此供应商编码');
  4436. $j++;
  4437. continue;
  4438. }
  4439. if (!$d) //如果没有这个SKU
  4440. {
  4441. $ed[] = array($sku . '-库存中不存在此SKU');
  4442. $j++;
  4443. continue;
  4444. }
  4445. if (!isset($warehouse['id'])) {
  4446. $ed[] = array($sku . '-仓库名错误!');
  4447. $j++;
  4448. continue;
  4449. }
  4450. if ($type != '0' && $type != '1') {
  4451. $ed[] = array($sku . '-扣减方式填写错误!');
  4452. $j++;
  4453. continue;
  4454. }
  4455. if ($num < 0) //扣减库存
  4456. {
  4457. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4458. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4459. $j++;
  4460. continue;
  4461. }
  4462. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4463. if (count($data) < abs($num)) {
  4464. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4465. $j++;
  4466. continue;
  4467. }
  4468. if ($type == 0) //如果扣减方式为 扣减库存
  4469. {
  4470. for ($i = 0; $i < abs($num); $i++) {
  4471. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4472. }
  4473. } else if ($type == 1) {
  4474. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4475. if (count($zt) > 0) {
  4476. $ed[] = array($sku . '-有在途库存无法删除!');
  4477. $j++;
  4478. continue;
  4479. }
  4480. for ($i = 0; $i < abs($num); $i++) {
  4481. $this->whlabel->remove($data[$i]['id']);
  4482. }
  4483. }
  4484. } else if ($num > 0) //增加库存
  4485. {
  4486. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4487. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4488. $j++;
  4489. continue;
  4490. }
  4491. $post['sku'] = $d['sku'];
  4492. $post['shop'] = $d['shop'];
  4493. $post['warehouse'] = $warehouse['id'];
  4494. $post['purchase'] = $purchase['id'];
  4495. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4496. $post['state'] = 0;
  4497. $post['title'] = $d['title'];
  4498. $post['number'] = $d['number'];
  4499. $post['features'] = $d['features'];
  4500. $post['enter'] = $time;
  4501. $post['time'] = $time; //操作时间
  4502. $post['rktype'] = $rktype;
  4503. for ($i = 0; $i < $num; $i++) {
  4504. $post['label'] = time() . rand(100, 999) . $i;
  4505. $this->whlabel->insert($post);
  4506. }
  4507. }
  4508. sleep(1); //防止入库时间一样,需要延迟1秒
  4509. }
  4510. if ($j > 0) {
  4511. $tt = date('Ymd', time());
  4512. $title = '库存导入错误信息-' . $tt;
  4513. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4514. $tail = "\n";
  4515. $filename = $title . ".xls";
  4516. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4517. $dir = '/data/excel/' . $time . '/';
  4518. $file_name = 'error_' . $time . rand(1000, 9999);
  4519. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4520. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4521. fwrite($myfile, $ecl);
  4522. fclose($myfile);
  4523. $error = $dir . $file_name . '.xls';
  4524. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4525. exit;
  4526. } else {
  4527. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4528. exit;
  4529. }
  4530. }
  4531. }
  4532. public function _presetedittwo(){
  4533. $data = $this->input->post(NULL, TRUE);
  4534. if(empty($list)){
  4535. $raw_data = $this->input->raw_input_stream;
  4536. // 解码 JSON
  4537. $data = json_decode($raw_data, true);
  4538. }
  4539. if(empty($data)){
  4540. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4541. }
  4542. $list = [];
  4543. if(isset($data['list'])){
  4544. $list = $data['list'];
  4545. }
  4546. $i = 0;
  4547. $j = 0;
  4548. $ed = array();
  4549. foreach ($list as $key => $value) {
  4550. $time = time();
  4551. if ($value['0'] == "") {
  4552. continue;
  4553. }
  4554. $warehouse = $this->warehouse->get_title($value['0']);
  4555. $purchase = $this->purchase->get_bm($value['1']);
  4556. $sku = $value['2'];
  4557. $num = $value['3']; //调整数量
  4558. $text = $value['4']; //扣减说明
  4559. $type = $value['5']; //调整方式0扣减1删除
  4560. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4561. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4562. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4563. if (!$purchase) //如果没有这个SKU
  4564. {
  4565. $ed[] = array($value['1'] . '-不存在此供应商编码');
  4566. $j++;
  4567. continue;
  4568. }
  4569. if (!$d) //如果没有这个SKU
  4570. {
  4571. $ed[] = array($sku . '-库存中不存在此SKU');
  4572. $j++;
  4573. continue;
  4574. }
  4575. if (!isset($warehouse['id'])) {
  4576. $ed[] = array($sku . '-仓库名错误!');
  4577. $j++;
  4578. continue;
  4579. }
  4580. if ($type != '0' && $type != '1') {
  4581. $ed[] = array($sku . '-扣减方式填写错误!');
  4582. $j++;
  4583. continue;
  4584. }
  4585. if ($num < 0) //扣减库存
  4586. {
  4587. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4588. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4589. $j++;
  4590. continue;
  4591. }
  4592. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4593. if (count($data) < abs($num)) {
  4594. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4595. $j++;
  4596. continue;
  4597. }
  4598. if ($type == 0) //如果扣减方式为 扣减库存
  4599. {
  4600. for ($i = 0; $i < abs($num); $i++) {
  4601. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4602. }
  4603. } else if ($type == 1) {
  4604. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4605. if (count($zt) > 0) {
  4606. $ed[] = array($sku . '-有在途库存无法删除!');
  4607. $j++;
  4608. continue;
  4609. }
  4610. for ($i = 0; $i < abs($num); $i++) {
  4611. $this->whlabel->remove($data[$i]['id']);
  4612. }
  4613. }
  4614. } else if ($num > 0) //增加库存
  4615. {
  4616. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4617. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4618. $j++;
  4619. continue;
  4620. }
  4621. $post['sku'] = $d['sku'];
  4622. $post['shop'] = $d['shop'];
  4623. $post['warehouse'] = $warehouse['id'];
  4624. $post['purchase'] = $purchase['id'];
  4625. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4626. $post['state'] = 0;
  4627. $post['title'] = $d['title'];
  4628. $post['number'] = $d['number'];
  4629. $post['features'] = $d['features'];
  4630. $post['enter'] = $time;
  4631. $post['time'] = $time; //操作时间
  4632. $post['rktype'] = $rktype;
  4633. $post['sku_master_id'] = $d['sku_master_id'];
  4634. $post['sku_shop_id'] = $d['sku_shop_id'];
  4635. for ($i = 0; $i < $num; $i++) {
  4636. $post['label'] = time() . rand(100, 999) . $i;
  4637. $this->whlabel->insert($post);
  4638. }
  4639. }
  4640. sleep(1); //防止入库时间一样,需要延迟1秒
  4641. }
  4642. if ($j > 0) {
  4643. $tt = date('Ymd', time());
  4644. $title = '库存导入错误信息-' . $tt;
  4645. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4646. $tail = "\n";
  4647. $filename = $title . ".xls";
  4648. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4649. $dir = '/data/excel/' . $time . '/';
  4650. $file_name = 'error_' . $time . rand(1000, 9999);
  4651. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4652. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4653. fwrite($myfile, $ecl);
  4654. fclose($myfile);
  4655. $error = $dir . $file_name . '.xls';
  4656. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4657. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4658. exit;
  4659. } else {
  4660. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4661. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4662. exit;
  4663. }
  4664. }
  4665. //笛卡儿积
  4666. function cp($ps, $sets, $list)
  4667. {
  4668. $result = array();
  4669. $j = 0;
  4670. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4671. if ($i == 0) {
  4672. $result = $sets[$i];
  4673. }
  4674. $tmp = array();
  4675. foreach ($result as $res) {
  4676. foreach ($sets[$i + 1] as $set) {
  4677. $tmp[] = $res . ',' . $set;
  4678. }
  4679. }
  4680. $result = $tmp;
  4681. }
  4682. $this->db->trans_begin();
  4683. foreach ($result as $v) {
  4684. $post = array();
  4685. $title = "";
  4686. $num = "";
  4687. $data = explode(',', $v);
  4688. for ($i = 0; $i < count($list); $i++) {
  4689. $post[$list[$i]] = $data[$i];
  4690. $typeclass = $this->typeclass->read($data[$i]);
  4691. $title = $title . $typeclass['title'] . " ";
  4692. if ($data[$i] != 0) {
  4693. $num .= $data[$i]; //所有数据ID拼接
  4694. }
  4695. }
  4696. foreach ($ps as $kp => $vp) {
  4697. $post[$kp] = $vp;
  4698. }
  4699. $post['number'] = $num;
  4700. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4701. if ($info_list) {
  4702. $j++;
  4703. } else {
  4704. $skunum = $this->whlabel->find_count();
  4705. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4706. $post['title'] = rtrim($title, ' ');
  4707. $this->whlabel->insert($post);
  4708. }
  4709. }
  4710. if ($this->db->trans_status() === FALSE) {
  4711. $this->db->trans_commit();
  4712. return NULL;
  4713. } else {
  4714. $this->db->trans_commit();
  4715. return $j;
  4716. }
  4717. }
  4718. public function _kj($arg_array)
  4719. {
  4720. if (isset($_POST['sku'])) {
  4721. $time = time();
  4722. $sku = $this->input->post('sku', true);
  4723. $warehouse = $this->input->post('warehouse', true);
  4724. $num = $this->input->post('num', true);
  4725. $text = $this->input->post('text', true);
  4726. $purchase = $this->input->post('purchase', true);
  4727. $cktype = $this->input->post('cktype', true);
  4728. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4729. if ($cktype != 1 && $text == '') {
  4730. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4731. exit;
  4732. }
  4733. if ($num > count($order)) {
  4734. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4735. exit;
  4736. } else {
  4737. for ($i = 0; $i < $num; $i++) {
  4738. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4739. }
  4740. }
  4741. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4742. exit;
  4743. }
  4744. $uid = $this->whlabel->read($arg_array[0]);
  4745. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4746. $this->data['data'] = $uid;
  4747. $this->_Template('whlabel_kj', $this->data);
  4748. }
  4749. public function _summary($arg_array)
  4750. {
  4751. $prc = array();
  4752. $purchase = $this->purchase->find_all();
  4753. foreach ($purchase as $k => $v) {
  4754. $prc[$v['id']] = $v['title'];
  4755. }
  4756. if (isset($_GET['excel'])) {
  4757. $ktime = $this->input->get('ktime', true);
  4758. $jtime = $this->input->get('jtime', true);
  4759. $ktime = strtotime($ktime);
  4760. $jtime = strtotime($jtime);
  4761. $where = "1=1";
  4762. if ($ktime && $jtime) {
  4763. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4764. }
  4765. //数据排序
  4766. $order_str = "time desc";
  4767. if (empty($page)) {
  4768. $start = 0;
  4769. $perpage = 1;
  4770. } else {
  4771. $start = ($page - 1) * $perpage;
  4772. }
  4773. //取得信息列表
  4774. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4775. foreach ($info_list as $key => $value) {
  4776. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4777. $warehouse = $this->warehouse->read($value['warehouse']);
  4778. $info_list[$key]['warehouse'] = $warehouse['title'];
  4779. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4780. $details = array();
  4781. $cpid = array();
  4782. foreach ($x as $k => $v) {
  4783. if ($v['details'] != '') {
  4784. $details[$v['details']] = $v['details'];
  4785. }
  4786. if ($v['cpid'] != 0) {
  4787. $cpid[$v['cpid']] = $v['cpid'];
  4788. }
  4789. }
  4790. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4791. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4792. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4793. $info_list[$key]['s'] = $s;
  4794. $info_list[$key]['x'] = count($x);
  4795. }
  4796. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4797. $titlename = "<table border=1>
  4798. <tr align='center'>
  4799. <td>仓库</td>
  4800. <td>供应商</td>
  4801. <td>出库位置</td>
  4802. <td>出库编码</td>
  4803. <td>SKU</td>
  4804. <td>产品名</td>
  4805. <td>总剩余库存</td>
  4806. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4807. </tr>
  4808. </table>";
  4809. $filename = $title . ".xls";
  4810. $tail = "";
  4811. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4812. }
  4813. }
  4814. //usps发货清单
  4815. public function _manifest()
  4816. {
  4817. if (isset($_POST['manifest'])) {
  4818. $wltext = $this->input->post('wltext', true);
  4819. $time = time() - 16 * 3600;
  4820. $ptime = strtotime(date('Y-m-d', $time));
  4821. $waybill = array();
  4822. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4823. foreach ($fullorder as $v) {
  4824. $waybill[$v['waybill']] = $v['waybill'];
  4825. }
  4826. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4827. foreach ($fullordersmt as $v) {
  4828. $waybill[$v['waybill']] = $v['waybill'];
  4829. }
  4830. $wltext = explode(';', $wltext);
  4831. foreach ($wltext as $v) {
  4832. if (isset($waybill[$v])) {
  4833. unset($waybill[$v]);
  4834. }
  4835. }
  4836. $data = $this->usps->get_manifest($waybill);
  4837. if (isset($data['Description'])) {
  4838. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4839. exit;
  4840. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4841. $bctime = date('Ymd', time());
  4842. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4843. echo json_encode(array('msg' => $pdf, 'success' => true));
  4844. exit;
  4845. } else {
  4846. echo json_encode(array('msg' => $data, 'success' => false));
  4847. exit;
  4848. }
  4849. }
  4850. }
  4851. public function _pdf($pdf, $title, $bctime)
  4852. {
  4853. $pdf_path = './data/pdf/' . $bctime . '/';
  4854. $file_base64 = $pdf;
  4855. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4856. $file_base64 = base64_decode($file_base64);
  4857. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4858. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4859. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4860. }
  4861. /**
  4862. *
  4863. *
  4864. *
  4865. 进销存占单异常索引
  4866. *
  4867. *
  4868. *
  4869. **/
  4870. public function _abnormal()
  4871. {
  4872. $post = $this->input->post(NULL, TRUE);
  4873. if (isset($post['page'])) {
  4874. $page = $this->input->post('page', true);
  4875. $perpage = $this->input->post('perpage', true);
  4876. $sku = $this->input->post('sku', true);
  4877. $where = "1=1";
  4878. //数据排序
  4879. $order_str = "id desc";
  4880. if (empty($page)) {
  4881. $start = 0;
  4882. $perpage = 1;
  4883. } else {
  4884. $start = ($page - 1) * $perpage;
  4885. }
  4886. //取得信息列表
  4887. $info_list = $this->whlabel->find_all($where, '*');
  4888. $rows = array();
  4889. $list = array();
  4890. foreach ($info_list as $key => $value) {
  4891. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4892. }
  4893. foreach ($rows as $value) {
  4894. $warehouse = $this->warehouse->read($value['warehouse']);
  4895. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4896. $number = $value['number'];
  4897. $ftime = time() - 15 * 24 * 3600;
  4898. if ($value['shop'] != '') {
  4899. $shop = $value['shop'];
  4900. $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');
  4901. $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');
  4902. $order = array_merge($orderdlz, $ordersmt);
  4903. $od = 0;
  4904. $a = '';
  4905. $orid = '';
  4906. foreach ($order as $v) {
  4907. $or = explode('|', ltrim($v['whlabel'], '|'));
  4908. for ($i = 0; $i < count($or); $i++) {
  4909. $orod = explode('-', $or[$i]);
  4910. if ($orod[0] == $number) {
  4911. $od += $orod[1];
  4912. }
  4913. }
  4914. $orid .= $v['number'] . '-';
  4915. }
  4916. } else {
  4917. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4918. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4919. $order = array_merge($orderdlz, $ordersmt);
  4920. $od = 0;
  4921. $a = '';
  4922. $orid = '';
  4923. $qt = array();
  4924. foreach ($order as $v) {
  4925. $or = explode('|', ltrim($v['whlabel'], '|'));
  4926. for ($i = 0; $i < count($or); $i++) {
  4927. $orod = explode('-', $or[$i]);
  4928. if ($orod[0] == $number) {
  4929. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4930. if ($czzs > 0) {
  4931. if (isset($qt[$v['shop']])) {
  4932. if ($qt[$v['shop']] < $orod[1]) {
  4933. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4934. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4935. } else {
  4936. $qt[$v['shop']] -= $orod[1];
  4937. }
  4938. } else {
  4939. $qt[$v['shop']] = $czzs;
  4940. }
  4941. } else {
  4942. $od += $orod[1];
  4943. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4944. }
  4945. }
  4946. }
  4947. }
  4948. }
  4949. $z = $od . '(' . $orid . ')'; //查看订单号
  4950. //$z = $od;
  4951. if ($od > $c) {
  4952. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4953. }
  4954. }
  4955. $listdata = array_slice($list, $start, $perpage);
  4956. $total = count($list);
  4957. $pagenum = ceil($total / $perpage);
  4958. $over = $total - ($start + $perpage);
  4959. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4960. echo json_encode($rows);
  4961. exit;
  4962. }
  4963. $this->_Template('whlabel_abnormal', $this->data);
  4964. }
  4965. /**
  4966. *
  4967. *
  4968. *
  4969. 进销存占单异常索引
  4970. *
  4971. *
  4972. *
  4973. **/
  4974. public function _error()
  4975. {
  4976. $post = $this->input->post(NULL, TRUE);
  4977. if (isset($post['page'])) {
  4978. $page = $this->input->post('page', true);
  4979. $perpage = $this->input->post('perpage', true);
  4980. $sku = $this->input->post('sku', true);
  4981. $warehouse = $this->input->post('warehouse', true);
  4982. $ktime = $this->input->post('ktime', true);
  4983. $jtime = $this->input->post('jtime', true);
  4984. $ktime = strtotime($ktime);
  4985. $jtime = strtotime($jtime);
  4986. $where = "sku != 'Preset'";
  4987. $gj = '';
  4988. if ($sku) {
  4989. $where .= " and sku like '%$sku%'";
  4990. } else {
  4991. if ($ktime && $jtime) {
  4992. $gj = " and time > '$ktime' and time < '$jtime'";
  4993. }
  4994. }
  4995. if ($warehouse) {
  4996. $where .= " and warehouse = '$warehouse'";
  4997. }
  4998. //数据排序
  4999. $order_str = "id desc";
  5000. if (empty($page)) {
  5001. $start = 0;
  5002. $perpage = 1;
  5003. } else {
  5004. $start = ($page - 1) * $perpage;
  5005. }
  5006. //取得信息列表
  5007. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5008. $rows = array();
  5009. $list = array();
  5010. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5011. // foreach ($info_list as $value)
  5012. // {
  5013. // $warehouse = $this->warehouse->read($value['warehouse']);
  5014. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5015. // $number = $value['number'];$ftime = time()-15*24*3600;
  5016. // if($c < 1)
  5017. // {
  5018. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5019. // }
  5020. // }
  5021. $warehouse_list = $this->warehouse->find_all();
  5022. $warehouse_list = array_column($warehouse_list, null, 'id');
  5023. foreach ($info_list as $value) {
  5024. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5025. 'title' => "",
  5026. ];
  5027. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5028. $number = $value['number'];
  5029. $ftime = time() - 15 * 24 * 3600;
  5030. if ($c < 1) {
  5031. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5032. }
  5033. }
  5034. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5035. // $query = $this->db->query($sql);
  5036. // $info_list = $query->result_array();
  5037. // $sql_two = "select title,id from crowd_warehouse";
  5038. // $query_two = $this->db->query($sql_two);
  5039. // $warehouse_list = $query_two->result_array();
  5040. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5041. // foreach ($info_list as $value)
  5042. // {
  5043. // if(isset($warehouse_arr[$value['warehouse']])){
  5044. // $warehouse = $warehouse_arr[$value['warehouse']];
  5045. // }else{
  5046. // $warehouse = [
  5047. // 'id'=>0,
  5048. // 'title'=>"异常",
  5049. // ];
  5050. // }
  5051. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5052. // $number = $value['number'];$ftime = time()-15*24*3600;
  5053. // if($c < 1)
  5054. // {
  5055. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5056. // }
  5057. // }
  5058. $listdata = array_slice($list, $start, $perpage);
  5059. $total = count($list);
  5060. $pagenum = ceil($total / $perpage);
  5061. $over = $total - ($start + $perpage);
  5062. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5063. echo json_encode($rows);
  5064. exit;
  5065. }
  5066. if (isset($post['s'])) {
  5067. $id_arr = $this->input->post('s');
  5068. $id_arr = explode(',', trim($id_arr, ','));
  5069. if (!$id_arr) {
  5070. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5071. exit;
  5072. }
  5073. //循环删除记录
  5074. foreach ($id_arr as $v) {
  5075. $dd = $this->whlabel->read($v);
  5076. if (!isset($dd['id'])) {
  5077. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5078. exit;
  5079. }
  5080. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5081. if (isset($zt[0])) {
  5082. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5083. exit;
  5084. }
  5085. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5086. foreach ($deldd as $vv) {
  5087. $this->whlabel->remove($vv['id']);
  5088. }
  5089. }
  5090. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5091. exit;
  5092. }
  5093. $this->_Template('whlabel_error', $this->data);
  5094. }
  5095. public function _errorexcel()
  5096. {
  5097. $post = $this->input->post(NULL, TRUE);
  5098. if (isset($_GET['page'])) {
  5099. $page = $this->input->get('page', true);
  5100. $perpage = $this->input->get('perpage', true);
  5101. $sku = $this->input->get('sku', true);
  5102. $warehouse = $this->input->get('warehouse', true);
  5103. $ktime = $this->input->get('ktime', true);
  5104. $jtime = $this->input->get('jtime', true);
  5105. $ktime = strtotime($ktime);
  5106. $jtime = strtotime($jtime);
  5107. $where = "sku != 'Preset'";
  5108. $gj = '';
  5109. if ($sku) {
  5110. $where .= " and sku like '%$sku%'";
  5111. } else {
  5112. if ($ktime && $jtime) {
  5113. $gj = " and time > '$ktime' and time < '$jtime'";
  5114. }
  5115. }
  5116. if ($warehouse) {
  5117. $where .= " and warehouse = '$warehouse'";
  5118. }
  5119. //数据排序
  5120. $order_str = "id desc";
  5121. if (empty($page)) {
  5122. $start = 0;
  5123. $perpage = 1;
  5124. } else {
  5125. $start = ($page - 1) * $perpage;
  5126. }
  5127. //取得信息列表
  5128. $rows = array();
  5129. $list = array();
  5130. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5131. foreach ($info_list as $value) {
  5132. $warehouse = $this->warehouse->read($value['warehouse']);
  5133. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5134. $number = $value['number'];
  5135. $ftime = time() - 15 * 24 * 3600;
  5136. if ($c < 1) {
  5137. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5138. }
  5139. }
  5140. $title = "0库存汇总";
  5141. $titlename = "<table border=1>
  5142. <tr align='center'>
  5143. <td>仓库</td>
  5144. <td>SKU</td>
  5145. <td>产品</td>
  5146. <td>当前库存</td>
  5147. </tr>
  5148. </table>";
  5149. $filename = $title . ".xls";
  5150. $tail = "";
  5151. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5152. }
  5153. }
  5154. /**
  5155. *
  5156. *
  5157. * 占单
  5158. *
  5159. *
  5160. **/
  5161. public function _kcyz()
  5162. {
  5163. $post = $this->input->post(NULL, TRUE);
  5164. if (isset($post['warehouse'])) {
  5165. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5166. exit; //不再使用
  5167. $warehouse = $this->input->post('warehouse', true);
  5168. $whlabel = $this->input->post('whlabel', true);
  5169. $id = $this->input->post('id', true);
  5170. $shop = $this->input->post('shop', true);
  5171. $number = $this->input->post('number', true);
  5172. if (!$whlabel || $whlabel == '|') {
  5173. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5174. exit;
  5175. }
  5176. $pp = explode('|', trim($whlabel, '|'));
  5177. $x = 0;
  5178. $save = array();
  5179. foreach ($pp as $va) {
  5180. $num = explode('-', $va);
  5181. if ($number) {
  5182. $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 = '')"); //通用
  5183. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5184. } else {
  5185. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5186. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5187. }
  5188. $x++;
  5189. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5190. $save[] = $x - 1;
  5191. continue; //提前先加X不然出错,所以要减1
  5192. }
  5193. }
  5194. if (isset($save[0])) {
  5195. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5196. exit;
  5197. } else {
  5198. echo json_encode(array('success' => true));
  5199. exit;
  5200. }
  5201. }
  5202. }
  5203. public function _db()
  5204. {
  5205. $post = $this->input->post(NULL, TRUE);
  5206. if (isset($post['page'])) {
  5207. $page = $this->input->post('page', true);
  5208. $perpage = $this->input->post('perpage', true);
  5209. $sku = $this->input->post('sku', true);
  5210. $number = $this->input->post('number', true);
  5211. $warehouse = $this->input->post('warehouse', true);
  5212. $purchase = $this->input->post('purchase', true);
  5213. $orderinfo = $this->input->post('orderinfo', true);
  5214. $waybill = $this->input->post('waybill', true);
  5215. $category = $this->input->post('category', true);
  5216. $size = $this->input->post('size', true);
  5217. $grade = $this->input->post('grade', true);
  5218. $color = $this->input->post('color', true);
  5219. $lowe = $this->input->post('lowe', true);
  5220. $state = $this->input->post('state', true);
  5221. $label = $this->input->post('label', true);
  5222. $timetk = $this->input->post('timetkk', true);
  5223. $timetj = $this->input->post('timetjj', true);
  5224. $timetk = strtotime($timetk);
  5225. $timetj = strtotime($timetj);
  5226. $where = "dbtime > 0";
  5227. if ($timetk && $timetj) {
  5228. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5229. }
  5230. if ($sku) {
  5231. $where .= " and sku = '$sku'";
  5232. }
  5233. if ($warehouse) {
  5234. $where .= " and warehouse = '$warehouse'";
  5235. if ($warehouse == 12) {
  5236. $w = 'specialstock';
  5237. } else {
  5238. $w = 'whlabel';
  5239. }
  5240. }
  5241. if ($purchase) {
  5242. $where .= " and purchase = '$purchase'";
  5243. }
  5244. if ($category) {
  5245. $where .= " and features like '%-$category-%'";
  5246. }
  5247. if ($size) {
  5248. $where .= " and features like '%-$size-%'";
  5249. }
  5250. if ($grade) {
  5251. $where .= " and features like '%-$grade-%'";
  5252. }
  5253. if ($color) {
  5254. $where .= " and features like '%-$color-%'";
  5255. }
  5256. if ($lowe) {
  5257. $where .= " and features like '%-$lowe-%'";
  5258. }
  5259. if ($state != '') {
  5260. $where .= " and state = '$state'";
  5261. }
  5262. //数据排序
  5263. $order_str = "dbtime desc";
  5264. if (empty($page)) {
  5265. $start = 0;
  5266. $perpage = 1;
  5267. } else {
  5268. $start = ($page - 1) * $perpage;
  5269. }
  5270. //取得信息列表
  5271. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5272. foreach ($info_list as $key => $value) {
  5273. $warehouse = $this->$w->read($value['warehouse']);
  5274. $info_list[$key]['warehouse'] = $warehouse['title'];
  5275. $purchase = $this->purchase->read($value['purchase']);
  5276. $info_list[$key]['purchase'] = $purchase['title'];
  5277. if ($value['enter'] != 0) {
  5278. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5279. } else {
  5280. $info_list[$key]['enter'] = "";
  5281. }
  5282. if ($value['dbtime'] != 0) {
  5283. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5284. } else {
  5285. $info_list[$key]['dbtime'] = "";
  5286. }
  5287. if ($value['state'] == 0) {
  5288. $info_list[$key]['state'] = "在库";
  5289. } else if ($value['state'] == 1) {
  5290. $info_list[$key]['state'] = "出库";
  5291. } else if ($value['state'] == 2) {
  5292. $info_list[$key]['state'] = "退库";
  5293. } else if ($value['state'] == 3) {
  5294. $info_list[$key]['state'] = "调拨中";
  5295. } else if ($value['state'] == 4) {
  5296. $info_list[$key]['state'] = "再加工";
  5297. } else if ($value['state'] == 5) {
  5298. $info_list[$key]['state'] = "维修中";
  5299. } else if ($value['state'] == 6) {
  5300. $info_list[$key]['state'] = "盘亏";
  5301. } else if ($value['state'] == 7) {
  5302. $info_list[$key]['state'] = "更换标签";
  5303. } else if ($value['state'] == 8) {
  5304. $info_list[$key]['state'] = "其它";
  5305. } else if ($value['state'] == 9) {
  5306. $info_list[$key]['state'] = "预设";
  5307. }
  5308. }
  5309. $total = $this->whlabel->find_count($where);
  5310. $pagenum = ceil($total / $perpage);
  5311. $over = $total - ($start + $perpage);
  5312. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5313. echo json_encode($rows);
  5314. exit;
  5315. }
  5316. if (isset($post['outsku'])) {
  5317. $time = time();
  5318. $cz = $this->input->post('cz', true);
  5319. $label = $this->input->post('outsku', true);
  5320. $sl = $this->input->post('sl', true);
  5321. $num = $this->input->post('num', true);
  5322. //$warehouse = $this->input->post('warehouse',true);
  5323. if (!$sl) {
  5324. $sl = 1;
  5325. }
  5326. if (!$warehouse) {
  5327. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5328. exit;
  5329. }
  5330. $dblabel = $this->whlabellabel->get_label($label);
  5331. if ($dblabel) {
  5332. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5333. if (count($data) < 1) {
  5334. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5335. exit;
  5336. }
  5337. if (count($data) < $num) {
  5338. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5339. exit;
  5340. }
  5341. for ($i = 0; $i < $sl; $i++) {
  5342. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5343. }
  5344. echo json_encode(array('success' => true));
  5345. exit;
  5346. } else {
  5347. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5348. exit;
  5349. }
  5350. }
  5351. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5352. $this->_Template('whlabel_db', $this->data);
  5353. }
  5354. public function _dbrk()
  5355. {
  5356. $post = $this->input->post(NULL, TRUE);
  5357. if (isset($post['page'])) {
  5358. $page = $this->input->post('page', true);
  5359. $perpage = $this->input->post('perpage', true);
  5360. $sku = $this->input->post('sku', true);
  5361. $number = $this->input->post('number', true);
  5362. $warehouse = $this->input->post('warehouse', true);
  5363. $purchase = $this->input->post('purchase', true);
  5364. $orderinfo = $this->input->post('orderinfo', true);
  5365. $waybill = $this->input->post('waybill', true);
  5366. $category = $this->input->post('category', true);
  5367. $size = $this->input->post('size', true);
  5368. $grade = $this->input->post('grade', true);
  5369. $color = $this->input->post('color', true);
  5370. $lowe = $this->input->post('lowe', true);
  5371. $state = $this->input->post('state', true);
  5372. $label = $this->input->post('label', true);
  5373. $ctime = $this->input->post('ctime', true);
  5374. $timetk = $this->input->post('timetkk', true);
  5375. $timetj = $this->input->post('timetjj', true);
  5376. $timetk = strtotime($timetk);
  5377. $timetj = strtotime($timetj);
  5378. $where = "dbtime > 0";
  5379. if ($timetk && $timetj) {
  5380. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5381. }
  5382. if ($sku) {
  5383. $where .= " and sku = '$sku'";
  5384. }
  5385. if ($warehouse) {
  5386. $where .= " and warehouse = '$warehouse'";
  5387. }
  5388. if ($purchase) {
  5389. $where .= " and purchase = '$purchase'";
  5390. }
  5391. if ($category) {
  5392. $where .= " and features like '%-$category-%'";
  5393. }
  5394. if ($size) {
  5395. $where .= " and features like '%-$size-%'";
  5396. }
  5397. if ($grade) {
  5398. $where .= " and features like '%-$grade-%'";
  5399. }
  5400. if ($color) {
  5401. $where .= " and features like '%-$color-%'";
  5402. }
  5403. if ($lowe) {
  5404. $where .= " and features like '%-$lowe-%'";
  5405. }
  5406. if ($state != '') {
  5407. $where .= " and state = '$state'";
  5408. }
  5409. //数据排序
  5410. $order_str = "dbtime desc";
  5411. if (empty($page)) {
  5412. $start = 0;
  5413. $perpage = 1;
  5414. } else {
  5415. $start = ($page - 1) * $perpage;
  5416. }
  5417. //取得信息列表
  5418. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5419. foreach ($info_list as $key => $value) {
  5420. $warehouse = $this->warehouse->read($value['warehouse']);
  5421. $info_list[$key]['warehouse'] = $warehouse['title'];
  5422. $purchase = $this->purchase->read($value['purchase']);
  5423. $info_list[$key]['purchase'] = $purchase['title'];
  5424. if ($value['enter'] != 0) {
  5425. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5426. } else {
  5427. $info_list[$key]['enter'] = "";
  5428. }
  5429. if ($value['dbtime'] != 0) {
  5430. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5431. } else {
  5432. $info_list[$key]['dbtime'] = "";
  5433. }
  5434. if ($value['state'] == 0) {
  5435. $info_list[$key]['state'] = "在库";
  5436. } else if ($value['state'] == 1) {
  5437. $info_list[$key]['state'] = "出库";
  5438. } else if ($value['state'] == 2) {
  5439. $info_list[$key]['state'] = "退库";
  5440. } else if ($value['state'] == 3) {
  5441. $info_list[$key]['state'] = "调拨中";
  5442. } else if ($value['state'] == 4) {
  5443. $info_list[$key]['state'] = "再加工";
  5444. } else if ($value['state'] == 5) {
  5445. $info_list[$key]['state'] = "维修中";
  5446. } else if ($value['state'] == 6) {
  5447. $info_list[$key]['state'] = "盘亏";
  5448. } else if ($value['state'] == 7) {
  5449. $info_list[$key]['state'] = "更换标签";
  5450. } else if ($value['state'] == 8) {
  5451. $info_list[$key]['state'] = "其它";
  5452. } else if ($value['state'] == 9) {
  5453. $info_list[$key]['state'] = "预设";
  5454. }
  5455. }
  5456. $total = $this->whlabel->find_count($where);
  5457. $pagenum = ceil($total / $perpage);
  5458. $over = $total - ($start + $perpage);
  5459. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5460. echo json_encode($rows);
  5461. exit;
  5462. }
  5463. if (isset($post['rsku'])) {
  5464. $cz = $this->input->post('cz', true);
  5465. $label = $this->input->post('rsku', true);
  5466. $sl = $this->input->post('sl', true);
  5467. $warehouse = $this->input->post('warehouse', true);
  5468. if (!$sl) {
  5469. $sl = 1;
  5470. }
  5471. if (!$warehouse) {
  5472. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5473. exit;
  5474. }
  5475. $dblabel = $this->whlabellabel->get_label($label);
  5476. if ($dblabel) {
  5477. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5478. if (count($data) < 1) {
  5479. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5480. exit;
  5481. }
  5482. if ($sl > count($data)) {
  5483. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5484. exit;
  5485. }
  5486. $time = time();
  5487. for ($i = 0; $i < $sl; $i++) {
  5488. $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']);
  5489. }
  5490. echo json_encode(array('success' => true));
  5491. exit;
  5492. } else {
  5493. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5494. exit;
  5495. }
  5496. }
  5497. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5498. $this->_Template('whlabel_dbrk', $this->data);
  5499. }
  5500. public function _whlabelczdc()
  5501. {
  5502. if (isset($_GET['excel'])) {
  5503. //数据排序
  5504. $order_str = "id desc";
  5505. if (empty($page)) {
  5506. $start = 0;
  5507. $perpage = 1;
  5508. } else {
  5509. $start = ($page - 1) * $perpage;
  5510. }
  5511. $state = $this->input->get('state', true);
  5512. $sku = $this->input->get('sku', true);
  5513. $ctime = $this->input->get('ctime', true);
  5514. $category = $this->input->get('category', true);
  5515. $size = $this->input->get('size', true);
  5516. $grade = $this->input->get('grade', true);
  5517. $color = $this->input->get('color', true);
  5518. $lowe = $this->input->get('lowe', true);
  5519. $timetk = $this->input->get('timetkk', true);
  5520. $timetj = $this->input->get('timetjj', true);
  5521. $timetk = strtotime($timetk);
  5522. $timetj = strtotime($timetj);
  5523. $where = "dbtime > 0";
  5524. if ($timetk && $timetj) {
  5525. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5526. }
  5527. if ($category) {
  5528. $where .= " and features like '%-$category-%'";
  5529. }
  5530. if ($size) {
  5531. $where .= " and features like '%-$size-%'";
  5532. }
  5533. if ($grade) {
  5534. $where .= " and features like '%-$grade-%'";
  5535. }
  5536. if ($color) {
  5537. $where .= " and features like '%-$color-%'";
  5538. }
  5539. if ($lowe) {
  5540. $where .= " and features like '%-$lowe-%'";
  5541. }
  5542. //取得信息列表
  5543. $info_list = $this->whlabel->find_all($where, '*');
  5544. $rows = array();
  5545. $list = array();
  5546. foreach ($info_list as $key => $value) {
  5547. $rows[$value['sku']] = $value; //所有数据sku
  5548. }
  5549. foreach ($rows as $value) {
  5550. $warehouse = $this->warehouse->read($value['warehouse']);
  5551. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5552. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5553. if ($value['orderinfo'] == 0) {
  5554. $info_list[$key]['orderinfo'] = "";
  5555. }
  5556. if ($value['waybill'] == 0) {
  5557. $info_list[$key]['waybill'] = "";
  5558. }
  5559. if ($value['state'] == 0) {
  5560. $value['state'] = "在库";
  5561. } else if ($value['state'] == 3) {
  5562. $value['state'] = "调拨中";
  5563. }
  5564. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5565. }
  5566. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5567. $titlename = "<table border=1>
  5568. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5569. <tr align='center'>
  5570. <td>SKU</td>
  5571. <td>产品</td>
  5572. <td>调拨数量</td>
  5573. <td>入库数量</td>
  5574. </tr>
  5575. </table>";
  5576. $filename = $title . ".xls";
  5577. $tail = "";
  5578. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5579. }
  5580. }
  5581. public function _print($arg_array)
  5582. {
  5583. if (isset($_SESSION['api'])) {
  5584. $user = $this->user->get_api($_SESSION['api']);
  5585. $usp = $user;
  5586. $fgshop = "";
  5587. $sid = "";
  5588. $wid = "";
  5589. $wtype = "";
  5590. $usersp = explode('|', trim($user['shop'], '|'));
  5591. $userwh = explode('|', trim($user['warehouse'], '|'));
  5592. foreach ($usersp as $value) {
  5593. $fgshop .= " shop = " . $value . " or";
  5594. $sid .= " id = " . $value . " or";
  5595. }
  5596. foreach ($userwh as $value) {
  5597. $wid .= " id = " . $value . " or";
  5598. $wtype .= " type = " . $value . " or";
  5599. }
  5600. }
  5601. $post = $this->input->post(NULL, TRUE);
  5602. if (isset($post['tmsku'])) {
  5603. $tmsku = $this->input->post('tmsku', true);
  5604. if (is_numeric($tmsku)) {
  5605. $yyh = $this->whlabellabel->get_label($tmsku);
  5606. } else {
  5607. $yyh = $this->whlabellabel->get_sku($tmsku);
  5608. if(empty($yyh)){
  5609. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  5610. if($r['code'] == -1 ){
  5611. echo json_encode(array('success' => false));
  5612. exit;
  5613. }else{
  5614. echo json_encode(array('features' => $r['data'], 'success' => true));
  5615. exit;
  5616. }
  5617. }
  5618. }
  5619. if ($yyh) {
  5620. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5621. exit;
  5622. } else {
  5623. echo json_encode(array('success' => false));
  5624. exit;
  5625. }
  5626. }
  5627. $classid = $this->classid->sku();
  5628. $pm = $classid;
  5629. $scsku = $classid;
  5630. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5631. if (isset($post['warehouse'])) {
  5632. if ($post['warehouse']) {
  5633. $list = array();
  5634. $num = "";
  5635. $title = "";
  5636. $features = "";
  5637. $order = 0;
  5638. $post['shop'] = '';
  5639. $brand = $this->input->post('brand', true);
  5640. if ($brand != '0,') {
  5641. $b = $this->brand->read(rtrim($brand, ','));
  5642. if ($b) {
  5643. $post['shop'] = str_replace('|', ',', $b['shop']);
  5644. }
  5645. }
  5646. $post['details'] = $this->input->post('details', true); //打印数量
  5647. $xbqnum = $this->input->post('xbqnum', true);
  5648. $post['purchase'] = $this->input->post('purchase', true);
  5649. $post['warehouse'] = $this->input->post('warehouse', true);
  5650. $post['purchase'] = $this->input->post('purchase', true);
  5651. $post['retreatwarehouse'] = $post['warehouse'];
  5652. $post['cpbz'] = $this->input->post('cpbz', true);
  5653. $post['state'] = 9;
  5654. $category = $this->input->post('category', true);
  5655. $list['category'] = $category;
  5656. $list['hairtype'] = $this->input->post('hairtype', true);
  5657. $list['grade'] = $this->input->post('grade', true);
  5658. $size = $this->input->post('size', true);
  5659. $list['size'] = rtrim($size, ',');
  5660. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5661. $list['extension'] = $this->input->post('extension', true);
  5662. if ($category == 1297) {
  5663. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5664. }
  5665. if ($category == 1702) {
  5666. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5667. $list['syother'] = $this->input->post('syother', true);
  5668. }
  5669. if ($category == 133) {
  5670. $list['fittype'] = $this->input->post('fittype', true);
  5671. $list['acother'] = $this->input->post('acother', true);
  5672. }
  5673. $list['color'] = $this->input->post('color', true);
  5674. $list['lowe'] = $this->input->post('lowe', true);
  5675. if ($category == 127) {
  5676. $list['type'] = $this->input->post('type', true);
  5677. $list['headroad'] = $this->input->post('headroad', true);
  5678. $list['density'] = $this->input->post('density', true);
  5679. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5680. $list['lacesize'] = $this->input->post('lacesize', true);
  5681. }
  5682. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5683. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5684. }
  5685. if ($category == 128) {
  5686. $list['lacetype'] = $this->input->post('lacetype', true);
  5687. $list['haircap'] = $this->input->post('haircap', true);
  5688. $list['density'] = $this->input->post('density', true);
  5689. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5690. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5691. $list['wigother'] = $this->input->post('wigother', true);
  5692. $list['wigother1'] = $this->input->post('wigother1', true);
  5693. $list['wigother2'] = $this->input->post('wigother2', true);
  5694. $list['product_related'] = $this->input->post('product_related', true);
  5695. }
  5696. if ($category == 129) {
  5697. $list['wide'] = $this->input->post('wide', true);
  5698. }
  5699. if ($category == 131) {
  5700. $list['gifttype'] = $this->input->post('gifttype', true);
  5701. $list['giftother'] = $this->input->post('giftother', true);
  5702. }
  5703. if ($category == 134) {
  5704. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5705. }
  5706. if ($category == 1297) {
  5707. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5708. $list['sywigother'] = $this->input->post('sywigother', true);
  5709. }
  5710. if ($category == 130 || $category == 133 || $category == 1702) {
  5711. $list['items'] = $this->input->post('items', true);
  5712. $list['weight'] = $this->input->post('weight', true);
  5713. }
  5714. if ($category == 1702) {
  5715. $list['syhairther'] = $this->input->post('syhairther', true);
  5716. }
  5717. if($category == 130){
  5718. $list['jfother'] = $this->input->post('jfother', true);
  5719. }
  5720. foreach ($list as $k => $v) {
  5721. if ($v != 0) {
  5722. $num .= $v;
  5723. $features .= $v . '-';
  5724. $post[$k] = $v;
  5725. $typeclass = $this->typeclass->read($v);
  5726. if (isset($pm[$typeclass['classid']])) {
  5727. if (stripos($typeclass['zh'], '|') !== false) {
  5728. $exzh = explode('|', $typeclass['zh']);
  5729. $pm[$typeclass['classid']] = $exzh[0];
  5730. } else {
  5731. $pm[$typeclass['classid']] = $typeclass['zh'];
  5732. }
  5733. }
  5734. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5735. if ($k != 'size') {
  5736. $title .= $typeclass['title'] . " ";
  5737. }
  5738. }
  5739. }
  5740. $typeclass = $this->typeclass->read($list['size']);
  5741. $title .= $typeclass['title'];
  5742. $time = time();
  5743. $post['title'] = rtrim($title, ' ');
  5744. $post['number'] = $num;
  5745. $post['features'] = '-' . $features;
  5746. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5747. $featurespp = explode('-', trim($featurespp, '-'));
  5748. if (isset($featurespp[5])) {
  5749. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5750. } else {
  5751. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5752. }
  5753. $post['enter'] = $time;
  5754. $post['time'] = $time; //操作时间
  5755. $scsku = implode("-", $scsku);
  5756. $zh = implode(" ", $pm);
  5757. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5758. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5759. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5760. $post['sku'] = $bqsku;
  5761. $label = time() . rand(0, 9);
  5762. $post['label'] = $label;
  5763. $cpid = $this->whlabellabel->find_count();
  5764. $post['cpid'] = $cpid + 1;
  5765. $cpid = $post['cpid'];
  5766. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5767. //if($whlabelbarcode)
  5768. //{
  5769. //$post['label'] = $whlabelbarcode['label'];
  5770. //if(!$this->whlabellabel->insert($post))
  5771. //{
  5772. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5773. //}
  5774. //}
  5775. //else
  5776. //{
  5777. $this->db->trans_begin();
  5778. $this->whlabellabel->insert($post);
  5779. //$this->whlabelbarcode->insert($post);
  5780. if ($this->db->trans_status() === TRUE) {
  5781. $this->db->trans_commit();
  5782. } else {
  5783. $this->db->trans_rollback();
  5784. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5785. exit;
  5786. }
  5787. //}
  5788. $warehouse_name = "";
  5789. $warehouse = $post['warehouse'];
  5790. if($warehouse == 12){
  5791. $warehouse_name = "特殊库存库";
  5792. }
  5793. // if($warehouse == 13){
  5794. // $warehouse_name = "许昌仓";
  5795. // }
  5796. // if($warehouse == 5){
  5797. // $warehouse_name = "美国店";
  5798. // }
  5799. // if($warehouse == 16){
  5800. // $warehouse_name = "定制头套仓";
  5801. // }
  5802. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5803. if(!empty($warehouse_name)){
  5804. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5805. }
  5806. $purchase = $this->purchase->read($post['purchase']);
  5807. 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));
  5808. exit; //特殊仓目前不需要仓库选项
  5809. }
  5810. }
  5811. if (isset($_SESSION['api'])) {
  5812. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5813. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5814. $this->data['wlshop'] = $wlshop;
  5815. $this->data['warehouse'] = $warehouse;
  5816. }
  5817. $whlabelwz = $this->whlabelwz->find_all();
  5818. $this->data['whlabelwz'] = $whlabelwz;
  5819. $this->_Template('whlabel_print', $this->data);
  5820. }
  5821. public function _usaprint($arg_array)
  5822. {
  5823. if (isset($_SESSION['api'])) {
  5824. $user = $this->user->get_api($_SESSION['api']);
  5825. $usp = $user;
  5826. $fgshop = "";
  5827. $sid = "";
  5828. $wid = "";
  5829. $wtype = "";
  5830. $usersp = explode('|', trim($user['shop'], '|'));
  5831. $userwh = explode('|', trim($user['warehouse'], '|'));
  5832. foreach ($usersp as $value) {
  5833. $fgshop .= " shop = " . $value . " or";
  5834. $sid .= " id = " . $value . " or";
  5835. }
  5836. foreach ($userwh as $value) {
  5837. $wid .= " id = " . $value . " or";
  5838. $wtype .= " type = " . $value . " or";
  5839. }
  5840. }
  5841. $post = $this->input->post(NULL, TRUE);
  5842. if (isset($post['tmsku'])) {
  5843. $tmsku = $this->input->post('tmsku', true);
  5844. if (is_numeric($tmsku)) {
  5845. $yyh = $this->whlabellabel->get_label($tmsku);
  5846. } else {
  5847. $yyh = $this->whlabellabel->get_sku($tmsku);
  5848. }
  5849. if ($yyh) {
  5850. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5851. exit;
  5852. } else {
  5853. echo json_encode(array('success' => false));
  5854. exit;
  5855. }
  5856. }
  5857. $classid = $this->classid->sku();
  5858. $pm = $classid;
  5859. $scsku = $classid;
  5860. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5861. if (isset($post['warehouse'])) {
  5862. if ($post['warehouse']) {
  5863. $list = array();
  5864. $num = "";
  5865. $title = "";
  5866. $features = "";
  5867. $order = 0;
  5868. $post['shop'] = '';
  5869. $brand = $this->input->post('brand', true);
  5870. if ($brand != '0,') {
  5871. $b = $this->brand->read(rtrim($brand, ','));
  5872. if ($b) {
  5873. $post['shop'] = str_replace('|', ',', $b['shop']);
  5874. }
  5875. }
  5876. $post['details'] = $this->input->post('details', true); //打印数量
  5877. $xbqnum = $this->input->post('xbqnum', true);
  5878. $post['purchase'] = $this->input->post('purchase', true);
  5879. $post['warehouse'] = $this->input->post('warehouse', true);
  5880. $post['purchase'] = $this->input->post('purchase', true);
  5881. $post['retreatwarehouse'] = $post['warehouse'];
  5882. $post['cpbz'] = $this->input->post('cpbz', true);
  5883. $post['state'] = 9;
  5884. $category = $this->input->post('category', true);
  5885. $list['category'] = $category;
  5886. $list['hairtype'] = $this->input->post('hairtype', true);
  5887. $list['grade'] = $this->input->post('grade', true);
  5888. $size = $this->input->post('size', true);
  5889. $list['size'] = rtrim($size, ',');
  5890. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5891. $list['extension'] = $this->input->post('extension', true);
  5892. if ($category == 1297) {
  5893. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5894. }
  5895. if ($category == 1702) {
  5896. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5897. $list['syother'] = $this->input->post('syother', true);
  5898. }
  5899. if ($category == 133) {
  5900. $list['fittype'] = $this->input->post('fittype', true);
  5901. $list['acother'] = $this->input->post('acother', true);
  5902. }
  5903. $list['color'] = $this->input->post('color', true);
  5904. $list['lowe'] = $this->input->post('lowe', true);
  5905. if ($category == 127) {
  5906. $list['type'] = $this->input->post('type', true);
  5907. $list['headroad'] = $this->input->post('headroad', true);
  5908. $list['density'] = $this->input->post('density', true);
  5909. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5910. $list['lacesize'] = $this->input->post('lacesize', true);
  5911. }
  5912. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5913. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5914. }
  5915. if ($category == 128) {
  5916. $list['lacetype'] = $this->input->post('lacetype', true);
  5917. $list['haircap'] = $this->input->post('haircap', true);
  5918. $list['density'] = $this->input->post('density', true);
  5919. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5920. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5921. $list['wigother'] = $this->input->post('wigother', true);
  5922. $list['wigother1'] = $this->input->post('wigother1', true);
  5923. $list['wigother2'] = $this->input->post('wigother2', true);
  5924. $list['product_related'] = $this->input->post('product_related', true);
  5925. }
  5926. if ($category == 129) {
  5927. $list['wide'] = $this->input->post('wide', true);
  5928. }
  5929. if ($category == 131) {
  5930. $list['gifttype'] = $this->input->post('gifttype', true);
  5931. $list['giftother'] = $this->input->post('giftother', true);
  5932. }
  5933. if ($category == 134) {
  5934. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5935. }
  5936. if ($category == 1297) {
  5937. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5938. $list['sywigother'] = $this->input->post('sywigother', true);
  5939. }
  5940. if ($category == 130 || $category == 133 || $category == 1702) {
  5941. $list['items'] = $this->input->post('items', true);
  5942. $list['weight'] = $this->input->post('weight', true);
  5943. }
  5944. if ($category == 1702) {
  5945. $list['syhairther'] = $this->input->post('syhairther', true);
  5946. }
  5947. foreach ($list as $k => $v) {
  5948. if ($v != 0) {
  5949. $num .= $v;
  5950. $features .= $v . '-';
  5951. $post[$k] = $v;
  5952. $typeclass = $this->typeclass->read($v);
  5953. if (isset($pm[$typeclass['classid']])) {
  5954. if (stripos($typeclass['zh'], '|') !== false) {
  5955. $exzh = explode('|', $typeclass['zh']);
  5956. $pm[$typeclass['classid']] = $exzh[0];
  5957. } else {
  5958. $pm[$typeclass['classid']] = $typeclass['zh'];
  5959. }
  5960. }
  5961. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5962. if ($k != 'size') {
  5963. $title .= $typeclass['title'] . " ";
  5964. }
  5965. }
  5966. }
  5967. $typeclass = $this->typeclass->read($list['size']);
  5968. $title .= $typeclass['title'];
  5969. $time = time();
  5970. $post['title'] = rtrim($title, ' ');
  5971. $post['number'] = $num;
  5972. $post['features'] = '-' . $features;
  5973. $fp = $this->whlabel->get_features($post['features']);
  5974. if (!$fp) {
  5975. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5976. exit;
  5977. }
  5978. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5979. $featurespp = explode('-', trim($featurespp, '-'));
  5980. if (isset($featurespp[5])) {
  5981. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5982. } else {
  5983. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5984. }
  5985. $post['enter'] = $time;
  5986. $post['time'] = $time; //操作时间
  5987. $scsku = implode("-", $scsku);
  5988. $zh = implode(" ", $pm);
  5989. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5990. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5991. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5992. $post['sku'] = $fp['sku'];
  5993. $post['label'] = $fp['sku'];
  5994. $cpid = $this->whlabellabel->find_count();
  5995. $post['cpid'] = $cpid + 1;
  5996. $cpid = $post['cpid'];
  5997. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5998. //if($whlabelbarcode)
  5999. //{
  6000. //$post['label'] = $whlabelbarcode['label'];
  6001. //if(!$this->whlabellabel->insert($post))
  6002. //{
  6003. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6004. //}
  6005. //}
  6006. //else
  6007. //{
  6008. $this->db->trans_begin();
  6009. $this->whlabellabel->insert($post);
  6010. //$this->whlabelbarcode->insert($post);
  6011. if ($this->db->trans_status() === TRUE) {
  6012. $this->db->trans_commit();
  6013. } else {
  6014. $this->db->trans_rollback();
  6015. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6016. exit;
  6017. }
  6018. //}
  6019. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6020. $purchase = $this->purchase->read($post['purchase']);
  6021. 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));
  6022. exit; //特殊仓目前不需要仓库选项
  6023. }
  6024. }
  6025. if (isset($_SESSION['api'])) {
  6026. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6027. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6028. $this->data['wlshop'] = $wlshop;
  6029. $this->data['warehouse'] = $warehouse;
  6030. }
  6031. $whlabelwz = $this->whlabelwz->find_all();
  6032. $this->data['whlabelwz'] = $whlabelwz;
  6033. $this->_Template('whlabel_usaprint', $this->data);
  6034. }
  6035. public function _printrk($arg_array)
  6036. {
  6037. $prc = array();
  6038. $purchase = $this->purchase->find_all();
  6039. foreach ($purchase as $k => $v) {
  6040. $prc[$v['id']] = $v['title'];
  6041. }
  6042. $post = $this->input->post(NULL, TRUE);
  6043. if (isset($post['page'])) {
  6044. $page = $this->input->post('page', true);
  6045. $perpage = $this->input->post('perpage', true);
  6046. $sku = $this->input->post('sku', true);
  6047. $bs = $this->input->post('bs', true);
  6048. $number = $this->input->post('number', true);
  6049. $warehouse = $this->input->post('warehouse', true);
  6050. $purchase = $this->input->post('purchase', true);
  6051. $orderinfo = $this->input->post('orderinfo', true);
  6052. $waybill = $this->input->post('waybill', true);
  6053. $category = $this->input->post('category', true);
  6054. $size = $this->input->post('size', true);
  6055. $grade = $this->input->post('grade', true);
  6056. $color = $this->input->post('color', true);
  6057. $lowe = $this->input->post('lowe', true);
  6058. $state = $this->input->post('state', true);
  6059. $label = $this->input->post('label', true);
  6060. $timetk = $this->input->post('ktime', true);
  6061. $timetj = $this->input->post('jtime', true);
  6062. $timetk = strtotime($timetk);
  6063. $timetj = strtotime($timetj);
  6064. $where = "1=1 ";
  6065. if ($timetk && $timetj) {
  6066. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6067. }
  6068. if ($sku) {
  6069. $where .= " and sku = '$sku'";
  6070. }
  6071. if ($bs != '') {
  6072. $where .= " and bs = '$bs'";
  6073. }
  6074. if ($number) {
  6075. $where .= " and number = '$number'";
  6076. }
  6077. if ($warehouse) {
  6078. $where .= " and warehouse = '$warehouse'";
  6079. }
  6080. if ($purchase) {
  6081. $where .= " and purchase = '$purchase'";
  6082. }
  6083. if ($orderinfo) {
  6084. $where .= " and orderinfo = '$orderinfo'";
  6085. }
  6086. if ($waybill) {
  6087. $where .= " and waybill = '$waybill'";
  6088. }
  6089. if ($category) {
  6090. $where .= " and features like '%-$category-%'";
  6091. }
  6092. if ($size) {
  6093. $where .= " and features like '%-$size-%'";
  6094. }
  6095. if ($grade) {
  6096. $where .= " and features like '%-$grade-%'";
  6097. }
  6098. if ($color) {
  6099. $where .= " and features like '%-$color-%'";
  6100. }
  6101. if ($lowe) {
  6102. $where .= " and features like '%-$lowe-%'";
  6103. }
  6104. if ($label) {
  6105. $where .= " and label = '$label'";
  6106. }
  6107. if ($state || $state == 0) {
  6108. $where .= " and state = '$state'";
  6109. }
  6110. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6111. //数据排序
  6112. $order_str = "enter desc";
  6113. if (empty($page)) {
  6114. $start = 0;
  6115. $perpage = 1;
  6116. } else {
  6117. $start = ($page - 1) * $perpage;
  6118. }
  6119. //取得信息列表
  6120. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6121. foreach ($info_list as $key => $value) {
  6122. $warehouse = $this->warehouse->read($value['warehouse']);
  6123. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6124. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6125. if ($value['state'] == 0) {
  6126. $info_list[$key]['state'] = "在库";
  6127. } else if ($value['state'] == 1) {
  6128. $info_list[$key]['state'] = "出库";
  6129. } else if ($value['state'] == 2) {
  6130. $info_list[$key]['state'] = "退库";
  6131. } else if ($value['state'] == 3) {
  6132. $info_list[$key]['state'] = "调拨中";
  6133. } else if ($value['state'] == 4) {
  6134. $info_list[$key]['state'] = "再加工";
  6135. } else if ($value['state'] == 5) {
  6136. $info_list[$key]['state'] = "维修中";
  6137. } else if ($value['state'] == 6) {
  6138. $info_list[$key]['state'] = "盘亏";
  6139. } else if ($value['state'] == 7) {
  6140. $info_list[$key]['state'] = "更换标签";
  6141. } else if ($value['state'] == 8) {
  6142. $info_list[$key]['state'] = "其它";
  6143. } else if ($value['state'] == 9) {
  6144. $info_list[$key]['state'] = "预设";
  6145. } else if ($value['state'] == 10) {
  6146. $info_list[$key]['state'] = "美店零售";
  6147. }
  6148. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6149. }
  6150. $total = $this->$ck->find_count($where);
  6151. $pagenum = ceil($total / $perpage);
  6152. $over = $total - ($start + $perpage);
  6153. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6154. echo json_encode($rows);
  6155. exit;
  6156. }
  6157. if (isset($post['tmsku'])) {
  6158. $time = time();
  6159. $tmsku = $this->input->post('tmsku', true);
  6160. //$post['shop'] = $this->input->post('shop',true);
  6161. $num = $this->input->post('num', true);
  6162. $rktype = $this->input->post('rktype', true);
  6163. if ($num > 200) {
  6164. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6165. exit;
  6166. }
  6167. if (!$rktype) {
  6168. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6169. }
  6170. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6171. /**
  6172. $wz = array();
  6173. foreach ($rk as $key=>$value)
  6174. {
  6175. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6176. }
  6177. if(count($wz) > 1)
  6178. {
  6179. $wz = array_values($wz);
  6180. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6181. }
  6182. **/
  6183. if (isset($rk[0]['purchase'])) {
  6184. $rk = $rk[0];
  6185. $j = 0;
  6186. $post['purchase'] = $rk['purchase'];
  6187. $post['warehouse'] = $rk['warehouse'];
  6188. $post['retreatwarehouse'] = $rk['warehouse'];
  6189. $post['sku'] = $rk['sku'];
  6190. $post['number'] = $rk['number'];
  6191. $post['features'] = $rk['features'];
  6192. $post['title'] = $rk['title'];
  6193. $post['enter'] = $time;
  6194. $post['time'] = $time;
  6195. $post['bs'] = 1;
  6196. $post['shop'] = $rk['shop'];
  6197. $post['details'] = $rk['details'];
  6198. $post['cpid'] = $rk['cpid'];
  6199. $post['cpbz'] = $rk['cpbz'];
  6200. $post['rktype'] = $rktype;
  6201. $warehouse = $this->warehouse->read($rk['warehouse']);
  6202. if ($warehouse['bdck'] == '') {
  6203. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6204. exit;
  6205. } else {
  6206. $bdck = $warehouse['bdck'];
  6207. }
  6208. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6209. if (isset($pdwz['details'])) {
  6210. if ($pdwz['details'] != $post['details']) {
  6211. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6212. }else{
  6213. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6214. exit;
  6215. }
  6216. }
  6217. }
  6218. $post['featurespp'] = $rk['featurespp'];
  6219. if ($post['warehouse'] == '5') {
  6220. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6221. if ($yza) {
  6222. if ($post['features'] != $yza[0]['features']) {
  6223. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6224. exit;
  6225. }
  6226. }
  6227. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6228. if ($yzb) {
  6229. if ($post['sku'] != $yzb[0]['sku']) {
  6230. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6231. exit;
  6232. }
  6233. }
  6234. }
  6235. for ($i = 0; $i < $num; $i++) {
  6236. $post['label'] = time() . rand(100, 999) . $i;
  6237. if ($this->$bdck->insert($post)) {
  6238. $j++;
  6239. }
  6240. }
  6241. /**
  6242. if($post['warehouse'] != 12)
  6243. {
  6244. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6245. }
  6246. **/
  6247. $this->whlabelscanlog->insert([
  6248. 'shop'=>$rk['shop'],
  6249. 'type'=>1,
  6250. 'purchase'=>$rk['purchase'],
  6251. 'sku'=>$rk['sku'],
  6252. 'features'=>$rk['features'],
  6253. 'title'=>$rk['title'],
  6254. 'label'=>$rk['label'],
  6255. 'warehouse'=>$rk['warehouse'],
  6256. 'wlid'=>$rk['id'],
  6257. 'num'=>$num,
  6258. 'addtime'=>time()
  6259. ]);
  6260. if ($j == $num) {
  6261. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6262. exit;
  6263. } else {
  6264. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6265. exit;
  6266. }
  6267. } else {
  6268. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6269. exit;
  6270. }
  6271. }
  6272. $this->_Template('whlabel_printrk', $this->data);
  6273. }
  6274. public function _printxzrk($arg_array)
  6275. {
  6276. $post = $this->input->post(NULL, TRUE);
  6277. if (isset($post['wzid'])) {
  6278. $time = time();
  6279. $id = $this->input->post('wzid', true);
  6280. //$post['shop'] = $this->input->post('shop',true);
  6281. $num = 1;
  6282. $rk = $this->whlabellabel->read($id);
  6283. if (isset($rk['purchase'])) {
  6284. $x = 0;
  6285. $post['purchase'] = $rk['purchase'];
  6286. $post['warehouse'] = $rk['warehouse'];
  6287. $post['retreatwarehouse'] = $rk['warehouse'];
  6288. $post['sku'] = $rk['sku'];
  6289. $post['number'] = $rk['number'];
  6290. $post['features'] = $rk['features'];
  6291. $post['title'] = $rk['title'];
  6292. $post['enter'] = $time;
  6293. $post['time'] = $time;
  6294. $post['bs'] = 1;
  6295. $post['shop'] = $rk['shop'];
  6296. $post['details'] = $rk['details'];
  6297. $post['cpid'] = $rk['cpid'];
  6298. $post['cpbz'] = $rk['cpbz'];
  6299. $warehouse = $this->warehouse->read($rk['warehouse']);
  6300. if ($warehouse['bdck'] == '') {
  6301. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6302. exit;
  6303. } else {
  6304. $bdck = $warehouse['bdck'];
  6305. }
  6306. $post['featurespp'] = $rk['featurespp'];
  6307. $this->db->trans_begin();
  6308. for ($i = 0; $i < $num; $i++) {
  6309. $post['label'] = time() . rand(100, 999) . $i;
  6310. $this->$bdck->insert($post);
  6311. }
  6312. /**
  6313. if($post['warehouse'] != 12)
  6314. {
  6315. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6316. }
  6317. **/
  6318. if ($this->db->trans_status() === TRUE) {
  6319. $this->db->trans_commit();
  6320. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6321. exit;
  6322. } else {
  6323. $this->db->trans_rollback();
  6324. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6325. exit;
  6326. }
  6327. } else {
  6328. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6329. exit;
  6330. }
  6331. }
  6332. }
  6333. public function _printck($arg_array)
  6334. {
  6335. $prc = array();
  6336. $purchase = $this->purchase->find_all();
  6337. foreach ($purchase as $k => $v) {
  6338. $prc[$v['id']] = $v['title'];
  6339. }
  6340. $post = $this->input->post(NULL, TRUE);
  6341. if (isset($post['page'])) {
  6342. $page = $this->input->post('page', true);
  6343. $perpage = $this->input->post('perpage', true);
  6344. $sku = $this->input->post('sku', true);
  6345. $bs = $this->input->post('bs', true);
  6346. $number = $this->input->post('number', true);
  6347. $warehouse = $this->input->post('warehouse', true);
  6348. $purchase = $this->input->post('purchase', true);
  6349. $orderinfo = $this->input->post('orderinfo', true);
  6350. $waybill = $this->input->post('waybill', true);
  6351. $category = $this->input->post('category', true);
  6352. $size = $this->input->post('size', true);
  6353. $grade = $this->input->post('grade', true);
  6354. $color = $this->input->post('color', true);
  6355. $lowe = $this->input->post('lowe', true);
  6356. $state = $this->input->post('state', true);
  6357. $label = $this->input->post('label', true);
  6358. $timetk = $this->input->post('ktime', true);
  6359. $timetj = $this->input->post('jtime', true);
  6360. $timetk = strtotime($timetk);
  6361. $timetj = strtotime($timetj);
  6362. $where = "state=1 ";
  6363. if ($timetk && $timetj) {
  6364. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6365. }
  6366. if ($sku) {
  6367. $where .= " and sku = '$sku'";
  6368. }
  6369. if ($bs != '') {
  6370. $where .= " and bs = '$bs'";
  6371. }
  6372. if ($number) {
  6373. $where .= " and number = '$number'";
  6374. }
  6375. if ($warehouse) {
  6376. $where .= " and warehouse = '$warehouse'";
  6377. }
  6378. if ($purchase) {
  6379. $where .= " and purchase = '$purchase'";
  6380. }
  6381. if ($orderinfo) {
  6382. $where .= " and orderinfo = '$orderinfo'";
  6383. }
  6384. if ($waybill) {
  6385. $where .= " and waybill = '$waybill'";
  6386. }
  6387. if ($category) {
  6388. $where .= " and features like '%-$category-%'";
  6389. }
  6390. if ($size) {
  6391. $where .= " and features like '%-$size-%'";
  6392. }
  6393. if ($grade) {
  6394. $where .= " and features like '%-$grade-%'";
  6395. }
  6396. if ($color) {
  6397. $where .= " and features like '%-$color-%'";
  6398. }
  6399. if ($lowe) {
  6400. $where .= " and features like '%-$lowe-%'";
  6401. }
  6402. if ($label) {
  6403. $where .= " and label = '$label'";
  6404. }
  6405. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6406. //数据排序
  6407. $order_str = "outk desc";
  6408. if (empty($page)) {
  6409. $start = 0;
  6410. $perpage = 1;
  6411. } else {
  6412. $start = ($page - 1) * $perpage;
  6413. }
  6414. //取得信息列表
  6415. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6416. foreach ($info_list as $key => $value) {
  6417. $warehouse = $this->warehouse->read($value['warehouse']);
  6418. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6419. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6420. if ($value['state'] == 0) {
  6421. $info_list[$key]['state'] = "在库";
  6422. } else if ($value['state'] == 1) {
  6423. $info_list[$key]['state'] = "出库";
  6424. } else if ($value['state'] == 2) {
  6425. $info_list[$key]['state'] = "退库";
  6426. } else if ($value['state'] == 3) {
  6427. $info_list[$key]['state'] = "调拨中";
  6428. } else if ($value['state'] == 4) {
  6429. $info_list[$key]['state'] = "再加工";
  6430. } else if ($value['state'] == 5) {
  6431. $info_list[$key]['state'] = "维修中";
  6432. } else if ($value['state'] == 6) {
  6433. $info_list[$key]['state'] = "盘亏";
  6434. } else if ($value['state'] == 7) {
  6435. $info_list[$key]['state'] = "更换标签";
  6436. } else if ($value['state'] == 8) {
  6437. $info_list[$key]['state'] = "其它";
  6438. } else if ($value['state'] == 9) {
  6439. $info_list[$key]['state'] = "预设";
  6440. } else if ($value['state'] == 10) {
  6441. $info_list[$key]['state'] = "美店零售";
  6442. }
  6443. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6444. }
  6445. $total = $this->$ck->find_count($where);
  6446. $pagenum = ceil($total / $perpage);
  6447. $over = $total - ($start + $perpage);
  6448. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6449. echo json_encode($rows);
  6450. exit;
  6451. }
  6452. if (isset($post['tmsku'])) {
  6453. $time = time();
  6454. $tmsku = $this->input->post('tmsku', true);
  6455. //$post['shop'] = $this->input->post('shop',true);
  6456. $num = $this->input->post('num', true);
  6457. $cktype = $this->input->post('cktype', true);
  6458. $label = $this->whlabellabel->get_label($tmsku);
  6459. if (!$cktype) {
  6460. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6461. }
  6462. if (!isset($label['warehouse'])) {
  6463. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6464. exit;
  6465. }
  6466. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6467. $extra_where = "";
  6468. if(!empty($label['details'])){
  6469. $extra_where .= " and details = '" . $label['details'] . "'";
  6470. }
  6471. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6472. if (stripos($label['features'], '-126-') !== false) {
  6473. $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 ) ".$extra_where);
  6474. } else {
  6475. $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 ) ".$extra_where);
  6476. }
  6477. $j = 0;
  6478. if (count($ck) >= $num) {
  6479. for ($i = 0; $i < $num; $i++) {
  6480. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6481. {
  6482. $j++;
  6483. }
  6484. }
  6485. $this->whlabelscanlog->insert([
  6486. 'shop'=>$label['shop'],
  6487. 'type'=>2,
  6488. 'purchase'=>$label['purchase'],
  6489. 'sku'=>$label['sku'],
  6490. 'features'=>$label['features'],
  6491. 'title'=>$label['title'],
  6492. 'label'=>$label['label'],
  6493. 'warehouse'=>$label['warehouse'],
  6494. 'wlid'=>$label['id'],
  6495. 'num'=>$num,
  6496. 'addtime'=>time()
  6497. ]);
  6498. if ($j == $num) {
  6499. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6500. exit;
  6501. } else {
  6502. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6503. exit;
  6504. }
  6505. } else {
  6506. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6507. exit;
  6508. }
  6509. }
  6510. if(isset($_SESSION['api']))
  6511. {
  6512. $user = $this->user->get_api($_SESSION['api']);
  6513. if(in_array($user['power'],[1,27])){
  6514. $vip = 1;
  6515. }
  6516. }
  6517. else
  6518. {
  6519. $vip = 0;
  6520. header('Location: /');exit;
  6521. }
  6522. $this->data['vip'] = $vip;
  6523. $this->_Template('whlabel_printck', $this->data);
  6524. }
  6525. public function _printexcel()
  6526. {
  6527. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6528. $config['upload_path'] = '.' . $dir;
  6529. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6530. $config['allowed_types'] = 'xls|xlsx|csv';
  6531. $config['max_size'] = 10240;
  6532. $this->load->library('upload', $config);
  6533. $this->upload->initialize($config);
  6534. if ($this->upload->do_upload('userfile')) {
  6535. $full_path = $dir . $this->upload->data('file_name');
  6536. $fileName = '.' . $full_path;
  6537. if (!file_exists($fileName)) {
  6538. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6539. exit;
  6540. } else {
  6541. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6542. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6543. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6544. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6545. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6546. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6547. ++$column; //如果列数大于26行
  6548. $list = array();
  6549. for ($i = 2; $i <= $row; $i++) // 行数循环
  6550. {
  6551. $data = array();
  6552. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6553. {
  6554. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6555. }
  6556. $list[] = $data;
  6557. }
  6558. }
  6559. $ed = array();
  6560. $i = 0;
  6561. $j = 0;
  6562. $dcdata = array();
  6563. $yc = '';
  6564. $cmf_arr = array_column($list, '1');
  6565. array_multisort($cmf_arr, SORT_ASC, $list);
  6566. foreach ($list as $key => $value) {
  6567. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6568. if ($typeclass) {
  6569. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6570. } else {
  6571. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6572. $i++;
  6573. continue;
  6574. }
  6575. }
  6576. if ($i > 0) {
  6577. $yc = $i . '条异常';
  6578. }
  6579. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6580. exit;
  6581. }
  6582. }
  6583. public function _uck()
  6584. {
  6585. if (isset($_GET['excel'])) {
  6586. $tc = array();
  6587. $typeclass = $this->typeclass->find_all();
  6588. foreach ($typeclass as $v) {
  6589. $tc[$v['id']] = $v['zh'];
  6590. }
  6591. $data = array();
  6592. $t = array();
  6593. $rq = '';
  6594. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6595. $ts = $ts / (24 * 3600);
  6596. for ($i = 0; $i < $ts; $i++) {
  6597. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6598. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6599. }
  6600. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6601. foreach ($info_list as $k => $v) {
  6602. $features = explode('-', trim($v['features'], '-'));
  6603. if (!isset($features[3]) || !isset($features[4])) {
  6604. continue;
  6605. }
  6606. $data[$k][0] = $tc[$features[0]]; //类型
  6607. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6608. $data[$k][2] = $tc[$features[4]]; //曲度
  6609. $data[$k][3] = '';
  6610. if (isset($data[$k][1])) {
  6611. $data[$k][3] .= $data[$k][1];
  6612. }
  6613. if (isset($data[$k][2])) {
  6614. $data[$k][3] .= $data[$k][2];
  6615. }
  6616. if (isset($features[5])) {
  6617. $data[$k][3] .= $tc[$features[5]];
  6618. }
  6619. if (isset($features[2])) {
  6620. $data[$k][3] .= $tc[$features[2]];
  6621. }
  6622. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6623. $data[$k][4] = $v['sku'];
  6624. $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())) . '))'); //月初库存
  6625. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6626. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6627. $ztrq = '';
  6628. $ztsl = '';
  6629. if (count($zt) > 0) {
  6630. foreach ($zt as $vv) {
  6631. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6632. $ztsl .= $vv['num'] . '<br>';
  6633. }
  6634. }
  6635. $data[$k][] = trim($ztsl, '<br>');
  6636. $data[$k][] = trim($ztrq, '<br>');
  6637. $byck = 0;
  6638. foreach ($t as $vv) {
  6639. $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));
  6640. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6641. $byck += $sl;
  6642. }
  6643. $data[$k][] = ($byck > 0) ? $byck : '';
  6644. }
  6645. $title = "详情 " . date("Y-m-d", time());
  6646. $titlename = "<table border=1>
  6647. <tr align='center'>
  6648. <td>类别</td>
  6649. <td>颜色</td>
  6650. <td>曲度</td>
  6651. <td>名称</td>
  6652. <td>SKU</td>
  6653. <td>月初库存</td>
  6654. <td>剩余库存</td>
  6655. <td>在途数量</td>
  6656. <td>预达日期</td>" .
  6657. $rq
  6658. . "<td>本月出库</td></tr>
  6659. </table>";
  6660. $filename = $title . ".xls";
  6661. $tail = "";
  6662. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  6663. }
  6664. }
  6665. public function _whlabelexcelzh()
  6666. {
  6667. if (isset($_GET['excel'])) {
  6668. $where = "sku != 'Preset'";
  6669. //数据排序
  6670. $order_str = "id desc";
  6671. if (empty($page)) {
  6672. $start = 0;
  6673. $perpage = 1;
  6674. } else {
  6675. $start = ($page - 1) * $perpage;
  6676. }
  6677. $category = $this->input->get('category', true);
  6678. $warehouse = $this->input->get('warehouse', true);
  6679. $excelid = $this->input->get('sid', true);
  6680. if ($category) {
  6681. $where .= " and features like '%-$category-%'";
  6682. }
  6683. if ($warehouse) {
  6684. $where .= " and warehouse = '$warehouse'";
  6685. }
  6686. $xzid = '';
  6687. if ($excelid) {
  6688. $excelid = explode(',', trim($excelid, ','));
  6689. foreach ($excelid as $key => $value) {
  6690. $xzid .= " id = " . $value . " or";
  6691. }
  6692. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6693. }
  6694. //取得信息列表
  6695. /**
  6696. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6697. $rows = array();$list = array();
  6698. foreach ($info_list as $key=>$value)
  6699. {
  6700. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6701. }
  6702. **/
  6703. $list = array();
  6704. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6705. foreach ($rows as $key => $value) {
  6706. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6707. $zh = '';
  6708. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6709. foreach ($zt as $v) {
  6710. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6711. }
  6712. $zt = array_sum(array_column($zt, 'num'));
  6713. $number = $value['number'];
  6714. $ftime = time() - 15 * 24 * 3600;
  6715. $warehouse = $this->warehouse->read($value['warehouse']);
  6716. $rows[$key]['warehouse'] = $warehouse['title'];
  6717. $rows[$key]['number'] = $c;
  6718. $rows[$key]['features'] = $zh;
  6719. $rows[$key]['hb'] = $c + $zt;
  6720. }
  6721. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6722. $titlename = "<table border=1>
  6723. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6724. <tr align='center'>
  6725. <td>仓库</td>
  6726. <td>SKU</td>
  6727. <td>产品</td>
  6728. <td>库存数量</td>
  6729. <td>在途数量及预达日期</td>
  6730. <td>在途+库存数量</td>
  6731. </tr>
  6732. </table>";
  6733. $filename = $title . ".xls";
  6734. $tail = "";
  6735. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6736. }
  6737. if (isset($_GET['excel'])) {
  6738. $warehouse = $this->input->get('warehouse', true);
  6739. $sku = $this->input->get('sku', true);
  6740. $cz = $this->input->get('cz', true);
  6741. $text = $this->input->post('text', true);
  6742. $xztime = $this->input->get('xztime', true);
  6743. $timetk = $this->input->get('timetk', true);
  6744. $timetj = $this->input->get('timetj', true);
  6745. $timetk = strtotime($timetk);
  6746. $timetj = strtotime($timetj);
  6747. $where = "time = '0' ";
  6748. if ($warehouse) {
  6749. $where .= " and warehouse = '$warehouse'";
  6750. }
  6751. if ($sku) {
  6752. $where .= " and sku = '$sku'";
  6753. }
  6754. if ($text) {
  6755. $where .= " and text like '%$text%'";
  6756. }
  6757. if ($cz != '') {
  6758. $where .= " and cz = '$cz'";
  6759. }
  6760. if ($timetk && $timetj) {
  6761. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6762. }
  6763. //数据排序
  6764. $order_str = $xztime . " desc";
  6765. //取得信息列表
  6766. $zh = array();
  6767. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6768. foreach ($info_list as $v) {
  6769. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6770. $warehouse = $this->warehouse->read($v['warehouse']);
  6771. $v['warehouse'] = $warehouse['title'];
  6772. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6773. $v['stime'] = date('Y-m-d', $v['stime']);
  6774. if (isset($zh[$v['features']])) {
  6775. $zh[$v['features']]['num'] += $v['num'];
  6776. } else {
  6777. $zh[$v['features']] = $v;
  6778. }
  6779. $zh[$v['features']]['features'] = $c;
  6780. }
  6781. $title = "在途数据" . date('Y-m-d', time());
  6782. $titlename = "<table border=1>
  6783. <tr align='center'>
  6784. <td>仓库</td>
  6785. <td>SKU</td>
  6786. <td>名称</td>
  6787. <td>在途数量</td>
  6788. <td>库存数量</td>
  6789. <td>添加在途日期</td>
  6790. <td>预达日期</td>
  6791. <td>备注</td>
  6792. </tr>
  6793. </table>";
  6794. $filename = $title . ".xls";
  6795. $tail = "";
  6796. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6797. }
  6798. }
  6799. public function _fc()
  6800. {
  6801. $vip = 0;
  6802. if (isset($_SESSION['api'])) {
  6803. $user = $this->user->get_api($_SESSION['api']);
  6804. if ($user['vip'] == 1) {
  6805. $vip = 1;
  6806. }
  6807. } else {
  6808. header('Location: /');
  6809. exit;
  6810. }
  6811. $post = $this->input->post(NULL, TRUE);
  6812. if (isset($post['page'])) {
  6813. $page = $this->input->post('page', true);
  6814. $perpage = $this->input->post('perpage', true);
  6815. $category = $this->input->post('category', true);
  6816. $size = $this->input->post('size', true);
  6817. $grade = $this->input->post('grade', true);
  6818. $color = $this->input->post('color', true);
  6819. $lowe = $this->input->post('lowe', true);
  6820. $sku = $this->input->post('sku');
  6821. $title = $this->input->post('title');
  6822. $warehouse = $this->input->post('warehouse', true);
  6823. $usa = $this->input->post('usa', true);
  6824. $purchase = $this->input->post('purchase', true);
  6825. $lacetype = $this->input->post('lacetype', true);
  6826. $haircap = $this->input->post('haircap', true);
  6827. $density = $this->input->post('density', true);
  6828. $details = $this->input->post('details', true);
  6829. $state = $this->input->post('state', true);
  6830. $ktime = $this->input->post('ktime', true);
  6831. $jtime = $this->input->post('jtime', true);
  6832. $ktime = strtotime($ktime);
  6833. $jtime = strtotime($jtime);
  6834. $where = "state = '11'";
  6835. $gj = "";
  6836. $ck = "";
  6837. if ($lacetype) {
  6838. $where .= " and features like '%-$lacetype-%'";
  6839. }
  6840. if ($category) {
  6841. $where .= " and features like '%-$category-%'";
  6842. }
  6843. if ($size) {
  6844. $where .= " and features like '%-$size-%'";
  6845. }
  6846. if ($grade) {
  6847. $where .= " and features like '%-$grade-%'";
  6848. }
  6849. if ($color) {
  6850. $where .= " and features like '%-$color-%'";
  6851. }
  6852. if ($lowe) {
  6853. $where .= " and features like '%-$lowe-%'";
  6854. }
  6855. if ($haircap) {
  6856. $where .= " and features like '%-$haircap-%'";
  6857. }
  6858. if ($density) {
  6859. $where .= " and features like '%-$density-%'";
  6860. }
  6861. if ($usa) {
  6862. if (!$warehouse) {
  6863. $where .= " and (warehouse = '5' or warehouse = '8')";
  6864. }
  6865. }
  6866. if ($warehouse) {
  6867. $where .= " and warehouse = '$warehouse'";
  6868. }
  6869. if ($details) {
  6870. $where .= " and details = '$details'";
  6871. }
  6872. if ($purchase) {
  6873. $where .= " and purchase = '$purchase'";
  6874. }
  6875. if ($state) {
  6876. $where .= " and state = '$state'";
  6877. }
  6878. if ($ktime && $jtime) {
  6879. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6880. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6881. }
  6882. //数据排序
  6883. $order_str = "id desc";
  6884. if (empty($page)) {
  6885. $start = 0;
  6886. $perpage = 1;
  6887. } else {
  6888. $start = ($page - 1) * $perpage;
  6889. }
  6890. if ($sku) {
  6891. $sku = trim($sku, ' ');
  6892. $sku = trim($sku, ' ');
  6893. $where .= " and sku like '%$sku%'";
  6894. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6895. } else if ($title) {
  6896. $title = trim($title, ' ');
  6897. $title = trim($title, ' ');
  6898. $where .= " and title like '%$title%'";
  6899. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6900. } else {
  6901. //$where .= " and time > '$ktime' and time < '$jtime'";
  6902. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6903. }
  6904. //取得信息列表
  6905. $rows = array();
  6906. $list = array();
  6907. foreach ($info_list as $key => $value) {
  6908. $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'] . '"');
  6909. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6910. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6911. $warehouse = $this->warehouse->read($value['warehouse']);
  6912. $info_list[$key]['warehouse'] = $warehouse['title'];
  6913. $info_list[$key]['number'] = $g;
  6914. $info_list[$key]['features'] = $x;
  6915. $info_list[$key]['x'] = $s;
  6916. }
  6917. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6918. $pagenum = ceil($total / $perpage);
  6919. $over = $total - ($start + $perpage);
  6920. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6921. echo json_encode($rows);
  6922. exit;
  6923. }
  6924. $this->data['vip'] = $vip;
  6925. $this->_Template('whlabel_fc', $this->data);
  6926. }
  6927. public function _fcmb()
  6928. {
  6929. $where = "sku != 'Preset'";
  6930. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6931. foreach ($rows as $k => $v) {
  6932. $warehouse = $this->warehouse->read($v['warehouse']);
  6933. $rows[$k]['warehouse'] = $warehouse['title'];
  6934. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6935. $rows[$k]['t'] = '';
  6936. $rows[$k]['n'] = '';
  6937. }
  6938. $title = "封货产品数据导入模板";
  6939. $titlename = "<table border=1>
  6940. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6941. <tr align='center'>
  6942. <td>仓库</td>
  6943. <td>SKU</td>
  6944. <td>产品</td>
  6945. <td>封存产品总数量</td>
  6946. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6947. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6948. </tr>
  6949. </table>";
  6950. $filename = $title . ".xls";
  6951. $tail = "";
  6952. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6953. }
  6954. public function _fcexcel()
  6955. {
  6956. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6957. $config['upload_path'] = '.' . $dir;
  6958. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6959. $config['allowed_types'] = 'xls|xlsx|csv';
  6960. $config['max_size'] = 10240;
  6961. $this->load->library('upload', $config);
  6962. $this->upload->initialize($config);
  6963. if ($this->upload->do_upload('userfile')) {
  6964. $full_path = $dir . $this->upload->data('file_name');
  6965. $fileName = '.' . $full_path;
  6966. if (!file_exists($fileName)) {
  6967. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6968. exit;
  6969. } else {
  6970. libxml_use_internal_errors(true);
  6971. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6972. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6973. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6974. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6975. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6976. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6977. ++$column; //如果列数大于26行
  6978. $list = array();
  6979. for ($i = 2; $i <= $row; $i++) // 行数循环
  6980. {
  6981. $data = array();
  6982. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6983. {
  6984. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6985. }
  6986. $list[] = $data;
  6987. }
  6988. }
  6989. $i = 0;
  6990. $j = 0;
  6991. $ed = array();
  6992. foreach ($list as $key => $value) {
  6993. $time = time();
  6994. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6995. continue;
  6996. }
  6997. $warehouse = $this->warehouse->get_title($value['0']);
  6998. $sku = $value['1'];
  6999. $type = $value['4']; //调整方式0扣减1删除
  7000. $num = $value['5']; //调整数量
  7001. //$text = $value['4'];//扣减说明
  7002. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7003. if (!$d) //如果没有这个SKU
  7004. {
  7005. $ed[] = array($sku . '-库存中不存在此SKU');
  7006. $j++;
  7007. continue;
  7008. }
  7009. if (!isset($warehouse['id'])) {
  7010. $ed[] = array($sku . '-仓库名错误!');
  7011. $j++;
  7012. continue;
  7013. }
  7014. if ($type == 1 || $type == 2) //扣减库存
  7015. {
  7016. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7017. if (count($data) < abs($num)) {
  7018. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7019. $j++;
  7020. continue;
  7021. }
  7022. if ($type == 1) //转入库存
  7023. {
  7024. for ($i = 0; $i < abs($num); $i++) {
  7025. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7026. }
  7027. } else if ($type == 2) //删除
  7028. {
  7029. for ($i = 0; $i < abs($num); $i++) {
  7030. $this->whlabel->remove($data[$i]['id']);
  7031. }
  7032. }
  7033. } else if ($type == 0) //增加库存
  7034. {
  7035. $post['sku'] = $d['sku'];
  7036. $post['shop'] = '';
  7037. $post['warehouse'] = $warehouse['id'];
  7038. $post['purchase'] = $d['purchase'];
  7039. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7040. $post['state'] = 11;
  7041. $post['title'] = $d['title'];
  7042. $post['number'] = $d['number'];
  7043. $post['features'] = $d['features'];
  7044. $post['enter'] = $time;
  7045. $post['time'] = $time; //操作时间
  7046. for ($i = 0; $i < $num; $i++) {
  7047. $post['label'] = time() . rand(100, 999) . $i;
  7048. $this->whlabel->insert($post);
  7049. }
  7050. }
  7051. sleep(1); //防止入库时间一样,需要延迟1秒
  7052. }
  7053. if ($j > 0) {
  7054. $tt = date('Ymd', time());
  7055. $title = '库存导入错误信息-' . $tt;
  7056. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7057. $tail = "\n";
  7058. $filename = $title . ".xls";
  7059. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7060. $dir = '/data/excel/' . $time . '/';
  7061. $file_name = 'error_' . $time . rand(1000, 9999);
  7062. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7063. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7064. fwrite($myfile, $ecl);
  7065. fclose($myfile);
  7066. $error = $dir . $file_name . '.xls';
  7067. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7068. exit;
  7069. } else {
  7070. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7071. exit;
  7072. }
  7073. }
  7074. }
  7075. public function _fcjxc($arg_array)
  7076. {
  7077. if (isset($_GET['excel'])) {
  7078. $category = $this->input->get('category', true);
  7079. $size = $this->input->get('size', true);
  7080. $grade = $this->input->get('grade', true);
  7081. $color = $this->input->get('color', true);
  7082. $lowe = $this->input->get('lowe', true);
  7083. $sku = $this->input->get('sku');
  7084. $title = $this->input->get('title');
  7085. $warehouse = $arg_array[0];
  7086. $usa = $this->input->get('usa', true);
  7087. $purchase = $this->input->get('purchase', true);
  7088. $lacetype = $this->input->get('lacetype', true);
  7089. $haircap = $this->input->get('haircap', true);
  7090. $density = $this->input->get('density', true);
  7091. $title = $this->input->get('title', true);
  7092. $state = $this->input->get('state', true);
  7093. $ktime = $this->input->get('ktime', true);
  7094. $jtime = $this->input->get('jtime', true);
  7095. $where = "state=11";
  7096. $gj = "";
  7097. $ck = "";
  7098. if ($lacetype) {
  7099. $where .= " and features like '%-$lacetype-%'";
  7100. }
  7101. if ($category) {
  7102. $where .= " and features like '%-$category-%'";
  7103. }
  7104. if ($size) {
  7105. $where .= " and features like '%-$size-%'";
  7106. }
  7107. if ($grade) {
  7108. $where .= " and features like '%-$grade-%'";
  7109. }
  7110. if ($color) {
  7111. $where .= " and features like '%-$color-%'";
  7112. }
  7113. if ($lowe) {
  7114. $where .= " and features like '%-$lowe-%'";
  7115. }
  7116. if ($haircap) {
  7117. $where .= " and features like '%-$haircap-%'";
  7118. }
  7119. if ($density) {
  7120. $where .= " and features like '%-$density-%'";
  7121. }
  7122. if ($usa) {
  7123. if (!$warehouse) {
  7124. $where .= " and (warehouse = '5' or warehouse = '8')";
  7125. }
  7126. }
  7127. if ($warehouse) {
  7128. $where .= " and warehouse = '$warehouse'";
  7129. }
  7130. if ($purchase) {
  7131. $where .= " and purchase = '$purchase'";
  7132. }
  7133. if ($state) {
  7134. $where .= " and state = '$state'";
  7135. }
  7136. $order_str = "id desc";
  7137. if ($sku) {
  7138. $sku = trim($sku, ' ');
  7139. $sku = trim($sku, ' ');
  7140. $where .= " and sku like '%$sku%'";
  7141. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7142. } else if ($title) {
  7143. $title = trim($title, ' ');
  7144. $title = trim($title, ' ');
  7145. $where .= " and title like '%$title%'";
  7146. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7147. } else {
  7148. //$where .= " and time > '$ktime' and time < '$jtime'";
  7149. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7150. }
  7151. //取得信息列表
  7152. $rows = array();
  7153. $list = array();
  7154. foreach ($info_list as $key => $value) {
  7155. $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'] . '"');
  7156. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7157. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7158. $rows[$key] = $value;
  7159. $warehouse = $this->warehouse->read($value['warehouse']);
  7160. $rows[$key]['warehouse'] = $warehouse['title'];
  7161. $rows[$key]['features'] = $g;
  7162. $rows[$key]['a'] = $x;
  7163. $rows[$key]['b'] = $s;
  7164. }
  7165. $title = "总统计表";
  7166. $titlename = "<table border=1>
  7167. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7168. <tr align='center'>
  7169. <td>仓库</td>
  7170. <td>SKU</td>
  7171. <td>产品名称</td>
  7172. <td>录入总量</td>
  7173. <td>取出总量</td>
  7174. <td>剩余总量</td>
  7175. </tr>
  7176. </table>";
  7177. $filename = $title . ".xls";
  7178. $tail = "";
  7179. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7180. }
  7181. $vip = 0;
  7182. if (isset($_SESSION['api'])) {
  7183. $user = $this->user->get_api($_SESSION['api']);
  7184. if ($user['vip'] == 1) {
  7185. $vip = 1;
  7186. }
  7187. } else {
  7188. header('Location: /');
  7189. exit;
  7190. }
  7191. $post = $this->input->post(NULL, TRUE);
  7192. if (isset($post['page'])) {
  7193. $page = $this->input->post('page', true);
  7194. $perpage = $this->input->post('perpage', true);
  7195. $category = $this->input->post('category', true);
  7196. $size = $this->input->post('size', true);
  7197. $grade = $this->input->post('grade', true);
  7198. $color = $this->input->post('color', true);
  7199. $lowe = $this->input->post('lowe', true);
  7200. $sku = $this->input->post('sku');
  7201. $title = $this->input->post('title');
  7202. $warehouse = $arg_array[0];
  7203. $usa = $this->input->post('usa', true);
  7204. $purchase = $this->input->post('purchase', true);
  7205. $lacetype = $this->input->post('lacetype', true);
  7206. $haircap = $this->input->post('haircap', true);
  7207. $density = $this->input->post('density', true);
  7208. $title = $this->input->post('title', true);
  7209. $state = $this->input->post('state', true);
  7210. $ktime = $this->input->post('ktime', true);
  7211. $jtime = $this->input->post('jtime', true);
  7212. $ktime = strtotime($ktime);
  7213. $jtime = strtotime($jtime);
  7214. $where = "state=11";
  7215. $gj = "";
  7216. $ck = "";
  7217. if ($lacetype) {
  7218. $where .= " and features like '%-$lacetype-%'";
  7219. }
  7220. if ($category) {
  7221. $where .= " and features like '%-$category-%'";
  7222. }
  7223. if ($size) {
  7224. $where .= " and features like '%-$size-%'";
  7225. }
  7226. if ($grade) {
  7227. $where .= " and features like '%-$grade-%'";
  7228. }
  7229. if ($color) {
  7230. $where .= " and features like '%-$color-%'";
  7231. }
  7232. if ($lowe) {
  7233. $where .= " and features like '%-$lowe-%'";
  7234. }
  7235. if ($haircap) {
  7236. $where .= " and features like '%-$haircap-%'";
  7237. }
  7238. if ($density) {
  7239. $where .= " and features like '%-$density-%'";
  7240. }
  7241. if ($usa) {
  7242. if (!$warehouse) {
  7243. $where .= " and (warehouse = '5' or warehouse = '8')";
  7244. }
  7245. }
  7246. if ($warehouse) {
  7247. $where .= " and warehouse = '$warehouse'";
  7248. }
  7249. if ($purchase) {
  7250. $where .= " and purchase = '$purchase'";
  7251. }
  7252. if ($state) {
  7253. $where .= " and state = '$state'";
  7254. }
  7255. if ($ktime && $jtime) {
  7256. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7257. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7258. }
  7259. //数据排序
  7260. $order_str = "id desc";
  7261. $xs = 0;
  7262. $rows = array();
  7263. $list = array();
  7264. if (empty($page)) {
  7265. $start = 0;
  7266. $perpage = 1;
  7267. } else {
  7268. $start = ($page - 1) * $perpage;
  7269. }
  7270. if ($sku || $title) {
  7271. if ($title) {
  7272. $title = trim($title, ' ');
  7273. $title = trim($title, ' ');
  7274. $where .= " and title like '%$title%'";
  7275. } else {
  7276. $sku = trim($sku, ' ');
  7277. $sku = trim($sku, ' ');
  7278. $where .= " and sku like '%$sku%'";
  7279. }
  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. $rows[$key] = $value;
  7286. $warehouse = $this->warehouse->read($value['warehouse']);
  7287. $rows[$key]['warehouse'] = $warehouse['title'];
  7288. $rows[$key]['features'] = $g;
  7289. $rows[$key]['a'] = $x;
  7290. $rows[$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. $rows[$key]['y'] = round($yj) . '天销量';
  7296. } else {
  7297. $rows[$key]['y'] = '正常';
  7298. }
  7299. }
  7300. } else {
  7301. //$where .= " and time > '$ktime' and time < '$jtime'";
  7302. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7303. foreach ($info_list as $key => $value) {
  7304. $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'] . '"');
  7305. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7306. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7307. $zs[$key] = $value;
  7308. $warehouse = $this->warehouse->read($value['warehouse']);
  7309. $zs[$key]['warehouse'] = $warehouse['title'];
  7310. $zs[$key]['features'] = $g;
  7311. $zs[$key]['a'] = $x;
  7312. $zs[$key]['b'] = $s;
  7313. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7314. $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天销量
  7315. $yj = $c / ($xl / 30);
  7316. if ($yj < 7) {
  7317. $zs[$key]['y'] = round($yj) . '天销量';
  7318. $rows[$key] = $zs[$key];
  7319. }
  7320. }
  7321. }
  7322. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7323. $pagenum = ceil($total / $perpage);
  7324. $over = $total - ($start + $perpage);
  7325. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7326. echo json_encode($rows);
  7327. exit;
  7328. }
  7329. $this->data['arg_array'] = $arg_array[0];
  7330. $this->_Template('whlabel_fcjxc', $this->data);
  7331. }
  7332. public function _0kcdel()
  7333. {
  7334. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7335. $config['upload_path'] = '.' . $dir;
  7336. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7337. $config['allowed_types'] = 'xls|xlsx|csv';
  7338. $config['max_size'] = 10240;
  7339. $this->load->library('upload', $config);
  7340. $this->upload->initialize($config);
  7341. if ($this->upload->do_upload('userfile')) {
  7342. $full_path = $dir . $this->upload->data('file_name');
  7343. $fileName = '.' . $full_path;
  7344. if (!file_exists($fileName)) {
  7345. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7346. exit;
  7347. } else {
  7348. require_once "./data/excel/PHPExcel/IOFactory.php";
  7349. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7350. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7351. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7352. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7353. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7354. ++$column; //如果列数大于26行
  7355. $list = array();
  7356. for ($i = 2; $i <= $row; $i++) // 行数循环
  7357. {
  7358. $data = array();
  7359. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7360. {
  7361. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7362. }
  7363. $list[] = $data;
  7364. }
  7365. }
  7366. $i = 0;
  7367. $j = 0;
  7368. $ed = array();
  7369. foreach ($list as $key => $value) {
  7370. $time = time();
  7371. if ($value['0'] == "" || $value['1'] == "") {
  7372. continue;
  7373. }
  7374. $warehouse = $this->warehouse->get_title($value['0']);
  7375. $sku = $value['1'];
  7376. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7377. if (!$d) //如果没有这个SKU
  7378. {
  7379. $ed[] = array($sku . '-库存中不存在此SKU');
  7380. $j++;
  7381. continue;
  7382. }
  7383. if (!isset($warehouse['id'])) {
  7384. $ed[] = array($sku . '-仓库名错误!');
  7385. $j++;
  7386. continue;
  7387. }
  7388. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7389. if ($z < 1) {
  7390. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7391. foreach ($z as $v) {
  7392. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7393. if (count($zt) > 0) {
  7394. $ed[] = array($sku . '-有在途库存无法删除!');
  7395. $j++;
  7396. continue;
  7397. }
  7398. $this->whlabel->remove($v['id']);
  7399. }
  7400. } else {
  7401. $ed[] = array($sku . '-非0库存!');
  7402. $j++;
  7403. continue;
  7404. }
  7405. }
  7406. if ($j > 0) {
  7407. $tt = date('Ymd', time());
  7408. $title = '删除0库存错误信息-' . $tt;
  7409. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7410. $tail = "\n";
  7411. $filename = $title . ".xls";
  7412. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7413. $dir = '/data/excel/' . $time . '/';
  7414. $file_name = 'error_' . $time . rand(1000, 9999);
  7415. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7416. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7417. fwrite($myfile, $ecl);
  7418. fclose($myfile);
  7419. $error = $dir . $file_name . '.xls';
  7420. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7421. exit;
  7422. } else {
  7423. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7424. exit;
  7425. }
  7426. }
  7427. }
  7428. public function _gbhtype()
  7429. {
  7430. $post = $this->input->post(NULL, TRUE);
  7431. if (isset($post['s'])) {
  7432. $n = $this->input->post('n');
  7433. $d = $this->input->post('s');
  7434. if (!$d) {
  7435. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7436. exit;
  7437. }
  7438. $d = explode(',', trim($d, ','));
  7439. $t = $this->whlabel_type->read($n);
  7440. //循环删除记录
  7441. foreach ($d as $v) {
  7442. $u = $this->whlabel->read($v);
  7443. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7444. foreach ($data as $val) {
  7445. $this->whlabel->save(array('type' => $n), $val['id']);
  7446. }
  7447. }
  7448. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7449. }
  7450. }
  7451. //出库、退库导出
  7452. public function _dccrtype()
  7453. {
  7454. $classid = $this->classid->sku();
  7455. $pm = $classid;
  7456. $typeclass = array();
  7457. $tc = $this->typeclass->find_all();
  7458. foreach ($tc as $v) {
  7459. $typeclass[$v['id']] = $v;
  7460. }
  7461. $prc = array();
  7462. $purchase = $this->purchase->find_all();
  7463. foreach ($purchase as $k => $v) {
  7464. $prc[$v['id']] = $v['title'];
  7465. }
  7466. if (isset($_GET['sid'])) {
  7467. $wh = array();
  7468. $w = $this->warehouse->find_all('1=1', 'id,title');
  7469. foreach ($w as $v) {
  7470. $wh[$v['id']] = $v['title'];
  7471. }
  7472. $type = $this->input->get('excel', true);
  7473. $category = $this->input->get('category', true);
  7474. $size = $this->input->get('size', true);
  7475. $grade = $this->input->get('grade', true);
  7476. $color = $this->input->get('color', true);
  7477. $lowe = $this->input->get('lowe', true);
  7478. $sku = $this->input->get('sku', true);
  7479. $warehouse = $this->input->get('warehouse', true);
  7480. $lacetype = $this->input->get('lacetype', true);
  7481. $lacecolor = $this->input->get('lacecolor', true);
  7482. $density = $this->input->get('density', true);
  7483. $haircap = $this->input->get('haircap', true);
  7484. $purchase = $this->input->get('purchase', true);
  7485. $title = $this->input->get('title', true);
  7486. $state = $this->input->get('state', true);
  7487. $sid = $this->input->get('sid', true);
  7488. $ktime = $this->input->get('ktime', true);
  7489. $jtime = $this->input->get('jtime', true);
  7490. $ktime = strtotime($ktime);
  7491. $jtime = strtotime($jtime);
  7492. $where = "1=1";
  7493. $gj = "";
  7494. $ck = "";
  7495. if ($category) {
  7496. $where .= " and features like '%-$category-%'";
  7497. }
  7498. if ($size) {
  7499. $where .= " and features like '%-$size-%'";
  7500. }
  7501. if ($grade) {
  7502. $where .= " and features like '%-$grade-%'";
  7503. }
  7504. if ($color) {
  7505. $where .= " and features like '%-$color-%'";
  7506. }
  7507. if ($lowe) {
  7508. $where .= " and features like '%-$lowe-%'";
  7509. }
  7510. if ($warehouse) {
  7511. $where .= " and warehouse = '$warehouse'";
  7512. }
  7513. if ($purchase) {
  7514. $where .= " and purchase = '$purchase'";
  7515. }
  7516. if ($state) {
  7517. $where .= " and state = '$state'";
  7518. }
  7519. if ($lacetype) {
  7520. $where .= " and features like '%-$lacetype-%'";
  7521. }
  7522. if ($lacecolor) {
  7523. $where .= " and features like '%-$lacecolor-%'";
  7524. }
  7525. if ($density) {
  7526. $where .= " and features like '%-$density-%'";
  7527. }
  7528. if ($haircap) {
  7529. $where .= " and features like '%-$haircap-%'";
  7530. }
  7531. if ($title) {
  7532. $title = trim($title, ' ');
  7533. $title = trim($title, ' ');
  7534. $where .= " and title like '%$title%'";
  7535. }
  7536. if ($sku) {
  7537. $sku = trim($sku, ' ');
  7538. $sku = trim($sku, ' ');
  7539. $where .= " and sku like '%$sku%'";
  7540. }
  7541. if ($ktime && $jtime) {
  7542. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7543. }
  7544. $sidwhere = '';
  7545. if ($sid) {
  7546. $sd = "";
  7547. $s = explode(',', trim($sid, ','));
  7548. foreach ($s as $value) {
  7549. $sd .= " id = " . $value . " or";
  7550. }
  7551. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7552. }
  7553. //数据排序
  7554. $order_str = "time desc";
  7555. if (empty($page)) {
  7556. $start = 0;
  7557. $perpage = 1;
  7558. } else {
  7559. $start = ($page - 1) * $perpage;
  7560. }
  7561. $wh = array();
  7562. $w = $this->warehouse->find_all('1=1', 'id,title');
  7563. foreach ($w as $v) {
  7564. $wh[$v['id']] = $v['title'];
  7565. }
  7566. $wt = array();
  7567. $whlabel_type = $this->whlabel_type->find_all();
  7568. foreach ($whlabel_type as $v) {
  7569. $wt[$v['id']] = $v['title'];
  7570. }
  7571. $classid = $this->classid->sku();
  7572. $list = array();
  7573. $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');
  7574. foreach ($rows_r as $key => $value) {
  7575. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7576. $pm = $classid;
  7577. $jm = $classid;
  7578. $rows_r[$key]['enter'] = '入库';
  7579. $rows_r[$key]['time'] = $value['enter'];
  7580. if ($value['rktype'] == 1) {
  7581. $rows_r[$key]['rktype'] = '采购入库';
  7582. } else if ($value['rktype'] == 2) {
  7583. $rows_r[$key]['rktype'] = '盘盈调整';
  7584. } else if ($value['rktype'] == 3) {
  7585. $rows_r[$key]['rktype'] = '其他调整入库';
  7586. } else if ($value['rktype'] == 4) {
  7587. $rows_r[$key]['rktype'] = '其他调整入库';
  7588. } else if ($value['rktype'] == 5) {
  7589. $rows_r[$key]['rktype'] = '退库入库';
  7590. } else if ($value['rktype'] == 6) {
  7591. $rows_r[$key]['rktype'] = '退货可用入库';
  7592. } else if ($value['rktype'] == 7) {
  7593. $rows_r[$key]['rktype'] = '形态转换入库';
  7594. } else {
  7595. $rows_r[$key]['rktype'] = '';
  7596. }
  7597. $features = explode('-', trim($value['features'], '-'));
  7598. foreach ($features as $v) {
  7599. if (isset($typeclass[$v])) {
  7600. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7601. $pm[$typeclass[$v]['classid']] = $zh[0];
  7602. }
  7603. if (isset($typeclass[$v])) {
  7604. if (isset($jm[$typeclass[$v]['classid']])) {
  7605. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7606. }
  7607. }
  7608. }
  7609. $zh = implode(" ", $pm);
  7610. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7611. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7612. $rows_r[$key]['zh'] = $zh;
  7613. $jm = array_filter($jm);
  7614. $rows_r[$key]['features'] = implode("-", $jm);
  7615. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7616. }
  7617. $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');
  7618. foreach ($rows_c as $key => $value) {
  7619. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7620. $pm = $classid;
  7621. $jm = $classid;
  7622. $rows_c[$key]['time'] = $value['outk'];
  7623. $rows_c[$key]['outk'] = '出库';
  7624. if ($value['cktype'] == 1) {
  7625. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7626. } else if ($value['cktype'] == 2) {
  7627. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7628. } else if ($value['cktype'] == 3) {
  7629. $rows_c[$key]['cktype'] = '盘亏调整';
  7630. } else if ($value['cktype'] == 4) {
  7631. $rows_c[$key]['cktype'] = '其他调整出库';
  7632. } else if ($value['cktype'] == 5) {
  7633. $rows_c[$key]['cktype'] = '形态转换出库';
  7634. } else {
  7635. $rows_c[$key]['cktype'] = '';
  7636. }
  7637. unset($rows_c[$key]['state']);
  7638. $features = explode('-', trim($value['features'], '-'));
  7639. foreach ($features as $v) {
  7640. if (isset($typeclass[$v])) {
  7641. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7642. $pm[$typeclass[$v]['classid']] = $zh[0];
  7643. }
  7644. if (isset($typeclass[$v])) {
  7645. if (isset($jm[$typeclass[$v]['classid']])) {
  7646. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7647. }
  7648. }
  7649. }
  7650. $zh = implode(" ", $pm);
  7651. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7652. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7653. $rows_c[$key]['zh'] = $zh;
  7654. $jm = array_filter($jm);
  7655. $rows_c[$key]['features'] = implode("-", $jm);
  7656. $rows_c[$key]['number'] = 1;
  7657. }
  7658. $merged = $rows_r;
  7659. foreach ($rows_c as $key => $value) {
  7660. if (isset($merged[$key])) {
  7661. $merged[] = $value;
  7662. } else {
  7663. $merged[$key] = $value;
  7664. }
  7665. }
  7666. usort($merged, function ($a, $b) {
  7667. return $a['time'] - $b['time'];
  7668. });
  7669. foreach ($merged as $key => $value) {
  7670. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7671. }
  7672. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7673. $titlename = "<table border=1>
  7674. <tr align='center'>
  7675. <td>仓库</td>
  7676. <td>SKU</td>
  7677. <td>商品名称</td>
  7678. <td>仓库品名</td>
  7679. <td>料号</td>
  7680. <td>时间</td>
  7681. <td>操作</td>
  7682. <td>类型</td>
  7683. <td>数量</td>
  7684. <td>备注</td>
  7685. </tr>
  7686. </table>";
  7687. $filename = $title . ".xlsx";
  7688. $tail = "";
  7689. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  7690. }
  7691. }
  7692. /*************************************处理exceljs导出****************************************************/
  7693. public function _excelrjs(){
  7694. if (isset($_GET['excel'])) {
  7695. $category = $this->input->get('category', true);
  7696. $size = $this->input->get('size', true);
  7697. $grade = $this->input->get('grade', true);
  7698. $color = $this->input->get('color', true);
  7699. $lowe = $this->input->get('lowe', true);
  7700. $sku = $this->input->get('sku', true);
  7701. $warehouse = $this->input->get('warehouse', true);
  7702. $purchase = $this->input->get('purchase', true);
  7703. $ktime = $this->input->get('ktime', true);
  7704. $jtime = $this->input->get('jtime', true);
  7705. $ktime = strtotime($ktime);
  7706. $jtime = strtotime($jtime);
  7707. $where = "1=1";
  7708. $gj = "";
  7709. $ck = "";
  7710. if ($category) {
  7711. $where .= " and features like '%-$category-%'";
  7712. }
  7713. if ($size) {
  7714. $where .= " and features like '%-$size-%'";
  7715. }
  7716. if ($grade) {
  7717. $where .= " and features like '%-$grade-%'";
  7718. }
  7719. if ($color) {
  7720. $where .= " and features like '%-$color-%'";
  7721. }
  7722. if ($lowe) {
  7723. $where .= " and features like '%-$lowe-%'";
  7724. }
  7725. if ($warehouse) {
  7726. $where .= " and warehouse = '$warehouse'";
  7727. }
  7728. if ($purchase) {
  7729. $where .= " and purchase = '$purchase'";
  7730. }
  7731. if ($sku) {
  7732. $where .= " and sku = '$sku'";
  7733. }
  7734. if ($ktime && $jtime) {
  7735. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7736. }
  7737. //数据排序
  7738. $order_str = "id desc";
  7739. if (empty($page)) {
  7740. $start = 0;
  7741. $perpage = 1;
  7742. } else {
  7743. $start = ($page - 1) * $perpage;
  7744. }
  7745. $list = array();
  7746. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7747. foreach ($rows as $value) {
  7748. $ck = $this->warehouse->read($value['warehouse']);
  7749. $warehouse = $ck['title'];
  7750. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7751. $retreatwarehouse = $tkck['title'];
  7752. $gy = $this->purchase->read($value['purchase']);
  7753. $purchase = $gy['title'];
  7754. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7755. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7756. }
  7757. if(empty($list)){
  7758. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7759. }else{
  7760. $final_list = [];
  7761. foreach($list as $v){
  7762. $final_list[] = array_values($v);
  7763. }
  7764. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7765. array_unshift($final_list,[
  7766. "仓库","SKU","商品名称","时间","数量"
  7767. ]);
  7768. array_unshift($final_list,[
  7769. $title,"","","",""
  7770. ]);
  7771. $merges = [
  7772. [
  7773. "s"=>["r"=>0,"c"=>0],
  7774. "e"=>["r"=>0,"c"=>4]
  7775. ]
  7776. ];
  7777. $cols = [
  7778. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7779. ];
  7780. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7781. }
  7782. }
  7783. }
  7784. //出库、退库导出
  7785. public function _excelctjs()
  7786. {
  7787. $classid = $this->classid->sku();
  7788. $pm = $classid;
  7789. $typeclass = array();
  7790. $tc = $this->typeclass->find_all();
  7791. foreach ($tc as $v) {
  7792. $typeclass[$v['id']] = $v;
  7793. }
  7794. $prc = array();
  7795. $purchase = $this->purchase->find_all();
  7796. foreach ($purchase as $k => $v) {
  7797. $prc[$v['id']] = $v['title'];
  7798. }
  7799. if (isset($_GET['excel'])) {
  7800. $wh = array();
  7801. $w = $this->warehouse->find_all('1=1', 'id,title');
  7802. foreach ($w as $v) {
  7803. $wh[$v['id']] = $v['title'];
  7804. }
  7805. $type = $this->input->get('excel', true);
  7806. $category = $this->input->get('category', true);
  7807. $size = $this->input->get('size', true);
  7808. $grade = $this->input->get('grade', true);
  7809. $color = $this->input->get('color', true);
  7810. $lowe = $this->input->get('lowe', true);
  7811. $sku = $this->input->get('sku', true);
  7812. $title = $this->input->get('title', true);
  7813. $warehouse = $this->input->get('warehouse', true);
  7814. $purchase = $this->input->get('purchase', true);
  7815. $lacetype = $this->input->get('lacetype', true);
  7816. $haircap = $this->input->get('haircap', true);
  7817. $lacecolor = $this->input->get('lacecolor', true);
  7818. $density = $this->input->get('density', true);
  7819. $details = $this->input->get('details', true);
  7820. $state = $this->input->get('state', true);
  7821. $shop = $this->input->get('shop', true);
  7822. $hairnumber = $this->input->get('hairnumber', true);
  7823. $type_leixi = $this->input->get('type', true);
  7824. $cpbz = $this->input->get('cpbz', true);
  7825. $sm = $this->input->get('sm', true);
  7826. $sid = $this->input->get('sid', true);
  7827. $ktime = $this->input->get('ktime', true);
  7828. $jtime = $this->input->get('jtime', true);
  7829. $ktime = strtotime($ktime);
  7830. $jtime = strtotime($jtime);
  7831. //$where = " 1=1 ";
  7832. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7833. $where = " sku != '' ";
  7834. $gj = "";
  7835. $ck = "";
  7836. if ($category) {
  7837. $where .= " and features like '%-$category-%'";
  7838. }
  7839. if ($size) {
  7840. $where .= " and features like '%-$size-%'";
  7841. }
  7842. if ($grade) {
  7843. $where .= " and features like '%-$grade-%'";
  7844. }
  7845. if ($color) {
  7846. $where .= " and features like '%-$color-%'";
  7847. }
  7848. if ($lowe) {
  7849. $where .= " and features like '%-$lowe-%'";
  7850. }
  7851. if ($warehouse) {
  7852. $where .= " and warehouse = '$warehouse'";
  7853. }
  7854. if ($purchase) {
  7855. $where .= " and purchase = '$purchase'";
  7856. }
  7857. if ($state) {
  7858. $where .= " and state = '$state'";
  7859. }
  7860. if ($lacetype) {
  7861. $where .= " and features like '%-$lacetype-%'";
  7862. }
  7863. if ($lacecolor) {
  7864. $where .= " and features like '%-$lacecolor-%'";
  7865. }
  7866. if ($density) {
  7867. $where .= " and features like '%-$density-%'";
  7868. }
  7869. if ($haircap) {
  7870. $where .= " and features like '%-$haircap-%'";
  7871. }
  7872. if ($details) {
  7873. $where .= " and details = '$details'";
  7874. }
  7875. if ($shop) {
  7876. $where .= " and shop like '%$shop%'";
  7877. }
  7878. if ($title) {
  7879. $title = trim($title, ' ');
  7880. $title = trim($title, ' ');
  7881. $where .= " and title like '%$title%'";
  7882. }
  7883. if (!empty($hairnumber)) {
  7884. $where .= " and features like '%-128-%' ";
  7885. if ($hairnumber < 0) {
  7886. $class_list = $this->typeclass->find_all('classid = 43');
  7887. foreach ($class_list as $v) {
  7888. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7889. }
  7890. } else {
  7891. $where .= " and features like '%-$hairnumber-%'";
  7892. }
  7893. }
  7894. if ($type_leixi) {
  7895. $where .= " and type = '$type_leixi'";
  7896. }
  7897. if ($cpbz) {
  7898. $where .= " and cpbz like '%$cpbz%' ";
  7899. }
  7900. if ($sm) {
  7901. $where .= " and sm like '%$sm%' ";
  7902. }
  7903. if ($sku) {
  7904. $sku = trim($sku, ' ');
  7905. $sku = trim($sku, ' ');
  7906. $where .= " and sku like '%$sku%'";
  7907. }
  7908. if ($ktime && $jtime) {
  7909. if ($type == 1) {
  7910. $tl = '出库';
  7911. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7912. } else if ($type == 2) {
  7913. $tl = '退库';
  7914. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7915. } else if ($type == 3) {
  7916. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7917. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7918. } else if ($type == 4) {
  7919. $tl = '出库+零售';
  7920. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7921. } else if ($type == 5) {
  7922. $tl = '零售';
  7923. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7924. }
  7925. }
  7926. $sidwhere = '';
  7927. if ($sid) {
  7928. $sd = "";
  7929. $s = explode(',', trim($sid, ','));
  7930. foreach ($s as $value) {
  7931. $sd .= " id = " . $value . " or";
  7932. }
  7933. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7934. }
  7935. //数据排序
  7936. $order_str = "time desc";
  7937. if (empty($page)) {
  7938. $start = 0;
  7939. $perpage = 1;
  7940. } else {
  7941. $start = ($page - 1) * $perpage;
  7942. }
  7943. //取得信息列表
  7944. if ($type != 3 && $type != 5) {
  7945. if ($type == 1 || $type == 4) {
  7946. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7947. foreach ($info_list as $key => $value) {
  7948. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7949. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7950. $warehouse = $this->warehouse->read($value['warehouse']);
  7951. $info_list[$key]['warehouse'] = $warehouse['title'];
  7952. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7953. $features = explode('-', trim($features, '-'));
  7954. $pm = $classid;
  7955. foreach ($features as $k => $v) {
  7956. if ($v != 0) {
  7957. if (!isset($typeclass[$v])) {
  7958. continue;
  7959. }
  7960. if (isset($pm[$typeclass[$v]['classid']])) {
  7961. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7962. $tz = explode('|', $typeclass[$v]['zh']);
  7963. $pm[$typeclass[$v]['classid']] = $tz[0];
  7964. } else {
  7965. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7966. }
  7967. }
  7968. }
  7969. }
  7970. $zh = implode(" ", $pm);
  7971. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7972. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7973. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7974. $info_list[$key]['features'] = $zh;
  7975. }
  7976. $final_list = [];
  7977. foreach($info_list as $k=>$v){
  7978. $number = "";
  7979. if(!empty($v['orderinfo'])){
  7980. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7981. if(!empty($tmp_info['number'])){
  7982. $number = $tmp_info['number'];
  7983. }
  7984. }
  7985. $final_list[] = [
  7986. 'warehouse'=>$v['warehouse'],
  7987. 'purchase'=>$v['purchase'],
  7988. 'sku'=>$v['sku'],
  7989. 'title'=>$v['title'],
  7990. 'features'=>$v['features'],
  7991. 'label'=>$v['label'],
  7992. 'orderinfo'=>$v['orderinfo'],
  7993. 'number'=>$number,
  7994. 'waybill'=>$v['waybill'],
  7995. 'outk'=>$v['outk'],
  7996. ];
  7997. }
  7998. } else {
  7999. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  8000. foreach ($info_list as $key => $value) {
  8001. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8002. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8003. $warehouse = $this->warehouse->read($value['warehouse']);
  8004. $info_list[$key]['warehouse'] = $warehouse['title'];
  8005. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8006. $features = explode('-', trim($features, '-'));
  8007. $pm = $classid;
  8008. foreach ($features as $k => $v) {
  8009. if ($v != 0) {
  8010. if (!isset($typeclass[$v])) {
  8011. continue;
  8012. }
  8013. if (isset($pm[$typeclass[$v]['classid']])) {
  8014. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8015. $tz = explode('|', $typeclass[$v]['zh']);
  8016. $pm[$typeclass[$v]['classid']] = $tz[0];
  8017. } else {
  8018. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8019. }
  8020. }
  8021. }
  8022. }
  8023. $zh = implode(" ", $pm);
  8024. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8025. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8026. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8027. $info_list[$key]['features'] = $zh;
  8028. }
  8029. $final_list = [];
  8030. foreach($info_list as $k=>$v){
  8031. $number = "";
  8032. if(!empty($v['orderinfo'])){
  8033. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8034. if(!empty($tmp_info['number'])){
  8035. $number = $tmp_info['number'];
  8036. }
  8037. }
  8038. $final_list[] = [
  8039. 'warehouse'=>$v['warehouse'],
  8040. 'purchase'=>$v['purchase'],
  8041. 'sku'=>$v['sku'],
  8042. 'title'=>$v['title'],
  8043. 'features'=>$v['features'],
  8044. 'label'=>$v['label'],
  8045. 'orderinfo'=>$v['orderinfo'],
  8046. 'number'=>$number,
  8047. 'waybill'=>$v['waybill'],
  8048. 'retreat'=>$v['retreat'],
  8049. ];
  8050. }
  8051. }
  8052. if(empty($final_list)){
  8053. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8054. }else{
  8055. $end_list = [];
  8056. foreach($final_list as $v){
  8057. $end_list[] = array_values($v);
  8058. }
  8059. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8060. array_unshift($end_list,[
  8061. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8062. ]);
  8063. array_unshift($end_list,[
  8064. $title,"","","","","","","","",""
  8065. ]);
  8066. $merges = [
  8067. [
  8068. "s"=>["r"=>0,"c"=>0],
  8069. "e"=>["r"=>0,"c"=>9]
  8070. ]
  8071. ];
  8072. $cols = [
  8073. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8074. ];
  8075. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8076. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8077. ] )));
  8078. }
  8079. } else if ($type == 5) {
  8080. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8081. foreach ($info_list as $key => $value) {
  8082. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8083. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8084. $warehouse = $this->warehouse->read($value['warehouse']);
  8085. $info_list[$key]['warehouse'] = $warehouse['title'];
  8086. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8087. $features = explode('-', trim($features, '-'));
  8088. $pm = $classid;
  8089. foreach ($features as $k => $v) {
  8090. if ($v != 0) {
  8091. if (!isset($typeclass[$v])) {
  8092. continue;
  8093. }
  8094. if (isset($pm[$typeclass[$v]['classid']])) {
  8095. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8096. $tz = explode('|', $typeclass[$v]['zh']);
  8097. $pm[$typeclass[$v]['classid']] = $tz[0];
  8098. } else {
  8099. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8100. }
  8101. }
  8102. }
  8103. }
  8104. $zh = implode(" ", $pm);
  8105. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8106. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8107. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8108. $info_list[$key]['features'] = $zh;
  8109. }
  8110. if(empty($info_list)){
  8111. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8112. }else{
  8113. $final_list = [];
  8114. foreach($info_list as $v){
  8115. $final_list[] = array_values($v);
  8116. }
  8117. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8118. array_unshift($final_list,[
  8119. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8120. ]);
  8121. array_unshift($final_list,[
  8122. $title,"","","","","","",
  8123. ]);
  8124. $merges = [
  8125. [
  8126. "s"=>["r"=>0,"c"=>0],
  8127. "e"=>["r"=>0,"c"=>6]
  8128. ]
  8129. ];
  8130. $cols = [
  8131. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8132. ];
  8133. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8134. }
  8135. } else {
  8136. $wh = array();
  8137. $w = $this->warehouse->find_all('1=1', 'id,title');
  8138. foreach ($w as $v) {
  8139. $wh[$v['id']] = $v['title'];
  8140. }
  8141. $wt = array();
  8142. $whlabel_type = $this->whlabel_type->find_all();
  8143. foreach ($whlabel_type as $v) {
  8144. $wt[$v['id']] = $v['title'];
  8145. }
  8146. $classid = $this->classid->sku();
  8147. $list = array();
  8148. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8149. foreach ($rows as $key => $value) {
  8150. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8151. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8152. $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');
  8153. $details = array();
  8154. $cpid = array();
  8155. $cpbz = array();
  8156. $c = 0;
  8157. $g = 0;
  8158. $x = 0;
  8159. $t = 0;
  8160. $s = 0;
  8161. $q = 0;
  8162. foreach ($sd as $k => $v) {
  8163. if ($v['state'] == 0) {
  8164. $c++;
  8165. }
  8166. if ($v['state'] != 9) {
  8167. $g++;
  8168. }
  8169. if ($v['outk'] > 1) {
  8170. $x++;
  8171. }
  8172. if ($v['retreat'] > 0) {
  8173. $t++;
  8174. }
  8175. if ($v['state'] == 8) {
  8176. $s++;
  8177. }
  8178. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8179. $q++;
  8180. }
  8181. $details[$v['details']] = $v['details'];
  8182. if ($v['cpid'] != 0) {
  8183. $cpid[$v['cpid']] = $v['cpid'];
  8184. }
  8185. if ($v['cpbz'] != '') {
  8186. $cpbz[$v['cpbz']] = $v['cpbz'];
  8187. }
  8188. }
  8189. if (isset($wt[$value['type']])) {
  8190. $rows[$key]['type'] = $wt[$value['type']];
  8191. } else {
  8192. $rows[$key]['type'] = '未设置';
  8193. }
  8194. $rows[$key]['details'] = implode("、", $details);
  8195. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8196. $ftime = time() - 15 * 24 * 3600;
  8197. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8198. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8199. $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);
  8200. $rows[$key]['c'] = $c;
  8201. $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);
  8202. $rows[$key]['t'] = $t;
  8203. $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'] . '"');
  8204. $rows[$key]['z'] = $z;
  8205. // $jm = $classid;
  8206. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8207. $features = explode('-', trim($features, '-'));
  8208. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8209. }
  8210. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8211. $final_list =[];
  8212. foreach($tmp_list as $k=>$v){
  8213. $final_list[] = [
  8214. "warehouse"=>$v['warehouse'],
  8215. "purchase"=>$v['purchase'],
  8216. "details"=>$v['details'],
  8217. "cpid"=>$v['cpid'],
  8218. "sku"=>$v['sku'],
  8219. "title"=>$v['title'],
  8220. "features"=>$v['pm'],
  8221. "cpbz"=>$v['cpbz'],
  8222. "sm"=>$v['sm'],
  8223. "type"=>$v['type'],
  8224. "g"=>$v["g"],
  8225. "c"=>$v["c"],
  8226. "x"=>$v["x"],
  8227. "t"=>$v["t"],
  8228. "z"=>$v["z"],
  8229. "jm"=>$v["jm"],
  8230. "weight"=>$v["weight"],
  8231. "asd"=>$v["asd"],
  8232. ];
  8233. }
  8234. if(empty($final_list)){
  8235. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8236. }else{
  8237. $end_list = [];
  8238. foreach($final_list as $v){
  8239. $end_list[] = array_values($v);
  8240. }
  8241. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8242. array_unshift($end_list,[
  8243. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8244. ]);
  8245. array_unshift($end_list,[
  8246. $title,"","","","","","","","","","","","","","","","","",""
  8247. ]);
  8248. $merges = [
  8249. [
  8250. "s"=>["r"=>0,"c"=>0],
  8251. "e"=>["r"=>0,"c"=>6]
  8252. ]
  8253. ];
  8254. $cols = [
  8255. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8256. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8257. ];
  8258. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8259. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8260. ])));
  8261. }
  8262. }
  8263. }
  8264. }
  8265. public function _exceljxcjs(){
  8266. $classid = $this->classid->sku();
  8267. $pm = $classid;
  8268. $typeclass = array();
  8269. $tc = $this->typeclass->find_all();
  8270. foreach ($tc as $v) {
  8271. $typeclass[$v['id']] = $v;
  8272. }
  8273. $prc = array();
  8274. $purchase = $this->purchase->find_all();
  8275. foreach ($purchase as $k => $v) {
  8276. $prc[$v['id']] = $v['title'];
  8277. }
  8278. if(!isset($_GET['excel'])){
  8279. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8280. }
  8281. $where = "sku != 'Preset'";
  8282. //数据排序
  8283. $order_str = "id desc";
  8284. if (empty($page)) {
  8285. $start = 0;
  8286. $perpage = 1;
  8287. } else {
  8288. $start = ($page - 1) * $perpage;
  8289. }
  8290. $category = $this->input->get('category', true);
  8291. $warehouse = $this->input->get('warehouse', true);
  8292. $excelid = $this->input->get('sid', true);
  8293. if ($category) {
  8294. $where .= " and features like '%-$category-%'";
  8295. }
  8296. if ($warehouse) {
  8297. $where .= " and warehouse = '$warehouse'";
  8298. }
  8299. $xzid = '';
  8300. if ($excelid) {
  8301. $excelid = explode(',', trim($excelid, ','));
  8302. foreach ($excelid as $key => $value) {
  8303. $xzid .= " id = " . $value . " or";
  8304. }
  8305. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8306. }
  8307. $wt = array();
  8308. $whlabel_type = $this->whlabel_type->find_all();
  8309. foreach ($whlabel_type as $v) {
  8310. $wt[$v['id']] = $v['title'];
  8311. }
  8312. $wh = array();
  8313. $w = $this->warehouse->find_all('1=1', 'id,title');
  8314. foreach ($w as $v) {
  8315. $wh[$v['id']] = $v['title'];
  8316. }
  8317. $list = array();
  8318. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8319. foreach ($rows as $key => $value) {
  8320. if (isset($wt[$value['type']])) {
  8321. $rows[$key]['type'] = $wt[$value['type']];
  8322. } else {
  8323. $rows[$key]['type'] = '未设置';
  8324. }
  8325. $bm = '03';
  8326. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8327. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8328. $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');
  8329. $details = array();
  8330. $cpid = array();
  8331. $cpbz = array();
  8332. $c = 0;
  8333. $g = 0;
  8334. $x = 0;
  8335. $t = 0;
  8336. $s = 0;
  8337. $q = 0;
  8338. foreach ($sd as $k => $v) {
  8339. if ($v['state'] == 0) {
  8340. $c++;
  8341. if ($v['cpid'] != 0) {
  8342. $cpid[$v['cpid']] = $v['cpid'];
  8343. }
  8344. if ($v['cpbz'] != '') {
  8345. $cpbz[$v['cpbz']] = $v['cpbz'];
  8346. }
  8347. }
  8348. if ($v['state'] != 9) {
  8349. $g++;
  8350. }
  8351. if ($v['state'] == 1) {
  8352. $x++;
  8353. }
  8354. if ($v['state'] == 2) {
  8355. $t++;
  8356. }
  8357. if ($v['state'] == 8) {
  8358. $s++;
  8359. }
  8360. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8361. $q++;
  8362. }
  8363. $details[$v['details']] = $v['details'];
  8364. }
  8365. $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'] . '"');
  8366. $rows[$key]['details'] = implode("、", $details);
  8367. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8368. $number = $value['number'];
  8369. $ftime = time() - 15 * 24 * 3600;
  8370. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8371. $rows[$key]['number'] = $g;
  8372. $rows[$key]['c'] = $c;
  8373. $rows[$key]['x'] = $x;
  8374. $rows[$key]['t'] = $t;
  8375. $rows[$key]['s'] = $s;
  8376. $rows[$key]['q'] = $q;
  8377. $rows[$key]['z'] = $z;
  8378. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8379. $features = explode('-', trim($features, '-'));
  8380. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8381. }
  8382. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8383. $final_list = [];
  8384. foreach ($list as $k => $v) {
  8385. if (empty($v['sku'])) {
  8386. continue;
  8387. }
  8388. $final_list[] = [
  8389. $v["warehouse"],
  8390. $v["purchase"],
  8391. $v["details"],
  8392. $v["cpid"],
  8393. $v["dbcontent"],
  8394. $v["sku"],
  8395. $v["bm"],
  8396. $v["jm"],
  8397. $v["title"],
  8398. $v["pm"],
  8399. $v["cpbz"],
  8400. $v["sm"],
  8401. $v["type"],
  8402. $v["number"],
  8403. $v["c"],
  8404. $v["x"],
  8405. $v["t"],
  8406. $v["s"],
  8407. $v["q"],
  8408. $v["z"],
  8409. $v['weight'],
  8410. ];
  8411. }
  8412. if(empty($final_list)){
  8413. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8414. }
  8415. $title = "总进销存统计表";
  8416. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8417. $merges = [
  8418. [
  8419. "s"=>["r"=>0,"c"=>0],
  8420. "e"=>["r"=>0,"c"=>21]
  8421. ]
  8422. ];
  8423. $cols = [
  8424. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8425. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8426. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8427. ];
  8428. array_unshift($final_list, $first_row);
  8429. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8430. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8431. }
  8432. public function _summaryjs($arg_array)
  8433. {
  8434. $prc = array();
  8435. $purchase = $this->purchase->find_all();
  8436. foreach ($purchase as $k => $v) {
  8437. $prc[$v['id']] = $v['title'];
  8438. }
  8439. if (isset($_GET['excel'])) {
  8440. $ktime = $this->input->get('ktime', true);
  8441. $jtime = $this->input->get('jtime', true);
  8442. $ktime = strtotime($ktime);
  8443. $jtime = strtotime($jtime);
  8444. $where = "1=1";
  8445. if ($ktime && $jtime) {
  8446. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8447. }
  8448. //数据排序
  8449. $order_str = "time desc";
  8450. if (empty($page)) {
  8451. $start = 0;
  8452. $perpage = 1;
  8453. } else {
  8454. $start = ($page - 1) * $perpage;
  8455. }
  8456. //取得信息列表
  8457. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8458. foreach ($info_list as $key => $value) {
  8459. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8460. $warehouse = $this->warehouse->read($value['warehouse']);
  8461. $info_list[$key]['warehouse'] = $warehouse['title'];
  8462. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8463. $details = array();
  8464. $cpid = array();
  8465. foreach ($x as $k => $v) {
  8466. if ($v['details'] != '') {
  8467. $details[$v['details']] = $v['details'];
  8468. }
  8469. if ($v['cpid'] != 0) {
  8470. $cpid[$v['cpid']] = $v['cpid'];
  8471. }
  8472. }
  8473. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8474. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8475. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8476. $info_list[$key]['s'] = $s;
  8477. $info_list[$key]['x'] = count($x);
  8478. }
  8479. if(empty($info_list)){
  8480. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8481. }
  8482. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8483. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8484. $merges = [
  8485. [
  8486. "s"=>["r"=>0,"c"=>0],
  8487. "e"=>["r"=>0,"c"=>7]
  8488. ]
  8489. ];
  8490. $cols = [
  8491. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8492. ];
  8493. $final_list = [];
  8494. foreach($info_list as $k => $v){
  8495. $final_list[] = array_values($v);
  8496. }
  8497. array_unshift($final_list, $first_row);
  8498. array_unshift($final_list,[
  8499. $title,"","","","","","","","",
  8500. ]);
  8501. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8502. $titlename = "<table border=1>
  8503. <tr align='center'>
  8504. <td>仓库</td>
  8505. <td>供应商</td>
  8506. <td>出库位置</td>
  8507. <td>出库编码</td>
  8508. <td>SKU</td>
  8509. <td>产品名</td>
  8510. <td>总剩余库存</td>
  8511. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8512. </tr>
  8513. </table>";
  8514. $filename = $title . ".xls";
  8515. $tail = "";
  8516. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8517. }
  8518. }
  8519. public function _uckjs()
  8520. {
  8521. if (isset($_GET['excel'])) {
  8522. $tc = array();
  8523. $typeclass = $this->typeclass->find_all();
  8524. foreach ($typeclass as $v) {
  8525. $tc[$v['id']] = $v['zh'];
  8526. }
  8527. $first_row = [
  8528. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8529. ];
  8530. $t = array();
  8531. $rq = '';
  8532. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8533. $ts = $ts / (24 * 3600);
  8534. for ($i = 0; $i < $ts; $i++) {
  8535. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8536. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8537. }
  8538. $day_len = count($t);
  8539. $first_row[] = "本月出库";
  8540. $merges = [
  8541. ];
  8542. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8543. $excel_key = 1;
  8544. $final_list = [];
  8545. foreach ($info_list as $k => $v) {
  8546. $features = explode('-', trim($v['features'], '-'));
  8547. if (!isset($features[3]) || !isset($features[4])) {
  8548. continue;
  8549. }
  8550. $tmp = [];
  8551. $tmp[0] = $tc[$features[0]]; //类型
  8552. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8553. $tmp[2] = $tc[$features[4]]; //曲度
  8554. $tmp[3] = '';
  8555. if (isset($data[$k][1])) {
  8556. $tmp[3] .=$tmp[1];
  8557. }
  8558. if (isset($data[$k][2])) {
  8559. $tmp[3] .= $tmp[2];
  8560. }
  8561. if (isset($features[5])) {
  8562. $tmp[3] .= $tc[$features[5]];
  8563. }
  8564. if (isset($features[2])) {
  8565. $tmp[3] .= $tc[$features[2]];
  8566. }
  8567. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8568. $tmp[4] = $v['sku'];
  8569. $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())) . '))'); //月初库存
  8570. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8571. $tmp[7] ="";
  8572. $tmp[8] ="";
  8573. $byck = 0;
  8574. foreach ($t as $vv) {
  8575. $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));
  8576. $tmp[] = ($sl > 0) ? $sl : '';
  8577. $byck += $sl;
  8578. }
  8579. $tmp[] = ($byck > 0) ? $byck : '';
  8580. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8581. // $ztrq = '';
  8582. // $ztsl = '';
  8583. // if (count($zt) > 0) {
  8584. // foreach ($zt as $vv) {
  8585. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8586. // $ztsl .= $vv['num'] . '<br>';
  8587. // }
  8588. // }
  8589. if(empty($zt)){
  8590. $final_list[] = $tmp;
  8591. $excel_key = $excel_key + 1;
  8592. }else{
  8593. $len = count($zt);
  8594. if($len == 1){
  8595. $tmp[7] = $zt[0]['num'] ;
  8596. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8597. $final_list[] = $tmp;
  8598. $excel_key = $excel_key + 1;
  8599. }else{
  8600. foreach($zt as $vv){
  8601. $tmp[7] = "";
  8602. $tmp[8] = "";
  8603. $tmp[7] = $vv['num'];
  8604. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8605. $final_list[] = $tmp;
  8606. }
  8607. $merges[] = [
  8608. "s"=>["r"=>$excel_key,"c"=>0],
  8609. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8610. ];
  8611. $merges[] = [
  8612. "s"=>["r"=>$excel_key,"c"=>1],
  8613. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8614. ];
  8615. $merges[] = [
  8616. "s"=>["r"=>$excel_key,"c"=>2],
  8617. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8618. ];
  8619. $merges[] = [
  8620. "s"=>["r"=>$excel_key,"c"=>3],
  8621. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8622. ];
  8623. $merges[] = [
  8624. "s"=>["r"=>$excel_key,"c"=>4],
  8625. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8626. ];
  8627. $merges[] = [
  8628. "s"=>["r"=>$excel_key,"c"=>5],
  8629. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8630. ];
  8631. $merges[] = [
  8632. "s"=>["r"=>$excel_key,"c"=>6],
  8633. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8634. ];
  8635. for($i=1;$i<=$day_len;$i++){
  8636. $merges[] = [
  8637. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8638. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8639. ];
  8640. }
  8641. $merges[] = [
  8642. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8643. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8644. ];
  8645. $excel_key = $excel_key + $len;
  8646. }
  8647. }
  8648. }
  8649. $title = "详情 " . date("Y-m-d", time());
  8650. if(empty($final_list)){
  8651. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8652. }
  8653. $cols = [
  8654. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8655. ];
  8656. array_unshift($final_list, $first_row);
  8657. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8658. }
  8659. }
  8660. public function _whlabelexcelzhjs(){
  8661. if(empty($_GET['excel'])){
  8662. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8663. }
  8664. $where = "sku != 'Preset' and sku != '' ";
  8665. //数据排序
  8666. $order_str = "id desc";
  8667. if (empty($page)) {
  8668. $start = 0;
  8669. $perpage = 1;
  8670. } else {
  8671. $start = ($page - 1) * $perpage;
  8672. }
  8673. $category = $this->input->get('category', true);
  8674. $warehouse = $this->input->get('warehouse', true);
  8675. $excelid = $this->input->get('sid', true);
  8676. if ($category) {
  8677. $where .= " and features like '%-$category-%'";
  8678. }
  8679. if ($warehouse) {
  8680. $where .= " and warehouse = '$warehouse'";
  8681. }
  8682. $xzid = '';
  8683. if ($excelid) {
  8684. $excelid = explode(',', trim($excelid, ','));
  8685. foreach ($excelid as $key => $value) {
  8686. $xzid .= " id = " . $value . " or";
  8687. }
  8688. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8689. }
  8690. $merges = [
  8691. [
  8692. "s"=>["r"=>0,"c"=>0],
  8693. "e"=>["r"=>0,"c"=>6]
  8694. ]
  8695. ];
  8696. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8697. $excel_index = 2;
  8698. $final_list = [];
  8699. foreach ($rows as $key => $value) {
  8700. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8701. $zh = '';
  8702. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8703. // foreach ($zt_list as $v) {
  8704. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8705. // }
  8706. $zt = array_sum(array_column($zt_list, 'num'));
  8707. $number = $value['number'];
  8708. $ftime = time() - 15 * 24 * 3600;
  8709. $warehouse = $this->warehouse->read($value['warehouse']);
  8710. // $rows[$key]['warehouse'] = $warehouse['title'];
  8711. // $rows[$key]['number'] = $c;
  8712. // $rows[$key]['features'] = $zh;
  8713. //$rows[$key]['hb'] = $c + $zt;
  8714. $tmp = [];
  8715. $tmp[0] = $warehouse['title'];
  8716. $tmp[1] = $value['sku'];
  8717. $tmp[2] = $value['title'];
  8718. $tmp[3] = $c;
  8719. $tmp[4] = "";
  8720. $tmp[5] = $c + $zt;
  8721. if(empty($zt_list)){
  8722. $tmp[4] = "";
  8723. $final_list[] = $tmp;
  8724. $excel_index = $excel_index + 1;
  8725. }else{
  8726. if(count($zt_list) == 1){
  8727. $tmp[4] = "";
  8728. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8729. $final_list[] = $tmp;
  8730. $excel_index = $excel_index + 1;
  8731. }else{
  8732. $len = count($zt_list);
  8733. foreach ($zt_list as $v){
  8734. $tmp[4] = "";
  8735. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8736. $final_list[] = $tmp;
  8737. }
  8738. $merges[] = [
  8739. "s"=>["r"=>$excel_index,"c"=>0],
  8740. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8741. ];
  8742. $merges[] = [
  8743. "s"=>["r"=>$excel_index,"c"=>1],
  8744. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8745. ];
  8746. $merges[] = [
  8747. "s"=>["r"=>$excel_index,"c"=>2],
  8748. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8749. ];
  8750. $merges[] = [
  8751. "s"=>["r"=>$excel_index,"c"=>3],
  8752. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8753. ];
  8754. $merges[] = [
  8755. "s"=>["r"=>$excel_index,"c"=>5],
  8756. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8757. ];
  8758. $excel_index = $excel_index + $len;
  8759. }
  8760. }
  8761. }
  8762. $first_row = [
  8763. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8764. ];
  8765. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8766. if(empty($final_list)){
  8767. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8768. }
  8769. $cols = [
  8770. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8771. ];
  8772. array_unshift($final_list, $first_row);
  8773. array_unshift($final_list, [
  8774. $title,"","","","",""
  8775. ]);
  8776. $end_list = [];
  8777. foreach ($final_list as $key => $value) {
  8778. $end_list[] = array_values($value);
  8779. }
  8780. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8781. }
  8782. //出库、退库导出
  8783. public function _dccrtypejs()
  8784. {
  8785. $classid = $this->classid->sku();
  8786. $pm = $classid;
  8787. $typeclass = array();
  8788. $tc = $this->typeclass->find_all();
  8789. foreach ($tc as $v) {
  8790. $typeclass[$v['id']] = $v;
  8791. }
  8792. $prc = array();
  8793. $purchase = $this->purchase->find_all();
  8794. foreach ($purchase as $k => $v) {
  8795. $prc[$v['id']] = $v['title'];
  8796. }
  8797. if (isset($_GET['sid'])) {
  8798. $wh = array();
  8799. $w = $this->warehouse->find_all('1=1', 'id,title');
  8800. foreach ($w as $v) {
  8801. $wh[$v['id']] = $v['title'];
  8802. }
  8803. $type = $this->input->get('excel', true);
  8804. $category = $this->input->get('category', true);
  8805. $size = $this->input->get('size', true);
  8806. $grade = $this->input->get('grade', true);
  8807. $color = $this->input->get('color', true);
  8808. $lowe = $this->input->get('lowe', true);
  8809. $sku = $this->input->get('sku', true);
  8810. $warehouse = $this->input->get('warehouse', true);
  8811. $lacetype = $this->input->get('lacetype', true);
  8812. $lacecolor = $this->input->get('lacecolor', true);
  8813. $density = $this->input->get('density', true);
  8814. $haircap = $this->input->get('haircap', true);
  8815. $purchase = $this->input->get('purchase', true);
  8816. $title = $this->input->get('title', true);
  8817. $state = $this->input->get('state', true);
  8818. $sid = $this->input->get('sid', true);
  8819. $ktime = $this->input->get('ktime', true);
  8820. $jtime = $this->input->get('jtime', true);
  8821. $ktime = strtotime($ktime);
  8822. $jtime = strtotime($jtime);
  8823. $where = "1=1";
  8824. $gj = "";
  8825. $ck = "";
  8826. if ($category) {
  8827. $where .= " and features like '%-$category-%'";
  8828. }
  8829. if ($size) {
  8830. $where .= " and features like '%-$size-%'";
  8831. }
  8832. if ($grade) {
  8833. $where .= " and features like '%-$grade-%'";
  8834. }
  8835. if ($color) {
  8836. $where .= " and features like '%-$color-%'";
  8837. }
  8838. if ($lowe) {
  8839. $where .= " and features like '%-$lowe-%'";
  8840. }
  8841. if ($warehouse) {
  8842. $where .= " and warehouse = '$warehouse'";
  8843. }
  8844. if ($purchase) {
  8845. $where .= " and purchase = '$purchase'";
  8846. }
  8847. if ($state) {
  8848. $where .= " and state = '$state'";
  8849. }
  8850. if ($lacetype) {
  8851. $where .= " and features like '%-$lacetype-%'";
  8852. }
  8853. if ($lacecolor) {
  8854. $where .= " and features like '%-$lacecolor-%'";
  8855. }
  8856. if ($density) {
  8857. $where .= " and features like '%-$density-%'";
  8858. }
  8859. if ($haircap) {
  8860. $where .= " and features like '%-$haircap-%'";
  8861. }
  8862. if ($title) {
  8863. $title = trim($title, ' ');
  8864. $title = trim($title, ' ');
  8865. $where .= " and title like '%$title%'";
  8866. }
  8867. if ($sku) {
  8868. $sku = trim($sku, ' ');
  8869. $sku = trim($sku, ' ');
  8870. $where .= " and sku like '%$sku%'";
  8871. }
  8872. if ($ktime && $jtime) {
  8873. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8874. }
  8875. $sidwhere = '';
  8876. if ($sid) {
  8877. $sd = "";
  8878. $s = explode(',', trim($sid, ','));
  8879. foreach ($s as $value) {
  8880. $sd .= " id = " . $value . " or";
  8881. }
  8882. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8883. }
  8884. //数据排序
  8885. $order_str = "time desc";
  8886. if (empty($page)) {
  8887. $start = 0;
  8888. $perpage = 1;
  8889. } else {
  8890. $start = ($page - 1) * $perpage;
  8891. }
  8892. $wh = array();
  8893. $w = $this->warehouse->find_all('1=1', 'id,title');
  8894. foreach ($w as $v) {
  8895. $wh[$v['id']] = $v['title'];
  8896. }
  8897. $wt = array();
  8898. $whlabel_type = $this->whlabel_type->find_all();
  8899. foreach ($whlabel_type as $v) {
  8900. $wt[$v['id']] = $v['title'];
  8901. }
  8902. $classid = $this->classid->sku();
  8903. $list = array();
  8904. $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');
  8905. foreach ($rows_r as $key => $value) {
  8906. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8907. $pm = $classid;
  8908. $jm = $classid;
  8909. $rows_r[$key]['enter'] = '入库';
  8910. $rows_r[$key]['time'] = $value['enter'];
  8911. if ($value['rktype'] == 1) {
  8912. $rows_r[$key]['rktype'] = '采购入库';
  8913. } else if ($value['rktype'] == 2) {
  8914. $rows_r[$key]['rktype'] = '盘盈调整';
  8915. } else if ($value['rktype'] == 3) {
  8916. $rows_r[$key]['rktype'] = '其他调整入库';
  8917. } else if ($value['rktype'] == 4) {
  8918. $rows_r[$key]['rktype'] = '其他调整入库';
  8919. } else if ($value['rktype'] == 5) {
  8920. $rows_r[$key]['rktype'] = '退库入库';
  8921. } else if ($value['rktype'] == 6) {
  8922. $rows_r[$key]['rktype'] = '退货可用入库';
  8923. } else if ($value['rktype'] == 7) {
  8924. $rows_r[$key]['rktype'] = '形态转换入库';
  8925. } else {
  8926. $rows_r[$key]['rktype'] = '';
  8927. }
  8928. $features = explode('-', trim($value['features'], '-'));
  8929. foreach ($features as $v) {
  8930. if (isset($typeclass[$v])) {
  8931. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8932. $pm[$typeclass[$v]['classid']] = $zh[0];
  8933. }
  8934. if (isset($typeclass[$v])) {
  8935. if (isset($jm[$typeclass[$v]['classid']])) {
  8936. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8937. }
  8938. }
  8939. }
  8940. $zh = implode(" ", $pm);
  8941. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8942. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8943. $rows_r[$key]['zh'] = $zh;
  8944. $jm = array_filter($jm);
  8945. $rows_r[$key]['features'] = implode("-", $jm);
  8946. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8947. }
  8948. $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');
  8949. foreach ($rows_c as $key => $value) {
  8950. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8951. $pm = $classid;
  8952. $jm = $classid;
  8953. $rows_c[$key]['time'] = $value['outk'];
  8954. $rows_c[$key]['outk'] = '出库';
  8955. if ($value['cktype'] == 1) {
  8956. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8957. } else if ($value['cktype'] == 2) {
  8958. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8959. } else if ($value['cktype'] == 3) {
  8960. $rows_c[$key]['cktype'] = '盘亏调整';
  8961. } else if ($value['cktype'] == 4) {
  8962. $rows_c[$key]['cktype'] = '其他调整出库';
  8963. } else if ($value['cktype'] == 5) {
  8964. $rows_c[$key]['cktype'] = '形态转换出库';
  8965. } else {
  8966. $rows_c[$key]['cktype'] = '';
  8967. }
  8968. unset($rows_c[$key]['state']);
  8969. $features = explode('-', trim($value['features'], '-'));
  8970. foreach ($features as $v) {
  8971. if (isset($typeclass[$v])) {
  8972. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8973. $pm[$typeclass[$v]['classid']] = $zh[0];
  8974. }
  8975. if (isset($typeclass[$v])) {
  8976. if (isset($jm[$typeclass[$v]['classid']])) {
  8977. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8978. }
  8979. }
  8980. }
  8981. $zh = implode(" ", $pm);
  8982. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8983. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8984. $rows_c[$key]['zh'] = $zh;
  8985. $jm = array_filter($jm);
  8986. $rows_c[$key]['features'] = implode("-", $jm);
  8987. $rows_c[$key]['number'] = 1;
  8988. }
  8989. $merged = $rows_r;
  8990. foreach ($rows_c as $key => $value) {
  8991. if (isset($merged[$key])) {
  8992. $merged[] = $value;
  8993. } else {
  8994. $merged[$key] = $value;
  8995. }
  8996. }
  8997. usort($merged, function ($a, $b) {
  8998. return $a['time'] - $b['time'];
  8999. });
  9000. foreach ($merged as $key => $value) {
  9001. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9002. }
  9003. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9004. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9005. $cols = [
  9006. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9007. ];
  9008. $final_list= [];
  9009. foreach($merged as $key => $value){
  9010. $final_list[] = array_values($value) ;
  9011. }
  9012. if(empty($merged)){
  9013. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9014. }
  9015. array_unshift($final_list, $first_row);
  9016. $end_list = [];
  9017. foreach ($final_list as $key => $value) {
  9018. $end_list[] = array_values($value);
  9019. }
  9020. $merges = [];
  9021. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9022. }
  9023. }
  9024. public function _errorexceljs()
  9025. {
  9026. $post = $this->input->post(NULL, TRUE);
  9027. if (isset($_GET['page'])) {
  9028. $page = $this->input->get('page', true);
  9029. $perpage = $this->input->get('perpage', true);
  9030. $sku = $this->input->get('sku', true);
  9031. $warehouse = $this->input->get('warehouse', true);
  9032. $ktime = $this->input->get('ktime', true);
  9033. $jtime = $this->input->get('jtime', true);
  9034. $ktime = strtotime($ktime);
  9035. $jtime = strtotime($jtime);
  9036. $where = "sku != 'Preset'";
  9037. $gj = '';
  9038. if ($sku) {
  9039. $where .= " and sku like '%$sku%'";
  9040. } else {
  9041. if ($ktime && $jtime) {
  9042. $gj = " and time > '$ktime' and time < '$jtime'";
  9043. }
  9044. }
  9045. if ($warehouse) {
  9046. $where .= " and warehouse = '$warehouse'";
  9047. }
  9048. //数据排序
  9049. $order_str = "id desc";
  9050. if (empty($page)) {
  9051. $start = 0;
  9052. $perpage = 1;
  9053. } else {
  9054. $start = ($page - 1) * $perpage;
  9055. }
  9056. //取得信息列表
  9057. $rows = array();
  9058. $list = array();
  9059. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9060. foreach ($info_list as $value) {
  9061. $warehouse = $this->warehouse->read($value['warehouse']);
  9062. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9063. $number = $value['number'];
  9064. $ftime = time() - 15 * 24 * 3600;
  9065. if ($c < 1) {
  9066. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9067. }
  9068. }
  9069. $title = "0库存汇总";
  9070. $first_row = ["仓库","SKU","产品","当前库存"];
  9071. $cols = [
  9072. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9073. ];
  9074. $final_list= [];
  9075. foreach($list as $key => $value){
  9076. $final_list[] = array_values($value) ;
  9077. }
  9078. if(empty($final_list)){
  9079. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9080. }
  9081. array_unshift($final_list, $first_row);
  9082. $merges = [];
  9083. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9084. }
  9085. }
  9086. }