Whlabel.php 259 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. }
  45. //定义方法的调用规则 获取URI第二段值
  46. public function _remap($arg, $arg_array)
  47. {
  48. if ($arg == 'existence') //在库标签
  49. {
  50. $this->_existence();
  51. } else if ($arg == 'cpbqdc') //在库标签
  52. {
  53. $this->_cpbqdc();
  54. } else if ($arg == 'type') //进销存浏览
  55. {
  56. $this->_type();
  57. } else if ($arg == 'typedy') //进销存浏览店员页面
  58. {
  59. $this->_typedy($arg_array);
  60. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  61. {
  62. $this->_typedy_ck($arg_array);
  63. } else if ($arg == 'typeck') {
  64. $this->_typeck($arg_array);
  65. } else if ($arg == 'whlabeckdc') {
  66. $this->_whlabeckdc($arg_array);
  67. } else if ($arg == 'usatype') //美仓进销存浏览
  68. {
  69. $this->_usatype();
  70. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  71. {
  72. $this->_usatypeapp();
  73. } else if ($arg == 'enteradd') //入库操作
  74. {
  75. $this->_enteradd();
  76. } else if ($arg == 'enteredit') //修改
  77. {
  78. $this->_enteredit($arg_array);
  79. } else if ($arg == 'enter') //入库浏览
  80. {
  81. $this->_enter();
  82. } else if ($arg == 'out') //出库浏览
  83. {
  84. $this->_out();
  85. } else if ($arg == 'label') //出库标签浏览
  86. {
  87. $this->_label();
  88. } else if ($arg == 'outorder') //独立站出库订单
  89. {
  90. $this->_outorder();
  91. } else if ($arg == 'soutorder') //速卖通出库订单
  92. {
  93. $this->_soutorder();
  94. } else if ($arg == 'toutorder') //TT出库订单
  95. {
  96. $this->_toutorder();
  97. }else if ($arg == 'aoutorder') //amz出库订单
  98. {
  99. $this->_aoutorder();
  100. } else if ($arg == 'retreat') //退库订单
  101. {
  102. $this->_retreat();
  103. } else if ($arg == 'retreatlk') //退库订单
  104. {
  105. $this->_retreatlk();
  106. } else if ($arg == 'change') //更换标签
  107. {
  108. $this->_change();
  109. } else if ($arg == 'del') //删除
  110. {
  111. $this->_del();
  112. } else if ($arg == 'exceljxc') //进销存信息导出
  113. {
  114. $this->_exceljxc();
  115. } else if ($arg == 'excelr') //入库信息导出
  116. {
  117. $this->_excelr();
  118. } else if ($arg == 'excelct') //出库、退库信息导出
  119. {
  120. $this->_excelct();
  121. } else if ($arg == 'dccrtype') //根据出入库类型导出
  122. {
  123. $this->_dccrtype();
  124. } else if ($arg == 'excelcr') //出库、退库信息导出
  125. {
  126. $this->_excelcr();
  127. } else if ($arg == 'kcyz') //库存验证
  128. {
  129. $this->_kcyz();
  130. } else if ($arg == 'kj') //库存扣减
  131. {
  132. $this->_kj($arg_array);
  133. } else if ($arg == 'presetout') //预设库存导入
  134. {
  135. $this->_presetout($arg_array);
  136. } else if ($arg == 'presetedit') //预设库存导入
  137. {
  138. $this->_presetedit($arg_array);
  139. } else if ($arg == 'summary') //汇总导出
  140. {
  141. $this->_summary($arg_array);
  142. } else if ($arg == 'manifest') //usps发货清单
  143. {
  144. $this->_manifest();
  145. } else if ($arg == 'abnormal') //占单异常
  146. {
  147. $this->_abnormal();
  148. } else if ($arg == 'error') //0库存SKU
  149. {
  150. $this->_error();
  151. } else if ($arg == 'errorexcel') //0库存SKU导出
  152. {
  153. $this->_errorexcel();
  154. } else if ($arg == 'db') {
  155. $this->_db();
  156. } else if ($arg == 'dbrk') {
  157. $this->_dbrk();
  158. } else if ($arg == 'whlabelczdc') {
  159. $this->_whlabelczdc();
  160. } else if ($arg == 'print') {
  161. $this->_print($arg_array);
  162. } else if ($arg == 'usaprint') {
  163. $this->_usaprint($arg_array);
  164. } else if ($arg == 'printck') {
  165. $this->_printck($arg_array);
  166. } else if ($arg == 'printrk') {
  167. $this->_printrk($arg_array);
  168. } else if ($arg == 'printxzrk') {
  169. $this->_printxzrk($arg_array);
  170. } else if ($arg == 'printexcel') {
  171. $this->_printexcel($arg_array);
  172. } else if ($arg == 'uck') {
  173. $this->_uck();
  174. } else if ($arg == 'whlabelexcelzh') {
  175. $this->_whlabelexcelzh();
  176. } else if ($arg == 'fc') {
  177. $this->_fc();
  178. } else if ($arg == 'fcmb') {
  179. $this->_fcmb();
  180. } else if ($arg == 'fcexcel') {
  181. $this->_fcexcel();
  182. } else if ($arg == 'fcjxc') {
  183. $this->_fcjxc($arg_array);
  184. } else if ($arg == '0kcdel') {
  185. $this->_0kcdel(); //导表删除0库存
  186. } else if ($arg == 'gbhtype') {
  187. $this->_gbhtype(); //更改备货状态
  188. } else {
  189. $this->_index();
  190. }
  191. }
  192. //管理
  193. public function _index()
  194. {
  195. $post = $this->input->post(NULL, TRUE);
  196. if (isset($post['page'])) {
  197. $page = $this->input->post('page', true);
  198. $perpage = $this->input->post('perpage', true);
  199. $sku = $this->input->post('sku', true);
  200. $number = $this->input->post('number', true);
  201. $warehouse = $this->input->post('warehouse', true);
  202. $purchase = $this->input->post('purchase', true);
  203. $orderinfo = $this->input->post('orderinfo', true);
  204. $waybill = $this->input->post('waybill', true);
  205. $category = $this->input->post('category', true);
  206. $size = $this->input->post('size', true);
  207. $grade = $this->input->post('grade', true);
  208. $color = $this->input->post('color', true);
  209. $lowe = $this->input->post('lowe', true);
  210. $state = $this->input->post('state', true);
  211. $label = $this->input->post('label', true);
  212. $timetk = $this->input->post('timetkk', true);
  213. $timetj = $this->input->post('timetjj', true);
  214. $timetk = strtotime($timetk);
  215. $timetj = strtotime($timetj);
  216. $where = "1=1 ";
  217. if ($timetk && $timetj) {
  218. $where .= " and time > '$timetk' and time < '$timetj'";
  219. }
  220. if ($sku) {
  221. $where .= " and sku = '$sku'";
  222. }
  223. if ($number) {
  224. $where .= " and number = '$number'";
  225. }
  226. if ($warehouse) {
  227. $where .= " and warehouse = '$warehouse'";
  228. }
  229. if ($purchase) {
  230. $where .= " and purchase = '$purchase'";
  231. }
  232. if ($orderinfo) {
  233. $where .= " and orderinfo = '$orderinfo'";
  234. }
  235. if ($waybill) {
  236. $where .= " and waybill = '$waybill'";
  237. }
  238. if ($category) {
  239. $where .= " and features like '%-$category-%'";
  240. }
  241. if ($size) {
  242. $where .= " and features like '%-$size-%'";
  243. }
  244. if ($grade) {
  245. $where .= " and features like '%-$grade-%'";
  246. }
  247. if ($color) {
  248. $where .= " and features like '%-$color-%'";
  249. }
  250. if ($lowe) {
  251. $where .= " and features like '%-$lowe-%'";
  252. }
  253. if ($label) {
  254. $where .= " and label = '$label'";
  255. }
  256. if ($state != '') {
  257. $where .= " and state = '$state'";
  258. }
  259. //数据排序
  260. $order_str = "time desc";
  261. if (empty($page)) {
  262. $start = 0;
  263. $perpage = 1;
  264. } else {
  265. $start = ($page - 1) * $perpage;
  266. }
  267. //取得信息列表
  268. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  269. foreach ($info_list as $key => $value) {
  270. $warehouse = $this->warehouse->read($value['warehouse']);
  271. $info_list[$key]['warehouse'] = $warehouse['title'];
  272. $purchase = $this->purchase->read($value['purchase']);
  273. $info_list[$key]['purchase'] = $purchase['title'];
  274. if ($value['enter'] != 0) {
  275. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  276. } else {
  277. $info_list[$key]['enter'] = "";
  278. }
  279. if ($value['outk'] != 0) {
  280. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  281. } else {
  282. $info_list[$key]['outk'] = "";
  283. }
  284. if ($value['printing'] != 0) {
  285. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  286. } else {
  287. $info_list[$key]['printing'] = "";
  288. }
  289. if ($value['orderinfo'] == 0) {
  290. $info_list[$key]['orderinfo'] = "";
  291. }
  292. if ($value['waybill'] == 0) {
  293. $info_list[$key]['waybill'] = "";
  294. }
  295. if ($value['state'] == 0) {
  296. $info_list[$key]['state'] = "在库";
  297. } else if ($value['state'] == 1) {
  298. $info_list[$key]['state'] = "出库";
  299. } else if ($value['state'] == 2) {
  300. $info_list[$key]['state'] = "退库";
  301. } else if ($value['state'] == 3) {
  302. $info_list[$key]['state'] = "调拨中";
  303. } else if ($value['state'] == 4) {
  304. $info_list[$key]['state'] = "再加工";
  305. } else if ($value['state'] == 5) {
  306. $info_list[$key]['state'] = "维修中";
  307. } else if ($value['state'] == 6) {
  308. $info_list[$key]['state'] = "盘亏";
  309. } else if ($value['state'] == 7) {
  310. $info_list[$key]['state'] = "更换标签";
  311. } else if ($value['state'] == 8) {
  312. $info_list[$key]['state'] = "其它";
  313. } else if ($value['state'] == 9) {
  314. $info_list[$key]['state'] = "预设";
  315. } else if ($value['state'] == 10) {
  316. $info_list[$key]['state'] = "美店零售";
  317. }
  318. if ($value['text'] == "") {
  319. $info_list[$key]['text'] = "";
  320. }
  321. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  322. }
  323. $total = $this->whlabel->find_count($where);
  324. $pagenum = ceil($total / $perpage);
  325. $over = $total - ($start + $perpage);
  326. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  327. echo json_encode($rows);
  328. exit;
  329. }
  330. if (isset($post['outsku'])) {
  331. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  332. $cz = $this->input->post('cz', true);
  333. if ($cz == '1') {
  334. $sku = $this->input->post('outsku', true);
  335. if ($sku) {
  336. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  337. if (count($data) < 1) {
  338. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  339. exit;
  340. }
  341. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  342. echo json_encode(array('success' => true));
  343. exit;
  344. }
  345. } else {
  346. $sku = $this->input->post('outsku', true);
  347. if ($sku) {
  348. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  349. if (count($data) < 1) {
  350. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  351. exit;
  352. }
  353. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  354. echo json_encode(array('success' => true));
  355. exit;
  356. }
  357. }
  358. }
  359. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  360. $this->_Template('whlabel', $this->data);
  361. }
  362. //在库标签
  363. public function _existence()
  364. {
  365. $post = $this->input->post(NULL, TRUE);
  366. if (isset($post['s'])) {
  367. $id_arr = $this->input->post('s');
  368. $id_arr = explode(',', $id_arr);
  369. if (!$id_arr) {
  370. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  371. exit;
  372. }
  373. //循环删除记录
  374. foreach ($id_arr as $v) {
  375. $sid = $this->whlabel->read($v);
  376. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  377. if ($count > 0) {
  378. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  379. exit;
  380. }
  381. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  382. if (count($zt) > 0) {
  383. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  384. exit;
  385. }
  386. $this->whlabel->remove($v);
  387. }
  388. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  389. exit;
  390. }
  391. if (isset($post['page'])) {
  392. $page = $this->input->post('page', true);
  393. $perpage = $this->input->post('perpage', true);
  394. $warehouse = $this->input->post('warehouse', true);
  395. $label = $this->input->post('label', true);
  396. $where = "1=1 and state = 0";
  397. if ($warehouse) {
  398. $where .= " and warehouse = '$warehouse'";
  399. }
  400. if ($label) {
  401. $where .= " and label = '$label'";
  402. }
  403. //数据排序
  404. $order_str = "time asc";
  405. if (empty($page)) {
  406. $start = 0;
  407. $perpage = 1;
  408. } else {
  409. $start = ($page - 1) * $perpage;
  410. }
  411. //取得信息列表
  412. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  413. foreach ($info_list as $key => $value) {
  414. if ($value['enter'] != 0) {
  415. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  416. } else {
  417. $info_list[$key]['enter'] = "";
  418. }
  419. if ($value['printing'] != 0) {
  420. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  421. } else {
  422. $info_list[$key]['printing'] = "";
  423. }
  424. }
  425. $total = $this->whlabel->find_count($where);
  426. $pagenum = ceil($total / $perpage);
  427. $over = $total - ($start + $perpage);
  428. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  429. echo json_encode($rows);
  430. exit;
  431. }
  432. $this->_Template('whlabel_existence', $this->data);
  433. }
  434. //进销存浏览
  435. public function _typedy($arg_array)
  436. {
  437. $prc = array();
  438. $purchase = $this->purchase->find_all();
  439. foreach ($purchase as $k => $v) {
  440. $prc[$v['id']] = $v['title'];
  441. }
  442. $post = $this->input->post(NULL, TRUE);
  443. if (isset($post['page'])) {
  444. $page = $this->input->post('page', true);
  445. $perpage = $this->input->post('perpage', true);
  446. $category = $this->input->post('category', true);
  447. $size = $this->input->post('size', true);
  448. $grade = $this->input->post('grade', true);
  449. $color = $this->input->post('color', true);
  450. $lowe = $this->input->post('lowe', true);
  451. $sku = $this->input->post('sku');
  452. $title = $this->input->post('title');
  453. $warehouse = $this->input->post('warehouse', true);
  454. $usa = $this->input->post('usa', true);
  455. $purchase = $this->input->post('purchase', true);
  456. $lacetype = $this->input->post('lacetype', true);
  457. $haircap = $this->input->post('haircap', true);
  458. $density = $this->input->post('density', true);
  459. $details = $this->input->post('details', true);
  460. $state = $this->input->post('state', true);
  461. $lacecolor = $this->input->post('lacecolor', true);
  462. $hairnumber = $this->input->post('hairnumber', true);
  463. $cklx = $this->input->post('cklx', true);
  464. $ktime = $this->input->post('ktime', true);
  465. $jtime = $this->input->post('jtime', true);
  466. $sm = $this->input->post('sm', true);
  467. $cpbz = $this->input->post('cpbz', true);
  468. $type = $this->input->post('type', true);
  469. $ktime = strtotime($ktime);
  470. $jtime = strtotime($jtime);
  471. $where = "1=1";
  472. $gj = "";
  473. $ck = "";
  474. if ($usa) {
  475. if (!$warehouse) {
  476. $where .= " and (warehouse = '5' or warehouse = '8')";
  477. }
  478. }
  479. if ($warehouse) {
  480. $where .= " and warehouse = '$warehouse'";
  481. }
  482. if ($details) {
  483. $where .= " and details = '$details'";
  484. }
  485. if ($purchase) {
  486. $where .= " and purchase = '$purchase'";
  487. }
  488. if ($state) {
  489. $where .= " and state = '$state'";
  490. }
  491. if ($lacetype) {
  492. $where .= " and features like '%-$lacetype-%'";
  493. }
  494. if ($category) {
  495. $where .= " and features like '%-$category-%'";
  496. }
  497. if ($size) {
  498. $where .= " and features like '%-$size-%'";
  499. }
  500. if ($grade) {
  501. $where .= " and features like '%-$grade-%'";
  502. }
  503. if ($color) {
  504. $where .= " and features like '%-$color-%'";
  505. }
  506. if ($lowe) {
  507. $where .= " and features like '%-$lowe-%'";
  508. }
  509. if ($haircap) {
  510. $where .= " and features like '%-$haircap-%'";
  511. }
  512. if ($density) {
  513. $where .= " and features like '%-$density-%'";
  514. }
  515. if ($lacecolor) {
  516. $where .= " and features like '%-$lacecolor-%'";
  517. }
  518. if($sm){
  519. $where .= " and sm like '%".$sm."%'";
  520. }
  521. if($cpbz){
  522. $where .= " and cpbz like '%".$cpbz."%'";
  523. }
  524. if($type){
  525. $where .= " and type = ".$type."";
  526. }
  527. if (!empty($hairnumber)) {
  528. $where .= " and features like '%-128-%' ";
  529. if ($hairnumber < 0) {
  530. $class_list = $this->typeclass->find_all('classid = 43');
  531. foreach ($class_list as $v) {
  532. $where .= " and features not like '%-" . $v['id'] . "-%'";
  533. }
  534. } else {
  535. $where .= " and features like '%-$hairnumber-%'";
  536. }
  537. }
  538. $where_add = '';
  539. if ($cklx) {
  540. $shop = $this->shop->read($cklx);
  541. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  542. }
  543. if ($ktime && $jtime) {
  544. $gj = " and enter > '$ktime' and enter < '$jtime'";
  545. $ck = " and outk > '$ktime' and outk < '$jtime'";
  546. }
  547. //数据排序
  548. $order_str = "id desc";
  549. if (empty($page)) {
  550. $start = 0;
  551. $perpage = 1;
  552. } else {
  553. $start = ($page - 1) * $perpage;
  554. }
  555. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  556. if ($sku) {
  557. $sku = trim($sku, ' ');
  558. $sku = trim($sku, ' ');
  559. $where .= " and sku like '%$sku%'";
  560. $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);
  561. } else if ($title) {
  562. $title = trim($title, ' ');
  563. $title = trim($title, ' ');
  564. $where .= " and title like '%$title%'";
  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 {
  567. //$where .= " and time > '$ktime' and time < '$jtime'";
  568. $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);
  569. }
  570. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  571. foreach ($info_list as $k => $v) {
  572. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  573. unset($info_list[$k]['pm']);
  574. unset($info_list[$k]['jm']);
  575. unset($info_list[$k]['bm']);
  576. }
  577. //取得信息列表
  578. $rows = array();
  579. $list = array();
  580. foreach ($info_list as $key => $value) {
  581. $warehouse = $this->warehouse->read($value['warehouse']);
  582. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  583. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  584. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  585. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  586. $info_list[$key]['label'] = $value['sm'];
  587. $number = $value['number'];
  588. $ftime = time() - 15 * 24 * 3600;
  589. $info_list[$key]['warehouse'] = $warehouse['title'];
  590. $info_list[$key]['features'] = count($c);
  591. $z = count($z); //查看订单号
  592. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  593. $ztdata = '';
  594. if (count($zt) > 0) {
  595. foreach ($zt as $vv) {
  596. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  597. }
  598. }
  599. $info_list[$key]['number'] = $ztdata;
  600. $info_list[$key]['sm'] = $z;
  601. $details = array();
  602. $cpid = array();
  603. foreach ($c as $k => $v) {
  604. $details[$v['details']] = $v['details'];
  605. if ($v['cpid'] != 0) {
  606. $cpid[$v['cpid']] = $v['cpid'];
  607. }
  608. }
  609. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  610. if ($value['shop'] != '') {
  611. $shop = explode(',', trim($value['shop'], ','));
  612. $shop = $this->shop->read($shop[0]);
  613. $info_list[$key]['shop'] = $shop['shopname'];
  614. }
  615. }
  616. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  617. $pagenum = ceil($total / $perpage);
  618. $over = $total - ($start + $perpage);
  619. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  620. echo json_encode($rows);
  621. exit;
  622. }
  623. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  624. $this->_Template('whlabel_typedy', $this->data);
  625. }
  626. //进销存浏览
  627. public function _typedy_ck($arg_array)
  628. {
  629. $prc = array();
  630. $purchase = $this->purchase->find_all();
  631. foreach ($purchase as $k => $v) {
  632. $prc[$v['id']] = $v['title'];
  633. }
  634. $post = $this->input->post(NULL, TRUE);
  635. if (isset($post['page'])) {
  636. $page = $this->input->post('page', true);
  637. $perpage = $this->input->post('perpage', true);
  638. $category = $this->input->post('category', true);
  639. $size = $this->input->post('size', true);
  640. $grade = $this->input->post('grade', true);
  641. $color = $this->input->post('color', true);
  642. $lowe = $this->input->post('lowe', true);
  643. $sku = $this->input->post('sku');
  644. $title = $this->input->post('title');
  645. $warehouse = $this->input->post('warehouse', true);
  646. $usa = $this->input->post('usa', true);
  647. $purchase = $this->input->post('purchase', true);
  648. $lacetype = $this->input->post('lacetype', true);
  649. $haircap = $this->input->post('haircap', true);
  650. $density = $this->input->post('density', true);
  651. $details = $this->input->post('details', true);
  652. $state = $this->input->post('state', true);
  653. $lacecolor = $this->input->post('lacecolor', true);
  654. $cklx = $this->input->post('cklx', true);
  655. $ktime = $this->input->post('ktime', true);
  656. $jtime = $this->input->post('jtime', true);
  657. $ktime = strtotime($ktime);
  658. $jtime = strtotime($jtime);
  659. $where = "1=1";
  660. $gj = "";
  661. $ck = "";
  662. if ($lacetype) {
  663. $where .= " and features like '%-$lacetype-%'";
  664. }
  665. if ($category) {
  666. $where .= " and features like '%-$category-%'";
  667. }
  668. if ($size) {
  669. $where .= " and features like '%-$size-%'";
  670. }
  671. if ($grade) {
  672. $where .= " and features like '%-$grade-%'";
  673. }
  674. if ($color) {
  675. $where .= " and features like '%-$color-%'";
  676. }
  677. if ($lowe) {
  678. $where .= " and features like '%-$lowe-%'";
  679. }
  680. if ($haircap) {
  681. $where .= " and features like '%-$haircap-%'";
  682. }
  683. if ($density) {
  684. $where .= " and features like '%-$density-%'";
  685. }
  686. if ($lacecolor) {
  687. $where .= " and features like '%-$lacecolor-%'";
  688. }
  689. if ($usa) {
  690. if (!$warehouse) {
  691. $where .= " and (warehouse = '5' or warehouse = '8')";
  692. }
  693. }
  694. if ($warehouse) {
  695. $where .= " and warehouse = '$warehouse'";
  696. }
  697. if ($details) {
  698. $where .= " and details = '$details'";
  699. }
  700. if ($purchase) {
  701. $where .= " and purchase = '$purchase'";
  702. }
  703. if ($state) {
  704. $where .= " and state = '$state'";
  705. }
  706. $where_add = '';
  707. if ($cklx) {
  708. $shop = $this->shop->read($cklx);
  709. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  710. }
  711. if ($ktime && $jtime) {
  712. $gj = " and enter > '$ktime' and enter < '$jtime'";
  713. $ck = " and outk > '$ktime' and outk < '$jtime'";
  714. }
  715. //数据排序
  716. $order_str = "id desc";
  717. if (empty($page)) {
  718. $start = 0;
  719. $perpage = 1;
  720. } else {
  721. $start = ($page - 1) * $perpage;
  722. }
  723. if ($sku) {
  724. $sku = trim($sku, ' ');
  725. $sku = trim($sku, ' ');
  726. $where .= " and sku like '%$sku%'";
  727. $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);
  728. } else if ($title) {
  729. $title = trim($title, ' ');
  730. $title = trim($title, ' ');
  731. $where .= " and title like '%$title%'";
  732. $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);
  733. } else {
  734. //$where .= " and time > '$ktime' and time < '$jtime'";
  735. $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);
  736. }
  737. //取得信息列表
  738. $rows = array();
  739. $list = array();
  740. foreach ($info_list as $key => $value) {
  741. $warehouse = $this->warehouse->read($value['warehouse']);
  742. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  743. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  744. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  745. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  746. $ftime = time() - 15 * 24 * 3600;
  747. $info_list[$key]['warehouse'] = $warehouse['title'];
  748. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  749. //$z = count($z);//查看订单号
  750. //$info_list[$key]['zd'] = $z;
  751. $details = array();
  752. $cpid = array();
  753. foreach ($c as $k => $v) {
  754. $details[$v['details']] = $v['details'];
  755. if ($v['cpid'] != 0) {
  756. $cpid[$v['cpid']] = $v['cpid'];
  757. }
  758. }
  759. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  760. if ($value['shop'] != '') {
  761. $shop = explode(',', trim($value['shop'], ','));
  762. $shop = $this->shop->read($shop[0]);
  763. $info_list[$key]['shop'] = $shop['shopname'];
  764. }
  765. }
  766. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  767. $pagenum = ceil($total / $perpage);
  768. $over = $total - ($start + $perpage);
  769. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  770. echo json_encode($rows);
  771. exit;
  772. }
  773. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  774. $this->_Template('whlabel_typedy_ck', $this->data);
  775. }
  776. public function _typeck($arg_array)
  777. {
  778. $prc = array();
  779. $purchase = $this->purchase->find_all();
  780. foreach ($purchase as $k => $v) {
  781. $prc[$v['id']] = $v['title'];
  782. }
  783. $post = $this->input->post(NULL, TRUE);
  784. if (isset($post['page'])) {
  785. $page = $this->input->post('page', true);
  786. $perpage = $this->input->post('perpage', true);
  787. $category = $this->input->post('category', true);
  788. $size = $this->input->post('size', true);
  789. $grade = $this->input->post('grade', true);
  790. $color = $this->input->post('color', true);
  791. $lacecolor = $this->input->post('lacecolor', true);
  792. $lowe = $this->input->post('lowe', true);
  793. $sku = $this->input->post('sku');
  794. $title = $this->input->post('title');
  795. $warehouse = 13;
  796. $usa = $this->input->post('usa', true);
  797. $purchase = $this->input->post('purchase', true);
  798. $lacetype = $this->input->post('lacetype', true);
  799. $haircap = $this->input->post('haircap', true);
  800. $density = $this->input->post('density', true);
  801. $details = $this->input->post('details', true);
  802. $state = $this->input->post('state', true);
  803. $ktime = $this->input->post('ktime', true);
  804. $jtime = $this->input->post('jtime', true);
  805. $ktime = strtotime($ktime);
  806. $jtime = strtotime($jtime);
  807. $where = "1=1";
  808. $gj = "";
  809. $ck = "";
  810. if ($lacetype) {
  811. $where .= " and features like '%-$lacetype-%'";
  812. }
  813. if ($category) {
  814. $where .= " and features like '%-$category-%'";
  815. }
  816. if ($size) {
  817. $where .= " and features like '%-$size-%'";
  818. }
  819. if ($grade) {
  820. $where .= " and features like '%-$grade-%'";
  821. }
  822. if ($color) {
  823. $where .= " and features like '%-$color-%'";
  824. }
  825. if ($lacecolor) {
  826. $where .= " and features like '%-$lacecolor-%'";
  827. }
  828. if ($lowe) {
  829. $where .= " and features like '%-$lowe-%'";
  830. }
  831. if ($haircap) {
  832. $where .= " and features like '%-$haircap-%'";
  833. }
  834. if ($density) {
  835. $where .= " and features like '%-$density-%'";
  836. }
  837. if ($warehouse) {
  838. $where .= " and warehouse = '$warehouse'";
  839. }
  840. if ($details) {
  841. $where .= " and details = '$details'";
  842. }
  843. if ($purchase) {
  844. $where .= " and purchase = '$purchase'";
  845. }
  846. if ($state) {
  847. $where .= " and state = '$state'";
  848. }
  849. if ($ktime && $jtime) {
  850. $gj = " and enter > '$ktime' and enter < '$jtime'";
  851. $ck = " and outk > '$ktime' and outk < '$jtime'";
  852. }
  853. //数据排序
  854. $order_str = "id desc";
  855. if (empty($page)) {
  856. $start = 0;
  857. $perpage = 1;
  858. } else {
  859. $start = ($page - 1) * $perpage;
  860. }
  861. if ($sku) {
  862. $sku = trim($sku, ' ');
  863. $sku = trim($sku, ' ');
  864. $where .= " and sku like '%$sku%'";
  865. } else if ($title) {
  866. $title = trim($title, ' ');
  867. $title = trim($title, ' ');
  868. $where .= " and title like '%$title%'";
  869. }
  870. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  871. //取得信息列表
  872. $t = array();
  873. $typeclass = $this->typeclass->find_all();
  874. foreach ($typeclass as $v) {
  875. $t[$v['id']] = $v;
  876. }
  877. $rows = array();
  878. $list = array();
  879. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  880. foreach ($info_list as $key => $value) {
  881. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  882. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  883. $warehouse = $this->warehouse->read($value['warehouse']);
  884. $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');
  885. $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'] . '"');
  886. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  887. $number = $value['number'];
  888. $ftime = time() - 15 * 24 * 3600;
  889. $z = count($z); //查看订单号
  890. $info_list[$key]['warehouse'] = $warehouse['title'];
  891. $info_list[$key]['features'] = count($c);
  892. $info_list[$key]['number'] = $z;
  893. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  894. $details = array();
  895. $cpid = array();
  896. foreach ($c as $k => $v) {
  897. $details[$v['details']] = $v['details'];
  898. if ($v['cpid'] != 0) {
  899. $cpid[$v['cpid']] = $v['cpid'];
  900. }
  901. }
  902. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  903. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  904. unset($info_list[$key]['pm']);
  905. unset($info_list[$key]['jm']);
  906. unset($info_list[$key]['bm']);
  907. }
  908. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  909. $pagenum = ceil($total / $perpage);
  910. $over = $total - ($start + $perpage);
  911. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  912. echo json_encode($rows);
  913. exit;
  914. }
  915. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  916. $this->_Template('whlabel_typeck', $this->data);
  917. }
  918. //进销存导出
  919. public function _whlabeckdc()
  920. {
  921. $prc = array();
  922. $purchase = $this->purchase->find_all();
  923. foreach ($purchase as $k => $v) {
  924. $prc[$v['id']] = $v['title'];
  925. }
  926. if (isset($_GET['excel'])) {
  927. $where = "sku != 'Preset'";
  928. //数据排序
  929. $order_str = "id desc";
  930. if (empty($page)) {
  931. $start = 0;
  932. $perpage = 1;
  933. } else {
  934. $start = ($page - 1) * $perpage;
  935. }
  936. $category = $this->input->get('category', true);
  937. $color = $this->input->get('color', true);
  938. $lowe = $this->input->get('lowe', true);
  939. $lacetype = $this->input->get('lacetype', true);
  940. $size = $this->input->get('size', true);
  941. $density = $this->input->get('density', true);
  942. $haircap = $this->input->get('haircap', true);
  943. $sku = $this->input->get('sku', true);
  944. $details = $this->input->get('details', true);
  945. $warehouse = 13;
  946. $excelid = $this->input->get('sid', true);
  947. if ($category) {
  948. $where .= " and features like '%-$category-%'";
  949. }
  950. if ($color) {
  951. $where .= " and features like '%-$color-%'";
  952. }
  953. if ($lowe) {
  954. $where .= " and features like '%-$lowe-%'";
  955. }
  956. if ($lacetype) {
  957. $where .= " and features like '%-$lacetype-%'";
  958. }
  959. if ($size) {
  960. $where .= " and features like '%-$size-%'";
  961. }
  962. if ($density) {
  963. $where .= " and features like '%-$density-%'";
  964. }
  965. if ($haircap) {
  966. $where .= " and features like '%-$haircap-%'";
  967. }
  968. if ($warehouse) {
  969. $where .= " and warehouse = '$warehouse'";
  970. }
  971. if ($sku) {
  972. $where .= " and sku like '%$sku%'";
  973. }
  974. if ($details) {
  975. $where .= " and details = '$details'";
  976. }
  977. $xzid = '';
  978. if ($excelid) {
  979. $excelid = explode(',', trim($excelid, ','));
  980. foreach ($excelid as $key => $value) {
  981. $xzid .= " id = " . $value . " or";
  982. }
  983. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  984. }
  985. //取得信息列表
  986. /**
  987. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  988. $rows = array();$list = array();
  989. foreach ($info_list as $key=>$value)
  990. {
  991. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  992. }
  993. **/
  994. $wh = array();
  995. $w = $this->warehouse->find_all('1=1', 'id,title');
  996. foreach ($w as $v) {
  997. $wh[$v['id']] = $v['title'];
  998. }
  999. $tc = array();
  1000. $tcdata = array();
  1001. $list = array();
  1002. $classid = $this->classid->sku();
  1003. $tcall = $this->typeclass->find_all();
  1004. $typeclass = array();
  1005. foreach ($tcall as $v)
  1006. {
  1007. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1008. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1009. }
  1010. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1011. foreach ($rows as $key => $value) {
  1012. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1013. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1014. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1015. $rows[$key]['cpbz'] = $u9_info['bm'];
  1016. $rows[$key]['cs'] = $u9_info['jm'];
  1017. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1018. $details = array();
  1019. $cpid = array();
  1020. $cpbz = array();
  1021. $c = 0;
  1022. $g = 0;
  1023. $x = 0;
  1024. $t = 0;
  1025. $s = 0;
  1026. $q = 0;
  1027. foreach ($sd as $k => $v) {
  1028. if ($v['state'] == 0) {
  1029. $c++;
  1030. }
  1031. if ($v['state'] != 9) {
  1032. $g++;
  1033. }
  1034. if ($v['state'] == 1) {
  1035. $x++;
  1036. }
  1037. if ($v['state'] == 2) {
  1038. $t++;
  1039. }
  1040. if ($v['state'] == 8) {
  1041. $s++;
  1042. }
  1043. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1044. $q++;
  1045. }
  1046. $details[$v['details']] = $v['details'];
  1047. if ($v['cpid'] != 0) {
  1048. $cpid[$v['cpid']] = $v['cpid'];
  1049. }
  1050. if ($v['cpbz'] != '') {
  1051. $cpbz[$v['cpbz']] = $v['cpbz'];
  1052. }
  1053. }
  1054. $rows[$key]['details'] = implode("、", $details);
  1055. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1056. $number = $value['number'];
  1057. $ftime = time() - 15 * 24 * 3600;
  1058. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1059. $rows[$key]['number'] = $g;
  1060. $rows[$key]['features'] = $c;
  1061. $rows[$key]['x'] = $x;
  1062. $rows[$key]['t'] = $t;
  1063. $rows[$key]['s'] = $s;
  1064. $rows[$key]['q'] = $q;
  1065. $rows[$key]['wzsl'] = count($details);
  1066. }
  1067. $title = "进销存统计表" . date('Y-m-d', time());
  1068. $titlename = "<table border=1>
  1069. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1070. <tr align='center'>
  1071. <td>仓库</td>
  1072. <td>供应商</td>
  1073. <td>位置</td>
  1074. <td>库存编码</td>
  1075. <td>SKU</td>
  1076. <td>用友编码</td>
  1077. <td>用友料号</td>
  1078. <td>产品英文名</td>
  1079. <td>产品中文名</td>
  1080. <td>入库总量</td>
  1081. <td>库存数量</td>
  1082. <td>销售数量</td>
  1083. <td>退货数量</td>
  1084. <td>删除数量</td>
  1085. <td>其它操作</td>
  1086. <td>位置数量</td>
  1087. </tr>
  1088. </table>";
  1089. $filename = $title . ".xls";
  1090. $tail = "";
  1091. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1092. }
  1093. }
  1094. public function _type()
  1095. {
  1096. $vip = 0;
  1097. if (isset($_SESSION['api'])) {
  1098. $user = $this->user->get_api($_SESSION['api']);
  1099. $fgshop = "";
  1100. $sid = "";
  1101. $usersp = explode('|', trim($user['shop'], '|'));
  1102. foreach ($usersp as $value) {
  1103. $fgshop .= " shop = " . $value . " or";
  1104. $sid .= " id = " . $value . " or";
  1105. }
  1106. if ($user['vip'] == 1) {
  1107. $vip = 1;
  1108. }
  1109. } else {
  1110. header('Location: /');
  1111. exit;
  1112. }
  1113. $prc = array();
  1114. $purchase = $this->purchase->find_all();
  1115. foreach ($purchase as $k => $v) {
  1116. $prc[$v['id']] = $v['title'];
  1117. }
  1118. $company = array();
  1119. $ct = $this->company->find_all();
  1120. foreach ($ct as $k => $v) {
  1121. $company[$v['id']] = $v['title'];
  1122. }
  1123. $sp = array();
  1124. $s = $this->shop->find_all('1=1', 'id,shopname');
  1125. foreach ($s as $v) {
  1126. $sp[$v['id']] = $v['shopname'];
  1127. }
  1128. $wh = array();
  1129. $w = $this->warehouse->find_all('1=1', 'id,title');
  1130. foreach ($w as $v) {
  1131. $wh[$v['id']] = $v['title'];
  1132. }
  1133. $post = $this->input->post(NULL, TRUE);
  1134. if (isset($post['page'])) {
  1135. $page = $this->input->post('page', true);
  1136. $perpage = $this->input->post('perpage', true);
  1137. $category = $this->input->post('category', true);
  1138. $size = $this->input->post('size', true);
  1139. $grade = $this->input->post('grade', true);
  1140. $color = $this->input->post('color', true);
  1141. $lowe = $this->input->post('lowe', true);
  1142. $sku = $this->input->post('sku');
  1143. $title = $this->input->post('title');
  1144. $warehouse = $this->input->post('warehouse', true);
  1145. $usa = $this->input->post('usa', true);
  1146. $purchase = $this->input->post('purchase', true);
  1147. $lacetype = $this->input->post('lacetype', true);
  1148. $haircap = $this->input->post('haircap', true);
  1149. $density = $this->input->post('density', true);
  1150. $details = $this->input->post('details', true);
  1151. $state = $this->input->post('state', true);
  1152. $shop = $this->input->post('shop', true);
  1153. $lacecolor = $this->input->post('lacecolor', true);
  1154. $hairnumber = $this->input->post('hairnumber', true);
  1155. $type = $this->input->post('type', true);
  1156. $ktime = $this->input->post('ktime', true);
  1157. $jtime = $this->input->post('jtime', true);
  1158. $ktime = strtotime($ktime);
  1159. $jtime = strtotime($jtime);
  1160. $cpbz = $this->input->post('cpbz', true);
  1161. $sm = $this->input->post('sm', true);
  1162. $where = "1=1";
  1163. $gj = "";
  1164. $ck = "";
  1165. if ($usa) {
  1166. if (!$warehouse) {
  1167. $where .= " and (warehouse = '5' or warehouse = '8')";
  1168. }
  1169. }
  1170. if ($warehouse) {
  1171. $where .= " and warehouse = '$warehouse'";
  1172. }
  1173. if ($details) {
  1174. $where .= " and details = '$details'";
  1175. }
  1176. if ($purchase) {
  1177. $where .= " and purchase = '$purchase'";
  1178. }
  1179. if ($state) {
  1180. $where .= " and state = '$state'";
  1181. }
  1182. if ($shop) {
  1183. $where .= " and shop like '%$shop%'";
  1184. }
  1185. if ($type) {
  1186. $where .= " and type = '$type'";
  1187. }
  1188. if ($ktime && $jtime) {
  1189. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1190. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1191. }
  1192. if ($cpbz) {
  1193. $where .= " and cpbz like '%$cpbz%' ";
  1194. }
  1195. if ($sm) {
  1196. $where .= " and sm like '%$sm%' ";
  1197. }
  1198. if ($lacecolor) {
  1199. $where .= " and features like '%-$lacecolor-%'";
  1200. }
  1201. if ($lacetype) {
  1202. $where .= " and features like '%-$lacetype-%'";
  1203. }
  1204. if ($category) {
  1205. $where .= " and features like '%-$category-%'";
  1206. }
  1207. if ($size) {
  1208. $where .= " and features like '%-$size-%'";
  1209. }
  1210. if ($grade) {
  1211. $where .= " and features like '%-$grade-%'";
  1212. }
  1213. if ($color) {
  1214. $where .= " and features like '%-$color-%'";
  1215. }
  1216. if ($lowe) {
  1217. $where .= " and features like '%-$lowe-%'";
  1218. }
  1219. if ($haircap) {
  1220. $where .= " and features like '%-$haircap-%'";
  1221. }
  1222. if ($density) {
  1223. $where .= " and features like '%-$density-%'";
  1224. }
  1225. if (!empty($hairnumber)) {
  1226. $where .= " and features like '%-128-%' ";
  1227. if ($hairnumber < 0) {
  1228. $class_list = $this->typeclass->find_all('classid = 43');
  1229. foreach ($class_list as $v) {
  1230. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1231. }
  1232. } else {
  1233. $where .= " and features like '%-$hairnumber-%'";
  1234. }
  1235. }
  1236. //数据排序
  1237. $order_str = "id desc";
  1238. if (empty($page)) {
  1239. $start = 0;
  1240. $perpage = 1;
  1241. } else {
  1242. $start = ($page - 1) * $perpage;
  1243. }
  1244. $fjnr = '';
  1245. if ($sku) {
  1246. $sku = trim($sku, ' ');
  1247. $sku = trim($sku, ' ');
  1248. $fjnr .= " and sku like '%$sku%'";
  1249. }
  1250. if ($title) {
  1251. $title = trim($title, ' ');
  1252. $title = trim($title, ' ');
  1253. $fjnr .= " and title like '%$title%'";
  1254. }
  1255. $wt = array();
  1256. $whlabel_type = $this->whlabel_type->find_all();
  1257. foreach ($whlabel_type as $v) {
  1258. $wt[$v['id']] = $v['title'];
  1259. }
  1260. //$where .= " and time > '$ktime' and time < '$jtime'";
  1261. $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
  1262. //取得信息列表
  1263. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1264. $rows = array();
  1265. $list = array();
  1266. foreach ($info_list as $key => $value) {
  1267. if (isset($wt[$value['type']])) {
  1268. $info_list[$key]['type'] = $wt[$value['type']];
  1269. } else {
  1270. $info_list[$key]['type'] = '未设置';
  1271. }
  1272. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1273. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1274. $ztdata = '';
  1275. if (count($zt) > 0) {
  1276. foreach ($zt as $vv) {
  1277. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1278. }
  1279. }
  1280. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1281. $cdata = array_filter($qbdata, function ($item) {
  1282. return $item['state'] < 1;
  1283. });
  1284. $c = array_sum(array_column($cdata, 'jnum'));
  1285. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1286. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1287. });
  1288. $g = array_sum(array_column($gdata, 'jnum'));
  1289. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1290. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1291. });
  1292. $x = array_sum(array_column($xdata, 'jnum'));
  1293. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1294. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1295. });
  1296. $t = array_sum(array_column($tdata, 'jnum'));
  1297. $zdata = array_filter($qbdata, function ($item) {
  1298. return $item['zd'] != "" && $item['state'] < 1;
  1299. });
  1300. $z = array_sum(array_column($zdata, 'jnum'));
  1301. $zdata = array_filter($qbdata, function ($item) {
  1302. return $item['zd'] != "" && $item['state'] < 1;
  1303. });
  1304. $z = array_sum(array_column($zdata, 'jnum'));
  1305. //$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');
  1306. //$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'].'"');
  1307. //$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'].'"');
  1308. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1309. //$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'].'"');
  1310. $details = array();
  1311. $cpid = array();
  1312. $od = array();
  1313. $odid = '';
  1314. $companytitle = '';
  1315. $shop_list = [];
  1316. foreach ($qbdata as $v) {
  1317. if ($v['zd'] != "" && $v['state'] < 1) {
  1318. if (!isset($od[$v['zd']])) {
  1319. $od[$v['zd']] = 1; //所有数据sku
  1320. } else {
  1321. $od[$v['zd']] = $od[$v['zd']] + 1;
  1322. }
  1323. }
  1324. if ($v['state'] < 1) {
  1325. $details[$v['details']] = $v['details'];
  1326. if ($v['cpid'] != 0) {
  1327. $cpid[$v['cpid']] = $v['cpid'];
  1328. }
  1329. }
  1330. if($v['state'] == 0){
  1331. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1332. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1333. }
  1334. if ($v['shop'] != '') {
  1335. $shop = explode(',', trim($v['shop'], ','));
  1336. foreach ($shop as $vv) {
  1337. if (!in_array($vv, $shop_list)) {
  1338. $shop_list[] = $vv;
  1339. }
  1340. }
  1341. }
  1342. }
  1343. }
  1344. foreach ($od as $k => $vv) {
  1345. $odid .= $k . '数量' . $vv;
  1346. }
  1347. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1348. $info_list[$key]['label'] = $value['sm'];
  1349. $number = $value['number'];
  1350. $ftime = time() - 15 * 24 * 3600;
  1351. $z = $z . '(' . $odid . ')'; //查看订单号
  1352. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1353. $info_list[$key]['features'] = $c;
  1354. $info_list[$key]['number'] = $ztdata;
  1355. $info_list[$key]['sm'] = $g;
  1356. $info_list[$key]['x'] = $x;
  1357. $info_list[$key]['t'] = $t;
  1358. $info_list[$key]['z'] = $z;
  1359. /**
  1360. foreach ($cdata as $k=>$v)
  1361. {
  1362. $details[$v['details']] = $v['details'];
  1363. if($v['cpid'] != 0)
  1364. {
  1365. $cpid[$v['cpid']] = $v['cpid'];
  1366. }
  1367. }
  1368. **/
  1369. $info_list[$key]['shop'] = '';
  1370. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1371. // if ($value['shop'] != '') {
  1372. // $shop = explode(',', trim($value['shop'], ','));
  1373. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1374. // }
  1375. $shop_list = array_unique($shop_list);
  1376. $shop_str = '';
  1377. foreach ($shop_list as $v) {
  1378. if(isset($sp[$v])){
  1379. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1380. }
  1381. }
  1382. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1383. /**
  1384. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1385. if(isset($companytitle[0]))
  1386. {
  1387. foreach ($companytitle as $k=>$v)
  1388. {
  1389. if($v['companytitle'] != '')
  1390. {
  1391. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1392. }
  1393. }
  1394. }
  1395. **/
  1396. }
  1397. $final_all_list = [];
  1398. foreach ($info_list as $k => $v) {
  1399. $final_all_list[] = [
  1400. 'id' => $v['id'],
  1401. "warehouse" => $v["warehouse"],
  1402. "purchase" => $v["purchase"],
  1403. "sku" => $v["sku"],
  1404. "title" => $v["title"] . "<br/>" . $v["pm"],
  1405. "details" => $v["details"],
  1406. "shop" => $v["shop"],
  1407. "cpbz" => $v["cpbz"],
  1408. 'label' => $v['label'],
  1409. "type" => $v["type"],
  1410. "features" => $v["features"],
  1411. "number" => $v["number"],
  1412. "sm" => $v["sm"],
  1413. "x" => $v["x"],
  1414. "t" => $v["t"],
  1415. "z" => $v["z"]
  1416. ];
  1417. }
  1418. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1419. $pagenum = ceil($total / $perpage);
  1420. $over = $total - ($start + $perpage);
  1421. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1422. echo json_encode($rows);
  1423. exit;
  1424. }
  1425. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1426. $this->data['shop'] = $wlshop;
  1427. $this->data['vip'] = $vip;
  1428. $this->_Template('whlabel_type', $this->data);
  1429. }
  1430. //美仓进销存浏览
  1431. public function _usatype()
  1432. {
  1433. if (isset($_SESSION['api'])) {
  1434. $user = $this->user->get_api($_SESSION['api']);
  1435. $usp = $user;
  1436. $fgshop = "";
  1437. $sid = "";
  1438. $wid = "";
  1439. $wtype = "";
  1440. $userwh = explode('|', trim($user['warehouse'], '|'));
  1441. foreach ($userwh as $value) {
  1442. $wid .= " id = " . $value . " or";
  1443. $wtype .= " type = " . $value . " or";
  1444. }
  1445. }
  1446. $prc = array();
  1447. $purchase = $this->purchase->find_all();
  1448. foreach ($purchase as $k => $v) {
  1449. $prc[$v['id']] = $v['title'];
  1450. }
  1451. $post = $this->input->post(NULL, TRUE);
  1452. if (isset($post['page'])) {
  1453. $page = $this->input->post('page', true);
  1454. $perpage = $this->input->post('perpage', true);
  1455. $category = $this->input->post('category', true);
  1456. $size = $this->input->post('size', true);
  1457. $grade = $this->input->post('grade', true);
  1458. $color = $this->input->post('color', true);
  1459. $lowe = $this->input->post('lowe', true);
  1460. $sku = $this->input->post('sku');
  1461. $title = $this->input->post('title');
  1462. $warehouse = $this->input->post('warehouse', true);
  1463. $usa = $this->input->post('usa', true);
  1464. $purchase = $this->input->post('purchase', true);
  1465. $lacetype = $this->input->post('lacetype', true);
  1466. $haircap = $this->input->post('haircap', true);
  1467. $density = $this->input->post('density', true);
  1468. $details = $this->input->post('details', true);
  1469. $state = $this->input->post('state', true);
  1470. $lacecolor = $this->input->post('lacecolor', true);
  1471. $cklx = $this->input->post('cklx', true);
  1472. $ktime = $this->input->post('ktime', true);
  1473. $jtime = $this->input->post('jtime', true);
  1474. $ktime = strtotime($ktime);
  1475. $jtime = strtotime($jtime);
  1476. $where = "1=1";
  1477. $gj = "";
  1478. $ck = "";
  1479. if ($lacetype) {
  1480. $where .= " and features like '%-$lacetype-%'";
  1481. }
  1482. if ($category) {
  1483. $where .= " and features like '%-$category-%'";
  1484. }
  1485. if ($size) {
  1486. $where .= " and features like '%-$size-%'";
  1487. }
  1488. if ($grade) {
  1489. $where .= " and features like '%-$grade-%'";
  1490. }
  1491. if ($color) {
  1492. $where .= " and features like '%-$color-%'";
  1493. }
  1494. if ($lowe) {
  1495. $where .= " and features like '%-$lowe-%'";
  1496. }
  1497. if ($haircap) {
  1498. $where .= " and features like '%-$haircap-%'";
  1499. }
  1500. if ($density) {
  1501. $where .= " and features like '%-$density-%'";
  1502. }
  1503. if ($lacecolor) {
  1504. $where .= " and features like '%-$lacecolor-%'";
  1505. }
  1506. if ($usa) {
  1507. if (!$warehouse) {
  1508. $where .= " and (warehouse = '5' or warehouse = '8')";
  1509. }
  1510. }
  1511. if ($warehouse) {
  1512. $where .= " and warehouse = '$warehouse'";
  1513. }
  1514. if ($details) {
  1515. $where .= " and details = '$details'";
  1516. }
  1517. if ($purchase) {
  1518. $where .= " and purchase = '$purchase'";
  1519. }
  1520. if ($state) {
  1521. $where .= " and state = '$state'";
  1522. }
  1523. $where_add = '';
  1524. if ($cklx) {
  1525. $shop = $this->shop->read($cklx);
  1526. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1527. }
  1528. if ($ktime && $jtime) {
  1529. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1530. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1531. }
  1532. //数据排序
  1533. $order_str = "id desc";
  1534. if (empty($page)) {
  1535. $start = 0;
  1536. $perpage = 1;
  1537. } else {
  1538. $start = ($page - 1) * $perpage;
  1539. }
  1540. if ($sku) {
  1541. $sku = trim($sku, ' ');
  1542. $sku = trim($sku, ' ');
  1543. $where .= " and sku like '%$sku%'";
  1544. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1545. } else if ($title) {
  1546. $title = trim($title, ' ');
  1547. $title = trim($title, ' ');
  1548. $where .= " and title like '%$title%'";
  1549. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1550. } else {
  1551. //$where .= " and time > '$ktime' and time < '$jtime'";
  1552. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1553. }
  1554. //取得信息列表
  1555. $rows = array();
  1556. $list = array();
  1557. foreach ($info_list as $key => $value) {
  1558. $warehouse = $this->warehouse->read($value['warehouse']);
  1559. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1560. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1561. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1562. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1563. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1564. $od = array();
  1565. $odid = '';
  1566. foreach ($z as $v) {
  1567. if (!isset($od[$v['zd']])) {
  1568. $od[$v['zd']] = 1; //所有数据sku
  1569. } else {
  1570. $od[$v['zd']] = $od[$v['zd']] + 1;
  1571. }
  1572. }
  1573. foreach ($od as $k => $vv) {
  1574. $odid .= $k . '数量' . $vv . ' ';
  1575. }
  1576. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1577. $info_list[$key]['features'] = $c;
  1578. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1579. $ztdata = '';
  1580. if (count($zt) > 0) {
  1581. foreach ($zt as $vv) {
  1582. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1583. }
  1584. }
  1585. $info_list[$key]['warehouse'] = $ztdata;
  1586. $info_list[$key]['g'] = $g;
  1587. $info_list[$key]['x'] = $x;
  1588. $info_list[$key]['t'] = $t;
  1589. $info_list[$key]['z'] = $z;
  1590. }
  1591. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1592. $pagenum = ceil($total / $perpage);
  1593. $over = $total - ($start + $perpage);
  1594. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1595. echo json_encode($rows);
  1596. exit;
  1597. }
  1598. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1599. $this->data['warehouse'] = $warehouse;
  1600. $this->_Template('whlabel_typeusa', $this->data);
  1601. }
  1602. //美仓进销存浏览
  1603. public function _usatypeapp()
  1604. {
  1605. $post = $this->input->post(NULL, TRUE);
  1606. if (isset($post['page'])) {
  1607. $page = $this->input->post('page', true);
  1608. $perpage = $this->input->post('perpage', true);
  1609. $sku = $this->input->post('sku', true);
  1610. $warehouse = 5;
  1611. $title = $this->input->post('title', true);
  1612. $state = $this->input->post('state', true);
  1613. $ktime = $this->input->post('ktime', true);
  1614. $jtime = $this->input->post('jtime', true);
  1615. $ktime = strtotime($ktime);
  1616. $jtime = strtotime($jtime);
  1617. $where = "1=1";
  1618. $gj = "";
  1619. $ck = "";
  1620. if ($title) {
  1621. $st = explode(' ', trim($title, ' '));
  1622. foreach ($st as $v) {
  1623. $where .= " and title like '%$v%'";
  1624. }
  1625. }
  1626. if ($warehouse) {
  1627. $where .= " and warehouse = '$warehouse'";
  1628. }
  1629. if ($state) {
  1630. $where .= " and state = '$state'";
  1631. }
  1632. if ($sku) {
  1633. $where .= " and sku like '%$sku%'";
  1634. }
  1635. if ($ktime && $jtime) {
  1636. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1637. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1638. }
  1639. //数据排序
  1640. $order_str = "id desc";
  1641. if (empty($page)) {
  1642. $start = 0;
  1643. $perpage = 1;
  1644. } else {
  1645. $start = ($page - 1) * $perpage;
  1646. }
  1647. //取得信息列表
  1648. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1649. $rows = array();
  1650. $list = array();
  1651. foreach ($info_list as $key => $value) {
  1652. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1653. }
  1654. $rowsdq = array_slice($rows, $start, $perpage);
  1655. foreach ($rowsdq as $value) {
  1656. $warehouse = $this->warehouse->read($value['warehouse']);
  1657. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1658. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1659. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1660. $od = array();
  1661. $odid = '';
  1662. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1663. }
  1664. $total = count($rows);
  1665. $pagenum = ceil($total / $perpage);
  1666. $over = $total - ($start + $perpage);
  1667. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1668. echo json_encode($rows);
  1669. exit;
  1670. }
  1671. $this->_Template('phone/p_usatypeapp', $this->data);
  1672. }
  1673. //入库操作
  1674. public function _enteradd()
  1675. {
  1676. $dt = 0;
  1677. if (isset($_SESSION['api'])) {
  1678. $user = $this->user->get_api($_SESSION['api']);
  1679. $usp = $user;
  1680. $fgshop = "";
  1681. $sid = "";
  1682. $user = explode('|', trim($user['shop'], '|'));
  1683. foreach ($user as $value) {
  1684. $fgshop .= " shop = " . $value . " or";
  1685. $sid .= " id = " . $value . " or";
  1686. }
  1687. }
  1688. $tc = $this->typeclass->find_all();
  1689. $typeclass = array();
  1690. foreach ($tc as $v) {
  1691. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1692. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1693. }
  1694. $post = $this->input->post(NULL, TRUE);
  1695. if (isset($post['sku'])) {
  1696. $list = array();
  1697. $num = "";
  1698. $title = "";
  1699. $features = "";
  1700. $order = $this->input->post('order', true);
  1701. $shop = $this->input->post('shop', true);
  1702. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1703. $sku = $this->input->post('sku', true);
  1704. $post['sm'] = $this->input->post('sm', true);
  1705. $post['warehouse'] = $this->input->post('warehouse', true);
  1706. $post['purchase'] = $this->input->post('purchase', true);
  1707. $post['retreatwarehouse'] = $post['warehouse'];
  1708. $post['state'] = $this->input->post('state', true);
  1709. $post['rktype'] = $this->input->post('rktype', true);
  1710. $post['text'] = $this->input->post('text', true);
  1711. $category = $this->input->post('category', true);
  1712. $list['category'] = $category;
  1713. $list['hairtype'] = $this->input->post('hairtype', true);
  1714. $list['grade'] = $this->input->post('grade', true);
  1715. $size = $this->input->post('size', true);
  1716. $xzsku = $this->input->post('xzsku', true);
  1717. $list['size'] = rtrim($size, ',');
  1718. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1719. $list['extension'] = $this->input->post('extension', true);
  1720. if ($category == 1297) {
  1721. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1722. }
  1723. if ($category == 1702) {
  1724. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1725. $list['syother'] = $this->input->post('syother', true);
  1726. }
  1727. if ($category == 133) {
  1728. $list['fittype'] = $this->input->post('fittype', true);
  1729. $list['acother'] = $this->input->post('acother', true);
  1730. }
  1731. $list['color'] = $this->input->post('color', true);
  1732. $list['lowe'] = $this->input->post('lowe', true);
  1733. if (!$post['purchase']) {
  1734. $post['purchase'] = 1;
  1735. }
  1736. if ($category == 127) {
  1737. $list['type'] = $this->input->post('type', true);
  1738. $list['headroad'] = $this->input->post('headroad', true);
  1739. $list['density'] = $this->input->post('density', true);
  1740. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1741. $list['lacesize'] = $this->input->post('lacesize', true);
  1742. }
  1743. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1744. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1745. }
  1746. if ($category == 128) {
  1747. $list['lacetype'] = $this->input->post('lacetype', true);
  1748. $list['haircap'] = $this->input->post('haircap', true);
  1749. $list['density'] = $this->input->post('density', true);
  1750. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1751. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1752. $list['wigother'] = $this->input->post('wigother', true);
  1753. $list['wigother1'] = $this->input->post('wigother1', true);
  1754. $list['wigother2'] = $this->input->post('wigother2', true);
  1755. }
  1756. if ($category == 129) {
  1757. $list['wide'] = $this->input->post('wide', true);
  1758. }
  1759. if ($category == 131) {
  1760. $list['gifttype'] = $this->input->post('gifttype', true);
  1761. $list['giftother'] = $this->input->post('giftother', true);
  1762. }
  1763. if ($category == 134) {
  1764. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1765. }
  1766. if ($category == 1297) {
  1767. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1768. $list['sywigother'] = $this->input->post('sywigother', true);
  1769. }
  1770. if ($category == 130 || $category == 133 || $category == 1702) {
  1771. $list['items'] = $this->input->post('items', true);
  1772. $list['weight'] = $this->input->post('weight', true);
  1773. }
  1774. if ($category == 1702) {
  1775. $list['syhairther'] = $this->input->post('syhairther', true);
  1776. }
  1777. $classid = $this->classid->sku();
  1778. $scsku = $classid;
  1779. $pm = $classid;
  1780. foreach ($list as $k => $v) {
  1781. if ($v != 0) {
  1782. $num .= $v;
  1783. $features .= $v . '-';
  1784. $post[$k] = $v;
  1785. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1786. if ($k != 'size') {
  1787. $title .= $typeclass[$v]['title'] . " ";
  1788. }
  1789. if (isset($pm[$typeclass[$v]['classid']])) {
  1790. if ($typeclass[$v]['title'] == '9A') {
  1791. $pm[$typeclass[$v]['classid']] = '9A';
  1792. } else if ($typeclass[$v]['title'] == '10A') {
  1793. $pm[$typeclass[$v]['classid']] = '10A';
  1794. } else {
  1795. $clzh = $typeclass[$v]['zh'];
  1796. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1797. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1798. $clzh = $clzh[0];
  1799. }
  1800. $pm[$typeclass[$v]['classid']] = $clzh;
  1801. }
  1802. }
  1803. }
  1804. }
  1805. $zh = implode(" ", $pm);
  1806. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1807. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1808. if ($list['size']) {
  1809. $typeclass = $this->typeclass->read($list['size']);
  1810. $title .= $typeclass['title'];
  1811. }
  1812. $time = time();
  1813. if ($xzsku) {
  1814. $scsku = implode("-", $scsku);
  1815. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1816. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1817. $post['sku'] = trim($scsku, ' ');
  1818. } else {
  1819. $post['sku'] = $sku;
  1820. }
  1821. //$post['sku'] = trim($sku,' ');
  1822. $post['title'] = rtrim($title, ' ');
  1823. $post['number'] = $num;
  1824. $post['features'] = '-' . $features;
  1825. $post['enter'] = $time;
  1826. $post['time'] = $time; //操作时间
  1827. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1828. if ($yza) {
  1829. if ($post['features'] != $yza[0]['features']) {
  1830. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1831. exit;
  1832. }
  1833. }
  1834. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1835. if ($yzb) {
  1836. if ($post['sku'] != $yzb[0]['sku']) {
  1837. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1838. exit;
  1839. }
  1840. }
  1841. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1842. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1843. exit;
  1844. }
  1845. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1846. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1847. exit;
  1848. }
  1849. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1850. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1851. exit;
  1852. }
  1853. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1854. if (isset($yz[0]['type'])) {
  1855. $post['type'] = $yz[0]['type'];
  1856. }
  1857. if ($post['state'] == 9) //如果选择预设库存
  1858. {
  1859. $this->whlabel->insert($post);
  1860. } else {
  1861. /**
  1862. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1863. if($ljg == 1)
  1864. {
  1865. for($i=0;$i<$order;$i++)
  1866. {
  1867. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1868. $this->whlabel->insert($post);
  1869. }
  1870. }
  1871. **/
  1872. //if($post['warehouse'] == '5')
  1873. //{
  1874. //}
  1875. $yydata = $post;
  1876. $yydata['zh'] = $zh;
  1877. /**
  1878. $wl = $this->apiyy->get_cjlp($yydata);
  1879. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1880. {
  1881. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1882. }
  1883. if($wl['Data'][0]['m_isSucess'] != 1)
  1884. {
  1885. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1886. }
  1887. **/
  1888. for ($i = 0; $i < $order; $i++) {
  1889. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1890. $this->whlabel->insert($post);
  1891. }
  1892. }
  1893. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1894. exit;
  1895. }
  1896. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1897. $this->data['wlshop'] = $wlshop;
  1898. $this->_Template('whlabel_enteradd', $this->data);
  1899. }
  1900. //修改产品
  1901. public function _enteredit($arg_array)
  1902. {
  1903. $dt = 0;
  1904. if (isset($_SESSION['api'])) {
  1905. $user = $this->user->get_api($_SESSION['api']);
  1906. $usp = $user;
  1907. $fgshop = "";
  1908. $sid = "";
  1909. $user = explode('|', trim($user['shop'], '|'));
  1910. foreach ($user as $value) {
  1911. $fgshop .= " shop = " . $value . " or";
  1912. $sid .= " id = " . $value . " or";
  1913. }
  1914. }
  1915. $post = $this->input->post(NULL, TRUE);
  1916. if (isset($post['sku'])) {
  1917. $list = array();
  1918. $num = "";
  1919. $title = "";
  1920. $features = "";
  1921. $id = $this->input->post('id', true);
  1922. $order = $this->input->post('order', true);
  1923. $shop = $this->input->post('shop', true);
  1924. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1925. $post['sku'] = $this->input->post('sku', true);
  1926. $post['sm'] = $this->input->post('sm', true);
  1927. $post['warehouse'] = $this->input->post('warehouse', true);
  1928. $post['purchase'] = $this->input->post('purchase', true);
  1929. $post['retreatwarehouse'] = $post['warehouse'];
  1930. $category = $this->input->post('category', true);
  1931. $list['category'] = $category;
  1932. $list['hairtype'] = $this->input->post('hairtype', true);
  1933. $list['grade'] = $this->input->post('grade', true);
  1934. $size = $this->input->post('size', true);
  1935. $list['size'] = rtrim($size, ',');
  1936. $post['rktype'] = $this->input->post('rktype', true);
  1937. $post['text'] = $this->input->post('text', true);
  1938. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1939. $list['extension'] = $this->input->post('extension', true);
  1940. if ($category == 1297) {
  1941. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1942. }
  1943. if ($category == 1702) {
  1944. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1945. $list['syother'] = $this->input->post('syother', true);
  1946. }
  1947. if ($category == 133) {
  1948. $list['fittype'] = $this->input->post('fittype', true);
  1949. $list['acother'] = $this->input->post('acother', true);
  1950. }
  1951. $list['color'] = $this->input->post('color', true);
  1952. $list['lowe'] = $this->input->post('lowe', true);
  1953. if (!$post['purchase']) {
  1954. $post['purchase'] = 1;
  1955. }
  1956. if ($category == 127) {
  1957. $list['type'] = $this->input->post('type', true);
  1958. $list['headroad'] = $this->input->post('headroad', true);
  1959. $list['density'] = $this->input->post('density', true);
  1960. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1961. $list['lacesize'] = $this->input->post('lacesize', true);
  1962. }
  1963. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1964. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1965. }
  1966. if ($category == 128) {
  1967. $list['lacetype'] = $this->input->post('lacetype', true);
  1968. $list['haircap'] = $this->input->post('haircap', true);
  1969. $list['density'] = $this->input->post('density', true);
  1970. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1971. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1972. $list['wigother'] = $this->input->post('wigother', true);
  1973. $list['wigother1'] = $this->input->post('wigother1', true);
  1974. $list['wigother2'] = $this->input->post('wigother2', true);
  1975. }
  1976. if ($category == 129) {
  1977. $list['wide'] = $this->input->post('wide', true);
  1978. }
  1979. if ($category == 131) {
  1980. $list['gifttype'] = $this->input->post('gifttype', true);
  1981. $list['giftother'] = $this->input->post('giftother', true);
  1982. }
  1983. if ($category == 134) {
  1984. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1985. }
  1986. if ($category == 1297) {
  1987. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1988. $list['sywigother'] = $this->input->post('sywigother', true);
  1989. }
  1990. if ($category == 130 || $category == 133 || $category == 1702) {
  1991. $list['items'] = $this->input->post('items', true);
  1992. $list['weight'] = $this->input->post('weight', true);
  1993. }
  1994. if ($category == 1702) {
  1995. $list['syhairther'] = $this->input->post('syhairther', true);
  1996. }
  1997. foreach ($list as $k => $v) {
  1998. if ($v != 0) {
  1999. $num .= $v;
  2000. $features .= $v . '-';
  2001. $typeclass = $this->typeclass->read($v);
  2002. if ($k != 'size') {
  2003. $title .= $typeclass['title'] . " ";
  2004. }
  2005. }
  2006. }
  2007. $typeclass = $this->typeclass->read($list['size']);
  2008. $title .= $typeclass['title'];
  2009. $time = time();
  2010. $post['title'] = rtrim($title, ' ');
  2011. $post['number'] = $num;
  2012. $post['features'] = '-' . $features;
  2013. $post['time'] = $time; //操作时间
  2014. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2015. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2016. exit;
  2017. }
  2018. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2019. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2020. exit;
  2021. }
  2022. $uid = $this->whlabel->read($id);
  2023. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2024. if ($datanum > 0) {
  2025. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2026. exit;
  2027. }
  2028. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2029. {
  2030. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2031. if ($yza) {
  2032. if ($post['features'] != $yza[0]['features']) {
  2033. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2034. exit;
  2035. }
  2036. }
  2037. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2038. if ($yzb) {
  2039. if ($post['sku'] != $yzb[0]['sku']) {
  2040. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2041. exit;
  2042. }
  2043. }
  2044. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2045. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2046. exit;
  2047. }
  2048. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2049. foreach ($data as $v) {
  2050. $post['id'] = $v['id'];
  2051. $this->whlabel->save($post, $v['id']);
  2052. }
  2053. } else {
  2054. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2055. if ($data > 0) {
  2056. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2057. exit;
  2058. } else {
  2059. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2060. foreach ($data as $v) {
  2061. $post['id'] = $v['id'];
  2062. $this->whlabel->save($post, $v['id']);
  2063. }
  2064. }
  2065. }
  2066. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2067. exit;
  2068. }
  2069. $uid = $this->whlabel->read($arg_array[0]);
  2070. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2071. $this->data['enter'] = $uid;
  2072. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2073. $this->data['wlshop'] = $wlshop;
  2074. $this->_Template('whlabel_enteredit', $this->data);
  2075. }
  2076. //入库浏览
  2077. public function _enter()
  2078. {
  2079. $post = $this->input->post(NULL, TRUE);
  2080. if (isset($post['s'])) {
  2081. $id_arr = $this->input->post('s');
  2082. $id_arr = explode(',', $id_arr);
  2083. if (!$id_arr) {
  2084. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2085. exit;
  2086. }
  2087. //循环删除记录
  2088. foreach ($id_arr as $v) {
  2089. $sid = $this->whlabel->read($v);
  2090. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2091. if ($count > 0) {
  2092. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2093. exit;
  2094. }
  2095. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2096. foreach ($info_list as $va) {
  2097. $this->whlabel->remove($va['id']);
  2098. }
  2099. }
  2100. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2101. exit;
  2102. }
  2103. $sp = array();
  2104. $s = $this->shop->find_all('1=1', 'id,shopname');
  2105. foreach ($s as $v) {
  2106. $sp[$v['id']] = $v['shopname'];
  2107. }
  2108. $wh = array();
  2109. $w = $this->warehouse->find_all('1=1', 'id,title');
  2110. foreach ($w as $v) {
  2111. $wh[$v['id']] = $v['title'];
  2112. }
  2113. if (isset($post['page'])) {
  2114. $page = $this->input->post('page', true);
  2115. $perpage = $this->input->post('perpage', true);
  2116. $category = $this->input->post('category', true);
  2117. $size = $this->input->post('size', true);
  2118. $grade = $this->input->post('grade', true);
  2119. $color = $this->input->post('color', true);
  2120. $lowe = $this->input->post('lowe', true);
  2121. $sku = $this->input->post('sku', true);
  2122. $warehouse = $this->input->post('warehouse', true);
  2123. $purchase = $this->input->post('purchase', true);
  2124. $ktime = $this->input->post('ktime', true);
  2125. $jtime = $this->input->post('jtime', true);
  2126. $ktime = strtotime($ktime);
  2127. $jtime = strtotime($jtime);
  2128. $where = "1=1";
  2129. $gj = "";
  2130. $ck = "";
  2131. if ($category) {
  2132. $where .= " and features like '%-$category-%'";
  2133. }
  2134. if ($size) {
  2135. $where .= " and features like '%-$size-%'";
  2136. }
  2137. if ($grade) {
  2138. $where .= " and features like '%-$grade-%'";
  2139. }
  2140. if ($color) {
  2141. $where .= " and features like '%-$color-%'";
  2142. }
  2143. if ($lowe) {
  2144. $where .= " and features like '%-$lowe-%'";
  2145. }
  2146. if ($warehouse) {
  2147. $where .= " and warehouse = '$warehouse'";
  2148. }
  2149. if ($purchase) {
  2150. $where .= " and purchase = '$purchase'";
  2151. }
  2152. if ($sku) {
  2153. $where .= " and sku like '%$sku%'";
  2154. }
  2155. if ($ktime && $jtime) {
  2156. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2157. }
  2158. //数据排序
  2159. $order_str = "enter desc";
  2160. if (empty($page)) {
  2161. $start = 0;
  2162. $perpage = 1;
  2163. } else {
  2164. $start = ($page - 1) * $perpage;
  2165. }
  2166. //取得信息列表
  2167. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2168. foreach ($info_list as $k => $v) {
  2169. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2170. if ($v['shop'] == '') {
  2171. $s = '通用';
  2172. } else {
  2173. $info_list[$k]['shop'] = '';
  2174. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2175. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2176. }
  2177. }
  2178. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2179. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2180. $info_list[$k]['g'] = $g;
  2181. }
  2182. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2183. $total = count($this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,sku,title,features,number'));
  2184. $pagenum = ceil($total / $perpage);
  2185. $over = $total - ($start + $perpage);
  2186. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2187. echo json_encode($rows);
  2188. exit;
  2189. }
  2190. $this->_Template('whlabel_enter', $this->data);
  2191. }
  2192. //出库浏览
  2193. public function _out()
  2194. {
  2195. $post = $this->input->post(NULL, TRUE);
  2196. if (isset($post['page'])) {
  2197. $page = $this->input->post('page', true);
  2198. $perpage = $this->input->post('perpage', true);
  2199. $category = $this->input->post('category', true);
  2200. $size = $this->input->post('size', true);
  2201. $grade = $this->input->post('grade', true);
  2202. $color = $this->input->post('color', true);
  2203. $lowe = $this->input->post('lowe', true);
  2204. $sku = $this->input->post('sku', true);
  2205. $warehouse = $this->input->post('warehouse', true);
  2206. $purchase = $this->input->post('purchase', true);
  2207. $state = $this->input->post('state', true);
  2208. $ktime = $this->input->post('ktime', true);
  2209. $jtime = $this->input->post('jtime', true);
  2210. $ktime = strtotime($ktime);
  2211. $jtime = strtotime($jtime);
  2212. $where = "state=3";
  2213. $gj = "";
  2214. $ck = "";
  2215. if ($category) {
  2216. $where .= " and features like '%-$category-%'";
  2217. }
  2218. if ($size) {
  2219. $where .= " and features like '%-$size-%'";
  2220. }
  2221. if ($grade) {
  2222. $where .= " and features like '%-$grade-%'";
  2223. }
  2224. if ($color) {
  2225. $where .= " and features like '%-$color-%'";
  2226. }
  2227. if ($lowe) {
  2228. $where .= " and features like '%-$lowe-%'";
  2229. }
  2230. if ($state) {
  2231. $where .= " and state = '$state'";
  2232. }
  2233. if ($warehouse) {
  2234. $where .= " and warehouse = '$warehouse'";
  2235. }
  2236. if ($purchase) {
  2237. $where .= " and purchase = '$purchase'";
  2238. }
  2239. if ($sku) {
  2240. $where .= " and sku = '$sku'";
  2241. }
  2242. if ($ktime && $jtime) {
  2243. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2244. }
  2245. //数据排序
  2246. $order_str = "id desc";
  2247. if (empty($page)) {
  2248. $start = 0;
  2249. $perpage = 1;
  2250. } else {
  2251. $start = ($page - 1) * $perpage;
  2252. }
  2253. //取得信息列表
  2254. $info_list = $this->whlabel->find_all($where, 'sku');
  2255. $rows = array();
  2256. $list = array();
  2257. foreach ($info_list as $key => $value) {
  2258. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2259. }
  2260. $rows = array_unique($rows); //删除重复记录
  2261. foreach ($rows as $key => $value) {
  2262. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2263. $ck = $this->warehouse->read($data['warehouse']);
  2264. $warehouse = $ck['title'];
  2265. $gy = $this->purchase->read($data['purchase']);
  2266. $purchase = $gy['purchase'];
  2267. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2268. $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);
  2269. }
  2270. $total = count($list);
  2271. $pagenum = ceil($total / $perpage);
  2272. $over = $total - ($start + $perpage);
  2273. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2274. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2275. echo json_encode($rows);
  2276. exit;
  2277. }
  2278. $this->_Template('whlabel_out', $this->data);
  2279. }
  2280. //出库标签浏览
  2281. public function _label()
  2282. {
  2283. $post = $this->input->post(NULL, TRUE);
  2284. if (isset($post['page'])) {
  2285. $page = $this->input->post('page', true);
  2286. $perpage = $this->input->post('perpage', true);
  2287. $sku = $this->input->post('sku', true);
  2288. $warehouse = $this->input->post('warehouse', true);
  2289. $purchase = $this->input->post('purchase', true);
  2290. $orderinfo = $this->input->post('orderinfo', true);
  2291. $waybill = $this->input->post('waybill', true);
  2292. $category = $this->input->post('category', true);
  2293. $size = $this->input->post('size', true);
  2294. $grade = $this->input->post('grade', true);
  2295. $color = $this->input->post('color', true);
  2296. $lowe = $this->input->post('lowe', true);
  2297. $where = "state=1";
  2298. if ($sku) {
  2299. $where .= " and sku = '$sku'";
  2300. }
  2301. if ($warehouse) {
  2302. $where .= " and warehouse = '$warehouse'";
  2303. }
  2304. if ($purchase) {
  2305. $where .= " and purchase = '$purchase'";
  2306. }
  2307. if ($orderinfo) {
  2308. $where .= " and orderinfo = '$orderinfo'";
  2309. }
  2310. if ($waybill) {
  2311. $where .= " and waybill = '$waybill'";
  2312. }
  2313. if ($category) {
  2314. $where .= " and features like '%-$category-%'";
  2315. }
  2316. if ($size) {
  2317. $where .= " and features like '%-$size-%'";
  2318. }
  2319. if ($grade) {
  2320. $where .= " and features like '%-$grade-%'";
  2321. }
  2322. if ($color) {
  2323. $where .= " and features like '%-$color-%'";
  2324. }
  2325. if ($lowe) {
  2326. $where .= " and features like '%-$lowe-%'";
  2327. }
  2328. //数据排序
  2329. $order_str = "outk desc";
  2330. if (empty($page)) {
  2331. $start = 0;
  2332. $perpage = 1;
  2333. } else {
  2334. $start = ($page - 1) * $perpage;
  2335. }
  2336. //取得信息列表
  2337. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2338. foreach ($info_list as $key => $value) {
  2339. $warehouse = $this->warehouse->read($value['warehouse']);
  2340. $info_list[$key]['warehouse'] = $warehouse['title'];
  2341. $purchase = $this->purchase->read($value['purchase']);
  2342. $info_list[$key]['purchase'] = $purchase['title'];
  2343. if ($value['outk'] != 0) {
  2344. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2345. } else {
  2346. $info_list[$key]['outk'] = "";
  2347. }
  2348. if ($value['orderinfo'] == 0) {
  2349. $info_list[$key]['orderinfo'] = "";
  2350. }
  2351. if ($value['waybill'] == 0) {
  2352. $info_list[$key]['waybill'] = "";
  2353. }
  2354. }
  2355. $total = $this->whlabel->find_count($where);
  2356. $pagenum = ceil($total / $perpage);
  2357. $over = $total - ($start + $perpage);
  2358. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2359. echo json_encode($rows);
  2360. exit;
  2361. }
  2362. $this->_Template('whlabel_label', $this->data);
  2363. }
  2364. //独立站出库订单
  2365. public function _outorder()
  2366. {
  2367. if (isset($_SESSION['api'])) {
  2368. $user = $this->user->get_api($_SESSION['api']);
  2369. $usp = $user;
  2370. $fgshop = "";
  2371. $sid = "";
  2372. $user = explode('|', trim($user['shop'], '|'));
  2373. foreach ($user as $value) {
  2374. $fgshop .= " shop = " . $value . " or";
  2375. $sid .= " id = " . $value . " or";
  2376. }
  2377. } else {
  2378. echo "请重新登录";
  2379. }
  2380. $post = $this->input->post(NULL, TRUE);
  2381. if (isset($post['page'])) {
  2382. $page = $this->input->post('page', true);
  2383. $perpage = $this->input->post('perpage', true);
  2384. $warehouse = $this->input->post('warehouse', true);
  2385. $xztime = $this->input->post('xztime', true);
  2386. $timetk = $this->input->post('timetkk', true);
  2387. $timetj = $this->input->post('timetjj', true);
  2388. $shop = $this->input->post('shop', true);
  2389. $source = $this->input->post('source', true);
  2390. $orderinfo = $this->input->post('orderinfo', true);
  2391. $number = $this->input->post('number', true);
  2392. $sfxh = $this->input->post('sfxh', true);
  2393. $express = $this->input->post('express', true);
  2394. $waybill = $this->input->post('waybill', true);
  2395. $library = $this->input->post('library', true);
  2396. $country = $this->input->post('country', true);
  2397. $so = $this->input->post('so', true);
  2398. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2399. $print = $this->input->post('print', true);
  2400. $state = $this->input->post('state', true);
  2401. $orderurl = $this->input->post('orderurl', true);
  2402. $timetk = strtotime($timetk);
  2403. $timetj = strtotime($timetj);
  2404. /**
  2405. $sj = $this->input->post('sj',true);
  2406. if($sj)
  2407. {
  2408. $sj = $this->input->post('sj',true);
  2409. }
  2410. else
  2411. {
  2412. $sj = "fullorder";
  2413. }
  2414. **/
  2415. $sj = "fullorder";
  2416. $where = "1=1";
  2417. if ($warehouse) {
  2418. $where .= " and type = '$warehouse'";
  2419. }
  2420. if ($timetk && $timetj) {
  2421. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2422. }
  2423. if ($orderinfo) {
  2424. $where .= " and orderinfo = '$orderinfo'";
  2425. }
  2426. if ($number) {
  2427. $where .= " and number = '$number'";
  2428. }
  2429. if ($express) {
  2430. $where .= " and express = '$express'";
  2431. }
  2432. if ($waybill) {
  2433. $where .= " and waybill = '$waybill'";
  2434. }
  2435. if ($library) {
  2436. $where .= " and library = '$library'";
  2437. }
  2438. if ($print) {
  2439. $where .= " and print = '$print'";
  2440. }
  2441. if ($libraryconfirm) {
  2442. $where .= " and libraryconfirm = '$libraryconfirm'";
  2443. }
  2444. if ($state) {
  2445. $where .= " and state = '$state'";
  2446. }
  2447. if ($shop) {
  2448. $where .= " and shop = '$shop'";
  2449. }
  2450. if ($country) {
  2451. $where .= " and country = '$country'";
  2452. }
  2453. if ($sfxh != '') {
  2454. $where .= " and sfxh = '$sfxh'";
  2455. }
  2456. if ($so) {
  2457. $where .= " and shipremarks like '%$so%'";
  2458. }
  2459. if ($source) {
  2460. if ($source == '2d') {
  2461. $where .= " and source >= '2'";
  2462. } else {
  2463. $where .= " and source = '$source'";
  2464. }
  2465. }
  2466. if (isset($_SESSION['api'])) {
  2467. foreach ($user as $value) {
  2468. $fgshop .= " shop = " . $value . " or";
  2469. }
  2470. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2471. }
  2472. if ($orderurl) {
  2473. $url = $this->orderurl->read($orderurl);
  2474. $where .= " and link like '%" . $url['url'] . "%'";
  2475. }
  2476. //数据排序
  2477. $order_str = "librarytime desc";
  2478. if (empty($page)) {
  2479. $start = 0;
  2480. $perpage = 1;
  2481. } else {
  2482. $start = ($page - 1) * $perpage;
  2483. }
  2484. //取得信息列表
  2485. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2486. //格式化数据
  2487. foreach ($info_list as $key => $value) {
  2488. $shop = $this->shop->read($value['shop']);
  2489. $info_list[$key]['shop'] = $shop['shopname'];
  2490. $express = $this->express->read($value['express']);
  2491. $info_list[$key]['express'] = $express['servicename'];
  2492. $warehouse = $this->warehouse->read($value['type']);
  2493. $info_list[$key]['type'] = $warehouse['title'];
  2494. if ($value['librarytime'] == '0') {
  2495. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2496. } else {
  2497. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2498. }
  2499. }
  2500. $total = $this->$sj->find_count($where);
  2501. $pagenum = ceil($total / $perpage);
  2502. $over = $total - ($start + $perpage);
  2503. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2504. echo json_encode($rows);
  2505. exit;
  2506. }
  2507. $this->data['express'] = $this->express->find_all();
  2508. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2509. $this->data['wlshop'] = $wlshop;
  2510. $user = $this->user->get_api($_SESSION['api']);
  2511. $powerid = $this->power->read($user['power']);
  2512. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2513. $pid = '';
  2514. foreach ($powertext as $v) {
  2515. $pid .= " id = " . $v . " or";
  2516. }
  2517. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2518. $this->data['fullorderexcel'] = $fullorderexcel;
  2519. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2520. $this->data['orderurl'] = $orderurl;
  2521. $this->_Template('whlabel_outorder', $this->data);
  2522. }
  2523. //tt出库
  2524. public function _toutorder()
  2525. {
  2526. if (isset($_SESSION['api'])) {
  2527. $user = $this->user->get_api($_SESSION['api']);
  2528. $usp = $user;
  2529. $fgshop = "";
  2530. $sid = "";
  2531. $user = explode('|', trim($user['shop'], '|'));
  2532. foreach ($user as $value) {
  2533. $fgshop .= " shop = " . $value . " or";
  2534. $sid .= " id = " . $value . " or";
  2535. }
  2536. } else {
  2537. echo "请重新登录";
  2538. }
  2539. $post = $this->input->post(NULL, TRUE);
  2540. if (isset($post['page'])) {
  2541. $page = $this->input->post('page', true);
  2542. $perpage = $this->input->post('perpage', true);
  2543. $warehouse = $this->input->post('warehouse', true);
  2544. $xztime = $this->input->post('xztime', true);
  2545. $timetk = $this->input->post('timetkk', true);
  2546. $timetj = $this->input->post('timetjj', true);
  2547. $shop = $this->input->post('shop', true);
  2548. $source = $this->input->post('source', true);
  2549. $orderinfo = $this->input->post('orderinfo', true);
  2550. $number = $this->input->post('number', true);
  2551. $sfxh = $this->input->post('sfxh', true);
  2552. $express = $this->input->post('express', true);
  2553. $waybill = $this->input->post('waybill', true);
  2554. $library = $this->input->post('library', true);
  2555. $country = $this->input->post('country', true);
  2556. $so = $this->input->post('so', true);
  2557. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2558. $print = $this->input->post('print', true);
  2559. $state = $this->input->post('state', true);
  2560. $orderurl = $this->input->post('orderurl', true);
  2561. $timetk = strtotime($timetk);
  2562. $timetj = strtotime($timetj);
  2563. /**
  2564. $sj = $this->input->post('sj',true);
  2565. if($sj)
  2566. {
  2567. $sj = $this->input->post('sj',true);
  2568. }
  2569. else
  2570. {
  2571. $sj = "fullorder";
  2572. }
  2573. **/
  2574. $sj = "fullordertt";
  2575. $where = "1=1";
  2576. if ($warehouse) {
  2577. $where .= " and type = '$warehouse'";
  2578. }
  2579. if ($timetk && $timetj) {
  2580. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2581. }
  2582. if ($orderinfo) {
  2583. $where .= " and orderinfo = '$orderinfo'";
  2584. }
  2585. if ($number) {
  2586. $where .= " and number = '$number'";
  2587. }
  2588. if ($express) {
  2589. $where .= " and express = '$express'";
  2590. }
  2591. if ($waybill) {
  2592. $where .= " and waybill = '$waybill'";
  2593. }
  2594. if ($library) {
  2595. $where .= " and library = '$library'";
  2596. }
  2597. if ($print) {
  2598. $where .= " and print = '$print'";
  2599. }
  2600. if ($libraryconfirm) {
  2601. $where .= " and libraryconfirm = '$libraryconfirm'";
  2602. }
  2603. if ($state) {
  2604. $where .= " and state = '$state'";
  2605. }
  2606. if ($shop) {
  2607. $where .= " and shop = '$shop'";
  2608. }
  2609. if ($country) {
  2610. $where .= " and country = '$country'";
  2611. }
  2612. if ($sfxh != '') {
  2613. $where .= " and sfxh = '$sfxh'";
  2614. }
  2615. if ($so) {
  2616. $where .= " and shipremarks like '%$so%'";
  2617. }
  2618. if ($source) {
  2619. if ($source == '2d') {
  2620. $where .= " and source >= '2'";
  2621. } else {
  2622. $where .= " and source = '$source'";
  2623. }
  2624. }
  2625. if (isset($_SESSION['api'])) {
  2626. foreach ($user as $value) {
  2627. $fgshop .= " shop = " . $value . " or";
  2628. }
  2629. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2630. }
  2631. if ($orderurl) {
  2632. $url = $this->orderurl->read($orderurl);
  2633. $where .= " and link like '%" . $url['url'] . "%'";
  2634. }
  2635. //数据排序
  2636. $order_str = "librarytime desc";
  2637. if (empty($page)) {
  2638. $start = 0;
  2639. $perpage = 1;
  2640. } else {
  2641. $start = ($page - 1) * $perpage;
  2642. }
  2643. //取得信息列表
  2644. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2645. //格式化数据
  2646. foreach ($info_list as $key => $value) {
  2647. $shop = $this->shop->read($value['shop']);
  2648. $info_list[$key]['shop'] = $shop['shopname'];
  2649. $express = $this->express->read($value['express']);
  2650. $info_list[$key]['express'] = $express['servicename'];
  2651. $warehouse = $this->warehouse->read($value['type']);
  2652. $info_list[$key]['type'] = $warehouse['title'];
  2653. if ($value['librarytime'] == '0') {
  2654. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2655. } else {
  2656. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2657. }
  2658. }
  2659. $total = $this->$sj->find_count($where);
  2660. $pagenum = ceil($total / $perpage);
  2661. $over = $total - ($start + $perpage);
  2662. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2663. echo json_encode($rows);
  2664. exit;
  2665. }
  2666. $this->data['express'] = $this->express->find_all();
  2667. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2668. $this->data['wlshop'] = $wlshop;
  2669. $user = $this->user->get_api($_SESSION['api']);
  2670. $powerid = $this->power->read($user['power']);
  2671. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2672. $pid = '';
  2673. foreach ($powertext as $v) {
  2674. $pid .= " id = " . $v . " or";
  2675. }
  2676. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2677. $this->data['fullorderexcel'] = $fullorderexcel;
  2678. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2679. $this->data['orderurl'] = $orderurl;
  2680. $this->_Template('whlabel_toutorder', $this->data);
  2681. }
  2682. //tt出库
  2683. public function _aoutorder()
  2684. {
  2685. if (isset($_SESSION['api'])) {
  2686. $user = $this->user->get_api($_SESSION['api']);
  2687. $usp = $user;
  2688. $fgshop = "";
  2689. $sid = "";
  2690. $user = explode('|', trim($user['shop'], '|'));
  2691. foreach ($user as $value) {
  2692. $fgshop .= " shop = " . $value . " or";
  2693. $sid .= " id = " . $value . " or";
  2694. }
  2695. } else {
  2696. echo "请重新登录";
  2697. }
  2698. $post = $this->input->post(NULL, TRUE);
  2699. if (isset($post['page'])) {
  2700. $page = $this->input->post('page', true);
  2701. $perpage = $this->input->post('perpage', true);
  2702. $warehouse = $this->input->post('warehouse', true);
  2703. $xztime = $this->input->post('xztime', true);
  2704. $timetk = $this->input->post('timetkk', true);
  2705. $timetj = $this->input->post('timetjj', true);
  2706. $shop = $this->input->post('shop', true);
  2707. $source = $this->input->post('source', true);
  2708. $orderinfo = $this->input->post('orderinfo', true);
  2709. $number = $this->input->post('number', true);
  2710. $sfxh = $this->input->post('sfxh', true);
  2711. $express = $this->input->post('express', true);
  2712. $waybill = $this->input->post('waybill', true);
  2713. $library = $this->input->post('library', true);
  2714. $country = $this->input->post('country', true);
  2715. $so = $this->input->post('so', true);
  2716. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2717. $print = $this->input->post('print', true);
  2718. $state = $this->input->post('state', true);
  2719. $orderurl = $this->input->post('orderurl', true);
  2720. $timetk = strtotime($timetk);
  2721. $timetj = strtotime($timetj);
  2722. /**
  2723. $sj = $this->input->post('sj',true);
  2724. if($sj)
  2725. {
  2726. $sj = $this->input->post('sj',true);
  2727. }
  2728. else
  2729. {
  2730. $sj = "fullorder";
  2731. }
  2732. **/
  2733. $sj = "fullorderamz";
  2734. $where = "1=1";
  2735. if ($warehouse) {
  2736. $where .= " and type = '$warehouse'";
  2737. }
  2738. if ($timetk && $timetj) {
  2739. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2740. }
  2741. if ($orderinfo) {
  2742. $where .= " and orderinfo = '$orderinfo'";
  2743. }
  2744. if ($number) {
  2745. $where .= " and number = '$number'";
  2746. }
  2747. if ($express) {
  2748. $where .= " and express = '$express'";
  2749. }
  2750. if ($waybill) {
  2751. $where .= " and waybill = '$waybill'";
  2752. }
  2753. if ($library) {
  2754. $where .= " and library = '$library'";
  2755. }
  2756. if ($print) {
  2757. $where .= " and print = '$print'";
  2758. }
  2759. if ($libraryconfirm) {
  2760. $where .= " and libraryconfirm = '$libraryconfirm'";
  2761. }
  2762. if ($state) {
  2763. $where .= " and state = '$state'";
  2764. }
  2765. if ($shop) {
  2766. $where .= " and shop = '$shop'";
  2767. }
  2768. if ($country) {
  2769. $where .= " and country = '$country'";
  2770. }
  2771. if ($sfxh != '') {
  2772. $where .= " and sfxh = '$sfxh'";
  2773. }
  2774. if ($so) {
  2775. $where .= " and shipremarks like '%$so%'";
  2776. }
  2777. if ($source) {
  2778. if ($source == '2d') {
  2779. $where .= " and source >= '2'";
  2780. } else {
  2781. $where .= " and source = '$source'";
  2782. }
  2783. }
  2784. if (isset($_SESSION['api'])) {
  2785. foreach ($user as $value) {
  2786. $fgshop .= " shop = " . $value . " or";
  2787. }
  2788. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2789. }
  2790. if ($orderurl) {
  2791. $url = $this->orderurl->read($orderurl);
  2792. $where .= " and link like '%" . $url['url'] . "%'";
  2793. }
  2794. //数据排序
  2795. $order_str = "librarytime desc";
  2796. if (empty($page)) {
  2797. $start = 0;
  2798. $perpage = 1;
  2799. } else {
  2800. $start = ($page - 1) * $perpage;
  2801. }
  2802. //取得信息列表
  2803. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2804. //格式化数据
  2805. foreach ($info_list as $key => $value) {
  2806. $shop = $this->shop->read($value['shop']);
  2807. $info_list[$key]['shop'] = $shop['shopname'];
  2808. $express = $this->express->read($value['express']);
  2809. $info_list[$key]['express'] = $express['servicename'];
  2810. $warehouse = $this->warehouse->read($value['type']);
  2811. $info_list[$key]['type'] = $warehouse['title'];
  2812. if ($value['librarytime'] == '0') {
  2813. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2814. } else {
  2815. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2816. }
  2817. }
  2818. $total = $this->$sj->find_count($where);
  2819. $pagenum = ceil($total / $perpage);
  2820. $over = $total - ($start + $perpage);
  2821. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2822. echo json_encode($rows);
  2823. exit;
  2824. }
  2825. $this->data['express'] = $this->express->find_all();
  2826. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2827. $this->data['wlshop'] = $wlshop;
  2828. $user = $this->user->get_api($_SESSION['api']);
  2829. $powerid = $this->power->read($user['power']);
  2830. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2831. $pid = '';
  2832. foreach ($powertext as $v) {
  2833. $pid .= " id = " . $v . " or";
  2834. }
  2835. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2836. $this->data['fullorderexcel'] = $fullorderexcel;
  2837. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2838. $this->data['orderurl'] = $orderurl;
  2839. $this->_Template('whlabel_aoutorder', $this->data);
  2840. }
  2841. //速卖通出库订单
  2842. public function _soutorder()
  2843. {
  2844. if (isset($_SESSION['api'])) {
  2845. $user = $this->user->get_api($_SESSION['api']);
  2846. $usp = $user;
  2847. $fgshop = "";
  2848. $sid = "";
  2849. $user = explode('|', trim($user['shop'], '|'));
  2850. foreach ($user as $value) {
  2851. $sid .= " id = " . $value . " or";
  2852. }
  2853. }
  2854. $post = $this->input->post(NULL, TRUE);
  2855. if (isset($post['page'])) {
  2856. $page = $this->input->post('page', true);
  2857. $perpage = $this->input->post('perpage', true);
  2858. $warehouse = $this->input->post('warehouse', true);
  2859. $xztime = $this->input->post('xztime', true);
  2860. $timetk = $this->input->post('timetkk', true);
  2861. $timetj = $this->input->post('timetjj', true);
  2862. $shop = $this->input->post('shop', true);
  2863. $source = $this->input->post('source', true);
  2864. $orderinfo = $this->input->post('orderinfo', true);
  2865. $number = $this->input->post('number', true);
  2866. $express = $this->input->post('express', true);
  2867. $waybill = $this->input->post('waybill', true);
  2868. $library = $this->input->post('library', true);
  2869. $country = $this->input->post('country', true);
  2870. $sfxh = $this->input->post('sfxh', true);
  2871. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2872. $print = $this->input->post('print', true);
  2873. $state = $this->input->post('state', true);
  2874. $so = $this->input->post('so', true);
  2875. $timetk = strtotime($timetk);
  2876. $timetj = strtotime($timetj);
  2877. /**
  2878. $sj = $this->input->post('sj',true);
  2879. if($sj)
  2880. {
  2881. $sj = $this->input->post('sj',true);
  2882. }
  2883. else
  2884. {
  2885. $sj = "fullorder";
  2886. }
  2887. **/
  2888. $sj = "fullordersmt";
  2889. $where = "1=1";
  2890. if ($warehouse) {
  2891. $where .= " and type = '$warehouse'";
  2892. }
  2893. if ($timetk && $timetj) {
  2894. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2895. }
  2896. if ($orderinfo) {
  2897. $where .= " and orderinfo = '$orderinfo'";
  2898. }
  2899. if ($number) {
  2900. $where .= " and number = '$number'";
  2901. }
  2902. if ($express) {
  2903. $where .= " and express = '$express'";
  2904. }
  2905. if ($waybill) {
  2906. $where .= " and waybill = '$waybill'";
  2907. }
  2908. if ($library) {
  2909. $where .= " and library = '$library'";
  2910. }
  2911. if ($print) {
  2912. $where .= " and print = '$print'";
  2913. }
  2914. if ($libraryconfirm) {
  2915. $where .= " and libraryconfirm = '$libraryconfirm'";
  2916. }
  2917. if ($state) {
  2918. $where .= " and state = '$state'";
  2919. }
  2920. if ($shop) {
  2921. $where .= " and shop = '$shop'";
  2922. }
  2923. if ($sfxh != '') {
  2924. $where .= " and sfxh = '$sfxh'";
  2925. }
  2926. if ($so) {
  2927. $where .= " and shipremarks like '%$so%'";
  2928. }
  2929. if ($source) {
  2930. $where .= " and source = '$source'";
  2931. }
  2932. if ($country) {
  2933. $where .= " and country = '$country'";
  2934. } else {
  2935. if (isset($_SESSION['api'])) {
  2936. foreach ($user as $value) {
  2937. $fgshop .= " shop = " . $value . " or";
  2938. }
  2939. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2940. }
  2941. }
  2942. //数据排序
  2943. $order_str = "librarytime desc";
  2944. if (empty($page)) {
  2945. $start = 0;
  2946. $perpage = 1;
  2947. } else {
  2948. $start = ($page - 1) * $perpage;
  2949. }
  2950. //取得信息列表
  2951. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2952. //格式化数据
  2953. foreach ($info_list as $key => $value) {
  2954. $shop = $this->shop->read($value['shop']);
  2955. $info_list[$key]['shop'] = $shop['shopname'];
  2956. $express = $this->express->read($value['express']);
  2957. $info_list[$key]['express'] = $express['servicename'];
  2958. $warehouse = $this->warehouse->read($value['type']);
  2959. $info_list[$key]['type'] = $warehouse['title'];
  2960. if ($value['librarytime'] == '0') {
  2961. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2962. } else {
  2963. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2964. }
  2965. }
  2966. $total = $this->$sj->find_count($where);
  2967. $pagenum = ceil($total / $perpage);
  2968. $over = $total - ($start + $perpage);
  2969. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2970. echo json_encode($rows);
  2971. exit;
  2972. }
  2973. $this->data['express'] = $this->express->find_all();
  2974. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2975. $this->data['wlshop'] = $wlshop;
  2976. $user = $this->user->get_api($_SESSION['api']);
  2977. $powerid = $this->power->read($user['power']);
  2978. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2979. $pid = '';
  2980. foreach ($powertext as $v) {
  2981. $pid .= " id = " . $v . " or";
  2982. }
  2983. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2984. $this->data['fullorderexcel'] = $fullorderexcel;
  2985. $this->_Template('whlabel_soutorder', $this->data);
  2986. }
  2987. //订单退库
  2988. public function _retreat()
  2989. {
  2990. $post = $this->input->post(NULL, TRUE);
  2991. if (isset($post['page'])) {
  2992. $page = $this->input->post('page', true);
  2993. $perpage = $this->input->post('perpage', true);
  2994. $warehouse = $this->input->post('warehouse', true);
  2995. $timetk = $this->input->post('timetk', true);
  2996. $timetj = $this->input->post('timetj', true);
  2997. $shop = $this->input->post('shop', true);
  2998. $source = $this->input->post('source', true);
  2999. $state = $this->input->post('state', true);
  3000. $review = $this->input->post('review', true);
  3001. $state = $this->input->post('state', true);
  3002. $express = $this->input->post('express', true);
  3003. $orderinfo = $this->input->post('orderinfo', true);
  3004. $user = $this->input->post('user', true);
  3005. $name = $this->input->post('name', true);
  3006. $waybill = $this->input->post('waybill', true);
  3007. $timetk = strtotime($timetk);
  3008. $timetj = strtotime($timetj);
  3009. $where = "(state=206 or state=210) and mergeid = 0";
  3010. if ($warehouse) {
  3011. $where .= " and state = '$warehouse'";
  3012. }
  3013. if ($timetk && $timetj) {
  3014. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3015. }
  3016. if ($shop) {
  3017. $where .= " and shop = '$shop'";
  3018. }
  3019. if ($source) {
  3020. $where .= " and source = '$source'";
  3021. }
  3022. if ($state) {
  3023. $where .= " and state = '$state'";
  3024. }
  3025. if ($review) {
  3026. $where .= " and review = '$review'";
  3027. }
  3028. if ($state) {
  3029. $where .= " and state = '$state'";
  3030. }
  3031. if ($express) {
  3032. $where .= " and express = '$express'";
  3033. }
  3034. if ($orderinfo) {
  3035. $where .= " and orderinfo = '$orderinfo'";
  3036. }
  3037. if ($user) {
  3038. $where .= " and user = '$user'";
  3039. }
  3040. if ($name) {
  3041. $where .= " and name = '$name'";
  3042. }
  3043. if ($waybill) {
  3044. $where .= " and waybill = '$waybill'";
  3045. }
  3046. //数据排序
  3047. $order_str = "id desc";
  3048. if (empty($page)) {
  3049. $start = 0;
  3050. $perpage = 1;
  3051. } else {
  3052. $start = ($page - 1) * $perpage;
  3053. }
  3054. //取得信息列表
  3055. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3056. //格式化数据
  3057. foreach ($info_list as $key => $value) {
  3058. $shop = $this->shop->read($value['shop']);
  3059. $info_list[$key]['shop'] = $shop['shopname'];
  3060. $warehouse = $this->warehouse->read($value['warehouse']);
  3061. $info_list[$key]['warehouse'] = $warehouse['title'];
  3062. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3063. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3064. if ($value['waybill'] == 0) {
  3065. $info_list[$key]['waybill'] = "";
  3066. }
  3067. $express = $this->express->read($value['express']);
  3068. $info_list[$key]['express'] = $express['title'];
  3069. $typeclass = $this->typeclass->read($value['state']);
  3070. $info_list[$key]['state'] = $typeclass['title'];
  3071. }
  3072. $total = $this->fullorder->find_count($where);
  3073. $pagenum = ceil($total / $perpage);
  3074. $over = $total - ($start + $perpage);
  3075. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3076. echo json_encode($rows);
  3077. exit;
  3078. }
  3079. $this->data['express'] = $this->express->find_all();
  3080. $this->_Template('whlabel_retreat', $this->data);
  3081. }
  3082. //退库标签浏览
  3083. public function _retreatlk()
  3084. {
  3085. $post = $this->input->post(NULL, TRUE);
  3086. if (isset($post['page'])) {
  3087. $page = $this->input->post('page', true);
  3088. $perpage = $this->input->post('perpage', true);
  3089. $timetk = $this->input->post('timetk', true);
  3090. $timetj = $this->input->post('timetj', true);
  3091. $sku = $this->input->post('sku', true);
  3092. $warehouse = $this->input->post('warehouse', true);
  3093. $purchase = $this->input->post('purchase', true);
  3094. $orderinfo = $this->input->post('orderinfo', true);
  3095. $waybill = $this->input->post('waybill', true);
  3096. $category = $this->input->post('category', true);
  3097. $size = $this->input->post('size', true);
  3098. $grade = $this->input->post('grade', true);
  3099. $color = $this->input->post('color', true);
  3100. $lowe = $this->input->post('lowe', true);
  3101. $state = $this->input->post('state', true);
  3102. $timetk = strtotime($timetk);
  3103. $timetj = strtotime($timetj);
  3104. $where = "state=2";
  3105. if ($timetk && $timetj) {
  3106. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3107. }
  3108. if ($sku) {
  3109. $where .= " and sku = '$sku'";
  3110. }
  3111. if ($warehouse) {
  3112. $where .= " and warehouse = '$warehouse'";
  3113. }
  3114. if ($purchase) {
  3115. $where .= " and purchase = '$purchase'";
  3116. }
  3117. if ($orderinfo) {
  3118. $where .= " and orderinfo = '$orderinfo'";
  3119. }
  3120. if ($waybill) {
  3121. $where .= " and waybill = '$waybill'";
  3122. }
  3123. if ($category) {
  3124. $where .= " and features like '%-$category-%'";
  3125. }
  3126. if ($size) {
  3127. $where .= " and features like '%-$size-%'";
  3128. }
  3129. if ($grade) {
  3130. $where .= " and features like '%-$grade-%'";
  3131. }
  3132. if ($color) {
  3133. $where .= " and features like '%-$color-%'";
  3134. }
  3135. if ($lowe) {
  3136. $where .= " and features like '%-$lowe-%'";
  3137. }
  3138. //数据排序
  3139. $order_str = "time desc";
  3140. if (empty($page)) {
  3141. $start = 0;
  3142. $perpage = 1;
  3143. } else {
  3144. $start = ($page - 1) * $perpage;
  3145. }
  3146. //取得信息列表
  3147. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3148. foreach ($info_list as $key => $value) {
  3149. $warehouse = $this->warehouse->read($value['warehouse']);
  3150. $info_list[$key]['warehouse'] = $warehouse['title'];
  3151. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3152. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3153. $purchase = $this->purchase->read($value['purchase']);
  3154. $info_list[$key]['purchase'] = $purchase['title'];
  3155. if ($value['outk'] != 0) {
  3156. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3157. } else {
  3158. $info_list[$key]['outk'] = "";
  3159. }
  3160. if ($value['retreat'] != 0) {
  3161. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3162. } else {
  3163. $info_list[$key]['retreat'] = "";
  3164. }
  3165. if ($value['orderinfo'] == 0) {
  3166. $info_list[$key]['orderinfo'] = "";
  3167. }
  3168. if ($value['waybill'] == 0) {
  3169. $info_list[$key]['waybill'] = "";
  3170. }
  3171. }
  3172. $total = $this->whlabel->find_count($where);
  3173. $pagenum = ceil($total / $perpage);
  3174. $over = $total - ($start + $perpage);
  3175. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3176. echo json_encode($rows);
  3177. exit;
  3178. }
  3179. $this->_Template('whlabel_retreatlk', $this->data);
  3180. }
  3181. //更换标签及浏览
  3182. public function _change()
  3183. {
  3184. $post = $this->input->post(NULL, TRUE);
  3185. if (isset($post['page'])) {
  3186. $page = $this->input->post('page', true);
  3187. $perpage = $this->input->post('perpage', true);
  3188. $timetk = $this->input->post('timetk', true);
  3189. $timetj = $this->input->post('timetj', true);
  3190. $label = $this->input->post('label', true);
  3191. $oldlabel = $this->input->post('oldlabel', true);
  3192. $timetk = strtotime($timetk);
  3193. $timetj = strtotime($timetj);
  3194. $where = "state=10 ";
  3195. if ($timetk && $timetj) {
  3196. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3197. }
  3198. if ($label) {
  3199. $where .= " and label = '$label'";
  3200. }
  3201. if ($oldlabel) {
  3202. $where .= " and oldlabel = '$oldlabel'";
  3203. }
  3204. //数据排序
  3205. $order_str = "time asc";
  3206. if (empty($page)) {
  3207. $start = 0;
  3208. $perpage = 1;
  3209. } else {
  3210. $start = ($page - 1) * $perpage;
  3211. }
  3212. //取得信息列表
  3213. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3214. foreach ($info_list as $key => $value) {
  3215. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3216. }
  3217. $total = $this->whlabel->find_count($where);
  3218. $pagenum = ceil($total / $perpage);
  3219. $over = $total - ($start + $perpage);
  3220. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3221. echo json_encode($rows);
  3222. exit;
  3223. }
  3224. $this->_Template('whlabel_change', $this->data);
  3225. }
  3226. //产品标签
  3227. public function _cpbqdc()
  3228. {
  3229. if (isset($_GET['excel'])) {
  3230. $where = "1=1";
  3231. //数据排序
  3232. $order_str = "id desc";
  3233. if (empty($page)) {
  3234. $start = 0;
  3235. $perpage = 1;
  3236. } else {
  3237. $start = ($page - 1) * $perpage;
  3238. }
  3239. $warehouse = $this->input->get('warehouse', true);
  3240. $state = $this->input->get('state', true);
  3241. $timetk = $this->input->get('timetkk', true);
  3242. $timetj = $this->input->get('timetjj', true);
  3243. $timetk = strtotime($timetk);
  3244. $timetj = strtotime($timetj);
  3245. if ($warehouse) {
  3246. $where .= " and warehouse = '$warehouse'";
  3247. }
  3248. if ($state || $state == 0) {
  3249. $where .= " and state = '$state'";
  3250. }
  3251. if ($timetk && $timetj) {
  3252. $where .= " and time > '$timetk' and time < '$timetj'";
  3253. }
  3254. //取得信息列表
  3255. $info_list = $this->whlabel->find_all($where, '*');
  3256. $rows = array();
  3257. $list = array();
  3258. foreach ($info_list as $key => $value) {
  3259. $rows[$value['time']] = $value; //所有数据sku
  3260. }
  3261. foreach ($rows as $value) {
  3262. $warehouse = $this->warehouse->read($value['warehouse']);
  3263. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3264. $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);
  3265. }
  3266. $title = "产品标签统计表";
  3267. $titlename = "<table border=1>
  3268. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3269. <tr align='center'>
  3270. <td>仓库</td>
  3271. <td>SKU</td>
  3272. <td>产品</td>
  3273. <td>入库时间</td>
  3274. <td>操作时间</td>
  3275. <td>备注</td>
  3276. <td>数量</td>
  3277. </tr>
  3278. </table>";
  3279. $filename = $title . ".xls";
  3280. $tail = "";
  3281. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3282. }
  3283. }
  3284. //进销存导出
  3285. public function _exceljxc()
  3286. {
  3287. $classid = $this->classid->sku();
  3288. $pm = $classid;
  3289. $typeclass = array();
  3290. $tc = $this->typeclass->find_all();
  3291. foreach ($tc as $v) {
  3292. $typeclass[$v['id']] = $v;
  3293. }
  3294. $prc = array();
  3295. $purchase = $this->purchase->find_all();
  3296. foreach ($purchase as $k => $v) {
  3297. $prc[$v['id']] = $v['title'];
  3298. }
  3299. if (isset($_GET['excel'])) {
  3300. $where = "sku != 'Preset'";
  3301. //数据排序
  3302. $order_str = "id desc";
  3303. if (empty($page)) {
  3304. $start = 0;
  3305. $perpage = 1;
  3306. } else {
  3307. $start = ($page - 1) * $perpage;
  3308. }
  3309. $category = $this->input->get('category', true);
  3310. $warehouse = $this->input->get('warehouse', true);
  3311. $excelid = $this->input->get('sid', true);
  3312. if ($category) {
  3313. $where .= " and features like '%-$category-%'";
  3314. }
  3315. if ($warehouse) {
  3316. $where .= " and warehouse = '$warehouse'";
  3317. }
  3318. $xzid = '';
  3319. if ($excelid) {
  3320. $excelid = explode(',', trim($excelid, ','));
  3321. foreach ($excelid as $key => $value) {
  3322. $xzid .= " id = " . $value . " or";
  3323. }
  3324. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3325. }
  3326. //取得信息列表
  3327. /**
  3328. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3329. $rows = array();$list = array();
  3330. foreach ($info_list as $key=>$value)
  3331. {
  3332. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3333. }
  3334. **/
  3335. $wt = array();
  3336. $whlabel_type = $this->whlabel_type->find_all();
  3337. foreach ($whlabel_type as $v) {
  3338. $wt[$v['id']] = $v['title'];
  3339. }
  3340. $wh = array();
  3341. $w = $this->warehouse->find_all('1=1', 'id,title');
  3342. foreach ($w as $v) {
  3343. $wh[$v['id']] = $v['title'];
  3344. }
  3345. $list = array();
  3346. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3347. foreach ($rows as $key => $value) {
  3348. if (isset($wt[$value['type']])) {
  3349. $rows[$key]['type'] = $wt[$value['type']];
  3350. } else {
  3351. $rows[$key]['type'] = '未设置';
  3352. }
  3353. $bm = '03';
  3354. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3355. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3356. $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');
  3357. $details = array();
  3358. $cpid = array();
  3359. $cpbz = array();
  3360. $c = 0;
  3361. $g = 0;
  3362. $x = 0;
  3363. $t = 0;
  3364. $s = 0;
  3365. $q = 0;
  3366. foreach ($sd as $k => $v) {
  3367. if ($v['state'] == 0) {
  3368. $c++;
  3369. if ($v['cpid'] != 0) {
  3370. $cpid[$v['cpid']] = $v['cpid'];
  3371. }
  3372. if ($v['cpbz'] != '') {
  3373. $cpbz[$v['cpbz']] = $v['cpbz'];
  3374. }
  3375. }
  3376. if ($v['state'] != 9) {
  3377. $g++;
  3378. }
  3379. if ($v['state'] == 1) {
  3380. $x++;
  3381. }
  3382. if ($v['state'] == 2) {
  3383. $t++;
  3384. }
  3385. if ($v['state'] == 8) {
  3386. $s++;
  3387. }
  3388. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3389. $q++;
  3390. }
  3391. $details[$v['details']] = $v['details'];
  3392. }
  3393. $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'] . '"');
  3394. $rows[$key]['details'] = implode("、", $details);
  3395. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3396. $number = $value['number'];
  3397. $ftime = time() - 15 * 24 * 3600;
  3398. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3399. $rows[$key]['number'] = $g;
  3400. $rows[$key]['c'] = $c;
  3401. $rows[$key]['x'] = $x;
  3402. $rows[$key]['t'] = $t;
  3403. $rows[$key]['s'] = $s;
  3404. $rows[$key]['q'] = $q;
  3405. $rows[$key]['z'] = $z;
  3406. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3407. $features = explode('-', trim($features, '-'));
  3408. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3409. // $pm = $classid;
  3410. // $jm = $classid;
  3411. // foreach($features as $k=>$v)
  3412. // {
  3413. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3414. // {
  3415. // if($typeclass[$v]['bm'] != '')
  3416. // {
  3417. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3418. // }
  3419. // }
  3420. // if($v != 0)
  3421. // {
  3422. // if(!isset($typeclass[$v]))
  3423. // {
  3424. // continue;
  3425. // }
  3426. // if(isset($pm[$typeclass[$v]['classid']]))
  3427. // {
  3428. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3429. // {
  3430. // $tz = explode('|',$typeclass[$v]['zh']);
  3431. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3432. // }
  3433. // else
  3434. // {
  3435. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3436. // }
  3437. // }
  3438. // if(isset($jm[$typeclass[$v]['classid']]))
  3439. // {
  3440. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3441. // }
  3442. // }
  3443. // }
  3444. // $jm = array_filter($jm);
  3445. // $rows[$key]['bs'] = implode("-",$jm);
  3446. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3447. // $zh = implode(" ",$pm);
  3448. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3449. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3450. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3451. // $rows[$key]['features'] = $zh;
  3452. }
  3453. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3454. $final_list = [];
  3455. foreach ($list as $k => $v) {
  3456. if (empty($v['sku'])) {
  3457. continue;
  3458. }
  3459. $final_list[] = [
  3460. "warehouse" => $v["warehouse"],
  3461. "purchase" => $v["purchase"],
  3462. "details" => $v["details"],
  3463. "cpid" => $v["cpid"],
  3464. "dbcontent" => $v["dbcontent"],
  3465. "sku" => $v["sku"],
  3466. "cs" => $v["bm"],
  3467. "bs" => $v["jm"],
  3468. "title" => $v["title"],
  3469. "features" => $v["pm"],
  3470. "cpbz" => $v["cpbz"],
  3471. "sm" => $v["sm"],
  3472. "type" => $v["type"],
  3473. "number" => $v["number"],
  3474. "c" => $v["c"],
  3475. "x" => $v["x"],
  3476. "t" => $v["t"],
  3477. "s" => $v["s"],
  3478. "q" => $v["q"],
  3479. "z" => $v["z"],
  3480. "weight" => $v['weight'],
  3481. ];
  3482. }
  3483. $title = "总进销存统计表";
  3484. $titlename = "<table border=1>
  3485. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3486. <tr align='center'>
  3487. <td>仓库</td>
  3488. <td>供应商</td>
  3489. <td>位置</td>
  3490. <td>库存编码</td>
  3491. <td>类目</td>
  3492. <td>SKU</td>
  3493. <td>用友编码</td>
  3494. <td>用友料号</td>
  3495. <td>商品名称</td>
  3496. <td>商品中文</td>
  3497. <td>产品备注</td>
  3498. <td>说明</td>
  3499. <td>类型</td>
  3500. <td>入库总量</td>
  3501. <td>库存数量</td>
  3502. <td>销售数量</td>
  3503. <td>退货数量</td>
  3504. <td>删除数量</td>
  3505. <td>其它操作</td>
  3506. <td>占单数量</td>
  3507. <td>重量(g)</td>
  3508. </tr>
  3509. </table>";
  3510. $filename = $title . ".xls";
  3511. $tail = "";
  3512. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3513. }
  3514. }
  3515. //入库导出
  3516. public function _excelr()
  3517. {
  3518. if (isset($_GET['excel'])) {
  3519. $category = $this->input->get('category', true);
  3520. $size = $this->input->get('size', true);
  3521. $grade = $this->input->get('grade', true);
  3522. $color = $this->input->get('color', true);
  3523. $lowe = $this->input->get('lowe', true);
  3524. $sku = $this->input->get('sku', true);
  3525. $warehouse = $this->input->get('warehouse', true);
  3526. $purchase = $this->input->get('purchase', true);
  3527. $ktime = $this->input->get('ktime', true);
  3528. $jtime = $this->input->get('jtime', true);
  3529. $ktime = strtotime($ktime);
  3530. $jtime = strtotime($jtime);
  3531. $where = "1=1";
  3532. $gj = "";
  3533. $ck = "";
  3534. if ($category) {
  3535. $where .= " and features like '%-$category-%'";
  3536. }
  3537. if ($size) {
  3538. $where .= " and features like '%-$size-%'";
  3539. }
  3540. if ($grade) {
  3541. $where .= " and features like '%-$grade-%'";
  3542. }
  3543. if ($color) {
  3544. $where .= " and features like '%-$color-%'";
  3545. }
  3546. if ($lowe) {
  3547. $where .= " and features like '%-$lowe-%'";
  3548. }
  3549. if ($warehouse) {
  3550. $where .= " and warehouse = '$warehouse'";
  3551. }
  3552. if ($purchase) {
  3553. $where .= " and purchase = '$purchase'";
  3554. }
  3555. if ($sku) {
  3556. $where .= " and sku = '$sku'";
  3557. }
  3558. if ($ktime && $jtime) {
  3559. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3560. }
  3561. //数据排序
  3562. $order_str = "id desc";
  3563. if (empty($page)) {
  3564. $start = 0;
  3565. $perpage = 1;
  3566. } else {
  3567. $start = ($page - 1) * $perpage;
  3568. }
  3569. $list = array();
  3570. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3571. foreach ($rows as $value) {
  3572. $ck = $this->warehouse->read($value['warehouse']);
  3573. $warehouse = $ck['title'];
  3574. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3575. $retreatwarehouse = $tkck['title'];
  3576. $gy = $this->purchase->read($value['purchase']);
  3577. $purchase = $gy['title'];
  3578. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3579. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3580. }
  3581. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3582. $titlename = "<table border=1>
  3583. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3584. <tr align='center'>
  3585. <td>仓库</td>
  3586. <td>SKU</td>
  3587. <td>产品</td>
  3588. <td>时间</td>
  3589. <td>数量</td>
  3590. </tr>
  3591. </table>";
  3592. $filename = $title . ".xls";
  3593. $tail = "";
  3594. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3595. }
  3596. }
  3597. //出库、退库导出
  3598. public function _excelct()
  3599. {
  3600. $classid = $this->classid->sku();
  3601. $pm = $classid;
  3602. $typeclass = array();
  3603. $tc = $this->typeclass->find_all();
  3604. foreach ($tc as $v) {
  3605. $typeclass[$v['id']] = $v;
  3606. }
  3607. $prc = array();
  3608. $purchase = $this->purchase->find_all();
  3609. foreach ($purchase as $k => $v) {
  3610. $prc[$v['id']] = $v['title'];
  3611. }
  3612. if (isset($_GET['excel'])) {
  3613. $wh = array();
  3614. $w = $this->warehouse->find_all('1=1', 'id,title');
  3615. foreach ($w as $v) {
  3616. $wh[$v['id']] = $v['title'];
  3617. }
  3618. $type = $this->input->get('excel', true);
  3619. $category = $this->input->get('category', true);
  3620. $size = $this->input->get('size', true);
  3621. $grade = $this->input->get('grade', true);
  3622. $color = $this->input->get('color', true);
  3623. $lowe = $this->input->get('lowe', true);
  3624. $sku = $this->input->get('sku', true);
  3625. $warehouse = $this->input->get('warehouse', true);
  3626. $lacetype = $this->input->get('lacetype', true);
  3627. $lacecolor = $this->input->get('lacecolor', true);
  3628. $density = $this->input->get('density', true);
  3629. $haircap = $this->input->get('haircap', true);
  3630. $purchase = $this->input->get('purchase', true);
  3631. $title = $this->input->get('title', true);
  3632. $state = $this->input->get('state', true);
  3633. $sid = $this->input->get('sid', true);
  3634. $ktime = $this->input->get('ktime', true);
  3635. $jtime = $this->input->get('jtime', true);
  3636. $ktime = strtotime($ktime);
  3637. $jtime = strtotime($jtime);
  3638. $where = "1=1";
  3639. $gj = "";
  3640. $ck = "";
  3641. if ($category) {
  3642. $where .= " and features like '%-$category-%'";
  3643. }
  3644. if ($size) {
  3645. $where .= " and features like '%-$size-%'";
  3646. }
  3647. if ($grade) {
  3648. $where .= " and features like '%-$grade-%'";
  3649. }
  3650. if ($color) {
  3651. $where .= " and features like '%-$color-%'";
  3652. }
  3653. if ($lowe) {
  3654. $where .= " and features like '%-$lowe-%'";
  3655. }
  3656. if ($warehouse) {
  3657. $where .= " and warehouse = '$warehouse'";
  3658. }
  3659. if ($purchase) {
  3660. $where .= " and purchase = '$purchase'";
  3661. }
  3662. if ($state) {
  3663. $where .= " and state = '$state'";
  3664. }
  3665. if ($lacetype) {
  3666. $where .= " and features like '%-$lacetype-%'";
  3667. }
  3668. if ($lacecolor) {
  3669. $where .= " and features like '%-$lacecolor-%'";
  3670. }
  3671. if ($density) {
  3672. $where .= " and features like '%-$density-%'";
  3673. }
  3674. if ($haircap) {
  3675. $where .= " and features like '%-$haircap-%'";
  3676. }
  3677. if ($title) {
  3678. $title = trim($title, ' ');
  3679. $title = trim($title, ' ');
  3680. $where .= " and title like '%$title%'";
  3681. }
  3682. if ($sku) {
  3683. $sku = trim($sku, ' ');
  3684. $sku = trim($sku, ' ');
  3685. $where .= " and sku like '%$sku%'";
  3686. }
  3687. if ($ktime && $jtime) {
  3688. if ($type == 1) {
  3689. $tl = '出库';
  3690. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3691. } else if ($type == 2) {
  3692. $tl = '退库';
  3693. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3694. } else if ($type == 3) {
  3695. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3696. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3697. } else if ($type == 4) {
  3698. $tl = '出库+零售';
  3699. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3700. } else if ($type == 5) {
  3701. $tl = '零售';
  3702. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3703. }
  3704. }
  3705. $sidwhere = '';
  3706. if ($sid) {
  3707. $sd = "";
  3708. $s = explode(',', trim($sid, ','));
  3709. foreach ($s as $value) {
  3710. $sd .= " id = " . $value . " or";
  3711. }
  3712. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3713. }
  3714. //数据排序
  3715. $order_str = "time desc";
  3716. if (empty($page)) {
  3717. $start = 0;
  3718. $perpage = 1;
  3719. } else {
  3720. $start = ($page - 1) * $perpage;
  3721. }
  3722. //取得信息列表
  3723. if ($type != 3 && $type != 5) {
  3724. if ($type == 1 || $type == 4) {
  3725. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3726. foreach ($info_list as $key => $value) {
  3727. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3728. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3729. $warehouse = $this->warehouse->read($value['warehouse']);
  3730. $info_list[$key]['warehouse'] = $warehouse['title'];
  3731. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3732. $features = explode('-', trim($features, '-'));
  3733. $pm = $classid;
  3734. foreach ($features as $k => $v) {
  3735. if ($v != 0) {
  3736. if (!isset($typeclass[$v])) {
  3737. continue;
  3738. }
  3739. if (isset($pm[$typeclass[$v]['classid']])) {
  3740. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3741. $tz = explode('|', $typeclass[$v]['zh']);
  3742. $pm[$typeclass[$v]['classid']] = $tz[0];
  3743. } else {
  3744. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3745. }
  3746. }
  3747. }
  3748. }
  3749. $zh = implode(" ", $pm);
  3750. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3751. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3752. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3753. $info_list[$key]['features'] = $zh;
  3754. }
  3755. $final_list = [];
  3756. foreach($info_list as $k=>$v){
  3757. $number = "";
  3758. if(!empty($v['orderinfo'])){
  3759. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3760. if(!empty($tmp_info['number'])){
  3761. $number = $tmp_info['number'];
  3762. }
  3763. }
  3764. $final_list[] = [
  3765. 'warehouse'=>$v['warehouse'],
  3766. 'purchase'=>$v['purchase'],
  3767. 'sku'=>$v['sku'],
  3768. 'title'=>$v['title'],
  3769. 'features'=>$v['features'],
  3770. 'label'=>$v['label'],
  3771. 'orderinfo'=>$v['orderinfo'],
  3772. 'number'=>$number,
  3773. 'waybill'=>$v['waybill'],
  3774. 'outk'=>$v['outk'],
  3775. ];
  3776. }
  3777. } else {
  3778. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3779. foreach ($info_list as $key => $value) {
  3780. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3781. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3782. $warehouse = $this->warehouse->read($value['warehouse']);
  3783. $info_list[$key]['warehouse'] = $warehouse['title'];
  3784. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3785. $features = explode('-', trim($features, '-'));
  3786. $pm = $classid;
  3787. foreach ($features as $k => $v) {
  3788. if ($v != 0) {
  3789. if (!isset($typeclass[$v])) {
  3790. continue;
  3791. }
  3792. if (isset($pm[$typeclass[$v]['classid']])) {
  3793. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3794. $tz = explode('|', $typeclass[$v]['zh']);
  3795. $pm[$typeclass[$v]['classid']] = $tz[0];
  3796. } else {
  3797. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3798. }
  3799. }
  3800. }
  3801. }
  3802. $zh = implode(" ", $pm);
  3803. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3804. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3805. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3806. $info_list[$key]['features'] = $zh;
  3807. }
  3808. $final_list = [];
  3809. foreach($info_list as $k=>$v){
  3810. $number = "";
  3811. if(!empty($v['orderinfo'])){
  3812. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3813. if(!empty($tmp_info['number'])){
  3814. $number = $tmp_info['number'];
  3815. }
  3816. }
  3817. $final_list[] = [
  3818. 'warehouse'=>$v['warehouse'],
  3819. 'purchase'=>$v['purchase'],
  3820. 'sku'=>$v['sku'],
  3821. 'title'=>$v['title'],
  3822. 'features'=>$v['features'],
  3823. 'label'=>$v['label'],
  3824. 'orderinfo'=>$v['orderinfo'],
  3825. 'number'=>$number,
  3826. 'waybill'=>$v['waybill'],
  3827. 'retreat'=>$v['retreat'],
  3828. ];
  3829. }
  3830. }
  3831. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3832. $titlename = "<table border=1>
  3833. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3834. <tr align='center'>
  3835. <td>仓库</td>
  3836. <td>供应商</td>
  3837. <td>SKU</td>
  3838. <td>商品名称</td>
  3839. <td>商品中文</td>
  3840. <td>标签</td>
  3841. <td>订单号</td>
  3842. <td>订单编码</td>
  3843. <td>运单号</td>
  3844. <td>" . $tl . "时间(中国时间)</td>
  3845. </tr>
  3846. </table>";
  3847. $filename = $title . ".xls";
  3848. $tail = "";
  3849. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3850. } else if ($type == 5) {
  3851. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3852. foreach ($info_list as $key => $value) {
  3853. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3854. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3855. $warehouse = $this->warehouse->read($value['warehouse']);
  3856. $info_list[$key]['warehouse'] = $warehouse['title'];
  3857. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3858. $features = explode('-', trim($features, '-'));
  3859. $pm = $classid;
  3860. foreach ($features as $k => $v) {
  3861. if ($v != 0) {
  3862. if (!isset($typeclass[$v])) {
  3863. continue;
  3864. }
  3865. if (isset($pm[$typeclass[$v]['classid']])) {
  3866. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3867. $tz = explode('|', $typeclass[$v]['zh']);
  3868. $pm[$typeclass[$v]['classid']] = $tz[0];
  3869. } else {
  3870. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3871. }
  3872. }
  3873. }
  3874. }
  3875. $zh = implode(" ", $pm);
  3876. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3877. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3878. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3879. $info_list[$key]['features'] = $zh;
  3880. }
  3881. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3882. $titlename = "<table border=1>
  3883. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3884. <tr align='center'>
  3885. <td>仓库</td>
  3886. <td>供应商</td>
  3887. <td>SKU</td>
  3888. <td>商品名称</td>
  3889. <td>商品中文</td>
  3890. <td>标签</td>
  3891. <td>" . $tl . "时间(中国时间)</td>
  3892. </tr>
  3893. </table>";
  3894. $filename = $title . ".xls";
  3895. $tail = "";
  3896. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3897. } else {
  3898. /**
  3899. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3900. $rows = array();$list = array();
  3901. foreach ($info_list as $key=>$value)
  3902. {
  3903. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3904. }
  3905. **/
  3906. $wh = array();
  3907. $w = $this->warehouse->find_all('1=1', 'id,title');
  3908. foreach ($w as $v) {
  3909. $wh[$v['id']] = $v['title'];
  3910. }
  3911. $wt = array();
  3912. $whlabel_type = $this->whlabel_type->find_all();
  3913. foreach ($whlabel_type as $v) {
  3914. $wt[$v['id']] = $v['title'];
  3915. }
  3916. $classid = $this->classid->sku();
  3917. $list = array();
  3918. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3919. foreach ($rows as $key => $value) {
  3920. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3921. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3922. $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');
  3923. $details = array();
  3924. $cpid = array();
  3925. $cpbz = array();
  3926. $c = 0;
  3927. $g = 0;
  3928. $x = 0;
  3929. $t = 0;
  3930. $s = 0;
  3931. $q = 0;
  3932. foreach ($sd as $k => $v) {
  3933. if ($v['state'] == 0) {
  3934. $c++;
  3935. }
  3936. if ($v['state'] != 9) {
  3937. $g++;
  3938. }
  3939. if ($v['outk'] > 1) {
  3940. $x++;
  3941. }
  3942. if ($v['retreat'] > 0) {
  3943. $t++;
  3944. }
  3945. if ($v['state'] == 8) {
  3946. $s++;
  3947. }
  3948. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3949. $q++;
  3950. }
  3951. $details[$v['details']] = $v['details'];
  3952. if ($v['cpid'] != 0) {
  3953. $cpid[$v['cpid']] = $v['cpid'];
  3954. }
  3955. if ($v['cpbz'] != '') {
  3956. $cpbz[$v['cpbz']] = $v['cpbz'];
  3957. }
  3958. }
  3959. if (isset($wt[$value['type']])) {
  3960. $rows[$key]['type'] = $wt[$value['type']];
  3961. } else {
  3962. $rows[$key]['type'] = '未设置';
  3963. }
  3964. $rows[$key]['details'] = implode("、", $details);
  3965. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3966. $ftime = time() - 15 * 24 * 3600;
  3967. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3968. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3969. $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);
  3970. $rows[$key]['c'] = $c;
  3971. $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);
  3972. $rows[$key]['t'] = $t;
  3973. $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'] . '"');
  3974. $rows[$key]['z'] = $z;
  3975. // $jm = $classid;
  3976. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3977. $features = explode('-', trim($features, '-'));
  3978. // $pm = $classid;
  3979. // foreach ($features as $k => $v) {
  3980. // if ($v != 0) {
  3981. // if (!isset($typeclass[$v])) {
  3982. // continue;
  3983. // }
  3984. // if (isset($pm[$typeclass[$v]['classid']])) {
  3985. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3986. // $tz = explode('|', $typeclass[$v]['zh']);
  3987. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3988. // } else {
  3989. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3990. // }
  3991. // if (isset($jm[$typeclass[$v]['classid']])) {
  3992. // if ($typeclass[$v]['jm']) {
  3993. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3994. // }
  3995. // }
  3996. // }
  3997. // }
  3998. // }
  3999. // $zh = implode(" ", $pm);
  4000. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4001. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4002. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4003. // $rows[$key]['features'] = $zh;
  4004. // $jm = array_filter($jm); //去除空值
  4005. // $jm = implode("-", $jm);
  4006. // $rows[$key]['jm'] = $jm;
  4007. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4008. }
  4009. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4010. // echo "<pre>";
  4011. // print_r($tmp_list);
  4012. // die;
  4013. $final_list =[];
  4014. foreach($tmp_list as $k=>$v){
  4015. $final_list[] = [
  4016. "warehouse"=>$v['warehouse'],
  4017. "purchase"=>$v['purchase'],
  4018. "details"=>$v['details'],
  4019. "cpid"=>$v['cpid'],
  4020. "sku"=>$v['sku'],
  4021. "title"=>$v['title'],
  4022. "features"=>$v['pm'],
  4023. "cpbz"=>$v['cpbz'],
  4024. "sm"=>$v['sm'],
  4025. "type"=>$v['type'],
  4026. "g"=>$v["g"],
  4027. "c"=>$v["c"],
  4028. "x"=>$v["x"],
  4029. "t"=>$v["t"],
  4030. "z"=>$v["z"],
  4031. "jm"=>$v["jm"],
  4032. "weight"=>$v["weight"],
  4033. "asd"=>$v["asd"],
  4034. ];
  4035. }
  4036. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4037. $titlename = "<table border=1>
  4038. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4039. <tr align='center'>
  4040. <td>仓库</td>
  4041. <td>供应商</td>
  4042. <td>位置</td>
  4043. <td>库存编码</td>
  4044. <td>SKU</td>
  4045. <td>商品名称</td>
  4046. <td>商品中文</td>
  4047. <td>产品备注</td>
  4048. <td>说明</td>
  4049. <td>类型</td>
  4050. <td>入库总量</td>
  4051. <td>库存数量</td>
  4052. <td>销售数量</td>
  4053. <td>退货数量</td>
  4054. <td>占单数量</td>
  4055. <td>料号</td>
  4056. <td>重量</td>
  4057. <td>类目</td>
  4058. </tr>
  4059. </table>";
  4060. $filename = $title . ".xls";
  4061. $tail = "";
  4062. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4063. }
  4064. }
  4065. }
  4066. //出库+入库数据整合
  4067. public function _excelcr()
  4068. {
  4069. if (isset($_GET['excel'])) {
  4070. $type = $this->input->get('excel', true);
  4071. $category = $this->input->get('category', true);
  4072. $size = $this->input->get('size', true);
  4073. $grade = $this->input->get('grade', true);
  4074. $color = $this->input->get('color', true);
  4075. $lowe = $this->input->get('lowe', true);
  4076. $sku = $this->input->get('sku', true);
  4077. $warehouse = $this->input->get('warehouse', true);
  4078. $purchase = $this->input->get('purchase', true);
  4079. $state = $this->input->get('state', true);
  4080. $sid = $this->input->get('sid', true);
  4081. $ktime = $this->input->get('ktime', true);
  4082. $jtime = $this->input->get('jtime', true);
  4083. $ktime = strtotime($ktime);
  4084. $jtime = strtotime($jtime);
  4085. $where = "1=1";
  4086. $gj = "";
  4087. $ck = "";
  4088. if ($category) {
  4089. $where .= " and features like '%-$category-%'";
  4090. }
  4091. if ($size) {
  4092. $where .= " and features like '%-$size-%'";
  4093. }
  4094. if ($grade) {
  4095. $where .= " and features like '%-$grade-%'";
  4096. }
  4097. if ($color) {
  4098. $where .= " and features like '%-$color-%'";
  4099. }
  4100. if ($lowe) {
  4101. $where .= " and features like '%-$lowe-%'";
  4102. }
  4103. if ($warehouse) {
  4104. $where .= " and warehouse = '$warehouse'";
  4105. }
  4106. if ($purchase) {
  4107. $where .= " and purchase = '$purchase'";
  4108. }
  4109. if ($state) {
  4110. $where .= " and state = '$state'";
  4111. }
  4112. if ($sku) {
  4113. $where .= " and sku like '%$sku%'";
  4114. }
  4115. if ($ktime && $jtime) {
  4116. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4117. }
  4118. $sidwhere = '';
  4119. if ($sid) {
  4120. $sd = "";
  4121. $s = explode(',', trim($sid, ','));
  4122. foreach ($s as $value) {
  4123. $sd .= " id = " . $value . " or";
  4124. }
  4125. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4126. }
  4127. //取得信息列表
  4128. $timeread = $ktime;
  4129. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4130. $timelist = array();
  4131. for ($i = 0; $i < $timenum; $i++) {
  4132. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4133. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4134. }
  4135. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4136. //echo "<pre>";
  4137. //print_r($info_list);
  4138. //exit();
  4139. $rows = array();
  4140. $list = array();
  4141. foreach ($info_list as $key => $value) {
  4142. $thistime = $timelist;
  4143. if (isset($rows[strtolower($value['sku'])])) {
  4144. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4145. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4146. }
  4147. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4148. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4149. }
  4150. } else {
  4151. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4152. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4153. }
  4154. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4155. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4156. }
  4157. $rows[strtolower($value['sku'])] = $thistime;
  4158. }
  4159. }
  4160. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4161. <head>
  4162. <!--[if gte mso 9]><xml>
  4163. <x:ExcelWorkbook>
  4164. <x:ExcelWorksheets>
  4165. <x:ExcelWorksheet>
  4166. <x:Name>EXCEL</x:Name>
  4167. <x:WorksheetOptions>
  4168. <x:Print>
  4169. <x:ValidPrinterInfo />
  4170. </x:Print>
  4171. </x:WorksheetOptions>
  4172. </x:ExcelWorksheet>
  4173. </x:ExcelWorksheets>
  4174. </x:ExcelWorkbook>
  4175. </xml>
  4176. <![endif]-->
  4177. </head><body>";
  4178. $str .= "<table border=1><tr><td>SKU</td>";
  4179. foreach ($timelist as $k => $v) {
  4180. $str .= "<td>" . $k . "出库</td>";
  4181. $str .= "<td>" . $k . "入库</td>";
  4182. }
  4183. $str .= "</tr></table>";
  4184. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4185. foreach ($rows as $key => $val) {
  4186. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4187. foreach ($val as $k => $v) {
  4188. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4189. if ($val[$k]['r'] > 0) {
  4190. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4191. } else {
  4192. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4193. }
  4194. }
  4195. $str .= "</tr>";
  4196. }
  4197. $str .= "</table>";
  4198. $str .= "</body></html>";
  4199. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4200. header("Content-type: application/octet-stream");
  4201. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4202. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4203. header("Pragma: no-cache");
  4204. header("Expires: 0");
  4205. exit($str);
  4206. }
  4207. }
  4208. //数量调整模板导出
  4209. public function _presetout()
  4210. {
  4211. if (isset($_GET['excel'])) {
  4212. $where = "sku != 'Preset' and purchase != 0";
  4213. //数据排序
  4214. $order_str = "id desc";
  4215. if (empty($page)) {
  4216. $start = 0;
  4217. $perpage = 1;
  4218. } else {
  4219. $start = ($page - 1) * $perpage;
  4220. }
  4221. //取得信息列表
  4222. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4223. $rows = array();
  4224. $list = array();
  4225. foreach ($info_list as $value) {
  4226. $warehouse = $this->warehouse->read($value['warehouse']);
  4227. $number = $value['number'];
  4228. $ftime = time() - 15 * 24 * 3600;
  4229. $purchase = $this->purchase->read($value['purchase']);
  4230. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4231. }
  4232. $title = "库存模板";
  4233. $titlename = "<table border=1>
  4234. <tr align='center'>
  4235. <td>仓库</td>
  4236. <td>供应商编码</td>
  4237. <td>SKU</td>
  4238. <td>增减数量(正数或负数)</td>
  4239. <td>增减备注</td>
  4240. <td>扣减方式:0减少库存1删除库存</td>
  4241. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4242. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4243. </tr>
  4244. </table>";
  4245. $filename = $title . ".xls";
  4246. $tail = "";
  4247. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4248. }
  4249. }
  4250. //数量调整模板导入
  4251. public function _presetedit()
  4252. {
  4253. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4254. $config['upload_path'] = '.' . $dir;
  4255. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4256. $config['allowed_types'] = 'xls|xlsx|csv';
  4257. $config['max_size'] = 10240;
  4258. $this->load->library('upload', $config);
  4259. $this->upload->initialize($config);
  4260. if ($this->upload->do_upload('userfile')) {
  4261. $full_path = $dir . $this->upload->data('file_name');
  4262. $fileName = '.' . $full_path;
  4263. if (!file_exists($fileName)) {
  4264. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4265. exit;
  4266. } else {
  4267. require_once "./data/excel/PHPExcel/IOFactory.php";
  4268. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4269. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4270. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4271. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4272. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4273. ++$column; //如果列数大于26行
  4274. $list = array();
  4275. for ($i = 2; $i <= $row; $i++) // 行数循环
  4276. {
  4277. $data = array();
  4278. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4279. {
  4280. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4281. }
  4282. $list[] = $data;
  4283. }
  4284. }
  4285. $i = 0;
  4286. $j = 0;
  4287. $ed = array();
  4288. foreach ($list as $key => $value) {
  4289. $time = time();
  4290. if ($value['0'] == "") {
  4291. continue;
  4292. }
  4293. $warehouse = $this->warehouse->get_title($value['0']);
  4294. $purchase = $this->purchase->get_bm($value['1']);
  4295. $sku = $value['2'];
  4296. $num = $value['3']; //调整数量
  4297. $text = $value['4']; //扣减说明
  4298. $type = $value['5']; //调整方式0扣减1删除
  4299. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4300. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4301. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4302. if (!$purchase) //如果没有这个SKU
  4303. {
  4304. $ed[] = array($purchase . '-不存在此供应商编码');
  4305. $j++;
  4306. continue;
  4307. }
  4308. if (!$d) //如果没有这个SKU
  4309. {
  4310. $ed[] = array($sku . '-库存中不存在此SKU');
  4311. $j++;
  4312. continue;
  4313. }
  4314. if (!isset($warehouse['id'])) {
  4315. $ed[] = array($sku . '-仓库名错误!');
  4316. $j++;
  4317. continue;
  4318. }
  4319. if ($type != '0' && $type != '1') {
  4320. $ed[] = array($sku . '-扣减方式填写错误!');
  4321. $j++;
  4322. continue;
  4323. }
  4324. if ($num < 0) //扣减库存
  4325. {
  4326. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4327. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4328. $j++;
  4329. continue;
  4330. }
  4331. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4332. if (count($data) < abs($num)) {
  4333. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4334. $j++;
  4335. continue;
  4336. }
  4337. if ($type == 0) //如果扣减方式为 扣减库存
  4338. {
  4339. for ($i = 0; $i < abs($num); $i++) {
  4340. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4341. }
  4342. } else if ($type == 1) {
  4343. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4344. if (count($zt) > 0) {
  4345. $ed[] = array($sku . '-有在途库存无法删除!');
  4346. $j++;
  4347. continue;
  4348. }
  4349. for ($i = 0; $i < abs($num); $i++) {
  4350. $this->whlabel->remove($data[$i]['id']);
  4351. }
  4352. }
  4353. } else if ($num > 0) //增加库存
  4354. {
  4355. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4356. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4357. $j++;
  4358. continue;
  4359. }
  4360. $post['sku'] = $d['sku'];
  4361. $post['shop'] = $d['shop'];
  4362. $post['warehouse'] = $warehouse['id'];
  4363. $post['purchase'] = $purchase['id'];
  4364. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4365. $post['state'] = 0;
  4366. $post['title'] = $d['title'];
  4367. $post['number'] = $d['number'];
  4368. $post['features'] = $d['features'];
  4369. $post['enter'] = $time;
  4370. $post['time'] = $time; //操作时间
  4371. $post['rktype'] = $rktype;
  4372. for ($i = 0; $i < $num; $i++) {
  4373. $post['label'] = time() . rand(100, 999) . $i;
  4374. $this->whlabel->insert($post);
  4375. }
  4376. }
  4377. sleep(1); //防止入库时间一样,需要延迟1秒
  4378. }
  4379. if ($j > 0) {
  4380. $tt = date('Ymd', time());
  4381. $title = '库存导入错误信息-' . $tt;
  4382. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4383. $tail = "\n";
  4384. $filename = $title . ".xls";
  4385. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4386. $dir = '/data/excel/' . $time . '/';
  4387. $file_name = 'error_' . $time . rand(1000, 9999);
  4388. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4389. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4390. fwrite($myfile, $ecl);
  4391. fclose($myfile);
  4392. $error = $dir . $file_name . '.xls';
  4393. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4394. exit;
  4395. } else {
  4396. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4397. exit;
  4398. }
  4399. }
  4400. }
  4401. //笛卡儿积
  4402. function cp($ps, $sets, $list)
  4403. {
  4404. $result = array();
  4405. $j = 0;
  4406. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4407. if ($i == 0) {
  4408. $result = $sets[$i];
  4409. }
  4410. $tmp = array();
  4411. foreach ($result as $res) {
  4412. foreach ($sets[$i + 1] as $set) {
  4413. $tmp[] = $res . ',' . $set;
  4414. }
  4415. }
  4416. $result = $tmp;
  4417. }
  4418. $this->db->trans_begin();
  4419. foreach ($result as $v) {
  4420. $post = array();
  4421. $title = "";
  4422. $num = "";
  4423. $data = explode(',', $v);
  4424. for ($i = 0; $i < count($list); $i++) {
  4425. $post[$list[$i]] = $data[$i];
  4426. $typeclass = $this->typeclass->read($data[$i]);
  4427. $title = $title . $typeclass['title'] . " ";
  4428. if ($data[$i] != 0) {
  4429. $num .= $data[$i]; //所有数据ID拼接
  4430. }
  4431. }
  4432. foreach ($ps as $kp => $vp) {
  4433. $post[$kp] = $vp;
  4434. }
  4435. $post['number'] = $num;
  4436. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4437. if ($info_list) {
  4438. $j++;
  4439. } else {
  4440. $skunum = $this->whlabel->find_count();
  4441. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4442. $post['title'] = rtrim($title, ' ');
  4443. $this->whlabel->insert($post);
  4444. }
  4445. }
  4446. if ($this->db->trans_status() === FALSE) {
  4447. $this->db->trans_commit();
  4448. return NULL;
  4449. } else {
  4450. $this->db->trans_commit();
  4451. return $j;
  4452. }
  4453. }
  4454. public function _kj($arg_array)
  4455. {
  4456. if (isset($_POST['sku'])) {
  4457. $time = time();
  4458. $sku = $this->input->post('sku', true);
  4459. $warehouse = $this->input->post('warehouse', true);
  4460. $num = $this->input->post('num', true);
  4461. $text = $this->input->post('text', true);
  4462. $purchase = $this->input->post('purchase', true);
  4463. $cktype = $this->input->post('cktype', true);
  4464. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4465. if ($cktype != 1 && $text == '') {
  4466. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4467. exit;
  4468. }
  4469. if ($num > count($order)) {
  4470. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4471. exit;
  4472. } else {
  4473. for ($i = 0; $i < $num; $i++) {
  4474. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4475. }
  4476. }
  4477. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4478. exit;
  4479. }
  4480. $uid = $this->whlabel->read($arg_array[0]);
  4481. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4482. $this->data['data'] = $uid;
  4483. $this->_Template('whlabel_kj', $this->data);
  4484. }
  4485. public function _summary($arg_array)
  4486. {
  4487. $prc = array();
  4488. $purchase = $this->purchase->find_all();
  4489. foreach ($purchase as $k => $v) {
  4490. $prc[$v['id']] = $v['title'];
  4491. }
  4492. if (isset($_GET['excel'])) {
  4493. $ktime = $this->input->get('ktime', true);
  4494. $jtime = $this->input->get('jtime', true);
  4495. $ktime = strtotime($ktime);
  4496. $jtime = strtotime($jtime);
  4497. $where = "1=1";
  4498. if ($ktime && $jtime) {
  4499. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4500. }
  4501. //数据排序
  4502. $order_str = "time desc";
  4503. if (empty($page)) {
  4504. $start = 0;
  4505. $perpage = 1;
  4506. } else {
  4507. $start = ($page - 1) * $perpage;
  4508. }
  4509. //取得信息列表
  4510. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4511. foreach ($info_list as $key => $value) {
  4512. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4513. $warehouse = $this->warehouse->read($value['warehouse']);
  4514. $info_list[$key]['warehouse'] = $warehouse['title'];
  4515. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4516. $details = array();
  4517. $cpid = array();
  4518. foreach ($x as $k => $v) {
  4519. if ($v['details'] != '') {
  4520. $details[$v['details']] = $v['details'];
  4521. }
  4522. if ($v['cpid'] != 0) {
  4523. $cpid[$v['cpid']] = $v['cpid'];
  4524. }
  4525. }
  4526. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4527. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4528. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4529. $info_list[$key]['s'] = $s;
  4530. $info_list[$key]['x'] = count($x);
  4531. }
  4532. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4533. $titlename = "<table border=1>
  4534. <tr align='center'>
  4535. <td>仓库</td>
  4536. <td>供应商</td>
  4537. <td>出库位置</td>
  4538. <td>出库编码</td>
  4539. <td>SKU</td>
  4540. <td>产品名</td>
  4541. <td>总剩余库存</td>
  4542. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4543. </tr>
  4544. </table>";
  4545. $filename = $title . ".xls";
  4546. $tail = "";
  4547. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4548. }
  4549. }
  4550. //usps发货清单
  4551. public function _manifest()
  4552. {
  4553. if (isset($_POST['manifest'])) {
  4554. $wltext = $this->input->post('wltext', true);
  4555. $time = time() - 16 * 3600;
  4556. $ptime = strtotime(date('Y-m-d', $time));
  4557. $waybill = array();
  4558. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4559. foreach ($fullorder as $v) {
  4560. $waybill[$v['waybill']] = $v['waybill'];
  4561. }
  4562. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4563. foreach ($fullordersmt as $v) {
  4564. $waybill[$v['waybill']] = $v['waybill'];
  4565. }
  4566. $wltext = explode(';', $wltext);
  4567. foreach ($wltext as $v) {
  4568. if (isset($waybill[$v])) {
  4569. unset($waybill[$v]);
  4570. }
  4571. }
  4572. $data = $this->usps->get_manifest($waybill);
  4573. if (isset($data['Description'])) {
  4574. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4575. exit;
  4576. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4577. $bctime = date('Ymd', time());
  4578. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4579. echo json_encode(array('msg' => $pdf, 'success' => true));
  4580. exit;
  4581. } else {
  4582. echo json_encode(array('msg' => $data, 'success' => false));
  4583. exit;
  4584. }
  4585. }
  4586. }
  4587. public function _pdf($pdf, $title, $bctime)
  4588. {
  4589. $pdf_path = './data/pdf/' . $bctime . '/';
  4590. $file_base64 = $pdf;
  4591. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4592. $file_base64 = base64_decode($file_base64);
  4593. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4594. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4595. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4596. }
  4597. /**
  4598. *
  4599. *
  4600. *
  4601. 进销存占单异常索引
  4602. *
  4603. *
  4604. *
  4605. **/
  4606. public function _abnormal()
  4607. {
  4608. $post = $this->input->post(NULL, TRUE);
  4609. if (isset($post['page'])) {
  4610. $page = $this->input->post('page', true);
  4611. $perpage = $this->input->post('perpage', true);
  4612. $sku = $this->input->post('sku', true);
  4613. $where = "1=1";
  4614. //数据排序
  4615. $order_str = "id desc";
  4616. if (empty($page)) {
  4617. $start = 0;
  4618. $perpage = 1;
  4619. } else {
  4620. $start = ($page - 1) * $perpage;
  4621. }
  4622. //取得信息列表
  4623. $info_list = $this->whlabel->find_all($where, '*');
  4624. $rows = array();
  4625. $list = array();
  4626. foreach ($info_list as $key => $value) {
  4627. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4628. }
  4629. foreach ($rows as $value) {
  4630. $warehouse = $this->warehouse->read($value['warehouse']);
  4631. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4632. $number = $value['number'];
  4633. $ftime = time() - 15 * 24 * 3600;
  4634. if ($value['shop'] != '') {
  4635. $shop = $value['shop'];
  4636. $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');
  4637. $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');
  4638. $order = array_merge($orderdlz, $ordersmt);
  4639. $od = 0;
  4640. $a = '';
  4641. $orid = '';
  4642. foreach ($order as $v) {
  4643. $or = explode('|', ltrim($v['whlabel'], '|'));
  4644. for ($i = 0; $i < count($or); $i++) {
  4645. $orod = explode('-', $or[$i]);
  4646. if ($orod[0] == $number) {
  4647. $od += $orod[1];
  4648. }
  4649. }
  4650. $orid .= $v['number'] . '-';
  4651. }
  4652. } else {
  4653. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4654. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4655. $order = array_merge($orderdlz, $ordersmt);
  4656. $od = 0;
  4657. $a = '';
  4658. $orid = '';
  4659. $qt = array();
  4660. foreach ($order as $v) {
  4661. $or = explode('|', ltrim($v['whlabel'], '|'));
  4662. for ($i = 0; $i < count($or); $i++) {
  4663. $orod = explode('-', $or[$i]);
  4664. if ($orod[0] == $number) {
  4665. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4666. if ($czzs > 0) {
  4667. if (isset($qt[$v['shop']])) {
  4668. if ($qt[$v['shop']] < $orod[1]) {
  4669. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4670. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4671. } else {
  4672. $qt[$v['shop']] -= $orod[1];
  4673. }
  4674. } else {
  4675. $qt[$v['shop']] = $czzs;
  4676. }
  4677. } else {
  4678. $od += $orod[1];
  4679. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4680. }
  4681. }
  4682. }
  4683. }
  4684. }
  4685. $z = $od . '(' . $orid . ')'; //查看订单号
  4686. //$z = $od;
  4687. if ($od > $c) {
  4688. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4689. }
  4690. }
  4691. $listdata = array_slice($list, $start, $perpage);
  4692. $total = count($list);
  4693. $pagenum = ceil($total / $perpage);
  4694. $over = $total - ($start + $perpage);
  4695. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4696. echo json_encode($rows);
  4697. exit;
  4698. }
  4699. $this->_Template('whlabel_abnormal', $this->data);
  4700. }
  4701. /**
  4702. *
  4703. *
  4704. *
  4705. 进销存占单异常索引
  4706. *
  4707. *
  4708. *
  4709. **/
  4710. public function _error()
  4711. {
  4712. $post = $this->input->post(NULL, TRUE);
  4713. if (isset($post['page'])) {
  4714. $page = $this->input->post('page', true);
  4715. $perpage = $this->input->post('perpage', true);
  4716. $sku = $this->input->post('sku', true);
  4717. $warehouse = $this->input->post('warehouse', true);
  4718. $ktime = $this->input->post('ktime', true);
  4719. $jtime = $this->input->post('jtime', true);
  4720. $ktime = strtotime($ktime);
  4721. $jtime = strtotime($jtime);
  4722. $where = "sku != 'Preset'";
  4723. $gj = '';
  4724. if ($sku) {
  4725. $where .= " and sku like '%$sku%'";
  4726. } else {
  4727. if ($ktime && $jtime) {
  4728. $gj = " and time > '$ktime' and time < '$jtime'";
  4729. }
  4730. }
  4731. if ($warehouse) {
  4732. $where .= " and warehouse = '$warehouse'";
  4733. }
  4734. //数据排序
  4735. $order_str = "id desc";
  4736. if (empty($page)) {
  4737. $start = 0;
  4738. $perpage = 1;
  4739. } else {
  4740. $start = ($page - 1) * $perpage;
  4741. }
  4742. //取得信息列表
  4743. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4744. $rows = array();
  4745. $list = array();
  4746. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4747. // foreach ($info_list as $value)
  4748. // {
  4749. // $warehouse = $this->warehouse->read($value['warehouse']);
  4750. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4751. // $number = $value['number'];$ftime = time()-15*24*3600;
  4752. // if($c < 1)
  4753. // {
  4754. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4755. // }
  4756. // }
  4757. $warehouse_list = $this->warehouse->find_all();
  4758. $warehouse_list = array_column($warehouse_list, null, 'id');
  4759. foreach ($info_list as $value) {
  4760. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4761. 'title' => "",
  4762. ];
  4763. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4764. $number = $value['number'];
  4765. $ftime = time() - 15 * 24 * 3600;
  4766. if ($c < 1) {
  4767. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4768. }
  4769. }
  4770. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4771. // $query = $this->db->query($sql);
  4772. // $info_list = $query->result_array();
  4773. // $sql_two = "select title,id from crowd_warehouse";
  4774. // $query_two = $this->db->query($sql_two);
  4775. // $warehouse_list = $query_two->result_array();
  4776. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4777. // foreach ($info_list as $value)
  4778. // {
  4779. // if(isset($warehouse_arr[$value['warehouse']])){
  4780. // $warehouse = $warehouse_arr[$value['warehouse']];
  4781. // }else{
  4782. // $warehouse = [
  4783. // 'id'=>0,
  4784. // 'title'=>"异常",
  4785. // ];
  4786. // }
  4787. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4788. // $number = $value['number'];$ftime = time()-15*24*3600;
  4789. // if($c < 1)
  4790. // {
  4791. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4792. // }
  4793. // }
  4794. $listdata = array_slice($list, $start, $perpage);
  4795. $total = count($list);
  4796. $pagenum = ceil($total / $perpage);
  4797. $over = $total - ($start + $perpage);
  4798. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4799. echo json_encode($rows);
  4800. exit;
  4801. }
  4802. if (isset($post['s'])) {
  4803. $id_arr = $this->input->post('s');
  4804. $id_arr = explode(',', trim($id_arr, ','));
  4805. if (!$id_arr) {
  4806. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4807. exit;
  4808. }
  4809. //循环删除记录
  4810. foreach ($id_arr as $v) {
  4811. $dd = $this->whlabel->read($v);
  4812. if (!isset($dd['id'])) {
  4813. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4814. exit;
  4815. }
  4816. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4817. if (isset($zt[0])) {
  4818. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4819. exit;
  4820. }
  4821. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4822. foreach ($deldd as $vv) {
  4823. $this->whlabel->remove($vv['id']);
  4824. }
  4825. }
  4826. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4827. exit;
  4828. }
  4829. $this->_Template('whlabel_error', $this->data);
  4830. }
  4831. public function _errorexcel()
  4832. {
  4833. $post = $this->input->post(NULL, TRUE);
  4834. if (isset($_GET['page'])) {
  4835. $page = $this->input->get('page', true);
  4836. $perpage = $this->input->get('perpage', true);
  4837. $sku = $this->input->get('sku', true);
  4838. $warehouse = $this->input->get('warehouse', true);
  4839. $ktime = $this->input->get('ktime', true);
  4840. $jtime = $this->input->get('jtime', true);
  4841. $ktime = strtotime($ktime);
  4842. $jtime = strtotime($jtime);
  4843. $where = "sku != 'Preset'";
  4844. $gj = '';
  4845. if ($sku) {
  4846. $where .= " and sku like '%$sku%'";
  4847. } else {
  4848. if ($ktime && $jtime) {
  4849. $gj = " and time > '$ktime' and time < '$jtime'";
  4850. }
  4851. }
  4852. if ($warehouse) {
  4853. $where .= " and warehouse = '$warehouse'";
  4854. }
  4855. //数据排序
  4856. $order_str = "id desc";
  4857. if (empty($page)) {
  4858. $start = 0;
  4859. $perpage = 1;
  4860. } else {
  4861. $start = ($page - 1) * $perpage;
  4862. }
  4863. //取得信息列表
  4864. $rows = array();
  4865. $list = array();
  4866. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4867. foreach ($info_list as $value) {
  4868. $warehouse = $this->warehouse->read($value['warehouse']);
  4869. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4870. $number = $value['number'];
  4871. $ftime = time() - 15 * 24 * 3600;
  4872. if ($c < 1) {
  4873. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4874. }
  4875. }
  4876. $title = "0库存汇总";
  4877. $titlename = "<table border=1>
  4878. <tr align='center'>
  4879. <td>仓库</td>
  4880. <td>SKU</td>
  4881. <td>产品</td>
  4882. <td>当前库存</td>
  4883. </tr>
  4884. </table>";
  4885. $filename = $title . ".xls";
  4886. $tail = "";
  4887. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4888. }
  4889. }
  4890. /**
  4891. *
  4892. *
  4893. * 占单
  4894. *
  4895. *
  4896. **/
  4897. public function _kcyz()
  4898. {
  4899. $post = $this->input->post(NULL, TRUE);
  4900. if (isset($post['warehouse'])) {
  4901. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4902. exit; //不再使用
  4903. $warehouse = $this->input->post('warehouse', true);
  4904. $whlabel = $this->input->post('whlabel', true);
  4905. $id = $this->input->post('id', true);
  4906. $shop = $this->input->post('shop', true);
  4907. $number = $this->input->post('number', true);
  4908. if (!$whlabel || $whlabel == '|') {
  4909. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4910. exit;
  4911. }
  4912. $pp = explode('|', trim($whlabel, '|'));
  4913. $x = 0;
  4914. $save = array();
  4915. foreach ($pp as $va) {
  4916. $num = explode('-', $va);
  4917. if ($number) {
  4918. $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 = '')"); //通用
  4919. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4920. } else {
  4921. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4922. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4923. }
  4924. $x++;
  4925. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4926. $save[] = $x - 1;
  4927. continue; //提前先加X不然出错,所以要减1
  4928. }
  4929. }
  4930. if (isset($save[0])) {
  4931. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4932. exit;
  4933. } else {
  4934. echo json_encode(array('success' => true));
  4935. exit;
  4936. }
  4937. }
  4938. }
  4939. public function _db()
  4940. {
  4941. $post = $this->input->post(NULL, TRUE);
  4942. if (isset($post['page'])) {
  4943. $page = $this->input->post('page', true);
  4944. $perpage = $this->input->post('perpage', true);
  4945. $sku = $this->input->post('sku', true);
  4946. $number = $this->input->post('number', true);
  4947. $warehouse = $this->input->post('warehouse', true);
  4948. $purchase = $this->input->post('purchase', true);
  4949. $orderinfo = $this->input->post('orderinfo', true);
  4950. $waybill = $this->input->post('waybill', true);
  4951. $category = $this->input->post('category', true);
  4952. $size = $this->input->post('size', true);
  4953. $grade = $this->input->post('grade', true);
  4954. $color = $this->input->post('color', true);
  4955. $lowe = $this->input->post('lowe', true);
  4956. $state = $this->input->post('state', true);
  4957. $label = $this->input->post('label', true);
  4958. $timetk = $this->input->post('timetkk', true);
  4959. $timetj = $this->input->post('timetjj', true);
  4960. $timetk = strtotime($timetk);
  4961. $timetj = strtotime($timetj);
  4962. $where = "dbtime > 0";
  4963. if ($timetk && $timetj) {
  4964. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4965. }
  4966. if ($sku) {
  4967. $where .= " and sku = '$sku'";
  4968. }
  4969. if ($warehouse) {
  4970. $where .= " and warehouse = '$warehouse'";
  4971. if ($warehouse == 12) {
  4972. $w = 'specialstock';
  4973. } else {
  4974. $w = 'whlabel';
  4975. }
  4976. }
  4977. if ($purchase) {
  4978. $where .= " and purchase = '$purchase'";
  4979. }
  4980. if ($category) {
  4981. $where .= " and features like '%-$category-%'";
  4982. }
  4983. if ($size) {
  4984. $where .= " and features like '%-$size-%'";
  4985. }
  4986. if ($grade) {
  4987. $where .= " and features like '%-$grade-%'";
  4988. }
  4989. if ($color) {
  4990. $where .= " and features like '%-$color-%'";
  4991. }
  4992. if ($lowe) {
  4993. $where .= " and features like '%-$lowe-%'";
  4994. }
  4995. if ($state != '') {
  4996. $where .= " and state = '$state'";
  4997. }
  4998. //数据排序
  4999. $order_str = "dbtime desc";
  5000. if (empty($page)) {
  5001. $start = 0;
  5002. $perpage = 1;
  5003. } else {
  5004. $start = ($page - 1) * $perpage;
  5005. }
  5006. //取得信息列表
  5007. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5008. foreach ($info_list as $key => $value) {
  5009. $warehouse = $this->$w->read($value['warehouse']);
  5010. $info_list[$key]['warehouse'] = $warehouse['title'];
  5011. $purchase = $this->purchase->read($value['purchase']);
  5012. $info_list[$key]['purchase'] = $purchase['title'];
  5013. if ($value['enter'] != 0) {
  5014. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5015. } else {
  5016. $info_list[$key]['enter'] = "";
  5017. }
  5018. if ($value['dbtime'] != 0) {
  5019. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5020. } else {
  5021. $info_list[$key]['dbtime'] = "";
  5022. }
  5023. if ($value['state'] == 0) {
  5024. $info_list[$key]['state'] = "在库";
  5025. } else if ($value['state'] == 1) {
  5026. $info_list[$key]['state'] = "出库";
  5027. } else if ($value['state'] == 2) {
  5028. $info_list[$key]['state'] = "退库";
  5029. } else if ($value['state'] == 3) {
  5030. $info_list[$key]['state'] = "调拨中";
  5031. } else if ($value['state'] == 4) {
  5032. $info_list[$key]['state'] = "再加工";
  5033. } else if ($value['state'] == 5) {
  5034. $info_list[$key]['state'] = "维修中";
  5035. } else if ($value['state'] == 6) {
  5036. $info_list[$key]['state'] = "盘亏";
  5037. } else if ($value['state'] == 7) {
  5038. $info_list[$key]['state'] = "更换标签";
  5039. } else if ($value['state'] == 8) {
  5040. $info_list[$key]['state'] = "其它";
  5041. } else if ($value['state'] == 9) {
  5042. $info_list[$key]['state'] = "预设";
  5043. }
  5044. }
  5045. $total = $this->whlabel->find_count($where);
  5046. $pagenum = ceil($total / $perpage);
  5047. $over = $total - ($start + $perpage);
  5048. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5049. echo json_encode($rows);
  5050. exit;
  5051. }
  5052. if (isset($post['outsku'])) {
  5053. $time = time();
  5054. $cz = $this->input->post('cz', true);
  5055. $label = $this->input->post('outsku', true);
  5056. $sl = $this->input->post('sl', true);
  5057. $num = $this->input->post('num', true);
  5058. //$warehouse = $this->input->post('warehouse',true);
  5059. if (!$sl) {
  5060. $sl = 1;
  5061. }
  5062. if (!$warehouse) {
  5063. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5064. exit;
  5065. }
  5066. $dblabel = $this->whlabellabel->get_label($label);
  5067. if ($dblabel) {
  5068. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5069. if (count($data) < 1) {
  5070. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5071. exit;
  5072. }
  5073. if (count($data) < $num) {
  5074. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5075. exit;
  5076. }
  5077. for ($i = 0; $i < $sl; $i++) {
  5078. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5079. }
  5080. echo json_encode(array('success' => true));
  5081. exit;
  5082. } else {
  5083. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5084. exit;
  5085. }
  5086. }
  5087. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5088. $this->_Template('whlabel_db', $this->data);
  5089. }
  5090. public function _dbrk()
  5091. {
  5092. $post = $this->input->post(NULL, TRUE);
  5093. if (isset($post['page'])) {
  5094. $page = $this->input->post('page', true);
  5095. $perpage = $this->input->post('perpage', true);
  5096. $sku = $this->input->post('sku', true);
  5097. $number = $this->input->post('number', true);
  5098. $warehouse = $this->input->post('warehouse', true);
  5099. $purchase = $this->input->post('purchase', true);
  5100. $orderinfo = $this->input->post('orderinfo', true);
  5101. $waybill = $this->input->post('waybill', true);
  5102. $category = $this->input->post('category', true);
  5103. $size = $this->input->post('size', true);
  5104. $grade = $this->input->post('grade', true);
  5105. $color = $this->input->post('color', true);
  5106. $lowe = $this->input->post('lowe', true);
  5107. $state = $this->input->post('state', true);
  5108. $label = $this->input->post('label', true);
  5109. $ctime = $this->input->post('ctime', true);
  5110. $timetk = $this->input->post('timetkk', true);
  5111. $timetj = $this->input->post('timetjj', true);
  5112. $timetk = strtotime($timetk);
  5113. $timetj = strtotime($timetj);
  5114. $where = "dbtime > 0";
  5115. if ($timetk && $timetj) {
  5116. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5117. }
  5118. if ($sku) {
  5119. $where .= " and sku = '$sku'";
  5120. }
  5121. if ($warehouse) {
  5122. $where .= " and warehouse = '$warehouse'";
  5123. }
  5124. if ($purchase) {
  5125. $where .= " and purchase = '$purchase'";
  5126. }
  5127. if ($category) {
  5128. $where .= " and features like '%-$category-%'";
  5129. }
  5130. if ($size) {
  5131. $where .= " and features like '%-$size-%'";
  5132. }
  5133. if ($grade) {
  5134. $where .= " and features like '%-$grade-%'";
  5135. }
  5136. if ($color) {
  5137. $where .= " and features like '%-$color-%'";
  5138. }
  5139. if ($lowe) {
  5140. $where .= " and features like '%-$lowe-%'";
  5141. }
  5142. if ($state != '') {
  5143. $where .= " and state = '$state'";
  5144. }
  5145. //数据排序
  5146. $order_str = "dbtime desc";
  5147. if (empty($page)) {
  5148. $start = 0;
  5149. $perpage = 1;
  5150. } else {
  5151. $start = ($page - 1) * $perpage;
  5152. }
  5153. //取得信息列表
  5154. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5155. foreach ($info_list as $key => $value) {
  5156. $warehouse = $this->warehouse->read($value['warehouse']);
  5157. $info_list[$key]['warehouse'] = $warehouse['title'];
  5158. $purchase = $this->purchase->read($value['purchase']);
  5159. $info_list[$key]['purchase'] = $purchase['title'];
  5160. if ($value['enter'] != 0) {
  5161. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5162. } else {
  5163. $info_list[$key]['enter'] = "";
  5164. }
  5165. if ($value['dbtime'] != 0) {
  5166. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5167. } else {
  5168. $info_list[$key]['dbtime'] = "";
  5169. }
  5170. if ($value['state'] == 0) {
  5171. $info_list[$key]['state'] = "在库";
  5172. } else if ($value['state'] == 1) {
  5173. $info_list[$key]['state'] = "出库";
  5174. } else if ($value['state'] == 2) {
  5175. $info_list[$key]['state'] = "退库";
  5176. } else if ($value['state'] == 3) {
  5177. $info_list[$key]['state'] = "调拨中";
  5178. } else if ($value['state'] == 4) {
  5179. $info_list[$key]['state'] = "再加工";
  5180. } else if ($value['state'] == 5) {
  5181. $info_list[$key]['state'] = "维修中";
  5182. } else if ($value['state'] == 6) {
  5183. $info_list[$key]['state'] = "盘亏";
  5184. } else if ($value['state'] == 7) {
  5185. $info_list[$key]['state'] = "更换标签";
  5186. } else if ($value['state'] == 8) {
  5187. $info_list[$key]['state'] = "其它";
  5188. } else if ($value['state'] == 9) {
  5189. $info_list[$key]['state'] = "预设";
  5190. }
  5191. }
  5192. $total = $this->whlabel->find_count($where);
  5193. $pagenum = ceil($total / $perpage);
  5194. $over = $total - ($start + $perpage);
  5195. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5196. echo json_encode($rows);
  5197. exit;
  5198. }
  5199. if (isset($post['rsku'])) {
  5200. $cz = $this->input->post('cz', true);
  5201. $label = $this->input->post('rsku', true);
  5202. $sl = $this->input->post('sl', true);
  5203. $warehouse = $this->input->post('warehouse', true);
  5204. if (!$sl) {
  5205. $sl = 1;
  5206. }
  5207. if (!$warehouse) {
  5208. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5209. exit;
  5210. }
  5211. $dblabel = $this->whlabellabel->get_label($label);
  5212. if ($dblabel) {
  5213. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5214. if (count($data) < 1) {
  5215. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5216. exit;
  5217. }
  5218. if ($sl > count($data)) {
  5219. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5220. exit;
  5221. }
  5222. $time = time();
  5223. for ($i = 0; $i < $sl; $i++) {
  5224. $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']);
  5225. }
  5226. echo json_encode(array('success' => true));
  5227. exit;
  5228. } else {
  5229. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5230. exit;
  5231. }
  5232. }
  5233. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5234. $this->_Template('whlabel_dbrk', $this->data);
  5235. }
  5236. public function _whlabelczdc()
  5237. {
  5238. if (isset($_GET['excel'])) {
  5239. //数据排序
  5240. $order_str = "id desc";
  5241. if (empty($page)) {
  5242. $start = 0;
  5243. $perpage = 1;
  5244. } else {
  5245. $start = ($page - 1) * $perpage;
  5246. }
  5247. $state = $this->input->get('state', true);
  5248. $sku = $this->input->get('sku', true);
  5249. $ctime = $this->input->get('ctime', true);
  5250. $category = $this->input->get('category', true);
  5251. $size = $this->input->get('size', true);
  5252. $grade = $this->input->get('grade', true);
  5253. $color = $this->input->get('color', true);
  5254. $lowe = $this->input->get('lowe', true);
  5255. $timetk = $this->input->get('timetkk', true);
  5256. $timetj = $this->input->get('timetjj', true);
  5257. $timetk = strtotime($timetk);
  5258. $timetj = strtotime($timetj);
  5259. $where = "dbtime > 0";
  5260. if ($timetk && $timetj) {
  5261. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5262. }
  5263. if ($category) {
  5264. $where .= " and features like '%-$category-%'";
  5265. }
  5266. if ($size) {
  5267. $where .= " and features like '%-$size-%'";
  5268. }
  5269. if ($grade) {
  5270. $where .= " and features like '%-$grade-%'";
  5271. }
  5272. if ($color) {
  5273. $where .= " and features like '%-$color-%'";
  5274. }
  5275. if ($lowe) {
  5276. $where .= " and features like '%-$lowe-%'";
  5277. }
  5278. //取得信息列表
  5279. $info_list = $this->whlabel->find_all($where, '*');
  5280. $rows = array();
  5281. $list = array();
  5282. foreach ($info_list as $key => $value) {
  5283. $rows[$value['sku']] = $value; //所有数据sku
  5284. }
  5285. foreach ($rows as $value) {
  5286. $warehouse = $this->warehouse->read($value['warehouse']);
  5287. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5288. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5289. if ($value['orderinfo'] == 0) {
  5290. $info_list[$key]['orderinfo'] = "";
  5291. }
  5292. if ($value['waybill'] == 0) {
  5293. $info_list[$key]['waybill'] = "";
  5294. }
  5295. if ($value['state'] == 0) {
  5296. $value['state'] = "在库";
  5297. } else if ($value['state'] == 3) {
  5298. $value['state'] = "调拨中";
  5299. }
  5300. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5301. }
  5302. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5303. $titlename = "<table border=1>
  5304. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5305. <tr align='center'>
  5306. <td>SKU</td>
  5307. <td>产品</td>
  5308. <td>调拨数量</td>
  5309. <td>入库数量</td>
  5310. </tr>
  5311. </table>";
  5312. $filename = $title . ".xls";
  5313. $tail = "";
  5314. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5315. }
  5316. }
  5317. public function _print($arg_array)
  5318. {
  5319. if (isset($_SESSION['api'])) {
  5320. $user = $this->user->get_api($_SESSION['api']);
  5321. $usp = $user;
  5322. $fgshop = "";
  5323. $sid = "";
  5324. $wid = "";
  5325. $wtype = "";
  5326. $usersp = explode('|', trim($user['shop'], '|'));
  5327. $userwh = explode('|', trim($user['warehouse'], '|'));
  5328. foreach ($usersp as $value) {
  5329. $fgshop .= " shop = " . $value . " or";
  5330. $sid .= " id = " . $value . " or";
  5331. }
  5332. foreach ($userwh as $value) {
  5333. $wid .= " id = " . $value . " or";
  5334. $wtype .= " type = " . $value . " or";
  5335. }
  5336. }
  5337. $post = $this->input->post(NULL, TRUE);
  5338. if (isset($post['tmsku'])) {
  5339. $tmsku = $this->input->post('tmsku', true);
  5340. if (is_numeric($tmsku)) {
  5341. $yyh = $this->whlabellabel->get_label($tmsku);
  5342. } else {
  5343. $yyh = $this->whlabellabel->get_sku($tmsku);
  5344. }
  5345. if ($yyh) {
  5346. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5347. exit;
  5348. } else {
  5349. echo json_encode(array('success' => false));
  5350. exit;
  5351. }
  5352. }
  5353. $classid = $this->classid->sku();
  5354. $pm = $classid;
  5355. $scsku = $classid;
  5356. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5357. if (isset($post['warehouse'])) {
  5358. if ($post['warehouse']) {
  5359. $list = array();
  5360. $num = "";
  5361. $title = "";
  5362. $features = "";
  5363. $order = 0;
  5364. $post['shop'] = '';
  5365. $brand = $this->input->post('brand', true);
  5366. if ($brand != '0,') {
  5367. $b = $this->brand->read(rtrim($brand, ','));
  5368. if ($b) {
  5369. $post['shop'] = str_replace('|', ',', $b['shop']);
  5370. }
  5371. }
  5372. $post['details'] = $this->input->post('details', true); //打印数量
  5373. $xbqnum = $this->input->post('xbqnum', true);
  5374. $post['purchase'] = $this->input->post('purchase', true);
  5375. $post['warehouse'] = $this->input->post('warehouse', true);
  5376. $post['purchase'] = $this->input->post('purchase', true);
  5377. $post['retreatwarehouse'] = $post['warehouse'];
  5378. $post['cpbz'] = $this->input->post('cpbz', true);
  5379. $post['state'] = 9;
  5380. $category = $this->input->post('category', true);
  5381. $list['category'] = $category;
  5382. $list['hairtype'] = $this->input->post('hairtype', true);
  5383. $list['grade'] = $this->input->post('grade', true);
  5384. $size = $this->input->post('size', true);
  5385. $list['size'] = rtrim($size, ',');
  5386. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5387. $list['extension'] = $this->input->post('extension', true);
  5388. if ($category == 1297) {
  5389. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5390. }
  5391. if ($category == 1702) {
  5392. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5393. $list['syother'] = $this->input->post('syother', true);
  5394. }
  5395. if ($category == 133) {
  5396. $list['fittype'] = $this->input->post('fittype', true);
  5397. $list['acother'] = $this->input->post('acother', true);
  5398. }
  5399. $list['color'] = $this->input->post('color', true);
  5400. $list['lowe'] = $this->input->post('lowe', true);
  5401. if ($category == 127) {
  5402. $list['type'] = $this->input->post('type', true);
  5403. $list['headroad'] = $this->input->post('headroad', true);
  5404. $list['density'] = $this->input->post('density', true);
  5405. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5406. $list['lacesize'] = $this->input->post('lacesize', true);
  5407. }
  5408. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5409. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5410. }
  5411. if ($category == 128) {
  5412. $list['lacetype'] = $this->input->post('lacetype', true);
  5413. $list['haircap'] = $this->input->post('haircap', true);
  5414. $list['density'] = $this->input->post('density', true);
  5415. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5416. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5417. $list['wigother'] = $this->input->post('wigother', true);
  5418. $list['wigother1'] = $this->input->post('wigother1', true);
  5419. $list['wigother2'] = $this->input->post('wigother2', true);
  5420. }
  5421. if ($category == 129) {
  5422. $list['wide'] = $this->input->post('wide', true);
  5423. }
  5424. if ($category == 131) {
  5425. $list['gifttype'] = $this->input->post('gifttype', true);
  5426. $list['giftother'] = $this->input->post('giftother', true);
  5427. }
  5428. if ($category == 134) {
  5429. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5430. }
  5431. if ($category == 1297) {
  5432. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5433. $list['sywigother'] = $this->input->post('sywigother', true);
  5434. }
  5435. if ($category == 130 || $category == 133 || $category == 1702) {
  5436. $list['items'] = $this->input->post('items', true);
  5437. $list['weight'] = $this->input->post('weight', true);
  5438. }
  5439. if ($category == 1702) {
  5440. $list['syhairther'] = $this->input->post('syhairther', true);
  5441. }
  5442. foreach ($list as $k => $v) {
  5443. if ($v != 0) {
  5444. $num .= $v;
  5445. $features .= $v . '-';
  5446. $post[$k] = $v;
  5447. $typeclass = $this->typeclass->read($v);
  5448. if (isset($pm[$typeclass['classid']])) {
  5449. if (stripos($typeclass['zh'], '|') !== false) {
  5450. $exzh = explode('|', $typeclass['zh']);
  5451. $pm[$typeclass['classid']] = $exzh[0];
  5452. } else {
  5453. $pm[$typeclass['classid']] = $typeclass['zh'];
  5454. }
  5455. }
  5456. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5457. if ($k != 'size') {
  5458. $title .= $typeclass['title'] . " ";
  5459. }
  5460. }
  5461. }
  5462. $typeclass = $this->typeclass->read($list['size']);
  5463. $title .= $typeclass['title'];
  5464. $time = time();
  5465. $post['title'] = rtrim($title, ' ');
  5466. $post['number'] = $num;
  5467. $post['features'] = '-' . $features;
  5468. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5469. $featurespp = explode('-', trim($featurespp, '-'));
  5470. if (isset($featurespp[5])) {
  5471. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5472. } else {
  5473. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5474. }
  5475. $post['enter'] = $time;
  5476. $post['time'] = $time; //操作时间
  5477. $scsku = implode("-", $scsku);
  5478. $zh = implode(" ", $pm);
  5479. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5480. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5481. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5482. $post['sku'] = $bqsku;
  5483. $label = time() . rand(0, 9);
  5484. $post['label'] = $label;
  5485. $cpid = $this->whlabellabel->find_count();
  5486. $post['cpid'] = $cpid + 1;
  5487. $cpid = $post['cpid'];
  5488. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5489. //if($whlabelbarcode)
  5490. //{
  5491. //$post['label'] = $whlabelbarcode['label'];
  5492. //if(!$this->whlabellabel->insert($post))
  5493. //{
  5494. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5495. //}
  5496. //}
  5497. //else
  5498. //{
  5499. $this->db->trans_begin();
  5500. $this->whlabellabel->insert($post);
  5501. //$this->whlabelbarcode->insert($post);
  5502. if ($this->db->trans_status() === TRUE) {
  5503. $this->db->trans_commit();
  5504. } else {
  5505. $this->db->trans_rollback();
  5506. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5507. exit;
  5508. }
  5509. //}
  5510. $warehouse_name = "";
  5511. $warehouse = $post['warehouse'];
  5512. if($warehouse == 12){
  5513. $warehouse_name = "特殊库存库";
  5514. }
  5515. // if($warehouse == 13){
  5516. // $warehouse_name = "许昌仓";
  5517. // }
  5518. // if($warehouse == 5){
  5519. // $warehouse_name = "美国店";
  5520. // }
  5521. // if($warehouse == 16){
  5522. // $warehouse_name = "定制头套仓";
  5523. // }
  5524. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5525. if(!empty($warehouse_name)){
  5526. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5527. }
  5528. $purchase = $this->purchase->read($post['purchase']);
  5529. 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));
  5530. exit; //特殊仓目前不需要仓库选项
  5531. }
  5532. }
  5533. if (isset($_SESSION['api'])) {
  5534. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5535. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5536. $this->data['wlshop'] = $wlshop;
  5537. $this->data['warehouse'] = $warehouse;
  5538. }
  5539. $whlabelwz = $this->whlabelwz->find_all();
  5540. $this->data['whlabelwz'] = $whlabelwz;
  5541. $this->_Template('whlabel_print', $this->data);
  5542. }
  5543. public function _usaprint($arg_array)
  5544. {
  5545. if (isset($_SESSION['api'])) {
  5546. $user = $this->user->get_api($_SESSION['api']);
  5547. $usp = $user;
  5548. $fgshop = "";
  5549. $sid = "";
  5550. $wid = "";
  5551. $wtype = "";
  5552. $usersp = explode('|', trim($user['shop'], '|'));
  5553. $userwh = explode('|', trim($user['warehouse'], '|'));
  5554. foreach ($usersp as $value) {
  5555. $fgshop .= " shop = " . $value . " or";
  5556. $sid .= " id = " . $value . " or";
  5557. }
  5558. foreach ($userwh as $value) {
  5559. $wid .= " id = " . $value . " or";
  5560. $wtype .= " type = " . $value . " or";
  5561. }
  5562. }
  5563. $post = $this->input->post(NULL, TRUE);
  5564. if (isset($post['tmsku'])) {
  5565. $tmsku = $this->input->post('tmsku', true);
  5566. if (is_numeric($tmsku)) {
  5567. $yyh = $this->whlabellabel->get_label($tmsku);
  5568. } else {
  5569. $yyh = $this->whlabellabel->get_sku($tmsku);
  5570. }
  5571. if ($yyh) {
  5572. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5573. exit;
  5574. } else {
  5575. echo json_encode(array('success' => false));
  5576. exit;
  5577. }
  5578. }
  5579. $classid = $this->classid->sku();
  5580. $pm = $classid;
  5581. $scsku = $classid;
  5582. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5583. if (isset($post['warehouse'])) {
  5584. if ($post['warehouse']) {
  5585. $list = array();
  5586. $num = "";
  5587. $title = "";
  5588. $features = "";
  5589. $order = 0;
  5590. $post['shop'] = '';
  5591. $brand = $this->input->post('brand', true);
  5592. if ($brand != '0,') {
  5593. $b = $this->brand->read(rtrim($brand, ','));
  5594. if ($b) {
  5595. $post['shop'] = str_replace('|', ',', $b['shop']);
  5596. }
  5597. }
  5598. $post['details'] = $this->input->post('details', true); //打印数量
  5599. $xbqnum = $this->input->post('xbqnum', true);
  5600. $post['purchase'] = $this->input->post('purchase', true);
  5601. $post['warehouse'] = $this->input->post('warehouse', true);
  5602. $post['purchase'] = $this->input->post('purchase', true);
  5603. $post['retreatwarehouse'] = $post['warehouse'];
  5604. $post['cpbz'] = $this->input->post('cpbz', true);
  5605. $post['state'] = 9;
  5606. $category = $this->input->post('category', true);
  5607. $list['category'] = $category;
  5608. $list['hairtype'] = $this->input->post('hairtype', true);
  5609. $list['grade'] = $this->input->post('grade', true);
  5610. $size = $this->input->post('size', true);
  5611. $list['size'] = rtrim($size, ',');
  5612. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5613. $list['extension'] = $this->input->post('extension', true);
  5614. if ($category == 1297) {
  5615. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5616. }
  5617. if ($category == 1702) {
  5618. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5619. $list['syother'] = $this->input->post('syother', true);
  5620. }
  5621. if ($category == 133) {
  5622. $list['fittype'] = $this->input->post('fittype', true);
  5623. $list['acother'] = $this->input->post('acother', true);
  5624. }
  5625. $list['color'] = $this->input->post('color', true);
  5626. $list['lowe'] = $this->input->post('lowe', true);
  5627. if ($category == 127) {
  5628. $list['type'] = $this->input->post('type', true);
  5629. $list['headroad'] = $this->input->post('headroad', true);
  5630. $list['density'] = $this->input->post('density', true);
  5631. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5632. $list['lacesize'] = $this->input->post('lacesize', true);
  5633. }
  5634. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5635. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5636. }
  5637. if ($category == 128) {
  5638. $list['lacetype'] = $this->input->post('lacetype', true);
  5639. $list['haircap'] = $this->input->post('haircap', true);
  5640. $list['density'] = $this->input->post('density', true);
  5641. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5642. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5643. $list['wigother'] = $this->input->post('wigother', true);
  5644. $list['wigother1'] = $this->input->post('wigother1', true);
  5645. $list['wigother2'] = $this->input->post('wigother2', true);
  5646. }
  5647. if ($category == 129) {
  5648. $list['wide'] = $this->input->post('wide', true);
  5649. }
  5650. if ($category == 131) {
  5651. $list['gifttype'] = $this->input->post('gifttype', true);
  5652. $list['giftother'] = $this->input->post('giftother', true);
  5653. }
  5654. if ($category == 134) {
  5655. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5656. }
  5657. if ($category == 1297) {
  5658. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5659. $list['sywigother'] = $this->input->post('sywigother', true);
  5660. }
  5661. if ($category == 130 || $category == 133 || $category == 1702) {
  5662. $list['items'] = $this->input->post('items', true);
  5663. $list['weight'] = $this->input->post('weight', true);
  5664. }
  5665. if ($category == 1702) {
  5666. $list['syhairther'] = $this->input->post('syhairther', true);
  5667. }
  5668. foreach ($list as $k => $v) {
  5669. if ($v != 0) {
  5670. $num .= $v;
  5671. $features .= $v . '-';
  5672. $post[$k] = $v;
  5673. $typeclass = $this->typeclass->read($v);
  5674. if (isset($pm[$typeclass['classid']])) {
  5675. if (stripos($typeclass['zh'], '|') !== false) {
  5676. $exzh = explode('|', $typeclass['zh']);
  5677. $pm[$typeclass['classid']] = $exzh[0];
  5678. } else {
  5679. $pm[$typeclass['classid']] = $typeclass['zh'];
  5680. }
  5681. }
  5682. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5683. if ($k != 'size') {
  5684. $title .= $typeclass['title'] . " ";
  5685. }
  5686. }
  5687. }
  5688. $typeclass = $this->typeclass->read($list['size']);
  5689. $title .= $typeclass['title'];
  5690. $time = time();
  5691. $post['title'] = rtrim($title, ' ');
  5692. $post['number'] = $num;
  5693. $post['features'] = '-' . $features;
  5694. $fp = $this->whlabel->get_features($post['features']);
  5695. if (!$fp) {
  5696. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5697. exit;
  5698. }
  5699. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5700. $featurespp = explode('-', trim($featurespp, '-'));
  5701. if (isset($featurespp[5])) {
  5702. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5703. } else {
  5704. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5705. }
  5706. $post['enter'] = $time;
  5707. $post['time'] = $time; //操作时间
  5708. $scsku = implode("-", $scsku);
  5709. $zh = implode(" ", $pm);
  5710. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5711. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5712. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5713. $post['sku'] = $fp['sku'];
  5714. $post['label'] = $fp['sku'];
  5715. $cpid = $this->whlabellabel->find_count();
  5716. $post['cpid'] = $cpid + 1;
  5717. $cpid = $post['cpid'];
  5718. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5719. //if($whlabelbarcode)
  5720. //{
  5721. //$post['label'] = $whlabelbarcode['label'];
  5722. //if(!$this->whlabellabel->insert($post))
  5723. //{
  5724. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5725. //}
  5726. //}
  5727. //else
  5728. //{
  5729. $this->db->trans_begin();
  5730. $this->whlabellabel->insert($post);
  5731. //$this->whlabelbarcode->insert($post);
  5732. if ($this->db->trans_status() === TRUE) {
  5733. $this->db->trans_commit();
  5734. } else {
  5735. $this->db->trans_rollback();
  5736. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5737. exit;
  5738. }
  5739. //}
  5740. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5741. $purchase = $this->purchase->read($post['purchase']);
  5742. 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));
  5743. exit; //特殊仓目前不需要仓库选项
  5744. }
  5745. }
  5746. if (isset($_SESSION['api'])) {
  5747. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5748. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5749. $this->data['wlshop'] = $wlshop;
  5750. $this->data['warehouse'] = $warehouse;
  5751. }
  5752. $whlabelwz = $this->whlabelwz->find_all();
  5753. $this->data['whlabelwz'] = $whlabelwz;
  5754. $this->_Template('whlabel_usaprint', $this->data);
  5755. }
  5756. public function _printrk($arg_array)
  5757. {
  5758. $prc = array();
  5759. $purchase = $this->purchase->find_all();
  5760. foreach ($purchase as $k => $v) {
  5761. $prc[$v['id']] = $v['title'];
  5762. }
  5763. $post = $this->input->post(NULL, TRUE);
  5764. if (isset($post['page'])) {
  5765. $page = $this->input->post('page', true);
  5766. $perpage = $this->input->post('perpage', true);
  5767. $sku = $this->input->post('sku', true);
  5768. $bs = $this->input->post('bs', true);
  5769. $number = $this->input->post('number', true);
  5770. $warehouse = $this->input->post('warehouse', true);
  5771. $purchase = $this->input->post('purchase', true);
  5772. $orderinfo = $this->input->post('orderinfo', true);
  5773. $waybill = $this->input->post('waybill', true);
  5774. $category = $this->input->post('category', true);
  5775. $size = $this->input->post('size', true);
  5776. $grade = $this->input->post('grade', true);
  5777. $color = $this->input->post('color', true);
  5778. $lowe = $this->input->post('lowe', true);
  5779. $state = $this->input->post('state', true);
  5780. $label = $this->input->post('label', true);
  5781. $timetk = $this->input->post('ktime', true);
  5782. $timetj = $this->input->post('jtime', true);
  5783. $timetk = strtotime($timetk);
  5784. $timetj = strtotime($timetj);
  5785. $where = "1=1 ";
  5786. if ($timetk && $timetj) {
  5787. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5788. }
  5789. if ($sku) {
  5790. $where .= " and sku = '$sku'";
  5791. }
  5792. if ($bs != '') {
  5793. $where .= " and bs = '$bs'";
  5794. }
  5795. if ($number) {
  5796. $where .= " and number = '$number'";
  5797. }
  5798. if ($warehouse) {
  5799. $where .= " and warehouse = '$warehouse'";
  5800. }
  5801. if ($purchase) {
  5802. $where .= " and purchase = '$purchase'";
  5803. }
  5804. if ($orderinfo) {
  5805. $where .= " and orderinfo = '$orderinfo'";
  5806. }
  5807. if ($waybill) {
  5808. $where .= " and waybill = '$waybill'";
  5809. }
  5810. if ($category) {
  5811. $where .= " and features like '%-$category-%'";
  5812. }
  5813. if ($size) {
  5814. $where .= " and features like '%-$size-%'";
  5815. }
  5816. if ($grade) {
  5817. $where .= " and features like '%-$grade-%'";
  5818. }
  5819. if ($color) {
  5820. $where .= " and features like '%-$color-%'";
  5821. }
  5822. if ($lowe) {
  5823. $where .= " and features like '%-$lowe-%'";
  5824. }
  5825. if ($label) {
  5826. $where .= " and label = '$label'";
  5827. }
  5828. if ($state || $state == 0) {
  5829. $where .= " and state = '$state'";
  5830. }
  5831. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5832. //数据排序
  5833. $order_str = "enter desc";
  5834. if (empty($page)) {
  5835. $start = 0;
  5836. $perpage = 1;
  5837. } else {
  5838. $start = ($page - 1) * $perpage;
  5839. }
  5840. //取得信息列表
  5841. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5842. foreach ($info_list as $key => $value) {
  5843. $warehouse = $this->warehouse->read($value['warehouse']);
  5844. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5845. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5846. if ($value['state'] == 0) {
  5847. $info_list[$key]['state'] = "在库";
  5848. } else if ($value['state'] == 1) {
  5849. $info_list[$key]['state'] = "出库";
  5850. } else if ($value['state'] == 2) {
  5851. $info_list[$key]['state'] = "退库";
  5852. } else if ($value['state'] == 3) {
  5853. $info_list[$key]['state'] = "调拨中";
  5854. } else if ($value['state'] == 4) {
  5855. $info_list[$key]['state'] = "再加工";
  5856. } else if ($value['state'] == 5) {
  5857. $info_list[$key]['state'] = "维修中";
  5858. } else if ($value['state'] == 6) {
  5859. $info_list[$key]['state'] = "盘亏";
  5860. } else if ($value['state'] == 7) {
  5861. $info_list[$key]['state'] = "更换标签";
  5862. } else if ($value['state'] == 8) {
  5863. $info_list[$key]['state'] = "其它";
  5864. } else if ($value['state'] == 9) {
  5865. $info_list[$key]['state'] = "预设";
  5866. } else if ($value['state'] == 10) {
  5867. $info_list[$key]['state'] = "美店零售";
  5868. }
  5869. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5870. }
  5871. $total = $this->$ck->find_count($where);
  5872. $pagenum = ceil($total / $perpage);
  5873. $over = $total - ($start + $perpage);
  5874. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5875. echo json_encode($rows);
  5876. exit;
  5877. }
  5878. if (isset($post['tmsku'])) {
  5879. $time = time();
  5880. $tmsku = $this->input->post('tmsku', true);
  5881. //$post['shop'] = $this->input->post('shop',true);
  5882. $num = $this->input->post('num', true);
  5883. $rktype = $this->input->post('rktype', true);
  5884. if ($num > 200) {
  5885. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5886. exit;
  5887. }
  5888. if (!$rktype) {
  5889. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5890. }
  5891. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5892. /**
  5893. $wz = array();
  5894. foreach ($rk as $key=>$value)
  5895. {
  5896. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5897. }
  5898. if(count($wz) > 1)
  5899. {
  5900. $wz = array_values($wz);
  5901. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5902. }
  5903. **/
  5904. if (isset($rk[0]['purchase'])) {
  5905. $rk = $rk[0];
  5906. $j = 0;
  5907. $post['purchase'] = $rk['purchase'];
  5908. $post['warehouse'] = $rk['warehouse'];
  5909. $post['retreatwarehouse'] = $rk['warehouse'];
  5910. $post['sku'] = $rk['sku'];
  5911. $post['number'] = $rk['number'];
  5912. $post['features'] = $rk['features'];
  5913. $post['title'] = $rk['title'];
  5914. $post['enter'] = $time;
  5915. $post['time'] = $time;
  5916. $post['bs'] = 1;
  5917. $post['shop'] = $rk['shop'];
  5918. $post['details'] = $rk['details'];
  5919. $post['cpid'] = $rk['cpid'];
  5920. $post['cpbz'] = $rk['cpbz'];
  5921. //$post['rktype'] = $rktype;
  5922. $warehouse = $this->warehouse->read($rk['warehouse']);
  5923. if ($warehouse['bdck'] == '') {
  5924. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5925. exit;
  5926. } else {
  5927. $bdck = $warehouse['bdck'];
  5928. }
  5929. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5930. if (isset($pdwz['details'])) {
  5931. if ($pdwz['details'] != $post['details']) {
  5932. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5933. exit;
  5934. }
  5935. }
  5936. $post['featurespp'] = $rk['featurespp'];
  5937. if ($post['warehouse'] == '5') {
  5938. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5939. if ($yza) {
  5940. if ($post['features'] != $yza[0]['features']) {
  5941. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5942. exit;
  5943. }
  5944. }
  5945. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5946. if ($yzb) {
  5947. if ($post['sku'] != $yzb[0]['sku']) {
  5948. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5949. exit;
  5950. }
  5951. }
  5952. }
  5953. for ($i = 0; $i < $num; $i++) {
  5954. $post['label'] = time() . rand(100, 999) . $i;
  5955. if ($this->$bdck->insert($post)) {
  5956. $j++;
  5957. }
  5958. }
  5959. /**
  5960. if($post['warehouse'] != 12)
  5961. {
  5962. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5963. }
  5964. **/
  5965. if ($j == $num) {
  5966. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5967. exit;
  5968. } else {
  5969. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5970. exit;
  5971. }
  5972. } else {
  5973. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5974. exit;
  5975. }
  5976. }
  5977. $this->_Template('whlabel_printrk', $this->data);
  5978. }
  5979. public function _printxzrk($arg_array)
  5980. {
  5981. $post = $this->input->post(NULL, TRUE);
  5982. if (isset($post['wzid'])) {
  5983. $time = time();
  5984. $id = $this->input->post('wzid', true);
  5985. //$post['shop'] = $this->input->post('shop',true);
  5986. $num = 1;
  5987. $rk = $this->whlabellabel->read($id);
  5988. if (isset($rk['purchase'])) {
  5989. $x = 0;
  5990. $post['purchase'] = $rk['purchase'];
  5991. $post['warehouse'] = $rk['warehouse'];
  5992. $post['retreatwarehouse'] = $rk['warehouse'];
  5993. $post['sku'] = $rk['sku'];
  5994. $post['number'] = $rk['number'];
  5995. $post['features'] = $rk['features'];
  5996. $post['title'] = $rk['title'];
  5997. $post['enter'] = $time;
  5998. $post['time'] = $time;
  5999. $post['bs'] = 1;
  6000. $post['shop'] = $rk['shop'];
  6001. $post['details'] = $rk['details'];
  6002. $post['cpid'] = $rk['cpid'];
  6003. $post['cpbz'] = $rk['cpbz'];
  6004. $warehouse = $this->warehouse->read($rk['warehouse']);
  6005. if ($warehouse['bdck'] == '') {
  6006. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6007. exit;
  6008. } else {
  6009. $bdck = $warehouse['bdck'];
  6010. }
  6011. $post['featurespp'] = $rk['featurespp'];
  6012. $this->db->trans_begin();
  6013. for ($i = 0; $i < $num; $i++) {
  6014. $post['label'] = time() . rand(100, 999) . $i;
  6015. $this->$bdck->insert($post);
  6016. }
  6017. /**
  6018. if($post['warehouse'] != 12)
  6019. {
  6020. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6021. }
  6022. **/
  6023. if ($this->db->trans_status() === TRUE) {
  6024. $this->db->trans_commit();
  6025. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6026. exit;
  6027. } else {
  6028. $this->db->trans_rollback();
  6029. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6030. exit;
  6031. }
  6032. } else {
  6033. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6034. exit;
  6035. }
  6036. }
  6037. }
  6038. public function _printck($arg_array)
  6039. {
  6040. $prc = array();
  6041. $purchase = $this->purchase->find_all();
  6042. foreach ($purchase as $k => $v) {
  6043. $prc[$v['id']] = $v['title'];
  6044. }
  6045. $post = $this->input->post(NULL, TRUE);
  6046. if (isset($post['page'])) {
  6047. $page = $this->input->post('page', true);
  6048. $perpage = $this->input->post('perpage', true);
  6049. $sku = $this->input->post('sku', true);
  6050. $bs = $this->input->post('bs', true);
  6051. $number = $this->input->post('number', true);
  6052. $warehouse = $this->input->post('warehouse', true);
  6053. $purchase = $this->input->post('purchase', true);
  6054. $orderinfo = $this->input->post('orderinfo', true);
  6055. $waybill = $this->input->post('waybill', true);
  6056. $category = $this->input->post('category', true);
  6057. $size = $this->input->post('size', true);
  6058. $grade = $this->input->post('grade', true);
  6059. $color = $this->input->post('color', true);
  6060. $lowe = $this->input->post('lowe', true);
  6061. $state = $this->input->post('state', true);
  6062. $label = $this->input->post('label', true);
  6063. $timetk = $this->input->post('ktime', true);
  6064. $timetj = $this->input->post('jtime', true);
  6065. $timetk = strtotime($timetk);
  6066. $timetj = strtotime($timetj);
  6067. $where = "state=1 ";
  6068. if ($timetk && $timetj) {
  6069. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6070. }
  6071. if ($sku) {
  6072. $where .= " and sku = '$sku'";
  6073. }
  6074. if ($bs != '') {
  6075. $where .= " and bs = '$bs'";
  6076. }
  6077. if ($number) {
  6078. $where .= " and number = '$number'";
  6079. }
  6080. if ($warehouse) {
  6081. $where .= " and warehouse = '$warehouse'";
  6082. }
  6083. if ($purchase) {
  6084. $where .= " and purchase = '$purchase'";
  6085. }
  6086. if ($orderinfo) {
  6087. $where .= " and orderinfo = '$orderinfo'";
  6088. }
  6089. if ($waybill) {
  6090. $where .= " and waybill = '$waybill'";
  6091. }
  6092. if ($category) {
  6093. $where .= " and features like '%-$category-%'";
  6094. }
  6095. if ($size) {
  6096. $where .= " and features like '%-$size-%'";
  6097. }
  6098. if ($grade) {
  6099. $where .= " and features like '%-$grade-%'";
  6100. }
  6101. if ($color) {
  6102. $where .= " and features like '%-$color-%'";
  6103. }
  6104. if ($lowe) {
  6105. $where .= " and features like '%-$lowe-%'";
  6106. }
  6107. if ($label) {
  6108. $where .= " and label = '$label'";
  6109. }
  6110. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6111. //数据排序
  6112. $order_str = "outk desc";
  6113. if (empty($page)) {
  6114. $start = 0;
  6115. $perpage = 1;
  6116. } else {
  6117. $start = ($page - 1) * $perpage;
  6118. }
  6119. //取得信息列表
  6120. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6121. foreach ($info_list as $key => $value) {
  6122. $warehouse = $this->warehouse->read($value['warehouse']);
  6123. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6124. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6125. if ($value['state'] == 0) {
  6126. $info_list[$key]['state'] = "在库";
  6127. } else if ($value['state'] == 1) {
  6128. $info_list[$key]['state'] = "出库";
  6129. } else if ($value['state'] == 2) {
  6130. $info_list[$key]['state'] = "退库";
  6131. } else if ($value['state'] == 3) {
  6132. $info_list[$key]['state'] = "调拨中";
  6133. } else if ($value['state'] == 4) {
  6134. $info_list[$key]['state'] = "再加工";
  6135. } else if ($value['state'] == 5) {
  6136. $info_list[$key]['state'] = "维修中";
  6137. } else if ($value['state'] == 6) {
  6138. $info_list[$key]['state'] = "盘亏";
  6139. } else if ($value['state'] == 7) {
  6140. $info_list[$key]['state'] = "更换标签";
  6141. } else if ($value['state'] == 8) {
  6142. $info_list[$key]['state'] = "其它";
  6143. } else if ($value['state'] == 9) {
  6144. $info_list[$key]['state'] = "预设";
  6145. } else if ($value['state'] == 10) {
  6146. $info_list[$key]['state'] = "美店零售";
  6147. }
  6148. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6149. }
  6150. $total = $this->$ck->find_count($where);
  6151. $pagenum = ceil($total / $perpage);
  6152. $over = $total - ($start + $perpage);
  6153. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6154. echo json_encode($rows);
  6155. exit;
  6156. }
  6157. if (isset($post['tmsku'])) {
  6158. $time = time();
  6159. $tmsku = $this->input->post('tmsku', true);
  6160. //$post['shop'] = $this->input->post('shop',true);
  6161. $num = $this->input->post('num', true);
  6162. $cktype = $this->input->post('cktype', true);
  6163. $label = $this->whlabellabel->get_label($tmsku);
  6164. if (!$cktype) {
  6165. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6166. }
  6167. if (!isset($label['warehouse'])) {
  6168. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6169. exit;
  6170. }
  6171. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6172. if (stripos($label['features'], '-126-') !== false) {
  6173. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6174. } else {
  6175. $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 = ''");
  6176. }
  6177. $j = 0;
  6178. if (count($ck) >= $num) {
  6179. for ($i = 0; $i < $num; $i++) {
  6180. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6181. {
  6182. $j++;
  6183. }
  6184. }
  6185. if ($j == $num) {
  6186. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6187. exit;
  6188. } else {
  6189. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6190. exit;
  6191. }
  6192. } else {
  6193. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6194. exit;
  6195. }
  6196. }
  6197. if(isset($_SESSION['api']))
  6198. {
  6199. $user = $this->user->get_api($_SESSION['api']);
  6200. if(in_array($user['power'],[1,27])){
  6201. $vip = 1;
  6202. }
  6203. }
  6204. else
  6205. {
  6206. $vip = 0;
  6207. header('Location: /');exit;
  6208. }
  6209. $this->data['vip'] = $vip;
  6210. $this->_Template('whlabel_printck', $this->data);
  6211. }
  6212. public function _printexcel()
  6213. {
  6214. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6215. $config['upload_path'] = '.' . $dir;
  6216. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6217. $config['allowed_types'] = 'xls|xlsx|csv';
  6218. $config['max_size'] = 10240;
  6219. $this->load->library('upload', $config);
  6220. $this->upload->initialize($config);
  6221. if ($this->upload->do_upload('userfile')) {
  6222. $full_path = $dir . $this->upload->data('file_name');
  6223. $fileName = '.' . $full_path;
  6224. if (!file_exists($fileName)) {
  6225. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6226. exit;
  6227. } else {
  6228. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6229. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6230. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6231. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6232. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6233. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6234. ++$column; //如果列数大于26行
  6235. $list = array();
  6236. for ($i = 2; $i <= $row; $i++) // 行数循环
  6237. {
  6238. $data = array();
  6239. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6240. {
  6241. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6242. }
  6243. $list[] = $data;
  6244. }
  6245. }
  6246. $ed = array();
  6247. $i = 0;
  6248. $j = 0;
  6249. $dcdata = array();
  6250. $yc = '';
  6251. $cmf_arr = array_column($list, '1');
  6252. array_multisort($cmf_arr, SORT_ASC, $list);
  6253. foreach ($list as $key => $value) {
  6254. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6255. if ($typeclass) {
  6256. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6257. } else {
  6258. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6259. $i++;
  6260. continue;
  6261. }
  6262. }
  6263. if ($i > 0) {
  6264. $yc = $i . '条异常';
  6265. }
  6266. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6267. exit;
  6268. }
  6269. }
  6270. public function _uck()
  6271. {
  6272. if (isset($_GET['excel'])) {
  6273. $tc = array();
  6274. $typeclass = $this->typeclass->find_all();
  6275. foreach ($typeclass as $v) {
  6276. $tc[$v['id']] = $v['zh'];
  6277. }
  6278. $data = array();
  6279. $t = array();
  6280. $rq = '';
  6281. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6282. $ts = $ts / (24 * 3600);
  6283. for ($i = 0; $i < $ts; $i++) {
  6284. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6285. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6286. }
  6287. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6288. foreach ($info_list as $k => $v) {
  6289. $features = explode('-', trim($v['features'], '-'));
  6290. if (!isset($features[3]) || !isset($features[4])) {
  6291. continue;
  6292. }
  6293. $data[$k][0] = $tc[$features[0]]; //类型
  6294. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6295. $data[$k][2] = $tc[$features[4]]; //曲度
  6296. $data[$k][3] = '';
  6297. if (isset($data[$k][1])) {
  6298. $data[$k][3] .= $data[$k][1];
  6299. }
  6300. if (isset($data[$k][2])) {
  6301. $data[$k][3] .= $data[$k][2];
  6302. }
  6303. if (isset($features[5])) {
  6304. $data[$k][3] .= $tc[$features[5]];
  6305. }
  6306. if (isset($features[2])) {
  6307. $data[$k][3] .= $tc[$features[2]];
  6308. }
  6309. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6310. $data[$k][4] = $v['sku'];
  6311. $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())) . '))'); //月初库存
  6312. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6313. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6314. $ztrq = '';
  6315. $ztsl = '';
  6316. if (count($zt) > 0) {
  6317. foreach ($zt as $vv) {
  6318. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6319. $ztsl .= $vv['num'] . '<br>';
  6320. }
  6321. }
  6322. $data[$k][] = trim($ztsl, '<br>');
  6323. $data[$k][] = trim($ztrq, '<br>');
  6324. $byck = 0;
  6325. foreach ($t as $vv) {
  6326. $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));
  6327. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6328. $byck += $sl;
  6329. }
  6330. $data[$k][] = ($byck > 0) ? $byck : '';
  6331. }
  6332. $title = "详情 " . date("Y-m-d", time());
  6333. $titlename = "<table border=1>
  6334. <tr align='center'>
  6335. <td>类别</td>
  6336. <td>颜色</td>
  6337. <td>曲度</td>
  6338. <td>名称</td>
  6339. <td>SKU</td>
  6340. <td>月初库存</td>
  6341. <td>剩余库存</td>
  6342. <td>在途数量</td>
  6343. <td>预达日期</td>" .
  6344. $rq
  6345. . "<td>本月出库</td></tr>
  6346. </table>";
  6347. $filename = $title . ".xls";
  6348. $tail = "";
  6349. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6350. }
  6351. }
  6352. public function _whlabelexcelzh()
  6353. {
  6354. if (isset($_GET['excel'])) {
  6355. $where = "sku != 'Preset'";
  6356. //数据排序
  6357. $order_str = "id desc";
  6358. if (empty($page)) {
  6359. $start = 0;
  6360. $perpage = 1;
  6361. } else {
  6362. $start = ($page - 1) * $perpage;
  6363. }
  6364. $category = $this->input->get('category', true);
  6365. $warehouse = $this->input->get('warehouse', true);
  6366. $excelid = $this->input->get('sid', true);
  6367. if ($category) {
  6368. $where .= " and features like '%-$category-%'";
  6369. }
  6370. if ($warehouse) {
  6371. $where .= " and warehouse = '$warehouse'";
  6372. }
  6373. $xzid = '';
  6374. if ($excelid) {
  6375. $excelid = explode(',', trim($excelid, ','));
  6376. foreach ($excelid as $key => $value) {
  6377. $xzid .= " id = " . $value . " or";
  6378. }
  6379. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6380. }
  6381. //取得信息列表
  6382. /**
  6383. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6384. $rows = array();$list = array();
  6385. foreach ($info_list as $key=>$value)
  6386. {
  6387. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6388. }
  6389. **/
  6390. $list = array();
  6391. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6392. foreach ($rows as $key => $value) {
  6393. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6394. $zh = '';
  6395. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6396. foreach ($zt as $v) {
  6397. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6398. }
  6399. $zt = array_sum(array_column($zt, 'num'));
  6400. $number = $value['number'];
  6401. $ftime = time() - 15 * 24 * 3600;
  6402. $warehouse = $this->warehouse->read($value['warehouse']);
  6403. $rows[$key]['warehouse'] = $warehouse['title'];
  6404. $rows[$key]['number'] = $c;
  6405. $rows[$key]['features'] = $zh;
  6406. $rows[$key]['hb'] = $c + $zt;
  6407. }
  6408. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6409. $titlename = "<table border=1>
  6410. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6411. <tr align='center'>
  6412. <td>仓库</td>
  6413. <td>SKU</td>
  6414. <td>产品</td>
  6415. <td>库存数量</td>
  6416. <td>在途数量及预达日期</td>
  6417. <td>在途+库存数量</td>
  6418. </tr>
  6419. </table>";
  6420. $filename = $title . ".xls";
  6421. $tail = "";
  6422. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6423. }
  6424. if (isset($_GET['excel'])) {
  6425. $warehouse = $this->input->get('warehouse', true);
  6426. $sku = $this->input->get('sku', true);
  6427. $cz = $this->input->get('cz', true);
  6428. $text = $this->input->post('text', true);
  6429. $xztime = $this->input->get('xztime', true);
  6430. $timetk = $this->input->get('timetk', true);
  6431. $timetj = $this->input->get('timetj', true);
  6432. $timetk = strtotime($timetk);
  6433. $timetj = strtotime($timetj);
  6434. $where = "time = '0' ";
  6435. if ($warehouse) {
  6436. $where .= " and warehouse = '$warehouse'";
  6437. }
  6438. if ($sku) {
  6439. $where .= " and sku = '$sku'";
  6440. }
  6441. if ($text) {
  6442. $where .= " and text like '%$text%'";
  6443. }
  6444. if ($cz != '') {
  6445. $where .= " and cz = '$cz'";
  6446. }
  6447. if ($timetk && $timetj) {
  6448. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6449. }
  6450. //数据排序
  6451. $order_str = $xztime . " desc";
  6452. //取得信息列表
  6453. $zh = array();
  6454. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6455. foreach ($info_list as $v) {
  6456. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6457. $warehouse = $this->warehouse->read($v['warehouse']);
  6458. $v['warehouse'] = $warehouse['title'];
  6459. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6460. $v['stime'] = date('Y-m-d', $v['stime']);
  6461. if (isset($zh[$v['features']])) {
  6462. $zh[$v['features']]['num'] += $v['num'];
  6463. } else {
  6464. $zh[$v['features']] = $v;
  6465. }
  6466. $zh[$v['features']]['features'] = $c;
  6467. }
  6468. $title = "在途数据" . date('Y-m-d', time());
  6469. $titlename = "<table border=1>
  6470. <tr align='center'>
  6471. <td>仓库</td>
  6472. <td>SKU</td>
  6473. <td>名称</td>
  6474. <td>在途数量</td>
  6475. <td>库存数量</td>
  6476. <td>添加在途日期</td>
  6477. <td>预达日期</td>
  6478. <td>备注</td>
  6479. </tr>
  6480. </table>";
  6481. $filename = $title . ".xls";
  6482. $tail = "";
  6483. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6484. }
  6485. }
  6486. public function _fc()
  6487. {
  6488. $vip = 0;
  6489. if (isset($_SESSION['api'])) {
  6490. $user = $this->user->get_api($_SESSION['api']);
  6491. if ($user['vip'] == 1) {
  6492. $vip = 1;
  6493. }
  6494. } else {
  6495. header('Location: /');
  6496. exit;
  6497. }
  6498. $post = $this->input->post(NULL, TRUE);
  6499. if (isset($post['page'])) {
  6500. $page = $this->input->post('page', true);
  6501. $perpage = $this->input->post('perpage', true);
  6502. $category = $this->input->post('category', true);
  6503. $size = $this->input->post('size', true);
  6504. $grade = $this->input->post('grade', true);
  6505. $color = $this->input->post('color', true);
  6506. $lowe = $this->input->post('lowe', true);
  6507. $sku = $this->input->post('sku');
  6508. $title = $this->input->post('title');
  6509. $warehouse = $this->input->post('warehouse', true);
  6510. $usa = $this->input->post('usa', true);
  6511. $purchase = $this->input->post('purchase', true);
  6512. $lacetype = $this->input->post('lacetype', true);
  6513. $haircap = $this->input->post('haircap', true);
  6514. $density = $this->input->post('density', true);
  6515. $details = $this->input->post('details', true);
  6516. $state = $this->input->post('state', true);
  6517. $ktime = $this->input->post('ktime', true);
  6518. $jtime = $this->input->post('jtime', true);
  6519. $ktime = strtotime($ktime);
  6520. $jtime = strtotime($jtime);
  6521. $where = "state = '11'";
  6522. $gj = "";
  6523. $ck = "";
  6524. if ($lacetype) {
  6525. $where .= " and features like '%-$lacetype-%'";
  6526. }
  6527. if ($category) {
  6528. $where .= " and features like '%-$category-%'";
  6529. }
  6530. if ($size) {
  6531. $where .= " and features like '%-$size-%'";
  6532. }
  6533. if ($grade) {
  6534. $where .= " and features like '%-$grade-%'";
  6535. }
  6536. if ($color) {
  6537. $where .= " and features like '%-$color-%'";
  6538. }
  6539. if ($lowe) {
  6540. $where .= " and features like '%-$lowe-%'";
  6541. }
  6542. if ($haircap) {
  6543. $where .= " and features like '%-$haircap-%'";
  6544. }
  6545. if ($density) {
  6546. $where .= " and features like '%-$density-%'";
  6547. }
  6548. if ($usa) {
  6549. if (!$warehouse) {
  6550. $where .= " and (warehouse = '5' or warehouse = '8')";
  6551. }
  6552. }
  6553. if ($warehouse) {
  6554. $where .= " and warehouse = '$warehouse'";
  6555. }
  6556. if ($details) {
  6557. $where .= " and details = '$details'";
  6558. }
  6559. if ($purchase) {
  6560. $where .= " and purchase = '$purchase'";
  6561. }
  6562. if ($state) {
  6563. $where .= " and state = '$state'";
  6564. }
  6565. if ($ktime && $jtime) {
  6566. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6567. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6568. }
  6569. //数据排序
  6570. $order_str = "id desc";
  6571. if (empty($page)) {
  6572. $start = 0;
  6573. $perpage = 1;
  6574. } else {
  6575. $start = ($page - 1) * $perpage;
  6576. }
  6577. if ($sku) {
  6578. $sku = trim($sku, ' ');
  6579. $sku = trim($sku, ' ');
  6580. $where .= " and sku like '%$sku%'";
  6581. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6582. } else if ($title) {
  6583. $title = trim($title, ' ');
  6584. $title = trim($title, ' ');
  6585. $where .= " and title like '%$title%'";
  6586. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6587. } else {
  6588. //$where .= " and time > '$ktime' and time < '$jtime'";
  6589. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6590. }
  6591. //取得信息列表
  6592. $rows = array();
  6593. $list = array();
  6594. foreach ($info_list as $key => $value) {
  6595. $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'] . '"');
  6596. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6597. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6598. $warehouse = $this->warehouse->read($value['warehouse']);
  6599. $info_list[$key]['warehouse'] = $warehouse['title'];
  6600. $info_list[$key]['number'] = $g;
  6601. $info_list[$key]['features'] = $x;
  6602. $info_list[$key]['x'] = $s;
  6603. }
  6604. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6605. $pagenum = ceil($total / $perpage);
  6606. $over = $total - ($start + $perpage);
  6607. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6608. echo json_encode($rows);
  6609. exit;
  6610. }
  6611. $this->data['vip'] = $vip;
  6612. $this->_Template('whlabel_fc', $this->data);
  6613. }
  6614. public function _fcmb()
  6615. {
  6616. $where = "sku != 'Preset'";
  6617. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6618. foreach ($rows as $k => $v) {
  6619. $warehouse = $this->warehouse->read($v['warehouse']);
  6620. $rows[$k]['warehouse'] = $warehouse['title'];
  6621. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6622. $rows[$k]['t'] = '';
  6623. $rows[$k]['n'] = '';
  6624. }
  6625. $title = "封货产品数据导入模板";
  6626. $titlename = "<table border=1>
  6627. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6628. <tr align='center'>
  6629. <td>仓库</td>
  6630. <td>SKU</td>
  6631. <td>产品</td>
  6632. <td>封存产品总数量</td>
  6633. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6634. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6635. </tr>
  6636. </table>";
  6637. $filename = $title . ".xls";
  6638. $tail = "";
  6639. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6640. }
  6641. public function _fcexcel()
  6642. {
  6643. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6644. $config['upload_path'] = '.' . $dir;
  6645. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6646. $config['allowed_types'] = 'xls|xlsx|csv';
  6647. $config['max_size'] = 10240;
  6648. $this->load->library('upload', $config);
  6649. $this->upload->initialize($config);
  6650. if ($this->upload->do_upload('userfile')) {
  6651. $full_path = $dir . $this->upload->data('file_name');
  6652. $fileName = '.' . $full_path;
  6653. if (!file_exists($fileName)) {
  6654. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6655. exit;
  6656. } else {
  6657. libxml_use_internal_errors(true);
  6658. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6659. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6660. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6661. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6662. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6663. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6664. ++$column; //如果列数大于26行
  6665. $list = array();
  6666. for ($i = 2; $i <= $row; $i++) // 行数循环
  6667. {
  6668. $data = array();
  6669. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6670. {
  6671. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6672. }
  6673. $list[] = $data;
  6674. }
  6675. }
  6676. $i = 0;
  6677. $j = 0;
  6678. $ed = array();
  6679. foreach ($list as $key => $value) {
  6680. $time = time();
  6681. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6682. continue;
  6683. }
  6684. $warehouse = $this->warehouse->get_title($value['0']);
  6685. $sku = $value['1'];
  6686. $type = $value['4']; //调整方式0扣减1删除
  6687. $num = $value['5']; //调整数量
  6688. //$text = $value['4'];//扣减说明
  6689. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6690. if (!$d) //如果没有这个SKU
  6691. {
  6692. $ed[] = array($sku . '-库存中不存在此SKU');
  6693. $j++;
  6694. continue;
  6695. }
  6696. if (!isset($warehouse['id'])) {
  6697. $ed[] = array($sku . '-仓库名错误!');
  6698. $j++;
  6699. continue;
  6700. }
  6701. if ($type == 1 || $type == 2) //扣减库存
  6702. {
  6703. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6704. if (count($data) < abs($num)) {
  6705. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6706. $j++;
  6707. continue;
  6708. }
  6709. if ($type == 1) //转入库存
  6710. {
  6711. for ($i = 0; $i < abs($num); $i++) {
  6712. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6713. }
  6714. } else if ($type == 2) //删除
  6715. {
  6716. for ($i = 0; $i < abs($num); $i++) {
  6717. $this->whlabel->remove($data[$i]['id']);
  6718. }
  6719. }
  6720. } else if ($type == 0) //增加库存
  6721. {
  6722. $post['sku'] = $d['sku'];
  6723. $post['shop'] = '';
  6724. $post['warehouse'] = $warehouse['id'];
  6725. $post['purchase'] = $d['purchase'];
  6726. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6727. $post['state'] = 11;
  6728. $post['title'] = $d['title'];
  6729. $post['number'] = $d['number'];
  6730. $post['features'] = $d['features'];
  6731. $post['enter'] = $time;
  6732. $post['time'] = $time; //操作时间
  6733. for ($i = 0; $i < $num; $i++) {
  6734. $post['label'] = time() . rand(100, 999) . $i;
  6735. $this->whlabel->insert($post);
  6736. }
  6737. }
  6738. sleep(1); //防止入库时间一样,需要延迟1秒
  6739. }
  6740. if ($j > 0) {
  6741. $tt = date('Ymd', time());
  6742. $title = '库存导入错误信息-' . $tt;
  6743. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6744. $tail = "\n";
  6745. $filename = $title . ".xls";
  6746. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6747. $dir = '/data/excel/' . $time . '/';
  6748. $file_name = 'error_' . $time . rand(1000, 9999);
  6749. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6750. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6751. fwrite($myfile, $ecl);
  6752. fclose($myfile);
  6753. $error = $dir . $file_name . '.xls';
  6754. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6755. exit;
  6756. } else {
  6757. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6758. exit;
  6759. }
  6760. }
  6761. }
  6762. public function _fcjxc($arg_array)
  6763. {
  6764. if (isset($_GET['excel'])) {
  6765. $category = $this->input->get('category', true);
  6766. $size = $this->input->get('size', true);
  6767. $grade = $this->input->get('grade', true);
  6768. $color = $this->input->get('color', true);
  6769. $lowe = $this->input->get('lowe', true);
  6770. $sku = $this->input->get('sku');
  6771. $title = $this->input->get('title');
  6772. $warehouse = $arg_array[0];
  6773. $usa = $this->input->get('usa', true);
  6774. $purchase = $this->input->get('purchase', true);
  6775. $lacetype = $this->input->get('lacetype', true);
  6776. $haircap = $this->input->get('haircap', true);
  6777. $density = $this->input->get('density', true);
  6778. $title = $this->input->get('title', true);
  6779. $state = $this->input->get('state', true);
  6780. $ktime = $this->input->get('ktime', true);
  6781. $jtime = $this->input->get('jtime', true);
  6782. $where = "state=11";
  6783. $gj = "";
  6784. $ck = "";
  6785. if ($lacetype) {
  6786. $where .= " and features like '%-$lacetype-%'";
  6787. }
  6788. if ($category) {
  6789. $where .= " and features like '%-$category-%'";
  6790. }
  6791. if ($size) {
  6792. $where .= " and features like '%-$size-%'";
  6793. }
  6794. if ($grade) {
  6795. $where .= " and features like '%-$grade-%'";
  6796. }
  6797. if ($color) {
  6798. $where .= " and features like '%-$color-%'";
  6799. }
  6800. if ($lowe) {
  6801. $where .= " and features like '%-$lowe-%'";
  6802. }
  6803. if ($haircap) {
  6804. $where .= " and features like '%-$haircap-%'";
  6805. }
  6806. if ($density) {
  6807. $where .= " and features like '%-$density-%'";
  6808. }
  6809. if ($usa) {
  6810. if (!$warehouse) {
  6811. $where .= " and (warehouse = '5' or warehouse = '8')";
  6812. }
  6813. }
  6814. if ($warehouse) {
  6815. $where .= " and warehouse = '$warehouse'";
  6816. }
  6817. if ($purchase) {
  6818. $where .= " and purchase = '$purchase'";
  6819. }
  6820. if ($state) {
  6821. $where .= " and state = '$state'";
  6822. }
  6823. $order_str = "id desc";
  6824. if ($sku) {
  6825. $sku = trim($sku, ' ');
  6826. $sku = trim($sku, ' ');
  6827. $where .= " and sku like '%$sku%'";
  6828. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6829. } else if ($title) {
  6830. $title = trim($title, ' ');
  6831. $title = trim($title, ' ');
  6832. $where .= " and title like '%$title%'";
  6833. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6834. } else {
  6835. //$where .= " and time > '$ktime' and time < '$jtime'";
  6836. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6837. }
  6838. //取得信息列表
  6839. $rows = array();
  6840. $list = array();
  6841. foreach ($info_list as $key => $value) {
  6842. $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'] . '"');
  6843. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6844. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6845. $rows[$key] = $value;
  6846. $warehouse = $this->warehouse->read($value['warehouse']);
  6847. $rows[$key]['warehouse'] = $warehouse['title'];
  6848. $rows[$key]['features'] = $g;
  6849. $rows[$key]['a'] = $x;
  6850. $rows[$key]['b'] = $s;
  6851. }
  6852. $title = "总统计表";
  6853. $titlename = "<table border=1>
  6854. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6855. <tr align='center'>
  6856. <td>仓库</td>
  6857. <td>SKU</td>
  6858. <td>产品名称</td>
  6859. <td>录入总量</td>
  6860. <td>取出总量</td>
  6861. <td>剩余总量</td>
  6862. </tr>
  6863. </table>";
  6864. $filename = $title . ".xls";
  6865. $tail = "";
  6866. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6867. }
  6868. $vip = 0;
  6869. if (isset($_SESSION['api'])) {
  6870. $user = $this->user->get_api($_SESSION['api']);
  6871. if ($user['vip'] == 1) {
  6872. $vip = 1;
  6873. }
  6874. } else {
  6875. header('Location: /');
  6876. exit;
  6877. }
  6878. $post = $this->input->post(NULL, TRUE);
  6879. if (isset($post['page'])) {
  6880. $page = $this->input->post('page', true);
  6881. $perpage = $this->input->post('perpage', true);
  6882. $category = $this->input->post('category', true);
  6883. $size = $this->input->post('size', true);
  6884. $grade = $this->input->post('grade', true);
  6885. $color = $this->input->post('color', true);
  6886. $lowe = $this->input->post('lowe', true);
  6887. $sku = $this->input->post('sku');
  6888. $title = $this->input->post('title');
  6889. $warehouse = $arg_array[0];
  6890. $usa = $this->input->post('usa', true);
  6891. $purchase = $this->input->post('purchase', true);
  6892. $lacetype = $this->input->post('lacetype', true);
  6893. $haircap = $this->input->post('haircap', true);
  6894. $density = $this->input->post('density', true);
  6895. $title = $this->input->post('title', true);
  6896. $state = $this->input->post('state', true);
  6897. $ktime = $this->input->post('ktime', true);
  6898. $jtime = $this->input->post('jtime', true);
  6899. $ktime = strtotime($ktime);
  6900. $jtime = strtotime($jtime);
  6901. $where = "state=11";
  6902. $gj = "";
  6903. $ck = "";
  6904. if ($lacetype) {
  6905. $where .= " and features like '%-$lacetype-%'";
  6906. }
  6907. if ($category) {
  6908. $where .= " and features like '%-$category-%'";
  6909. }
  6910. if ($size) {
  6911. $where .= " and features like '%-$size-%'";
  6912. }
  6913. if ($grade) {
  6914. $where .= " and features like '%-$grade-%'";
  6915. }
  6916. if ($color) {
  6917. $where .= " and features like '%-$color-%'";
  6918. }
  6919. if ($lowe) {
  6920. $where .= " and features like '%-$lowe-%'";
  6921. }
  6922. if ($haircap) {
  6923. $where .= " and features like '%-$haircap-%'";
  6924. }
  6925. if ($density) {
  6926. $where .= " and features like '%-$density-%'";
  6927. }
  6928. if ($usa) {
  6929. if (!$warehouse) {
  6930. $where .= " and (warehouse = '5' or warehouse = '8')";
  6931. }
  6932. }
  6933. if ($warehouse) {
  6934. $where .= " and warehouse = '$warehouse'";
  6935. }
  6936. if ($purchase) {
  6937. $where .= " and purchase = '$purchase'";
  6938. }
  6939. if ($state) {
  6940. $where .= " and state = '$state'";
  6941. }
  6942. if ($ktime && $jtime) {
  6943. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6944. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6945. }
  6946. //数据排序
  6947. $order_str = "id desc";
  6948. $xs = 0;
  6949. $rows = array();
  6950. $list = array();
  6951. if (empty($page)) {
  6952. $start = 0;
  6953. $perpage = 1;
  6954. } else {
  6955. $start = ($page - 1) * $perpage;
  6956. }
  6957. if ($sku || $title) {
  6958. if ($title) {
  6959. $title = trim($title, ' ');
  6960. $title = trim($title, ' ');
  6961. $where .= " and title like '%$title%'";
  6962. } else {
  6963. $sku = trim($sku, ' ');
  6964. $sku = trim($sku, ' ');
  6965. $where .= " and sku like '%$sku%'";
  6966. }
  6967. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6968. foreach ($info_list as $key => $value) {
  6969. $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'] . '"');
  6970. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6971. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6972. $rows[$key] = $value;
  6973. $warehouse = $this->warehouse->read($value['warehouse']);
  6974. $rows[$key]['warehouse'] = $warehouse['title'];
  6975. $rows[$key]['features'] = $g;
  6976. $rows[$key]['a'] = $x;
  6977. $rows[$key]['b'] = $s;
  6978. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6979. $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天销量
  6980. $yj = $c / ($xl / 30);
  6981. if ($yj < 7) {
  6982. $rows[$key]['y'] = round($yj) . '天销量';
  6983. } else {
  6984. $rows[$key]['y'] = '正常';
  6985. }
  6986. }
  6987. } else {
  6988. //$where .= " and time > '$ktime' and time < '$jtime'";
  6989. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6990. foreach ($info_list as $key => $value) {
  6991. $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'] . '"');
  6992. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6993. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6994. $zs[$key] = $value;
  6995. $warehouse = $this->warehouse->read($value['warehouse']);
  6996. $zs[$key]['warehouse'] = $warehouse['title'];
  6997. $zs[$key]['features'] = $g;
  6998. $zs[$key]['a'] = $x;
  6999. $zs[$key]['b'] = $s;
  7000. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7001. $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天销量
  7002. $yj = $c / ($xl / 30);
  7003. if ($yj < 7) {
  7004. $zs[$key]['y'] = round($yj) . '天销量';
  7005. $rows[$key] = $zs[$key];
  7006. }
  7007. }
  7008. }
  7009. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7010. $pagenum = ceil($total / $perpage);
  7011. $over = $total - ($start + $perpage);
  7012. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7013. echo json_encode($rows);
  7014. exit;
  7015. }
  7016. $this->data['arg_array'] = $arg_array[0];
  7017. $this->_Template('whlabel_fcjxc', $this->data);
  7018. }
  7019. public function _0kcdel()
  7020. {
  7021. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7022. $config['upload_path'] = '.' . $dir;
  7023. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7024. $config['allowed_types'] = 'xls|xlsx|csv';
  7025. $config['max_size'] = 10240;
  7026. $this->load->library('upload', $config);
  7027. $this->upload->initialize($config);
  7028. if ($this->upload->do_upload('userfile')) {
  7029. $full_path = $dir . $this->upload->data('file_name');
  7030. $fileName = '.' . $full_path;
  7031. if (!file_exists($fileName)) {
  7032. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7033. exit;
  7034. } else {
  7035. require_once "./data/excel/PHPExcel/IOFactory.php";
  7036. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7037. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7038. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7039. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7040. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7041. ++$column; //如果列数大于26行
  7042. $list = array();
  7043. for ($i = 2; $i <= $row; $i++) // 行数循环
  7044. {
  7045. $data = array();
  7046. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7047. {
  7048. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7049. }
  7050. $list[] = $data;
  7051. }
  7052. }
  7053. $i = 0;
  7054. $j = 0;
  7055. $ed = array();
  7056. foreach ($list as $key => $value) {
  7057. $time = time();
  7058. if ($value['0'] == "" || $value['1'] == "") {
  7059. continue;
  7060. }
  7061. $warehouse = $this->warehouse->get_title($value['0']);
  7062. $sku = $value['1'];
  7063. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7064. if (!$d) //如果没有这个SKU
  7065. {
  7066. $ed[] = array($sku . '-库存中不存在此SKU');
  7067. $j++;
  7068. continue;
  7069. }
  7070. if (!isset($warehouse['id'])) {
  7071. $ed[] = array($sku . '-仓库名错误!');
  7072. $j++;
  7073. continue;
  7074. }
  7075. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7076. if ($z < 1) {
  7077. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7078. foreach ($z as $v) {
  7079. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7080. if (count($zt) > 0) {
  7081. $ed[] = array($sku . '-有在途库存无法删除!');
  7082. $j++;
  7083. continue;
  7084. }
  7085. $this->whlabel->remove($v['id']);
  7086. }
  7087. } else {
  7088. $ed[] = array($sku . '-非0库存!');
  7089. $j++;
  7090. continue;
  7091. }
  7092. }
  7093. if ($j > 0) {
  7094. $tt = date('Ymd', time());
  7095. $title = '删除0库存错误信息-' . $tt;
  7096. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7097. $tail = "\n";
  7098. $filename = $title . ".xls";
  7099. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7100. $dir = '/data/excel/' . $time . '/';
  7101. $file_name = 'error_' . $time . rand(1000, 9999);
  7102. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7103. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7104. fwrite($myfile, $ecl);
  7105. fclose($myfile);
  7106. $error = $dir . $file_name . '.xls';
  7107. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7108. exit;
  7109. } else {
  7110. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7111. exit;
  7112. }
  7113. }
  7114. }
  7115. public function _gbhtype()
  7116. {
  7117. $post = $this->input->post(NULL, TRUE);
  7118. if (isset($post['s'])) {
  7119. $n = $this->input->post('n');
  7120. $d = $this->input->post('s');
  7121. if (!$d) {
  7122. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7123. exit;
  7124. }
  7125. $d = explode(',', trim($d, ','));
  7126. $t = $this->whlabel_type->read($n);
  7127. //循环删除记录
  7128. foreach ($d as $v) {
  7129. $u = $this->whlabel->read($v);
  7130. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7131. foreach ($data as $val) {
  7132. $this->whlabel->save(array('type' => $n), $val['id']);
  7133. }
  7134. }
  7135. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7136. }
  7137. }
  7138. //出库、退库导出
  7139. public function _dccrtype()
  7140. {
  7141. $classid = $this->classid->sku();
  7142. $pm = $classid;
  7143. $typeclass = array();
  7144. $tc = $this->typeclass->find_all();
  7145. foreach ($tc as $v) {
  7146. $typeclass[$v['id']] = $v;
  7147. }
  7148. $prc = array();
  7149. $purchase = $this->purchase->find_all();
  7150. foreach ($purchase as $k => $v) {
  7151. $prc[$v['id']] = $v['title'];
  7152. }
  7153. if (isset($_GET['sid'])) {
  7154. $wh = array();
  7155. $w = $this->warehouse->find_all('1=1', 'id,title');
  7156. foreach ($w as $v) {
  7157. $wh[$v['id']] = $v['title'];
  7158. }
  7159. $type = $this->input->get('excel', true);
  7160. $category = $this->input->get('category', true);
  7161. $size = $this->input->get('size', true);
  7162. $grade = $this->input->get('grade', true);
  7163. $color = $this->input->get('color', true);
  7164. $lowe = $this->input->get('lowe', true);
  7165. $sku = $this->input->get('sku', true);
  7166. $warehouse = $this->input->get('warehouse', true);
  7167. $lacetype = $this->input->get('lacetype', true);
  7168. $lacecolor = $this->input->get('lacecolor', true);
  7169. $density = $this->input->get('density', true);
  7170. $haircap = $this->input->get('haircap', true);
  7171. $purchase = $this->input->get('purchase', true);
  7172. $title = $this->input->get('title', true);
  7173. $state = $this->input->get('state', true);
  7174. $sid = $this->input->get('sid', true);
  7175. $ktime = $this->input->get('ktime', true);
  7176. $jtime = $this->input->get('jtime', true);
  7177. $ktime = strtotime($ktime);
  7178. $jtime = strtotime($jtime);
  7179. $where = "1=1";
  7180. $gj = "";
  7181. $ck = "";
  7182. if ($category) {
  7183. $where .= " and features like '%-$category-%'";
  7184. }
  7185. if ($size) {
  7186. $where .= " and features like '%-$size-%'";
  7187. }
  7188. if ($grade) {
  7189. $where .= " and features like '%-$grade-%'";
  7190. }
  7191. if ($color) {
  7192. $where .= " and features like '%-$color-%'";
  7193. }
  7194. if ($lowe) {
  7195. $where .= " and features like '%-$lowe-%'";
  7196. }
  7197. if ($warehouse) {
  7198. $where .= " and warehouse = '$warehouse'";
  7199. }
  7200. if ($purchase) {
  7201. $where .= " and purchase = '$purchase'";
  7202. }
  7203. if ($state) {
  7204. $where .= " and state = '$state'";
  7205. }
  7206. if ($lacetype) {
  7207. $where .= " and features like '%-$lacetype-%'";
  7208. }
  7209. if ($lacecolor) {
  7210. $where .= " and features like '%-$lacecolor-%'";
  7211. }
  7212. if ($density) {
  7213. $where .= " and features like '%-$density-%'";
  7214. }
  7215. if ($haircap) {
  7216. $where .= " and features like '%-$haircap-%'";
  7217. }
  7218. if ($title) {
  7219. $title = trim($title, ' ');
  7220. $title = trim($title, ' ');
  7221. $where .= " and title like '%$title%'";
  7222. }
  7223. if ($sku) {
  7224. $sku = trim($sku, ' ');
  7225. $sku = trim($sku, ' ');
  7226. $where .= " and sku like '%$sku%'";
  7227. }
  7228. if ($ktime && $jtime) {
  7229. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7230. }
  7231. $sidwhere = '';
  7232. if ($sid) {
  7233. $sd = "";
  7234. $s = explode(',', trim($sid, ','));
  7235. foreach ($s as $value) {
  7236. $sd .= " id = " . $value . " or";
  7237. }
  7238. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7239. }
  7240. //数据排序
  7241. $order_str = "time desc";
  7242. if (empty($page)) {
  7243. $start = 0;
  7244. $perpage = 1;
  7245. } else {
  7246. $start = ($page - 1) * $perpage;
  7247. }
  7248. $wh = array();
  7249. $w = $this->warehouse->find_all('1=1', 'id,title');
  7250. foreach ($w as $v) {
  7251. $wh[$v['id']] = $v['title'];
  7252. }
  7253. $wt = array();
  7254. $whlabel_type = $this->whlabel_type->find_all();
  7255. foreach ($whlabel_type as $v) {
  7256. $wt[$v['id']] = $v['title'];
  7257. }
  7258. $classid = $this->classid->sku();
  7259. $list = array();
  7260. $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');
  7261. foreach ($rows_r as $key => $value) {
  7262. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7263. $pm = $classid;
  7264. $jm = $classid;
  7265. $rows_r[$key]['enter'] = '入库';
  7266. $rows_r[$key]['time'] = $value['enter'];
  7267. if ($value['rktype'] == 1) {
  7268. $rows_r[$key]['rktype'] = '采购入库';
  7269. } else if ($value['rktype'] == 2) {
  7270. $rows_r[$key]['rktype'] = '盘盈调整';
  7271. } else if ($value['rktype'] == 3) {
  7272. $rows_r[$key]['rktype'] = '其他调整入库';
  7273. } else if ($value['rktype'] == 4) {
  7274. $rows_r[$key]['rktype'] = '其他调整入库';
  7275. } else if ($value['rktype'] == 5) {
  7276. $rows_r[$key]['rktype'] = '退库入库';
  7277. } else if ($value['rktype'] == 6) {
  7278. $rows_r[$key]['rktype'] = '退货可用入库';
  7279. } else if ($value['rktype'] == 7) {
  7280. $rows_r[$key]['rktype'] = '形态转换入库';
  7281. } else {
  7282. $rows_r[$key]['rktype'] = '';
  7283. }
  7284. $features = explode('-', trim($value['features'], '-'));
  7285. foreach ($features as $v) {
  7286. if (isset($typeclass[$v])) {
  7287. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7288. $pm[$typeclass[$v]['classid']] = $zh[0];
  7289. }
  7290. if (isset($typeclass[$v])) {
  7291. if (isset($jm[$typeclass[$v]['classid']])) {
  7292. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7293. }
  7294. }
  7295. }
  7296. $zh = implode(" ", $pm);
  7297. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7298. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7299. $rows_r[$key]['zh'] = $zh;
  7300. $jm = array_filter($jm);
  7301. $rows_r[$key]['features'] = implode("-", $jm);
  7302. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7303. }
  7304. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7305. foreach ($rows_c as $key => $value) {
  7306. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7307. $pm = $classid;
  7308. $jm = $classid;
  7309. $rows_c[$key]['time'] = $value['outk'];
  7310. $rows_c[$key]['outk'] = '出库';
  7311. if ($value['cktype'] == 1) {
  7312. $rows_c[$key]['cktype'] = '销售出库';
  7313. } else if ($value['cktype'] == 2) {
  7314. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7315. } else if ($value['cktype'] == 3) {
  7316. $rows_c[$key]['cktype'] = '盘亏调整';
  7317. } else if ($value['cktype'] == 4) {
  7318. $rows_c[$key]['cktype'] = '其他调整出库';
  7319. } else if ($value['cktype'] == 5) {
  7320. $rows_c[$key]['cktype'] = '形态转换出库';
  7321. } else {
  7322. $rows_c[$key]['cktype'] = '';
  7323. }
  7324. $features = explode('-', trim($value['features'], '-'));
  7325. foreach ($features as $v) {
  7326. if (isset($typeclass[$v])) {
  7327. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7328. $pm[$typeclass[$v]['classid']] = $zh[0];
  7329. }
  7330. if (isset($typeclass[$v])) {
  7331. if (isset($jm[$typeclass[$v]['classid']])) {
  7332. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7333. }
  7334. }
  7335. }
  7336. $zh = implode(" ", $pm);
  7337. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7338. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7339. $rows_c[$key]['zh'] = $zh;
  7340. $jm = array_filter($jm);
  7341. $rows_c[$key]['features'] = implode("-", $jm);
  7342. $rows_c[$key]['number'] = 1;
  7343. }
  7344. $merged = $rows_r;
  7345. foreach ($rows_c as $key => $value) {
  7346. if (isset($merged[$key])) {
  7347. $merged[] = $value;
  7348. } else {
  7349. $merged[$key] = $value;
  7350. }
  7351. }
  7352. usort($merged, function ($a, $b) {
  7353. return $a['time'] - $b['time'];
  7354. });
  7355. foreach ($merged as $key => $value) {
  7356. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7357. }
  7358. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7359. $titlename = "<table border=1>
  7360. <tr align='center'>
  7361. <td>仓库</td>
  7362. <td>SKU</td>
  7363. <td>商品名称</td>
  7364. <td>仓库品名</td>
  7365. <td>料号</td>
  7366. <td>时间</td>
  7367. <td>操作</td>
  7368. <td>类型</td>
  7369. <td>数量</td>
  7370. <td>备注</td>
  7371. </tr>
  7372. </table>";
  7373. $filename = $title . ".xlsx";
  7374. $tail = "";
  7375. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7376. }
  7377. }
  7378. }