Whlabel.php 253 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_whlabel','whlabel');
  7. $this->load->_model('Model_warehouse','warehouse');
  8. $this->load->_model('Model_purchase','purchase');
  9. $this->load->_model('Model_excel','excel');
  10. $this->load->_model('Model_fullorder','fullorder');
  11. $this->load->_model('Model_fullordertt','fullordertt');
  12. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_shop','shop');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. $this->load->_model('Model_country','country');
  18. $this->load->_model('Model_warehouse','warehouse');
  19. $this->load->_model('Model_kdniao','kdniao');
  20. $this->load->_model('Model_notice','notice');
  21. $this->load->_model('Model_dhl','dhl');
  22. $this->load->_model('Model_shop','shop');
  23. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  24. $this->load->_model('Model_ljg','ljg');
  25. $this->load->_model('Model_usps','usps');
  26. $this->load->_model('Model_specialstock','specialstock');
  27. $this->load->_model('Model_whlabellabel','whlabellabel');
  28. $this->load->_model('Model_whlabelwz','whlabelwz');
  29. $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
  30. $this->load->_model('Model_whlabeltransport','whlabeltransport');
  31. $this->load->_model('Model_orderurl','orderurl');
  32. $this->load->_model('Model_brand','brand');
  33. $this->load->_model('Model_classid','classid');
  34. $this->load->_model('Model_apiyy','apiyy');
  35. $this->load->_model('Model_power','power');
  36. $this->load->_model('Model_whlabel_type','whlabel_type');
  37. }
  38. //定义方法的调用规则 获取URI第二段值
  39. public function _remap($arg,$arg_array)
  40. {
  41. if($arg == 'existence')//在库标签
  42. {
  43. $this->_existence();
  44. }
  45. else if($arg == 'cpbqdc')//在库标签
  46. {
  47. $this->_cpbqdc();
  48. }
  49. else if($arg == 'type')//进销存浏览
  50. {
  51. $this->_type();
  52. }
  53. else if($arg == 'typedy')//进销存浏览店员页面
  54. {
  55. $this->_typedy($arg_array);
  56. }
  57. else if($arg == 'typedy_ck')//进销存浏览店员页面
  58. {
  59. $this->_typedy_ck($arg_array);
  60. }
  61. else if($arg == 'typeck')
  62. {
  63. $this->_typeck($arg_array);
  64. }
  65. else if($arg == 'whlabeckdc')
  66. {
  67. $this->_whlabeckdc($arg_array);
  68. }
  69. else if($arg == 'usatype')//美仓进销存浏览
  70. {
  71. $this->_usatype();
  72. }
  73. else if($arg == 'usatypeapp')//美仓APP进销存浏览
  74. {
  75. $this->_usatypeapp();
  76. }
  77. else if($arg == 'enteradd')//入库操作
  78. {
  79. $this->_enteradd();
  80. }
  81. else if($arg == 'enteredit')//修改
  82. {
  83. $this->_enteredit($arg_array);
  84. }
  85. else if($arg == 'enter')//入库浏览
  86. {
  87. $this->_enter();
  88. }
  89. else if($arg == 'out')//出库浏览
  90. {
  91. $this->_out();
  92. }
  93. else if($arg == 'label')//出库标签浏览
  94. {
  95. $this->_label();
  96. }
  97. else if($arg == 'outorder')//独立站出库订单
  98. {
  99. $this->_outorder();
  100. }
  101. else if($arg == 'soutorder')//速卖通出库订单
  102. {
  103. $this->_soutorder();
  104. }
  105. else if($arg == 'toutorder')//TT出库订单
  106. {
  107. $this->_toutorder();
  108. }
  109. else if($arg == 'retreat')//退库订单
  110. {
  111. $this->_retreat();
  112. }
  113. else if($arg == 'retreatlk')//退库订单
  114. {
  115. $this->_retreatlk();
  116. }
  117. else if($arg == 'change')//更换标签
  118. {
  119. $this->_change();
  120. }
  121. else if($arg == 'del')//删除
  122. {
  123. $this->_del();
  124. }
  125. else if($arg == 'exceljxc')//进销存信息导出
  126. {
  127. $this->_exceljxc();
  128. }
  129. else if($arg == 'excelr')//入库信息导出
  130. {
  131. $this->_excelr();
  132. }
  133. else if($arg == 'excelct')//出库、退库信息导出
  134. {
  135. $this->_excelct();
  136. }
  137. else if($arg == 'excelcr')//出库、退库信息导出
  138. {
  139. $this->_excelcr();
  140. }
  141. else if($arg == 'kcyz')//库存验证
  142. {
  143. $this->_kcyz();
  144. }
  145. else if($arg == 'kj')//库存扣减
  146. {
  147. $this->_kj($arg_array);
  148. }
  149. else if($arg == 'presetout')//预设库存导入
  150. {
  151. $this->_presetout($arg_array);
  152. }
  153. else if($arg == 'presetedit')//预设库存导入
  154. {
  155. $this->_presetedit($arg_array);
  156. }
  157. else if($arg == 'summary')//汇总导出
  158. {
  159. $this->_summary($arg_array);
  160. }
  161. else if($arg == 'manifest')//usps发货清单
  162. {
  163. $this->_manifest();
  164. }
  165. else if($arg == 'abnormal')//占单异常
  166. {
  167. $this->_abnormal();
  168. }
  169. else if($arg == 'error')//0库存SKU
  170. {
  171. $this->_error();
  172. }
  173. else if($arg == 'errorexcel')//0库存SKU导出
  174. {
  175. $this->_errorexcel();
  176. }
  177. else if($arg == 'db')
  178. {
  179. $this->_db();
  180. }
  181. else if($arg == 'dbrk')
  182. {
  183. $this->_dbrk();
  184. }
  185. else if($arg == 'whlabelczdc')
  186. {
  187. $this->_whlabelczdc();
  188. }
  189. else if($arg == 'print')
  190. {
  191. $this->_print($arg_array);
  192. }
  193. else if($arg == 'usaprint')
  194. {
  195. $this->_usaprint($arg_array);
  196. }
  197. else if($arg == 'printck')
  198. {
  199. $this->_printck($arg_array);
  200. }
  201. else if($arg == 'printrk')
  202. {
  203. $this->_printrk($arg_array);
  204. }
  205. else if($arg == 'printxzrk')
  206. {
  207. $this->_printxzrk($arg_array);
  208. }
  209. else if($arg == 'printexcel')
  210. {
  211. $this->_printexcel($arg_array);
  212. }
  213. else if($arg == 'uck')
  214. {
  215. $this->_uck();
  216. }
  217. else if($arg == 'whlabelexcelzh')
  218. {
  219. $this->_whlabelexcelzh();
  220. }
  221. else if($arg == 'fc')
  222. {
  223. $this->_fc();
  224. }
  225. else if($arg == 'fcmb')
  226. {
  227. $this->_fcmb();
  228. }
  229. else if($arg == 'fcexcel')
  230. {
  231. $this->_fcexcel();
  232. }
  233. else if($arg == 'fcjxc')
  234. {
  235. $this->_fcjxc($arg_array);
  236. }
  237. else if($arg == '0kcdel')
  238. {
  239. $this->_0kcdel();//导表删除0库存
  240. }
  241. else if($arg == 'gbhtype')
  242. {
  243. $this->_gbhtype();//更改备货状态
  244. }
  245. else
  246. {
  247. $this->_index();
  248. }
  249. }
  250. //管理
  251. public function _index()
  252. {
  253. $post = $this->input->post(NULL, TRUE);
  254. if(isset($post['page']))
  255. {
  256. $page = $this->input->post('page',true);
  257. $perpage = $this->input->post('perpage',true);
  258. $sku = $this->input->post('sku',true);
  259. $number = $this->input->post('number',true);
  260. $warehouse = $this->input->post('warehouse',true);
  261. $purchase = $this->input->post('purchase',true);
  262. $orderinfo = $this->input->post('orderinfo',true);
  263. $waybill = $this->input->post('waybill',true);
  264. $category = $this->input->post('category',true);
  265. $size = $this->input->post('size',true);
  266. $grade = $this->input->post('grade',true);
  267. $color = $this->input->post('color',true);
  268. $lowe = $this->input->post('lowe',true);
  269. $state = $this->input->post('state',true);
  270. $label = $this->input->post('label',true);
  271. $timetk = $this->input->post('timetkk',true);
  272. $timetj = $this->input->post('timetjj',true);
  273. $timetk = strtotime($timetk);
  274. $timetj = strtotime($timetj);
  275. $where = "1=1 ";
  276. if($timetk && $timetj)
  277. {
  278. $where .= " and time > '$timetk' and time < '$timetj'";
  279. }
  280. if($sku)
  281. {
  282. $where .= " and sku = '$sku'";
  283. }
  284. if($number)
  285. {
  286. $where .= " and number = '$number'";
  287. }
  288. if($warehouse)
  289. {
  290. $where .= " and warehouse = '$warehouse'";
  291. }
  292. if($purchase)
  293. {
  294. $where .= " and purchase = '$purchase'";
  295. }
  296. if($orderinfo)
  297. {
  298. $where .= " and orderinfo = '$orderinfo'";
  299. }
  300. if($waybill)
  301. {
  302. $where .= " and waybill = '$waybill'";
  303. }
  304. if($category)
  305. {
  306. $where .= " and features like '%-$category-%'";
  307. }
  308. if($size)
  309. {
  310. $where .= " and features like '%-$size-%'";
  311. }
  312. if($grade)
  313. {
  314. $where .= " and features like '%-$grade-%'";
  315. }
  316. if($color)
  317. {
  318. $where .= " and features like '%-$color-%'";
  319. }
  320. if($lowe)
  321. {
  322. $where .= " and features like '%-$lowe-%'";
  323. }
  324. if($label)
  325. {
  326. $where .= " and label = '$label'";
  327. }
  328. if($state != '')
  329. {
  330. $where .= " and state = '$state'";
  331. }
  332. //数据排序
  333. $order_str = "time desc";
  334. if(empty($page))
  335. {
  336. $start = 0;
  337. $perpage = 1;
  338. }
  339. else
  340. {
  341. $start = ($page - 1)*$perpage;
  342. }
  343. //取得信息列表
  344. $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);
  345. foreach ($info_list as $key=>$value)
  346. {
  347. $warehouse = $this->warehouse->read($value['warehouse']);
  348. $info_list[$key]['warehouse'] = $warehouse['title'];
  349. $purchase = $this->purchase->read($value['purchase']);
  350. $info_list[$key]['purchase'] = $purchase['title'];
  351. if($value['enter'] != 0)
  352. {
  353. $info_list[$key]['enter'] = '<p>'.date('Y-m-d',$value['enter']).'</p><p>'.date('H:i:s',$value['enter']).'</p>';
  354. }
  355. else
  356. {
  357. $info_list[$key]['enter'] = "";
  358. }
  359. if($value['outk'] != 0)
  360. {
  361. $info_list[$key]['outk'] = '<p>'.date('Y-m-d',$value['outk']).'</p><p>'.date('H:i:s',$value['outk']).'</p>';
  362. }
  363. else
  364. {
  365. $info_list[$key]['outk'] = "";
  366. }
  367. if($value['printing'] != 0)
  368. {
  369. $info_list[$key]['printing'] = '<p>'.date('Y-m-d',$value['printing']).'</p><p>'.date('H:i:s',$value['printing']).'</p>';
  370. }
  371. else
  372. {
  373. $info_list[$key]['printing'] = "";
  374. }
  375. if($value['orderinfo'] == 0)
  376. {
  377. $info_list[$key]['orderinfo'] = "";
  378. }
  379. if($value['waybill'] == 0)
  380. {
  381. $info_list[$key]['waybill'] = "";
  382. }
  383. if($value['state'] == 0)
  384. {
  385. $info_list[$key]['state'] = "在库";
  386. }
  387. else if($value['state'] == 1)
  388. {
  389. $info_list[$key]['state'] = "出库";
  390. }
  391. else if($value['state'] == 2)
  392. {
  393. $info_list[$key]['state'] = "退库";
  394. }
  395. else if($value['state'] == 3)
  396. {
  397. $info_list[$key]['state'] = "调拨中";
  398. }
  399. else if($value['state'] == 4)
  400. {
  401. $info_list[$key]['state'] = "再加工";
  402. }
  403. else if($value['state'] == 5)
  404. {
  405. $info_list[$key]['state'] = "维修中";
  406. }
  407. else if($value['state'] == 6)
  408. {
  409. $info_list[$key]['state'] = "盘亏";
  410. }
  411. else if($value['state'] == 7)
  412. {
  413. $info_list[$key]['state'] = "更换标签";
  414. }
  415. else if($value['state'] == 8)
  416. {
  417. $info_list[$key]['state'] = "其它";
  418. }
  419. else if($value['state'] == 9)
  420. {
  421. $info_list[$key]['state'] = "预设";
  422. }
  423. else if($value['state'] == 10)
  424. {
  425. $info_list[$key]['state'] = "美店零售";
  426. }
  427. if($value['text'] == "")
  428. {
  429. $info_list[$key]['text'] = "";
  430. }
  431. $info_list[$key]['time'] = '<p>'.date('Y-m-d',$value['time']).'</p><p>'.date('H:i:s',$value['time']).'</p>';
  432. }
  433. $total = $this->whlabel->find_count($where);
  434. $pagenum = ceil($total/$perpage);
  435. $over = $total-($start+$perpage);
  436. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  437. echo json_encode($rows);exit;
  438. }
  439. if(isset($post['outsku']))
  440. {
  441. $cz = $this->input->post('cz',true);
  442. if($cz == '1')
  443. {
  444. $sku = $this->input->post('outsku',true);
  445. if($sku)
  446. {
  447. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  448. if(count($data) < 1)
  449. {
  450. echo json_encode(array('msg'=>'库存不足!','success'=>false));exit;
  451. }
  452. $this->whlabel->save(array('state'=>10,'outk'=>time(),'time'=>time()),$data[0]['id']);
  453. echo json_encode(array('success'=>true));exit;
  454. }
  455. }
  456. else
  457. {
  458. $sku = $this->input->post('outsku',true);
  459. if($sku)
  460. {
  461. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  462. if(count($data) < 1)
  463. {
  464. echo json_encode(array('msg'=>'没有此SKU出库数据!','success'=>false));exit;
  465. }
  466. $this->whlabel->save(array('state'=>0,'outk'=>0,'time'=>time()),$data[0]['id']);
  467. echo json_encode(array('success'=>true));exit;
  468. }
  469. }
  470. }
  471. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  472. $this->_Template('whlabel',$this->data);
  473. }
  474. //在库标签
  475. public function _existence()
  476. {
  477. $post = $this->input->post(NULL, TRUE);
  478. if(isset($post['s']))
  479. {
  480. $id_arr = $this->input->post('s');
  481. $id_arr = explode(',',$id_arr);
  482. if(!$id_arr)
  483. {
  484. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  485. }
  486. //循环删除记录
  487. foreach ($id_arr as $v)
  488. {
  489. $sid = $this->whlabel->read($v);
  490. $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
  491. if($count > 0)
  492. {
  493. echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
  494. }
  495. $this->whlabel->remove($v);
  496. }
  497. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  498. }
  499. if(isset($post['page']))
  500. {
  501. $page = $this->input->post('page',true);
  502. $perpage = $this->input->post('perpage',true);
  503. $warehouse = $this->input->post('warehouse',true);
  504. $label = $this->input->post('label',true);
  505. $where = "1=1 and state = 0";
  506. if($warehouse)
  507. {
  508. $where .= " and warehouse = '$warehouse'";
  509. }
  510. if($label)
  511. {
  512. $where .= " and label = '$label'";
  513. }
  514. //数据排序
  515. $order_str = "time asc";
  516. if(empty($page))
  517. {
  518. $start = 0;
  519. $perpage = 1;
  520. }
  521. else
  522. {
  523. $start = ($page - 1)*$perpage;
  524. }
  525. //取得信息列表
  526. $info_list = $this->whlabel->find_all($where,'id,sku,title,label,printing,enter',$order_str,$start,$perpage);
  527. foreach ($info_list as $key=>$value)
  528. {
  529. if($value['enter'] != 0)
  530. {
  531. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  532. }
  533. else
  534. {
  535. $info_list[$key]['enter'] = "";
  536. }
  537. if($value['printing'] != 0)
  538. {
  539. $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']);
  540. }
  541. else
  542. {
  543. $info_list[$key]['printing'] = "";
  544. }
  545. }
  546. $total = $this->whlabel->find_count($where);
  547. $pagenum = ceil($total/$perpage);
  548. $over = $total-($start+$perpage);
  549. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  550. echo json_encode($rows);exit;
  551. }
  552. $this->_Template('whlabel_existence',$this->data);
  553. }
  554. //进销存浏览
  555. public function _typedy($arg_array)
  556. {
  557. $prc = array();
  558. $purchase = $this->purchase->find_all();
  559. foreach($purchase as $k=>$v)
  560. {
  561. $prc[$v['id']] = $v['title'];
  562. }
  563. $post = $this->input->post(NULL, TRUE);
  564. if(isset($post['page']))
  565. {
  566. $page = $this->input->post('page',true);
  567. $perpage = $this->input->post('perpage',true);
  568. $category = $this->input->post('category',true);
  569. $size = $this->input->post('size',true);
  570. $grade = $this->input->post('grade',true);
  571. $color = $this->input->post('color',true);
  572. $lowe = $this->input->post('lowe',true);
  573. $sku = $this->input->post('sku');
  574. $title = $this->input->post('title');
  575. $warehouse = $this->input->post('warehouse',true);
  576. $usa = $this->input->post('usa',true);
  577. $purchase = $this->input->post('purchase',true);
  578. $lacetype = $this->input->post('lacetype',true);
  579. $haircap = $this->input->post('haircap',true);
  580. $density = $this->input->post('density',true);
  581. $details = $this->input->post('details',true);
  582. $state = $this->input->post('state',true);
  583. $lacecolor = $this->input->post('lacecolor',true);
  584. $cklx = $this->input->post('cklx',true);
  585. $ktime = $this->input->post('ktime',true);
  586. $jtime = $this->input->post('jtime',true);
  587. $ktime = strtotime($ktime);
  588. $jtime = strtotime($jtime);
  589. $where = "1=1";$gj = "";$ck = "";
  590. if($lacetype)
  591. {
  592. $where .= " and features like '%-$lacetype-%'";
  593. }
  594. if($category)
  595. {
  596. $where .= " and features like '%-$category-%'";
  597. }
  598. if($size)
  599. {
  600. $where .= " and features like '%-$size-%'";
  601. }
  602. if($grade)
  603. {
  604. $where .= " and features like '%-$grade-%'";
  605. }
  606. if($color)
  607. {
  608. $where .= " and features like '%-$color-%'";
  609. }
  610. if($lowe)
  611. {
  612. $where .= " and features like '%-$lowe-%'";
  613. }
  614. if($haircap)
  615. {
  616. $where .= " and features like '%-$haircap-%'";
  617. }
  618. if($density)
  619. {
  620. $where .= " and features like '%-$density-%'";
  621. }
  622. if($lacecolor)
  623. {
  624. $where .= " and features like '%-$lacecolor-%'";
  625. }
  626. if($usa)
  627. {
  628. if(!$warehouse)
  629. {
  630. $where .= " and (warehouse = '5' or warehouse = '8')";
  631. }
  632. }
  633. if($warehouse)
  634. {
  635. $where .= " and warehouse = '$warehouse'";
  636. }
  637. if($details)
  638. {
  639. $where .= " and details = '$details'";
  640. }
  641. if($purchase)
  642. {
  643. $where .= " and purchase = '$purchase'";
  644. }
  645. if($state)
  646. {
  647. $where .= " and state = '$state'";
  648. }
  649. $where_add = '';
  650. if($cklx)
  651. {
  652. $shop = $this->shop->read($cklx);
  653. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  654. }
  655. if($ktime && $jtime)
  656. {
  657. $gj = " and enter > '$ktime' and enter < '$jtime'";
  658. $ck = " and outk > '$ktime' and outk < '$jtime'";
  659. }
  660. //数据排序
  661. $order_str = "id desc";
  662. if(empty($page))
  663. {
  664. $start = 0;
  665. $perpage = 1;
  666. }
  667. else
  668. {
  669. $start = ($page - 1)*$perpage;
  670. }
  671. if($sku)
  672. {
  673. $sku = trim($sku,' ');
  674. $sku = trim($sku,' ');
  675. $where .= " and sku like '%$sku%'";
  676. $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);
  677. }
  678. else if($title)
  679. {
  680. $title = trim($title,' ');
  681. $title = trim($title,' ');
  682. $where .= " and title like '%$title%'";
  683. $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);
  684. }
  685. else
  686. {
  687. //$where .= " and time > '$ktime' and time < '$jtime'";
  688. $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);
  689. }
  690. //取得信息列表
  691. $rows = array();$list = array();
  692. foreach ($info_list as $key=>$value)
  693. {
  694. $warehouse = $this->warehouse->read($value['warehouse']);
  695. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  696. $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  697. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  698. $number = $value['number'];$ftime = time()-15*24*3600;
  699. $info_list[$key]['warehouse'] = $warehouse['title'];
  700. $info_list[$key]['features'] = count($c);
  701. $z = count($z);//查看订单号
  702. $info_list[$key]['number'] = $z;
  703. $details = array();
  704. $cpid = array();
  705. foreach ($c as $k=>$v)
  706. {
  707. $details[$v['details']] = $v['details'];
  708. if($v['cpid'] != 0)
  709. {
  710. $cpid[$v['cpid']] = $v['cpid'];
  711. }
  712. }
  713. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  714. if($value['shop'] != '')
  715. {
  716. $shop = explode(',',trim($value['shop'],','));
  717. $shop = $this->shop->read($shop[0]);
  718. $info_list[$key]['shop'] = $shop['shopname'];
  719. }
  720. }
  721. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  722. $pagenum = ceil($total/$perpage);
  723. $over = $total-($start+$perpage);
  724. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  725. echo json_encode($rows);exit;
  726. }
  727. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  728. $this->_Template('whlabel_typedy',$this->data);
  729. }
  730. //进销存浏览
  731. public function _typedy_ck($arg_array)
  732. {
  733. $prc = array();
  734. $purchase = $this->purchase->find_all();
  735. foreach($purchase as $k=>$v)
  736. {
  737. $prc[$v['id']] = $v['title'];
  738. }
  739. $post = $this->input->post(NULL, TRUE);
  740. if(isset($post['page']))
  741. {
  742. $page = $this->input->post('page',true);
  743. $perpage = $this->input->post('perpage',true);
  744. $category = $this->input->post('category',true);
  745. $size = $this->input->post('size',true);
  746. $grade = $this->input->post('grade',true);
  747. $color = $this->input->post('color',true);
  748. $lowe = $this->input->post('lowe',true);
  749. $sku = $this->input->post('sku');
  750. $title = $this->input->post('title');
  751. $warehouse = $this->input->post('warehouse',true);
  752. $usa = $this->input->post('usa',true);
  753. $purchase = $this->input->post('purchase',true);
  754. $lacetype = $this->input->post('lacetype',true);
  755. $haircap = $this->input->post('haircap',true);
  756. $density = $this->input->post('density',true);
  757. $details = $this->input->post('details',true);
  758. $state = $this->input->post('state',true);
  759. $lacecolor = $this->input->post('lacecolor',true);
  760. $cklx = $this->input->post('cklx',true);
  761. $ktime = $this->input->post('ktime',true);
  762. $jtime = $this->input->post('jtime',true);
  763. $ktime = strtotime($ktime);
  764. $jtime = strtotime($jtime);
  765. $where = "1=1";$gj = "";$ck = "";
  766. if($lacetype)
  767. {
  768. $where .= " and features like '%-$lacetype-%'";
  769. }
  770. if($category)
  771. {
  772. $where .= " and features like '%-$category-%'";
  773. }
  774. if($size)
  775. {
  776. $where .= " and features like '%-$size-%'";
  777. }
  778. if($grade)
  779. {
  780. $where .= " and features like '%-$grade-%'";
  781. }
  782. if($color)
  783. {
  784. $where .= " and features like '%-$color-%'";
  785. }
  786. if($lowe)
  787. {
  788. $where .= " and features like '%-$lowe-%'";
  789. }
  790. if($haircap)
  791. {
  792. $where .= " and features like '%-$haircap-%'";
  793. }
  794. if($density)
  795. {
  796. $where .= " and features like '%-$density-%'";
  797. }
  798. if($lacecolor)
  799. {
  800. $where .= " and features like '%-$lacecolor-%'";
  801. }
  802. if($usa)
  803. {
  804. if(!$warehouse)
  805. {
  806. $where .= " and (warehouse = '5' or warehouse = '8')";
  807. }
  808. }
  809. if($warehouse)
  810. {
  811. $where .= " and warehouse = '$warehouse'";
  812. }
  813. if($details)
  814. {
  815. $where .= " and details = '$details'";
  816. }
  817. if($purchase)
  818. {
  819. $where .= " and purchase = '$purchase'";
  820. }
  821. if($state)
  822. {
  823. $where .= " and state = '$state'";
  824. }
  825. $where_add = '';
  826. if($cklx)
  827. {
  828. $shop = $this->shop->read($cklx);
  829. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  830. }
  831. if($ktime && $jtime)
  832. {
  833. $gj = " and enter > '$ktime' and enter < '$jtime'";
  834. $ck = " and outk > '$ktime' and outk < '$jtime'";
  835. }
  836. //数据排序
  837. $order_str = "id desc";
  838. if(empty($page))
  839. {
  840. $start = 0;
  841. $perpage = 1;
  842. }
  843. else
  844. {
  845. $start = ($page - 1)*$perpage;
  846. }
  847. if($sku)
  848. {
  849. $sku = trim($sku,' ');
  850. $sku = trim($sku,' ');
  851. $where .= " and sku like '%$sku%'";
  852. $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);
  853. }
  854. else if($title)
  855. {
  856. $title = trim($title,' ');
  857. $title = trim($title,' ');
  858. $where .= " and title like '%$title%'";
  859. $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);
  860. }
  861. else
  862. {
  863. //$where .= " and time > '$ktime' and time < '$jtime'";
  864. $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);
  865. }
  866. //取得信息列表
  867. $rows = array();$list = array();
  868. foreach ($info_list as $key=>$value)
  869. {
  870. $warehouse = $this->warehouse->read($value['warehouse']);
  871. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  872. $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  873. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  874. $ftime = time()-15*24*3600;
  875. $info_list[$key]['warehouse'] = $warehouse['title'];
  876. $info_list[$key]['features'] = count($c)<10?"<em style='color:#F00'>".count($c)."</em>":count($c);
  877. //$z = count($z);//查看订单号
  878. //$info_list[$key]['zd'] = $z;
  879. $details = array();
  880. $cpid = array();
  881. foreach ($c as $k=>$v)
  882. {
  883. $details[$v['details']] = $v['details'];
  884. if($v['cpid'] != 0)
  885. {
  886. $cpid[$v['cpid']] = $v['cpid'];
  887. }
  888. }
  889. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  890. if($value['shop'] != '')
  891. {
  892. $shop = explode(',',trim($value['shop'],','));
  893. $shop = $this->shop->read($shop[0]);
  894. $info_list[$key]['shop'] = $shop['shopname'];
  895. }
  896. }
  897. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  898. $pagenum = ceil($total/$perpage);
  899. $over = $total-($start+$perpage);
  900. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  901. echo json_encode($rows);exit;
  902. }
  903. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  904. $this->_Template('whlabel_typedy_ck',$this->data);
  905. }
  906. public function _typeck($arg_array)
  907. {
  908. $prc = array();
  909. $purchase = $this->purchase->find_all();
  910. foreach($purchase as $k=>$v)
  911. {
  912. $prc[$v['id']] = $v['title'];
  913. }
  914. $post = $this->input->post(NULL, TRUE);
  915. if(isset($post['page']))
  916. {
  917. $page = $this->input->post('page',true);
  918. $perpage = $this->input->post('perpage',true);
  919. $category = $this->input->post('category',true);
  920. $size = $this->input->post('size',true);
  921. $grade = $this->input->post('grade',true);
  922. $color = $this->input->post('color',true);
  923. $lacecolor = $this->input->post('lacecolor',true);
  924. $lowe = $this->input->post('lowe',true);
  925. $sku = $this->input->post('sku');
  926. $title = $this->input->post('title');
  927. $warehouse = 13;
  928. $usa = $this->input->post('usa',true);
  929. $purchase = $this->input->post('purchase',true);
  930. $lacetype = $this->input->post('lacetype',true);
  931. $haircap = $this->input->post('haircap',true);
  932. $density = $this->input->post('density',true);
  933. $details = $this->input->post('details',true);
  934. $state = $this->input->post('state',true);
  935. $ktime = $this->input->post('ktime',true);
  936. $jtime = $this->input->post('jtime',true);
  937. $ktime = strtotime($ktime);
  938. $jtime = strtotime($jtime);
  939. $where = "1=1";$gj = "";$ck = "";
  940. if($lacetype)
  941. {
  942. $where .= " and features like '%-$lacetype-%'";
  943. }
  944. if($category)
  945. {
  946. $where .= " and features like '%-$category-%'";
  947. }
  948. if($size)
  949. {
  950. $where .= " and features like '%-$size-%'";
  951. }
  952. if($grade)
  953. {
  954. $where .= " and features like '%-$grade-%'";
  955. }
  956. if($color)
  957. {
  958. $where .= " and features like '%-$color-%'";
  959. }
  960. if($lacecolor)
  961. {
  962. $where .= " and features like '%-$lacecolor-%'";
  963. }
  964. if($lowe)
  965. {
  966. $where .= " and features like '%-$lowe-%'";
  967. }
  968. if($haircap)
  969. {
  970. $where .= " and features like '%-$haircap-%'";
  971. }
  972. if($density)
  973. {
  974. $where .= " and features like '%-$density-%'";
  975. }
  976. if($warehouse)
  977. {
  978. $where .= " and warehouse = '$warehouse'";
  979. }
  980. if($details)
  981. {
  982. $where .= " and details = '$details'";
  983. }
  984. if($purchase)
  985. {
  986. $where .= " and purchase = '$purchase'";
  987. }
  988. if($state)
  989. {
  990. $where .= " and state = '$state'";
  991. }
  992. if($ktime && $jtime)
  993. {
  994. $gj = " and enter > '$ktime' and enter < '$jtime'";
  995. $ck = " and outk > '$ktime' and outk < '$jtime'";
  996. }
  997. //数据排序
  998. $order_str = "id desc";
  999. if(empty($page))
  1000. {
  1001. $start = 0;
  1002. $perpage = 1;
  1003. }
  1004. else
  1005. {
  1006. $start = ($page - 1)*$perpage;
  1007. }
  1008. if($sku)
  1009. {
  1010. $sku = trim($sku,' ');
  1011. $sku = trim($sku,' ');
  1012. $where .= " and sku like '%$sku%'";
  1013. }
  1014. else if($title)
  1015. {
  1016. $title = trim($title,' ');
  1017. $title = trim($title,' ');
  1018. $where .= " and title like '%$title%'";
  1019. }
  1020. $info_list = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,title,details,cpbz,features,number',$order_str,$start,$perpage);
  1021. //取得信息列表
  1022. $t = array();
  1023. $typeclass = $this->typeclass->find_all();
  1024. foreach ($typeclass as $v)
  1025. {
  1026. $t[$v['id']] = $v;
  1027. }
  1028. $rows = array();$list = array();
  1029. foreach ($info_list as $key=>$value)
  1030. {
  1031. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1032. $mc = $this->whlabel->find_all("sku = '".$value['sku']."' and features = '".$value['features']."' and warehouse = '".$value['warehouse']."'",'cpbz','id desc',0,1);
  1033. $warehouse = $this->warehouse->read($value['warehouse']);
  1034. $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');
  1035. $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'].'"');
  1036. $number = $value['number'];$ftime = time()-15*24*3600;
  1037. $z = count($z);//查看订单号
  1038. $info_list[$key]['warehouse'] = $warehouse['title'];
  1039. $info_list[$key]['features'] = count($c);
  1040. $info_list[$key]['number'] = $z;
  1041. $info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  1042. $details = array();
  1043. $cpid = array();
  1044. foreach ($c as $k=>$v)
  1045. {
  1046. $details[$v['details']] = $v['details'];
  1047. if($v['cpid'] != 0)
  1048. {
  1049. $cpid[$v['cpid']] = $v['cpid'];
  1050. }
  1051. }
  1052. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1053. $classid = $this->classid->sku();
  1054. $pm = $classid;
  1055. $features = explode('-',trim($value['features'],'-'));
  1056. foreach($features as $v)
  1057. {
  1058. $zh = explode('|',trim($t[$v]['zh'],'|'));
  1059. $pm[$t[$v]['classid']] = $zh[0];
  1060. }
  1061. $zh = implode(" ",$pm);
  1062. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1063. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1064. $info_list[$key]['title'] = $zh;
  1065. }
  1066. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  1067. $pagenum = ceil($total/$perpage);
  1068. $over = $total-($start+$perpage);
  1069. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1070. echo json_encode($rows);exit;
  1071. }
  1072. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  1073. $this->_Template('whlabel_typeck',$this->data);
  1074. }
  1075. //进销存导出
  1076. public function _whlabeckdc()
  1077. {
  1078. $prc = array();
  1079. $purchase = $this->purchase->find_all();
  1080. foreach($purchase as $k=>$v)
  1081. {
  1082. $prc[$v['id']] = $v['title'];
  1083. }
  1084. if(isset($_GET['excel']))
  1085. {
  1086. $where = "sku != 'Preset'";
  1087. //数据排序
  1088. $order_str = "id desc";
  1089. if(empty($page))
  1090. {
  1091. $start = 0;
  1092. $perpage = 1;
  1093. }
  1094. else
  1095. {
  1096. $start = ($page - 1)*$perpage;
  1097. }
  1098. $category = $this->input->get('category',true);
  1099. $color = $this->input->get('color',true);
  1100. $lowe = $this->input->get('lowe',true);
  1101. $lacetype = $this->input->get('lacetype',true);
  1102. $size = $this->input->get('size',true);
  1103. $density = $this->input->get('density',true);
  1104. $haircap = $this->input->get('haircap',true);
  1105. $sku = $this->input->get('sku',true);
  1106. $details = $this->input->get('details',true);
  1107. $warehouse = 13;
  1108. $excelid = $this->input->get('sid',true);
  1109. if($category)
  1110. {
  1111. $where .= " and features like '%-$category-%'";
  1112. }
  1113. if($color)
  1114. {
  1115. $where .= " and features like '%-$color-%'";
  1116. }
  1117. if($lowe)
  1118. {
  1119. $where .= " and features like '%-$lowe-%'";
  1120. }
  1121. if($lacetype)
  1122. {
  1123. $where .= " and features like '%-$lacetype-%'";
  1124. }
  1125. if($size)
  1126. {
  1127. $where .= " and features like '%-$size-%'";
  1128. }
  1129. if($density)
  1130. {
  1131. $where .= " and features like '%-$density-%'";
  1132. }
  1133. if($haircap)
  1134. {
  1135. $where .= " and features like '%-$haircap-%'";
  1136. }
  1137. if($warehouse)
  1138. {
  1139. $where .= " and warehouse = '$warehouse'";
  1140. }
  1141. if($sku)
  1142. {
  1143. $where .= " and sku like '%$sku%'";
  1144. }
  1145. if($details)
  1146. {
  1147. $where .= " and details = '$details'";
  1148. }
  1149. $xzid = '';
  1150. if($excelid)
  1151. {
  1152. $excelid = explode(',',trim($excelid,','));
  1153. foreach ($excelid as $key=>$value)
  1154. {
  1155. $xzid .= " id = ".$value." or";
  1156. }
  1157. $xzid = " and (".rtrim($xzid,'or').")";;
  1158. }
  1159. //取得信息列表
  1160. /**
  1161. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1162. $rows = array();$list = array();
  1163. foreach ($info_list as $key=>$value)
  1164. {
  1165. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1166. }
  1167. **/
  1168. $wh = array();
  1169. $w = $this->warehouse->find_all('1=1','id,title');
  1170. foreach ($w as $v)
  1171. {
  1172. $wh[$v['id']] = $v['title'];
  1173. }
  1174. $tc = array();$tcdata = array();
  1175. $typeclass = $this->typeclass->find_all();
  1176. foreach ($typeclass as $v)
  1177. {
  1178. $tc[$v['id']] = $v;
  1179. }
  1180. $list = array();
  1181. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1182. foreach ($rows as $key=>$value)
  1183. {
  1184. $bm = '03';
  1185. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1186. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1187. $classid = $this->classid->sku();
  1188. $pm = $classid;
  1189. $jm = $classid;
  1190. $features = explode('-',trim($value['features'],'-'));
  1191. foreach($features as $v)
  1192. {
  1193. if(isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']]))
  1194. {
  1195. if($tc[$v]['bm'] != '')
  1196. {
  1197. $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
  1198. }
  1199. }
  1200. if(isset($tc[$v]))
  1201. {
  1202. $zh = explode('|',trim($tc[$v]['zh'],'|'));
  1203. $pm[$tc[$v]['classid']] = $zh[0];
  1204. }
  1205. if(isset($tc[$v]))
  1206. {
  1207. if(isset($jm[$tc[$v]['classid']]))
  1208. {
  1209. $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
  1210. }
  1211. }
  1212. }
  1213. $zh = implode(" ",$pm);
  1214. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1215. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1216. $rows[$key]['dbcontent'] = $zh;
  1217. $rows[$key]['cpbz'] = $bm.implode("",$bmpx);
  1218. $jm = array_filter($jm);
  1219. $rows[$key]['cs'] = implode("-",$jm);
  1220. $sd = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,cpbz,state');
  1221. $details = array();
  1222. $cpid = array();
  1223. $cpbz = array();
  1224. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  1225. foreach ($sd as $k=>$v)
  1226. {
  1227. if($v['state'] == 0)
  1228. {
  1229. $c++;
  1230. }
  1231. if($v['state'] != 9)
  1232. {
  1233. $g++;
  1234. }
  1235. if($v['state'] == 1)
  1236. {
  1237. $x++;
  1238. }
  1239. if($v['state'] == 2)
  1240. {
  1241. $t++;
  1242. }
  1243. if($v['state'] == 8)
  1244. {
  1245. $s++;
  1246. }
  1247. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  1248. {
  1249. $q++;
  1250. }
  1251. $details[$v['details']] = $v['details'];
  1252. if($v['cpid'] != 0)
  1253. {
  1254. $cpid[$v['cpid']] = $v['cpid'];
  1255. }
  1256. if($v['cpbz'] != '')
  1257. {
  1258. $cpbz[$v['cpbz']] = $v['cpbz'];
  1259. }
  1260. }
  1261. $rows[$key]['details'] = implode("、",$details);
  1262. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  1263. $number = $value['number'];
  1264. $ftime = time()-15*24*3600;
  1265. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1266. $rows[$key]['number'] = $g;
  1267. $rows[$key]['features'] = $c;
  1268. $rows[$key]['x'] = $x;
  1269. $rows[$key]['t'] = $t;
  1270. $rows[$key]['s'] = $s;
  1271. $rows[$key]['q'] = $q;
  1272. $rows[$key]['wzsl'] = count($details);
  1273. }
  1274. $title = "进销存统计表".date('Y-m-d',time());
  1275. $titlename = "<table border=1>
  1276. <tr><th colspan='12' align='center'><h3>".$title."<h3></th></tr>
  1277. <tr align='center'>
  1278. <td>仓库</td>
  1279. <td>供应商</td>
  1280. <td>位置</td>
  1281. <td>库存编码</td>
  1282. <td>SKU</td>
  1283. <td>用友编码</td>
  1284. <td>用友料号</td>
  1285. <td>产品英文名</td>
  1286. <td>产品中文名</td>
  1287. <td>入库总量</td>
  1288. <td>库存数量</td>
  1289. <td>销售数量</td>
  1290. <td>退货数量</td>
  1291. <td>删除数量</td>
  1292. <td>其它操作</td>
  1293. <td>位置数量</td>
  1294. </tr>
  1295. </table>";
  1296. $filename = $title.".xls";
  1297. $tail = "";
  1298. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1299. }
  1300. }
  1301. public function _type()
  1302. {
  1303. $vip = 0;
  1304. if(isset($_SESSION['api']))
  1305. {
  1306. $user = $this->user->get_api($_SESSION['api']);
  1307. $fgshop = "";$sid = "";
  1308. $usersp = explode('|',trim($user['shop'],'|'));
  1309. foreach ($usersp as $value)
  1310. {
  1311. $fgshop .= " shop = ".$value." or";
  1312. $sid .= " id = ".$value." or";
  1313. }
  1314. if($user['vip'] == 1)
  1315. {
  1316. $vip = 1;
  1317. }
  1318. }
  1319. else
  1320. {
  1321. header('Location: /');exit;
  1322. }
  1323. $prc = array();
  1324. $purchase = $this->purchase->find_all();
  1325. foreach($purchase as $k=>$v)
  1326. {
  1327. $prc[$v['id']] = $v['title'];
  1328. }
  1329. $sp = array();
  1330. $s = $this->shop->find_all('1=1','id,shopname');
  1331. foreach ($s as $v)
  1332. {
  1333. $sp[$v['id']] = $v['shopname'];
  1334. }
  1335. $wh = array();
  1336. $w = $this->warehouse->find_all('1=1','id,title');
  1337. foreach ($w as $v)
  1338. {
  1339. $wh[$v['id']] = $v['title'];
  1340. }
  1341. $post = $this->input->post(NULL, TRUE);
  1342. if(isset($post['page']))
  1343. {
  1344. $page = $this->input->post('page',true);
  1345. $perpage = $this->input->post('perpage',true);
  1346. $category = $this->input->post('category',true);
  1347. $size = $this->input->post('size',true);
  1348. $grade = $this->input->post('grade',true);
  1349. $color = $this->input->post('color',true);
  1350. $lowe = $this->input->post('lowe',true);
  1351. $sku = $this->input->post('sku');
  1352. $title = $this->input->post('title');
  1353. $warehouse = $this->input->post('warehouse',true);
  1354. $usa = $this->input->post('usa',true);
  1355. $purchase = $this->input->post('purchase',true);
  1356. $lacetype = $this->input->post('lacetype',true);
  1357. $haircap = $this->input->post('haircap',true);
  1358. $density = $this->input->post('density',true);
  1359. $details = $this->input->post('details',true);
  1360. $state = $this->input->post('state',true);
  1361. $shop = $this->input->post('shop',true);
  1362. $lacecolor = $this->input->post('lacecolor',true);
  1363. $ktime = $this->input->post('ktime',true);
  1364. $jtime = $this->input->post('jtime',true);
  1365. $ktime = strtotime($ktime);
  1366. $jtime = strtotime($jtime);
  1367. $where = "1=1";$gj = "";$ck = "";
  1368. if($lacetype)
  1369. {
  1370. $where .= " and features like '%-$lacetype-%'";
  1371. }
  1372. if($category)
  1373. {
  1374. $where .= " and features like '%-$category-%'";
  1375. }
  1376. if($size)
  1377. {
  1378. $where .= " and features like '%-$size-%'";
  1379. }
  1380. if($grade)
  1381. {
  1382. $where .= " and features like '%-$grade-%'";
  1383. }
  1384. if($color)
  1385. {
  1386. $where .= " and features like '%-$color-%'";
  1387. }
  1388. if($lowe)
  1389. {
  1390. $where .= " and features like '%-$lowe-%'";
  1391. }
  1392. if($haircap)
  1393. {
  1394. $where .= " and features like '%-$haircap-%'";
  1395. }
  1396. if($density)
  1397. {
  1398. $where .= " and features like '%-$density-%'";
  1399. }
  1400. if($usa)
  1401. {
  1402. if(!$warehouse)
  1403. {
  1404. $where .= " and (warehouse = '5' or warehouse = '8')";
  1405. }
  1406. }
  1407. if($warehouse)
  1408. {
  1409. $where .= " and warehouse = '$warehouse'";
  1410. }
  1411. if($details)
  1412. {
  1413. $where .= " and details = '$details'";
  1414. }
  1415. if($purchase)
  1416. {
  1417. $where .= " and purchase = '$purchase'";
  1418. }
  1419. if($state)
  1420. {
  1421. $where .= " and state = '$state'";
  1422. }
  1423. if($shop)
  1424. {
  1425. $where .= " and shop like '%$shop%'";
  1426. }
  1427. if($lacecolor)
  1428. {
  1429. $where .= " and features like '%-$lacecolor-%'";
  1430. }
  1431. if($ktime && $jtime)
  1432. {
  1433. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1434. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1435. }
  1436. //数据排序
  1437. $order_str = "id desc";
  1438. if(empty($page))
  1439. {
  1440. $start = 0;
  1441. $perpage = 1;
  1442. }
  1443. else
  1444. {
  1445. $start = ($page - 1)*$perpage;
  1446. }
  1447. $fjnr = '';
  1448. if($sku)
  1449. {
  1450. $sku = trim($sku,' ');
  1451. $sku = trim($sku,' ');
  1452. $fjnr .= " and sku like '%$sku%'";
  1453. }
  1454. if($title)
  1455. {
  1456. $title = trim($title,' ');
  1457. $title = trim($title,' ');
  1458. $fjnr .= " and title like '%$title%'";
  1459. }
  1460. $wt = array();
  1461. $whlabel_type = $this->whlabel_type->find_all();
  1462. foreach ($whlabel_type as $v)
  1463. {
  1464. $wt[$v['id']] = $v['title'];
  1465. }
  1466. //$where .= " and time > '$ktime' and time < '$jtime'";
  1467. $info_list = $this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,type,features,number',$order_str,$start,$perpage);//改这需要修改_gbhtype
  1468. //取得信息列表
  1469. $rows = array();$list = array();
  1470. foreach ($info_list as $key=>$value)
  1471. {
  1472. if(isset($wt[$value['type']]))
  1473. {
  1474. $info_list[$key]['type'] = $wt[$value['type']];
  1475. }
  1476. else
  1477. {
  1478. $info_list[$key]['type'] = '未设置';
  1479. }
  1480. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1481. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1482. $ztdata = '';
  1483. if(count($zt) > 0)
  1484. {
  1485. foreach ($zt as $vv)
  1486. {
  1487. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1488. }
  1489. }
  1490. $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');
  1491. $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'].'"');
  1492. $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'].'"');
  1493. $t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1494. $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'].'"');
  1495. $od = array();$odid = '';
  1496. foreach ($z as $v)
  1497. {
  1498. if(!isset($od[$v['zd']]))
  1499. {
  1500. $od[$v['zd']] = 1;//所有数据sku
  1501. }
  1502. else
  1503. {
  1504. $od[$v['zd']] = $od[$v['zd']]+1;
  1505. }
  1506. }
  1507. foreach ($od as $k=>$vv)
  1508. {
  1509. $odid .= $k.'数量'.$vv;
  1510. }
  1511. $number = $value['number'];$ftime = time()-15*24*3600;
  1512. $z = count($z).'('.$odid.')';//查看订单号
  1513. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:'无';
  1514. $info_list[$key]['features'] = count($c);
  1515. $info_list[$key]['number'] = $ztdata;
  1516. $info_list[$key]['g'] = $g;
  1517. $info_list[$key]['x'] = $x;
  1518. $info_list[$key]['t'] = $t;
  1519. $info_list[$key]['z'] = $z;
  1520. $details = array();
  1521. $cpid = array();
  1522. foreach ($c as $k=>$v)
  1523. {
  1524. $details[$v['details']] = $v['details'];
  1525. if($v['cpid'] != 0)
  1526. {
  1527. $cpid[$v['cpid']] = $v['cpid'];
  1528. }
  1529. }
  1530. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1531. if($value['shop'] != '')
  1532. {
  1533. $shop = explode(',',trim($value['shop'],','));
  1534. $info_list[$key]['shop'] = $sp[$shop[0]];
  1535. }
  1536. }
  1537. $total = count($this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,sku,title,features,number'));
  1538. $pagenum = ceil($total/$perpage);
  1539. $over = $total-($start+$perpage);
  1540. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  1541. echo json_encode($rows);exit;
  1542. }
  1543. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1544. $this->data['shop'] = $wlshop;
  1545. $this->data['vip'] = $vip;
  1546. $this->_Template('whlabel_type',$this->data);
  1547. }
  1548. //美仓进销存浏览
  1549. public function _usatype()
  1550. {
  1551. if(isset($_SESSION['api']))
  1552. {
  1553. $user = $this->user->get_api($_SESSION['api']);
  1554. $usp = $user;
  1555. $fgshop = "";$sid = "";$wid="";$wtype="";
  1556. $userwh = explode('|',trim($user['warehouse'],'|'));
  1557. foreach ($userwh as $value)
  1558. {
  1559. $wid .= " id = ".$value." or";
  1560. $wtype .= " type = ".$value." or";
  1561. }
  1562. }
  1563. $prc = array();
  1564. $purchase = $this->purchase->find_all();
  1565. foreach($purchase as $k=>$v)
  1566. {
  1567. $prc[$v['id']] = $v['title'];
  1568. }
  1569. $post = $this->input->post(NULL, TRUE);
  1570. if(isset($post['page']))
  1571. {
  1572. $page = $this->input->post('page',true);
  1573. $perpage = $this->input->post('perpage',true);
  1574. $category = $this->input->post('category',true);
  1575. $size = $this->input->post('size',true);
  1576. $grade = $this->input->post('grade',true);
  1577. $color = $this->input->post('color',true);
  1578. $lowe = $this->input->post('lowe',true);
  1579. $sku = $this->input->post('sku');
  1580. $title = $this->input->post('title');
  1581. $warehouse = $this->input->post('warehouse',true);
  1582. $usa = $this->input->post('usa',true);
  1583. $purchase = $this->input->post('purchase',true);
  1584. $lacetype = $this->input->post('lacetype',true);
  1585. $haircap = $this->input->post('haircap',true);
  1586. $density = $this->input->post('density',true);
  1587. $details = $this->input->post('details',true);
  1588. $state = $this->input->post('state',true);
  1589. $lacecolor = $this->input->post('lacecolor',true);
  1590. $cklx = $this->input->post('cklx',true);
  1591. $ktime = $this->input->post('ktime',true);
  1592. $jtime = $this->input->post('jtime',true);
  1593. $ktime = strtotime($ktime);
  1594. $jtime = strtotime($jtime);
  1595. $where = "1=1";$gj = "";$ck = "";
  1596. if($lacetype)
  1597. {
  1598. $where .= " and features like '%-$lacetype-%'";
  1599. }
  1600. if($category)
  1601. {
  1602. $where .= " and features like '%-$category-%'";
  1603. }
  1604. if($size)
  1605. {
  1606. $where .= " and features like '%-$size-%'";
  1607. }
  1608. if($grade)
  1609. {
  1610. $where .= " and features like '%-$grade-%'";
  1611. }
  1612. if($color)
  1613. {
  1614. $where .= " and features like '%-$color-%'";
  1615. }
  1616. if($lowe)
  1617. {
  1618. $where .= " and features like '%-$lowe-%'";
  1619. }
  1620. if($haircap)
  1621. {
  1622. $where .= " and features like '%-$haircap-%'";
  1623. }
  1624. if($density)
  1625. {
  1626. $where .= " and features like '%-$density-%'";
  1627. }
  1628. if($lacecolor)
  1629. {
  1630. $where .= " and features like '%-$lacecolor-%'";
  1631. }
  1632. if($usa)
  1633. {
  1634. if(!$warehouse)
  1635. {
  1636. $where .= " and (warehouse = '5' or warehouse = '8')";
  1637. }
  1638. }
  1639. if($warehouse)
  1640. {
  1641. $where .= " and warehouse = '$warehouse'";
  1642. }
  1643. if($details)
  1644. {
  1645. $where .= " and details = '$details'";
  1646. }
  1647. if($purchase)
  1648. {
  1649. $where .= " and purchase = '$purchase'";
  1650. }
  1651. if($state)
  1652. {
  1653. $where .= " and state = '$state'";
  1654. }
  1655. $where_add = '';
  1656. if($cklx)
  1657. {
  1658. $shop = $this->shop->read($cklx);
  1659. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  1660. }
  1661. if($ktime && $jtime)
  1662. {
  1663. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1664. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1665. }
  1666. //数据排序
  1667. $order_str = "id desc";
  1668. if(empty($page))
  1669. {
  1670. $start = 0;
  1671. $perpage = 1;
  1672. }
  1673. else
  1674. {
  1675. $start = ($page - 1)*$perpage;
  1676. }
  1677. if($sku)
  1678. {
  1679. $sku = trim($sku,' ');
  1680. $sku = trim($sku,' ');
  1681. $where .= " and sku like '%$sku%'";
  1682. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1683. }
  1684. else if($title)
  1685. {
  1686. $title = trim($title,' ');
  1687. $title = trim($title,' ');
  1688. $where .= " and title like '%$title%'";
  1689. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1690. }
  1691. else
  1692. {
  1693. //$where .= " and time > '$ktime' and time < '$jtime'";
  1694. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1695. }
  1696. //取得信息列表
  1697. $rows = array();$list = array();
  1698. foreach ($info_list as $key=>$value)
  1699. {
  1700. $warehouse = $this->warehouse->read($value['warehouse']);
  1701. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1702. $g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1703. $x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1704. $t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1705. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1706. $od = array();$odid = '';
  1707. foreach ($z as $v)
  1708. {
  1709. if(!isset($od[$v['zd']]))
  1710. {
  1711. $od[$v['zd']] = 1;//所有数据sku
  1712. }
  1713. else
  1714. {
  1715. $od[$v['zd']] = $od[$v['zd']]+1;
  1716. }
  1717. }
  1718. foreach ($od as $k=>$vv)
  1719. {
  1720. $odid .= $k.'数量'.$vv.' ';
  1721. }
  1722. $z = count($z).'('.$odid.')';//查看订单号
  1723. $info_list[$key]['features'] = $c;
  1724. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1725. $ztdata = '';
  1726. if(count($zt) > 0)
  1727. {
  1728. foreach ($zt as $vv)
  1729. {
  1730. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1731. }
  1732. }
  1733. $info_list[$key]['warehouse'] = $ztdata;
  1734. $info_list[$key]['g'] = $g;
  1735. $info_list[$key]['x'] = $x;
  1736. $info_list[$key]['t'] = $t;
  1737. $info_list[$key]['z'] = $z;
  1738. }
  1739. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title'));
  1740. $pagenum = ceil($total/$perpage);
  1741. $over = $total-($start+$perpage);
  1742. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1743. echo json_encode($rows);exit;
  1744. }
  1745. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1746. $this->data['warehouse'] = $warehouse;
  1747. $this->_Template('whlabel_typeusa',$this->data);
  1748. }
  1749. //美仓进销存浏览
  1750. public function _usatypeapp()
  1751. {
  1752. $post = $this->input->post(NULL, TRUE);
  1753. if(isset($post['page']))
  1754. {
  1755. $page = $this->input->post('page',true);
  1756. $perpage = $this->input->post('perpage',true);
  1757. $sku = $this->input->post('sku',true);
  1758. $warehouse = 5;
  1759. $title = $this->input->post('title',true);
  1760. $state = $this->input->post('state',true);
  1761. $ktime = $this->input->post('ktime',true);
  1762. $jtime = $this->input->post('jtime',true);
  1763. $ktime = strtotime($ktime);
  1764. $jtime = strtotime($jtime);
  1765. $where = "1=1";$gj = "";$ck = "";
  1766. if($title)
  1767. {
  1768. $st = explode(' ',trim($title,' '));
  1769. foreach ($st as $v)
  1770. {
  1771. $where .= " and title like '%$v%'";
  1772. }
  1773. }
  1774. if($warehouse)
  1775. {
  1776. $where .= " and warehouse = '$warehouse'";
  1777. }
  1778. if($state)
  1779. {
  1780. $where .= " and state = '$state'";
  1781. }
  1782. if($sku)
  1783. {
  1784. $where .= " and sku like '%$sku%'";
  1785. }
  1786. if($ktime && $jtime)
  1787. {
  1788. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1789. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1790. }
  1791. //数据排序
  1792. $order_str = "id desc";
  1793. if(empty($page))
  1794. {
  1795. $start = 0;
  1796. $perpage = 1;
  1797. }
  1798. else
  1799. {
  1800. $start = ($page - 1)*$perpage;
  1801. }
  1802. //取得信息列表
  1803. $info_list = $this->whlabel->find_all($where.' and '.rtrim($wid,'or'),'*');
  1804. $rows = array();$list = array();
  1805. foreach ($info_list as $key=>$value)
  1806. {
  1807. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1808. }
  1809. $rowsdq = array_slice($rows,$start,$perpage);
  1810. foreach ($rowsdq as $value)
  1811. {
  1812. $warehouse = $this->warehouse->read($value['warehouse']);
  1813. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'"');
  1814. $x = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'"');
  1815. $t = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1816. $od = array();$odid = '';
  1817. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'x'=>$x,'t'=>$t);
  1818. }
  1819. $total = count($rows);
  1820. $pagenum = ceil($total/$perpage);
  1821. $over = $total-($start+$perpage);
  1822. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1823. echo json_encode($rows);exit;
  1824. }
  1825. $this->_Template('phone/p_usatypeapp',$this->data);
  1826. }
  1827. //入库操作
  1828. public function _enteradd()
  1829. {
  1830. $dt = 0;
  1831. if(isset($_SESSION['api']))
  1832. {
  1833. $user = $this->user->get_api($_SESSION['api']);
  1834. $usp = $user;
  1835. $fgshop = "";$sid = "";
  1836. $user = explode('|',trim($user['shop'],'|'));
  1837. foreach ($user as $value)
  1838. {
  1839. $fgshop .= " shop = ".$value." or";
  1840. $sid .= " id = ".$value." or";
  1841. }
  1842. }
  1843. $tc = $this->typeclass->find_all();
  1844. $typeclass = array();
  1845. foreach ($tc as $v)
  1846. {
  1847. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1848. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'bqsku'=>$v['bqsku']);
  1849. }
  1850. $post = $this->input->post(NULL, TRUE);
  1851. if(isset($post['sku']))
  1852. {
  1853. $list = array();$num = "";$title = "";$features = "";
  1854. $order = $this->input->post('order',true);
  1855. $shop = $this->input->post('shop',true);
  1856. $post['shop'] = ($shop!="")?','.$shop:"";
  1857. $sku = $this->input->post('sku',true);
  1858. $post['warehouse'] = $this->input->post('warehouse',true);
  1859. $post['purchase'] = $this->input->post('purchase',true);
  1860. $post['retreatwarehouse'] = $post['warehouse'];
  1861. $post['state'] = $this->input->post('state',true);
  1862. $category = $this->input->post('category',true);
  1863. $list['category'] = $category;
  1864. $list['hairtype'] = $this->input->post('hairtype',true);
  1865. $list['grade'] = $this->input->post('grade',true);
  1866. $size = $this->input->post('size',true);
  1867. $xzsku = $this->input->post('xzsku',true);
  1868. $list['size'] = rtrim($size,',');
  1869. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1870. $list['extension'] = $this->input->post('extension',true);
  1871. if($category == 1297)
  1872. {
  1873. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1874. }
  1875. if($category == 1702)
  1876. {
  1877. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1878. $list['syother'] = $this->input->post('syother',true);
  1879. }
  1880. if($category == 133)
  1881. {
  1882. $list['fittype'] = $this->input->post('fittype',true);
  1883. $list['acother'] = $this->input->post('acother',true);
  1884. }
  1885. $list['color'] = $this->input->post('color',true);
  1886. $list['lowe'] = $this->input->post('lowe',true);
  1887. if(!$post['purchase'])
  1888. {
  1889. $post['purchase'] = 1;
  1890. }
  1891. if($category == 127)
  1892. {
  1893. $list['type'] = $this->input->post('type',true);
  1894. $list['headroad'] = $this->input->post('headroad',true);
  1895. $list['density'] = $this->input->post('density',true);
  1896. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  1897. {
  1898. $list['lacesize'] = $this->input->post('lacesize',true);
  1899. }
  1900. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1901. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1902. }
  1903. if($category == 128)
  1904. {
  1905. $list['lacetype'] = $this->input->post('lacetype',true);
  1906. $list['haircap'] = $this->input->post('haircap',true);
  1907. $list['density'] = $this->input->post('density',true);
  1908. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1909. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1910. $list['wigother'] = $this->input->post('wigother',true);
  1911. }
  1912. if($category == 129)
  1913. {
  1914. $list['wide'] = $this->input->post('wide',true);
  1915. }
  1916. if($category == 131)
  1917. {
  1918. $list['gifttype'] = $this->input->post('gifttype',true);
  1919. $list['giftother'] = $this->input->post('giftother',true);
  1920. }
  1921. if($category == 134)
  1922. {
  1923. $list['pieceweight'] = $this->input->post('pieceweight',true);
  1924. }
  1925. if($category == 1297)
  1926. {
  1927. $list['synthetictype'] = $this->input->post('synthetictype',true);
  1928. $list['sywigother'] = $this->input->post('sywigother',true);
  1929. }
  1930. if($category == 130 || $category == 133 || $category == 1702)
  1931. {
  1932. $list['items'] = $this->input->post('items',true);
  1933. }
  1934. if($category == 1702)
  1935. {
  1936. $list['syhairther'] = $this->input->post('syhairther',true);
  1937. }
  1938. $classid = $this->classid->sku();
  1939. $scsku = $classid;
  1940. $pm = $classid;
  1941. foreach($list as $k=>$v)
  1942. {
  1943. if($v != 0)
  1944. {
  1945. $num .=$v;
  1946. $features .=$v.'-';
  1947. $post[$k] = $v;
  1948. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1949. if($k != 'size')
  1950. {
  1951. $title .= $typeclass[$v]['title']." ";
  1952. }
  1953. if(isset($pm[$typeclass[$v]['classid']]))
  1954. {
  1955. if($typeclass[$v]['title'] == '9A')
  1956. {
  1957. $pm[$typeclass[$v]['classid']] = '9A';
  1958. }
  1959. else if($typeclass[$v]['title'] == '10A')
  1960. {
  1961. $pm[$typeclass[$v]['classid']] = '10A';
  1962. }
  1963. else
  1964. {
  1965. $clzh = $typeclass[$v]['zh'];
  1966. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1967. {
  1968. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1969. $clzh = $clzh[0];
  1970. }
  1971. $pm[$typeclass[$v]['classid']] = $clzh;
  1972. }
  1973. }
  1974. }
  1975. }
  1976. $zh = implode(" ",$pm);
  1977. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1978. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1979. if($list['size'])
  1980. {
  1981. $typeclass = $this->typeclass->read($list['size']);
  1982. $title .= $typeclass['title'];
  1983. }
  1984. $time = time();
  1985. if($xzsku)
  1986. {
  1987. $scsku = implode("-",$scsku);
  1988. $scsku = str_replace('- ','-',trim($scsku,'-'));
  1989. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  1990. $post['sku'] = trim($scsku,' ');
  1991. }
  1992. else
  1993. {
  1994. $post['sku'] = $sku;
  1995. }
  1996. //$post['sku'] = trim($sku,' ');
  1997. $post['title'] = rtrim($title,' ');
  1998. $post['number'] = $num;
  1999. $post['features'] = '-'.$features;
  2000. $post['enter'] = $time;
  2001. $post['time'] = $time;//操作时间
  2002. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2003. if($yza)
  2004. {
  2005. if($post['features'] != $yza[0]['features'])
  2006. {
  2007. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'success'=>false));exit;
  2008. }
  2009. }
  2010. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2011. if($yzb)
  2012. {
  2013. if($post['sku'] != $yzb[0]['sku'])
  2014. {
  2015. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','success'=>false));exit;
  2016. }
  2017. }
  2018. $yz = $this->whlabel->find_all("sku = '".$post['sku']."' and features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'",'type');
  2019. if(isset($yz[0]['type']))
  2020. {
  2021. $post['type'] = $yz[0]['type'];
  2022. }
  2023. if($post['state'] == 9)//如果选择预设库存
  2024. {
  2025. $this->whlabel->insert($post);
  2026. }
  2027. else
  2028. {
  2029. /**
  2030. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2031. if($ljg == 1)
  2032. {
  2033. for($i=0;$i<$order;$i++)
  2034. {
  2035. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2036. $this->whlabel->insert($post);
  2037. }
  2038. }
  2039. **/
  2040. //if($post['warehouse'] == '5')
  2041. //{
  2042. //}
  2043. $yydata = $post;
  2044. $yydata['zh'] = $zh;
  2045. /**
  2046. $wl = $this->apiyy->get_cjlp($yydata);
  2047. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2048. {
  2049. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2050. }
  2051. if($wl['Data'][0]['m_isSucess'] != 1)
  2052. {
  2053. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2054. }
  2055. **/
  2056. for($i=0;$i<$order;$i++)
  2057. {
  2058. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2059. $this->whlabel->insert($post);
  2060. }
  2061. }
  2062. echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
  2063. }
  2064. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2065. $this->data['wlshop'] = $wlshop;
  2066. $this->_Template('whlabel_enteradd',$this->data);
  2067. }
  2068. //修改产品
  2069. public function _enteredit($arg_array)
  2070. {
  2071. $dt = 0;
  2072. if(isset($_SESSION['api']))
  2073. {
  2074. $user = $this->user->get_api($_SESSION['api']);
  2075. $usp = $user;
  2076. $fgshop = "";$sid = "";
  2077. $user = explode('|',trim($user['shop'],'|'));
  2078. foreach ($user as $value)
  2079. {
  2080. $fgshop .= " shop = ".$value." or";
  2081. $sid .= " id = ".$value." or";
  2082. }
  2083. }
  2084. $post = $this->input->post(NULL, TRUE);
  2085. if(isset($post['sku']))
  2086. {
  2087. $list = array();$num = "";$title = "";$features = "";
  2088. $id = $this->input->post('id',true);
  2089. $order = $this->input->post('order',true);
  2090. $shop = $this->input->post('shop',true);
  2091. $post['shop'] = ($shop!="")?','.$shop:"";
  2092. $post['sku'] = $this->input->post('sku',true);
  2093. $post['warehouse'] = $this->input->post('warehouse',true);
  2094. $post['purchase'] = $this->input->post('purchase',true);
  2095. $post['retreatwarehouse'] = $post['warehouse'];
  2096. $category = $this->input->post('category',true);
  2097. $list['category'] = $category;
  2098. $list['hairtype'] = $this->input->post('hairtype',true);
  2099. $list['grade'] = $this->input->post('grade',true);
  2100. $size = $this->input->post('size',true);
  2101. $list['size'] = rtrim($size,',');
  2102. $list['hairnumber'] = $this->input->post('hairnumber',true);
  2103. $list['extension'] = $this->input->post('extension',true);
  2104. if($category == 1297)
  2105. {
  2106. $list['sywignumber'] = $this->input->post('sywignumber',true);
  2107. }
  2108. if($category == 1702)
  2109. {
  2110. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  2111. $list['syother'] = $this->input->post('syother',true);
  2112. }
  2113. if($category == 133)
  2114. {
  2115. $list['fittype'] = $this->input->post('fittype',true);
  2116. $list['acother'] = $this->input->post('acother',true);
  2117. }
  2118. $list['color'] = $this->input->post('color',true);
  2119. $list['lowe'] = $this->input->post('lowe',true);
  2120. if(!$post['purchase'])
  2121. {
  2122. $post['purchase'] = 1;
  2123. }
  2124. if($category == 127)
  2125. {
  2126. $list['type'] = $this->input->post('type',true);
  2127. $list['headroad'] = $this->input->post('headroad',true);
  2128. $list['density'] = $this->input->post('density',true);
  2129. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  2130. {
  2131. $list['lacesize'] = $this->input->post('lacesize',true);
  2132. }
  2133. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2134. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2135. }
  2136. if($category == 128)
  2137. {
  2138. $list['lacetype'] = $this->input->post('lacetype',true);
  2139. $list['haircap'] = $this->input->post('haircap',true);
  2140. $list['density'] = $this->input->post('density',true);
  2141. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2142. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2143. $list['wigother'] = $this->input->post('wigother',true);
  2144. }
  2145. if($category == 129)
  2146. {
  2147. $list['wide'] = $this->input->post('wide',true);
  2148. }
  2149. if($category == 131)
  2150. {
  2151. $list['gifttype'] = $this->input->post('gifttype',true);
  2152. $list['giftother'] = $this->input->post('giftother',true);
  2153. }
  2154. if($category == 134)
  2155. {
  2156. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2157. }
  2158. if($category == 1297)
  2159. {
  2160. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2161. $list['sywigother'] = $this->input->post('sywigother',true);
  2162. }
  2163. if($category == 130 || $category == 133 || $category == 1702)
  2164. {
  2165. $list['items'] = $this->input->post('items',true);
  2166. }
  2167. if($category == 1702)
  2168. {
  2169. $list['syhairther'] = $this->input->post('syhairther',true);
  2170. }
  2171. foreach($list as $k=>$v)
  2172. {
  2173. if($v != 0)
  2174. {
  2175. $num .=$v;
  2176. $features .=$v.'-';
  2177. $typeclass = $this->typeclass->read($v);
  2178. if($k != 'size')
  2179. {
  2180. $title .= $typeclass['title']." ";
  2181. }
  2182. }
  2183. }
  2184. $typeclass = $this->typeclass->read($list['size']);
  2185. $title .= $typeclass['title'];
  2186. $time = time();
  2187. $post['title'] = rtrim($title,' ');
  2188. $post['number'] = $num;
  2189. $post['features'] = '-'.$features;
  2190. $post['time'] = $time;//操作时间
  2191. $uid = $this->whlabel->read($id);
  2192. $datanum = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2193. if($datanum > 0)
  2194. {
  2195. echo json_encode(array('msg'=>'此SKU有占单,请解除占单后再修改!','success'=>false));exit;
  2196. }
  2197. if($post['warehouse'] != '99999')//现在所有仓都检测,之前只有美仓5检测
  2198. {
  2199. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."'");
  2200. if($yza)
  2201. {
  2202. if($post['features'] != $yza[0]['features'])
  2203. {
  2204. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','success'=>false));exit;
  2205. }
  2206. }
  2207. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."'");
  2208. if($yzb)
  2209. {
  2210. if($post['sku'] != $yzb[0]['sku'])
  2211. {
  2212. echo json_encode(array('msg'=>'此产品信息的SKU和现有不一致!','success'=>false));exit;
  2213. }
  2214. }
  2215. $data = $this->whlabel->find_all("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2216. foreach ($data as $v)
  2217. {
  2218. $post['id'] = $v['id'];
  2219. $this->whlabel->save($post,$v['id']);
  2220. }
  2221. }
  2222. else
  2223. {
  2224. $data = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2225. if($data > 0)
  2226. {
  2227. echo json_encode(array('msg'=>'此产品有占单,无法修改!','success'=>false));exit;
  2228. }
  2229. else
  2230. {
  2231. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2232. foreach ($data as $v)
  2233. {
  2234. $post['id'] = $v['id'];
  2235. $this->whlabel->save($post,$v['id']);
  2236. }
  2237. }
  2238. }
  2239. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  2240. }
  2241. $uid = $this->whlabel->read($arg_array[0]);
  2242. $uid['order'] = $this->whlabel->find_count('enter = "'.$uid['enter'].'" and sku = "'.$uid['sku'].'" and state = "0"');
  2243. $this->data['enter'] = $uid ;
  2244. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2245. $this->data['wlshop'] = $wlshop;
  2246. $this->_Template('whlabel_enteredit',$this->data);
  2247. }
  2248. //入库浏览
  2249. public function _enter()
  2250. {
  2251. $post = $this->input->post(NULL, TRUE);
  2252. if(isset($post['s']))
  2253. {
  2254. $id_arr = $this->input->post('s');
  2255. $id_arr = explode(',',$id_arr);
  2256. if(!$id_arr)
  2257. {
  2258. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2259. }
  2260. //循环删除记录
  2261. foreach ($id_arr as $v)
  2262. {
  2263. $sid = $this->whlabel->read($v);
  2264. $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
  2265. if($count > 0)
  2266. {
  2267. echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
  2268. }
  2269. $info_list = $this->whlabel->find_all('enter ='.$sid['enter']);
  2270. foreach ($info_list as $va)
  2271. {
  2272. $this->whlabel->remove($va['id']);
  2273. }
  2274. }
  2275. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  2276. }
  2277. $sp = array();
  2278. $s = $this->shop->find_all('1=1','id,shopname');
  2279. foreach ($s as $v)
  2280. {
  2281. $sp[$v['id']] = $v['shopname'];
  2282. }
  2283. $wh = array();
  2284. $w = $this->warehouse->find_all('1=1','id,title');
  2285. foreach ($w as $v)
  2286. {
  2287. $wh[$v['id']] = $v['title'];
  2288. }
  2289. if(isset($post['page']))
  2290. {
  2291. $page = $this->input->post('page',true);
  2292. $perpage = $this->input->post('perpage',true);
  2293. $category = $this->input->post('category',true);
  2294. $size = $this->input->post('size',true);
  2295. $grade = $this->input->post('grade',true);
  2296. $color = $this->input->post('color',true);
  2297. $lowe = $this->input->post('lowe',true);
  2298. $sku = $this->input->post('sku',true);
  2299. $warehouse = $this->input->post('warehouse',true);
  2300. $purchase = $this->input->post('purchase',true);
  2301. $ktime = $this->input->post('ktime',true);
  2302. $jtime = $this->input->post('jtime',true);
  2303. $ktime = strtotime($ktime);
  2304. $jtime = strtotime($jtime);
  2305. $where = "1=1";$gj = "";$ck = "";
  2306. if($category)
  2307. {
  2308. $where .= " and features like '%-$category-%'";
  2309. }
  2310. if($size)
  2311. {
  2312. $where .= " and features like '%-$size-%'";
  2313. }
  2314. if($grade)
  2315. {
  2316. $where .= " and features like '%-$grade-%'";
  2317. }
  2318. if($color)
  2319. {
  2320. $where .= " and features like '%-$color-%'";
  2321. }
  2322. if($lowe)
  2323. {
  2324. $where .= " and features like '%-$lowe-%'";
  2325. }
  2326. if($warehouse)
  2327. {
  2328. $where .= " and warehouse = '$warehouse'";
  2329. }
  2330. if($purchase)
  2331. {
  2332. $where .= " and purchase = '$purchase'";
  2333. }
  2334. if($sku)
  2335. {
  2336. $where .= " and sku like '%$sku%'";
  2337. }
  2338. if($ktime && $jtime)
  2339. {
  2340. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2341. }
  2342. //数据排序
  2343. $order_str = "enter desc";
  2344. if(empty($page))
  2345. {
  2346. $start = 0;
  2347. $perpage = 1;
  2348. }
  2349. else
  2350. {
  2351. $start = ($page - 1)*$perpage;
  2352. }
  2353. //取得信息列表
  2354. $info_list = $this->whlabel->find_pc($where,'enter,warehouse,sku','id,warehouse,shop,sku,title,enter',$order_str,$start,$perpage);
  2355. foreach ($info_list as $k=>$v)
  2356. {
  2357. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2358. if($v['shop']=='')
  2359. {
  2360. $s = '通用';
  2361. }
  2362. else
  2363. {
  2364. $info_list[$k]['shop'] = '';
  2365. foreach (explode(',',trim($v['shop'],',')) as $val)
  2366. {
  2367. $info_list[$k]['shop'] .= $sp[$val].'</br>';
  2368. }
  2369. }
  2370. $info_list[$k]['enter'] = date('Y-m-d H:i:s',$v['enter']);
  2371. $g = $this->whlabel->find_count($where.' and enter = "'.$v['enter'].'" and sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'"');
  2372. $info_list[$k]['g'] = $g;
  2373. }
  2374. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  2375. $pagenum = ceil($total/$perpage);
  2376. $over = $total-($start+$perpage);
  2377. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2378. echo json_encode($rows);exit;
  2379. }
  2380. $this->_Template('whlabel_enter',$this->data);
  2381. }
  2382. //出库浏览
  2383. public function _out()
  2384. {
  2385. $post = $this->input->post(NULL, TRUE);
  2386. if(isset($post['page']))
  2387. {
  2388. $page = $this->input->post('page',true);
  2389. $perpage = $this->input->post('perpage',true);
  2390. $category = $this->input->post('category',true);
  2391. $size = $this->input->post('size',true);
  2392. $grade = $this->input->post('grade',true);
  2393. $color = $this->input->post('color',true);
  2394. $lowe = $this->input->post('lowe',true);
  2395. $sku = $this->input->post('sku',true);
  2396. $warehouse = $this->input->post('warehouse',true);
  2397. $purchase = $this->input->post('purchase',true);
  2398. $ktime = $this->input->post('ktime',true);
  2399. $jtime = $this->input->post('jtime',true);
  2400. $ktime = strtotime($ktime);
  2401. $jtime = strtotime($jtime);
  2402. $where = "state=3";$gj = "";$ck = "";
  2403. if($category)
  2404. {
  2405. $where .= " and features like '%-$category-%'";
  2406. }
  2407. if($size)
  2408. {
  2409. $where .= " and features like '%-$size-%'";
  2410. }
  2411. if($grade)
  2412. {
  2413. $where .= " and features like '%-$grade-%'";
  2414. }
  2415. if($color)
  2416. {
  2417. $where .= " and features like '%-$color-%'";
  2418. }
  2419. if($lowe)
  2420. {
  2421. $where .= " and features like '%-$lowe-%'";
  2422. }
  2423. if($state)
  2424. {
  2425. $where .= " and state = '$state'";
  2426. }
  2427. if($warehouse)
  2428. {
  2429. $where .= " and warehouse = '$warehouse'";
  2430. }
  2431. if($purchase)
  2432. {
  2433. $where .= " and purchase = '$purchase'";
  2434. }
  2435. if($sku)
  2436. {
  2437. $where .= " and sku = '$sku'";
  2438. }
  2439. if($ktime && $jtime)
  2440. {
  2441. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2442. }
  2443. //数据排序
  2444. $order_str = "id desc";
  2445. if(empty($page))
  2446. {
  2447. $start = 0;
  2448. $perpage = 1;
  2449. }
  2450. else
  2451. {
  2452. $start = ($page - 1)*$perpage;
  2453. }
  2454. //取得信息列表
  2455. $info_list = $this->whlabel->find_all($where,'sku');
  2456. $rows = array();$list = array();
  2457. foreach ($info_list as $key=>$value)
  2458. {
  2459. $rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
  2460. }
  2461. $rows = array_unique($rows);//删除重复记录
  2462. foreach ($rows as $key=>$value)
  2463. {
  2464. $data = $this->whlabel->get_sku($value);//获取目前sku的所有数据
  2465. $ck = $this->warehouse->read($data['warehouse']);
  2466. $warehouse = $ck['title'];
  2467. $gy = $this->purchase->read($data['purchase']);
  2468. $purchase = $gy['purchase'];
  2469. $g = $this->whlabel->find_count($where.' and sku = "'.$value.'" and state = 3');
  2470. $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);
  2471. }
  2472. $total = count($list);
  2473. $pagenum = ceil($total/$perpage);
  2474. $over = $total-($start+$perpage);
  2475. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  2476. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  2477. echo json_encode($rows);exit;
  2478. }
  2479. $this->_Template('whlabel_out',$this->data);
  2480. }
  2481. //出库标签浏览
  2482. public function _label()
  2483. {
  2484. $post = $this->input->post(NULL, TRUE);
  2485. if(isset($post['page']))
  2486. {
  2487. $page = $this->input->post('page',true);
  2488. $perpage = $this->input->post('perpage',true);
  2489. $sku = $this->input->post('sku',true);
  2490. $warehouse = $this->input->post('warehouse',true);
  2491. $purchase = $this->input->post('purchase',true);
  2492. $orderinfo = $this->input->post('orderinfo',true);
  2493. $waybill = $this->input->post('waybill',true);
  2494. $category = $this->input->post('category',true);
  2495. $size = $this->input->post('size',true);
  2496. $grade = $this->input->post('grade',true);
  2497. $color = $this->input->post('color',true);
  2498. $lowe = $this->input->post('lowe',true);
  2499. $where = "state=1";
  2500. if($sku)
  2501. {
  2502. $where .= " and sku = '$sku'";
  2503. }
  2504. if($warehouse)
  2505. {
  2506. $where .= " and warehouse = '$warehouse'";
  2507. }
  2508. if($purchase)
  2509. {
  2510. $where .= " and purchase = '$purchase'";
  2511. }
  2512. if($orderinfo)
  2513. {
  2514. $where .= " and orderinfo = '$orderinfo'";
  2515. }
  2516. if($waybill)
  2517. {
  2518. $where .= " and waybill = '$waybill'";
  2519. }
  2520. if($category)
  2521. {
  2522. $where .= " and features like '%-$category-%'";
  2523. }
  2524. if($size)
  2525. {
  2526. $where .= " and features like '%-$size-%'";
  2527. }
  2528. if($grade)
  2529. {
  2530. $where .= " and features like '%-$grade-%'";
  2531. }
  2532. if($color)
  2533. {
  2534. $where .= " and features like '%-$color-%'";
  2535. }
  2536. if($lowe)
  2537. {
  2538. $where .= " and features like '%-$lowe-%'";
  2539. }
  2540. //数据排序
  2541. $order_str = "outk desc";
  2542. if(empty($page))
  2543. {
  2544. $start = 0;
  2545. $perpage = 1;
  2546. }
  2547. else
  2548. {
  2549. $start = ($page - 1)*$perpage;
  2550. }
  2551. //取得信息列表
  2552. $info_list = $this->whlabel->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
  2553. foreach ($info_list as $key=>$value)
  2554. {
  2555. $warehouse = $this->warehouse->read($value['warehouse']);
  2556. $info_list[$key]['warehouse'] = $warehouse['title'];
  2557. $purchase = $this->purchase->read($value['purchase']);
  2558. $info_list[$key]['purchase'] = $purchase['title'];
  2559. if($value['outk'] != 0)
  2560. {
  2561. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  2562. }
  2563. else
  2564. {
  2565. $info_list[$key]['outk'] = "";
  2566. }
  2567. if($value['orderinfo'] == 0)
  2568. {
  2569. $info_list[$key]['orderinfo'] = "";
  2570. }
  2571. if($value['waybill'] == 0)
  2572. {
  2573. $info_list[$key]['waybill'] = "";
  2574. }
  2575. }
  2576. $total = $this->whlabel->find_count($where);
  2577. $pagenum = ceil($total/$perpage);
  2578. $over = $total-($start+$perpage);
  2579. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2580. echo json_encode($rows);exit;
  2581. }
  2582. $this->_Template('whlabel_label',$this->data);
  2583. }
  2584. //独立站出库订单
  2585. public function _outorder()
  2586. {
  2587. if(isset($_SESSION['api']))
  2588. {
  2589. $user = $this->user->get_api($_SESSION['api']);
  2590. $usp = $user;
  2591. $fgshop = "";$sid = "";
  2592. $user = explode('|',trim($user['shop'],'|'));
  2593. foreach ($user as $value)
  2594. {
  2595. $fgshop .= " shop = ".$value." or";
  2596. $sid .= " id = ".$value." or";
  2597. }
  2598. }
  2599. else
  2600. {
  2601. echo "请重新登录";
  2602. }
  2603. $post = $this->input->post(NULL, TRUE);
  2604. if(isset($post['page']))
  2605. {
  2606. $page = $this->input->post('page',true);
  2607. $perpage = $this->input->post('perpage',true);
  2608. $warehouse = $this->input->post('warehouse',true);
  2609. $xztime = $this->input->post('xztime',true);
  2610. $timetk = $this->input->post('timetkk',true);
  2611. $timetj = $this->input->post('timetjj',true);
  2612. $shop = $this->input->post('shop',true);
  2613. $source = $this->input->post('source',true);
  2614. $orderinfo = $this->input->post('orderinfo',true);
  2615. $number = $this->input->post('number',true);
  2616. $sfxh = $this->input->post('sfxh',true);
  2617. $express = $this->input->post('express',true);
  2618. $waybill = $this->input->post('waybill',true);
  2619. $library = $this->input->post('library',true);
  2620. $country = $this->input->post('country',true);
  2621. $so = $this->input->post('so',true);
  2622. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2623. $print = $this->input->post('print',true);
  2624. $state = $this->input->post('state',true);
  2625. $orderurl = $this->input->post('orderurl',true);
  2626. $timetk = strtotime($timetk);
  2627. $timetj = strtotime($timetj);
  2628. /**
  2629. $sj = $this->input->post('sj',true);
  2630. if($sj)
  2631. {
  2632. $sj = $this->input->post('sj',true);
  2633. }
  2634. else
  2635. {
  2636. $sj = "fullorder";
  2637. }
  2638. **/
  2639. $sj = "fullorder";
  2640. $where = "mergeid = 0";
  2641. if($warehouse)
  2642. {
  2643. $where .= " and type = '$warehouse'";
  2644. }
  2645. if($timetk && $timetj)
  2646. {
  2647. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2648. }
  2649. if($orderinfo)
  2650. {
  2651. $where .= " and orderinfo = '$orderinfo'";
  2652. }
  2653. if($number)
  2654. {
  2655. $where .= " and number = '$number'";
  2656. }
  2657. if($express)
  2658. {
  2659. $where .= " and express = '$express'";
  2660. }
  2661. if($waybill)
  2662. {
  2663. $where .= " and waybill = '$waybill'";
  2664. }
  2665. if($library)
  2666. {
  2667. $where .= " and library = '$library'";
  2668. }
  2669. if($print)
  2670. {
  2671. $where .= " and print = '$print'";
  2672. }
  2673. if($libraryconfirm)
  2674. {
  2675. $where .= " and libraryconfirm = '$libraryconfirm'";
  2676. }
  2677. if($state)
  2678. {
  2679. $where .= " and state = '$state'";
  2680. }
  2681. if($shop)
  2682. {
  2683. $where .= " and shop = '$shop'";
  2684. }
  2685. if($country)
  2686. {
  2687. $where .= " and country = '$country'";
  2688. }
  2689. if($sfxh != '')
  2690. {
  2691. $where .= " and sfxh = '$sfxh'";
  2692. }
  2693. if($so)
  2694. {
  2695. $where .= " and shipremarks like '%$so%'";
  2696. }
  2697. if($source)
  2698. {
  2699. if($source == '2d')
  2700. {
  2701. $where .= " and source >= '2'";
  2702. }
  2703. else
  2704. {
  2705. $where .= " and source = '$source'";
  2706. }
  2707. }
  2708. if(isset($_SESSION['api']))
  2709. {
  2710. foreach ($user as $value)
  2711. {
  2712. $fgshop .= " shop = ".$value." or";
  2713. }
  2714. $where .= " and (".rtrim($fgshop,'or').")";
  2715. }
  2716. if($orderurl)
  2717. {
  2718. $url = $this->orderurl->read($orderurl);
  2719. $where .= " and link like '%".$url['url']."%'";
  2720. }
  2721. //数据排序
  2722. $order_str = "librarytime desc";
  2723. if(empty($page))
  2724. {
  2725. $start = 0;
  2726. $perpage = 1;
  2727. }
  2728. else
  2729. {
  2730. $start = ($page - 1)*$perpage;
  2731. }
  2732. //取得信息列表
  2733. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2734. //格式化数据
  2735. foreach ($info_list as $key=>$value)
  2736. {
  2737. $shop = $this->shop->read($value['shop']);
  2738. $info_list[$key]['shop'] = $shop['shopname'];
  2739. $express = $this->express->read($value['express']);
  2740. $info_list[$key]['express'] = $express['servicename'];
  2741. $warehouse = $this->warehouse->read($value['type']);
  2742. $info_list[$key]['type'] = $warehouse['title'];
  2743. if($value['librarytime'] == '0')
  2744. {
  2745. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2746. }
  2747. else
  2748. {
  2749. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2750. }
  2751. }
  2752. $total = $this->$sj->find_count($where);
  2753. $pagenum = ceil($total/$perpage);
  2754. $over = $total-($start+$perpage);
  2755. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2756. echo json_encode($rows);exit;
  2757. }
  2758. $this->data['express'] = $this->express->find_all();
  2759. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2760. $this->data['wlshop'] = $wlshop;
  2761. $user = $this->user->get_api($_SESSION['api']);
  2762. $powerid = $this->power->read($user['power']);
  2763. $powertext = explode('|',trim($powerid['excelid'],'|'));
  2764. $pid = '';
  2765. foreach ($powertext as $v)
  2766. {
  2767. $pid .= " id = ".$v." or";
  2768. }
  2769. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  2770. $this->data['fullorderexcel'] = $fullorderexcel;
  2771. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  2772. $this->data['orderurl'] = $orderurl;
  2773. $this->_Template('whlabel_outorder',$this->data);
  2774. }
  2775. //tt出库
  2776. public function _toutorder()
  2777. {
  2778. if(isset($_SESSION['api']))
  2779. {
  2780. $user = $this->user->get_api($_SESSION['api']);
  2781. $usp = $user;
  2782. $fgshop = "";$sid = "";
  2783. $user = explode('|',trim($user['shop'],'|'));
  2784. foreach ($user as $value)
  2785. {
  2786. $fgshop .= " shop = ".$value." or";
  2787. $sid .= " id = ".$value." or";
  2788. }
  2789. }
  2790. else
  2791. {
  2792. echo "请重新登录";
  2793. }
  2794. $post = $this->input->post(NULL, TRUE);
  2795. if(isset($post['page']))
  2796. {
  2797. $page = $this->input->post('page',true);
  2798. $perpage = $this->input->post('perpage',true);
  2799. $warehouse = $this->input->post('warehouse',true);
  2800. $xztime = $this->input->post('xztime',true);
  2801. $timetk = $this->input->post('timetkk',true);
  2802. $timetj = $this->input->post('timetjj',true);
  2803. $shop = $this->input->post('shop',true);
  2804. $source = $this->input->post('source',true);
  2805. $orderinfo = $this->input->post('orderinfo',true);
  2806. $number = $this->input->post('number',true);
  2807. $sfxh = $this->input->post('sfxh',true);
  2808. $express = $this->input->post('express',true);
  2809. $waybill = $this->input->post('waybill',true);
  2810. $library = $this->input->post('library',true);
  2811. $country = $this->input->post('country',true);
  2812. $so = $this->input->post('so',true);
  2813. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2814. $print = $this->input->post('print',true);
  2815. $state = $this->input->post('state',true);
  2816. $orderurl = $this->input->post('orderurl',true);
  2817. $timetk = strtotime($timetk);
  2818. $timetj = strtotime($timetj);
  2819. /**
  2820. $sj = $this->input->post('sj',true);
  2821. if($sj)
  2822. {
  2823. $sj = $this->input->post('sj',true);
  2824. }
  2825. else
  2826. {
  2827. $sj = "fullorder";
  2828. }
  2829. **/
  2830. $sj = "fullordertt";
  2831. $where = "mergeid = 0";
  2832. if($warehouse)
  2833. {
  2834. $where .= " and type = '$warehouse'";
  2835. }
  2836. if($timetk && $timetj)
  2837. {
  2838. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2839. }
  2840. if($orderinfo)
  2841. {
  2842. $where .= " and orderinfo = '$orderinfo'";
  2843. }
  2844. if($number)
  2845. {
  2846. $where .= " and number = '$number'";
  2847. }
  2848. if($express)
  2849. {
  2850. $where .= " and express = '$express'";
  2851. }
  2852. if($waybill)
  2853. {
  2854. $where .= " and waybill = '$waybill'";
  2855. }
  2856. if($library)
  2857. {
  2858. $where .= " and library = '$library'";
  2859. }
  2860. if($print)
  2861. {
  2862. $where .= " and print = '$print'";
  2863. }
  2864. if($libraryconfirm)
  2865. {
  2866. $where .= " and libraryconfirm = '$libraryconfirm'";
  2867. }
  2868. if($state)
  2869. {
  2870. $where .= " and state = '$state'";
  2871. }
  2872. if($shop)
  2873. {
  2874. $where .= " and shop = '$shop'";
  2875. }
  2876. if($country)
  2877. {
  2878. $where .= " and country = '$country'";
  2879. }
  2880. if($sfxh != '')
  2881. {
  2882. $where .= " and sfxh = '$sfxh'";
  2883. }
  2884. if($so)
  2885. {
  2886. $where .= " and shipremarks like '%$so%'";
  2887. }
  2888. if($source)
  2889. {
  2890. if($source == '2d')
  2891. {
  2892. $where .= " and source >= '2'";
  2893. }
  2894. else
  2895. {
  2896. $where .= " and source = '$source'";
  2897. }
  2898. }
  2899. if(isset($_SESSION['api']))
  2900. {
  2901. foreach ($user as $value)
  2902. {
  2903. $fgshop .= " shop = ".$value." or";
  2904. }
  2905. $where .= " and (".rtrim($fgshop,'or').")";
  2906. }
  2907. if($orderurl)
  2908. {
  2909. $url = $this->orderurl->read($orderurl);
  2910. $where .= " and link like '%".$url['url']."%'";
  2911. }
  2912. //数据排序
  2913. $order_str = "librarytime desc";
  2914. if(empty($page))
  2915. {
  2916. $start = 0;
  2917. $perpage = 1;
  2918. }
  2919. else
  2920. {
  2921. $start = ($page - 1)*$perpage;
  2922. }
  2923. //取得信息列表
  2924. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2925. //格式化数据
  2926. foreach ($info_list as $key=>$value)
  2927. {
  2928. $shop = $this->shop->read($value['shop']);
  2929. $info_list[$key]['shop'] = $shop['shopname'];
  2930. $express = $this->express->read($value['express']);
  2931. $info_list[$key]['express'] = $express['servicename'];
  2932. $warehouse = $this->warehouse->read($value['type']);
  2933. $info_list[$key]['type'] = $warehouse['title'];
  2934. if($value['librarytime'] == '0')
  2935. {
  2936. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2937. }
  2938. else
  2939. {
  2940. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2941. }
  2942. }
  2943. $total = $this->$sj->find_count($where);
  2944. $pagenum = ceil($total/$perpage);
  2945. $over = $total-($start+$perpage);
  2946. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2947. echo json_encode($rows);exit;
  2948. }
  2949. $this->data['express'] = $this->express->find_all();
  2950. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2951. $this->data['wlshop'] = $wlshop;
  2952. $user = $this->user->get_api($_SESSION['api']);
  2953. $powerid = $this->power->read($user['power']);
  2954. $powertext = explode('|',trim($powerid['excelid'],'|'));
  2955. $pid = '';
  2956. foreach ($powertext as $v)
  2957. {
  2958. $pid .= " id = ".$v." or";
  2959. }
  2960. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  2961. $this->data['fullorderexcel'] = $fullorderexcel;
  2962. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  2963. $this->data['orderurl'] = $orderurl;
  2964. $this->_Template('whlabel_toutorder',$this->data);
  2965. }
  2966. //速卖通出库订单
  2967. public function _soutorder()
  2968. {
  2969. if(isset($_SESSION['api']))
  2970. {
  2971. $user = $this->user->get_api($_SESSION['api']);
  2972. $usp = $user;
  2973. $fgshop = "";$sid = "";
  2974. $user = explode('|',trim($user['shop'],'|'));
  2975. foreach ($user as $value)
  2976. {
  2977. $sid .= " id = ".$value." or";
  2978. }
  2979. }
  2980. $post = $this->input->post(NULL, TRUE);
  2981. if(isset($post['page']))
  2982. {
  2983. $page = $this->input->post('page',true);
  2984. $perpage = $this->input->post('perpage',true);
  2985. $warehouse = $this->input->post('warehouse',true);
  2986. $xztime = $this->input->post('xztime',true);
  2987. $timetk = $this->input->post('timetkk',true);
  2988. $timetj = $this->input->post('timetjj',true);
  2989. $shop = $this->input->post('shop',true);
  2990. $source = $this->input->post('source',true);
  2991. $orderinfo = $this->input->post('orderinfo',true);
  2992. $number = $this->input->post('number',true);
  2993. $express = $this->input->post('express',true);
  2994. $waybill = $this->input->post('waybill',true);
  2995. $library = $this->input->post('library',true);
  2996. $country = $this->input->post('country',true);
  2997. $sfxh = $this->input->post('sfxh',true);
  2998. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2999. $print = $this->input->post('print',true);
  3000. $state = $this->input->post('state',true);
  3001. $so = $this->input->post('so',true);
  3002. $timetk = strtotime($timetk);
  3003. $timetj = strtotime($timetj);
  3004. /**
  3005. $sj = $this->input->post('sj',true);
  3006. if($sj)
  3007. {
  3008. $sj = $this->input->post('sj',true);
  3009. }
  3010. else
  3011. {
  3012. $sj = "fullorder";
  3013. }
  3014. **/
  3015. $sj = "fullordersmt";
  3016. $where = "mergeid = 0";
  3017. if($warehouse)
  3018. {
  3019. $where .= " and type = '$warehouse'";
  3020. }
  3021. if($timetk && $timetj)
  3022. {
  3023. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3024. }
  3025. if($orderinfo)
  3026. {
  3027. $where .= " and orderinfo = '$orderinfo'";
  3028. }
  3029. if($number)
  3030. {
  3031. $where .= " and number = '$number'";
  3032. }
  3033. if($express)
  3034. {
  3035. $where .= " and express = '$express'";
  3036. }
  3037. if($waybill)
  3038. {
  3039. $where .= " and waybill = '$waybill'";
  3040. }
  3041. if($library)
  3042. {
  3043. $where .= " and library = '$library'";
  3044. }
  3045. if($print)
  3046. {
  3047. $where .= " and print = '$print'";
  3048. }
  3049. if($libraryconfirm)
  3050. {
  3051. $where .= " and libraryconfirm = '$libraryconfirm'";
  3052. }
  3053. if($state)
  3054. {
  3055. $where .= " and state = '$state'";
  3056. }
  3057. if($shop)
  3058. {
  3059. $where .= " and shop = '$shop'";
  3060. }
  3061. if($sfxh != '')
  3062. {
  3063. $where .= " and sfxh = '$sfxh'";
  3064. }
  3065. if($so)
  3066. {
  3067. $where .= " and shipremarks like '%$so%'";
  3068. }
  3069. if($source)
  3070. {
  3071. $where .= " and source = '$source'";
  3072. }
  3073. if($country)
  3074. {
  3075. $where .= " and country = '$country'";
  3076. }
  3077. else
  3078. {
  3079. if(isset($_SESSION['api']))
  3080. {
  3081. foreach ($user as $value)
  3082. {
  3083. $fgshop .= " shop = ".$value." or";
  3084. }
  3085. $where .= " and (".rtrim($fgshop,'or').")";
  3086. }
  3087. }
  3088. //数据排序
  3089. $order_str = "librarytime desc";
  3090. if(empty($page))
  3091. {
  3092. $start = 0;
  3093. $perpage = 1;
  3094. }
  3095. else
  3096. {
  3097. $start = ($page - 1)*$perpage;
  3098. }
  3099. //取得信息列表
  3100. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3101. //格式化数据
  3102. foreach ($info_list as $key=>$value)
  3103. {
  3104. $shop = $this->shop->read($value['shop']);
  3105. $info_list[$key]['shop'] = $shop['shopname'];
  3106. $express = $this->express->read($value['express']);
  3107. $info_list[$key]['express'] = $express['servicename'];
  3108. $warehouse = $this->warehouse->read($value['type']);
  3109. $info_list[$key]['type'] = $warehouse['title'];
  3110. if($value['librarytime'] == '0')
  3111. {
  3112. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3113. }
  3114. else
  3115. {
  3116. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3117. }
  3118. }
  3119. $total = $this->$sj->find_count($where);
  3120. $pagenum = ceil($total/$perpage);
  3121. $over = $total-($start+$perpage);
  3122. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3123. echo json_encode($rows);exit;
  3124. }
  3125. $this->data['express'] = $this->express->find_all();
  3126. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3127. $this->data['wlshop'] = $wlshop;
  3128. $user = $this->user->get_api($_SESSION['api']);
  3129. $powerid = $this->power->read($user['power']);
  3130. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3131. $pid = '';
  3132. foreach ($powertext as $v)
  3133. {
  3134. $pid .= " id = ".$v." or";
  3135. }
  3136. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3137. $this->data['fullorderexcel'] = $fullorderexcel;
  3138. $this->_Template('whlabel_soutorder',$this->data);
  3139. }
  3140. //订单退库
  3141. public function _retreat()
  3142. {
  3143. $post = $this->input->post(NULL, TRUE);
  3144. if(isset($post['page']))
  3145. {
  3146. $page = $this->input->post('page',true);
  3147. $perpage = $this->input->post('perpage',true);
  3148. $warehouse = $this->input->post('warehouse',true);
  3149. $timetk = $this->input->post('timetk',true);
  3150. $timetj = $this->input->post('timetj',true);
  3151. $shop = $this->input->post('shop',true);
  3152. $source = $this->input->post('source',true);
  3153. $state = $this->input->post('state',true);
  3154. $review = $this->input->post('review',true);
  3155. $state = $this->input->post('state',true);
  3156. $express = $this->input->post('express',true);
  3157. $orderinfo = $this->input->post('orderinfo',true);
  3158. $user = $this->input->post('user',true);
  3159. $name = $this->input->post('name',true);
  3160. $waybill = $this->input->post('waybill',true);
  3161. $timetk = strtotime($timetk);
  3162. $timetj = strtotime($timetj);
  3163. $where = "(state=206 or state=210) and mergeid = 0";
  3164. if($warehouse)
  3165. {
  3166. $where .= " and state = '$warehouse'";
  3167. }
  3168. if($timetk && $timetj)
  3169. {
  3170. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3171. }
  3172. if($shop)
  3173. {
  3174. $where .= " and shop = '$shop'";
  3175. }
  3176. if($source)
  3177. {
  3178. $where .= " and source = '$source'";
  3179. }
  3180. if($state)
  3181. {
  3182. $where .= " and state = '$state'";
  3183. }
  3184. if($review)
  3185. {
  3186. $where .= " and review = '$review'";
  3187. }
  3188. if($state)
  3189. {
  3190. $where .= " and state = '$state'";
  3191. }
  3192. if($express)
  3193. {
  3194. $where .= " and express = '$express'";
  3195. }
  3196. if($orderinfo)
  3197. {
  3198. $where .= " and orderinfo = '$orderinfo'";
  3199. }
  3200. if($user)
  3201. {
  3202. $where .= " and user = '$user'";
  3203. }
  3204. if($name)
  3205. {
  3206. $where .= " and name = '$name'";
  3207. }
  3208. if($waybill)
  3209. {
  3210. $where .= " and waybill = '$waybill'";
  3211. }
  3212. //数据排序
  3213. $order_str = "id desc";
  3214. if(empty($page))
  3215. {
  3216. $start = 0;
  3217. $perpage = 1;
  3218. }
  3219. else
  3220. {
  3221. $start = ($page - 1)*$perpage;
  3222. }
  3223. //取得信息列表
  3224. $info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
  3225. //格式化数据
  3226. foreach ($info_list as $key=>$value)
  3227. {
  3228. $shop = $this->shop->read($value['shop']);
  3229. $info_list[$key]['shop'] = $shop['shopname'];
  3230. $warehouse = $this->warehouse->read($value['warehouse']);
  3231. $info_list[$key]['warehouse'] = $warehouse['title'];
  3232. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/".$value['id']."'>".$value['orderinfo']."</a>";
  3233. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  3234. if($value['waybill'] == 0)
  3235. {
  3236. $info_list[$key]['waybill'] = "";
  3237. }
  3238. $express = $this->express->read($value['express']);
  3239. $info_list[$key]['express'] = $express['title'];
  3240. $typeclass = $this->typeclass->read($value['state']);
  3241. $info_list[$key]['state'] = $typeclass['title'];
  3242. }
  3243. $total = $this->fullorder->find_count($where);
  3244. $pagenum = ceil($total/$perpage);
  3245. $over = $total-($start+$perpage);
  3246. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3247. echo json_encode($rows);exit;
  3248. }
  3249. $this->data['express'] = $this->express->find_all();
  3250. $this->_Template('whlabel_retreat',$this->data);
  3251. }
  3252. //退库标签浏览
  3253. public function _retreatlk()
  3254. {
  3255. $post = $this->input->post(NULL, TRUE);
  3256. if(isset($post['page']))
  3257. {
  3258. $page = $this->input->post('page',true);
  3259. $perpage = $this->input->post('perpage',true);
  3260. $timetk = $this->input->post('timetk',true);
  3261. $timetj = $this->input->post('timetj',true);
  3262. $sku = $this->input->post('sku',true);
  3263. $warehouse = $this->input->post('warehouse',true);
  3264. $purchase = $this->input->post('purchase',true);
  3265. $orderinfo = $this->input->post('orderinfo',true);
  3266. $waybill = $this->input->post('waybill',true);
  3267. $category = $this->input->post('category',true);
  3268. $size = $this->input->post('size',true);
  3269. $grade = $this->input->post('grade',true);
  3270. $color = $this->input->post('color',true);
  3271. $lowe = $this->input->post('lowe',true);
  3272. $state = $this->input->post('state',true);
  3273. $timetk = strtotime($timetk);
  3274. $timetj = strtotime($timetj);
  3275. $where = "state=2";
  3276. if($timetk && $timetj)
  3277. {
  3278. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3279. }
  3280. if($sku)
  3281. {
  3282. $where .= " and sku = '$sku'";
  3283. }
  3284. if($warehouse)
  3285. {
  3286. $where .= " and warehouse = '$warehouse'";
  3287. }
  3288. if($purchase)
  3289. {
  3290. $where .= " and purchase = '$purchase'";
  3291. }
  3292. if($orderinfo)
  3293. {
  3294. $where .= " and orderinfo = '$orderinfo'";
  3295. }
  3296. if($waybill)
  3297. {
  3298. $where .= " and waybill = '$waybill'";
  3299. }
  3300. if($category)
  3301. {
  3302. $where .= " and features like '%-$category-%'";
  3303. }
  3304. if($size)
  3305. {
  3306. $where .= " and features like '%-$size-%'";
  3307. }
  3308. if($grade)
  3309. {
  3310. $where .= " and features like '%-$grade-%'";
  3311. }
  3312. if($color)
  3313. {
  3314. $where .= " and features like '%-$color-%'";
  3315. }
  3316. if($lowe)
  3317. {
  3318. $where .= " and features like '%-$lowe-%'";
  3319. }
  3320. //数据排序
  3321. $order_str = "time desc";
  3322. if(empty($page))
  3323. {
  3324. $start = 0;
  3325. $perpage = 1;
  3326. }
  3327. else
  3328. {
  3329. $start = ($page - 1)*$perpage;
  3330. }
  3331. //取得信息列表
  3332. $info_list = $this->whlabel->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
  3333. foreach ($info_list as $key=>$value)
  3334. {
  3335. $warehouse = $this->warehouse->read($value['warehouse']);
  3336. $info_list[$key]['warehouse'] = $warehouse['title'];
  3337. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3338. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3339. $purchase = $this->purchase->read($value['purchase']);
  3340. $info_list[$key]['purchase'] = $purchase['title'];
  3341. if($value['outk'] != 0)
  3342. {
  3343. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  3344. }
  3345. else
  3346. {
  3347. $info_list[$key]['outk'] = "";
  3348. }
  3349. if($value['retreat'] != 0)
  3350. {
  3351. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
  3352. }
  3353. else
  3354. {
  3355. $info_list[$key]['retreat'] = "";
  3356. }
  3357. if($value['orderinfo'] == 0)
  3358. {
  3359. $info_list[$key]['orderinfo'] = "";
  3360. }
  3361. if($value['waybill'] == 0)
  3362. {
  3363. $info_list[$key]['waybill'] = "";
  3364. }
  3365. }
  3366. $total = $this->whlabel->find_count($where);
  3367. $pagenum = ceil($total/$perpage);
  3368. $over = $total-($start+$perpage);
  3369. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3370. echo json_encode($rows);exit;
  3371. }
  3372. $this->_Template('whlabel_retreatlk',$this->data);
  3373. }
  3374. //更换标签及浏览
  3375. public function _change()
  3376. {
  3377. $post = $this->input->post(NULL, TRUE);
  3378. if(isset($post['page']))
  3379. {
  3380. $page = $this->input->post('page',true);
  3381. $perpage = $this->input->post('perpage',true);
  3382. $timetk = $this->input->post('timetk',true);
  3383. $timetj = $this->input->post('timetj',true);
  3384. $label = $this->input->post('label',true);
  3385. $oldlabel = $this->input->post('oldlabel',true);
  3386. $timetk = strtotime($timetk);
  3387. $timetj = strtotime($timetj);
  3388. $where = "state=10 ";
  3389. if($timetk && $timetj)
  3390. {
  3391. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3392. }
  3393. if($label)
  3394. {
  3395. $where .= " and label = '$label'";
  3396. }
  3397. if($oldlabel)
  3398. {
  3399. $where .= " and oldlabel = '$oldlabel'";
  3400. }
  3401. //数据排序
  3402. $order_str = "time asc";
  3403. if(empty($page))
  3404. {
  3405. $start = 0;
  3406. $perpage = 1;
  3407. }
  3408. else
  3409. {
  3410. $start = ($page - 1)*$perpage;
  3411. }
  3412. //取得信息列表
  3413. $info_list = $this->whlabel->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
  3414. foreach ($info_list as $key=>$value)
  3415. {
  3416. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
  3417. }
  3418. $total = $this->whlabel->find_count($where);
  3419. $pagenum = ceil($total/$perpage);
  3420. $over = $total-($start+$perpage);
  3421. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3422. echo json_encode($rows);exit;
  3423. }
  3424. $this->_Template('whlabel_change',$this->data);
  3425. }
  3426. //产品标签
  3427. public function _cpbqdc()
  3428. {
  3429. if(isset($_GET['excel']))
  3430. {
  3431. $where = "1=1";
  3432. //数据排序
  3433. $order_str = "id desc";
  3434. if(empty($page))
  3435. {
  3436. $start = 0;
  3437. $perpage = 1;
  3438. }
  3439. else
  3440. {
  3441. $start = ($page - 1)*$perpage;
  3442. }
  3443. $warehouse = $this->input->get('warehouse',true);
  3444. $state = $this->input->get('state',true);
  3445. $timetk = $this->input->get('timetkk',true);
  3446. $timetj = $this->input->get('timetjj',true);
  3447. $timetk = strtotime($timetk);
  3448. $timetj = strtotime($timetj);
  3449. if($warehouse)
  3450. {
  3451. $where .= " and warehouse = '$warehouse'";
  3452. }
  3453. if($state || $state == 0)
  3454. {
  3455. $where .= " and state = '$state'";
  3456. }
  3457. if($timetk && $timetj)
  3458. {
  3459. $where .= " and time > '$timetk' and time < '$timetj'";
  3460. }
  3461. //取得信息列表
  3462. $info_list = $this->whlabel->find_all($where,'*');
  3463. $rows = array();$list = array();
  3464. foreach ($info_list as $key=>$value)
  3465. {
  3466. $rows[$value['time']] = $value;//所有数据sku
  3467. }
  3468. foreach ($rows as $value)
  3469. {
  3470. $warehouse = $this->warehouse->read($value['warehouse']);
  3471. $s = $this->whlabel->find_count($where.' and time = "'.$value['time'].'"');
  3472. $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);
  3473. }
  3474. $title = "产品标签统计表";
  3475. $titlename = "<table border=1>
  3476. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  3477. <tr align='center'>
  3478. <td>仓库</td>
  3479. <td>SKU</td>
  3480. <td>产品</td>
  3481. <td>入库时间</td>
  3482. <td>操作时间</td>
  3483. <td>备注</td>
  3484. <td>数量</td>
  3485. </tr>
  3486. </table>";
  3487. $filename = $title.".xls";
  3488. $tail = "";
  3489. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3490. }
  3491. }
  3492. //进销存导出
  3493. public function _exceljxc()
  3494. {
  3495. $classid = $this->classid->sku();
  3496. $pm = $classid;
  3497. $typeclass = array();
  3498. $tc = $this->typeclass->find_all();
  3499. foreach ($tc as $v)
  3500. {
  3501. $typeclass[$v['id']] = $v;
  3502. }
  3503. $prc = array();
  3504. $purchase = $this->purchase->find_all();
  3505. foreach($purchase as $k=>$v)
  3506. {
  3507. $prc[$v['id']] = $v['title'];
  3508. }
  3509. if(isset($_GET['excel']))
  3510. {
  3511. $where = "sku != 'Preset'";
  3512. //数据排序
  3513. $order_str = "id desc";
  3514. if(empty($page))
  3515. {
  3516. $start = 0;
  3517. $perpage = 1;
  3518. }
  3519. else
  3520. {
  3521. $start = ($page - 1)*$perpage;
  3522. }
  3523. $category = $this->input->get('category',true);
  3524. $warehouse = $this->input->get('warehouse',true);
  3525. $excelid = $this->input->get('sid',true);
  3526. if($category)
  3527. {
  3528. $where .= " and features like '%-$category-%'";
  3529. }
  3530. if($warehouse)
  3531. {
  3532. $where .= " and warehouse = '$warehouse'";
  3533. }
  3534. $xzid = '';
  3535. if($excelid)
  3536. {
  3537. $excelid = explode(',',trim($excelid,','));
  3538. foreach ($excelid as $key=>$value)
  3539. {
  3540. $xzid .= " id = ".$value." or";
  3541. }
  3542. $xzid = " and (".rtrim($xzid,'or').")";;
  3543. }
  3544. //取得信息列表
  3545. /**
  3546. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3547. $rows = array();$list = array();
  3548. foreach ($info_list as $key=>$value)
  3549. {
  3550. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3551. }
  3552. **/
  3553. $wt = array();
  3554. $whlabel_type = $this->whlabel_type->find_all();
  3555. foreach ($whlabel_type as $v)
  3556. {
  3557. $wt[$v['id']] = $v['title'];
  3558. }
  3559. $wh = array();
  3560. $w = $this->warehouse->find_all('1=1','id,title');
  3561. foreach ($w as $v)
  3562. {
  3563. $wh[$v['id']] = $v['title'];
  3564. }
  3565. $list = array();
  3566. $rows = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,sku,cs,bs,title,features,cpbz,type,number');
  3567. foreach ($rows as $key=>$value)
  3568. {
  3569. if(isset($wt[$value['type']]))
  3570. {
  3571. $rows[$key]['type'] = $wt[$value['type']];
  3572. }
  3573. else
  3574. {
  3575. $rows[$key]['type'] = '未设置';
  3576. }
  3577. $bm = '03';
  3578. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  3579. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  3580. $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');
  3581. $details = array();
  3582. $cpid = array();
  3583. $cpbz = array();
  3584. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  3585. foreach ($sd as $k=>$v)
  3586. {
  3587. if($v['state'] == 0)
  3588. {
  3589. $c++;
  3590. if($v['cpid'] != 0)
  3591. {
  3592. $cpid[$v['cpid']] = $v['cpid'];
  3593. }
  3594. if($v['cpbz'] != '')
  3595. {
  3596. $cpbz[$v['cpbz']] = $v['cpbz'];
  3597. }
  3598. }
  3599. if($v['state'] != 9)
  3600. {
  3601. $g++;
  3602. }
  3603. if($v['state'] == 1)
  3604. {
  3605. $x++;
  3606. }
  3607. if($v['state'] == 2)
  3608. {
  3609. $t++;
  3610. }
  3611. if($v['state'] == 8)
  3612. {
  3613. $s++;
  3614. }
  3615. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  3616. {
  3617. $q++;
  3618. }
  3619. $details[$v['details']] = $v['details'];
  3620. }
  3621. $rows[$key]['details'] = implode("、",$details);
  3622. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  3623. $number = $value['number'];
  3624. $ftime = time()-15*24*3600;
  3625. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3626. $rows[$key]['cpbz'] = ($cpbz)?implode(" ",$cpbz):'';
  3627. $rows[$key]['number'] = $g;
  3628. $rows[$key]['c'] = $c;
  3629. $rows[$key]['x'] = $x;
  3630. $rows[$key]['t'] = $t;
  3631. $rows[$key]['s'] = $s;
  3632. $rows[$key]['q'] = $q;
  3633. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  3634. $features = explode('-',trim($features,'-'));
  3635. $pm = $classid;
  3636. $jm = $classid;
  3637. foreach($features as $k=>$v)
  3638. {
  3639. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3640. {
  3641. if($typeclass[$v]['bm'] != '')
  3642. {
  3643. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3644. }
  3645. }
  3646. if($v != 0)
  3647. {
  3648. if(!isset($typeclass[$v]))
  3649. {
  3650. continue;
  3651. }
  3652. if(isset($pm[$typeclass[$v]['classid']]))
  3653. {
  3654. if(stripos($typeclass[$v]['zh'],'|') !== false)
  3655. {
  3656. $tz = explode('|',$typeclass[$v]['zh']);
  3657. $pm[$typeclass[$v]['classid']] = $tz[0];
  3658. }
  3659. else
  3660. {
  3661. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3662. }
  3663. }
  3664. if(isset($jm[$typeclass[$v]['classid']]))
  3665. {
  3666. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3667. }
  3668. }
  3669. }
  3670. $jm = array_filter($jm);
  3671. $rows[$key]['bs'] = implode("-",$jm);
  3672. $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3673. $zh = implode(" ",$pm);
  3674. $zh = str_replace('自然色 ','',trim($zh,' '));
  3675. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3676. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3677. $rows[$key]['features'] = $zh;
  3678. }
  3679. $title = "总进销存统计表";
  3680. $titlename = "<table border=1>
  3681. <tr><th colspan='12' align='center'><h3>".$title."<h3></th></tr>
  3682. <tr align='center'>
  3683. <td>仓库</td>
  3684. <td>供应商</td>
  3685. <td>位置</td>
  3686. <td>库存编码</td>
  3687. <td>SKU</td>
  3688. <td>用友编码</td>
  3689. <td>用友料号</td>
  3690. <td>商品名称</td>
  3691. <td>商品中文</td>
  3692. <td>备注</td>
  3693. <td>类型</td>
  3694. <td>入库总量</td>
  3695. <td>库存数量</td>
  3696. <td>销售数量</td>
  3697. <td>退货数量</td>
  3698. <td>删除数量</td>
  3699. <td>其它操作</td>
  3700. </tr>
  3701. </table>";
  3702. $filename = $title.".xls";
  3703. $tail = "";
  3704. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  3705. }
  3706. }
  3707. //入库导出
  3708. public function _excelr()
  3709. {
  3710. if(isset($_GET['excel']))
  3711. {
  3712. $category = $this->input->get('category',true);
  3713. $size = $this->input->get('size',true);
  3714. $grade = $this->input->get('grade',true);
  3715. $color = $this->input->get('color',true);
  3716. $lowe = $this->input->get('lowe',true);
  3717. $sku = $this->input->get('sku',true);
  3718. $warehouse = $this->input->get('warehouse',true);
  3719. $purchase = $this->input->get('purchase',true);
  3720. $ktime = $this->input->get('ktime',true);
  3721. $jtime = $this->input->get('jtime',true);
  3722. $ktime = strtotime($ktime);
  3723. $jtime = strtotime($jtime);
  3724. $where = "1=1";$gj = "";$ck = "";
  3725. if($category)
  3726. {
  3727. $where .= " and features like '%-$category-%'";
  3728. }
  3729. if($size)
  3730. {
  3731. $where .= " and features like '%-$size-%'";
  3732. }
  3733. if($grade)
  3734. {
  3735. $where .= " and features like '%-$grade-%'";
  3736. }
  3737. if($color)
  3738. {
  3739. $where .= " and features like '%-$color-%'";
  3740. }
  3741. if($lowe)
  3742. {
  3743. $where .= " and features like '%-$lowe-%'";
  3744. }
  3745. if($warehouse)
  3746. {
  3747. $where .= " and warehouse = '$warehouse'";
  3748. }
  3749. if($purchase)
  3750. {
  3751. $where .= " and purchase = '$purchase'";
  3752. }
  3753. if($sku)
  3754. {
  3755. $where .= " and sku = '$sku'";
  3756. }
  3757. if($ktime && $jtime)
  3758. {
  3759. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3760. }
  3761. //数据排序
  3762. $order_str = "id desc";
  3763. if(empty($page))
  3764. {
  3765. $start = 0;
  3766. $perpage = 1;
  3767. }
  3768. else
  3769. {
  3770. $start = ($page - 1)*$perpage;
  3771. }
  3772. $list = array();
  3773. $rows = $this->whlabel->find_pc($where,'enter,sku,warehouse','*',$order_str);
  3774. foreach ($rows as $value)
  3775. {
  3776. $ck = $this->warehouse->read($value['warehouse']);
  3777. $warehouse = $ck['title'];
  3778. $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
  3779. $retreatwarehouse = $tkck['title'];
  3780. $gy = $this->purchase->read($value['purchase']);
  3781. $purchase = $gy['title'];
  3782. $g = $this->whlabel->find_count($where.' and enter = "'.$value['enter'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'"');
  3783. $list[] = array('warehouse'=>$warehouse,'sku'=>$value['sku'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
  3784. }
  3785. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
  3786. $titlename = "<table border=1>
  3787. <tr><th colspan='5' align='center'><h3>".$title."<h3></th></tr>
  3788. <tr align='center'>
  3789. <td>仓库</td>
  3790. <td>SKU</td>
  3791. <td>产品</td>
  3792. <td>时间</td>
  3793. <td>数量</td>
  3794. </tr>
  3795. </table>";
  3796. $filename = $title.".xls";
  3797. $tail = "";
  3798. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3799. }
  3800. }
  3801. //出库、退库导出
  3802. public function _excelct()
  3803. {
  3804. $classid = $this->classid->sku();
  3805. $pm = $classid;
  3806. $typeclass = array();
  3807. $tc = $this->typeclass->find_all();
  3808. foreach ($tc as $v)
  3809. {
  3810. $typeclass[$v['id']] = $v;
  3811. }
  3812. $prc = array();
  3813. $purchase = $this->purchase->find_all();
  3814. foreach($purchase as $k=>$v)
  3815. {
  3816. $prc[$v['id']] = $v['title'];
  3817. }
  3818. if(isset($_GET['excel']))
  3819. {
  3820. $wh = array();
  3821. $w = $this->warehouse->find_all('1=1','id,title');
  3822. foreach ($w as $v)
  3823. {
  3824. $wh[$v['id']] = $v['title'];
  3825. }
  3826. $type = $this->input->get('excel',true);
  3827. $category = $this->input->get('category',true);
  3828. $size = $this->input->get('size',true);
  3829. $grade = $this->input->get('grade',true);
  3830. $color = $this->input->get('color',true);
  3831. $lowe = $this->input->get('lowe',true);
  3832. $sku = $this->input->get('sku',true);
  3833. $warehouse = $this->input->get('warehouse',true);
  3834. $lacetype = $this->input->get('lacetype',true);
  3835. $lacecolor = $this->input->get('lacecolor',true);
  3836. $density = $this->input->get('density',true);
  3837. $haircap = $this->input->get('haircap',true);
  3838. $purchase = $this->input->get('purchase',true);
  3839. $title = $this->input->get('title',true);
  3840. $state = $this->input->get('state',true);
  3841. $sid = $this->input->get('sid',true);
  3842. $ktime = $this->input->get('ktime',true);
  3843. $jtime = $this->input->get('jtime',true);
  3844. $ktime = strtotime($ktime);
  3845. $jtime = strtotime($jtime);
  3846. $where = "1=1";$gj = "";$ck = "";
  3847. if($category)
  3848. {
  3849. $where .= " and features like '%-$category-%'";
  3850. }
  3851. if($size)
  3852. {
  3853. $where .= " and features like '%-$size-%'";
  3854. }
  3855. if($grade)
  3856. {
  3857. $where .= " and features like '%-$grade-%'";
  3858. }
  3859. if($color)
  3860. {
  3861. $where .= " and features like '%-$color-%'";
  3862. }
  3863. if($lowe)
  3864. {
  3865. $where .= " and features like '%-$lowe-%'";
  3866. }
  3867. if($warehouse)
  3868. {
  3869. $where .= " and warehouse = '$warehouse'";
  3870. }
  3871. if($purchase)
  3872. {
  3873. $where .= " and purchase = '$purchase'";
  3874. }
  3875. if($state)
  3876. {
  3877. $where .= " and state = '$state'";
  3878. }
  3879. if($lacetype)
  3880. {
  3881. $where .= " and features like '%-$lacetype-%'";
  3882. }
  3883. if($lacecolor)
  3884. {
  3885. $where .= " and features like '%-$lacecolor-%'";
  3886. }
  3887. if($density)
  3888. {
  3889. $where .= " and features like '%-$density-%'";
  3890. }
  3891. if($haircap)
  3892. {
  3893. $where .= " and features like '%-$haircap-%'";
  3894. }
  3895. if($title)
  3896. {
  3897. $title = trim($title,' ');
  3898. $title = trim($title,' ');
  3899. $where .= " and title like '%$title%'";
  3900. }
  3901. if($sku)
  3902. {
  3903. $sku = trim($sku,' ');
  3904. $sku = trim($sku,' ');
  3905. $where .= " and sku like '%$sku%'";
  3906. }
  3907. if($ktime && $jtime)
  3908. {
  3909. if($type == 1)
  3910. {
  3911. $tl = '出库';
  3912. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3913. }
  3914. else if($type == 2)
  3915. {
  3916. $tl = '退库';
  3917. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3918. }
  3919. else if($type == 3)
  3920. {
  3921. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3922. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3923. }
  3924. else if($type == 4)
  3925. {
  3926. $tl = '出库+零售';
  3927. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3928. }
  3929. else if($type == 5)
  3930. {
  3931. $tl = '零售';
  3932. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3933. }
  3934. }
  3935. $sidwhere = '';
  3936. if($sid)
  3937. {
  3938. $sd = "";
  3939. $s = explode(',',trim($sid,','));
  3940. foreach ($s as $value)
  3941. {
  3942. $sd .= " id = ".$value." or";
  3943. }
  3944. $sidwhere = " and (".rtrim($sd,'or').")";
  3945. }
  3946. //数据排序
  3947. $order_str = "time desc";
  3948. if(empty($page))
  3949. {
  3950. $start = 0;
  3951. $perpage = 1;
  3952. }
  3953. else
  3954. {
  3955. $start = ($page - 1)*$perpage;
  3956. }
  3957. //取得信息列表
  3958. if($type != 3 && $type != 5)
  3959. {
  3960. if($type == 1 || $type == 4)
  3961. {
  3962. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk',$order_str);
  3963. foreach ($info_list as $key=>$value)
  3964. {
  3965. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  3966. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  3967. $warehouse = $this->warehouse->read($value['warehouse']);
  3968. $info_list[$key]['warehouse'] = $warehouse['title'];
  3969. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  3970. $features = explode('-',trim($features,'-'));
  3971. $pm = $classid;
  3972. foreach($features as $k=>$v)
  3973. {
  3974. if($v != 0)
  3975. {
  3976. if(!isset($typeclass[$v]))
  3977. {
  3978. continue;
  3979. }
  3980. if(isset($pm[$typeclass[$v]['classid']]))
  3981. {
  3982. if(stripos($typeclass[$v]['zh'],'|') !== false)
  3983. {
  3984. $tz = explode('|',$typeclass[$v]['zh']);
  3985. $pm[$typeclass[$v]['classid']] = $tz[0];
  3986. }
  3987. else
  3988. {
  3989. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3990. }
  3991. }
  3992. }
  3993. }
  3994. $zh = implode(" ",$pm);
  3995. $zh = str_replace('自然色 ','',trim($zh,' '));
  3996. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3997. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3998. $info_list[$key]['features'] = $zh;
  3999. }
  4000. }
  4001. else
  4002. {
  4003. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat',$order_str);
  4004. foreach ($info_list as $key=>$value)
  4005. {
  4006. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4007. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
  4008. $warehouse = $this->warehouse->read($value['warehouse']);
  4009. $info_list[$key]['warehouse'] = $warehouse['title'];
  4010. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4011. $features = explode('-',trim($features,'-'));
  4012. $pm = $classid;
  4013. foreach($features as $k=>$v)
  4014. {
  4015. if($v != 0)
  4016. {
  4017. if(!isset($typeclass[$v]))
  4018. {
  4019. continue;
  4020. }
  4021. if(isset($pm[$typeclass[$v]['classid']]))
  4022. {
  4023. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4024. {
  4025. $tz = explode('|',$typeclass[$v]['zh']);
  4026. $pm[$typeclass[$v]['classid']] = $tz[0];
  4027. }
  4028. else
  4029. {
  4030. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4031. }
  4032. }
  4033. }
  4034. }
  4035. $zh = implode(" ",$pm);
  4036. $zh = str_replace('自然色 ','',trim($zh,' '));
  4037. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4038. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4039. $info_list[$key]['features'] = $zh;
  4040. }
  4041. }
  4042. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4043. $titlename = "<table border=1>
  4044. <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
  4045. <tr align='center'>
  4046. <td>仓库</td>
  4047. <td>供应商</td>
  4048. <td>SKU</td>
  4049. <td>商品名称</td>
  4050. <td>商品中文</td>
  4051. <td>标签</td>
  4052. <td>订单号</td>
  4053. <td>运单号</td>
  4054. <td>".$tl."时间(中国时间)</td>
  4055. </tr>
  4056. </table>";
  4057. $filename = $title.".xls";
  4058. $tail = "";
  4059. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4060. }
  4061. else if($type == 5)
  4062. {
  4063. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,outk',$order_str);
  4064. foreach ($info_list as $key=>$value)
  4065. {
  4066. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4067. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4068. $warehouse = $this->warehouse->read($value['warehouse']);
  4069. $info_list[$key]['warehouse'] = $warehouse['title'];
  4070. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4071. $features = explode('-',trim($features,'-'));
  4072. $pm = $classid;
  4073. foreach($features as $k=>$v)
  4074. {
  4075. if($v != 0)
  4076. {
  4077. if(!isset($typeclass[$v]))
  4078. {
  4079. continue;
  4080. }
  4081. if(isset($pm[$typeclass[$v]['classid']]))
  4082. {
  4083. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4084. {
  4085. $tz = explode('|',$typeclass[$v]['zh']);
  4086. $pm[$typeclass[$v]['classid']] = $tz[0];
  4087. }
  4088. else
  4089. {
  4090. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4091. }
  4092. }
  4093. }
  4094. }
  4095. $zh = implode(" ",$pm);
  4096. $zh = str_replace('自然色 ','',trim($zh,' '));
  4097. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4098. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4099. $info_list[$key]['features'] = $zh;
  4100. }
  4101. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4102. $titlename = "<table border=1>
  4103. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  4104. <tr align='center'>
  4105. <td>仓库</td>
  4106. <td>供应商</td>
  4107. <td>SKU</td>
  4108. <td>商品名称</td>
  4109. <td>商品中文</td>
  4110. <td>标签</td>
  4111. <td>".$tl."时间(中国时间)</td>
  4112. </tr>
  4113. </table>";
  4114. $filename = $title.".xls";
  4115. $tail = "";
  4116. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4117. }
  4118. else
  4119. {
  4120. /**
  4121. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4122. $rows = array();$list = array();
  4123. foreach ($info_list as $key=>$value)
  4124. {
  4125. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4126. }
  4127. **/
  4128. $wh = array();
  4129. $w = $this->warehouse->find_all('1=1','id,title');
  4130. foreach ($w as $v)
  4131. {
  4132. $wh[$v['id']] = $v['title'];
  4133. }
  4134. $wt = array();
  4135. $whlabel_type = $this->whlabel_type->find_all();
  4136. foreach ($whlabel_type as $v)
  4137. {
  4138. $wt[$v['id']] = $v['title'];
  4139. }
  4140. $list = array();
  4141. $rows = $this->whlabel->find_pc($where.$sidwhere,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,sku,title,features,cpbz,type');
  4142. foreach ($rows as $key=>$value)
  4143. {
  4144. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4145. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4146. $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');
  4147. $details = array();
  4148. $cpid = array();
  4149. $cpbz = array();
  4150. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  4151. foreach ($sd as $k=>$v)
  4152. {
  4153. if($v['state'] == 0)
  4154. {
  4155. $c++;
  4156. }
  4157. if($v['state'] != 9)
  4158. {
  4159. $g++;
  4160. }
  4161. if($v['state'] == 1)
  4162. {
  4163. $x++;
  4164. }
  4165. if($v['state'] == 2)
  4166. {
  4167. $t++;
  4168. }
  4169. if($v['state'] == 8)
  4170. {
  4171. $s++;
  4172. }
  4173. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  4174. {
  4175. $q++;
  4176. }
  4177. $details[$v['details']] = $v['details'];
  4178. if($v['cpid'] != 0)
  4179. {
  4180. $cpid[$v['cpid']] = $v['cpid'];
  4181. }
  4182. if($v['cpbz'] != '')
  4183. {
  4184. $cpbz[$v['cpbz']] = $v['cpbz'];
  4185. }
  4186. }
  4187. if(isset($wt[$value['type']]))
  4188. {
  4189. $rows[$key]['type'] = $wt[$value['type']];
  4190. }
  4191. else
  4192. {
  4193. $rows[$key]['type'] = '未设置';
  4194. }
  4195. $rows[$key]['details'] = implode("、",$details);
  4196. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4197. $ftime = time()-15*24*3600;
  4198. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4199. $rows[$key]['cpbz'] = ($cpbz)?implode(" ",$cpbz):'';
  4200. $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);
  4201. $rows[$key]['c'] = $c;
  4202. $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);
  4203. $rows[$key]['t'] = $t;
  4204. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4205. $features = explode('-',trim($features,'-'));
  4206. $pm = $classid;
  4207. foreach($features as $k=>$v)
  4208. {
  4209. if($v != 0)
  4210. {
  4211. if(!isset($typeclass[$v]))
  4212. {
  4213. continue;
  4214. }
  4215. if(isset($pm[$typeclass[$v]['classid']]))
  4216. {
  4217. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4218. {
  4219. $tz = explode('|',$typeclass[$v]['zh']);
  4220. $pm[$typeclass[$v]['classid']] = $tz[0];
  4221. }
  4222. else
  4223. {
  4224. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4225. }
  4226. }
  4227. }
  4228. }
  4229. $zh = implode(" ",$pm);
  4230. $zh = str_replace('自然色 ','',trim($zh,' '));
  4231. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4232. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4233. $rows[$key]['features'] = $zh;
  4234. }
  4235. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
  4236. $titlename = "<table border=1>
  4237. <tr><th colspan='11' align='center'><h3>".$title."<h3></th></tr>
  4238. <tr align='center'>
  4239. <td>仓库</td>
  4240. <td>供应商</td>
  4241. <td>位置</td>
  4242. <td>库存编码</td>
  4243. <td>SKU</td>
  4244. <td>商品名称</td>
  4245. <td>商品中文</td>
  4246. <td>备注</td>
  4247. <td>类型</td>
  4248. <td>入库总量</td>
  4249. <td>库存数量</td>
  4250. <td>销售数量</td>
  4251. <td>退货数量</td>
  4252. </tr>
  4253. </table>";
  4254. $filename = $title.".xls";
  4255. $tail = "";
  4256. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  4257. }
  4258. }
  4259. }
  4260. //出库+入库数据整合
  4261. public function _excelcr()
  4262. {
  4263. if(isset($_GET['excel']))
  4264. {
  4265. $type = $this->input->get('excel',true);
  4266. $category = $this->input->get('category',true);
  4267. $size = $this->input->get('size',true);
  4268. $grade = $this->input->get('grade',true);
  4269. $color = $this->input->get('color',true);
  4270. $lowe = $this->input->get('lowe',true);
  4271. $sku = $this->input->get('sku',true);
  4272. $warehouse = $this->input->get('warehouse',true);
  4273. $purchase = $this->input->get('purchase',true);
  4274. $state = $this->input->get('state',true);
  4275. $sid = $this->input->get('sid',true);
  4276. $ktime = $this->input->get('ktime',true);
  4277. $jtime = $this->input->get('jtime',true);
  4278. $ktime = strtotime($ktime);
  4279. $jtime = strtotime($jtime);
  4280. $where = "1=1";$gj = "";$ck = "";
  4281. if($category)
  4282. {
  4283. $where .= " and features like '%-$category-%'";
  4284. }
  4285. if($size)
  4286. {
  4287. $where .= " and features like '%-$size-%'";
  4288. }
  4289. if($grade)
  4290. {
  4291. $where .= " and features like '%-$grade-%'";
  4292. }
  4293. if($color)
  4294. {
  4295. $where .= " and features like '%-$color-%'";
  4296. }
  4297. if($lowe)
  4298. {
  4299. $where .= " and features like '%-$lowe-%'";
  4300. }
  4301. if($warehouse)
  4302. {
  4303. $where .= " and warehouse = '$warehouse'";
  4304. }
  4305. if($purchase)
  4306. {
  4307. $where .= " and purchase = '$purchase'";
  4308. }
  4309. if($state)
  4310. {
  4311. $where .= " and state = '$state'";
  4312. }
  4313. if($sku)
  4314. {
  4315. $where .= " and sku like '%$sku%'";
  4316. }
  4317. if($ktime && $jtime)
  4318. {
  4319. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4320. }
  4321. $sidwhere = '';
  4322. if($sid)
  4323. {
  4324. $sd = "";
  4325. $s = explode(',',trim($sid,','));
  4326. foreach ($s as $value)
  4327. {
  4328. $sd .= " id = ".$value." or";
  4329. }
  4330. $sidwhere .= " and (".rtrim($sd,'or').")";
  4331. }
  4332. //取得信息列表
  4333. $timeread = $ktime;
  4334. $timenum = ceil(($jtime - $ktime) / (24*3600));
  4335. $timelist = array();
  4336. for($i=0;$i<$timenum;$i++)
  4337. {
  4338. $timeread = ($i>0)?$ktime+$i*24*3600:$ktime;
  4339. $timelist[date('Y-m-d',$timeread)] = array('c'=>0,'r'=>0);
  4340. }
  4341. $info_list = $this->whlabel->find_all($where.$sidwhere,'outk,enter,sku,state');
  4342. //echo "<pre>";
  4343. //print_r($info_list);
  4344. //exit();
  4345. $rows = array();$list = array();
  4346. foreach ($info_list as $key=>$value)
  4347. {
  4348. $thistime = $timelist;
  4349. if(isset($rows[strtolower($value['sku'])]))
  4350. {
  4351. if($value['outk'] > $ktime && $value['state'] < $jtime && $value['state'] == 1)
  4352. {
  4353. $rows[strtolower($value['sku'])][date('Y-m-d',$value['outk'])]['c'] += 1;
  4354. }
  4355. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4356. {
  4357. $rows[strtolower($value['sku'])][date('Y-m-d',$value['enter'])]['r'] += 1;
  4358. }
  4359. }
  4360. else
  4361. {
  4362. if($value['outk'] > $ktime && $value['outk'] < $jtime && $value['state'] == 1)
  4363. {
  4364. $thistime[date('Y-m-d',$value['outk'])]['c'] += 1;
  4365. }
  4366. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4367. {
  4368. $thistime[date('Y-m-d',$value['enter'])]['r'] += 1;
  4369. }
  4370. $rows[strtolower($value['sku'])] = $thistime;
  4371. }
  4372. }
  4373. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4374. <head>
  4375. <!--[if gte mso 9]><xml>
  4376. <x:ExcelWorkbook>
  4377. <x:ExcelWorksheets>
  4378. <x:ExcelWorksheet>
  4379. <x:Name>EXCEL</x:Name>
  4380. <x:WorksheetOptions>
  4381. <x:Print>
  4382. <x:ValidPrinterInfo />
  4383. </x:Print>
  4384. </x:WorksheetOptions>
  4385. </x:ExcelWorksheet>
  4386. </x:ExcelWorksheets>
  4387. </x:ExcelWorkbook>
  4388. </xml>
  4389. <![endif]-->
  4390. </head><body>";
  4391. $str .= "<table border=1><tr><td>SKU</td>";
  4392. foreach ($timelist as $k=>$v)
  4393. {
  4394. $str .="<td>".$k."出库</td>";
  4395. $str .="<td>".$k."入库</td>";
  4396. }
  4397. $str .= "</tr></table>";
  4398. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4399. foreach ($rows as $key=>$val)
  4400. {
  4401. $str .= "<tr><td>".strtoupper($key)."</td>";
  4402. foreach ($val as $k=>$v)
  4403. {
  4404. $str .= "<td>".$val[$k]['c']."</td>";
  4405. if($val[$k]['r'] > 0)
  4406. {
  4407. $str .= "<td style='color:#f00'>-".$val[$k]['r']."</td>";
  4408. }
  4409. else
  4410. {
  4411. $str .= "<td>".$val[$k]['r']."</td>";
  4412. }
  4413. }
  4414. $str .= "</tr>";
  4415. }
  4416. $str .= "</table>";
  4417. $str .= "</body></html>";
  4418. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  4419. header( "Content-type: application/octet-stream" );
  4420. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  4421. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  4422. header( "Pragma: no-cache" );
  4423. header( "Expires: 0" );
  4424. exit($str);
  4425. }
  4426. }
  4427. //数量调整模板导出
  4428. public function _presetout()
  4429. {
  4430. if(isset($_GET['excel']))
  4431. {
  4432. $where = "sku != 'Preset' and purchase != 0";
  4433. //数据排序
  4434. $order_str = "id desc";
  4435. if(empty($page))
  4436. {
  4437. $start = 0;
  4438. $perpage = 1;
  4439. }
  4440. else
  4441. {
  4442. $start = ($page - 1)*$perpage;
  4443. }
  4444. //取得信息列表
  4445. $info_list = $this->whlabel->find_pc($where,'warehouse,purchase,sku','*','id desc',0,1);
  4446. $rows = array();$list = array();
  4447. foreach ($info_list as $value)
  4448. {
  4449. $warehouse = $this->warehouse->read($value['warehouse']);
  4450. $number = $value['number'];$ftime = time()-15*24*3600;
  4451. $purchase = $this->purchase->read($value['purchase']);
  4452. $list[] = array($warehouse['title'],$purchase['bm'],$value['sku'],'0','','0');
  4453. }
  4454. $title = "库存模板";
  4455. $titlename = "<table border=1>
  4456. <tr align='center'>
  4457. <td>仓库</td>
  4458. <td>供应商编码</td>
  4459. <td>SKU</td>
  4460. <td>增减数量(正数或负数)</td>
  4461. <td>扣减备注</td>
  4462. <td>扣减方式:0减少库存1删除库存</td>
  4463. </tr>
  4464. </table>";
  4465. $filename = $title.".xls";
  4466. $tail = "";
  4467. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4468. }
  4469. }
  4470. //数量调整模板导入
  4471. public function _presetedit()
  4472. {
  4473. $dir = '/data/excel/'.date('Ymd',time()).'/';
  4474. $config['upload_path'] = '.'.$dir ;
  4475. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  4476. $config['allowed_types'] = 'xls|xlsx|csv';
  4477. $config['max_size'] = 10240;
  4478. $this->load->library('upload', $config);
  4479. $this->upload->initialize($config);
  4480. if ($this->upload->do_upload('userfile'))
  4481. {
  4482. $full_path = $dir.$this->upload->data('file_name');
  4483. $fileName = '.' . $full_path;
  4484. if (!file_exists($fileName))
  4485. {
  4486. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  4487. }
  4488. else
  4489. {
  4490. libxml_use_internal_errors(true);
  4491. require_once "./data/excel/PHPExcel/IOFactory.php";
  4492. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  4493. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  4494. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  4495. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  4496. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  4497. ++$column;//如果列数大于26行
  4498. $list = array();
  4499. for ($i = 2; $i <= $row; $i++) // 行数循环
  4500. {
  4501. $data = array();
  4502. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4503. {
  4504. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4505. }
  4506. $list[] = $data;
  4507. }
  4508. }
  4509. $i = 0;$j = 0;$ed = array();
  4510. foreach ($list as $key=>$value)
  4511. {
  4512. $time = time();
  4513. if($value['0'] == "")
  4514. {
  4515. continue;
  4516. }
  4517. $warehouse = $this->warehouse->get_title($value['0']);
  4518. $purchase = $this->purchase->get_bm($value['1']);
  4519. $sku = $value['2'];
  4520. $num = $value['3'];//调整数量
  4521. $text = $value['4'];//扣减说明
  4522. $type = $value['5'];//调整方式0扣减1删除
  4523. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  4524. if(!$purchase)//如果没有这个SKU
  4525. {
  4526. $ed[] = array($purchase.'-不存在此供应商编码');
  4527. $j++;
  4528. continue;
  4529. }
  4530. if(!$d)//如果没有这个SKU
  4531. {
  4532. $ed[] = array($sku.'-库存中不存在此SKU');
  4533. $j++;
  4534. continue;
  4535. }
  4536. if(!isset($warehouse['id']))
  4537. {
  4538. $ed[] = array($sku.'-仓库名错误!');
  4539. $j++;
  4540. continue;
  4541. }
  4542. if($type != '0' && $type != '1')
  4543. {
  4544. $ed[] = array($sku.'-扣减方式填写错误!');
  4545. $j++;
  4546. continue;
  4547. }
  4548. if($num < 0)//扣减库存
  4549. {
  4550. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and zd = "" and state = 0');
  4551. if(count($data) < abs($num))
  4552. {
  4553. $ed[] = array($sku.'-扣减数量大于库存剩余数量!');
  4554. $j++;
  4555. continue;
  4556. }
  4557. if($type == 0)//如果扣减方式为 扣减库存
  4558. {
  4559. for($i=0;$i<abs($num);$i++)
  4560. {
  4561. $this->whlabel->save(array('state'=>8,'text'=>$text,'deltime'=>$time,'time'=>$time),$data[$i]['id']);
  4562. }
  4563. }
  4564. else if($type == 1)
  4565. {
  4566. for($i=0;$i<abs($num);$i++)
  4567. {
  4568. $this->whlabel->remove($data[$i]['id']);
  4569. }
  4570. }
  4571. }
  4572. else if($num > 0)//增加库存
  4573. {
  4574. $post['sku'] = $d['sku'];
  4575. $post['shop'] = $d['shop'];
  4576. $post['warehouse'] = $warehouse['id'];
  4577. $post['purchase'] = $purchase['id'];
  4578. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4579. $post['state'] = 0;
  4580. $post['title'] = $d['title'];
  4581. $post['number'] = $d['number'];
  4582. $post['features'] = $d['features'];
  4583. $post['enter'] = $time;
  4584. $post['time'] = $time;//操作时间
  4585. for($i=0;$i<$num;$i++)
  4586. {
  4587. $post['label'] = time().rand(100,999).$i;
  4588. $this->whlabel->insert($post);
  4589. }
  4590. }
  4591. sleep(1);//防止入库时间一样,需要延迟1秒
  4592. }
  4593. if($j > 0)
  4594. {
  4595. $tt = date('Ymd',time());
  4596. $title = '库存导入错误信息-'.$tt;
  4597. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4598. $tail = "\n";
  4599. $filename = $title.".xls";
  4600. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  4601. $dir = '/data/excel/'.$time.'/';
  4602. $file_name = 'error_'.$time.rand(1000,9999);
  4603. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  4604. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  4605. fwrite($myfile,$ecl);
  4606. fclose($myfile);
  4607. $error = $dir.$file_name.'.xls';
  4608. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  4609. }
  4610. else
  4611. {
  4612. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  4613. }
  4614. }
  4615. }
  4616. //笛卡儿积
  4617. function cp($ps,$sets,$list)
  4618. {
  4619. $result = array();$j=0;
  4620. for($i=0,$count=count($sets); $i<$count-1; $i++)
  4621. {
  4622. if($i==0)
  4623. {
  4624. $result = $sets[$i];
  4625. }
  4626. $tmp = array();
  4627. foreach($result as $res)
  4628. {
  4629. foreach($sets[$i+1] as $set)
  4630. {
  4631. $tmp[] = $res.','.$set;
  4632. }
  4633. }
  4634. $result = $tmp;
  4635. }
  4636. $this->db->trans_begin();
  4637. foreach ($result as $v)
  4638. {
  4639. $post = array();$title = "";$num="";
  4640. $data = explode(',',$v);
  4641. for($i=0;$i<count($list); $i++)
  4642. {
  4643. $post[$list[$i]] = $data[$i];
  4644. $typeclass = $this->typeclass->read($data[$i]);
  4645. $title = $title.$typeclass['title']." ";
  4646. if($data[$i] != 0)
  4647. {
  4648. $num .=$data[$i];//所有数据ID拼接
  4649. }
  4650. }
  4651. foreach ($ps as $kp=>$vp)
  4652. {
  4653. $post[$kp] = $vp;
  4654. }
  4655. $post['number'] = $num;
  4656. $info_list = $this->whlabel->get_number($num);//查询whlabel是否存在此拼接的数据ID
  4657. if($info_list)
  4658. {
  4659. $j++;
  4660. }
  4661. else
  4662. {
  4663. $skunum = $this->whlabel->find_count();
  4664. $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
  4665. $post['title'] = rtrim($title,' ');
  4666. $this->whlabel->insert($post);
  4667. }
  4668. }
  4669. if ($this->db->trans_status() === FALSE)
  4670. {
  4671. $this->db->trans_commit();
  4672. return NULL;
  4673. }
  4674. else
  4675. {
  4676. $this->db->trans_commit();
  4677. return $j;
  4678. }
  4679. }
  4680. public function _kj($arg_array)
  4681. {
  4682. if(isset($_POST['sku']))
  4683. {
  4684. $time = time();
  4685. $sku = $this->input->post('sku',true);
  4686. $warehouse = $this->input->post('warehouse',true);
  4687. $num = $this->input->post('num',true);
  4688. $text = $this->input->post('text',true);
  4689. $purchase = $this->input->post('purchase',true);
  4690. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4691. if($num > count($order))
  4692. {
  4693. echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
  4694. }
  4695. else
  4696. {
  4697. for($i=0;$i<$num;$i++)
  4698. {
  4699. $this->whlabel->save(array('state'=>8,'text'=>$text,'deltime'=>$time,'time'=>$time),$order[$i]['id']);
  4700. }
  4701. }
  4702. echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
  4703. }
  4704. $uid = $this->whlabel->read($arg_array[0]);
  4705. $uid['num'] = $this->whlabel->find_count('purchase = "'.$uid['purchase']. '" and sku = "'.$uid['sku']. '" and warehouse = "'.$uid['warehouse']. '" and zd = "" and state = 0');
  4706. $this->data['data'] = $uid ;
  4707. $this->_Template('whlabel_kj',$this->data);
  4708. }
  4709. public function _summary($arg_array)
  4710. {
  4711. $prc = array();
  4712. $purchase = $this->purchase->find_all();
  4713. foreach($purchase as $k=>$v)
  4714. {
  4715. $prc[$v['id']] = $v['title'];
  4716. }
  4717. if(isset($_GET['excel']))
  4718. {
  4719. $ktime = $this->input->get('ktime',true);
  4720. $jtime = $this->input->get('jtime',true);
  4721. $ktime = strtotime($ktime);
  4722. $jtime = strtotime($jtime);
  4723. $where = "1=1";
  4724. if($ktime && $jtime)
  4725. {
  4726. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4727. }
  4728. //数据排序
  4729. $order_str = "time desc";
  4730. if(empty($page))
  4731. {
  4732. $start = 0;
  4733. $perpage = 1;
  4734. }
  4735. else
  4736. {
  4737. $start = ($page - 1)*$perpage;
  4738. }
  4739. //取得信息列表
  4740. $info_list = $this->whlabel->find_pc($where,'sku','warehouse,purchase,details,cpid,sku,title');
  4741. foreach ($info_list as $key=>$value)
  4742. {
  4743. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4744. $warehouse = $this->warehouse->read($value['warehouse']);
  4745. $info_list[$key]['warehouse'] = $warehouse['title'];
  4746. $x = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'"','details,cpid');
  4747. $details = array();
  4748. $cpid = array();
  4749. foreach ($x as $k=>$v)
  4750. {
  4751. if($v['details'] != '')
  4752. {
  4753. $details[$v['details']] = $v['details'];
  4754. }
  4755. if($v['cpid'] != 0)
  4756. {
  4757. $cpid[$v['cpid']] = $v['cpid'];
  4758. }
  4759. }
  4760. $info_list[$key]['details'] = ($details)?implode(" ",$details):'';
  4761. $info_list[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4762. $s = $this->whlabel->find_count('state = 0 and sku = "'.$value['sku'].'"');
  4763. $info_list[$key]['s'] = $s;
  4764. $info_list[$key]['x'] = count($x);
  4765. }
  4766. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
  4767. $titlename = "<table border=1>
  4768. <tr align='center'>
  4769. <td>仓库</td>
  4770. <td>供应商</td>
  4771. <td>出库位置</td>
  4772. <td>出库编码</td>
  4773. <td>SKU</td>
  4774. <td>产品名</td>
  4775. <td>总剩余库存</td>
  4776. <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
  4777. </tr>
  4778. </table>";
  4779. $filename = $title.".xls";
  4780. $tail = "";
  4781. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4782. }
  4783. }
  4784. //usps发货清单
  4785. public function _manifest()
  4786. {
  4787. if(isset($_POST['manifest']))
  4788. {
  4789. $wltext = $this->input->post('wltext',true);
  4790. $time = time()-16*3600;
  4791. $ptime = strtotime(date('Y-m-d',$time));
  4792. $waybill = array();
  4793. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  4794. foreach ($fullorder as $v)
  4795. {
  4796. $waybill[$v['waybill']] = $v['waybill'];
  4797. }
  4798. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  4799. foreach ($fullordersmt as $v)
  4800. {
  4801. $waybill[$v['waybill']] = $v['waybill'];
  4802. }
  4803. $wltext = explode(';',$wltext);
  4804. foreach ($wltext as $v)
  4805. {
  4806. if(isset($waybill[$v]))
  4807. {
  4808. unset($waybill[$v]);
  4809. }
  4810. }
  4811. $data = $this->usps->get_manifest($waybill);
  4812. if(isset($data['Description']))
  4813. {
  4814. echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
  4815. }
  4816. else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
  4817. {
  4818. $bctime = date('Ymd',time());
  4819. $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
  4820. echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
  4821. }
  4822. else
  4823. {
  4824. echo json_encode(array('msg'=>$data,'success'=>false));exit;
  4825. }
  4826. }
  4827. }
  4828. public function _pdf($pdf,$title,$bctime)
  4829. {
  4830. $pdf_path = './data/pdf/'.$bctime.'/';
  4831. $file_base64 = $pdf;
  4832. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4833. $file_base64 = base64_decode($file_base64);
  4834. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  4835. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  4836. return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
  4837. }
  4838. /**
  4839. *
  4840. *
  4841. *
  4842. 进销存占单异常索引
  4843. *
  4844. *
  4845. *
  4846. **/
  4847. public function _abnormal()
  4848. {
  4849. $post = $this->input->post(NULL, TRUE);
  4850. if(isset($post['page']))
  4851. {
  4852. $page = $this->input->post('page',true);
  4853. $perpage = $this->input->post('perpage',true);
  4854. $sku = $this->input->post('sku',true);
  4855. $where = "1=1";
  4856. //数据排序
  4857. $order_str = "id desc";
  4858. if(empty($page))
  4859. {
  4860. $start = 0;
  4861. $perpage = 1;
  4862. }
  4863. else
  4864. {
  4865. $start = ($page - 1)*$perpage;
  4866. }
  4867. //取得信息列表
  4868. $info_list = $this->whlabel->find_all($where,'*');
  4869. $rows = array();$list = array();
  4870. foreach ($info_list as $key=>$value)
  4871. {
  4872. $rows[strtolower($value['sku'])] = $value;//所有数据sku
  4873. }
  4874. foreach ($rows as $value)
  4875. {
  4876. $warehouse = $this->warehouse->read($value['warehouse']);
  4877. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
  4878. $number = $value['number'];$ftime = time()-15*24*3600;
  4879. if($value['shop'] != '')
  4880. {
  4881. $shop = $value['shop'];
  4882. $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');
  4883. $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');
  4884. $order = array_merge($orderdlz,$ordersmt);
  4885. $od = 0;$a = '';$orid = '';
  4886. foreach ($order as $v)
  4887. {
  4888. $or = explode('|',ltrim($v['whlabel'],'|'));
  4889. for($i=0;$i<count($or);$i++)
  4890. {
  4891. $orod = explode('-',$or[$i]);
  4892. if($orod[0] == $number)
  4893. {
  4894. $od += $orod[1];
  4895. }
  4896. }
  4897. $orid .= $v['number'].'-';
  4898. }
  4899. }
  4900. else
  4901. {
  4902. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  4903. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  4904. $order = array_merge($orderdlz,$ordersmt);
  4905. $od = 0;$a = '';$orid = '';$qt = array();
  4906. foreach ($order as $v)
  4907. {
  4908. $or = explode('|',ltrim($v['whlabel'],'|'));
  4909. for($i=0;$i<count($or);$i++)
  4910. {
  4911. $orod = explode('-',$or[$i]);
  4912. if($orod[0] == $number)
  4913. {
  4914. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
  4915. if($czzs > 0)
  4916. {
  4917. if(isset($qt[$v['shop']]))
  4918. {
  4919. if($qt[$v['shop']] < $orod[1])
  4920. {
  4921. $od += $orod[1];//专属小于单量不计算剩余直接归入通用
  4922. $orid .= $v['number'].'+数量'.$orod[1].'-';
  4923. }
  4924. else
  4925. {
  4926. $qt[$v['shop']] -= $orod[1];
  4927. }
  4928. }
  4929. else
  4930. {
  4931. $qt[$v['shop']] = $czzs;
  4932. }
  4933. }
  4934. else
  4935. {
  4936. $od += $orod[1];
  4937. $orid .= $v['number'].'+数量'.$orod[1].'-';
  4938. }
  4939. }
  4940. }
  4941. }
  4942. }
  4943. $z = $od.'('.$orid.')';//查看订单号
  4944. //$z = $od;
  4945. if($od > $c)
  4946. {
  4947. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
  4948. }
  4949. }
  4950. $listdata = array_slice($list,$start,$perpage);
  4951. $total = count($list);
  4952. $pagenum = ceil($total/$perpage);
  4953. $over = $total-($start+$perpage);
  4954. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  4955. echo json_encode($rows);exit;
  4956. }
  4957. $this->_Template('whlabel_abnormal',$this->data);
  4958. }
  4959. /**
  4960. *
  4961. *
  4962. *
  4963. 进销存占单异常索引
  4964. *
  4965. *
  4966. *
  4967. **/
  4968. public function _error()
  4969. {
  4970. $post = $this->input->post(NULL, TRUE);
  4971. if(isset($post['page']))
  4972. {
  4973. $page = $this->input->post('page',true);
  4974. $perpage = $this->input->post('perpage',true);
  4975. $sku = $this->input->post('sku',true);
  4976. $warehouse = $this->input->post('warehouse',true);
  4977. $ktime = $this->input->post('ktime',true);
  4978. $jtime = $this->input->post('jtime',true);
  4979. $ktime = strtotime($ktime);
  4980. $jtime = strtotime($jtime);
  4981. $where = "sku != 'Preset'";
  4982. $gj = '';
  4983. if($sku)
  4984. {
  4985. $where .= " and sku like '%$sku%'";
  4986. }
  4987. else
  4988. {
  4989. if($ktime && $jtime)
  4990. {
  4991. $gj = " and time > '$ktime' and time < '$jtime'";
  4992. }
  4993. }
  4994. if($warehouse)
  4995. {
  4996. $where .= " and warehouse = '$warehouse'";
  4997. }
  4998. //数据排序
  4999. $order_str = "id desc";
  5000. if(empty($page))
  5001. {
  5002. $start = 0;
  5003. $perpage = 1;
  5004. }
  5005. else
  5006. {
  5007. $start = ($page - 1)*$perpage;
  5008. }
  5009. //取得信息列表
  5010. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5011. $rows = array();$list = array();
  5012. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5013. foreach ($info_list as $value)
  5014. {
  5015. $warehouse = $this->warehouse->read($value['warehouse']);
  5016. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5017. $number = $value['number'];$ftime = time()-15*24*3600;
  5018. if($c < 1)
  5019. {
  5020. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5021. }
  5022. }
  5023. $listdata = array_slice($list,$start,$perpage);
  5024. $total = count($list);
  5025. $pagenum = ceil($total/$perpage);
  5026. $over = $total-($start+$perpage);
  5027. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5028. echo json_encode($rows);exit;
  5029. }
  5030. if(isset($post['s']))
  5031. {
  5032. $id_arr = $this->input->post('s');
  5033. $id_arr = explode(',',$id_arr);
  5034. if(!$id_arr)
  5035. {
  5036. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  5037. }
  5038. //循环删除记录
  5039. foreach ($id_arr as $v)
  5040. {
  5041. $dd = $this->whlabel->read($v);
  5042. $deldd = $this->whlabel->find_all("sku = '".$dd['sku']."' and warehouse = '".$dd['warehouse']."'");
  5043. foreach ($deldd as $vv)
  5044. {
  5045. $this->whlabel->remove($vv['id']);
  5046. }
  5047. }
  5048. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  5049. }
  5050. $this->_Template('whlabel_error',$this->data);
  5051. }
  5052. public function _errorexcel()
  5053. {
  5054. $post = $this->input->post(NULL, TRUE);
  5055. if(isset($_GET['page']))
  5056. {
  5057. $page = $this->input->get('page',true);
  5058. $perpage = $this->input->get('perpage',true);
  5059. $sku = $this->input->get('sku',true);
  5060. $warehouse = $this->input->get('warehouse',true);
  5061. $ktime = $this->input->get('ktime',true);
  5062. $jtime = $this->input->get('jtime',true);
  5063. $ktime = strtotime($ktime);
  5064. $jtime = strtotime($jtime);
  5065. $where = "sku != 'Preset'";
  5066. $gj = '';
  5067. if($sku)
  5068. {
  5069. $where .= " and sku like '%$sku%'";
  5070. }
  5071. else
  5072. {
  5073. if($ktime && $jtime)
  5074. {
  5075. $gj = " and time > '$ktime' and time < '$jtime'";
  5076. }
  5077. }
  5078. if($warehouse)
  5079. {
  5080. $where .= " and warehouse = '$warehouse'";
  5081. }
  5082. //数据排序
  5083. $order_str = "id desc";
  5084. if(empty($page))
  5085. {
  5086. $start = 0;
  5087. $perpage = 1;
  5088. }
  5089. else
  5090. {
  5091. $start = ($page - 1)*$perpage;
  5092. }
  5093. //取得信息列表
  5094. $rows = array();$list = array();
  5095. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5096. foreach ($info_list as $value)
  5097. {
  5098. $warehouse = $this->warehouse->read($value['warehouse']);
  5099. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5100. $number = $value['number'];$ftime = time()-15*24*3600;
  5101. if($c < 1)
  5102. {
  5103. $list[] = array('warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5104. }
  5105. }
  5106. $title = "0库存汇总";
  5107. $titlename = "<table border=1>
  5108. <tr align='center'>
  5109. <td>仓库</td>
  5110. <td>SKU</td>
  5111. <td>产品</td>
  5112. <td>当前库存</td>
  5113. </tr>
  5114. </table>";
  5115. $filename = $title.".xls";
  5116. $tail = "";
  5117. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5118. }
  5119. }
  5120. /**
  5121. *
  5122. *
  5123. * 占单
  5124. *
  5125. *
  5126. **/
  5127. public function _kcyz()
  5128. {
  5129. $post = $this->input->post(NULL, TRUE);
  5130. if(isset($post['warehouse']))
  5131. {
  5132. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请更新浏览器缓存!','success'=>false)));exit;//不再使用
  5133. $warehouse = $this->input->post('warehouse',true);
  5134. $whlabel = $this->input->post('whlabel',true);
  5135. $id = $this->input->post('id',true);
  5136. $shop = $this->input->post('shop',true);
  5137. $number = $this->input->post('number',true);
  5138. if(!$whlabel || $whlabel == '|')
  5139. {
  5140. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  5141. }
  5142. $pp = explode('|',trim($whlabel,'|'));
  5143. $x = 0;$save = array();
  5144. foreach ($pp as $va)
  5145. {
  5146. $num = explode('-',$va);
  5147. if($number)
  5148. {
  5149. $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 = '')");//通用
  5150. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  5151. }
  5152. else
  5153. {
  5154. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  5155. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  5156. }
  5157. $x++;
  5158. if(count($whlabel)+count($shopwhlabel) < $num[1])
  5159. {
  5160. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  5161. }
  5162. }
  5163. if(isset($save[0]))
  5164. {
  5165. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
  5166. }
  5167. else
  5168. {
  5169. echo json_encode(array('success'=>true));exit;
  5170. }
  5171. }
  5172. }
  5173. public function _db()
  5174. {
  5175. $post = $this->input->post(NULL, TRUE);
  5176. if(isset($post['page']))
  5177. {
  5178. $page = $this->input->post('page',true);
  5179. $perpage = $this->input->post('perpage',true);
  5180. $sku = $this->input->post('sku',true);
  5181. $number = $this->input->post('number',true);
  5182. $warehouse = $this->input->post('warehouse',true);
  5183. $purchase = $this->input->post('purchase',true);
  5184. $orderinfo = $this->input->post('orderinfo',true);
  5185. $waybill = $this->input->post('waybill',true);
  5186. $category = $this->input->post('category',true);
  5187. $size = $this->input->post('size',true);
  5188. $grade = $this->input->post('grade',true);
  5189. $color = $this->input->post('color',true);
  5190. $lowe = $this->input->post('lowe',true);
  5191. $state = $this->input->post('state',true);
  5192. $label = $this->input->post('label',true);
  5193. $timetk = $this->input->post('timetkk',true);
  5194. $timetj = $this->input->post('timetjj',true);
  5195. $timetk = strtotime($timetk);
  5196. $timetj = strtotime($timetj);
  5197. $where = "dbtime > 0";
  5198. if($timetk && $timetj)
  5199. {
  5200. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5201. }
  5202. if($sku)
  5203. {
  5204. $where .= " and sku = '$sku'";
  5205. }
  5206. if($warehouse)
  5207. {
  5208. $where .= " and warehouse = '$warehouse'";
  5209. if($warehouse == 12)
  5210. {
  5211. $w = 'specialstock';
  5212. }
  5213. else
  5214. {
  5215. $w = 'whlabel';
  5216. }
  5217. }
  5218. if($purchase)
  5219. {
  5220. $where .= " and purchase = '$purchase'";
  5221. }
  5222. if($category)
  5223. {
  5224. $where .= " and features like '%-$category-%'";
  5225. }
  5226. if($size)
  5227. {
  5228. $where .= " and features like '%-$size-%'";
  5229. }
  5230. if($grade)
  5231. {
  5232. $where .= " and features like '%-$grade-%'";
  5233. }
  5234. if($color)
  5235. {
  5236. $where .= " and features like '%-$color-%'";
  5237. }
  5238. if($lowe)
  5239. {
  5240. $where .= " and features like '%-$lowe-%'";
  5241. }
  5242. if($state != '')
  5243. {
  5244. $where .= " and state = '$state'";
  5245. }
  5246. //数据排序
  5247. $order_str = "dbtime desc";
  5248. if(empty($page))
  5249. {
  5250. $start = 0;
  5251. $perpage = 1;
  5252. }
  5253. else
  5254. {
  5255. $start = ($page - 1)*$perpage;
  5256. }
  5257. //取得信息列表
  5258. $info_list = $this->$w->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5259. foreach ($info_list as $key=>$value)
  5260. {
  5261. $warehouse = $this->$w->read($value['warehouse']);
  5262. $info_list[$key]['warehouse'] = $warehouse['title'];
  5263. $purchase = $this->purchase->read($value['purchase']);
  5264. $info_list[$key]['purchase'] = $purchase['title'];
  5265. if($value['enter'] != 0)
  5266. {
  5267. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5268. }
  5269. else
  5270. {
  5271. $info_list[$key]['enter'] = "";
  5272. }
  5273. if($value['dbtime'] != 0)
  5274. {
  5275. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5276. }
  5277. else
  5278. {
  5279. $info_list[$key]['dbtime'] = "";
  5280. }
  5281. if($value['state'] == 0)
  5282. {
  5283. $info_list[$key]['state'] = "在库";
  5284. }
  5285. else if($value['state'] == 1)
  5286. {
  5287. $info_list[$key]['state'] = "出库";
  5288. }
  5289. else if($value['state'] == 2)
  5290. {
  5291. $info_list[$key]['state'] = "退库";
  5292. }
  5293. else if($value['state'] == 3)
  5294. {
  5295. $info_list[$key]['state'] = "调拨中";
  5296. }
  5297. else if($value['state'] == 4)
  5298. {
  5299. $info_list[$key]['state'] = "再加工";
  5300. }
  5301. else if($value['state'] == 5)
  5302. {
  5303. $info_list[$key]['state'] = "维修中";
  5304. }
  5305. else if($value['state'] == 6)
  5306. {
  5307. $info_list[$key]['state'] = "盘亏";
  5308. }
  5309. else if($value['state'] == 7)
  5310. {
  5311. $info_list[$key]['state'] = "更换标签";
  5312. }
  5313. else if($value['state'] == 8)
  5314. {
  5315. $info_list[$key]['state'] = "其它";
  5316. }
  5317. else if($value['state'] == 9)
  5318. {
  5319. $info_list[$key]['state'] = "预设";
  5320. }
  5321. }
  5322. $total = $this->whlabel->find_count($where);
  5323. $pagenum = ceil($total/$perpage);
  5324. $over = $total-($start+$perpage);
  5325. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5326. echo json_encode($rows);exit;
  5327. }
  5328. if(isset($post['outsku']))
  5329. {
  5330. $time = time();
  5331. $cz = $this->input->post('cz',true);
  5332. $label = $this->input->post('outsku',true);
  5333. $sl = $this->input->post('sl',true);
  5334. $num = $this->input->post('num',true);
  5335. //$warehouse = $this->input->post('warehouse',true);
  5336. if(!$sl)
  5337. {
  5338. $sl = 1;
  5339. }
  5340. if(!$warehouse)
  5341. {
  5342. echo json_encode(array('msg'=>'请选择调拨到的仓库','success'=>false));exit;
  5343. }
  5344. $dblabel = $this->whlabellabel->get_label($label);
  5345. if($dblabel)
  5346. {
  5347. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '0' and zd = ''");
  5348. if(count($data) < 1)
  5349. {
  5350. echo json_encode(array('msg'=>'没有此产品数据!','success'=>false));exit;
  5351. }
  5352. if(count($data) < $num)
  5353. {
  5354. echo json_encode(array('msg'=>'库存数量少于调拨数量!','success'=>false));exit;
  5355. }
  5356. for($i=0;$i<$sl;$i++)
  5357. {
  5358. $this->whlabel->save(array('state'=>3,'dbtime'=>$dbtime,'dbcontent'=>$data[$i]['warehouse'].'-'.$time.'|','time'=>$time),$data[$i]['id']);
  5359. }
  5360. echo json_encode(array('success'=>true));exit;
  5361. }
  5362. else
  5363. {
  5364. echo json_encode(array('msg'=>'未找到此条码产品!','success'=>false));exit;
  5365. }
  5366. }
  5367. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5368. $this->_Template('whlabel_db',$this->data);
  5369. }
  5370. public function _dbrk()
  5371. {
  5372. $post = $this->input->post(NULL, TRUE);
  5373. if(isset($post['page']))
  5374. {
  5375. $page = $this->input->post('page',true);
  5376. $perpage = $this->input->post('perpage',true);
  5377. $sku = $this->input->post('sku',true);
  5378. $number = $this->input->post('number',true);
  5379. $warehouse = $this->input->post('warehouse',true);
  5380. $purchase = $this->input->post('purchase',true);
  5381. $orderinfo = $this->input->post('orderinfo',true);
  5382. $waybill = $this->input->post('waybill',true);
  5383. $category = $this->input->post('category',true);
  5384. $size = $this->input->post('size',true);
  5385. $grade = $this->input->post('grade',true);
  5386. $color = $this->input->post('color',true);
  5387. $lowe = $this->input->post('lowe',true);
  5388. $state = $this->input->post('state',true);
  5389. $label = $this->input->post('label',true);
  5390. $ctime = $this->input->post('ctime',true);
  5391. $timetk = $this->input->post('timetkk',true);
  5392. $timetj = $this->input->post('timetjj',true);
  5393. $timetk = strtotime($timetk);
  5394. $timetj = strtotime($timetj);
  5395. $where = "dbtime > 0";
  5396. if($timetk && $timetj)
  5397. {
  5398. $where .= " and ".$ctime." > '$timetk' and ".$ctime." < '$timetj'";
  5399. }
  5400. if($sku)
  5401. {
  5402. $where .= " and sku = '$sku'";
  5403. }
  5404. if($warehouse)
  5405. {
  5406. $where .= " and warehouse = '$warehouse'";
  5407. }
  5408. if($purchase)
  5409. {
  5410. $where .= " and purchase = '$purchase'";
  5411. }
  5412. if($category)
  5413. {
  5414. $where .= " and features like '%-$category-%'";
  5415. }
  5416. if($size)
  5417. {
  5418. $where .= " and features like '%-$size-%'";
  5419. }
  5420. if($grade)
  5421. {
  5422. $where .= " and features like '%-$grade-%'";
  5423. }
  5424. if($color)
  5425. {
  5426. $where .= " and features like '%-$color-%'";
  5427. }
  5428. if($lowe)
  5429. {
  5430. $where .= " and features like '%-$lowe-%'";
  5431. }
  5432. if($state != '')
  5433. {
  5434. $where .= " and state = '$state'";
  5435. }
  5436. //数据排序
  5437. $order_str = "dbtime desc";
  5438. if(empty($page))
  5439. {
  5440. $start = 0;
  5441. $perpage = 1;
  5442. }
  5443. else
  5444. {
  5445. $start = ($page - 1)*$perpage;
  5446. }
  5447. //取得信息列表
  5448. $info_list = $this->whlabel->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5449. foreach ($info_list as $key=>$value)
  5450. {
  5451. $warehouse = $this->warehouse->read($value['warehouse']);
  5452. $info_list[$key]['warehouse'] = $warehouse['title'];
  5453. $purchase = $this->purchase->read($value['purchase']);
  5454. $info_list[$key]['purchase'] = $purchase['title'];
  5455. if($value['enter'] != 0)
  5456. {
  5457. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5458. }
  5459. else
  5460. {
  5461. $info_list[$key]['enter'] = "";
  5462. }
  5463. if($value['dbtime'] != 0)
  5464. {
  5465. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5466. }
  5467. else
  5468. {
  5469. $info_list[$key]['dbtime'] = "";
  5470. }
  5471. if($value['state'] == 0)
  5472. {
  5473. $info_list[$key]['state'] = "在库";
  5474. }
  5475. else if($value['state'] == 1)
  5476. {
  5477. $info_list[$key]['state'] = "出库";
  5478. }
  5479. else if($value['state'] == 2)
  5480. {
  5481. $info_list[$key]['state'] = "退库";
  5482. }
  5483. else if($value['state'] == 3)
  5484. {
  5485. $info_list[$key]['state'] = "调拨中";
  5486. }
  5487. else if($value['state'] == 4)
  5488. {
  5489. $info_list[$key]['state'] = "再加工";
  5490. }
  5491. else if($value['state'] == 5)
  5492. {
  5493. $info_list[$key]['state'] = "维修中";
  5494. }
  5495. else if($value['state'] == 6)
  5496. {
  5497. $info_list[$key]['state'] = "盘亏";
  5498. }
  5499. else if($value['state'] == 7)
  5500. {
  5501. $info_list[$key]['state'] = "更换标签";
  5502. }
  5503. else if($value['state'] == 8)
  5504. {
  5505. $info_list[$key]['state'] = "其它";
  5506. }
  5507. else if($value['state'] == 9)
  5508. {
  5509. $info_list[$key]['state'] = "预设";
  5510. }
  5511. }
  5512. $total = $this->whlabel->find_count($where);
  5513. $pagenum = ceil($total/$perpage);
  5514. $over = $total-($start+$perpage);
  5515. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5516. echo json_encode($rows);exit;
  5517. }
  5518. if(isset($post['rsku']))
  5519. {
  5520. $cz = $this->input->post('cz',true);
  5521. $label = $this->input->post('rsku',true);
  5522. $sl = $this->input->post('sl',true);
  5523. $warehouse = $this->input->post('warehouse',true);
  5524. if(!$sl)
  5525. {
  5526. $sl = 1;
  5527. }
  5528. if(!$warehouse)
  5529. {
  5530. echo json_encode(array('msg'=>'请选择入库仓库','success'=>false));exit;
  5531. }
  5532. $dblabel = $this->whlabellabel->get_label($label);
  5533. if($dblabel)
  5534. {
  5535. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '3' and zd = ''");
  5536. if(count($data) < 1)
  5537. {
  5538. echo json_encode(array('msg'=>'没有此SKU调拨数据!','success'=>false));exit;
  5539. }
  5540. if($sl > count($data))
  5541. {
  5542. echo json_encode(array('msg'=>'入库数量大于调拨数量!','success'=>false));exit;
  5543. }
  5544. $time = time();
  5545. for($i=0;$i<$sl;$i++)
  5546. {
  5547. $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']);
  5548. }
  5549. echo json_encode(array('success'=>true));exit;
  5550. }
  5551. else
  5552. {
  5553. echo json_encode(array('msg'=>'没有此条码的库存信息!','success'=>false));exit;
  5554. }
  5555. }
  5556. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5557. $this->_Template('whlabel_dbrk',$this->data);
  5558. }
  5559. public function _whlabelczdc()
  5560. {
  5561. if(isset($_GET['excel']))
  5562. {
  5563. //数据排序
  5564. $order_str = "id desc";
  5565. if(empty($page))
  5566. {
  5567. $start = 0;
  5568. $perpage = 1;
  5569. }
  5570. else
  5571. {
  5572. $start = ($page - 1)*$perpage;
  5573. }
  5574. $state = $this->input->get('state',true);
  5575. $sku = $this->input->get('sku',true);
  5576. $ctime = $this->input->get('ctime',true);
  5577. $category = $this->input->get('category',true);
  5578. $size = $this->input->get('size',true);
  5579. $grade = $this->input->get('grade',true);
  5580. $color = $this->input->get('color',true);
  5581. $lowe = $this->input->get('lowe',true);
  5582. $timetk = $this->input->get('timetkk',true);
  5583. $timetj = $this->input->get('timetjj',true);
  5584. $timetk = strtotime($timetk);
  5585. $timetj = strtotime($timetj);
  5586. $where = "dbtime > 0";
  5587. if($timetk && $timetj)
  5588. {
  5589. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5590. }
  5591. if($category)
  5592. {
  5593. $where .= " and features like '%-$category-%'";
  5594. }
  5595. if($size)
  5596. {
  5597. $where .= " and features like '%-$size-%'";
  5598. }
  5599. if($grade)
  5600. {
  5601. $where .= " and features like '%-$grade-%'";
  5602. }
  5603. if($color)
  5604. {
  5605. $where .= " and features like '%-$color-%'";
  5606. }
  5607. if($lowe)
  5608. {
  5609. $where .= " and features like '%-$lowe-%'";
  5610. }
  5611. //取得信息列表
  5612. $info_list = $this->whlabel->find_all($where,'*');
  5613. $rows = array();$list = array();
  5614. foreach ($info_list as $key=>$value)
  5615. {
  5616. $rows[$value['sku']] = $value;//所有数据sku
  5617. }
  5618. foreach ($rows as $value)
  5619. {
  5620. $warehouse = $this->warehouse->read($value['warehouse']);
  5621. $db = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'"');
  5622. $rk = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and enter > 0');
  5623. if($value['orderinfo'] == 0)
  5624. {
  5625. $info_list[$key]['orderinfo'] = "";
  5626. }
  5627. if($value['waybill'] == 0)
  5628. {
  5629. $info_list[$key]['waybill'] = "";
  5630. }
  5631. if($value['state'] == 0)
  5632. {
  5633. $value['state'] = "在库";
  5634. }
  5635. else if($value['state'] == 3)
  5636. {
  5637. $value['state'] = "调拨中";
  5638. }
  5639. $list[] = array($value['sku'],$value['title'],$db,$rk);
  5640. }
  5641. $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj)."统计表";
  5642. $titlename = "<table border=1>
  5643. <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
  5644. <tr align='center'>
  5645. <td>SKU</td>
  5646. <td>产品</td>
  5647. <td>调拨数量</td>
  5648. <td>入库数量</td>
  5649. </tr>
  5650. </table>";
  5651. $filename = $title.".xls";
  5652. $tail = "";
  5653. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5654. }
  5655. }
  5656. public function _print($arg_array)
  5657. {
  5658. if(isset($_SESSION['api']))
  5659. {
  5660. $user = $this->user->get_api($_SESSION['api']);
  5661. $usp = $user;
  5662. $fgshop = "";$sid = "";$wid="";$wtype="";
  5663. $usersp = explode('|',trim($user['shop'],'|'));
  5664. $userwh = explode('|',trim($user['warehouse'],'|'));
  5665. foreach ($usersp as $value)
  5666. {
  5667. $fgshop .= " shop = ".$value." or";
  5668. $sid .= " id = ".$value." or";
  5669. }
  5670. foreach ($userwh as $value)
  5671. {
  5672. $wid .= " id = ".$value." or";
  5673. $wtype .= " type = ".$value." or";
  5674. }
  5675. }
  5676. $post = $this->input->post(NULL, TRUE);
  5677. if(isset($post['tmsku']))
  5678. {
  5679. $tmsku = $this->input->post('tmsku',true);
  5680. if(is_numeric($tmsku))
  5681. {
  5682. $yyh = $this->whlabellabel->get_label($tmsku);
  5683. }
  5684. else
  5685. {
  5686. $yyh = $this->whlabellabel->get_sku($tmsku);
  5687. }
  5688. if($yyh)
  5689. {
  5690. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  5691. }
  5692. else
  5693. {
  5694. echo json_encode(array('success'=>false));exit;
  5695. }
  5696. }
  5697. $classid = $this->classid->sku();
  5698. $pm = $classid;
  5699. $scsku = $classid;
  5700. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5701. if(isset($post['warehouse']))
  5702. {
  5703. if($post['warehouse'])
  5704. {
  5705. $list = array();$num = "";$title = "";$features = "";
  5706. $order = 0;
  5707. $post['shop'] = '';
  5708. $brand = $this->input->post('brand',true);
  5709. if($brand != '0,')
  5710. {
  5711. $b = $this->brand->read(rtrim($brand,','));
  5712. if($b)
  5713. {
  5714. $post['shop'] = str_replace('|',',',$b['shop']);
  5715. }
  5716. }
  5717. $post['details'] = $this->input->post('details',true);//打印数量
  5718. $xbqnum = $this->input->post('xbqnum',true);
  5719. $post['purchase'] = $this->input->post('purchase',true);
  5720. $post['warehouse'] = $this->input->post('warehouse',true);
  5721. $post['purchase'] = $this->input->post('purchase',true);
  5722. $post['retreatwarehouse'] = $post['warehouse'];
  5723. $post['cpbz'] = $this->input->post('cpbz',true);
  5724. $post['state'] = 9;
  5725. $category = $this->input->post('category',true);
  5726. $list['category'] = $category;
  5727. $list['hairtype'] = $this->input->post('hairtype',true);
  5728. $list['grade'] = $this->input->post('grade',true);
  5729. $size = $this->input->post('size',true);
  5730. $list['size'] = rtrim($size,',');
  5731. $list['hairnumber'] = $this->input->post('hairnumber',true);
  5732. $list['extension'] = $this->input->post('extension',true);
  5733. if($category == 1297)
  5734. {
  5735. $list['sywignumber'] = $this->input->post('sywignumber',true);
  5736. }
  5737. if($category == 1702)
  5738. {
  5739. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  5740. $list['syother'] = $this->input->post('syother',true);
  5741. }
  5742. if($category == 133)
  5743. {
  5744. $list['fittype'] = $this->input->post('fittype',true);
  5745. $list['acother'] = $this->input->post('acother',true);
  5746. }
  5747. $list['color'] = $this->input->post('color',true);
  5748. $list['lowe'] = $this->input->post('lowe',true);
  5749. if($category == 127)
  5750. {
  5751. $list['type'] = $this->input->post('type',true);
  5752. $list['headroad'] = $this->input->post('headroad',true);
  5753. $list['density'] = $this->input->post('density',true);
  5754. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  5755. {
  5756. $list['lacesize'] = $this->input->post('lacesize',true);
  5757. }
  5758. $list['lacecolor'] = $this->input->post('lacecolor',true);
  5759. $list['lacetypes'] = $this->input->post('lacetypes',true);
  5760. }
  5761. if($category == 128)
  5762. {
  5763. $list['lacetype'] = $this->input->post('lacetype',true);
  5764. $list['haircap'] = $this->input->post('haircap',true);
  5765. $list['density'] = $this->input->post('density',true);
  5766. $list['lacecolor'] = $this->input->post('lacecolor',true);
  5767. $list['lacetypes'] = $this->input->post('lacetypes',true);
  5768. $list['wigother'] = $this->input->post('wigother',true);
  5769. }
  5770. if($category == 129)
  5771. {
  5772. $list['wide'] = $this->input->post('wide',true);
  5773. }
  5774. if($category == 131)
  5775. {
  5776. $list['gifttype'] = $this->input->post('gifttype',true);
  5777. $list['giftother'] = $this->input->post('giftother',true);
  5778. }
  5779. if($category == 134)
  5780. {
  5781. $list['pieceweight'] = $this->input->post('pieceweight',true);
  5782. }
  5783. if($category == 1297)
  5784. {
  5785. $list['synthetictype'] = $this->input->post('synthetictype',true);
  5786. $list['sywigother'] = $this->input->post('sywigother',true);
  5787. }
  5788. if($category == 130 || $category == 133 || $category == 1702)
  5789. {
  5790. $list['items'] = $this->input->post('items',true);
  5791. }
  5792. if($category == 1702)
  5793. {
  5794. $list['syhairther'] = $this->input->post('syhairther',true);
  5795. }
  5796. foreach($list as $k=>$v)
  5797. {
  5798. if($v != 0)
  5799. {
  5800. $num .=$v;
  5801. $features .=$v.'-';
  5802. $post[$k] = $v;
  5803. $typeclass = $this->typeclass->read($v);
  5804. if(isset($pm[$typeclass['classid']]))
  5805. {
  5806. if(stripos($typeclass['zh'],'|') !== false)
  5807. {
  5808. $exzh = explode('|',$typeclass['zh']);
  5809. $pm[$typeclass['classid']] = $exzh[0];
  5810. }
  5811. else
  5812. {
  5813. $pm[$typeclass['classid']] = $typeclass['zh'];
  5814. }
  5815. }
  5816. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5817. if($k != 'size')
  5818. {
  5819. $title .= $typeclass['title']." ";
  5820. }
  5821. }
  5822. }
  5823. $typeclass = $this->typeclass->read($list['size']);
  5824. $title .= $typeclass['title'];
  5825. $time = time();
  5826. $post['title'] = rtrim($title,' ');
  5827. $post['number'] = $num;
  5828. $post['features'] = '-'.$features;
  5829. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  5830. $featurespp = explode('-',trim($featurespp,'-'));
  5831. if(isset($featurespp[5]))
  5832. {
  5833. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  5834. }
  5835. else
  5836. {
  5837. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  5838. }
  5839. $post['enter'] = $time;
  5840. $post['time'] = $time;//操作时间
  5841. $scsku = implode("-",$scsku);
  5842. $zh = implode(" ",$pm);
  5843. $scsku = str_replace('- ','-',trim($scsku,'-'));
  5844. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  5845. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  5846. $post['sku'] = $bqsku;
  5847. $label = time().rand(0,9);
  5848. $post['label'] = $label;
  5849. $cpid = $this->whlabellabel->find_count();
  5850. $post['cpid'] = $cpid+1;
  5851. $cpid = $post['cpid'];
  5852. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5853. //if($whlabelbarcode)
  5854. //{
  5855. //$post['label'] = $whlabelbarcode['label'];
  5856. //if(!$this->whlabellabel->insert($post))
  5857. //{
  5858. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5859. //}
  5860. //}
  5861. //else
  5862. //{
  5863. $this->db->trans_begin();
  5864. $this->whlabellabel->insert($post);
  5865. //$this->whlabelbarcode->insert($post);
  5866. if ($this->db->trans_status() === TRUE)
  5867. {
  5868. $this->db->trans_commit();
  5869. }
  5870. else
  5871. {
  5872. $this->db->trans_rollback();
  5873. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5874. }
  5875. //}
  5876. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  5877. $purchase = $this->purchase->read($post['purchase']);
  5878. echo json_encode(array('title'=>$title,'num'=>$post['label'],'bqsku'=>$bqsku,'xbqnum'=>$xbqnum,'zh'=>str_replace('自然色 ','',rtrim($zh,' ')),'details'=>$details,'purchase'=>$purchase['title'],'cpbz'=>$post['cpbz'],'usa'=>0,'success'=>true));exit;//特殊仓目前不需要仓库选项
  5879. }
  5880. }
  5881. if(isset($_SESSION['api']))
  5882. {
  5883. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  5884. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  5885. $this->data['wlshop'] = $wlshop;
  5886. $this->data['warehouse'] = $warehouse;
  5887. }
  5888. $whlabelwz = $this->whlabelwz->find_all();
  5889. $this->data['whlabelwz'] = $whlabelwz;
  5890. $this->_Template('whlabel_print',$this->data);
  5891. }
  5892. public function _usaprint($arg_array)
  5893. {
  5894. if(isset($_SESSION['api']))
  5895. {
  5896. $user = $this->user->get_api($_SESSION['api']);
  5897. $usp = $user;
  5898. $fgshop = "";$sid = "";$wid="";$wtype="";
  5899. $usersp = explode('|',trim($user['shop'],'|'));
  5900. $userwh = explode('|',trim($user['warehouse'],'|'));
  5901. foreach ($usersp as $value)
  5902. {
  5903. $fgshop .= " shop = ".$value." or";
  5904. $sid .= " id = ".$value." or";
  5905. }
  5906. foreach ($userwh as $value)
  5907. {
  5908. $wid .= " id = ".$value." or";
  5909. $wtype .= " type = ".$value." or";
  5910. }
  5911. }
  5912. $post = $this->input->post(NULL, TRUE);
  5913. if(isset($post['tmsku']))
  5914. {
  5915. $tmsku = $this->input->post('tmsku',true);
  5916. if(is_numeric($tmsku))
  5917. {
  5918. $yyh = $this->whlabellabel->get_label($tmsku);
  5919. }
  5920. else
  5921. {
  5922. $yyh = $this->whlabellabel->get_sku($tmsku);
  5923. }
  5924. if($yyh)
  5925. {
  5926. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  5927. }
  5928. else
  5929. {
  5930. echo json_encode(array('success'=>false));exit;
  5931. }
  5932. }
  5933. $classid = $this->classid->sku();
  5934. $pm = $classid;
  5935. $scsku = $classid;
  5936. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5937. if(isset($post['warehouse']))
  5938. {
  5939. if($post['warehouse'])
  5940. {
  5941. $list = array();$num = "";$title = "";$features = "";
  5942. $order = 0;
  5943. $post['shop'] = '';
  5944. $brand = $this->input->post('brand',true);
  5945. if($brand != '0,')
  5946. {
  5947. $b = $this->brand->read(rtrim($brand,','));
  5948. if($b)
  5949. {
  5950. $post['shop'] = str_replace('|',',',$b['shop']);
  5951. }
  5952. }
  5953. $post['details'] = $this->input->post('details',true);//打印数量
  5954. $xbqnum = $this->input->post('xbqnum',true);
  5955. $post['purchase'] = $this->input->post('purchase',true);
  5956. $post['warehouse'] = $this->input->post('warehouse',true);
  5957. $post['purchase'] = $this->input->post('purchase',true);
  5958. $post['retreatwarehouse'] = $post['warehouse'];
  5959. $post['cpbz'] = $this->input->post('cpbz',true);
  5960. $post['state'] = 9;
  5961. $category = $this->input->post('category',true);
  5962. $list['category'] = $category;
  5963. $list['hairtype'] = $this->input->post('hairtype',true);
  5964. $list['grade'] = $this->input->post('grade',true);
  5965. $size = $this->input->post('size',true);
  5966. $list['size'] = rtrim($size,',');
  5967. $list['hairnumber'] = $this->input->post('hairnumber',true);
  5968. $list['extension'] = $this->input->post('extension',true);
  5969. if($category == 1297)
  5970. {
  5971. $list['sywignumber'] = $this->input->post('sywignumber',true);
  5972. }
  5973. if($category == 1702)
  5974. {
  5975. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  5976. $list['syother'] = $this->input->post('syother',true);
  5977. }
  5978. if($category == 133)
  5979. {
  5980. $list['fittype'] = $this->input->post('fittype',true);
  5981. $list['acother'] = $this->input->post('acother',true);
  5982. }
  5983. $list['color'] = $this->input->post('color',true);
  5984. $list['lowe'] = $this->input->post('lowe',true);
  5985. if($category == 127)
  5986. {
  5987. $list['type'] = $this->input->post('type',true);
  5988. $list['headroad'] = $this->input->post('headroad',true);
  5989. $list['density'] = $this->input->post('density',true);
  5990. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  5991. {
  5992. $list['lacesize'] = $this->input->post('lacesize',true);
  5993. }
  5994. $list['lacecolor'] = $this->input->post('lacecolor',true);
  5995. $list['lacetypes'] = $this->input->post('lacetypes',true);
  5996. }
  5997. if($category == 128)
  5998. {
  5999. $list['lacetype'] = $this->input->post('lacetype',true);
  6000. $list['haircap'] = $this->input->post('haircap',true);
  6001. $list['density'] = $this->input->post('density',true);
  6002. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6003. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6004. $list['wigother'] = $this->input->post('wigother',true);
  6005. }
  6006. if($category == 129)
  6007. {
  6008. $list['wide'] = $this->input->post('wide',true);
  6009. }
  6010. if($category == 131)
  6011. {
  6012. $list['gifttype'] = $this->input->post('gifttype',true);
  6013. $list['giftother'] = $this->input->post('giftother',true);
  6014. }
  6015. if($category == 134)
  6016. {
  6017. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6018. }
  6019. if($category == 1297)
  6020. {
  6021. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6022. $list['sywigother'] = $this->input->post('sywigother',true);
  6023. }
  6024. if($category == 130 || $category == 133 || $category == 1702)
  6025. {
  6026. $list['items'] = $this->input->post('items',true);
  6027. }
  6028. if($category == 1702)
  6029. {
  6030. $list['syhairther'] = $this->input->post('syhairther',true);
  6031. }
  6032. foreach($list as $k=>$v)
  6033. {
  6034. if($v != 0)
  6035. {
  6036. $num .=$v;
  6037. $features .=$v.'-';
  6038. $post[$k] = $v;
  6039. $typeclass = $this->typeclass->read($v);
  6040. if(isset($pm[$typeclass['classid']]))
  6041. {
  6042. if(stripos($typeclass['zh'],'|') !== false)
  6043. {
  6044. $exzh = explode('|',$typeclass['zh']);
  6045. $pm[$typeclass['classid']] = $exzh[0];
  6046. }
  6047. else
  6048. {
  6049. $pm[$typeclass['classid']] = $typeclass['zh'];
  6050. }
  6051. }
  6052. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6053. if($k != 'size')
  6054. {
  6055. $title .= $typeclass['title']." ";
  6056. }
  6057. }
  6058. }
  6059. $typeclass = $this->typeclass->read($list['size']);
  6060. $title .= $typeclass['title'];
  6061. $time = time();
  6062. $post['title'] = rtrim($title,' ');
  6063. $post['number'] = $num;
  6064. $post['features'] = '-'.$features;
  6065. $fp = $this->whlabel->get_features($post['features']);
  6066. if(!$fp)
  6067. {
  6068. echo json_encode(array('msg'=>'美仓无此产品,需要添加后才可打印','success'=>false));exit;
  6069. }
  6070. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6071. $featurespp = explode('-',trim($featurespp,'-'));
  6072. if(isset($featurespp[5]))
  6073. {
  6074. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6075. }
  6076. else
  6077. {
  6078. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6079. }
  6080. $post['enter'] = $time;
  6081. $post['time'] = $time;//操作时间
  6082. $scsku = implode("-",$scsku);
  6083. $zh = implode(" ",$pm);
  6084. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6085. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6086. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6087. $post['sku'] = $fp['sku'];
  6088. $post['label'] = $fp['sku'];
  6089. $cpid = $this->whlabellabel->find_count();
  6090. $post['cpid'] = $cpid+1;
  6091. $cpid = $post['cpid'];
  6092. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6093. //if($whlabelbarcode)
  6094. //{
  6095. //$post['label'] = $whlabelbarcode['label'];
  6096. //if(!$this->whlabellabel->insert($post))
  6097. //{
  6098. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6099. //}
  6100. //}
  6101. //else
  6102. //{
  6103. $this->db->trans_begin();
  6104. $this->whlabellabel->insert($post);
  6105. //$this->whlabelbarcode->insert($post);
  6106. if ($this->db->trans_status() === TRUE)
  6107. {
  6108. $this->db->trans_commit();
  6109. }
  6110. else
  6111. {
  6112. $this->db->trans_rollback();
  6113. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6114. }
  6115. //}
  6116. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6117. $purchase = $this->purchase->read($post['purchase']);
  6118. echo json_encode(array('title'=>$title,'num'=>$post['label'],'bqsku'=>$bqsku,'xbqnum'=>$xbqnum,'zh'=>str_replace('自然色 ','',rtrim($zh,' ')),'details'=>$details,'purchase'=>$purchase['title'],'cpbz'=>$post['cpbz'],'usa'=>1,'success'=>true));exit;//特殊仓目前不需要仓库选项
  6119. }
  6120. }
  6121. if(isset($_SESSION['api']))
  6122. {
  6123. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6124. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6125. $this->data['wlshop'] = $wlshop;
  6126. $this->data['warehouse'] = $warehouse;
  6127. }
  6128. $whlabelwz = $this->whlabelwz->find_all();
  6129. $this->data['whlabelwz'] = $whlabelwz;
  6130. $this->_Template('whlabel_usaprint',$this->data);
  6131. }
  6132. public function _printrk($arg_array)
  6133. {
  6134. $prc = array();
  6135. $purchase = $this->purchase->find_all();
  6136. foreach($purchase as $k=>$v)
  6137. {
  6138. $prc[$v['id']] = $v['title'];
  6139. }
  6140. $post = $this->input->post(NULL, TRUE);
  6141. if(isset($post['page']))
  6142. {
  6143. $page = $this->input->post('page',true);
  6144. $perpage = $this->input->post('perpage',true);
  6145. $sku = $this->input->post('sku',true);
  6146. $bs = $this->input->post('bs',true);
  6147. $number = $this->input->post('number',true);
  6148. $warehouse = $this->input->post('warehouse',true);
  6149. $purchase = $this->input->post('purchase',true);
  6150. $orderinfo = $this->input->post('orderinfo',true);
  6151. $waybill = $this->input->post('waybill',true);
  6152. $category = $this->input->post('category',true);
  6153. $size = $this->input->post('size',true);
  6154. $grade = $this->input->post('grade',true);
  6155. $color = $this->input->post('color',true);
  6156. $lowe = $this->input->post('lowe',true);
  6157. $state = $this->input->post('state',true);
  6158. $label = $this->input->post('label',true);
  6159. $timetk = $this->input->post('ktime',true);
  6160. $timetj = $this->input->post('jtime',true);
  6161. $timetk = strtotime($timetk);
  6162. $timetj = strtotime($timetj);
  6163. $where = "1=1 ";
  6164. if($timetk && $timetj)
  6165. {
  6166. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6167. }
  6168. if($sku)
  6169. {
  6170. $where .= " and sku = '$sku'";
  6171. }
  6172. if($bs != '')
  6173. {
  6174. $where .= " and bs = '$bs'";
  6175. }
  6176. if($number)
  6177. {
  6178. $where .= " and number = '$number'";
  6179. }
  6180. if($warehouse)
  6181. {
  6182. $where .= " and warehouse = '$warehouse'";
  6183. }
  6184. if($purchase)
  6185. {
  6186. $where .= " and purchase = '$purchase'";
  6187. }
  6188. if($orderinfo)
  6189. {
  6190. $where .= " and orderinfo = '$orderinfo'";
  6191. }
  6192. if($waybill)
  6193. {
  6194. $where .= " and waybill = '$waybill'";
  6195. }
  6196. if($category)
  6197. {
  6198. $where .= " and features like '%-$category-%'";
  6199. }
  6200. if($size)
  6201. {
  6202. $where .= " and features like '%-$size-%'";
  6203. }
  6204. if($grade)
  6205. {
  6206. $where .= " and features like '%-$grade-%'";
  6207. }
  6208. if($color)
  6209. {
  6210. $where .= " and features like '%-$color-%'";
  6211. }
  6212. if($lowe)
  6213. {
  6214. $where .= " and features like '%-$lowe-%'";
  6215. }
  6216. if($label)
  6217. {
  6218. $where .= " and label = '$label'";
  6219. }
  6220. if($state || $state == 0)
  6221. {
  6222. $where .= " and state = '$state'";
  6223. }
  6224. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6225. //数据排序
  6226. $order_str = "enter desc";
  6227. if(empty($page))
  6228. {
  6229. $start = 0;
  6230. $perpage = 1;
  6231. }
  6232. else
  6233. {
  6234. $start = ($page - 1)*$perpage;
  6235. }
  6236. //取得信息列表
  6237. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,enter,details',$order_str,$start,$perpage);
  6238. foreach ($info_list as $key=>$value)
  6239. {
  6240. $warehouse = $this->warehouse->read($value['warehouse']);
  6241. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6242. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6243. if($value['state'] == 0)
  6244. {
  6245. $info_list[$key]['state'] = "在库";
  6246. }
  6247. else if($value['state'] == 1)
  6248. {
  6249. $info_list[$key]['state'] = "出库";
  6250. }
  6251. else if($value['state'] == 2)
  6252. {
  6253. $info_list[$key]['state'] = "退库";
  6254. }
  6255. else if($value['state'] == 3)
  6256. {
  6257. $info_list[$key]['state'] = "调拨中";
  6258. }
  6259. else if($value['state'] == 4)
  6260. {
  6261. $info_list[$key]['state'] = "再加工";
  6262. }
  6263. else if($value['state'] == 5)
  6264. {
  6265. $info_list[$key]['state'] = "维修中";
  6266. }
  6267. else if($value['state'] == 6)
  6268. {
  6269. $info_list[$key]['state'] = "盘亏";
  6270. }
  6271. else if($value['state'] == 7)
  6272. {
  6273. $info_list[$key]['state'] = "更换标签";
  6274. }
  6275. else if($value['state'] == 8)
  6276. {
  6277. $info_list[$key]['state'] = "其它";
  6278. }
  6279. else if($value['state'] == 9)
  6280. {
  6281. $info_list[$key]['state'] = "预设";
  6282. }
  6283. else if($value['state'] == 10)
  6284. {
  6285. $info_list[$key]['state'] = "美店零售";
  6286. }
  6287. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  6288. }
  6289. $total = $this->$ck->find_count($where);
  6290. $pagenum = ceil($total/$perpage);
  6291. $over = $total-($start+$perpage);
  6292. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6293. echo json_encode($rows);exit;
  6294. }
  6295. if(isset($post['tmsku']))
  6296. {
  6297. $time = time();
  6298. $tmsku = $this->input->post('tmsku',true);
  6299. //$post['shop'] = $this->input->post('shop',true);
  6300. $num = 1;
  6301. $rk = $this->whlabellabel->find_all("label = '$tmsku'","*","id desc");
  6302. /**
  6303. $wz = array();
  6304. foreach ($rk as $key=>$value)
  6305. {
  6306. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6307. }
  6308. if(count($wz) > 1)
  6309. {
  6310. $wz = array_values($wz);
  6311. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6312. }
  6313. **/
  6314. if(isset($rk[0]['purchase']))
  6315. {
  6316. $rk = $rk[0];
  6317. $j = 0;
  6318. $post['purchase'] = $rk['purchase'];
  6319. $post['warehouse'] = $rk['warehouse'];
  6320. $post['retreatwarehouse'] = $rk['warehouse'];
  6321. $post['sku'] = $rk['sku'];
  6322. $post['number'] = $rk['number'];
  6323. $post['features'] = $rk['features'];
  6324. $post['title'] = $rk['title'];
  6325. $post['enter'] = $time;
  6326. $post['time'] = $time;
  6327. $post['bs'] = 1;
  6328. $post['shop'] = $rk['shop'];
  6329. $post['details'] = $rk['details'];
  6330. $post['cpid'] = $rk['cpid'];
  6331. $post['cpbz'] = $rk['cpbz'];
  6332. $warehouse = $this->warehouse->read($rk['warehouse']);
  6333. if($warehouse['bdck'] == '')
  6334. {
  6335. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','success'=>false));exit;
  6336. }
  6337. else
  6338. {
  6339. $bdck = $warehouse['bdck'];
  6340. }
  6341. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'],$post['sku']);
  6342. if(isset($pdwz['details']))
  6343. {
  6344. if($pdwz['details'] != $post['details'])
  6345. {
  6346. echo json_encode(array('msg'=>'此产品位置应为:'.$pdwz['details'],'c'=>0,'cs'=>$pdwz['details'].' - '.$post['details'],'success'=>false));exit;
  6347. }
  6348. }
  6349. $post['featurespp'] = $rk['featurespp'];
  6350. if($post['warehouse'] == '5')
  6351. {
  6352. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6353. if($yza)
  6354. {
  6355. if($post['features'] != $yza[0]['features'])
  6356. {
  6357. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'success'=>false));exit;
  6358. }
  6359. }
  6360. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6361. if($yzb)
  6362. {
  6363. if($post['sku'] != $yzb[0]['sku'])
  6364. {
  6365. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','success'=>false));exit;
  6366. }
  6367. }
  6368. }
  6369. for($i=0;$i<$num;$i++)
  6370. {
  6371. $post['label'] = time().rand(100,999).$i;
  6372. if($this->$bdck->insert($post))
  6373. {
  6374. $j++;
  6375. }
  6376. }
  6377. /**
  6378. if($post['warehouse'] != 12)
  6379. {
  6380. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6381. }
  6382. **/
  6383. if($j == $num)
  6384. {
  6385. echo json_encode(array('msg'=>'入库成功!','success'=>true));exit;
  6386. }
  6387. else
  6388. {
  6389. echo json_encode(array('msg'=>'未成功入库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6390. }
  6391. }
  6392. else
  6393. {
  6394. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6395. }
  6396. }
  6397. $this->_Template('whlabel_printrk',$this->data);
  6398. }
  6399. public function _printxzrk($arg_array)
  6400. {
  6401. $post = $this->input->post(NULL, TRUE);
  6402. if(isset($post['wzid']))
  6403. {
  6404. $time = time();
  6405. $id = $this->input->post('wzid',true);
  6406. //$post['shop'] = $this->input->post('shop',true);
  6407. $num = 1;
  6408. $rk = $this->whlabellabel->read($id);
  6409. if(isset($rk['purchase']))
  6410. {
  6411. $x = 0;
  6412. $post['purchase'] = $rk['purchase'];
  6413. $post['warehouse'] = $rk['warehouse'];
  6414. $post['retreatwarehouse'] = $rk['warehouse'];
  6415. $post['sku'] = $rk['sku'];
  6416. $post['number'] = $rk['number'];
  6417. $post['features'] = $rk['features'];
  6418. $post['title'] = $rk['title'];
  6419. $post['enter'] = $time;
  6420. $post['time'] = $time;
  6421. $post['bs'] = 1;
  6422. $post['shop'] = $rk['shop'];
  6423. $post['details'] = $rk['details'];
  6424. $post['cpid'] = $rk['cpid'];
  6425. $post['cpbz'] = $rk['cpbz'];
  6426. $warehouse = $this->warehouse->read($rk['warehouse']);
  6427. if($warehouse['bdck'] == '')
  6428. {
  6429. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','success'=>false));exit;
  6430. }
  6431. else
  6432. {
  6433. $bdck = $warehouse['bdck'];
  6434. }
  6435. $post['featurespp'] = $rk['featurespp'];
  6436. $this->db->trans_begin();
  6437. for($i=0;$i<$num;$i++)
  6438. {
  6439. $post['label'] = time().rand(100,999).$i;
  6440. $this->$bdck->insert($post);
  6441. }
  6442. /**
  6443. if($post['warehouse'] != 12)
  6444. {
  6445. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6446. }
  6447. **/
  6448. if ($this->db->trans_status() === TRUE)
  6449. {
  6450. $this->db->trans_commit();
  6451. echo json_encode(array('msg'=>'入库成功!','cs'=>$post,'cs2'=>$warehouse,'success'=>true));exit;
  6452. }
  6453. else
  6454. {
  6455. $this->db->trans_rollback();
  6456. echo json_encode(array('msg'=>'入库失败,请重试','c'=>0,'success'=>false));exit;
  6457. }
  6458. }
  6459. else
  6460. {
  6461. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6462. }
  6463. }
  6464. }
  6465. public function _printck($arg_array)
  6466. {
  6467. $prc = array();
  6468. $purchase = $this->purchase->find_all();
  6469. foreach($purchase as $k=>$v)
  6470. {
  6471. $prc[$v['id']] = $v['title'];
  6472. }
  6473. $post = $this->input->post(NULL, TRUE);
  6474. if(isset($post['page']))
  6475. {
  6476. $page = $this->input->post('page',true);
  6477. $perpage = $this->input->post('perpage',true);
  6478. $sku = $this->input->post('sku',true);
  6479. $bs = $this->input->post('bs',true);
  6480. $number = $this->input->post('number',true);
  6481. $warehouse = $this->input->post('warehouse',true);
  6482. $purchase = $this->input->post('purchase',true);
  6483. $orderinfo = $this->input->post('orderinfo',true);
  6484. $waybill = $this->input->post('waybill',true);
  6485. $category = $this->input->post('category',true);
  6486. $size = $this->input->post('size',true);
  6487. $grade = $this->input->post('grade',true);
  6488. $color = $this->input->post('color',true);
  6489. $lowe = $this->input->post('lowe',true);
  6490. $state = $this->input->post('state',true);
  6491. $label = $this->input->post('label',true);
  6492. $timetk = $this->input->post('ktime',true);
  6493. $timetj = $this->input->post('jtime',true);
  6494. $timetk = strtotime($timetk);
  6495. $timetj = strtotime($timetj);
  6496. $where = "state=1 ";
  6497. if($timetk && $timetj)
  6498. {
  6499. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6500. }
  6501. if($sku)
  6502. {
  6503. $where .= " and sku = '$sku'";
  6504. }
  6505. if($bs != '')
  6506. {
  6507. $where .= " and bs = '$bs'";
  6508. }
  6509. if($number)
  6510. {
  6511. $where .= " and number = '$number'";
  6512. }
  6513. if($warehouse)
  6514. {
  6515. $where .= " and warehouse = '$warehouse'";
  6516. }
  6517. if($purchase)
  6518. {
  6519. $where .= " and purchase = '$purchase'";
  6520. }
  6521. if($orderinfo)
  6522. {
  6523. $where .= " and orderinfo = '$orderinfo'";
  6524. }
  6525. if($waybill)
  6526. {
  6527. $where .= " and waybill = '$waybill'";
  6528. }
  6529. if($category)
  6530. {
  6531. $where .= " and features like '%-$category-%'";
  6532. }
  6533. if($size)
  6534. {
  6535. $where .= " and features like '%-$size-%'";
  6536. }
  6537. if($grade)
  6538. {
  6539. $where .= " and features like '%-$grade-%'";
  6540. }
  6541. if($color)
  6542. {
  6543. $where .= " and features like '%-$color-%'";
  6544. }
  6545. if($lowe)
  6546. {
  6547. $where .= " and features like '%-$lowe-%'";
  6548. }
  6549. if($label)
  6550. {
  6551. $where .= " and label = '$label'";
  6552. }
  6553. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6554. //数据排序
  6555. $order_str = "outk desc";
  6556. if(empty($page))
  6557. {
  6558. $start = 0;
  6559. $perpage = 1;
  6560. }
  6561. else
  6562. {
  6563. $start = ($page - 1)*$perpage;
  6564. }
  6565. //取得信息列表
  6566. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,outk,details',$order_str,$start,$perpage);
  6567. foreach ($info_list as $key=>$value)
  6568. {
  6569. $warehouse = $this->warehouse->read($value['warehouse']);
  6570. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6571. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6572. if($value['state'] == 0)
  6573. {
  6574. $info_list[$key]['state'] = "在库";
  6575. }
  6576. else if($value['state'] == 1)
  6577. {
  6578. $info_list[$key]['state'] = "出库";
  6579. }
  6580. else if($value['state'] == 2)
  6581. {
  6582. $info_list[$key]['state'] = "退库";
  6583. }
  6584. else if($value['state'] == 3)
  6585. {
  6586. $info_list[$key]['state'] = "调拨中";
  6587. }
  6588. else if($value['state'] == 4)
  6589. {
  6590. $info_list[$key]['state'] = "再加工";
  6591. }
  6592. else if($value['state'] == 5)
  6593. {
  6594. $info_list[$key]['state'] = "维修中";
  6595. }
  6596. else if($value['state'] == 6)
  6597. {
  6598. $info_list[$key]['state'] = "盘亏";
  6599. }
  6600. else if($value['state'] == 7)
  6601. {
  6602. $info_list[$key]['state'] = "更换标签";
  6603. }
  6604. else if($value['state'] == 8)
  6605. {
  6606. $info_list[$key]['state'] = "其它";
  6607. }
  6608. else if($value['state'] == 9)
  6609. {
  6610. $info_list[$key]['state'] = "预设";
  6611. }
  6612. else if($value['state'] == 10)
  6613. {
  6614. $info_list[$key]['state'] = "美店零售";
  6615. }
  6616. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  6617. }
  6618. $total = $this->$ck->find_count($where);
  6619. $pagenum = ceil($total/$perpage);
  6620. $over = $total-($start+$perpage);
  6621. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6622. echo json_encode($rows);exit;
  6623. }
  6624. if(isset($post['tmsku']))
  6625. {
  6626. $time = time();
  6627. $tmsku = $this->input->post('tmsku',true);
  6628. //$post['shop'] = $this->input->post('shop',true);
  6629. //$num = $this->input->post('num',true);
  6630. $label = $this->whlabellabel->get_label($tmsku);
  6631. if(!isset($label['warehouse']))
  6632. {
  6633. echo json_encode(array('msg'=>'没有此条码信息!','success'=>false));exit;
  6634. }
  6635. $xzck = ($label['warehouse'] == '12')?'specialstock':'whlabel';
  6636. if(stripos($label['features'],'-126-') !== false)
  6637. {
  6638. $ck = $this->$xzck->get_labelnumberout_purchase_nopur($label['shop'],$label['number'],$label['warehouse']);
  6639. }
  6640. else
  6641. {
  6642. $ck = $this->$xzck->get_labelnumberout_purchase($label['shop'],$label['number'],$label['warehouse'],$label['purchase']);
  6643. }
  6644. if($ck)
  6645. {
  6646. if($this->$xzck->save(array('state'=>1,'outk'=>$time,'time'=>$time),$ck['id']))
  6647. {
  6648. echo json_encode(array('msg'=>'出库成功!','success'=>true));exit;
  6649. }
  6650. else
  6651. {
  6652. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  6653. }
  6654. }
  6655. else
  6656. {
  6657. echo json_encode(array('msg'=>'没有库存!','cs'=>$label['sku'].' - '.$label['purchase'],'success'=>false));exit;
  6658. }
  6659. }
  6660. $this->_Template('whlabel_printck',$this->data);
  6661. }
  6662. public function _printexcel()
  6663. {
  6664. $dir = '/data/excel/'.date('Ymd',time()).'/';
  6665. $config['upload_path'] = '.'.$dir ;
  6666. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  6667. $config['allowed_types'] = 'xls|xlsx|csv';
  6668. $config['max_size'] = 10240;
  6669. $this->load->library('upload', $config);
  6670. $this->upload->initialize($config);
  6671. if ($this->upload->do_upload('userfile'))
  6672. {
  6673. $full_path = $dir.$this->upload->data('file_name');
  6674. $fileName = '.' . $full_path;
  6675. if (!file_exists($fileName))
  6676. {
  6677. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  6678. }
  6679. else
  6680. {
  6681. require_once "./data/excel/PHPExcel/IOFactory.php";
  6682. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  6683. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  6684. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  6685. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  6686. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  6687. ++$column;//如果列数大于26行
  6688. $list = array();
  6689. for ($i = 2; $i <= $row; $i++) // 行数循环
  6690. {
  6691. $data = array();
  6692. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6693. {
  6694. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6695. }
  6696. $list[] = $data;
  6697. }
  6698. }
  6699. $ed = array();$i = 0;$j = 0;$dcdata = array();$yc = '';
  6700. $cmf_arr = array_column($list, '1');
  6701. array_multisort($cmf_arr, SORT_ASC, $list);
  6702. foreach ($list as $key=>$value)
  6703. {
  6704. $typeclass = $this->typeclass->get_bqsku($value['1'],$value['2']);
  6705. if($typeclass)
  6706. {
  6707. $this->typeclass->save(array('bqsku'=>$value['3']),$typeclass['id']);
  6708. }
  6709. else
  6710. {
  6711. $ed[] = array($value['1'].'-系统未找到此订单信息');
  6712. $i++;
  6713. continue;
  6714. }
  6715. }
  6716. if($i > 0)
  6717. {
  6718. $yc = $i.'条异常';
  6719. }
  6720. echo json_encode(array('msg'=>'操作成功 '.$yc,'yc'=>$ed,'success'=>true));exit;
  6721. }
  6722. }
  6723. public function _uck()
  6724. {
  6725. if(isset($_GET['excel']))
  6726. {
  6727. $tc = array();
  6728. $typeclass = $this->typeclass->find_all();
  6729. foreach ($typeclass as $v)
  6730. {
  6731. $tc[$v['id']] = $v['zh'];
  6732. }
  6733. $data = array();$t = array();$rq = '';
  6734. $ts = strtotime(date("Y-m-d",time()))-strtotime(date("Y-m",time()));
  6735. $ts = $ts/(24*3600);
  6736. for($i=0;$i<$ts;$i++)
  6737. {
  6738. $t[] = date("Y-m-d",strtotime('-'.($ts-$i).' day'));
  6739. $rq .= "<td>".date("Y-m-d",strtotime('-'.($ts-$i).' day'))."</td>";
  6740. }
  6741. $info_list = $this->whlabel->find_pc("warehouse = '5'",'sku','warehouse,sku,features');
  6742. foreach ($info_list as $k=>$v)
  6743. {
  6744. $features = explode('-',trim($v['features'],'-'));
  6745. if(!isset($features[3]) || !isset($features[4]))
  6746. {
  6747. continue;
  6748. }
  6749. $data[$k][0] = $tc[$features[0]];//类型
  6750. $data[$k][1] = ($features[3] != 57)?$tc[$features[3]]:'';//颜色,自然色不显示
  6751. $data[$k][2] = $tc[$features[4]];//曲度
  6752. $data[$k][3] = '';
  6753. if(isset($data[$k][1]))
  6754. {
  6755. $data[$k][3] .= $data[$k][1];
  6756. }
  6757. if(isset($data[$k][2]))
  6758. {
  6759. $data[$k][3] .= $data[$k][2];
  6760. }
  6761. if(isset($features[5]))
  6762. {
  6763. $data[$k][3] .= $tc[$features[5]];
  6764. }
  6765. if(isset($features[2]))
  6766. {
  6767. $data[$k][3] .= $tc[$features[2]];
  6768. }
  6769. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6770. $data[$k][4] = $v['sku'];
  6771. $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())).'))');//月初库存
  6772. $data[$k][] = $this->whlabel->find_count('sku = "'.$v['sku'].'" and state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');//剩余库存
  6773. $zt = $this->whlabeltransport->find_all('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and cz = "0"');
  6774. $ztrq = '';$ztsl = '';
  6775. if(count($zt) > 0)
  6776. {
  6777. foreach ($zt as $vv)
  6778. {
  6779. $ztrq .= date('Y-m-d',$vv['stime']).'<br>';
  6780. $ztsl .= $vv['num'].'<br>';
  6781. }
  6782. }
  6783. $data[$k][] = trim($ztsl,'<br>');
  6784. $data[$k][] = trim($ztrq,'<br>');
  6785. $byck = 0;
  6786. foreach ($t as $vv)
  6787. {
  6788. $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));
  6789. $data[$k][] = ($sl > 0)?'<b>'.$sl.'</b>':'';
  6790. $byck += $sl;
  6791. }
  6792. $data[$k][] = ($byck > 0)?$byck:'';
  6793. }
  6794. $title = "详情 ".date("Y-m-d",time());
  6795. $titlename = "<table border=1>
  6796. <tr align='center'>
  6797. <td>类别</td>
  6798. <td>颜色</td>
  6799. <td>曲度</td>
  6800. <td>名称</td>
  6801. <td>SKU</td>
  6802. <td>月初库存</td>
  6803. <td>剩余库存</td>
  6804. <td>在途数量</td>
  6805. <td>预达日期</td>".
  6806. $rq
  6807. ."<td>本月出库</td></tr>
  6808. </table>";
  6809. $filename = $title.".xls";
  6810. $tail = "";
  6811. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  6812. }
  6813. }
  6814. public function _whlabelexcelzh()
  6815. {
  6816. if(isset($_GET['excel']))
  6817. {
  6818. $where = "sku != 'Preset'";
  6819. //数据排序
  6820. $order_str = "id desc";
  6821. if(empty($page))
  6822. {
  6823. $start = 0;
  6824. $perpage = 1;
  6825. }
  6826. else
  6827. {
  6828. $start = ($page - 1)*$perpage;
  6829. }
  6830. $category = $this->input->get('category',true);
  6831. $warehouse = $this->input->get('warehouse',true);
  6832. $excelid = $this->input->get('sid',true);
  6833. if($category)
  6834. {
  6835. $where .= " and features like '%-$category-%'";
  6836. }
  6837. if($warehouse)
  6838. {
  6839. $where .= " and warehouse = '$warehouse'";
  6840. }
  6841. $xzid = '';
  6842. if($excelid)
  6843. {
  6844. $excelid = explode(',',trim($excelid,','));
  6845. foreach ($excelid as $key=>$value)
  6846. {
  6847. $xzid .= " id = ".$value." or";
  6848. }
  6849. $xzid = " and (".rtrim($xzid,'or').")";;
  6850. }
  6851. //取得信息列表
  6852. /**
  6853. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6854. $rows = array();$list = array();
  6855. foreach ($info_list as $key=>$value)
  6856. {
  6857. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6858. }
  6859. **/
  6860. $list = array();
  6861. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,number,features');
  6862. foreach ($rows as $key=>$value)
  6863. {
  6864. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"');
  6865. $zh = '';
  6866. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and time = "0" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','num,stime');
  6867. foreach ($zt as $v)
  6868. {
  6869. $zh .= $v['num']." / ".date('Y-m-d',$v['stime'])."<br>";
  6870. }
  6871. $zt = array_sum(array_column($zt,'num'));
  6872. $number = $value['number'];
  6873. $ftime = time()-15*24*3600;
  6874. $warehouse = $this->warehouse->read($value['warehouse']);
  6875. $rows[$key]['warehouse'] = $warehouse['title'];
  6876. $rows[$key]['number'] = $c;
  6877. $rows[$key]['features'] = $zh;
  6878. $rows[$key]['hb'] = $c+$zt;
  6879. }
  6880. $title = "导出库存数据及在途中数据".date('Y-m-d',time());
  6881. $titlename = "<table border=1>
  6882. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6883. <tr align='center'>
  6884. <td>仓库</td>
  6885. <td>SKU</td>
  6886. <td>产品</td>
  6887. <td>库存数量</td>
  6888. <td>在途数量及预达日期</td>
  6889. <td>在途+库存数量</td>
  6890. </tr>
  6891. </table>";
  6892. $filename = $title.".xls";
  6893. $tail = "";
  6894. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  6895. }
  6896. if(isset($_GET['excel']))
  6897. {
  6898. $warehouse = $this->input->get('warehouse',true);
  6899. $sku = $this->input->get('sku',true);
  6900. $cz = $this->input->get('cz',true);
  6901. $text = $this->input->post('text',true);
  6902. $xztime = $this->input->get('xztime',true);
  6903. $timetk = $this->input->get('timetk',true);
  6904. $timetj = $this->input->get('timetj',true);
  6905. $timetk = strtotime($timetk);
  6906. $timetj = strtotime($timetj);
  6907. $where = "time = '0' ";
  6908. if($warehouse)
  6909. {
  6910. $where .= " and warehouse = '$warehouse'";
  6911. }
  6912. if($sku)
  6913. {
  6914. $where .= " and sku = '$sku'";
  6915. }
  6916. if($text)
  6917. {
  6918. $where .= " and text like '%$text%'";
  6919. }
  6920. if($cz != '')
  6921. {
  6922. $where .= " and cz = '$cz'";
  6923. }
  6924. if($timetk && $timetj)
  6925. {
  6926. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  6927. }
  6928. //数据排序
  6929. $order_str = $xztime." desc";
  6930. //取得信息列表
  6931. $zh = array();
  6932. $info_list = $this->whlabeltransport->find_all($where,'warehouse,sku,title,num,features,enter,stime,text');
  6933. foreach ($info_list as $v)
  6934. {
  6935. $c = $this->whlabel->find_count('state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');
  6936. $warehouse = $this->warehouse->read($v['warehouse']);
  6937. $v['warehouse'] = $warehouse['title'];
  6938. $v['enter'] = date('Y-m-d H:i:s',$v['enter']);
  6939. $v['stime'] = date('Y-m-d',$v['stime']);
  6940. if(isset($zh[$v['features']]))
  6941. {
  6942. $zh[$v['features']]['num'] += $v['num'];
  6943. }
  6944. else
  6945. {
  6946. $zh[$v['features']] = $v;
  6947. }
  6948. $zh[$v['features']]['features'] = $c;
  6949. }
  6950. $title = "在途数据".date('Y-m-d',time());
  6951. $titlename = "<table border=1>
  6952. <tr align='center'>
  6953. <td>仓库</td>
  6954. <td>SKU</td>
  6955. <td>名称</td>
  6956. <td>在途数量</td>
  6957. <td>库存数量</td>
  6958. <td>添加在途日期</td>
  6959. <td>预达日期</td>
  6960. <td>备注</td>
  6961. </tr>
  6962. </table>";
  6963. $filename = $title.".xls";
  6964. $tail = "";
  6965. $this->excel->get_fz2($zh,$titlename,$filename,$tail);
  6966. }
  6967. }
  6968. public function _fc()
  6969. {
  6970. $vip = 0;
  6971. if(isset($_SESSION['api']))
  6972. {
  6973. $user = $this->user->get_api($_SESSION['api']);
  6974. if($user['vip'] == 1)
  6975. {
  6976. $vip = 1;
  6977. }
  6978. }
  6979. else
  6980. {
  6981. header('Location: /');exit;
  6982. }
  6983. $post = $this->input->post(NULL, TRUE);
  6984. if(isset($post['page']))
  6985. {
  6986. $page = $this->input->post('page',true);
  6987. $perpage = $this->input->post('perpage',true);
  6988. $category = $this->input->post('category',true);
  6989. $size = $this->input->post('size',true);
  6990. $grade = $this->input->post('grade',true);
  6991. $color = $this->input->post('color',true);
  6992. $lowe = $this->input->post('lowe',true);
  6993. $sku = $this->input->post('sku');
  6994. $title = $this->input->post('title');
  6995. $warehouse = $this->input->post('warehouse',true);
  6996. $usa = $this->input->post('usa',true);
  6997. $purchase = $this->input->post('purchase',true);
  6998. $lacetype = $this->input->post('lacetype',true);
  6999. $haircap = $this->input->post('haircap',true);
  7000. $density = $this->input->post('density',true);
  7001. $details = $this->input->post('details',true);
  7002. $state = $this->input->post('state',true);
  7003. $ktime = $this->input->post('ktime',true);
  7004. $jtime = $this->input->post('jtime',true);
  7005. $ktime = strtotime($ktime);
  7006. $jtime = strtotime($jtime);
  7007. $where = "state = '11'";$gj = "";$ck = "";
  7008. if($lacetype)
  7009. {
  7010. $where .= " and features like '%-$lacetype-%'";
  7011. }
  7012. if($category)
  7013. {
  7014. $where .= " and features like '%-$category-%'";
  7015. }
  7016. if($size)
  7017. {
  7018. $where .= " and features like '%-$size-%'";
  7019. }
  7020. if($grade)
  7021. {
  7022. $where .= " and features like '%-$grade-%'";
  7023. }
  7024. if($color)
  7025. {
  7026. $where .= " and features like '%-$color-%'";
  7027. }
  7028. if($lowe)
  7029. {
  7030. $where .= " and features like '%-$lowe-%'";
  7031. }
  7032. if($haircap)
  7033. {
  7034. $where .= " and features like '%-$haircap-%'";
  7035. }
  7036. if($density)
  7037. {
  7038. $where .= " and features like '%-$density-%'";
  7039. }
  7040. if($usa)
  7041. {
  7042. if(!$warehouse)
  7043. {
  7044. $where .= " and (warehouse = '5' or warehouse = '8')";
  7045. }
  7046. }
  7047. if($warehouse)
  7048. {
  7049. $where .= " and warehouse = '$warehouse'";
  7050. }
  7051. if($details)
  7052. {
  7053. $where .= " and details = '$details'";
  7054. }
  7055. if($purchase)
  7056. {
  7057. $where .= " and purchase = '$purchase'";
  7058. }
  7059. if($state)
  7060. {
  7061. $where .= " and state = '$state'";
  7062. }
  7063. if($ktime && $jtime)
  7064. {
  7065. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7066. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7067. }
  7068. //数据排序
  7069. $order_str = "id desc";
  7070. if(empty($page))
  7071. {
  7072. $start = 0;
  7073. $perpage = 1;
  7074. }
  7075. else
  7076. {
  7077. $start = ($page - 1)*$perpage;
  7078. }
  7079. if($sku)
  7080. {
  7081. $sku = trim($sku,' ');
  7082. $sku = trim($sku,' ');
  7083. $where .= " and sku like '%$sku%'";
  7084. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7085. }
  7086. else if($title)
  7087. {
  7088. $title = trim($title,' ');
  7089. $title = trim($title,' ');
  7090. $where .= " and title like '%$title%'";
  7091. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7092. }
  7093. else
  7094. {
  7095. //$where .= " and time > '$ktime' and time < '$jtime'";
  7096. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7097. }
  7098. //取得信息列表
  7099. $rows = array();$list = array();
  7100. foreach ($info_list as $key=>$value)
  7101. {
  7102. $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'].'"');
  7103. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7104. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7105. $warehouse = $this->warehouse->read($value['warehouse']);
  7106. $info_list[$key]['warehouse'] = $warehouse['title'];
  7107. $info_list[$key]['number'] = $g;
  7108. $info_list[$key]['features'] = $x;
  7109. $info_list[$key]['x'] = $s;
  7110. }
  7111. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  7112. $pagenum = ceil($total/$perpage);
  7113. $over = $total-($start+$perpage);
  7114. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  7115. echo json_encode($rows);exit;
  7116. }
  7117. $this->data['vip'] = $vip;
  7118. $this->_Template('whlabel_fc',$this->data);
  7119. }
  7120. public function _fcmb()
  7121. {
  7122. $where = "sku != 'Preset'";
  7123. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title');
  7124. foreach ($rows as $k=>$v)
  7125. {
  7126. $warehouse = $this->warehouse->read($v['warehouse']);
  7127. $rows[$k]['warehouse'] = $warehouse['title'];
  7128. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "'.$v['warehouse'].'" and sku = "'.$v['sku'].'" and state = 11');
  7129. $rows[$k]['t'] = '';
  7130. $rows[$k]['n'] = '';
  7131. }
  7132. $title = "封货产品数据导入模板";
  7133. $titlename = "<table border=1>
  7134. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7135. <tr align='center'>
  7136. <td>仓库</td>
  7137. <td>SKU</td>
  7138. <td>产品</td>
  7139. <td>封存产品总数量</td>
  7140. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7141. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7142. </tr>
  7143. </table>";
  7144. $filename = $title.".xls";
  7145. $tail = "";
  7146. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7147. }
  7148. public function _fcexcel()
  7149. {
  7150. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7151. $config['upload_path'] = '.'.$dir ;
  7152. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7153. $config['allowed_types'] = 'xls|xlsx|csv';
  7154. $config['max_size'] = 10240;
  7155. $this->load->library('upload', $config);
  7156. $this->upload->initialize($config);
  7157. if ($this->upload->do_upload('userfile'))
  7158. {
  7159. $full_path = $dir.$this->upload->data('file_name');
  7160. $fileName = '.' . $full_path;
  7161. if (!file_exists($fileName))
  7162. {
  7163. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7164. }
  7165. else
  7166. {
  7167. libxml_use_internal_errors(true);
  7168. require_once "./data/excel/PHPExcel/IOFactory.php";
  7169. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7170. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7171. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7172. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7173. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7174. ++$column;//如果列数大于26行
  7175. $list = array();
  7176. for ($i = 2; $i <= $row; $i++) // 行数循环
  7177. {
  7178. $data = array();
  7179. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7180. {
  7181. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7182. }
  7183. $list[] = $data;
  7184. }
  7185. }
  7186. $i = 0;$j = 0;$ed = array();
  7187. foreach ($list as $key=>$value)
  7188. {
  7189. $time = time();
  7190. if($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4']))
  7191. {
  7192. continue;
  7193. }
  7194. $warehouse = $this->warehouse->get_title($value['0']);
  7195. $sku = $value['1'];
  7196. $type = $value['4'];//调整方式0扣减1删除
  7197. $num = $value['5'];//调整数量
  7198. //$text = $value['4'];//扣减说明
  7199. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7200. if(!$d)//如果没有这个SKU
  7201. {
  7202. $ed[] = array($sku.'-库存中不存在此SKU');
  7203. $j++;
  7204. continue;
  7205. }
  7206. if(!isset($warehouse['id']))
  7207. {
  7208. $ed[] = array($sku.'-仓库名错误!');
  7209. $j++;
  7210. continue;
  7211. }
  7212. if($type == 1 || $type == 2)//扣减库存
  7213. {
  7214. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and state = 11');
  7215. if(count($data) < abs($num))
  7216. {
  7217. $ed[] = array($sku.'-数量大于封存产品剩余数量!');
  7218. $j++;
  7219. continue;
  7220. }
  7221. if($type == 1)//转入库存
  7222. {
  7223. for($i=0;$i<abs($num);$i++)
  7224. {
  7225. $this->whlabel->save(array('state'=>0,'oldstate'=>11,'time'=>$time),$data[$i]['id']);
  7226. }
  7227. }
  7228. else if($type == 2)//删除
  7229. {
  7230. for($i=0;$i<abs($num);$i++)
  7231. {
  7232. $this->whlabel->remove($data[$i]['id']);
  7233. }
  7234. }
  7235. }
  7236. else if($type == 0)//增加库存
  7237. {
  7238. $post['sku'] = $d['sku'];
  7239. $post['shop'] = '';
  7240. $post['warehouse'] = $warehouse['id'];
  7241. $post['purchase'] = $d['purchase'];
  7242. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7243. $post['state'] = 11;
  7244. $post['title'] = $d['title'];
  7245. $post['number'] = $d['number'];
  7246. $post['features'] = $d['features'];
  7247. $post['enter'] = $time;
  7248. $post['time'] = $time;//操作时间
  7249. for($i=0;$i<$num;$i++)
  7250. {
  7251. $post['label'] = time().rand(100,999).$i;
  7252. $this->whlabel->insert($post);
  7253. }
  7254. }
  7255. sleep(1);//防止入库时间一样,需要延迟1秒
  7256. }
  7257. if($j > 0)
  7258. {
  7259. $tt = date('Ymd',time());
  7260. $title = '库存导入错误信息-'.$tt;
  7261. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7262. $tail = "\n";
  7263. $filename = $title.".xls";
  7264. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7265. $dir = '/data/excel/'.$time.'/';
  7266. $file_name = 'error_'.$time.rand(1000,9999);
  7267. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7268. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7269. fwrite($myfile,$ecl);
  7270. fclose($myfile);
  7271. $error = $dir.$file_name.'.xls';
  7272. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7273. }
  7274. else
  7275. {
  7276. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7277. }
  7278. }
  7279. }
  7280. public function _fcjxc($arg_array)
  7281. {
  7282. if(isset($_GET['excel']))
  7283. {
  7284. $category = $this->input->get('category',true);
  7285. $size = $this->input->get('size',true);
  7286. $grade = $this->input->get('grade',true);
  7287. $color = $this->input->get('color',true);
  7288. $lowe = $this->input->get('lowe',true);
  7289. $sku = $this->input->get('sku');
  7290. $title = $this->input->get('title');
  7291. $warehouse = $arg_array[0];
  7292. $usa = $this->input->get('usa',true);
  7293. $purchase = $this->input->get('purchase',true);
  7294. $lacetype = $this->input->get('lacetype',true);
  7295. $haircap = $this->input->get('haircap',true);
  7296. $density = $this->input->get('density',true);
  7297. $title = $this->input->get('title',true);
  7298. $state = $this->input->get('state',true);
  7299. $ktime = $this->input->get('ktime',true);
  7300. $jtime = $this->input->get('jtime',true);
  7301. $where = "state=11";$gj = "";$ck = "";
  7302. if($lacetype)
  7303. {
  7304. $where .= " and features like '%-$lacetype-%'";
  7305. }
  7306. if($category)
  7307. {
  7308. $where .= " and features like '%-$category-%'";
  7309. }
  7310. if($size)
  7311. {
  7312. $where .= " and features like '%-$size-%'";
  7313. }
  7314. if($grade)
  7315. {
  7316. $where .= " and features like '%-$grade-%'";
  7317. }
  7318. if($color)
  7319. {
  7320. $where .= " and features like '%-$color-%'";
  7321. }
  7322. if($lowe)
  7323. {
  7324. $where .= " and features like '%-$lowe-%'";
  7325. }
  7326. if($haircap)
  7327. {
  7328. $where .= " and features like '%-$haircap-%'";
  7329. }
  7330. if($density)
  7331. {
  7332. $where .= " and features like '%-$density-%'";
  7333. }
  7334. if($usa)
  7335. {
  7336. if(!$warehouse)
  7337. {
  7338. $where .= " and (warehouse = '5' or warehouse = '8')";
  7339. }
  7340. }
  7341. if($warehouse)
  7342. {
  7343. $where .= " and warehouse = '$warehouse'";
  7344. }
  7345. if($purchase)
  7346. {
  7347. $where .= " and purchase = '$purchase'";
  7348. }
  7349. if($state)
  7350. {
  7351. $where .= " and state = '$state'";
  7352. }
  7353. $order_str = "id desc";
  7354. if($sku)
  7355. {
  7356. $sku = trim($sku,' ');
  7357. $sku = trim($sku,' ');
  7358. $where .= " and sku like '%$sku%'";
  7359. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7360. }
  7361. else if($title)
  7362. {
  7363. $title = trim($title,' ');
  7364. $title = trim($title,' ');
  7365. $where .= " and title like '%$title%'";
  7366. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7367. }
  7368. else
  7369. {
  7370. //$where .= " and time > '$ktime' and time < '$jtime'";
  7371. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7372. }
  7373. //取得信息列表
  7374. $rows = array();$list = array();
  7375. foreach ($info_list as $key=>$value)
  7376. {
  7377. $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'].'"');
  7378. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7379. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7380. $rows[$key] = $value;
  7381. $warehouse = $this->warehouse->read($value['warehouse']);
  7382. $rows[$key]['warehouse'] = $warehouse['title'];
  7383. $rows[$key]['features'] = $g;
  7384. $rows[$key]['a'] = $x;
  7385. $rows[$key]['b'] = $s;
  7386. }
  7387. $title = "总统计表";
  7388. $titlename = "<table border=1>
  7389. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7390. <tr align='center'>
  7391. <td>仓库</td>
  7392. <td>SKU</td>
  7393. <td>产品名称</td>
  7394. <td>录入总量</td>
  7395. <td>取出总量</td>
  7396. <td>剩余总量</td>
  7397. </tr>
  7398. </table>";
  7399. $filename = $title.".xls";
  7400. $tail = "";
  7401. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7402. }
  7403. $vip = 0;
  7404. if(isset($_SESSION['api']))
  7405. {
  7406. $user = $this->user->get_api($_SESSION['api']);
  7407. if($user['vip'] == 1)
  7408. {
  7409. $vip = 1;
  7410. }
  7411. }
  7412. else
  7413. {
  7414. header('Location: /');exit;
  7415. }
  7416. $post = $this->input->post(NULL, TRUE);
  7417. if(isset($post['page']))
  7418. {
  7419. $page = $this->input->post('page',true);
  7420. $perpage = $this->input->post('perpage',true);
  7421. $category = $this->input->post('category',true);
  7422. $size = $this->input->post('size',true);
  7423. $grade = $this->input->post('grade',true);
  7424. $color = $this->input->post('color',true);
  7425. $lowe = $this->input->post('lowe',true);
  7426. $sku = $this->input->post('sku');
  7427. $title = $this->input->post('title');
  7428. $warehouse = $arg_array[0];
  7429. $usa = $this->input->post('usa',true);
  7430. $purchase = $this->input->post('purchase',true);
  7431. $lacetype = $this->input->post('lacetype',true);
  7432. $haircap = $this->input->post('haircap',true);
  7433. $density = $this->input->post('density',true);
  7434. $title = $this->input->post('title',true);
  7435. $state = $this->input->post('state',true);
  7436. $ktime = $this->input->post('ktime',true);
  7437. $jtime = $this->input->post('jtime',true);
  7438. $ktime = strtotime($ktime);
  7439. $jtime = strtotime($jtime);
  7440. $where = "state=11";$gj = "";$ck = "";
  7441. if($lacetype)
  7442. {
  7443. $where .= " and features like '%-$lacetype-%'";
  7444. }
  7445. if($category)
  7446. {
  7447. $where .= " and features like '%-$category-%'";
  7448. }
  7449. if($size)
  7450. {
  7451. $where .= " and features like '%-$size-%'";
  7452. }
  7453. if($grade)
  7454. {
  7455. $where .= " and features like '%-$grade-%'";
  7456. }
  7457. if($color)
  7458. {
  7459. $where .= " and features like '%-$color-%'";
  7460. }
  7461. if($lowe)
  7462. {
  7463. $where .= " and features like '%-$lowe-%'";
  7464. }
  7465. if($haircap)
  7466. {
  7467. $where .= " and features like '%-$haircap-%'";
  7468. }
  7469. if($density)
  7470. {
  7471. $where .= " and features like '%-$density-%'";
  7472. }
  7473. if($usa)
  7474. {
  7475. if(!$warehouse)
  7476. {
  7477. $where .= " and (warehouse = '5' or warehouse = '8')";
  7478. }
  7479. }
  7480. if($warehouse)
  7481. {
  7482. $where .= " and warehouse = '$warehouse'";
  7483. }
  7484. if($purchase)
  7485. {
  7486. $where .= " and purchase = '$purchase'";
  7487. }
  7488. if($state)
  7489. {
  7490. $where .= " and state = '$state'";
  7491. }
  7492. if($ktime && $jtime)
  7493. {
  7494. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7495. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7496. }
  7497. //数据排序
  7498. $order_str = "id desc";$xs=0;
  7499. $rows = array();$list = array();
  7500. if(empty($page))
  7501. {
  7502. $start = 0;
  7503. $perpage = 1;
  7504. }
  7505. else
  7506. {
  7507. $start = ($page - 1)*$perpage;
  7508. }
  7509. if($sku || $title)
  7510. {
  7511. if($title)
  7512. {
  7513. $title = trim($title,' ');
  7514. $title = trim($title,' ');
  7515. $where .= " and title like '%$title%'";
  7516. }
  7517. else
  7518. {
  7519. $sku = trim($sku,' ');
  7520. $sku = trim($sku,' ');
  7521. $where .= " and sku like '%$sku%'";
  7522. }
  7523. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7524. foreach ($info_list as $key=>$value)
  7525. {
  7526. $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'].'"');
  7527. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7528. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7529. $rows[$key] = $value;
  7530. $warehouse = $this->warehouse->read($value['warehouse']);
  7531. $rows[$key]['warehouse'] = $warehouse['title'];
  7532. $rows[$key]['features'] = $g;
  7533. $rows[$key]['a'] = $x;
  7534. $rows[$key]['b'] = $s;
  7535. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7536. $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天销量
  7537. $yj = $c/($xl/30);
  7538. if($yj < 7)
  7539. {
  7540. $rows[$key]['y'] = round($yj).'天销量';
  7541. }
  7542. else
  7543. {
  7544. $rows[$key]['y'] = '正常';
  7545. }
  7546. }
  7547. }
  7548. else
  7549. {
  7550. //$where .= " and time > '$ktime' and time < '$jtime'";
  7551. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7552. foreach ($info_list as $key=>$value)
  7553. {
  7554. $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'].'"');
  7555. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7556. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7557. $zs[$key] = $value;
  7558. $warehouse = $this->warehouse->read($value['warehouse']);
  7559. $zs[$key]['warehouse'] = $warehouse['title'];
  7560. $zs[$key]['features'] = $g;
  7561. $zs[$key]['a'] = $x;
  7562. $zs[$key]['b'] = $s;
  7563. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7564. $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天销量
  7565. $yj = $c/($xl/30);
  7566. if($yj < 7)
  7567. {
  7568. $zs[$key]['y'] = round($yj).'天销量';
  7569. $rows[$key] = $zs[$key];
  7570. }
  7571. }
  7572. }
  7573. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id'));
  7574. $pagenum = ceil($total/$perpage);
  7575. $over = $total-($start+$perpage);
  7576. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
  7577. echo json_encode($rows);exit;
  7578. }
  7579. $this->data['arg_array'] = $arg_array[0];
  7580. $this->_Template('whlabel_fcjxc',$this->data);
  7581. }
  7582. public function _0kcdel()
  7583. {
  7584. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7585. $config['upload_path'] = '.'.$dir ;
  7586. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7587. $config['allowed_types'] = 'xls|xlsx|csv';
  7588. $config['max_size'] = 10240;
  7589. $this->load->library('upload', $config);
  7590. $this->upload->initialize($config);
  7591. if ($this->upload->do_upload('userfile'))
  7592. {
  7593. $full_path = $dir.$this->upload->data('file_name');
  7594. $fileName = '.' . $full_path;
  7595. if (!file_exists($fileName))
  7596. {
  7597. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7598. }
  7599. else
  7600. {
  7601. libxml_use_internal_errors(true);
  7602. require_once "./data/excel/PHPExcel/IOFactory.php";
  7603. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7604. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7605. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7606. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7607. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7608. ++$column;//如果列数大于26行
  7609. $list = array();
  7610. for ($i = 2; $i <= $row; $i++) // 行数循环
  7611. {
  7612. $data = array();
  7613. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7614. {
  7615. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7616. }
  7617. $list[] = $data;
  7618. }
  7619. }
  7620. $i = 0;$j = 0;$ed = array();
  7621. foreach ($list as $key=>$value)
  7622. {
  7623. $time = time();
  7624. if($value['0'] == "" || $value['1'] == "")
  7625. {
  7626. continue;
  7627. }
  7628. $warehouse = $this->warehouse->get_title($value['0']);
  7629. $sku = $value['1'];
  7630. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7631. if(!$d)//如果没有这个SKU
  7632. {
  7633. $ed[] = array($sku.'-库存中不存在此SKU');
  7634. $j++;
  7635. continue;
  7636. }
  7637. if(!isset($warehouse['id']))
  7638. {
  7639. $ed[] = array($sku.'-仓库名错误!');
  7640. $j++;
  7641. continue;
  7642. }
  7643. $z = $this->whlabel->find_count('sku = "'.$sku.'" and zd = "" and state = 0 and warehouse = "'.$warehouse['id'].'"');
  7644. if($z < 1)
  7645. {
  7646. $z = $this->whlabel->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'"');
  7647. foreach ($z as $v)
  7648. {
  7649. $this->whlabel->remove($v['id']);
  7650. }
  7651. }
  7652. else
  7653. {
  7654. $ed[] = array($sku.'-非0库存!');
  7655. $j++;
  7656. continue;
  7657. }
  7658. }
  7659. if($j > 0)
  7660. {
  7661. $tt = date('Ymd',time());
  7662. $title = '删除0库存错误信息-'.$tt;
  7663. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7664. $tail = "\n";
  7665. $filename = $title.".xls";
  7666. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7667. $dir = '/data/excel/'.$time.'/';
  7668. $file_name = 'error_'.$time.rand(1000,9999);
  7669. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7670. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7671. fwrite($myfile,$ecl);
  7672. fclose($myfile);
  7673. $error = $dir.$file_name.'.xls';
  7674. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7675. }
  7676. else
  7677. {
  7678. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7679. }
  7680. }
  7681. }
  7682. public function _gbhtype()
  7683. {
  7684. $post = $this->input->post(NULL, TRUE);
  7685. if(isset($post['s']))
  7686. {
  7687. $n = $this->input->post('n');
  7688. $d = $this->input->post('s');
  7689. if(!$d)
  7690. {
  7691. echo json_encode(array('msg'=>'未选择需要更改的商品','success'=>false));exit;
  7692. }
  7693. $d = explode(',',trim($d,','));
  7694. $t = $this->whlabel_type->read($n);
  7695. //循环删除记录
  7696. foreach ($d as $v)
  7697. {
  7698. $u = $this->whlabel->read($v);
  7699. $data = $this->whlabel->find_all("sku = '".$u['sku']."' and purchase = '".$u['purchase']."' and features = '".$u['features']."' and warehouse = '".$u['warehouse']."'");
  7700. foreach ($data as $val)
  7701. {
  7702. $this->whlabel->save(array('type'=>$n),$val['id']);
  7703. }
  7704. }
  7705. echo json_encode(array('d'=>$d,'t'=>$t['title'],'msg'=>'修改成功!','success'=>true));
  7706. }
  7707. }
  7708. }