Whlabel.php 258 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487
  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['wigother2'] = $this->input->post('wigother2', true);
  1742. }
  1743. if ($category == 129) {
  1744. $list['wide'] = $this->input->post('wide', true);
  1745. }
  1746. if ($category == 131) {
  1747. $list['gifttype'] = $this->input->post('gifttype', true);
  1748. $list['giftother'] = $this->input->post('giftother', true);
  1749. }
  1750. if ($category == 134) {
  1751. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1752. }
  1753. if ($category == 1297) {
  1754. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1755. $list['sywigother'] = $this->input->post('sywigother', true);
  1756. }
  1757. if ($category == 130 || $category == 133 || $category == 1702) {
  1758. $list['items'] = $this->input->post('items', true);
  1759. $list['weight'] = $this->input->post('weight', true);
  1760. }
  1761. if ($category == 1702) {
  1762. $list['syhairther'] = $this->input->post('syhairther', true);
  1763. }
  1764. $classid = $this->classid->sku();
  1765. $scsku = $classid;
  1766. $pm = $classid;
  1767. foreach ($list as $k => $v) {
  1768. if ($v != 0) {
  1769. $num .= $v;
  1770. $features .= $v . '-';
  1771. $post[$k] = $v;
  1772. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1773. if ($k != 'size') {
  1774. $title .= $typeclass[$v]['title'] . " ";
  1775. }
  1776. if (isset($pm[$typeclass[$v]['classid']])) {
  1777. if ($typeclass[$v]['title'] == '9A') {
  1778. $pm[$typeclass[$v]['classid']] = '9A';
  1779. } else if ($typeclass[$v]['title'] == '10A') {
  1780. $pm[$typeclass[$v]['classid']] = '10A';
  1781. } else {
  1782. $clzh = $typeclass[$v]['zh'];
  1783. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1784. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1785. $clzh = $clzh[0];
  1786. }
  1787. $pm[$typeclass[$v]['classid']] = $clzh;
  1788. }
  1789. }
  1790. }
  1791. }
  1792. $zh = implode(" ", $pm);
  1793. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1794. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1795. if ($list['size']) {
  1796. $typeclass = $this->typeclass->read($list['size']);
  1797. $title .= $typeclass['title'];
  1798. }
  1799. $time = time();
  1800. if ($xzsku) {
  1801. $scsku = implode("-", $scsku);
  1802. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1803. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1804. $post['sku'] = trim($scsku, ' ');
  1805. } else {
  1806. $post['sku'] = $sku;
  1807. }
  1808. //$post['sku'] = trim($sku,' ');
  1809. $post['title'] = rtrim($title, ' ');
  1810. $post['number'] = $num;
  1811. $post['features'] = '-' . $features;
  1812. $post['enter'] = $time;
  1813. $post['time'] = $time; //操作时间
  1814. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1815. if ($yza) {
  1816. if ($post['features'] != $yza[0]['features']) {
  1817. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1818. exit;
  1819. }
  1820. }
  1821. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1822. if ($yzb) {
  1823. if ($post['sku'] != $yzb[0]['sku']) {
  1824. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1825. exit;
  1826. }
  1827. }
  1828. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1829. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1830. exit;
  1831. }
  1832. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1833. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1834. exit;
  1835. }
  1836. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1837. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1838. exit;
  1839. }
  1840. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1841. if (isset($yz[0]['type'])) {
  1842. $post['type'] = $yz[0]['type'];
  1843. }
  1844. if ($post['state'] == 9) //如果选择预设库存
  1845. {
  1846. $this->whlabel->insert($post);
  1847. } else {
  1848. /**
  1849. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1850. if($ljg == 1)
  1851. {
  1852. for($i=0;$i<$order;$i++)
  1853. {
  1854. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1855. $this->whlabel->insert($post);
  1856. }
  1857. }
  1858. **/
  1859. //if($post['warehouse'] == '5')
  1860. //{
  1861. //}
  1862. $yydata = $post;
  1863. $yydata['zh'] = $zh;
  1864. /**
  1865. $wl = $this->apiyy->get_cjlp($yydata);
  1866. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1867. {
  1868. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1869. }
  1870. if($wl['Data'][0]['m_isSucess'] != 1)
  1871. {
  1872. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1873. }
  1874. **/
  1875. for ($i = 0; $i < $order; $i++) {
  1876. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1877. $this->whlabel->insert($post);
  1878. }
  1879. }
  1880. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1881. exit;
  1882. }
  1883. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1884. $this->data['wlshop'] = $wlshop;
  1885. $this->_Template('whlabel_enteradd', $this->data);
  1886. }
  1887. //修改产品
  1888. public function _enteredit($arg_array)
  1889. {
  1890. $dt = 0;
  1891. if (isset($_SESSION['api'])) {
  1892. $user = $this->user->get_api($_SESSION['api']);
  1893. $usp = $user;
  1894. $fgshop = "";
  1895. $sid = "";
  1896. $user = explode('|', trim($user['shop'], '|'));
  1897. foreach ($user as $value) {
  1898. $fgshop .= " shop = " . $value . " or";
  1899. $sid .= " id = " . $value . " or";
  1900. }
  1901. }
  1902. $post = $this->input->post(NULL, TRUE);
  1903. if (isset($post['sku'])) {
  1904. $list = array();
  1905. $num = "";
  1906. $title = "";
  1907. $features = "";
  1908. $id = $this->input->post('id', true);
  1909. $order = $this->input->post('order', true);
  1910. $shop = $this->input->post('shop', true);
  1911. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1912. $post['sku'] = $this->input->post('sku', true);
  1913. $post['sm'] = $this->input->post('sm', true);
  1914. $post['warehouse'] = $this->input->post('warehouse', true);
  1915. $post['purchase'] = $this->input->post('purchase', true);
  1916. $post['retreatwarehouse'] = $post['warehouse'];
  1917. $category = $this->input->post('category', true);
  1918. $list['category'] = $category;
  1919. $list['hairtype'] = $this->input->post('hairtype', true);
  1920. $list['grade'] = $this->input->post('grade', true);
  1921. $size = $this->input->post('size', true);
  1922. $list['size'] = rtrim($size, ',');
  1923. $post['rktype'] = $this->input->post('rktype', true);
  1924. $post['text'] = $this->input->post('text', true);
  1925. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1926. $list['extension'] = $this->input->post('extension', true);
  1927. if ($category == 1297) {
  1928. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1929. }
  1930. if ($category == 1702) {
  1931. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1932. $list['syother'] = $this->input->post('syother', true);
  1933. }
  1934. if ($category == 133) {
  1935. $list['fittype'] = $this->input->post('fittype', true);
  1936. $list['acother'] = $this->input->post('acother', true);
  1937. }
  1938. $list['color'] = $this->input->post('color', true);
  1939. $list['lowe'] = $this->input->post('lowe', true);
  1940. if (!$post['purchase']) {
  1941. $post['purchase'] = 1;
  1942. }
  1943. if ($category == 127) {
  1944. $list['type'] = $this->input->post('type', true);
  1945. $list['headroad'] = $this->input->post('headroad', true);
  1946. $list['density'] = $this->input->post('density', true);
  1947. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1948. $list['lacesize'] = $this->input->post('lacesize', true);
  1949. }
  1950. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1951. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1952. }
  1953. if ($category == 128) {
  1954. $list['lacetype'] = $this->input->post('lacetype', true);
  1955. $list['haircap'] = $this->input->post('haircap', true);
  1956. $list['density'] = $this->input->post('density', true);
  1957. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1958. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1959. $list['wigother'] = $this->input->post('wigother', true);
  1960. $list['wigother2'] = $this->input->post('wigother2', true);
  1961. }
  1962. if ($category == 129) {
  1963. $list['wide'] = $this->input->post('wide', true);
  1964. }
  1965. if ($category == 131) {
  1966. $list['gifttype'] = $this->input->post('gifttype', true);
  1967. $list['giftother'] = $this->input->post('giftother', true);
  1968. }
  1969. if ($category == 134) {
  1970. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1971. }
  1972. if ($category == 1297) {
  1973. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1974. $list['sywigother'] = $this->input->post('sywigother', true);
  1975. }
  1976. if ($category == 130 || $category == 133 || $category == 1702) {
  1977. $list['items'] = $this->input->post('items', true);
  1978. $list['weight'] = $this->input->post('weight', true);
  1979. }
  1980. if ($category == 1702) {
  1981. $list['syhairther'] = $this->input->post('syhairther', true);
  1982. }
  1983. foreach ($list as $k => $v) {
  1984. if ($v != 0) {
  1985. $num .= $v;
  1986. $features .= $v . '-';
  1987. $typeclass = $this->typeclass->read($v);
  1988. if ($k != 'size') {
  1989. $title .= $typeclass['title'] . " ";
  1990. }
  1991. }
  1992. }
  1993. $typeclass = $this->typeclass->read($list['size']);
  1994. $title .= $typeclass['title'];
  1995. $time = time();
  1996. $post['title'] = rtrim($title, ' ');
  1997. $post['number'] = $num;
  1998. $post['features'] = '-' . $features;
  1999. $post['time'] = $time; //操作时间
  2000. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2001. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2002. exit;
  2003. }
  2004. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2005. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2006. exit;
  2007. }
  2008. $uid = $this->whlabel->read($id);
  2009. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2010. if ($datanum > 0) {
  2011. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2012. exit;
  2013. }
  2014. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2015. {
  2016. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2017. if ($yza) {
  2018. if ($post['features'] != $yza[0]['features']) {
  2019. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2020. exit;
  2021. }
  2022. }
  2023. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2024. if ($yzb) {
  2025. if ($post['sku'] != $yzb[0]['sku']) {
  2026. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2027. exit;
  2028. }
  2029. }
  2030. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2031. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2032. exit;
  2033. }
  2034. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2035. foreach ($data as $v) {
  2036. $post['id'] = $v['id'];
  2037. $this->whlabel->save($post, $v['id']);
  2038. }
  2039. } else {
  2040. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2041. if ($data > 0) {
  2042. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2043. exit;
  2044. } else {
  2045. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2046. foreach ($data as $v) {
  2047. $post['id'] = $v['id'];
  2048. $this->whlabel->save($post, $v['id']);
  2049. }
  2050. }
  2051. }
  2052. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2053. exit;
  2054. }
  2055. $uid = $this->whlabel->read($arg_array[0]);
  2056. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2057. $this->data['enter'] = $uid;
  2058. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2059. $this->data['wlshop'] = $wlshop;
  2060. $this->_Template('whlabel_enteredit', $this->data);
  2061. }
  2062. //入库浏览
  2063. public function _enter()
  2064. {
  2065. $post = $this->input->post(NULL, TRUE);
  2066. if (isset($post['s'])) {
  2067. $id_arr = $this->input->post('s');
  2068. $id_arr = explode(',', $id_arr);
  2069. if (!$id_arr) {
  2070. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2071. exit;
  2072. }
  2073. //循环删除记录
  2074. foreach ($id_arr as $v) {
  2075. $sid = $this->whlabel->read($v);
  2076. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2077. if ($count > 0) {
  2078. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2079. exit;
  2080. }
  2081. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2082. foreach ($info_list as $va) {
  2083. $this->whlabel->remove($va['id']);
  2084. }
  2085. }
  2086. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2087. exit;
  2088. }
  2089. $sp = array();
  2090. $s = $this->shop->find_all('1=1', 'id,shopname');
  2091. foreach ($s as $v) {
  2092. $sp[$v['id']] = $v['shopname'];
  2093. }
  2094. $wh = array();
  2095. $w = $this->warehouse->find_all('1=1', 'id,title');
  2096. foreach ($w as $v) {
  2097. $wh[$v['id']] = $v['title'];
  2098. }
  2099. if (isset($post['page'])) {
  2100. $page = $this->input->post('page', true);
  2101. $perpage = $this->input->post('perpage', true);
  2102. $category = $this->input->post('category', true);
  2103. $size = $this->input->post('size', true);
  2104. $grade = $this->input->post('grade', true);
  2105. $color = $this->input->post('color', true);
  2106. $lowe = $this->input->post('lowe', true);
  2107. $sku = $this->input->post('sku', true);
  2108. $warehouse = $this->input->post('warehouse', true);
  2109. $purchase = $this->input->post('purchase', true);
  2110. $ktime = $this->input->post('ktime', true);
  2111. $jtime = $this->input->post('jtime', true);
  2112. $ktime = strtotime($ktime);
  2113. $jtime = strtotime($jtime);
  2114. $where = "1=1";
  2115. $gj = "";
  2116. $ck = "";
  2117. if ($category) {
  2118. $where .= " and features like '%-$category-%'";
  2119. }
  2120. if ($size) {
  2121. $where .= " and features like '%-$size-%'";
  2122. }
  2123. if ($grade) {
  2124. $where .= " and features like '%-$grade-%'";
  2125. }
  2126. if ($color) {
  2127. $where .= " and features like '%-$color-%'";
  2128. }
  2129. if ($lowe) {
  2130. $where .= " and features like '%-$lowe-%'";
  2131. }
  2132. if ($warehouse) {
  2133. $where .= " and warehouse = '$warehouse'";
  2134. }
  2135. if ($purchase) {
  2136. $where .= " and purchase = '$purchase'";
  2137. }
  2138. if ($sku) {
  2139. $where .= " and sku like '%$sku%'";
  2140. }
  2141. if ($ktime && $jtime) {
  2142. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2143. }
  2144. //数据排序
  2145. $order_str = "enter desc";
  2146. if (empty($page)) {
  2147. $start = 0;
  2148. $perpage = 1;
  2149. } else {
  2150. $start = ($page - 1) * $perpage;
  2151. }
  2152. //取得信息列表
  2153. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2154. foreach ($info_list as $k => $v) {
  2155. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2156. if ($v['shop'] == '') {
  2157. $s = '通用';
  2158. } else {
  2159. $info_list[$k]['shop'] = '';
  2160. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2161. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2162. }
  2163. }
  2164. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2165. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2166. $info_list[$k]['g'] = $g;
  2167. }
  2168. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2169. $pagenum = ceil($total / $perpage);
  2170. $over = $total - ($start + $perpage);
  2171. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2172. echo json_encode($rows);
  2173. exit;
  2174. }
  2175. $this->_Template('whlabel_enter', $this->data);
  2176. }
  2177. //出库浏览
  2178. public function _out()
  2179. {
  2180. $post = $this->input->post(NULL, TRUE);
  2181. if (isset($post['page'])) {
  2182. $page = $this->input->post('page', true);
  2183. $perpage = $this->input->post('perpage', true);
  2184. $category = $this->input->post('category', true);
  2185. $size = $this->input->post('size', true);
  2186. $grade = $this->input->post('grade', true);
  2187. $color = $this->input->post('color', true);
  2188. $lowe = $this->input->post('lowe', true);
  2189. $sku = $this->input->post('sku', true);
  2190. $warehouse = $this->input->post('warehouse', true);
  2191. $purchase = $this->input->post('purchase', true);
  2192. $state = $this->input->post('state', true);
  2193. $ktime = $this->input->post('ktime', true);
  2194. $jtime = $this->input->post('jtime', true);
  2195. $ktime = strtotime($ktime);
  2196. $jtime = strtotime($jtime);
  2197. $where = "state=3";
  2198. $gj = "";
  2199. $ck = "";
  2200. if ($category) {
  2201. $where .= " and features like '%-$category-%'";
  2202. }
  2203. if ($size) {
  2204. $where .= " and features like '%-$size-%'";
  2205. }
  2206. if ($grade) {
  2207. $where .= " and features like '%-$grade-%'";
  2208. }
  2209. if ($color) {
  2210. $where .= " and features like '%-$color-%'";
  2211. }
  2212. if ($lowe) {
  2213. $where .= " and features like '%-$lowe-%'";
  2214. }
  2215. if ($state) {
  2216. $where .= " and state = '$state'";
  2217. }
  2218. if ($warehouse) {
  2219. $where .= " and warehouse = '$warehouse'";
  2220. }
  2221. if ($purchase) {
  2222. $where .= " and purchase = '$purchase'";
  2223. }
  2224. if ($sku) {
  2225. $where .= " and sku = '$sku'";
  2226. }
  2227. if ($ktime && $jtime) {
  2228. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2229. }
  2230. //数据排序
  2231. $order_str = "id desc";
  2232. if (empty($page)) {
  2233. $start = 0;
  2234. $perpage = 1;
  2235. } else {
  2236. $start = ($page - 1) * $perpage;
  2237. }
  2238. //取得信息列表
  2239. $info_list = $this->whlabel->find_all($where, 'sku');
  2240. $rows = array();
  2241. $list = array();
  2242. foreach ($info_list as $key => $value) {
  2243. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2244. }
  2245. $rows = array_unique($rows); //删除重复记录
  2246. foreach ($rows as $key => $value) {
  2247. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2248. $ck = $this->warehouse->read($data['warehouse']);
  2249. $warehouse = $ck['title'];
  2250. $gy = $this->purchase->read($data['purchase']);
  2251. $purchase = $gy['purchase'];
  2252. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2253. $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);
  2254. }
  2255. $total = count($list);
  2256. $pagenum = ceil($total / $perpage);
  2257. $over = $total - ($start + $perpage);
  2258. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2259. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2260. echo json_encode($rows);
  2261. exit;
  2262. }
  2263. $this->_Template('whlabel_out', $this->data);
  2264. }
  2265. //出库标签浏览
  2266. public function _label()
  2267. {
  2268. $post = $this->input->post(NULL, TRUE);
  2269. if (isset($post['page'])) {
  2270. $page = $this->input->post('page', true);
  2271. $perpage = $this->input->post('perpage', true);
  2272. $sku = $this->input->post('sku', true);
  2273. $warehouse = $this->input->post('warehouse', true);
  2274. $purchase = $this->input->post('purchase', true);
  2275. $orderinfo = $this->input->post('orderinfo', true);
  2276. $waybill = $this->input->post('waybill', true);
  2277. $category = $this->input->post('category', true);
  2278. $size = $this->input->post('size', true);
  2279. $grade = $this->input->post('grade', true);
  2280. $color = $this->input->post('color', true);
  2281. $lowe = $this->input->post('lowe', true);
  2282. $where = "state=1";
  2283. if ($sku) {
  2284. $where .= " and sku = '$sku'";
  2285. }
  2286. if ($warehouse) {
  2287. $where .= " and warehouse = '$warehouse'";
  2288. }
  2289. if ($purchase) {
  2290. $where .= " and purchase = '$purchase'";
  2291. }
  2292. if ($orderinfo) {
  2293. $where .= " and orderinfo = '$orderinfo'";
  2294. }
  2295. if ($waybill) {
  2296. $where .= " and waybill = '$waybill'";
  2297. }
  2298. if ($category) {
  2299. $where .= " and features like '%-$category-%'";
  2300. }
  2301. if ($size) {
  2302. $where .= " and features like '%-$size-%'";
  2303. }
  2304. if ($grade) {
  2305. $where .= " and features like '%-$grade-%'";
  2306. }
  2307. if ($color) {
  2308. $where .= " and features like '%-$color-%'";
  2309. }
  2310. if ($lowe) {
  2311. $where .= " and features like '%-$lowe-%'";
  2312. }
  2313. //数据排序
  2314. $order_str = "outk desc";
  2315. if (empty($page)) {
  2316. $start = 0;
  2317. $perpage = 1;
  2318. } else {
  2319. $start = ($page - 1) * $perpage;
  2320. }
  2321. //取得信息列表
  2322. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2323. foreach ($info_list as $key => $value) {
  2324. $warehouse = $this->warehouse->read($value['warehouse']);
  2325. $info_list[$key]['warehouse'] = $warehouse['title'];
  2326. $purchase = $this->purchase->read($value['purchase']);
  2327. $info_list[$key]['purchase'] = $purchase['title'];
  2328. if ($value['outk'] != 0) {
  2329. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2330. } else {
  2331. $info_list[$key]['outk'] = "";
  2332. }
  2333. if ($value['orderinfo'] == 0) {
  2334. $info_list[$key]['orderinfo'] = "";
  2335. }
  2336. if ($value['waybill'] == 0) {
  2337. $info_list[$key]['waybill'] = "";
  2338. }
  2339. }
  2340. $total = $this->whlabel->find_count($where);
  2341. $pagenum = ceil($total / $perpage);
  2342. $over = $total - ($start + $perpage);
  2343. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2344. echo json_encode($rows);
  2345. exit;
  2346. }
  2347. $this->_Template('whlabel_label', $this->data);
  2348. }
  2349. //独立站出库订单
  2350. public function _outorder()
  2351. {
  2352. if (isset($_SESSION['api'])) {
  2353. $user = $this->user->get_api($_SESSION['api']);
  2354. $usp = $user;
  2355. $fgshop = "";
  2356. $sid = "";
  2357. $user = explode('|', trim($user['shop'], '|'));
  2358. foreach ($user as $value) {
  2359. $fgshop .= " shop = " . $value . " or";
  2360. $sid .= " id = " . $value . " or";
  2361. }
  2362. } else {
  2363. echo "请重新登录";
  2364. }
  2365. $post = $this->input->post(NULL, TRUE);
  2366. if (isset($post['page'])) {
  2367. $page = $this->input->post('page', true);
  2368. $perpage = $this->input->post('perpage', true);
  2369. $warehouse = $this->input->post('warehouse', true);
  2370. $xztime = $this->input->post('xztime', true);
  2371. $timetk = $this->input->post('timetkk', true);
  2372. $timetj = $this->input->post('timetjj', true);
  2373. $shop = $this->input->post('shop', true);
  2374. $source = $this->input->post('source', true);
  2375. $orderinfo = $this->input->post('orderinfo', true);
  2376. $number = $this->input->post('number', true);
  2377. $sfxh = $this->input->post('sfxh', true);
  2378. $express = $this->input->post('express', true);
  2379. $waybill = $this->input->post('waybill', true);
  2380. $library = $this->input->post('library', true);
  2381. $country = $this->input->post('country', true);
  2382. $so = $this->input->post('so', true);
  2383. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2384. $print = $this->input->post('print', true);
  2385. $state = $this->input->post('state', true);
  2386. $orderurl = $this->input->post('orderurl', true);
  2387. $timetk = strtotime($timetk);
  2388. $timetj = strtotime($timetj);
  2389. /**
  2390. $sj = $this->input->post('sj',true);
  2391. if($sj)
  2392. {
  2393. $sj = $this->input->post('sj',true);
  2394. }
  2395. else
  2396. {
  2397. $sj = "fullorder";
  2398. }
  2399. **/
  2400. $sj = "fullorder";
  2401. $where = "1=1";
  2402. if ($warehouse) {
  2403. $where .= " and type = '$warehouse'";
  2404. }
  2405. if ($timetk && $timetj) {
  2406. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2407. }
  2408. if ($orderinfo) {
  2409. $where .= " and orderinfo = '$orderinfo'";
  2410. }
  2411. if ($number) {
  2412. $where .= " and number = '$number'";
  2413. }
  2414. if ($express) {
  2415. $where .= " and express = '$express'";
  2416. }
  2417. if ($waybill) {
  2418. $where .= " and waybill = '$waybill'";
  2419. }
  2420. if ($library) {
  2421. $where .= " and library = '$library'";
  2422. }
  2423. if ($print) {
  2424. $where .= " and print = '$print'";
  2425. }
  2426. if ($libraryconfirm) {
  2427. $where .= " and libraryconfirm = '$libraryconfirm'";
  2428. }
  2429. if ($state) {
  2430. $where .= " and state = '$state'";
  2431. }
  2432. if ($shop) {
  2433. $where .= " and shop = '$shop'";
  2434. }
  2435. if ($country) {
  2436. $where .= " and country = '$country'";
  2437. }
  2438. if ($sfxh != '') {
  2439. $where .= " and sfxh = '$sfxh'";
  2440. }
  2441. if ($so) {
  2442. $where .= " and shipremarks like '%$so%'";
  2443. }
  2444. if ($source) {
  2445. if ($source == '2d') {
  2446. $where .= " and source >= '2'";
  2447. } else {
  2448. $where .= " and source = '$source'";
  2449. }
  2450. }
  2451. if (isset($_SESSION['api'])) {
  2452. foreach ($user as $value) {
  2453. $fgshop .= " shop = " . $value . " or";
  2454. }
  2455. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2456. }
  2457. if ($orderurl) {
  2458. $url = $this->orderurl->read($orderurl);
  2459. $where .= " and link like '%" . $url['url'] . "%'";
  2460. }
  2461. //数据排序
  2462. $order_str = "librarytime desc";
  2463. if (empty($page)) {
  2464. $start = 0;
  2465. $perpage = 1;
  2466. } else {
  2467. $start = ($page - 1) * $perpage;
  2468. }
  2469. //取得信息列表
  2470. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2471. //格式化数据
  2472. foreach ($info_list as $key => $value) {
  2473. $shop = $this->shop->read($value['shop']);
  2474. $info_list[$key]['shop'] = $shop['shopname'];
  2475. $express = $this->express->read($value['express']);
  2476. $info_list[$key]['express'] = $express['servicename'];
  2477. $warehouse = $this->warehouse->read($value['type']);
  2478. $info_list[$key]['type'] = $warehouse['title'];
  2479. if ($value['librarytime'] == '0') {
  2480. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2481. } else {
  2482. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2483. }
  2484. }
  2485. $total = $this->$sj->find_count($where);
  2486. $pagenum = ceil($total / $perpage);
  2487. $over = $total - ($start + $perpage);
  2488. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2489. echo json_encode($rows);
  2490. exit;
  2491. }
  2492. $this->data['express'] = $this->express->find_all();
  2493. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2494. $this->data['wlshop'] = $wlshop;
  2495. $user = $this->user->get_api($_SESSION['api']);
  2496. $powerid = $this->power->read($user['power']);
  2497. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2498. $pid = '';
  2499. foreach ($powertext as $v) {
  2500. $pid .= " id = " . $v . " or";
  2501. }
  2502. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2503. $this->data['fullorderexcel'] = $fullorderexcel;
  2504. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2505. $this->data['orderurl'] = $orderurl;
  2506. $this->_Template('whlabel_outorder', $this->data);
  2507. }
  2508. //tt出库
  2509. public function _toutorder()
  2510. {
  2511. if (isset($_SESSION['api'])) {
  2512. $user = $this->user->get_api($_SESSION['api']);
  2513. $usp = $user;
  2514. $fgshop = "";
  2515. $sid = "";
  2516. $user = explode('|', trim($user['shop'], '|'));
  2517. foreach ($user as $value) {
  2518. $fgshop .= " shop = " . $value . " or";
  2519. $sid .= " id = " . $value . " or";
  2520. }
  2521. } else {
  2522. echo "请重新登录";
  2523. }
  2524. $post = $this->input->post(NULL, TRUE);
  2525. if (isset($post['page'])) {
  2526. $page = $this->input->post('page', true);
  2527. $perpage = $this->input->post('perpage', true);
  2528. $warehouse = $this->input->post('warehouse', true);
  2529. $xztime = $this->input->post('xztime', true);
  2530. $timetk = $this->input->post('timetkk', true);
  2531. $timetj = $this->input->post('timetjj', true);
  2532. $shop = $this->input->post('shop', true);
  2533. $source = $this->input->post('source', true);
  2534. $orderinfo = $this->input->post('orderinfo', true);
  2535. $number = $this->input->post('number', true);
  2536. $sfxh = $this->input->post('sfxh', true);
  2537. $express = $this->input->post('express', true);
  2538. $waybill = $this->input->post('waybill', true);
  2539. $library = $this->input->post('library', true);
  2540. $country = $this->input->post('country', true);
  2541. $so = $this->input->post('so', true);
  2542. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2543. $print = $this->input->post('print', true);
  2544. $state = $this->input->post('state', true);
  2545. $orderurl = $this->input->post('orderurl', true);
  2546. $timetk = strtotime($timetk);
  2547. $timetj = strtotime($timetj);
  2548. /**
  2549. $sj = $this->input->post('sj',true);
  2550. if($sj)
  2551. {
  2552. $sj = $this->input->post('sj',true);
  2553. }
  2554. else
  2555. {
  2556. $sj = "fullorder";
  2557. }
  2558. **/
  2559. $sj = "fullordertt";
  2560. $where = "1=1";
  2561. if ($warehouse) {
  2562. $where .= " and type = '$warehouse'";
  2563. }
  2564. if ($timetk && $timetj) {
  2565. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2566. }
  2567. if ($orderinfo) {
  2568. $where .= " and orderinfo = '$orderinfo'";
  2569. }
  2570. if ($number) {
  2571. $where .= " and number = '$number'";
  2572. }
  2573. if ($express) {
  2574. $where .= " and express = '$express'";
  2575. }
  2576. if ($waybill) {
  2577. $where .= " and waybill = '$waybill'";
  2578. }
  2579. if ($library) {
  2580. $where .= " and library = '$library'";
  2581. }
  2582. if ($print) {
  2583. $where .= " and print = '$print'";
  2584. }
  2585. if ($libraryconfirm) {
  2586. $where .= " and libraryconfirm = '$libraryconfirm'";
  2587. }
  2588. if ($state) {
  2589. $where .= " and state = '$state'";
  2590. }
  2591. if ($shop) {
  2592. $where .= " and shop = '$shop'";
  2593. }
  2594. if ($country) {
  2595. $where .= " and country = '$country'";
  2596. }
  2597. if ($sfxh != '') {
  2598. $where .= " and sfxh = '$sfxh'";
  2599. }
  2600. if ($so) {
  2601. $where .= " and shipremarks like '%$so%'";
  2602. }
  2603. if ($source) {
  2604. if ($source == '2d') {
  2605. $where .= " and source >= '2'";
  2606. } else {
  2607. $where .= " and source = '$source'";
  2608. }
  2609. }
  2610. if (isset($_SESSION['api'])) {
  2611. foreach ($user as $value) {
  2612. $fgshop .= " shop = " . $value . " or";
  2613. }
  2614. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2615. }
  2616. if ($orderurl) {
  2617. $url = $this->orderurl->read($orderurl);
  2618. $where .= " and link like '%" . $url['url'] . "%'";
  2619. }
  2620. //数据排序
  2621. $order_str = "librarytime desc";
  2622. if (empty($page)) {
  2623. $start = 0;
  2624. $perpage = 1;
  2625. } else {
  2626. $start = ($page - 1) * $perpage;
  2627. }
  2628. //取得信息列表
  2629. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2630. //格式化数据
  2631. foreach ($info_list as $key => $value) {
  2632. $shop = $this->shop->read($value['shop']);
  2633. $info_list[$key]['shop'] = $shop['shopname'];
  2634. $express = $this->express->read($value['express']);
  2635. $info_list[$key]['express'] = $express['servicename'];
  2636. $warehouse = $this->warehouse->read($value['type']);
  2637. $info_list[$key]['type'] = $warehouse['title'];
  2638. if ($value['librarytime'] == '0') {
  2639. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2640. } else {
  2641. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2642. }
  2643. }
  2644. $total = $this->$sj->find_count($where);
  2645. $pagenum = ceil($total / $perpage);
  2646. $over = $total - ($start + $perpage);
  2647. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2648. echo json_encode($rows);
  2649. exit;
  2650. }
  2651. $this->data['express'] = $this->express->find_all();
  2652. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2653. $this->data['wlshop'] = $wlshop;
  2654. $user = $this->user->get_api($_SESSION['api']);
  2655. $powerid = $this->power->read($user['power']);
  2656. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2657. $pid = '';
  2658. foreach ($powertext as $v) {
  2659. $pid .= " id = " . $v . " or";
  2660. }
  2661. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2662. $this->data['fullorderexcel'] = $fullorderexcel;
  2663. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2664. $this->data['orderurl'] = $orderurl;
  2665. $this->_Template('whlabel_toutorder', $this->data);
  2666. }
  2667. //tt出库
  2668. public function _aoutorder()
  2669. {
  2670. if (isset($_SESSION['api'])) {
  2671. $user = $this->user->get_api($_SESSION['api']);
  2672. $usp = $user;
  2673. $fgshop = "";
  2674. $sid = "";
  2675. $user = explode('|', trim($user['shop'], '|'));
  2676. foreach ($user as $value) {
  2677. $fgshop .= " shop = " . $value . " or";
  2678. $sid .= " id = " . $value . " or";
  2679. }
  2680. } else {
  2681. echo "请重新登录";
  2682. }
  2683. $post = $this->input->post(NULL, TRUE);
  2684. if (isset($post['page'])) {
  2685. $page = $this->input->post('page', true);
  2686. $perpage = $this->input->post('perpage', true);
  2687. $warehouse = $this->input->post('warehouse', true);
  2688. $xztime = $this->input->post('xztime', true);
  2689. $timetk = $this->input->post('timetkk', true);
  2690. $timetj = $this->input->post('timetjj', true);
  2691. $shop = $this->input->post('shop', true);
  2692. $source = $this->input->post('source', true);
  2693. $orderinfo = $this->input->post('orderinfo', true);
  2694. $number = $this->input->post('number', true);
  2695. $sfxh = $this->input->post('sfxh', true);
  2696. $express = $this->input->post('express', true);
  2697. $waybill = $this->input->post('waybill', true);
  2698. $library = $this->input->post('library', true);
  2699. $country = $this->input->post('country', true);
  2700. $so = $this->input->post('so', true);
  2701. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2702. $print = $this->input->post('print', true);
  2703. $state = $this->input->post('state', true);
  2704. $orderurl = $this->input->post('orderurl', true);
  2705. $timetk = strtotime($timetk);
  2706. $timetj = strtotime($timetj);
  2707. /**
  2708. $sj = $this->input->post('sj',true);
  2709. if($sj)
  2710. {
  2711. $sj = $this->input->post('sj',true);
  2712. }
  2713. else
  2714. {
  2715. $sj = "fullorder";
  2716. }
  2717. **/
  2718. $sj = "fullorderamz";
  2719. $where = "1=1";
  2720. if ($warehouse) {
  2721. $where .= " and type = '$warehouse'";
  2722. }
  2723. if ($timetk && $timetj) {
  2724. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2725. }
  2726. if ($orderinfo) {
  2727. $where .= " and orderinfo = '$orderinfo'";
  2728. }
  2729. if ($number) {
  2730. $where .= " and number = '$number'";
  2731. }
  2732. if ($express) {
  2733. $where .= " and express = '$express'";
  2734. }
  2735. if ($waybill) {
  2736. $where .= " and waybill = '$waybill'";
  2737. }
  2738. if ($library) {
  2739. $where .= " and library = '$library'";
  2740. }
  2741. if ($print) {
  2742. $where .= " and print = '$print'";
  2743. }
  2744. if ($libraryconfirm) {
  2745. $where .= " and libraryconfirm = '$libraryconfirm'";
  2746. }
  2747. if ($state) {
  2748. $where .= " and state = '$state'";
  2749. }
  2750. if ($shop) {
  2751. $where .= " and shop = '$shop'";
  2752. }
  2753. if ($country) {
  2754. $where .= " and country = '$country'";
  2755. }
  2756. if ($sfxh != '') {
  2757. $where .= " and sfxh = '$sfxh'";
  2758. }
  2759. if ($so) {
  2760. $where .= " and shipremarks like '%$so%'";
  2761. }
  2762. if ($source) {
  2763. if ($source == '2d') {
  2764. $where .= " and source >= '2'";
  2765. } else {
  2766. $where .= " and source = '$source'";
  2767. }
  2768. }
  2769. if (isset($_SESSION['api'])) {
  2770. foreach ($user as $value) {
  2771. $fgshop .= " shop = " . $value . " or";
  2772. }
  2773. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2774. }
  2775. if ($orderurl) {
  2776. $url = $this->orderurl->read($orderurl);
  2777. $where .= " and link like '%" . $url['url'] . "%'";
  2778. }
  2779. //数据排序
  2780. $order_str = "librarytime desc";
  2781. if (empty($page)) {
  2782. $start = 0;
  2783. $perpage = 1;
  2784. } else {
  2785. $start = ($page - 1) * $perpage;
  2786. }
  2787. //取得信息列表
  2788. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2789. //格式化数据
  2790. foreach ($info_list as $key => $value) {
  2791. $shop = $this->shop->read($value['shop']);
  2792. $info_list[$key]['shop'] = $shop['shopname'];
  2793. $express = $this->express->read($value['express']);
  2794. $info_list[$key]['express'] = $express['servicename'];
  2795. $warehouse = $this->warehouse->read($value['type']);
  2796. $info_list[$key]['type'] = $warehouse['title'];
  2797. if ($value['librarytime'] == '0') {
  2798. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2799. } else {
  2800. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2801. }
  2802. }
  2803. $total = $this->$sj->find_count($where);
  2804. $pagenum = ceil($total / $perpage);
  2805. $over = $total - ($start + $perpage);
  2806. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2807. echo json_encode($rows);
  2808. exit;
  2809. }
  2810. $this->data['express'] = $this->express->find_all();
  2811. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2812. $this->data['wlshop'] = $wlshop;
  2813. $user = $this->user->get_api($_SESSION['api']);
  2814. $powerid = $this->power->read($user['power']);
  2815. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2816. $pid = '';
  2817. foreach ($powertext as $v) {
  2818. $pid .= " id = " . $v . " or";
  2819. }
  2820. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2821. $this->data['fullorderexcel'] = $fullorderexcel;
  2822. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2823. $this->data['orderurl'] = $orderurl;
  2824. $this->_Template('whlabel_aoutorder', $this->data);
  2825. }
  2826. //速卖通出库订单
  2827. public function _soutorder()
  2828. {
  2829. if (isset($_SESSION['api'])) {
  2830. $user = $this->user->get_api($_SESSION['api']);
  2831. $usp = $user;
  2832. $fgshop = "";
  2833. $sid = "";
  2834. $user = explode('|', trim($user['shop'], '|'));
  2835. foreach ($user as $value) {
  2836. $sid .= " id = " . $value . " or";
  2837. }
  2838. }
  2839. $post = $this->input->post(NULL, TRUE);
  2840. if (isset($post['page'])) {
  2841. $page = $this->input->post('page', true);
  2842. $perpage = $this->input->post('perpage', true);
  2843. $warehouse = $this->input->post('warehouse', true);
  2844. $xztime = $this->input->post('xztime', true);
  2845. $timetk = $this->input->post('timetkk', true);
  2846. $timetj = $this->input->post('timetjj', true);
  2847. $shop = $this->input->post('shop', true);
  2848. $source = $this->input->post('source', true);
  2849. $orderinfo = $this->input->post('orderinfo', true);
  2850. $number = $this->input->post('number', true);
  2851. $express = $this->input->post('express', true);
  2852. $waybill = $this->input->post('waybill', true);
  2853. $library = $this->input->post('library', true);
  2854. $country = $this->input->post('country', true);
  2855. $sfxh = $this->input->post('sfxh', true);
  2856. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2857. $print = $this->input->post('print', true);
  2858. $state = $this->input->post('state', true);
  2859. $so = $this->input->post('so', true);
  2860. $timetk = strtotime($timetk);
  2861. $timetj = strtotime($timetj);
  2862. /**
  2863. $sj = $this->input->post('sj',true);
  2864. if($sj)
  2865. {
  2866. $sj = $this->input->post('sj',true);
  2867. }
  2868. else
  2869. {
  2870. $sj = "fullorder";
  2871. }
  2872. **/
  2873. $sj = "fullordersmt";
  2874. $where = "1=1";
  2875. if ($warehouse) {
  2876. $where .= " and type = '$warehouse'";
  2877. }
  2878. if ($timetk && $timetj) {
  2879. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2880. }
  2881. if ($orderinfo) {
  2882. $where .= " and orderinfo = '$orderinfo'";
  2883. }
  2884. if ($number) {
  2885. $where .= " and number = '$number'";
  2886. }
  2887. if ($express) {
  2888. $where .= " and express = '$express'";
  2889. }
  2890. if ($waybill) {
  2891. $where .= " and waybill = '$waybill'";
  2892. }
  2893. if ($library) {
  2894. $where .= " and library = '$library'";
  2895. }
  2896. if ($print) {
  2897. $where .= " and print = '$print'";
  2898. }
  2899. if ($libraryconfirm) {
  2900. $where .= " and libraryconfirm = '$libraryconfirm'";
  2901. }
  2902. if ($state) {
  2903. $where .= " and state = '$state'";
  2904. }
  2905. if ($shop) {
  2906. $where .= " and shop = '$shop'";
  2907. }
  2908. if ($sfxh != '') {
  2909. $where .= " and sfxh = '$sfxh'";
  2910. }
  2911. if ($so) {
  2912. $where .= " and shipremarks like '%$so%'";
  2913. }
  2914. if ($source) {
  2915. $where .= " and source = '$source'";
  2916. }
  2917. if ($country) {
  2918. $where .= " and country = '$country'";
  2919. } else {
  2920. if (isset($_SESSION['api'])) {
  2921. foreach ($user as $value) {
  2922. $fgshop .= " shop = " . $value . " or";
  2923. }
  2924. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2925. }
  2926. }
  2927. //数据排序
  2928. $order_str = "librarytime desc";
  2929. if (empty($page)) {
  2930. $start = 0;
  2931. $perpage = 1;
  2932. } else {
  2933. $start = ($page - 1) * $perpage;
  2934. }
  2935. //取得信息列表
  2936. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2937. //格式化数据
  2938. foreach ($info_list as $key => $value) {
  2939. $shop = $this->shop->read($value['shop']);
  2940. $info_list[$key]['shop'] = $shop['shopname'];
  2941. $express = $this->express->read($value['express']);
  2942. $info_list[$key]['express'] = $express['servicename'];
  2943. $warehouse = $this->warehouse->read($value['type']);
  2944. $info_list[$key]['type'] = $warehouse['title'];
  2945. if ($value['librarytime'] == '0') {
  2946. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2947. } else {
  2948. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2949. }
  2950. }
  2951. $total = $this->$sj->find_count($where);
  2952. $pagenum = ceil($total / $perpage);
  2953. $over = $total - ($start + $perpage);
  2954. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2955. echo json_encode($rows);
  2956. exit;
  2957. }
  2958. $this->data['express'] = $this->express->find_all();
  2959. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2960. $this->data['wlshop'] = $wlshop;
  2961. $user = $this->user->get_api($_SESSION['api']);
  2962. $powerid = $this->power->read($user['power']);
  2963. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2964. $pid = '';
  2965. foreach ($powertext as $v) {
  2966. $pid .= " id = " . $v . " or";
  2967. }
  2968. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2969. $this->data['fullorderexcel'] = $fullorderexcel;
  2970. $this->_Template('whlabel_soutorder', $this->data);
  2971. }
  2972. //订单退库
  2973. public function _retreat()
  2974. {
  2975. $post = $this->input->post(NULL, TRUE);
  2976. if (isset($post['page'])) {
  2977. $page = $this->input->post('page', true);
  2978. $perpage = $this->input->post('perpage', true);
  2979. $warehouse = $this->input->post('warehouse', true);
  2980. $timetk = $this->input->post('timetk', true);
  2981. $timetj = $this->input->post('timetj', true);
  2982. $shop = $this->input->post('shop', true);
  2983. $source = $this->input->post('source', true);
  2984. $state = $this->input->post('state', true);
  2985. $review = $this->input->post('review', true);
  2986. $state = $this->input->post('state', true);
  2987. $express = $this->input->post('express', true);
  2988. $orderinfo = $this->input->post('orderinfo', true);
  2989. $user = $this->input->post('user', true);
  2990. $name = $this->input->post('name', true);
  2991. $waybill = $this->input->post('waybill', true);
  2992. $timetk = strtotime($timetk);
  2993. $timetj = strtotime($timetj);
  2994. $where = "(state=206 or state=210) and mergeid = 0";
  2995. if ($warehouse) {
  2996. $where .= " and state = '$warehouse'";
  2997. }
  2998. if ($timetk && $timetj) {
  2999. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3000. }
  3001. if ($shop) {
  3002. $where .= " and shop = '$shop'";
  3003. }
  3004. if ($source) {
  3005. $where .= " and source = '$source'";
  3006. }
  3007. if ($state) {
  3008. $where .= " and state = '$state'";
  3009. }
  3010. if ($review) {
  3011. $where .= " and review = '$review'";
  3012. }
  3013. if ($state) {
  3014. $where .= " and state = '$state'";
  3015. }
  3016. if ($express) {
  3017. $where .= " and express = '$express'";
  3018. }
  3019. if ($orderinfo) {
  3020. $where .= " and orderinfo = '$orderinfo'";
  3021. }
  3022. if ($user) {
  3023. $where .= " and user = '$user'";
  3024. }
  3025. if ($name) {
  3026. $where .= " and name = '$name'";
  3027. }
  3028. if ($waybill) {
  3029. $where .= " and waybill = '$waybill'";
  3030. }
  3031. //数据排序
  3032. $order_str = "id desc";
  3033. if (empty($page)) {
  3034. $start = 0;
  3035. $perpage = 1;
  3036. } else {
  3037. $start = ($page - 1) * $perpage;
  3038. }
  3039. //取得信息列表
  3040. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3041. //格式化数据
  3042. foreach ($info_list as $key => $value) {
  3043. $shop = $this->shop->read($value['shop']);
  3044. $info_list[$key]['shop'] = $shop['shopname'];
  3045. $warehouse = $this->warehouse->read($value['warehouse']);
  3046. $info_list[$key]['warehouse'] = $warehouse['title'];
  3047. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3048. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3049. if ($value['waybill'] == 0) {
  3050. $info_list[$key]['waybill'] = "";
  3051. }
  3052. $express = $this->express->read($value['express']);
  3053. $info_list[$key]['express'] = $express['title'];
  3054. $typeclass = $this->typeclass->read($value['state']);
  3055. $info_list[$key]['state'] = $typeclass['title'];
  3056. }
  3057. $total = $this->fullorder->find_count($where);
  3058. $pagenum = ceil($total / $perpage);
  3059. $over = $total - ($start + $perpage);
  3060. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3061. echo json_encode($rows);
  3062. exit;
  3063. }
  3064. $this->data['express'] = $this->express->find_all();
  3065. $this->_Template('whlabel_retreat', $this->data);
  3066. }
  3067. //退库标签浏览
  3068. public function _retreatlk()
  3069. {
  3070. $post = $this->input->post(NULL, TRUE);
  3071. if (isset($post['page'])) {
  3072. $page = $this->input->post('page', true);
  3073. $perpage = $this->input->post('perpage', true);
  3074. $timetk = $this->input->post('timetk', true);
  3075. $timetj = $this->input->post('timetj', true);
  3076. $sku = $this->input->post('sku', true);
  3077. $warehouse = $this->input->post('warehouse', true);
  3078. $purchase = $this->input->post('purchase', true);
  3079. $orderinfo = $this->input->post('orderinfo', true);
  3080. $waybill = $this->input->post('waybill', true);
  3081. $category = $this->input->post('category', true);
  3082. $size = $this->input->post('size', true);
  3083. $grade = $this->input->post('grade', true);
  3084. $color = $this->input->post('color', true);
  3085. $lowe = $this->input->post('lowe', true);
  3086. $state = $this->input->post('state', true);
  3087. $timetk = strtotime($timetk);
  3088. $timetj = strtotime($timetj);
  3089. $where = "state=2";
  3090. if ($timetk && $timetj) {
  3091. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3092. }
  3093. if ($sku) {
  3094. $where .= " and sku = '$sku'";
  3095. }
  3096. if ($warehouse) {
  3097. $where .= " and warehouse = '$warehouse'";
  3098. }
  3099. if ($purchase) {
  3100. $where .= " and purchase = '$purchase'";
  3101. }
  3102. if ($orderinfo) {
  3103. $where .= " and orderinfo = '$orderinfo'";
  3104. }
  3105. if ($waybill) {
  3106. $where .= " and waybill = '$waybill'";
  3107. }
  3108. if ($category) {
  3109. $where .= " and features like '%-$category-%'";
  3110. }
  3111. if ($size) {
  3112. $where .= " and features like '%-$size-%'";
  3113. }
  3114. if ($grade) {
  3115. $where .= " and features like '%-$grade-%'";
  3116. }
  3117. if ($color) {
  3118. $where .= " and features like '%-$color-%'";
  3119. }
  3120. if ($lowe) {
  3121. $where .= " and features like '%-$lowe-%'";
  3122. }
  3123. //数据排序
  3124. $order_str = "time desc";
  3125. if (empty($page)) {
  3126. $start = 0;
  3127. $perpage = 1;
  3128. } else {
  3129. $start = ($page - 1) * $perpage;
  3130. }
  3131. //取得信息列表
  3132. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3133. foreach ($info_list as $key => $value) {
  3134. $warehouse = $this->warehouse->read($value['warehouse']);
  3135. $info_list[$key]['warehouse'] = $warehouse['title'];
  3136. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3137. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3138. $purchase = $this->purchase->read($value['purchase']);
  3139. $info_list[$key]['purchase'] = $purchase['title'];
  3140. if ($value['outk'] != 0) {
  3141. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3142. } else {
  3143. $info_list[$key]['outk'] = "";
  3144. }
  3145. if ($value['retreat'] != 0) {
  3146. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3147. } else {
  3148. $info_list[$key]['retreat'] = "";
  3149. }
  3150. if ($value['orderinfo'] == 0) {
  3151. $info_list[$key]['orderinfo'] = "";
  3152. }
  3153. if ($value['waybill'] == 0) {
  3154. $info_list[$key]['waybill'] = "";
  3155. }
  3156. }
  3157. $total = $this->whlabel->find_count($where);
  3158. $pagenum = ceil($total / $perpage);
  3159. $over = $total - ($start + $perpage);
  3160. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3161. echo json_encode($rows);
  3162. exit;
  3163. }
  3164. $this->_Template('whlabel_retreatlk', $this->data);
  3165. }
  3166. //更换标签及浏览
  3167. public function _change()
  3168. {
  3169. $post = $this->input->post(NULL, TRUE);
  3170. if (isset($post['page'])) {
  3171. $page = $this->input->post('page', true);
  3172. $perpage = $this->input->post('perpage', true);
  3173. $timetk = $this->input->post('timetk', true);
  3174. $timetj = $this->input->post('timetj', true);
  3175. $label = $this->input->post('label', true);
  3176. $oldlabel = $this->input->post('oldlabel', true);
  3177. $timetk = strtotime($timetk);
  3178. $timetj = strtotime($timetj);
  3179. $where = "state=10 ";
  3180. if ($timetk && $timetj) {
  3181. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3182. }
  3183. if ($label) {
  3184. $where .= " and label = '$label'";
  3185. }
  3186. if ($oldlabel) {
  3187. $where .= " and oldlabel = '$oldlabel'";
  3188. }
  3189. //数据排序
  3190. $order_str = "time asc";
  3191. if (empty($page)) {
  3192. $start = 0;
  3193. $perpage = 1;
  3194. } else {
  3195. $start = ($page - 1) * $perpage;
  3196. }
  3197. //取得信息列表
  3198. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3199. foreach ($info_list as $key => $value) {
  3200. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3201. }
  3202. $total = $this->whlabel->find_count($where);
  3203. $pagenum = ceil($total / $perpage);
  3204. $over = $total - ($start + $perpage);
  3205. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3206. echo json_encode($rows);
  3207. exit;
  3208. }
  3209. $this->_Template('whlabel_change', $this->data);
  3210. }
  3211. //产品标签
  3212. public function _cpbqdc()
  3213. {
  3214. if (isset($_GET['excel'])) {
  3215. $where = "1=1";
  3216. //数据排序
  3217. $order_str = "id desc";
  3218. if (empty($page)) {
  3219. $start = 0;
  3220. $perpage = 1;
  3221. } else {
  3222. $start = ($page - 1) * $perpage;
  3223. }
  3224. $warehouse = $this->input->get('warehouse', true);
  3225. $state = $this->input->get('state', true);
  3226. $timetk = $this->input->get('timetkk', true);
  3227. $timetj = $this->input->get('timetjj', true);
  3228. $timetk = strtotime($timetk);
  3229. $timetj = strtotime($timetj);
  3230. if ($warehouse) {
  3231. $where .= " and warehouse = '$warehouse'";
  3232. }
  3233. if ($state || $state == 0) {
  3234. $where .= " and state = '$state'";
  3235. }
  3236. if ($timetk && $timetj) {
  3237. $where .= " and time > '$timetk' and time < '$timetj'";
  3238. }
  3239. //取得信息列表
  3240. $info_list = $this->whlabel->find_all($where, '*');
  3241. $rows = array();
  3242. $list = array();
  3243. foreach ($info_list as $key => $value) {
  3244. $rows[$value['time']] = $value; //所有数据sku
  3245. }
  3246. foreach ($rows as $value) {
  3247. $warehouse = $this->warehouse->read($value['warehouse']);
  3248. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3249. $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);
  3250. }
  3251. $title = "产品标签统计表";
  3252. $titlename = "<table border=1>
  3253. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3254. <tr align='center'>
  3255. <td>仓库</td>
  3256. <td>SKU</td>
  3257. <td>产品</td>
  3258. <td>入库时间</td>
  3259. <td>操作时间</td>
  3260. <td>备注</td>
  3261. <td>数量</td>
  3262. </tr>
  3263. </table>";
  3264. $filename = $title . ".xls";
  3265. $tail = "";
  3266. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3267. }
  3268. }
  3269. //进销存导出
  3270. public function _exceljxc()
  3271. {
  3272. $classid = $this->classid->sku();
  3273. $pm = $classid;
  3274. $typeclass = array();
  3275. $tc = $this->typeclass->find_all();
  3276. foreach ($tc as $v) {
  3277. $typeclass[$v['id']] = $v;
  3278. }
  3279. $prc = array();
  3280. $purchase = $this->purchase->find_all();
  3281. foreach ($purchase as $k => $v) {
  3282. $prc[$v['id']] = $v['title'];
  3283. }
  3284. if (isset($_GET['excel'])) {
  3285. $where = "sku != 'Preset'";
  3286. //数据排序
  3287. $order_str = "id desc";
  3288. if (empty($page)) {
  3289. $start = 0;
  3290. $perpage = 1;
  3291. } else {
  3292. $start = ($page - 1) * $perpage;
  3293. }
  3294. $category = $this->input->get('category', true);
  3295. $warehouse = $this->input->get('warehouse', true);
  3296. $excelid = $this->input->get('sid', true);
  3297. if ($category) {
  3298. $where .= " and features like '%-$category-%'";
  3299. }
  3300. if ($warehouse) {
  3301. $where .= " and warehouse = '$warehouse'";
  3302. }
  3303. $xzid = '';
  3304. if ($excelid) {
  3305. $excelid = explode(',', trim($excelid, ','));
  3306. foreach ($excelid as $key => $value) {
  3307. $xzid .= " id = " . $value . " or";
  3308. }
  3309. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3310. }
  3311. //取得信息列表
  3312. /**
  3313. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3314. $rows = array();$list = array();
  3315. foreach ($info_list as $key=>$value)
  3316. {
  3317. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3318. }
  3319. **/
  3320. $wt = array();
  3321. $whlabel_type = $this->whlabel_type->find_all();
  3322. foreach ($whlabel_type as $v) {
  3323. $wt[$v['id']] = $v['title'];
  3324. }
  3325. $wh = array();
  3326. $w = $this->warehouse->find_all('1=1', 'id,title');
  3327. foreach ($w as $v) {
  3328. $wh[$v['id']] = $v['title'];
  3329. }
  3330. $list = array();
  3331. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3332. foreach ($rows as $key => $value) {
  3333. if (isset($wt[$value['type']])) {
  3334. $rows[$key]['type'] = $wt[$value['type']];
  3335. } else {
  3336. $rows[$key]['type'] = '未设置';
  3337. }
  3338. $bm = '03';
  3339. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3340. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3341. $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');
  3342. $details = array();
  3343. $cpid = array();
  3344. $cpbz = array();
  3345. $c = 0;
  3346. $g = 0;
  3347. $x = 0;
  3348. $t = 0;
  3349. $s = 0;
  3350. $q = 0;
  3351. foreach ($sd as $k => $v) {
  3352. if ($v['state'] == 0) {
  3353. $c++;
  3354. if ($v['cpid'] != 0) {
  3355. $cpid[$v['cpid']] = $v['cpid'];
  3356. }
  3357. if ($v['cpbz'] != '') {
  3358. $cpbz[$v['cpbz']] = $v['cpbz'];
  3359. }
  3360. }
  3361. if ($v['state'] != 9) {
  3362. $g++;
  3363. }
  3364. if ($v['state'] == 1) {
  3365. $x++;
  3366. }
  3367. if ($v['state'] == 2) {
  3368. $t++;
  3369. }
  3370. if ($v['state'] == 8) {
  3371. $s++;
  3372. }
  3373. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3374. $q++;
  3375. }
  3376. $details[$v['details']] = $v['details'];
  3377. }
  3378. $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'] . '"');
  3379. $rows[$key]['details'] = implode("、", $details);
  3380. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3381. $number = $value['number'];
  3382. $ftime = time() - 15 * 24 * 3600;
  3383. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3384. $rows[$key]['number'] = $g;
  3385. $rows[$key]['c'] = $c;
  3386. $rows[$key]['x'] = $x;
  3387. $rows[$key]['t'] = $t;
  3388. $rows[$key]['s'] = $s;
  3389. $rows[$key]['q'] = $q;
  3390. $rows[$key]['z'] = $z;
  3391. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3392. $features = explode('-', trim($features, '-'));
  3393. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3394. // $pm = $classid;
  3395. // $jm = $classid;
  3396. // foreach($features as $k=>$v)
  3397. // {
  3398. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3399. // {
  3400. // if($typeclass[$v]['bm'] != '')
  3401. // {
  3402. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3403. // }
  3404. // }
  3405. // if($v != 0)
  3406. // {
  3407. // if(!isset($typeclass[$v]))
  3408. // {
  3409. // continue;
  3410. // }
  3411. // if(isset($pm[$typeclass[$v]['classid']]))
  3412. // {
  3413. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3414. // {
  3415. // $tz = explode('|',$typeclass[$v]['zh']);
  3416. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3417. // }
  3418. // else
  3419. // {
  3420. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3421. // }
  3422. // }
  3423. // if(isset($jm[$typeclass[$v]['classid']]))
  3424. // {
  3425. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3426. // }
  3427. // }
  3428. // }
  3429. // $jm = array_filter($jm);
  3430. // $rows[$key]['bs'] = implode("-",$jm);
  3431. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3432. // $zh = implode(" ",$pm);
  3433. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3434. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3435. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3436. // $rows[$key]['features'] = $zh;
  3437. }
  3438. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3439. $final_list = [];
  3440. foreach ($list as $k => $v) {
  3441. if (empty($v['sku'])) {
  3442. continue;
  3443. }
  3444. $final_list[] = [
  3445. "warehouse" => $v["warehouse"],
  3446. "purchase" => $v["purchase"],
  3447. "details" => $v["details"],
  3448. "cpid" => $v["cpid"],
  3449. "dbcontent" => $v["dbcontent"],
  3450. "sku" => $v["sku"],
  3451. "cs" => $v["bm"],
  3452. "bs" => $v["jm"],
  3453. "title" => $v["title"],
  3454. "features" => $v["pm"],
  3455. "cpbz" => $v["cpbz"],
  3456. "sm" => $v["sm"],
  3457. "type" => $v["type"],
  3458. "number" => $v["number"],
  3459. "c" => $v["c"],
  3460. "x" => $v["x"],
  3461. "t" => $v["t"],
  3462. "s" => $v["s"],
  3463. "q" => $v["q"],
  3464. "z" => $v["z"],
  3465. "weight" => $v['weight'],
  3466. ];
  3467. }
  3468. $title = "总进销存统计表";
  3469. $titlename = "<table border=1>
  3470. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3471. <tr align='center'>
  3472. <td>仓库</td>
  3473. <td>供应商</td>
  3474. <td>位置</td>
  3475. <td>库存编码</td>
  3476. <td>类目</td>
  3477. <td>SKU</td>
  3478. <td>用友编码</td>
  3479. <td>用友料号</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>重量(g)</td>
  3493. </tr>
  3494. </table>";
  3495. $filename = $title . ".xls";
  3496. $tail = "";
  3497. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3498. }
  3499. }
  3500. //入库导出
  3501. public function _excelr()
  3502. {
  3503. if (isset($_GET['excel'])) {
  3504. $category = $this->input->get('category', true);
  3505. $size = $this->input->get('size', true);
  3506. $grade = $this->input->get('grade', true);
  3507. $color = $this->input->get('color', true);
  3508. $lowe = $this->input->get('lowe', true);
  3509. $sku = $this->input->get('sku', true);
  3510. $warehouse = $this->input->get('warehouse', true);
  3511. $purchase = $this->input->get('purchase', true);
  3512. $ktime = $this->input->get('ktime', true);
  3513. $jtime = $this->input->get('jtime', true);
  3514. $ktime = strtotime($ktime);
  3515. $jtime = strtotime($jtime);
  3516. $where = "1=1";
  3517. $gj = "";
  3518. $ck = "";
  3519. if ($category) {
  3520. $where .= " and features like '%-$category-%'";
  3521. }
  3522. if ($size) {
  3523. $where .= " and features like '%-$size-%'";
  3524. }
  3525. if ($grade) {
  3526. $where .= " and features like '%-$grade-%'";
  3527. }
  3528. if ($color) {
  3529. $where .= " and features like '%-$color-%'";
  3530. }
  3531. if ($lowe) {
  3532. $where .= " and features like '%-$lowe-%'";
  3533. }
  3534. if ($warehouse) {
  3535. $where .= " and warehouse = '$warehouse'";
  3536. }
  3537. if ($purchase) {
  3538. $where .= " and purchase = '$purchase'";
  3539. }
  3540. if ($sku) {
  3541. $where .= " and sku = '$sku'";
  3542. }
  3543. if ($ktime && $jtime) {
  3544. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3545. }
  3546. //数据排序
  3547. $order_str = "id desc";
  3548. if (empty($page)) {
  3549. $start = 0;
  3550. $perpage = 1;
  3551. } else {
  3552. $start = ($page - 1) * $perpage;
  3553. }
  3554. $list = array();
  3555. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3556. foreach ($rows as $value) {
  3557. $ck = $this->warehouse->read($value['warehouse']);
  3558. $warehouse = $ck['title'];
  3559. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3560. $retreatwarehouse = $tkck['title'];
  3561. $gy = $this->purchase->read($value['purchase']);
  3562. $purchase = $gy['title'];
  3563. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3564. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3565. }
  3566. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3567. $titlename = "<table border=1>
  3568. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3569. <tr align='center'>
  3570. <td>仓库</td>
  3571. <td>SKU</td>
  3572. <td>产品</td>
  3573. <td>时间</td>
  3574. <td>数量</td>
  3575. </tr>
  3576. </table>";
  3577. $filename = $title . ".xls";
  3578. $tail = "";
  3579. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3580. }
  3581. }
  3582. //出库、退库导出
  3583. public function _excelct()
  3584. {
  3585. $classid = $this->classid->sku();
  3586. $pm = $classid;
  3587. $typeclass = array();
  3588. $tc = $this->typeclass->find_all();
  3589. foreach ($tc as $v) {
  3590. $typeclass[$v['id']] = $v;
  3591. }
  3592. $prc = array();
  3593. $purchase = $this->purchase->find_all();
  3594. foreach ($purchase as $k => $v) {
  3595. $prc[$v['id']] = $v['title'];
  3596. }
  3597. if (isset($_GET['excel'])) {
  3598. $wh = array();
  3599. $w = $this->warehouse->find_all('1=1', 'id,title');
  3600. foreach ($w as $v) {
  3601. $wh[$v['id']] = $v['title'];
  3602. }
  3603. $type = $this->input->get('excel', true);
  3604. $category = $this->input->get('category', true);
  3605. $size = $this->input->get('size', true);
  3606. $grade = $this->input->get('grade', true);
  3607. $color = $this->input->get('color', true);
  3608. $lowe = $this->input->get('lowe', true);
  3609. $sku = $this->input->get('sku', true);
  3610. $warehouse = $this->input->get('warehouse', true);
  3611. $lacetype = $this->input->get('lacetype', true);
  3612. $lacecolor = $this->input->get('lacecolor', true);
  3613. $density = $this->input->get('density', true);
  3614. $haircap = $this->input->get('haircap', true);
  3615. $purchase = $this->input->get('purchase', true);
  3616. $title = $this->input->get('title', true);
  3617. $state = $this->input->get('state', true);
  3618. $sid = $this->input->get('sid', true);
  3619. $ktime = $this->input->get('ktime', true);
  3620. $jtime = $this->input->get('jtime', true);
  3621. $ktime = strtotime($ktime);
  3622. $jtime = strtotime($jtime);
  3623. $where = "1=1";
  3624. $gj = "";
  3625. $ck = "";
  3626. if ($category) {
  3627. $where .= " and features like '%-$category-%'";
  3628. }
  3629. if ($size) {
  3630. $where .= " and features like '%-$size-%'";
  3631. }
  3632. if ($grade) {
  3633. $where .= " and features like '%-$grade-%'";
  3634. }
  3635. if ($color) {
  3636. $where .= " and features like '%-$color-%'";
  3637. }
  3638. if ($lowe) {
  3639. $where .= " and features like '%-$lowe-%'";
  3640. }
  3641. if ($warehouse) {
  3642. $where .= " and warehouse = '$warehouse'";
  3643. }
  3644. if ($purchase) {
  3645. $where .= " and purchase = '$purchase'";
  3646. }
  3647. if ($state) {
  3648. $where .= " and state = '$state'";
  3649. }
  3650. if ($lacetype) {
  3651. $where .= " and features like '%-$lacetype-%'";
  3652. }
  3653. if ($lacecolor) {
  3654. $where .= " and features like '%-$lacecolor-%'";
  3655. }
  3656. if ($density) {
  3657. $where .= " and features like '%-$density-%'";
  3658. }
  3659. if ($haircap) {
  3660. $where .= " and features like '%-$haircap-%'";
  3661. }
  3662. if ($title) {
  3663. $title = trim($title, ' ');
  3664. $title = trim($title, ' ');
  3665. $where .= " and title like '%$title%'";
  3666. }
  3667. if ($sku) {
  3668. $sku = trim($sku, ' ');
  3669. $sku = trim($sku, ' ');
  3670. $where .= " and sku like '%$sku%'";
  3671. }
  3672. if ($ktime && $jtime) {
  3673. if ($type == 1) {
  3674. $tl = '出库';
  3675. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3676. } else if ($type == 2) {
  3677. $tl = '退库';
  3678. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3679. } else if ($type == 3) {
  3680. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3681. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3682. } else if ($type == 4) {
  3683. $tl = '出库+零售';
  3684. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3685. } else if ($type == 5) {
  3686. $tl = '零售';
  3687. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3688. }
  3689. }
  3690. $sidwhere = '';
  3691. if ($sid) {
  3692. $sd = "";
  3693. $s = explode(',', trim($sid, ','));
  3694. foreach ($s as $value) {
  3695. $sd .= " id = " . $value . " or";
  3696. }
  3697. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3698. }
  3699. //数据排序
  3700. $order_str = "time desc";
  3701. if (empty($page)) {
  3702. $start = 0;
  3703. $perpage = 1;
  3704. } else {
  3705. $start = ($page - 1) * $perpage;
  3706. }
  3707. //取得信息列表
  3708. if ($type != 3 && $type != 5) {
  3709. if ($type == 1 || $type == 4) {
  3710. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3711. foreach ($info_list as $key => $value) {
  3712. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3713. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3714. $warehouse = $this->warehouse->read($value['warehouse']);
  3715. $info_list[$key]['warehouse'] = $warehouse['title'];
  3716. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3717. $features = explode('-', trim($features, '-'));
  3718. $pm = $classid;
  3719. foreach ($features as $k => $v) {
  3720. if ($v != 0) {
  3721. if (!isset($typeclass[$v])) {
  3722. continue;
  3723. }
  3724. if (isset($pm[$typeclass[$v]['classid']])) {
  3725. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3726. $tz = explode('|', $typeclass[$v]['zh']);
  3727. $pm[$typeclass[$v]['classid']] = $tz[0];
  3728. } else {
  3729. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3730. }
  3731. }
  3732. }
  3733. }
  3734. $zh = implode(" ", $pm);
  3735. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3736. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3737. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3738. $info_list[$key]['features'] = $zh;
  3739. }
  3740. $final_list = [];
  3741. foreach($info_list as $k=>$v){
  3742. $number = "";
  3743. if(!empty($v['orderinfo'])){
  3744. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3745. if(!empty($tmp_info['number'])){
  3746. $number = $tmp_info['number'];
  3747. }
  3748. }
  3749. $final_list[] = [
  3750. 'warehouse'=>$v['warehouse'],
  3751. 'purchase'=>$v['purchase'],
  3752. 'sku'=>$v['sku'],
  3753. 'title'=>$v['title'],
  3754. 'features'=>$v['features'],
  3755. 'label'=>$v['label'],
  3756. 'orderinfo'=>$v['orderinfo'],
  3757. 'number'=>$number,
  3758. 'waybill'=>$v['waybill'],
  3759. 'outk'=>$v['outk'],
  3760. ];
  3761. }
  3762. } else {
  3763. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3764. foreach ($info_list as $key => $value) {
  3765. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3766. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3767. $warehouse = $this->warehouse->read($value['warehouse']);
  3768. $info_list[$key]['warehouse'] = $warehouse['title'];
  3769. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3770. $features = explode('-', trim($features, '-'));
  3771. $pm = $classid;
  3772. foreach ($features as $k => $v) {
  3773. if ($v != 0) {
  3774. if (!isset($typeclass[$v])) {
  3775. continue;
  3776. }
  3777. if (isset($pm[$typeclass[$v]['classid']])) {
  3778. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3779. $tz = explode('|', $typeclass[$v]['zh']);
  3780. $pm[$typeclass[$v]['classid']] = $tz[0];
  3781. } else {
  3782. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3783. }
  3784. }
  3785. }
  3786. }
  3787. $zh = implode(" ", $pm);
  3788. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3789. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3790. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3791. $info_list[$key]['features'] = $zh;
  3792. }
  3793. $final_list = [];
  3794. foreach($info_list as $k=>$v){
  3795. $number = "";
  3796. if(!empty($v['orderinfo'])){
  3797. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3798. if(!empty($tmp_info['number'])){
  3799. $number = $tmp_info['number'];
  3800. }
  3801. }
  3802. $final_list[] = [
  3803. 'warehouse'=>$v['warehouse'],
  3804. 'purchase'=>$v['purchase'],
  3805. 'sku'=>$v['sku'],
  3806. 'title'=>$v['title'],
  3807. 'features'=>$v['features'],
  3808. 'label'=>$v['label'],
  3809. 'orderinfo'=>$v['orderinfo'],
  3810. 'number'=>$number,
  3811. 'waybill'=>$v['waybill'],
  3812. 'retreat'=>$v['retreat'],
  3813. ];
  3814. }
  3815. }
  3816. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3817. $titlename = "<table border=1>
  3818. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3819. <tr align='center'>
  3820. <td>仓库</td>
  3821. <td>供应商</td>
  3822. <td>SKU</td>
  3823. <td>商品名称</td>
  3824. <td>商品中文</td>
  3825. <td>标签</td>
  3826. <td>订单号</td>
  3827. <td>订单编码</td>
  3828. <td>运单号</td>
  3829. <td>" . $tl . "时间(中国时间)</td>
  3830. </tr>
  3831. </table>";
  3832. $filename = $title . ".xls";
  3833. $tail = "";
  3834. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3835. } else if ($type == 5) {
  3836. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3837. foreach ($info_list as $key => $value) {
  3838. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3839. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3840. $warehouse = $this->warehouse->read($value['warehouse']);
  3841. $info_list[$key]['warehouse'] = $warehouse['title'];
  3842. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3843. $features = explode('-', trim($features, '-'));
  3844. $pm = $classid;
  3845. foreach ($features as $k => $v) {
  3846. if ($v != 0) {
  3847. if (!isset($typeclass[$v])) {
  3848. continue;
  3849. }
  3850. if (isset($pm[$typeclass[$v]['classid']])) {
  3851. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3852. $tz = explode('|', $typeclass[$v]['zh']);
  3853. $pm[$typeclass[$v]['classid']] = $tz[0];
  3854. } else {
  3855. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3856. }
  3857. }
  3858. }
  3859. }
  3860. $zh = implode(" ", $pm);
  3861. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3862. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3863. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3864. $info_list[$key]['features'] = $zh;
  3865. }
  3866. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3867. $titlename = "<table border=1>
  3868. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3869. <tr align='center'>
  3870. <td>仓库</td>
  3871. <td>供应商</td>
  3872. <td>SKU</td>
  3873. <td>商品名称</td>
  3874. <td>商品中文</td>
  3875. <td>标签</td>
  3876. <td>" . $tl . "时间(中国时间)</td>
  3877. </tr>
  3878. </table>";
  3879. $filename = $title . ".xls";
  3880. $tail = "";
  3881. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3882. } else {
  3883. /**
  3884. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3885. $rows = array();$list = array();
  3886. foreach ($info_list as $key=>$value)
  3887. {
  3888. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3889. }
  3890. **/
  3891. $wh = array();
  3892. $w = $this->warehouse->find_all('1=1', 'id,title');
  3893. foreach ($w as $v) {
  3894. $wh[$v['id']] = $v['title'];
  3895. }
  3896. $wt = array();
  3897. $whlabel_type = $this->whlabel_type->find_all();
  3898. foreach ($whlabel_type as $v) {
  3899. $wt[$v['id']] = $v['title'];
  3900. }
  3901. $classid = $this->classid->sku();
  3902. $list = array();
  3903. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3904. foreach ($rows as $key => $value) {
  3905. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3906. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3907. $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');
  3908. $details = array();
  3909. $cpid = array();
  3910. $cpbz = array();
  3911. $c = 0;
  3912. $g = 0;
  3913. $x = 0;
  3914. $t = 0;
  3915. $s = 0;
  3916. $q = 0;
  3917. foreach ($sd as $k => $v) {
  3918. if ($v['state'] == 0) {
  3919. $c++;
  3920. }
  3921. if ($v['state'] != 9) {
  3922. $g++;
  3923. }
  3924. if ($v['outk'] > 1) {
  3925. $x++;
  3926. }
  3927. if ($v['retreat'] > 0) {
  3928. $t++;
  3929. }
  3930. if ($v['state'] == 8) {
  3931. $s++;
  3932. }
  3933. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3934. $q++;
  3935. }
  3936. $details[$v['details']] = $v['details'];
  3937. if ($v['cpid'] != 0) {
  3938. $cpid[$v['cpid']] = $v['cpid'];
  3939. }
  3940. if ($v['cpbz'] != '') {
  3941. $cpbz[$v['cpbz']] = $v['cpbz'];
  3942. }
  3943. }
  3944. if (isset($wt[$value['type']])) {
  3945. $rows[$key]['type'] = $wt[$value['type']];
  3946. } else {
  3947. $rows[$key]['type'] = '未设置';
  3948. }
  3949. $rows[$key]['details'] = implode("、", $details);
  3950. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3951. $ftime = time() - 15 * 24 * 3600;
  3952. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3953. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3954. $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);
  3955. $rows[$key]['c'] = $c;
  3956. $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);
  3957. $rows[$key]['t'] = $t;
  3958. $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'] . '"');
  3959. $rows[$key]['z'] = $z;
  3960. // $jm = $classid;
  3961. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3962. $features = explode('-', trim($features, '-'));
  3963. // $pm = $classid;
  3964. // foreach ($features as $k => $v) {
  3965. // if ($v != 0) {
  3966. // if (!isset($typeclass[$v])) {
  3967. // continue;
  3968. // }
  3969. // if (isset($pm[$typeclass[$v]['classid']])) {
  3970. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3971. // $tz = explode('|', $typeclass[$v]['zh']);
  3972. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3973. // } else {
  3974. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3975. // }
  3976. // if (isset($jm[$typeclass[$v]['classid']])) {
  3977. // if ($typeclass[$v]['jm']) {
  3978. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3979. // }
  3980. // }
  3981. // }
  3982. // }
  3983. // }
  3984. // $zh = implode(" ", $pm);
  3985. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3986. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3987. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3988. // $rows[$key]['features'] = $zh;
  3989. // $jm = array_filter($jm); //去除空值
  3990. // $jm = implode("-", $jm);
  3991. // $rows[$key]['jm'] = $jm;
  3992. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  3993. }
  3994. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  3995. // echo "<pre>";
  3996. // print_r($tmp_list);
  3997. // die;
  3998. $final_list =[];
  3999. foreach($tmp_list as $k=>$v){
  4000. $final_list[] = [
  4001. "warehouse"=>$v['warehouse'],
  4002. "purchase"=>$v['purchase'],
  4003. "details"=>$v['details'],
  4004. "cpid"=>$v['cpid'],
  4005. "sku"=>$v['sku'],
  4006. "title"=>$v['title'],
  4007. "features"=>$v['pm'],
  4008. "cpbz"=>$v['cpbz'],
  4009. "sm"=>$v['sm'],
  4010. "type"=>$v['type'],
  4011. "g"=>$v["g"],
  4012. "c"=>$v["c"],
  4013. "x"=>$v["x"],
  4014. "t"=>$v["t"],
  4015. "z"=>$v["z"],
  4016. "jm"=>$v["jm"],
  4017. "weight"=>$v["weight"],
  4018. "asd"=>$v["asd"],
  4019. ];
  4020. }
  4021. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4022. $titlename = "<table border=1>
  4023. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4024. <tr align='center'>
  4025. <td>仓库</td>
  4026. <td>供应商</td>
  4027. <td>位置</td>
  4028. <td>库存编码</td>
  4029. <td>SKU</td>
  4030. <td>商品名称</td>
  4031. <td>商品中文</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. </tr>
  4044. </table>";
  4045. $filename = $title . ".xls";
  4046. $tail = "";
  4047. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4048. }
  4049. }
  4050. }
  4051. //出库+入库数据整合
  4052. public function _excelcr()
  4053. {
  4054. if (isset($_GET['excel'])) {
  4055. $type = $this->input->get('excel', true);
  4056. $category = $this->input->get('category', true);
  4057. $size = $this->input->get('size', true);
  4058. $grade = $this->input->get('grade', true);
  4059. $color = $this->input->get('color', true);
  4060. $lowe = $this->input->get('lowe', true);
  4061. $sku = $this->input->get('sku', true);
  4062. $warehouse = $this->input->get('warehouse', true);
  4063. $purchase = $this->input->get('purchase', true);
  4064. $state = $this->input->get('state', true);
  4065. $sid = $this->input->get('sid', true);
  4066. $ktime = $this->input->get('ktime', true);
  4067. $jtime = $this->input->get('jtime', true);
  4068. $ktime = strtotime($ktime);
  4069. $jtime = strtotime($jtime);
  4070. $where = "1=1";
  4071. $gj = "";
  4072. $ck = "";
  4073. if ($category) {
  4074. $where .= " and features like '%-$category-%'";
  4075. }
  4076. if ($size) {
  4077. $where .= " and features like '%-$size-%'";
  4078. }
  4079. if ($grade) {
  4080. $where .= " and features like '%-$grade-%'";
  4081. }
  4082. if ($color) {
  4083. $where .= " and features like '%-$color-%'";
  4084. }
  4085. if ($lowe) {
  4086. $where .= " and features like '%-$lowe-%'";
  4087. }
  4088. if ($warehouse) {
  4089. $where .= " and warehouse = '$warehouse'";
  4090. }
  4091. if ($purchase) {
  4092. $where .= " and purchase = '$purchase'";
  4093. }
  4094. if ($state) {
  4095. $where .= " and state = '$state'";
  4096. }
  4097. if ($sku) {
  4098. $where .= " and sku like '%$sku%'";
  4099. }
  4100. if ($ktime && $jtime) {
  4101. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4102. }
  4103. $sidwhere = '';
  4104. if ($sid) {
  4105. $sd = "";
  4106. $s = explode(',', trim($sid, ','));
  4107. foreach ($s as $value) {
  4108. $sd .= " id = " . $value . " or";
  4109. }
  4110. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4111. }
  4112. //取得信息列表
  4113. $timeread = $ktime;
  4114. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4115. $timelist = array();
  4116. for ($i = 0; $i < $timenum; $i++) {
  4117. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4118. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4119. }
  4120. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4121. //echo "<pre>";
  4122. //print_r($info_list);
  4123. //exit();
  4124. $rows = array();
  4125. $list = array();
  4126. foreach ($info_list as $key => $value) {
  4127. $thistime = $timelist;
  4128. if (isset($rows[strtolower($value['sku'])])) {
  4129. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4130. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4131. }
  4132. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4133. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4134. }
  4135. } else {
  4136. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4137. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4138. }
  4139. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4140. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4141. }
  4142. $rows[strtolower($value['sku'])] = $thistime;
  4143. }
  4144. }
  4145. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4146. <head>
  4147. <!--[if gte mso 9]><xml>
  4148. <x:ExcelWorkbook>
  4149. <x:ExcelWorksheets>
  4150. <x:ExcelWorksheet>
  4151. <x:Name>EXCEL</x:Name>
  4152. <x:WorksheetOptions>
  4153. <x:Print>
  4154. <x:ValidPrinterInfo />
  4155. </x:Print>
  4156. </x:WorksheetOptions>
  4157. </x:ExcelWorksheet>
  4158. </x:ExcelWorksheets>
  4159. </x:ExcelWorkbook>
  4160. </xml>
  4161. <![endif]-->
  4162. </head><body>";
  4163. $str .= "<table border=1><tr><td>SKU</td>";
  4164. foreach ($timelist as $k => $v) {
  4165. $str .= "<td>" . $k . "出库</td>";
  4166. $str .= "<td>" . $k . "入库</td>";
  4167. }
  4168. $str .= "</tr></table>";
  4169. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4170. foreach ($rows as $key => $val) {
  4171. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4172. foreach ($val as $k => $v) {
  4173. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4174. if ($val[$k]['r'] > 0) {
  4175. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4176. } else {
  4177. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4178. }
  4179. }
  4180. $str .= "</tr>";
  4181. }
  4182. $str .= "</table>";
  4183. $str .= "</body></html>";
  4184. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4185. header("Content-type: application/octet-stream");
  4186. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4187. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4188. header("Pragma: no-cache");
  4189. header("Expires: 0");
  4190. exit($str);
  4191. }
  4192. }
  4193. //数量调整模板导出
  4194. public function _presetout()
  4195. {
  4196. if (isset($_GET['excel'])) {
  4197. $where = "sku != 'Preset' and purchase != 0";
  4198. //数据排序
  4199. $order_str = "id desc";
  4200. if (empty($page)) {
  4201. $start = 0;
  4202. $perpage = 1;
  4203. } else {
  4204. $start = ($page - 1) * $perpage;
  4205. }
  4206. //取得信息列表
  4207. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4208. $rows = array();
  4209. $list = array();
  4210. foreach ($info_list as $value) {
  4211. $warehouse = $this->warehouse->read($value['warehouse']);
  4212. $number = $value['number'];
  4213. $ftime = time() - 15 * 24 * 3600;
  4214. $purchase = $this->purchase->read($value['purchase']);
  4215. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4216. }
  4217. $title = "库存模板";
  4218. $titlename = "<table border=1>
  4219. <tr align='center'>
  4220. <td>仓库</td>
  4221. <td>供应商编码</td>
  4222. <td>SKU</td>
  4223. <td>增减数量(正数或负数)</td>
  4224. <td>增减备注</td>
  4225. <td>扣减方式:0减少库存1删除库存</td>
  4226. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4227. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4228. </tr>
  4229. </table>";
  4230. $filename = $title . ".xls";
  4231. $tail = "";
  4232. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4233. }
  4234. }
  4235. //数量调整模板导入
  4236. public function _presetedit()
  4237. {
  4238. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4239. $config['upload_path'] = '.' . $dir;
  4240. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4241. $config['allowed_types'] = 'xls|xlsx|csv';
  4242. $config['max_size'] = 10240;
  4243. $this->load->library('upload', $config);
  4244. $this->upload->initialize($config);
  4245. if ($this->upload->do_upload('userfile')) {
  4246. $full_path = $dir . $this->upload->data('file_name');
  4247. $fileName = '.' . $full_path;
  4248. if (!file_exists($fileName)) {
  4249. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4250. exit;
  4251. } else {
  4252. require_once "./data/excel/PHPExcel/IOFactory.php";
  4253. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4254. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4255. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4256. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4257. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4258. ++$column; //如果列数大于26行
  4259. $list = array();
  4260. for ($i = 2; $i <= $row; $i++) // 行数循环
  4261. {
  4262. $data = array();
  4263. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4264. {
  4265. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4266. }
  4267. $list[] = $data;
  4268. }
  4269. }
  4270. $i = 0;
  4271. $j = 0;
  4272. $ed = array();
  4273. foreach ($list as $key => $value) {
  4274. $time = time();
  4275. if ($value['0'] == "") {
  4276. continue;
  4277. }
  4278. $warehouse = $this->warehouse->get_title($value['0']);
  4279. $purchase = $this->purchase->get_bm($value['1']);
  4280. $sku = $value['2'];
  4281. $num = $value['3']; //调整数量
  4282. $text = $value['4']; //扣减说明
  4283. $type = $value['5']; //调整方式0扣减1删除
  4284. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4285. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4286. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4287. if (!$purchase) //如果没有这个SKU
  4288. {
  4289. $ed[] = array($purchase . '-不存在此供应商编码');
  4290. $j++;
  4291. continue;
  4292. }
  4293. if (!$d) //如果没有这个SKU
  4294. {
  4295. $ed[] = array($sku . '-库存中不存在此SKU');
  4296. $j++;
  4297. continue;
  4298. }
  4299. if (!isset($warehouse['id'])) {
  4300. $ed[] = array($sku . '-仓库名错误!');
  4301. $j++;
  4302. continue;
  4303. }
  4304. if ($type != '0' && $type != '1') {
  4305. $ed[] = array($sku . '-扣减方式填写错误!');
  4306. $j++;
  4307. continue;
  4308. }
  4309. if ($num < 0) //扣减库存
  4310. {
  4311. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4312. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4313. $j++;
  4314. continue;
  4315. }
  4316. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4317. if (count($data) < abs($num)) {
  4318. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4319. $j++;
  4320. continue;
  4321. }
  4322. if ($type == 0) //如果扣减方式为 扣减库存
  4323. {
  4324. for ($i = 0; $i < abs($num); $i++) {
  4325. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4326. }
  4327. } else if ($type == 1) {
  4328. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4329. if (count($zt) > 0) {
  4330. $ed[] = array($sku . '-有在途库存无法删除!');
  4331. $j++;
  4332. continue;
  4333. }
  4334. for ($i = 0; $i < abs($num); $i++) {
  4335. $this->whlabel->remove($data[$i]['id']);
  4336. }
  4337. }
  4338. } else if ($num > 0) //增加库存
  4339. {
  4340. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4341. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4342. $j++;
  4343. continue;
  4344. }
  4345. $post['sku'] = $d['sku'];
  4346. $post['shop'] = $d['shop'];
  4347. $post['warehouse'] = $warehouse['id'];
  4348. $post['purchase'] = $purchase['id'];
  4349. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4350. $post['state'] = 0;
  4351. $post['title'] = $d['title'];
  4352. $post['number'] = $d['number'];
  4353. $post['features'] = $d['features'];
  4354. $post['enter'] = $time;
  4355. $post['time'] = $time; //操作时间
  4356. $post['rktype'] = $rktype;
  4357. for ($i = 0; $i < $num; $i++) {
  4358. $post['label'] = time() . rand(100, 999) . $i;
  4359. $this->whlabel->insert($post);
  4360. }
  4361. }
  4362. sleep(1); //防止入库时间一样,需要延迟1秒
  4363. }
  4364. if ($j > 0) {
  4365. $tt = date('Ymd', time());
  4366. $title = '库存导入错误信息-' . $tt;
  4367. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4368. $tail = "\n";
  4369. $filename = $title . ".xls";
  4370. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4371. $dir = '/data/excel/' . $time . '/';
  4372. $file_name = 'error_' . $time . rand(1000, 9999);
  4373. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4374. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4375. fwrite($myfile, $ecl);
  4376. fclose($myfile);
  4377. $error = $dir . $file_name . '.xls';
  4378. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4379. exit;
  4380. } else {
  4381. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4382. exit;
  4383. }
  4384. }
  4385. }
  4386. //笛卡儿积
  4387. function cp($ps, $sets, $list)
  4388. {
  4389. $result = array();
  4390. $j = 0;
  4391. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4392. if ($i == 0) {
  4393. $result = $sets[$i];
  4394. }
  4395. $tmp = array();
  4396. foreach ($result as $res) {
  4397. foreach ($sets[$i + 1] as $set) {
  4398. $tmp[] = $res . ',' . $set;
  4399. }
  4400. }
  4401. $result = $tmp;
  4402. }
  4403. $this->db->trans_begin();
  4404. foreach ($result as $v) {
  4405. $post = array();
  4406. $title = "";
  4407. $num = "";
  4408. $data = explode(',', $v);
  4409. for ($i = 0; $i < count($list); $i++) {
  4410. $post[$list[$i]] = $data[$i];
  4411. $typeclass = $this->typeclass->read($data[$i]);
  4412. $title = $title . $typeclass['title'] . " ";
  4413. if ($data[$i] != 0) {
  4414. $num .= $data[$i]; //所有数据ID拼接
  4415. }
  4416. }
  4417. foreach ($ps as $kp => $vp) {
  4418. $post[$kp] = $vp;
  4419. }
  4420. $post['number'] = $num;
  4421. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4422. if ($info_list) {
  4423. $j++;
  4424. } else {
  4425. $skunum = $this->whlabel->find_count();
  4426. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4427. $post['title'] = rtrim($title, ' ');
  4428. $this->whlabel->insert($post);
  4429. }
  4430. }
  4431. if ($this->db->trans_status() === FALSE) {
  4432. $this->db->trans_commit();
  4433. return NULL;
  4434. } else {
  4435. $this->db->trans_commit();
  4436. return $j;
  4437. }
  4438. }
  4439. public function _kj($arg_array)
  4440. {
  4441. if (isset($_POST['sku'])) {
  4442. $time = time();
  4443. $sku = $this->input->post('sku', true);
  4444. $warehouse = $this->input->post('warehouse', true);
  4445. $num = $this->input->post('num', true);
  4446. $text = $this->input->post('text', true);
  4447. $purchase = $this->input->post('purchase', true);
  4448. $cktype = $this->input->post('cktype', true);
  4449. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4450. if ($cktype != 1 && $text == '') {
  4451. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4452. exit;
  4453. }
  4454. if ($num > count($order)) {
  4455. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4456. exit;
  4457. } else {
  4458. for ($i = 0; $i < $num; $i++) {
  4459. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4460. }
  4461. }
  4462. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4463. exit;
  4464. }
  4465. $uid = $this->whlabel->read($arg_array[0]);
  4466. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4467. $this->data['data'] = $uid;
  4468. $this->_Template('whlabel_kj', $this->data);
  4469. }
  4470. public function _summary($arg_array)
  4471. {
  4472. $prc = array();
  4473. $purchase = $this->purchase->find_all();
  4474. foreach ($purchase as $k => $v) {
  4475. $prc[$v['id']] = $v['title'];
  4476. }
  4477. if (isset($_GET['excel'])) {
  4478. $ktime = $this->input->get('ktime', true);
  4479. $jtime = $this->input->get('jtime', true);
  4480. $ktime = strtotime($ktime);
  4481. $jtime = strtotime($jtime);
  4482. $where = "1=1";
  4483. if ($ktime && $jtime) {
  4484. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4485. }
  4486. //数据排序
  4487. $order_str = "time desc";
  4488. if (empty($page)) {
  4489. $start = 0;
  4490. $perpage = 1;
  4491. } else {
  4492. $start = ($page - 1) * $perpage;
  4493. }
  4494. //取得信息列表
  4495. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4496. foreach ($info_list as $key => $value) {
  4497. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4498. $warehouse = $this->warehouse->read($value['warehouse']);
  4499. $info_list[$key]['warehouse'] = $warehouse['title'];
  4500. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4501. $details = array();
  4502. $cpid = array();
  4503. foreach ($x as $k => $v) {
  4504. if ($v['details'] != '') {
  4505. $details[$v['details']] = $v['details'];
  4506. }
  4507. if ($v['cpid'] != 0) {
  4508. $cpid[$v['cpid']] = $v['cpid'];
  4509. }
  4510. }
  4511. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4512. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4513. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4514. $info_list[$key]['s'] = $s;
  4515. $info_list[$key]['x'] = count($x);
  4516. }
  4517. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4518. $titlename = "<table border=1>
  4519. <tr align='center'>
  4520. <td>仓库</td>
  4521. <td>供应商</td>
  4522. <td>出库位置</td>
  4523. <td>出库编码</td>
  4524. <td>SKU</td>
  4525. <td>产品名</td>
  4526. <td>总剩余库存</td>
  4527. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4528. </tr>
  4529. </table>";
  4530. $filename = $title . ".xls";
  4531. $tail = "";
  4532. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4533. }
  4534. }
  4535. //usps发货清单
  4536. public function _manifest()
  4537. {
  4538. if (isset($_POST['manifest'])) {
  4539. $wltext = $this->input->post('wltext', true);
  4540. $time = time() - 16 * 3600;
  4541. $ptime = strtotime(date('Y-m-d', $time));
  4542. $waybill = array();
  4543. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4544. foreach ($fullorder as $v) {
  4545. $waybill[$v['waybill']] = $v['waybill'];
  4546. }
  4547. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4548. foreach ($fullordersmt as $v) {
  4549. $waybill[$v['waybill']] = $v['waybill'];
  4550. }
  4551. $wltext = explode(';', $wltext);
  4552. foreach ($wltext as $v) {
  4553. if (isset($waybill[$v])) {
  4554. unset($waybill[$v]);
  4555. }
  4556. }
  4557. $data = $this->usps->get_manifest($waybill);
  4558. if (isset($data['Description'])) {
  4559. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4560. exit;
  4561. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4562. $bctime = date('Ymd', time());
  4563. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4564. echo json_encode(array('msg' => $pdf, 'success' => true));
  4565. exit;
  4566. } else {
  4567. echo json_encode(array('msg' => $data, 'success' => false));
  4568. exit;
  4569. }
  4570. }
  4571. }
  4572. public function _pdf($pdf, $title, $bctime)
  4573. {
  4574. $pdf_path = './data/pdf/' . $bctime . '/';
  4575. $file_base64 = $pdf;
  4576. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4577. $file_base64 = base64_decode($file_base64);
  4578. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4579. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4580. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4581. }
  4582. /**
  4583. *
  4584. *
  4585. *
  4586. 进销存占单异常索引
  4587. *
  4588. *
  4589. *
  4590. **/
  4591. public function _abnormal()
  4592. {
  4593. $post = $this->input->post(NULL, TRUE);
  4594. if (isset($post['page'])) {
  4595. $page = $this->input->post('page', true);
  4596. $perpage = $this->input->post('perpage', true);
  4597. $sku = $this->input->post('sku', true);
  4598. $where = "1=1";
  4599. //数据排序
  4600. $order_str = "id desc";
  4601. if (empty($page)) {
  4602. $start = 0;
  4603. $perpage = 1;
  4604. } else {
  4605. $start = ($page - 1) * $perpage;
  4606. }
  4607. //取得信息列表
  4608. $info_list = $this->whlabel->find_all($where, '*');
  4609. $rows = array();
  4610. $list = array();
  4611. foreach ($info_list as $key => $value) {
  4612. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4613. }
  4614. foreach ($rows as $value) {
  4615. $warehouse = $this->warehouse->read($value['warehouse']);
  4616. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4617. $number = $value['number'];
  4618. $ftime = time() - 15 * 24 * 3600;
  4619. if ($value['shop'] != '') {
  4620. $shop = $value['shop'];
  4621. $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');
  4622. $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');
  4623. $order = array_merge($orderdlz, $ordersmt);
  4624. $od = 0;
  4625. $a = '';
  4626. $orid = '';
  4627. foreach ($order as $v) {
  4628. $or = explode('|', ltrim($v['whlabel'], '|'));
  4629. for ($i = 0; $i < count($or); $i++) {
  4630. $orod = explode('-', $or[$i]);
  4631. if ($orod[0] == $number) {
  4632. $od += $orod[1];
  4633. }
  4634. }
  4635. $orid .= $v['number'] . '-';
  4636. }
  4637. } else {
  4638. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4639. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4640. $order = array_merge($orderdlz, $ordersmt);
  4641. $od = 0;
  4642. $a = '';
  4643. $orid = '';
  4644. $qt = array();
  4645. foreach ($order as $v) {
  4646. $or = explode('|', ltrim($v['whlabel'], '|'));
  4647. for ($i = 0; $i < count($or); $i++) {
  4648. $orod = explode('-', $or[$i]);
  4649. if ($orod[0] == $number) {
  4650. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4651. if ($czzs > 0) {
  4652. if (isset($qt[$v['shop']])) {
  4653. if ($qt[$v['shop']] < $orod[1]) {
  4654. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4655. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4656. } else {
  4657. $qt[$v['shop']] -= $orod[1];
  4658. }
  4659. } else {
  4660. $qt[$v['shop']] = $czzs;
  4661. }
  4662. } else {
  4663. $od += $orod[1];
  4664. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4665. }
  4666. }
  4667. }
  4668. }
  4669. }
  4670. $z = $od . '(' . $orid . ')'; //查看订单号
  4671. //$z = $od;
  4672. if ($od > $c) {
  4673. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4674. }
  4675. }
  4676. $listdata = array_slice($list, $start, $perpage);
  4677. $total = count($list);
  4678. $pagenum = ceil($total / $perpage);
  4679. $over = $total - ($start + $perpage);
  4680. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4681. echo json_encode($rows);
  4682. exit;
  4683. }
  4684. $this->_Template('whlabel_abnormal', $this->data);
  4685. }
  4686. /**
  4687. *
  4688. *
  4689. *
  4690. 进销存占单异常索引
  4691. *
  4692. *
  4693. *
  4694. **/
  4695. public function _error()
  4696. {
  4697. $post = $this->input->post(NULL, TRUE);
  4698. if (isset($post['page'])) {
  4699. $page = $this->input->post('page', true);
  4700. $perpage = $this->input->post('perpage', true);
  4701. $sku = $this->input->post('sku', true);
  4702. $warehouse = $this->input->post('warehouse', true);
  4703. $ktime = $this->input->post('ktime', true);
  4704. $jtime = $this->input->post('jtime', true);
  4705. $ktime = strtotime($ktime);
  4706. $jtime = strtotime($jtime);
  4707. $where = "sku != 'Preset'";
  4708. $gj = '';
  4709. if ($sku) {
  4710. $where .= " and sku like '%$sku%'";
  4711. } else {
  4712. if ($ktime && $jtime) {
  4713. $gj = " and time > '$ktime' and time < '$jtime'";
  4714. }
  4715. }
  4716. if ($warehouse) {
  4717. $where .= " and warehouse = '$warehouse'";
  4718. }
  4719. //数据排序
  4720. $order_str = "id desc";
  4721. if (empty($page)) {
  4722. $start = 0;
  4723. $perpage = 1;
  4724. } else {
  4725. $start = ($page - 1) * $perpage;
  4726. }
  4727. //取得信息列表
  4728. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4729. $rows = array();
  4730. $list = array();
  4731. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4732. // foreach ($info_list as $value)
  4733. // {
  4734. // $warehouse = $this->warehouse->read($value['warehouse']);
  4735. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4736. // $number = $value['number'];$ftime = time()-15*24*3600;
  4737. // if($c < 1)
  4738. // {
  4739. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4740. // }
  4741. // }
  4742. $warehouse_list = $this->warehouse->find_all();
  4743. $warehouse_list = array_column($warehouse_list, null, 'id');
  4744. foreach ($info_list as $value) {
  4745. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4746. 'title' => "",
  4747. ];
  4748. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4749. $number = $value['number'];
  4750. $ftime = time() - 15 * 24 * 3600;
  4751. if ($c < 1) {
  4752. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4753. }
  4754. }
  4755. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4756. // $query = $this->db->query($sql);
  4757. // $info_list = $query->result_array();
  4758. // $sql_two = "select title,id from crowd_warehouse";
  4759. // $query_two = $this->db->query($sql_two);
  4760. // $warehouse_list = $query_two->result_array();
  4761. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4762. // foreach ($info_list as $value)
  4763. // {
  4764. // if(isset($warehouse_arr[$value['warehouse']])){
  4765. // $warehouse = $warehouse_arr[$value['warehouse']];
  4766. // }else{
  4767. // $warehouse = [
  4768. // 'id'=>0,
  4769. // 'title'=>"异常",
  4770. // ];
  4771. // }
  4772. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4773. // $number = $value['number'];$ftime = time()-15*24*3600;
  4774. // if($c < 1)
  4775. // {
  4776. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4777. // }
  4778. // }
  4779. $listdata = array_slice($list, $start, $perpage);
  4780. $total = count($list);
  4781. $pagenum = ceil($total / $perpage);
  4782. $over = $total - ($start + $perpage);
  4783. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4784. echo json_encode($rows);
  4785. exit;
  4786. }
  4787. if (isset($post['s'])) {
  4788. $id_arr = $this->input->post('s');
  4789. $id_arr = explode(',', trim($id_arr, ','));
  4790. if (!$id_arr) {
  4791. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4792. exit;
  4793. }
  4794. //循环删除记录
  4795. foreach ($id_arr as $v) {
  4796. $dd = $this->whlabel->read($v);
  4797. if (!isset($dd['id'])) {
  4798. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4799. exit;
  4800. }
  4801. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4802. if (isset($zt[0])) {
  4803. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4804. exit;
  4805. }
  4806. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4807. foreach ($deldd as $vv) {
  4808. $this->whlabel->remove($vv['id']);
  4809. }
  4810. }
  4811. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4812. exit;
  4813. }
  4814. $this->_Template('whlabel_error', $this->data);
  4815. }
  4816. public function _errorexcel()
  4817. {
  4818. $post = $this->input->post(NULL, TRUE);
  4819. if (isset($_GET['page'])) {
  4820. $page = $this->input->get('page', true);
  4821. $perpage = $this->input->get('perpage', true);
  4822. $sku = $this->input->get('sku', true);
  4823. $warehouse = $this->input->get('warehouse', true);
  4824. $ktime = $this->input->get('ktime', true);
  4825. $jtime = $this->input->get('jtime', true);
  4826. $ktime = strtotime($ktime);
  4827. $jtime = strtotime($jtime);
  4828. $where = "sku != 'Preset'";
  4829. $gj = '';
  4830. if ($sku) {
  4831. $where .= " and sku like '%$sku%'";
  4832. } else {
  4833. if ($ktime && $jtime) {
  4834. $gj = " and time > '$ktime' and time < '$jtime'";
  4835. }
  4836. }
  4837. if ($warehouse) {
  4838. $where .= " and warehouse = '$warehouse'";
  4839. }
  4840. //数据排序
  4841. $order_str = "id desc";
  4842. if (empty($page)) {
  4843. $start = 0;
  4844. $perpage = 1;
  4845. } else {
  4846. $start = ($page - 1) * $perpage;
  4847. }
  4848. //取得信息列表
  4849. $rows = array();
  4850. $list = array();
  4851. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4852. foreach ($info_list as $value) {
  4853. $warehouse = $this->warehouse->read($value['warehouse']);
  4854. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4855. $number = $value['number'];
  4856. $ftime = time() - 15 * 24 * 3600;
  4857. if ($c < 1) {
  4858. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4859. }
  4860. }
  4861. $title = "0库存汇总";
  4862. $titlename = "<table border=1>
  4863. <tr align='center'>
  4864. <td>仓库</td>
  4865. <td>SKU</td>
  4866. <td>产品</td>
  4867. <td>当前库存</td>
  4868. </tr>
  4869. </table>";
  4870. $filename = $title . ".xls";
  4871. $tail = "";
  4872. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4873. }
  4874. }
  4875. /**
  4876. *
  4877. *
  4878. * 占单
  4879. *
  4880. *
  4881. **/
  4882. public function _kcyz()
  4883. {
  4884. $post = $this->input->post(NULL, TRUE);
  4885. if (isset($post['warehouse'])) {
  4886. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4887. exit; //不再使用
  4888. $warehouse = $this->input->post('warehouse', true);
  4889. $whlabel = $this->input->post('whlabel', true);
  4890. $id = $this->input->post('id', true);
  4891. $shop = $this->input->post('shop', true);
  4892. $number = $this->input->post('number', true);
  4893. if (!$whlabel || $whlabel == '|') {
  4894. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4895. exit;
  4896. }
  4897. $pp = explode('|', trim($whlabel, '|'));
  4898. $x = 0;
  4899. $save = array();
  4900. foreach ($pp as $va) {
  4901. $num = explode('-', $va);
  4902. if ($number) {
  4903. $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 = '')"); //通用
  4904. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4905. } else {
  4906. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4907. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4908. }
  4909. $x++;
  4910. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4911. $save[] = $x - 1;
  4912. continue; //提前先加X不然出错,所以要减1
  4913. }
  4914. }
  4915. if (isset($save[0])) {
  4916. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4917. exit;
  4918. } else {
  4919. echo json_encode(array('success' => true));
  4920. exit;
  4921. }
  4922. }
  4923. }
  4924. public function _db()
  4925. {
  4926. $post = $this->input->post(NULL, TRUE);
  4927. if (isset($post['page'])) {
  4928. $page = $this->input->post('page', true);
  4929. $perpage = $this->input->post('perpage', true);
  4930. $sku = $this->input->post('sku', true);
  4931. $number = $this->input->post('number', true);
  4932. $warehouse = $this->input->post('warehouse', true);
  4933. $purchase = $this->input->post('purchase', true);
  4934. $orderinfo = $this->input->post('orderinfo', true);
  4935. $waybill = $this->input->post('waybill', true);
  4936. $category = $this->input->post('category', true);
  4937. $size = $this->input->post('size', true);
  4938. $grade = $this->input->post('grade', true);
  4939. $color = $this->input->post('color', true);
  4940. $lowe = $this->input->post('lowe', true);
  4941. $state = $this->input->post('state', true);
  4942. $label = $this->input->post('label', true);
  4943. $timetk = $this->input->post('timetkk', true);
  4944. $timetj = $this->input->post('timetjj', true);
  4945. $timetk = strtotime($timetk);
  4946. $timetj = strtotime($timetj);
  4947. $where = "dbtime > 0";
  4948. if ($timetk && $timetj) {
  4949. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4950. }
  4951. if ($sku) {
  4952. $where .= " and sku = '$sku'";
  4953. }
  4954. if ($warehouse) {
  4955. $where .= " and warehouse = '$warehouse'";
  4956. if ($warehouse == 12) {
  4957. $w = 'specialstock';
  4958. } else {
  4959. $w = 'whlabel';
  4960. }
  4961. }
  4962. if ($purchase) {
  4963. $where .= " and purchase = '$purchase'";
  4964. }
  4965. if ($category) {
  4966. $where .= " and features like '%-$category-%'";
  4967. }
  4968. if ($size) {
  4969. $where .= " and features like '%-$size-%'";
  4970. }
  4971. if ($grade) {
  4972. $where .= " and features like '%-$grade-%'";
  4973. }
  4974. if ($color) {
  4975. $where .= " and features like '%-$color-%'";
  4976. }
  4977. if ($lowe) {
  4978. $where .= " and features like '%-$lowe-%'";
  4979. }
  4980. if ($state != '') {
  4981. $where .= " and state = '$state'";
  4982. }
  4983. //数据排序
  4984. $order_str = "dbtime desc";
  4985. if (empty($page)) {
  4986. $start = 0;
  4987. $perpage = 1;
  4988. } else {
  4989. $start = ($page - 1) * $perpage;
  4990. }
  4991. //取得信息列表
  4992. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  4993. foreach ($info_list as $key => $value) {
  4994. $warehouse = $this->$w->read($value['warehouse']);
  4995. $info_list[$key]['warehouse'] = $warehouse['title'];
  4996. $purchase = $this->purchase->read($value['purchase']);
  4997. $info_list[$key]['purchase'] = $purchase['title'];
  4998. if ($value['enter'] != 0) {
  4999. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5000. } else {
  5001. $info_list[$key]['enter'] = "";
  5002. }
  5003. if ($value['dbtime'] != 0) {
  5004. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5005. } else {
  5006. $info_list[$key]['dbtime'] = "";
  5007. }
  5008. if ($value['state'] == 0) {
  5009. $info_list[$key]['state'] = "在库";
  5010. } else if ($value['state'] == 1) {
  5011. $info_list[$key]['state'] = "出库";
  5012. } else if ($value['state'] == 2) {
  5013. $info_list[$key]['state'] = "退库";
  5014. } else if ($value['state'] == 3) {
  5015. $info_list[$key]['state'] = "调拨中";
  5016. } else if ($value['state'] == 4) {
  5017. $info_list[$key]['state'] = "再加工";
  5018. } else if ($value['state'] == 5) {
  5019. $info_list[$key]['state'] = "维修中";
  5020. } else if ($value['state'] == 6) {
  5021. $info_list[$key]['state'] = "盘亏";
  5022. } else if ($value['state'] == 7) {
  5023. $info_list[$key]['state'] = "更换标签";
  5024. } else if ($value['state'] == 8) {
  5025. $info_list[$key]['state'] = "其它";
  5026. } else if ($value['state'] == 9) {
  5027. $info_list[$key]['state'] = "预设";
  5028. }
  5029. }
  5030. $total = $this->whlabel->find_count($where);
  5031. $pagenum = ceil($total / $perpage);
  5032. $over = $total - ($start + $perpage);
  5033. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5034. echo json_encode($rows);
  5035. exit;
  5036. }
  5037. if (isset($post['outsku'])) {
  5038. $time = time();
  5039. $cz = $this->input->post('cz', true);
  5040. $label = $this->input->post('outsku', true);
  5041. $sl = $this->input->post('sl', true);
  5042. $num = $this->input->post('num', true);
  5043. //$warehouse = $this->input->post('warehouse',true);
  5044. if (!$sl) {
  5045. $sl = 1;
  5046. }
  5047. if (!$warehouse) {
  5048. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5049. exit;
  5050. }
  5051. $dblabel = $this->whlabellabel->get_label($label);
  5052. if ($dblabel) {
  5053. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5054. if (count($data) < 1) {
  5055. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5056. exit;
  5057. }
  5058. if (count($data) < $num) {
  5059. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5060. exit;
  5061. }
  5062. for ($i = 0; $i < $sl; $i++) {
  5063. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5064. }
  5065. echo json_encode(array('success' => true));
  5066. exit;
  5067. } else {
  5068. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5069. exit;
  5070. }
  5071. }
  5072. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5073. $this->_Template('whlabel_db', $this->data);
  5074. }
  5075. public function _dbrk()
  5076. {
  5077. $post = $this->input->post(NULL, TRUE);
  5078. if (isset($post['page'])) {
  5079. $page = $this->input->post('page', true);
  5080. $perpage = $this->input->post('perpage', true);
  5081. $sku = $this->input->post('sku', true);
  5082. $number = $this->input->post('number', true);
  5083. $warehouse = $this->input->post('warehouse', true);
  5084. $purchase = $this->input->post('purchase', true);
  5085. $orderinfo = $this->input->post('orderinfo', true);
  5086. $waybill = $this->input->post('waybill', true);
  5087. $category = $this->input->post('category', true);
  5088. $size = $this->input->post('size', true);
  5089. $grade = $this->input->post('grade', true);
  5090. $color = $this->input->post('color', true);
  5091. $lowe = $this->input->post('lowe', true);
  5092. $state = $this->input->post('state', true);
  5093. $label = $this->input->post('label', true);
  5094. $ctime = $this->input->post('ctime', true);
  5095. $timetk = $this->input->post('timetkk', true);
  5096. $timetj = $this->input->post('timetjj', true);
  5097. $timetk = strtotime($timetk);
  5098. $timetj = strtotime($timetj);
  5099. $where = "dbtime > 0";
  5100. if ($timetk && $timetj) {
  5101. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5102. }
  5103. if ($sku) {
  5104. $where .= " and sku = '$sku'";
  5105. }
  5106. if ($warehouse) {
  5107. $where .= " and warehouse = '$warehouse'";
  5108. }
  5109. if ($purchase) {
  5110. $where .= " and purchase = '$purchase'";
  5111. }
  5112. if ($category) {
  5113. $where .= " and features like '%-$category-%'";
  5114. }
  5115. if ($size) {
  5116. $where .= " and features like '%-$size-%'";
  5117. }
  5118. if ($grade) {
  5119. $where .= " and features like '%-$grade-%'";
  5120. }
  5121. if ($color) {
  5122. $where .= " and features like '%-$color-%'";
  5123. }
  5124. if ($lowe) {
  5125. $where .= " and features like '%-$lowe-%'";
  5126. }
  5127. if ($state != '') {
  5128. $where .= " and state = '$state'";
  5129. }
  5130. //数据排序
  5131. $order_str = "dbtime desc";
  5132. if (empty($page)) {
  5133. $start = 0;
  5134. $perpage = 1;
  5135. } else {
  5136. $start = ($page - 1) * $perpage;
  5137. }
  5138. //取得信息列表
  5139. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5140. foreach ($info_list as $key => $value) {
  5141. $warehouse = $this->warehouse->read($value['warehouse']);
  5142. $info_list[$key]['warehouse'] = $warehouse['title'];
  5143. $purchase = $this->purchase->read($value['purchase']);
  5144. $info_list[$key]['purchase'] = $purchase['title'];
  5145. if ($value['enter'] != 0) {
  5146. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5147. } else {
  5148. $info_list[$key]['enter'] = "";
  5149. }
  5150. if ($value['dbtime'] != 0) {
  5151. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5152. } else {
  5153. $info_list[$key]['dbtime'] = "";
  5154. }
  5155. if ($value['state'] == 0) {
  5156. $info_list[$key]['state'] = "在库";
  5157. } else if ($value['state'] == 1) {
  5158. $info_list[$key]['state'] = "出库";
  5159. } else if ($value['state'] == 2) {
  5160. $info_list[$key]['state'] = "退库";
  5161. } else if ($value['state'] == 3) {
  5162. $info_list[$key]['state'] = "调拨中";
  5163. } else if ($value['state'] == 4) {
  5164. $info_list[$key]['state'] = "再加工";
  5165. } else if ($value['state'] == 5) {
  5166. $info_list[$key]['state'] = "维修中";
  5167. } else if ($value['state'] == 6) {
  5168. $info_list[$key]['state'] = "盘亏";
  5169. } else if ($value['state'] == 7) {
  5170. $info_list[$key]['state'] = "更换标签";
  5171. } else if ($value['state'] == 8) {
  5172. $info_list[$key]['state'] = "其它";
  5173. } else if ($value['state'] == 9) {
  5174. $info_list[$key]['state'] = "预设";
  5175. }
  5176. }
  5177. $total = $this->whlabel->find_count($where);
  5178. $pagenum = ceil($total / $perpage);
  5179. $over = $total - ($start + $perpage);
  5180. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5181. echo json_encode($rows);
  5182. exit;
  5183. }
  5184. if (isset($post['rsku'])) {
  5185. $cz = $this->input->post('cz', true);
  5186. $label = $this->input->post('rsku', true);
  5187. $sl = $this->input->post('sl', true);
  5188. $warehouse = $this->input->post('warehouse', true);
  5189. if (!$sl) {
  5190. $sl = 1;
  5191. }
  5192. if (!$warehouse) {
  5193. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5194. exit;
  5195. }
  5196. $dblabel = $this->whlabellabel->get_label($label);
  5197. if ($dblabel) {
  5198. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5199. if (count($data) < 1) {
  5200. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5201. exit;
  5202. }
  5203. if ($sl > count($data)) {
  5204. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5205. exit;
  5206. }
  5207. $time = time();
  5208. for ($i = 0; $i < $sl; $i++) {
  5209. $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']);
  5210. }
  5211. echo json_encode(array('success' => true));
  5212. exit;
  5213. } else {
  5214. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5215. exit;
  5216. }
  5217. }
  5218. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5219. $this->_Template('whlabel_dbrk', $this->data);
  5220. }
  5221. public function _whlabelczdc()
  5222. {
  5223. if (isset($_GET['excel'])) {
  5224. //数据排序
  5225. $order_str = "id desc";
  5226. if (empty($page)) {
  5227. $start = 0;
  5228. $perpage = 1;
  5229. } else {
  5230. $start = ($page - 1) * $perpage;
  5231. }
  5232. $state = $this->input->get('state', true);
  5233. $sku = $this->input->get('sku', true);
  5234. $ctime = $this->input->get('ctime', true);
  5235. $category = $this->input->get('category', true);
  5236. $size = $this->input->get('size', true);
  5237. $grade = $this->input->get('grade', true);
  5238. $color = $this->input->get('color', true);
  5239. $lowe = $this->input->get('lowe', true);
  5240. $timetk = $this->input->get('timetkk', true);
  5241. $timetj = $this->input->get('timetjj', true);
  5242. $timetk = strtotime($timetk);
  5243. $timetj = strtotime($timetj);
  5244. $where = "dbtime > 0";
  5245. if ($timetk && $timetj) {
  5246. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5247. }
  5248. if ($category) {
  5249. $where .= " and features like '%-$category-%'";
  5250. }
  5251. if ($size) {
  5252. $where .= " and features like '%-$size-%'";
  5253. }
  5254. if ($grade) {
  5255. $where .= " and features like '%-$grade-%'";
  5256. }
  5257. if ($color) {
  5258. $where .= " and features like '%-$color-%'";
  5259. }
  5260. if ($lowe) {
  5261. $where .= " and features like '%-$lowe-%'";
  5262. }
  5263. //取得信息列表
  5264. $info_list = $this->whlabel->find_all($where, '*');
  5265. $rows = array();
  5266. $list = array();
  5267. foreach ($info_list as $key => $value) {
  5268. $rows[$value['sku']] = $value; //所有数据sku
  5269. }
  5270. foreach ($rows as $value) {
  5271. $warehouse = $this->warehouse->read($value['warehouse']);
  5272. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5273. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5274. if ($value['orderinfo'] == 0) {
  5275. $info_list[$key]['orderinfo'] = "";
  5276. }
  5277. if ($value['waybill'] == 0) {
  5278. $info_list[$key]['waybill'] = "";
  5279. }
  5280. if ($value['state'] == 0) {
  5281. $value['state'] = "在库";
  5282. } else if ($value['state'] == 3) {
  5283. $value['state'] = "调拨中";
  5284. }
  5285. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5286. }
  5287. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5288. $titlename = "<table border=1>
  5289. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5290. <tr align='center'>
  5291. <td>SKU</td>
  5292. <td>产品</td>
  5293. <td>调拨数量</td>
  5294. <td>入库数量</td>
  5295. </tr>
  5296. </table>";
  5297. $filename = $title . ".xls";
  5298. $tail = "";
  5299. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5300. }
  5301. }
  5302. public function _print($arg_array)
  5303. {
  5304. if (isset($_SESSION['api'])) {
  5305. $user = $this->user->get_api($_SESSION['api']);
  5306. $usp = $user;
  5307. $fgshop = "";
  5308. $sid = "";
  5309. $wid = "";
  5310. $wtype = "";
  5311. $usersp = explode('|', trim($user['shop'], '|'));
  5312. $userwh = explode('|', trim($user['warehouse'], '|'));
  5313. foreach ($usersp as $value) {
  5314. $fgshop .= " shop = " . $value . " or";
  5315. $sid .= " id = " . $value . " or";
  5316. }
  5317. foreach ($userwh as $value) {
  5318. $wid .= " id = " . $value . " or";
  5319. $wtype .= " type = " . $value . " or";
  5320. }
  5321. }
  5322. $post = $this->input->post(NULL, TRUE);
  5323. if (isset($post['tmsku'])) {
  5324. $tmsku = $this->input->post('tmsku', true);
  5325. if (is_numeric($tmsku)) {
  5326. $yyh = $this->whlabellabel->get_label($tmsku);
  5327. } else {
  5328. $yyh = $this->whlabellabel->get_sku($tmsku);
  5329. }
  5330. if ($yyh) {
  5331. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5332. exit;
  5333. } else {
  5334. echo json_encode(array('success' => false));
  5335. exit;
  5336. }
  5337. }
  5338. $classid = $this->classid->sku();
  5339. $pm = $classid;
  5340. $scsku = $classid;
  5341. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5342. if (isset($post['warehouse'])) {
  5343. if ($post['warehouse']) {
  5344. $list = array();
  5345. $num = "";
  5346. $title = "";
  5347. $features = "";
  5348. $order = 0;
  5349. $post['shop'] = '';
  5350. $brand = $this->input->post('brand', true);
  5351. if ($brand != '0,') {
  5352. $b = $this->brand->read(rtrim($brand, ','));
  5353. if ($b) {
  5354. $post['shop'] = str_replace('|', ',', $b['shop']);
  5355. }
  5356. }
  5357. $post['details'] = $this->input->post('details', true); //打印数量
  5358. $xbqnum = $this->input->post('xbqnum', true);
  5359. $post['purchase'] = $this->input->post('purchase', true);
  5360. $post['warehouse'] = $this->input->post('warehouse', true);
  5361. $post['purchase'] = $this->input->post('purchase', true);
  5362. $post['retreatwarehouse'] = $post['warehouse'];
  5363. $post['cpbz'] = $this->input->post('cpbz', true);
  5364. $post['state'] = 9;
  5365. $category = $this->input->post('category', true);
  5366. $list['category'] = $category;
  5367. $list['hairtype'] = $this->input->post('hairtype', true);
  5368. $list['grade'] = $this->input->post('grade', true);
  5369. $size = $this->input->post('size', true);
  5370. $list['size'] = rtrim($size, ',');
  5371. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5372. $list['extension'] = $this->input->post('extension', true);
  5373. if ($category == 1297) {
  5374. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5375. }
  5376. if ($category == 1702) {
  5377. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5378. $list['syother'] = $this->input->post('syother', true);
  5379. }
  5380. if ($category == 133) {
  5381. $list['fittype'] = $this->input->post('fittype', true);
  5382. $list['acother'] = $this->input->post('acother', true);
  5383. }
  5384. $list['color'] = $this->input->post('color', true);
  5385. $list['lowe'] = $this->input->post('lowe', true);
  5386. if ($category == 127) {
  5387. $list['type'] = $this->input->post('type', true);
  5388. $list['headroad'] = $this->input->post('headroad', true);
  5389. $list['density'] = $this->input->post('density', true);
  5390. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5391. $list['lacesize'] = $this->input->post('lacesize', true);
  5392. }
  5393. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5394. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5395. }
  5396. if ($category == 128) {
  5397. $list['lacetype'] = $this->input->post('lacetype', true);
  5398. $list['haircap'] = $this->input->post('haircap', true);
  5399. $list['density'] = $this->input->post('density', true);
  5400. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5401. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5402. $list['wigother'] = $this->input->post('wigother', true);
  5403. $list['wigother2'] = $this->input->post('wigother2', true);
  5404. }
  5405. if ($category == 129) {
  5406. $list['wide'] = $this->input->post('wide', true);
  5407. }
  5408. if ($category == 131) {
  5409. $list['gifttype'] = $this->input->post('gifttype', true);
  5410. $list['giftother'] = $this->input->post('giftother', true);
  5411. }
  5412. if ($category == 134) {
  5413. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5414. }
  5415. if ($category == 1297) {
  5416. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5417. $list['sywigother'] = $this->input->post('sywigother', true);
  5418. }
  5419. if ($category == 130 || $category == 133 || $category == 1702) {
  5420. $list['items'] = $this->input->post('items', true);
  5421. $list['weight'] = $this->input->post('weight', true);
  5422. }
  5423. if ($category == 1702) {
  5424. $list['syhairther'] = $this->input->post('syhairther', true);
  5425. }
  5426. foreach ($list as $k => $v) {
  5427. if ($v != 0) {
  5428. $num .= $v;
  5429. $features .= $v . '-';
  5430. $post[$k] = $v;
  5431. $typeclass = $this->typeclass->read($v);
  5432. if (isset($pm[$typeclass['classid']])) {
  5433. if (stripos($typeclass['zh'], '|') !== false) {
  5434. $exzh = explode('|', $typeclass['zh']);
  5435. $pm[$typeclass['classid']] = $exzh[0];
  5436. } else {
  5437. $pm[$typeclass['classid']] = $typeclass['zh'];
  5438. }
  5439. }
  5440. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5441. if ($k != 'size') {
  5442. $title .= $typeclass['title'] . " ";
  5443. }
  5444. }
  5445. }
  5446. $typeclass = $this->typeclass->read($list['size']);
  5447. $title .= $typeclass['title'];
  5448. $time = time();
  5449. $post['title'] = rtrim($title, ' ');
  5450. $post['number'] = $num;
  5451. $post['features'] = '-' . $features;
  5452. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5453. $featurespp = explode('-', trim($featurespp, '-'));
  5454. if (isset($featurespp[5])) {
  5455. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5456. } else {
  5457. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5458. }
  5459. $post['enter'] = $time;
  5460. $post['time'] = $time; //操作时间
  5461. $scsku = implode("-", $scsku);
  5462. $zh = implode(" ", $pm);
  5463. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5464. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5465. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5466. $post['sku'] = $bqsku;
  5467. $label = time() . rand(0, 9);
  5468. $post['label'] = $label;
  5469. $cpid = $this->whlabellabel->find_count();
  5470. $post['cpid'] = $cpid + 1;
  5471. $cpid = $post['cpid'];
  5472. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5473. //if($whlabelbarcode)
  5474. //{
  5475. //$post['label'] = $whlabelbarcode['label'];
  5476. //if(!$this->whlabellabel->insert($post))
  5477. //{
  5478. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5479. //}
  5480. //}
  5481. //else
  5482. //{
  5483. $this->db->trans_begin();
  5484. $this->whlabellabel->insert($post);
  5485. //$this->whlabelbarcode->insert($post);
  5486. if ($this->db->trans_status() === TRUE) {
  5487. $this->db->trans_commit();
  5488. } else {
  5489. $this->db->trans_rollback();
  5490. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5491. exit;
  5492. }
  5493. //}
  5494. $warehouse_name = "";
  5495. $warehouse = $post['warehouse'];
  5496. if($warehouse == 12){
  5497. $warehouse_name = "特殊库存库";
  5498. }
  5499. // if($warehouse == 13){
  5500. // $warehouse_name = "许昌仓";
  5501. // }
  5502. // if($warehouse == 5){
  5503. // $warehouse_name = "美国店";
  5504. // }
  5505. // if($warehouse == 16){
  5506. // $warehouse_name = "定制头套仓";
  5507. // }
  5508. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5509. if(!empty($warehouse_name)){
  5510. $details = "仓库 <b>".$warehouse_name."</b> ".$details;
  5511. }
  5512. $purchase = $this->purchase->read($post['purchase']);
  5513. 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));
  5514. exit; //特殊仓目前不需要仓库选项
  5515. }
  5516. }
  5517. if (isset($_SESSION['api'])) {
  5518. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5519. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5520. $this->data['wlshop'] = $wlshop;
  5521. $this->data['warehouse'] = $warehouse;
  5522. }
  5523. $whlabelwz = $this->whlabelwz->find_all();
  5524. $this->data['whlabelwz'] = $whlabelwz;
  5525. $this->_Template('whlabel_print', $this->data);
  5526. }
  5527. public function _usaprint($arg_array)
  5528. {
  5529. if (isset($_SESSION['api'])) {
  5530. $user = $this->user->get_api($_SESSION['api']);
  5531. $usp = $user;
  5532. $fgshop = "";
  5533. $sid = "";
  5534. $wid = "";
  5535. $wtype = "";
  5536. $usersp = explode('|', trim($user['shop'], '|'));
  5537. $userwh = explode('|', trim($user['warehouse'], '|'));
  5538. foreach ($usersp as $value) {
  5539. $fgshop .= " shop = " . $value . " or";
  5540. $sid .= " id = " . $value . " or";
  5541. }
  5542. foreach ($userwh as $value) {
  5543. $wid .= " id = " . $value . " or";
  5544. $wtype .= " type = " . $value . " or";
  5545. }
  5546. }
  5547. $post = $this->input->post(NULL, TRUE);
  5548. if (isset($post['tmsku'])) {
  5549. $tmsku = $this->input->post('tmsku', true);
  5550. if (is_numeric($tmsku)) {
  5551. $yyh = $this->whlabellabel->get_label($tmsku);
  5552. } else {
  5553. $yyh = $this->whlabellabel->get_sku($tmsku);
  5554. }
  5555. if ($yyh) {
  5556. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5557. exit;
  5558. } else {
  5559. echo json_encode(array('success' => false));
  5560. exit;
  5561. }
  5562. }
  5563. $classid = $this->classid->sku();
  5564. $pm = $classid;
  5565. $scsku = $classid;
  5566. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5567. if (isset($post['warehouse'])) {
  5568. if ($post['warehouse']) {
  5569. $list = array();
  5570. $num = "";
  5571. $title = "";
  5572. $features = "";
  5573. $order = 0;
  5574. $post['shop'] = '';
  5575. $brand = $this->input->post('brand', true);
  5576. if ($brand != '0,') {
  5577. $b = $this->brand->read(rtrim($brand, ','));
  5578. if ($b) {
  5579. $post['shop'] = str_replace('|', ',', $b['shop']);
  5580. }
  5581. }
  5582. $post['details'] = $this->input->post('details', true); //打印数量
  5583. $xbqnum = $this->input->post('xbqnum', true);
  5584. $post['purchase'] = $this->input->post('purchase', true);
  5585. $post['warehouse'] = $this->input->post('warehouse', true);
  5586. $post['purchase'] = $this->input->post('purchase', true);
  5587. $post['retreatwarehouse'] = $post['warehouse'];
  5588. $post['cpbz'] = $this->input->post('cpbz', true);
  5589. $post['state'] = 9;
  5590. $category = $this->input->post('category', true);
  5591. $list['category'] = $category;
  5592. $list['hairtype'] = $this->input->post('hairtype', true);
  5593. $list['grade'] = $this->input->post('grade', true);
  5594. $size = $this->input->post('size', true);
  5595. $list['size'] = rtrim($size, ',');
  5596. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5597. $list['extension'] = $this->input->post('extension', true);
  5598. if ($category == 1297) {
  5599. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5600. }
  5601. if ($category == 1702) {
  5602. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5603. $list['syother'] = $this->input->post('syother', true);
  5604. }
  5605. if ($category == 133) {
  5606. $list['fittype'] = $this->input->post('fittype', true);
  5607. $list['acother'] = $this->input->post('acother', true);
  5608. }
  5609. $list['color'] = $this->input->post('color', true);
  5610. $list['lowe'] = $this->input->post('lowe', true);
  5611. if ($category == 127) {
  5612. $list['type'] = $this->input->post('type', true);
  5613. $list['headroad'] = $this->input->post('headroad', true);
  5614. $list['density'] = $this->input->post('density', true);
  5615. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5616. $list['lacesize'] = $this->input->post('lacesize', true);
  5617. }
  5618. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5619. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5620. }
  5621. if ($category == 128) {
  5622. $list['lacetype'] = $this->input->post('lacetype', true);
  5623. $list['haircap'] = $this->input->post('haircap', true);
  5624. $list['density'] = $this->input->post('density', true);
  5625. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5626. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5627. $list['wigother'] = $this->input->post('wigother', true);
  5628. $list['wigother2'] = $this->input->post('wigother2', true);
  5629. }
  5630. if ($category == 129) {
  5631. $list['wide'] = $this->input->post('wide', true);
  5632. }
  5633. if ($category == 131) {
  5634. $list['gifttype'] = $this->input->post('gifttype', true);
  5635. $list['giftother'] = $this->input->post('giftother', true);
  5636. }
  5637. if ($category == 134) {
  5638. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5639. }
  5640. if ($category == 1297) {
  5641. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5642. $list['sywigother'] = $this->input->post('sywigother', true);
  5643. }
  5644. if ($category == 130 || $category == 133 || $category == 1702) {
  5645. $list['items'] = $this->input->post('items', true);
  5646. $list['weight'] = $this->input->post('weight', true);
  5647. }
  5648. if ($category == 1702) {
  5649. $list['syhairther'] = $this->input->post('syhairther', true);
  5650. }
  5651. foreach ($list as $k => $v) {
  5652. if ($v != 0) {
  5653. $num .= $v;
  5654. $features .= $v . '-';
  5655. $post[$k] = $v;
  5656. $typeclass = $this->typeclass->read($v);
  5657. if (isset($pm[$typeclass['classid']])) {
  5658. if (stripos($typeclass['zh'], '|') !== false) {
  5659. $exzh = explode('|', $typeclass['zh']);
  5660. $pm[$typeclass['classid']] = $exzh[0];
  5661. } else {
  5662. $pm[$typeclass['classid']] = $typeclass['zh'];
  5663. }
  5664. }
  5665. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5666. if ($k != 'size') {
  5667. $title .= $typeclass['title'] . " ";
  5668. }
  5669. }
  5670. }
  5671. $typeclass = $this->typeclass->read($list['size']);
  5672. $title .= $typeclass['title'];
  5673. $time = time();
  5674. $post['title'] = rtrim($title, ' ');
  5675. $post['number'] = $num;
  5676. $post['features'] = '-' . $features;
  5677. $fp = $this->whlabel->get_features($post['features']);
  5678. if (!$fp) {
  5679. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5680. exit;
  5681. }
  5682. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5683. $featurespp = explode('-', trim($featurespp, '-'));
  5684. if (isset($featurespp[5])) {
  5685. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5686. } else {
  5687. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5688. }
  5689. $post['enter'] = $time;
  5690. $post['time'] = $time; //操作时间
  5691. $scsku = implode("-", $scsku);
  5692. $zh = implode(" ", $pm);
  5693. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5694. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5695. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5696. $post['sku'] = $fp['sku'];
  5697. $post['label'] = $fp['sku'];
  5698. $cpid = $this->whlabellabel->find_count();
  5699. $post['cpid'] = $cpid + 1;
  5700. $cpid = $post['cpid'];
  5701. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5702. //if($whlabelbarcode)
  5703. //{
  5704. //$post['label'] = $whlabelbarcode['label'];
  5705. //if(!$this->whlabellabel->insert($post))
  5706. //{
  5707. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5708. //}
  5709. //}
  5710. //else
  5711. //{
  5712. $this->db->trans_begin();
  5713. $this->whlabellabel->insert($post);
  5714. //$this->whlabelbarcode->insert($post);
  5715. if ($this->db->trans_status() === TRUE) {
  5716. $this->db->trans_commit();
  5717. } else {
  5718. $this->db->trans_rollback();
  5719. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5720. exit;
  5721. }
  5722. //}
  5723. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5724. $purchase = $this->purchase->read($post['purchase']);
  5725. 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));
  5726. exit; //特殊仓目前不需要仓库选项
  5727. }
  5728. }
  5729. if (isset($_SESSION['api'])) {
  5730. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5731. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5732. $this->data['wlshop'] = $wlshop;
  5733. $this->data['warehouse'] = $warehouse;
  5734. }
  5735. $whlabelwz = $this->whlabelwz->find_all();
  5736. $this->data['whlabelwz'] = $whlabelwz;
  5737. $this->_Template('whlabel_usaprint', $this->data);
  5738. }
  5739. public function _printrk($arg_array)
  5740. {
  5741. $prc = array();
  5742. $purchase = $this->purchase->find_all();
  5743. foreach ($purchase as $k => $v) {
  5744. $prc[$v['id']] = $v['title'];
  5745. }
  5746. $post = $this->input->post(NULL, TRUE);
  5747. if (isset($post['page'])) {
  5748. $page = $this->input->post('page', true);
  5749. $perpage = $this->input->post('perpage', true);
  5750. $sku = $this->input->post('sku', true);
  5751. $bs = $this->input->post('bs', true);
  5752. $number = $this->input->post('number', true);
  5753. $warehouse = $this->input->post('warehouse', true);
  5754. $purchase = $this->input->post('purchase', true);
  5755. $orderinfo = $this->input->post('orderinfo', true);
  5756. $waybill = $this->input->post('waybill', true);
  5757. $category = $this->input->post('category', true);
  5758. $size = $this->input->post('size', true);
  5759. $grade = $this->input->post('grade', true);
  5760. $color = $this->input->post('color', true);
  5761. $lowe = $this->input->post('lowe', true);
  5762. $state = $this->input->post('state', true);
  5763. $label = $this->input->post('label', true);
  5764. $timetk = $this->input->post('ktime', true);
  5765. $timetj = $this->input->post('jtime', true);
  5766. $timetk = strtotime($timetk);
  5767. $timetj = strtotime($timetj);
  5768. $where = "1=1 ";
  5769. if ($timetk && $timetj) {
  5770. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5771. }
  5772. if ($sku) {
  5773. $where .= " and sku = '$sku'";
  5774. }
  5775. if ($bs != '') {
  5776. $where .= " and bs = '$bs'";
  5777. }
  5778. if ($number) {
  5779. $where .= " and number = '$number'";
  5780. }
  5781. if ($warehouse) {
  5782. $where .= " and warehouse = '$warehouse'";
  5783. }
  5784. if ($purchase) {
  5785. $where .= " and purchase = '$purchase'";
  5786. }
  5787. if ($orderinfo) {
  5788. $where .= " and orderinfo = '$orderinfo'";
  5789. }
  5790. if ($waybill) {
  5791. $where .= " and waybill = '$waybill'";
  5792. }
  5793. if ($category) {
  5794. $where .= " and features like '%-$category-%'";
  5795. }
  5796. if ($size) {
  5797. $where .= " and features like '%-$size-%'";
  5798. }
  5799. if ($grade) {
  5800. $where .= " and features like '%-$grade-%'";
  5801. }
  5802. if ($color) {
  5803. $where .= " and features like '%-$color-%'";
  5804. }
  5805. if ($lowe) {
  5806. $where .= " and features like '%-$lowe-%'";
  5807. }
  5808. if ($label) {
  5809. $where .= " and label = '$label'";
  5810. }
  5811. if ($state || $state == 0) {
  5812. $where .= " and state = '$state'";
  5813. }
  5814. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5815. //数据排序
  5816. $order_str = "enter desc";
  5817. if (empty($page)) {
  5818. $start = 0;
  5819. $perpage = 1;
  5820. } else {
  5821. $start = ($page - 1) * $perpage;
  5822. }
  5823. //取得信息列表
  5824. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5825. foreach ($info_list as $key => $value) {
  5826. $warehouse = $this->warehouse->read($value['warehouse']);
  5827. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5828. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5829. if ($value['state'] == 0) {
  5830. $info_list[$key]['state'] = "在库";
  5831. } else if ($value['state'] == 1) {
  5832. $info_list[$key]['state'] = "出库";
  5833. } else if ($value['state'] == 2) {
  5834. $info_list[$key]['state'] = "退库";
  5835. } else if ($value['state'] == 3) {
  5836. $info_list[$key]['state'] = "调拨中";
  5837. } else if ($value['state'] == 4) {
  5838. $info_list[$key]['state'] = "再加工";
  5839. } else if ($value['state'] == 5) {
  5840. $info_list[$key]['state'] = "维修中";
  5841. } else if ($value['state'] == 6) {
  5842. $info_list[$key]['state'] = "盘亏";
  5843. } else if ($value['state'] == 7) {
  5844. $info_list[$key]['state'] = "更换标签";
  5845. } else if ($value['state'] == 8) {
  5846. $info_list[$key]['state'] = "其它";
  5847. } else if ($value['state'] == 9) {
  5848. $info_list[$key]['state'] = "预设";
  5849. } else if ($value['state'] == 10) {
  5850. $info_list[$key]['state'] = "美店零售";
  5851. }
  5852. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5853. }
  5854. $total = $this->$ck->find_count($where);
  5855. $pagenum = ceil($total / $perpage);
  5856. $over = $total - ($start + $perpage);
  5857. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5858. echo json_encode($rows);
  5859. exit;
  5860. }
  5861. if (isset($post['tmsku'])) {
  5862. $time = time();
  5863. $tmsku = $this->input->post('tmsku', true);
  5864. //$post['shop'] = $this->input->post('shop',true);
  5865. $num = $this->input->post('num', true);
  5866. $rktype = $this->input->post('rktype', true);
  5867. if ($num > 200) {
  5868. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5869. exit;
  5870. }
  5871. if (!$rktype) {
  5872. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5873. }
  5874. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5875. /**
  5876. $wz = array();
  5877. foreach ($rk as $key=>$value)
  5878. {
  5879. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5880. }
  5881. if(count($wz) > 1)
  5882. {
  5883. $wz = array_values($wz);
  5884. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5885. }
  5886. **/
  5887. if (isset($rk[0]['purchase'])) {
  5888. $rk = $rk[0];
  5889. $j = 0;
  5890. $post['purchase'] = $rk['purchase'];
  5891. $post['warehouse'] = $rk['warehouse'];
  5892. $post['retreatwarehouse'] = $rk['warehouse'];
  5893. $post['sku'] = $rk['sku'];
  5894. $post['number'] = $rk['number'];
  5895. $post['features'] = $rk['features'];
  5896. $post['title'] = $rk['title'];
  5897. $post['enter'] = $time;
  5898. $post['time'] = $time;
  5899. $post['bs'] = 1;
  5900. $post['shop'] = $rk['shop'];
  5901. $post['details'] = $rk['details'];
  5902. $post['cpid'] = $rk['cpid'];
  5903. $post['cpbz'] = $rk['cpbz'];
  5904. //$post['rktype'] = $rktype;
  5905. $warehouse = $this->warehouse->read($rk['warehouse']);
  5906. if ($warehouse['bdck'] == '') {
  5907. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5908. exit;
  5909. } else {
  5910. $bdck = $warehouse['bdck'];
  5911. }
  5912. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5913. if (isset($pdwz['details'])) {
  5914. if ($pdwz['details'] != $post['details']) {
  5915. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5916. exit;
  5917. }
  5918. }
  5919. $post['featurespp'] = $rk['featurespp'];
  5920. if ($post['warehouse'] == '5') {
  5921. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5922. if ($yza) {
  5923. if ($post['features'] != $yza[0]['features']) {
  5924. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5925. exit;
  5926. }
  5927. }
  5928. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5929. if ($yzb) {
  5930. if ($post['sku'] != $yzb[0]['sku']) {
  5931. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5932. exit;
  5933. }
  5934. }
  5935. }
  5936. for ($i = 0; $i < $num; $i++) {
  5937. $post['label'] = time() . rand(100, 999) . $i;
  5938. if ($this->$bdck->insert($post)) {
  5939. $j++;
  5940. }
  5941. }
  5942. /**
  5943. if($post['warehouse'] != 12)
  5944. {
  5945. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5946. }
  5947. **/
  5948. if ($j == $num) {
  5949. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5950. exit;
  5951. } else {
  5952. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5953. exit;
  5954. }
  5955. } else {
  5956. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5957. exit;
  5958. }
  5959. }
  5960. $this->_Template('whlabel_printrk', $this->data);
  5961. }
  5962. public function _printxzrk($arg_array)
  5963. {
  5964. $post = $this->input->post(NULL, TRUE);
  5965. if (isset($post['wzid'])) {
  5966. $time = time();
  5967. $id = $this->input->post('wzid', true);
  5968. //$post['shop'] = $this->input->post('shop',true);
  5969. $num = 1;
  5970. $rk = $this->whlabellabel->read($id);
  5971. if (isset($rk['purchase'])) {
  5972. $x = 0;
  5973. $post['purchase'] = $rk['purchase'];
  5974. $post['warehouse'] = $rk['warehouse'];
  5975. $post['retreatwarehouse'] = $rk['warehouse'];
  5976. $post['sku'] = $rk['sku'];
  5977. $post['number'] = $rk['number'];
  5978. $post['features'] = $rk['features'];
  5979. $post['title'] = $rk['title'];
  5980. $post['enter'] = $time;
  5981. $post['time'] = $time;
  5982. $post['bs'] = 1;
  5983. $post['shop'] = $rk['shop'];
  5984. $post['details'] = $rk['details'];
  5985. $post['cpid'] = $rk['cpid'];
  5986. $post['cpbz'] = $rk['cpbz'];
  5987. $warehouse = $this->warehouse->read($rk['warehouse']);
  5988. if ($warehouse['bdck'] == '') {
  5989. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  5990. exit;
  5991. } else {
  5992. $bdck = $warehouse['bdck'];
  5993. }
  5994. $post['featurespp'] = $rk['featurespp'];
  5995. $this->db->trans_begin();
  5996. for ($i = 0; $i < $num; $i++) {
  5997. $post['label'] = time() . rand(100, 999) . $i;
  5998. $this->$bdck->insert($post);
  5999. }
  6000. /**
  6001. if($post['warehouse'] != 12)
  6002. {
  6003. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6004. }
  6005. **/
  6006. if ($this->db->trans_status() === TRUE) {
  6007. $this->db->trans_commit();
  6008. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6009. exit;
  6010. } else {
  6011. $this->db->trans_rollback();
  6012. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6013. exit;
  6014. }
  6015. } else {
  6016. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6017. exit;
  6018. }
  6019. }
  6020. }
  6021. public function _printck($arg_array)
  6022. {
  6023. $prc = array();
  6024. $purchase = $this->purchase->find_all();
  6025. foreach ($purchase as $k => $v) {
  6026. $prc[$v['id']] = $v['title'];
  6027. }
  6028. $post = $this->input->post(NULL, TRUE);
  6029. if (isset($post['page'])) {
  6030. $page = $this->input->post('page', true);
  6031. $perpage = $this->input->post('perpage', true);
  6032. $sku = $this->input->post('sku', true);
  6033. $bs = $this->input->post('bs', true);
  6034. $number = $this->input->post('number', true);
  6035. $warehouse = $this->input->post('warehouse', true);
  6036. $purchase = $this->input->post('purchase', true);
  6037. $orderinfo = $this->input->post('orderinfo', true);
  6038. $waybill = $this->input->post('waybill', true);
  6039. $category = $this->input->post('category', true);
  6040. $size = $this->input->post('size', true);
  6041. $grade = $this->input->post('grade', true);
  6042. $color = $this->input->post('color', true);
  6043. $lowe = $this->input->post('lowe', true);
  6044. $state = $this->input->post('state', true);
  6045. $label = $this->input->post('label', true);
  6046. $timetk = $this->input->post('ktime', true);
  6047. $timetj = $this->input->post('jtime', true);
  6048. $timetk = strtotime($timetk);
  6049. $timetj = strtotime($timetj);
  6050. $where = "state=1 ";
  6051. if ($timetk && $timetj) {
  6052. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6053. }
  6054. if ($sku) {
  6055. $where .= " and sku = '$sku'";
  6056. }
  6057. if ($bs != '') {
  6058. $where .= " and bs = '$bs'";
  6059. }
  6060. if ($number) {
  6061. $where .= " and number = '$number'";
  6062. }
  6063. if ($warehouse) {
  6064. $where .= " and warehouse = '$warehouse'";
  6065. }
  6066. if ($purchase) {
  6067. $where .= " and purchase = '$purchase'";
  6068. }
  6069. if ($orderinfo) {
  6070. $where .= " and orderinfo = '$orderinfo'";
  6071. }
  6072. if ($waybill) {
  6073. $where .= " and waybill = '$waybill'";
  6074. }
  6075. if ($category) {
  6076. $where .= " and features like '%-$category-%'";
  6077. }
  6078. if ($size) {
  6079. $where .= " and features like '%-$size-%'";
  6080. }
  6081. if ($grade) {
  6082. $where .= " and features like '%-$grade-%'";
  6083. }
  6084. if ($color) {
  6085. $where .= " and features like '%-$color-%'";
  6086. }
  6087. if ($lowe) {
  6088. $where .= " and features like '%-$lowe-%'";
  6089. }
  6090. if ($label) {
  6091. $where .= " and label = '$label'";
  6092. }
  6093. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6094. //数据排序
  6095. $order_str = "outk desc";
  6096. if (empty($page)) {
  6097. $start = 0;
  6098. $perpage = 1;
  6099. } else {
  6100. $start = ($page - 1) * $perpage;
  6101. }
  6102. //取得信息列表
  6103. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6104. foreach ($info_list as $key => $value) {
  6105. $warehouse = $this->warehouse->read($value['warehouse']);
  6106. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6107. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6108. if ($value['state'] == 0) {
  6109. $info_list[$key]['state'] = "在库";
  6110. } else if ($value['state'] == 1) {
  6111. $info_list[$key]['state'] = "出库";
  6112. } else if ($value['state'] == 2) {
  6113. $info_list[$key]['state'] = "退库";
  6114. } else if ($value['state'] == 3) {
  6115. $info_list[$key]['state'] = "调拨中";
  6116. } else if ($value['state'] == 4) {
  6117. $info_list[$key]['state'] = "再加工";
  6118. } else if ($value['state'] == 5) {
  6119. $info_list[$key]['state'] = "维修中";
  6120. } else if ($value['state'] == 6) {
  6121. $info_list[$key]['state'] = "盘亏";
  6122. } else if ($value['state'] == 7) {
  6123. $info_list[$key]['state'] = "更换标签";
  6124. } else if ($value['state'] == 8) {
  6125. $info_list[$key]['state'] = "其它";
  6126. } else if ($value['state'] == 9) {
  6127. $info_list[$key]['state'] = "预设";
  6128. } else if ($value['state'] == 10) {
  6129. $info_list[$key]['state'] = "美店零售";
  6130. }
  6131. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6132. }
  6133. $total = $this->$ck->find_count($where);
  6134. $pagenum = ceil($total / $perpage);
  6135. $over = $total - ($start + $perpage);
  6136. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6137. echo json_encode($rows);
  6138. exit;
  6139. }
  6140. if (isset($post['tmsku'])) {
  6141. $time = time();
  6142. $tmsku = $this->input->post('tmsku', true);
  6143. //$post['shop'] = $this->input->post('shop',true);
  6144. $num = $this->input->post('num', true);
  6145. $cktype = $this->input->post('cktype', true);
  6146. $label = $this->whlabellabel->get_label($tmsku);
  6147. if (!$cktype) {
  6148. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6149. }
  6150. if (!isset($label['warehouse'])) {
  6151. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6152. exit;
  6153. }
  6154. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6155. if (stripos($label['features'], '-126-') !== false) {
  6156. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6157. } else {
  6158. $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 = ''");
  6159. }
  6160. $j = 0;
  6161. if (count($ck) >= $num) {
  6162. for ($i = 0; $i < $num; $i++) {
  6163. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6164. {
  6165. $j++;
  6166. }
  6167. }
  6168. if ($j == $num) {
  6169. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6170. exit;
  6171. } else {
  6172. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6173. exit;
  6174. }
  6175. } else {
  6176. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6177. exit;
  6178. }
  6179. }
  6180. $this->_Template('whlabel_printck', $this->data);
  6181. }
  6182. public function _printexcel()
  6183. {
  6184. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6185. $config['upload_path'] = '.' . $dir;
  6186. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6187. $config['allowed_types'] = 'xls|xlsx|csv';
  6188. $config['max_size'] = 10240;
  6189. $this->load->library('upload', $config);
  6190. $this->upload->initialize($config);
  6191. if ($this->upload->do_upload('userfile')) {
  6192. $full_path = $dir . $this->upload->data('file_name');
  6193. $fileName = '.' . $full_path;
  6194. if (!file_exists($fileName)) {
  6195. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6196. exit;
  6197. } else {
  6198. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6199. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6200. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6201. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6202. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6203. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6204. ++$column; //如果列数大于26行
  6205. $list = array();
  6206. for ($i = 2; $i <= $row; $i++) // 行数循环
  6207. {
  6208. $data = array();
  6209. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6210. {
  6211. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6212. }
  6213. $list[] = $data;
  6214. }
  6215. }
  6216. $ed = array();
  6217. $i = 0;
  6218. $j = 0;
  6219. $dcdata = array();
  6220. $yc = '';
  6221. $cmf_arr = array_column($list, '1');
  6222. array_multisort($cmf_arr, SORT_ASC, $list);
  6223. foreach ($list as $key => $value) {
  6224. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6225. if ($typeclass) {
  6226. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6227. } else {
  6228. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6229. $i++;
  6230. continue;
  6231. }
  6232. }
  6233. if ($i > 0) {
  6234. $yc = $i . '条异常';
  6235. }
  6236. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6237. exit;
  6238. }
  6239. }
  6240. public function _uck()
  6241. {
  6242. if (isset($_GET['excel'])) {
  6243. $tc = array();
  6244. $typeclass = $this->typeclass->find_all();
  6245. foreach ($typeclass as $v) {
  6246. $tc[$v['id']] = $v['zh'];
  6247. }
  6248. $data = array();
  6249. $t = array();
  6250. $rq = '';
  6251. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6252. $ts = $ts / (24 * 3600);
  6253. for ($i = 0; $i < $ts; $i++) {
  6254. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6255. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6256. }
  6257. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6258. foreach ($info_list as $k => $v) {
  6259. $features = explode('-', trim($v['features'], '-'));
  6260. if (!isset($features[3]) || !isset($features[4])) {
  6261. continue;
  6262. }
  6263. $data[$k][0] = $tc[$features[0]]; //类型
  6264. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6265. $data[$k][2] = $tc[$features[4]]; //曲度
  6266. $data[$k][3] = '';
  6267. if (isset($data[$k][1])) {
  6268. $data[$k][3] .= $data[$k][1];
  6269. }
  6270. if (isset($data[$k][2])) {
  6271. $data[$k][3] .= $data[$k][2];
  6272. }
  6273. if (isset($features[5])) {
  6274. $data[$k][3] .= $tc[$features[5]];
  6275. }
  6276. if (isset($features[2])) {
  6277. $data[$k][3] .= $tc[$features[2]];
  6278. }
  6279. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6280. $data[$k][4] = $v['sku'];
  6281. $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())) . '))'); //月初库存
  6282. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6283. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6284. $ztrq = '';
  6285. $ztsl = '';
  6286. if (count($zt) > 0) {
  6287. foreach ($zt as $vv) {
  6288. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6289. $ztsl .= $vv['num'] . '<br>';
  6290. }
  6291. }
  6292. $data[$k][] = trim($ztsl, '<br>');
  6293. $data[$k][] = trim($ztrq, '<br>');
  6294. $byck = 0;
  6295. foreach ($t as $vv) {
  6296. $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));
  6297. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6298. $byck += $sl;
  6299. }
  6300. $data[$k][] = ($byck > 0) ? $byck : '';
  6301. }
  6302. $title = "详情 " . date("Y-m-d", time());
  6303. $titlename = "<table border=1>
  6304. <tr align='center'>
  6305. <td>类别</td>
  6306. <td>颜色</td>
  6307. <td>曲度</td>
  6308. <td>名称</td>
  6309. <td>SKU</td>
  6310. <td>月初库存</td>
  6311. <td>剩余库存</td>
  6312. <td>在途数量</td>
  6313. <td>预达日期</td>" .
  6314. $rq
  6315. . "<td>本月出库</td></tr>
  6316. </table>";
  6317. $filename = $title . ".xls";
  6318. $tail = "";
  6319. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6320. }
  6321. }
  6322. public function _whlabelexcelzh()
  6323. {
  6324. if (isset($_GET['excel'])) {
  6325. $where = "sku != 'Preset'";
  6326. //数据排序
  6327. $order_str = "id desc";
  6328. if (empty($page)) {
  6329. $start = 0;
  6330. $perpage = 1;
  6331. } else {
  6332. $start = ($page - 1) * $perpage;
  6333. }
  6334. $category = $this->input->get('category', true);
  6335. $warehouse = $this->input->get('warehouse', true);
  6336. $excelid = $this->input->get('sid', true);
  6337. if ($category) {
  6338. $where .= " and features like '%-$category-%'";
  6339. }
  6340. if ($warehouse) {
  6341. $where .= " and warehouse = '$warehouse'";
  6342. }
  6343. $xzid = '';
  6344. if ($excelid) {
  6345. $excelid = explode(',', trim($excelid, ','));
  6346. foreach ($excelid as $key => $value) {
  6347. $xzid .= " id = " . $value . " or";
  6348. }
  6349. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6350. }
  6351. //取得信息列表
  6352. /**
  6353. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6354. $rows = array();$list = array();
  6355. foreach ($info_list as $key=>$value)
  6356. {
  6357. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6358. }
  6359. **/
  6360. $list = array();
  6361. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6362. foreach ($rows as $key => $value) {
  6363. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6364. $zh = '';
  6365. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6366. foreach ($zt as $v) {
  6367. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6368. }
  6369. $zt = array_sum(array_column($zt, 'num'));
  6370. $number = $value['number'];
  6371. $ftime = time() - 15 * 24 * 3600;
  6372. $warehouse = $this->warehouse->read($value['warehouse']);
  6373. $rows[$key]['warehouse'] = $warehouse['title'];
  6374. $rows[$key]['number'] = $c;
  6375. $rows[$key]['features'] = $zh;
  6376. $rows[$key]['hb'] = $c + $zt;
  6377. }
  6378. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6379. $titlename = "<table border=1>
  6380. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6381. <tr align='center'>
  6382. <td>仓库</td>
  6383. <td>SKU</td>
  6384. <td>产品</td>
  6385. <td>库存数量</td>
  6386. <td>在途数量及预达日期</td>
  6387. <td>在途+库存数量</td>
  6388. </tr>
  6389. </table>";
  6390. $filename = $title . ".xls";
  6391. $tail = "";
  6392. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6393. }
  6394. if (isset($_GET['excel'])) {
  6395. $warehouse = $this->input->get('warehouse', true);
  6396. $sku = $this->input->get('sku', true);
  6397. $cz = $this->input->get('cz', true);
  6398. $text = $this->input->post('text', true);
  6399. $xztime = $this->input->get('xztime', true);
  6400. $timetk = $this->input->get('timetk', true);
  6401. $timetj = $this->input->get('timetj', true);
  6402. $timetk = strtotime($timetk);
  6403. $timetj = strtotime($timetj);
  6404. $where = "time = '0' ";
  6405. if ($warehouse) {
  6406. $where .= " and warehouse = '$warehouse'";
  6407. }
  6408. if ($sku) {
  6409. $where .= " and sku = '$sku'";
  6410. }
  6411. if ($text) {
  6412. $where .= " and text like '%$text%'";
  6413. }
  6414. if ($cz != '') {
  6415. $where .= " and cz = '$cz'";
  6416. }
  6417. if ($timetk && $timetj) {
  6418. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6419. }
  6420. //数据排序
  6421. $order_str = $xztime . " desc";
  6422. //取得信息列表
  6423. $zh = array();
  6424. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6425. foreach ($info_list as $v) {
  6426. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6427. $warehouse = $this->warehouse->read($v['warehouse']);
  6428. $v['warehouse'] = $warehouse['title'];
  6429. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6430. $v['stime'] = date('Y-m-d', $v['stime']);
  6431. if (isset($zh[$v['features']])) {
  6432. $zh[$v['features']]['num'] += $v['num'];
  6433. } else {
  6434. $zh[$v['features']] = $v;
  6435. }
  6436. $zh[$v['features']]['features'] = $c;
  6437. }
  6438. $title = "在途数据" . date('Y-m-d', time());
  6439. $titlename = "<table border=1>
  6440. <tr align='center'>
  6441. <td>仓库</td>
  6442. <td>SKU</td>
  6443. <td>名称</td>
  6444. <td>在途数量</td>
  6445. <td>库存数量</td>
  6446. <td>添加在途日期</td>
  6447. <td>预达日期</td>
  6448. <td>备注</td>
  6449. </tr>
  6450. </table>";
  6451. $filename = $title . ".xls";
  6452. $tail = "";
  6453. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6454. }
  6455. }
  6456. public function _fc()
  6457. {
  6458. $vip = 0;
  6459. if (isset($_SESSION['api'])) {
  6460. $user = $this->user->get_api($_SESSION['api']);
  6461. if ($user['vip'] == 1) {
  6462. $vip = 1;
  6463. }
  6464. } else {
  6465. header('Location: /');
  6466. exit;
  6467. }
  6468. $post = $this->input->post(NULL, TRUE);
  6469. if (isset($post['page'])) {
  6470. $page = $this->input->post('page', true);
  6471. $perpage = $this->input->post('perpage', true);
  6472. $category = $this->input->post('category', true);
  6473. $size = $this->input->post('size', true);
  6474. $grade = $this->input->post('grade', true);
  6475. $color = $this->input->post('color', true);
  6476. $lowe = $this->input->post('lowe', true);
  6477. $sku = $this->input->post('sku');
  6478. $title = $this->input->post('title');
  6479. $warehouse = $this->input->post('warehouse', true);
  6480. $usa = $this->input->post('usa', true);
  6481. $purchase = $this->input->post('purchase', true);
  6482. $lacetype = $this->input->post('lacetype', true);
  6483. $haircap = $this->input->post('haircap', true);
  6484. $density = $this->input->post('density', true);
  6485. $details = $this->input->post('details', true);
  6486. $state = $this->input->post('state', true);
  6487. $ktime = $this->input->post('ktime', true);
  6488. $jtime = $this->input->post('jtime', true);
  6489. $ktime = strtotime($ktime);
  6490. $jtime = strtotime($jtime);
  6491. $where = "state = '11'";
  6492. $gj = "";
  6493. $ck = "";
  6494. if ($lacetype) {
  6495. $where .= " and features like '%-$lacetype-%'";
  6496. }
  6497. if ($category) {
  6498. $where .= " and features like '%-$category-%'";
  6499. }
  6500. if ($size) {
  6501. $where .= " and features like '%-$size-%'";
  6502. }
  6503. if ($grade) {
  6504. $where .= " and features like '%-$grade-%'";
  6505. }
  6506. if ($color) {
  6507. $where .= " and features like '%-$color-%'";
  6508. }
  6509. if ($lowe) {
  6510. $where .= " and features like '%-$lowe-%'";
  6511. }
  6512. if ($haircap) {
  6513. $where .= " and features like '%-$haircap-%'";
  6514. }
  6515. if ($density) {
  6516. $where .= " and features like '%-$density-%'";
  6517. }
  6518. if ($usa) {
  6519. if (!$warehouse) {
  6520. $where .= " and (warehouse = '5' or warehouse = '8')";
  6521. }
  6522. }
  6523. if ($warehouse) {
  6524. $where .= " and warehouse = '$warehouse'";
  6525. }
  6526. if ($details) {
  6527. $where .= " and details = '$details'";
  6528. }
  6529. if ($purchase) {
  6530. $where .= " and purchase = '$purchase'";
  6531. }
  6532. if ($state) {
  6533. $where .= " and state = '$state'";
  6534. }
  6535. if ($ktime && $jtime) {
  6536. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6537. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6538. }
  6539. //数据排序
  6540. $order_str = "id desc";
  6541. if (empty($page)) {
  6542. $start = 0;
  6543. $perpage = 1;
  6544. } else {
  6545. $start = ($page - 1) * $perpage;
  6546. }
  6547. if ($sku) {
  6548. $sku = trim($sku, ' ');
  6549. $sku = trim($sku, ' ');
  6550. $where .= " and sku like '%$sku%'";
  6551. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6552. } else if ($title) {
  6553. $title = trim($title, ' ');
  6554. $title = trim($title, ' ');
  6555. $where .= " and title like '%$title%'";
  6556. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6557. } else {
  6558. //$where .= " and time > '$ktime' and time < '$jtime'";
  6559. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6560. }
  6561. //取得信息列表
  6562. $rows = array();
  6563. $list = array();
  6564. foreach ($info_list as $key => $value) {
  6565. $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'] . '"');
  6566. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6567. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6568. $warehouse = $this->warehouse->read($value['warehouse']);
  6569. $info_list[$key]['warehouse'] = $warehouse['title'];
  6570. $info_list[$key]['number'] = $g;
  6571. $info_list[$key]['features'] = $x;
  6572. $info_list[$key]['x'] = $s;
  6573. }
  6574. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6575. $pagenum = ceil($total / $perpage);
  6576. $over = $total - ($start + $perpage);
  6577. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6578. echo json_encode($rows);
  6579. exit;
  6580. }
  6581. $this->data['vip'] = $vip;
  6582. $this->_Template('whlabel_fc', $this->data);
  6583. }
  6584. public function _fcmb()
  6585. {
  6586. $where = "sku != 'Preset'";
  6587. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6588. foreach ($rows as $k => $v) {
  6589. $warehouse = $this->warehouse->read($v['warehouse']);
  6590. $rows[$k]['warehouse'] = $warehouse['title'];
  6591. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6592. $rows[$k]['t'] = '';
  6593. $rows[$k]['n'] = '';
  6594. }
  6595. $title = "封货产品数据导入模板";
  6596. $titlename = "<table border=1>
  6597. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6598. <tr align='center'>
  6599. <td>仓库</td>
  6600. <td>SKU</td>
  6601. <td>产品</td>
  6602. <td>封存产品总数量</td>
  6603. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6604. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6605. </tr>
  6606. </table>";
  6607. $filename = $title . ".xls";
  6608. $tail = "";
  6609. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6610. }
  6611. public function _fcexcel()
  6612. {
  6613. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6614. $config['upload_path'] = '.' . $dir;
  6615. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6616. $config['allowed_types'] = 'xls|xlsx|csv';
  6617. $config['max_size'] = 10240;
  6618. $this->load->library('upload', $config);
  6619. $this->upload->initialize($config);
  6620. if ($this->upload->do_upload('userfile')) {
  6621. $full_path = $dir . $this->upload->data('file_name');
  6622. $fileName = '.' . $full_path;
  6623. if (!file_exists($fileName)) {
  6624. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6625. exit;
  6626. } else {
  6627. libxml_use_internal_errors(true);
  6628. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6629. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6630. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6631. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6632. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6633. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6634. ++$column; //如果列数大于26行
  6635. $list = array();
  6636. for ($i = 2; $i <= $row; $i++) // 行数循环
  6637. {
  6638. $data = array();
  6639. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6640. {
  6641. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6642. }
  6643. $list[] = $data;
  6644. }
  6645. }
  6646. $i = 0;
  6647. $j = 0;
  6648. $ed = array();
  6649. foreach ($list as $key => $value) {
  6650. $time = time();
  6651. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6652. continue;
  6653. }
  6654. $warehouse = $this->warehouse->get_title($value['0']);
  6655. $sku = $value['1'];
  6656. $type = $value['4']; //调整方式0扣减1删除
  6657. $num = $value['5']; //调整数量
  6658. //$text = $value['4'];//扣减说明
  6659. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6660. if (!$d) //如果没有这个SKU
  6661. {
  6662. $ed[] = array($sku . '-库存中不存在此SKU');
  6663. $j++;
  6664. continue;
  6665. }
  6666. if (!isset($warehouse['id'])) {
  6667. $ed[] = array($sku . '-仓库名错误!');
  6668. $j++;
  6669. continue;
  6670. }
  6671. if ($type == 1 || $type == 2) //扣减库存
  6672. {
  6673. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6674. if (count($data) < abs($num)) {
  6675. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6676. $j++;
  6677. continue;
  6678. }
  6679. if ($type == 1) //转入库存
  6680. {
  6681. for ($i = 0; $i < abs($num); $i++) {
  6682. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6683. }
  6684. } else if ($type == 2) //删除
  6685. {
  6686. for ($i = 0; $i < abs($num); $i++) {
  6687. $this->whlabel->remove($data[$i]['id']);
  6688. }
  6689. }
  6690. } else if ($type == 0) //增加库存
  6691. {
  6692. $post['sku'] = $d['sku'];
  6693. $post['shop'] = '';
  6694. $post['warehouse'] = $warehouse['id'];
  6695. $post['purchase'] = $d['purchase'];
  6696. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6697. $post['state'] = 11;
  6698. $post['title'] = $d['title'];
  6699. $post['number'] = $d['number'];
  6700. $post['features'] = $d['features'];
  6701. $post['enter'] = $time;
  6702. $post['time'] = $time; //操作时间
  6703. for ($i = 0; $i < $num; $i++) {
  6704. $post['label'] = time() . rand(100, 999) . $i;
  6705. $this->whlabel->insert($post);
  6706. }
  6707. }
  6708. sleep(1); //防止入库时间一样,需要延迟1秒
  6709. }
  6710. if ($j > 0) {
  6711. $tt = date('Ymd', time());
  6712. $title = '库存导入错误信息-' . $tt;
  6713. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6714. $tail = "\n";
  6715. $filename = $title . ".xls";
  6716. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6717. $dir = '/data/excel/' . $time . '/';
  6718. $file_name = 'error_' . $time . rand(1000, 9999);
  6719. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6720. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6721. fwrite($myfile, $ecl);
  6722. fclose($myfile);
  6723. $error = $dir . $file_name . '.xls';
  6724. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6725. exit;
  6726. } else {
  6727. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6728. exit;
  6729. }
  6730. }
  6731. }
  6732. public function _fcjxc($arg_array)
  6733. {
  6734. if (isset($_GET['excel'])) {
  6735. $category = $this->input->get('category', true);
  6736. $size = $this->input->get('size', true);
  6737. $grade = $this->input->get('grade', true);
  6738. $color = $this->input->get('color', true);
  6739. $lowe = $this->input->get('lowe', true);
  6740. $sku = $this->input->get('sku');
  6741. $title = $this->input->get('title');
  6742. $warehouse = $arg_array[0];
  6743. $usa = $this->input->get('usa', true);
  6744. $purchase = $this->input->get('purchase', true);
  6745. $lacetype = $this->input->get('lacetype', true);
  6746. $haircap = $this->input->get('haircap', true);
  6747. $density = $this->input->get('density', true);
  6748. $title = $this->input->get('title', true);
  6749. $state = $this->input->get('state', true);
  6750. $ktime = $this->input->get('ktime', true);
  6751. $jtime = $this->input->get('jtime', true);
  6752. $where = "state=11";
  6753. $gj = "";
  6754. $ck = "";
  6755. if ($lacetype) {
  6756. $where .= " and features like '%-$lacetype-%'";
  6757. }
  6758. if ($category) {
  6759. $where .= " and features like '%-$category-%'";
  6760. }
  6761. if ($size) {
  6762. $where .= " and features like '%-$size-%'";
  6763. }
  6764. if ($grade) {
  6765. $where .= " and features like '%-$grade-%'";
  6766. }
  6767. if ($color) {
  6768. $where .= " and features like '%-$color-%'";
  6769. }
  6770. if ($lowe) {
  6771. $where .= " and features like '%-$lowe-%'";
  6772. }
  6773. if ($haircap) {
  6774. $where .= " and features like '%-$haircap-%'";
  6775. }
  6776. if ($density) {
  6777. $where .= " and features like '%-$density-%'";
  6778. }
  6779. if ($usa) {
  6780. if (!$warehouse) {
  6781. $where .= " and (warehouse = '5' or warehouse = '8')";
  6782. }
  6783. }
  6784. if ($warehouse) {
  6785. $where .= " and warehouse = '$warehouse'";
  6786. }
  6787. if ($purchase) {
  6788. $where .= " and purchase = '$purchase'";
  6789. }
  6790. if ($state) {
  6791. $where .= " and state = '$state'";
  6792. }
  6793. $order_str = "id desc";
  6794. if ($sku) {
  6795. $sku = trim($sku, ' ');
  6796. $sku = trim($sku, ' ');
  6797. $where .= " and sku like '%$sku%'";
  6798. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6799. } else if ($title) {
  6800. $title = trim($title, ' ');
  6801. $title = trim($title, ' ');
  6802. $where .= " and title like '%$title%'";
  6803. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6804. } else {
  6805. //$where .= " and time > '$ktime' and time < '$jtime'";
  6806. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6807. }
  6808. //取得信息列表
  6809. $rows = array();
  6810. $list = array();
  6811. foreach ($info_list as $key => $value) {
  6812. $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'] . '"');
  6813. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6814. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6815. $rows[$key] = $value;
  6816. $warehouse = $this->warehouse->read($value['warehouse']);
  6817. $rows[$key]['warehouse'] = $warehouse['title'];
  6818. $rows[$key]['features'] = $g;
  6819. $rows[$key]['a'] = $x;
  6820. $rows[$key]['b'] = $s;
  6821. }
  6822. $title = "总统计表";
  6823. $titlename = "<table border=1>
  6824. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6825. <tr align='center'>
  6826. <td>仓库</td>
  6827. <td>SKU</td>
  6828. <td>产品名称</td>
  6829. <td>录入总量</td>
  6830. <td>取出总量</td>
  6831. <td>剩余总量</td>
  6832. </tr>
  6833. </table>";
  6834. $filename = $title . ".xls";
  6835. $tail = "";
  6836. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6837. }
  6838. $vip = 0;
  6839. if (isset($_SESSION['api'])) {
  6840. $user = $this->user->get_api($_SESSION['api']);
  6841. if ($user['vip'] == 1) {
  6842. $vip = 1;
  6843. }
  6844. } else {
  6845. header('Location: /');
  6846. exit;
  6847. }
  6848. $post = $this->input->post(NULL, TRUE);
  6849. if (isset($post['page'])) {
  6850. $page = $this->input->post('page', true);
  6851. $perpage = $this->input->post('perpage', true);
  6852. $category = $this->input->post('category', true);
  6853. $size = $this->input->post('size', true);
  6854. $grade = $this->input->post('grade', true);
  6855. $color = $this->input->post('color', true);
  6856. $lowe = $this->input->post('lowe', true);
  6857. $sku = $this->input->post('sku');
  6858. $title = $this->input->post('title');
  6859. $warehouse = $arg_array[0];
  6860. $usa = $this->input->post('usa', true);
  6861. $purchase = $this->input->post('purchase', true);
  6862. $lacetype = $this->input->post('lacetype', true);
  6863. $haircap = $this->input->post('haircap', true);
  6864. $density = $this->input->post('density', true);
  6865. $title = $this->input->post('title', true);
  6866. $state = $this->input->post('state', true);
  6867. $ktime = $this->input->post('ktime', true);
  6868. $jtime = $this->input->post('jtime', true);
  6869. $ktime = strtotime($ktime);
  6870. $jtime = strtotime($jtime);
  6871. $where = "state=11";
  6872. $gj = "";
  6873. $ck = "";
  6874. if ($lacetype) {
  6875. $where .= " and features like '%-$lacetype-%'";
  6876. }
  6877. if ($category) {
  6878. $where .= " and features like '%-$category-%'";
  6879. }
  6880. if ($size) {
  6881. $where .= " and features like '%-$size-%'";
  6882. }
  6883. if ($grade) {
  6884. $where .= " and features like '%-$grade-%'";
  6885. }
  6886. if ($color) {
  6887. $where .= " and features like '%-$color-%'";
  6888. }
  6889. if ($lowe) {
  6890. $where .= " and features like '%-$lowe-%'";
  6891. }
  6892. if ($haircap) {
  6893. $where .= " and features like '%-$haircap-%'";
  6894. }
  6895. if ($density) {
  6896. $where .= " and features like '%-$density-%'";
  6897. }
  6898. if ($usa) {
  6899. if (!$warehouse) {
  6900. $where .= " and (warehouse = '5' or warehouse = '8')";
  6901. }
  6902. }
  6903. if ($warehouse) {
  6904. $where .= " and warehouse = '$warehouse'";
  6905. }
  6906. if ($purchase) {
  6907. $where .= " and purchase = '$purchase'";
  6908. }
  6909. if ($state) {
  6910. $where .= " and state = '$state'";
  6911. }
  6912. if ($ktime && $jtime) {
  6913. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6914. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6915. }
  6916. //数据排序
  6917. $order_str = "id desc";
  6918. $xs = 0;
  6919. $rows = array();
  6920. $list = array();
  6921. if (empty($page)) {
  6922. $start = 0;
  6923. $perpage = 1;
  6924. } else {
  6925. $start = ($page - 1) * $perpage;
  6926. }
  6927. if ($sku || $title) {
  6928. if ($title) {
  6929. $title = trim($title, ' ');
  6930. $title = trim($title, ' ');
  6931. $where .= " and title like '%$title%'";
  6932. } else {
  6933. $sku = trim($sku, ' ');
  6934. $sku = trim($sku, ' ');
  6935. $where .= " and sku like '%$sku%'";
  6936. }
  6937. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6938. foreach ($info_list as $key => $value) {
  6939. $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'] . '"');
  6940. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6941. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6942. $rows[$key] = $value;
  6943. $warehouse = $this->warehouse->read($value['warehouse']);
  6944. $rows[$key]['warehouse'] = $warehouse['title'];
  6945. $rows[$key]['features'] = $g;
  6946. $rows[$key]['a'] = $x;
  6947. $rows[$key]['b'] = $s;
  6948. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6949. $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天销量
  6950. $yj = $c / ($xl / 30);
  6951. if ($yj < 7) {
  6952. $rows[$key]['y'] = round($yj) . '天销量';
  6953. } else {
  6954. $rows[$key]['y'] = '正常';
  6955. }
  6956. }
  6957. } else {
  6958. //$where .= " and time > '$ktime' and time < '$jtime'";
  6959. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6960. foreach ($info_list as $key => $value) {
  6961. $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'] . '"');
  6962. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6963. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6964. $zs[$key] = $value;
  6965. $warehouse = $this->warehouse->read($value['warehouse']);
  6966. $zs[$key]['warehouse'] = $warehouse['title'];
  6967. $zs[$key]['features'] = $g;
  6968. $zs[$key]['a'] = $x;
  6969. $zs[$key]['b'] = $s;
  6970. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6971. $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天销量
  6972. $yj = $c / ($xl / 30);
  6973. if ($yj < 7) {
  6974. $zs[$key]['y'] = round($yj) . '天销量';
  6975. $rows[$key] = $zs[$key];
  6976. }
  6977. }
  6978. }
  6979. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  6980. $pagenum = ceil($total / $perpage);
  6981. $over = $total - ($start + $perpage);
  6982. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  6983. echo json_encode($rows);
  6984. exit;
  6985. }
  6986. $this->data['arg_array'] = $arg_array[0];
  6987. $this->_Template('whlabel_fcjxc', $this->data);
  6988. }
  6989. public function _0kcdel()
  6990. {
  6991. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6992. $config['upload_path'] = '.' . $dir;
  6993. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6994. $config['allowed_types'] = 'xls|xlsx|csv';
  6995. $config['max_size'] = 10240;
  6996. $this->load->library('upload', $config);
  6997. $this->upload->initialize($config);
  6998. if ($this->upload->do_upload('userfile')) {
  6999. $full_path = $dir . $this->upload->data('file_name');
  7000. $fileName = '.' . $full_path;
  7001. if (!file_exists($fileName)) {
  7002. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7003. exit;
  7004. } else {
  7005. require_once "./data/excel/PHPExcel/IOFactory.php";
  7006. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7007. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7008. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7009. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7010. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7011. ++$column; //如果列数大于26行
  7012. $list = array();
  7013. for ($i = 2; $i <= $row; $i++) // 行数循环
  7014. {
  7015. $data = array();
  7016. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7017. {
  7018. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7019. }
  7020. $list[] = $data;
  7021. }
  7022. }
  7023. $i = 0;
  7024. $j = 0;
  7025. $ed = array();
  7026. foreach ($list as $key => $value) {
  7027. $time = time();
  7028. if ($value['0'] == "" || $value['1'] == "") {
  7029. continue;
  7030. }
  7031. $warehouse = $this->warehouse->get_title($value['0']);
  7032. $sku = $value['1'];
  7033. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7034. if (!$d) //如果没有这个SKU
  7035. {
  7036. $ed[] = array($sku . '-库存中不存在此SKU');
  7037. $j++;
  7038. continue;
  7039. }
  7040. if (!isset($warehouse['id'])) {
  7041. $ed[] = array($sku . '-仓库名错误!');
  7042. $j++;
  7043. continue;
  7044. }
  7045. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7046. if ($z < 1) {
  7047. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7048. foreach ($z as $v) {
  7049. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7050. if (count($zt) > 0) {
  7051. $ed[] = array($sku . '-有在途库存无法删除!');
  7052. $j++;
  7053. continue;
  7054. }
  7055. $this->whlabel->remove($v['id']);
  7056. }
  7057. } else {
  7058. $ed[] = array($sku . '-非0库存!');
  7059. $j++;
  7060. continue;
  7061. }
  7062. }
  7063. if ($j > 0) {
  7064. $tt = date('Ymd', time());
  7065. $title = '删除0库存错误信息-' . $tt;
  7066. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7067. $tail = "\n";
  7068. $filename = $title . ".xls";
  7069. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7070. $dir = '/data/excel/' . $time . '/';
  7071. $file_name = 'error_' . $time . rand(1000, 9999);
  7072. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7073. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7074. fwrite($myfile, $ecl);
  7075. fclose($myfile);
  7076. $error = $dir . $file_name . '.xls';
  7077. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7078. exit;
  7079. } else {
  7080. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7081. exit;
  7082. }
  7083. }
  7084. }
  7085. public function _gbhtype()
  7086. {
  7087. $post = $this->input->post(NULL, TRUE);
  7088. if (isset($post['s'])) {
  7089. $n = $this->input->post('n');
  7090. $d = $this->input->post('s');
  7091. if (!$d) {
  7092. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7093. exit;
  7094. }
  7095. $d = explode(',', trim($d, ','));
  7096. $t = $this->whlabel_type->read($n);
  7097. //循环删除记录
  7098. foreach ($d as $v) {
  7099. $u = $this->whlabel->read($v);
  7100. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7101. foreach ($data as $val) {
  7102. $this->whlabel->save(array('type' => $n), $val['id']);
  7103. }
  7104. }
  7105. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7106. }
  7107. }
  7108. //出库、退库导出
  7109. public function _dccrtype()
  7110. {
  7111. $classid = $this->classid->sku();
  7112. $pm = $classid;
  7113. $typeclass = array();
  7114. $tc = $this->typeclass->find_all();
  7115. foreach ($tc as $v) {
  7116. $typeclass[$v['id']] = $v;
  7117. }
  7118. $prc = array();
  7119. $purchase = $this->purchase->find_all();
  7120. foreach ($purchase as $k => $v) {
  7121. $prc[$v['id']] = $v['title'];
  7122. }
  7123. if (isset($_GET['sid'])) {
  7124. $wh = array();
  7125. $w = $this->warehouse->find_all('1=1', 'id,title');
  7126. foreach ($w as $v) {
  7127. $wh[$v['id']] = $v['title'];
  7128. }
  7129. $type = $this->input->get('excel', true);
  7130. $category = $this->input->get('category', true);
  7131. $size = $this->input->get('size', true);
  7132. $grade = $this->input->get('grade', true);
  7133. $color = $this->input->get('color', true);
  7134. $lowe = $this->input->get('lowe', true);
  7135. $sku = $this->input->get('sku', true);
  7136. $warehouse = $this->input->get('warehouse', true);
  7137. $lacetype = $this->input->get('lacetype', true);
  7138. $lacecolor = $this->input->get('lacecolor', true);
  7139. $density = $this->input->get('density', true);
  7140. $haircap = $this->input->get('haircap', true);
  7141. $purchase = $this->input->get('purchase', true);
  7142. $title = $this->input->get('title', true);
  7143. $state = $this->input->get('state', true);
  7144. $sid = $this->input->get('sid', true);
  7145. $ktime = $this->input->get('ktime', true);
  7146. $jtime = $this->input->get('jtime', true);
  7147. $ktime = strtotime($ktime);
  7148. $jtime = strtotime($jtime);
  7149. $where = "1=1";
  7150. $gj = "";
  7151. $ck = "";
  7152. if ($category) {
  7153. $where .= " and features like '%-$category-%'";
  7154. }
  7155. if ($size) {
  7156. $where .= " and features like '%-$size-%'";
  7157. }
  7158. if ($grade) {
  7159. $where .= " and features like '%-$grade-%'";
  7160. }
  7161. if ($color) {
  7162. $where .= " and features like '%-$color-%'";
  7163. }
  7164. if ($lowe) {
  7165. $where .= " and features like '%-$lowe-%'";
  7166. }
  7167. if ($warehouse) {
  7168. $where .= " and warehouse = '$warehouse'";
  7169. }
  7170. if ($purchase) {
  7171. $where .= " and purchase = '$purchase'";
  7172. }
  7173. if ($state) {
  7174. $where .= " and state = '$state'";
  7175. }
  7176. if ($lacetype) {
  7177. $where .= " and features like '%-$lacetype-%'";
  7178. }
  7179. if ($lacecolor) {
  7180. $where .= " and features like '%-$lacecolor-%'";
  7181. }
  7182. if ($density) {
  7183. $where .= " and features like '%-$density-%'";
  7184. }
  7185. if ($haircap) {
  7186. $where .= " and features like '%-$haircap-%'";
  7187. }
  7188. if ($title) {
  7189. $title = trim($title, ' ');
  7190. $title = trim($title, ' ');
  7191. $where .= " and title like '%$title%'";
  7192. }
  7193. if ($sku) {
  7194. $sku = trim($sku, ' ');
  7195. $sku = trim($sku, ' ');
  7196. $where .= " and sku like '%$sku%'";
  7197. }
  7198. if ($ktime && $jtime) {
  7199. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7200. }
  7201. $sidwhere = '';
  7202. if ($sid) {
  7203. $sd = "";
  7204. $s = explode(',', trim($sid, ','));
  7205. foreach ($s as $value) {
  7206. $sd .= " id = " . $value . " or";
  7207. }
  7208. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7209. }
  7210. //数据排序
  7211. $order_str = "time desc";
  7212. if (empty($page)) {
  7213. $start = 0;
  7214. $perpage = 1;
  7215. } else {
  7216. $start = ($page - 1) * $perpage;
  7217. }
  7218. $wh = array();
  7219. $w = $this->warehouse->find_all('1=1', 'id,title');
  7220. foreach ($w as $v) {
  7221. $wh[$v['id']] = $v['title'];
  7222. }
  7223. $wt = array();
  7224. $whlabel_type = $this->whlabel_type->find_all();
  7225. foreach ($whlabel_type as $v) {
  7226. $wt[$v['id']] = $v['title'];
  7227. }
  7228. $classid = $this->classid->sku();
  7229. $list = array();
  7230. $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');
  7231. foreach ($rows_r as $key => $value) {
  7232. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7233. $pm = $classid;
  7234. $jm = $classid;
  7235. $rows_r[$key]['enter'] = '入库';
  7236. $rows_r[$key]['time'] = $value['enter'];
  7237. if ($value['rktype'] == 1) {
  7238. $rows_r[$key]['rktype'] = '采购入库';
  7239. } else if ($value['rktype'] == 2) {
  7240. $rows_r[$key]['rktype'] = '盘盈调整';
  7241. } else if ($value['rktype'] == 3) {
  7242. $rows_r[$key]['rktype'] = '其他调整入库';
  7243. } else if ($value['rktype'] == 4) {
  7244. $rows_r[$key]['rktype'] = '其他调整入库';
  7245. } else if ($value['rktype'] == 5) {
  7246. $rows_r[$key]['rktype'] = '退库入库';
  7247. } else if ($value['rktype'] == 6) {
  7248. $rows_r[$key]['rktype'] = '退货可用入库';
  7249. } else if ($value['rktype'] == 7) {
  7250. $rows_r[$key]['rktype'] = '形态转换入库';
  7251. } else {
  7252. $rows_r[$key]['rktype'] = '';
  7253. }
  7254. $features = explode('-', trim($value['features'], '-'));
  7255. foreach ($features as $v) {
  7256. if (isset($typeclass[$v])) {
  7257. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7258. $pm[$typeclass[$v]['classid']] = $zh[0];
  7259. }
  7260. if (isset($typeclass[$v])) {
  7261. if (isset($jm[$typeclass[$v]['classid']])) {
  7262. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7263. }
  7264. }
  7265. }
  7266. $zh = implode(" ", $pm);
  7267. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7268. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7269. $rows_r[$key]['zh'] = $zh;
  7270. $jm = array_filter($jm);
  7271. $rows_r[$key]['features'] = implode("-", $jm);
  7272. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7273. }
  7274. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7275. foreach ($rows_c as $key => $value) {
  7276. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7277. $pm = $classid;
  7278. $jm = $classid;
  7279. $rows_c[$key]['time'] = $value['outk'];
  7280. $rows_c[$key]['outk'] = '出库';
  7281. if ($value['cktype'] == 1) {
  7282. $rows_c[$key]['cktype'] = '销售出库';
  7283. } else if ($value['cktype'] == 2) {
  7284. $rows_c[$key]['cktype'] = '销售美国出库';
  7285. } else if ($value['cktype'] == 3) {
  7286. $rows_c[$key]['cktype'] = '盘亏调整';
  7287. } else if ($value['cktype'] == 4) {
  7288. $rows_c[$key]['cktype'] = '其他调整出库';
  7289. } else if ($value['cktype'] == 5) {
  7290. $rows_c[$key]['cktype'] = '形态转换出库';
  7291. } else {
  7292. $rows_c[$key]['cktype'] = '';
  7293. }
  7294. $features = explode('-', trim($value['features'], '-'));
  7295. foreach ($features as $v) {
  7296. if (isset($typeclass[$v])) {
  7297. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7298. $pm[$typeclass[$v]['classid']] = $zh[0];
  7299. }
  7300. if (isset($typeclass[$v])) {
  7301. if (isset($jm[$typeclass[$v]['classid']])) {
  7302. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7303. }
  7304. }
  7305. }
  7306. $zh = implode(" ", $pm);
  7307. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7308. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7309. $rows_c[$key]['zh'] = $zh;
  7310. $jm = array_filter($jm);
  7311. $rows_c[$key]['features'] = implode("-", $jm);
  7312. $rows_c[$key]['number'] = 1;
  7313. }
  7314. $merged = $rows_r;
  7315. foreach ($rows_c as $key => $value) {
  7316. if (isset($merged[$key])) {
  7317. $merged[] = $value;
  7318. } else {
  7319. $merged[$key] = $value;
  7320. }
  7321. }
  7322. usort($merged, function ($a, $b) {
  7323. return $a['time'] - $b['time'];
  7324. });
  7325. foreach ($merged as $key => $value) {
  7326. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7327. }
  7328. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7329. $titlename = "<table border=1>
  7330. <tr align='center'>
  7331. <td>仓库</td>
  7332. <td>SKU</td>
  7333. <td>商品名称</td>
  7334. <td>仓库品名</td>
  7335. <td>料号</td>
  7336. <td>时间</td>
  7337. <td>操作</td>
  7338. <td>类型</td>
  7339. <td>数量</td>
  7340. <td>备注</td>
  7341. </tr>
  7342. </table>";
  7343. $filename = $title . ".xlsx";
  7344. $tail = "";
  7345. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7346. }
  7347. }
  7348. }