Whlabel.php 258 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. }
  45. //定义方法的调用规则 获取URI第二段值
  46. public function _remap($arg, $arg_array)
  47. {
  48. if ($arg == 'existence') //在库标签
  49. {
  50. $this->_existence();
  51. } else if ($arg == 'cpbqdc') //在库标签
  52. {
  53. $this->_cpbqdc();
  54. } else if ($arg == 'type') //进销存浏览
  55. {
  56. $this->_type();
  57. } else if ($arg == 'typedy') //进销存浏览店员页面
  58. {
  59. $this->_typedy($arg_array);
  60. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  61. {
  62. $this->_typedy_ck($arg_array);
  63. } else if ($arg == 'typeck') {
  64. $this->_typeck($arg_array);
  65. } else if ($arg == 'whlabeckdc') {
  66. $this->_whlabeckdc($arg_array);
  67. } else if ($arg == 'usatype') //美仓进销存浏览
  68. {
  69. $this->_usatype();
  70. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  71. {
  72. $this->_usatypeapp();
  73. } else if ($arg == 'enteradd') //入库操作
  74. {
  75. $this->_enteradd();
  76. } else if ($arg == 'enteredit') //修改
  77. {
  78. $this->_enteredit($arg_array);
  79. } else if ($arg == 'enter') //入库浏览
  80. {
  81. $this->_enter();
  82. } else if ($arg == 'out') //出库浏览
  83. {
  84. $this->_out();
  85. } else if ($arg == 'label') //出库标签浏览
  86. {
  87. $this->_label();
  88. } else if ($arg == 'outorder') //独立站出库订单
  89. {
  90. $this->_outorder();
  91. } else if ($arg == 'soutorder') //速卖通出库订单
  92. {
  93. $this->_soutorder();
  94. } else if ($arg == 'toutorder') //TT出库订单
  95. {
  96. $this->_toutorder();
  97. }else if ($arg == 'aoutorder') //amz出库订单
  98. {
  99. $this->_aoutorder();
  100. } else if ($arg == 'retreat') //退库订单
  101. {
  102. $this->_retreat();
  103. } else if ($arg == 'retreatlk') //退库订单
  104. {
  105. $this->_retreatlk();
  106. } else if ($arg == 'change') //更换标签
  107. {
  108. $this->_change();
  109. } else if ($arg == 'del') //删除
  110. {
  111. $this->_del();
  112. } else if ($arg == 'exceljxc') //进销存信息导出
  113. {
  114. $this->_exceljxc();
  115. } else if ($arg == 'excelr') //入库信息导出
  116. {
  117. $this->_excelr();
  118. } else if ($arg == 'excelct') //出库、退库信息导出
  119. {
  120. $this->_excelct();
  121. } else if ($arg == 'dccrtype') //根据出入库类型导出
  122. {
  123. $this->_dccrtype();
  124. } else if ($arg == 'excelcr') //出库、退库信息导出
  125. {
  126. $this->_excelcr();
  127. } else if ($arg == 'kcyz') //库存验证
  128. {
  129. $this->_kcyz();
  130. } else if ($arg == 'kj') //库存扣减
  131. {
  132. $this->_kj($arg_array);
  133. } else if ($arg == 'presetout') //预设库存导入
  134. {
  135. $this->_presetout($arg_array);
  136. } else if ($arg == 'presetedit') //预设库存导入
  137. {
  138. $this->_presetedit($arg_array);
  139. } else if ($arg == 'summary') //汇总导出
  140. {
  141. $this->_summary($arg_array);
  142. } else if ($arg == 'manifest') //usps发货清单
  143. {
  144. $this->_manifest();
  145. } else if ($arg == 'abnormal') //占单异常
  146. {
  147. $this->_abnormal();
  148. } else if ($arg == 'error') //0库存SKU
  149. {
  150. $this->_error();
  151. } else if ($arg == 'errorexcel') //0库存SKU导出
  152. {
  153. $this->_errorexcel();
  154. } else if ($arg == 'db') {
  155. $this->_db();
  156. } else if ($arg == 'dbrk') {
  157. $this->_dbrk();
  158. } else if ($arg == 'whlabelczdc') {
  159. $this->_whlabelczdc();
  160. } else if ($arg == 'print') {
  161. $this->_print($arg_array);
  162. } else if ($arg == 'usaprint') {
  163. $this->_usaprint($arg_array);
  164. } else if ($arg == 'printck') {
  165. $this->_printck($arg_array);
  166. } else if ($arg == 'printrk') {
  167. $this->_printrk($arg_array);
  168. } else if ($arg == 'printxzrk') {
  169. $this->_printxzrk($arg_array);
  170. } else if ($arg == 'printexcel') {
  171. $this->_printexcel($arg_array);
  172. } else if ($arg == 'uck') {
  173. $this->_uck();
  174. } else if ($arg == 'whlabelexcelzh') {
  175. $this->_whlabelexcelzh();
  176. } else if ($arg == 'fc') {
  177. $this->_fc();
  178. } else if ($arg == 'fcmb') {
  179. $this->_fcmb();
  180. } else if ($arg == 'fcexcel') {
  181. $this->_fcexcel();
  182. } else if ($arg == 'fcjxc') {
  183. $this->_fcjxc($arg_array);
  184. } else if ($arg == '0kcdel') {
  185. $this->_0kcdel(); //导表删除0库存
  186. } else if ($arg == 'gbhtype') {
  187. $this->_gbhtype(); //更改备货状态
  188. } else {
  189. $this->_index();
  190. }
  191. }
  192. //管理
  193. public function _index()
  194. {
  195. $post = $this->input->post(NULL, TRUE);
  196. if (isset($post['page'])) {
  197. $page = $this->input->post('page', true);
  198. $perpage = $this->input->post('perpage', true);
  199. $sku = $this->input->post('sku', true);
  200. $number = $this->input->post('number', true);
  201. $warehouse = $this->input->post('warehouse', true);
  202. $purchase = $this->input->post('purchase', true);
  203. $orderinfo = $this->input->post('orderinfo', true);
  204. $waybill = $this->input->post('waybill', true);
  205. $category = $this->input->post('category', true);
  206. $size = $this->input->post('size', true);
  207. $grade = $this->input->post('grade', true);
  208. $color = $this->input->post('color', true);
  209. $lowe = $this->input->post('lowe', true);
  210. $state = $this->input->post('state', true);
  211. $label = $this->input->post('label', true);
  212. $timetk = $this->input->post('timetkk', true);
  213. $timetj = $this->input->post('timetjj', true);
  214. $timetk = strtotime($timetk);
  215. $timetj = strtotime($timetj);
  216. $where = "1=1 ";
  217. if ($timetk && $timetj) {
  218. $where .= " and time > '$timetk' and time < '$timetj'";
  219. }
  220. if ($sku) {
  221. $where .= " and sku = '$sku'";
  222. }
  223. if ($number) {
  224. $where .= " and number = '$number'";
  225. }
  226. if ($warehouse) {
  227. $where .= " and warehouse = '$warehouse'";
  228. }
  229. if ($purchase) {
  230. $where .= " and purchase = '$purchase'";
  231. }
  232. if ($orderinfo) {
  233. $where .= " and orderinfo = '$orderinfo'";
  234. }
  235. if ($waybill) {
  236. $where .= " and waybill = '$waybill'";
  237. }
  238. if ($category) {
  239. $where .= " and features like '%-$category-%'";
  240. }
  241. if ($size) {
  242. $where .= " and features like '%-$size-%'";
  243. }
  244. if ($grade) {
  245. $where .= " and features like '%-$grade-%'";
  246. }
  247. if ($color) {
  248. $where .= " and features like '%-$color-%'";
  249. }
  250. if ($lowe) {
  251. $where .= " and features like '%-$lowe-%'";
  252. }
  253. if ($label) {
  254. $where .= " and label = '$label'";
  255. }
  256. if ($state != '') {
  257. $where .= " and state = '$state'";
  258. }
  259. //数据排序
  260. $order_str = "time desc";
  261. if (empty($page)) {
  262. $start = 0;
  263. $perpage = 1;
  264. } else {
  265. $start = ($page - 1) * $perpage;
  266. }
  267. //取得信息列表
  268. $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);
  269. foreach ($info_list as $key => $value) {
  270. $warehouse = $this->warehouse->read($value['warehouse']);
  271. $info_list[$key]['warehouse'] = $warehouse['title'];
  272. $purchase = $this->purchase->read($value['purchase']);
  273. $info_list[$key]['purchase'] = $purchase['title'];
  274. if ($value['enter'] != 0) {
  275. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  276. } else {
  277. $info_list[$key]['enter'] = "";
  278. }
  279. if ($value['outk'] != 0) {
  280. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  281. } else {
  282. $info_list[$key]['outk'] = "";
  283. }
  284. if ($value['printing'] != 0) {
  285. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  286. } else {
  287. $info_list[$key]['printing'] = "";
  288. }
  289. if ($value['orderinfo'] == 0) {
  290. $info_list[$key]['orderinfo'] = "";
  291. }
  292. if ($value['waybill'] == 0) {
  293. $info_list[$key]['waybill'] = "";
  294. }
  295. if ($value['state'] == 0) {
  296. $info_list[$key]['state'] = "在库";
  297. } else if ($value['state'] == 1) {
  298. $info_list[$key]['state'] = "出库";
  299. } else if ($value['state'] == 2) {
  300. $info_list[$key]['state'] = "退库";
  301. } else if ($value['state'] == 3) {
  302. $info_list[$key]['state'] = "调拨中";
  303. } else if ($value['state'] == 4) {
  304. $info_list[$key]['state'] = "再加工";
  305. } else if ($value['state'] == 5) {
  306. $info_list[$key]['state'] = "维修中";
  307. } else if ($value['state'] == 6) {
  308. $info_list[$key]['state'] = "盘亏";
  309. } else if ($value['state'] == 7) {
  310. $info_list[$key]['state'] = "更换标签";
  311. } else if ($value['state'] == 8) {
  312. $info_list[$key]['state'] = "其它";
  313. } else if ($value['state'] == 9) {
  314. $info_list[$key]['state'] = "预设";
  315. } else if ($value['state'] == 10) {
  316. $info_list[$key]['state'] = "美店零售";
  317. }
  318. if ($value['text'] == "") {
  319. $info_list[$key]['text'] = "";
  320. }
  321. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  322. }
  323. $total = $this->whlabel->find_count($where);
  324. $pagenum = ceil($total / $perpage);
  325. $over = $total - ($start + $perpage);
  326. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  327. echo json_encode($rows);
  328. exit;
  329. }
  330. if (isset($post['outsku'])) {
  331. $cz = $this->input->post('cz', true);
  332. if ($cz == '1') {
  333. $sku = $this->input->post('outsku', true);
  334. if ($sku) {
  335. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  336. if (count($data) < 1) {
  337. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  338. exit;
  339. }
  340. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 1), $data[0]['id']);
  341. echo json_encode(array('success' => true));
  342. exit;
  343. }
  344. } else {
  345. $sku = $this->input->post('outsku', true);
  346. if ($sku) {
  347. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  348. if (count($data) < 1) {
  349. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  350. exit;
  351. }
  352. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  353. echo json_encode(array('success' => true));
  354. exit;
  355. }
  356. }
  357. }
  358. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  359. $this->_Template('whlabel', $this->data);
  360. }
  361. //在库标签
  362. public function _existence()
  363. {
  364. $post = $this->input->post(NULL, TRUE);
  365. if (isset($post['s'])) {
  366. $id_arr = $this->input->post('s');
  367. $id_arr = explode(',', $id_arr);
  368. if (!$id_arr) {
  369. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  370. exit;
  371. }
  372. //循环删除记录
  373. foreach ($id_arr as $v) {
  374. $sid = $this->whlabel->read($v);
  375. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  376. if ($count > 0) {
  377. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  378. exit;
  379. }
  380. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  381. if (count($zt) > 0) {
  382. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  383. exit;
  384. }
  385. $this->whlabel->remove($v);
  386. }
  387. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  388. exit;
  389. }
  390. if (isset($post['page'])) {
  391. $page = $this->input->post('page', true);
  392. $perpage = $this->input->post('perpage', true);
  393. $warehouse = $this->input->post('warehouse', true);
  394. $label = $this->input->post('label', true);
  395. $where = "1=1 and state = 0";
  396. if ($warehouse) {
  397. $where .= " and warehouse = '$warehouse'";
  398. }
  399. if ($label) {
  400. $where .= " and label = '$label'";
  401. }
  402. //数据排序
  403. $order_str = "time asc";
  404. if (empty($page)) {
  405. $start = 0;
  406. $perpage = 1;
  407. } else {
  408. $start = ($page - 1) * $perpage;
  409. }
  410. //取得信息列表
  411. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  412. foreach ($info_list as $key => $value) {
  413. if ($value['enter'] != 0) {
  414. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  415. } else {
  416. $info_list[$key]['enter'] = "";
  417. }
  418. if ($value['printing'] != 0) {
  419. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  420. } else {
  421. $info_list[$key]['printing'] = "";
  422. }
  423. }
  424. $total = $this->whlabel->find_count($where);
  425. $pagenum = ceil($total / $perpage);
  426. $over = $total - ($start + $perpage);
  427. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  428. echo json_encode($rows);
  429. exit;
  430. }
  431. $this->_Template('whlabel_existence', $this->data);
  432. }
  433. //进销存浏览
  434. public function _typedy($arg_array)
  435. {
  436. $prc = array();
  437. $purchase = $this->purchase->find_all();
  438. foreach ($purchase as $k => $v) {
  439. $prc[$v['id']] = $v['title'];
  440. }
  441. $post = $this->input->post(NULL, TRUE);
  442. if (isset($post['page'])) {
  443. $page = $this->input->post('page', true);
  444. $perpage = $this->input->post('perpage', true);
  445. $category = $this->input->post('category', true);
  446. $size = $this->input->post('size', true);
  447. $grade = $this->input->post('grade', true);
  448. $color = $this->input->post('color', true);
  449. $lowe = $this->input->post('lowe', true);
  450. $sku = $this->input->post('sku');
  451. $title = $this->input->post('title');
  452. $warehouse = $this->input->post('warehouse', true);
  453. $usa = $this->input->post('usa', true);
  454. $purchase = $this->input->post('purchase', true);
  455. $lacetype = $this->input->post('lacetype', true);
  456. $haircap = $this->input->post('haircap', true);
  457. $density = $this->input->post('density', true);
  458. $details = $this->input->post('details', true);
  459. $state = $this->input->post('state', true);
  460. $lacecolor = $this->input->post('lacecolor', true);
  461. $hairnumber = $this->input->post('hairnumber', true);
  462. $cklx = $this->input->post('cklx', true);
  463. $ktime = $this->input->post('ktime', true);
  464. $jtime = $this->input->post('jtime', true);
  465. $ktime = strtotime($ktime);
  466. $jtime = strtotime($jtime);
  467. $where = "1=1";
  468. $gj = "";
  469. $ck = "";
  470. if ($usa) {
  471. if (!$warehouse) {
  472. $where .= " and (warehouse = '5' or warehouse = '8')";
  473. }
  474. }
  475. if ($warehouse) {
  476. $where .= " and warehouse = '$warehouse'";
  477. }
  478. if ($details) {
  479. $where .= " and details = '$details'";
  480. }
  481. if ($purchase) {
  482. $where .= " and purchase = '$purchase'";
  483. }
  484. if ($state) {
  485. $where .= " and state = '$state'";
  486. }
  487. if ($lacetype) {
  488. $where .= " and features like '%-$lacetype-%'";
  489. }
  490. if ($category) {
  491. $where .= " and features like '%-$category-%'";
  492. }
  493. if ($size) {
  494. $where .= " and features like '%-$size-%'";
  495. }
  496. if ($grade) {
  497. $where .= " and features like '%-$grade-%'";
  498. }
  499. if ($color) {
  500. $where .= " and features like '%-$color-%'";
  501. }
  502. if ($lowe) {
  503. $where .= " and features like '%-$lowe-%'";
  504. }
  505. if ($haircap) {
  506. $where .= " and features like '%-$haircap-%'";
  507. }
  508. if ($density) {
  509. $where .= " and features like '%-$density-%'";
  510. }
  511. if ($lacecolor) {
  512. $where .= " and features like '%-$lacecolor-%'";
  513. }
  514. if (!empty($hairnumber)) {
  515. $where .= " and features like '%-128-%' ";
  516. if ($hairnumber < 0) {
  517. $class_list = $this->typeclass->find_all('classid = 43');
  518. foreach ($class_list as $v) {
  519. $where .= " and features not like '%-" . $v['id'] . "-%'";
  520. }
  521. } else {
  522. $where .= " and features like '%-$hairnumber-%'";
  523. }
  524. }
  525. $where_add = '';
  526. if ($cklx) {
  527. $shop = $this->shop->read($cklx);
  528. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  529. }
  530. if ($ktime && $jtime) {
  531. $gj = " and enter > '$ktime' and enter < '$jtime'";
  532. $ck = " and outk > '$ktime' and outk < '$jtime'";
  533. }
  534. //数据排序
  535. $order_str = "id desc";
  536. if (empty($page)) {
  537. $start = 0;
  538. $perpage = 1;
  539. } else {
  540. $start = ($page - 1) * $perpage;
  541. }
  542. if ($sku) {
  543. $sku = trim($sku, ' ');
  544. $sku = trim($sku, ' ');
  545. $where .= " and sku like '%$sku%'";
  546. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  547. } else if ($title) {
  548. $title = trim($title, ' ');
  549. $title = trim($title, ' ');
  550. $where .= " and title like '%$title%'";
  551. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  552. } else {
  553. //$where .= " and time > '$ktime' and time < '$jtime'";
  554. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  555. }
  556. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  557. foreach ($info_list as $k => $v) {
  558. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  559. unset($info_list[$k]['pm']);
  560. unset($info_list[$k]['jm']);
  561. unset($info_list[$k]['bm']);
  562. }
  563. //取得信息列表
  564. $rows = array();
  565. $list = array();
  566. foreach ($info_list as $key => $value) {
  567. $warehouse = $this->warehouse->read($value['warehouse']);
  568. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  569. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  570. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  571. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  572. $number = $value['number'];
  573. $ftime = time() - 15 * 24 * 3600;
  574. $info_list[$key]['warehouse'] = $warehouse['title'];
  575. $info_list[$key]['features'] = count($c);
  576. $z = count($z); //查看订单号
  577. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  578. $ztdata = '';
  579. if (count($zt) > 0) {
  580. foreach ($zt as $vv) {
  581. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  582. }
  583. }
  584. $info_list[$key]['number'] = $ztdata;
  585. $info_list[$key]['sm'] = $z;
  586. $details = array();
  587. $cpid = array();
  588. foreach ($c as $k => $v) {
  589. $details[$v['details']] = $v['details'];
  590. if ($v['cpid'] != 0) {
  591. $cpid[$v['cpid']] = $v['cpid'];
  592. }
  593. }
  594. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  595. if ($value['shop'] != '') {
  596. $shop = explode(',', trim($value['shop'], ','));
  597. $shop = $this->shop->read($shop[0]);
  598. $info_list[$key]['shop'] = $shop['shopname'];
  599. }
  600. }
  601. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  602. $pagenum = ceil($total / $perpage);
  603. $over = $total - ($start + $perpage);
  604. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  605. echo json_encode($rows);
  606. exit;
  607. }
  608. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  609. $this->_Template('whlabel_typedy', $this->data);
  610. }
  611. //进销存浏览
  612. public function _typedy_ck($arg_array)
  613. {
  614. $prc = array();
  615. $purchase = $this->purchase->find_all();
  616. foreach ($purchase as $k => $v) {
  617. $prc[$v['id']] = $v['title'];
  618. }
  619. $post = $this->input->post(NULL, TRUE);
  620. if (isset($post['page'])) {
  621. $page = $this->input->post('page', true);
  622. $perpage = $this->input->post('perpage', true);
  623. $category = $this->input->post('category', true);
  624. $size = $this->input->post('size', true);
  625. $grade = $this->input->post('grade', true);
  626. $color = $this->input->post('color', true);
  627. $lowe = $this->input->post('lowe', true);
  628. $sku = $this->input->post('sku');
  629. $title = $this->input->post('title');
  630. $warehouse = $this->input->post('warehouse', true);
  631. $usa = $this->input->post('usa', true);
  632. $purchase = $this->input->post('purchase', true);
  633. $lacetype = $this->input->post('lacetype', true);
  634. $haircap = $this->input->post('haircap', true);
  635. $density = $this->input->post('density', true);
  636. $details = $this->input->post('details', true);
  637. $state = $this->input->post('state', true);
  638. $lacecolor = $this->input->post('lacecolor', true);
  639. $cklx = $this->input->post('cklx', true);
  640. $ktime = $this->input->post('ktime', true);
  641. $jtime = $this->input->post('jtime', true);
  642. $ktime = strtotime($ktime);
  643. $jtime = strtotime($jtime);
  644. $where = "1=1";
  645. $gj = "";
  646. $ck = "";
  647. if ($lacetype) {
  648. $where .= " and features like '%-$lacetype-%'";
  649. }
  650. if ($category) {
  651. $where .= " and features like '%-$category-%'";
  652. }
  653. if ($size) {
  654. $where .= " and features like '%-$size-%'";
  655. }
  656. if ($grade) {
  657. $where .= " and features like '%-$grade-%'";
  658. }
  659. if ($color) {
  660. $where .= " and features like '%-$color-%'";
  661. }
  662. if ($lowe) {
  663. $where .= " and features like '%-$lowe-%'";
  664. }
  665. if ($haircap) {
  666. $where .= " and features like '%-$haircap-%'";
  667. }
  668. if ($density) {
  669. $where .= " and features like '%-$density-%'";
  670. }
  671. if ($lacecolor) {
  672. $where .= " and features like '%-$lacecolor-%'";
  673. }
  674. if ($usa) {
  675. if (!$warehouse) {
  676. $where .= " and (warehouse = '5' or warehouse = '8')";
  677. }
  678. }
  679. if ($warehouse) {
  680. $where .= " and warehouse = '$warehouse'";
  681. }
  682. if ($details) {
  683. $where .= " and details = '$details'";
  684. }
  685. if ($purchase) {
  686. $where .= " and purchase = '$purchase'";
  687. }
  688. if ($state) {
  689. $where .= " and state = '$state'";
  690. }
  691. $where_add = '';
  692. if ($cklx) {
  693. $shop = $this->shop->read($cklx);
  694. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  695. }
  696. if ($ktime && $jtime) {
  697. $gj = " and enter > '$ktime' and enter < '$jtime'";
  698. $ck = " and outk > '$ktime' and outk < '$jtime'";
  699. }
  700. //数据排序
  701. $order_str = "id desc";
  702. if (empty($page)) {
  703. $start = 0;
  704. $perpage = 1;
  705. } else {
  706. $start = ($page - 1) * $perpage;
  707. }
  708. if ($sku) {
  709. $sku = trim($sku, ' ');
  710. $sku = trim($sku, ' ');
  711. $where .= " and sku like '%$sku%'";
  712. $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);
  713. } else if ($title) {
  714. $title = trim($title, ' ');
  715. $title = trim($title, ' ');
  716. $where .= " and title like '%$title%'";
  717. $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);
  718. } else {
  719. //$where .= " and time > '$ktime' and time < '$jtime'";
  720. $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);
  721. }
  722. //取得信息列表
  723. $rows = array();
  724. $list = array();
  725. foreach ($info_list as $key => $value) {
  726. $warehouse = $this->warehouse->read($value['warehouse']);
  727. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  728. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  729. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  730. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  731. $ftime = time() - 15 * 24 * 3600;
  732. $info_list[$key]['warehouse'] = $warehouse['title'];
  733. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  734. //$z = count($z);//查看订单号
  735. //$info_list[$key]['zd'] = $z;
  736. $details = array();
  737. $cpid = array();
  738. foreach ($c as $k => $v) {
  739. $details[$v['details']] = $v['details'];
  740. if ($v['cpid'] != 0) {
  741. $cpid[$v['cpid']] = $v['cpid'];
  742. }
  743. }
  744. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  745. if ($value['shop'] != '') {
  746. $shop = explode(',', trim($value['shop'], ','));
  747. $shop = $this->shop->read($shop[0]);
  748. $info_list[$key]['shop'] = $shop['shopname'];
  749. }
  750. }
  751. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  752. $pagenum = ceil($total / $perpage);
  753. $over = $total - ($start + $perpage);
  754. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  755. echo json_encode($rows);
  756. exit;
  757. }
  758. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  759. $this->_Template('whlabel_typedy_ck', $this->data);
  760. }
  761. public function _typeck($arg_array)
  762. {
  763. $prc = array();
  764. $purchase = $this->purchase->find_all();
  765. foreach ($purchase as $k => $v) {
  766. $prc[$v['id']] = $v['title'];
  767. }
  768. $post = $this->input->post(NULL, TRUE);
  769. if (isset($post['page'])) {
  770. $page = $this->input->post('page', true);
  771. $perpage = $this->input->post('perpage', true);
  772. $category = $this->input->post('category', true);
  773. $size = $this->input->post('size', true);
  774. $grade = $this->input->post('grade', true);
  775. $color = $this->input->post('color', true);
  776. $lacecolor = $this->input->post('lacecolor', true);
  777. $lowe = $this->input->post('lowe', true);
  778. $sku = $this->input->post('sku');
  779. $title = $this->input->post('title');
  780. $warehouse = 13;
  781. $usa = $this->input->post('usa', true);
  782. $purchase = $this->input->post('purchase', true);
  783. $lacetype = $this->input->post('lacetype', true);
  784. $haircap = $this->input->post('haircap', true);
  785. $density = $this->input->post('density', true);
  786. $details = $this->input->post('details', true);
  787. $state = $this->input->post('state', true);
  788. $ktime = $this->input->post('ktime', true);
  789. $jtime = $this->input->post('jtime', true);
  790. $ktime = strtotime($ktime);
  791. $jtime = strtotime($jtime);
  792. $where = "1=1";
  793. $gj = "";
  794. $ck = "";
  795. if ($lacetype) {
  796. $where .= " and features like '%-$lacetype-%'";
  797. }
  798. if ($category) {
  799. $where .= " and features like '%-$category-%'";
  800. }
  801. if ($size) {
  802. $where .= " and features like '%-$size-%'";
  803. }
  804. if ($grade) {
  805. $where .= " and features like '%-$grade-%'";
  806. }
  807. if ($color) {
  808. $where .= " and features like '%-$color-%'";
  809. }
  810. if ($lacecolor) {
  811. $where .= " and features like '%-$lacecolor-%'";
  812. }
  813. if ($lowe) {
  814. $where .= " and features like '%-$lowe-%'";
  815. }
  816. if ($haircap) {
  817. $where .= " and features like '%-$haircap-%'";
  818. }
  819. if ($density) {
  820. $where .= " and features like '%-$density-%'";
  821. }
  822. if ($warehouse) {
  823. $where .= " and warehouse = '$warehouse'";
  824. }
  825. if ($details) {
  826. $where .= " and details = '$details'";
  827. }
  828. if ($purchase) {
  829. $where .= " and purchase = '$purchase'";
  830. }
  831. if ($state) {
  832. $where .= " and state = '$state'";
  833. }
  834. if ($ktime && $jtime) {
  835. $gj = " and enter > '$ktime' and enter < '$jtime'";
  836. $ck = " and outk > '$ktime' and outk < '$jtime'";
  837. }
  838. //数据排序
  839. $order_str = "id desc";
  840. if (empty($page)) {
  841. $start = 0;
  842. $perpage = 1;
  843. } else {
  844. $start = ($page - 1) * $perpage;
  845. }
  846. if ($sku) {
  847. $sku = trim($sku, ' ');
  848. $sku = trim($sku, ' ');
  849. $where .= " and sku like '%$sku%'";
  850. } else if ($title) {
  851. $title = trim($title, ' ');
  852. $title = trim($title, ' ');
  853. $where .= " and title like '%$title%'";
  854. }
  855. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  856. //取得信息列表
  857. $t = array();
  858. $typeclass = $this->typeclass->find_all();
  859. foreach ($typeclass as $v) {
  860. $t[$v['id']] = $v;
  861. }
  862. $rows = array();
  863. $list = array();
  864. foreach ($info_list as $key => $value) {
  865. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  866. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  867. $warehouse = $this->warehouse->read($value['warehouse']);
  868. $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');
  869. $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'] . '"');
  870. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  871. $number = $value['number'];
  872. $ftime = time() - 15 * 24 * 3600;
  873. $z = count($z); //查看订单号
  874. $info_list[$key]['warehouse'] = $warehouse['title'];
  875. $info_list[$key]['features'] = count($c);
  876. $info_list[$key]['number'] = $z;
  877. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  878. $details = array();
  879. $cpid = array();
  880. foreach ($c as $k => $v) {
  881. $details[$v['details']] = $v['details'];
  882. if ($v['cpid'] != 0) {
  883. $cpid[$v['cpid']] = $v['cpid'];
  884. }
  885. }
  886. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  887. $classid = $this->classid->sku();
  888. $pm = $classid;
  889. $features = explode('-', trim($value['features'], '-'));
  890. foreach ($features as $v) {
  891. $zh = explode('|', trim($t[$v]['zh'], '|'));
  892. $pm[$t[$v]['classid']] = $zh[0];
  893. }
  894. $zh = implode(" ", $pm);
  895. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  896. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  897. $info_list[$key]['sm'] = $zh;
  898. }
  899. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  900. $pagenum = ceil($total / $perpage);
  901. $over = $total - ($start + $perpage);
  902. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  903. echo json_encode($rows);
  904. exit;
  905. }
  906. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  907. $this->_Template('whlabel_typeck', $this->data);
  908. }
  909. //进销存导出
  910. public function _whlabeckdc()
  911. {
  912. $prc = array();
  913. $purchase = $this->purchase->find_all();
  914. foreach ($purchase as $k => $v) {
  915. $prc[$v['id']] = $v['title'];
  916. }
  917. if (isset($_GET['excel'])) {
  918. $where = "sku != 'Preset'";
  919. //数据排序
  920. $order_str = "id desc";
  921. if (empty($page)) {
  922. $start = 0;
  923. $perpage = 1;
  924. } else {
  925. $start = ($page - 1) * $perpage;
  926. }
  927. $category = $this->input->get('category', true);
  928. $color = $this->input->get('color', true);
  929. $lowe = $this->input->get('lowe', true);
  930. $lacetype = $this->input->get('lacetype', true);
  931. $size = $this->input->get('size', true);
  932. $density = $this->input->get('density', true);
  933. $haircap = $this->input->get('haircap', true);
  934. $sku = $this->input->get('sku', true);
  935. $details = $this->input->get('details', true);
  936. $warehouse = 13;
  937. $excelid = $this->input->get('sid', true);
  938. if ($category) {
  939. $where .= " and features like '%-$category-%'";
  940. }
  941. if ($color) {
  942. $where .= " and features like '%-$color-%'";
  943. }
  944. if ($lowe) {
  945. $where .= " and features like '%-$lowe-%'";
  946. }
  947. if ($lacetype) {
  948. $where .= " and features like '%-$lacetype-%'";
  949. }
  950. if ($size) {
  951. $where .= " and features like '%-$size-%'";
  952. }
  953. if ($density) {
  954. $where .= " and features like '%-$density-%'";
  955. }
  956. if ($haircap) {
  957. $where .= " and features like '%-$haircap-%'";
  958. }
  959. if ($warehouse) {
  960. $where .= " and warehouse = '$warehouse'";
  961. }
  962. if ($sku) {
  963. $where .= " and sku like '%$sku%'";
  964. }
  965. if ($details) {
  966. $where .= " and details = '$details'";
  967. }
  968. $xzid = '';
  969. if ($excelid) {
  970. $excelid = explode(',', trim($excelid, ','));
  971. foreach ($excelid as $key => $value) {
  972. $xzid .= " id = " . $value . " or";
  973. }
  974. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  975. }
  976. //取得信息列表
  977. /**
  978. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  979. $rows = array();$list = array();
  980. foreach ($info_list as $key=>$value)
  981. {
  982. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  983. }
  984. **/
  985. $wh = array();
  986. $w = $this->warehouse->find_all('1=1', 'id,title');
  987. foreach ($w as $v) {
  988. $wh[$v['id']] = $v['title'];
  989. }
  990. $tc = array();
  991. $tcdata = array();
  992. $typeclass = $this->typeclass->find_all();
  993. foreach ($typeclass as $v) {
  994. $tc[$v['id']] = $v;
  995. }
  996. $list = array();
  997. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  998. foreach ($rows as $key => $value) {
  999. $bm = '03';
  1000. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  1001. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1002. $classid = $this->classid->sku();
  1003. $pm = $classid;
  1004. $jm = $classid;
  1005. $features = explode('-', trim($value['features'], '-'));
  1006. foreach ($features as $v) {
  1007. if (isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']])) {
  1008. if ($tc[$v]['bm'] != '') {
  1009. $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
  1010. }
  1011. }
  1012. if (isset($tc[$v])) {
  1013. $zh = explode('|', trim($tc[$v]['zh'], '|'));
  1014. $pm[$tc[$v]['classid']] = $zh[0];
  1015. }
  1016. if (isset($tc[$v])) {
  1017. if (isset($jm[$tc[$v]['classid']])) {
  1018. $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
  1019. }
  1020. }
  1021. }
  1022. $zh = implode(" ", $pm);
  1023. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  1024. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1025. $rows[$key]['dbcontent'] = $zh;
  1026. $rows[$key]['cpbz'] = $bm . implode("", $bmpx);
  1027. $jm = array_filter($jm);
  1028. $rows[$key]['cs'] = implode("-", $jm);
  1029. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1030. $details = array();
  1031. $cpid = array();
  1032. $cpbz = array();
  1033. $c = 0;
  1034. $g = 0;
  1035. $x = 0;
  1036. $t = 0;
  1037. $s = 0;
  1038. $q = 0;
  1039. foreach ($sd as $k => $v) {
  1040. if ($v['state'] == 0) {
  1041. $c++;
  1042. }
  1043. if ($v['state'] != 9) {
  1044. $g++;
  1045. }
  1046. if ($v['state'] == 1) {
  1047. $x++;
  1048. }
  1049. if ($v['state'] == 2) {
  1050. $t++;
  1051. }
  1052. if ($v['state'] == 8) {
  1053. $s++;
  1054. }
  1055. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1056. $q++;
  1057. }
  1058. $details[$v['details']] = $v['details'];
  1059. if ($v['cpid'] != 0) {
  1060. $cpid[$v['cpid']] = $v['cpid'];
  1061. }
  1062. if ($v['cpbz'] != '') {
  1063. $cpbz[$v['cpbz']] = $v['cpbz'];
  1064. }
  1065. }
  1066. $rows[$key]['details'] = implode("、", $details);
  1067. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1068. $number = $value['number'];
  1069. $ftime = time() - 15 * 24 * 3600;
  1070. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1071. $rows[$key]['number'] = $g;
  1072. $rows[$key]['features'] = $c;
  1073. $rows[$key]['x'] = $x;
  1074. $rows[$key]['t'] = $t;
  1075. $rows[$key]['s'] = $s;
  1076. $rows[$key]['q'] = $q;
  1077. $rows[$key]['wzsl'] = count($details);
  1078. }
  1079. $title = "进销存统计表" . date('Y-m-d', time());
  1080. $titlename = "<table border=1>
  1081. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1082. <tr align='center'>
  1083. <td>仓库</td>
  1084. <td>供应商</td>
  1085. <td>位置</td>
  1086. <td>库存编码</td>
  1087. <td>SKU</td>
  1088. <td>用友编码</td>
  1089. <td>用友料号</td>
  1090. <td>产品英文名</td>
  1091. <td>产品中文名</td>
  1092. <td>入库总量</td>
  1093. <td>库存数量</td>
  1094. <td>销售数量</td>
  1095. <td>退货数量</td>
  1096. <td>删除数量</td>
  1097. <td>其它操作</td>
  1098. <td>位置数量</td>
  1099. </tr>
  1100. </table>";
  1101. $filename = $title . ".xls";
  1102. $tail = "";
  1103. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1104. }
  1105. }
  1106. public function _type()
  1107. {
  1108. $vip = 0;
  1109. if (isset($_SESSION['api'])) {
  1110. $user = $this->user->get_api($_SESSION['api']);
  1111. $fgshop = "";
  1112. $sid = "";
  1113. $usersp = explode('|', trim($user['shop'], '|'));
  1114. foreach ($usersp as $value) {
  1115. $fgshop .= " shop = " . $value . " or";
  1116. $sid .= " id = " . $value . " or";
  1117. }
  1118. if ($user['vip'] == 1) {
  1119. $vip = 1;
  1120. }
  1121. } else {
  1122. header('Location: /');
  1123. exit;
  1124. }
  1125. $prc = array();
  1126. $purchase = $this->purchase->find_all();
  1127. foreach ($purchase as $k => $v) {
  1128. $prc[$v['id']] = $v['title'];
  1129. }
  1130. $company = array();
  1131. $ct = $this->company->find_all();
  1132. foreach ($ct as $k => $v) {
  1133. $company[$v['id']] = $v['title'];
  1134. }
  1135. $sp = array();
  1136. $s = $this->shop->find_all('1=1', 'id,shopname');
  1137. foreach ($s as $v) {
  1138. $sp[$v['id']] = $v['shopname'];
  1139. }
  1140. $wh = array();
  1141. $w = $this->warehouse->find_all('1=1', 'id,title');
  1142. foreach ($w as $v) {
  1143. $wh[$v['id']] = $v['title'];
  1144. }
  1145. $post = $this->input->post(NULL, TRUE);
  1146. if (isset($post['page'])) {
  1147. $page = $this->input->post('page', true);
  1148. $perpage = $this->input->post('perpage', true);
  1149. $category = $this->input->post('category', true);
  1150. $size = $this->input->post('size', true);
  1151. $grade = $this->input->post('grade', true);
  1152. $color = $this->input->post('color', true);
  1153. $lowe = $this->input->post('lowe', true);
  1154. $sku = $this->input->post('sku');
  1155. $title = $this->input->post('title');
  1156. $warehouse = $this->input->post('warehouse', true);
  1157. $usa = $this->input->post('usa', true);
  1158. $purchase = $this->input->post('purchase', true);
  1159. $lacetype = $this->input->post('lacetype', true);
  1160. $haircap = $this->input->post('haircap', true);
  1161. $density = $this->input->post('density', true);
  1162. $details = $this->input->post('details', true);
  1163. $state = $this->input->post('state', true);
  1164. $shop = $this->input->post('shop', true);
  1165. $lacecolor = $this->input->post('lacecolor', true);
  1166. $hairnumber = $this->input->post('hairnumber', true);
  1167. $type = $this->input->post('type', true);
  1168. $ktime = $this->input->post('ktime', true);
  1169. $jtime = $this->input->post('jtime', true);
  1170. $ktime = strtotime($ktime);
  1171. $jtime = strtotime($jtime);
  1172. $cpbz = $this->input->post('cpbz', true);
  1173. $where = "1=1";
  1174. $gj = "";
  1175. $ck = "";
  1176. if ($usa) {
  1177. if (!$warehouse) {
  1178. $where .= " and (warehouse = '5' or warehouse = '8')";
  1179. }
  1180. }
  1181. if ($warehouse) {
  1182. $where .= " and warehouse = '$warehouse'";
  1183. }
  1184. if ($details) {
  1185. $where .= " and details = '$details'";
  1186. }
  1187. if ($purchase) {
  1188. $where .= " and purchase = '$purchase'";
  1189. }
  1190. if ($state) {
  1191. $where .= " and state = '$state'";
  1192. }
  1193. if ($shop) {
  1194. $where .= " and shop like '%$shop%'";
  1195. }
  1196. if ($type) {
  1197. $where .= " and type = '$type'";
  1198. }
  1199. if ($ktime && $jtime) {
  1200. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1201. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1202. }
  1203. if ($cpbz) {
  1204. $where .= " and cpbz like '%$cpbz%' ";
  1205. }
  1206. if ($lacecolor) {
  1207. $where .= " and features like '%-$lacecolor-%'";
  1208. }
  1209. if ($lacetype) {
  1210. $where .= " and features like '%-$lacetype-%'";
  1211. }
  1212. if ($category) {
  1213. $where .= " and features like '%-$category-%'";
  1214. }
  1215. if ($size) {
  1216. $where .= " and features like '%-$size-%'";
  1217. }
  1218. if ($grade) {
  1219. $where .= " and features like '%-$grade-%'";
  1220. }
  1221. if ($color) {
  1222. $where .= " and features like '%-$color-%'";
  1223. }
  1224. if ($lowe) {
  1225. $where .= " and features like '%-$lowe-%'";
  1226. }
  1227. if ($haircap) {
  1228. $where .= " and features like '%-$haircap-%'";
  1229. }
  1230. if ($density) {
  1231. $where .= " and features like '%-$density-%'";
  1232. }
  1233. if (!empty($hairnumber)) {
  1234. $where .= " and features like '%-128-%' ";
  1235. if ($hairnumber < 0) {
  1236. $class_list = $this->typeclass->find_all('classid = 43');
  1237. foreach ($class_list as $v) {
  1238. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1239. }
  1240. } else {
  1241. $where .= " and features like '%-$hairnumber-%'";
  1242. }
  1243. }
  1244. //数据排序
  1245. $order_str = "id desc";
  1246. if (empty($page)) {
  1247. $start = 0;
  1248. $perpage = 1;
  1249. } else {
  1250. $start = ($page - 1) * $perpage;
  1251. }
  1252. $fjnr = '';
  1253. if ($sku) {
  1254. $sku = trim($sku, ' ');
  1255. $sku = trim($sku, ' ');
  1256. $fjnr .= " and sku like '%$sku%'";
  1257. }
  1258. if ($title) {
  1259. $title = trim($title, ' ');
  1260. $title = trim($title, ' ');
  1261. $fjnr .= " and title like '%$title%'";
  1262. }
  1263. $wt = array();
  1264. $whlabel_type = $this->whlabel_type->find_all();
  1265. foreach ($whlabel_type as $v) {
  1266. $wt[$v['id']] = $v['title'];
  1267. }
  1268. //$where .= " and time > '$ktime' and time < '$jtime'";
  1269. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1270. //取得信息列表
  1271. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1272. $rows = array();
  1273. $list = array();
  1274. foreach ($info_list as $key => $value) {
  1275. if (isset($wt[$value['type']])) {
  1276. $info_list[$key]['type'] = $wt[$value['type']];
  1277. } else {
  1278. $info_list[$key]['type'] = '未设置';
  1279. }
  1280. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1281. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1282. $ztdata = '';
  1283. if (count($zt) > 0) {
  1284. foreach ($zt as $vv) {
  1285. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1286. }
  1287. }
  1288. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1289. $cdata = array_filter($qbdata, function ($item) {
  1290. return $item['state'] < 1;
  1291. });
  1292. $c = array_sum(array_column($cdata, 'jnum'));
  1293. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1294. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1295. });
  1296. $g = array_sum(array_column($gdata, 'jnum'));
  1297. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1298. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1299. });
  1300. $x = array_sum(array_column($xdata, 'jnum'));
  1301. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1302. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1303. });
  1304. $t = array_sum(array_column($tdata, 'jnum'));
  1305. $zdata = array_filter($qbdata, function ($item) {
  1306. return $item['zd'] != "" && $item['state'] < 1;
  1307. });
  1308. $z = array_sum(array_column($zdata, 'jnum'));
  1309. $zdata = array_filter($qbdata, function ($item) {
  1310. return $item['zd'] != "" && $item['state'] < 1;
  1311. });
  1312. $z = array_sum(array_column($zdata, 'jnum'));
  1313. //$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');
  1314. //$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'].'"');
  1315. //$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'].'"');
  1316. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1317. //$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'].'"');
  1318. $details = array();
  1319. $cpid = array();
  1320. $od = array();
  1321. $odid = '';
  1322. $companytitle = '';
  1323. foreach ($qbdata as $v) {
  1324. if ($v['zd'] != "" && $v['state'] < 1) {
  1325. if (!isset($od[$v['zd']])) {
  1326. $od[$v['zd']] = 1; //所有数据sku
  1327. } else {
  1328. $od[$v['zd']] = $od[$v['zd']] + 1;
  1329. }
  1330. }
  1331. if ($v['state'] < 1) {
  1332. $details[$v['details']] = $v['details'];
  1333. if ($v['cpid'] != 0) {
  1334. $cpid[$v['cpid']] = $v['cpid'];
  1335. }
  1336. }
  1337. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1338. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1339. }
  1340. }
  1341. foreach ($od as $k => $vv) {
  1342. $odid .= $k . '数量' . $vv;
  1343. }
  1344. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  1345. $number = $value['number'];
  1346. $ftime = time() - 15 * 24 * 3600;
  1347. $z = $z . '(' . $odid . ')'; //查看订单号
  1348. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1349. $info_list[$key]['features'] = $c;
  1350. $info_list[$key]['number'] = $ztdata;
  1351. $info_list[$key]['sm'] = $g;
  1352. $info_list[$key]['x'] = $x;
  1353. $info_list[$key]['t'] = $t;
  1354. $info_list[$key]['z'] = $z;
  1355. /**
  1356. foreach ($cdata as $k=>$v)
  1357. {
  1358. $details[$v['details']] = $v['details'];
  1359. if($v['cpid'] != 0)
  1360. {
  1361. $cpid[$v['cpid']] = $v['cpid'];
  1362. }
  1363. }
  1364. **/
  1365. $info_list[$key]['shop'] = '';
  1366. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1367. if ($value['shop'] != '') {
  1368. $shop = explode(',', trim($value['shop'], ','));
  1369. $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1370. }
  1371. $info_list[$key]['shop'] .= $companytitle;
  1372. /**
  1373. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1374. if(isset($companytitle[0]))
  1375. {
  1376. foreach ($companytitle as $k=>$v)
  1377. {
  1378. if($v['companytitle'] != '')
  1379. {
  1380. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1381. }
  1382. }
  1383. }
  1384. **/
  1385. }
  1386. $final_all_list = [];
  1387. foreach ($info_list as $k => $v) {
  1388. $final_all_list[] = [
  1389. 'id' => $v['id'],
  1390. "warehouse" => $v["warehouse"],
  1391. "purchase" => $v["purchase"],
  1392. "sku" => $v["sku"],
  1393. "title" => $v["title"] . "<br/>" . $v["pm"],
  1394. "details" => $v["details"],
  1395. "shop" => $v["shop"],
  1396. "cpbz" => $v["cpbz"],
  1397. "type" => $v["type"],
  1398. "features" => $v["features"],
  1399. "number" => $v["number"],
  1400. "sm" => $v["sm"],
  1401. "x" => $v["x"],
  1402. "t" => $v["t"],
  1403. "z" => $v["z"]
  1404. ];
  1405. }
  1406. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1407. $pagenum = ceil($total / $perpage);
  1408. $over = $total - ($start + $perpage);
  1409. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1410. echo json_encode($rows);
  1411. exit;
  1412. }
  1413. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1414. $this->data['shop'] = $wlshop;
  1415. $this->data['vip'] = $vip;
  1416. $this->_Template('whlabel_type', $this->data);
  1417. }
  1418. //美仓进销存浏览
  1419. public function _usatype()
  1420. {
  1421. if (isset($_SESSION['api'])) {
  1422. $user = $this->user->get_api($_SESSION['api']);
  1423. $usp = $user;
  1424. $fgshop = "";
  1425. $sid = "";
  1426. $wid = "";
  1427. $wtype = "";
  1428. $userwh = explode('|', trim($user['warehouse'], '|'));
  1429. foreach ($userwh as $value) {
  1430. $wid .= " id = " . $value . " or";
  1431. $wtype .= " type = " . $value . " or";
  1432. }
  1433. }
  1434. $prc = array();
  1435. $purchase = $this->purchase->find_all();
  1436. foreach ($purchase as $k => $v) {
  1437. $prc[$v['id']] = $v['title'];
  1438. }
  1439. $post = $this->input->post(NULL, TRUE);
  1440. if (isset($post['page'])) {
  1441. $page = $this->input->post('page', true);
  1442. $perpage = $this->input->post('perpage', true);
  1443. $category = $this->input->post('category', true);
  1444. $size = $this->input->post('size', true);
  1445. $grade = $this->input->post('grade', true);
  1446. $color = $this->input->post('color', true);
  1447. $lowe = $this->input->post('lowe', true);
  1448. $sku = $this->input->post('sku');
  1449. $title = $this->input->post('title');
  1450. $warehouse = $this->input->post('warehouse', true);
  1451. $usa = $this->input->post('usa', true);
  1452. $purchase = $this->input->post('purchase', true);
  1453. $lacetype = $this->input->post('lacetype', true);
  1454. $haircap = $this->input->post('haircap', true);
  1455. $density = $this->input->post('density', true);
  1456. $details = $this->input->post('details', true);
  1457. $state = $this->input->post('state', true);
  1458. $lacecolor = $this->input->post('lacecolor', true);
  1459. $cklx = $this->input->post('cklx', true);
  1460. $ktime = $this->input->post('ktime', true);
  1461. $jtime = $this->input->post('jtime', true);
  1462. $ktime = strtotime($ktime);
  1463. $jtime = strtotime($jtime);
  1464. $where = "1=1";
  1465. $gj = "";
  1466. $ck = "";
  1467. if ($lacetype) {
  1468. $where .= " and features like '%-$lacetype-%'";
  1469. }
  1470. if ($category) {
  1471. $where .= " and features like '%-$category-%'";
  1472. }
  1473. if ($size) {
  1474. $where .= " and features like '%-$size-%'";
  1475. }
  1476. if ($grade) {
  1477. $where .= " and features like '%-$grade-%'";
  1478. }
  1479. if ($color) {
  1480. $where .= " and features like '%-$color-%'";
  1481. }
  1482. if ($lowe) {
  1483. $where .= " and features like '%-$lowe-%'";
  1484. }
  1485. if ($haircap) {
  1486. $where .= " and features like '%-$haircap-%'";
  1487. }
  1488. if ($density) {
  1489. $where .= " and features like '%-$density-%'";
  1490. }
  1491. if ($lacecolor) {
  1492. $where .= " and features like '%-$lacecolor-%'";
  1493. }
  1494. if ($usa) {
  1495. if (!$warehouse) {
  1496. $where .= " and (warehouse = '5' or warehouse = '8')";
  1497. }
  1498. }
  1499. if ($warehouse) {
  1500. $where .= " and warehouse = '$warehouse'";
  1501. }
  1502. if ($details) {
  1503. $where .= " and details = '$details'";
  1504. }
  1505. if ($purchase) {
  1506. $where .= " and purchase = '$purchase'";
  1507. }
  1508. if ($state) {
  1509. $where .= " and state = '$state'";
  1510. }
  1511. $where_add = '';
  1512. if ($cklx) {
  1513. $shop = $this->shop->read($cklx);
  1514. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1515. }
  1516. if ($ktime && $jtime) {
  1517. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1518. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1519. }
  1520. //数据排序
  1521. $order_str = "id desc";
  1522. if (empty($page)) {
  1523. $start = 0;
  1524. $perpage = 1;
  1525. } else {
  1526. $start = ($page - 1) * $perpage;
  1527. }
  1528. if ($sku) {
  1529. $sku = trim($sku, ' ');
  1530. $sku = trim($sku, ' ');
  1531. $where .= " and sku like '%$sku%'";
  1532. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1533. } else if ($title) {
  1534. $title = trim($title, ' ');
  1535. $title = trim($title, ' ');
  1536. $where .= " and title like '%$title%'";
  1537. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1538. } else {
  1539. //$where .= " and time > '$ktime' and time < '$jtime'";
  1540. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1541. }
  1542. //取得信息列表
  1543. $rows = array();
  1544. $list = array();
  1545. foreach ($info_list as $key => $value) {
  1546. $warehouse = $this->warehouse->read($value['warehouse']);
  1547. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1548. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1549. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1550. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1551. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1552. $od = array();
  1553. $odid = '';
  1554. foreach ($z as $v) {
  1555. if (!isset($od[$v['zd']])) {
  1556. $od[$v['zd']] = 1; //所有数据sku
  1557. } else {
  1558. $od[$v['zd']] = $od[$v['zd']] + 1;
  1559. }
  1560. }
  1561. foreach ($od as $k => $vv) {
  1562. $odid .= $k . '数量' . $vv . ' ';
  1563. }
  1564. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1565. $info_list[$key]['features'] = $c;
  1566. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1567. $ztdata = '';
  1568. if (count($zt) > 0) {
  1569. foreach ($zt as $vv) {
  1570. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1571. }
  1572. }
  1573. $info_list[$key]['warehouse'] = $ztdata;
  1574. $info_list[$key]['g'] = $g;
  1575. $info_list[$key]['x'] = $x;
  1576. $info_list[$key]['t'] = $t;
  1577. $info_list[$key]['z'] = $z;
  1578. }
  1579. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1580. $pagenum = ceil($total / $perpage);
  1581. $over = $total - ($start + $perpage);
  1582. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1583. echo json_encode($rows);
  1584. exit;
  1585. }
  1586. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1587. $this->data['warehouse'] = $warehouse;
  1588. $this->_Template('whlabel_typeusa', $this->data);
  1589. }
  1590. //美仓进销存浏览
  1591. public function _usatypeapp()
  1592. {
  1593. $post = $this->input->post(NULL, TRUE);
  1594. if (isset($post['page'])) {
  1595. $page = $this->input->post('page', true);
  1596. $perpage = $this->input->post('perpage', true);
  1597. $sku = $this->input->post('sku', true);
  1598. $warehouse = 5;
  1599. $title = $this->input->post('title', true);
  1600. $state = $this->input->post('state', true);
  1601. $ktime = $this->input->post('ktime', true);
  1602. $jtime = $this->input->post('jtime', true);
  1603. $ktime = strtotime($ktime);
  1604. $jtime = strtotime($jtime);
  1605. $where = "1=1";
  1606. $gj = "";
  1607. $ck = "";
  1608. if ($title) {
  1609. $st = explode(' ', trim($title, ' '));
  1610. foreach ($st as $v) {
  1611. $where .= " and title like '%$v%'";
  1612. }
  1613. }
  1614. if ($warehouse) {
  1615. $where .= " and warehouse = '$warehouse'";
  1616. }
  1617. if ($state) {
  1618. $where .= " and state = '$state'";
  1619. }
  1620. if ($sku) {
  1621. $where .= " and sku like '%$sku%'";
  1622. }
  1623. if ($ktime && $jtime) {
  1624. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1625. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1626. }
  1627. //数据排序
  1628. $order_str = "id desc";
  1629. if (empty($page)) {
  1630. $start = 0;
  1631. $perpage = 1;
  1632. } else {
  1633. $start = ($page - 1) * $perpage;
  1634. }
  1635. //取得信息列表
  1636. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1637. $rows = array();
  1638. $list = array();
  1639. foreach ($info_list as $key => $value) {
  1640. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1641. }
  1642. $rowsdq = array_slice($rows, $start, $perpage);
  1643. foreach ($rowsdq as $value) {
  1644. $warehouse = $this->warehouse->read($value['warehouse']);
  1645. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1646. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1647. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1648. $od = array();
  1649. $odid = '';
  1650. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1651. }
  1652. $total = count($rows);
  1653. $pagenum = ceil($total / $perpage);
  1654. $over = $total - ($start + $perpage);
  1655. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1656. echo json_encode($rows);
  1657. exit;
  1658. }
  1659. $this->_Template('phone/p_usatypeapp', $this->data);
  1660. }
  1661. //入库操作
  1662. public function _enteradd()
  1663. {
  1664. $dt = 0;
  1665. if (isset($_SESSION['api'])) {
  1666. $user = $this->user->get_api($_SESSION['api']);
  1667. $usp = $user;
  1668. $fgshop = "";
  1669. $sid = "";
  1670. $user = explode('|', trim($user['shop'], '|'));
  1671. foreach ($user as $value) {
  1672. $fgshop .= " shop = " . $value . " or";
  1673. $sid .= " id = " . $value . " or";
  1674. }
  1675. }
  1676. $tc = $this->typeclass->find_all();
  1677. $typeclass = array();
  1678. foreach ($tc as $v) {
  1679. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1680. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1681. }
  1682. $post = $this->input->post(NULL, TRUE);
  1683. if (isset($post['sku'])) {
  1684. $list = array();
  1685. $num = "";
  1686. $title = "";
  1687. $features = "";
  1688. $order = $this->input->post('order', true);
  1689. $shop = $this->input->post('shop', true);
  1690. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1691. $sku = $this->input->post('sku', true);
  1692. $post['sm'] = $this->input->post('sm', true);
  1693. $post['warehouse'] = $this->input->post('warehouse', true);
  1694. $post['purchase'] = $this->input->post('purchase', true);
  1695. $post['retreatwarehouse'] = $post['warehouse'];
  1696. $post['state'] = $this->input->post('state', true);
  1697. $post['rktype'] = $this->input->post('rktype', true);
  1698. $post['text'] = $this->input->post('text', true);
  1699. $category = $this->input->post('category', true);
  1700. $list['category'] = $category;
  1701. $list['hairtype'] = $this->input->post('hairtype', true);
  1702. $list['grade'] = $this->input->post('grade', true);
  1703. $size = $this->input->post('size', true);
  1704. $xzsku = $this->input->post('xzsku', true);
  1705. $list['size'] = rtrim($size, ',');
  1706. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1707. $list['extension'] = $this->input->post('extension', true);
  1708. if ($category == 1297) {
  1709. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1710. }
  1711. if ($category == 1702) {
  1712. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1713. $list['syother'] = $this->input->post('syother', true);
  1714. }
  1715. if ($category == 133) {
  1716. $list['fittype'] = $this->input->post('fittype', true);
  1717. $list['acother'] = $this->input->post('acother', true);
  1718. }
  1719. $list['color'] = $this->input->post('color', true);
  1720. $list['lowe'] = $this->input->post('lowe', true);
  1721. if (!$post['purchase']) {
  1722. $post['purchase'] = 1;
  1723. }
  1724. if ($category == 127) {
  1725. $list['type'] = $this->input->post('type', true);
  1726. $list['headroad'] = $this->input->post('headroad', true);
  1727. $list['density'] = $this->input->post('density', true);
  1728. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1729. $list['lacesize'] = $this->input->post('lacesize', true);
  1730. }
  1731. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1732. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1733. }
  1734. if ($category == 128) {
  1735. $list['lacetype'] = $this->input->post('lacetype', true);
  1736. $list['haircap'] = $this->input->post('haircap', true);
  1737. $list['density'] = $this->input->post('density', true);
  1738. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1739. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1740. $list['wigother'] = $this->input->post('wigother', true);
  1741. $list['wigother1'] = $this->input->post('wigother1', true);
  1742. $list['wigother2'] = $this->input->post('wigother2', true);
  1743. }
  1744. if ($category == 129) {
  1745. $list['wide'] = $this->input->post('wide', true);
  1746. }
  1747. if ($category == 131) {
  1748. $list['gifttype'] = $this->input->post('gifttype', true);
  1749. $list['giftother'] = $this->input->post('giftother', true);
  1750. }
  1751. if ($category == 134) {
  1752. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1753. }
  1754. if ($category == 1297) {
  1755. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1756. $list['sywigother'] = $this->input->post('sywigother', true);
  1757. }
  1758. if ($category == 130 || $category == 133 || $category == 1702) {
  1759. $list['items'] = $this->input->post('items', true);
  1760. $list['weight'] = $this->input->post('weight', true);
  1761. }
  1762. if ($category == 1702) {
  1763. $list['syhairther'] = $this->input->post('syhairther', true);
  1764. }
  1765. $classid = $this->classid->sku();
  1766. $scsku = $classid;
  1767. $pm = $classid;
  1768. foreach ($list as $k => $v) {
  1769. if ($v != 0) {
  1770. $num .= $v;
  1771. $features .= $v . '-';
  1772. $post[$k] = $v;
  1773. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1774. if ($k != 'size') {
  1775. $title .= $typeclass[$v]['title'] . " ";
  1776. }
  1777. if (isset($pm[$typeclass[$v]['classid']])) {
  1778. if ($typeclass[$v]['title'] == '9A') {
  1779. $pm[$typeclass[$v]['classid']] = '9A';
  1780. } else if ($typeclass[$v]['title'] == '10A') {
  1781. $pm[$typeclass[$v]['classid']] = '10A';
  1782. } else {
  1783. $clzh = $typeclass[$v]['zh'];
  1784. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1785. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1786. $clzh = $clzh[0];
  1787. }
  1788. $pm[$typeclass[$v]['classid']] = $clzh;
  1789. }
  1790. }
  1791. }
  1792. }
  1793. $zh = implode(" ", $pm);
  1794. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1795. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1796. if ($list['size']) {
  1797. $typeclass = $this->typeclass->read($list['size']);
  1798. $title .= $typeclass['title'];
  1799. }
  1800. $time = time();
  1801. if ($xzsku) {
  1802. $scsku = implode("-", $scsku);
  1803. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1804. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1805. $post['sku'] = trim($scsku, ' ');
  1806. } else {
  1807. $post['sku'] = $sku;
  1808. }
  1809. //$post['sku'] = trim($sku,' ');
  1810. $post['title'] = rtrim($title, ' ');
  1811. $post['number'] = $num;
  1812. $post['features'] = '-' . $features;
  1813. $post['enter'] = $time;
  1814. $post['time'] = $time; //操作时间
  1815. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1816. if ($yza) {
  1817. if ($post['features'] != $yza[0]['features']) {
  1818. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1819. exit;
  1820. }
  1821. }
  1822. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1823. if ($yzb) {
  1824. if ($post['sku'] != $yzb[0]['sku']) {
  1825. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1826. exit;
  1827. }
  1828. }
  1829. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1830. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1831. exit;
  1832. }
  1833. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1834. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1835. exit;
  1836. }
  1837. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1838. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1839. exit;
  1840. }
  1841. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1842. if (isset($yz[0]['type'])) {
  1843. $post['type'] = $yz[0]['type'];
  1844. }
  1845. if ($post['state'] == 9) //如果选择预设库存
  1846. {
  1847. $this->whlabel->insert($post);
  1848. } else {
  1849. /**
  1850. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1851. if($ljg == 1)
  1852. {
  1853. for($i=0;$i<$order;$i++)
  1854. {
  1855. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1856. $this->whlabel->insert($post);
  1857. }
  1858. }
  1859. **/
  1860. //if($post['warehouse'] == '5')
  1861. //{
  1862. //}
  1863. $yydata = $post;
  1864. $yydata['zh'] = $zh;
  1865. /**
  1866. $wl = $this->apiyy->get_cjlp($yydata);
  1867. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1868. {
  1869. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1870. }
  1871. if($wl['Data'][0]['m_isSucess'] != 1)
  1872. {
  1873. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1874. }
  1875. **/
  1876. for ($i = 0; $i < $order; $i++) {
  1877. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1878. $this->whlabel->insert($post);
  1879. }
  1880. }
  1881. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1882. exit;
  1883. }
  1884. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1885. $this->data['wlshop'] = $wlshop;
  1886. $this->_Template('whlabel_enteradd', $this->data);
  1887. }
  1888. //修改产品
  1889. public function _enteredit($arg_array)
  1890. {
  1891. $dt = 0;
  1892. if (isset($_SESSION['api'])) {
  1893. $user = $this->user->get_api($_SESSION['api']);
  1894. $usp = $user;
  1895. $fgshop = "";
  1896. $sid = "";
  1897. $user = explode('|', trim($user['shop'], '|'));
  1898. foreach ($user as $value) {
  1899. $fgshop .= " shop = " . $value . " or";
  1900. $sid .= " id = " . $value . " or";
  1901. }
  1902. }
  1903. $post = $this->input->post(NULL, TRUE);
  1904. if (isset($post['sku'])) {
  1905. $list = array();
  1906. $num = "";
  1907. $title = "";
  1908. $features = "";
  1909. $id = $this->input->post('id', true);
  1910. $order = $this->input->post('order', true);
  1911. $shop = $this->input->post('shop', true);
  1912. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1913. $post['sku'] = $this->input->post('sku', true);
  1914. $post['sm'] = $this->input->post('sm', true);
  1915. $post['warehouse'] = $this->input->post('warehouse', true);
  1916. $post['purchase'] = $this->input->post('purchase', true);
  1917. $post['retreatwarehouse'] = $post['warehouse'];
  1918. $category = $this->input->post('category', true);
  1919. $list['category'] = $category;
  1920. $list['hairtype'] = $this->input->post('hairtype', true);
  1921. $list['grade'] = $this->input->post('grade', true);
  1922. $size = $this->input->post('size', true);
  1923. $list['size'] = rtrim($size, ',');
  1924. $post['rktype'] = $this->input->post('rktype', true);
  1925. $post['text'] = $this->input->post('text', true);
  1926. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1927. $list['extension'] = $this->input->post('extension', true);
  1928. if ($category == 1297) {
  1929. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1930. }
  1931. if ($category == 1702) {
  1932. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1933. $list['syother'] = $this->input->post('syother', true);
  1934. }
  1935. if ($category == 133) {
  1936. $list['fittype'] = $this->input->post('fittype', true);
  1937. $list['acother'] = $this->input->post('acother', true);
  1938. }
  1939. $list['color'] = $this->input->post('color', true);
  1940. $list['lowe'] = $this->input->post('lowe', true);
  1941. if (!$post['purchase']) {
  1942. $post['purchase'] = 1;
  1943. }
  1944. if ($category == 127) {
  1945. $list['type'] = $this->input->post('type', true);
  1946. $list['headroad'] = $this->input->post('headroad', true);
  1947. $list['density'] = $this->input->post('density', true);
  1948. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1949. $list['lacesize'] = $this->input->post('lacesize', true);
  1950. }
  1951. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1952. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1953. }
  1954. if ($category == 128) {
  1955. $list['lacetype'] = $this->input->post('lacetype', true);
  1956. $list['haircap'] = $this->input->post('haircap', true);
  1957. $list['density'] = $this->input->post('density', true);
  1958. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1959. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1960. $list['wigother'] = $this->input->post('wigother', true);
  1961. $list['wigother1'] = $this->input->post('wigother2', true);
  1962. $list['wigother2'] = $this->input->post('wigother2', true);
  1963. }
  1964. if ($category == 129) {
  1965. $list['wide'] = $this->input->post('wide', true);
  1966. }
  1967. if ($category == 131) {
  1968. $list['gifttype'] = $this->input->post('gifttype', true);
  1969. $list['giftother'] = $this->input->post('giftother', true);
  1970. }
  1971. if ($category == 134) {
  1972. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1973. }
  1974. if ($category == 1297) {
  1975. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1976. $list['sywigother'] = $this->input->post('sywigother', true);
  1977. }
  1978. if ($category == 130 || $category == 133 || $category == 1702) {
  1979. $list['items'] = $this->input->post('items', true);
  1980. $list['weight'] = $this->input->post('weight', true);
  1981. }
  1982. if ($category == 1702) {
  1983. $list['syhairther'] = $this->input->post('syhairther', true);
  1984. }
  1985. foreach ($list as $k => $v) {
  1986. if ($v != 0) {
  1987. $num .= $v;
  1988. $features .= $v . '-';
  1989. $typeclass = $this->typeclass->read($v);
  1990. if ($k != 'size') {
  1991. $title .= $typeclass['title'] . " ";
  1992. }
  1993. }
  1994. }
  1995. $typeclass = $this->typeclass->read($list['size']);
  1996. $title .= $typeclass['title'];
  1997. $time = time();
  1998. $post['title'] = rtrim($title, ' ');
  1999. $post['number'] = $num;
  2000. $post['features'] = '-' . $features;
  2001. $post['time'] = $time; //操作时间
  2002. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2003. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2004. exit;
  2005. }
  2006. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2007. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2008. exit;
  2009. }
  2010. $uid = $this->whlabel->read($id);
  2011. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2012. if ($datanum > 0) {
  2013. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2014. exit;
  2015. }
  2016. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2017. {
  2018. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2019. if ($yza) {
  2020. if ($post['features'] != $yza[0]['features']) {
  2021. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2022. exit;
  2023. }
  2024. }
  2025. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2026. if ($yzb) {
  2027. if ($post['sku'] != $yzb[0]['sku']) {
  2028. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2029. exit;
  2030. }
  2031. }
  2032. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2033. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2034. exit;
  2035. }
  2036. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2037. foreach ($data as $v) {
  2038. $post['id'] = $v['id'];
  2039. $this->whlabel->save($post, $v['id']);
  2040. }
  2041. } else {
  2042. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2043. if ($data > 0) {
  2044. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2045. exit;
  2046. } else {
  2047. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2048. foreach ($data as $v) {
  2049. $post['id'] = $v['id'];
  2050. $this->whlabel->save($post, $v['id']);
  2051. }
  2052. }
  2053. }
  2054. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2055. exit;
  2056. }
  2057. $uid = $this->whlabel->read($arg_array[0]);
  2058. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2059. $this->data['enter'] = $uid;
  2060. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2061. $this->data['wlshop'] = $wlshop;
  2062. $this->_Template('whlabel_enteredit', $this->data);
  2063. }
  2064. //入库浏览
  2065. public function _enter()
  2066. {
  2067. $post = $this->input->post(NULL, TRUE);
  2068. if (isset($post['s'])) {
  2069. $id_arr = $this->input->post('s');
  2070. $id_arr = explode(',', $id_arr);
  2071. if (!$id_arr) {
  2072. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2073. exit;
  2074. }
  2075. //循环删除记录
  2076. foreach ($id_arr as $v) {
  2077. $sid = $this->whlabel->read($v);
  2078. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2079. if ($count > 0) {
  2080. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2081. exit;
  2082. }
  2083. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2084. foreach ($info_list as $va) {
  2085. $this->whlabel->remove($va['id']);
  2086. }
  2087. }
  2088. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2089. exit;
  2090. }
  2091. $sp = array();
  2092. $s = $this->shop->find_all('1=1', 'id,shopname');
  2093. foreach ($s as $v) {
  2094. $sp[$v['id']] = $v['shopname'];
  2095. }
  2096. $wh = array();
  2097. $w = $this->warehouse->find_all('1=1', 'id,title');
  2098. foreach ($w as $v) {
  2099. $wh[$v['id']] = $v['title'];
  2100. }
  2101. if (isset($post['page'])) {
  2102. $page = $this->input->post('page', true);
  2103. $perpage = $this->input->post('perpage', true);
  2104. $category = $this->input->post('category', true);
  2105. $size = $this->input->post('size', true);
  2106. $grade = $this->input->post('grade', true);
  2107. $color = $this->input->post('color', true);
  2108. $lowe = $this->input->post('lowe', true);
  2109. $sku = $this->input->post('sku', true);
  2110. $warehouse = $this->input->post('warehouse', true);
  2111. $purchase = $this->input->post('purchase', true);
  2112. $ktime = $this->input->post('ktime', true);
  2113. $jtime = $this->input->post('jtime', true);
  2114. $ktime = strtotime($ktime);
  2115. $jtime = strtotime($jtime);
  2116. $where = "1=1";
  2117. $gj = "";
  2118. $ck = "";
  2119. if ($category) {
  2120. $where .= " and features like '%-$category-%'";
  2121. }
  2122. if ($size) {
  2123. $where .= " and features like '%-$size-%'";
  2124. }
  2125. if ($grade) {
  2126. $where .= " and features like '%-$grade-%'";
  2127. }
  2128. if ($color) {
  2129. $where .= " and features like '%-$color-%'";
  2130. }
  2131. if ($lowe) {
  2132. $where .= " and features like '%-$lowe-%'";
  2133. }
  2134. if ($warehouse) {
  2135. $where .= " and warehouse = '$warehouse'";
  2136. }
  2137. if ($purchase) {
  2138. $where .= " and purchase = '$purchase'";
  2139. }
  2140. if ($sku) {
  2141. $where .= " and sku like '%$sku%'";
  2142. }
  2143. if ($ktime && $jtime) {
  2144. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2145. }
  2146. //数据排序
  2147. $order_str = "enter desc";
  2148. if (empty($page)) {
  2149. $start = 0;
  2150. $perpage = 1;
  2151. } else {
  2152. $start = ($page - 1) * $perpage;
  2153. }
  2154. //取得信息列表
  2155. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2156. foreach ($info_list as $k => $v) {
  2157. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2158. if ($v['shop'] == '') {
  2159. $s = '通用';
  2160. } else {
  2161. $info_list[$k]['shop'] = '';
  2162. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2163. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2164. }
  2165. }
  2166. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2167. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2168. $info_list[$k]['g'] = $g;
  2169. }
  2170. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2171. $pagenum = ceil($total / $perpage);
  2172. $over = $total - ($start + $perpage);
  2173. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2174. echo json_encode($rows);
  2175. exit;
  2176. }
  2177. $this->_Template('whlabel_enter', $this->data);
  2178. }
  2179. //出库浏览
  2180. public function _out()
  2181. {
  2182. $post = $this->input->post(NULL, TRUE);
  2183. if (isset($post['page'])) {
  2184. $page = $this->input->post('page', true);
  2185. $perpage = $this->input->post('perpage', true);
  2186. $category = $this->input->post('category', true);
  2187. $size = $this->input->post('size', true);
  2188. $grade = $this->input->post('grade', true);
  2189. $color = $this->input->post('color', true);
  2190. $lowe = $this->input->post('lowe', true);
  2191. $sku = $this->input->post('sku', true);
  2192. $warehouse = $this->input->post('warehouse', true);
  2193. $purchase = $this->input->post('purchase', true);
  2194. $state = $this->input->post('state', true);
  2195. $ktime = $this->input->post('ktime', true);
  2196. $jtime = $this->input->post('jtime', true);
  2197. $ktime = strtotime($ktime);
  2198. $jtime = strtotime($jtime);
  2199. $where = "state=3";
  2200. $gj = "";
  2201. $ck = "";
  2202. if ($category) {
  2203. $where .= " and features like '%-$category-%'";
  2204. }
  2205. if ($size) {
  2206. $where .= " and features like '%-$size-%'";
  2207. }
  2208. if ($grade) {
  2209. $where .= " and features like '%-$grade-%'";
  2210. }
  2211. if ($color) {
  2212. $where .= " and features like '%-$color-%'";
  2213. }
  2214. if ($lowe) {
  2215. $where .= " and features like '%-$lowe-%'";
  2216. }
  2217. if ($state) {
  2218. $where .= " and state = '$state'";
  2219. }
  2220. if ($warehouse) {
  2221. $where .= " and warehouse = '$warehouse'";
  2222. }
  2223. if ($purchase) {
  2224. $where .= " and purchase = '$purchase'";
  2225. }
  2226. if ($sku) {
  2227. $where .= " and sku = '$sku'";
  2228. }
  2229. if ($ktime && $jtime) {
  2230. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2231. }
  2232. //数据排序
  2233. $order_str = "id desc";
  2234. if (empty($page)) {
  2235. $start = 0;
  2236. $perpage = 1;
  2237. } else {
  2238. $start = ($page - 1) * $perpage;
  2239. }
  2240. //取得信息列表
  2241. $info_list = $this->whlabel->find_all($where, 'sku');
  2242. $rows = array();
  2243. $list = array();
  2244. foreach ($info_list as $key => $value) {
  2245. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2246. }
  2247. $rows = array_unique($rows); //删除重复记录
  2248. foreach ($rows as $key => $value) {
  2249. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2250. $ck = $this->warehouse->read($data['warehouse']);
  2251. $warehouse = $ck['title'];
  2252. $gy = $this->purchase->read($data['purchase']);
  2253. $purchase = $gy['purchase'];
  2254. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2255. $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);
  2256. }
  2257. $total = count($list);
  2258. $pagenum = ceil($total / $perpage);
  2259. $over = $total - ($start + $perpage);
  2260. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2261. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2262. echo json_encode($rows);
  2263. exit;
  2264. }
  2265. $this->_Template('whlabel_out', $this->data);
  2266. }
  2267. //出库标签浏览
  2268. public function _label()
  2269. {
  2270. $post = $this->input->post(NULL, TRUE);
  2271. if (isset($post['page'])) {
  2272. $page = $this->input->post('page', true);
  2273. $perpage = $this->input->post('perpage', true);
  2274. $sku = $this->input->post('sku', true);
  2275. $warehouse = $this->input->post('warehouse', true);
  2276. $purchase = $this->input->post('purchase', true);
  2277. $orderinfo = $this->input->post('orderinfo', true);
  2278. $waybill = $this->input->post('waybill', true);
  2279. $category = $this->input->post('category', true);
  2280. $size = $this->input->post('size', true);
  2281. $grade = $this->input->post('grade', true);
  2282. $color = $this->input->post('color', true);
  2283. $lowe = $this->input->post('lowe', true);
  2284. $where = "state=1";
  2285. if ($sku) {
  2286. $where .= " and sku = '$sku'";
  2287. }
  2288. if ($warehouse) {
  2289. $where .= " and warehouse = '$warehouse'";
  2290. }
  2291. if ($purchase) {
  2292. $where .= " and purchase = '$purchase'";
  2293. }
  2294. if ($orderinfo) {
  2295. $where .= " and orderinfo = '$orderinfo'";
  2296. }
  2297. if ($waybill) {
  2298. $where .= " and waybill = '$waybill'";
  2299. }
  2300. if ($category) {
  2301. $where .= " and features like '%-$category-%'";
  2302. }
  2303. if ($size) {
  2304. $where .= " and features like '%-$size-%'";
  2305. }
  2306. if ($grade) {
  2307. $where .= " and features like '%-$grade-%'";
  2308. }
  2309. if ($color) {
  2310. $where .= " and features like '%-$color-%'";
  2311. }
  2312. if ($lowe) {
  2313. $where .= " and features like '%-$lowe-%'";
  2314. }
  2315. //数据排序
  2316. $order_str = "outk desc";
  2317. if (empty($page)) {
  2318. $start = 0;
  2319. $perpage = 1;
  2320. } else {
  2321. $start = ($page - 1) * $perpage;
  2322. }
  2323. //取得信息列表
  2324. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2325. foreach ($info_list as $key => $value) {
  2326. $warehouse = $this->warehouse->read($value['warehouse']);
  2327. $info_list[$key]['warehouse'] = $warehouse['title'];
  2328. $purchase = $this->purchase->read($value['purchase']);
  2329. $info_list[$key]['purchase'] = $purchase['title'];
  2330. if ($value['outk'] != 0) {
  2331. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2332. } else {
  2333. $info_list[$key]['outk'] = "";
  2334. }
  2335. if ($value['orderinfo'] == 0) {
  2336. $info_list[$key]['orderinfo'] = "";
  2337. }
  2338. if ($value['waybill'] == 0) {
  2339. $info_list[$key]['waybill'] = "";
  2340. }
  2341. }
  2342. $total = $this->whlabel->find_count($where);
  2343. $pagenum = ceil($total / $perpage);
  2344. $over = $total - ($start + $perpage);
  2345. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2346. echo json_encode($rows);
  2347. exit;
  2348. }
  2349. $this->_Template('whlabel_label', $this->data);
  2350. }
  2351. //独立站出库订单
  2352. public function _outorder()
  2353. {
  2354. if (isset($_SESSION['api'])) {
  2355. $user = $this->user->get_api($_SESSION['api']);
  2356. $usp = $user;
  2357. $fgshop = "";
  2358. $sid = "";
  2359. $user = explode('|', trim($user['shop'], '|'));
  2360. foreach ($user as $value) {
  2361. $fgshop .= " shop = " . $value . " or";
  2362. $sid .= " id = " . $value . " or";
  2363. }
  2364. } else {
  2365. echo "请重新登录";
  2366. }
  2367. $post = $this->input->post(NULL, TRUE);
  2368. if (isset($post['page'])) {
  2369. $page = $this->input->post('page', true);
  2370. $perpage = $this->input->post('perpage', true);
  2371. $warehouse = $this->input->post('warehouse', true);
  2372. $xztime = $this->input->post('xztime', true);
  2373. $timetk = $this->input->post('timetkk', true);
  2374. $timetj = $this->input->post('timetjj', true);
  2375. $shop = $this->input->post('shop', true);
  2376. $source = $this->input->post('source', true);
  2377. $orderinfo = $this->input->post('orderinfo', true);
  2378. $number = $this->input->post('number', true);
  2379. $sfxh = $this->input->post('sfxh', true);
  2380. $express = $this->input->post('express', true);
  2381. $waybill = $this->input->post('waybill', true);
  2382. $library = $this->input->post('library', true);
  2383. $country = $this->input->post('country', true);
  2384. $so = $this->input->post('so', true);
  2385. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2386. $print = $this->input->post('print', true);
  2387. $state = $this->input->post('state', true);
  2388. $orderurl = $this->input->post('orderurl', true);
  2389. $timetk = strtotime($timetk);
  2390. $timetj = strtotime($timetj);
  2391. /**
  2392. $sj = $this->input->post('sj',true);
  2393. if($sj)
  2394. {
  2395. $sj = $this->input->post('sj',true);
  2396. }
  2397. else
  2398. {
  2399. $sj = "fullorder";
  2400. }
  2401. **/
  2402. $sj = "fullorder";
  2403. $where = "1=1";
  2404. if ($warehouse) {
  2405. $where .= " and type = '$warehouse'";
  2406. }
  2407. if ($timetk && $timetj) {
  2408. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2409. }
  2410. if ($orderinfo) {
  2411. $where .= " and orderinfo = '$orderinfo'";
  2412. }
  2413. if ($number) {
  2414. $where .= " and number = '$number'";
  2415. }
  2416. if ($express) {
  2417. $where .= " and express = '$express'";
  2418. }
  2419. if ($waybill) {
  2420. $where .= " and waybill = '$waybill'";
  2421. }
  2422. if ($library) {
  2423. $where .= " and library = '$library'";
  2424. }
  2425. if ($print) {
  2426. $where .= " and print = '$print'";
  2427. }
  2428. if ($libraryconfirm) {
  2429. $where .= " and libraryconfirm = '$libraryconfirm'";
  2430. }
  2431. if ($state) {
  2432. $where .= " and state = '$state'";
  2433. }
  2434. if ($shop) {
  2435. $where .= " and shop = '$shop'";
  2436. }
  2437. if ($country) {
  2438. $where .= " and country = '$country'";
  2439. }
  2440. if ($sfxh != '') {
  2441. $where .= " and sfxh = '$sfxh'";
  2442. }
  2443. if ($so) {
  2444. $where .= " and shipremarks like '%$so%'";
  2445. }
  2446. if ($source) {
  2447. if ($source == '2d') {
  2448. $where .= " and source >= '2'";
  2449. } else {
  2450. $where .= " and source = '$source'";
  2451. }
  2452. }
  2453. if (isset($_SESSION['api'])) {
  2454. foreach ($user as $value) {
  2455. $fgshop .= " shop = " . $value . " or";
  2456. }
  2457. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2458. }
  2459. if ($orderurl) {
  2460. $url = $this->orderurl->read($orderurl);
  2461. $where .= " and link like '%" . $url['url'] . "%'";
  2462. }
  2463. //数据排序
  2464. $order_str = "librarytime desc";
  2465. if (empty($page)) {
  2466. $start = 0;
  2467. $perpage = 1;
  2468. } else {
  2469. $start = ($page - 1) * $perpage;
  2470. }
  2471. //取得信息列表
  2472. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2473. //格式化数据
  2474. foreach ($info_list as $key => $value) {
  2475. $shop = $this->shop->read($value['shop']);
  2476. $info_list[$key]['shop'] = $shop['shopname'];
  2477. $express = $this->express->read($value['express']);
  2478. $info_list[$key]['express'] = $express['servicename'];
  2479. $warehouse = $this->warehouse->read($value['type']);
  2480. $info_list[$key]['type'] = $warehouse['title'];
  2481. if ($value['librarytime'] == '0') {
  2482. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2483. } else {
  2484. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2485. }
  2486. }
  2487. $total = $this->$sj->find_count($where);
  2488. $pagenum = ceil($total / $perpage);
  2489. $over = $total - ($start + $perpage);
  2490. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2491. echo json_encode($rows);
  2492. exit;
  2493. }
  2494. $this->data['express'] = $this->express->find_all();
  2495. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2496. $this->data['wlshop'] = $wlshop;
  2497. $user = $this->user->get_api($_SESSION['api']);
  2498. $powerid = $this->power->read($user['power']);
  2499. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2500. $pid = '';
  2501. foreach ($powertext as $v) {
  2502. $pid .= " id = " . $v . " or";
  2503. }
  2504. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2505. $this->data['fullorderexcel'] = $fullorderexcel;
  2506. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2507. $this->data['orderurl'] = $orderurl;
  2508. $this->_Template('whlabel_outorder', $this->data);
  2509. }
  2510. //tt出库
  2511. public function _toutorder()
  2512. {
  2513. if (isset($_SESSION['api'])) {
  2514. $user = $this->user->get_api($_SESSION['api']);
  2515. $usp = $user;
  2516. $fgshop = "";
  2517. $sid = "";
  2518. $user = explode('|', trim($user['shop'], '|'));
  2519. foreach ($user as $value) {
  2520. $fgshop .= " shop = " . $value . " or";
  2521. $sid .= " id = " . $value . " or";
  2522. }
  2523. } else {
  2524. echo "请重新登录";
  2525. }
  2526. $post = $this->input->post(NULL, TRUE);
  2527. if (isset($post['page'])) {
  2528. $page = $this->input->post('page', true);
  2529. $perpage = $this->input->post('perpage', true);
  2530. $warehouse = $this->input->post('warehouse', true);
  2531. $xztime = $this->input->post('xztime', true);
  2532. $timetk = $this->input->post('timetkk', true);
  2533. $timetj = $this->input->post('timetjj', true);
  2534. $shop = $this->input->post('shop', true);
  2535. $source = $this->input->post('source', true);
  2536. $orderinfo = $this->input->post('orderinfo', true);
  2537. $number = $this->input->post('number', true);
  2538. $sfxh = $this->input->post('sfxh', true);
  2539. $express = $this->input->post('express', true);
  2540. $waybill = $this->input->post('waybill', true);
  2541. $library = $this->input->post('library', true);
  2542. $country = $this->input->post('country', true);
  2543. $so = $this->input->post('so', true);
  2544. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2545. $print = $this->input->post('print', true);
  2546. $state = $this->input->post('state', true);
  2547. $orderurl = $this->input->post('orderurl', true);
  2548. $timetk = strtotime($timetk);
  2549. $timetj = strtotime($timetj);
  2550. /**
  2551. $sj = $this->input->post('sj',true);
  2552. if($sj)
  2553. {
  2554. $sj = $this->input->post('sj',true);
  2555. }
  2556. else
  2557. {
  2558. $sj = "fullorder";
  2559. }
  2560. **/
  2561. $sj = "fullordertt";
  2562. $where = "1=1";
  2563. if ($warehouse) {
  2564. $where .= " and type = '$warehouse'";
  2565. }
  2566. if ($timetk && $timetj) {
  2567. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2568. }
  2569. if ($orderinfo) {
  2570. $where .= " and orderinfo = '$orderinfo'";
  2571. }
  2572. if ($number) {
  2573. $where .= " and number = '$number'";
  2574. }
  2575. if ($express) {
  2576. $where .= " and express = '$express'";
  2577. }
  2578. if ($waybill) {
  2579. $where .= " and waybill = '$waybill'";
  2580. }
  2581. if ($library) {
  2582. $where .= " and library = '$library'";
  2583. }
  2584. if ($print) {
  2585. $where .= " and print = '$print'";
  2586. }
  2587. if ($libraryconfirm) {
  2588. $where .= " and libraryconfirm = '$libraryconfirm'";
  2589. }
  2590. if ($state) {
  2591. $where .= " and state = '$state'";
  2592. }
  2593. if ($shop) {
  2594. $where .= " and shop = '$shop'";
  2595. }
  2596. if ($country) {
  2597. $where .= " and country = '$country'";
  2598. }
  2599. if ($sfxh != '') {
  2600. $where .= " and sfxh = '$sfxh'";
  2601. }
  2602. if ($so) {
  2603. $where .= " and shipremarks like '%$so%'";
  2604. }
  2605. if ($source) {
  2606. if ($source == '2d') {
  2607. $where .= " and source >= '2'";
  2608. } else {
  2609. $where .= " and source = '$source'";
  2610. }
  2611. }
  2612. if (isset($_SESSION['api'])) {
  2613. foreach ($user as $value) {
  2614. $fgshop .= " shop = " . $value . " or";
  2615. }
  2616. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2617. }
  2618. if ($orderurl) {
  2619. $url = $this->orderurl->read($orderurl);
  2620. $where .= " and link like '%" . $url['url'] . "%'";
  2621. }
  2622. //数据排序
  2623. $order_str = "librarytime desc";
  2624. if (empty($page)) {
  2625. $start = 0;
  2626. $perpage = 1;
  2627. } else {
  2628. $start = ($page - 1) * $perpage;
  2629. }
  2630. //取得信息列表
  2631. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2632. //格式化数据
  2633. foreach ($info_list as $key => $value) {
  2634. $shop = $this->shop->read($value['shop']);
  2635. $info_list[$key]['shop'] = $shop['shopname'];
  2636. $express = $this->express->read($value['express']);
  2637. $info_list[$key]['express'] = $express['servicename'];
  2638. $warehouse = $this->warehouse->read($value['type']);
  2639. $info_list[$key]['type'] = $warehouse['title'];
  2640. if ($value['librarytime'] == '0') {
  2641. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2642. } else {
  2643. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2644. }
  2645. }
  2646. $total = $this->$sj->find_count($where);
  2647. $pagenum = ceil($total / $perpage);
  2648. $over = $total - ($start + $perpage);
  2649. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2650. echo json_encode($rows);
  2651. exit;
  2652. }
  2653. $this->data['express'] = $this->express->find_all();
  2654. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2655. $this->data['wlshop'] = $wlshop;
  2656. $user = $this->user->get_api($_SESSION['api']);
  2657. $powerid = $this->power->read($user['power']);
  2658. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2659. $pid = '';
  2660. foreach ($powertext as $v) {
  2661. $pid .= " id = " . $v . " or";
  2662. }
  2663. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2664. $this->data['fullorderexcel'] = $fullorderexcel;
  2665. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2666. $this->data['orderurl'] = $orderurl;
  2667. $this->_Template('whlabel_toutorder', $this->data);
  2668. }
  2669. //tt出库
  2670. public function _aoutorder()
  2671. {
  2672. if (isset($_SESSION['api'])) {
  2673. $user = $this->user->get_api($_SESSION['api']);
  2674. $usp = $user;
  2675. $fgshop = "";
  2676. $sid = "";
  2677. $user = explode('|', trim($user['shop'], '|'));
  2678. foreach ($user as $value) {
  2679. $fgshop .= " shop = " . $value . " or";
  2680. $sid .= " id = " . $value . " or";
  2681. }
  2682. } else {
  2683. echo "请重新登录";
  2684. }
  2685. $post = $this->input->post(NULL, TRUE);
  2686. if (isset($post['page'])) {
  2687. $page = $this->input->post('page', true);
  2688. $perpage = $this->input->post('perpage', true);
  2689. $warehouse = $this->input->post('warehouse', true);
  2690. $xztime = $this->input->post('xztime', true);
  2691. $timetk = $this->input->post('timetkk', true);
  2692. $timetj = $this->input->post('timetjj', true);
  2693. $shop = $this->input->post('shop', true);
  2694. $source = $this->input->post('source', true);
  2695. $orderinfo = $this->input->post('orderinfo', true);
  2696. $number = $this->input->post('number', true);
  2697. $sfxh = $this->input->post('sfxh', true);
  2698. $express = $this->input->post('express', true);
  2699. $waybill = $this->input->post('waybill', true);
  2700. $library = $this->input->post('library', true);
  2701. $country = $this->input->post('country', true);
  2702. $so = $this->input->post('so', true);
  2703. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2704. $print = $this->input->post('print', true);
  2705. $state = $this->input->post('state', true);
  2706. $orderurl = $this->input->post('orderurl', true);
  2707. $timetk = strtotime($timetk);
  2708. $timetj = strtotime($timetj);
  2709. /**
  2710. $sj = $this->input->post('sj',true);
  2711. if($sj)
  2712. {
  2713. $sj = $this->input->post('sj',true);
  2714. }
  2715. else
  2716. {
  2717. $sj = "fullorder";
  2718. }
  2719. **/
  2720. $sj = "fullorderamz";
  2721. $where = "1=1";
  2722. if ($warehouse) {
  2723. $where .= " and type = '$warehouse'";
  2724. }
  2725. if ($timetk && $timetj) {
  2726. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2727. }
  2728. if ($orderinfo) {
  2729. $where .= " and orderinfo = '$orderinfo'";
  2730. }
  2731. if ($number) {
  2732. $where .= " and number = '$number'";
  2733. }
  2734. if ($express) {
  2735. $where .= " and express = '$express'";
  2736. }
  2737. if ($waybill) {
  2738. $where .= " and waybill = '$waybill'";
  2739. }
  2740. if ($library) {
  2741. $where .= " and library = '$library'";
  2742. }
  2743. if ($print) {
  2744. $where .= " and print = '$print'";
  2745. }
  2746. if ($libraryconfirm) {
  2747. $where .= " and libraryconfirm = '$libraryconfirm'";
  2748. }
  2749. if ($state) {
  2750. $where .= " and state = '$state'";
  2751. }
  2752. if ($shop) {
  2753. $where .= " and shop = '$shop'";
  2754. }
  2755. if ($country) {
  2756. $where .= " and country = '$country'";
  2757. }
  2758. if ($sfxh != '') {
  2759. $where .= " and sfxh = '$sfxh'";
  2760. }
  2761. if ($so) {
  2762. $where .= " and shipremarks like '%$so%'";
  2763. }
  2764. if ($source) {
  2765. if ($source == '2d') {
  2766. $where .= " and source >= '2'";
  2767. } else {
  2768. $where .= " and source = '$source'";
  2769. }
  2770. }
  2771. if (isset($_SESSION['api'])) {
  2772. foreach ($user as $value) {
  2773. $fgshop .= " shop = " . $value . " or";
  2774. }
  2775. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2776. }
  2777. if ($orderurl) {
  2778. $url = $this->orderurl->read($orderurl);
  2779. $where .= " and link like '%" . $url['url'] . "%'";
  2780. }
  2781. //数据排序
  2782. $order_str = "librarytime desc";
  2783. if (empty($page)) {
  2784. $start = 0;
  2785. $perpage = 1;
  2786. } else {
  2787. $start = ($page - 1) * $perpage;
  2788. }
  2789. //取得信息列表
  2790. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2791. //格式化数据
  2792. foreach ($info_list as $key => $value) {
  2793. $shop = $this->shop->read($value['shop']);
  2794. $info_list[$key]['shop'] = $shop['shopname'];
  2795. $express = $this->express->read($value['express']);
  2796. $info_list[$key]['express'] = $express['servicename'];
  2797. $warehouse = $this->warehouse->read($value['type']);
  2798. $info_list[$key]['type'] = $warehouse['title'];
  2799. if ($value['librarytime'] == '0') {
  2800. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2801. } else {
  2802. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2803. }
  2804. }
  2805. $total = $this->$sj->find_count($where);
  2806. $pagenum = ceil($total / $perpage);
  2807. $over = $total - ($start + $perpage);
  2808. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2809. echo json_encode($rows);
  2810. exit;
  2811. }
  2812. $this->data['express'] = $this->express->find_all();
  2813. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2814. $this->data['wlshop'] = $wlshop;
  2815. $user = $this->user->get_api($_SESSION['api']);
  2816. $powerid = $this->power->read($user['power']);
  2817. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2818. $pid = '';
  2819. foreach ($powertext as $v) {
  2820. $pid .= " id = " . $v . " or";
  2821. }
  2822. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2823. $this->data['fullorderexcel'] = $fullorderexcel;
  2824. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2825. $this->data['orderurl'] = $orderurl;
  2826. $this->_Template('whlabel_aoutorder', $this->data);
  2827. }
  2828. //速卖通出库订单
  2829. public function _soutorder()
  2830. {
  2831. if (isset($_SESSION['api'])) {
  2832. $user = $this->user->get_api($_SESSION['api']);
  2833. $usp = $user;
  2834. $fgshop = "";
  2835. $sid = "";
  2836. $user = explode('|', trim($user['shop'], '|'));
  2837. foreach ($user as $value) {
  2838. $sid .= " id = " . $value . " or";
  2839. }
  2840. }
  2841. $post = $this->input->post(NULL, TRUE);
  2842. if (isset($post['page'])) {
  2843. $page = $this->input->post('page', true);
  2844. $perpage = $this->input->post('perpage', true);
  2845. $warehouse = $this->input->post('warehouse', true);
  2846. $xztime = $this->input->post('xztime', true);
  2847. $timetk = $this->input->post('timetkk', true);
  2848. $timetj = $this->input->post('timetjj', true);
  2849. $shop = $this->input->post('shop', true);
  2850. $source = $this->input->post('source', true);
  2851. $orderinfo = $this->input->post('orderinfo', true);
  2852. $number = $this->input->post('number', true);
  2853. $express = $this->input->post('express', true);
  2854. $waybill = $this->input->post('waybill', true);
  2855. $library = $this->input->post('library', true);
  2856. $country = $this->input->post('country', true);
  2857. $sfxh = $this->input->post('sfxh', true);
  2858. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2859. $print = $this->input->post('print', true);
  2860. $state = $this->input->post('state', true);
  2861. $so = $this->input->post('so', true);
  2862. $timetk = strtotime($timetk);
  2863. $timetj = strtotime($timetj);
  2864. /**
  2865. $sj = $this->input->post('sj',true);
  2866. if($sj)
  2867. {
  2868. $sj = $this->input->post('sj',true);
  2869. }
  2870. else
  2871. {
  2872. $sj = "fullorder";
  2873. }
  2874. **/
  2875. $sj = "fullordersmt";
  2876. $where = "1=1";
  2877. if ($warehouse) {
  2878. $where .= " and type = '$warehouse'";
  2879. }
  2880. if ($timetk && $timetj) {
  2881. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2882. }
  2883. if ($orderinfo) {
  2884. $where .= " and orderinfo = '$orderinfo'";
  2885. }
  2886. if ($number) {
  2887. $where .= " and number = '$number'";
  2888. }
  2889. if ($express) {
  2890. $where .= " and express = '$express'";
  2891. }
  2892. if ($waybill) {
  2893. $where .= " and waybill = '$waybill'";
  2894. }
  2895. if ($library) {
  2896. $where .= " and library = '$library'";
  2897. }
  2898. if ($print) {
  2899. $where .= " and print = '$print'";
  2900. }
  2901. if ($libraryconfirm) {
  2902. $where .= " and libraryconfirm = '$libraryconfirm'";
  2903. }
  2904. if ($state) {
  2905. $where .= " and state = '$state'";
  2906. }
  2907. if ($shop) {
  2908. $where .= " and shop = '$shop'";
  2909. }
  2910. if ($sfxh != '') {
  2911. $where .= " and sfxh = '$sfxh'";
  2912. }
  2913. if ($so) {
  2914. $where .= " and shipremarks like '%$so%'";
  2915. }
  2916. if ($source) {
  2917. $where .= " and source = '$source'";
  2918. }
  2919. if ($country) {
  2920. $where .= " and country = '$country'";
  2921. } else {
  2922. if (isset($_SESSION['api'])) {
  2923. foreach ($user as $value) {
  2924. $fgshop .= " shop = " . $value . " or";
  2925. }
  2926. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2927. }
  2928. }
  2929. //数据排序
  2930. $order_str = "librarytime desc";
  2931. if (empty($page)) {
  2932. $start = 0;
  2933. $perpage = 1;
  2934. } else {
  2935. $start = ($page - 1) * $perpage;
  2936. }
  2937. //取得信息列表
  2938. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2939. //格式化数据
  2940. foreach ($info_list as $key => $value) {
  2941. $shop = $this->shop->read($value['shop']);
  2942. $info_list[$key]['shop'] = $shop['shopname'];
  2943. $express = $this->express->read($value['express']);
  2944. $info_list[$key]['express'] = $express['servicename'];
  2945. $warehouse = $this->warehouse->read($value['type']);
  2946. $info_list[$key]['type'] = $warehouse['title'];
  2947. if ($value['librarytime'] == '0') {
  2948. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2949. } else {
  2950. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2951. }
  2952. }
  2953. $total = $this->$sj->find_count($where);
  2954. $pagenum = ceil($total / $perpage);
  2955. $over = $total - ($start + $perpage);
  2956. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2957. echo json_encode($rows);
  2958. exit;
  2959. }
  2960. $this->data['express'] = $this->express->find_all();
  2961. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2962. $this->data['wlshop'] = $wlshop;
  2963. $user = $this->user->get_api($_SESSION['api']);
  2964. $powerid = $this->power->read($user['power']);
  2965. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2966. $pid = '';
  2967. foreach ($powertext as $v) {
  2968. $pid .= " id = " . $v . " or";
  2969. }
  2970. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2971. $this->data['fullorderexcel'] = $fullorderexcel;
  2972. $this->_Template('whlabel_soutorder', $this->data);
  2973. }
  2974. //订单退库
  2975. public function _retreat()
  2976. {
  2977. $post = $this->input->post(NULL, TRUE);
  2978. if (isset($post['page'])) {
  2979. $page = $this->input->post('page', true);
  2980. $perpage = $this->input->post('perpage', true);
  2981. $warehouse = $this->input->post('warehouse', true);
  2982. $timetk = $this->input->post('timetk', true);
  2983. $timetj = $this->input->post('timetj', true);
  2984. $shop = $this->input->post('shop', true);
  2985. $source = $this->input->post('source', true);
  2986. $state = $this->input->post('state', true);
  2987. $review = $this->input->post('review', true);
  2988. $state = $this->input->post('state', true);
  2989. $express = $this->input->post('express', true);
  2990. $orderinfo = $this->input->post('orderinfo', true);
  2991. $user = $this->input->post('user', true);
  2992. $name = $this->input->post('name', true);
  2993. $waybill = $this->input->post('waybill', true);
  2994. $timetk = strtotime($timetk);
  2995. $timetj = strtotime($timetj);
  2996. $where = "(state=206 or state=210) and mergeid = 0";
  2997. if ($warehouse) {
  2998. $where .= " and state = '$warehouse'";
  2999. }
  3000. if ($timetk && $timetj) {
  3001. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3002. }
  3003. if ($shop) {
  3004. $where .= " and shop = '$shop'";
  3005. }
  3006. if ($source) {
  3007. $where .= " and source = '$source'";
  3008. }
  3009. if ($state) {
  3010. $where .= " and state = '$state'";
  3011. }
  3012. if ($review) {
  3013. $where .= " and review = '$review'";
  3014. }
  3015. if ($state) {
  3016. $where .= " and state = '$state'";
  3017. }
  3018. if ($express) {
  3019. $where .= " and express = '$express'";
  3020. }
  3021. if ($orderinfo) {
  3022. $where .= " and orderinfo = '$orderinfo'";
  3023. }
  3024. if ($user) {
  3025. $where .= " and user = '$user'";
  3026. }
  3027. if ($name) {
  3028. $where .= " and name = '$name'";
  3029. }
  3030. if ($waybill) {
  3031. $where .= " and waybill = '$waybill'";
  3032. }
  3033. //数据排序
  3034. $order_str = "id desc";
  3035. if (empty($page)) {
  3036. $start = 0;
  3037. $perpage = 1;
  3038. } else {
  3039. $start = ($page - 1) * $perpage;
  3040. }
  3041. //取得信息列表
  3042. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3043. //格式化数据
  3044. foreach ($info_list as $key => $value) {
  3045. $shop = $this->shop->read($value['shop']);
  3046. $info_list[$key]['shop'] = $shop['shopname'];
  3047. $warehouse = $this->warehouse->read($value['warehouse']);
  3048. $info_list[$key]['warehouse'] = $warehouse['title'];
  3049. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3050. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3051. if ($value['waybill'] == 0) {
  3052. $info_list[$key]['waybill'] = "";
  3053. }
  3054. $express = $this->express->read($value['express']);
  3055. $info_list[$key]['express'] = $express['title'];
  3056. $typeclass = $this->typeclass->read($value['state']);
  3057. $info_list[$key]['state'] = $typeclass['title'];
  3058. }
  3059. $total = $this->fullorder->find_count($where);
  3060. $pagenum = ceil($total / $perpage);
  3061. $over = $total - ($start + $perpage);
  3062. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3063. echo json_encode($rows);
  3064. exit;
  3065. }
  3066. $this->data['express'] = $this->express->find_all();
  3067. $this->_Template('whlabel_retreat', $this->data);
  3068. }
  3069. //退库标签浏览
  3070. public function _retreatlk()
  3071. {
  3072. $post = $this->input->post(NULL, TRUE);
  3073. if (isset($post['page'])) {
  3074. $page = $this->input->post('page', true);
  3075. $perpage = $this->input->post('perpage', true);
  3076. $timetk = $this->input->post('timetk', true);
  3077. $timetj = $this->input->post('timetj', true);
  3078. $sku = $this->input->post('sku', true);
  3079. $warehouse = $this->input->post('warehouse', true);
  3080. $purchase = $this->input->post('purchase', true);
  3081. $orderinfo = $this->input->post('orderinfo', true);
  3082. $waybill = $this->input->post('waybill', true);
  3083. $category = $this->input->post('category', true);
  3084. $size = $this->input->post('size', true);
  3085. $grade = $this->input->post('grade', true);
  3086. $color = $this->input->post('color', true);
  3087. $lowe = $this->input->post('lowe', true);
  3088. $state = $this->input->post('state', true);
  3089. $timetk = strtotime($timetk);
  3090. $timetj = strtotime($timetj);
  3091. $where = "state=2";
  3092. if ($timetk && $timetj) {
  3093. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3094. }
  3095. if ($sku) {
  3096. $where .= " and sku = '$sku'";
  3097. }
  3098. if ($warehouse) {
  3099. $where .= " and warehouse = '$warehouse'";
  3100. }
  3101. if ($purchase) {
  3102. $where .= " and purchase = '$purchase'";
  3103. }
  3104. if ($orderinfo) {
  3105. $where .= " and orderinfo = '$orderinfo'";
  3106. }
  3107. if ($waybill) {
  3108. $where .= " and waybill = '$waybill'";
  3109. }
  3110. if ($category) {
  3111. $where .= " and features like '%-$category-%'";
  3112. }
  3113. if ($size) {
  3114. $where .= " and features like '%-$size-%'";
  3115. }
  3116. if ($grade) {
  3117. $where .= " and features like '%-$grade-%'";
  3118. }
  3119. if ($color) {
  3120. $where .= " and features like '%-$color-%'";
  3121. }
  3122. if ($lowe) {
  3123. $where .= " and features like '%-$lowe-%'";
  3124. }
  3125. //数据排序
  3126. $order_str = "time desc";
  3127. if (empty($page)) {
  3128. $start = 0;
  3129. $perpage = 1;
  3130. } else {
  3131. $start = ($page - 1) * $perpage;
  3132. }
  3133. //取得信息列表
  3134. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3135. foreach ($info_list as $key => $value) {
  3136. $warehouse = $this->warehouse->read($value['warehouse']);
  3137. $info_list[$key]['warehouse'] = $warehouse['title'];
  3138. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3139. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3140. $purchase = $this->purchase->read($value['purchase']);
  3141. $info_list[$key]['purchase'] = $purchase['title'];
  3142. if ($value['outk'] != 0) {
  3143. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3144. } else {
  3145. $info_list[$key]['outk'] = "";
  3146. }
  3147. if ($value['retreat'] != 0) {
  3148. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3149. } else {
  3150. $info_list[$key]['retreat'] = "";
  3151. }
  3152. if ($value['orderinfo'] == 0) {
  3153. $info_list[$key]['orderinfo'] = "";
  3154. }
  3155. if ($value['waybill'] == 0) {
  3156. $info_list[$key]['waybill'] = "";
  3157. }
  3158. }
  3159. $total = $this->whlabel->find_count($where);
  3160. $pagenum = ceil($total / $perpage);
  3161. $over = $total - ($start + $perpage);
  3162. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3163. echo json_encode($rows);
  3164. exit;
  3165. }
  3166. $this->_Template('whlabel_retreatlk', $this->data);
  3167. }
  3168. //更换标签及浏览
  3169. public function _change()
  3170. {
  3171. $post = $this->input->post(NULL, TRUE);
  3172. if (isset($post['page'])) {
  3173. $page = $this->input->post('page', true);
  3174. $perpage = $this->input->post('perpage', true);
  3175. $timetk = $this->input->post('timetk', true);
  3176. $timetj = $this->input->post('timetj', true);
  3177. $label = $this->input->post('label', true);
  3178. $oldlabel = $this->input->post('oldlabel', true);
  3179. $timetk = strtotime($timetk);
  3180. $timetj = strtotime($timetj);
  3181. $where = "state=10 ";
  3182. if ($timetk && $timetj) {
  3183. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3184. }
  3185. if ($label) {
  3186. $where .= " and label = '$label'";
  3187. }
  3188. if ($oldlabel) {
  3189. $where .= " and oldlabel = '$oldlabel'";
  3190. }
  3191. //数据排序
  3192. $order_str = "time asc";
  3193. if (empty($page)) {
  3194. $start = 0;
  3195. $perpage = 1;
  3196. } else {
  3197. $start = ($page - 1) * $perpage;
  3198. }
  3199. //取得信息列表
  3200. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3201. foreach ($info_list as $key => $value) {
  3202. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3203. }
  3204. $total = $this->whlabel->find_count($where);
  3205. $pagenum = ceil($total / $perpage);
  3206. $over = $total - ($start + $perpage);
  3207. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3208. echo json_encode($rows);
  3209. exit;
  3210. }
  3211. $this->_Template('whlabel_change', $this->data);
  3212. }
  3213. //产品标签
  3214. public function _cpbqdc()
  3215. {
  3216. if (isset($_GET['excel'])) {
  3217. $where = "1=1";
  3218. //数据排序
  3219. $order_str = "id desc";
  3220. if (empty($page)) {
  3221. $start = 0;
  3222. $perpage = 1;
  3223. } else {
  3224. $start = ($page - 1) * $perpage;
  3225. }
  3226. $warehouse = $this->input->get('warehouse', true);
  3227. $state = $this->input->get('state', true);
  3228. $timetk = $this->input->get('timetkk', true);
  3229. $timetj = $this->input->get('timetjj', true);
  3230. $timetk = strtotime($timetk);
  3231. $timetj = strtotime($timetj);
  3232. if ($warehouse) {
  3233. $where .= " and warehouse = '$warehouse'";
  3234. }
  3235. if ($state || $state == 0) {
  3236. $where .= " and state = '$state'";
  3237. }
  3238. if ($timetk && $timetj) {
  3239. $where .= " and time > '$timetk' and time < '$timetj'";
  3240. }
  3241. //取得信息列表
  3242. $info_list = $this->whlabel->find_all($where, '*');
  3243. $rows = array();
  3244. $list = array();
  3245. foreach ($info_list as $key => $value) {
  3246. $rows[$value['time']] = $value; //所有数据sku
  3247. }
  3248. foreach ($rows as $value) {
  3249. $warehouse = $this->warehouse->read($value['warehouse']);
  3250. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3251. $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);
  3252. }
  3253. $title = "产品标签统计表";
  3254. $titlename = "<table border=1>
  3255. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3256. <tr align='center'>
  3257. <td>仓库</td>
  3258. <td>SKU</td>
  3259. <td>产品</td>
  3260. <td>入库时间</td>
  3261. <td>操作时间</td>
  3262. <td>备注</td>
  3263. <td>数量</td>
  3264. </tr>
  3265. </table>";
  3266. $filename = $title . ".xls";
  3267. $tail = "";
  3268. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3269. }
  3270. }
  3271. //进销存导出
  3272. public function _exceljxc()
  3273. {
  3274. $classid = $this->classid->sku();
  3275. $pm = $classid;
  3276. $typeclass = array();
  3277. $tc = $this->typeclass->find_all();
  3278. foreach ($tc as $v) {
  3279. $typeclass[$v['id']] = $v;
  3280. }
  3281. $prc = array();
  3282. $purchase = $this->purchase->find_all();
  3283. foreach ($purchase as $k => $v) {
  3284. $prc[$v['id']] = $v['title'];
  3285. }
  3286. if (isset($_GET['excel'])) {
  3287. $where = "sku != 'Preset'";
  3288. //数据排序
  3289. $order_str = "id desc";
  3290. if (empty($page)) {
  3291. $start = 0;
  3292. $perpage = 1;
  3293. } else {
  3294. $start = ($page - 1) * $perpage;
  3295. }
  3296. $category = $this->input->get('category', true);
  3297. $warehouse = $this->input->get('warehouse', true);
  3298. $excelid = $this->input->get('sid', true);
  3299. if ($category) {
  3300. $where .= " and features like '%-$category-%'";
  3301. }
  3302. if ($warehouse) {
  3303. $where .= " and warehouse = '$warehouse'";
  3304. }
  3305. $xzid = '';
  3306. if ($excelid) {
  3307. $excelid = explode(',', trim($excelid, ','));
  3308. foreach ($excelid as $key => $value) {
  3309. $xzid .= " id = " . $value . " or";
  3310. }
  3311. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3312. }
  3313. //取得信息列表
  3314. /**
  3315. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3316. $rows = array();$list = array();
  3317. foreach ($info_list as $key=>$value)
  3318. {
  3319. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3320. }
  3321. **/
  3322. $wt = array();
  3323. $whlabel_type = $this->whlabel_type->find_all();
  3324. foreach ($whlabel_type as $v) {
  3325. $wt[$v['id']] = $v['title'];
  3326. }
  3327. $wh = array();
  3328. $w = $this->warehouse->find_all('1=1', 'id,title');
  3329. foreach ($w as $v) {
  3330. $wh[$v['id']] = $v['title'];
  3331. }
  3332. $list = array();
  3333. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3334. foreach ($rows as $key => $value) {
  3335. if (isset($wt[$value['type']])) {
  3336. $rows[$key]['type'] = $wt[$value['type']];
  3337. } else {
  3338. $rows[$key]['type'] = '未设置';
  3339. }
  3340. $bm = '03';
  3341. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3342. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3343. $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');
  3344. $details = array();
  3345. $cpid = array();
  3346. $cpbz = array();
  3347. $c = 0;
  3348. $g = 0;
  3349. $x = 0;
  3350. $t = 0;
  3351. $s = 0;
  3352. $q = 0;
  3353. foreach ($sd as $k => $v) {
  3354. if ($v['state'] == 0) {
  3355. $c++;
  3356. if ($v['cpid'] != 0) {
  3357. $cpid[$v['cpid']] = $v['cpid'];
  3358. }
  3359. if ($v['cpbz'] != '') {
  3360. $cpbz[$v['cpbz']] = $v['cpbz'];
  3361. }
  3362. }
  3363. if ($v['state'] != 9) {
  3364. $g++;
  3365. }
  3366. if ($v['state'] == 1) {
  3367. $x++;
  3368. }
  3369. if ($v['state'] == 2) {
  3370. $t++;
  3371. }
  3372. if ($v['state'] == 8) {
  3373. $s++;
  3374. }
  3375. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3376. $q++;
  3377. }
  3378. $details[$v['details']] = $v['details'];
  3379. }
  3380. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  3381. $rows[$key]['details'] = implode("、", $details);
  3382. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3383. $number = $value['number'];
  3384. $ftime = time() - 15 * 24 * 3600;
  3385. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3386. $rows[$key]['number'] = $g;
  3387. $rows[$key]['c'] = $c;
  3388. $rows[$key]['x'] = $x;
  3389. $rows[$key]['t'] = $t;
  3390. $rows[$key]['s'] = $s;
  3391. $rows[$key]['q'] = $q;
  3392. $rows[$key]['z'] = $z;
  3393. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3394. $features = explode('-', trim($features, '-'));
  3395. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3396. // $pm = $classid;
  3397. // $jm = $classid;
  3398. // foreach($features as $k=>$v)
  3399. // {
  3400. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3401. // {
  3402. // if($typeclass[$v]['bm'] != '')
  3403. // {
  3404. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3405. // }
  3406. // }
  3407. // if($v != 0)
  3408. // {
  3409. // if(!isset($typeclass[$v]))
  3410. // {
  3411. // continue;
  3412. // }
  3413. // if(isset($pm[$typeclass[$v]['classid']]))
  3414. // {
  3415. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3416. // {
  3417. // $tz = explode('|',$typeclass[$v]['zh']);
  3418. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3419. // }
  3420. // else
  3421. // {
  3422. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3423. // }
  3424. // }
  3425. // if(isset($jm[$typeclass[$v]['classid']]))
  3426. // {
  3427. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3428. // }
  3429. // }
  3430. // }
  3431. // $jm = array_filter($jm);
  3432. // $rows[$key]['bs'] = implode("-",$jm);
  3433. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3434. // $zh = implode(" ",$pm);
  3435. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3436. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3437. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3438. // $rows[$key]['features'] = $zh;
  3439. }
  3440. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3441. $final_list = [];
  3442. foreach ($list as $k => $v) {
  3443. if (empty($v['sku'])) {
  3444. continue;
  3445. }
  3446. $final_list[] = [
  3447. "warehouse" => $v["warehouse"],
  3448. "purchase" => $v["purchase"],
  3449. "details" => $v["details"],
  3450. "cpid" => $v["cpid"],
  3451. "dbcontent" => $v["dbcontent"],
  3452. "sku" => $v["sku"],
  3453. "cs" => $v["bm"],
  3454. "bs" => $v["jm"],
  3455. "title" => $v["title"],
  3456. "features" => $v["pm"],
  3457. "cpbz" => $v["cpbz"],
  3458. "sm" => $v["sm"],
  3459. "type" => $v["type"],
  3460. "number" => $v["number"],
  3461. "c" => $v["c"],
  3462. "x" => $v["x"],
  3463. "t" => $v["t"],
  3464. "s" => $v["s"],
  3465. "q" => $v["q"],
  3466. "z" => $v["z"],
  3467. "weight" => $v['weight'],
  3468. ];
  3469. }
  3470. $title = "总进销存统计表";
  3471. $titlename = "<table border=1>
  3472. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3473. <tr align='center'>
  3474. <td>仓库</td>
  3475. <td>供应商</td>
  3476. <td>位置</td>
  3477. <td>库存编码</td>
  3478. <td>类目</td>
  3479. <td>SKU</td>
  3480. <td>用友编码</td>
  3481. <td>用友料号</td>
  3482. <td>商品名称</td>
  3483. <td>商品中文</td>
  3484. <td>产品备注</td>
  3485. <td>说明</td>
  3486. <td>类型</td>
  3487. <td>入库总量</td>
  3488. <td>库存数量</td>
  3489. <td>销售数量</td>
  3490. <td>退货数量</td>
  3491. <td>删除数量</td>
  3492. <td>其它操作</td>
  3493. <td>占单数量</td>
  3494. <td>重量(g)</td>
  3495. </tr>
  3496. </table>";
  3497. $filename = $title . ".xls";
  3498. $tail = "";
  3499. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3500. }
  3501. }
  3502. //入库导出
  3503. public function _excelr()
  3504. {
  3505. if (isset($_GET['excel'])) {
  3506. $category = $this->input->get('category', true);
  3507. $size = $this->input->get('size', true);
  3508. $grade = $this->input->get('grade', true);
  3509. $color = $this->input->get('color', true);
  3510. $lowe = $this->input->get('lowe', true);
  3511. $sku = $this->input->get('sku', true);
  3512. $warehouse = $this->input->get('warehouse', true);
  3513. $purchase = $this->input->get('purchase', true);
  3514. $ktime = $this->input->get('ktime', true);
  3515. $jtime = $this->input->get('jtime', true);
  3516. $ktime = strtotime($ktime);
  3517. $jtime = strtotime($jtime);
  3518. $where = "1=1";
  3519. $gj = "";
  3520. $ck = "";
  3521. if ($category) {
  3522. $where .= " and features like '%-$category-%'";
  3523. }
  3524. if ($size) {
  3525. $where .= " and features like '%-$size-%'";
  3526. }
  3527. if ($grade) {
  3528. $where .= " and features like '%-$grade-%'";
  3529. }
  3530. if ($color) {
  3531. $where .= " and features like '%-$color-%'";
  3532. }
  3533. if ($lowe) {
  3534. $where .= " and features like '%-$lowe-%'";
  3535. }
  3536. if ($warehouse) {
  3537. $where .= " and warehouse = '$warehouse'";
  3538. }
  3539. if ($purchase) {
  3540. $where .= " and purchase = '$purchase'";
  3541. }
  3542. if ($sku) {
  3543. $where .= " and sku = '$sku'";
  3544. }
  3545. if ($ktime && $jtime) {
  3546. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3547. }
  3548. //数据排序
  3549. $order_str = "id desc";
  3550. if (empty($page)) {
  3551. $start = 0;
  3552. $perpage = 1;
  3553. } else {
  3554. $start = ($page - 1) * $perpage;
  3555. }
  3556. $list = array();
  3557. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3558. foreach ($rows as $value) {
  3559. $ck = $this->warehouse->read($value['warehouse']);
  3560. $warehouse = $ck['title'];
  3561. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3562. $retreatwarehouse = $tkck['title'];
  3563. $gy = $this->purchase->read($value['purchase']);
  3564. $purchase = $gy['title'];
  3565. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3566. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3567. }
  3568. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3569. $titlename = "<table border=1>
  3570. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3571. <tr align='center'>
  3572. <td>仓库</td>
  3573. <td>SKU</td>
  3574. <td>产品</td>
  3575. <td>时间</td>
  3576. <td>数量</td>
  3577. </tr>
  3578. </table>";
  3579. $filename = $title . ".xls";
  3580. $tail = "";
  3581. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3582. }
  3583. }
  3584. //出库、退库导出
  3585. public function _excelct()
  3586. {
  3587. $classid = $this->classid->sku();
  3588. $pm = $classid;
  3589. $typeclass = array();
  3590. $tc = $this->typeclass->find_all();
  3591. foreach ($tc as $v) {
  3592. $typeclass[$v['id']] = $v;
  3593. }
  3594. $prc = array();
  3595. $purchase = $this->purchase->find_all();
  3596. foreach ($purchase as $k => $v) {
  3597. $prc[$v['id']] = $v['title'];
  3598. }
  3599. if (isset($_GET['excel'])) {
  3600. $wh = array();
  3601. $w = $this->warehouse->find_all('1=1', 'id,title');
  3602. foreach ($w as $v) {
  3603. $wh[$v['id']] = $v['title'];
  3604. }
  3605. $type = $this->input->get('excel', true);
  3606. $category = $this->input->get('category', true);
  3607. $size = $this->input->get('size', true);
  3608. $grade = $this->input->get('grade', true);
  3609. $color = $this->input->get('color', true);
  3610. $lowe = $this->input->get('lowe', true);
  3611. $sku = $this->input->get('sku', true);
  3612. $warehouse = $this->input->get('warehouse', true);
  3613. $lacetype = $this->input->get('lacetype', true);
  3614. $lacecolor = $this->input->get('lacecolor', true);
  3615. $density = $this->input->get('density', true);
  3616. $haircap = $this->input->get('haircap', true);
  3617. $purchase = $this->input->get('purchase', true);
  3618. $title = $this->input->get('title', true);
  3619. $state = $this->input->get('state', true);
  3620. $sid = $this->input->get('sid', true);
  3621. $ktime = $this->input->get('ktime', true);
  3622. $jtime = $this->input->get('jtime', true);
  3623. $ktime = strtotime($ktime);
  3624. $jtime = strtotime($jtime);
  3625. $where = "1=1";
  3626. $gj = "";
  3627. $ck = "";
  3628. if ($category) {
  3629. $where .= " and features like '%-$category-%'";
  3630. }
  3631. if ($size) {
  3632. $where .= " and features like '%-$size-%'";
  3633. }
  3634. if ($grade) {
  3635. $where .= " and features like '%-$grade-%'";
  3636. }
  3637. if ($color) {
  3638. $where .= " and features like '%-$color-%'";
  3639. }
  3640. if ($lowe) {
  3641. $where .= " and features like '%-$lowe-%'";
  3642. }
  3643. if ($warehouse) {
  3644. $where .= " and warehouse = '$warehouse'";
  3645. }
  3646. if ($purchase) {
  3647. $where .= " and purchase = '$purchase'";
  3648. }
  3649. if ($state) {
  3650. $where .= " and state = '$state'";
  3651. }
  3652. if ($lacetype) {
  3653. $where .= " and features like '%-$lacetype-%'";
  3654. }
  3655. if ($lacecolor) {
  3656. $where .= " and features like '%-$lacecolor-%'";
  3657. }
  3658. if ($density) {
  3659. $where .= " and features like '%-$density-%'";
  3660. }
  3661. if ($haircap) {
  3662. $where .= " and features like '%-$haircap-%'";
  3663. }
  3664. if ($title) {
  3665. $title = trim($title, ' ');
  3666. $title = trim($title, ' ');
  3667. $where .= " and title like '%$title%'";
  3668. }
  3669. if ($sku) {
  3670. $sku = trim($sku, ' ');
  3671. $sku = trim($sku, ' ');
  3672. $where .= " and sku like '%$sku%'";
  3673. }
  3674. if ($ktime && $jtime) {
  3675. if ($type == 1) {
  3676. $tl = '出库';
  3677. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3678. } else if ($type == 2) {
  3679. $tl = '退库';
  3680. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3681. } else if ($type == 3) {
  3682. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3683. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3684. } else if ($type == 4) {
  3685. $tl = '出库+零售';
  3686. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3687. } else if ($type == 5) {
  3688. $tl = '零售';
  3689. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3690. }
  3691. }
  3692. $sidwhere = '';
  3693. if ($sid) {
  3694. $sd = "";
  3695. $s = explode(',', trim($sid, ','));
  3696. foreach ($s as $value) {
  3697. $sd .= " id = " . $value . " or";
  3698. }
  3699. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3700. }
  3701. //数据排序
  3702. $order_str = "time desc";
  3703. if (empty($page)) {
  3704. $start = 0;
  3705. $perpage = 1;
  3706. } else {
  3707. $start = ($page - 1) * $perpage;
  3708. }
  3709. //取得信息列表
  3710. if ($type != 3 && $type != 5) {
  3711. if ($type == 1 || $type == 4) {
  3712. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3713. foreach ($info_list as $key => $value) {
  3714. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3715. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3716. $warehouse = $this->warehouse->read($value['warehouse']);
  3717. $info_list[$key]['warehouse'] = $warehouse['title'];
  3718. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3719. $features = explode('-', trim($features, '-'));
  3720. $pm = $classid;
  3721. foreach ($features as $k => $v) {
  3722. if ($v != 0) {
  3723. if (!isset($typeclass[$v])) {
  3724. continue;
  3725. }
  3726. if (isset($pm[$typeclass[$v]['classid']])) {
  3727. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3728. $tz = explode('|', $typeclass[$v]['zh']);
  3729. $pm[$typeclass[$v]['classid']] = $tz[0];
  3730. } else {
  3731. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3732. }
  3733. }
  3734. }
  3735. }
  3736. $zh = implode(" ", $pm);
  3737. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3738. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3739. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3740. $info_list[$key]['features'] = $zh;
  3741. }
  3742. $final_list = [];
  3743. foreach($info_list as $k=>$v){
  3744. $number = "";
  3745. if(!empty($v['orderinfo'])){
  3746. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3747. if(!empty($tmp_info['number'])){
  3748. $number = $tmp_info['number'];
  3749. }
  3750. }
  3751. $final_list[] = [
  3752. 'warehouse'=>$v['warehouse'],
  3753. 'purchase'=>$v['purchase'],
  3754. 'sku'=>$v['sku'],
  3755. 'title'=>$v['title'],
  3756. 'features'=>$v['features'],
  3757. 'label'=>$v['label'],
  3758. 'orderinfo'=>$v['orderinfo'],
  3759. 'number'=>$number,
  3760. 'waybill'=>$v['waybill'],
  3761. 'outk'=>$v['outk'],
  3762. ];
  3763. }
  3764. } else {
  3765. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3766. foreach ($info_list as $key => $value) {
  3767. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3768. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3769. $warehouse = $this->warehouse->read($value['warehouse']);
  3770. $info_list[$key]['warehouse'] = $warehouse['title'];
  3771. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3772. $features = explode('-', trim($features, '-'));
  3773. $pm = $classid;
  3774. foreach ($features as $k => $v) {
  3775. if ($v != 0) {
  3776. if (!isset($typeclass[$v])) {
  3777. continue;
  3778. }
  3779. if (isset($pm[$typeclass[$v]['classid']])) {
  3780. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3781. $tz = explode('|', $typeclass[$v]['zh']);
  3782. $pm[$typeclass[$v]['classid']] = $tz[0];
  3783. } else {
  3784. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3785. }
  3786. }
  3787. }
  3788. }
  3789. $zh = implode(" ", $pm);
  3790. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3791. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3792. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3793. $info_list[$key]['features'] = $zh;
  3794. }
  3795. $final_list = [];
  3796. foreach($info_list as $k=>$v){
  3797. $number = "";
  3798. if(!empty($v['orderinfo'])){
  3799. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3800. if(!empty($tmp_info['number'])){
  3801. $number = $tmp_info['number'];
  3802. }
  3803. }
  3804. $final_list[] = [
  3805. 'warehouse'=>$v['warehouse'],
  3806. 'purchase'=>$v['purchase'],
  3807. 'sku'=>$v['sku'],
  3808. 'title'=>$v['title'],
  3809. 'features'=>$v['features'],
  3810. 'label'=>$v['label'],
  3811. 'orderinfo'=>$v['orderinfo'],
  3812. 'number'=>$number,
  3813. 'waybill'=>$v['waybill'],
  3814. 'retreat'=>$v['retreat'],
  3815. ];
  3816. }
  3817. }
  3818. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3819. $titlename = "<table border=1>
  3820. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3821. <tr align='center'>
  3822. <td>仓库</td>
  3823. <td>供应商</td>
  3824. <td>SKU</td>
  3825. <td>商品名称</td>
  3826. <td>商品中文</td>
  3827. <td>标签</td>
  3828. <td>订单号</td>
  3829. <td>订单编码</td>
  3830. <td>运单号</td>
  3831. <td>" . $tl . "时间(中国时间)</td>
  3832. </tr>
  3833. </table>";
  3834. $filename = $title . ".xls";
  3835. $tail = "";
  3836. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3837. } else if ($type == 5) {
  3838. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3839. foreach ($info_list as $key => $value) {
  3840. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3841. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3842. $warehouse = $this->warehouse->read($value['warehouse']);
  3843. $info_list[$key]['warehouse'] = $warehouse['title'];
  3844. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3845. $features = explode('-', trim($features, '-'));
  3846. $pm = $classid;
  3847. foreach ($features as $k => $v) {
  3848. if ($v != 0) {
  3849. if (!isset($typeclass[$v])) {
  3850. continue;
  3851. }
  3852. if (isset($pm[$typeclass[$v]['classid']])) {
  3853. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3854. $tz = explode('|', $typeclass[$v]['zh']);
  3855. $pm[$typeclass[$v]['classid']] = $tz[0];
  3856. } else {
  3857. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3858. }
  3859. }
  3860. }
  3861. }
  3862. $zh = implode(" ", $pm);
  3863. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3864. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3865. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3866. $info_list[$key]['features'] = $zh;
  3867. }
  3868. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3869. $titlename = "<table border=1>
  3870. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3871. <tr align='center'>
  3872. <td>仓库</td>
  3873. <td>供应商</td>
  3874. <td>SKU</td>
  3875. <td>商品名称</td>
  3876. <td>商品中文</td>
  3877. <td>标签</td>
  3878. <td>" . $tl . "时间(中国时间)</td>
  3879. </tr>
  3880. </table>";
  3881. $filename = $title . ".xls";
  3882. $tail = "";
  3883. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3884. } else {
  3885. /**
  3886. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3887. $rows = array();$list = array();
  3888. foreach ($info_list as $key=>$value)
  3889. {
  3890. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3891. }
  3892. **/
  3893. $wh = array();
  3894. $w = $this->warehouse->find_all('1=1', 'id,title');
  3895. foreach ($w as $v) {
  3896. $wh[$v['id']] = $v['title'];
  3897. }
  3898. $wt = array();
  3899. $whlabel_type = $this->whlabel_type->find_all();
  3900. foreach ($whlabel_type as $v) {
  3901. $wt[$v['id']] = $v['title'];
  3902. }
  3903. $classid = $this->classid->sku();
  3904. $list = array();
  3905. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3906. foreach ($rows as $key => $value) {
  3907. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3908. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3909. $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state,outk,retreat');
  3910. $details = array();
  3911. $cpid = array();
  3912. $cpbz = array();
  3913. $c = 0;
  3914. $g = 0;
  3915. $x = 0;
  3916. $t = 0;
  3917. $s = 0;
  3918. $q = 0;
  3919. foreach ($sd as $k => $v) {
  3920. if ($v['state'] == 0) {
  3921. $c++;
  3922. }
  3923. if ($v['state'] != 9) {
  3924. $g++;
  3925. }
  3926. if ($v['outk'] > 1) {
  3927. $x++;
  3928. }
  3929. if ($v['retreat'] > 0) {
  3930. $t++;
  3931. }
  3932. if ($v['state'] == 8) {
  3933. $s++;
  3934. }
  3935. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3936. $q++;
  3937. }
  3938. $details[$v['details']] = $v['details'];
  3939. if ($v['cpid'] != 0) {
  3940. $cpid[$v['cpid']] = $v['cpid'];
  3941. }
  3942. if ($v['cpbz'] != '') {
  3943. $cpbz[$v['cpbz']] = $v['cpbz'];
  3944. }
  3945. }
  3946. if (isset($wt[$value['type']])) {
  3947. $rows[$key]['type'] = $wt[$value['type']];
  3948. } else {
  3949. $rows[$key]['type'] = '未设置';
  3950. }
  3951. $rows[$key]['details'] = implode("、", $details);
  3952. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3953. $ftime = time() - 15 * 24 * 3600;
  3954. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3955. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3956. $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);
  3957. $rows[$key]['c'] = $c;
  3958. $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);
  3959. $rows[$key]['t'] = $t;
  3960. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  3961. $rows[$key]['z'] = $z;
  3962. // $jm = $classid;
  3963. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3964. $features = explode('-', trim($features, '-'));
  3965. // $pm = $classid;
  3966. // foreach ($features as $k => $v) {
  3967. // if ($v != 0) {
  3968. // if (!isset($typeclass[$v])) {
  3969. // continue;
  3970. // }
  3971. // if (isset($pm[$typeclass[$v]['classid']])) {
  3972. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3973. // $tz = explode('|', $typeclass[$v]['zh']);
  3974. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3975. // } else {
  3976. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3977. // }
  3978. // if (isset($jm[$typeclass[$v]['classid']])) {
  3979. // if ($typeclass[$v]['jm']) {
  3980. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3981. // }
  3982. // }
  3983. // }
  3984. // }
  3985. // }
  3986. // $zh = implode(" ", $pm);
  3987. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3988. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3989. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3990. // $rows[$key]['features'] = $zh;
  3991. // $jm = array_filter($jm); //去除空值
  3992. // $jm = implode("-", $jm);
  3993. // $rows[$key]['jm'] = $jm;
  3994. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  3995. }
  3996. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  3997. // echo "<pre>";
  3998. // print_r($tmp_list);
  3999. // die;
  4000. $final_list =[];
  4001. foreach($tmp_list as $k=>$v){
  4002. $final_list[] = [
  4003. "warehouse"=>$v['warehouse'],
  4004. "purchase"=>$v['purchase'],
  4005. "details"=>$v['details'],
  4006. "cpid"=>$v['cpid'],
  4007. "sku"=>$v['sku'],
  4008. "title"=>$v['title'],
  4009. "features"=>$v['pm'],
  4010. "cpbz"=>$v['cpbz'],
  4011. "sm"=>$v['sm'],
  4012. "type"=>$v['type'],
  4013. "g"=>$v["g"],
  4014. "c"=>$v["c"],
  4015. "x"=>$v["x"],
  4016. "t"=>$v["t"],
  4017. "z"=>$v["z"],
  4018. "jm"=>$v["jm"],
  4019. "weight"=>$v["weight"],
  4020. "asd"=>$v["asd"],
  4021. ];
  4022. }
  4023. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4024. $titlename = "<table border=1>
  4025. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4026. <tr align='center'>
  4027. <td>仓库</td>
  4028. <td>供应商</td>
  4029. <td>位置</td>
  4030. <td>库存编码</td>
  4031. <td>SKU</td>
  4032. <td>商品名称</td>
  4033. <td>商品中文</td>
  4034. <td>产品备注</td>
  4035. <td>说明</td>
  4036. <td>类型</td>
  4037. <td>入库总量</td>
  4038. <td>库存数量</td>
  4039. <td>销售数量</td>
  4040. <td>退货数量</td>
  4041. <td>占单数量</td>
  4042. <td>料号</td>
  4043. <td>重量</td>
  4044. <td>类目</td>
  4045. </tr>
  4046. </table>";
  4047. $filename = $title . ".xls";
  4048. $tail = "";
  4049. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4050. }
  4051. }
  4052. }
  4053. //出库+入库数据整合
  4054. public function _excelcr()
  4055. {
  4056. if (isset($_GET['excel'])) {
  4057. $type = $this->input->get('excel', true);
  4058. $category = $this->input->get('category', true);
  4059. $size = $this->input->get('size', true);
  4060. $grade = $this->input->get('grade', true);
  4061. $color = $this->input->get('color', true);
  4062. $lowe = $this->input->get('lowe', true);
  4063. $sku = $this->input->get('sku', true);
  4064. $warehouse = $this->input->get('warehouse', true);
  4065. $purchase = $this->input->get('purchase', true);
  4066. $state = $this->input->get('state', true);
  4067. $sid = $this->input->get('sid', true);
  4068. $ktime = $this->input->get('ktime', true);
  4069. $jtime = $this->input->get('jtime', true);
  4070. $ktime = strtotime($ktime);
  4071. $jtime = strtotime($jtime);
  4072. $where = "1=1";
  4073. $gj = "";
  4074. $ck = "";
  4075. if ($category) {
  4076. $where .= " and features like '%-$category-%'";
  4077. }
  4078. if ($size) {
  4079. $where .= " and features like '%-$size-%'";
  4080. }
  4081. if ($grade) {
  4082. $where .= " and features like '%-$grade-%'";
  4083. }
  4084. if ($color) {
  4085. $where .= " and features like '%-$color-%'";
  4086. }
  4087. if ($lowe) {
  4088. $where .= " and features like '%-$lowe-%'";
  4089. }
  4090. if ($warehouse) {
  4091. $where .= " and warehouse = '$warehouse'";
  4092. }
  4093. if ($purchase) {
  4094. $where .= " and purchase = '$purchase'";
  4095. }
  4096. if ($state) {
  4097. $where .= " and state = '$state'";
  4098. }
  4099. if ($sku) {
  4100. $where .= " and sku like '%$sku%'";
  4101. }
  4102. if ($ktime && $jtime) {
  4103. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4104. }
  4105. $sidwhere = '';
  4106. if ($sid) {
  4107. $sd = "";
  4108. $s = explode(',', trim($sid, ','));
  4109. foreach ($s as $value) {
  4110. $sd .= " id = " . $value . " or";
  4111. }
  4112. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4113. }
  4114. //取得信息列表
  4115. $timeread = $ktime;
  4116. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4117. $timelist = array();
  4118. for ($i = 0; $i < $timenum; $i++) {
  4119. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4120. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4121. }
  4122. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4123. //echo "<pre>";
  4124. //print_r($info_list);
  4125. //exit();
  4126. $rows = array();
  4127. $list = array();
  4128. foreach ($info_list as $key => $value) {
  4129. $thistime = $timelist;
  4130. if (isset($rows[strtolower($value['sku'])])) {
  4131. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4132. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4133. }
  4134. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4135. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4136. }
  4137. } else {
  4138. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4139. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4140. }
  4141. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4142. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4143. }
  4144. $rows[strtolower($value['sku'])] = $thistime;
  4145. }
  4146. }
  4147. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4148. <head>
  4149. <!--[if gte mso 9]><xml>
  4150. <x:ExcelWorkbook>
  4151. <x:ExcelWorksheets>
  4152. <x:ExcelWorksheet>
  4153. <x:Name>EXCEL</x:Name>
  4154. <x:WorksheetOptions>
  4155. <x:Print>
  4156. <x:ValidPrinterInfo />
  4157. </x:Print>
  4158. </x:WorksheetOptions>
  4159. </x:ExcelWorksheet>
  4160. </x:ExcelWorksheets>
  4161. </x:ExcelWorkbook>
  4162. </xml>
  4163. <![endif]-->
  4164. </head><body>";
  4165. $str .= "<table border=1><tr><td>SKU</td>";
  4166. foreach ($timelist as $k => $v) {
  4167. $str .= "<td>" . $k . "出库</td>";
  4168. $str .= "<td>" . $k . "入库</td>";
  4169. }
  4170. $str .= "</tr></table>";
  4171. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4172. foreach ($rows as $key => $val) {
  4173. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4174. foreach ($val as $k => $v) {
  4175. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4176. if ($val[$k]['r'] > 0) {
  4177. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4178. } else {
  4179. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4180. }
  4181. }
  4182. $str .= "</tr>";
  4183. }
  4184. $str .= "</table>";
  4185. $str .= "</body></html>";
  4186. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4187. header("Content-type: application/octet-stream");
  4188. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4189. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4190. header("Pragma: no-cache");
  4191. header("Expires: 0");
  4192. exit($str);
  4193. }
  4194. }
  4195. //数量调整模板导出
  4196. public function _presetout()
  4197. {
  4198. if (isset($_GET['excel'])) {
  4199. $where = "sku != 'Preset' and purchase != 0";
  4200. //数据排序
  4201. $order_str = "id desc";
  4202. if (empty($page)) {
  4203. $start = 0;
  4204. $perpage = 1;
  4205. } else {
  4206. $start = ($page - 1) * $perpage;
  4207. }
  4208. //取得信息列表
  4209. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4210. $rows = array();
  4211. $list = array();
  4212. foreach ($info_list as $value) {
  4213. $warehouse = $this->warehouse->read($value['warehouse']);
  4214. $number = $value['number'];
  4215. $ftime = time() - 15 * 24 * 3600;
  4216. $purchase = $this->purchase->read($value['purchase']);
  4217. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4218. }
  4219. $title = "库存模板";
  4220. $titlename = "<table border=1>
  4221. <tr align='center'>
  4222. <td>仓库</td>
  4223. <td>供应商编码</td>
  4224. <td>SKU</td>
  4225. <td>增减数量(正数或负数)</td>
  4226. <td>增减备注</td>
  4227. <td>扣减方式:0减少库存1删除库存</td>
  4228. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4229. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4230. </tr>
  4231. </table>";
  4232. $filename = $title . ".xls";
  4233. $tail = "";
  4234. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4235. }
  4236. }
  4237. //数量调整模板导入
  4238. public function _presetedit()
  4239. {
  4240. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4241. $config['upload_path'] = '.' . $dir;
  4242. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4243. $config['allowed_types'] = 'xls|xlsx|csv';
  4244. $config['max_size'] = 10240;
  4245. $this->load->library('upload', $config);
  4246. $this->upload->initialize($config);
  4247. if ($this->upload->do_upload('userfile')) {
  4248. $full_path = $dir . $this->upload->data('file_name');
  4249. $fileName = '.' . $full_path;
  4250. if (!file_exists($fileName)) {
  4251. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4252. exit;
  4253. } else {
  4254. require_once "./data/excel/PHPExcel/IOFactory.php";
  4255. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4256. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4257. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4258. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4259. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4260. ++$column; //如果列数大于26行
  4261. $list = array();
  4262. for ($i = 2; $i <= $row; $i++) // 行数循环
  4263. {
  4264. $data = array();
  4265. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4266. {
  4267. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4268. }
  4269. $list[] = $data;
  4270. }
  4271. }
  4272. $i = 0;
  4273. $j = 0;
  4274. $ed = array();
  4275. foreach ($list as $key => $value) {
  4276. $time = time();
  4277. if ($value['0'] == "") {
  4278. continue;
  4279. }
  4280. $warehouse = $this->warehouse->get_title($value['0']);
  4281. $purchase = $this->purchase->get_bm($value['1']);
  4282. $sku = $value['2'];
  4283. $num = $value['3']; //调整数量
  4284. $text = $value['4']; //扣减说明
  4285. $type = $value['5']; //调整方式0扣减1删除
  4286. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4287. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4288. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4289. if (!$purchase) //如果没有这个SKU
  4290. {
  4291. $ed[] = array($purchase . '-不存在此供应商编码');
  4292. $j++;
  4293. continue;
  4294. }
  4295. if (!$d) //如果没有这个SKU
  4296. {
  4297. $ed[] = array($sku . '-库存中不存在此SKU');
  4298. $j++;
  4299. continue;
  4300. }
  4301. if (!isset($warehouse['id'])) {
  4302. $ed[] = array($sku . '-仓库名错误!');
  4303. $j++;
  4304. continue;
  4305. }
  4306. if ($type != '0' && $type != '1') {
  4307. $ed[] = array($sku . '-扣减方式填写错误!');
  4308. $j++;
  4309. continue;
  4310. }
  4311. if ($num < 0) //扣减库存
  4312. {
  4313. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4314. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4315. $j++;
  4316. continue;
  4317. }
  4318. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4319. if (count($data) < abs($num)) {
  4320. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4321. $j++;
  4322. continue;
  4323. }
  4324. if ($type == 0) //如果扣减方式为 扣减库存
  4325. {
  4326. for ($i = 0; $i < abs($num); $i++) {
  4327. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4328. }
  4329. } else if ($type == 1) {
  4330. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4331. if (count($zt) > 0) {
  4332. $ed[] = array($sku . '-有在途库存无法删除!');
  4333. $j++;
  4334. continue;
  4335. }
  4336. for ($i = 0; $i < abs($num); $i++) {
  4337. $this->whlabel->remove($data[$i]['id']);
  4338. }
  4339. }
  4340. } else if ($num > 0) //增加库存
  4341. {
  4342. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4343. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4344. $j++;
  4345. continue;
  4346. }
  4347. $post['sku'] = $d['sku'];
  4348. $post['shop'] = $d['shop'];
  4349. $post['warehouse'] = $warehouse['id'];
  4350. $post['purchase'] = $purchase['id'];
  4351. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4352. $post['state'] = 0;
  4353. $post['title'] = $d['title'];
  4354. $post['number'] = $d['number'];
  4355. $post['features'] = $d['features'];
  4356. $post['enter'] = $time;
  4357. $post['time'] = $time; //操作时间
  4358. $post['rktype'] = $rktype;
  4359. for ($i = 0; $i < $num; $i++) {
  4360. $post['label'] = time() . rand(100, 999) . $i;
  4361. $this->whlabel->insert($post);
  4362. }
  4363. }
  4364. sleep(1); //防止入库时间一样,需要延迟1秒
  4365. }
  4366. if ($j > 0) {
  4367. $tt = date('Ymd', time());
  4368. $title = '库存导入错误信息-' . $tt;
  4369. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4370. $tail = "\n";
  4371. $filename = $title . ".xls";
  4372. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4373. $dir = '/data/excel/' . $time . '/';
  4374. $file_name = 'error_' . $time . rand(1000, 9999);
  4375. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4376. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4377. fwrite($myfile, $ecl);
  4378. fclose($myfile);
  4379. $error = $dir . $file_name . '.xls';
  4380. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4381. exit;
  4382. } else {
  4383. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4384. exit;
  4385. }
  4386. }
  4387. }
  4388. //笛卡儿积
  4389. function cp($ps, $sets, $list)
  4390. {
  4391. $result = array();
  4392. $j = 0;
  4393. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4394. if ($i == 0) {
  4395. $result = $sets[$i];
  4396. }
  4397. $tmp = array();
  4398. foreach ($result as $res) {
  4399. foreach ($sets[$i + 1] as $set) {
  4400. $tmp[] = $res . ',' . $set;
  4401. }
  4402. }
  4403. $result = $tmp;
  4404. }
  4405. $this->db->trans_begin();
  4406. foreach ($result as $v) {
  4407. $post = array();
  4408. $title = "";
  4409. $num = "";
  4410. $data = explode(',', $v);
  4411. for ($i = 0; $i < count($list); $i++) {
  4412. $post[$list[$i]] = $data[$i];
  4413. $typeclass = $this->typeclass->read($data[$i]);
  4414. $title = $title . $typeclass['title'] . " ";
  4415. if ($data[$i] != 0) {
  4416. $num .= $data[$i]; //所有数据ID拼接
  4417. }
  4418. }
  4419. foreach ($ps as $kp => $vp) {
  4420. $post[$kp] = $vp;
  4421. }
  4422. $post['number'] = $num;
  4423. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4424. if ($info_list) {
  4425. $j++;
  4426. } else {
  4427. $skunum = $this->whlabel->find_count();
  4428. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4429. $post['title'] = rtrim($title, ' ');
  4430. $this->whlabel->insert($post);
  4431. }
  4432. }
  4433. if ($this->db->trans_status() === FALSE) {
  4434. $this->db->trans_commit();
  4435. return NULL;
  4436. } else {
  4437. $this->db->trans_commit();
  4438. return $j;
  4439. }
  4440. }
  4441. public function _kj($arg_array)
  4442. {
  4443. if (isset($_POST['sku'])) {
  4444. $time = time();
  4445. $sku = $this->input->post('sku', true);
  4446. $warehouse = $this->input->post('warehouse', true);
  4447. $num = $this->input->post('num', true);
  4448. $text = $this->input->post('text', true);
  4449. $purchase = $this->input->post('purchase', true);
  4450. $cktype = $this->input->post('cktype', true);
  4451. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4452. if ($cktype != 1 && $text == '') {
  4453. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4454. exit;
  4455. }
  4456. if ($num > count($order)) {
  4457. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4458. exit;
  4459. } else {
  4460. for ($i = 0; $i < $num; $i++) {
  4461. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4462. }
  4463. }
  4464. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4465. exit;
  4466. }
  4467. $uid = $this->whlabel->read($arg_array[0]);
  4468. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4469. $this->data['data'] = $uid;
  4470. $this->_Template('whlabel_kj', $this->data);
  4471. }
  4472. public function _summary($arg_array)
  4473. {
  4474. $prc = array();
  4475. $purchase = $this->purchase->find_all();
  4476. foreach ($purchase as $k => $v) {
  4477. $prc[$v['id']] = $v['title'];
  4478. }
  4479. if (isset($_GET['excel'])) {
  4480. $ktime = $this->input->get('ktime', true);
  4481. $jtime = $this->input->get('jtime', true);
  4482. $ktime = strtotime($ktime);
  4483. $jtime = strtotime($jtime);
  4484. $where = "1=1";
  4485. if ($ktime && $jtime) {
  4486. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4487. }
  4488. //数据排序
  4489. $order_str = "time desc";
  4490. if (empty($page)) {
  4491. $start = 0;
  4492. $perpage = 1;
  4493. } else {
  4494. $start = ($page - 1) * $perpage;
  4495. }
  4496. //取得信息列表
  4497. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4498. foreach ($info_list as $key => $value) {
  4499. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4500. $warehouse = $this->warehouse->read($value['warehouse']);
  4501. $info_list[$key]['warehouse'] = $warehouse['title'];
  4502. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4503. $details = array();
  4504. $cpid = array();
  4505. foreach ($x as $k => $v) {
  4506. if ($v['details'] != '') {
  4507. $details[$v['details']] = $v['details'];
  4508. }
  4509. if ($v['cpid'] != 0) {
  4510. $cpid[$v['cpid']] = $v['cpid'];
  4511. }
  4512. }
  4513. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4514. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4515. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4516. $info_list[$key]['s'] = $s;
  4517. $info_list[$key]['x'] = count($x);
  4518. }
  4519. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4520. $titlename = "<table border=1>
  4521. <tr align='center'>
  4522. <td>仓库</td>
  4523. <td>供应商</td>
  4524. <td>出库位置</td>
  4525. <td>出库编码</td>
  4526. <td>SKU</td>
  4527. <td>产品名</td>
  4528. <td>总剩余库存</td>
  4529. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4530. </tr>
  4531. </table>";
  4532. $filename = $title . ".xls";
  4533. $tail = "";
  4534. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4535. }
  4536. }
  4537. //usps发货清单
  4538. public function _manifest()
  4539. {
  4540. if (isset($_POST['manifest'])) {
  4541. $wltext = $this->input->post('wltext', true);
  4542. $time = time() - 16 * 3600;
  4543. $ptime = strtotime(date('Y-m-d', $time));
  4544. $waybill = array();
  4545. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4546. foreach ($fullorder as $v) {
  4547. $waybill[$v['waybill']] = $v['waybill'];
  4548. }
  4549. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4550. foreach ($fullordersmt as $v) {
  4551. $waybill[$v['waybill']] = $v['waybill'];
  4552. }
  4553. $wltext = explode(';', $wltext);
  4554. foreach ($wltext as $v) {
  4555. if (isset($waybill[$v])) {
  4556. unset($waybill[$v]);
  4557. }
  4558. }
  4559. $data = $this->usps->get_manifest($waybill);
  4560. if (isset($data['Description'])) {
  4561. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4562. exit;
  4563. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4564. $bctime = date('Ymd', time());
  4565. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4566. echo json_encode(array('msg' => $pdf, 'success' => true));
  4567. exit;
  4568. } else {
  4569. echo json_encode(array('msg' => $data, 'success' => false));
  4570. exit;
  4571. }
  4572. }
  4573. }
  4574. public function _pdf($pdf, $title, $bctime)
  4575. {
  4576. $pdf_path = './data/pdf/' . $bctime . '/';
  4577. $file_base64 = $pdf;
  4578. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4579. $file_base64 = base64_decode($file_base64);
  4580. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4581. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4582. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4583. }
  4584. /**
  4585. *
  4586. *
  4587. *
  4588. 进销存占单异常索引
  4589. *
  4590. *
  4591. *
  4592. **/
  4593. public function _abnormal()
  4594. {
  4595. $post = $this->input->post(NULL, TRUE);
  4596. if (isset($post['page'])) {
  4597. $page = $this->input->post('page', true);
  4598. $perpage = $this->input->post('perpage', true);
  4599. $sku = $this->input->post('sku', true);
  4600. $where = "1=1";
  4601. //数据排序
  4602. $order_str = "id desc";
  4603. if (empty($page)) {
  4604. $start = 0;
  4605. $perpage = 1;
  4606. } else {
  4607. $start = ($page - 1) * $perpage;
  4608. }
  4609. //取得信息列表
  4610. $info_list = $this->whlabel->find_all($where, '*');
  4611. $rows = array();
  4612. $list = array();
  4613. foreach ($info_list as $key => $value) {
  4614. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4615. }
  4616. foreach ($rows as $value) {
  4617. $warehouse = $this->warehouse->read($value['warehouse']);
  4618. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4619. $number = $value['number'];
  4620. $ftime = time() - 15 * 24 * 3600;
  4621. if ($value['shop'] != '') {
  4622. $shop = $value['shop'];
  4623. $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');
  4624. $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');
  4625. $order = array_merge($orderdlz, $ordersmt);
  4626. $od = 0;
  4627. $a = '';
  4628. $orid = '';
  4629. foreach ($order as $v) {
  4630. $or = explode('|', ltrim($v['whlabel'], '|'));
  4631. for ($i = 0; $i < count($or); $i++) {
  4632. $orod = explode('-', $or[$i]);
  4633. if ($orod[0] == $number) {
  4634. $od += $orod[1];
  4635. }
  4636. }
  4637. $orid .= $v['number'] . '-';
  4638. }
  4639. } else {
  4640. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4641. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4642. $order = array_merge($orderdlz, $ordersmt);
  4643. $od = 0;
  4644. $a = '';
  4645. $orid = '';
  4646. $qt = array();
  4647. foreach ($order as $v) {
  4648. $or = explode('|', ltrim($v['whlabel'], '|'));
  4649. for ($i = 0; $i < count($or); $i++) {
  4650. $orod = explode('-', $or[$i]);
  4651. if ($orod[0] == $number) {
  4652. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4653. if ($czzs > 0) {
  4654. if (isset($qt[$v['shop']])) {
  4655. if ($qt[$v['shop']] < $orod[1]) {
  4656. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4657. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4658. } else {
  4659. $qt[$v['shop']] -= $orod[1];
  4660. }
  4661. } else {
  4662. $qt[$v['shop']] = $czzs;
  4663. }
  4664. } else {
  4665. $od += $orod[1];
  4666. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4667. }
  4668. }
  4669. }
  4670. }
  4671. }
  4672. $z = $od . '(' . $orid . ')'; //查看订单号
  4673. //$z = $od;
  4674. if ($od > $c) {
  4675. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4676. }
  4677. }
  4678. $listdata = array_slice($list, $start, $perpage);
  4679. $total = count($list);
  4680. $pagenum = ceil($total / $perpage);
  4681. $over = $total - ($start + $perpage);
  4682. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4683. echo json_encode($rows);
  4684. exit;
  4685. }
  4686. $this->_Template('whlabel_abnormal', $this->data);
  4687. }
  4688. /**
  4689. *
  4690. *
  4691. *
  4692. 进销存占单异常索引
  4693. *
  4694. *
  4695. *
  4696. **/
  4697. public function _error()
  4698. {
  4699. $post = $this->input->post(NULL, TRUE);
  4700. if (isset($post['page'])) {
  4701. $page = $this->input->post('page', true);
  4702. $perpage = $this->input->post('perpage', true);
  4703. $sku = $this->input->post('sku', true);
  4704. $warehouse = $this->input->post('warehouse', true);
  4705. $ktime = $this->input->post('ktime', true);
  4706. $jtime = $this->input->post('jtime', true);
  4707. $ktime = strtotime($ktime);
  4708. $jtime = strtotime($jtime);
  4709. $where = "sku != 'Preset'";
  4710. $gj = '';
  4711. if ($sku) {
  4712. $where .= " and sku like '%$sku%'";
  4713. } else {
  4714. if ($ktime && $jtime) {
  4715. $gj = " and time > '$ktime' and time < '$jtime'";
  4716. }
  4717. }
  4718. if ($warehouse) {
  4719. $where .= " and warehouse = '$warehouse'";
  4720. }
  4721. //数据排序
  4722. $order_str = "id desc";
  4723. if (empty($page)) {
  4724. $start = 0;
  4725. $perpage = 1;
  4726. } else {
  4727. $start = ($page - 1) * $perpage;
  4728. }
  4729. //取得信息列表
  4730. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4731. $rows = array();
  4732. $list = array();
  4733. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4734. // foreach ($info_list as $value)
  4735. // {
  4736. // $warehouse = $this->warehouse->read($value['warehouse']);
  4737. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4738. // $number = $value['number'];$ftime = time()-15*24*3600;
  4739. // if($c < 1)
  4740. // {
  4741. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4742. // }
  4743. // }
  4744. $warehouse_list = $this->warehouse->find_all();
  4745. $warehouse_list = array_column($warehouse_list, null, 'id');
  4746. foreach ($info_list as $value) {
  4747. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4748. 'title' => "",
  4749. ];
  4750. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4751. $number = $value['number'];
  4752. $ftime = time() - 15 * 24 * 3600;
  4753. if ($c < 1) {
  4754. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4755. }
  4756. }
  4757. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4758. // $query = $this->db->query($sql);
  4759. // $info_list = $query->result_array();
  4760. // $sql_two = "select title,id from crowd_warehouse";
  4761. // $query_two = $this->db->query($sql_two);
  4762. // $warehouse_list = $query_two->result_array();
  4763. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4764. // foreach ($info_list as $value)
  4765. // {
  4766. // if(isset($warehouse_arr[$value['warehouse']])){
  4767. // $warehouse = $warehouse_arr[$value['warehouse']];
  4768. // }else{
  4769. // $warehouse = [
  4770. // 'id'=>0,
  4771. // 'title'=>"异常",
  4772. // ];
  4773. // }
  4774. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4775. // $number = $value['number'];$ftime = time()-15*24*3600;
  4776. // if($c < 1)
  4777. // {
  4778. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4779. // }
  4780. // }
  4781. $listdata = array_slice($list, $start, $perpage);
  4782. $total = count($list);
  4783. $pagenum = ceil($total / $perpage);
  4784. $over = $total - ($start + $perpage);
  4785. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4786. echo json_encode($rows);
  4787. exit;
  4788. }
  4789. if (isset($post['s'])) {
  4790. $id_arr = $this->input->post('s');
  4791. $id_arr = explode(',', trim($id_arr, ','));
  4792. if (!$id_arr) {
  4793. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4794. exit;
  4795. }
  4796. //循环删除记录
  4797. foreach ($id_arr as $v) {
  4798. $dd = $this->whlabel->read($v);
  4799. if (!isset($dd['id'])) {
  4800. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4801. exit;
  4802. }
  4803. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4804. if (isset($zt[0])) {
  4805. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4806. exit;
  4807. }
  4808. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4809. foreach ($deldd as $vv) {
  4810. $this->whlabel->remove($vv['id']);
  4811. }
  4812. }
  4813. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4814. exit;
  4815. }
  4816. $this->_Template('whlabel_error', $this->data);
  4817. }
  4818. public function _errorexcel()
  4819. {
  4820. $post = $this->input->post(NULL, TRUE);
  4821. if (isset($_GET['page'])) {
  4822. $page = $this->input->get('page', true);
  4823. $perpage = $this->input->get('perpage', true);
  4824. $sku = $this->input->get('sku', true);
  4825. $warehouse = $this->input->get('warehouse', true);
  4826. $ktime = $this->input->get('ktime', true);
  4827. $jtime = $this->input->get('jtime', true);
  4828. $ktime = strtotime($ktime);
  4829. $jtime = strtotime($jtime);
  4830. $where = "sku != 'Preset'";
  4831. $gj = '';
  4832. if ($sku) {
  4833. $where .= " and sku like '%$sku%'";
  4834. } else {
  4835. if ($ktime && $jtime) {
  4836. $gj = " and time > '$ktime' and time < '$jtime'";
  4837. }
  4838. }
  4839. if ($warehouse) {
  4840. $where .= " and warehouse = '$warehouse'";
  4841. }
  4842. //数据排序
  4843. $order_str = "id desc";
  4844. if (empty($page)) {
  4845. $start = 0;
  4846. $perpage = 1;
  4847. } else {
  4848. $start = ($page - 1) * $perpage;
  4849. }
  4850. //取得信息列表
  4851. $rows = array();
  4852. $list = array();
  4853. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4854. foreach ($info_list as $value) {
  4855. $warehouse = $this->warehouse->read($value['warehouse']);
  4856. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4857. $number = $value['number'];
  4858. $ftime = time() - 15 * 24 * 3600;
  4859. if ($c < 1) {
  4860. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4861. }
  4862. }
  4863. $title = "0库存汇总";
  4864. $titlename = "<table border=1>
  4865. <tr align='center'>
  4866. <td>仓库</td>
  4867. <td>SKU</td>
  4868. <td>产品</td>
  4869. <td>当前库存</td>
  4870. </tr>
  4871. </table>";
  4872. $filename = $title . ".xls";
  4873. $tail = "";
  4874. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4875. }
  4876. }
  4877. /**
  4878. *
  4879. *
  4880. * 占单
  4881. *
  4882. *
  4883. **/
  4884. public function _kcyz()
  4885. {
  4886. $post = $this->input->post(NULL, TRUE);
  4887. if (isset($post['warehouse'])) {
  4888. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4889. exit; //不再使用
  4890. $warehouse = $this->input->post('warehouse', true);
  4891. $whlabel = $this->input->post('whlabel', true);
  4892. $id = $this->input->post('id', true);
  4893. $shop = $this->input->post('shop', true);
  4894. $number = $this->input->post('number', true);
  4895. if (!$whlabel || $whlabel == '|') {
  4896. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4897. exit;
  4898. }
  4899. $pp = explode('|', trim($whlabel, '|'));
  4900. $x = 0;
  4901. $save = array();
  4902. foreach ($pp as $va) {
  4903. $num = explode('-', $va);
  4904. if ($number) {
  4905. $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 = '')"); //通用
  4906. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4907. } else {
  4908. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4909. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4910. }
  4911. $x++;
  4912. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4913. $save[] = $x - 1;
  4914. continue; //提前先加X不然出错,所以要减1
  4915. }
  4916. }
  4917. if (isset($save[0])) {
  4918. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4919. exit;
  4920. } else {
  4921. echo json_encode(array('success' => true));
  4922. exit;
  4923. }
  4924. }
  4925. }
  4926. public function _db()
  4927. {
  4928. $post = $this->input->post(NULL, TRUE);
  4929. if (isset($post['page'])) {
  4930. $page = $this->input->post('page', true);
  4931. $perpage = $this->input->post('perpage', true);
  4932. $sku = $this->input->post('sku', true);
  4933. $number = $this->input->post('number', true);
  4934. $warehouse = $this->input->post('warehouse', true);
  4935. $purchase = $this->input->post('purchase', true);
  4936. $orderinfo = $this->input->post('orderinfo', true);
  4937. $waybill = $this->input->post('waybill', true);
  4938. $category = $this->input->post('category', true);
  4939. $size = $this->input->post('size', true);
  4940. $grade = $this->input->post('grade', true);
  4941. $color = $this->input->post('color', true);
  4942. $lowe = $this->input->post('lowe', true);
  4943. $state = $this->input->post('state', true);
  4944. $label = $this->input->post('label', true);
  4945. $timetk = $this->input->post('timetkk', true);
  4946. $timetj = $this->input->post('timetjj', true);
  4947. $timetk = strtotime($timetk);
  4948. $timetj = strtotime($timetj);
  4949. $where = "dbtime > 0";
  4950. if ($timetk && $timetj) {
  4951. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4952. }
  4953. if ($sku) {
  4954. $where .= " and sku = '$sku'";
  4955. }
  4956. if ($warehouse) {
  4957. $where .= " and warehouse = '$warehouse'";
  4958. if ($warehouse == 12) {
  4959. $w = 'specialstock';
  4960. } else {
  4961. $w = 'whlabel';
  4962. }
  4963. }
  4964. if ($purchase) {
  4965. $where .= " and purchase = '$purchase'";
  4966. }
  4967. if ($category) {
  4968. $where .= " and features like '%-$category-%'";
  4969. }
  4970. if ($size) {
  4971. $where .= " and features like '%-$size-%'";
  4972. }
  4973. if ($grade) {
  4974. $where .= " and features like '%-$grade-%'";
  4975. }
  4976. if ($color) {
  4977. $where .= " and features like '%-$color-%'";
  4978. }
  4979. if ($lowe) {
  4980. $where .= " and features like '%-$lowe-%'";
  4981. }
  4982. if ($state != '') {
  4983. $where .= " and state = '$state'";
  4984. }
  4985. //数据排序
  4986. $order_str = "dbtime desc";
  4987. if (empty($page)) {
  4988. $start = 0;
  4989. $perpage = 1;
  4990. } else {
  4991. $start = ($page - 1) * $perpage;
  4992. }
  4993. //取得信息列表
  4994. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  4995. foreach ($info_list as $key => $value) {
  4996. $warehouse = $this->$w->read($value['warehouse']);
  4997. $info_list[$key]['warehouse'] = $warehouse['title'];
  4998. $purchase = $this->purchase->read($value['purchase']);
  4999. $info_list[$key]['purchase'] = $purchase['title'];
  5000. if ($value['enter'] != 0) {
  5001. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5002. } else {
  5003. $info_list[$key]['enter'] = "";
  5004. }
  5005. if ($value['dbtime'] != 0) {
  5006. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5007. } else {
  5008. $info_list[$key]['dbtime'] = "";
  5009. }
  5010. if ($value['state'] == 0) {
  5011. $info_list[$key]['state'] = "在库";
  5012. } else if ($value['state'] == 1) {
  5013. $info_list[$key]['state'] = "出库";
  5014. } else if ($value['state'] == 2) {
  5015. $info_list[$key]['state'] = "退库";
  5016. } else if ($value['state'] == 3) {
  5017. $info_list[$key]['state'] = "调拨中";
  5018. } else if ($value['state'] == 4) {
  5019. $info_list[$key]['state'] = "再加工";
  5020. } else if ($value['state'] == 5) {
  5021. $info_list[$key]['state'] = "维修中";
  5022. } else if ($value['state'] == 6) {
  5023. $info_list[$key]['state'] = "盘亏";
  5024. } else if ($value['state'] == 7) {
  5025. $info_list[$key]['state'] = "更换标签";
  5026. } else if ($value['state'] == 8) {
  5027. $info_list[$key]['state'] = "其它";
  5028. } else if ($value['state'] == 9) {
  5029. $info_list[$key]['state'] = "预设";
  5030. }
  5031. }
  5032. $total = $this->whlabel->find_count($where);
  5033. $pagenum = ceil($total / $perpage);
  5034. $over = $total - ($start + $perpage);
  5035. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5036. echo json_encode($rows);
  5037. exit;
  5038. }
  5039. if (isset($post['outsku'])) {
  5040. $time = time();
  5041. $cz = $this->input->post('cz', true);
  5042. $label = $this->input->post('outsku', true);
  5043. $sl = $this->input->post('sl', true);
  5044. $num = $this->input->post('num', true);
  5045. //$warehouse = $this->input->post('warehouse',true);
  5046. if (!$sl) {
  5047. $sl = 1;
  5048. }
  5049. if (!$warehouse) {
  5050. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5051. exit;
  5052. }
  5053. $dblabel = $this->whlabellabel->get_label($label);
  5054. if ($dblabel) {
  5055. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5056. if (count($data) < 1) {
  5057. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5058. exit;
  5059. }
  5060. if (count($data) < $num) {
  5061. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5062. exit;
  5063. }
  5064. for ($i = 0; $i < $sl; $i++) {
  5065. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5066. }
  5067. echo json_encode(array('success' => true));
  5068. exit;
  5069. } else {
  5070. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5071. exit;
  5072. }
  5073. }
  5074. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5075. $this->_Template('whlabel_db', $this->data);
  5076. }
  5077. public function _dbrk()
  5078. {
  5079. $post = $this->input->post(NULL, TRUE);
  5080. if (isset($post['page'])) {
  5081. $page = $this->input->post('page', true);
  5082. $perpage = $this->input->post('perpage', true);
  5083. $sku = $this->input->post('sku', true);
  5084. $number = $this->input->post('number', true);
  5085. $warehouse = $this->input->post('warehouse', true);
  5086. $purchase = $this->input->post('purchase', true);
  5087. $orderinfo = $this->input->post('orderinfo', true);
  5088. $waybill = $this->input->post('waybill', true);
  5089. $category = $this->input->post('category', true);
  5090. $size = $this->input->post('size', true);
  5091. $grade = $this->input->post('grade', true);
  5092. $color = $this->input->post('color', true);
  5093. $lowe = $this->input->post('lowe', true);
  5094. $state = $this->input->post('state', true);
  5095. $label = $this->input->post('label', true);
  5096. $ctime = $this->input->post('ctime', true);
  5097. $timetk = $this->input->post('timetkk', true);
  5098. $timetj = $this->input->post('timetjj', true);
  5099. $timetk = strtotime($timetk);
  5100. $timetj = strtotime($timetj);
  5101. $where = "dbtime > 0";
  5102. if ($timetk && $timetj) {
  5103. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5104. }
  5105. if ($sku) {
  5106. $where .= " and sku = '$sku'";
  5107. }
  5108. if ($warehouse) {
  5109. $where .= " and warehouse = '$warehouse'";
  5110. }
  5111. if ($purchase) {
  5112. $where .= " and purchase = '$purchase'";
  5113. }
  5114. if ($category) {
  5115. $where .= " and features like '%-$category-%'";
  5116. }
  5117. if ($size) {
  5118. $where .= " and features like '%-$size-%'";
  5119. }
  5120. if ($grade) {
  5121. $where .= " and features like '%-$grade-%'";
  5122. }
  5123. if ($color) {
  5124. $where .= " and features like '%-$color-%'";
  5125. }
  5126. if ($lowe) {
  5127. $where .= " and features like '%-$lowe-%'";
  5128. }
  5129. if ($state != '') {
  5130. $where .= " and state = '$state'";
  5131. }
  5132. //数据排序
  5133. $order_str = "dbtime desc";
  5134. if (empty($page)) {
  5135. $start = 0;
  5136. $perpage = 1;
  5137. } else {
  5138. $start = ($page - 1) * $perpage;
  5139. }
  5140. //取得信息列表
  5141. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5142. foreach ($info_list as $key => $value) {
  5143. $warehouse = $this->warehouse->read($value['warehouse']);
  5144. $info_list[$key]['warehouse'] = $warehouse['title'];
  5145. $purchase = $this->purchase->read($value['purchase']);
  5146. $info_list[$key]['purchase'] = $purchase['title'];
  5147. if ($value['enter'] != 0) {
  5148. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5149. } else {
  5150. $info_list[$key]['enter'] = "";
  5151. }
  5152. if ($value['dbtime'] != 0) {
  5153. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5154. } else {
  5155. $info_list[$key]['dbtime'] = "";
  5156. }
  5157. if ($value['state'] == 0) {
  5158. $info_list[$key]['state'] = "在库";
  5159. } else if ($value['state'] == 1) {
  5160. $info_list[$key]['state'] = "出库";
  5161. } else if ($value['state'] == 2) {
  5162. $info_list[$key]['state'] = "退库";
  5163. } else if ($value['state'] == 3) {
  5164. $info_list[$key]['state'] = "调拨中";
  5165. } else if ($value['state'] == 4) {
  5166. $info_list[$key]['state'] = "再加工";
  5167. } else if ($value['state'] == 5) {
  5168. $info_list[$key]['state'] = "维修中";
  5169. } else if ($value['state'] == 6) {
  5170. $info_list[$key]['state'] = "盘亏";
  5171. } else if ($value['state'] == 7) {
  5172. $info_list[$key]['state'] = "更换标签";
  5173. } else if ($value['state'] == 8) {
  5174. $info_list[$key]['state'] = "其它";
  5175. } else if ($value['state'] == 9) {
  5176. $info_list[$key]['state'] = "预设";
  5177. }
  5178. }
  5179. $total = $this->whlabel->find_count($where);
  5180. $pagenum = ceil($total / $perpage);
  5181. $over = $total - ($start + $perpage);
  5182. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5183. echo json_encode($rows);
  5184. exit;
  5185. }
  5186. if (isset($post['rsku'])) {
  5187. $cz = $this->input->post('cz', true);
  5188. $label = $this->input->post('rsku', true);
  5189. $sl = $this->input->post('sl', true);
  5190. $warehouse = $this->input->post('warehouse', true);
  5191. if (!$sl) {
  5192. $sl = 1;
  5193. }
  5194. if (!$warehouse) {
  5195. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5196. exit;
  5197. }
  5198. $dblabel = $this->whlabellabel->get_label($label);
  5199. if ($dblabel) {
  5200. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5201. if (count($data) < 1) {
  5202. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5203. exit;
  5204. }
  5205. if ($sl > count($data)) {
  5206. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5207. exit;
  5208. }
  5209. $time = time();
  5210. for ($i = 0; $i < $sl; $i++) {
  5211. $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']);
  5212. }
  5213. echo json_encode(array('success' => true));
  5214. exit;
  5215. } else {
  5216. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5217. exit;
  5218. }
  5219. }
  5220. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5221. $this->_Template('whlabel_dbrk', $this->data);
  5222. }
  5223. public function _whlabelczdc()
  5224. {
  5225. if (isset($_GET['excel'])) {
  5226. //数据排序
  5227. $order_str = "id desc";
  5228. if (empty($page)) {
  5229. $start = 0;
  5230. $perpage = 1;
  5231. } else {
  5232. $start = ($page - 1) * $perpage;
  5233. }
  5234. $state = $this->input->get('state', true);
  5235. $sku = $this->input->get('sku', true);
  5236. $ctime = $this->input->get('ctime', true);
  5237. $category = $this->input->get('category', true);
  5238. $size = $this->input->get('size', true);
  5239. $grade = $this->input->get('grade', true);
  5240. $color = $this->input->get('color', true);
  5241. $lowe = $this->input->get('lowe', true);
  5242. $timetk = $this->input->get('timetkk', true);
  5243. $timetj = $this->input->get('timetjj', true);
  5244. $timetk = strtotime($timetk);
  5245. $timetj = strtotime($timetj);
  5246. $where = "dbtime > 0";
  5247. if ($timetk && $timetj) {
  5248. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5249. }
  5250. if ($category) {
  5251. $where .= " and features like '%-$category-%'";
  5252. }
  5253. if ($size) {
  5254. $where .= " and features like '%-$size-%'";
  5255. }
  5256. if ($grade) {
  5257. $where .= " and features like '%-$grade-%'";
  5258. }
  5259. if ($color) {
  5260. $where .= " and features like '%-$color-%'";
  5261. }
  5262. if ($lowe) {
  5263. $where .= " and features like '%-$lowe-%'";
  5264. }
  5265. //取得信息列表
  5266. $info_list = $this->whlabel->find_all($where, '*');
  5267. $rows = array();
  5268. $list = array();
  5269. foreach ($info_list as $key => $value) {
  5270. $rows[$value['sku']] = $value; //所有数据sku
  5271. }
  5272. foreach ($rows as $value) {
  5273. $warehouse = $this->warehouse->read($value['warehouse']);
  5274. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5275. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5276. if ($value['orderinfo'] == 0) {
  5277. $info_list[$key]['orderinfo'] = "";
  5278. }
  5279. if ($value['waybill'] == 0) {
  5280. $info_list[$key]['waybill'] = "";
  5281. }
  5282. if ($value['state'] == 0) {
  5283. $value['state'] = "在库";
  5284. } else if ($value['state'] == 3) {
  5285. $value['state'] = "调拨中";
  5286. }
  5287. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5288. }
  5289. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5290. $titlename = "<table border=1>
  5291. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5292. <tr align='center'>
  5293. <td>SKU</td>
  5294. <td>产品</td>
  5295. <td>调拨数量</td>
  5296. <td>入库数量</td>
  5297. </tr>
  5298. </table>";
  5299. $filename = $title . ".xls";
  5300. $tail = "";
  5301. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5302. }
  5303. }
  5304. public function _print($arg_array)
  5305. {
  5306. if (isset($_SESSION['api'])) {
  5307. $user = $this->user->get_api($_SESSION['api']);
  5308. $usp = $user;
  5309. $fgshop = "";
  5310. $sid = "";
  5311. $wid = "";
  5312. $wtype = "";
  5313. $usersp = explode('|', trim($user['shop'], '|'));
  5314. $userwh = explode('|', trim($user['warehouse'], '|'));
  5315. foreach ($usersp as $value) {
  5316. $fgshop .= " shop = " . $value . " or";
  5317. $sid .= " id = " . $value . " or";
  5318. }
  5319. foreach ($userwh as $value) {
  5320. $wid .= " id = " . $value . " or";
  5321. $wtype .= " type = " . $value . " or";
  5322. }
  5323. }
  5324. $post = $this->input->post(NULL, TRUE);
  5325. if (isset($post['tmsku'])) {
  5326. $tmsku = $this->input->post('tmsku', true);
  5327. if (is_numeric($tmsku)) {
  5328. $yyh = $this->whlabellabel->get_label($tmsku);
  5329. } else {
  5330. $yyh = $this->whlabellabel->get_sku($tmsku);
  5331. }
  5332. if ($yyh) {
  5333. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5334. exit;
  5335. } else {
  5336. echo json_encode(array('success' => false));
  5337. exit;
  5338. }
  5339. }
  5340. $classid = $this->classid->sku();
  5341. $pm = $classid;
  5342. $scsku = $classid;
  5343. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5344. if (isset($post['warehouse'])) {
  5345. if ($post['warehouse']) {
  5346. $list = array();
  5347. $num = "";
  5348. $title = "";
  5349. $features = "";
  5350. $order = 0;
  5351. $post['shop'] = '';
  5352. $brand = $this->input->post('brand', true);
  5353. if ($brand != '0,') {
  5354. $b = $this->brand->read(rtrim($brand, ','));
  5355. if ($b) {
  5356. $post['shop'] = str_replace('|', ',', $b['shop']);
  5357. }
  5358. }
  5359. $post['details'] = $this->input->post('details', true); //打印数量
  5360. $xbqnum = $this->input->post('xbqnum', true);
  5361. $post['purchase'] = $this->input->post('purchase', true);
  5362. $post['warehouse'] = $this->input->post('warehouse', true);
  5363. $post['purchase'] = $this->input->post('purchase', true);
  5364. $post['retreatwarehouse'] = $post['warehouse'];
  5365. $post['cpbz'] = $this->input->post('cpbz', true);
  5366. $post['state'] = 9;
  5367. $category = $this->input->post('category', true);
  5368. $list['category'] = $category;
  5369. $list['hairtype'] = $this->input->post('hairtype', true);
  5370. $list['grade'] = $this->input->post('grade', true);
  5371. $size = $this->input->post('size', true);
  5372. $list['size'] = rtrim($size, ',');
  5373. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5374. $list['extension'] = $this->input->post('extension', true);
  5375. if ($category == 1297) {
  5376. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5377. }
  5378. if ($category == 1702) {
  5379. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5380. $list['syother'] = $this->input->post('syother', true);
  5381. }
  5382. if ($category == 133) {
  5383. $list['fittype'] = $this->input->post('fittype', true);
  5384. $list['acother'] = $this->input->post('acother', true);
  5385. }
  5386. $list['color'] = $this->input->post('color', true);
  5387. $list['lowe'] = $this->input->post('lowe', true);
  5388. if ($category == 127) {
  5389. $list['type'] = $this->input->post('type', true);
  5390. $list['headroad'] = $this->input->post('headroad', true);
  5391. $list['density'] = $this->input->post('density', true);
  5392. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5393. $list['lacesize'] = $this->input->post('lacesize', true);
  5394. }
  5395. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5396. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5397. }
  5398. if ($category == 128) {
  5399. $list['lacetype'] = $this->input->post('lacetype', true);
  5400. $list['haircap'] = $this->input->post('haircap', true);
  5401. $list['density'] = $this->input->post('density', true);
  5402. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5403. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5404. $list['wigother'] = $this->input->post('wigother', true);
  5405. $list['wigother1'] = $this->input->post('wigother1', true);
  5406. $list['wigother2'] = $this->input->post('wigother2', true);
  5407. }
  5408. if ($category == 129) {
  5409. $list['wide'] = $this->input->post('wide', true);
  5410. }
  5411. if ($category == 131) {
  5412. $list['gifttype'] = $this->input->post('gifttype', true);
  5413. $list['giftother'] = $this->input->post('giftother', true);
  5414. }
  5415. if ($category == 134) {
  5416. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5417. }
  5418. if ($category == 1297) {
  5419. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5420. $list['sywigother'] = $this->input->post('sywigother', true);
  5421. }
  5422. if ($category == 130 || $category == 133 || $category == 1702) {
  5423. $list['items'] = $this->input->post('items', true);
  5424. $list['weight'] = $this->input->post('weight', true);
  5425. }
  5426. if ($category == 1702) {
  5427. $list['syhairther'] = $this->input->post('syhairther', true);
  5428. }
  5429. foreach ($list as $k => $v) {
  5430. if ($v != 0) {
  5431. $num .= $v;
  5432. $features .= $v . '-';
  5433. $post[$k] = $v;
  5434. $typeclass = $this->typeclass->read($v);
  5435. if (isset($pm[$typeclass['classid']])) {
  5436. if (stripos($typeclass['zh'], '|') !== false) {
  5437. $exzh = explode('|', $typeclass['zh']);
  5438. $pm[$typeclass['classid']] = $exzh[0];
  5439. } else {
  5440. $pm[$typeclass['classid']] = $typeclass['zh'];
  5441. }
  5442. }
  5443. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5444. if ($k != 'size') {
  5445. $title .= $typeclass['title'] . " ";
  5446. }
  5447. }
  5448. }
  5449. $typeclass = $this->typeclass->read($list['size']);
  5450. $title .= $typeclass['title'];
  5451. $time = time();
  5452. $post['title'] = rtrim($title, ' ');
  5453. $post['number'] = $num;
  5454. $post['features'] = '-' . $features;
  5455. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5456. $featurespp = explode('-', trim($featurespp, '-'));
  5457. if (isset($featurespp[5])) {
  5458. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5459. } else {
  5460. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5461. }
  5462. $post['enter'] = $time;
  5463. $post['time'] = $time; //操作时间
  5464. $scsku = implode("-", $scsku);
  5465. $zh = implode(" ", $pm);
  5466. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5467. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5468. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5469. $post['sku'] = $bqsku;
  5470. $label = time() . rand(0, 9);
  5471. $post['label'] = $label;
  5472. $cpid = $this->whlabellabel->find_count();
  5473. $post['cpid'] = $cpid + 1;
  5474. $cpid = $post['cpid'];
  5475. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5476. //if($whlabelbarcode)
  5477. //{
  5478. //$post['label'] = $whlabelbarcode['label'];
  5479. //if(!$this->whlabellabel->insert($post))
  5480. //{
  5481. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5482. //}
  5483. //}
  5484. //else
  5485. //{
  5486. $this->db->trans_begin();
  5487. $this->whlabellabel->insert($post);
  5488. //$this->whlabelbarcode->insert($post);
  5489. if ($this->db->trans_status() === TRUE) {
  5490. $this->db->trans_commit();
  5491. } else {
  5492. $this->db->trans_rollback();
  5493. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5494. exit;
  5495. }
  5496. //}
  5497. $warehouse_name = "";
  5498. $warehouse = $post['warehouse'];
  5499. if($warehouse == 12){
  5500. $warehouse_name = "特殊库存库";
  5501. }
  5502. // if($warehouse == 13){
  5503. // $warehouse_name = "许昌仓";
  5504. // }
  5505. // if($warehouse == 5){
  5506. // $warehouse_name = "美国店";
  5507. // }
  5508. // if($warehouse == 16){
  5509. // $warehouse_name = "定制头套仓";
  5510. // }
  5511. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5512. if(!empty($warehouse_name)){
  5513. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5514. }
  5515. $purchase = $this->purchase->read($post['purchase']);
  5516. 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));
  5517. exit; //特殊仓目前不需要仓库选项
  5518. }
  5519. }
  5520. if (isset($_SESSION['api'])) {
  5521. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5522. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5523. $this->data['wlshop'] = $wlshop;
  5524. $this->data['warehouse'] = $warehouse;
  5525. }
  5526. $whlabelwz = $this->whlabelwz->find_all();
  5527. $this->data['whlabelwz'] = $whlabelwz;
  5528. $this->_Template('whlabel_print', $this->data);
  5529. }
  5530. public function _usaprint($arg_array)
  5531. {
  5532. if (isset($_SESSION['api'])) {
  5533. $user = $this->user->get_api($_SESSION['api']);
  5534. $usp = $user;
  5535. $fgshop = "";
  5536. $sid = "";
  5537. $wid = "";
  5538. $wtype = "";
  5539. $usersp = explode('|', trim($user['shop'], '|'));
  5540. $userwh = explode('|', trim($user['warehouse'], '|'));
  5541. foreach ($usersp as $value) {
  5542. $fgshop .= " shop = " . $value . " or";
  5543. $sid .= " id = " . $value . " or";
  5544. }
  5545. foreach ($userwh as $value) {
  5546. $wid .= " id = " . $value . " or";
  5547. $wtype .= " type = " . $value . " or";
  5548. }
  5549. }
  5550. $post = $this->input->post(NULL, TRUE);
  5551. if (isset($post['tmsku'])) {
  5552. $tmsku = $this->input->post('tmsku', true);
  5553. if (is_numeric($tmsku)) {
  5554. $yyh = $this->whlabellabel->get_label($tmsku);
  5555. } else {
  5556. $yyh = $this->whlabellabel->get_sku($tmsku);
  5557. }
  5558. if ($yyh) {
  5559. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5560. exit;
  5561. } else {
  5562. echo json_encode(array('success' => false));
  5563. exit;
  5564. }
  5565. }
  5566. $classid = $this->classid->sku();
  5567. $pm = $classid;
  5568. $scsku = $classid;
  5569. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5570. if (isset($post['warehouse'])) {
  5571. if ($post['warehouse']) {
  5572. $list = array();
  5573. $num = "";
  5574. $title = "";
  5575. $features = "";
  5576. $order = 0;
  5577. $post['shop'] = '';
  5578. $brand = $this->input->post('brand', true);
  5579. if ($brand != '0,') {
  5580. $b = $this->brand->read(rtrim($brand, ','));
  5581. if ($b) {
  5582. $post['shop'] = str_replace('|', ',', $b['shop']);
  5583. }
  5584. }
  5585. $post['details'] = $this->input->post('details', true); //打印数量
  5586. $xbqnum = $this->input->post('xbqnum', true);
  5587. $post['purchase'] = $this->input->post('purchase', true);
  5588. $post['warehouse'] = $this->input->post('warehouse', true);
  5589. $post['purchase'] = $this->input->post('purchase', true);
  5590. $post['retreatwarehouse'] = $post['warehouse'];
  5591. $post['cpbz'] = $this->input->post('cpbz', true);
  5592. $post['state'] = 9;
  5593. $category = $this->input->post('category', true);
  5594. $list['category'] = $category;
  5595. $list['hairtype'] = $this->input->post('hairtype', true);
  5596. $list['grade'] = $this->input->post('grade', true);
  5597. $size = $this->input->post('size', true);
  5598. $list['size'] = rtrim($size, ',');
  5599. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5600. $list['extension'] = $this->input->post('extension', true);
  5601. if ($category == 1297) {
  5602. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5603. }
  5604. if ($category == 1702) {
  5605. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5606. $list['syother'] = $this->input->post('syother', true);
  5607. }
  5608. if ($category == 133) {
  5609. $list['fittype'] = $this->input->post('fittype', true);
  5610. $list['acother'] = $this->input->post('acother', true);
  5611. }
  5612. $list['color'] = $this->input->post('color', true);
  5613. $list['lowe'] = $this->input->post('lowe', true);
  5614. if ($category == 127) {
  5615. $list['type'] = $this->input->post('type', true);
  5616. $list['headroad'] = $this->input->post('headroad', true);
  5617. $list['density'] = $this->input->post('density', true);
  5618. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5619. $list['lacesize'] = $this->input->post('lacesize', true);
  5620. }
  5621. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5622. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5623. }
  5624. if ($category == 128) {
  5625. $list['lacetype'] = $this->input->post('lacetype', true);
  5626. $list['haircap'] = $this->input->post('haircap', true);
  5627. $list['density'] = $this->input->post('density', true);
  5628. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5629. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5630. $list['wigother'] = $this->input->post('wigother', true);
  5631. $list['wigother2'] = $this->input->post('wigother2', true);
  5632. }
  5633. if ($category == 129) {
  5634. $list['wide'] = $this->input->post('wide', true);
  5635. }
  5636. if ($category == 131) {
  5637. $list['gifttype'] = $this->input->post('gifttype', true);
  5638. $list['giftother'] = $this->input->post('giftother', true);
  5639. }
  5640. if ($category == 134) {
  5641. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5642. }
  5643. if ($category == 1297) {
  5644. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5645. $list['sywigother'] = $this->input->post('sywigother', true);
  5646. }
  5647. if ($category == 130 || $category == 133 || $category == 1702) {
  5648. $list['items'] = $this->input->post('items', true);
  5649. $list['weight'] = $this->input->post('weight', true);
  5650. }
  5651. if ($category == 1702) {
  5652. $list['syhairther'] = $this->input->post('syhairther', true);
  5653. }
  5654. foreach ($list as $k => $v) {
  5655. if ($v != 0) {
  5656. $num .= $v;
  5657. $features .= $v . '-';
  5658. $post[$k] = $v;
  5659. $typeclass = $this->typeclass->read($v);
  5660. if (isset($pm[$typeclass['classid']])) {
  5661. if (stripos($typeclass['zh'], '|') !== false) {
  5662. $exzh = explode('|', $typeclass['zh']);
  5663. $pm[$typeclass['classid']] = $exzh[0];
  5664. } else {
  5665. $pm[$typeclass['classid']] = $typeclass['zh'];
  5666. }
  5667. }
  5668. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5669. if ($k != 'size') {
  5670. $title .= $typeclass['title'] . " ";
  5671. }
  5672. }
  5673. }
  5674. $typeclass = $this->typeclass->read($list['size']);
  5675. $title .= $typeclass['title'];
  5676. $time = time();
  5677. $post['title'] = rtrim($title, ' ');
  5678. $post['number'] = $num;
  5679. $post['features'] = '-' . $features;
  5680. $fp = $this->whlabel->get_features($post['features']);
  5681. if (!$fp) {
  5682. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5683. exit;
  5684. }
  5685. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5686. $featurespp = explode('-', trim($featurespp, '-'));
  5687. if (isset($featurespp[5])) {
  5688. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5689. } else {
  5690. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5691. }
  5692. $post['enter'] = $time;
  5693. $post['time'] = $time; //操作时间
  5694. $scsku = implode("-", $scsku);
  5695. $zh = implode(" ", $pm);
  5696. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5697. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5698. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5699. $post['sku'] = $fp['sku'];
  5700. $post['label'] = $fp['sku'];
  5701. $cpid = $this->whlabellabel->find_count();
  5702. $post['cpid'] = $cpid + 1;
  5703. $cpid = $post['cpid'];
  5704. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5705. //if($whlabelbarcode)
  5706. //{
  5707. //$post['label'] = $whlabelbarcode['label'];
  5708. //if(!$this->whlabellabel->insert($post))
  5709. //{
  5710. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5711. //}
  5712. //}
  5713. //else
  5714. //{
  5715. $this->db->trans_begin();
  5716. $this->whlabellabel->insert($post);
  5717. //$this->whlabelbarcode->insert($post);
  5718. if ($this->db->trans_status() === TRUE) {
  5719. $this->db->trans_commit();
  5720. } else {
  5721. $this->db->trans_rollback();
  5722. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5723. exit;
  5724. }
  5725. //}
  5726. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5727. $purchase = $this->purchase->read($post['purchase']);
  5728. 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));
  5729. exit; //特殊仓目前不需要仓库选项
  5730. }
  5731. }
  5732. if (isset($_SESSION['api'])) {
  5733. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5734. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5735. $this->data['wlshop'] = $wlshop;
  5736. $this->data['warehouse'] = $warehouse;
  5737. }
  5738. $whlabelwz = $this->whlabelwz->find_all();
  5739. $this->data['whlabelwz'] = $whlabelwz;
  5740. $this->_Template('whlabel_usaprint', $this->data);
  5741. }
  5742. public function _printrk($arg_array)
  5743. {
  5744. $prc = array();
  5745. $purchase = $this->purchase->find_all();
  5746. foreach ($purchase as $k => $v) {
  5747. $prc[$v['id']] = $v['title'];
  5748. }
  5749. $post = $this->input->post(NULL, TRUE);
  5750. if (isset($post['page'])) {
  5751. $page = $this->input->post('page', true);
  5752. $perpage = $this->input->post('perpage', true);
  5753. $sku = $this->input->post('sku', true);
  5754. $bs = $this->input->post('bs', true);
  5755. $number = $this->input->post('number', true);
  5756. $warehouse = $this->input->post('warehouse', true);
  5757. $purchase = $this->input->post('purchase', true);
  5758. $orderinfo = $this->input->post('orderinfo', true);
  5759. $waybill = $this->input->post('waybill', true);
  5760. $category = $this->input->post('category', true);
  5761. $size = $this->input->post('size', true);
  5762. $grade = $this->input->post('grade', true);
  5763. $color = $this->input->post('color', true);
  5764. $lowe = $this->input->post('lowe', true);
  5765. $state = $this->input->post('state', true);
  5766. $label = $this->input->post('label', true);
  5767. $timetk = $this->input->post('ktime', true);
  5768. $timetj = $this->input->post('jtime', true);
  5769. $timetk = strtotime($timetk);
  5770. $timetj = strtotime($timetj);
  5771. $where = "1=1 ";
  5772. if ($timetk && $timetj) {
  5773. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5774. }
  5775. if ($sku) {
  5776. $where .= " and sku = '$sku'";
  5777. }
  5778. if ($bs != '') {
  5779. $where .= " and bs = '$bs'";
  5780. }
  5781. if ($number) {
  5782. $where .= " and number = '$number'";
  5783. }
  5784. if ($warehouse) {
  5785. $where .= " and warehouse = '$warehouse'";
  5786. }
  5787. if ($purchase) {
  5788. $where .= " and purchase = '$purchase'";
  5789. }
  5790. if ($orderinfo) {
  5791. $where .= " and orderinfo = '$orderinfo'";
  5792. }
  5793. if ($waybill) {
  5794. $where .= " and waybill = '$waybill'";
  5795. }
  5796. if ($category) {
  5797. $where .= " and features like '%-$category-%'";
  5798. }
  5799. if ($size) {
  5800. $where .= " and features like '%-$size-%'";
  5801. }
  5802. if ($grade) {
  5803. $where .= " and features like '%-$grade-%'";
  5804. }
  5805. if ($color) {
  5806. $where .= " and features like '%-$color-%'";
  5807. }
  5808. if ($lowe) {
  5809. $where .= " and features like '%-$lowe-%'";
  5810. }
  5811. if ($label) {
  5812. $where .= " and label = '$label'";
  5813. }
  5814. if ($state || $state == 0) {
  5815. $where .= " and state = '$state'";
  5816. }
  5817. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5818. //数据排序
  5819. $order_str = "enter desc";
  5820. if (empty($page)) {
  5821. $start = 0;
  5822. $perpage = 1;
  5823. } else {
  5824. $start = ($page - 1) * $perpage;
  5825. }
  5826. //取得信息列表
  5827. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5828. foreach ($info_list as $key => $value) {
  5829. $warehouse = $this->warehouse->read($value['warehouse']);
  5830. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5831. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5832. if ($value['state'] == 0) {
  5833. $info_list[$key]['state'] = "在库";
  5834. } else if ($value['state'] == 1) {
  5835. $info_list[$key]['state'] = "出库";
  5836. } else if ($value['state'] == 2) {
  5837. $info_list[$key]['state'] = "退库";
  5838. } else if ($value['state'] == 3) {
  5839. $info_list[$key]['state'] = "调拨中";
  5840. } else if ($value['state'] == 4) {
  5841. $info_list[$key]['state'] = "再加工";
  5842. } else if ($value['state'] == 5) {
  5843. $info_list[$key]['state'] = "维修中";
  5844. } else if ($value['state'] == 6) {
  5845. $info_list[$key]['state'] = "盘亏";
  5846. } else if ($value['state'] == 7) {
  5847. $info_list[$key]['state'] = "更换标签";
  5848. } else if ($value['state'] == 8) {
  5849. $info_list[$key]['state'] = "其它";
  5850. } else if ($value['state'] == 9) {
  5851. $info_list[$key]['state'] = "预设";
  5852. } else if ($value['state'] == 10) {
  5853. $info_list[$key]['state'] = "美店零售";
  5854. }
  5855. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5856. }
  5857. $total = $this->$ck->find_count($where);
  5858. $pagenum = ceil($total / $perpage);
  5859. $over = $total - ($start + $perpage);
  5860. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5861. echo json_encode($rows);
  5862. exit;
  5863. }
  5864. if (isset($post['tmsku'])) {
  5865. $time = time();
  5866. $tmsku = $this->input->post('tmsku', true);
  5867. //$post['shop'] = $this->input->post('shop',true);
  5868. $num = $this->input->post('num', true);
  5869. $rktype = $this->input->post('rktype', true);
  5870. if ($num > 200) {
  5871. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5872. exit;
  5873. }
  5874. if (!$rktype) {
  5875. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5876. }
  5877. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5878. /**
  5879. $wz = array();
  5880. foreach ($rk as $key=>$value)
  5881. {
  5882. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5883. }
  5884. if(count($wz) > 1)
  5885. {
  5886. $wz = array_values($wz);
  5887. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5888. }
  5889. **/
  5890. if (isset($rk[0]['purchase'])) {
  5891. $rk = $rk[0];
  5892. $j = 0;
  5893. $post['purchase'] = $rk['purchase'];
  5894. $post['warehouse'] = $rk['warehouse'];
  5895. $post['retreatwarehouse'] = $rk['warehouse'];
  5896. $post['sku'] = $rk['sku'];
  5897. $post['number'] = $rk['number'];
  5898. $post['features'] = $rk['features'];
  5899. $post['title'] = $rk['title'];
  5900. $post['enter'] = $time;
  5901. $post['time'] = $time;
  5902. $post['bs'] = 1;
  5903. $post['shop'] = $rk['shop'];
  5904. $post['details'] = $rk['details'];
  5905. $post['cpid'] = $rk['cpid'];
  5906. $post['cpbz'] = $rk['cpbz'];
  5907. //$post['rktype'] = $rktype;
  5908. $warehouse = $this->warehouse->read($rk['warehouse']);
  5909. if ($warehouse['bdck'] == '') {
  5910. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5911. exit;
  5912. } else {
  5913. $bdck = $warehouse['bdck'];
  5914. }
  5915. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5916. if (isset($pdwz['details'])) {
  5917. if ($pdwz['details'] != $post['details']) {
  5918. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5919. exit;
  5920. }
  5921. }
  5922. $post['featurespp'] = $rk['featurespp'];
  5923. if ($post['warehouse'] == '5') {
  5924. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5925. if ($yza) {
  5926. if ($post['features'] != $yza[0]['features']) {
  5927. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5928. exit;
  5929. }
  5930. }
  5931. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5932. if ($yzb) {
  5933. if ($post['sku'] != $yzb[0]['sku']) {
  5934. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5935. exit;
  5936. }
  5937. }
  5938. }
  5939. for ($i = 0; $i < $num; $i++) {
  5940. $post['label'] = time() . rand(100, 999) . $i;
  5941. if ($this->$bdck->insert($post)) {
  5942. $j++;
  5943. }
  5944. }
  5945. /**
  5946. if($post['warehouse'] != 12)
  5947. {
  5948. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5949. }
  5950. **/
  5951. if ($j == $num) {
  5952. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5953. exit;
  5954. } else {
  5955. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5956. exit;
  5957. }
  5958. } else {
  5959. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5960. exit;
  5961. }
  5962. }
  5963. $this->_Template('whlabel_printrk', $this->data);
  5964. }
  5965. public function _printxzrk($arg_array)
  5966. {
  5967. $post = $this->input->post(NULL, TRUE);
  5968. if (isset($post['wzid'])) {
  5969. $time = time();
  5970. $id = $this->input->post('wzid', true);
  5971. //$post['shop'] = $this->input->post('shop',true);
  5972. $num = 1;
  5973. $rk = $this->whlabellabel->read($id);
  5974. if (isset($rk['purchase'])) {
  5975. $x = 0;
  5976. $post['purchase'] = $rk['purchase'];
  5977. $post['warehouse'] = $rk['warehouse'];
  5978. $post['retreatwarehouse'] = $rk['warehouse'];
  5979. $post['sku'] = $rk['sku'];
  5980. $post['number'] = $rk['number'];
  5981. $post['features'] = $rk['features'];
  5982. $post['title'] = $rk['title'];
  5983. $post['enter'] = $time;
  5984. $post['time'] = $time;
  5985. $post['bs'] = 1;
  5986. $post['shop'] = $rk['shop'];
  5987. $post['details'] = $rk['details'];
  5988. $post['cpid'] = $rk['cpid'];
  5989. $post['cpbz'] = $rk['cpbz'];
  5990. $warehouse = $this->warehouse->read($rk['warehouse']);
  5991. if ($warehouse['bdck'] == '') {
  5992. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  5993. exit;
  5994. } else {
  5995. $bdck = $warehouse['bdck'];
  5996. }
  5997. $post['featurespp'] = $rk['featurespp'];
  5998. $this->db->trans_begin();
  5999. for ($i = 0; $i < $num; $i++) {
  6000. $post['label'] = time() . rand(100, 999) . $i;
  6001. $this->$bdck->insert($post);
  6002. }
  6003. /**
  6004. if($post['warehouse'] != 12)
  6005. {
  6006. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6007. }
  6008. **/
  6009. if ($this->db->trans_status() === TRUE) {
  6010. $this->db->trans_commit();
  6011. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6012. exit;
  6013. } else {
  6014. $this->db->trans_rollback();
  6015. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6016. exit;
  6017. }
  6018. } else {
  6019. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6020. exit;
  6021. }
  6022. }
  6023. }
  6024. public function _printck($arg_array)
  6025. {
  6026. $prc = array();
  6027. $purchase = $this->purchase->find_all();
  6028. foreach ($purchase as $k => $v) {
  6029. $prc[$v['id']] = $v['title'];
  6030. }
  6031. $post = $this->input->post(NULL, TRUE);
  6032. if (isset($post['page'])) {
  6033. $page = $this->input->post('page', true);
  6034. $perpage = $this->input->post('perpage', true);
  6035. $sku = $this->input->post('sku', true);
  6036. $bs = $this->input->post('bs', true);
  6037. $number = $this->input->post('number', true);
  6038. $warehouse = $this->input->post('warehouse', true);
  6039. $purchase = $this->input->post('purchase', true);
  6040. $orderinfo = $this->input->post('orderinfo', true);
  6041. $waybill = $this->input->post('waybill', true);
  6042. $category = $this->input->post('category', true);
  6043. $size = $this->input->post('size', true);
  6044. $grade = $this->input->post('grade', true);
  6045. $color = $this->input->post('color', true);
  6046. $lowe = $this->input->post('lowe', true);
  6047. $state = $this->input->post('state', true);
  6048. $label = $this->input->post('label', true);
  6049. $timetk = $this->input->post('ktime', true);
  6050. $timetj = $this->input->post('jtime', true);
  6051. $timetk = strtotime($timetk);
  6052. $timetj = strtotime($timetj);
  6053. $where = "state=1 ";
  6054. if ($timetk && $timetj) {
  6055. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6056. }
  6057. if ($sku) {
  6058. $where .= " and sku = '$sku'";
  6059. }
  6060. if ($bs != '') {
  6061. $where .= " and bs = '$bs'";
  6062. }
  6063. if ($number) {
  6064. $where .= " and number = '$number'";
  6065. }
  6066. if ($warehouse) {
  6067. $where .= " and warehouse = '$warehouse'";
  6068. }
  6069. if ($purchase) {
  6070. $where .= " and purchase = '$purchase'";
  6071. }
  6072. if ($orderinfo) {
  6073. $where .= " and orderinfo = '$orderinfo'";
  6074. }
  6075. if ($waybill) {
  6076. $where .= " and waybill = '$waybill'";
  6077. }
  6078. if ($category) {
  6079. $where .= " and features like '%-$category-%'";
  6080. }
  6081. if ($size) {
  6082. $where .= " and features like '%-$size-%'";
  6083. }
  6084. if ($grade) {
  6085. $where .= " and features like '%-$grade-%'";
  6086. }
  6087. if ($color) {
  6088. $where .= " and features like '%-$color-%'";
  6089. }
  6090. if ($lowe) {
  6091. $where .= " and features like '%-$lowe-%'";
  6092. }
  6093. if ($label) {
  6094. $where .= " and label = '$label'";
  6095. }
  6096. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6097. //数据排序
  6098. $order_str = "outk desc";
  6099. if (empty($page)) {
  6100. $start = 0;
  6101. $perpage = 1;
  6102. } else {
  6103. $start = ($page - 1) * $perpage;
  6104. }
  6105. //取得信息列表
  6106. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6107. foreach ($info_list as $key => $value) {
  6108. $warehouse = $this->warehouse->read($value['warehouse']);
  6109. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6110. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6111. if ($value['state'] == 0) {
  6112. $info_list[$key]['state'] = "在库";
  6113. } else if ($value['state'] == 1) {
  6114. $info_list[$key]['state'] = "出库";
  6115. } else if ($value['state'] == 2) {
  6116. $info_list[$key]['state'] = "退库";
  6117. } else if ($value['state'] == 3) {
  6118. $info_list[$key]['state'] = "调拨中";
  6119. } else if ($value['state'] == 4) {
  6120. $info_list[$key]['state'] = "再加工";
  6121. } else if ($value['state'] == 5) {
  6122. $info_list[$key]['state'] = "维修中";
  6123. } else if ($value['state'] == 6) {
  6124. $info_list[$key]['state'] = "盘亏";
  6125. } else if ($value['state'] == 7) {
  6126. $info_list[$key]['state'] = "更换标签";
  6127. } else if ($value['state'] == 8) {
  6128. $info_list[$key]['state'] = "其它";
  6129. } else if ($value['state'] == 9) {
  6130. $info_list[$key]['state'] = "预设";
  6131. } else if ($value['state'] == 10) {
  6132. $info_list[$key]['state'] = "美店零售";
  6133. }
  6134. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6135. }
  6136. $total = $this->$ck->find_count($where);
  6137. $pagenum = ceil($total / $perpage);
  6138. $over = $total - ($start + $perpage);
  6139. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6140. echo json_encode($rows);
  6141. exit;
  6142. }
  6143. if (isset($post['tmsku'])) {
  6144. $time = time();
  6145. $tmsku = $this->input->post('tmsku', true);
  6146. //$post['shop'] = $this->input->post('shop',true);
  6147. $num = $this->input->post('num', true);
  6148. $cktype = $this->input->post('cktype', true);
  6149. $label = $this->whlabellabel->get_label($tmsku);
  6150. if (!$cktype) {
  6151. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6152. }
  6153. if (!isset($label['warehouse'])) {
  6154. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6155. exit;
  6156. }
  6157. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6158. if (stripos($label['features'], '-126-') !== false) {
  6159. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6160. } else {
  6161. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and purchase = '" . $label['purchase'] . "' and zd = ''");
  6162. }
  6163. $j = 0;
  6164. if (count($ck) >= $num) {
  6165. for ($i = 0; $i < $num; $i++) {
  6166. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6167. {
  6168. $j++;
  6169. }
  6170. }
  6171. if ($j == $num) {
  6172. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6173. exit;
  6174. } else {
  6175. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6176. exit;
  6177. }
  6178. } else {
  6179. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6180. exit;
  6181. }
  6182. }
  6183. $this->_Template('whlabel_printck', $this->data);
  6184. }
  6185. public function _printexcel()
  6186. {
  6187. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6188. $config['upload_path'] = '.' . $dir;
  6189. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6190. $config['allowed_types'] = 'xls|xlsx|csv';
  6191. $config['max_size'] = 10240;
  6192. $this->load->library('upload', $config);
  6193. $this->upload->initialize($config);
  6194. if ($this->upload->do_upload('userfile')) {
  6195. $full_path = $dir . $this->upload->data('file_name');
  6196. $fileName = '.' . $full_path;
  6197. if (!file_exists($fileName)) {
  6198. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6199. exit;
  6200. } else {
  6201. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6202. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6203. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6204. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6205. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6206. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6207. ++$column; //如果列数大于26行
  6208. $list = array();
  6209. for ($i = 2; $i <= $row; $i++) // 行数循环
  6210. {
  6211. $data = array();
  6212. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6213. {
  6214. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6215. }
  6216. $list[] = $data;
  6217. }
  6218. }
  6219. $ed = array();
  6220. $i = 0;
  6221. $j = 0;
  6222. $dcdata = array();
  6223. $yc = '';
  6224. $cmf_arr = array_column($list, '1');
  6225. array_multisort($cmf_arr, SORT_ASC, $list);
  6226. foreach ($list as $key => $value) {
  6227. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6228. if ($typeclass) {
  6229. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6230. } else {
  6231. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6232. $i++;
  6233. continue;
  6234. }
  6235. }
  6236. if ($i > 0) {
  6237. $yc = $i . '条异常';
  6238. }
  6239. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6240. exit;
  6241. }
  6242. }
  6243. public function _uck()
  6244. {
  6245. if (isset($_GET['excel'])) {
  6246. $tc = array();
  6247. $typeclass = $this->typeclass->find_all();
  6248. foreach ($typeclass as $v) {
  6249. $tc[$v['id']] = $v['zh'];
  6250. }
  6251. $data = array();
  6252. $t = array();
  6253. $rq = '';
  6254. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6255. $ts = $ts / (24 * 3600);
  6256. for ($i = 0; $i < $ts; $i++) {
  6257. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6258. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6259. }
  6260. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6261. foreach ($info_list as $k => $v) {
  6262. $features = explode('-', trim($v['features'], '-'));
  6263. if (!isset($features[3]) || !isset($features[4])) {
  6264. continue;
  6265. }
  6266. $data[$k][0] = $tc[$features[0]]; //类型
  6267. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6268. $data[$k][2] = $tc[$features[4]]; //曲度
  6269. $data[$k][3] = '';
  6270. if (isset($data[$k][1])) {
  6271. $data[$k][3] .= $data[$k][1];
  6272. }
  6273. if (isset($data[$k][2])) {
  6274. $data[$k][3] .= $data[$k][2];
  6275. }
  6276. if (isset($features[5])) {
  6277. $data[$k][3] .= $tc[$features[5]];
  6278. }
  6279. if (isset($features[2])) {
  6280. $data[$k][3] .= $tc[$features[2]];
  6281. }
  6282. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6283. $data[$k][4] = $v['sku'];
  6284. $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())) . '))'); //月初库存
  6285. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6286. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6287. $ztrq = '';
  6288. $ztsl = '';
  6289. if (count($zt) > 0) {
  6290. foreach ($zt as $vv) {
  6291. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6292. $ztsl .= $vv['num'] . '<br>';
  6293. }
  6294. }
  6295. $data[$k][] = trim($ztsl, '<br>');
  6296. $data[$k][] = trim($ztrq, '<br>');
  6297. $byck = 0;
  6298. foreach ($t as $vv) {
  6299. $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));
  6300. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6301. $byck += $sl;
  6302. }
  6303. $data[$k][] = ($byck > 0) ? $byck : '';
  6304. }
  6305. $title = "详情 " . date("Y-m-d", time());
  6306. $titlename = "<table border=1>
  6307. <tr align='center'>
  6308. <td>类别</td>
  6309. <td>颜色</td>
  6310. <td>曲度</td>
  6311. <td>名称</td>
  6312. <td>SKU</td>
  6313. <td>月初库存</td>
  6314. <td>剩余库存</td>
  6315. <td>在途数量</td>
  6316. <td>预达日期</td>" .
  6317. $rq
  6318. . "<td>本月出库</td></tr>
  6319. </table>";
  6320. $filename = $title . ".xls";
  6321. $tail = "";
  6322. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6323. }
  6324. }
  6325. public function _whlabelexcelzh()
  6326. {
  6327. if (isset($_GET['excel'])) {
  6328. $where = "sku != 'Preset'";
  6329. //数据排序
  6330. $order_str = "id desc";
  6331. if (empty($page)) {
  6332. $start = 0;
  6333. $perpage = 1;
  6334. } else {
  6335. $start = ($page - 1) * $perpage;
  6336. }
  6337. $category = $this->input->get('category', true);
  6338. $warehouse = $this->input->get('warehouse', true);
  6339. $excelid = $this->input->get('sid', true);
  6340. if ($category) {
  6341. $where .= " and features like '%-$category-%'";
  6342. }
  6343. if ($warehouse) {
  6344. $where .= " and warehouse = '$warehouse'";
  6345. }
  6346. $xzid = '';
  6347. if ($excelid) {
  6348. $excelid = explode(',', trim($excelid, ','));
  6349. foreach ($excelid as $key => $value) {
  6350. $xzid .= " id = " . $value . " or";
  6351. }
  6352. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6353. }
  6354. //取得信息列表
  6355. /**
  6356. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6357. $rows = array();$list = array();
  6358. foreach ($info_list as $key=>$value)
  6359. {
  6360. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6361. }
  6362. **/
  6363. $list = array();
  6364. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6365. foreach ($rows as $key => $value) {
  6366. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6367. $zh = '';
  6368. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6369. foreach ($zt as $v) {
  6370. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6371. }
  6372. $zt = array_sum(array_column($zt, 'num'));
  6373. $number = $value['number'];
  6374. $ftime = time() - 15 * 24 * 3600;
  6375. $warehouse = $this->warehouse->read($value['warehouse']);
  6376. $rows[$key]['warehouse'] = $warehouse['title'];
  6377. $rows[$key]['number'] = $c;
  6378. $rows[$key]['features'] = $zh;
  6379. $rows[$key]['hb'] = $c + $zt;
  6380. }
  6381. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6382. $titlename = "<table border=1>
  6383. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6384. <tr align='center'>
  6385. <td>仓库</td>
  6386. <td>SKU</td>
  6387. <td>产品</td>
  6388. <td>库存数量</td>
  6389. <td>在途数量及预达日期</td>
  6390. <td>在途+库存数量</td>
  6391. </tr>
  6392. </table>";
  6393. $filename = $title . ".xls";
  6394. $tail = "";
  6395. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6396. }
  6397. if (isset($_GET['excel'])) {
  6398. $warehouse = $this->input->get('warehouse', true);
  6399. $sku = $this->input->get('sku', true);
  6400. $cz = $this->input->get('cz', true);
  6401. $text = $this->input->post('text', true);
  6402. $xztime = $this->input->get('xztime', true);
  6403. $timetk = $this->input->get('timetk', true);
  6404. $timetj = $this->input->get('timetj', true);
  6405. $timetk = strtotime($timetk);
  6406. $timetj = strtotime($timetj);
  6407. $where = "time = '0' ";
  6408. if ($warehouse) {
  6409. $where .= " and warehouse = '$warehouse'";
  6410. }
  6411. if ($sku) {
  6412. $where .= " and sku = '$sku'";
  6413. }
  6414. if ($text) {
  6415. $where .= " and text like '%$text%'";
  6416. }
  6417. if ($cz != '') {
  6418. $where .= " and cz = '$cz'";
  6419. }
  6420. if ($timetk && $timetj) {
  6421. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6422. }
  6423. //数据排序
  6424. $order_str = $xztime . " desc";
  6425. //取得信息列表
  6426. $zh = array();
  6427. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6428. foreach ($info_list as $v) {
  6429. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6430. $warehouse = $this->warehouse->read($v['warehouse']);
  6431. $v['warehouse'] = $warehouse['title'];
  6432. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6433. $v['stime'] = date('Y-m-d', $v['stime']);
  6434. if (isset($zh[$v['features']])) {
  6435. $zh[$v['features']]['num'] += $v['num'];
  6436. } else {
  6437. $zh[$v['features']] = $v;
  6438. }
  6439. $zh[$v['features']]['features'] = $c;
  6440. }
  6441. $title = "在途数据" . date('Y-m-d', time());
  6442. $titlename = "<table border=1>
  6443. <tr align='center'>
  6444. <td>仓库</td>
  6445. <td>SKU</td>
  6446. <td>名称</td>
  6447. <td>在途数量</td>
  6448. <td>库存数量</td>
  6449. <td>添加在途日期</td>
  6450. <td>预达日期</td>
  6451. <td>备注</td>
  6452. </tr>
  6453. </table>";
  6454. $filename = $title . ".xls";
  6455. $tail = "";
  6456. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6457. }
  6458. }
  6459. public function _fc()
  6460. {
  6461. $vip = 0;
  6462. if (isset($_SESSION['api'])) {
  6463. $user = $this->user->get_api($_SESSION['api']);
  6464. if ($user['vip'] == 1) {
  6465. $vip = 1;
  6466. }
  6467. } else {
  6468. header('Location: /');
  6469. exit;
  6470. }
  6471. $post = $this->input->post(NULL, TRUE);
  6472. if (isset($post['page'])) {
  6473. $page = $this->input->post('page', true);
  6474. $perpage = $this->input->post('perpage', true);
  6475. $category = $this->input->post('category', true);
  6476. $size = $this->input->post('size', true);
  6477. $grade = $this->input->post('grade', true);
  6478. $color = $this->input->post('color', true);
  6479. $lowe = $this->input->post('lowe', true);
  6480. $sku = $this->input->post('sku');
  6481. $title = $this->input->post('title');
  6482. $warehouse = $this->input->post('warehouse', true);
  6483. $usa = $this->input->post('usa', true);
  6484. $purchase = $this->input->post('purchase', true);
  6485. $lacetype = $this->input->post('lacetype', true);
  6486. $haircap = $this->input->post('haircap', true);
  6487. $density = $this->input->post('density', true);
  6488. $details = $this->input->post('details', true);
  6489. $state = $this->input->post('state', true);
  6490. $ktime = $this->input->post('ktime', true);
  6491. $jtime = $this->input->post('jtime', true);
  6492. $ktime = strtotime($ktime);
  6493. $jtime = strtotime($jtime);
  6494. $where = "state = '11'";
  6495. $gj = "";
  6496. $ck = "";
  6497. if ($lacetype) {
  6498. $where .= " and features like '%-$lacetype-%'";
  6499. }
  6500. if ($category) {
  6501. $where .= " and features like '%-$category-%'";
  6502. }
  6503. if ($size) {
  6504. $where .= " and features like '%-$size-%'";
  6505. }
  6506. if ($grade) {
  6507. $where .= " and features like '%-$grade-%'";
  6508. }
  6509. if ($color) {
  6510. $where .= " and features like '%-$color-%'";
  6511. }
  6512. if ($lowe) {
  6513. $where .= " and features like '%-$lowe-%'";
  6514. }
  6515. if ($haircap) {
  6516. $where .= " and features like '%-$haircap-%'";
  6517. }
  6518. if ($density) {
  6519. $where .= " and features like '%-$density-%'";
  6520. }
  6521. if ($usa) {
  6522. if (!$warehouse) {
  6523. $where .= " and (warehouse = '5' or warehouse = '8')";
  6524. }
  6525. }
  6526. if ($warehouse) {
  6527. $where .= " and warehouse = '$warehouse'";
  6528. }
  6529. if ($details) {
  6530. $where .= " and details = '$details'";
  6531. }
  6532. if ($purchase) {
  6533. $where .= " and purchase = '$purchase'";
  6534. }
  6535. if ($state) {
  6536. $where .= " and state = '$state'";
  6537. }
  6538. if ($ktime && $jtime) {
  6539. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6540. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6541. }
  6542. //数据排序
  6543. $order_str = "id desc";
  6544. if (empty($page)) {
  6545. $start = 0;
  6546. $perpage = 1;
  6547. } else {
  6548. $start = ($page - 1) * $perpage;
  6549. }
  6550. if ($sku) {
  6551. $sku = trim($sku, ' ');
  6552. $sku = trim($sku, ' ');
  6553. $where .= " and sku like '%$sku%'";
  6554. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6555. } else if ($title) {
  6556. $title = trim($title, ' ');
  6557. $title = trim($title, ' ');
  6558. $where .= " and title like '%$title%'";
  6559. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6560. } else {
  6561. //$where .= " and time > '$ktime' and time < '$jtime'";
  6562. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6563. }
  6564. //取得信息列表
  6565. $rows = array();
  6566. $list = array();
  6567. foreach ($info_list as $key => $value) {
  6568. $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'] . '"');
  6569. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6570. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6571. $warehouse = $this->warehouse->read($value['warehouse']);
  6572. $info_list[$key]['warehouse'] = $warehouse['title'];
  6573. $info_list[$key]['number'] = $g;
  6574. $info_list[$key]['features'] = $x;
  6575. $info_list[$key]['x'] = $s;
  6576. }
  6577. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6578. $pagenum = ceil($total / $perpage);
  6579. $over = $total - ($start + $perpage);
  6580. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6581. echo json_encode($rows);
  6582. exit;
  6583. }
  6584. $this->data['vip'] = $vip;
  6585. $this->_Template('whlabel_fc', $this->data);
  6586. }
  6587. public function _fcmb()
  6588. {
  6589. $where = "sku != 'Preset'";
  6590. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6591. foreach ($rows as $k => $v) {
  6592. $warehouse = $this->warehouse->read($v['warehouse']);
  6593. $rows[$k]['warehouse'] = $warehouse['title'];
  6594. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6595. $rows[$k]['t'] = '';
  6596. $rows[$k]['n'] = '';
  6597. }
  6598. $title = "封货产品数据导入模板";
  6599. $titlename = "<table border=1>
  6600. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6601. <tr align='center'>
  6602. <td>仓库</td>
  6603. <td>SKU</td>
  6604. <td>产品</td>
  6605. <td>封存产品总数量</td>
  6606. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6607. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6608. </tr>
  6609. </table>";
  6610. $filename = $title . ".xls";
  6611. $tail = "";
  6612. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6613. }
  6614. public function _fcexcel()
  6615. {
  6616. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6617. $config['upload_path'] = '.' . $dir;
  6618. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6619. $config['allowed_types'] = 'xls|xlsx|csv';
  6620. $config['max_size'] = 10240;
  6621. $this->load->library('upload', $config);
  6622. $this->upload->initialize($config);
  6623. if ($this->upload->do_upload('userfile')) {
  6624. $full_path = $dir . $this->upload->data('file_name');
  6625. $fileName = '.' . $full_path;
  6626. if (!file_exists($fileName)) {
  6627. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6628. exit;
  6629. } else {
  6630. libxml_use_internal_errors(true);
  6631. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6632. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6633. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6634. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6635. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6636. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6637. ++$column; //如果列数大于26行
  6638. $list = array();
  6639. for ($i = 2; $i <= $row; $i++) // 行数循环
  6640. {
  6641. $data = array();
  6642. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6643. {
  6644. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6645. }
  6646. $list[] = $data;
  6647. }
  6648. }
  6649. $i = 0;
  6650. $j = 0;
  6651. $ed = array();
  6652. foreach ($list as $key => $value) {
  6653. $time = time();
  6654. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6655. continue;
  6656. }
  6657. $warehouse = $this->warehouse->get_title($value['0']);
  6658. $sku = $value['1'];
  6659. $type = $value['4']; //调整方式0扣减1删除
  6660. $num = $value['5']; //调整数量
  6661. //$text = $value['4'];//扣减说明
  6662. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6663. if (!$d) //如果没有这个SKU
  6664. {
  6665. $ed[] = array($sku . '-库存中不存在此SKU');
  6666. $j++;
  6667. continue;
  6668. }
  6669. if (!isset($warehouse['id'])) {
  6670. $ed[] = array($sku . '-仓库名错误!');
  6671. $j++;
  6672. continue;
  6673. }
  6674. if ($type == 1 || $type == 2) //扣减库存
  6675. {
  6676. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6677. if (count($data) < abs($num)) {
  6678. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6679. $j++;
  6680. continue;
  6681. }
  6682. if ($type == 1) //转入库存
  6683. {
  6684. for ($i = 0; $i < abs($num); $i++) {
  6685. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6686. }
  6687. } else if ($type == 2) //删除
  6688. {
  6689. for ($i = 0; $i < abs($num); $i++) {
  6690. $this->whlabel->remove($data[$i]['id']);
  6691. }
  6692. }
  6693. } else if ($type == 0) //增加库存
  6694. {
  6695. $post['sku'] = $d['sku'];
  6696. $post['shop'] = '';
  6697. $post['warehouse'] = $warehouse['id'];
  6698. $post['purchase'] = $d['purchase'];
  6699. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6700. $post['state'] = 11;
  6701. $post['title'] = $d['title'];
  6702. $post['number'] = $d['number'];
  6703. $post['features'] = $d['features'];
  6704. $post['enter'] = $time;
  6705. $post['time'] = $time; //操作时间
  6706. for ($i = 0; $i < $num; $i++) {
  6707. $post['label'] = time() . rand(100, 999) . $i;
  6708. $this->whlabel->insert($post);
  6709. }
  6710. }
  6711. sleep(1); //防止入库时间一样,需要延迟1秒
  6712. }
  6713. if ($j > 0) {
  6714. $tt = date('Ymd', time());
  6715. $title = '库存导入错误信息-' . $tt;
  6716. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6717. $tail = "\n";
  6718. $filename = $title . ".xls";
  6719. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6720. $dir = '/data/excel/' . $time . '/';
  6721. $file_name = 'error_' . $time . rand(1000, 9999);
  6722. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6723. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6724. fwrite($myfile, $ecl);
  6725. fclose($myfile);
  6726. $error = $dir . $file_name . '.xls';
  6727. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6728. exit;
  6729. } else {
  6730. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6731. exit;
  6732. }
  6733. }
  6734. }
  6735. public function _fcjxc($arg_array)
  6736. {
  6737. if (isset($_GET['excel'])) {
  6738. $category = $this->input->get('category', true);
  6739. $size = $this->input->get('size', true);
  6740. $grade = $this->input->get('grade', true);
  6741. $color = $this->input->get('color', true);
  6742. $lowe = $this->input->get('lowe', true);
  6743. $sku = $this->input->get('sku');
  6744. $title = $this->input->get('title');
  6745. $warehouse = $arg_array[0];
  6746. $usa = $this->input->get('usa', true);
  6747. $purchase = $this->input->get('purchase', true);
  6748. $lacetype = $this->input->get('lacetype', true);
  6749. $haircap = $this->input->get('haircap', true);
  6750. $density = $this->input->get('density', true);
  6751. $title = $this->input->get('title', true);
  6752. $state = $this->input->get('state', true);
  6753. $ktime = $this->input->get('ktime', true);
  6754. $jtime = $this->input->get('jtime', true);
  6755. $where = "state=11";
  6756. $gj = "";
  6757. $ck = "";
  6758. if ($lacetype) {
  6759. $where .= " and features like '%-$lacetype-%'";
  6760. }
  6761. if ($category) {
  6762. $where .= " and features like '%-$category-%'";
  6763. }
  6764. if ($size) {
  6765. $where .= " and features like '%-$size-%'";
  6766. }
  6767. if ($grade) {
  6768. $where .= " and features like '%-$grade-%'";
  6769. }
  6770. if ($color) {
  6771. $where .= " and features like '%-$color-%'";
  6772. }
  6773. if ($lowe) {
  6774. $where .= " and features like '%-$lowe-%'";
  6775. }
  6776. if ($haircap) {
  6777. $where .= " and features like '%-$haircap-%'";
  6778. }
  6779. if ($density) {
  6780. $where .= " and features like '%-$density-%'";
  6781. }
  6782. if ($usa) {
  6783. if (!$warehouse) {
  6784. $where .= " and (warehouse = '5' or warehouse = '8')";
  6785. }
  6786. }
  6787. if ($warehouse) {
  6788. $where .= " and warehouse = '$warehouse'";
  6789. }
  6790. if ($purchase) {
  6791. $where .= " and purchase = '$purchase'";
  6792. }
  6793. if ($state) {
  6794. $where .= " and state = '$state'";
  6795. }
  6796. $order_str = "id desc";
  6797. if ($sku) {
  6798. $sku = trim($sku, ' ');
  6799. $sku = trim($sku, ' ');
  6800. $where .= " and sku like '%$sku%'";
  6801. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6802. } else if ($title) {
  6803. $title = trim($title, ' ');
  6804. $title = trim($title, ' ');
  6805. $where .= " and title like '%$title%'";
  6806. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6807. } else {
  6808. //$where .= " and time > '$ktime' and time < '$jtime'";
  6809. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6810. }
  6811. //取得信息列表
  6812. $rows = array();
  6813. $list = array();
  6814. foreach ($info_list as $key => $value) {
  6815. $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'] . '"');
  6816. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6817. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6818. $rows[$key] = $value;
  6819. $warehouse = $this->warehouse->read($value['warehouse']);
  6820. $rows[$key]['warehouse'] = $warehouse['title'];
  6821. $rows[$key]['features'] = $g;
  6822. $rows[$key]['a'] = $x;
  6823. $rows[$key]['b'] = $s;
  6824. }
  6825. $title = "总统计表";
  6826. $titlename = "<table border=1>
  6827. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6828. <tr align='center'>
  6829. <td>仓库</td>
  6830. <td>SKU</td>
  6831. <td>产品名称</td>
  6832. <td>录入总量</td>
  6833. <td>取出总量</td>
  6834. <td>剩余总量</td>
  6835. </tr>
  6836. </table>";
  6837. $filename = $title . ".xls";
  6838. $tail = "";
  6839. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6840. }
  6841. $vip = 0;
  6842. if (isset($_SESSION['api'])) {
  6843. $user = $this->user->get_api($_SESSION['api']);
  6844. if ($user['vip'] == 1) {
  6845. $vip = 1;
  6846. }
  6847. } else {
  6848. header('Location: /');
  6849. exit;
  6850. }
  6851. $post = $this->input->post(NULL, TRUE);
  6852. if (isset($post['page'])) {
  6853. $page = $this->input->post('page', true);
  6854. $perpage = $this->input->post('perpage', true);
  6855. $category = $this->input->post('category', true);
  6856. $size = $this->input->post('size', true);
  6857. $grade = $this->input->post('grade', true);
  6858. $color = $this->input->post('color', true);
  6859. $lowe = $this->input->post('lowe', true);
  6860. $sku = $this->input->post('sku');
  6861. $title = $this->input->post('title');
  6862. $warehouse = $arg_array[0];
  6863. $usa = $this->input->post('usa', true);
  6864. $purchase = $this->input->post('purchase', true);
  6865. $lacetype = $this->input->post('lacetype', true);
  6866. $haircap = $this->input->post('haircap', true);
  6867. $density = $this->input->post('density', true);
  6868. $title = $this->input->post('title', true);
  6869. $state = $this->input->post('state', true);
  6870. $ktime = $this->input->post('ktime', true);
  6871. $jtime = $this->input->post('jtime', true);
  6872. $ktime = strtotime($ktime);
  6873. $jtime = strtotime($jtime);
  6874. $where = "state=11";
  6875. $gj = "";
  6876. $ck = "";
  6877. if ($lacetype) {
  6878. $where .= " and features like '%-$lacetype-%'";
  6879. }
  6880. if ($category) {
  6881. $where .= " and features like '%-$category-%'";
  6882. }
  6883. if ($size) {
  6884. $where .= " and features like '%-$size-%'";
  6885. }
  6886. if ($grade) {
  6887. $where .= " and features like '%-$grade-%'";
  6888. }
  6889. if ($color) {
  6890. $where .= " and features like '%-$color-%'";
  6891. }
  6892. if ($lowe) {
  6893. $where .= " and features like '%-$lowe-%'";
  6894. }
  6895. if ($haircap) {
  6896. $where .= " and features like '%-$haircap-%'";
  6897. }
  6898. if ($density) {
  6899. $where .= " and features like '%-$density-%'";
  6900. }
  6901. if ($usa) {
  6902. if (!$warehouse) {
  6903. $where .= " and (warehouse = '5' or warehouse = '8')";
  6904. }
  6905. }
  6906. if ($warehouse) {
  6907. $where .= " and warehouse = '$warehouse'";
  6908. }
  6909. if ($purchase) {
  6910. $where .= " and purchase = '$purchase'";
  6911. }
  6912. if ($state) {
  6913. $where .= " and state = '$state'";
  6914. }
  6915. if ($ktime && $jtime) {
  6916. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6917. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6918. }
  6919. //数据排序
  6920. $order_str = "id desc";
  6921. $xs = 0;
  6922. $rows = array();
  6923. $list = array();
  6924. if (empty($page)) {
  6925. $start = 0;
  6926. $perpage = 1;
  6927. } else {
  6928. $start = ($page - 1) * $perpage;
  6929. }
  6930. if ($sku || $title) {
  6931. if ($title) {
  6932. $title = trim($title, ' ');
  6933. $title = trim($title, ' ');
  6934. $where .= " and title like '%$title%'";
  6935. } else {
  6936. $sku = trim($sku, ' ');
  6937. $sku = trim($sku, ' ');
  6938. $where .= " and sku like '%$sku%'";
  6939. }
  6940. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6941. foreach ($info_list as $key => $value) {
  6942. $g = $this->whlabel->find_count($where . ' and (oldstate = "11" or state = "11") and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state != "9" and features = "' . $value['features'] . '"');
  6943. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6944. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6945. $rows[$key] = $value;
  6946. $warehouse = $this->warehouse->read($value['warehouse']);
  6947. $rows[$key]['warehouse'] = $warehouse['title'];
  6948. $rows[$key]['features'] = $g;
  6949. $rows[$key]['a'] = $x;
  6950. $rows[$key]['b'] = $s;
  6951. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6952. $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天销量
  6953. $yj = $c / ($xl / 30);
  6954. if ($yj < 7) {
  6955. $rows[$key]['y'] = round($yj) . '天销量';
  6956. } else {
  6957. $rows[$key]['y'] = '正常';
  6958. }
  6959. }
  6960. } else {
  6961. //$where .= " and time > '$ktime' and time < '$jtime'";
  6962. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6963. foreach ($info_list as $key => $value) {
  6964. $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'] . '"');
  6965. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6966. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6967. $zs[$key] = $value;
  6968. $warehouse = $this->warehouse->read($value['warehouse']);
  6969. $zs[$key]['warehouse'] = $warehouse['title'];
  6970. $zs[$key]['features'] = $g;
  6971. $zs[$key]['a'] = $x;
  6972. $zs[$key]['b'] = $s;
  6973. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6974. $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天销量
  6975. $yj = $c / ($xl / 30);
  6976. if ($yj < 7) {
  6977. $zs[$key]['y'] = round($yj) . '天销量';
  6978. $rows[$key] = $zs[$key];
  6979. }
  6980. }
  6981. }
  6982. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  6983. $pagenum = ceil($total / $perpage);
  6984. $over = $total - ($start + $perpage);
  6985. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  6986. echo json_encode($rows);
  6987. exit;
  6988. }
  6989. $this->data['arg_array'] = $arg_array[0];
  6990. $this->_Template('whlabel_fcjxc', $this->data);
  6991. }
  6992. public function _0kcdel()
  6993. {
  6994. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6995. $config['upload_path'] = '.' . $dir;
  6996. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6997. $config['allowed_types'] = 'xls|xlsx|csv';
  6998. $config['max_size'] = 10240;
  6999. $this->load->library('upload', $config);
  7000. $this->upload->initialize($config);
  7001. if ($this->upload->do_upload('userfile')) {
  7002. $full_path = $dir . $this->upload->data('file_name');
  7003. $fileName = '.' . $full_path;
  7004. if (!file_exists($fileName)) {
  7005. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7006. exit;
  7007. } else {
  7008. require_once "./data/excel/PHPExcel/IOFactory.php";
  7009. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7010. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7011. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7012. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7013. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7014. ++$column; //如果列数大于26行
  7015. $list = array();
  7016. for ($i = 2; $i <= $row; $i++) // 行数循环
  7017. {
  7018. $data = array();
  7019. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7020. {
  7021. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7022. }
  7023. $list[] = $data;
  7024. }
  7025. }
  7026. $i = 0;
  7027. $j = 0;
  7028. $ed = array();
  7029. foreach ($list as $key => $value) {
  7030. $time = time();
  7031. if ($value['0'] == "" || $value['1'] == "") {
  7032. continue;
  7033. }
  7034. $warehouse = $this->warehouse->get_title($value['0']);
  7035. $sku = $value['1'];
  7036. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7037. if (!$d) //如果没有这个SKU
  7038. {
  7039. $ed[] = array($sku . '-库存中不存在此SKU');
  7040. $j++;
  7041. continue;
  7042. }
  7043. if (!isset($warehouse['id'])) {
  7044. $ed[] = array($sku . '-仓库名错误!');
  7045. $j++;
  7046. continue;
  7047. }
  7048. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7049. if ($z < 1) {
  7050. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7051. foreach ($z as $v) {
  7052. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7053. if (count($zt) > 0) {
  7054. $ed[] = array($sku . '-有在途库存无法删除!');
  7055. $j++;
  7056. continue;
  7057. }
  7058. $this->whlabel->remove($v['id']);
  7059. }
  7060. } else {
  7061. $ed[] = array($sku . '-非0库存!');
  7062. $j++;
  7063. continue;
  7064. }
  7065. }
  7066. if ($j > 0) {
  7067. $tt = date('Ymd', time());
  7068. $title = '删除0库存错误信息-' . $tt;
  7069. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7070. $tail = "\n";
  7071. $filename = $title . ".xls";
  7072. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7073. $dir = '/data/excel/' . $time . '/';
  7074. $file_name = 'error_' . $time . rand(1000, 9999);
  7075. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7076. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7077. fwrite($myfile, $ecl);
  7078. fclose($myfile);
  7079. $error = $dir . $file_name . '.xls';
  7080. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7081. exit;
  7082. } else {
  7083. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7084. exit;
  7085. }
  7086. }
  7087. }
  7088. public function _gbhtype()
  7089. {
  7090. $post = $this->input->post(NULL, TRUE);
  7091. if (isset($post['s'])) {
  7092. $n = $this->input->post('n');
  7093. $d = $this->input->post('s');
  7094. if (!$d) {
  7095. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7096. exit;
  7097. }
  7098. $d = explode(',', trim($d, ','));
  7099. $t = $this->whlabel_type->read($n);
  7100. //循环删除记录
  7101. foreach ($d as $v) {
  7102. $u = $this->whlabel->read($v);
  7103. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7104. foreach ($data as $val) {
  7105. $this->whlabel->save(array('type' => $n), $val['id']);
  7106. }
  7107. }
  7108. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7109. }
  7110. }
  7111. //出库、退库导出
  7112. public function _dccrtype()
  7113. {
  7114. $classid = $this->classid->sku();
  7115. $pm = $classid;
  7116. $typeclass = array();
  7117. $tc = $this->typeclass->find_all();
  7118. foreach ($tc as $v) {
  7119. $typeclass[$v['id']] = $v;
  7120. }
  7121. $prc = array();
  7122. $purchase = $this->purchase->find_all();
  7123. foreach ($purchase as $k => $v) {
  7124. $prc[$v['id']] = $v['title'];
  7125. }
  7126. if (isset($_GET['sid'])) {
  7127. $wh = array();
  7128. $w = $this->warehouse->find_all('1=1', 'id,title');
  7129. foreach ($w as $v) {
  7130. $wh[$v['id']] = $v['title'];
  7131. }
  7132. $type = $this->input->get('excel', true);
  7133. $category = $this->input->get('category', true);
  7134. $size = $this->input->get('size', true);
  7135. $grade = $this->input->get('grade', true);
  7136. $color = $this->input->get('color', true);
  7137. $lowe = $this->input->get('lowe', true);
  7138. $sku = $this->input->get('sku', true);
  7139. $warehouse = $this->input->get('warehouse', true);
  7140. $lacetype = $this->input->get('lacetype', true);
  7141. $lacecolor = $this->input->get('lacecolor', true);
  7142. $density = $this->input->get('density', true);
  7143. $haircap = $this->input->get('haircap', true);
  7144. $purchase = $this->input->get('purchase', true);
  7145. $title = $this->input->get('title', true);
  7146. $state = $this->input->get('state', true);
  7147. $sid = $this->input->get('sid', true);
  7148. $ktime = $this->input->get('ktime', true);
  7149. $jtime = $this->input->get('jtime', true);
  7150. $ktime = strtotime($ktime);
  7151. $jtime = strtotime($jtime);
  7152. $where = "1=1";
  7153. $gj = "";
  7154. $ck = "";
  7155. if ($category) {
  7156. $where .= " and features like '%-$category-%'";
  7157. }
  7158. if ($size) {
  7159. $where .= " and features like '%-$size-%'";
  7160. }
  7161. if ($grade) {
  7162. $where .= " and features like '%-$grade-%'";
  7163. }
  7164. if ($color) {
  7165. $where .= " and features like '%-$color-%'";
  7166. }
  7167. if ($lowe) {
  7168. $where .= " and features like '%-$lowe-%'";
  7169. }
  7170. if ($warehouse) {
  7171. $where .= " and warehouse = '$warehouse'";
  7172. }
  7173. if ($purchase) {
  7174. $where .= " and purchase = '$purchase'";
  7175. }
  7176. if ($state) {
  7177. $where .= " and state = '$state'";
  7178. }
  7179. if ($lacetype) {
  7180. $where .= " and features like '%-$lacetype-%'";
  7181. }
  7182. if ($lacecolor) {
  7183. $where .= " and features like '%-$lacecolor-%'";
  7184. }
  7185. if ($density) {
  7186. $where .= " and features like '%-$density-%'";
  7187. }
  7188. if ($haircap) {
  7189. $where .= " and features like '%-$haircap-%'";
  7190. }
  7191. if ($title) {
  7192. $title = trim($title, ' ');
  7193. $title = trim($title, ' ');
  7194. $where .= " and title like '%$title%'";
  7195. }
  7196. if ($sku) {
  7197. $sku = trim($sku, ' ');
  7198. $sku = trim($sku, ' ');
  7199. $where .= " and sku like '%$sku%'";
  7200. }
  7201. if ($ktime && $jtime) {
  7202. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7203. }
  7204. $sidwhere = '';
  7205. if ($sid) {
  7206. $sd = "";
  7207. $s = explode(',', trim($sid, ','));
  7208. foreach ($s as $value) {
  7209. $sd .= " id = " . $value . " or";
  7210. }
  7211. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7212. }
  7213. //数据排序
  7214. $order_str = "time desc";
  7215. if (empty($page)) {
  7216. $start = 0;
  7217. $perpage = 1;
  7218. } else {
  7219. $start = ($page - 1) * $perpage;
  7220. }
  7221. $wh = array();
  7222. $w = $this->warehouse->find_all('1=1', 'id,title');
  7223. foreach ($w as $v) {
  7224. $wh[$v['id']] = $v['title'];
  7225. }
  7226. $wt = array();
  7227. $whlabel_type = $this->whlabel_type->find_all();
  7228. foreach ($whlabel_type as $v) {
  7229. $wt[$v['id']] = $v['title'];
  7230. }
  7231. $classid = $this->classid->sku();
  7232. $list = array();
  7233. $rows_r = $this->whlabel->find_pc($where . " and enter > '$ktime' and enter < '$jtime' " . $sidwhere, 'sku,features,warehouse,enter', 'warehouse,sku,title,zh,features,time,enter,rktype,number,text');
  7234. foreach ($rows_r as $key => $value) {
  7235. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7236. $pm = $classid;
  7237. $jm = $classid;
  7238. $rows_r[$key]['enter'] = '入库';
  7239. $rows_r[$key]['time'] = $value['enter'];
  7240. if ($value['rktype'] == 1) {
  7241. $rows_r[$key]['rktype'] = '采购入库';
  7242. } else if ($value['rktype'] == 2) {
  7243. $rows_r[$key]['rktype'] = '盘盈调整';
  7244. } else if ($value['rktype'] == 3) {
  7245. $rows_r[$key]['rktype'] = '其他调整入库';
  7246. } else if ($value['rktype'] == 4) {
  7247. $rows_r[$key]['rktype'] = '其他调整入库';
  7248. } else if ($value['rktype'] == 5) {
  7249. $rows_r[$key]['rktype'] = '退库入库';
  7250. } else if ($value['rktype'] == 6) {
  7251. $rows_r[$key]['rktype'] = '退货可用入库';
  7252. } else if ($value['rktype'] == 7) {
  7253. $rows_r[$key]['rktype'] = '形态转换入库';
  7254. } else {
  7255. $rows_r[$key]['rktype'] = '';
  7256. }
  7257. $features = explode('-', trim($value['features'], '-'));
  7258. foreach ($features as $v) {
  7259. if (isset($typeclass[$v])) {
  7260. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7261. $pm[$typeclass[$v]['classid']] = $zh[0];
  7262. }
  7263. if (isset($typeclass[$v])) {
  7264. if (isset($jm[$typeclass[$v]['classid']])) {
  7265. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7266. }
  7267. }
  7268. }
  7269. $zh = implode(" ", $pm);
  7270. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7271. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7272. $rows_r[$key]['zh'] = $zh;
  7273. $jm = array_filter($jm);
  7274. $rows_r[$key]['features'] = implode("-", $jm);
  7275. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7276. }
  7277. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7278. foreach ($rows_c as $key => $value) {
  7279. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7280. $pm = $classid;
  7281. $jm = $classid;
  7282. $rows_c[$key]['time'] = $value['outk'];
  7283. $rows_c[$key]['outk'] = '出库';
  7284. if ($value['cktype'] == 1) {
  7285. $rows_c[$key]['cktype'] = '销售出库';
  7286. } else if ($value['cktype'] == 2) {
  7287. $rows_c[$key]['cktype'] = '销售美国出库';
  7288. } else if ($value['cktype'] == 3) {
  7289. $rows_c[$key]['cktype'] = '盘亏调整';
  7290. } else if ($value['cktype'] == 4) {
  7291. $rows_c[$key]['cktype'] = '其他调整出库';
  7292. } else if ($value['cktype'] == 5) {
  7293. $rows_c[$key]['cktype'] = '形态转换出库';
  7294. } else {
  7295. $rows_c[$key]['cktype'] = '';
  7296. }
  7297. $features = explode('-', trim($value['features'], '-'));
  7298. foreach ($features as $v) {
  7299. if (isset($typeclass[$v])) {
  7300. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7301. $pm[$typeclass[$v]['classid']] = $zh[0];
  7302. }
  7303. if (isset($typeclass[$v])) {
  7304. if (isset($jm[$typeclass[$v]['classid']])) {
  7305. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7306. }
  7307. }
  7308. }
  7309. $zh = implode(" ", $pm);
  7310. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7311. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7312. $rows_c[$key]['zh'] = $zh;
  7313. $jm = array_filter($jm);
  7314. $rows_c[$key]['features'] = implode("-", $jm);
  7315. $rows_c[$key]['number'] = 1;
  7316. }
  7317. $merged = $rows_r;
  7318. foreach ($rows_c as $key => $value) {
  7319. if (isset($merged[$key])) {
  7320. $merged[] = $value;
  7321. } else {
  7322. $merged[$key] = $value;
  7323. }
  7324. }
  7325. usort($merged, function ($a, $b) {
  7326. return $a['time'] - $b['time'];
  7327. });
  7328. foreach ($merged as $key => $value) {
  7329. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7330. }
  7331. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7332. $titlename = "<table border=1>
  7333. <tr align='center'>
  7334. <td>仓库</td>
  7335. <td>SKU</td>
  7336. <td>商品名称</td>
  7337. <td>仓库品名</td>
  7338. <td>料号</td>
  7339. <td>时间</td>
  7340. <td>操作</td>
  7341. <td>类型</td>
  7342. <td>数量</td>
  7343. <td>备注</td>
  7344. </tr>
  7345. </table>";
  7346. $filename = $title . ".xlsx";
  7347. $tail = "";
  7348. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7349. }
  7350. }
  7351. }