Whlabel.php 259 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. } else if ($arg == 'summary') //汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. } else if ($arg == 'manifest') //usps发货清单
  144. {
  145. $this->_manifest();
  146. } else if ($arg == 'abnormal') //占单异常
  147. {
  148. $this->_abnormal();
  149. } else if ($arg == 'error') //0库存SKU
  150. {
  151. $this->_error();
  152. } else if ($arg == 'errorexcel') //0库存SKU导出
  153. {
  154. $this->_errorexcel();
  155. } else if ($arg == 'db') {
  156. $this->_db();
  157. } else if ($arg == 'dbrk') {
  158. $this->_dbrk();
  159. } else if ($arg == 'whlabelczdc') {
  160. $this->_whlabelczdc();
  161. } else if ($arg == 'print') {
  162. $this->_print($arg_array);
  163. } else if ($arg == 'usaprint') {
  164. $this->_usaprint($arg_array);
  165. } else if ($arg == 'printck') {
  166. $this->_printck($arg_array);
  167. } else if ($arg == 'printrk') {
  168. $this->_printrk($arg_array);
  169. } else if ($arg == 'printxzrk') {
  170. $this->_printxzrk($arg_array);
  171. } else if ($arg == 'printexcel') {
  172. $this->_printexcel($arg_array);
  173. } else if ($arg == 'uck') {
  174. $this->_uck();
  175. } else if ($arg == 'whlabelexcelzh') {
  176. $this->_whlabelexcelzh();
  177. } else if ($arg == 'fc') {
  178. $this->_fc();
  179. } else if ($arg == 'fcmb') {
  180. $this->_fcmb();
  181. } else if ($arg == 'fcexcel') {
  182. $this->_fcexcel();
  183. } else if ($arg == 'fcjxc') {
  184. $this->_fcjxc($arg_array);
  185. } else if ($arg == '0kcdel') {
  186. $this->_0kcdel(); //导表删除0库存
  187. } else if ($arg == 'gbhtype') {
  188. $this->_gbhtype(); //更改备货状态
  189. } else {
  190. $this->_index();
  191. }
  192. }
  193. //管理
  194. public function _index()
  195. {
  196. $post = $this->input->post(NULL, TRUE);
  197. if (isset($post['page'])) {
  198. $page = $this->input->post('page', true);
  199. $perpage = $this->input->post('perpage', true);
  200. $sku = $this->input->post('sku', true);
  201. $number = $this->input->post('number', true);
  202. $warehouse = $this->input->post('warehouse', true);
  203. $purchase = $this->input->post('purchase', true);
  204. $orderinfo = $this->input->post('orderinfo', true);
  205. $waybill = $this->input->post('waybill', true);
  206. $category = $this->input->post('category', true);
  207. $size = $this->input->post('size', true);
  208. $grade = $this->input->post('grade', true);
  209. $color = $this->input->post('color', true);
  210. $lowe = $this->input->post('lowe', true);
  211. $state = $this->input->post('state', true);
  212. $label = $this->input->post('label', true);
  213. $timetk = $this->input->post('timetkk', true);
  214. $timetj = $this->input->post('timetjj', true);
  215. $timetk = strtotime($timetk);
  216. $timetj = strtotime($timetj);
  217. $where = "1=1 ";
  218. if ($timetk && $timetj) {
  219. $where .= " and time > '$timetk' and time < '$timetj'";
  220. }
  221. if ($sku) {
  222. $where .= " and sku = '$sku'";
  223. }
  224. if ($number) {
  225. $where .= " and number = '$number'";
  226. }
  227. if ($warehouse) {
  228. $where .= " and warehouse = '$warehouse'";
  229. }
  230. if ($purchase) {
  231. $where .= " and purchase = '$purchase'";
  232. }
  233. if ($orderinfo) {
  234. $where .= " and orderinfo = '$orderinfo'";
  235. }
  236. if ($waybill) {
  237. $where .= " and waybill = '$waybill'";
  238. }
  239. if ($category) {
  240. $where .= " and features like '%-$category-%'";
  241. }
  242. if ($size) {
  243. $where .= " and features like '%-$size-%'";
  244. }
  245. if ($grade) {
  246. $where .= " and features like '%-$grade-%'";
  247. }
  248. if ($color) {
  249. $where .= " and features like '%-$color-%'";
  250. }
  251. if ($lowe) {
  252. $where .= " and features like '%-$lowe-%'";
  253. }
  254. if ($label) {
  255. $where .= " and label = '$label'";
  256. }
  257. if ($state != '') {
  258. $where .= " and state = '$state'";
  259. }
  260. //数据排序
  261. $order_str = "time desc";
  262. if (empty($page)) {
  263. $start = 0;
  264. $perpage = 1;
  265. } else {
  266. $start = ($page - 1) * $perpage;
  267. }
  268. //取得信息列表
  269. $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);
  270. foreach ($info_list as $key => $value) {
  271. $warehouse = $this->warehouse->read($value['warehouse']);
  272. $info_list[$key]['warehouse'] = $warehouse['title'];
  273. $purchase = $this->purchase->read($value['purchase']);
  274. $info_list[$key]['purchase'] = $purchase['title'];
  275. if ($value['enter'] != 0) {
  276. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  277. } else {
  278. $info_list[$key]['enter'] = "";
  279. }
  280. if ($value['outk'] != 0) {
  281. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  282. } else {
  283. $info_list[$key]['outk'] = "";
  284. }
  285. if ($value['printing'] != 0) {
  286. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  287. } else {
  288. $info_list[$key]['printing'] = "";
  289. }
  290. if ($value['orderinfo'] == 0) {
  291. $info_list[$key]['orderinfo'] = "";
  292. }
  293. if ($value['waybill'] == 0) {
  294. $info_list[$key]['waybill'] = "";
  295. }
  296. if ($value['state'] == 0) {
  297. $info_list[$key]['state'] = "在库";
  298. } else if ($value['state'] == 1) {
  299. $info_list[$key]['state'] = "出库";
  300. } else if ($value['state'] == 2) {
  301. $info_list[$key]['state'] = "退库";
  302. } else if ($value['state'] == 3) {
  303. $info_list[$key]['state'] = "调拨中";
  304. } else if ($value['state'] == 4) {
  305. $info_list[$key]['state'] = "再加工";
  306. } else if ($value['state'] == 5) {
  307. $info_list[$key]['state'] = "维修中";
  308. } else if ($value['state'] == 6) {
  309. $info_list[$key]['state'] = "盘亏";
  310. } else if ($value['state'] == 7) {
  311. $info_list[$key]['state'] = "更换标签";
  312. } else if ($value['state'] == 8) {
  313. $info_list[$key]['state'] = "其它";
  314. } else if ($value['state'] == 9) {
  315. $info_list[$key]['state'] = "预设";
  316. } else if ($value['state'] == 10) {
  317. $info_list[$key]['state'] = "美店零售";
  318. }
  319. if ($value['text'] == "") {
  320. $info_list[$key]['text'] = "";
  321. }
  322. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  323. }
  324. $total = $this->whlabel->find_count($where);
  325. $pagenum = ceil($total / $perpage);
  326. $over = $total - ($start + $perpage);
  327. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  328. echo json_encode($rows);
  329. exit;
  330. }
  331. if (isset($post['outsku'])) {
  332. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  333. $cz = $this->input->post('cz', true);
  334. if ($cz == '1') {
  335. $sku = $this->input->post('outsku', true);
  336. if ($sku) {
  337. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  338. if (count($data) < 1) {
  339. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  340. exit;
  341. }
  342. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  343. echo json_encode(array('success' => true));
  344. exit;
  345. }
  346. } else {
  347. echo json_encode(array('msg' => '此方法禁用!', 'success' => false));
  348. exit;
  349. $sku = $this->input->post('outsku', true);
  350. if ($sku) {
  351. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  352. if (count($data) < 1) {
  353. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  354. exit;
  355. }
  356. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  357. echo json_encode(array('success' => true));
  358. exit;
  359. }
  360. }
  361. }
  362. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  363. $this->_Template('whlabel', $this->data);
  364. }
  365. //在库标签
  366. public function _existence()
  367. {
  368. $post = $this->input->post(NULL, TRUE);
  369. if (isset($post['s'])) {
  370. $id_arr = $this->input->post('s');
  371. $id_arr = explode(',', $id_arr);
  372. if (!$id_arr) {
  373. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  374. exit;
  375. }
  376. //循环删除记录
  377. foreach ($id_arr as $v) {
  378. $sid = $this->whlabel->read($v);
  379. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  380. if ($count > 0) {
  381. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  382. exit;
  383. }
  384. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  385. if (count($zt) > 0) {
  386. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  387. exit;
  388. }
  389. $this->whlabel->remove($v);
  390. }
  391. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  392. exit;
  393. }
  394. if (isset($post['page'])) {
  395. $page = $this->input->post('page', true);
  396. $perpage = $this->input->post('perpage', true);
  397. $warehouse = $this->input->post('warehouse', true);
  398. $label = $this->input->post('label', true);
  399. $where = "1=1 and state = 0";
  400. if ($warehouse) {
  401. $where .= " and warehouse = '$warehouse'";
  402. }
  403. if ($label) {
  404. $where .= " and label = '$label'";
  405. }
  406. //数据排序
  407. $order_str = "time asc";
  408. if (empty($page)) {
  409. $start = 0;
  410. $perpage = 1;
  411. } else {
  412. $start = ($page - 1) * $perpage;
  413. }
  414. //取得信息列表
  415. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  416. foreach ($info_list as $key => $value) {
  417. if ($value['enter'] != 0) {
  418. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  419. } else {
  420. $info_list[$key]['enter'] = "";
  421. }
  422. if ($value['printing'] != 0) {
  423. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  424. } else {
  425. $info_list[$key]['printing'] = "";
  426. }
  427. }
  428. $total = $this->whlabel->find_count($where);
  429. $pagenum = ceil($total / $perpage);
  430. $over = $total - ($start + $perpage);
  431. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  432. echo json_encode($rows);
  433. exit;
  434. }
  435. $this->_Template('whlabel_existence', $this->data);
  436. }
  437. //进销存浏览
  438. public function _typedy($arg_array)
  439. {
  440. $prc = array();
  441. $purchase = $this->purchase->find_all();
  442. foreach ($purchase as $k => $v) {
  443. $prc[$v['id']] = $v['title'];
  444. }
  445. $post = $this->input->post(NULL, TRUE);
  446. if (isset($post['page'])) {
  447. $page = $this->input->post('page', true);
  448. $perpage = $this->input->post('perpage', true);
  449. $category = $this->input->post('category', true);
  450. $size = $this->input->post('size', true);
  451. $grade = $this->input->post('grade', true);
  452. $color = $this->input->post('color', true);
  453. $lowe = $this->input->post('lowe', true);
  454. $sku = $this->input->post('sku');
  455. $title = $this->input->post('title');
  456. $warehouse = $this->input->post('warehouse', true);
  457. $usa = $this->input->post('usa', true);
  458. $purchase = $this->input->post('purchase', true);
  459. $lacetype = $this->input->post('lacetype', true);
  460. $haircap = $this->input->post('haircap', true);
  461. $density = $this->input->post('density', true);
  462. $details = $this->input->post('details', true);
  463. $state = $this->input->post('state', true);
  464. $lacecolor = $this->input->post('lacecolor', true);
  465. $hairnumber = $this->input->post('hairnumber', true);
  466. $cklx = $this->input->post('cklx', true);
  467. $ktime = $this->input->post('ktime', true);
  468. $jtime = $this->input->post('jtime', true);
  469. $sm = $this->input->post('sm', true);
  470. $cpbz = $this->input->post('cpbz', true);
  471. $type = $this->input->post('type', true);
  472. $ktime = strtotime($ktime);
  473. $jtime = strtotime($jtime);
  474. $where = "1=1";
  475. $gj = "";
  476. $ck = "";
  477. if ($usa) {
  478. if (!$warehouse) {
  479. $where .= " and (warehouse = '5' or warehouse = '8')";
  480. }
  481. }
  482. if ($warehouse) {
  483. $where .= " and warehouse = '$warehouse'";
  484. }
  485. if ($details) {
  486. $where .= " and details = '$details'";
  487. }
  488. if ($purchase) {
  489. $where .= " and purchase = '$purchase'";
  490. }
  491. if (isset($state)) {
  492. if($state >-1){
  493. $where .= " and state = '$state'";
  494. }
  495. }
  496. if ($lacetype) {
  497. $where .= " and features like '%-$lacetype-%'";
  498. }
  499. if ($category) {
  500. $where .= " and features like '%-$category-%'";
  501. }
  502. if ($size) {
  503. $where .= " and features like '%-$size-%'";
  504. }
  505. if ($grade) {
  506. $where .= " and features like '%-$grade-%'";
  507. }
  508. if ($color) {
  509. $where .= " and features like '%-$color-%'";
  510. }
  511. if ($lowe) {
  512. $where .= " and features like '%-$lowe-%'";
  513. }
  514. if ($haircap) {
  515. $where .= " and features like '%-$haircap-%'";
  516. }
  517. if ($density) {
  518. $where .= " and features like '%-$density-%'";
  519. }
  520. if ($lacecolor) {
  521. $where .= " and features like '%-$lacecolor-%'";
  522. }
  523. if($sm){
  524. $where .= " and sm like '%".$sm."%'";
  525. }
  526. if($cpbz){
  527. $where .= " and cpbz like '%".$cpbz."%'";
  528. }
  529. if($type){
  530. $where .= " and type = ".$type."";
  531. }
  532. if (!empty($hairnumber)) {
  533. $where .= " and features like '%-128-%' ";
  534. if ($hairnumber < 0) {
  535. $class_list = $this->typeclass->find_all('classid = 43');
  536. foreach ($class_list as $v) {
  537. $where .= " and features not like '%-" . $v['id'] . "-%'";
  538. }
  539. } else {
  540. $where .= " and features like '%-$hairnumber-%'";
  541. }
  542. }
  543. $where_add = '';
  544. if ($cklx) {
  545. $shop = $this->shop->read($cklx);
  546. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  547. }
  548. if ($ktime && $jtime) {
  549. $gj = " and enter > '$ktime' and enter < '$jtime'";
  550. $ck = " and outk > '$ktime' and outk < '$jtime'";
  551. }
  552. //数据排序
  553. $order_str = "id desc";
  554. if (empty($page)) {
  555. $start = 0;
  556. $perpage = 1;
  557. } else {
  558. $start = ($page - 1) * $perpage;
  559. }
  560. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  561. if ($sku) {
  562. $sku = trim($sku, ' ');
  563. $sku = trim($sku, ' ');
  564. $where .= " and sku like '%$sku%'";
  565. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  566. } else if ($title) {
  567. $title = trim($title, ' ');
  568. $title = trim($title, ' ');
  569. $where .= " and title like '%$title%'";
  570. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  571. } else {
  572. //$where .= " and time > '$ktime' and time < '$jtime'";
  573. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  574. }
  575. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  576. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  577. foreach ($info_list as $k => $v) {
  578. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  579. unset($info_list[$k]['pm']);
  580. unset($info_list[$k]['jm']);
  581. unset($info_list[$k]['bm']);
  582. }
  583. //取得信息列表
  584. $rows = array();
  585. $list = array();
  586. foreach ($info_list as $key => $value) {
  587. $warehouse = $this->warehouse->read($value['warehouse']);
  588. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  589. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  590. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  591. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  592. $info_list[$key]['label'] = $value['sm'];
  593. $number = $value['number'];
  594. $ftime = time() - 15 * 24 * 3600;
  595. $info_list[$key]['warehouse'] = $warehouse['title'];
  596. $info_list[$key]['features'] = count($c);
  597. $z = count($z); //查看订单号
  598. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  599. $ztdata = '';
  600. if (count($zt) > 0) {
  601. foreach ($zt as $vv) {
  602. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  603. }
  604. }
  605. $info_list[$key]['number'] = $ztdata;
  606. $info_list[$key]['sm'] = $z;
  607. $details = array();
  608. $cpid = array();
  609. foreach ($c as $k => $v) {
  610. $details[$v['details']] = $v['details'];
  611. if ($v['cpid'] != 0) {
  612. $cpid[$v['cpid']] = $v['cpid'];
  613. }
  614. }
  615. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  616. if ($value['shop'] != '') {
  617. $shop = explode(',', trim($value['shop'], ','));
  618. $shop = $this->shop->read($shop[0]);
  619. $info_list[$key]['shop'] = $shop['shopname'];
  620. }
  621. }
  622. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  623. $pagenum = ceil($total / $perpage);
  624. $over = $total - ($start + $perpage);
  625. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  626. echo json_encode($rows);
  627. exit;
  628. }
  629. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  630. $this->_Template('whlabel_typedy', $this->data);
  631. }
  632. //进销存浏览
  633. public function _typedy_ck($arg_array)
  634. {
  635. $prc = array();
  636. $purchase = $this->purchase->find_all();
  637. foreach ($purchase as $k => $v) {
  638. $prc[$v['id']] = $v['title'];
  639. }
  640. $post = $this->input->post(NULL, TRUE);
  641. if (isset($post['page'])) {
  642. $page = $this->input->post('page', true);
  643. $perpage = $this->input->post('perpage', true);
  644. $category = $this->input->post('category', true);
  645. $size = $this->input->post('size', true);
  646. $grade = $this->input->post('grade', true);
  647. $color = $this->input->post('color', true);
  648. $lowe = $this->input->post('lowe', true);
  649. $sku = $this->input->post('sku');
  650. $title = $this->input->post('title');
  651. $warehouse = $this->input->post('warehouse', true);
  652. $usa = $this->input->post('usa', true);
  653. $purchase = $this->input->post('purchase', true);
  654. $lacetype = $this->input->post('lacetype', true);
  655. $haircap = $this->input->post('haircap', true);
  656. $density = $this->input->post('density', true);
  657. $details = $this->input->post('details', true);
  658. $state = $this->input->post('state', true);
  659. $lacecolor = $this->input->post('lacecolor', true);
  660. $cklx = $this->input->post('cklx', true);
  661. $ktime = $this->input->post('ktime', true);
  662. $jtime = $this->input->post('jtime', true);
  663. $ktime = strtotime($ktime);
  664. $jtime = strtotime($jtime);
  665. $where = "1=1";
  666. $gj = "";
  667. $ck = "";
  668. if ($lacetype) {
  669. $where .= " and features like '%-$lacetype-%'";
  670. }
  671. if ($category) {
  672. $where .= " and features like '%-$category-%'";
  673. }
  674. if ($size) {
  675. $where .= " and features like '%-$size-%'";
  676. }
  677. if ($grade) {
  678. $where .= " and features like '%-$grade-%'";
  679. }
  680. if ($color) {
  681. $where .= " and features like '%-$color-%'";
  682. }
  683. if ($lowe) {
  684. $where .= " and features like '%-$lowe-%'";
  685. }
  686. if ($haircap) {
  687. $where .= " and features like '%-$haircap-%'";
  688. }
  689. if ($density) {
  690. $where .= " and features like '%-$density-%'";
  691. }
  692. if ($lacecolor) {
  693. $where .= " and features like '%-$lacecolor-%'";
  694. }
  695. if ($usa) {
  696. if (!$warehouse) {
  697. $where .= " and (warehouse = '5' or warehouse = '8')";
  698. }
  699. }
  700. if ($warehouse) {
  701. $where .= " and warehouse = '$warehouse'";
  702. }
  703. if ($details) {
  704. $where .= " and details = '$details'";
  705. }
  706. if ($purchase) {
  707. $where .= " and purchase = '$purchase'";
  708. }
  709. if ($state) {
  710. $where .= " and state = '$state'";
  711. }
  712. $where_add = '';
  713. if ($cklx) {
  714. $shop = $this->shop->read($cklx);
  715. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  716. }
  717. if ($ktime && $jtime) {
  718. $gj = " and enter > '$ktime' and enter < '$jtime'";
  719. $ck = " and outk > '$ktime' and outk < '$jtime'";
  720. }
  721. //数据排序
  722. $order_str = "id desc";
  723. if (empty($page)) {
  724. $start = 0;
  725. $perpage = 1;
  726. } else {
  727. $start = ($page - 1) * $perpage;
  728. }
  729. if ($sku) {
  730. $sku = trim($sku, ' ');
  731. $sku = trim($sku, ' ');
  732. $where .= " and sku like '%$sku%'";
  733. $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);
  734. } else if ($title) {
  735. $title = trim($title, ' ');
  736. $title = trim($title, ' ');
  737. $where .= " and title like '%$title%'";
  738. $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);
  739. } else {
  740. //$where .= " and time > '$ktime' and time < '$jtime'";
  741. $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);
  742. }
  743. //取得信息列表
  744. $rows = array();
  745. $list = array();
  746. foreach ($info_list as $key => $value) {
  747. $warehouse = $this->warehouse->read($value['warehouse']);
  748. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  749. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  750. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  751. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  752. $ftime = time() - 15 * 24 * 3600;
  753. $info_list[$key]['warehouse'] = $warehouse['title'];
  754. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  755. //$z = count($z);//查看订单号
  756. //$info_list[$key]['zd'] = $z;
  757. $details = array();
  758. $cpid = array();
  759. foreach ($c as $k => $v) {
  760. $details[$v['details']] = $v['details'];
  761. if ($v['cpid'] != 0) {
  762. $cpid[$v['cpid']] = $v['cpid'];
  763. }
  764. }
  765. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  766. if ($value['shop'] != '') {
  767. $shop = explode(',', trim($value['shop'], ','));
  768. $shop = $this->shop->read($shop[0]);
  769. $info_list[$key]['shop'] = $shop['shopname'];
  770. }
  771. }
  772. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  773. $pagenum = ceil($total / $perpage);
  774. $over = $total - ($start + $perpage);
  775. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  776. echo json_encode($rows);
  777. exit;
  778. }
  779. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  780. $this->_Template('whlabel_typedy_ck', $this->data);
  781. }
  782. public function _typeck($arg_array)
  783. {
  784. $prc = array();
  785. $purchase = $this->purchase->find_all();
  786. foreach ($purchase as $k => $v) {
  787. $prc[$v['id']] = $v['title'];
  788. }
  789. $post = $this->input->post(NULL, TRUE);
  790. if (isset($post['page'])) {
  791. $page = $this->input->post('page', true);
  792. $perpage = $this->input->post('perpage', true);
  793. $category = $this->input->post('category', true);
  794. $size = $this->input->post('size', true);
  795. $grade = $this->input->post('grade', true);
  796. $color = $this->input->post('color', true);
  797. $lacecolor = $this->input->post('lacecolor', true);
  798. $lowe = $this->input->post('lowe', true);
  799. $sku = $this->input->post('sku');
  800. $title = $this->input->post('title');
  801. $warehouse = 13;
  802. $usa = $this->input->post('usa', true);
  803. $purchase = $this->input->post('purchase', true);
  804. $lacetype = $this->input->post('lacetype', true);
  805. $haircap = $this->input->post('haircap', true);
  806. $density = $this->input->post('density', true);
  807. $details = $this->input->post('details', true);
  808. $state = $this->input->post('state', true);
  809. $ktime = $this->input->post('ktime', true);
  810. $jtime = $this->input->post('jtime', true);
  811. $ktime = strtotime($ktime);
  812. $jtime = strtotime($jtime);
  813. $where = "1=1";
  814. $gj = "";
  815. $ck = "";
  816. if ($lacetype) {
  817. $where .= " and features like '%-$lacetype-%'";
  818. }
  819. if ($category) {
  820. $where .= " and features like '%-$category-%'";
  821. }
  822. if ($size) {
  823. $where .= " and features like '%-$size-%'";
  824. }
  825. if ($grade) {
  826. $where .= " and features like '%-$grade-%'";
  827. }
  828. if ($color) {
  829. $where .= " and features like '%-$color-%'";
  830. }
  831. if ($lacecolor) {
  832. $where .= " and features like '%-$lacecolor-%'";
  833. }
  834. if ($lowe) {
  835. $where .= " and features like '%-$lowe-%'";
  836. }
  837. if ($haircap) {
  838. $where .= " and features like '%-$haircap-%'";
  839. }
  840. if ($density) {
  841. $where .= " and features like '%-$density-%'";
  842. }
  843. if ($warehouse) {
  844. $where .= " and warehouse = '$warehouse'";
  845. }
  846. if ($details) {
  847. $where .= " and details = '$details'";
  848. }
  849. if ($purchase) {
  850. $where .= " and purchase = '$purchase'";
  851. }
  852. if ($state) {
  853. $where .= " and state = '$state'";
  854. }
  855. if ($ktime && $jtime) {
  856. $gj = " and enter > '$ktime' and enter < '$jtime'";
  857. $ck = " and outk > '$ktime' and outk < '$jtime'";
  858. }
  859. //数据排序
  860. $order_str = "id desc";
  861. if (empty($page)) {
  862. $start = 0;
  863. $perpage = 1;
  864. } else {
  865. $start = ($page - 1) * $perpage;
  866. }
  867. if ($sku) {
  868. $sku = trim($sku, ' ');
  869. $sku = trim($sku, ' ');
  870. $where .= " and sku like '%$sku%'";
  871. } else if ($title) {
  872. $title = trim($title, ' ');
  873. $title = trim($title, ' ');
  874. $where .= " and title like '%$title%'";
  875. }
  876. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  877. //取得信息列表
  878. $t = array();
  879. $typeclass = $this->typeclass->find_all();
  880. foreach ($typeclass as $v) {
  881. $t[$v['id']] = $v;
  882. }
  883. $rows = array();
  884. $list = array();
  885. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  886. foreach ($info_list as $key => $value) {
  887. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  888. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  889. $warehouse = $this->warehouse->read($value['warehouse']);
  890. $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');
  891. $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'] . '"');
  892. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  893. $number = $value['number'];
  894. $ftime = time() - 15 * 24 * 3600;
  895. $z = count($z); //查看订单号
  896. $info_list[$key]['warehouse'] = $warehouse['title'];
  897. $info_list[$key]['features'] = count($c);
  898. $info_list[$key]['number'] = $z;
  899. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  900. $details = array();
  901. $cpid = array();
  902. foreach ($c as $k => $v) {
  903. $details[$v['details']] = $v['details'];
  904. if ($v['cpid'] != 0) {
  905. $cpid[$v['cpid']] = $v['cpid'];
  906. }
  907. }
  908. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  909. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  910. unset($info_list[$key]['pm']);
  911. unset($info_list[$key]['jm']);
  912. unset($info_list[$key]['bm']);
  913. }
  914. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  915. $pagenum = ceil($total / $perpage);
  916. $over = $total - ($start + $perpage);
  917. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  918. echo json_encode($rows);
  919. exit;
  920. }
  921. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  922. $this->_Template('whlabel_typeck', $this->data);
  923. }
  924. //进销存导出
  925. public function _whlabeckdc()
  926. {
  927. $prc = array();
  928. $purchase = $this->purchase->find_all();
  929. foreach ($purchase as $k => $v) {
  930. $prc[$v['id']] = $v['title'];
  931. }
  932. if (isset($_GET['excel'])) {
  933. $where = "sku != 'Preset'";
  934. //数据排序
  935. $order_str = "id desc";
  936. if (empty($page)) {
  937. $start = 0;
  938. $perpage = 1;
  939. } else {
  940. $start = ($page - 1) * $perpage;
  941. }
  942. $category = $this->input->get('category', true);
  943. $color = $this->input->get('color', true);
  944. $lowe = $this->input->get('lowe', true);
  945. $lacetype = $this->input->get('lacetype', true);
  946. $size = $this->input->get('size', true);
  947. $density = $this->input->get('density', true);
  948. $haircap = $this->input->get('haircap', true);
  949. $sku = $this->input->get('sku', true);
  950. $details = $this->input->get('details', true);
  951. $warehouse = 13;
  952. $excelid = $this->input->get('sid', true);
  953. if ($category) {
  954. $where .= " and features like '%-$category-%'";
  955. }
  956. if ($color) {
  957. $where .= " and features like '%-$color-%'";
  958. }
  959. if ($lowe) {
  960. $where .= " and features like '%-$lowe-%'";
  961. }
  962. if ($lacetype) {
  963. $where .= " and features like '%-$lacetype-%'";
  964. }
  965. if ($size) {
  966. $where .= " and features like '%-$size-%'";
  967. }
  968. if ($density) {
  969. $where .= " and features like '%-$density-%'";
  970. }
  971. if ($haircap) {
  972. $where .= " and features like '%-$haircap-%'";
  973. }
  974. if ($warehouse) {
  975. $where .= " and warehouse = '$warehouse'";
  976. }
  977. if ($sku) {
  978. $where .= " and sku like '%$sku%'";
  979. }
  980. if ($details) {
  981. $where .= " and details = '$details'";
  982. }
  983. $xzid = '';
  984. if ($excelid) {
  985. $excelid = explode(',', trim($excelid, ','));
  986. foreach ($excelid as $key => $value) {
  987. $xzid .= " id = " . $value . " or";
  988. }
  989. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  990. }
  991. //取得信息列表
  992. /**
  993. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  994. $rows = array();$list = array();
  995. foreach ($info_list as $key=>$value)
  996. {
  997. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  998. }
  999. **/
  1000. $wh = array();
  1001. $w = $this->warehouse->find_all('1=1', 'id,title');
  1002. foreach ($w as $v) {
  1003. $wh[$v['id']] = $v['title'];
  1004. }
  1005. $tc = array();
  1006. $tcdata = array();
  1007. $list = array();
  1008. $classid = $this->classid->sku();
  1009. $tcall = $this->typeclass->find_all();
  1010. $typeclass = array();
  1011. foreach ($tcall as $v)
  1012. {
  1013. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1014. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1015. }
  1016. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1017. foreach ($rows as $key => $value) {
  1018. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1019. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1020. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1021. $rows[$key]['cpbz'] = $u9_info['bm'];
  1022. $rows[$key]['cs'] = $u9_info['jm'];
  1023. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1024. $details = array();
  1025. $cpid = array();
  1026. $cpbz = array();
  1027. $c = 0;
  1028. $g = 0;
  1029. $x = 0;
  1030. $t = 0;
  1031. $s = 0;
  1032. $q = 0;
  1033. foreach ($sd as $k => $v) {
  1034. if ($v['state'] == 0) {
  1035. $c++;
  1036. }
  1037. if ($v['state'] != 9) {
  1038. $g++;
  1039. }
  1040. if ($v['state'] == 1) {
  1041. $x++;
  1042. }
  1043. if ($v['state'] == 2) {
  1044. $t++;
  1045. }
  1046. if ($v['state'] == 8) {
  1047. $s++;
  1048. }
  1049. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1050. $q++;
  1051. }
  1052. $details[$v['details']] = $v['details'];
  1053. if ($v['cpid'] != 0) {
  1054. $cpid[$v['cpid']] = $v['cpid'];
  1055. }
  1056. if ($v['cpbz'] != '') {
  1057. $cpbz[$v['cpbz']] = $v['cpbz'];
  1058. }
  1059. }
  1060. $rows[$key]['details'] = implode("、", $details);
  1061. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1062. $number = $value['number'];
  1063. $ftime = time() - 15 * 24 * 3600;
  1064. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1065. $rows[$key]['number'] = $g;
  1066. $rows[$key]['features'] = $c;
  1067. $rows[$key]['x'] = $x;
  1068. $rows[$key]['t'] = $t;
  1069. $rows[$key]['s'] = $s;
  1070. $rows[$key]['q'] = $q;
  1071. $rows[$key]['wzsl'] = count($details);
  1072. }
  1073. $title = "进销存统计表" . date('Y-m-d', time());
  1074. $titlename = "<table border=1>
  1075. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1076. <tr align='center'>
  1077. <td>仓库</td>
  1078. <td>供应商</td>
  1079. <td>位置</td>
  1080. <td>库存编码</td>
  1081. <td>SKU</td>
  1082. <td>用友编码</td>
  1083. <td>用友料号</td>
  1084. <td>产品英文名</td>
  1085. <td>产品中文名</td>
  1086. <td>入库总量</td>
  1087. <td>库存数量</td>
  1088. <td>销售数量</td>
  1089. <td>退货数量</td>
  1090. <td>删除数量</td>
  1091. <td>其它操作</td>
  1092. <td>位置数量</td>
  1093. </tr>
  1094. </table>";
  1095. $filename = $title . ".xls";
  1096. $tail = "";
  1097. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1098. }
  1099. }
  1100. public function _type()
  1101. {
  1102. $vip = 0;
  1103. if (isset($_SESSION['api'])) {
  1104. $user = $this->user->get_api($_SESSION['api']);
  1105. $fgshop = "";
  1106. $sid = "";
  1107. $usersp = explode('|', trim($user['shop'], '|'));
  1108. foreach ($usersp as $value) {
  1109. $fgshop .= " shop = " . $value . " or";
  1110. $sid .= " id = " . $value . " or";
  1111. }
  1112. if ($user['vip'] == 1) {
  1113. $vip = 1;
  1114. }
  1115. } else {
  1116. header('Location: /');
  1117. exit;
  1118. }
  1119. $prc = array();
  1120. $purchase = $this->purchase->find_all();
  1121. foreach ($purchase as $k => $v) {
  1122. $prc[$v['id']] = $v['title'];
  1123. }
  1124. $company = array();
  1125. $ct = $this->company->find_all();
  1126. foreach ($ct as $k => $v) {
  1127. $company[$v['id']] = $v['title'];
  1128. }
  1129. $sp = array();
  1130. $s = $this->shop->find_all('1=1', 'id,shopname');
  1131. foreach ($s as $v) {
  1132. $sp[$v['id']] = $v['shopname'];
  1133. }
  1134. $wh = array();
  1135. $w = $this->warehouse->find_all('1=1', 'id,title');
  1136. foreach ($w as $v) {
  1137. $wh[$v['id']] = $v['title'];
  1138. }
  1139. $post = $this->input->post(NULL, TRUE);
  1140. if (isset($post['page'])) {
  1141. $page = $this->input->post('page', true);
  1142. $perpage = $this->input->post('perpage', true);
  1143. $category = $this->input->post('category', true);
  1144. $size = $this->input->post('size', true);
  1145. $grade = $this->input->post('grade', true);
  1146. $color = $this->input->post('color', true);
  1147. $lowe = $this->input->post('lowe', true);
  1148. $sku = $this->input->post('sku');
  1149. $title = $this->input->post('title');
  1150. $warehouse = $this->input->post('warehouse', true);
  1151. $usa = $this->input->post('usa', true);
  1152. $purchase = $this->input->post('purchase', true);
  1153. $lacetype = $this->input->post('lacetype', true);
  1154. $haircap = $this->input->post('haircap', true);
  1155. $density = $this->input->post('density', true);
  1156. $details = $this->input->post('details', true);
  1157. $state = $this->input->post('state', true);
  1158. $shop = $this->input->post('shop', true);
  1159. $lacecolor = $this->input->post('lacecolor', true);
  1160. $hairnumber = $this->input->post('hairnumber', true);
  1161. $type = $this->input->post('type', true);
  1162. $ktime = $this->input->post('ktime', true);
  1163. $jtime = $this->input->post('jtime', true);
  1164. $ktime = strtotime($ktime);
  1165. $jtime = strtotime($jtime);
  1166. $cpbz = $this->input->post('cpbz', true);
  1167. $sm = $this->input->post('sm', true);
  1168. $where = "1=1";
  1169. $gj = "";
  1170. $ck = "";
  1171. if ($usa) {
  1172. if (!$warehouse) {
  1173. $where .= " and (warehouse = '5' or warehouse = '8')";
  1174. }
  1175. }
  1176. if ($warehouse) {
  1177. $where .= " and warehouse = '$warehouse'";
  1178. }
  1179. if ($details) {
  1180. $where .= " and details = '$details'";
  1181. }
  1182. if ($purchase) {
  1183. $where .= " and purchase = '$purchase'";
  1184. }
  1185. if ($state) {
  1186. $where .= " and state = '$state'";
  1187. }
  1188. if ($shop) {
  1189. $where .= " and shop like '%$shop%'";
  1190. }
  1191. if ($type) {
  1192. $where .= " and type = '$type'";
  1193. }
  1194. if ($ktime && $jtime) {
  1195. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1196. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1197. }
  1198. if ($cpbz) {
  1199. $where .= " and cpbz like '%$cpbz%' ";
  1200. }
  1201. if ($sm) {
  1202. $where .= " and sm like '%$sm%' ";
  1203. }
  1204. if ($lacecolor) {
  1205. $where .= " and features like '%-$lacecolor-%'";
  1206. }
  1207. if ($lacetype) {
  1208. $where .= " and features like '%-$lacetype-%'";
  1209. }
  1210. if ($category) {
  1211. $where .= " and features like '%-$category-%'";
  1212. }
  1213. if ($size) {
  1214. $where .= " and features like '%-$size-%'";
  1215. }
  1216. if ($grade) {
  1217. $where .= " and features like '%-$grade-%'";
  1218. }
  1219. if ($color) {
  1220. $where .= " and features like '%-$color-%'";
  1221. }
  1222. if ($lowe) {
  1223. $where .= " and features like '%-$lowe-%'";
  1224. }
  1225. if ($haircap) {
  1226. $where .= " and features like '%-$haircap-%'";
  1227. }
  1228. if ($density) {
  1229. $where .= " and features like '%-$density-%'";
  1230. }
  1231. if (!empty($hairnumber)) {
  1232. $where .= " and features like '%-128-%' ";
  1233. if ($hairnumber < 0) {
  1234. $class_list = $this->typeclass->find_all('classid = 43');
  1235. foreach ($class_list as $v) {
  1236. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1237. }
  1238. } else {
  1239. $where .= " and features like '%-$hairnumber-%'";
  1240. }
  1241. }
  1242. //数据排序
  1243. $order_str = "id desc";
  1244. if (empty($page)) {
  1245. $start = 0;
  1246. $perpage = 1;
  1247. } else {
  1248. $start = ($page - 1) * $perpage;
  1249. }
  1250. $fjnr = '';
  1251. if ($sku) {
  1252. $sku = trim($sku, ' ');
  1253. $sku = trim($sku, ' ');
  1254. $fjnr .= " and sku like '%$sku%'";
  1255. }
  1256. if ($title) {
  1257. $title = trim($title, ' ');
  1258. $title = trim($title, ' ');
  1259. $fjnr .= " and title like '%$title%'";
  1260. }
  1261. $wt = array();
  1262. $whlabel_type = $this->whlabel_type->find_all();
  1263. foreach ($whlabel_type as $v) {
  1264. $wt[$v['id']] = $v['title'];
  1265. }
  1266. //$where .= " and time > '$ktime' and time < '$jtime'";
  1267. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1268. //取得信息列表
  1269. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1270. $rows = array();
  1271. $list = array();
  1272. foreach ($info_list as $key => $value) {
  1273. if (isset($wt[$value['type']])) {
  1274. $info_list[$key]['type'] = $wt[$value['type']];
  1275. } else {
  1276. $info_list[$key]['type'] = '未设置';
  1277. }
  1278. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1279. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1280. $ztdata = '';
  1281. if (count($zt) > 0) {
  1282. foreach ($zt as $vv) {
  1283. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1284. }
  1285. }
  1286. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1287. $cdata = array_filter($qbdata, function ($item) {
  1288. return $item['state'] < 1;
  1289. });
  1290. $c = array_sum(array_column($cdata, 'jnum'));
  1291. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1292. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1293. });
  1294. $g = array_sum(array_column($gdata, 'jnum'));
  1295. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1296. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1297. });
  1298. $x = array_sum(array_column($xdata, 'jnum'));
  1299. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1300. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1301. });
  1302. $t = array_sum(array_column($tdata, 'jnum'));
  1303. $zdata = array_filter($qbdata, function ($item) {
  1304. return $item['zd'] != "" && $item['state'] < 1;
  1305. });
  1306. $z = array_sum(array_column($zdata, 'jnum'));
  1307. $zdata = array_filter($qbdata, function ($item) {
  1308. return $item['zd'] != "" && $item['state'] < 1;
  1309. });
  1310. $z = array_sum(array_column($zdata, 'jnum'));
  1311. //$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');
  1312. //$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'].'"');
  1313. //$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'].'"');
  1314. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1315. //$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'].'"');
  1316. $details = array();
  1317. $cpid = array();
  1318. $od = array();
  1319. $odid = '';
  1320. $companytitle = '';
  1321. $shop_list = [];
  1322. foreach ($qbdata as $v) {
  1323. if ($v['zd'] != "" && $v['state'] < 1) {
  1324. if (!isset($od[$v['zd']])) {
  1325. $od[$v['zd']] = 1; //所有数据sku
  1326. } else {
  1327. $od[$v['zd']] = $od[$v['zd']] + 1;
  1328. }
  1329. }
  1330. if ($v['state'] < 1) {
  1331. $details[$v['details']] = $v['details'];
  1332. if ($v['cpid'] != 0) {
  1333. $cpid[$v['cpid']] = $v['cpid'];
  1334. }
  1335. }
  1336. if($v['state'] == 0){
  1337. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1338. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1339. }
  1340. if ($v['shop'] != '') {
  1341. $shop = explode(',', trim($v['shop'], ','));
  1342. foreach ($shop as $vv) {
  1343. if (!in_array($vv, $shop_list)) {
  1344. $shop_list[] = $vv;
  1345. }
  1346. }
  1347. }
  1348. }
  1349. }
  1350. foreach ($od as $k => $vv) {
  1351. $odid .= $k . '数量' . $vv;
  1352. }
  1353. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1354. $info_list[$key]['label'] = $value['sm'];
  1355. $number = $value['number'];
  1356. $ftime = time() - 15 * 24 * 3600;
  1357. $z = $z . '(' . $odid . ')'; //查看订单号
  1358. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1359. $info_list[$key]['features'] = $c;
  1360. $info_list[$key]['number'] = $ztdata;
  1361. $info_list[$key]['sm'] = $g;
  1362. $info_list[$key]['x'] = $x;
  1363. $info_list[$key]['t'] = $t;
  1364. $info_list[$key]['z'] = $z;
  1365. /**
  1366. foreach ($cdata as $k=>$v)
  1367. {
  1368. $details[$v['details']] = $v['details'];
  1369. if($v['cpid'] != 0)
  1370. {
  1371. $cpid[$v['cpid']] = $v['cpid'];
  1372. }
  1373. }
  1374. **/
  1375. $info_list[$key]['shop'] = '';
  1376. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1377. // if ($value['shop'] != '') {
  1378. // $shop = explode(',', trim($value['shop'], ','));
  1379. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1380. // }
  1381. $shop_list = array_unique($shop_list);
  1382. $shop_str = '';
  1383. foreach ($shop_list as $v) {
  1384. if(isset($sp[$v])){
  1385. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1386. }
  1387. }
  1388. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1389. /**
  1390. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1391. if(isset($companytitle[0]))
  1392. {
  1393. foreach ($companytitle as $k=>$v)
  1394. {
  1395. if($v['companytitle'] != '')
  1396. {
  1397. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1398. }
  1399. }
  1400. }
  1401. **/
  1402. }
  1403. $final_all_list = [];
  1404. foreach ($info_list as $k => $v) {
  1405. $final_all_list[] = [
  1406. 'id' => $v['id'],
  1407. "warehouse" => $v["warehouse"],
  1408. "purchase" => $v["purchase"],
  1409. "sku" => $v["sku"],
  1410. "title" => $v["title"] . "<br/>" . $v["pm"],
  1411. "details" => $v["details"],
  1412. "shop" => $v["shop"],
  1413. "cpbz" => $v["cpbz"],
  1414. 'label' => $v['label'],
  1415. "type" => $v["type"],
  1416. "features" => $v["features"],
  1417. "number" => $v["number"],
  1418. "sm" => $v["sm"],
  1419. "x" => $v["x"],
  1420. "t" => $v["t"],
  1421. "z" => $v["z"]
  1422. ];
  1423. }
  1424. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1425. $pagenum = ceil($total / $perpage);
  1426. $over = $total - ($start + $perpage);
  1427. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1428. echo json_encode($rows);
  1429. exit;
  1430. }
  1431. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1432. $this->data['shop'] = $wlshop;
  1433. $this->data['vip'] = $vip;
  1434. $this->_Template('whlabel_type', $this->data);
  1435. }
  1436. //美仓进销存浏览
  1437. public function _usatype()
  1438. {
  1439. if (isset($_SESSION['api'])) {
  1440. $user = $this->user->get_api($_SESSION['api']);
  1441. $usp = $user;
  1442. $fgshop = "";
  1443. $sid = "";
  1444. $wid = "";
  1445. $wtype = "";
  1446. $userwh = explode('|', trim($user['warehouse'], '|'));
  1447. foreach ($userwh as $value) {
  1448. $wid .= " id = " . $value . " or";
  1449. $wtype .= " type = " . $value . " or";
  1450. }
  1451. }
  1452. $prc = array();
  1453. $purchase = $this->purchase->find_all();
  1454. foreach ($purchase as $k => $v) {
  1455. $prc[$v['id']] = $v['title'];
  1456. }
  1457. $post = $this->input->post(NULL, TRUE);
  1458. if (isset($post['page'])) {
  1459. $page = $this->input->post('page', true);
  1460. $perpage = $this->input->post('perpage', true);
  1461. $category = $this->input->post('category', true);
  1462. $size = $this->input->post('size', true);
  1463. $grade = $this->input->post('grade', true);
  1464. $color = $this->input->post('color', true);
  1465. $lowe = $this->input->post('lowe', true);
  1466. $sku = $this->input->post('sku');
  1467. $title = $this->input->post('title');
  1468. $warehouse = $this->input->post('warehouse', true);
  1469. $usa = $this->input->post('usa', true);
  1470. $purchase = $this->input->post('purchase', true);
  1471. $lacetype = $this->input->post('lacetype', true);
  1472. $haircap = $this->input->post('haircap', true);
  1473. $density = $this->input->post('density', true);
  1474. $details = $this->input->post('details', true);
  1475. $state = $this->input->post('state', true);
  1476. $lacecolor = $this->input->post('lacecolor', true);
  1477. $cklx = $this->input->post('cklx', true);
  1478. $ktime = $this->input->post('ktime', true);
  1479. $jtime = $this->input->post('jtime', true);
  1480. $ktime = strtotime($ktime);
  1481. $jtime = strtotime($jtime);
  1482. $where = "1=1";
  1483. $gj = "";
  1484. $ck = "";
  1485. if ($lacetype) {
  1486. $where .= " and features like '%-$lacetype-%'";
  1487. }
  1488. if ($category) {
  1489. $where .= " and features like '%-$category-%'";
  1490. }
  1491. if ($size) {
  1492. $where .= " and features like '%-$size-%'";
  1493. }
  1494. if ($grade) {
  1495. $where .= " and features like '%-$grade-%'";
  1496. }
  1497. if ($color) {
  1498. $where .= " and features like '%-$color-%'";
  1499. }
  1500. if ($lowe) {
  1501. $where .= " and features like '%-$lowe-%'";
  1502. }
  1503. if ($haircap) {
  1504. $where .= " and features like '%-$haircap-%'";
  1505. }
  1506. if ($density) {
  1507. $where .= " and features like '%-$density-%'";
  1508. }
  1509. if ($lacecolor) {
  1510. $where .= " and features like '%-$lacecolor-%'";
  1511. }
  1512. if ($usa) {
  1513. if (!$warehouse) {
  1514. $where .= " and (warehouse = '5' or warehouse = '8')";
  1515. }
  1516. }
  1517. if ($warehouse) {
  1518. $where .= " and warehouse = '$warehouse'";
  1519. }
  1520. if ($details) {
  1521. $where .= " and details = '$details'";
  1522. }
  1523. if ($purchase) {
  1524. $where .= " and purchase = '$purchase'";
  1525. }
  1526. if ($state) {
  1527. $where .= " and state = '$state'";
  1528. }
  1529. $where_add = '';
  1530. if ($cklx) {
  1531. $shop = $this->shop->read($cklx);
  1532. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1533. }
  1534. if ($ktime && $jtime) {
  1535. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1536. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1537. }
  1538. //数据排序
  1539. $order_str = "id desc";
  1540. if (empty($page)) {
  1541. $start = 0;
  1542. $perpage = 1;
  1543. } else {
  1544. $start = ($page - 1) * $perpage;
  1545. }
  1546. if ($sku) {
  1547. $sku = trim($sku, ' ');
  1548. $sku = trim($sku, ' ');
  1549. $where .= " and sku like '%$sku%'";
  1550. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1551. } else if ($title) {
  1552. $title = trim($title, ' ');
  1553. $title = trim($title, ' ');
  1554. $where .= " and title like '%$title%'";
  1555. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1556. } else {
  1557. //$where .= " and time > '$ktime' and time < '$jtime'";
  1558. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1559. }
  1560. //取得信息列表
  1561. $rows = array();
  1562. $list = array();
  1563. foreach ($info_list as $key => $value) {
  1564. $warehouse = $this->warehouse->read($value['warehouse']);
  1565. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1566. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1567. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1568. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1569. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1570. $od = array();
  1571. $odid = '';
  1572. foreach ($z as $v) {
  1573. if (!isset($od[$v['zd']])) {
  1574. $od[$v['zd']] = 1; //所有数据sku
  1575. } else {
  1576. $od[$v['zd']] = $od[$v['zd']] + 1;
  1577. }
  1578. }
  1579. foreach ($od as $k => $vv) {
  1580. $odid .= $k . '数量' . $vv . ' ';
  1581. }
  1582. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1583. $info_list[$key]['features'] = $c;
  1584. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1585. $ztdata = '';
  1586. if (count($zt) > 0) {
  1587. foreach ($zt as $vv) {
  1588. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1589. }
  1590. }
  1591. $info_list[$key]['warehouse'] = $ztdata;
  1592. $info_list[$key]['g'] = $g;
  1593. $info_list[$key]['x'] = $x;
  1594. $info_list[$key]['t'] = $t;
  1595. $info_list[$key]['z'] = $z;
  1596. }
  1597. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1598. $pagenum = ceil($total / $perpage);
  1599. $over = $total - ($start + $perpage);
  1600. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1601. echo json_encode($rows);
  1602. exit;
  1603. }
  1604. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1605. $this->data['warehouse'] = $warehouse;
  1606. $this->_Template('whlabel_typeusa', $this->data);
  1607. }
  1608. //美仓进销存浏览
  1609. public function _usatypeapp()
  1610. {
  1611. $post = $this->input->post(NULL, TRUE);
  1612. if (isset($post['page'])) {
  1613. $page = $this->input->post('page', true);
  1614. $perpage = $this->input->post('perpage', true);
  1615. $sku = $this->input->post('sku', true);
  1616. $warehouse = 5;
  1617. $title = $this->input->post('title', true);
  1618. $state = $this->input->post('state', true);
  1619. $ktime = $this->input->post('ktime', true);
  1620. $jtime = $this->input->post('jtime', true);
  1621. $ktime = strtotime($ktime);
  1622. $jtime = strtotime($jtime);
  1623. $where = "1=1";
  1624. $gj = "";
  1625. $ck = "";
  1626. if ($title) {
  1627. $st = explode(' ', trim($title, ' '));
  1628. foreach ($st as $v) {
  1629. $where .= " and title like '%$v%'";
  1630. }
  1631. }
  1632. if ($warehouse) {
  1633. $where .= " and warehouse = '$warehouse'";
  1634. }
  1635. if ($state) {
  1636. $where .= " and state = '$state'";
  1637. }
  1638. if ($sku) {
  1639. $where .= " and sku like '%$sku%'";
  1640. }
  1641. if ($ktime && $jtime) {
  1642. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1643. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1644. }
  1645. //数据排序
  1646. $order_str = "id desc";
  1647. if (empty($page)) {
  1648. $start = 0;
  1649. $perpage = 1;
  1650. } else {
  1651. $start = ($page - 1) * $perpage;
  1652. }
  1653. //取得信息列表
  1654. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1655. $rows = array();
  1656. $list = array();
  1657. foreach ($info_list as $key => $value) {
  1658. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1659. }
  1660. $rowsdq = array_slice($rows, $start, $perpage);
  1661. foreach ($rowsdq as $value) {
  1662. $warehouse = $this->warehouse->read($value['warehouse']);
  1663. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1664. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1665. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1666. $od = array();
  1667. $odid = '';
  1668. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1669. }
  1670. $total = count($rows);
  1671. $pagenum = ceil($total / $perpage);
  1672. $over = $total - ($start + $perpage);
  1673. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1674. echo json_encode($rows);
  1675. exit;
  1676. }
  1677. $this->_Template('phone/p_usatypeapp', $this->data);
  1678. }
  1679. //入库操作
  1680. public function _enteradd()
  1681. {
  1682. $dt = 0;
  1683. if (isset($_SESSION['api'])) {
  1684. $user = $this->user->get_api($_SESSION['api']);
  1685. $usp = $user;
  1686. $fgshop = "";
  1687. $sid = "";
  1688. $user = explode('|', trim($user['shop'], '|'));
  1689. foreach ($user as $value) {
  1690. $fgshop .= " shop = " . $value . " or";
  1691. $sid .= " id = " . $value . " or";
  1692. }
  1693. }
  1694. $tc = $this->typeclass->find_all();
  1695. $typeclass = array();
  1696. foreach ($tc as $v) {
  1697. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1698. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1699. }
  1700. $post = $this->input->post(NULL, TRUE);
  1701. if (isset($post['sku'])) {
  1702. $list = array();
  1703. $num = "";
  1704. $title = "";
  1705. $features = "";
  1706. $order = $this->input->post('order', true);
  1707. $shop = $this->input->post('shop', true);
  1708. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1709. $sku = $this->input->post('sku', true);
  1710. $post['sm'] = $this->input->post('sm', true);
  1711. $post['warehouse'] = $this->input->post('warehouse', true);
  1712. $post['purchase'] = $this->input->post('purchase', true);
  1713. $post['retreatwarehouse'] = $post['warehouse'];
  1714. $post['state'] = $this->input->post('state', true);
  1715. $post['rktype'] = $this->input->post('rktype', true);
  1716. $post['text'] = $this->input->post('text', true);
  1717. $category = $this->input->post('category', true);
  1718. $list['category'] = $category;
  1719. $list['hairtype'] = $this->input->post('hairtype', true);
  1720. $list['grade'] = $this->input->post('grade', true);
  1721. $size = $this->input->post('size', true);
  1722. $xzsku = $this->input->post('xzsku', true);
  1723. $list['size'] = rtrim($size, ',');
  1724. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1725. $list['extension'] = $this->input->post('extension', true);
  1726. if ($category == 1297) {
  1727. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1728. }
  1729. if ($category == 1702) {
  1730. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1731. $list['syother'] = $this->input->post('syother', true);
  1732. }
  1733. if ($category == 133) {
  1734. $list['fittype'] = $this->input->post('fittype', true);
  1735. $list['acother'] = $this->input->post('acother', true);
  1736. }
  1737. $list['color'] = $this->input->post('color', true);
  1738. $list['lowe'] = $this->input->post('lowe', true);
  1739. if (!$post['purchase']) {
  1740. $post['purchase'] = 1;
  1741. }
  1742. if ($category == 127) {
  1743. $list['type'] = $this->input->post('type', true);
  1744. $list['headroad'] = $this->input->post('headroad', true);
  1745. $list['density'] = $this->input->post('density', true);
  1746. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1747. $list['lacesize'] = $this->input->post('lacesize', true);
  1748. }
  1749. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1750. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1751. }
  1752. if ($category == 128) {
  1753. $list['lacetype'] = $this->input->post('lacetype', true);
  1754. $list['haircap'] = $this->input->post('haircap', true);
  1755. $list['density'] = $this->input->post('density', true);
  1756. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1757. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1758. $list['wigother'] = $this->input->post('wigother', true);
  1759. $list['wigother1'] = $this->input->post('wigother1', true);
  1760. $list['wigother2'] = $this->input->post('wigother2', true);
  1761. }
  1762. if ($category == 129) {
  1763. $list['wide'] = $this->input->post('wide', true);
  1764. }
  1765. if ($category == 131) {
  1766. $list['gifttype'] = $this->input->post('gifttype', true);
  1767. $list['giftother'] = $this->input->post('giftother', true);
  1768. }
  1769. if ($category == 134) {
  1770. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1771. }
  1772. if ($category == 1297) {
  1773. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1774. $list['sywigother'] = $this->input->post('sywigother', true);
  1775. }
  1776. if ($category == 130 || $category == 133 || $category == 1702) {
  1777. $list['items'] = $this->input->post('items', true);
  1778. $list['weight'] = $this->input->post('weight', true);
  1779. }
  1780. if ($category == 1702) {
  1781. $list['syhairther'] = $this->input->post('syhairther', true);
  1782. }
  1783. $classid = $this->classid->sku();
  1784. $scsku = $classid;
  1785. $pm = $classid;
  1786. foreach ($list as $k => $v) {
  1787. if ($v != 0) {
  1788. $num .= $v;
  1789. $features .= $v . '-';
  1790. $post[$k] = $v;
  1791. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1792. if ($k != 'size') {
  1793. $title .= $typeclass[$v]['title'] . " ";
  1794. }
  1795. if (isset($pm[$typeclass[$v]['classid']])) {
  1796. if ($typeclass[$v]['title'] == '9A') {
  1797. $pm[$typeclass[$v]['classid']] = '9A';
  1798. } else if ($typeclass[$v]['title'] == '10A') {
  1799. $pm[$typeclass[$v]['classid']] = '10A';
  1800. } else {
  1801. $clzh = $typeclass[$v]['zh'];
  1802. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1803. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1804. $clzh = $clzh[0];
  1805. }
  1806. $pm[$typeclass[$v]['classid']] = $clzh;
  1807. }
  1808. }
  1809. }
  1810. }
  1811. $zh = implode(" ", $pm);
  1812. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1813. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1814. if ($list['size']) {
  1815. $typeclass = $this->typeclass->read($list['size']);
  1816. $title .= $typeclass['title'];
  1817. }
  1818. $time = time();
  1819. if ($xzsku) {
  1820. $scsku = implode("-", $scsku);
  1821. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1822. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1823. $post['sku'] = trim($scsku, ' ');
  1824. } else {
  1825. $post['sku'] = $sku;
  1826. }
  1827. //$post['sku'] = trim($sku,' ');
  1828. $post['title'] = rtrim($title, ' ');
  1829. $post['number'] = $num;
  1830. $post['features'] = '-' . $features;
  1831. $post['enter'] = $time;
  1832. $post['time'] = $time; //操作时间
  1833. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1834. if ($yza) {
  1835. if ($post['features'] != $yza[0]['features']) {
  1836. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1837. exit;
  1838. }
  1839. }
  1840. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1841. if ($yzb) {
  1842. if ($post['sku'] != $yzb[0]['sku']) {
  1843. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1844. exit;
  1845. }
  1846. }
  1847. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1848. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1849. exit;
  1850. }
  1851. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1852. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1853. exit;
  1854. }
  1855. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1856. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1857. exit;
  1858. }
  1859. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1860. if (isset($yz[0]['type'])) {
  1861. $post['type'] = $yz[0]['type'];
  1862. }
  1863. if ($post['state'] == 9) //如果选择预设库存
  1864. {
  1865. $this->whlabel->insert($post);
  1866. } else {
  1867. /**
  1868. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1869. if($ljg == 1)
  1870. {
  1871. for($i=0;$i<$order;$i++)
  1872. {
  1873. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1874. $this->whlabel->insert($post);
  1875. }
  1876. }
  1877. **/
  1878. //if($post['warehouse'] == '5')
  1879. //{
  1880. //}
  1881. $yydata = $post;
  1882. $yydata['zh'] = $zh;
  1883. /**
  1884. $wl = $this->apiyy->get_cjlp($yydata);
  1885. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1886. {
  1887. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1888. }
  1889. if($wl['Data'][0]['m_isSucess'] != 1)
  1890. {
  1891. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1892. }
  1893. **/
  1894. for ($i = 0; $i < $order; $i++) {
  1895. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1896. $this->whlabel->insert($post);
  1897. }
  1898. }
  1899. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1900. exit;
  1901. }
  1902. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1903. $this->data['wlshop'] = $wlshop;
  1904. $this->_Template('whlabel_enteradd', $this->data);
  1905. }
  1906. //修改产品
  1907. public function _enteredit($arg_array)
  1908. {
  1909. $dt = 0;
  1910. if (isset($_SESSION['api'])) {
  1911. $user = $this->user->get_api($_SESSION['api']);
  1912. $usp = $user;
  1913. $fgshop = "";
  1914. $sid = "";
  1915. $user = explode('|', trim($user['shop'], '|'));
  1916. foreach ($user as $value) {
  1917. $fgshop .= " shop = " . $value . " or";
  1918. $sid .= " id = " . $value . " or";
  1919. }
  1920. }
  1921. $post = $this->input->post(NULL, TRUE);
  1922. if (isset($post['sku'])) {
  1923. $list = array();
  1924. $num = "";
  1925. $title = "";
  1926. $features = "";
  1927. $id = $this->input->post('id', true);
  1928. $order = $this->input->post('order', true);
  1929. $shop = $this->input->post('shop', true);
  1930. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1931. $post['sku'] = $this->input->post('sku', true);
  1932. $post['sm'] = $this->input->post('sm', true);
  1933. $post['warehouse'] = $this->input->post('warehouse', true);
  1934. $post['purchase'] = $this->input->post('purchase', true);
  1935. $post['retreatwarehouse'] = $post['warehouse'];
  1936. $category = $this->input->post('category', true);
  1937. $list['category'] = $category;
  1938. $list['hairtype'] = $this->input->post('hairtype', true);
  1939. $list['grade'] = $this->input->post('grade', true);
  1940. $size = $this->input->post('size', true);
  1941. $list['size'] = rtrim($size, ',');
  1942. $post['rktype'] = $this->input->post('rktype', true);
  1943. $post['text'] = $this->input->post('text', true);
  1944. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1945. $list['extension'] = $this->input->post('extension', true);
  1946. if ($category == 1297) {
  1947. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1948. }
  1949. if ($category == 1702) {
  1950. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1951. $list['syother'] = $this->input->post('syother', true);
  1952. }
  1953. if ($category == 133) {
  1954. $list['fittype'] = $this->input->post('fittype', true);
  1955. $list['acother'] = $this->input->post('acother', true);
  1956. }
  1957. $list['color'] = $this->input->post('color', true);
  1958. $list['lowe'] = $this->input->post('lowe', true);
  1959. if (!$post['purchase']) {
  1960. $post['purchase'] = 1;
  1961. }
  1962. if ($category == 127) {
  1963. $list['type'] = $this->input->post('type', true);
  1964. $list['headroad'] = $this->input->post('headroad', true);
  1965. $list['density'] = $this->input->post('density', true);
  1966. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1967. $list['lacesize'] = $this->input->post('lacesize', true);
  1968. }
  1969. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1970. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1971. }
  1972. if ($category == 128) {
  1973. $list['lacetype'] = $this->input->post('lacetype', true);
  1974. $list['haircap'] = $this->input->post('haircap', true);
  1975. $list['density'] = $this->input->post('density', true);
  1976. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1977. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1978. $list['wigother'] = $this->input->post('wigother', true);
  1979. $list['wigother1'] = $this->input->post('wigother1', true);
  1980. $list['wigother2'] = $this->input->post('wigother2', true);
  1981. }
  1982. if ($category == 129) {
  1983. $list['wide'] = $this->input->post('wide', true);
  1984. }
  1985. if ($category == 131) {
  1986. $list['gifttype'] = $this->input->post('gifttype', true);
  1987. $list['giftother'] = $this->input->post('giftother', true);
  1988. }
  1989. if ($category == 134) {
  1990. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1991. }
  1992. if ($category == 1297) {
  1993. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1994. $list['sywigother'] = $this->input->post('sywigother', true);
  1995. }
  1996. if ($category == 130 || $category == 133 || $category == 1702) {
  1997. $list['items'] = $this->input->post('items', true);
  1998. $list['weight'] = $this->input->post('weight', true);
  1999. }
  2000. if ($category == 1702) {
  2001. $list['syhairther'] = $this->input->post('syhairther', true);
  2002. }
  2003. foreach ($list as $k => $v) {
  2004. if ($v != 0) {
  2005. $num .= $v;
  2006. $features .= $v . '-';
  2007. $typeclass = $this->typeclass->read($v);
  2008. if ($k != 'size') {
  2009. $title .= $typeclass['title'] . " ";
  2010. }
  2011. }
  2012. }
  2013. $typeclass = $this->typeclass->read($list['size']);
  2014. $title .= $typeclass['title'];
  2015. $time = time();
  2016. $post['title'] = rtrim($title, ' ');
  2017. $post['number'] = $num;
  2018. $post['features'] = '-' . $features;
  2019. $post['time'] = $time; //操作时间
  2020. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2021. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2022. exit;
  2023. }
  2024. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2025. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2026. exit;
  2027. }
  2028. $uid = $this->whlabel->read($id);
  2029. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2030. if ($datanum > 0) {
  2031. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2032. exit;
  2033. }
  2034. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2035. {
  2036. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2037. if ($yza) {
  2038. if ($post['features'] != $yza[0]['features']) {
  2039. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2040. exit;
  2041. }
  2042. }
  2043. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2044. if ($yzb) {
  2045. if ($post['sku'] != $yzb[0]['sku']) {
  2046. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2047. exit;
  2048. }
  2049. }
  2050. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2051. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2052. exit;
  2053. }
  2054. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2055. foreach ($data as $v) {
  2056. $post['id'] = $v['id'];
  2057. $this->whlabel->save($post, $v['id']);
  2058. }
  2059. } else {
  2060. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2061. if ($data > 0) {
  2062. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2063. exit;
  2064. } else {
  2065. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2066. foreach ($data as $v) {
  2067. $post['id'] = $v['id'];
  2068. $this->whlabel->save($post, $v['id']);
  2069. }
  2070. }
  2071. }
  2072. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2073. exit;
  2074. }
  2075. $uid = $this->whlabel->read($arg_array[0]);
  2076. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2077. $this->data['enter'] = $uid;
  2078. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2079. $this->data['wlshop'] = $wlshop;
  2080. $this->_Template('whlabel_enteredit', $this->data);
  2081. }
  2082. //入库浏览
  2083. public function _enter()
  2084. {
  2085. $post = $this->input->post(NULL, TRUE);
  2086. if (isset($post['s'])) {
  2087. $id_arr = $this->input->post('s');
  2088. $id_arr = explode(',', $id_arr);
  2089. if (!$id_arr) {
  2090. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2091. exit;
  2092. }
  2093. //循环删除记录
  2094. foreach ($id_arr as $v) {
  2095. $sid = $this->whlabel->read($v);
  2096. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2097. if ($count > 0) {
  2098. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2099. exit;
  2100. }
  2101. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2102. foreach ($info_list as $va) {
  2103. $this->whlabel->remove($va['id']);
  2104. }
  2105. }
  2106. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2107. exit;
  2108. }
  2109. $sp = array();
  2110. $s = $this->shop->find_all('1=1', 'id,shopname');
  2111. foreach ($s as $v) {
  2112. $sp[$v['id']] = $v['shopname'];
  2113. }
  2114. $wh = array();
  2115. $w = $this->warehouse->find_all('1=1', 'id,title');
  2116. foreach ($w as $v) {
  2117. $wh[$v['id']] = $v['title'];
  2118. }
  2119. if (isset($post['page'])) {
  2120. $page = $this->input->post('page', true);
  2121. $perpage = $this->input->post('perpage', true);
  2122. $category = $this->input->post('category', true);
  2123. $size = $this->input->post('size', true);
  2124. $grade = $this->input->post('grade', true);
  2125. $color = $this->input->post('color', true);
  2126. $lowe = $this->input->post('lowe', true);
  2127. $sku = $this->input->post('sku', true);
  2128. $warehouse = $this->input->post('warehouse', true);
  2129. $purchase = $this->input->post('purchase', true);
  2130. $ktime = $this->input->post('ktime', true);
  2131. $jtime = $this->input->post('jtime', true);
  2132. $ktime = strtotime($ktime);
  2133. $jtime = strtotime($jtime);
  2134. $where = "1=1";
  2135. $gj = "";
  2136. $ck = "";
  2137. if ($category) {
  2138. $where .= " and features like '%-$category-%'";
  2139. }
  2140. if ($size) {
  2141. $where .= " and features like '%-$size-%'";
  2142. }
  2143. if ($grade) {
  2144. $where .= " and features like '%-$grade-%'";
  2145. }
  2146. if ($color) {
  2147. $where .= " and features like '%-$color-%'";
  2148. }
  2149. if ($lowe) {
  2150. $where .= " and features like '%-$lowe-%'";
  2151. }
  2152. if ($warehouse) {
  2153. $where .= " and warehouse = '$warehouse'";
  2154. }
  2155. if ($purchase) {
  2156. $where .= " and purchase = '$purchase'";
  2157. }
  2158. if ($sku) {
  2159. $where .= " and sku like '%$sku%'";
  2160. }
  2161. if ($ktime && $jtime) {
  2162. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2163. }
  2164. //数据排序
  2165. $order_str = "enter desc";
  2166. if (empty($page)) {
  2167. $start = 0;
  2168. $perpage = 1;
  2169. } else {
  2170. $start = ($page - 1) * $perpage;
  2171. }
  2172. //取得信息列表
  2173. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2174. foreach ($info_list as $k => $v) {
  2175. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2176. if ($v['shop'] == '') {
  2177. $s = '通用';
  2178. } else {
  2179. $info_list[$k]['shop'] = '';
  2180. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2181. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2182. }
  2183. }
  2184. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2185. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2186. $info_list[$k]['g'] = $g;
  2187. }
  2188. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2189. $total = count($this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,sku,title,features,number'));
  2190. $pagenum = ceil($total / $perpage);
  2191. $over = $total - ($start + $perpage);
  2192. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2193. echo json_encode($rows);
  2194. exit;
  2195. }
  2196. $this->_Template('whlabel_enter', $this->data);
  2197. }
  2198. //出库浏览
  2199. public function _out()
  2200. {
  2201. $post = $this->input->post(NULL, TRUE);
  2202. if (isset($post['page'])) {
  2203. $page = $this->input->post('page', true);
  2204. $perpage = $this->input->post('perpage', true);
  2205. $category = $this->input->post('category', true);
  2206. $size = $this->input->post('size', true);
  2207. $grade = $this->input->post('grade', true);
  2208. $color = $this->input->post('color', true);
  2209. $lowe = $this->input->post('lowe', true);
  2210. $sku = $this->input->post('sku', true);
  2211. $warehouse = $this->input->post('warehouse', true);
  2212. $purchase = $this->input->post('purchase', true);
  2213. $state = $this->input->post('state', true);
  2214. $ktime = $this->input->post('ktime', true);
  2215. $jtime = $this->input->post('jtime', true);
  2216. $ktime = strtotime($ktime);
  2217. $jtime = strtotime($jtime);
  2218. $where = "state=3";
  2219. $gj = "";
  2220. $ck = "";
  2221. if ($category) {
  2222. $where .= " and features like '%-$category-%'";
  2223. }
  2224. if ($size) {
  2225. $where .= " and features like '%-$size-%'";
  2226. }
  2227. if ($grade) {
  2228. $where .= " and features like '%-$grade-%'";
  2229. }
  2230. if ($color) {
  2231. $where .= " and features like '%-$color-%'";
  2232. }
  2233. if ($lowe) {
  2234. $where .= " and features like '%-$lowe-%'";
  2235. }
  2236. if ($state) {
  2237. $where .= " and state = '$state'";
  2238. }
  2239. if ($warehouse) {
  2240. $where .= " and warehouse = '$warehouse'";
  2241. }
  2242. if ($purchase) {
  2243. $where .= " and purchase = '$purchase'";
  2244. }
  2245. if ($sku) {
  2246. $where .= " and sku = '$sku'";
  2247. }
  2248. if ($ktime && $jtime) {
  2249. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2250. }
  2251. //数据排序
  2252. $order_str = "id desc";
  2253. if (empty($page)) {
  2254. $start = 0;
  2255. $perpage = 1;
  2256. } else {
  2257. $start = ($page - 1) * $perpage;
  2258. }
  2259. //取得信息列表
  2260. $info_list = $this->whlabel->find_all($where, 'sku');
  2261. $rows = array();
  2262. $list = array();
  2263. foreach ($info_list as $key => $value) {
  2264. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2265. }
  2266. $rows = array_unique($rows); //删除重复记录
  2267. foreach ($rows as $key => $value) {
  2268. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2269. $ck = $this->warehouse->read($data['warehouse']);
  2270. $warehouse = $ck['title'];
  2271. $gy = $this->purchase->read($data['purchase']);
  2272. $purchase = $gy['purchase'];
  2273. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2274. $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);
  2275. }
  2276. $total = count($list);
  2277. $pagenum = ceil($total / $perpage);
  2278. $over = $total - ($start + $perpage);
  2279. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2280. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2281. echo json_encode($rows);
  2282. exit;
  2283. }
  2284. $this->_Template('whlabel_out', $this->data);
  2285. }
  2286. //出库标签浏览
  2287. public function _label()
  2288. {
  2289. $post = $this->input->post(NULL, TRUE);
  2290. if (isset($post['page'])) {
  2291. $page = $this->input->post('page', true);
  2292. $perpage = $this->input->post('perpage', true);
  2293. $sku = $this->input->post('sku', true);
  2294. $warehouse = $this->input->post('warehouse', true);
  2295. $purchase = $this->input->post('purchase', true);
  2296. $orderinfo = $this->input->post('orderinfo', true);
  2297. $waybill = $this->input->post('waybill', true);
  2298. $category = $this->input->post('category', true);
  2299. $size = $this->input->post('size', true);
  2300. $grade = $this->input->post('grade', true);
  2301. $color = $this->input->post('color', true);
  2302. $lowe = $this->input->post('lowe', true);
  2303. $where = "state=1";
  2304. if ($sku) {
  2305. $where .= " and sku = '$sku'";
  2306. }
  2307. if ($warehouse) {
  2308. $where .= " and warehouse = '$warehouse'";
  2309. }
  2310. if ($purchase) {
  2311. $where .= " and purchase = '$purchase'";
  2312. }
  2313. if ($orderinfo) {
  2314. $where .= " and orderinfo = '$orderinfo'";
  2315. }
  2316. if ($waybill) {
  2317. $where .= " and waybill = '$waybill'";
  2318. }
  2319. if ($category) {
  2320. $where .= " and features like '%-$category-%'";
  2321. }
  2322. if ($size) {
  2323. $where .= " and features like '%-$size-%'";
  2324. }
  2325. if ($grade) {
  2326. $where .= " and features like '%-$grade-%'";
  2327. }
  2328. if ($color) {
  2329. $where .= " and features like '%-$color-%'";
  2330. }
  2331. if ($lowe) {
  2332. $where .= " and features like '%-$lowe-%'";
  2333. }
  2334. //数据排序
  2335. $order_str = "outk desc";
  2336. if (empty($page)) {
  2337. $start = 0;
  2338. $perpage = 1;
  2339. } else {
  2340. $start = ($page - 1) * $perpage;
  2341. }
  2342. //取得信息列表
  2343. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2344. foreach ($info_list as $key => $value) {
  2345. $warehouse = $this->warehouse->read($value['warehouse']);
  2346. $info_list[$key]['warehouse'] = $warehouse['title'];
  2347. $purchase = $this->purchase->read($value['purchase']);
  2348. $info_list[$key]['purchase'] = $purchase['title'];
  2349. if ($value['outk'] != 0) {
  2350. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2351. } else {
  2352. $info_list[$key]['outk'] = "";
  2353. }
  2354. if ($value['orderinfo'] == 0) {
  2355. $info_list[$key]['orderinfo'] = "";
  2356. }
  2357. if ($value['waybill'] == 0) {
  2358. $info_list[$key]['waybill'] = "";
  2359. }
  2360. }
  2361. $total = $this->whlabel->find_count($where);
  2362. $pagenum = ceil($total / $perpage);
  2363. $over = $total - ($start + $perpage);
  2364. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2365. echo json_encode($rows);
  2366. exit;
  2367. }
  2368. $this->_Template('whlabel_label', $this->data);
  2369. }
  2370. //独立站出库订单
  2371. public function _outorder()
  2372. {
  2373. if (isset($_SESSION['api'])) {
  2374. $user = $this->user->get_api($_SESSION['api']);
  2375. $usp = $user;
  2376. $fgshop = "";
  2377. $sid = "";
  2378. $user = explode('|', trim($user['shop'], '|'));
  2379. foreach ($user as $value) {
  2380. $fgshop .= " shop = " . $value . " or";
  2381. $sid .= " id = " . $value . " or";
  2382. }
  2383. } else {
  2384. echo "请重新登录";
  2385. }
  2386. $post = $this->input->post(NULL, TRUE);
  2387. if (isset($post['page'])) {
  2388. $page = $this->input->post('page', true);
  2389. $perpage = $this->input->post('perpage', true);
  2390. $warehouse = $this->input->post('warehouse', true);
  2391. $xztime = $this->input->post('xztime', true);
  2392. $timetk = $this->input->post('timetkk', true);
  2393. $timetj = $this->input->post('timetjj', true);
  2394. $shop = $this->input->post('shop', true);
  2395. $source = $this->input->post('source', true);
  2396. $orderinfo = $this->input->post('orderinfo', true);
  2397. $number = $this->input->post('number', true);
  2398. $sfxh = $this->input->post('sfxh', true);
  2399. $express = $this->input->post('express', true);
  2400. $waybill = $this->input->post('waybill', true);
  2401. $library = $this->input->post('library', true);
  2402. $country = $this->input->post('country', true);
  2403. $so = $this->input->post('so', true);
  2404. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2405. $print = $this->input->post('print', true);
  2406. $state = $this->input->post('state', true);
  2407. $orderurl = $this->input->post('orderurl', true);
  2408. $productid = $this->input->post('productid', true);
  2409. $timetk = strtotime($timetk);
  2410. $timetj = strtotime($timetj);
  2411. /**
  2412. $sj = $this->input->post('sj',true);
  2413. if($sj)
  2414. {
  2415. $sj = $this->input->post('sj',true);
  2416. }
  2417. else
  2418. {
  2419. $sj = "fullorder";
  2420. }
  2421. **/
  2422. $sj = "fullorder";
  2423. $where = "1=1";
  2424. if ($warehouse) {
  2425. $where .= " and type = '$warehouse'";
  2426. }
  2427. if ($timetk && $timetj) {
  2428. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2429. }
  2430. if ($orderinfo) {
  2431. $where .= " and orderinfo = '$orderinfo'";
  2432. }
  2433. if ($number) {
  2434. $where .= " and number = '$number'";
  2435. }
  2436. if ($express) {
  2437. $where .= " and express = '$express'";
  2438. }
  2439. if ($waybill) {
  2440. $where .= " and waybill = '$waybill'";
  2441. }
  2442. if ($library) {
  2443. $where .= " and library = '$library'";
  2444. }
  2445. if ($print) {
  2446. $where .= " and print = '$print'";
  2447. }
  2448. if ($libraryconfirm) {
  2449. $where .= " and libraryconfirm = '$libraryconfirm'";
  2450. }
  2451. if ($state) {
  2452. $where .= " and state = '$state'";
  2453. }
  2454. if ($shop) {
  2455. $where .= " and shop = '$shop'";
  2456. }
  2457. if ($country) {
  2458. $where .= " and country = '$country'";
  2459. }
  2460. if ($sfxh != '') {
  2461. $where .= " and sfxh = '$sfxh'";
  2462. }
  2463. if ($so) {
  2464. $where .= " and shipremarks like '%$so%'";
  2465. }
  2466. if ($source) {
  2467. if ($source == '2d') {
  2468. $where .= " and source >= '2'";
  2469. } else {
  2470. $where .= " and source = '$source'";
  2471. }
  2472. }
  2473. if (isset($_SESSION['api'])) {
  2474. foreach ($user as $value) {
  2475. $fgshop .= " shop = " . $value . " or";
  2476. }
  2477. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2478. }
  2479. if ($orderurl) {
  2480. $url = $this->orderurl->read($orderurl);
  2481. $where .= " and link like '%" . $url['url'] . "%'";
  2482. }
  2483. if($productid){
  2484. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2485. }
  2486. //数据排序
  2487. $order_str = "librarytime desc";
  2488. if (empty($page)) {
  2489. $start = 0;
  2490. $perpage = 1;
  2491. } else {
  2492. $start = ($page - 1) * $perpage;
  2493. }
  2494. //取得信息列表
  2495. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2496. //格式化数据
  2497. foreach ($info_list as $key => $value) {
  2498. $shop = $this->shop->read($value['shop']);
  2499. $info_list[$key]['shop'] = $shop['shopname'];
  2500. $express = $this->express->read($value['express']);
  2501. $info_list[$key]['express'] = $express['servicename'];
  2502. $warehouse = $this->warehouse->read($value['type']);
  2503. $info_list[$key]['type'] = $warehouse['title'];
  2504. if ($value['librarytime'] == '0') {
  2505. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2506. } else {
  2507. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2508. }
  2509. }
  2510. $total = $this->$sj->find_count($where);
  2511. $pagenum = ceil($total / $perpage);
  2512. $over = $total - ($start + $perpage);
  2513. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2514. echo json_encode($rows);
  2515. exit;
  2516. }
  2517. $this->data['express'] = $this->express->find_all();
  2518. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2519. $this->data['wlshop'] = $wlshop;
  2520. $user = $this->user->get_api($_SESSION['api']);
  2521. $powerid = $this->power->read($user['power']);
  2522. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2523. $pid = '';
  2524. foreach ($powertext as $v) {
  2525. $pid .= " id = " . $v . " or";
  2526. }
  2527. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2528. $this->data['fullorderexcel'] = $fullorderexcel;
  2529. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2530. $this->data['orderurl'] = $orderurl;
  2531. $this->_Template('whlabel_outorder', $this->data);
  2532. }
  2533. //tt出库
  2534. public function _toutorder()
  2535. {
  2536. $fgshop = "";
  2537. $sid = "";
  2538. if (isset($_SESSION['api'])) {
  2539. $user = $this->user->get_api($_SESSION['api']);
  2540. $usp = $user;
  2541. $user = explode('|', trim($user['shop'], '|'));
  2542. foreach ($user as $value) {
  2543. $fgshop .= " shop = " . $value . " or";
  2544. $sid .= " id = " . $value . " or";
  2545. }
  2546. } else {
  2547. echo "请重新登录";
  2548. }
  2549. $post = $this->input->post(NULL, TRUE);
  2550. if (isset($post['page'])) {
  2551. $page = $this->input->post('page', true);
  2552. $perpage = $this->input->post('perpage', true);
  2553. $warehouse = $this->input->post('warehouse', true);
  2554. $xztime = $this->input->post('xztime', true);
  2555. $timetk = $this->input->post('timetkk', true);
  2556. $timetj = $this->input->post('timetjj', true);
  2557. $shop = $this->input->post('shop', true);
  2558. $source = $this->input->post('source', true);
  2559. $orderinfo = $this->input->post('orderinfo', true);
  2560. $number = $this->input->post('number', true);
  2561. $sfxh = $this->input->post('sfxh', true);
  2562. $express = $this->input->post('express', true);
  2563. $waybill = $this->input->post('waybill', true);
  2564. $library = $this->input->post('library', true);
  2565. $country = $this->input->post('country', true);
  2566. $so = $this->input->post('so', true);
  2567. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2568. $print = $this->input->post('print', true);
  2569. $state = $this->input->post('state', true);
  2570. $orderurl = $this->input->post('orderurl', true);
  2571. $timetk = strtotime($timetk);
  2572. $timetj = strtotime($timetj);
  2573. /**
  2574. $sj = $this->input->post('sj',true);
  2575. if($sj)
  2576. {
  2577. $sj = $this->input->post('sj',true);
  2578. }
  2579. else
  2580. {
  2581. $sj = "fullorder";
  2582. }
  2583. **/
  2584. $sj = "fullordertt";
  2585. $where = "1=1";
  2586. if ($warehouse) {
  2587. $where .= " and type = '$warehouse'";
  2588. }
  2589. if ($timetk && $timetj) {
  2590. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2591. }
  2592. if ($orderinfo) {
  2593. $where .= " and orderinfo = '$orderinfo'";
  2594. }
  2595. if ($number) {
  2596. $where .= " and number = '$number'";
  2597. }
  2598. if ($express) {
  2599. $where .= " and express = '$express'";
  2600. }
  2601. if ($waybill) {
  2602. $where .= " and waybill = '$waybill'";
  2603. }
  2604. if ($library) {
  2605. $where .= " and library = '$library'";
  2606. }
  2607. if ($print) {
  2608. $where .= " and print = '$print'";
  2609. }
  2610. if ($libraryconfirm) {
  2611. $where .= " and libraryconfirm = '$libraryconfirm'";
  2612. }
  2613. if ($state) {
  2614. $where .= " and state = '$state'";
  2615. }
  2616. if ($shop) {
  2617. $where .= " and shop = '$shop'";
  2618. }
  2619. if ($country) {
  2620. $where .= " and country = '$country'";
  2621. }
  2622. if ($sfxh != '') {
  2623. $where .= " and sfxh = '$sfxh'";
  2624. }
  2625. if ($so) {
  2626. $where .= " and shipremarks like '%$so%'";
  2627. }
  2628. if ($source) {
  2629. if ($source == '2d') {
  2630. $where .= " and source >= '2'";
  2631. } else {
  2632. $where .= " and source = '$source'";
  2633. }
  2634. }
  2635. if (isset($_SESSION['api'])) {
  2636. foreach ($user as $value) {
  2637. $fgshop .= " shop = " . $value . " or";
  2638. }
  2639. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2640. }
  2641. if ($orderurl) {
  2642. $url = $this->orderurl->read($orderurl);
  2643. $where .= " and link like '%" . $url['url'] . "%'";
  2644. }
  2645. //数据排序
  2646. $order_str = "librarytime desc";
  2647. if (empty($page)) {
  2648. $start = 0;
  2649. $perpage = 1;
  2650. } else {
  2651. $start = ($page - 1) * $perpage;
  2652. }
  2653. //取得信息列表
  2654. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2655. //格式化数据
  2656. foreach ($info_list as $key => $value) {
  2657. $shop = $this->shop->read($value['shop']);
  2658. $info_list[$key]['shop'] = $shop['shopname'];
  2659. $express = $this->express->read($value['express']);
  2660. $info_list[$key]['express'] = $express['servicename'];
  2661. $warehouse = $this->warehouse->read($value['type']);
  2662. $info_list[$key]['type'] = $warehouse['title'];
  2663. if ($value['librarytime'] == '0') {
  2664. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2665. } else {
  2666. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2667. }
  2668. }
  2669. $total = $this->$sj->find_count($where);
  2670. $pagenum = ceil($total / $perpage);
  2671. $over = $total - ($start + $perpage);
  2672. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2673. echo json_encode($rows);
  2674. exit;
  2675. }
  2676. $this->data['express'] = $this->express->find_all();
  2677. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2678. $this->data['wlshop'] = $wlshop;
  2679. $user = $this->user->get_api($_SESSION['api']);
  2680. $powerid = $this->power->read($user['power']);
  2681. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2682. $pid = '';
  2683. foreach ($powertext as $v) {
  2684. $pid .= " id = " . $v . " or";
  2685. }
  2686. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2687. $this->data['fullorderexcel'] = $fullorderexcel;
  2688. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2689. $this->data['orderurl'] = $orderurl;
  2690. $this->_Template('whlabel_toutorder', $this->data);
  2691. }
  2692. //tt出库
  2693. public function _aoutorder()
  2694. {
  2695. if (isset($_SESSION['api'])) {
  2696. $user = $this->user->get_api($_SESSION['api']);
  2697. $usp = $user;
  2698. $fgshop = "";
  2699. $sid = "";
  2700. $user = explode('|', trim($user['shop'], '|'));
  2701. foreach ($user as $value) {
  2702. $fgshop .= " shop = " . $value . " or";
  2703. $sid .= " id = " . $value . " or";
  2704. }
  2705. } else {
  2706. echo "请重新登录";
  2707. }
  2708. $post = $this->input->post(NULL, TRUE);
  2709. if (isset($post['page'])) {
  2710. $page = $this->input->post('page', true);
  2711. $perpage = $this->input->post('perpage', true);
  2712. $warehouse = $this->input->post('warehouse', true);
  2713. $xztime = $this->input->post('xztime', true);
  2714. $timetk = $this->input->post('timetkk', true);
  2715. $timetj = $this->input->post('timetjj', true);
  2716. $shop = $this->input->post('shop', true);
  2717. $source = $this->input->post('source', true);
  2718. $orderinfo = $this->input->post('orderinfo', true);
  2719. $number = $this->input->post('number', true);
  2720. $sfxh = $this->input->post('sfxh', true);
  2721. $express = $this->input->post('express', true);
  2722. $waybill = $this->input->post('waybill', true);
  2723. $library = $this->input->post('library', true);
  2724. $country = $this->input->post('country', true);
  2725. $so = $this->input->post('so', true);
  2726. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2727. $print = $this->input->post('print', true);
  2728. $state = $this->input->post('state', true);
  2729. $orderurl = $this->input->post('orderurl', true);
  2730. $timetk = strtotime($timetk);
  2731. $timetj = strtotime($timetj);
  2732. /**
  2733. $sj = $this->input->post('sj',true);
  2734. if($sj)
  2735. {
  2736. $sj = $this->input->post('sj',true);
  2737. }
  2738. else
  2739. {
  2740. $sj = "fullorder";
  2741. }
  2742. **/
  2743. $sj = "fullorderamz";
  2744. $where = "1=1";
  2745. if ($warehouse) {
  2746. $where .= " and type = '$warehouse'";
  2747. }
  2748. if ($timetk && $timetj) {
  2749. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2750. }
  2751. if ($orderinfo) {
  2752. $where .= " and orderinfo = '$orderinfo'";
  2753. }
  2754. if ($number) {
  2755. $where .= " and number = '$number'";
  2756. }
  2757. if ($express) {
  2758. $where .= " and express = '$express'";
  2759. }
  2760. if ($waybill) {
  2761. $where .= " and waybill = '$waybill'";
  2762. }
  2763. if ($library) {
  2764. $where .= " and library = '$library'";
  2765. }
  2766. if ($print) {
  2767. $where .= " and print = '$print'";
  2768. }
  2769. if ($libraryconfirm) {
  2770. $where .= " and libraryconfirm = '$libraryconfirm'";
  2771. }
  2772. if ($state) {
  2773. $where .= " and state = '$state'";
  2774. }
  2775. if ($shop) {
  2776. $where .= " and shop = '$shop'";
  2777. }
  2778. if ($country) {
  2779. $where .= " and country = '$country'";
  2780. }
  2781. if ($sfxh != '') {
  2782. $where .= " and sfxh = '$sfxh'";
  2783. }
  2784. if ($so) {
  2785. $where .= " and shipremarks like '%$so%'";
  2786. }
  2787. if ($source) {
  2788. if ($source == '2d') {
  2789. $where .= " and source >= '2'";
  2790. } else {
  2791. $where .= " and source = '$source'";
  2792. }
  2793. }
  2794. if (isset($_SESSION['api'])) {
  2795. foreach ($user as $value) {
  2796. $fgshop .= " shop = " . $value . " or";
  2797. }
  2798. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2799. }
  2800. if ($orderurl) {
  2801. $url = $this->orderurl->read($orderurl);
  2802. $where .= " and link like '%" . $url['url'] . "%'";
  2803. }
  2804. //数据排序
  2805. $order_str = "librarytime desc";
  2806. if (empty($page)) {
  2807. $start = 0;
  2808. $perpage = 1;
  2809. } else {
  2810. $start = ($page - 1) * $perpage;
  2811. }
  2812. //取得信息列表
  2813. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2814. //格式化数据
  2815. foreach ($info_list as $key => $value) {
  2816. $shop = $this->shop->read($value['shop']);
  2817. $info_list[$key]['shop'] = $shop['shopname'];
  2818. $express = $this->express->read($value['express']);
  2819. $info_list[$key]['express'] = $express['servicename'];
  2820. $warehouse = $this->warehouse->read($value['type']);
  2821. $info_list[$key]['type'] = $warehouse['title'];
  2822. if ($value['librarytime'] == '0') {
  2823. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2824. } else {
  2825. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2826. }
  2827. }
  2828. $total = $this->$sj->find_count($where);
  2829. $pagenum = ceil($total / $perpage);
  2830. $over = $total - ($start + $perpage);
  2831. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2832. echo json_encode($rows);
  2833. exit;
  2834. }
  2835. $this->data['express'] = $this->express->find_all();
  2836. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2837. $this->data['wlshop'] = $wlshop;
  2838. $user = $this->user->get_api($_SESSION['api']);
  2839. $powerid = $this->power->read($user['power']);
  2840. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2841. $pid = '';
  2842. foreach ($powertext as $v) {
  2843. $pid .= " id = " . $v . " or";
  2844. }
  2845. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2846. $this->data['fullorderexcel'] = $fullorderexcel;
  2847. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2848. $this->data['orderurl'] = $orderurl;
  2849. $this->_Template('whlabel_aoutorder', $this->data);
  2850. }
  2851. //速卖通出库订单
  2852. public function _soutorder()
  2853. {
  2854. if (isset($_SESSION['api'])) {
  2855. $user = $this->user->get_api($_SESSION['api']);
  2856. $usp = $user;
  2857. $fgshop = "";
  2858. $sid = "";
  2859. $user = explode('|', trim($user['shop'], '|'));
  2860. foreach ($user as $value) {
  2861. $sid .= " id = " . $value . " or";
  2862. }
  2863. }
  2864. $post = $this->input->post(NULL, TRUE);
  2865. if (isset($post['page'])) {
  2866. $page = $this->input->post('page', true);
  2867. $perpage = $this->input->post('perpage', true);
  2868. $warehouse = $this->input->post('warehouse', true);
  2869. $xztime = $this->input->post('xztime', true);
  2870. $timetk = $this->input->post('timetkk', true);
  2871. $timetj = $this->input->post('timetjj', true);
  2872. $shop = $this->input->post('shop', true);
  2873. $source = $this->input->post('source', true);
  2874. $orderinfo = $this->input->post('orderinfo', true);
  2875. $number = $this->input->post('number', true);
  2876. $express = $this->input->post('express', true);
  2877. $waybill = $this->input->post('waybill', true);
  2878. $library = $this->input->post('library', true);
  2879. $country = $this->input->post('country', true);
  2880. $sfxh = $this->input->post('sfxh', true);
  2881. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2882. $print = $this->input->post('print', true);
  2883. $state = $this->input->post('state', true);
  2884. $so = $this->input->post('so', true);
  2885. $timetk = strtotime($timetk);
  2886. $timetj = strtotime($timetj);
  2887. /**
  2888. $sj = $this->input->post('sj',true);
  2889. if($sj)
  2890. {
  2891. $sj = $this->input->post('sj',true);
  2892. }
  2893. else
  2894. {
  2895. $sj = "fullorder";
  2896. }
  2897. **/
  2898. $sj = "fullordersmt";
  2899. $where = "1=1";
  2900. if ($warehouse) {
  2901. $where .= " and type = '$warehouse'";
  2902. }
  2903. if ($timetk && $timetj) {
  2904. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2905. }
  2906. if ($orderinfo) {
  2907. $where .= " and orderinfo = '$orderinfo'";
  2908. }
  2909. if ($number) {
  2910. $where .= " and number = '$number'";
  2911. }
  2912. if ($express) {
  2913. $where .= " and express = '$express'";
  2914. }
  2915. if ($waybill) {
  2916. $where .= " and waybill = '$waybill'";
  2917. }
  2918. if ($library) {
  2919. $where .= " and library = '$library'";
  2920. }
  2921. if ($print) {
  2922. $where .= " and print = '$print'";
  2923. }
  2924. if ($libraryconfirm) {
  2925. $where .= " and libraryconfirm = '$libraryconfirm'";
  2926. }
  2927. if ($state) {
  2928. $where .= " and state = '$state'";
  2929. }
  2930. if ($shop) {
  2931. $where .= " and shop = '$shop'";
  2932. }
  2933. if ($sfxh != '') {
  2934. $where .= " and sfxh = '$sfxh'";
  2935. }
  2936. if ($so) {
  2937. $where .= " and shipremarks like '%$so%'";
  2938. }
  2939. if ($source) {
  2940. $where .= " and source = '$source'";
  2941. }
  2942. if ($country) {
  2943. $where .= " and country = '$country'";
  2944. } else {
  2945. if (isset($_SESSION['api'])) {
  2946. foreach ($user as $value) {
  2947. $fgshop .= " shop = " . $value . " or";
  2948. }
  2949. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2950. }
  2951. }
  2952. //数据排序
  2953. $order_str = "librarytime desc";
  2954. if (empty($page)) {
  2955. $start = 0;
  2956. $perpage = 1;
  2957. } else {
  2958. $start = ($page - 1) * $perpage;
  2959. }
  2960. //取得信息列表
  2961. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2962. //格式化数据
  2963. foreach ($info_list as $key => $value) {
  2964. $shop = $this->shop->read($value['shop']);
  2965. $info_list[$key]['shop'] = $shop['shopname'];
  2966. $express = $this->express->read($value['express']);
  2967. $info_list[$key]['express'] = $express['servicename'];
  2968. $warehouse = $this->warehouse->read($value['type']);
  2969. $info_list[$key]['type'] = $warehouse['title'];
  2970. if ($value['librarytime'] == '0') {
  2971. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2972. } else {
  2973. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2974. }
  2975. }
  2976. $total = $this->$sj->find_count($where);
  2977. $pagenum = ceil($total / $perpage);
  2978. $over = $total - ($start + $perpage);
  2979. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2980. echo json_encode($rows);
  2981. exit;
  2982. }
  2983. $this->data['express'] = $this->express->find_all();
  2984. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2985. $this->data['wlshop'] = $wlshop;
  2986. $user = $this->user->get_api($_SESSION['api']);
  2987. $powerid = $this->power->read($user['power']);
  2988. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2989. $pid = '';
  2990. foreach ($powertext as $v) {
  2991. $pid .= " id = " . $v . " or";
  2992. }
  2993. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2994. $this->data['fullorderexcel'] = $fullorderexcel;
  2995. $this->_Template('whlabel_soutorder', $this->data);
  2996. }
  2997. //订单退库
  2998. public function _retreat()
  2999. {
  3000. $post = $this->input->post(NULL, TRUE);
  3001. if (isset($post['page'])) {
  3002. $page = $this->input->post('page', true);
  3003. $perpage = $this->input->post('perpage', true);
  3004. $warehouse = $this->input->post('warehouse', true);
  3005. $timetk = $this->input->post('timetk', true);
  3006. $timetj = $this->input->post('timetj', true);
  3007. $shop = $this->input->post('shop', true);
  3008. $source = $this->input->post('source', true);
  3009. $state = $this->input->post('state', true);
  3010. $review = $this->input->post('review', true);
  3011. $state = $this->input->post('state', true);
  3012. $express = $this->input->post('express', true);
  3013. $orderinfo = $this->input->post('orderinfo', true);
  3014. $user = $this->input->post('user', true);
  3015. $name = $this->input->post('name', true);
  3016. $waybill = $this->input->post('waybill', true);
  3017. $timetk = strtotime($timetk);
  3018. $timetj = strtotime($timetj);
  3019. $where = "(state=206 or state=210) and mergeid = 0";
  3020. if ($warehouse) {
  3021. $where .= " and state = '$warehouse'";
  3022. }
  3023. if ($timetk && $timetj) {
  3024. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3025. }
  3026. if ($shop) {
  3027. $where .= " and shop = '$shop'";
  3028. }
  3029. if ($source) {
  3030. $where .= " and source = '$source'";
  3031. }
  3032. if ($state) {
  3033. $where .= " and state = '$state'";
  3034. }
  3035. if ($review) {
  3036. $where .= " and review = '$review'";
  3037. }
  3038. if ($state) {
  3039. $where .= " and state = '$state'";
  3040. }
  3041. if ($express) {
  3042. $where .= " and express = '$express'";
  3043. }
  3044. if ($orderinfo) {
  3045. $where .= " and orderinfo = '$orderinfo'";
  3046. }
  3047. if ($user) {
  3048. $where .= " and user = '$user'";
  3049. }
  3050. if ($name) {
  3051. $where .= " and name = '$name'";
  3052. }
  3053. if ($waybill) {
  3054. $where .= " and waybill = '$waybill'";
  3055. }
  3056. //数据排序
  3057. $order_str = "id desc";
  3058. if (empty($page)) {
  3059. $start = 0;
  3060. $perpage = 1;
  3061. } else {
  3062. $start = ($page - 1) * $perpage;
  3063. }
  3064. //取得信息列表
  3065. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3066. //格式化数据
  3067. foreach ($info_list as $key => $value) {
  3068. $shop = $this->shop->read($value['shop']);
  3069. $info_list[$key]['shop'] = $shop['shopname'];
  3070. $warehouse = $this->warehouse->read($value['warehouse']);
  3071. $info_list[$key]['warehouse'] = $warehouse['title'];
  3072. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3073. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3074. if ($value['waybill'] == 0) {
  3075. $info_list[$key]['waybill'] = "";
  3076. }
  3077. $express = $this->express->read($value['express']);
  3078. $info_list[$key]['express'] = $express['title'];
  3079. $typeclass = $this->typeclass->read($value['state']);
  3080. $info_list[$key]['state'] = $typeclass['title'];
  3081. }
  3082. $total = $this->fullorder->find_count($where);
  3083. $pagenum = ceil($total / $perpage);
  3084. $over = $total - ($start + $perpage);
  3085. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3086. echo json_encode($rows);
  3087. exit;
  3088. }
  3089. $this->data['express'] = $this->express->find_all();
  3090. $this->_Template('whlabel_retreat', $this->data);
  3091. }
  3092. //退库标签浏览
  3093. public function _retreatlk()
  3094. {
  3095. $post = $this->input->post(NULL, TRUE);
  3096. if (isset($post['page'])) {
  3097. $page = $this->input->post('page', true);
  3098. $perpage = $this->input->post('perpage', true);
  3099. $timetk = $this->input->post('timetk', true);
  3100. $timetj = $this->input->post('timetj', true);
  3101. $sku = $this->input->post('sku', true);
  3102. $warehouse = $this->input->post('warehouse', true);
  3103. $purchase = $this->input->post('purchase', true);
  3104. $orderinfo = $this->input->post('orderinfo', true);
  3105. $waybill = $this->input->post('waybill', true);
  3106. $category = $this->input->post('category', true);
  3107. $size = $this->input->post('size', true);
  3108. $grade = $this->input->post('grade', true);
  3109. $color = $this->input->post('color', true);
  3110. $lowe = $this->input->post('lowe', true);
  3111. $state = $this->input->post('state', true);
  3112. $timetk = strtotime($timetk);
  3113. $timetj = strtotime($timetj);
  3114. $where = "state=2";
  3115. if ($timetk && $timetj) {
  3116. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3117. }
  3118. if ($sku) {
  3119. $where .= " and sku = '$sku'";
  3120. }
  3121. if ($warehouse) {
  3122. $where .= " and warehouse = '$warehouse'";
  3123. }
  3124. if ($purchase) {
  3125. $where .= " and purchase = '$purchase'";
  3126. }
  3127. if ($orderinfo) {
  3128. $where .= " and orderinfo = '$orderinfo'";
  3129. }
  3130. if ($waybill) {
  3131. $where .= " and waybill = '$waybill'";
  3132. }
  3133. if ($category) {
  3134. $where .= " and features like '%-$category-%'";
  3135. }
  3136. if ($size) {
  3137. $where .= " and features like '%-$size-%'";
  3138. }
  3139. if ($grade) {
  3140. $where .= " and features like '%-$grade-%'";
  3141. }
  3142. if ($color) {
  3143. $where .= " and features like '%-$color-%'";
  3144. }
  3145. if ($lowe) {
  3146. $where .= " and features like '%-$lowe-%'";
  3147. }
  3148. //数据排序
  3149. $order_str = "time desc";
  3150. if (empty($page)) {
  3151. $start = 0;
  3152. $perpage = 1;
  3153. } else {
  3154. $start = ($page - 1) * $perpage;
  3155. }
  3156. //取得信息列表
  3157. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3158. foreach ($info_list as $key => $value) {
  3159. $warehouse = $this->warehouse->read($value['warehouse']);
  3160. $info_list[$key]['warehouse'] = $warehouse['title'];
  3161. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3162. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3163. $purchase = $this->purchase->read($value['purchase']);
  3164. $info_list[$key]['purchase'] = $purchase['title'];
  3165. if ($value['outk'] != 0) {
  3166. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3167. } else {
  3168. $info_list[$key]['outk'] = "";
  3169. }
  3170. if ($value['retreat'] != 0) {
  3171. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3172. } else {
  3173. $info_list[$key]['retreat'] = "";
  3174. }
  3175. if ($value['orderinfo'] == 0) {
  3176. $info_list[$key]['orderinfo'] = "";
  3177. }
  3178. if ($value['waybill'] == 0) {
  3179. $info_list[$key]['waybill'] = "";
  3180. }
  3181. }
  3182. $total = $this->whlabel->find_count($where);
  3183. $pagenum = ceil($total / $perpage);
  3184. $over = $total - ($start + $perpage);
  3185. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3186. echo json_encode($rows);
  3187. exit;
  3188. }
  3189. $this->_Template('whlabel_retreatlk', $this->data);
  3190. }
  3191. //更换标签及浏览
  3192. public function _change()
  3193. {
  3194. $post = $this->input->post(NULL, TRUE);
  3195. if (isset($post['page'])) {
  3196. $page = $this->input->post('page', true);
  3197. $perpage = $this->input->post('perpage', true);
  3198. $timetk = $this->input->post('timetk', true);
  3199. $timetj = $this->input->post('timetj', true);
  3200. $label = $this->input->post('label', true);
  3201. $oldlabel = $this->input->post('oldlabel', true);
  3202. $timetk = strtotime($timetk);
  3203. $timetj = strtotime($timetj);
  3204. $where = "state=10 ";
  3205. if ($timetk && $timetj) {
  3206. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3207. }
  3208. if ($label) {
  3209. $where .= " and label = '$label'";
  3210. }
  3211. if ($oldlabel) {
  3212. $where .= " and oldlabel = '$oldlabel'";
  3213. }
  3214. //数据排序
  3215. $order_str = "time asc";
  3216. if (empty($page)) {
  3217. $start = 0;
  3218. $perpage = 1;
  3219. } else {
  3220. $start = ($page - 1) * $perpage;
  3221. }
  3222. //取得信息列表
  3223. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3224. foreach ($info_list as $key => $value) {
  3225. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3226. }
  3227. $total = $this->whlabel->find_count($where);
  3228. $pagenum = ceil($total / $perpage);
  3229. $over = $total - ($start + $perpage);
  3230. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3231. echo json_encode($rows);
  3232. exit;
  3233. }
  3234. $this->_Template('whlabel_change', $this->data);
  3235. }
  3236. //产品标签
  3237. public function _cpbqdc()
  3238. {
  3239. if (isset($_GET['excel'])) {
  3240. $where = "1=1";
  3241. //数据排序
  3242. $order_str = "id desc";
  3243. if (empty($page)) {
  3244. $start = 0;
  3245. $perpage = 1;
  3246. } else {
  3247. $start = ($page - 1) * $perpage;
  3248. }
  3249. $warehouse = $this->input->get('warehouse', true);
  3250. $state = $this->input->get('state', true);
  3251. $timetk = $this->input->get('timetkk', true);
  3252. $timetj = $this->input->get('timetjj', true);
  3253. $timetk = strtotime($timetk);
  3254. $timetj = strtotime($timetj);
  3255. if ($warehouse) {
  3256. $where .= " and warehouse = '$warehouse'";
  3257. }
  3258. if ($state || $state == 0) {
  3259. $where .= " and state = '$state'";
  3260. }
  3261. if ($timetk && $timetj) {
  3262. $where .= " and time > '$timetk' and time < '$timetj'";
  3263. }
  3264. //取得信息列表
  3265. $info_list = $this->whlabel->find_all($where, '*');
  3266. $rows = array();
  3267. $list = array();
  3268. foreach ($info_list as $key => $value) {
  3269. $rows[$value['time']] = $value; //所有数据sku
  3270. }
  3271. foreach ($rows as $value) {
  3272. $warehouse = $this->warehouse->read($value['warehouse']);
  3273. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3274. $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);
  3275. }
  3276. $title = "产品标签统计表";
  3277. $titlename = "<table border=1>
  3278. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3279. <tr align='center'>
  3280. <td>仓库</td>
  3281. <td>SKU</td>
  3282. <td>产品</td>
  3283. <td>入库时间</td>
  3284. <td>操作时间</td>
  3285. <td>备注</td>
  3286. <td>数量</td>
  3287. </tr>
  3288. </table>";
  3289. $filename = $title . ".xls";
  3290. $tail = "";
  3291. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3292. }
  3293. }
  3294. //进销存导出
  3295. public function _exceljxc()
  3296. {
  3297. $classid = $this->classid->sku();
  3298. $pm = $classid;
  3299. $typeclass = array();
  3300. $tc = $this->typeclass->find_all();
  3301. foreach ($tc as $v) {
  3302. $typeclass[$v['id']] = $v;
  3303. }
  3304. $prc = array();
  3305. $purchase = $this->purchase->find_all();
  3306. foreach ($purchase as $k => $v) {
  3307. $prc[$v['id']] = $v['title'];
  3308. }
  3309. if (isset($_GET['excel'])) {
  3310. $where = "sku != 'Preset'";
  3311. //数据排序
  3312. $order_str = "id desc";
  3313. if (empty($page)) {
  3314. $start = 0;
  3315. $perpage = 1;
  3316. } else {
  3317. $start = ($page - 1) * $perpage;
  3318. }
  3319. $category = $this->input->get('category', true);
  3320. $warehouse = $this->input->get('warehouse', true);
  3321. $excelid = $this->input->get('sid', true);
  3322. if ($category) {
  3323. $where .= " and features like '%-$category-%'";
  3324. }
  3325. if ($warehouse) {
  3326. $where .= " and warehouse = '$warehouse'";
  3327. }
  3328. $xzid = '';
  3329. if ($excelid) {
  3330. $excelid = explode(',', trim($excelid, ','));
  3331. foreach ($excelid as $key => $value) {
  3332. $xzid .= " id = " . $value . " or";
  3333. }
  3334. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3335. }
  3336. //取得信息列表
  3337. /**
  3338. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3339. $rows = array();$list = array();
  3340. foreach ($info_list as $key=>$value)
  3341. {
  3342. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3343. }
  3344. **/
  3345. $wt = array();
  3346. $whlabel_type = $this->whlabel_type->find_all();
  3347. foreach ($whlabel_type as $v) {
  3348. $wt[$v['id']] = $v['title'];
  3349. }
  3350. $wh = array();
  3351. $w = $this->warehouse->find_all('1=1', 'id,title');
  3352. foreach ($w as $v) {
  3353. $wh[$v['id']] = $v['title'];
  3354. }
  3355. $list = array();
  3356. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3357. foreach ($rows as $key => $value) {
  3358. if (isset($wt[$value['type']])) {
  3359. $rows[$key]['type'] = $wt[$value['type']];
  3360. } else {
  3361. $rows[$key]['type'] = '未设置';
  3362. }
  3363. $bm = '03';
  3364. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3365. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3366. $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');
  3367. $details = array();
  3368. $cpid = array();
  3369. $cpbz = array();
  3370. $c = 0;
  3371. $g = 0;
  3372. $x = 0;
  3373. $t = 0;
  3374. $s = 0;
  3375. $q = 0;
  3376. foreach ($sd as $k => $v) {
  3377. if ($v['state'] == 0) {
  3378. $c++;
  3379. if ($v['cpid'] != 0) {
  3380. $cpid[$v['cpid']] = $v['cpid'];
  3381. }
  3382. if ($v['cpbz'] != '') {
  3383. $cpbz[$v['cpbz']] = $v['cpbz'];
  3384. }
  3385. }
  3386. if ($v['state'] != 9) {
  3387. $g++;
  3388. }
  3389. if ($v['state'] == 1) {
  3390. $x++;
  3391. }
  3392. if ($v['state'] == 2) {
  3393. $t++;
  3394. }
  3395. if ($v['state'] == 8) {
  3396. $s++;
  3397. }
  3398. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3399. $q++;
  3400. }
  3401. $details[$v['details']] = $v['details'];
  3402. }
  3403. $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'] . '"');
  3404. $rows[$key]['details'] = implode("、", $details);
  3405. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3406. $number = $value['number'];
  3407. $ftime = time() - 15 * 24 * 3600;
  3408. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3409. $rows[$key]['number'] = $g;
  3410. $rows[$key]['c'] = $c;
  3411. $rows[$key]['x'] = $x;
  3412. $rows[$key]['t'] = $t;
  3413. $rows[$key]['s'] = $s;
  3414. $rows[$key]['q'] = $q;
  3415. $rows[$key]['z'] = $z;
  3416. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3417. $features = explode('-', trim($features, '-'));
  3418. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3419. // $pm = $classid;
  3420. // $jm = $classid;
  3421. // foreach($features as $k=>$v)
  3422. // {
  3423. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3424. // {
  3425. // if($typeclass[$v]['bm'] != '')
  3426. // {
  3427. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3428. // }
  3429. // }
  3430. // if($v != 0)
  3431. // {
  3432. // if(!isset($typeclass[$v]))
  3433. // {
  3434. // continue;
  3435. // }
  3436. // if(isset($pm[$typeclass[$v]['classid']]))
  3437. // {
  3438. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3439. // {
  3440. // $tz = explode('|',$typeclass[$v]['zh']);
  3441. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3442. // }
  3443. // else
  3444. // {
  3445. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3446. // }
  3447. // }
  3448. // if(isset($jm[$typeclass[$v]['classid']]))
  3449. // {
  3450. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3451. // }
  3452. // }
  3453. // }
  3454. // $jm = array_filter($jm);
  3455. // $rows[$key]['bs'] = implode("-",$jm);
  3456. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3457. // $zh = implode(" ",$pm);
  3458. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3459. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3460. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3461. // $rows[$key]['features'] = $zh;
  3462. }
  3463. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3464. $final_list = [];
  3465. foreach ($list as $k => $v) {
  3466. if (empty($v['sku'])) {
  3467. continue;
  3468. }
  3469. $final_list[] = [
  3470. "warehouse" => $v["warehouse"],
  3471. "purchase" => $v["purchase"],
  3472. "details" => $v["details"],
  3473. "cpid" => $v["cpid"],
  3474. "dbcontent" => $v["dbcontent"],
  3475. "sku" => $v["sku"],
  3476. "cs" => $v["bm"],
  3477. "bs" => $v["jm"],
  3478. "title" => $v["title"],
  3479. "features" => $v["pm"],
  3480. "cpbz" => $v["cpbz"],
  3481. "sm" => $v["sm"],
  3482. "type" => $v["type"],
  3483. "number" => $v["number"],
  3484. "c" => $v["c"],
  3485. "x" => $v["x"],
  3486. "t" => $v["t"],
  3487. "s" => $v["s"],
  3488. "q" => $v["q"],
  3489. "z" => $v["z"],
  3490. "weight" => $v['weight'],
  3491. ];
  3492. }
  3493. $title = "总进销存统计表";
  3494. $titlename = "<table border=1>
  3495. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3496. <tr align='center'>
  3497. <td>仓库</td>
  3498. <td>供应商</td>
  3499. <td>位置</td>
  3500. <td>库存编码</td>
  3501. <td>类目</td>
  3502. <td>SKU</td>
  3503. <td>用友编码</td>
  3504. <td>用友料号</td>
  3505. <td>商品名称</td>
  3506. <td>商品中文</td>
  3507. <td>产品备注</td>
  3508. <td>说明</td>
  3509. <td>类型</td>
  3510. <td>入库总量</td>
  3511. <td>库存数量</td>
  3512. <td>销售数量</td>
  3513. <td>退货数量</td>
  3514. <td>删除数量</td>
  3515. <td>其它操作</td>
  3516. <td>占单数量</td>
  3517. <td>重量(g)</td>
  3518. </tr>
  3519. </table>";
  3520. $filename = $title . ".xls";
  3521. $tail = "";
  3522. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3523. }
  3524. }
  3525. //入库导出
  3526. public function _excelr()
  3527. {
  3528. if (isset($_GET['excel'])) {
  3529. $category = $this->input->get('category', true);
  3530. $size = $this->input->get('size', true);
  3531. $grade = $this->input->get('grade', true);
  3532. $color = $this->input->get('color', true);
  3533. $lowe = $this->input->get('lowe', true);
  3534. $sku = $this->input->get('sku', true);
  3535. $warehouse = $this->input->get('warehouse', true);
  3536. $purchase = $this->input->get('purchase', true);
  3537. $ktime = $this->input->get('ktime', true);
  3538. $jtime = $this->input->get('jtime', true);
  3539. $ktime = strtotime($ktime);
  3540. $jtime = strtotime($jtime);
  3541. $where = "1=1";
  3542. $gj = "";
  3543. $ck = "";
  3544. if ($category) {
  3545. $where .= " and features like '%-$category-%'";
  3546. }
  3547. if ($size) {
  3548. $where .= " and features like '%-$size-%'";
  3549. }
  3550. if ($grade) {
  3551. $where .= " and features like '%-$grade-%'";
  3552. }
  3553. if ($color) {
  3554. $where .= " and features like '%-$color-%'";
  3555. }
  3556. if ($lowe) {
  3557. $where .= " and features like '%-$lowe-%'";
  3558. }
  3559. if ($warehouse) {
  3560. $where .= " and warehouse = '$warehouse'";
  3561. }
  3562. if ($purchase) {
  3563. $where .= " and purchase = '$purchase'";
  3564. }
  3565. if ($sku) {
  3566. $where .= " and sku = '$sku'";
  3567. }
  3568. if ($ktime && $jtime) {
  3569. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3570. }
  3571. //数据排序
  3572. $order_str = "id desc";
  3573. if (empty($page)) {
  3574. $start = 0;
  3575. $perpage = 1;
  3576. } else {
  3577. $start = ($page - 1) * $perpage;
  3578. }
  3579. $list = array();
  3580. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3581. foreach ($rows as $value) {
  3582. $ck = $this->warehouse->read($value['warehouse']);
  3583. $warehouse = $ck['title'];
  3584. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3585. $retreatwarehouse = $tkck['title'];
  3586. $gy = $this->purchase->read($value['purchase']);
  3587. $purchase = $gy['title'];
  3588. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3589. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3590. }
  3591. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3592. $titlename = "<table border=1>
  3593. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3594. <tr align='center'>
  3595. <td>仓库</td>
  3596. <td>SKU</td>
  3597. <td>产品</td>
  3598. <td>时间</td>
  3599. <td>数量</td>
  3600. </tr>
  3601. </table>";
  3602. $filename = $title . ".xls";
  3603. $tail = "";
  3604. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3605. }
  3606. }
  3607. //出库、退库导出
  3608. public function _excelct()
  3609. {
  3610. $classid = $this->classid->sku();
  3611. $pm = $classid;
  3612. $typeclass = array();
  3613. $tc = $this->typeclass->find_all();
  3614. foreach ($tc as $v) {
  3615. $typeclass[$v['id']] = $v;
  3616. }
  3617. $prc = array();
  3618. $purchase = $this->purchase->find_all();
  3619. foreach ($purchase as $k => $v) {
  3620. $prc[$v['id']] = $v['title'];
  3621. }
  3622. if (isset($_GET['excel'])) {
  3623. $wh = array();
  3624. $w = $this->warehouse->find_all('1=1', 'id,title');
  3625. foreach ($w as $v) {
  3626. $wh[$v['id']] = $v['title'];
  3627. }
  3628. $type = $this->input->get('excel', true);
  3629. $category = $this->input->get('category', true);
  3630. $size = $this->input->get('size', true);
  3631. $grade = $this->input->get('grade', true);
  3632. $color = $this->input->get('color', true);
  3633. $lowe = $this->input->get('lowe', true);
  3634. $sku = $this->input->get('sku', true);
  3635. $warehouse = $this->input->get('warehouse', true);
  3636. $lacetype = $this->input->get('lacetype', true);
  3637. $lacecolor = $this->input->get('lacecolor', true);
  3638. $density = $this->input->get('density', true);
  3639. $haircap = $this->input->get('haircap', true);
  3640. $purchase = $this->input->get('purchase', true);
  3641. $title = $this->input->get('title', true);
  3642. $state = $this->input->get('state', true);
  3643. $sid = $this->input->get('sid', true);
  3644. $ktime = $this->input->get('ktime', true);
  3645. $jtime = $this->input->get('jtime', true);
  3646. $ktime = strtotime($ktime);
  3647. $jtime = strtotime($jtime);
  3648. $where = "1=1";
  3649. $gj = "";
  3650. $ck = "";
  3651. if ($category) {
  3652. $where .= " and features like '%-$category-%'";
  3653. }
  3654. if ($size) {
  3655. $where .= " and features like '%-$size-%'";
  3656. }
  3657. if ($grade) {
  3658. $where .= " and features like '%-$grade-%'";
  3659. }
  3660. if ($color) {
  3661. $where .= " and features like '%-$color-%'";
  3662. }
  3663. if ($lowe) {
  3664. $where .= " and features like '%-$lowe-%'";
  3665. }
  3666. if ($warehouse) {
  3667. $where .= " and warehouse = '$warehouse'";
  3668. }
  3669. if ($purchase) {
  3670. $where .= " and purchase = '$purchase'";
  3671. }
  3672. if ($state) {
  3673. $where .= " and state = '$state'";
  3674. }
  3675. if ($lacetype) {
  3676. $where .= " and features like '%-$lacetype-%'";
  3677. }
  3678. if ($lacecolor) {
  3679. $where .= " and features like '%-$lacecolor-%'";
  3680. }
  3681. if ($density) {
  3682. $where .= " and features like '%-$density-%'";
  3683. }
  3684. if ($haircap) {
  3685. $where .= " and features like '%-$haircap-%'";
  3686. }
  3687. if ($title) {
  3688. $title = trim($title, ' ');
  3689. $title = trim($title, ' ');
  3690. $where .= " and title like '%$title%'";
  3691. }
  3692. if ($sku) {
  3693. $sku = trim($sku, ' ');
  3694. $sku = trim($sku, ' ');
  3695. $where .= " and sku like '%$sku%'";
  3696. }
  3697. if ($ktime && $jtime) {
  3698. if ($type == 1) {
  3699. $tl = '出库';
  3700. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3701. } else if ($type == 2) {
  3702. $tl = '退库';
  3703. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3704. } else if ($type == 3) {
  3705. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3706. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3707. } else if ($type == 4) {
  3708. $tl = '出库+零售';
  3709. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3710. } else if ($type == 5) {
  3711. $tl = '零售';
  3712. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3713. }
  3714. }
  3715. $sidwhere = '';
  3716. if ($sid) {
  3717. $sd = "";
  3718. $s = explode(',', trim($sid, ','));
  3719. foreach ($s as $value) {
  3720. $sd .= " id = " . $value . " or";
  3721. }
  3722. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3723. }
  3724. //数据排序
  3725. $order_str = "time desc";
  3726. if (empty($page)) {
  3727. $start = 0;
  3728. $perpage = 1;
  3729. } else {
  3730. $start = ($page - 1) * $perpage;
  3731. }
  3732. //取得信息列表
  3733. if ($type != 3 && $type != 5) {
  3734. if ($type == 1 || $type == 4) {
  3735. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3736. foreach ($info_list as $key => $value) {
  3737. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3738. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3739. $warehouse = $this->warehouse->read($value['warehouse']);
  3740. $info_list[$key]['warehouse'] = $warehouse['title'];
  3741. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3742. $features = explode('-', trim($features, '-'));
  3743. $pm = $classid;
  3744. foreach ($features as $k => $v) {
  3745. if ($v != 0) {
  3746. if (!isset($typeclass[$v])) {
  3747. continue;
  3748. }
  3749. if (isset($pm[$typeclass[$v]['classid']])) {
  3750. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3751. $tz = explode('|', $typeclass[$v]['zh']);
  3752. $pm[$typeclass[$v]['classid']] = $tz[0];
  3753. } else {
  3754. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3755. }
  3756. }
  3757. }
  3758. }
  3759. $zh = implode(" ", $pm);
  3760. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3761. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3762. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3763. $info_list[$key]['features'] = $zh;
  3764. }
  3765. $final_list = [];
  3766. foreach($info_list as $k=>$v){
  3767. $number = "";
  3768. if(!empty($v['orderinfo'])){
  3769. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3770. if(!empty($tmp_info['number'])){
  3771. $number = $tmp_info['number'];
  3772. }
  3773. }
  3774. $final_list[] = [
  3775. 'warehouse'=>$v['warehouse'],
  3776. 'purchase'=>$v['purchase'],
  3777. 'sku'=>$v['sku'],
  3778. 'title'=>$v['title'],
  3779. 'features'=>$v['features'],
  3780. 'label'=>$v['label'],
  3781. 'orderinfo'=>$v['orderinfo'],
  3782. 'number'=>$number,
  3783. 'waybill'=>$v['waybill'],
  3784. 'outk'=>$v['outk'],
  3785. ];
  3786. }
  3787. } else {
  3788. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3789. foreach ($info_list as $key => $value) {
  3790. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3791. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3792. $warehouse = $this->warehouse->read($value['warehouse']);
  3793. $info_list[$key]['warehouse'] = $warehouse['title'];
  3794. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3795. $features = explode('-', trim($features, '-'));
  3796. $pm = $classid;
  3797. foreach ($features as $k => $v) {
  3798. if ($v != 0) {
  3799. if (!isset($typeclass[$v])) {
  3800. continue;
  3801. }
  3802. if (isset($pm[$typeclass[$v]['classid']])) {
  3803. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3804. $tz = explode('|', $typeclass[$v]['zh']);
  3805. $pm[$typeclass[$v]['classid']] = $tz[0];
  3806. } else {
  3807. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3808. }
  3809. }
  3810. }
  3811. }
  3812. $zh = implode(" ", $pm);
  3813. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3814. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3815. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3816. $info_list[$key]['features'] = $zh;
  3817. }
  3818. $final_list = [];
  3819. foreach($info_list as $k=>$v){
  3820. $number = "";
  3821. if(!empty($v['orderinfo'])){
  3822. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3823. if(!empty($tmp_info['number'])){
  3824. $number = $tmp_info['number'];
  3825. }
  3826. }
  3827. $final_list[] = [
  3828. 'warehouse'=>$v['warehouse'],
  3829. 'purchase'=>$v['purchase'],
  3830. 'sku'=>$v['sku'],
  3831. 'title'=>$v['title'],
  3832. 'features'=>$v['features'],
  3833. 'label'=>$v['label'],
  3834. 'orderinfo'=>$v['orderinfo'],
  3835. 'number'=>$number,
  3836. 'waybill'=>$v['waybill'],
  3837. 'retreat'=>$v['retreat'],
  3838. ];
  3839. }
  3840. }
  3841. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3842. $titlename = "<table border=1>
  3843. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3844. <tr align='center'>
  3845. <td>仓库</td>
  3846. <td>供应商</td>
  3847. <td>SKU</td>
  3848. <td>商品名称</td>
  3849. <td>商品中文</td>
  3850. <td>标签</td>
  3851. <td>订单号</td>
  3852. <td>订单编码</td>
  3853. <td>运单号</td>
  3854. <td>" . $tl . "时间(中国时间)</td>
  3855. </tr>
  3856. </table>";
  3857. $filename = $title . ".xls";
  3858. $tail = "";
  3859. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3860. } else if ($type == 5) {
  3861. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3862. foreach ($info_list as $key => $value) {
  3863. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3864. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3865. $warehouse = $this->warehouse->read($value['warehouse']);
  3866. $info_list[$key]['warehouse'] = $warehouse['title'];
  3867. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3868. $features = explode('-', trim($features, '-'));
  3869. $pm = $classid;
  3870. foreach ($features as $k => $v) {
  3871. if ($v != 0) {
  3872. if (!isset($typeclass[$v])) {
  3873. continue;
  3874. }
  3875. if (isset($pm[$typeclass[$v]['classid']])) {
  3876. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3877. $tz = explode('|', $typeclass[$v]['zh']);
  3878. $pm[$typeclass[$v]['classid']] = $tz[0];
  3879. } else {
  3880. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3881. }
  3882. }
  3883. }
  3884. }
  3885. $zh = implode(" ", $pm);
  3886. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3887. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3888. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3889. $info_list[$key]['features'] = $zh;
  3890. }
  3891. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3892. $titlename = "<table border=1>
  3893. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3894. <tr align='center'>
  3895. <td>仓库</td>
  3896. <td>供应商</td>
  3897. <td>SKU</td>
  3898. <td>商品名称</td>
  3899. <td>商品中文</td>
  3900. <td>标签</td>
  3901. <td>" . $tl . "时间(中国时间)</td>
  3902. </tr>
  3903. </table>";
  3904. $filename = $title . ".xls";
  3905. $tail = "";
  3906. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3907. } else {
  3908. /**
  3909. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3910. $rows = array();$list = array();
  3911. foreach ($info_list as $key=>$value)
  3912. {
  3913. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3914. }
  3915. **/
  3916. $wh = array();
  3917. $w = $this->warehouse->find_all('1=1', 'id,title');
  3918. foreach ($w as $v) {
  3919. $wh[$v['id']] = $v['title'];
  3920. }
  3921. $wt = array();
  3922. $whlabel_type = $this->whlabel_type->find_all();
  3923. foreach ($whlabel_type as $v) {
  3924. $wt[$v['id']] = $v['title'];
  3925. }
  3926. $classid = $this->classid->sku();
  3927. $list = array();
  3928. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3929. foreach ($rows as $key => $value) {
  3930. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3931. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3932. $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');
  3933. $details = array();
  3934. $cpid = array();
  3935. $cpbz = array();
  3936. $c = 0;
  3937. $g = 0;
  3938. $x = 0;
  3939. $t = 0;
  3940. $s = 0;
  3941. $q = 0;
  3942. foreach ($sd as $k => $v) {
  3943. if ($v['state'] == 0) {
  3944. $c++;
  3945. }
  3946. if ($v['state'] != 9) {
  3947. $g++;
  3948. }
  3949. if ($v['outk'] > 1) {
  3950. $x++;
  3951. }
  3952. if ($v['retreat'] > 0) {
  3953. $t++;
  3954. }
  3955. if ($v['state'] == 8) {
  3956. $s++;
  3957. }
  3958. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3959. $q++;
  3960. }
  3961. $details[$v['details']] = $v['details'];
  3962. if ($v['cpid'] != 0) {
  3963. $cpid[$v['cpid']] = $v['cpid'];
  3964. }
  3965. if ($v['cpbz'] != '') {
  3966. $cpbz[$v['cpbz']] = $v['cpbz'];
  3967. }
  3968. }
  3969. if (isset($wt[$value['type']])) {
  3970. $rows[$key]['type'] = $wt[$value['type']];
  3971. } else {
  3972. $rows[$key]['type'] = '未设置';
  3973. }
  3974. $rows[$key]['details'] = implode("、", $details);
  3975. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3976. $ftime = time() - 15 * 24 * 3600;
  3977. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3978. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3979. $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);
  3980. $rows[$key]['c'] = $c;
  3981. $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);
  3982. $rows[$key]['t'] = $t;
  3983. $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'] . '"');
  3984. $rows[$key]['z'] = $z;
  3985. // $jm = $classid;
  3986. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3987. $features = explode('-', trim($features, '-'));
  3988. // $pm = $classid;
  3989. // foreach ($features as $k => $v) {
  3990. // if ($v != 0) {
  3991. // if (!isset($typeclass[$v])) {
  3992. // continue;
  3993. // }
  3994. // if (isset($pm[$typeclass[$v]['classid']])) {
  3995. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3996. // $tz = explode('|', $typeclass[$v]['zh']);
  3997. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3998. // } else {
  3999. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4000. // }
  4001. // if (isset($jm[$typeclass[$v]['classid']])) {
  4002. // if ($typeclass[$v]['jm']) {
  4003. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4004. // }
  4005. // }
  4006. // }
  4007. // }
  4008. // }
  4009. // $zh = implode(" ", $pm);
  4010. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4011. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4012. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4013. // $rows[$key]['features'] = $zh;
  4014. // $jm = array_filter($jm); //去除空值
  4015. // $jm = implode("-", $jm);
  4016. // $rows[$key]['jm'] = $jm;
  4017. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4018. }
  4019. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4020. // echo "<pre>";
  4021. // print_r($tmp_list);
  4022. // die;
  4023. $final_list =[];
  4024. foreach($tmp_list as $k=>$v){
  4025. $final_list[] = [
  4026. "warehouse"=>$v['warehouse'],
  4027. "purchase"=>$v['purchase'],
  4028. "details"=>$v['details'],
  4029. "cpid"=>$v['cpid'],
  4030. "sku"=>$v['sku'],
  4031. "title"=>$v['title'],
  4032. "features"=>$v['pm'],
  4033. "cpbz"=>$v['cpbz'],
  4034. "sm"=>$v['sm'],
  4035. "type"=>$v['type'],
  4036. "g"=>$v["g"],
  4037. "c"=>$v["c"],
  4038. "x"=>$v["x"],
  4039. "t"=>$v["t"],
  4040. "z"=>$v["z"],
  4041. "jm"=>$v["jm"],
  4042. "weight"=>$v["weight"],
  4043. "asd"=>$v["asd"],
  4044. ];
  4045. }
  4046. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4047. $titlename = "<table border=1>
  4048. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4049. <tr align='center'>
  4050. <td>仓库</td>
  4051. <td>供应商</td>
  4052. <td>位置</td>
  4053. <td>库存编码</td>
  4054. <td>SKU</td>
  4055. <td>商品名称</td>
  4056. <td>商品中文</td>
  4057. <td>产品备注</td>
  4058. <td>说明</td>
  4059. <td>类型</td>
  4060. <td>入库总量</td>
  4061. <td>库存数量</td>
  4062. <td>销售数量</td>
  4063. <td>退货数量</td>
  4064. <td>占单数量</td>
  4065. <td>料号</td>
  4066. <td>重量</td>
  4067. <td>类目</td>
  4068. </tr>
  4069. </table>";
  4070. $filename = $title . ".xls";
  4071. $tail = "";
  4072. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4073. }
  4074. }
  4075. }
  4076. //出库+入库数据整合
  4077. public function _excelcr()
  4078. {
  4079. if (isset($_GET['excel'])) {
  4080. $type = $this->input->get('excel', true);
  4081. $category = $this->input->get('category', true);
  4082. $size = $this->input->get('size', true);
  4083. $grade = $this->input->get('grade', true);
  4084. $color = $this->input->get('color', true);
  4085. $lowe = $this->input->get('lowe', true);
  4086. $sku = $this->input->get('sku', true);
  4087. $warehouse = $this->input->get('warehouse', true);
  4088. $purchase = $this->input->get('purchase', true);
  4089. $state = $this->input->get('state', true);
  4090. $sid = $this->input->get('sid', true);
  4091. $ktime = $this->input->get('ktime', true);
  4092. $jtime = $this->input->get('jtime', true);
  4093. $ktime = strtotime($ktime);
  4094. $jtime = strtotime($jtime);
  4095. $where = "1=1";
  4096. $gj = "";
  4097. $ck = "";
  4098. if ($category) {
  4099. $where .= " and features like '%-$category-%'";
  4100. }
  4101. if ($size) {
  4102. $where .= " and features like '%-$size-%'";
  4103. }
  4104. if ($grade) {
  4105. $where .= " and features like '%-$grade-%'";
  4106. }
  4107. if ($color) {
  4108. $where .= " and features like '%-$color-%'";
  4109. }
  4110. if ($lowe) {
  4111. $where .= " and features like '%-$lowe-%'";
  4112. }
  4113. if ($warehouse) {
  4114. $where .= " and warehouse = '$warehouse'";
  4115. }
  4116. if ($purchase) {
  4117. $where .= " and purchase = '$purchase'";
  4118. }
  4119. if ($state) {
  4120. $where .= " and state = '$state'";
  4121. }
  4122. if ($sku) {
  4123. $where .= " and sku like '%$sku%'";
  4124. }
  4125. if ($ktime && $jtime) {
  4126. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4127. }
  4128. $sidwhere = '';
  4129. if ($sid) {
  4130. $sd = "";
  4131. $s = explode(',', trim($sid, ','));
  4132. foreach ($s as $value) {
  4133. $sd .= " id = " . $value . " or";
  4134. }
  4135. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4136. }
  4137. //取得信息列表
  4138. $timeread = $ktime;
  4139. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4140. $timelist = array();
  4141. for ($i = 0; $i < $timenum; $i++) {
  4142. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4143. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4144. }
  4145. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4146. //echo "<pre>";
  4147. //print_r($info_list);
  4148. //exit();
  4149. $rows = array();
  4150. $list = array();
  4151. foreach ($info_list as $key => $value) {
  4152. $thistime = $timelist;
  4153. if (isset($rows[strtolower($value['sku'])])) {
  4154. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4155. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4156. }
  4157. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4158. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4159. }
  4160. } else {
  4161. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4162. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4163. }
  4164. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4165. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4166. }
  4167. $rows[strtolower($value['sku'])] = $thistime;
  4168. }
  4169. }
  4170. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4171. <head>
  4172. <!--[if gte mso 9]><xml>
  4173. <x:ExcelWorkbook>
  4174. <x:ExcelWorksheets>
  4175. <x:ExcelWorksheet>
  4176. <x:Name>EXCEL</x:Name>
  4177. <x:WorksheetOptions>
  4178. <x:Print>
  4179. <x:ValidPrinterInfo />
  4180. </x:Print>
  4181. </x:WorksheetOptions>
  4182. </x:ExcelWorksheet>
  4183. </x:ExcelWorksheets>
  4184. </x:ExcelWorkbook>
  4185. </xml>
  4186. <![endif]-->
  4187. </head><body>";
  4188. $str .= "<table border=1><tr><td>SKU</td>";
  4189. foreach ($timelist as $k => $v) {
  4190. $str .= "<td>" . $k . "出库</td>";
  4191. $str .= "<td>" . $k . "入库</td>";
  4192. }
  4193. $str .= "</tr></table>";
  4194. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4195. foreach ($rows as $key => $val) {
  4196. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4197. foreach ($val as $k => $v) {
  4198. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4199. if ($val[$k]['r'] > 0) {
  4200. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4201. } else {
  4202. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4203. }
  4204. }
  4205. $str .= "</tr>";
  4206. }
  4207. $str .= "</table>";
  4208. $str .= "</body></html>";
  4209. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4210. header("Content-type: application/octet-stream");
  4211. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4212. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4213. header("Pragma: no-cache");
  4214. header("Expires: 0");
  4215. exit($str);
  4216. }
  4217. }
  4218. //数量调整模板导出
  4219. public function _presetout()
  4220. {
  4221. if (isset($_GET['excel'])) {
  4222. $where = "sku != 'Preset' and purchase != 0";
  4223. //数据排序
  4224. $order_str = "id desc";
  4225. if (empty($page)) {
  4226. $start = 0;
  4227. $perpage = 1;
  4228. } else {
  4229. $start = ($page - 1) * $perpage;
  4230. }
  4231. //取得信息列表
  4232. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4233. $rows = array();
  4234. $list = array();
  4235. foreach ($info_list as $value) {
  4236. $warehouse = $this->warehouse->read($value['warehouse']);
  4237. $number = $value['number'];
  4238. $ftime = time() - 15 * 24 * 3600;
  4239. $purchase = $this->purchase->read($value['purchase']);
  4240. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4241. }
  4242. $title = "库存模板";
  4243. $titlename = "<table border=1>
  4244. <tr align='center'>
  4245. <td>仓库</td>
  4246. <td>供应商编码</td>
  4247. <td>SKU</td>
  4248. <td>增减数量(正数或负数)</td>
  4249. <td>增减备注</td>
  4250. <td>扣减方式:0减少库存1删除库存</td>
  4251. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4252. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4253. </tr>
  4254. </table>";
  4255. $filename = $title . ".xls";
  4256. $tail = "";
  4257. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4258. }
  4259. }
  4260. //数量调整模板导入
  4261. public function _presetedit()
  4262. {
  4263. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4264. $config['upload_path'] = '.' . $dir;
  4265. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4266. $config['allowed_types'] = 'xls|xlsx|csv';
  4267. $config['max_size'] = 10240;
  4268. $this->load->library('upload', $config);
  4269. $this->upload->initialize($config);
  4270. if ($this->upload->do_upload('userfile')) {
  4271. $full_path = $dir . $this->upload->data('file_name');
  4272. $fileName = '.' . $full_path;
  4273. if (!file_exists($fileName)) {
  4274. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4275. exit;
  4276. } else {
  4277. require_once "./data/excel/PHPExcel/IOFactory.php";
  4278. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4279. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4280. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4281. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4282. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4283. ++$column; //如果列数大于26行
  4284. $list = array();
  4285. for ($i = 2; $i <= $row; $i++) // 行数循环
  4286. {
  4287. $data = array();
  4288. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4289. {
  4290. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4291. }
  4292. $list[] = $data;
  4293. }
  4294. }
  4295. $i = 0;
  4296. $j = 0;
  4297. $ed = array();
  4298. foreach ($list as $key => $value) {
  4299. $time = time();
  4300. if ($value['0'] == "") {
  4301. continue;
  4302. }
  4303. $warehouse = $this->warehouse->get_title($value['0']);
  4304. $purchase = $this->purchase->get_bm($value['1']);
  4305. $sku = $value['2'];
  4306. $num = $value['3']; //调整数量
  4307. $text = $value['4']; //扣减说明
  4308. $type = $value['5']; //调整方式0扣减1删除
  4309. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4310. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4311. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4312. if (!$purchase) //如果没有这个SKU
  4313. {
  4314. $ed[] = array($purchase . '-不存在此供应商编码');
  4315. $j++;
  4316. continue;
  4317. }
  4318. if (!$d) //如果没有这个SKU
  4319. {
  4320. $ed[] = array($sku . '-库存中不存在此SKU');
  4321. $j++;
  4322. continue;
  4323. }
  4324. if (!isset($warehouse['id'])) {
  4325. $ed[] = array($sku . '-仓库名错误!');
  4326. $j++;
  4327. continue;
  4328. }
  4329. if ($type != '0' && $type != '1') {
  4330. $ed[] = array($sku . '-扣减方式填写错误!');
  4331. $j++;
  4332. continue;
  4333. }
  4334. if ($num < 0) //扣减库存
  4335. {
  4336. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4337. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4338. $j++;
  4339. continue;
  4340. }
  4341. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4342. if (count($data) < abs($num)) {
  4343. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4344. $j++;
  4345. continue;
  4346. }
  4347. if ($type == 0) //如果扣减方式为 扣减库存
  4348. {
  4349. for ($i = 0; $i < abs($num); $i++) {
  4350. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4351. }
  4352. } else if ($type == 1) {
  4353. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4354. if (count($zt) > 0) {
  4355. $ed[] = array($sku . '-有在途库存无法删除!');
  4356. $j++;
  4357. continue;
  4358. }
  4359. for ($i = 0; $i < abs($num); $i++) {
  4360. $this->whlabel->remove($data[$i]['id']);
  4361. }
  4362. }
  4363. } else if ($num > 0) //增加库存
  4364. {
  4365. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4366. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4367. $j++;
  4368. continue;
  4369. }
  4370. $post['sku'] = $d['sku'];
  4371. $post['shop'] = $d['shop'];
  4372. $post['warehouse'] = $warehouse['id'];
  4373. $post['purchase'] = $purchase['id'];
  4374. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4375. $post['state'] = 0;
  4376. $post['title'] = $d['title'];
  4377. $post['number'] = $d['number'];
  4378. $post['features'] = $d['features'];
  4379. $post['enter'] = $time;
  4380. $post['time'] = $time; //操作时间
  4381. $post['rktype'] = $rktype;
  4382. for ($i = 0; $i < $num; $i++) {
  4383. $post['label'] = time() . rand(100, 999) . $i;
  4384. $this->whlabel->insert($post);
  4385. }
  4386. }
  4387. sleep(1); //防止入库时间一样,需要延迟1秒
  4388. }
  4389. if ($j > 0) {
  4390. $tt = date('Ymd', time());
  4391. $title = '库存导入错误信息-' . $tt;
  4392. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4393. $tail = "\n";
  4394. $filename = $title . ".xls";
  4395. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4396. $dir = '/data/excel/' . $time . '/';
  4397. $file_name = 'error_' . $time . rand(1000, 9999);
  4398. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4399. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4400. fwrite($myfile, $ecl);
  4401. fclose($myfile);
  4402. $error = $dir . $file_name . '.xls';
  4403. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4404. exit;
  4405. } else {
  4406. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4407. exit;
  4408. }
  4409. }
  4410. }
  4411. //笛卡儿积
  4412. function cp($ps, $sets, $list)
  4413. {
  4414. $result = array();
  4415. $j = 0;
  4416. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4417. if ($i == 0) {
  4418. $result = $sets[$i];
  4419. }
  4420. $tmp = array();
  4421. foreach ($result as $res) {
  4422. foreach ($sets[$i + 1] as $set) {
  4423. $tmp[] = $res . ',' . $set;
  4424. }
  4425. }
  4426. $result = $tmp;
  4427. }
  4428. $this->db->trans_begin();
  4429. foreach ($result as $v) {
  4430. $post = array();
  4431. $title = "";
  4432. $num = "";
  4433. $data = explode(',', $v);
  4434. for ($i = 0; $i < count($list); $i++) {
  4435. $post[$list[$i]] = $data[$i];
  4436. $typeclass = $this->typeclass->read($data[$i]);
  4437. $title = $title . $typeclass['title'] . " ";
  4438. if ($data[$i] != 0) {
  4439. $num .= $data[$i]; //所有数据ID拼接
  4440. }
  4441. }
  4442. foreach ($ps as $kp => $vp) {
  4443. $post[$kp] = $vp;
  4444. }
  4445. $post['number'] = $num;
  4446. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4447. if ($info_list) {
  4448. $j++;
  4449. } else {
  4450. $skunum = $this->whlabel->find_count();
  4451. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4452. $post['title'] = rtrim($title, ' ');
  4453. $this->whlabel->insert($post);
  4454. }
  4455. }
  4456. if ($this->db->trans_status() === FALSE) {
  4457. $this->db->trans_commit();
  4458. return NULL;
  4459. } else {
  4460. $this->db->trans_commit();
  4461. return $j;
  4462. }
  4463. }
  4464. public function _kj($arg_array)
  4465. {
  4466. if (isset($_POST['sku'])) {
  4467. $time = time();
  4468. $sku = $this->input->post('sku', true);
  4469. $warehouse = $this->input->post('warehouse', true);
  4470. $num = $this->input->post('num', true);
  4471. $text = $this->input->post('text', true);
  4472. $purchase = $this->input->post('purchase', true);
  4473. $cktype = $this->input->post('cktype', true);
  4474. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4475. if ($cktype != 1 && $text == '') {
  4476. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4477. exit;
  4478. }
  4479. if ($num > count($order)) {
  4480. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4481. exit;
  4482. } else {
  4483. for ($i = 0; $i < $num; $i++) {
  4484. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4485. }
  4486. }
  4487. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4488. exit;
  4489. }
  4490. $uid = $this->whlabel->read($arg_array[0]);
  4491. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4492. $this->data['data'] = $uid;
  4493. $this->_Template('whlabel_kj', $this->data);
  4494. }
  4495. public function _summary($arg_array)
  4496. {
  4497. $prc = array();
  4498. $purchase = $this->purchase->find_all();
  4499. foreach ($purchase as $k => $v) {
  4500. $prc[$v['id']] = $v['title'];
  4501. }
  4502. if (isset($_GET['excel'])) {
  4503. $ktime = $this->input->get('ktime', true);
  4504. $jtime = $this->input->get('jtime', true);
  4505. $ktime = strtotime($ktime);
  4506. $jtime = strtotime($jtime);
  4507. $where = "1=1";
  4508. if ($ktime && $jtime) {
  4509. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4510. }
  4511. //数据排序
  4512. $order_str = "time desc";
  4513. if (empty($page)) {
  4514. $start = 0;
  4515. $perpage = 1;
  4516. } else {
  4517. $start = ($page - 1) * $perpage;
  4518. }
  4519. //取得信息列表
  4520. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4521. foreach ($info_list as $key => $value) {
  4522. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4523. $warehouse = $this->warehouse->read($value['warehouse']);
  4524. $info_list[$key]['warehouse'] = $warehouse['title'];
  4525. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4526. $details = array();
  4527. $cpid = array();
  4528. foreach ($x as $k => $v) {
  4529. if ($v['details'] != '') {
  4530. $details[$v['details']] = $v['details'];
  4531. }
  4532. if ($v['cpid'] != 0) {
  4533. $cpid[$v['cpid']] = $v['cpid'];
  4534. }
  4535. }
  4536. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4537. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4538. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4539. $info_list[$key]['s'] = $s;
  4540. $info_list[$key]['x'] = count($x);
  4541. }
  4542. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4543. $titlename = "<table border=1>
  4544. <tr align='center'>
  4545. <td>仓库</td>
  4546. <td>供应商</td>
  4547. <td>出库位置</td>
  4548. <td>出库编码</td>
  4549. <td>SKU</td>
  4550. <td>产品名</td>
  4551. <td>总剩余库存</td>
  4552. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4553. </tr>
  4554. </table>";
  4555. $filename = $title . ".xls";
  4556. $tail = "";
  4557. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4558. }
  4559. }
  4560. //usps发货清单
  4561. public function _manifest()
  4562. {
  4563. if (isset($_POST['manifest'])) {
  4564. $wltext = $this->input->post('wltext', true);
  4565. $time = time() - 16 * 3600;
  4566. $ptime = strtotime(date('Y-m-d', $time));
  4567. $waybill = array();
  4568. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4569. foreach ($fullorder as $v) {
  4570. $waybill[$v['waybill']] = $v['waybill'];
  4571. }
  4572. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4573. foreach ($fullordersmt as $v) {
  4574. $waybill[$v['waybill']] = $v['waybill'];
  4575. }
  4576. $wltext = explode(';', $wltext);
  4577. foreach ($wltext as $v) {
  4578. if (isset($waybill[$v])) {
  4579. unset($waybill[$v]);
  4580. }
  4581. }
  4582. $data = $this->usps->get_manifest($waybill);
  4583. if (isset($data['Description'])) {
  4584. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4585. exit;
  4586. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4587. $bctime = date('Ymd', time());
  4588. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4589. echo json_encode(array('msg' => $pdf, 'success' => true));
  4590. exit;
  4591. } else {
  4592. echo json_encode(array('msg' => $data, 'success' => false));
  4593. exit;
  4594. }
  4595. }
  4596. }
  4597. public function _pdf($pdf, $title, $bctime)
  4598. {
  4599. $pdf_path = './data/pdf/' . $bctime . '/';
  4600. $file_base64 = $pdf;
  4601. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4602. $file_base64 = base64_decode($file_base64);
  4603. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4604. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4605. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4606. }
  4607. /**
  4608. *
  4609. *
  4610. *
  4611. 进销存占单异常索引
  4612. *
  4613. *
  4614. *
  4615. **/
  4616. public function _abnormal()
  4617. {
  4618. $post = $this->input->post(NULL, TRUE);
  4619. if (isset($post['page'])) {
  4620. $page = $this->input->post('page', true);
  4621. $perpage = $this->input->post('perpage', true);
  4622. $sku = $this->input->post('sku', true);
  4623. $where = "1=1";
  4624. //数据排序
  4625. $order_str = "id desc";
  4626. if (empty($page)) {
  4627. $start = 0;
  4628. $perpage = 1;
  4629. } else {
  4630. $start = ($page - 1) * $perpage;
  4631. }
  4632. //取得信息列表
  4633. $info_list = $this->whlabel->find_all($where, '*');
  4634. $rows = array();
  4635. $list = array();
  4636. foreach ($info_list as $key => $value) {
  4637. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4638. }
  4639. foreach ($rows as $value) {
  4640. $warehouse = $this->warehouse->read($value['warehouse']);
  4641. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4642. $number = $value['number'];
  4643. $ftime = time() - 15 * 24 * 3600;
  4644. if ($value['shop'] != '') {
  4645. $shop = $value['shop'];
  4646. $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');
  4647. $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');
  4648. $order = array_merge($orderdlz, $ordersmt);
  4649. $od = 0;
  4650. $a = '';
  4651. $orid = '';
  4652. foreach ($order as $v) {
  4653. $or = explode('|', ltrim($v['whlabel'], '|'));
  4654. for ($i = 0; $i < count($or); $i++) {
  4655. $orod = explode('-', $or[$i]);
  4656. if ($orod[0] == $number) {
  4657. $od += $orod[1];
  4658. }
  4659. }
  4660. $orid .= $v['number'] . '-';
  4661. }
  4662. } else {
  4663. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4664. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4665. $order = array_merge($orderdlz, $ordersmt);
  4666. $od = 0;
  4667. $a = '';
  4668. $orid = '';
  4669. $qt = array();
  4670. foreach ($order as $v) {
  4671. $or = explode('|', ltrim($v['whlabel'], '|'));
  4672. for ($i = 0; $i < count($or); $i++) {
  4673. $orod = explode('-', $or[$i]);
  4674. if ($orod[0] == $number) {
  4675. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4676. if ($czzs > 0) {
  4677. if (isset($qt[$v['shop']])) {
  4678. if ($qt[$v['shop']] < $orod[1]) {
  4679. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4680. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4681. } else {
  4682. $qt[$v['shop']] -= $orod[1];
  4683. }
  4684. } else {
  4685. $qt[$v['shop']] = $czzs;
  4686. }
  4687. } else {
  4688. $od += $orod[1];
  4689. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4690. }
  4691. }
  4692. }
  4693. }
  4694. }
  4695. $z = $od . '(' . $orid . ')'; //查看订单号
  4696. //$z = $od;
  4697. if ($od > $c) {
  4698. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4699. }
  4700. }
  4701. $listdata = array_slice($list, $start, $perpage);
  4702. $total = count($list);
  4703. $pagenum = ceil($total / $perpage);
  4704. $over = $total - ($start + $perpage);
  4705. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4706. echo json_encode($rows);
  4707. exit;
  4708. }
  4709. $this->_Template('whlabel_abnormal', $this->data);
  4710. }
  4711. /**
  4712. *
  4713. *
  4714. *
  4715. 进销存占单异常索引
  4716. *
  4717. *
  4718. *
  4719. **/
  4720. public function _error()
  4721. {
  4722. $post = $this->input->post(NULL, TRUE);
  4723. if (isset($post['page'])) {
  4724. $page = $this->input->post('page', true);
  4725. $perpage = $this->input->post('perpage', true);
  4726. $sku = $this->input->post('sku', true);
  4727. $warehouse = $this->input->post('warehouse', true);
  4728. $ktime = $this->input->post('ktime', true);
  4729. $jtime = $this->input->post('jtime', true);
  4730. $ktime = strtotime($ktime);
  4731. $jtime = strtotime($jtime);
  4732. $where = "sku != 'Preset'";
  4733. $gj = '';
  4734. if ($sku) {
  4735. $where .= " and sku like '%$sku%'";
  4736. } else {
  4737. if ($ktime && $jtime) {
  4738. $gj = " and time > '$ktime' and time < '$jtime'";
  4739. }
  4740. }
  4741. if ($warehouse) {
  4742. $where .= " and warehouse = '$warehouse'";
  4743. }
  4744. //数据排序
  4745. $order_str = "id desc";
  4746. if (empty($page)) {
  4747. $start = 0;
  4748. $perpage = 1;
  4749. } else {
  4750. $start = ($page - 1) * $perpage;
  4751. }
  4752. //取得信息列表
  4753. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4754. $rows = array();
  4755. $list = array();
  4756. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4757. // foreach ($info_list as $value)
  4758. // {
  4759. // $warehouse = $this->warehouse->read($value['warehouse']);
  4760. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4761. // $number = $value['number'];$ftime = time()-15*24*3600;
  4762. // if($c < 1)
  4763. // {
  4764. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4765. // }
  4766. // }
  4767. $warehouse_list = $this->warehouse->find_all();
  4768. $warehouse_list = array_column($warehouse_list, null, 'id');
  4769. foreach ($info_list as $value) {
  4770. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4771. 'title' => "",
  4772. ];
  4773. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4774. $number = $value['number'];
  4775. $ftime = time() - 15 * 24 * 3600;
  4776. if ($c < 1) {
  4777. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4778. }
  4779. }
  4780. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4781. // $query = $this->db->query($sql);
  4782. // $info_list = $query->result_array();
  4783. // $sql_two = "select title,id from crowd_warehouse";
  4784. // $query_two = $this->db->query($sql_two);
  4785. // $warehouse_list = $query_two->result_array();
  4786. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4787. // foreach ($info_list as $value)
  4788. // {
  4789. // if(isset($warehouse_arr[$value['warehouse']])){
  4790. // $warehouse = $warehouse_arr[$value['warehouse']];
  4791. // }else{
  4792. // $warehouse = [
  4793. // 'id'=>0,
  4794. // 'title'=>"异常",
  4795. // ];
  4796. // }
  4797. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4798. // $number = $value['number'];$ftime = time()-15*24*3600;
  4799. // if($c < 1)
  4800. // {
  4801. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4802. // }
  4803. // }
  4804. $listdata = array_slice($list, $start, $perpage);
  4805. $total = count($list);
  4806. $pagenum = ceil($total / $perpage);
  4807. $over = $total - ($start + $perpage);
  4808. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4809. echo json_encode($rows);
  4810. exit;
  4811. }
  4812. if (isset($post['s'])) {
  4813. $id_arr = $this->input->post('s');
  4814. $id_arr = explode(',', trim($id_arr, ','));
  4815. if (!$id_arr) {
  4816. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4817. exit;
  4818. }
  4819. //循环删除记录
  4820. foreach ($id_arr as $v) {
  4821. $dd = $this->whlabel->read($v);
  4822. if (!isset($dd['id'])) {
  4823. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4824. exit;
  4825. }
  4826. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4827. if (isset($zt[0])) {
  4828. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4829. exit;
  4830. }
  4831. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4832. foreach ($deldd as $vv) {
  4833. $this->whlabel->remove($vv['id']);
  4834. }
  4835. }
  4836. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4837. exit;
  4838. }
  4839. $this->_Template('whlabel_error', $this->data);
  4840. }
  4841. public function _errorexcel()
  4842. {
  4843. $post = $this->input->post(NULL, TRUE);
  4844. if (isset($_GET['page'])) {
  4845. $page = $this->input->get('page', true);
  4846. $perpage = $this->input->get('perpage', true);
  4847. $sku = $this->input->get('sku', true);
  4848. $warehouse = $this->input->get('warehouse', true);
  4849. $ktime = $this->input->get('ktime', true);
  4850. $jtime = $this->input->get('jtime', true);
  4851. $ktime = strtotime($ktime);
  4852. $jtime = strtotime($jtime);
  4853. $where = "sku != 'Preset'";
  4854. $gj = '';
  4855. if ($sku) {
  4856. $where .= " and sku like '%$sku%'";
  4857. } else {
  4858. if ($ktime && $jtime) {
  4859. $gj = " and time > '$ktime' and time < '$jtime'";
  4860. }
  4861. }
  4862. if ($warehouse) {
  4863. $where .= " and warehouse = '$warehouse'";
  4864. }
  4865. //数据排序
  4866. $order_str = "id desc";
  4867. if (empty($page)) {
  4868. $start = 0;
  4869. $perpage = 1;
  4870. } else {
  4871. $start = ($page - 1) * $perpage;
  4872. }
  4873. //取得信息列表
  4874. $rows = array();
  4875. $list = array();
  4876. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4877. foreach ($info_list as $value) {
  4878. $warehouse = $this->warehouse->read($value['warehouse']);
  4879. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4880. $number = $value['number'];
  4881. $ftime = time() - 15 * 24 * 3600;
  4882. if ($c < 1) {
  4883. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4884. }
  4885. }
  4886. $title = "0库存汇总";
  4887. $titlename = "<table border=1>
  4888. <tr align='center'>
  4889. <td>仓库</td>
  4890. <td>SKU</td>
  4891. <td>产品</td>
  4892. <td>当前库存</td>
  4893. </tr>
  4894. </table>";
  4895. $filename = $title . ".xls";
  4896. $tail = "";
  4897. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4898. }
  4899. }
  4900. /**
  4901. *
  4902. *
  4903. * 占单
  4904. *
  4905. *
  4906. **/
  4907. public function _kcyz()
  4908. {
  4909. $post = $this->input->post(NULL, TRUE);
  4910. if (isset($post['warehouse'])) {
  4911. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4912. exit; //不再使用
  4913. $warehouse = $this->input->post('warehouse', true);
  4914. $whlabel = $this->input->post('whlabel', true);
  4915. $id = $this->input->post('id', true);
  4916. $shop = $this->input->post('shop', true);
  4917. $number = $this->input->post('number', true);
  4918. if (!$whlabel || $whlabel == '|') {
  4919. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4920. exit;
  4921. }
  4922. $pp = explode('|', trim($whlabel, '|'));
  4923. $x = 0;
  4924. $save = array();
  4925. foreach ($pp as $va) {
  4926. $num = explode('-', $va);
  4927. if ($number) {
  4928. $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 = '')"); //通用
  4929. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4930. } else {
  4931. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4932. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4933. }
  4934. $x++;
  4935. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4936. $save[] = $x - 1;
  4937. continue; //提前先加X不然出错,所以要减1
  4938. }
  4939. }
  4940. if (isset($save[0])) {
  4941. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4942. exit;
  4943. } else {
  4944. echo json_encode(array('success' => true));
  4945. exit;
  4946. }
  4947. }
  4948. }
  4949. public function _db()
  4950. {
  4951. $post = $this->input->post(NULL, TRUE);
  4952. if (isset($post['page'])) {
  4953. $page = $this->input->post('page', true);
  4954. $perpage = $this->input->post('perpage', true);
  4955. $sku = $this->input->post('sku', true);
  4956. $number = $this->input->post('number', true);
  4957. $warehouse = $this->input->post('warehouse', true);
  4958. $purchase = $this->input->post('purchase', true);
  4959. $orderinfo = $this->input->post('orderinfo', true);
  4960. $waybill = $this->input->post('waybill', true);
  4961. $category = $this->input->post('category', true);
  4962. $size = $this->input->post('size', true);
  4963. $grade = $this->input->post('grade', true);
  4964. $color = $this->input->post('color', true);
  4965. $lowe = $this->input->post('lowe', true);
  4966. $state = $this->input->post('state', true);
  4967. $label = $this->input->post('label', true);
  4968. $timetk = $this->input->post('timetkk', true);
  4969. $timetj = $this->input->post('timetjj', true);
  4970. $timetk = strtotime($timetk);
  4971. $timetj = strtotime($timetj);
  4972. $where = "dbtime > 0";
  4973. if ($timetk && $timetj) {
  4974. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4975. }
  4976. if ($sku) {
  4977. $where .= " and sku = '$sku'";
  4978. }
  4979. if ($warehouse) {
  4980. $where .= " and warehouse = '$warehouse'";
  4981. if ($warehouse == 12) {
  4982. $w = 'specialstock';
  4983. } else {
  4984. $w = 'whlabel';
  4985. }
  4986. }
  4987. if ($purchase) {
  4988. $where .= " and purchase = '$purchase'";
  4989. }
  4990. if ($category) {
  4991. $where .= " and features like '%-$category-%'";
  4992. }
  4993. if ($size) {
  4994. $where .= " and features like '%-$size-%'";
  4995. }
  4996. if ($grade) {
  4997. $where .= " and features like '%-$grade-%'";
  4998. }
  4999. if ($color) {
  5000. $where .= " and features like '%-$color-%'";
  5001. }
  5002. if ($lowe) {
  5003. $where .= " and features like '%-$lowe-%'";
  5004. }
  5005. if ($state != '') {
  5006. $where .= " and state = '$state'";
  5007. }
  5008. //数据排序
  5009. $order_str = "dbtime desc";
  5010. if (empty($page)) {
  5011. $start = 0;
  5012. $perpage = 1;
  5013. } else {
  5014. $start = ($page - 1) * $perpage;
  5015. }
  5016. //取得信息列表
  5017. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5018. foreach ($info_list as $key => $value) {
  5019. $warehouse = $this->$w->read($value['warehouse']);
  5020. $info_list[$key]['warehouse'] = $warehouse['title'];
  5021. $purchase = $this->purchase->read($value['purchase']);
  5022. $info_list[$key]['purchase'] = $purchase['title'];
  5023. if ($value['enter'] != 0) {
  5024. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5025. } else {
  5026. $info_list[$key]['enter'] = "";
  5027. }
  5028. if ($value['dbtime'] != 0) {
  5029. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5030. } else {
  5031. $info_list[$key]['dbtime'] = "";
  5032. }
  5033. if ($value['state'] == 0) {
  5034. $info_list[$key]['state'] = "在库";
  5035. } else if ($value['state'] == 1) {
  5036. $info_list[$key]['state'] = "出库";
  5037. } else if ($value['state'] == 2) {
  5038. $info_list[$key]['state'] = "退库";
  5039. } else if ($value['state'] == 3) {
  5040. $info_list[$key]['state'] = "调拨中";
  5041. } else if ($value['state'] == 4) {
  5042. $info_list[$key]['state'] = "再加工";
  5043. } else if ($value['state'] == 5) {
  5044. $info_list[$key]['state'] = "维修中";
  5045. } else if ($value['state'] == 6) {
  5046. $info_list[$key]['state'] = "盘亏";
  5047. } else if ($value['state'] == 7) {
  5048. $info_list[$key]['state'] = "更换标签";
  5049. } else if ($value['state'] == 8) {
  5050. $info_list[$key]['state'] = "其它";
  5051. } else if ($value['state'] == 9) {
  5052. $info_list[$key]['state'] = "预设";
  5053. }
  5054. }
  5055. $total = $this->whlabel->find_count($where);
  5056. $pagenum = ceil($total / $perpage);
  5057. $over = $total - ($start + $perpage);
  5058. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5059. echo json_encode($rows);
  5060. exit;
  5061. }
  5062. if (isset($post['outsku'])) {
  5063. $time = time();
  5064. $cz = $this->input->post('cz', true);
  5065. $label = $this->input->post('outsku', true);
  5066. $sl = $this->input->post('sl', true);
  5067. $num = $this->input->post('num', true);
  5068. //$warehouse = $this->input->post('warehouse',true);
  5069. if (!$sl) {
  5070. $sl = 1;
  5071. }
  5072. if (!$warehouse) {
  5073. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5074. exit;
  5075. }
  5076. $dblabel = $this->whlabellabel->get_label($label);
  5077. if ($dblabel) {
  5078. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5079. if (count($data) < 1) {
  5080. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5081. exit;
  5082. }
  5083. if (count($data) < $num) {
  5084. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5085. exit;
  5086. }
  5087. for ($i = 0; $i < $sl; $i++) {
  5088. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5089. }
  5090. echo json_encode(array('success' => true));
  5091. exit;
  5092. } else {
  5093. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5094. exit;
  5095. }
  5096. }
  5097. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5098. $this->_Template('whlabel_db', $this->data);
  5099. }
  5100. public function _dbrk()
  5101. {
  5102. $post = $this->input->post(NULL, TRUE);
  5103. if (isset($post['page'])) {
  5104. $page = $this->input->post('page', true);
  5105. $perpage = $this->input->post('perpage', true);
  5106. $sku = $this->input->post('sku', true);
  5107. $number = $this->input->post('number', true);
  5108. $warehouse = $this->input->post('warehouse', true);
  5109. $purchase = $this->input->post('purchase', true);
  5110. $orderinfo = $this->input->post('orderinfo', true);
  5111. $waybill = $this->input->post('waybill', true);
  5112. $category = $this->input->post('category', true);
  5113. $size = $this->input->post('size', true);
  5114. $grade = $this->input->post('grade', true);
  5115. $color = $this->input->post('color', true);
  5116. $lowe = $this->input->post('lowe', true);
  5117. $state = $this->input->post('state', true);
  5118. $label = $this->input->post('label', true);
  5119. $ctime = $this->input->post('ctime', true);
  5120. $timetk = $this->input->post('timetkk', true);
  5121. $timetj = $this->input->post('timetjj', true);
  5122. $timetk = strtotime($timetk);
  5123. $timetj = strtotime($timetj);
  5124. $where = "dbtime > 0";
  5125. if ($timetk && $timetj) {
  5126. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5127. }
  5128. if ($sku) {
  5129. $where .= " and sku = '$sku'";
  5130. }
  5131. if ($warehouse) {
  5132. $where .= " and warehouse = '$warehouse'";
  5133. }
  5134. if ($purchase) {
  5135. $where .= " and purchase = '$purchase'";
  5136. }
  5137. if ($category) {
  5138. $where .= " and features like '%-$category-%'";
  5139. }
  5140. if ($size) {
  5141. $where .= " and features like '%-$size-%'";
  5142. }
  5143. if ($grade) {
  5144. $where .= " and features like '%-$grade-%'";
  5145. }
  5146. if ($color) {
  5147. $where .= " and features like '%-$color-%'";
  5148. }
  5149. if ($lowe) {
  5150. $where .= " and features like '%-$lowe-%'";
  5151. }
  5152. if ($state != '') {
  5153. $where .= " and state = '$state'";
  5154. }
  5155. //数据排序
  5156. $order_str = "dbtime desc";
  5157. if (empty($page)) {
  5158. $start = 0;
  5159. $perpage = 1;
  5160. } else {
  5161. $start = ($page - 1) * $perpage;
  5162. }
  5163. //取得信息列表
  5164. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5165. foreach ($info_list as $key => $value) {
  5166. $warehouse = $this->warehouse->read($value['warehouse']);
  5167. $info_list[$key]['warehouse'] = $warehouse['title'];
  5168. $purchase = $this->purchase->read($value['purchase']);
  5169. $info_list[$key]['purchase'] = $purchase['title'];
  5170. if ($value['enter'] != 0) {
  5171. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5172. } else {
  5173. $info_list[$key]['enter'] = "";
  5174. }
  5175. if ($value['dbtime'] != 0) {
  5176. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5177. } else {
  5178. $info_list[$key]['dbtime'] = "";
  5179. }
  5180. if ($value['state'] == 0) {
  5181. $info_list[$key]['state'] = "在库";
  5182. } else if ($value['state'] == 1) {
  5183. $info_list[$key]['state'] = "出库";
  5184. } else if ($value['state'] == 2) {
  5185. $info_list[$key]['state'] = "退库";
  5186. } else if ($value['state'] == 3) {
  5187. $info_list[$key]['state'] = "调拨中";
  5188. } else if ($value['state'] == 4) {
  5189. $info_list[$key]['state'] = "再加工";
  5190. } else if ($value['state'] == 5) {
  5191. $info_list[$key]['state'] = "维修中";
  5192. } else if ($value['state'] == 6) {
  5193. $info_list[$key]['state'] = "盘亏";
  5194. } else if ($value['state'] == 7) {
  5195. $info_list[$key]['state'] = "更换标签";
  5196. } else if ($value['state'] == 8) {
  5197. $info_list[$key]['state'] = "其它";
  5198. } else if ($value['state'] == 9) {
  5199. $info_list[$key]['state'] = "预设";
  5200. }
  5201. }
  5202. $total = $this->whlabel->find_count($where);
  5203. $pagenum = ceil($total / $perpage);
  5204. $over = $total - ($start + $perpage);
  5205. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5206. echo json_encode($rows);
  5207. exit;
  5208. }
  5209. if (isset($post['rsku'])) {
  5210. $cz = $this->input->post('cz', true);
  5211. $label = $this->input->post('rsku', true);
  5212. $sl = $this->input->post('sl', true);
  5213. $warehouse = $this->input->post('warehouse', true);
  5214. if (!$sl) {
  5215. $sl = 1;
  5216. }
  5217. if (!$warehouse) {
  5218. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5219. exit;
  5220. }
  5221. $dblabel = $this->whlabellabel->get_label($label);
  5222. if ($dblabel) {
  5223. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5224. if (count($data) < 1) {
  5225. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5226. exit;
  5227. }
  5228. if ($sl > count($data)) {
  5229. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5230. exit;
  5231. }
  5232. $time = time();
  5233. for ($i = 0; $i < $sl; $i++) {
  5234. $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']);
  5235. }
  5236. echo json_encode(array('success' => true));
  5237. exit;
  5238. } else {
  5239. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5240. exit;
  5241. }
  5242. }
  5243. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5244. $this->_Template('whlabel_dbrk', $this->data);
  5245. }
  5246. public function _whlabelczdc()
  5247. {
  5248. if (isset($_GET['excel'])) {
  5249. //数据排序
  5250. $order_str = "id desc";
  5251. if (empty($page)) {
  5252. $start = 0;
  5253. $perpage = 1;
  5254. } else {
  5255. $start = ($page - 1) * $perpage;
  5256. }
  5257. $state = $this->input->get('state', true);
  5258. $sku = $this->input->get('sku', true);
  5259. $ctime = $this->input->get('ctime', true);
  5260. $category = $this->input->get('category', true);
  5261. $size = $this->input->get('size', true);
  5262. $grade = $this->input->get('grade', true);
  5263. $color = $this->input->get('color', true);
  5264. $lowe = $this->input->get('lowe', true);
  5265. $timetk = $this->input->get('timetkk', true);
  5266. $timetj = $this->input->get('timetjj', true);
  5267. $timetk = strtotime($timetk);
  5268. $timetj = strtotime($timetj);
  5269. $where = "dbtime > 0";
  5270. if ($timetk && $timetj) {
  5271. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5272. }
  5273. if ($category) {
  5274. $where .= " and features like '%-$category-%'";
  5275. }
  5276. if ($size) {
  5277. $where .= " and features like '%-$size-%'";
  5278. }
  5279. if ($grade) {
  5280. $where .= " and features like '%-$grade-%'";
  5281. }
  5282. if ($color) {
  5283. $where .= " and features like '%-$color-%'";
  5284. }
  5285. if ($lowe) {
  5286. $where .= " and features like '%-$lowe-%'";
  5287. }
  5288. //取得信息列表
  5289. $info_list = $this->whlabel->find_all($where, '*');
  5290. $rows = array();
  5291. $list = array();
  5292. foreach ($info_list as $key => $value) {
  5293. $rows[$value['sku']] = $value; //所有数据sku
  5294. }
  5295. foreach ($rows as $value) {
  5296. $warehouse = $this->warehouse->read($value['warehouse']);
  5297. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5298. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5299. if ($value['orderinfo'] == 0) {
  5300. $info_list[$key]['orderinfo'] = "";
  5301. }
  5302. if ($value['waybill'] == 0) {
  5303. $info_list[$key]['waybill'] = "";
  5304. }
  5305. if ($value['state'] == 0) {
  5306. $value['state'] = "在库";
  5307. } else if ($value['state'] == 3) {
  5308. $value['state'] = "调拨中";
  5309. }
  5310. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5311. }
  5312. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5313. $titlename = "<table border=1>
  5314. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5315. <tr align='center'>
  5316. <td>SKU</td>
  5317. <td>产品</td>
  5318. <td>调拨数量</td>
  5319. <td>入库数量</td>
  5320. </tr>
  5321. </table>";
  5322. $filename = $title . ".xls";
  5323. $tail = "";
  5324. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5325. }
  5326. }
  5327. public function _print($arg_array)
  5328. {
  5329. if (isset($_SESSION['api'])) {
  5330. $user = $this->user->get_api($_SESSION['api']);
  5331. $usp = $user;
  5332. $fgshop = "";
  5333. $sid = "";
  5334. $wid = "";
  5335. $wtype = "";
  5336. $usersp = explode('|', trim($user['shop'], '|'));
  5337. $userwh = explode('|', trim($user['warehouse'], '|'));
  5338. foreach ($usersp as $value) {
  5339. $fgshop .= " shop = " . $value . " or";
  5340. $sid .= " id = " . $value . " or";
  5341. }
  5342. foreach ($userwh as $value) {
  5343. $wid .= " id = " . $value . " or";
  5344. $wtype .= " type = " . $value . " or";
  5345. }
  5346. }
  5347. $post = $this->input->post(NULL, TRUE);
  5348. if (isset($post['tmsku'])) {
  5349. $tmsku = $this->input->post('tmsku', true);
  5350. if (is_numeric($tmsku)) {
  5351. $yyh = $this->whlabellabel->get_label($tmsku);
  5352. } else {
  5353. $yyh = $this->whlabellabel->get_sku($tmsku);
  5354. }
  5355. if ($yyh) {
  5356. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5357. exit;
  5358. } else {
  5359. echo json_encode(array('success' => false));
  5360. exit;
  5361. }
  5362. }
  5363. $classid = $this->classid->sku();
  5364. $pm = $classid;
  5365. $scsku = $classid;
  5366. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5367. if (isset($post['warehouse'])) {
  5368. if ($post['warehouse']) {
  5369. $list = array();
  5370. $num = "";
  5371. $title = "";
  5372. $features = "";
  5373. $order = 0;
  5374. $post['shop'] = '';
  5375. $brand = $this->input->post('brand', true);
  5376. if ($brand != '0,') {
  5377. $b = $this->brand->read(rtrim($brand, ','));
  5378. if ($b) {
  5379. $post['shop'] = str_replace('|', ',', $b['shop']);
  5380. }
  5381. }
  5382. $post['details'] = $this->input->post('details', true); //打印数量
  5383. $xbqnum = $this->input->post('xbqnum', true);
  5384. $post['purchase'] = $this->input->post('purchase', true);
  5385. $post['warehouse'] = $this->input->post('warehouse', true);
  5386. $post['purchase'] = $this->input->post('purchase', true);
  5387. $post['retreatwarehouse'] = $post['warehouse'];
  5388. $post['cpbz'] = $this->input->post('cpbz', true);
  5389. $post['state'] = 9;
  5390. $category = $this->input->post('category', true);
  5391. $list['category'] = $category;
  5392. $list['hairtype'] = $this->input->post('hairtype', true);
  5393. $list['grade'] = $this->input->post('grade', true);
  5394. $size = $this->input->post('size', true);
  5395. $list['size'] = rtrim($size, ',');
  5396. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5397. $list['extension'] = $this->input->post('extension', true);
  5398. if ($category == 1297) {
  5399. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5400. }
  5401. if ($category == 1702) {
  5402. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5403. $list['syother'] = $this->input->post('syother', true);
  5404. }
  5405. if ($category == 133) {
  5406. $list['fittype'] = $this->input->post('fittype', true);
  5407. $list['acother'] = $this->input->post('acother', true);
  5408. }
  5409. $list['color'] = $this->input->post('color', true);
  5410. $list['lowe'] = $this->input->post('lowe', true);
  5411. if ($category == 127) {
  5412. $list['type'] = $this->input->post('type', true);
  5413. $list['headroad'] = $this->input->post('headroad', true);
  5414. $list['density'] = $this->input->post('density', true);
  5415. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5416. $list['lacesize'] = $this->input->post('lacesize', true);
  5417. }
  5418. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5419. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5420. }
  5421. if ($category == 128) {
  5422. $list['lacetype'] = $this->input->post('lacetype', true);
  5423. $list['haircap'] = $this->input->post('haircap', true);
  5424. $list['density'] = $this->input->post('density', true);
  5425. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5426. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5427. $list['wigother'] = $this->input->post('wigother', true);
  5428. $list['wigother1'] = $this->input->post('wigother1', true);
  5429. $list['wigother2'] = $this->input->post('wigother2', true);
  5430. }
  5431. if ($category == 129) {
  5432. $list['wide'] = $this->input->post('wide', true);
  5433. }
  5434. if ($category == 131) {
  5435. $list['gifttype'] = $this->input->post('gifttype', true);
  5436. $list['giftother'] = $this->input->post('giftother', true);
  5437. }
  5438. if ($category == 134) {
  5439. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5440. }
  5441. if ($category == 1297) {
  5442. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5443. $list['sywigother'] = $this->input->post('sywigother', true);
  5444. }
  5445. if ($category == 130 || $category == 133 || $category == 1702) {
  5446. $list['items'] = $this->input->post('items', true);
  5447. $list['weight'] = $this->input->post('weight', true);
  5448. }
  5449. if ($category == 1702) {
  5450. $list['syhairther'] = $this->input->post('syhairther', true);
  5451. }
  5452. foreach ($list as $k => $v) {
  5453. if ($v != 0) {
  5454. $num .= $v;
  5455. $features .= $v . '-';
  5456. $post[$k] = $v;
  5457. $typeclass = $this->typeclass->read($v);
  5458. if (isset($pm[$typeclass['classid']])) {
  5459. if (stripos($typeclass['zh'], '|') !== false) {
  5460. $exzh = explode('|', $typeclass['zh']);
  5461. $pm[$typeclass['classid']] = $exzh[0];
  5462. } else {
  5463. $pm[$typeclass['classid']] = $typeclass['zh'];
  5464. }
  5465. }
  5466. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5467. if ($k != 'size') {
  5468. $title .= $typeclass['title'] . " ";
  5469. }
  5470. }
  5471. }
  5472. $typeclass = $this->typeclass->read($list['size']);
  5473. $title .= $typeclass['title'];
  5474. $time = time();
  5475. $post['title'] = rtrim($title, ' ');
  5476. $post['number'] = $num;
  5477. $post['features'] = '-' . $features;
  5478. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5479. $featurespp = explode('-', trim($featurespp, '-'));
  5480. if (isset($featurespp[5])) {
  5481. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5482. } else {
  5483. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5484. }
  5485. $post['enter'] = $time;
  5486. $post['time'] = $time; //操作时间
  5487. $scsku = implode("-", $scsku);
  5488. $zh = implode(" ", $pm);
  5489. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5490. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5491. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5492. $post['sku'] = $bqsku;
  5493. $label = time() . rand(0, 9);
  5494. $post['label'] = $label;
  5495. $cpid = $this->whlabellabel->find_count();
  5496. $post['cpid'] = $cpid + 1;
  5497. $cpid = $post['cpid'];
  5498. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5499. //if($whlabelbarcode)
  5500. //{
  5501. //$post['label'] = $whlabelbarcode['label'];
  5502. //if(!$this->whlabellabel->insert($post))
  5503. //{
  5504. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5505. //}
  5506. //}
  5507. //else
  5508. //{
  5509. $this->db->trans_begin();
  5510. $this->whlabellabel->insert($post);
  5511. //$this->whlabelbarcode->insert($post);
  5512. if ($this->db->trans_status() === TRUE) {
  5513. $this->db->trans_commit();
  5514. } else {
  5515. $this->db->trans_rollback();
  5516. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5517. exit;
  5518. }
  5519. //}
  5520. $warehouse_name = "";
  5521. $warehouse = $post['warehouse'];
  5522. if($warehouse == 12){
  5523. $warehouse_name = "特殊库存库";
  5524. }
  5525. // if($warehouse == 13){
  5526. // $warehouse_name = "许昌仓";
  5527. // }
  5528. // if($warehouse == 5){
  5529. // $warehouse_name = "美国店";
  5530. // }
  5531. // if($warehouse == 16){
  5532. // $warehouse_name = "定制头套仓";
  5533. // }
  5534. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5535. if(!empty($warehouse_name)){
  5536. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5537. }
  5538. $purchase = $this->purchase->read($post['purchase']);
  5539. 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));
  5540. exit; //特殊仓目前不需要仓库选项
  5541. }
  5542. }
  5543. if (isset($_SESSION['api'])) {
  5544. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5545. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5546. $this->data['wlshop'] = $wlshop;
  5547. $this->data['warehouse'] = $warehouse;
  5548. }
  5549. $whlabelwz = $this->whlabelwz->find_all();
  5550. $this->data['whlabelwz'] = $whlabelwz;
  5551. $this->_Template('whlabel_print', $this->data);
  5552. }
  5553. public function _usaprint($arg_array)
  5554. {
  5555. if (isset($_SESSION['api'])) {
  5556. $user = $this->user->get_api($_SESSION['api']);
  5557. $usp = $user;
  5558. $fgshop = "";
  5559. $sid = "";
  5560. $wid = "";
  5561. $wtype = "";
  5562. $usersp = explode('|', trim($user['shop'], '|'));
  5563. $userwh = explode('|', trim($user['warehouse'], '|'));
  5564. foreach ($usersp as $value) {
  5565. $fgshop .= " shop = " . $value . " or";
  5566. $sid .= " id = " . $value . " or";
  5567. }
  5568. foreach ($userwh as $value) {
  5569. $wid .= " id = " . $value . " or";
  5570. $wtype .= " type = " . $value . " or";
  5571. }
  5572. }
  5573. $post = $this->input->post(NULL, TRUE);
  5574. if (isset($post['tmsku'])) {
  5575. $tmsku = $this->input->post('tmsku', true);
  5576. if (is_numeric($tmsku)) {
  5577. $yyh = $this->whlabellabel->get_label($tmsku);
  5578. } else {
  5579. $yyh = $this->whlabellabel->get_sku($tmsku);
  5580. }
  5581. if ($yyh) {
  5582. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5583. exit;
  5584. } else {
  5585. echo json_encode(array('success' => false));
  5586. exit;
  5587. }
  5588. }
  5589. $classid = $this->classid->sku();
  5590. $pm = $classid;
  5591. $scsku = $classid;
  5592. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5593. if (isset($post['warehouse'])) {
  5594. if ($post['warehouse']) {
  5595. $list = array();
  5596. $num = "";
  5597. $title = "";
  5598. $features = "";
  5599. $order = 0;
  5600. $post['shop'] = '';
  5601. $brand = $this->input->post('brand', true);
  5602. if ($brand != '0,') {
  5603. $b = $this->brand->read(rtrim($brand, ','));
  5604. if ($b) {
  5605. $post['shop'] = str_replace('|', ',', $b['shop']);
  5606. }
  5607. }
  5608. $post['details'] = $this->input->post('details', true); //打印数量
  5609. $xbqnum = $this->input->post('xbqnum', true);
  5610. $post['purchase'] = $this->input->post('purchase', true);
  5611. $post['warehouse'] = $this->input->post('warehouse', true);
  5612. $post['purchase'] = $this->input->post('purchase', true);
  5613. $post['retreatwarehouse'] = $post['warehouse'];
  5614. $post['cpbz'] = $this->input->post('cpbz', true);
  5615. $post['state'] = 9;
  5616. $category = $this->input->post('category', true);
  5617. $list['category'] = $category;
  5618. $list['hairtype'] = $this->input->post('hairtype', true);
  5619. $list['grade'] = $this->input->post('grade', true);
  5620. $size = $this->input->post('size', true);
  5621. $list['size'] = rtrim($size, ',');
  5622. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5623. $list['extension'] = $this->input->post('extension', true);
  5624. if ($category == 1297) {
  5625. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5626. }
  5627. if ($category == 1702) {
  5628. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5629. $list['syother'] = $this->input->post('syother', true);
  5630. }
  5631. if ($category == 133) {
  5632. $list['fittype'] = $this->input->post('fittype', true);
  5633. $list['acother'] = $this->input->post('acother', true);
  5634. }
  5635. $list['color'] = $this->input->post('color', true);
  5636. $list['lowe'] = $this->input->post('lowe', true);
  5637. if ($category == 127) {
  5638. $list['type'] = $this->input->post('type', true);
  5639. $list['headroad'] = $this->input->post('headroad', true);
  5640. $list['density'] = $this->input->post('density', true);
  5641. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5642. $list['lacesize'] = $this->input->post('lacesize', true);
  5643. }
  5644. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5645. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5646. }
  5647. if ($category == 128) {
  5648. $list['lacetype'] = $this->input->post('lacetype', true);
  5649. $list['haircap'] = $this->input->post('haircap', true);
  5650. $list['density'] = $this->input->post('density', true);
  5651. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5652. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5653. $list['wigother'] = $this->input->post('wigother', true);
  5654. $list['wigother1'] = $this->input->post('wigother1', true);
  5655. $list['wigother2'] = $this->input->post('wigother2', true);
  5656. }
  5657. if ($category == 129) {
  5658. $list['wide'] = $this->input->post('wide', true);
  5659. }
  5660. if ($category == 131) {
  5661. $list['gifttype'] = $this->input->post('gifttype', true);
  5662. $list['giftother'] = $this->input->post('giftother', true);
  5663. }
  5664. if ($category == 134) {
  5665. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5666. }
  5667. if ($category == 1297) {
  5668. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5669. $list['sywigother'] = $this->input->post('sywigother', true);
  5670. }
  5671. if ($category == 130 || $category == 133 || $category == 1702) {
  5672. $list['items'] = $this->input->post('items', true);
  5673. $list['weight'] = $this->input->post('weight', true);
  5674. }
  5675. if ($category == 1702) {
  5676. $list['syhairther'] = $this->input->post('syhairther', true);
  5677. }
  5678. foreach ($list as $k => $v) {
  5679. if ($v != 0) {
  5680. $num .= $v;
  5681. $features .= $v . '-';
  5682. $post[$k] = $v;
  5683. $typeclass = $this->typeclass->read($v);
  5684. if (isset($pm[$typeclass['classid']])) {
  5685. if (stripos($typeclass['zh'], '|') !== false) {
  5686. $exzh = explode('|', $typeclass['zh']);
  5687. $pm[$typeclass['classid']] = $exzh[0];
  5688. } else {
  5689. $pm[$typeclass['classid']] = $typeclass['zh'];
  5690. }
  5691. }
  5692. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5693. if ($k != 'size') {
  5694. $title .= $typeclass['title'] . " ";
  5695. }
  5696. }
  5697. }
  5698. $typeclass = $this->typeclass->read($list['size']);
  5699. $title .= $typeclass['title'];
  5700. $time = time();
  5701. $post['title'] = rtrim($title, ' ');
  5702. $post['number'] = $num;
  5703. $post['features'] = '-' . $features;
  5704. $fp = $this->whlabel->get_features($post['features']);
  5705. if (!$fp) {
  5706. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5707. exit;
  5708. }
  5709. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5710. $featurespp = explode('-', trim($featurespp, '-'));
  5711. if (isset($featurespp[5])) {
  5712. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5713. } else {
  5714. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5715. }
  5716. $post['enter'] = $time;
  5717. $post['time'] = $time; //操作时间
  5718. $scsku = implode("-", $scsku);
  5719. $zh = implode(" ", $pm);
  5720. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5721. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5722. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5723. $post['sku'] = $fp['sku'];
  5724. $post['label'] = $fp['sku'];
  5725. $cpid = $this->whlabellabel->find_count();
  5726. $post['cpid'] = $cpid + 1;
  5727. $cpid = $post['cpid'];
  5728. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5729. //if($whlabelbarcode)
  5730. //{
  5731. //$post['label'] = $whlabelbarcode['label'];
  5732. //if(!$this->whlabellabel->insert($post))
  5733. //{
  5734. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5735. //}
  5736. //}
  5737. //else
  5738. //{
  5739. $this->db->trans_begin();
  5740. $this->whlabellabel->insert($post);
  5741. //$this->whlabelbarcode->insert($post);
  5742. if ($this->db->trans_status() === TRUE) {
  5743. $this->db->trans_commit();
  5744. } else {
  5745. $this->db->trans_rollback();
  5746. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5747. exit;
  5748. }
  5749. //}
  5750. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5751. $purchase = $this->purchase->read($post['purchase']);
  5752. 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));
  5753. exit; //特殊仓目前不需要仓库选项
  5754. }
  5755. }
  5756. if (isset($_SESSION['api'])) {
  5757. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5758. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5759. $this->data['wlshop'] = $wlshop;
  5760. $this->data['warehouse'] = $warehouse;
  5761. }
  5762. $whlabelwz = $this->whlabelwz->find_all();
  5763. $this->data['whlabelwz'] = $whlabelwz;
  5764. $this->_Template('whlabel_usaprint', $this->data);
  5765. }
  5766. public function _printrk($arg_array)
  5767. {
  5768. $prc = array();
  5769. $purchase = $this->purchase->find_all();
  5770. foreach ($purchase as $k => $v) {
  5771. $prc[$v['id']] = $v['title'];
  5772. }
  5773. $post = $this->input->post(NULL, TRUE);
  5774. if (isset($post['page'])) {
  5775. $page = $this->input->post('page', true);
  5776. $perpage = $this->input->post('perpage', true);
  5777. $sku = $this->input->post('sku', true);
  5778. $bs = $this->input->post('bs', true);
  5779. $number = $this->input->post('number', true);
  5780. $warehouse = $this->input->post('warehouse', true);
  5781. $purchase = $this->input->post('purchase', true);
  5782. $orderinfo = $this->input->post('orderinfo', true);
  5783. $waybill = $this->input->post('waybill', true);
  5784. $category = $this->input->post('category', true);
  5785. $size = $this->input->post('size', true);
  5786. $grade = $this->input->post('grade', true);
  5787. $color = $this->input->post('color', true);
  5788. $lowe = $this->input->post('lowe', true);
  5789. $state = $this->input->post('state', true);
  5790. $label = $this->input->post('label', true);
  5791. $timetk = $this->input->post('ktime', true);
  5792. $timetj = $this->input->post('jtime', true);
  5793. $timetk = strtotime($timetk);
  5794. $timetj = strtotime($timetj);
  5795. $where = "1=1 ";
  5796. if ($timetk && $timetj) {
  5797. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5798. }
  5799. if ($sku) {
  5800. $where .= " and sku = '$sku'";
  5801. }
  5802. if ($bs != '') {
  5803. $where .= " and bs = '$bs'";
  5804. }
  5805. if ($number) {
  5806. $where .= " and number = '$number'";
  5807. }
  5808. if ($warehouse) {
  5809. $where .= " and warehouse = '$warehouse'";
  5810. }
  5811. if ($purchase) {
  5812. $where .= " and purchase = '$purchase'";
  5813. }
  5814. if ($orderinfo) {
  5815. $where .= " and orderinfo = '$orderinfo'";
  5816. }
  5817. if ($waybill) {
  5818. $where .= " and waybill = '$waybill'";
  5819. }
  5820. if ($category) {
  5821. $where .= " and features like '%-$category-%'";
  5822. }
  5823. if ($size) {
  5824. $where .= " and features like '%-$size-%'";
  5825. }
  5826. if ($grade) {
  5827. $where .= " and features like '%-$grade-%'";
  5828. }
  5829. if ($color) {
  5830. $where .= " and features like '%-$color-%'";
  5831. }
  5832. if ($lowe) {
  5833. $where .= " and features like '%-$lowe-%'";
  5834. }
  5835. if ($label) {
  5836. $where .= " and label = '$label'";
  5837. }
  5838. if ($state || $state == 0) {
  5839. $where .= " and state = '$state'";
  5840. }
  5841. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5842. //数据排序
  5843. $order_str = "enter desc";
  5844. if (empty($page)) {
  5845. $start = 0;
  5846. $perpage = 1;
  5847. } else {
  5848. $start = ($page - 1) * $perpage;
  5849. }
  5850. //取得信息列表
  5851. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5852. foreach ($info_list as $key => $value) {
  5853. $warehouse = $this->warehouse->read($value['warehouse']);
  5854. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5855. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5856. if ($value['state'] == 0) {
  5857. $info_list[$key]['state'] = "在库";
  5858. } else if ($value['state'] == 1) {
  5859. $info_list[$key]['state'] = "出库";
  5860. } else if ($value['state'] == 2) {
  5861. $info_list[$key]['state'] = "退库";
  5862. } else if ($value['state'] == 3) {
  5863. $info_list[$key]['state'] = "调拨中";
  5864. } else if ($value['state'] == 4) {
  5865. $info_list[$key]['state'] = "再加工";
  5866. } else if ($value['state'] == 5) {
  5867. $info_list[$key]['state'] = "维修中";
  5868. } else if ($value['state'] == 6) {
  5869. $info_list[$key]['state'] = "盘亏";
  5870. } else if ($value['state'] == 7) {
  5871. $info_list[$key]['state'] = "更换标签";
  5872. } else if ($value['state'] == 8) {
  5873. $info_list[$key]['state'] = "其它";
  5874. } else if ($value['state'] == 9) {
  5875. $info_list[$key]['state'] = "预设";
  5876. } else if ($value['state'] == 10) {
  5877. $info_list[$key]['state'] = "美店零售";
  5878. }
  5879. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5880. }
  5881. $total = $this->$ck->find_count($where);
  5882. $pagenum = ceil($total / $perpage);
  5883. $over = $total - ($start + $perpage);
  5884. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5885. echo json_encode($rows);
  5886. exit;
  5887. }
  5888. if (isset($post['tmsku'])) {
  5889. $time = time();
  5890. $tmsku = $this->input->post('tmsku', true);
  5891. //$post['shop'] = $this->input->post('shop',true);
  5892. $num = $this->input->post('num', true);
  5893. $rktype = $this->input->post('rktype', true);
  5894. if ($num > 200) {
  5895. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5896. exit;
  5897. }
  5898. if (!$rktype) {
  5899. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5900. }
  5901. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5902. /**
  5903. $wz = array();
  5904. foreach ($rk as $key=>$value)
  5905. {
  5906. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5907. }
  5908. if(count($wz) > 1)
  5909. {
  5910. $wz = array_values($wz);
  5911. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5912. }
  5913. **/
  5914. if (isset($rk[0]['purchase'])) {
  5915. $rk = $rk[0];
  5916. $j = 0;
  5917. $post['purchase'] = $rk['purchase'];
  5918. $post['warehouse'] = $rk['warehouse'];
  5919. $post['retreatwarehouse'] = $rk['warehouse'];
  5920. $post['sku'] = $rk['sku'];
  5921. $post['number'] = $rk['number'];
  5922. $post['features'] = $rk['features'];
  5923. $post['title'] = $rk['title'];
  5924. $post['enter'] = $time;
  5925. $post['time'] = $time;
  5926. $post['bs'] = 1;
  5927. $post['shop'] = $rk['shop'];
  5928. $post['details'] = $rk['details'];
  5929. $post['cpid'] = $rk['cpid'];
  5930. $post['cpbz'] = $rk['cpbz'];
  5931. //$post['rktype'] = $rktype;
  5932. $warehouse = $this->warehouse->read($rk['warehouse']);
  5933. if ($warehouse['bdck'] == '') {
  5934. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5935. exit;
  5936. } else {
  5937. $bdck = $warehouse['bdck'];
  5938. }
  5939. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5940. if (isset($pdwz['details'])) {
  5941. if ($pdwz['details'] != $post['details']) {
  5942. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5943. exit;
  5944. }
  5945. }
  5946. $post['featurespp'] = $rk['featurespp'];
  5947. if ($post['warehouse'] == '5') {
  5948. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5949. if ($yza) {
  5950. if ($post['features'] != $yza[0]['features']) {
  5951. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5952. exit;
  5953. }
  5954. }
  5955. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5956. if ($yzb) {
  5957. if ($post['sku'] != $yzb[0]['sku']) {
  5958. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5959. exit;
  5960. }
  5961. }
  5962. }
  5963. for ($i = 0; $i < $num; $i++) {
  5964. $post['label'] = time() . rand(100, 999) . $i;
  5965. if ($this->$bdck->insert($post)) {
  5966. $j++;
  5967. }
  5968. }
  5969. /**
  5970. if($post['warehouse'] != 12)
  5971. {
  5972. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5973. }
  5974. **/
  5975. if ($j == $num) {
  5976. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5977. exit;
  5978. } else {
  5979. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5980. exit;
  5981. }
  5982. } else {
  5983. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5984. exit;
  5985. }
  5986. }
  5987. $this->_Template('whlabel_printrk', $this->data);
  5988. }
  5989. public function _printxzrk($arg_array)
  5990. {
  5991. $post = $this->input->post(NULL, TRUE);
  5992. if (isset($post['wzid'])) {
  5993. $time = time();
  5994. $id = $this->input->post('wzid', true);
  5995. //$post['shop'] = $this->input->post('shop',true);
  5996. $num = 1;
  5997. $rk = $this->whlabellabel->read($id);
  5998. if (isset($rk['purchase'])) {
  5999. $x = 0;
  6000. $post['purchase'] = $rk['purchase'];
  6001. $post['warehouse'] = $rk['warehouse'];
  6002. $post['retreatwarehouse'] = $rk['warehouse'];
  6003. $post['sku'] = $rk['sku'];
  6004. $post['number'] = $rk['number'];
  6005. $post['features'] = $rk['features'];
  6006. $post['title'] = $rk['title'];
  6007. $post['enter'] = $time;
  6008. $post['time'] = $time;
  6009. $post['bs'] = 1;
  6010. $post['shop'] = $rk['shop'];
  6011. $post['details'] = $rk['details'];
  6012. $post['cpid'] = $rk['cpid'];
  6013. $post['cpbz'] = $rk['cpbz'];
  6014. $warehouse = $this->warehouse->read($rk['warehouse']);
  6015. if ($warehouse['bdck'] == '') {
  6016. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6017. exit;
  6018. } else {
  6019. $bdck = $warehouse['bdck'];
  6020. }
  6021. $post['featurespp'] = $rk['featurespp'];
  6022. $this->db->trans_begin();
  6023. for ($i = 0; $i < $num; $i++) {
  6024. $post['label'] = time() . rand(100, 999) . $i;
  6025. $this->$bdck->insert($post);
  6026. }
  6027. /**
  6028. if($post['warehouse'] != 12)
  6029. {
  6030. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6031. }
  6032. **/
  6033. if ($this->db->trans_status() === TRUE) {
  6034. $this->db->trans_commit();
  6035. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6036. exit;
  6037. } else {
  6038. $this->db->trans_rollback();
  6039. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6040. exit;
  6041. }
  6042. } else {
  6043. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6044. exit;
  6045. }
  6046. }
  6047. }
  6048. public function _printck($arg_array)
  6049. {
  6050. $prc = array();
  6051. $purchase = $this->purchase->find_all();
  6052. foreach ($purchase as $k => $v) {
  6053. $prc[$v['id']] = $v['title'];
  6054. }
  6055. $post = $this->input->post(NULL, TRUE);
  6056. if (isset($post['page'])) {
  6057. $page = $this->input->post('page', true);
  6058. $perpage = $this->input->post('perpage', true);
  6059. $sku = $this->input->post('sku', true);
  6060. $bs = $this->input->post('bs', true);
  6061. $number = $this->input->post('number', true);
  6062. $warehouse = $this->input->post('warehouse', true);
  6063. $purchase = $this->input->post('purchase', true);
  6064. $orderinfo = $this->input->post('orderinfo', true);
  6065. $waybill = $this->input->post('waybill', true);
  6066. $category = $this->input->post('category', true);
  6067. $size = $this->input->post('size', true);
  6068. $grade = $this->input->post('grade', true);
  6069. $color = $this->input->post('color', true);
  6070. $lowe = $this->input->post('lowe', true);
  6071. $state = $this->input->post('state', true);
  6072. $label = $this->input->post('label', true);
  6073. $timetk = $this->input->post('ktime', true);
  6074. $timetj = $this->input->post('jtime', true);
  6075. $timetk = strtotime($timetk);
  6076. $timetj = strtotime($timetj);
  6077. $where = "state=1 ";
  6078. if ($timetk && $timetj) {
  6079. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6080. }
  6081. if ($sku) {
  6082. $where .= " and sku = '$sku'";
  6083. }
  6084. if ($bs != '') {
  6085. $where .= " and bs = '$bs'";
  6086. }
  6087. if ($number) {
  6088. $where .= " and number = '$number'";
  6089. }
  6090. if ($warehouse) {
  6091. $where .= " and warehouse = '$warehouse'";
  6092. }
  6093. if ($purchase) {
  6094. $where .= " and purchase = '$purchase'";
  6095. }
  6096. if ($orderinfo) {
  6097. $where .= " and orderinfo = '$orderinfo'";
  6098. }
  6099. if ($waybill) {
  6100. $where .= " and waybill = '$waybill'";
  6101. }
  6102. if ($category) {
  6103. $where .= " and features like '%-$category-%'";
  6104. }
  6105. if ($size) {
  6106. $where .= " and features like '%-$size-%'";
  6107. }
  6108. if ($grade) {
  6109. $where .= " and features like '%-$grade-%'";
  6110. }
  6111. if ($color) {
  6112. $where .= " and features like '%-$color-%'";
  6113. }
  6114. if ($lowe) {
  6115. $where .= " and features like '%-$lowe-%'";
  6116. }
  6117. if ($label) {
  6118. $where .= " and label = '$label'";
  6119. }
  6120. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6121. //数据排序
  6122. $order_str = "outk desc";
  6123. if (empty($page)) {
  6124. $start = 0;
  6125. $perpage = 1;
  6126. } else {
  6127. $start = ($page - 1) * $perpage;
  6128. }
  6129. //取得信息列表
  6130. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6131. foreach ($info_list as $key => $value) {
  6132. $warehouse = $this->warehouse->read($value['warehouse']);
  6133. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6134. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6135. if ($value['state'] == 0) {
  6136. $info_list[$key]['state'] = "在库";
  6137. } else if ($value['state'] == 1) {
  6138. $info_list[$key]['state'] = "出库";
  6139. } else if ($value['state'] == 2) {
  6140. $info_list[$key]['state'] = "退库";
  6141. } else if ($value['state'] == 3) {
  6142. $info_list[$key]['state'] = "调拨中";
  6143. } else if ($value['state'] == 4) {
  6144. $info_list[$key]['state'] = "再加工";
  6145. } else if ($value['state'] == 5) {
  6146. $info_list[$key]['state'] = "维修中";
  6147. } else if ($value['state'] == 6) {
  6148. $info_list[$key]['state'] = "盘亏";
  6149. } else if ($value['state'] == 7) {
  6150. $info_list[$key]['state'] = "更换标签";
  6151. } else if ($value['state'] == 8) {
  6152. $info_list[$key]['state'] = "其它";
  6153. } else if ($value['state'] == 9) {
  6154. $info_list[$key]['state'] = "预设";
  6155. } else if ($value['state'] == 10) {
  6156. $info_list[$key]['state'] = "美店零售";
  6157. }
  6158. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6159. }
  6160. $total = $this->$ck->find_count($where);
  6161. $pagenum = ceil($total / $perpage);
  6162. $over = $total - ($start + $perpage);
  6163. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6164. echo json_encode($rows);
  6165. exit;
  6166. }
  6167. if (isset($post['tmsku'])) {
  6168. $time = time();
  6169. $tmsku = $this->input->post('tmsku', true);
  6170. //$post['shop'] = $this->input->post('shop',true);
  6171. $num = $this->input->post('num', true);
  6172. $cktype = $this->input->post('cktype', true);
  6173. $label = $this->whlabellabel->get_label($tmsku);
  6174. if (!$cktype) {
  6175. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6176. }
  6177. if (!isset($label['warehouse'])) {
  6178. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6179. exit;
  6180. }
  6181. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6182. if (stripos($label['features'], '-126-') !== false) {
  6183. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6184. } else {
  6185. $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 = ''");
  6186. }
  6187. $j = 0;
  6188. if (count($ck) >= $num) {
  6189. for ($i = 0; $i < $num; $i++) {
  6190. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6191. {
  6192. $j++;
  6193. }
  6194. }
  6195. if ($j == $num) {
  6196. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6197. exit;
  6198. } else {
  6199. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6200. exit;
  6201. }
  6202. } else {
  6203. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6204. exit;
  6205. }
  6206. }
  6207. if(isset($_SESSION['api']))
  6208. {
  6209. $user = $this->user->get_api($_SESSION['api']);
  6210. if(in_array($user['power'],[1,27])){
  6211. $vip = 1;
  6212. }
  6213. }
  6214. else
  6215. {
  6216. $vip = 0;
  6217. header('Location: /');exit;
  6218. }
  6219. $this->data['vip'] = $vip;
  6220. $this->_Template('whlabel_printck', $this->data);
  6221. }
  6222. public function _printexcel()
  6223. {
  6224. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6225. $config['upload_path'] = '.' . $dir;
  6226. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6227. $config['allowed_types'] = 'xls|xlsx|csv';
  6228. $config['max_size'] = 10240;
  6229. $this->load->library('upload', $config);
  6230. $this->upload->initialize($config);
  6231. if ($this->upload->do_upload('userfile')) {
  6232. $full_path = $dir . $this->upload->data('file_name');
  6233. $fileName = '.' . $full_path;
  6234. if (!file_exists($fileName)) {
  6235. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6236. exit;
  6237. } else {
  6238. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6239. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6240. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6241. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6242. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6243. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6244. ++$column; //如果列数大于26行
  6245. $list = array();
  6246. for ($i = 2; $i <= $row; $i++) // 行数循环
  6247. {
  6248. $data = array();
  6249. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6250. {
  6251. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6252. }
  6253. $list[] = $data;
  6254. }
  6255. }
  6256. $ed = array();
  6257. $i = 0;
  6258. $j = 0;
  6259. $dcdata = array();
  6260. $yc = '';
  6261. $cmf_arr = array_column($list, '1');
  6262. array_multisort($cmf_arr, SORT_ASC, $list);
  6263. foreach ($list as $key => $value) {
  6264. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6265. if ($typeclass) {
  6266. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6267. } else {
  6268. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6269. $i++;
  6270. continue;
  6271. }
  6272. }
  6273. if ($i > 0) {
  6274. $yc = $i . '条异常';
  6275. }
  6276. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6277. exit;
  6278. }
  6279. }
  6280. public function _uck()
  6281. {
  6282. if (isset($_GET['excel'])) {
  6283. $tc = array();
  6284. $typeclass = $this->typeclass->find_all();
  6285. foreach ($typeclass as $v) {
  6286. $tc[$v['id']] = $v['zh'];
  6287. }
  6288. $data = array();
  6289. $t = array();
  6290. $rq = '';
  6291. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6292. $ts = $ts / (24 * 3600);
  6293. for ($i = 0; $i < $ts; $i++) {
  6294. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6295. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6296. }
  6297. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6298. foreach ($info_list as $k => $v) {
  6299. $features = explode('-', trim($v['features'], '-'));
  6300. if (!isset($features[3]) || !isset($features[4])) {
  6301. continue;
  6302. }
  6303. $data[$k][0] = $tc[$features[0]]; //类型
  6304. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6305. $data[$k][2] = $tc[$features[4]]; //曲度
  6306. $data[$k][3] = '';
  6307. if (isset($data[$k][1])) {
  6308. $data[$k][3] .= $data[$k][1];
  6309. }
  6310. if (isset($data[$k][2])) {
  6311. $data[$k][3] .= $data[$k][2];
  6312. }
  6313. if (isset($features[5])) {
  6314. $data[$k][3] .= $tc[$features[5]];
  6315. }
  6316. if (isset($features[2])) {
  6317. $data[$k][3] .= $tc[$features[2]];
  6318. }
  6319. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6320. $data[$k][4] = $v['sku'];
  6321. $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())) . '))'); //月初库存
  6322. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6323. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6324. $ztrq = '';
  6325. $ztsl = '';
  6326. if (count($zt) > 0) {
  6327. foreach ($zt as $vv) {
  6328. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6329. $ztsl .= $vv['num'] . '<br>';
  6330. }
  6331. }
  6332. $data[$k][] = trim($ztsl, '<br>');
  6333. $data[$k][] = trim($ztrq, '<br>');
  6334. $byck = 0;
  6335. foreach ($t as $vv) {
  6336. $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));
  6337. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6338. $byck += $sl;
  6339. }
  6340. $data[$k][] = ($byck > 0) ? $byck : '';
  6341. }
  6342. $title = "详情 " . date("Y-m-d", time());
  6343. $titlename = "<table border=1>
  6344. <tr align='center'>
  6345. <td>类别</td>
  6346. <td>颜色</td>
  6347. <td>曲度</td>
  6348. <td>名称</td>
  6349. <td>SKU</td>
  6350. <td>月初库存</td>
  6351. <td>剩余库存</td>
  6352. <td>在途数量</td>
  6353. <td>预达日期</td>" .
  6354. $rq
  6355. . "<td>本月出库</td></tr>
  6356. </table>";
  6357. $filename = $title . ".xls";
  6358. $tail = "";
  6359. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6360. }
  6361. }
  6362. public function _whlabelexcelzh()
  6363. {
  6364. if (isset($_GET['excel'])) {
  6365. $where = "sku != 'Preset'";
  6366. //数据排序
  6367. $order_str = "id desc";
  6368. if (empty($page)) {
  6369. $start = 0;
  6370. $perpage = 1;
  6371. } else {
  6372. $start = ($page - 1) * $perpage;
  6373. }
  6374. $category = $this->input->get('category', true);
  6375. $warehouse = $this->input->get('warehouse', true);
  6376. $excelid = $this->input->get('sid', true);
  6377. if ($category) {
  6378. $where .= " and features like '%-$category-%'";
  6379. }
  6380. if ($warehouse) {
  6381. $where .= " and warehouse = '$warehouse'";
  6382. }
  6383. $xzid = '';
  6384. if ($excelid) {
  6385. $excelid = explode(',', trim($excelid, ','));
  6386. foreach ($excelid as $key => $value) {
  6387. $xzid .= " id = " . $value . " or";
  6388. }
  6389. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6390. }
  6391. //取得信息列表
  6392. /**
  6393. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6394. $rows = array();$list = array();
  6395. foreach ($info_list as $key=>$value)
  6396. {
  6397. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6398. }
  6399. **/
  6400. $list = array();
  6401. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6402. foreach ($rows as $key => $value) {
  6403. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6404. $zh = '';
  6405. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6406. foreach ($zt as $v) {
  6407. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6408. }
  6409. $zt = array_sum(array_column($zt, 'num'));
  6410. $number = $value['number'];
  6411. $ftime = time() - 15 * 24 * 3600;
  6412. $warehouse = $this->warehouse->read($value['warehouse']);
  6413. $rows[$key]['warehouse'] = $warehouse['title'];
  6414. $rows[$key]['number'] = $c;
  6415. $rows[$key]['features'] = $zh;
  6416. $rows[$key]['hb'] = $c + $zt;
  6417. }
  6418. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6419. $titlename = "<table border=1>
  6420. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6421. <tr align='center'>
  6422. <td>仓库</td>
  6423. <td>SKU</td>
  6424. <td>产品</td>
  6425. <td>库存数量</td>
  6426. <td>在途数量及预达日期</td>
  6427. <td>在途+库存数量</td>
  6428. </tr>
  6429. </table>";
  6430. $filename = $title . ".xls";
  6431. $tail = "";
  6432. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6433. }
  6434. if (isset($_GET['excel'])) {
  6435. $warehouse = $this->input->get('warehouse', true);
  6436. $sku = $this->input->get('sku', true);
  6437. $cz = $this->input->get('cz', true);
  6438. $text = $this->input->post('text', true);
  6439. $xztime = $this->input->get('xztime', true);
  6440. $timetk = $this->input->get('timetk', true);
  6441. $timetj = $this->input->get('timetj', true);
  6442. $timetk = strtotime($timetk);
  6443. $timetj = strtotime($timetj);
  6444. $where = "time = '0' ";
  6445. if ($warehouse) {
  6446. $where .= " and warehouse = '$warehouse'";
  6447. }
  6448. if ($sku) {
  6449. $where .= " and sku = '$sku'";
  6450. }
  6451. if ($text) {
  6452. $where .= " and text like '%$text%'";
  6453. }
  6454. if ($cz != '') {
  6455. $where .= " and cz = '$cz'";
  6456. }
  6457. if ($timetk && $timetj) {
  6458. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6459. }
  6460. //数据排序
  6461. $order_str = $xztime . " desc";
  6462. //取得信息列表
  6463. $zh = array();
  6464. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6465. foreach ($info_list as $v) {
  6466. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6467. $warehouse = $this->warehouse->read($v['warehouse']);
  6468. $v['warehouse'] = $warehouse['title'];
  6469. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6470. $v['stime'] = date('Y-m-d', $v['stime']);
  6471. if (isset($zh[$v['features']])) {
  6472. $zh[$v['features']]['num'] += $v['num'];
  6473. } else {
  6474. $zh[$v['features']] = $v;
  6475. }
  6476. $zh[$v['features']]['features'] = $c;
  6477. }
  6478. $title = "在途数据" . date('Y-m-d', time());
  6479. $titlename = "<table border=1>
  6480. <tr align='center'>
  6481. <td>仓库</td>
  6482. <td>SKU</td>
  6483. <td>名称</td>
  6484. <td>在途数量</td>
  6485. <td>库存数量</td>
  6486. <td>添加在途日期</td>
  6487. <td>预达日期</td>
  6488. <td>备注</td>
  6489. </tr>
  6490. </table>";
  6491. $filename = $title . ".xls";
  6492. $tail = "";
  6493. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6494. }
  6495. }
  6496. public function _fc()
  6497. {
  6498. $vip = 0;
  6499. if (isset($_SESSION['api'])) {
  6500. $user = $this->user->get_api($_SESSION['api']);
  6501. if ($user['vip'] == 1) {
  6502. $vip = 1;
  6503. }
  6504. } else {
  6505. header('Location: /');
  6506. exit;
  6507. }
  6508. $post = $this->input->post(NULL, TRUE);
  6509. if (isset($post['page'])) {
  6510. $page = $this->input->post('page', true);
  6511. $perpage = $this->input->post('perpage', true);
  6512. $category = $this->input->post('category', true);
  6513. $size = $this->input->post('size', true);
  6514. $grade = $this->input->post('grade', true);
  6515. $color = $this->input->post('color', true);
  6516. $lowe = $this->input->post('lowe', true);
  6517. $sku = $this->input->post('sku');
  6518. $title = $this->input->post('title');
  6519. $warehouse = $this->input->post('warehouse', true);
  6520. $usa = $this->input->post('usa', true);
  6521. $purchase = $this->input->post('purchase', true);
  6522. $lacetype = $this->input->post('lacetype', true);
  6523. $haircap = $this->input->post('haircap', true);
  6524. $density = $this->input->post('density', true);
  6525. $details = $this->input->post('details', true);
  6526. $state = $this->input->post('state', true);
  6527. $ktime = $this->input->post('ktime', true);
  6528. $jtime = $this->input->post('jtime', true);
  6529. $ktime = strtotime($ktime);
  6530. $jtime = strtotime($jtime);
  6531. $where = "state = '11'";
  6532. $gj = "";
  6533. $ck = "";
  6534. if ($lacetype) {
  6535. $where .= " and features like '%-$lacetype-%'";
  6536. }
  6537. if ($category) {
  6538. $where .= " and features like '%-$category-%'";
  6539. }
  6540. if ($size) {
  6541. $where .= " and features like '%-$size-%'";
  6542. }
  6543. if ($grade) {
  6544. $where .= " and features like '%-$grade-%'";
  6545. }
  6546. if ($color) {
  6547. $where .= " and features like '%-$color-%'";
  6548. }
  6549. if ($lowe) {
  6550. $where .= " and features like '%-$lowe-%'";
  6551. }
  6552. if ($haircap) {
  6553. $where .= " and features like '%-$haircap-%'";
  6554. }
  6555. if ($density) {
  6556. $where .= " and features like '%-$density-%'";
  6557. }
  6558. if ($usa) {
  6559. if (!$warehouse) {
  6560. $where .= " and (warehouse = '5' or warehouse = '8')";
  6561. }
  6562. }
  6563. if ($warehouse) {
  6564. $where .= " and warehouse = '$warehouse'";
  6565. }
  6566. if ($details) {
  6567. $where .= " and details = '$details'";
  6568. }
  6569. if ($purchase) {
  6570. $where .= " and purchase = '$purchase'";
  6571. }
  6572. if ($state) {
  6573. $where .= " and state = '$state'";
  6574. }
  6575. if ($ktime && $jtime) {
  6576. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6577. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6578. }
  6579. //数据排序
  6580. $order_str = "id desc";
  6581. if (empty($page)) {
  6582. $start = 0;
  6583. $perpage = 1;
  6584. } else {
  6585. $start = ($page - 1) * $perpage;
  6586. }
  6587. if ($sku) {
  6588. $sku = trim($sku, ' ');
  6589. $sku = trim($sku, ' ');
  6590. $where .= " and sku like '%$sku%'";
  6591. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6592. } else if ($title) {
  6593. $title = trim($title, ' ');
  6594. $title = trim($title, ' ');
  6595. $where .= " and title like '%$title%'";
  6596. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6597. } else {
  6598. //$where .= " and time > '$ktime' and time < '$jtime'";
  6599. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6600. }
  6601. //取得信息列表
  6602. $rows = array();
  6603. $list = array();
  6604. foreach ($info_list as $key => $value) {
  6605. $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'] . '"');
  6606. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6607. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6608. $warehouse = $this->warehouse->read($value['warehouse']);
  6609. $info_list[$key]['warehouse'] = $warehouse['title'];
  6610. $info_list[$key]['number'] = $g;
  6611. $info_list[$key]['features'] = $x;
  6612. $info_list[$key]['x'] = $s;
  6613. }
  6614. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6615. $pagenum = ceil($total / $perpage);
  6616. $over = $total - ($start + $perpage);
  6617. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6618. echo json_encode($rows);
  6619. exit;
  6620. }
  6621. $this->data['vip'] = $vip;
  6622. $this->_Template('whlabel_fc', $this->data);
  6623. }
  6624. public function _fcmb()
  6625. {
  6626. $where = "sku != 'Preset'";
  6627. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6628. foreach ($rows as $k => $v) {
  6629. $warehouse = $this->warehouse->read($v['warehouse']);
  6630. $rows[$k]['warehouse'] = $warehouse['title'];
  6631. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6632. $rows[$k]['t'] = '';
  6633. $rows[$k]['n'] = '';
  6634. }
  6635. $title = "封货产品数据导入模板";
  6636. $titlename = "<table border=1>
  6637. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6638. <tr align='center'>
  6639. <td>仓库</td>
  6640. <td>SKU</td>
  6641. <td>产品</td>
  6642. <td>封存产品总数量</td>
  6643. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6644. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6645. </tr>
  6646. </table>";
  6647. $filename = $title . ".xls";
  6648. $tail = "";
  6649. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6650. }
  6651. public function _fcexcel()
  6652. {
  6653. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6654. $config['upload_path'] = '.' . $dir;
  6655. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6656. $config['allowed_types'] = 'xls|xlsx|csv';
  6657. $config['max_size'] = 10240;
  6658. $this->load->library('upload', $config);
  6659. $this->upload->initialize($config);
  6660. if ($this->upload->do_upload('userfile')) {
  6661. $full_path = $dir . $this->upload->data('file_name');
  6662. $fileName = '.' . $full_path;
  6663. if (!file_exists($fileName)) {
  6664. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6665. exit;
  6666. } else {
  6667. libxml_use_internal_errors(true);
  6668. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6669. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6670. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6671. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6672. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6673. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6674. ++$column; //如果列数大于26行
  6675. $list = array();
  6676. for ($i = 2; $i <= $row; $i++) // 行数循环
  6677. {
  6678. $data = array();
  6679. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6680. {
  6681. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6682. }
  6683. $list[] = $data;
  6684. }
  6685. }
  6686. $i = 0;
  6687. $j = 0;
  6688. $ed = array();
  6689. foreach ($list as $key => $value) {
  6690. $time = time();
  6691. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6692. continue;
  6693. }
  6694. $warehouse = $this->warehouse->get_title($value['0']);
  6695. $sku = $value['1'];
  6696. $type = $value['4']; //调整方式0扣减1删除
  6697. $num = $value['5']; //调整数量
  6698. //$text = $value['4'];//扣减说明
  6699. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6700. if (!$d) //如果没有这个SKU
  6701. {
  6702. $ed[] = array($sku . '-库存中不存在此SKU');
  6703. $j++;
  6704. continue;
  6705. }
  6706. if (!isset($warehouse['id'])) {
  6707. $ed[] = array($sku . '-仓库名错误!');
  6708. $j++;
  6709. continue;
  6710. }
  6711. if ($type == 1 || $type == 2) //扣减库存
  6712. {
  6713. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6714. if (count($data) < abs($num)) {
  6715. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6716. $j++;
  6717. continue;
  6718. }
  6719. if ($type == 1) //转入库存
  6720. {
  6721. for ($i = 0; $i < abs($num); $i++) {
  6722. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6723. }
  6724. } else if ($type == 2) //删除
  6725. {
  6726. for ($i = 0; $i < abs($num); $i++) {
  6727. $this->whlabel->remove($data[$i]['id']);
  6728. }
  6729. }
  6730. } else if ($type == 0) //增加库存
  6731. {
  6732. $post['sku'] = $d['sku'];
  6733. $post['shop'] = '';
  6734. $post['warehouse'] = $warehouse['id'];
  6735. $post['purchase'] = $d['purchase'];
  6736. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6737. $post['state'] = 11;
  6738. $post['title'] = $d['title'];
  6739. $post['number'] = $d['number'];
  6740. $post['features'] = $d['features'];
  6741. $post['enter'] = $time;
  6742. $post['time'] = $time; //操作时间
  6743. for ($i = 0; $i < $num; $i++) {
  6744. $post['label'] = time() . rand(100, 999) . $i;
  6745. $this->whlabel->insert($post);
  6746. }
  6747. }
  6748. sleep(1); //防止入库时间一样,需要延迟1秒
  6749. }
  6750. if ($j > 0) {
  6751. $tt = date('Ymd', time());
  6752. $title = '库存导入错误信息-' . $tt;
  6753. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6754. $tail = "\n";
  6755. $filename = $title . ".xls";
  6756. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6757. $dir = '/data/excel/' . $time . '/';
  6758. $file_name = 'error_' . $time . rand(1000, 9999);
  6759. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6760. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6761. fwrite($myfile, $ecl);
  6762. fclose($myfile);
  6763. $error = $dir . $file_name . '.xls';
  6764. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6765. exit;
  6766. } else {
  6767. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6768. exit;
  6769. }
  6770. }
  6771. }
  6772. public function _fcjxc($arg_array)
  6773. {
  6774. if (isset($_GET['excel'])) {
  6775. $category = $this->input->get('category', true);
  6776. $size = $this->input->get('size', true);
  6777. $grade = $this->input->get('grade', true);
  6778. $color = $this->input->get('color', true);
  6779. $lowe = $this->input->get('lowe', true);
  6780. $sku = $this->input->get('sku');
  6781. $title = $this->input->get('title');
  6782. $warehouse = $arg_array[0];
  6783. $usa = $this->input->get('usa', true);
  6784. $purchase = $this->input->get('purchase', true);
  6785. $lacetype = $this->input->get('lacetype', true);
  6786. $haircap = $this->input->get('haircap', true);
  6787. $density = $this->input->get('density', true);
  6788. $title = $this->input->get('title', true);
  6789. $state = $this->input->get('state', true);
  6790. $ktime = $this->input->get('ktime', true);
  6791. $jtime = $this->input->get('jtime', true);
  6792. $where = "state=11";
  6793. $gj = "";
  6794. $ck = "";
  6795. if ($lacetype) {
  6796. $where .= " and features like '%-$lacetype-%'";
  6797. }
  6798. if ($category) {
  6799. $where .= " and features like '%-$category-%'";
  6800. }
  6801. if ($size) {
  6802. $where .= " and features like '%-$size-%'";
  6803. }
  6804. if ($grade) {
  6805. $where .= " and features like '%-$grade-%'";
  6806. }
  6807. if ($color) {
  6808. $where .= " and features like '%-$color-%'";
  6809. }
  6810. if ($lowe) {
  6811. $where .= " and features like '%-$lowe-%'";
  6812. }
  6813. if ($haircap) {
  6814. $where .= " and features like '%-$haircap-%'";
  6815. }
  6816. if ($density) {
  6817. $where .= " and features like '%-$density-%'";
  6818. }
  6819. if ($usa) {
  6820. if (!$warehouse) {
  6821. $where .= " and (warehouse = '5' or warehouse = '8')";
  6822. }
  6823. }
  6824. if ($warehouse) {
  6825. $where .= " and warehouse = '$warehouse'";
  6826. }
  6827. if ($purchase) {
  6828. $where .= " and purchase = '$purchase'";
  6829. }
  6830. if ($state) {
  6831. $where .= " and state = '$state'";
  6832. }
  6833. $order_str = "id desc";
  6834. if ($sku) {
  6835. $sku = trim($sku, ' ');
  6836. $sku = trim($sku, ' ');
  6837. $where .= " and sku like '%$sku%'";
  6838. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6839. } else if ($title) {
  6840. $title = trim($title, ' ');
  6841. $title = trim($title, ' ');
  6842. $where .= " and title like '%$title%'";
  6843. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6844. } else {
  6845. //$where .= " and time > '$ktime' and time < '$jtime'";
  6846. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6847. }
  6848. //取得信息列表
  6849. $rows = array();
  6850. $list = array();
  6851. foreach ($info_list as $key => $value) {
  6852. $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'] . '"');
  6853. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6854. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6855. $rows[$key] = $value;
  6856. $warehouse = $this->warehouse->read($value['warehouse']);
  6857. $rows[$key]['warehouse'] = $warehouse['title'];
  6858. $rows[$key]['features'] = $g;
  6859. $rows[$key]['a'] = $x;
  6860. $rows[$key]['b'] = $s;
  6861. }
  6862. $title = "总统计表";
  6863. $titlename = "<table border=1>
  6864. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6865. <tr align='center'>
  6866. <td>仓库</td>
  6867. <td>SKU</td>
  6868. <td>产品名称</td>
  6869. <td>录入总量</td>
  6870. <td>取出总量</td>
  6871. <td>剩余总量</td>
  6872. </tr>
  6873. </table>";
  6874. $filename = $title . ".xls";
  6875. $tail = "";
  6876. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6877. }
  6878. $vip = 0;
  6879. if (isset($_SESSION['api'])) {
  6880. $user = $this->user->get_api($_SESSION['api']);
  6881. if ($user['vip'] == 1) {
  6882. $vip = 1;
  6883. }
  6884. } else {
  6885. header('Location: /');
  6886. exit;
  6887. }
  6888. $post = $this->input->post(NULL, TRUE);
  6889. if (isset($post['page'])) {
  6890. $page = $this->input->post('page', true);
  6891. $perpage = $this->input->post('perpage', true);
  6892. $category = $this->input->post('category', true);
  6893. $size = $this->input->post('size', true);
  6894. $grade = $this->input->post('grade', true);
  6895. $color = $this->input->post('color', true);
  6896. $lowe = $this->input->post('lowe', true);
  6897. $sku = $this->input->post('sku');
  6898. $title = $this->input->post('title');
  6899. $warehouse = $arg_array[0];
  6900. $usa = $this->input->post('usa', true);
  6901. $purchase = $this->input->post('purchase', true);
  6902. $lacetype = $this->input->post('lacetype', true);
  6903. $haircap = $this->input->post('haircap', true);
  6904. $density = $this->input->post('density', true);
  6905. $title = $this->input->post('title', true);
  6906. $state = $this->input->post('state', true);
  6907. $ktime = $this->input->post('ktime', true);
  6908. $jtime = $this->input->post('jtime', true);
  6909. $ktime = strtotime($ktime);
  6910. $jtime = strtotime($jtime);
  6911. $where = "state=11";
  6912. $gj = "";
  6913. $ck = "";
  6914. if ($lacetype) {
  6915. $where .= " and features like '%-$lacetype-%'";
  6916. }
  6917. if ($category) {
  6918. $where .= " and features like '%-$category-%'";
  6919. }
  6920. if ($size) {
  6921. $where .= " and features like '%-$size-%'";
  6922. }
  6923. if ($grade) {
  6924. $where .= " and features like '%-$grade-%'";
  6925. }
  6926. if ($color) {
  6927. $where .= " and features like '%-$color-%'";
  6928. }
  6929. if ($lowe) {
  6930. $where .= " and features like '%-$lowe-%'";
  6931. }
  6932. if ($haircap) {
  6933. $where .= " and features like '%-$haircap-%'";
  6934. }
  6935. if ($density) {
  6936. $where .= " and features like '%-$density-%'";
  6937. }
  6938. if ($usa) {
  6939. if (!$warehouse) {
  6940. $where .= " and (warehouse = '5' or warehouse = '8')";
  6941. }
  6942. }
  6943. if ($warehouse) {
  6944. $where .= " and warehouse = '$warehouse'";
  6945. }
  6946. if ($purchase) {
  6947. $where .= " and purchase = '$purchase'";
  6948. }
  6949. if ($state) {
  6950. $where .= " and state = '$state'";
  6951. }
  6952. if ($ktime && $jtime) {
  6953. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6954. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6955. }
  6956. //数据排序
  6957. $order_str = "id desc";
  6958. $xs = 0;
  6959. $rows = array();
  6960. $list = array();
  6961. if (empty($page)) {
  6962. $start = 0;
  6963. $perpage = 1;
  6964. } else {
  6965. $start = ($page - 1) * $perpage;
  6966. }
  6967. if ($sku || $title) {
  6968. if ($title) {
  6969. $title = trim($title, ' ');
  6970. $title = trim($title, ' ');
  6971. $where .= " and title like '%$title%'";
  6972. } else {
  6973. $sku = trim($sku, ' ');
  6974. $sku = trim($sku, ' ');
  6975. $where .= " and sku like '%$sku%'";
  6976. }
  6977. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6978. foreach ($info_list as $key => $value) {
  6979. $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'] . '"');
  6980. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6981. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6982. $rows[$key] = $value;
  6983. $warehouse = $this->warehouse->read($value['warehouse']);
  6984. $rows[$key]['warehouse'] = $warehouse['title'];
  6985. $rows[$key]['features'] = $g;
  6986. $rows[$key]['a'] = $x;
  6987. $rows[$key]['b'] = $s;
  6988. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6989. $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天销量
  6990. $yj = $c / ($xl / 30);
  6991. if ($yj < 7) {
  6992. $rows[$key]['y'] = round($yj) . '天销量';
  6993. } else {
  6994. $rows[$key]['y'] = '正常';
  6995. }
  6996. }
  6997. } else {
  6998. //$where .= " and time > '$ktime' and time < '$jtime'";
  6999. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7000. foreach ($info_list as $key => $value) {
  7001. $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'] . '"');
  7002. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7003. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7004. $zs[$key] = $value;
  7005. $warehouse = $this->warehouse->read($value['warehouse']);
  7006. $zs[$key]['warehouse'] = $warehouse['title'];
  7007. $zs[$key]['features'] = $g;
  7008. $zs[$key]['a'] = $x;
  7009. $zs[$key]['b'] = $s;
  7010. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7011. $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天销量
  7012. $yj = $c / ($xl / 30);
  7013. if ($yj < 7) {
  7014. $zs[$key]['y'] = round($yj) . '天销量';
  7015. $rows[$key] = $zs[$key];
  7016. }
  7017. }
  7018. }
  7019. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7020. $pagenum = ceil($total / $perpage);
  7021. $over = $total - ($start + $perpage);
  7022. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7023. echo json_encode($rows);
  7024. exit;
  7025. }
  7026. $this->data['arg_array'] = $arg_array[0];
  7027. $this->_Template('whlabel_fcjxc', $this->data);
  7028. }
  7029. public function _0kcdel()
  7030. {
  7031. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7032. $config['upload_path'] = '.' . $dir;
  7033. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7034. $config['allowed_types'] = 'xls|xlsx|csv';
  7035. $config['max_size'] = 10240;
  7036. $this->load->library('upload', $config);
  7037. $this->upload->initialize($config);
  7038. if ($this->upload->do_upload('userfile')) {
  7039. $full_path = $dir . $this->upload->data('file_name');
  7040. $fileName = '.' . $full_path;
  7041. if (!file_exists($fileName)) {
  7042. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7043. exit;
  7044. } else {
  7045. require_once "./data/excel/PHPExcel/IOFactory.php";
  7046. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7047. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7048. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7049. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7050. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7051. ++$column; //如果列数大于26行
  7052. $list = array();
  7053. for ($i = 2; $i <= $row; $i++) // 行数循环
  7054. {
  7055. $data = array();
  7056. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7057. {
  7058. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7059. }
  7060. $list[] = $data;
  7061. }
  7062. }
  7063. $i = 0;
  7064. $j = 0;
  7065. $ed = array();
  7066. foreach ($list as $key => $value) {
  7067. $time = time();
  7068. if ($value['0'] == "" || $value['1'] == "") {
  7069. continue;
  7070. }
  7071. $warehouse = $this->warehouse->get_title($value['0']);
  7072. $sku = $value['1'];
  7073. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7074. if (!$d) //如果没有这个SKU
  7075. {
  7076. $ed[] = array($sku . '-库存中不存在此SKU');
  7077. $j++;
  7078. continue;
  7079. }
  7080. if (!isset($warehouse['id'])) {
  7081. $ed[] = array($sku . '-仓库名错误!');
  7082. $j++;
  7083. continue;
  7084. }
  7085. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7086. if ($z < 1) {
  7087. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7088. foreach ($z as $v) {
  7089. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7090. if (count($zt) > 0) {
  7091. $ed[] = array($sku . '-有在途库存无法删除!');
  7092. $j++;
  7093. continue;
  7094. }
  7095. $this->whlabel->remove($v['id']);
  7096. }
  7097. } else {
  7098. $ed[] = array($sku . '-非0库存!');
  7099. $j++;
  7100. continue;
  7101. }
  7102. }
  7103. if ($j > 0) {
  7104. $tt = date('Ymd', time());
  7105. $title = '删除0库存错误信息-' . $tt;
  7106. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7107. $tail = "\n";
  7108. $filename = $title . ".xls";
  7109. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7110. $dir = '/data/excel/' . $time . '/';
  7111. $file_name = 'error_' . $time . rand(1000, 9999);
  7112. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7113. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7114. fwrite($myfile, $ecl);
  7115. fclose($myfile);
  7116. $error = $dir . $file_name . '.xls';
  7117. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7118. exit;
  7119. } else {
  7120. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7121. exit;
  7122. }
  7123. }
  7124. }
  7125. public function _gbhtype()
  7126. {
  7127. $post = $this->input->post(NULL, TRUE);
  7128. if (isset($post['s'])) {
  7129. $n = $this->input->post('n');
  7130. $d = $this->input->post('s');
  7131. if (!$d) {
  7132. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7133. exit;
  7134. }
  7135. $d = explode(',', trim($d, ','));
  7136. $t = $this->whlabel_type->read($n);
  7137. //循环删除记录
  7138. foreach ($d as $v) {
  7139. $u = $this->whlabel->read($v);
  7140. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7141. foreach ($data as $val) {
  7142. $this->whlabel->save(array('type' => $n), $val['id']);
  7143. }
  7144. }
  7145. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7146. }
  7147. }
  7148. //出库、退库导出
  7149. public function _dccrtype()
  7150. {
  7151. $classid = $this->classid->sku();
  7152. $pm = $classid;
  7153. $typeclass = array();
  7154. $tc = $this->typeclass->find_all();
  7155. foreach ($tc as $v) {
  7156. $typeclass[$v['id']] = $v;
  7157. }
  7158. $prc = array();
  7159. $purchase = $this->purchase->find_all();
  7160. foreach ($purchase as $k => $v) {
  7161. $prc[$v['id']] = $v['title'];
  7162. }
  7163. if (isset($_GET['sid'])) {
  7164. $wh = array();
  7165. $w = $this->warehouse->find_all('1=1', 'id,title');
  7166. foreach ($w as $v) {
  7167. $wh[$v['id']] = $v['title'];
  7168. }
  7169. $type = $this->input->get('excel', true);
  7170. $category = $this->input->get('category', true);
  7171. $size = $this->input->get('size', true);
  7172. $grade = $this->input->get('grade', true);
  7173. $color = $this->input->get('color', true);
  7174. $lowe = $this->input->get('lowe', true);
  7175. $sku = $this->input->get('sku', true);
  7176. $warehouse = $this->input->get('warehouse', true);
  7177. $lacetype = $this->input->get('lacetype', true);
  7178. $lacecolor = $this->input->get('lacecolor', true);
  7179. $density = $this->input->get('density', true);
  7180. $haircap = $this->input->get('haircap', true);
  7181. $purchase = $this->input->get('purchase', true);
  7182. $title = $this->input->get('title', true);
  7183. $state = $this->input->get('state', true);
  7184. $sid = $this->input->get('sid', true);
  7185. $ktime = $this->input->get('ktime', true);
  7186. $jtime = $this->input->get('jtime', true);
  7187. $ktime = strtotime($ktime);
  7188. $jtime = strtotime($jtime);
  7189. $where = "1=1";
  7190. $gj = "";
  7191. $ck = "";
  7192. if ($category) {
  7193. $where .= " and features like '%-$category-%'";
  7194. }
  7195. if ($size) {
  7196. $where .= " and features like '%-$size-%'";
  7197. }
  7198. if ($grade) {
  7199. $where .= " and features like '%-$grade-%'";
  7200. }
  7201. if ($color) {
  7202. $where .= " and features like '%-$color-%'";
  7203. }
  7204. if ($lowe) {
  7205. $where .= " and features like '%-$lowe-%'";
  7206. }
  7207. if ($warehouse) {
  7208. $where .= " and warehouse = '$warehouse'";
  7209. }
  7210. if ($purchase) {
  7211. $where .= " and purchase = '$purchase'";
  7212. }
  7213. if ($state) {
  7214. $where .= " and state = '$state'";
  7215. }
  7216. if ($lacetype) {
  7217. $where .= " and features like '%-$lacetype-%'";
  7218. }
  7219. if ($lacecolor) {
  7220. $where .= " and features like '%-$lacecolor-%'";
  7221. }
  7222. if ($density) {
  7223. $where .= " and features like '%-$density-%'";
  7224. }
  7225. if ($haircap) {
  7226. $where .= " and features like '%-$haircap-%'";
  7227. }
  7228. if ($title) {
  7229. $title = trim($title, ' ');
  7230. $title = trim($title, ' ');
  7231. $where .= " and title like '%$title%'";
  7232. }
  7233. if ($sku) {
  7234. $sku = trim($sku, ' ');
  7235. $sku = trim($sku, ' ');
  7236. $where .= " and sku like '%$sku%'";
  7237. }
  7238. if ($ktime && $jtime) {
  7239. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7240. }
  7241. $sidwhere = '';
  7242. if ($sid) {
  7243. $sd = "";
  7244. $s = explode(',', trim($sid, ','));
  7245. foreach ($s as $value) {
  7246. $sd .= " id = " . $value . " or";
  7247. }
  7248. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7249. }
  7250. //数据排序
  7251. $order_str = "time desc";
  7252. if (empty($page)) {
  7253. $start = 0;
  7254. $perpage = 1;
  7255. } else {
  7256. $start = ($page - 1) * $perpage;
  7257. }
  7258. $wh = array();
  7259. $w = $this->warehouse->find_all('1=1', 'id,title');
  7260. foreach ($w as $v) {
  7261. $wh[$v['id']] = $v['title'];
  7262. }
  7263. $wt = array();
  7264. $whlabel_type = $this->whlabel_type->find_all();
  7265. foreach ($whlabel_type as $v) {
  7266. $wt[$v['id']] = $v['title'];
  7267. }
  7268. $classid = $this->classid->sku();
  7269. $list = array();
  7270. $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');
  7271. foreach ($rows_r as $key => $value) {
  7272. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7273. $pm = $classid;
  7274. $jm = $classid;
  7275. $rows_r[$key]['enter'] = '入库';
  7276. $rows_r[$key]['time'] = $value['enter'];
  7277. if ($value['rktype'] == 1) {
  7278. $rows_r[$key]['rktype'] = '采购入库';
  7279. } else if ($value['rktype'] == 2) {
  7280. $rows_r[$key]['rktype'] = '盘盈调整';
  7281. } else if ($value['rktype'] == 3) {
  7282. $rows_r[$key]['rktype'] = '其他调整入库';
  7283. } else if ($value['rktype'] == 4) {
  7284. $rows_r[$key]['rktype'] = '其他调整入库';
  7285. } else if ($value['rktype'] == 5) {
  7286. $rows_r[$key]['rktype'] = '退库入库';
  7287. } else if ($value['rktype'] == 6) {
  7288. $rows_r[$key]['rktype'] = '退货可用入库';
  7289. } else if ($value['rktype'] == 7) {
  7290. $rows_r[$key]['rktype'] = '形态转换入库';
  7291. } else {
  7292. $rows_r[$key]['rktype'] = '';
  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_r[$key]['zh'] = $zh;
  7310. $jm = array_filter($jm);
  7311. $rows_r[$key]['features'] = implode("-", $jm);
  7312. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7313. }
  7314. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout,state');
  7315. foreach ($rows_c as $key => $value) {
  7316. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7317. $pm = $classid;
  7318. $jm = $classid;
  7319. $rows_c[$key]['time'] = $value['outk'];
  7320. $rows_c[$key]['outk'] = '出库';
  7321. if ($value['cktype'] == 1) {
  7322. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7323. } else if ($value['cktype'] == 2) {
  7324. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7325. } else if ($value['cktype'] == 3) {
  7326. $rows_c[$key]['cktype'] = '盘亏调整';
  7327. } else if ($value['cktype'] == 4) {
  7328. $rows_c[$key]['cktype'] = '其他调整出库';
  7329. } else if ($value['cktype'] == 5) {
  7330. $rows_c[$key]['cktype'] = '形态转换出库';
  7331. } else {
  7332. $rows_c[$key]['cktype'] = '';
  7333. }
  7334. unset($rows_c[$key]['state']);
  7335. $features = explode('-', trim($value['features'], '-'));
  7336. foreach ($features as $v) {
  7337. if (isset($typeclass[$v])) {
  7338. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7339. $pm[$typeclass[$v]['classid']] = $zh[0];
  7340. }
  7341. if (isset($typeclass[$v])) {
  7342. if (isset($jm[$typeclass[$v]['classid']])) {
  7343. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7344. }
  7345. }
  7346. }
  7347. $zh = implode(" ", $pm);
  7348. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7349. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7350. $rows_c[$key]['zh'] = $zh;
  7351. $jm = array_filter($jm);
  7352. $rows_c[$key]['features'] = implode("-", $jm);
  7353. $rows_c[$key]['number'] = 1;
  7354. }
  7355. $merged = $rows_r;
  7356. foreach ($rows_c as $key => $value) {
  7357. if (isset($merged[$key])) {
  7358. $merged[] = $value;
  7359. } else {
  7360. $merged[$key] = $value;
  7361. }
  7362. }
  7363. usort($merged, function ($a, $b) {
  7364. return $a['time'] - $b['time'];
  7365. });
  7366. foreach ($merged as $key => $value) {
  7367. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7368. }
  7369. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7370. $titlename = "<table border=1>
  7371. <tr align='center'>
  7372. <td>仓库</td>
  7373. <td>SKU</td>
  7374. <td>商品名称</td>
  7375. <td>仓库品名</td>
  7376. <td>料号</td>
  7377. <td>时间</td>
  7378. <td>操作</td>
  7379. <td>类型</td>
  7380. <td>数量</td>
  7381. <td>备注</td>
  7382. </tr>
  7383. </table>";
  7384. $filename = $title . ".xlsx";
  7385. $tail = "";
  7386. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7387. }
  7388. }
  7389. }