Whlabel.php 259 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. } else if ($arg == 'summary') //汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. } else if ($arg == 'manifest') //usps发货清单
  144. {
  145. $this->_manifest();
  146. } else if ($arg == 'abnormal') //占单异常
  147. {
  148. $this->_abnormal();
  149. } else if ($arg == 'error') //0库存SKU
  150. {
  151. $this->_error();
  152. } else if ($arg == 'errorexcel') //0库存SKU导出
  153. {
  154. $this->_errorexcel();
  155. } else if ($arg == 'db') {
  156. $this->_db();
  157. } else if ($arg == 'dbrk') {
  158. $this->_dbrk();
  159. } else if ($arg == 'whlabelczdc') {
  160. $this->_whlabelczdc();
  161. } else if ($arg == 'print') {
  162. $this->_print($arg_array);
  163. } else if ($arg == 'usaprint') {
  164. $this->_usaprint($arg_array);
  165. } else if ($arg == 'printck') {
  166. $this->_printck($arg_array);
  167. } else if ($arg == 'printrk') {
  168. $this->_printrk($arg_array);
  169. } else if ($arg == 'printxzrk') {
  170. $this->_printxzrk($arg_array);
  171. } else if ($arg == 'printexcel') {
  172. $this->_printexcel($arg_array);
  173. } else if ($arg == 'uck') {
  174. $this->_uck();
  175. } else if ($arg == 'whlabelexcelzh') {
  176. $this->_whlabelexcelzh();
  177. } else if ($arg == 'fc') {
  178. $this->_fc();
  179. } else if ($arg == 'fcmb') {
  180. $this->_fcmb();
  181. } else if ($arg == 'fcexcel') {
  182. $this->_fcexcel();
  183. } else if ($arg == 'fcjxc') {
  184. $this->_fcjxc($arg_array);
  185. } else if ($arg == '0kcdel') {
  186. $this->_0kcdel(); //导表删除0库存
  187. } else if ($arg == 'gbhtype') {
  188. $this->_gbhtype(); //更改备货状态
  189. } else {
  190. $this->_index();
  191. }
  192. }
  193. //管理
  194. public function _index()
  195. {
  196. $post = $this->input->post(NULL, TRUE);
  197. if (isset($post['page'])) {
  198. $page = $this->input->post('page', true);
  199. $perpage = $this->input->post('perpage', true);
  200. $sku = $this->input->post('sku', true);
  201. $number = $this->input->post('number', true);
  202. $warehouse = $this->input->post('warehouse', true);
  203. $purchase = $this->input->post('purchase', true);
  204. $orderinfo = $this->input->post('orderinfo', true);
  205. $waybill = $this->input->post('waybill', true);
  206. $category = $this->input->post('category', true);
  207. $size = $this->input->post('size', true);
  208. $grade = $this->input->post('grade', true);
  209. $color = $this->input->post('color', true);
  210. $lowe = $this->input->post('lowe', true);
  211. $state = $this->input->post('state', true);
  212. $label = $this->input->post('label', true);
  213. $timetk = $this->input->post('timetkk', true);
  214. $timetj = $this->input->post('timetjj', true);
  215. $timetk = strtotime($timetk);
  216. $timetj = strtotime($timetj);
  217. $where = "1=1 ";
  218. if ($timetk && $timetj) {
  219. $where .= " and time > '$timetk' and time < '$timetj'";
  220. }
  221. if ($sku) {
  222. $where .= " and sku = '$sku'";
  223. }
  224. if ($number) {
  225. $where .= " and number = '$number'";
  226. }
  227. if ($warehouse) {
  228. $where .= " and warehouse = '$warehouse'";
  229. }
  230. if ($purchase) {
  231. $where .= " and purchase = '$purchase'";
  232. }
  233. if ($orderinfo) {
  234. $where .= " and orderinfo = '$orderinfo'";
  235. }
  236. if ($waybill) {
  237. $where .= " and waybill = '$waybill'";
  238. }
  239. if ($category) {
  240. $where .= " and features like '%-$category-%'";
  241. }
  242. if ($size) {
  243. $where .= " and features like '%-$size-%'";
  244. }
  245. if ($grade) {
  246. $where .= " and features like '%-$grade-%'";
  247. }
  248. if ($color) {
  249. $where .= " and features like '%-$color-%'";
  250. }
  251. if ($lowe) {
  252. $where .= " and features like '%-$lowe-%'";
  253. }
  254. if ($label) {
  255. $where .= " and label = '$label'";
  256. }
  257. if ($state != '') {
  258. $where .= " and state = '$state'";
  259. }
  260. //数据排序
  261. $order_str = "time desc";
  262. if (empty($page)) {
  263. $start = 0;
  264. $perpage = 1;
  265. } else {
  266. $start = ($page - 1) * $perpage;
  267. }
  268. //取得信息列表
  269. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  270. foreach ($info_list as $key => $value) {
  271. $warehouse = $this->warehouse->read($value['warehouse']);
  272. $info_list[$key]['warehouse'] = $warehouse['title'];
  273. $purchase = $this->purchase->read($value['purchase']);
  274. $info_list[$key]['purchase'] = $purchase['title'];
  275. if ($value['enter'] != 0) {
  276. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  277. } else {
  278. $info_list[$key]['enter'] = "";
  279. }
  280. if ($value['outk'] != 0) {
  281. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  282. } else {
  283. $info_list[$key]['outk'] = "";
  284. }
  285. if ($value['printing'] != 0) {
  286. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  287. } else {
  288. $info_list[$key]['printing'] = "";
  289. }
  290. if ($value['orderinfo'] == 0) {
  291. $info_list[$key]['orderinfo'] = "";
  292. }
  293. if ($value['waybill'] == 0) {
  294. $info_list[$key]['waybill'] = "";
  295. }
  296. if ($value['state'] == 0) {
  297. $info_list[$key]['state'] = "在库";
  298. } else if ($value['state'] == 1) {
  299. $info_list[$key]['state'] = "出库";
  300. } else if ($value['state'] == 2) {
  301. $info_list[$key]['state'] = "退库";
  302. } else if ($value['state'] == 3) {
  303. $info_list[$key]['state'] = "调拨中";
  304. } else if ($value['state'] == 4) {
  305. $info_list[$key]['state'] = "再加工";
  306. } else if ($value['state'] == 5) {
  307. $info_list[$key]['state'] = "维修中";
  308. } else if ($value['state'] == 6) {
  309. $info_list[$key]['state'] = "盘亏";
  310. } else if ($value['state'] == 7) {
  311. $info_list[$key]['state'] = "更换标签";
  312. } else if ($value['state'] == 8) {
  313. $info_list[$key]['state'] = "其它";
  314. } else if ($value['state'] == 9) {
  315. $info_list[$key]['state'] = "预设";
  316. } else if ($value['state'] == 10) {
  317. $info_list[$key]['state'] = "美店零售";
  318. }
  319. if ($value['text'] == "") {
  320. $info_list[$key]['text'] = "";
  321. }
  322. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  323. }
  324. $total = $this->whlabel->find_count($where);
  325. $pagenum = ceil($total / $perpage);
  326. $over = $total - ($start + $perpage);
  327. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  328. echo json_encode($rows);
  329. exit;
  330. }
  331. if (isset($post['outsku'])) {
  332. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  333. $cz = $this->input->post('cz', true);
  334. if ($cz == '1') {
  335. $sku = $this->input->post('outsku', true);
  336. if ($sku) {
  337. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  338. if (count($data) < 1) {
  339. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  340. exit;
  341. }
  342. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  343. echo json_encode(array('success' => true));
  344. exit;
  345. }
  346. } else {
  347. $sku = $this->input->post('outsku', true);
  348. if ($sku) {
  349. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  350. if (count($data) < 1) {
  351. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  352. exit;
  353. }
  354. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  355. echo json_encode(array('success' => true));
  356. exit;
  357. }
  358. }
  359. }
  360. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  361. $this->_Template('whlabel', $this->data);
  362. }
  363. //在库标签
  364. public function _existence()
  365. {
  366. $post = $this->input->post(NULL, TRUE);
  367. if (isset($post['s'])) {
  368. $id_arr = $this->input->post('s');
  369. $id_arr = explode(',', $id_arr);
  370. if (!$id_arr) {
  371. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  372. exit;
  373. }
  374. //循环删除记录
  375. foreach ($id_arr as $v) {
  376. $sid = $this->whlabel->read($v);
  377. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  378. if ($count > 0) {
  379. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  380. exit;
  381. }
  382. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  383. if (count($zt) > 0) {
  384. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  385. exit;
  386. }
  387. $this->whlabel->remove($v);
  388. }
  389. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  390. exit;
  391. }
  392. if (isset($post['page'])) {
  393. $page = $this->input->post('page', true);
  394. $perpage = $this->input->post('perpage', true);
  395. $warehouse = $this->input->post('warehouse', true);
  396. $label = $this->input->post('label', true);
  397. $where = "1=1 and state = 0";
  398. if ($warehouse) {
  399. $where .= " and warehouse = '$warehouse'";
  400. }
  401. if ($label) {
  402. $where .= " and label = '$label'";
  403. }
  404. //数据排序
  405. $order_str = "time asc";
  406. if (empty($page)) {
  407. $start = 0;
  408. $perpage = 1;
  409. } else {
  410. $start = ($page - 1) * $perpage;
  411. }
  412. //取得信息列表
  413. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  414. foreach ($info_list as $key => $value) {
  415. if ($value['enter'] != 0) {
  416. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  417. } else {
  418. $info_list[$key]['enter'] = "";
  419. }
  420. if ($value['printing'] != 0) {
  421. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  422. } else {
  423. $info_list[$key]['printing'] = "";
  424. }
  425. }
  426. $total = $this->whlabel->find_count($where);
  427. $pagenum = ceil($total / $perpage);
  428. $over = $total - ($start + $perpage);
  429. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  430. echo json_encode($rows);
  431. exit;
  432. }
  433. $this->_Template('whlabel_existence', $this->data);
  434. }
  435. //进销存浏览
  436. public function _typedy($arg_array)
  437. {
  438. $prc = array();
  439. $purchase = $this->purchase->find_all();
  440. foreach ($purchase as $k => $v) {
  441. $prc[$v['id']] = $v['title'];
  442. }
  443. $post = $this->input->post(NULL, TRUE);
  444. if (isset($post['page'])) {
  445. $page = $this->input->post('page', true);
  446. $perpage = $this->input->post('perpage', true);
  447. $category = $this->input->post('category', true);
  448. $size = $this->input->post('size', true);
  449. $grade = $this->input->post('grade', true);
  450. $color = $this->input->post('color', true);
  451. $lowe = $this->input->post('lowe', true);
  452. $sku = $this->input->post('sku');
  453. $title = $this->input->post('title');
  454. $warehouse = $this->input->post('warehouse', true);
  455. $usa = $this->input->post('usa', true);
  456. $purchase = $this->input->post('purchase', true);
  457. $lacetype = $this->input->post('lacetype', true);
  458. $haircap = $this->input->post('haircap', true);
  459. $density = $this->input->post('density', true);
  460. $details = $this->input->post('details', true);
  461. $state = $this->input->post('state', true);
  462. $lacecolor = $this->input->post('lacecolor', true);
  463. $hairnumber = $this->input->post('hairnumber', true);
  464. $cklx = $this->input->post('cklx', true);
  465. $ktime = $this->input->post('ktime', true);
  466. $jtime = $this->input->post('jtime', true);
  467. $sm = $this->input->post('sm', true);
  468. $cpbz = $this->input->post('cpbz', true);
  469. $type = $this->input->post('type', true);
  470. $ktime = strtotime($ktime);
  471. $jtime = strtotime($jtime);
  472. $where = "1=1";
  473. $gj = "";
  474. $ck = "";
  475. if ($usa) {
  476. if (!$warehouse) {
  477. $where .= " and (warehouse = '5' or warehouse = '8')";
  478. }
  479. }
  480. if ($warehouse) {
  481. $where .= " and warehouse = '$warehouse'";
  482. }
  483. if ($details) {
  484. $where .= " and details = '$details'";
  485. }
  486. if ($purchase) {
  487. $where .= " and purchase = '$purchase'";
  488. }
  489. if ($state) {
  490. $where .= " and state = '$state'";
  491. }
  492. if ($lacetype) {
  493. $where .= " and features like '%-$lacetype-%'";
  494. }
  495. if ($category) {
  496. $where .= " and features like '%-$category-%'";
  497. }
  498. if ($size) {
  499. $where .= " and features like '%-$size-%'";
  500. }
  501. if ($grade) {
  502. $where .= " and features like '%-$grade-%'";
  503. }
  504. if ($color) {
  505. $where .= " and features like '%-$color-%'";
  506. }
  507. if ($lowe) {
  508. $where .= " and features like '%-$lowe-%'";
  509. }
  510. if ($haircap) {
  511. $where .= " and features like '%-$haircap-%'";
  512. }
  513. if ($density) {
  514. $where .= " and features like '%-$density-%'";
  515. }
  516. if ($lacecolor) {
  517. $where .= " and features like '%-$lacecolor-%'";
  518. }
  519. if($sm){
  520. $where .= " and sm like '%".$sm."%'";
  521. }
  522. if($cpbz){
  523. $where .= " and cpbz like '%".$cpbz."%'";
  524. }
  525. if($type){
  526. $where .= " and type = ".$type."";
  527. }
  528. if (!empty($hairnumber)) {
  529. $where .= " and features like '%-128-%' ";
  530. if ($hairnumber < 0) {
  531. $class_list = $this->typeclass->find_all('classid = 43');
  532. foreach ($class_list as $v) {
  533. $where .= " and features not like '%-" . $v['id'] . "-%'";
  534. }
  535. } else {
  536. $where .= " and features like '%-$hairnumber-%'";
  537. }
  538. }
  539. $where_add = '';
  540. if ($cklx) {
  541. $shop = $this->shop->read($cklx);
  542. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  543. }
  544. if ($ktime && $jtime) {
  545. $gj = " and enter > '$ktime' and enter < '$jtime'";
  546. $ck = " and outk > '$ktime' and outk < '$jtime'";
  547. }
  548. //数据排序
  549. $order_str = "id desc";
  550. if (empty($page)) {
  551. $start = 0;
  552. $perpage = 1;
  553. } else {
  554. $start = ($page - 1) * $perpage;
  555. }
  556. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  557. if ($sku) {
  558. $sku = trim($sku, ' ');
  559. $sku = trim($sku, ' ');
  560. $where .= " and sku like '%$sku%'";
  561. $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);
  562. } else if ($title) {
  563. $title = trim($title, ' ');
  564. $title = trim($title, ' ');
  565. $where .= " and title like '%$title%'";
  566. $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);
  567. } else {
  568. //$where .= " and time > '$ktime' and time < '$jtime'";
  569. $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);
  570. }
  571. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  572. foreach ($info_list as $k => $v) {
  573. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  574. unset($info_list[$k]['pm']);
  575. unset($info_list[$k]['jm']);
  576. unset($info_list[$k]['bm']);
  577. }
  578. //取得信息列表
  579. $rows = array();
  580. $list = array();
  581. foreach ($info_list as $key => $value) {
  582. $warehouse = $this->warehouse->read($value['warehouse']);
  583. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  584. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  585. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  586. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  587. $info_list[$key]['label'] = $value['sm'];
  588. $number = $value['number'];
  589. $ftime = time() - 15 * 24 * 3600;
  590. $info_list[$key]['warehouse'] = $warehouse['title'];
  591. $info_list[$key]['features'] = count($c);
  592. $z = count($z); //查看订单号
  593. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  594. $ztdata = '';
  595. if (count($zt) > 0) {
  596. foreach ($zt as $vv) {
  597. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  598. }
  599. }
  600. $info_list[$key]['number'] = $ztdata;
  601. $info_list[$key]['sm'] = $z;
  602. $details = array();
  603. $cpid = array();
  604. foreach ($c as $k => $v) {
  605. $details[$v['details']] = $v['details'];
  606. if ($v['cpid'] != 0) {
  607. $cpid[$v['cpid']] = $v['cpid'];
  608. }
  609. }
  610. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  611. if ($value['shop'] != '') {
  612. $shop = explode(',', trim($value['shop'], ','));
  613. $shop = $this->shop->read($shop[0]);
  614. $info_list[$key]['shop'] = $shop['shopname'];
  615. }
  616. }
  617. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  618. $pagenum = ceil($total / $perpage);
  619. $over = $total - ($start + $perpage);
  620. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  621. echo json_encode($rows);
  622. exit;
  623. }
  624. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  625. $this->_Template('whlabel_typedy', $this->data);
  626. }
  627. //进销存浏览
  628. public function _typedy_ck($arg_array)
  629. {
  630. $prc = array();
  631. $purchase = $this->purchase->find_all();
  632. foreach ($purchase as $k => $v) {
  633. $prc[$v['id']] = $v['title'];
  634. }
  635. $post = $this->input->post(NULL, TRUE);
  636. if (isset($post['page'])) {
  637. $page = $this->input->post('page', true);
  638. $perpage = $this->input->post('perpage', true);
  639. $category = $this->input->post('category', true);
  640. $size = $this->input->post('size', true);
  641. $grade = $this->input->post('grade', true);
  642. $color = $this->input->post('color', true);
  643. $lowe = $this->input->post('lowe', true);
  644. $sku = $this->input->post('sku');
  645. $title = $this->input->post('title');
  646. $warehouse = $this->input->post('warehouse', true);
  647. $usa = $this->input->post('usa', true);
  648. $purchase = $this->input->post('purchase', true);
  649. $lacetype = $this->input->post('lacetype', true);
  650. $haircap = $this->input->post('haircap', true);
  651. $density = $this->input->post('density', true);
  652. $details = $this->input->post('details', true);
  653. $state = $this->input->post('state', true);
  654. $lacecolor = $this->input->post('lacecolor', true);
  655. $cklx = $this->input->post('cklx', true);
  656. $ktime = $this->input->post('ktime', true);
  657. $jtime = $this->input->post('jtime', true);
  658. $ktime = strtotime($ktime);
  659. $jtime = strtotime($jtime);
  660. $where = "1=1";
  661. $gj = "";
  662. $ck = "";
  663. if ($lacetype) {
  664. $where .= " and features like '%-$lacetype-%'";
  665. }
  666. if ($category) {
  667. $where .= " and features like '%-$category-%'";
  668. }
  669. if ($size) {
  670. $where .= " and features like '%-$size-%'";
  671. }
  672. if ($grade) {
  673. $where .= " and features like '%-$grade-%'";
  674. }
  675. if ($color) {
  676. $where .= " and features like '%-$color-%'";
  677. }
  678. if ($lowe) {
  679. $where .= " and features like '%-$lowe-%'";
  680. }
  681. if ($haircap) {
  682. $where .= " and features like '%-$haircap-%'";
  683. }
  684. if ($density) {
  685. $where .= " and features like '%-$density-%'";
  686. }
  687. if ($lacecolor) {
  688. $where .= " and features like '%-$lacecolor-%'";
  689. }
  690. if ($usa) {
  691. if (!$warehouse) {
  692. $where .= " and (warehouse = '5' or warehouse = '8')";
  693. }
  694. }
  695. if ($warehouse) {
  696. $where .= " and warehouse = '$warehouse'";
  697. }
  698. if ($details) {
  699. $where .= " and details = '$details'";
  700. }
  701. if ($purchase) {
  702. $where .= " and purchase = '$purchase'";
  703. }
  704. if ($state) {
  705. $where .= " and state = '$state'";
  706. }
  707. $where_add = '';
  708. if ($cklx) {
  709. $shop = $this->shop->read($cklx);
  710. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  711. }
  712. if ($ktime && $jtime) {
  713. $gj = " and enter > '$ktime' and enter < '$jtime'";
  714. $ck = " and outk > '$ktime' and outk < '$jtime'";
  715. }
  716. //数据排序
  717. $order_str = "id desc";
  718. if (empty($page)) {
  719. $start = 0;
  720. $perpage = 1;
  721. } else {
  722. $start = ($page - 1) * $perpage;
  723. }
  724. if ($sku) {
  725. $sku = trim($sku, ' ');
  726. $sku = trim($sku, ' ');
  727. $where .= " and sku like '%$sku%'";
  728. $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);
  729. } else if ($title) {
  730. $title = trim($title, ' ');
  731. $title = trim($title, ' ');
  732. $where .= " and title like '%$title%'";
  733. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  734. } else {
  735. //$where .= " and time > '$ktime' and time < '$jtime'";
  736. $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);
  737. }
  738. //取得信息列表
  739. $rows = array();
  740. $list = array();
  741. foreach ($info_list as $key => $value) {
  742. $warehouse = $this->warehouse->read($value['warehouse']);
  743. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  744. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  745. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  746. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  747. $ftime = time() - 15 * 24 * 3600;
  748. $info_list[$key]['warehouse'] = $warehouse['title'];
  749. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  750. //$z = count($z);//查看订单号
  751. //$info_list[$key]['zd'] = $z;
  752. $details = array();
  753. $cpid = array();
  754. foreach ($c as $k => $v) {
  755. $details[$v['details']] = $v['details'];
  756. if ($v['cpid'] != 0) {
  757. $cpid[$v['cpid']] = $v['cpid'];
  758. }
  759. }
  760. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  761. if ($value['shop'] != '') {
  762. $shop = explode(',', trim($value['shop'], ','));
  763. $shop = $this->shop->read($shop[0]);
  764. $info_list[$key]['shop'] = $shop['shopname'];
  765. }
  766. }
  767. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  768. $pagenum = ceil($total / $perpage);
  769. $over = $total - ($start + $perpage);
  770. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  771. echo json_encode($rows);
  772. exit;
  773. }
  774. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  775. $this->_Template('whlabel_typedy_ck', $this->data);
  776. }
  777. public function _typeck($arg_array)
  778. {
  779. $prc = array();
  780. $purchase = $this->purchase->find_all();
  781. foreach ($purchase as $k => $v) {
  782. $prc[$v['id']] = $v['title'];
  783. }
  784. $post = $this->input->post(NULL, TRUE);
  785. if (isset($post['page'])) {
  786. $page = $this->input->post('page', true);
  787. $perpage = $this->input->post('perpage', true);
  788. $category = $this->input->post('category', true);
  789. $size = $this->input->post('size', true);
  790. $grade = $this->input->post('grade', true);
  791. $color = $this->input->post('color', true);
  792. $lacecolor = $this->input->post('lacecolor', true);
  793. $lowe = $this->input->post('lowe', true);
  794. $sku = $this->input->post('sku');
  795. $title = $this->input->post('title');
  796. $warehouse = 13;
  797. $usa = $this->input->post('usa', true);
  798. $purchase = $this->input->post('purchase', true);
  799. $lacetype = $this->input->post('lacetype', true);
  800. $haircap = $this->input->post('haircap', true);
  801. $density = $this->input->post('density', true);
  802. $details = $this->input->post('details', true);
  803. $state = $this->input->post('state', true);
  804. $ktime = $this->input->post('ktime', true);
  805. $jtime = $this->input->post('jtime', true);
  806. $ktime = strtotime($ktime);
  807. $jtime = strtotime($jtime);
  808. $where = "1=1";
  809. $gj = "";
  810. $ck = "";
  811. if ($lacetype) {
  812. $where .= " and features like '%-$lacetype-%'";
  813. }
  814. if ($category) {
  815. $where .= " and features like '%-$category-%'";
  816. }
  817. if ($size) {
  818. $where .= " and features like '%-$size-%'";
  819. }
  820. if ($grade) {
  821. $where .= " and features like '%-$grade-%'";
  822. }
  823. if ($color) {
  824. $where .= " and features like '%-$color-%'";
  825. }
  826. if ($lacecolor) {
  827. $where .= " and features like '%-$lacecolor-%'";
  828. }
  829. if ($lowe) {
  830. $where .= " and features like '%-$lowe-%'";
  831. }
  832. if ($haircap) {
  833. $where .= " and features like '%-$haircap-%'";
  834. }
  835. if ($density) {
  836. $where .= " and features like '%-$density-%'";
  837. }
  838. if ($warehouse) {
  839. $where .= " and warehouse = '$warehouse'";
  840. }
  841. if ($details) {
  842. $where .= " and details = '$details'";
  843. }
  844. if ($purchase) {
  845. $where .= " and purchase = '$purchase'";
  846. }
  847. if ($state) {
  848. $where .= " and state = '$state'";
  849. }
  850. if ($ktime && $jtime) {
  851. $gj = " and enter > '$ktime' and enter < '$jtime'";
  852. $ck = " and outk > '$ktime' and outk < '$jtime'";
  853. }
  854. //数据排序
  855. $order_str = "id desc";
  856. if (empty($page)) {
  857. $start = 0;
  858. $perpage = 1;
  859. } else {
  860. $start = ($page - 1) * $perpage;
  861. }
  862. if ($sku) {
  863. $sku = trim($sku, ' ');
  864. $sku = trim($sku, ' ');
  865. $where .= " and sku like '%$sku%'";
  866. } else if ($title) {
  867. $title = trim($title, ' ');
  868. $title = trim($title, ' ');
  869. $where .= " and title like '%$title%'";
  870. }
  871. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  872. //取得信息列表
  873. $t = array();
  874. $typeclass = $this->typeclass->find_all();
  875. foreach ($typeclass as $v) {
  876. $t[$v['id']] = $v;
  877. }
  878. $rows = array();
  879. $list = array();
  880. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  881. foreach ($info_list as $key => $value) {
  882. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  883. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  884. $warehouse = $this->warehouse->read($value['warehouse']);
  885. $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');
  886. $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'] . '"');
  887. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  888. $number = $value['number'];
  889. $ftime = time() - 15 * 24 * 3600;
  890. $z = count($z); //查看订单号
  891. $info_list[$key]['warehouse'] = $warehouse['title'];
  892. $info_list[$key]['features'] = count($c);
  893. $info_list[$key]['number'] = $z;
  894. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  895. $details = array();
  896. $cpid = array();
  897. foreach ($c as $k => $v) {
  898. $details[$v['details']] = $v['details'];
  899. if ($v['cpid'] != 0) {
  900. $cpid[$v['cpid']] = $v['cpid'];
  901. }
  902. }
  903. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  904. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  905. unset($info_list[$key]['pm']);
  906. unset($info_list[$key]['jm']);
  907. unset($info_list[$key]['bm']);
  908. }
  909. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  910. $pagenum = ceil($total / $perpage);
  911. $over = $total - ($start + $perpage);
  912. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  913. echo json_encode($rows);
  914. exit;
  915. }
  916. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  917. $this->_Template('whlabel_typeck', $this->data);
  918. }
  919. //进销存导出
  920. public function _whlabeckdc()
  921. {
  922. $prc = array();
  923. $purchase = $this->purchase->find_all();
  924. foreach ($purchase as $k => $v) {
  925. $prc[$v['id']] = $v['title'];
  926. }
  927. if (isset($_GET['excel'])) {
  928. $where = "sku != 'Preset'";
  929. //数据排序
  930. $order_str = "id desc";
  931. if (empty($page)) {
  932. $start = 0;
  933. $perpage = 1;
  934. } else {
  935. $start = ($page - 1) * $perpage;
  936. }
  937. $category = $this->input->get('category', true);
  938. $color = $this->input->get('color', true);
  939. $lowe = $this->input->get('lowe', true);
  940. $lacetype = $this->input->get('lacetype', true);
  941. $size = $this->input->get('size', true);
  942. $density = $this->input->get('density', true);
  943. $haircap = $this->input->get('haircap', true);
  944. $sku = $this->input->get('sku', true);
  945. $details = $this->input->get('details', true);
  946. $warehouse = 13;
  947. $excelid = $this->input->get('sid', true);
  948. if ($category) {
  949. $where .= " and features like '%-$category-%'";
  950. }
  951. if ($color) {
  952. $where .= " and features like '%-$color-%'";
  953. }
  954. if ($lowe) {
  955. $where .= " and features like '%-$lowe-%'";
  956. }
  957. if ($lacetype) {
  958. $where .= " and features like '%-$lacetype-%'";
  959. }
  960. if ($size) {
  961. $where .= " and features like '%-$size-%'";
  962. }
  963. if ($density) {
  964. $where .= " and features like '%-$density-%'";
  965. }
  966. if ($haircap) {
  967. $where .= " and features like '%-$haircap-%'";
  968. }
  969. if ($warehouse) {
  970. $where .= " and warehouse = '$warehouse'";
  971. }
  972. if ($sku) {
  973. $where .= " and sku like '%$sku%'";
  974. }
  975. if ($details) {
  976. $where .= " and details = '$details'";
  977. }
  978. $xzid = '';
  979. if ($excelid) {
  980. $excelid = explode(',', trim($excelid, ','));
  981. foreach ($excelid as $key => $value) {
  982. $xzid .= " id = " . $value . " or";
  983. }
  984. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  985. }
  986. //取得信息列表
  987. /**
  988. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  989. $rows = array();$list = array();
  990. foreach ($info_list as $key=>$value)
  991. {
  992. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  993. }
  994. **/
  995. $wh = array();
  996. $w = $this->warehouse->find_all('1=1', 'id,title');
  997. foreach ($w as $v) {
  998. $wh[$v['id']] = $v['title'];
  999. }
  1000. $tc = array();
  1001. $tcdata = array();
  1002. $list = array();
  1003. $classid = $this->classid->sku();
  1004. $tcall = $this->typeclass->find_all();
  1005. $typeclass = array();
  1006. foreach ($tcall as $v)
  1007. {
  1008. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1009. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1010. }
  1011. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1012. foreach ($rows as $key => $value) {
  1013. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1014. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1015. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1016. $rows[$key]['cpbz'] = $u9_info['bm'];
  1017. $rows[$key]['cs'] = $u9_info['jm'];
  1018. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1019. $details = array();
  1020. $cpid = array();
  1021. $cpbz = array();
  1022. $c = 0;
  1023. $g = 0;
  1024. $x = 0;
  1025. $t = 0;
  1026. $s = 0;
  1027. $q = 0;
  1028. foreach ($sd as $k => $v) {
  1029. if ($v['state'] == 0) {
  1030. $c++;
  1031. }
  1032. if ($v['state'] != 9) {
  1033. $g++;
  1034. }
  1035. if ($v['state'] == 1) {
  1036. $x++;
  1037. }
  1038. if ($v['state'] == 2) {
  1039. $t++;
  1040. }
  1041. if ($v['state'] == 8) {
  1042. $s++;
  1043. }
  1044. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1045. $q++;
  1046. }
  1047. $details[$v['details']] = $v['details'];
  1048. if ($v['cpid'] != 0) {
  1049. $cpid[$v['cpid']] = $v['cpid'];
  1050. }
  1051. if ($v['cpbz'] != '') {
  1052. $cpbz[$v['cpbz']] = $v['cpbz'];
  1053. }
  1054. }
  1055. $rows[$key]['details'] = implode("、", $details);
  1056. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1057. $number = $value['number'];
  1058. $ftime = time() - 15 * 24 * 3600;
  1059. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1060. $rows[$key]['number'] = $g;
  1061. $rows[$key]['features'] = $c;
  1062. $rows[$key]['x'] = $x;
  1063. $rows[$key]['t'] = $t;
  1064. $rows[$key]['s'] = $s;
  1065. $rows[$key]['q'] = $q;
  1066. $rows[$key]['wzsl'] = count($details);
  1067. }
  1068. $title = "进销存统计表" . date('Y-m-d', time());
  1069. $titlename = "<table border=1>
  1070. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1071. <tr align='center'>
  1072. <td>仓库</td>
  1073. <td>供应商</td>
  1074. <td>位置</td>
  1075. <td>库存编码</td>
  1076. <td>SKU</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. <td>位置数量</td>
  1088. </tr>
  1089. </table>";
  1090. $filename = $title . ".xls";
  1091. $tail = "";
  1092. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1093. }
  1094. }
  1095. public function _type()
  1096. {
  1097. $vip = 0;
  1098. if (isset($_SESSION['api'])) {
  1099. $user = $this->user->get_api($_SESSION['api']);
  1100. $fgshop = "";
  1101. $sid = "";
  1102. $usersp = explode('|', trim($user['shop'], '|'));
  1103. foreach ($usersp as $value) {
  1104. $fgshop .= " shop = " . $value . " or";
  1105. $sid .= " id = " . $value . " or";
  1106. }
  1107. if ($user['vip'] == 1) {
  1108. $vip = 1;
  1109. }
  1110. } else {
  1111. header('Location: /');
  1112. exit;
  1113. }
  1114. $prc = array();
  1115. $purchase = $this->purchase->find_all();
  1116. foreach ($purchase as $k => $v) {
  1117. $prc[$v['id']] = $v['title'];
  1118. }
  1119. $company = array();
  1120. $ct = $this->company->find_all();
  1121. foreach ($ct as $k => $v) {
  1122. $company[$v['id']] = $v['title'];
  1123. }
  1124. $sp = array();
  1125. $s = $this->shop->find_all('1=1', 'id,shopname');
  1126. foreach ($s as $v) {
  1127. $sp[$v['id']] = $v['shopname'];
  1128. }
  1129. $wh = array();
  1130. $w = $this->warehouse->find_all('1=1', 'id,title');
  1131. foreach ($w as $v) {
  1132. $wh[$v['id']] = $v['title'];
  1133. }
  1134. $post = $this->input->post(NULL, TRUE);
  1135. if (isset($post['page'])) {
  1136. $page = $this->input->post('page', true);
  1137. $perpage = $this->input->post('perpage', true);
  1138. $category = $this->input->post('category', true);
  1139. $size = $this->input->post('size', true);
  1140. $grade = $this->input->post('grade', true);
  1141. $color = $this->input->post('color', true);
  1142. $lowe = $this->input->post('lowe', true);
  1143. $sku = $this->input->post('sku');
  1144. $title = $this->input->post('title');
  1145. $warehouse = $this->input->post('warehouse', true);
  1146. $usa = $this->input->post('usa', true);
  1147. $purchase = $this->input->post('purchase', true);
  1148. $lacetype = $this->input->post('lacetype', true);
  1149. $haircap = $this->input->post('haircap', true);
  1150. $density = $this->input->post('density', true);
  1151. $details = $this->input->post('details', true);
  1152. $state = $this->input->post('state', true);
  1153. $shop = $this->input->post('shop', true);
  1154. $lacecolor = $this->input->post('lacecolor', true);
  1155. $hairnumber = $this->input->post('hairnumber', true);
  1156. $type = $this->input->post('type', true);
  1157. $ktime = $this->input->post('ktime', true);
  1158. $jtime = $this->input->post('jtime', true);
  1159. $ktime = strtotime($ktime);
  1160. $jtime = strtotime($jtime);
  1161. $cpbz = $this->input->post('cpbz', true);
  1162. $sm = $this->input->post('sm', true);
  1163. $where = "1=1";
  1164. $gj = "";
  1165. $ck = "";
  1166. if ($usa) {
  1167. if (!$warehouse) {
  1168. $where .= " and (warehouse = '5' or warehouse = '8')";
  1169. }
  1170. }
  1171. if ($warehouse) {
  1172. $where .= " and warehouse = '$warehouse'";
  1173. }
  1174. if ($details) {
  1175. $where .= " and details = '$details'";
  1176. }
  1177. if ($purchase) {
  1178. $where .= " and purchase = '$purchase'";
  1179. }
  1180. if ($state) {
  1181. $where .= " and state = '$state'";
  1182. }
  1183. if ($shop) {
  1184. $where .= " and shop like '%$shop%'";
  1185. }
  1186. if ($type) {
  1187. $where .= " and type = '$type'";
  1188. }
  1189. if ($ktime && $jtime) {
  1190. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1191. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1192. }
  1193. if ($cpbz) {
  1194. $where .= " and cpbz like '%$cpbz%' ";
  1195. }
  1196. if ($sm) {
  1197. $where .= " and sm like '%$sm%' ";
  1198. }
  1199. if ($lacecolor) {
  1200. $where .= " and features like '%-$lacecolor-%'";
  1201. }
  1202. if ($lacetype) {
  1203. $where .= " and features like '%-$lacetype-%'";
  1204. }
  1205. if ($category) {
  1206. $where .= " and features like '%-$category-%'";
  1207. }
  1208. if ($size) {
  1209. $where .= " and features like '%-$size-%'";
  1210. }
  1211. if ($grade) {
  1212. $where .= " and features like '%-$grade-%'";
  1213. }
  1214. if ($color) {
  1215. $where .= " and features like '%-$color-%'";
  1216. }
  1217. if ($lowe) {
  1218. $where .= " and features like '%-$lowe-%'";
  1219. }
  1220. if ($haircap) {
  1221. $where .= " and features like '%-$haircap-%'";
  1222. }
  1223. if ($density) {
  1224. $where .= " and features like '%-$density-%'";
  1225. }
  1226. if (!empty($hairnumber)) {
  1227. $where .= " and features like '%-128-%' ";
  1228. if ($hairnumber < 0) {
  1229. $class_list = $this->typeclass->find_all('classid = 43');
  1230. foreach ($class_list as $v) {
  1231. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1232. }
  1233. } else {
  1234. $where .= " and features like '%-$hairnumber-%'";
  1235. }
  1236. }
  1237. //数据排序
  1238. $order_str = "id desc";
  1239. if (empty($page)) {
  1240. $start = 0;
  1241. $perpage = 1;
  1242. } else {
  1243. $start = ($page - 1) * $perpage;
  1244. }
  1245. $fjnr = '';
  1246. if ($sku) {
  1247. $sku = trim($sku, ' ');
  1248. $sku = trim($sku, ' ');
  1249. $fjnr .= " and sku like '%$sku%'";
  1250. }
  1251. if ($title) {
  1252. $title = trim($title, ' ');
  1253. $title = trim($title, ' ');
  1254. $fjnr .= " and title like '%$title%'";
  1255. }
  1256. $wt = array();
  1257. $whlabel_type = $this->whlabel_type->find_all();
  1258. foreach ($whlabel_type as $v) {
  1259. $wt[$v['id']] = $v['title'];
  1260. }
  1261. $this->logic_ding->sendToDing("监听美仓BCA".$where. $fjnr);
  1262. //$where .= " and time > '$ktime' and time < '$jtime'";
  1263. $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
  1264. //取得信息列表
  1265. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1266. $rows = array();
  1267. $list = array();
  1268. foreach ($info_list as $key => $value) {
  1269. if (isset($wt[$value['type']])) {
  1270. $info_list[$key]['type'] = $wt[$value['type']];
  1271. } else {
  1272. $info_list[$key]['type'] = '未设置';
  1273. }
  1274. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1275. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1276. $ztdata = '';
  1277. if (count($zt) > 0) {
  1278. foreach ($zt as $vv) {
  1279. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1280. }
  1281. }
  1282. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1283. $cdata = array_filter($qbdata, function ($item) {
  1284. return $item['state'] < 1;
  1285. });
  1286. $this->logic_ding->sendToDing("监听美仓BCA【".json_encode($qbdata)."】".json_encode($cdata));
  1287. $c = array_sum(array_column($cdata, 'jnum'));
  1288. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1289. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1290. });
  1291. $g = array_sum(array_column($gdata, 'jnum'));
  1292. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1293. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1294. });
  1295. $x = array_sum(array_column($xdata, 'jnum'));
  1296. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1297. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1298. });
  1299. $t = array_sum(array_column($tdata, 'jnum'));
  1300. $zdata = array_filter($qbdata, function ($item) {
  1301. return $item['zd'] != "" && $item['state'] < 1;
  1302. });
  1303. $z = array_sum(array_column($zdata, 'jnum'));
  1304. $zdata = array_filter($qbdata, function ($item) {
  1305. return $item['zd'] != "" && $item['state'] < 1;
  1306. });
  1307. $z = array_sum(array_column($zdata, 'jnum'));
  1308. //$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');
  1309. //$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'].'"');
  1310. //$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'].'"');
  1311. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1312. //$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'].'"');
  1313. $details = array();
  1314. $cpid = array();
  1315. $od = array();
  1316. $odid = '';
  1317. $companytitle = '';
  1318. $shop_list = [];
  1319. foreach ($qbdata as $v) {
  1320. if ($v['zd'] != "" && $v['state'] < 1) {
  1321. if (!isset($od[$v['zd']])) {
  1322. $od[$v['zd']] = 1; //所有数据sku
  1323. } else {
  1324. $od[$v['zd']] = $od[$v['zd']] + 1;
  1325. }
  1326. }
  1327. if ($v['state'] < 1) {
  1328. $details[$v['details']] = $v['details'];
  1329. if ($v['cpid'] != 0) {
  1330. $cpid[$v['cpid']] = $v['cpid'];
  1331. }
  1332. }
  1333. if($v['state'] == 0){
  1334. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1335. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1336. }
  1337. if ($v['shop'] != '') {
  1338. $shop = explode(',', trim($v['shop'], ','));
  1339. foreach ($shop as $vv) {
  1340. if (!in_array($vv, $shop_list)) {
  1341. $shop_list[] = $vv;
  1342. }
  1343. }
  1344. }
  1345. }
  1346. }
  1347. foreach ($od as $k => $vv) {
  1348. $odid .= $k . '数量' . $vv;
  1349. }
  1350. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1351. $info_list[$key]['label'] = $value['sm'];
  1352. $number = $value['number'];
  1353. $ftime = time() - 15 * 24 * 3600;
  1354. $z = $z . '(' . $odid . ')'; //查看订单号
  1355. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1356. $info_list[$key]['features'] = $c;
  1357. $info_list[$key]['number'] = $ztdata;
  1358. $info_list[$key]['sm'] = $g;
  1359. $info_list[$key]['x'] = $x;
  1360. $info_list[$key]['t'] = $t;
  1361. $info_list[$key]['z'] = $z;
  1362. /**
  1363. foreach ($cdata as $k=>$v)
  1364. {
  1365. $details[$v['details']] = $v['details'];
  1366. if($v['cpid'] != 0)
  1367. {
  1368. $cpid[$v['cpid']] = $v['cpid'];
  1369. }
  1370. }
  1371. **/
  1372. $info_list[$key]['shop'] = '';
  1373. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1374. // if ($value['shop'] != '') {
  1375. // $shop = explode(',', trim($value['shop'], ','));
  1376. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1377. // }
  1378. $shop_list = array_unique($shop_list);
  1379. $shop_str = '';
  1380. foreach ($shop_list as $v) {
  1381. if(isset($sp[$v])){
  1382. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1383. }
  1384. }
  1385. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1386. /**
  1387. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1388. if(isset($companytitle[0]))
  1389. {
  1390. foreach ($companytitle as $k=>$v)
  1391. {
  1392. if($v['companytitle'] != '')
  1393. {
  1394. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1395. }
  1396. }
  1397. }
  1398. **/
  1399. }
  1400. $final_all_list = [];
  1401. foreach ($info_list as $k => $v) {
  1402. $final_all_list[] = [
  1403. 'id' => $v['id'],
  1404. "warehouse" => $v["warehouse"],
  1405. "purchase" => $v["purchase"],
  1406. "sku" => $v["sku"],
  1407. "title" => $v["title"] . "<br/>" . $v["pm"],
  1408. "details" => $v["details"],
  1409. "shop" => $v["shop"],
  1410. "cpbz" => $v["cpbz"],
  1411. 'label' => $v['label'],
  1412. "type" => $v["type"],
  1413. "features" => $v["features"],
  1414. "number" => $v["number"],
  1415. "sm" => $v["sm"],
  1416. "x" => $v["x"],
  1417. "t" => $v["t"],
  1418. "z" => $v["z"]
  1419. ];
  1420. }
  1421. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1422. $pagenum = ceil($total / $perpage);
  1423. $over = $total - ($start + $perpage);
  1424. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1425. echo json_encode($rows);
  1426. exit;
  1427. }
  1428. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1429. $this->data['shop'] = $wlshop;
  1430. $this->data['vip'] = $vip;
  1431. $this->_Template('whlabel_type', $this->data);
  1432. }
  1433. //美仓进销存浏览
  1434. public function _usatype()
  1435. {
  1436. if (isset($_SESSION['api'])) {
  1437. $user = $this->user->get_api($_SESSION['api']);
  1438. $usp = $user;
  1439. $fgshop = "";
  1440. $sid = "";
  1441. $wid = "";
  1442. $wtype = "";
  1443. $userwh = explode('|', trim($user['warehouse'], '|'));
  1444. foreach ($userwh as $value) {
  1445. $wid .= " id = " . $value . " or";
  1446. $wtype .= " type = " . $value . " or";
  1447. }
  1448. }
  1449. $prc = array();
  1450. $purchase = $this->purchase->find_all();
  1451. foreach ($purchase as $k => $v) {
  1452. $prc[$v['id']] = $v['title'];
  1453. }
  1454. $post = $this->input->post(NULL, TRUE);
  1455. if (isset($post['page'])) {
  1456. $page = $this->input->post('page', true);
  1457. $perpage = $this->input->post('perpage', true);
  1458. $category = $this->input->post('category', true);
  1459. $size = $this->input->post('size', true);
  1460. $grade = $this->input->post('grade', true);
  1461. $color = $this->input->post('color', true);
  1462. $lowe = $this->input->post('lowe', true);
  1463. $sku = $this->input->post('sku');
  1464. $title = $this->input->post('title');
  1465. $warehouse = $this->input->post('warehouse', true);
  1466. $usa = $this->input->post('usa', true);
  1467. $purchase = $this->input->post('purchase', true);
  1468. $lacetype = $this->input->post('lacetype', true);
  1469. $haircap = $this->input->post('haircap', true);
  1470. $density = $this->input->post('density', true);
  1471. $details = $this->input->post('details', true);
  1472. $state = $this->input->post('state', true);
  1473. $lacecolor = $this->input->post('lacecolor', true);
  1474. $cklx = $this->input->post('cklx', true);
  1475. $ktime = $this->input->post('ktime', true);
  1476. $jtime = $this->input->post('jtime', true);
  1477. $ktime = strtotime($ktime);
  1478. $jtime = strtotime($jtime);
  1479. $where = "1=1";
  1480. $gj = "";
  1481. $ck = "";
  1482. if ($lacetype) {
  1483. $where .= " and features like '%-$lacetype-%'";
  1484. }
  1485. if ($category) {
  1486. $where .= " and features like '%-$category-%'";
  1487. }
  1488. if ($size) {
  1489. $where .= " and features like '%-$size-%'";
  1490. }
  1491. if ($grade) {
  1492. $where .= " and features like '%-$grade-%'";
  1493. }
  1494. if ($color) {
  1495. $where .= " and features like '%-$color-%'";
  1496. }
  1497. if ($lowe) {
  1498. $where .= " and features like '%-$lowe-%'";
  1499. }
  1500. if ($haircap) {
  1501. $where .= " and features like '%-$haircap-%'";
  1502. }
  1503. if ($density) {
  1504. $where .= " and features like '%-$density-%'";
  1505. }
  1506. if ($lacecolor) {
  1507. $where .= " and features like '%-$lacecolor-%'";
  1508. }
  1509. if ($usa) {
  1510. if (!$warehouse) {
  1511. $where .= " and (warehouse = '5' or warehouse = '8')";
  1512. }
  1513. }
  1514. if ($warehouse) {
  1515. $where .= " and warehouse = '$warehouse'";
  1516. }
  1517. if ($details) {
  1518. $where .= " and details = '$details'";
  1519. }
  1520. if ($purchase) {
  1521. $where .= " and purchase = '$purchase'";
  1522. }
  1523. if ($state) {
  1524. $where .= " and state = '$state'";
  1525. }
  1526. $where_add = '';
  1527. if ($cklx) {
  1528. $shop = $this->shop->read($cklx);
  1529. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1530. }
  1531. if ($ktime && $jtime) {
  1532. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1533. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1534. }
  1535. //数据排序
  1536. $order_str = "id desc";
  1537. if (empty($page)) {
  1538. $start = 0;
  1539. $perpage = 1;
  1540. } else {
  1541. $start = ($page - 1) * $perpage;
  1542. }
  1543. if ($sku) {
  1544. $sku = trim($sku, ' ');
  1545. $sku = trim($sku, ' ');
  1546. $where .= " and sku like '%$sku%'";
  1547. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1548. } else if ($title) {
  1549. $title = trim($title, ' ');
  1550. $title = trim($title, ' ');
  1551. $where .= " and title like '%$title%'";
  1552. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1553. } else {
  1554. //$where .= " and time > '$ktime' and time < '$jtime'";
  1555. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1556. }
  1557. //取得信息列表
  1558. $rows = array();
  1559. $list = array();
  1560. foreach ($info_list as $key => $value) {
  1561. $warehouse = $this->warehouse->read($value['warehouse']);
  1562. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1563. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1564. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1565. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1566. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1567. $od = array();
  1568. $odid = '';
  1569. foreach ($z as $v) {
  1570. if (!isset($od[$v['zd']])) {
  1571. $od[$v['zd']] = 1; //所有数据sku
  1572. } else {
  1573. $od[$v['zd']] = $od[$v['zd']] + 1;
  1574. }
  1575. }
  1576. foreach ($od as $k => $vv) {
  1577. $odid .= $k . '数量' . $vv . ' ';
  1578. }
  1579. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1580. $info_list[$key]['features'] = $c;
  1581. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1582. $ztdata = '';
  1583. if (count($zt) > 0) {
  1584. foreach ($zt as $vv) {
  1585. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1586. }
  1587. }
  1588. $info_list[$key]['warehouse'] = $ztdata;
  1589. $info_list[$key]['g'] = $g;
  1590. $info_list[$key]['x'] = $x;
  1591. $info_list[$key]['t'] = $t;
  1592. $info_list[$key]['z'] = $z;
  1593. }
  1594. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1595. $pagenum = ceil($total / $perpage);
  1596. $over = $total - ($start + $perpage);
  1597. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1598. echo json_encode($rows);
  1599. exit;
  1600. }
  1601. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1602. $this->data['warehouse'] = $warehouse;
  1603. $this->_Template('whlabel_typeusa', $this->data);
  1604. }
  1605. //美仓进销存浏览
  1606. public function _usatypeapp()
  1607. {
  1608. $post = $this->input->post(NULL, TRUE);
  1609. if (isset($post['page'])) {
  1610. $page = $this->input->post('page', true);
  1611. $perpage = $this->input->post('perpage', true);
  1612. $sku = $this->input->post('sku', true);
  1613. $warehouse = 5;
  1614. $title = $this->input->post('title', true);
  1615. $state = $this->input->post('state', true);
  1616. $ktime = $this->input->post('ktime', true);
  1617. $jtime = $this->input->post('jtime', true);
  1618. $ktime = strtotime($ktime);
  1619. $jtime = strtotime($jtime);
  1620. $where = "1=1";
  1621. $gj = "";
  1622. $ck = "";
  1623. if ($title) {
  1624. $st = explode(' ', trim($title, ' '));
  1625. foreach ($st as $v) {
  1626. $where .= " and title like '%$v%'";
  1627. }
  1628. }
  1629. if ($warehouse) {
  1630. $where .= " and warehouse = '$warehouse'";
  1631. }
  1632. if ($state) {
  1633. $where .= " and state = '$state'";
  1634. }
  1635. if ($sku) {
  1636. $where .= " and sku like '%$sku%'";
  1637. }
  1638. if ($ktime && $jtime) {
  1639. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1640. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1641. }
  1642. //数据排序
  1643. $order_str = "id desc";
  1644. if (empty($page)) {
  1645. $start = 0;
  1646. $perpage = 1;
  1647. } else {
  1648. $start = ($page - 1) * $perpage;
  1649. }
  1650. //取得信息列表
  1651. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1652. $rows = array();
  1653. $list = array();
  1654. foreach ($info_list as $key => $value) {
  1655. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1656. }
  1657. $rowsdq = array_slice($rows, $start, $perpage);
  1658. foreach ($rowsdq as $value) {
  1659. $warehouse = $this->warehouse->read($value['warehouse']);
  1660. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1661. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1662. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1663. $od = array();
  1664. $odid = '';
  1665. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1666. }
  1667. $total = count($rows);
  1668. $pagenum = ceil($total / $perpage);
  1669. $over = $total - ($start + $perpage);
  1670. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1671. echo json_encode($rows);
  1672. exit;
  1673. }
  1674. $this->_Template('phone/p_usatypeapp', $this->data);
  1675. }
  1676. //入库操作
  1677. public function _enteradd()
  1678. {
  1679. $dt = 0;
  1680. if (isset($_SESSION['api'])) {
  1681. $user = $this->user->get_api($_SESSION['api']);
  1682. $usp = $user;
  1683. $fgshop = "";
  1684. $sid = "";
  1685. $user = explode('|', trim($user['shop'], '|'));
  1686. foreach ($user as $value) {
  1687. $fgshop .= " shop = " . $value . " or";
  1688. $sid .= " id = " . $value . " or";
  1689. }
  1690. }
  1691. $tc = $this->typeclass->find_all();
  1692. $typeclass = array();
  1693. foreach ($tc as $v) {
  1694. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1695. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1696. }
  1697. $post = $this->input->post(NULL, TRUE);
  1698. if (isset($post['sku'])) {
  1699. $list = array();
  1700. $num = "";
  1701. $title = "";
  1702. $features = "";
  1703. $order = $this->input->post('order', true);
  1704. $shop = $this->input->post('shop', true);
  1705. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1706. $sku = $this->input->post('sku', true);
  1707. $post['sm'] = $this->input->post('sm', true);
  1708. $post['warehouse'] = $this->input->post('warehouse', true);
  1709. $post['purchase'] = $this->input->post('purchase', true);
  1710. $post['retreatwarehouse'] = $post['warehouse'];
  1711. $post['state'] = $this->input->post('state', true);
  1712. $post['rktype'] = $this->input->post('rktype', true);
  1713. $post['text'] = $this->input->post('text', true);
  1714. $category = $this->input->post('category', true);
  1715. $list['category'] = $category;
  1716. $list['hairtype'] = $this->input->post('hairtype', true);
  1717. $list['grade'] = $this->input->post('grade', true);
  1718. $size = $this->input->post('size', true);
  1719. $xzsku = $this->input->post('xzsku', true);
  1720. $list['size'] = rtrim($size, ',');
  1721. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1722. $list['extension'] = $this->input->post('extension', true);
  1723. if ($category == 1297) {
  1724. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1725. }
  1726. if ($category == 1702) {
  1727. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1728. $list['syother'] = $this->input->post('syother', true);
  1729. }
  1730. if ($category == 133) {
  1731. $list['fittype'] = $this->input->post('fittype', true);
  1732. $list['acother'] = $this->input->post('acother', true);
  1733. }
  1734. $list['color'] = $this->input->post('color', true);
  1735. $list['lowe'] = $this->input->post('lowe', true);
  1736. if (!$post['purchase']) {
  1737. $post['purchase'] = 1;
  1738. }
  1739. if ($category == 127) {
  1740. $list['type'] = $this->input->post('type', true);
  1741. $list['headroad'] = $this->input->post('headroad', true);
  1742. $list['density'] = $this->input->post('density', true);
  1743. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1744. $list['lacesize'] = $this->input->post('lacesize', true);
  1745. }
  1746. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1747. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1748. }
  1749. if ($category == 128) {
  1750. $list['lacetype'] = $this->input->post('lacetype', true);
  1751. $list['haircap'] = $this->input->post('haircap', true);
  1752. $list['density'] = $this->input->post('density', true);
  1753. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1754. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1755. $list['wigother'] = $this->input->post('wigother', true);
  1756. $list['wigother1'] = $this->input->post('wigother1', true);
  1757. $list['wigother2'] = $this->input->post('wigother2', true);
  1758. }
  1759. if ($category == 129) {
  1760. $list['wide'] = $this->input->post('wide', true);
  1761. }
  1762. if ($category == 131) {
  1763. $list['gifttype'] = $this->input->post('gifttype', true);
  1764. $list['giftother'] = $this->input->post('giftother', true);
  1765. }
  1766. if ($category == 134) {
  1767. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1768. }
  1769. if ($category == 1297) {
  1770. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1771. $list['sywigother'] = $this->input->post('sywigother', true);
  1772. }
  1773. if ($category == 130 || $category == 133 || $category == 1702) {
  1774. $list['items'] = $this->input->post('items', true);
  1775. $list['weight'] = $this->input->post('weight', true);
  1776. }
  1777. if ($category == 1702) {
  1778. $list['syhairther'] = $this->input->post('syhairther', true);
  1779. }
  1780. $classid = $this->classid->sku();
  1781. $scsku = $classid;
  1782. $pm = $classid;
  1783. foreach ($list as $k => $v) {
  1784. if ($v != 0) {
  1785. $num .= $v;
  1786. $features .= $v . '-';
  1787. $post[$k] = $v;
  1788. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1789. if ($k != 'size') {
  1790. $title .= $typeclass[$v]['title'] . " ";
  1791. }
  1792. if (isset($pm[$typeclass[$v]['classid']])) {
  1793. if ($typeclass[$v]['title'] == '9A') {
  1794. $pm[$typeclass[$v]['classid']] = '9A';
  1795. } else if ($typeclass[$v]['title'] == '10A') {
  1796. $pm[$typeclass[$v]['classid']] = '10A';
  1797. } else {
  1798. $clzh = $typeclass[$v]['zh'];
  1799. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1800. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1801. $clzh = $clzh[0];
  1802. }
  1803. $pm[$typeclass[$v]['classid']] = $clzh;
  1804. }
  1805. }
  1806. }
  1807. }
  1808. $zh = implode(" ", $pm);
  1809. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1810. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1811. if ($list['size']) {
  1812. $typeclass = $this->typeclass->read($list['size']);
  1813. $title .= $typeclass['title'];
  1814. }
  1815. $time = time();
  1816. if ($xzsku) {
  1817. $scsku = implode("-", $scsku);
  1818. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1819. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1820. $post['sku'] = trim($scsku, ' ');
  1821. } else {
  1822. $post['sku'] = $sku;
  1823. }
  1824. //$post['sku'] = trim($sku,' ');
  1825. $post['title'] = rtrim($title, ' ');
  1826. $post['number'] = $num;
  1827. $post['features'] = '-' . $features;
  1828. $post['enter'] = $time;
  1829. $post['time'] = $time; //操作时间
  1830. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1831. if ($yza) {
  1832. if ($post['features'] != $yza[0]['features']) {
  1833. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1834. exit;
  1835. }
  1836. }
  1837. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1838. if ($yzb) {
  1839. if ($post['sku'] != $yzb[0]['sku']) {
  1840. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1841. exit;
  1842. }
  1843. }
  1844. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1845. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1846. exit;
  1847. }
  1848. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1849. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1850. exit;
  1851. }
  1852. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1853. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1854. exit;
  1855. }
  1856. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1857. if (isset($yz[0]['type'])) {
  1858. $post['type'] = $yz[0]['type'];
  1859. }
  1860. if ($post['state'] == 9) //如果选择预设库存
  1861. {
  1862. $this->whlabel->insert($post);
  1863. } else {
  1864. /**
  1865. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1866. if($ljg == 1)
  1867. {
  1868. for($i=0;$i<$order;$i++)
  1869. {
  1870. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1871. $this->whlabel->insert($post);
  1872. }
  1873. }
  1874. **/
  1875. //if($post['warehouse'] == '5')
  1876. //{
  1877. //}
  1878. $yydata = $post;
  1879. $yydata['zh'] = $zh;
  1880. /**
  1881. $wl = $this->apiyy->get_cjlp($yydata);
  1882. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1883. {
  1884. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1885. }
  1886. if($wl['Data'][0]['m_isSucess'] != 1)
  1887. {
  1888. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1889. }
  1890. **/
  1891. for ($i = 0; $i < $order; $i++) {
  1892. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1893. $this->whlabel->insert($post);
  1894. }
  1895. }
  1896. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1897. exit;
  1898. }
  1899. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1900. $this->data['wlshop'] = $wlshop;
  1901. $this->_Template('whlabel_enteradd', $this->data);
  1902. }
  1903. //修改产品
  1904. public function _enteredit($arg_array)
  1905. {
  1906. $dt = 0;
  1907. if (isset($_SESSION['api'])) {
  1908. $user = $this->user->get_api($_SESSION['api']);
  1909. $usp = $user;
  1910. $fgshop = "";
  1911. $sid = "";
  1912. $user = explode('|', trim($user['shop'], '|'));
  1913. foreach ($user as $value) {
  1914. $fgshop .= " shop = " . $value . " or";
  1915. $sid .= " id = " . $value . " or";
  1916. }
  1917. }
  1918. $post = $this->input->post(NULL, TRUE);
  1919. if (isset($post['sku'])) {
  1920. $list = array();
  1921. $num = "";
  1922. $title = "";
  1923. $features = "";
  1924. $id = $this->input->post('id', true);
  1925. $order = $this->input->post('order', true);
  1926. $shop = $this->input->post('shop', true);
  1927. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1928. $post['sku'] = $this->input->post('sku', true);
  1929. $post['sm'] = $this->input->post('sm', true);
  1930. $post['warehouse'] = $this->input->post('warehouse', true);
  1931. $post['purchase'] = $this->input->post('purchase', true);
  1932. $post['retreatwarehouse'] = $post['warehouse'];
  1933. $category = $this->input->post('category', true);
  1934. $list['category'] = $category;
  1935. $list['hairtype'] = $this->input->post('hairtype', true);
  1936. $list['grade'] = $this->input->post('grade', true);
  1937. $size = $this->input->post('size', true);
  1938. $list['size'] = rtrim($size, ',');
  1939. $post['rktype'] = $this->input->post('rktype', true);
  1940. $post['text'] = $this->input->post('text', true);
  1941. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1942. $list['extension'] = $this->input->post('extension', true);
  1943. if ($category == 1297) {
  1944. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1945. }
  1946. if ($category == 1702) {
  1947. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1948. $list['syother'] = $this->input->post('syother', true);
  1949. }
  1950. if ($category == 133) {
  1951. $list['fittype'] = $this->input->post('fittype', true);
  1952. $list['acother'] = $this->input->post('acother', true);
  1953. }
  1954. $list['color'] = $this->input->post('color', true);
  1955. $list['lowe'] = $this->input->post('lowe', true);
  1956. if (!$post['purchase']) {
  1957. $post['purchase'] = 1;
  1958. }
  1959. if ($category == 127) {
  1960. $list['type'] = $this->input->post('type', true);
  1961. $list['headroad'] = $this->input->post('headroad', true);
  1962. $list['density'] = $this->input->post('density', true);
  1963. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1964. $list['lacesize'] = $this->input->post('lacesize', true);
  1965. }
  1966. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1967. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1968. }
  1969. if ($category == 128) {
  1970. $list['lacetype'] = $this->input->post('lacetype', true);
  1971. $list['haircap'] = $this->input->post('haircap', true);
  1972. $list['density'] = $this->input->post('density', true);
  1973. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1974. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1975. $list['wigother'] = $this->input->post('wigother', true);
  1976. $list['wigother1'] = $this->input->post('wigother1', true);
  1977. $list['wigother2'] = $this->input->post('wigother2', true);
  1978. }
  1979. if ($category == 129) {
  1980. $list['wide'] = $this->input->post('wide', true);
  1981. }
  1982. if ($category == 131) {
  1983. $list['gifttype'] = $this->input->post('gifttype', true);
  1984. $list['giftother'] = $this->input->post('giftother', true);
  1985. }
  1986. if ($category == 134) {
  1987. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1988. }
  1989. if ($category == 1297) {
  1990. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1991. $list['sywigother'] = $this->input->post('sywigother', true);
  1992. }
  1993. if ($category == 130 || $category == 133 || $category == 1702) {
  1994. $list['items'] = $this->input->post('items', true);
  1995. $list['weight'] = $this->input->post('weight', true);
  1996. }
  1997. if ($category == 1702) {
  1998. $list['syhairther'] = $this->input->post('syhairther', true);
  1999. }
  2000. foreach ($list as $k => $v) {
  2001. if ($v != 0) {
  2002. $num .= $v;
  2003. $features .= $v . '-';
  2004. $typeclass = $this->typeclass->read($v);
  2005. if ($k != 'size') {
  2006. $title .= $typeclass['title'] . " ";
  2007. }
  2008. }
  2009. }
  2010. $typeclass = $this->typeclass->read($list['size']);
  2011. $title .= $typeclass['title'];
  2012. $time = time();
  2013. $post['title'] = rtrim($title, ' ');
  2014. $post['number'] = $num;
  2015. $post['features'] = '-' . $features;
  2016. $post['time'] = $time; //操作时间
  2017. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2018. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2019. exit;
  2020. }
  2021. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2022. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2023. exit;
  2024. }
  2025. $uid = $this->whlabel->read($id);
  2026. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2027. if ($datanum > 0) {
  2028. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2029. exit;
  2030. }
  2031. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2032. {
  2033. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2034. if ($yza) {
  2035. if ($post['features'] != $yza[0]['features']) {
  2036. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2037. exit;
  2038. }
  2039. }
  2040. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2041. if ($yzb) {
  2042. if ($post['sku'] != $yzb[0]['sku']) {
  2043. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2044. exit;
  2045. }
  2046. }
  2047. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2048. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2049. exit;
  2050. }
  2051. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2052. foreach ($data as $v) {
  2053. $post['id'] = $v['id'];
  2054. $this->whlabel->save($post, $v['id']);
  2055. }
  2056. } else {
  2057. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2058. if ($data > 0) {
  2059. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2060. exit;
  2061. } else {
  2062. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2063. foreach ($data as $v) {
  2064. $post['id'] = $v['id'];
  2065. $this->whlabel->save($post, $v['id']);
  2066. }
  2067. }
  2068. }
  2069. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2070. exit;
  2071. }
  2072. $uid = $this->whlabel->read($arg_array[0]);
  2073. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2074. $this->data['enter'] = $uid;
  2075. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2076. $this->data['wlshop'] = $wlshop;
  2077. $this->_Template('whlabel_enteredit', $this->data);
  2078. }
  2079. //入库浏览
  2080. public function _enter()
  2081. {
  2082. $post = $this->input->post(NULL, TRUE);
  2083. if (isset($post['s'])) {
  2084. $id_arr = $this->input->post('s');
  2085. $id_arr = explode(',', $id_arr);
  2086. if (!$id_arr) {
  2087. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2088. exit;
  2089. }
  2090. //循环删除记录
  2091. foreach ($id_arr as $v) {
  2092. $sid = $this->whlabel->read($v);
  2093. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2094. if ($count > 0) {
  2095. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2096. exit;
  2097. }
  2098. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2099. foreach ($info_list as $va) {
  2100. $this->whlabel->remove($va['id']);
  2101. }
  2102. }
  2103. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2104. exit;
  2105. }
  2106. $sp = array();
  2107. $s = $this->shop->find_all('1=1', 'id,shopname');
  2108. foreach ($s as $v) {
  2109. $sp[$v['id']] = $v['shopname'];
  2110. }
  2111. $wh = array();
  2112. $w = $this->warehouse->find_all('1=1', 'id,title');
  2113. foreach ($w as $v) {
  2114. $wh[$v['id']] = $v['title'];
  2115. }
  2116. if (isset($post['page'])) {
  2117. $page = $this->input->post('page', true);
  2118. $perpage = $this->input->post('perpage', true);
  2119. $category = $this->input->post('category', true);
  2120. $size = $this->input->post('size', true);
  2121. $grade = $this->input->post('grade', true);
  2122. $color = $this->input->post('color', true);
  2123. $lowe = $this->input->post('lowe', true);
  2124. $sku = $this->input->post('sku', true);
  2125. $warehouse = $this->input->post('warehouse', true);
  2126. $purchase = $this->input->post('purchase', true);
  2127. $ktime = $this->input->post('ktime', true);
  2128. $jtime = $this->input->post('jtime', true);
  2129. $ktime = strtotime($ktime);
  2130. $jtime = strtotime($jtime);
  2131. $where = "1=1";
  2132. $gj = "";
  2133. $ck = "";
  2134. if ($category) {
  2135. $where .= " and features like '%-$category-%'";
  2136. }
  2137. if ($size) {
  2138. $where .= " and features like '%-$size-%'";
  2139. }
  2140. if ($grade) {
  2141. $where .= " and features like '%-$grade-%'";
  2142. }
  2143. if ($color) {
  2144. $where .= " and features like '%-$color-%'";
  2145. }
  2146. if ($lowe) {
  2147. $where .= " and features like '%-$lowe-%'";
  2148. }
  2149. if ($warehouse) {
  2150. $where .= " and warehouse = '$warehouse'";
  2151. }
  2152. if ($purchase) {
  2153. $where .= " and purchase = '$purchase'";
  2154. }
  2155. if ($sku) {
  2156. $where .= " and sku like '%$sku%'";
  2157. }
  2158. if ($ktime && $jtime) {
  2159. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2160. }
  2161. //数据排序
  2162. $order_str = "enter desc";
  2163. if (empty($page)) {
  2164. $start = 0;
  2165. $perpage = 1;
  2166. } else {
  2167. $start = ($page - 1) * $perpage;
  2168. }
  2169. //取得信息列表
  2170. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2171. foreach ($info_list as $k => $v) {
  2172. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2173. if ($v['shop'] == '') {
  2174. $s = '通用';
  2175. } else {
  2176. $info_list[$k]['shop'] = '';
  2177. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2178. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2179. }
  2180. }
  2181. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2182. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2183. $info_list[$k]['g'] = $g;
  2184. }
  2185. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2186. $total = count($this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,sku,title,features,number'));
  2187. $pagenum = ceil($total / $perpage);
  2188. $over = $total - ($start + $perpage);
  2189. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2190. echo json_encode($rows);
  2191. exit;
  2192. }
  2193. $this->_Template('whlabel_enter', $this->data);
  2194. }
  2195. //出库浏览
  2196. public function _out()
  2197. {
  2198. $post = $this->input->post(NULL, TRUE);
  2199. if (isset($post['page'])) {
  2200. $page = $this->input->post('page', true);
  2201. $perpage = $this->input->post('perpage', true);
  2202. $category = $this->input->post('category', true);
  2203. $size = $this->input->post('size', true);
  2204. $grade = $this->input->post('grade', true);
  2205. $color = $this->input->post('color', true);
  2206. $lowe = $this->input->post('lowe', true);
  2207. $sku = $this->input->post('sku', true);
  2208. $warehouse = $this->input->post('warehouse', true);
  2209. $purchase = $this->input->post('purchase', true);
  2210. $state = $this->input->post('state', true);
  2211. $ktime = $this->input->post('ktime', true);
  2212. $jtime = $this->input->post('jtime', true);
  2213. $ktime = strtotime($ktime);
  2214. $jtime = strtotime($jtime);
  2215. $where = "state=3";
  2216. $gj = "";
  2217. $ck = "";
  2218. if ($category) {
  2219. $where .= " and features like '%-$category-%'";
  2220. }
  2221. if ($size) {
  2222. $where .= " and features like '%-$size-%'";
  2223. }
  2224. if ($grade) {
  2225. $where .= " and features like '%-$grade-%'";
  2226. }
  2227. if ($color) {
  2228. $where .= " and features like '%-$color-%'";
  2229. }
  2230. if ($lowe) {
  2231. $where .= " and features like '%-$lowe-%'";
  2232. }
  2233. if ($state) {
  2234. $where .= " and state = '$state'";
  2235. }
  2236. if ($warehouse) {
  2237. $where .= " and warehouse = '$warehouse'";
  2238. }
  2239. if ($purchase) {
  2240. $where .= " and purchase = '$purchase'";
  2241. }
  2242. if ($sku) {
  2243. $where .= " and sku = '$sku'";
  2244. }
  2245. if ($ktime && $jtime) {
  2246. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2247. }
  2248. //数据排序
  2249. $order_str = "id desc";
  2250. if (empty($page)) {
  2251. $start = 0;
  2252. $perpage = 1;
  2253. } else {
  2254. $start = ($page - 1) * $perpage;
  2255. }
  2256. //取得信息列表
  2257. $info_list = $this->whlabel->find_all($where, 'sku');
  2258. $rows = array();
  2259. $list = array();
  2260. foreach ($info_list as $key => $value) {
  2261. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2262. }
  2263. $rows = array_unique($rows); //删除重复记录
  2264. foreach ($rows as $key => $value) {
  2265. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2266. $ck = $this->warehouse->read($data['warehouse']);
  2267. $warehouse = $ck['title'];
  2268. $gy = $this->purchase->read($data['purchase']);
  2269. $purchase = $gy['purchase'];
  2270. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2271. $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);
  2272. }
  2273. $total = count($list);
  2274. $pagenum = ceil($total / $perpage);
  2275. $over = $total - ($start + $perpage);
  2276. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2277. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2278. echo json_encode($rows);
  2279. exit;
  2280. }
  2281. $this->_Template('whlabel_out', $this->data);
  2282. }
  2283. //出库标签浏览
  2284. public function _label()
  2285. {
  2286. $post = $this->input->post(NULL, TRUE);
  2287. if (isset($post['page'])) {
  2288. $page = $this->input->post('page', true);
  2289. $perpage = $this->input->post('perpage', true);
  2290. $sku = $this->input->post('sku', true);
  2291. $warehouse = $this->input->post('warehouse', true);
  2292. $purchase = $this->input->post('purchase', true);
  2293. $orderinfo = $this->input->post('orderinfo', true);
  2294. $waybill = $this->input->post('waybill', true);
  2295. $category = $this->input->post('category', true);
  2296. $size = $this->input->post('size', true);
  2297. $grade = $this->input->post('grade', true);
  2298. $color = $this->input->post('color', true);
  2299. $lowe = $this->input->post('lowe', true);
  2300. $where = "state=1";
  2301. if ($sku) {
  2302. $where .= " and sku = '$sku'";
  2303. }
  2304. if ($warehouse) {
  2305. $where .= " and warehouse = '$warehouse'";
  2306. }
  2307. if ($purchase) {
  2308. $where .= " and purchase = '$purchase'";
  2309. }
  2310. if ($orderinfo) {
  2311. $where .= " and orderinfo = '$orderinfo'";
  2312. }
  2313. if ($waybill) {
  2314. $where .= " and waybill = '$waybill'";
  2315. }
  2316. if ($category) {
  2317. $where .= " and features like '%-$category-%'";
  2318. }
  2319. if ($size) {
  2320. $where .= " and features like '%-$size-%'";
  2321. }
  2322. if ($grade) {
  2323. $where .= " and features like '%-$grade-%'";
  2324. }
  2325. if ($color) {
  2326. $where .= " and features like '%-$color-%'";
  2327. }
  2328. if ($lowe) {
  2329. $where .= " and features like '%-$lowe-%'";
  2330. }
  2331. //数据排序
  2332. $order_str = "outk desc";
  2333. if (empty($page)) {
  2334. $start = 0;
  2335. $perpage = 1;
  2336. } else {
  2337. $start = ($page - 1) * $perpage;
  2338. }
  2339. //取得信息列表
  2340. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2341. foreach ($info_list as $key => $value) {
  2342. $warehouse = $this->warehouse->read($value['warehouse']);
  2343. $info_list[$key]['warehouse'] = $warehouse['title'];
  2344. $purchase = $this->purchase->read($value['purchase']);
  2345. $info_list[$key]['purchase'] = $purchase['title'];
  2346. if ($value['outk'] != 0) {
  2347. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2348. } else {
  2349. $info_list[$key]['outk'] = "";
  2350. }
  2351. if ($value['orderinfo'] == 0) {
  2352. $info_list[$key]['orderinfo'] = "";
  2353. }
  2354. if ($value['waybill'] == 0) {
  2355. $info_list[$key]['waybill'] = "";
  2356. }
  2357. }
  2358. $total = $this->whlabel->find_count($where);
  2359. $pagenum = ceil($total / $perpage);
  2360. $over = $total - ($start + $perpage);
  2361. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2362. echo json_encode($rows);
  2363. exit;
  2364. }
  2365. $this->_Template('whlabel_label', $this->data);
  2366. }
  2367. //独立站出库订单
  2368. public function _outorder()
  2369. {
  2370. if (isset($_SESSION['api'])) {
  2371. $user = $this->user->get_api($_SESSION['api']);
  2372. $usp = $user;
  2373. $fgshop = "";
  2374. $sid = "";
  2375. $user = explode('|', trim($user['shop'], '|'));
  2376. foreach ($user as $value) {
  2377. $fgshop .= " shop = " . $value . " or";
  2378. $sid .= " id = " . $value . " or";
  2379. }
  2380. } else {
  2381. echo "请重新登录";
  2382. }
  2383. $post = $this->input->post(NULL, TRUE);
  2384. if (isset($post['page'])) {
  2385. $page = $this->input->post('page', true);
  2386. $perpage = $this->input->post('perpage', true);
  2387. $warehouse = $this->input->post('warehouse', true);
  2388. $xztime = $this->input->post('xztime', true);
  2389. $timetk = $this->input->post('timetkk', true);
  2390. $timetj = $this->input->post('timetjj', true);
  2391. $shop = $this->input->post('shop', true);
  2392. $source = $this->input->post('source', true);
  2393. $orderinfo = $this->input->post('orderinfo', true);
  2394. $number = $this->input->post('number', true);
  2395. $sfxh = $this->input->post('sfxh', true);
  2396. $express = $this->input->post('express', true);
  2397. $waybill = $this->input->post('waybill', true);
  2398. $library = $this->input->post('library', true);
  2399. $country = $this->input->post('country', true);
  2400. $so = $this->input->post('so', true);
  2401. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2402. $print = $this->input->post('print', true);
  2403. $state = $this->input->post('state', true);
  2404. $orderurl = $this->input->post('orderurl', true);
  2405. $timetk = strtotime($timetk);
  2406. $timetj = strtotime($timetj);
  2407. /**
  2408. $sj = $this->input->post('sj',true);
  2409. if($sj)
  2410. {
  2411. $sj = $this->input->post('sj',true);
  2412. }
  2413. else
  2414. {
  2415. $sj = "fullorder";
  2416. }
  2417. **/
  2418. $sj = "fullorder";
  2419. $where = "1=1";
  2420. if ($warehouse) {
  2421. $where .= " and type = '$warehouse'";
  2422. }
  2423. if ($timetk && $timetj) {
  2424. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2425. }
  2426. if ($orderinfo) {
  2427. $where .= " and orderinfo = '$orderinfo'";
  2428. }
  2429. if ($number) {
  2430. $where .= " and number = '$number'";
  2431. }
  2432. if ($express) {
  2433. $where .= " and express = '$express'";
  2434. }
  2435. if ($waybill) {
  2436. $where .= " and waybill = '$waybill'";
  2437. }
  2438. if ($library) {
  2439. $where .= " and library = '$library'";
  2440. }
  2441. if ($print) {
  2442. $where .= " and print = '$print'";
  2443. }
  2444. if ($libraryconfirm) {
  2445. $where .= " and libraryconfirm = '$libraryconfirm'";
  2446. }
  2447. if ($state) {
  2448. $where .= " and state = '$state'";
  2449. }
  2450. if ($shop) {
  2451. $where .= " and shop = '$shop'";
  2452. }
  2453. if ($country) {
  2454. $where .= " and country = '$country'";
  2455. }
  2456. if ($sfxh != '') {
  2457. $where .= " and sfxh = '$sfxh'";
  2458. }
  2459. if ($so) {
  2460. $where .= " and shipremarks like '%$so%'";
  2461. }
  2462. if ($source) {
  2463. if ($source == '2d') {
  2464. $where .= " and source >= '2'";
  2465. } else {
  2466. $where .= " and source = '$source'";
  2467. }
  2468. }
  2469. if (isset($_SESSION['api'])) {
  2470. foreach ($user as $value) {
  2471. $fgshop .= " shop = " . $value . " or";
  2472. }
  2473. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2474. }
  2475. if ($orderurl) {
  2476. $url = $this->orderurl->read($orderurl);
  2477. $where .= " and link like '%" . $url['url'] . "%'";
  2478. }
  2479. //数据排序
  2480. $order_str = "librarytime desc";
  2481. if (empty($page)) {
  2482. $start = 0;
  2483. $perpage = 1;
  2484. } else {
  2485. $start = ($page - 1) * $perpage;
  2486. }
  2487. //取得信息列表
  2488. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2489. //格式化数据
  2490. foreach ($info_list as $key => $value) {
  2491. $shop = $this->shop->read($value['shop']);
  2492. $info_list[$key]['shop'] = $shop['shopname'];
  2493. $express = $this->express->read($value['express']);
  2494. $info_list[$key]['express'] = $express['servicename'];
  2495. $warehouse = $this->warehouse->read($value['type']);
  2496. $info_list[$key]['type'] = $warehouse['title'];
  2497. if ($value['librarytime'] == '0') {
  2498. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2499. } else {
  2500. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2501. }
  2502. }
  2503. $total = $this->$sj->find_count($where);
  2504. $pagenum = ceil($total / $perpage);
  2505. $over = $total - ($start + $perpage);
  2506. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2507. echo json_encode($rows);
  2508. exit;
  2509. }
  2510. $this->data['express'] = $this->express->find_all();
  2511. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2512. $this->data['wlshop'] = $wlshop;
  2513. $user = $this->user->get_api($_SESSION['api']);
  2514. $powerid = $this->power->read($user['power']);
  2515. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2516. $pid = '';
  2517. foreach ($powertext as $v) {
  2518. $pid .= " id = " . $v . " or";
  2519. }
  2520. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2521. $this->data['fullorderexcel'] = $fullorderexcel;
  2522. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2523. $this->data['orderurl'] = $orderurl;
  2524. $this->_Template('whlabel_outorder', $this->data);
  2525. }
  2526. //tt出库
  2527. public function _toutorder()
  2528. {
  2529. if (isset($_SESSION['api'])) {
  2530. $user = $this->user->get_api($_SESSION['api']);
  2531. $usp = $user;
  2532. $fgshop = "";
  2533. $sid = "";
  2534. $user = explode('|', trim($user['shop'], '|'));
  2535. foreach ($user as $value) {
  2536. $fgshop .= " shop = " . $value . " or";
  2537. $sid .= " id = " . $value . " or";
  2538. }
  2539. } else {
  2540. echo "请重新登录";
  2541. }
  2542. $post = $this->input->post(NULL, TRUE);
  2543. if (isset($post['page'])) {
  2544. $page = $this->input->post('page', true);
  2545. $perpage = $this->input->post('perpage', true);
  2546. $warehouse = $this->input->post('warehouse', true);
  2547. $xztime = $this->input->post('xztime', true);
  2548. $timetk = $this->input->post('timetkk', true);
  2549. $timetj = $this->input->post('timetjj', true);
  2550. $shop = $this->input->post('shop', true);
  2551. $source = $this->input->post('source', true);
  2552. $orderinfo = $this->input->post('orderinfo', true);
  2553. $number = $this->input->post('number', true);
  2554. $sfxh = $this->input->post('sfxh', true);
  2555. $express = $this->input->post('express', true);
  2556. $waybill = $this->input->post('waybill', true);
  2557. $library = $this->input->post('library', true);
  2558. $country = $this->input->post('country', true);
  2559. $so = $this->input->post('so', true);
  2560. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2561. $print = $this->input->post('print', true);
  2562. $state = $this->input->post('state', true);
  2563. $orderurl = $this->input->post('orderurl', true);
  2564. $timetk = strtotime($timetk);
  2565. $timetj = strtotime($timetj);
  2566. /**
  2567. $sj = $this->input->post('sj',true);
  2568. if($sj)
  2569. {
  2570. $sj = $this->input->post('sj',true);
  2571. }
  2572. else
  2573. {
  2574. $sj = "fullorder";
  2575. }
  2576. **/
  2577. $sj = "fullordertt";
  2578. $where = "1=1";
  2579. if ($warehouse) {
  2580. $where .= " and type = '$warehouse'";
  2581. }
  2582. if ($timetk && $timetj) {
  2583. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2584. }
  2585. if ($orderinfo) {
  2586. $where .= " and orderinfo = '$orderinfo'";
  2587. }
  2588. if ($number) {
  2589. $where .= " and number = '$number'";
  2590. }
  2591. if ($express) {
  2592. $where .= " and express = '$express'";
  2593. }
  2594. if ($waybill) {
  2595. $where .= " and waybill = '$waybill'";
  2596. }
  2597. if ($library) {
  2598. $where .= " and library = '$library'";
  2599. }
  2600. if ($print) {
  2601. $where .= " and print = '$print'";
  2602. }
  2603. if ($libraryconfirm) {
  2604. $where .= " and libraryconfirm = '$libraryconfirm'";
  2605. }
  2606. if ($state) {
  2607. $where .= " and state = '$state'";
  2608. }
  2609. if ($shop) {
  2610. $where .= " and shop = '$shop'";
  2611. }
  2612. if ($country) {
  2613. $where .= " and country = '$country'";
  2614. }
  2615. if ($sfxh != '') {
  2616. $where .= " and sfxh = '$sfxh'";
  2617. }
  2618. if ($so) {
  2619. $where .= " and shipremarks like '%$so%'";
  2620. }
  2621. if ($source) {
  2622. if ($source == '2d') {
  2623. $where .= " and source >= '2'";
  2624. } else {
  2625. $where .= " and source = '$source'";
  2626. }
  2627. }
  2628. if (isset($_SESSION['api'])) {
  2629. foreach ($user as $value) {
  2630. $fgshop .= " shop = " . $value . " or";
  2631. }
  2632. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2633. }
  2634. if ($orderurl) {
  2635. $url = $this->orderurl->read($orderurl);
  2636. $where .= " and link like '%" . $url['url'] . "%'";
  2637. }
  2638. //数据排序
  2639. $order_str = "librarytime desc";
  2640. if (empty($page)) {
  2641. $start = 0;
  2642. $perpage = 1;
  2643. } else {
  2644. $start = ($page - 1) * $perpage;
  2645. }
  2646. //取得信息列表
  2647. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2648. //格式化数据
  2649. foreach ($info_list as $key => $value) {
  2650. $shop = $this->shop->read($value['shop']);
  2651. $info_list[$key]['shop'] = $shop['shopname'];
  2652. $express = $this->express->read($value['express']);
  2653. $info_list[$key]['express'] = $express['servicename'];
  2654. $warehouse = $this->warehouse->read($value['type']);
  2655. $info_list[$key]['type'] = $warehouse['title'];
  2656. if ($value['librarytime'] == '0') {
  2657. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2658. } else {
  2659. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2660. }
  2661. }
  2662. $total = $this->$sj->find_count($where);
  2663. $pagenum = ceil($total / $perpage);
  2664. $over = $total - ($start + $perpage);
  2665. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2666. echo json_encode($rows);
  2667. exit;
  2668. }
  2669. $this->data['express'] = $this->express->find_all();
  2670. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2671. $this->data['wlshop'] = $wlshop;
  2672. $user = $this->user->get_api($_SESSION['api']);
  2673. $powerid = $this->power->read($user['power']);
  2674. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2675. $pid = '';
  2676. foreach ($powertext as $v) {
  2677. $pid .= " id = " . $v . " or";
  2678. }
  2679. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2680. $this->data['fullorderexcel'] = $fullorderexcel;
  2681. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2682. $this->data['orderurl'] = $orderurl;
  2683. $this->_Template('whlabel_toutorder', $this->data);
  2684. }
  2685. //tt出库
  2686. public function _aoutorder()
  2687. {
  2688. if (isset($_SESSION['api'])) {
  2689. $user = $this->user->get_api($_SESSION['api']);
  2690. $usp = $user;
  2691. $fgshop = "";
  2692. $sid = "";
  2693. $user = explode('|', trim($user['shop'], '|'));
  2694. foreach ($user as $value) {
  2695. $fgshop .= " shop = " . $value . " or";
  2696. $sid .= " id = " . $value . " or";
  2697. }
  2698. } else {
  2699. echo "请重新登录";
  2700. }
  2701. $post = $this->input->post(NULL, TRUE);
  2702. if (isset($post['page'])) {
  2703. $page = $this->input->post('page', true);
  2704. $perpage = $this->input->post('perpage', true);
  2705. $warehouse = $this->input->post('warehouse', true);
  2706. $xztime = $this->input->post('xztime', true);
  2707. $timetk = $this->input->post('timetkk', true);
  2708. $timetj = $this->input->post('timetjj', true);
  2709. $shop = $this->input->post('shop', true);
  2710. $source = $this->input->post('source', true);
  2711. $orderinfo = $this->input->post('orderinfo', true);
  2712. $number = $this->input->post('number', true);
  2713. $sfxh = $this->input->post('sfxh', true);
  2714. $express = $this->input->post('express', true);
  2715. $waybill = $this->input->post('waybill', true);
  2716. $library = $this->input->post('library', true);
  2717. $country = $this->input->post('country', true);
  2718. $so = $this->input->post('so', true);
  2719. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2720. $print = $this->input->post('print', true);
  2721. $state = $this->input->post('state', true);
  2722. $orderurl = $this->input->post('orderurl', true);
  2723. $timetk = strtotime($timetk);
  2724. $timetj = strtotime($timetj);
  2725. /**
  2726. $sj = $this->input->post('sj',true);
  2727. if($sj)
  2728. {
  2729. $sj = $this->input->post('sj',true);
  2730. }
  2731. else
  2732. {
  2733. $sj = "fullorder";
  2734. }
  2735. **/
  2736. $sj = "fullorderamz";
  2737. $where = "1=1";
  2738. if ($warehouse) {
  2739. $where .= " and type = '$warehouse'";
  2740. }
  2741. if ($timetk && $timetj) {
  2742. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2743. }
  2744. if ($orderinfo) {
  2745. $where .= " and orderinfo = '$orderinfo'";
  2746. }
  2747. if ($number) {
  2748. $where .= " and number = '$number'";
  2749. }
  2750. if ($express) {
  2751. $where .= " and express = '$express'";
  2752. }
  2753. if ($waybill) {
  2754. $where .= " and waybill = '$waybill'";
  2755. }
  2756. if ($library) {
  2757. $where .= " and library = '$library'";
  2758. }
  2759. if ($print) {
  2760. $where .= " and print = '$print'";
  2761. }
  2762. if ($libraryconfirm) {
  2763. $where .= " and libraryconfirm = '$libraryconfirm'";
  2764. }
  2765. if ($state) {
  2766. $where .= " and state = '$state'";
  2767. }
  2768. if ($shop) {
  2769. $where .= " and shop = '$shop'";
  2770. }
  2771. if ($country) {
  2772. $where .= " and country = '$country'";
  2773. }
  2774. if ($sfxh != '') {
  2775. $where .= " and sfxh = '$sfxh'";
  2776. }
  2777. if ($so) {
  2778. $where .= " and shipremarks like '%$so%'";
  2779. }
  2780. if ($source) {
  2781. if ($source == '2d') {
  2782. $where .= " and source >= '2'";
  2783. } else {
  2784. $where .= " and source = '$source'";
  2785. }
  2786. }
  2787. if (isset($_SESSION['api'])) {
  2788. foreach ($user as $value) {
  2789. $fgshop .= " shop = " . $value . " or";
  2790. }
  2791. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2792. }
  2793. if ($orderurl) {
  2794. $url = $this->orderurl->read($orderurl);
  2795. $where .= " and link like '%" . $url['url'] . "%'";
  2796. }
  2797. //数据排序
  2798. $order_str = "librarytime desc";
  2799. if (empty($page)) {
  2800. $start = 0;
  2801. $perpage = 1;
  2802. } else {
  2803. $start = ($page - 1) * $perpage;
  2804. }
  2805. //取得信息列表
  2806. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2807. //格式化数据
  2808. foreach ($info_list as $key => $value) {
  2809. $shop = $this->shop->read($value['shop']);
  2810. $info_list[$key]['shop'] = $shop['shopname'];
  2811. $express = $this->express->read($value['express']);
  2812. $info_list[$key]['express'] = $express['servicename'];
  2813. $warehouse = $this->warehouse->read($value['type']);
  2814. $info_list[$key]['type'] = $warehouse['title'];
  2815. if ($value['librarytime'] == '0') {
  2816. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2817. } else {
  2818. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2819. }
  2820. }
  2821. $total = $this->$sj->find_count($where);
  2822. $pagenum = ceil($total / $perpage);
  2823. $over = $total - ($start + $perpage);
  2824. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2825. echo json_encode($rows);
  2826. exit;
  2827. }
  2828. $this->data['express'] = $this->express->find_all();
  2829. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2830. $this->data['wlshop'] = $wlshop;
  2831. $user = $this->user->get_api($_SESSION['api']);
  2832. $powerid = $this->power->read($user['power']);
  2833. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2834. $pid = '';
  2835. foreach ($powertext as $v) {
  2836. $pid .= " id = " . $v . " or";
  2837. }
  2838. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2839. $this->data['fullorderexcel'] = $fullorderexcel;
  2840. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2841. $this->data['orderurl'] = $orderurl;
  2842. $this->_Template('whlabel_aoutorder', $this->data);
  2843. }
  2844. //速卖通出库订单
  2845. public function _soutorder()
  2846. {
  2847. if (isset($_SESSION['api'])) {
  2848. $user = $this->user->get_api($_SESSION['api']);
  2849. $usp = $user;
  2850. $fgshop = "";
  2851. $sid = "";
  2852. $user = explode('|', trim($user['shop'], '|'));
  2853. foreach ($user as $value) {
  2854. $sid .= " id = " . $value . " or";
  2855. }
  2856. }
  2857. $post = $this->input->post(NULL, TRUE);
  2858. if (isset($post['page'])) {
  2859. $page = $this->input->post('page', true);
  2860. $perpage = $this->input->post('perpage', true);
  2861. $warehouse = $this->input->post('warehouse', true);
  2862. $xztime = $this->input->post('xztime', true);
  2863. $timetk = $this->input->post('timetkk', true);
  2864. $timetj = $this->input->post('timetjj', true);
  2865. $shop = $this->input->post('shop', true);
  2866. $source = $this->input->post('source', true);
  2867. $orderinfo = $this->input->post('orderinfo', true);
  2868. $number = $this->input->post('number', true);
  2869. $express = $this->input->post('express', true);
  2870. $waybill = $this->input->post('waybill', true);
  2871. $library = $this->input->post('library', true);
  2872. $country = $this->input->post('country', true);
  2873. $sfxh = $this->input->post('sfxh', true);
  2874. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2875. $print = $this->input->post('print', true);
  2876. $state = $this->input->post('state', true);
  2877. $so = $this->input->post('so', true);
  2878. $timetk = strtotime($timetk);
  2879. $timetj = strtotime($timetj);
  2880. /**
  2881. $sj = $this->input->post('sj',true);
  2882. if($sj)
  2883. {
  2884. $sj = $this->input->post('sj',true);
  2885. }
  2886. else
  2887. {
  2888. $sj = "fullorder";
  2889. }
  2890. **/
  2891. $sj = "fullordersmt";
  2892. $where = "1=1";
  2893. if ($warehouse) {
  2894. $where .= " and type = '$warehouse'";
  2895. }
  2896. if ($timetk && $timetj) {
  2897. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2898. }
  2899. if ($orderinfo) {
  2900. $where .= " and orderinfo = '$orderinfo'";
  2901. }
  2902. if ($number) {
  2903. $where .= " and number = '$number'";
  2904. }
  2905. if ($express) {
  2906. $where .= " and express = '$express'";
  2907. }
  2908. if ($waybill) {
  2909. $where .= " and waybill = '$waybill'";
  2910. }
  2911. if ($library) {
  2912. $where .= " and library = '$library'";
  2913. }
  2914. if ($print) {
  2915. $where .= " and print = '$print'";
  2916. }
  2917. if ($libraryconfirm) {
  2918. $where .= " and libraryconfirm = '$libraryconfirm'";
  2919. }
  2920. if ($state) {
  2921. $where .= " and state = '$state'";
  2922. }
  2923. if ($shop) {
  2924. $where .= " and shop = '$shop'";
  2925. }
  2926. if ($sfxh != '') {
  2927. $where .= " and sfxh = '$sfxh'";
  2928. }
  2929. if ($so) {
  2930. $where .= " and shipremarks like '%$so%'";
  2931. }
  2932. if ($source) {
  2933. $where .= " and source = '$source'";
  2934. }
  2935. if ($country) {
  2936. $where .= " and country = '$country'";
  2937. } else {
  2938. if (isset($_SESSION['api'])) {
  2939. foreach ($user as $value) {
  2940. $fgshop .= " shop = " . $value . " or";
  2941. }
  2942. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2943. }
  2944. }
  2945. //数据排序
  2946. $order_str = "librarytime desc";
  2947. if (empty($page)) {
  2948. $start = 0;
  2949. $perpage = 1;
  2950. } else {
  2951. $start = ($page - 1) * $perpage;
  2952. }
  2953. //取得信息列表
  2954. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2955. //格式化数据
  2956. foreach ($info_list as $key => $value) {
  2957. $shop = $this->shop->read($value['shop']);
  2958. $info_list[$key]['shop'] = $shop['shopname'];
  2959. $express = $this->express->read($value['express']);
  2960. $info_list[$key]['express'] = $express['servicename'];
  2961. $warehouse = $this->warehouse->read($value['type']);
  2962. $info_list[$key]['type'] = $warehouse['title'];
  2963. if ($value['librarytime'] == '0') {
  2964. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2965. } else {
  2966. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2967. }
  2968. }
  2969. $total = $this->$sj->find_count($where);
  2970. $pagenum = ceil($total / $perpage);
  2971. $over = $total - ($start + $perpage);
  2972. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2973. echo json_encode($rows);
  2974. exit;
  2975. }
  2976. $this->data['express'] = $this->express->find_all();
  2977. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2978. $this->data['wlshop'] = $wlshop;
  2979. $user = $this->user->get_api($_SESSION['api']);
  2980. $powerid = $this->power->read($user['power']);
  2981. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2982. $pid = '';
  2983. foreach ($powertext as $v) {
  2984. $pid .= " id = " . $v . " or";
  2985. }
  2986. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2987. $this->data['fullorderexcel'] = $fullorderexcel;
  2988. $this->_Template('whlabel_soutorder', $this->data);
  2989. }
  2990. //订单退库
  2991. public function _retreat()
  2992. {
  2993. $post = $this->input->post(NULL, TRUE);
  2994. if (isset($post['page'])) {
  2995. $page = $this->input->post('page', true);
  2996. $perpage = $this->input->post('perpage', true);
  2997. $warehouse = $this->input->post('warehouse', true);
  2998. $timetk = $this->input->post('timetk', true);
  2999. $timetj = $this->input->post('timetj', true);
  3000. $shop = $this->input->post('shop', true);
  3001. $source = $this->input->post('source', true);
  3002. $state = $this->input->post('state', true);
  3003. $review = $this->input->post('review', true);
  3004. $state = $this->input->post('state', true);
  3005. $express = $this->input->post('express', true);
  3006. $orderinfo = $this->input->post('orderinfo', true);
  3007. $user = $this->input->post('user', true);
  3008. $name = $this->input->post('name', true);
  3009. $waybill = $this->input->post('waybill', true);
  3010. $timetk = strtotime($timetk);
  3011. $timetj = strtotime($timetj);
  3012. $where = "(state=206 or state=210) and mergeid = 0";
  3013. if ($warehouse) {
  3014. $where .= " and state = '$warehouse'";
  3015. }
  3016. if ($timetk && $timetj) {
  3017. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3018. }
  3019. if ($shop) {
  3020. $where .= " and shop = '$shop'";
  3021. }
  3022. if ($source) {
  3023. $where .= " and source = '$source'";
  3024. }
  3025. if ($state) {
  3026. $where .= " and state = '$state'";
  3027. }
  3028. if ($review) {
  3029. $where .= " and review = '$review'";
  3030. }
  3031. if ($state) {
  3032. $where .= " and state = '$state'";
  3033. }
  3034. if ($express) {
  3035. $where .= " and express = '$express'";
  3036. }
  3037. if ($orderinfo) {
  3038. $where .= " and orderinfo = '$orderinfo'";
  3039. }
  3040. if ($user) {
  3041. $where .= " and user = '$user'";
  3042. }
  3043. if ($name) {
  3044. $where .= " and name = '$name'";
  3045. }
  3046. if ($waybill) {
  3047. $where .= " and waybill = '$waybill'";
  3048. }
  3049. //数据排序
  3050. $order_str = "id desc";
  3051. if (empty($page)) {
  3052. $start = 0;
  3053. $perpage = 1;
  3054. } else {
  3055. $start = ($page - 1) * $perpage;
  3056. }
  3057. //取得信息列表
  3058. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3059. //格式化数据
  3060. foreach ($info_list as $key => $value) {
  3061. $shop = $this->shop->read($value['shop']);
  3062. $info_list[$key]['shop'] = $shop['shopname'];
  3063. $warehouse = $this->warehouse->read($value['warehouse']);
  3064. $info_list[$key]['warehouse'] = $warehouse['title'];
  3065. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3066. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3067. if ($value['waybill'] == 0) {
  3068. $info_list[$key]['waybill'] = "";
  3069. }
  3070. $express = $this->express->read($value['express']);
  3071. $info_list[$key]['express'] = $express['title'];
  3072. $typeclass = $this->typeclass->read($value['state']);
  3073. $info_list[$key]['state'] = $typeclass['title'];
  3074. }
  3075. $total = $this->fullorder->find_count($where);
  3076. $pagenum = ceil($total / $perpage);
  3077. $over = $total - ($start + $perpage);
  3078. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3079. echo json_encode($rows);
  3080. exit;
  3081. }
  3082. $this->data['express'] = $this->express->find_all();
  3083. $this->_Template('whlabel_retreat', $this->data);
  3084. }
  3085. //退库标签浏览
  3086. public function _retreatlk()
  3087. {
  3088. $post = $this->input->post(NULL, TRUE);
  3089. if (isset($post['page'])) {
  3090. $page = $this->input->post('page', true);
  3091. $perpage = $this->input->post('perpage', true);
  3092. $timetk = $this->input->post('timetk', true);
  3093. $timetj = $this->input->post('timetj', true);
  3094. $sku = $this->input->post('sku', true);
  3095. $warehouse = $this->input->post('warehouse', true);
  3096. $purchase = $this->input->post('purchase', true);
  3097. $orderinfo = $this->input->post('orderinfo', true);
  3098. $waybill = $this->input->post('waybill', true);
  3099. $category = $this->input->post('category', true);
  3100. $size = $this->input->post('size', true);
  3101. $grade = $this->input->post('grade', true);
  3102. $color = $this->input->post('color', true);
  3103. $lowe = $this->input->post('lowe', true);
  3104. $state = $this->input->post('state', true);
  3105. $timetk = strtotime($timetk);
  3106. $timetj = strtotime($timetj);
  3107. $where = "state=2";
  3108. if ($timetk && $timetj) {
  3109. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3110. }
  3111. if ($sku) {
  3112. $where .= " and sku = '$sku'";
  3113. }
  3114. if ($warehouse) {
  3115. $where .= " and warehouse = '$warehouse'";
  3116. }
  3117. if ($purchase) {
  3118. $where .= " and purchase = '$purchase'";
  3119. }
  3120. if ($orderinfo) {
  3121. $where .= " and orderinfo = '$orderinfo'";
  3122. }
  3123. if ($waybill) {
  3124. $where .= " and waybill = '$waybill'";
  3125. }
  3126. if ($category) {
  3127. $where .= " and features like '%-$category-%'";
  3128. }
  3129. if ($size) {
  3130. $where .= " and features like '%-$size-%'";
  3131. }
  3132. if ($grade) {
  3133. $where .= " and features like '%-$grade-%'";
  3134. }
  3135. if ($color) {
  3136. $where .= " and features like '%-$color-%'";
  3137. }
  3138. if ($lowe) {
  3139. $where .= " and features like '%-$lowe-%'";
  3140. }
  3141. //数据排序
  3142. $order_str = "time desc";
  3143. if (empty($page)) {
  3144. $start = 0;
  3145. $perpage = 1;
  3146. } else {
  3147. $start = ($page - 1) * $perpage;
  3148. }
  3149. //取得信息列表
  3150. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3151. foreach ($info_list as $key => $value) {
  3152. $warehouse = $this->warehouse->read($value['warehouse']);
  3153. $info_list[$key]['warehouse'] = $warehouse['title'];
  3154. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3155. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3156. $purchase = $this->purchase->read($value['purchase']);
  3157. $info_list[$key]['purchase'] = $purchase['title'];
  3158. if ($value['outk'] != 0) {
  3159. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3160. } else {
  3161. $info_list[$key]['outk'] = "";
  3162. }
  3163. if ($value['retreat'] != 0) {
  3164. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3165. } else {
  3166. $info_list[$key]['retreat'] = "";
  3167. }
  3168. if ($value['orderinfo'] == 0) {
  3169. $info_list[$key]['orderinfo'] = "";
  3170. }
  3171. if ($value['waybill'] == 0) {
  3172. $info_list[$key]['waybill'] = "";
  3173. }
  3174. }
  3175. $total = $this->whlabel->find_count($where);
  3176. $pagenum = ceil($total / $perpage);
  3177. $over = $total - ($start + $perpage);
  3178. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3179. echo json_encode($rows);
  3180. exit;
  3181. }
  3182. $this->_Template('whlabel_retreatlk', $this->data);
  3183. }
  3184. //更换标签及浏览
  3185. public function _change()
  3186. {
  3187. $post = $this->input->post(NULL, TRUE);
  3188. if (isset($post['page'])) {
  3189. $page = $this->input->post('page', true);
  3190. $perpage = $this->input->post('perpage', true);
  3191. $timetk = $this->input->post('timetk', true);
  3192. $timetj = $this->input->post('timetj', true);
  3193. $label = $this->input->post('label', true);
  3194. $oldlabel = $this->input->post('oldlabel', true);
  3195. $timetk = strtotime($timetk);
  3196. $timetj = strtotime($timetj);
  3197. $where = "state=10 ";
  3198. if ($timetk && $timetj) {
  3199. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3200. }
  3201. if ($label) {
  3202. $where .= " and label = '$label'";
  3203. }
  3204. if ($oldlabel) {
  3205. $where .= " and oldlabel = '$oldlabel'";
  3206. }
  3207. //数据排序
  3208. $order_str = "time asc";
  3209. if (empty($page)) {
  3210. $start = 0;
  3211. $perpage = 1;
  3212. } else {
  3213. $start = ($page - 1) * $perpage;
  3214. }
  3215. //取得信息列表
  3216. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3217. foreach ($info_list as $key => $value) {
  3218. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3219. }
  3220. $total = $this->whlabel->find_count($where);
  3221. $pagenum = ceil($total / $perpage);
  3222. $over = $total - ($start + $perpage);
  3223. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3224. echo json_encode($rows);
  3225. exit;
  3226. }
  3227. $this->_Template('whlabel_change', $this->data);
  3228. }
  3229. //产品标签
  3230. public function _cpbqdc()
  3231. {
  3232. if (isset($_GET['excel'])) {
  3233. $where = "1=1";
  3234. //数据排序
  3235. $order_str = "id desc";
  3236. if (empty($page)) {
  3237. $start = 0;
  3238. $perpage = 1;
  3239. } else {
  3240. $start = ($page - 1) * $perpage;
  3241. }
  3242. $warehouse = $this->input->get('warehouse', true);
  3243. $state = $this->input->get('state', true);
  3244. $timetk = $this->input->get('timetkk', true);
  3245. $timetj = $this->input->get('timetjj', true);
  3246. $timetk = strtotime($timetk);
  3247. $timetj = strtotime($timetj);
  3248. if ($warehouse) {
  3249. $where .= " and warehouse = '$warehouse'";
  3250. }
  3251. if ($state || $state == 0) {
  3252. $where .= " and state = '$state'";
  3253. }
  3254. if ($timetk && $timetj) {
  3255. $where .= " and time > '$timetk' and time < '$timetj'";
  3256. }
  3257. //取得信息列表
  3258. $info_list = $this->whlabel->find_all($where, '*');
  3259. $rows = array();
  3260. $list = array();
  3261. foreach ($info_list as $key => $value) {
  3262. $rows[$value['time']] = $value; //所有数据sku
  3263. }
  3264. foreach ($rows as $value) {
  3265. $warehouse = $this->warehouse->read($value['warehouse']);
  3266. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3267. $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);
  3268. }
  3269. $title = "产品标签统计表";
  3270. $titlename = "<table border=1>
  3271. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3272. <tr align='center'>
  3273. <td>仓库</td>
  3274. <td>SKU</td>
  3275. <td>产品</td>
  3276. <td>入库时间</td>
  3277. <td>操作时间</td>
  3278. <td>备注</td>
  3279. <td>数量</td>
  3280. </tr>
  3281. </table>";
  3282. $filename = $title . ".xls";
  3283. $tail = "";
  3284. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3285. }
  3286. }
  3287. //进销存导出
  3288. public function _exceljxc()
  3289. {
  3290. $classid = $this->classid->sku();
  3291. $pm = $classid;
  3292. $typeclass = array();
  3293. $tc = $this->typeclass->find_all();
  3294. foreach ($tc as $v) {
  3295. $typeclass[$v['id']] = $v;
  3296. }
  3297. $prc = array();
  3298. $purchase = $this->purchase->find_all();
  3299. foreach ($purchase as $k => $v) {
  3300. $prc[$v['id']] = $v['title'];
  3301. }
  3302. if (isset($_GET['excel'])) {
  3303. $where = "sku != 'Preset'";
  3304. //数据排序
  3305. $order_str = "id desc";
  3306. if (empty($page)) {
  3307. $start = 0;
  3308. $perpage = 1;
  3309. } else {
  3310. $start = ($page - 1) * $perpage;
  3311. }
  3312. $category = $this->input->get('category', true);
  3313. $warehouse = $this->input->get('warehouse', true);
  3314. $excelid = $this->input->get('sid', true);
  3315. if ($category) {
  3316. $where .= " and features like '%-$category-%'";
  3317. }
  3318. if ($warehouse) {
  3319. $where .= " and warehouse = '$warehouse'";
  3320. }
  3321. $xzid = '';
  3322. if ($excelid) {
  3323. $excelid = explode(',', trim($excelid, ','));
  3324. foreach ($excelid as $key => $value) {
  3325. $xzid .= " id = " . $value . " or";
  3326. }
  3327. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3328. }
  3329. //取得信息列表
  3330. /**
  3331. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3332. $rows = array();$list = array();
  3333. foreach ($info_list as $key=>$value)
  3334. {
  3335. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3336. }
  3337. **/
  3338. $wt = array();
  3339. $whlabel_type = $this->whlabel_type->find_all();
  3340. foreach ($whlabel_type as $v) {
  3341. $wt[$v['id']] = $v['title'];
  3342. }
  3343. $wh = array();
  3344. $w = $this->warehouse->find_all('1=1', 'id,title');
  3345. foreach ($w as $v) {
  3346. $wh[$v['id']] = $v['title'];
  3347. }
  3348. $list = array();
  3349. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3350. foreach ($rows as $key => $value) {
  3351. if (isset($wt[$value['type']])) {
  3352. $rows[$key]['type'] = $wt[$value['type']];
  3353. } else {
  3354. $rows[$key]['type'] = '未设置';
  3355. }
  3356. $bm = '03';
  3357. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3358. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3359. $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');
  3360. $details = array();
  3361. $cpid = array();
  3362. $cpbz = array();
  3363. $c = 0;
  3364. $g = 0;
  3365. $x = 0;
  3366. $t = 0;
  3367. $s = 0;
  3368. $q = 0;
  3369. foreach ($sd as $k => $v) {
  3370. if ($v['state'] == 0) {
  3371. $c++;
  3372. if ($v['cpid'] != 0) {
  3373. $cpid[$v['cpid']] = $v['cpid'];
  3374. }
  3375. if ($v['cpbz'] != '') {
  3376. $cpbz[$v['cpbz']] = $v['cpbz'];
  3377. }
  3378. }
  3379. if ($v['state'] != 9) {
  3380. $g++;
  3381. }
  3382. if ($v['state'] == 1) {
  3383. $x++;
  3384. }
  3385. if ($v['state'] == 2) {
  3386. $t++;
  3387. }
  3388. if ($v['state'] == 8) {
  3389. $s++;
  3390. }
  3391. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3392. $q++;
  3393. }
  3394. $details[$v['details']] = $v['details'];
  3395. }
  3396. $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'] . '"');
  3397. $rows[$key]['details'] = implode("、", $details);
  3398. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3399. $number = $value['number'];
  3400. $ftime = time() - 15 * 24 * 3600;
  3401. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3402. $rows[$key]['number'] = $g;
  3403. $rows[$key]['c'] = $c;
  3404. $rows[$key]['x'] = $x;
  3405. $rows[$key]['t'] = $t;
  3406. $rows[$key]['s'] = $s;
  3407. $rows[$key]['q'] = $q;
  3408. $rows[$key]['z'] = $z;
  3409. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3410. $features = explode('-', trim($features, '-'));
  3411. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3412. // $pm = $classid;
  3413. // $jm = $classid;
  3414. // foreach($features as $k=>$v)
  3415. // {
  3416. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3417. // {
  3418. // if($typeclass[$v]['bm'] != '')
  3419. // {
  3420. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3421. // }
  3422. // }
  3423. // if($v != 0)
  3424. // {
  3425. // if(!isset($typeclass[$v]))
  3426. // {
  3427. // continue;
  3428. // }
  3429. // if(isset($pm[$typeclass[$v]['classid']]))
  3430. // {
  3431. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3432. // {
  3433. // $tz = explode('|',$typeclass[$v]['zh']);
  3434. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3435. // }
  3436. // else
  3437. // {
  3438. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3439. // }
  3440. // }
  3441. // if(isset($jm[$typeclass[$v]['classid']]))
  3442. // {
  3443. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3444. // }
  3445. // }
  3446. // }
  3447. // $jm = array_filter($jm);
  3448. // $rows[$key]['bs'] = implode("-",$jm);
  3449. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3450. // $zh = implode(" ",$pm);
  3451. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3452. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3453. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3454. // $rows[$key]['features'] = $zh;
  3455. }
  3456. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3457. $final_list = [];
  3458. foreach ($list as $k => $v) {
  3459. if (empty($v['sku'])) {
  3460. continue;
  3461. }
  3462. $final_list[] = [
  3463. "warehouse" => $v["warehouse"],
  3464. "purchase" => $v["purchase"],
  3465. "details" => $v["details"],
  3466. "cpid" => $v["cpid"],
  3467. "dbcontent" => $v["dbcontent"],
  3468. "sku" => $v["sku"],
  3469. "cs" => $v["bm"],
  3470. "bs" => $v["jm"],
  3471. "title" => $v["title"],
  3472. "features" => $v["pm"],
  3473. "cpbz" => $v["cpbz"],
  3474. "sm" => $v["sm"],
  3475. "type" => $v["type"],
  3476. "number" => $v["number"],
  3477. "c" => $v["c"],
  3478. "x" => $v["x"],
  3479. "t" => $v["t"],
  3480. "s" => $v["s"],
  3481. "q" => $v["q"],
  3482. "z" => $v["z"],
  3483. "weight" => $v['weight'],
  3484. ];
  3485. }
  3486. $title = "总进销存统计表";
  3487. $titlename = "<table border=1>
  3488. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3489. <tr align='center'>
  3490. <td>仓库</td>
  3491. <td>供应商</td>
  3492. <td>位置</td>
  3493. <td>库存编码</td>
  3494. <td>类目</td>
  3495. <td>SKU</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>删除数量</td>
  3508. <td>其它操作</td>
  3509. <td>占单数量</td>
  3510. <td>重量(g)</td>
  3511. </tr>
  3512. </table>";
  3513. $filename = $title . ".xls";
  3514. $tail = "";
  3515. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3516. }
  3517. }
  3518. //入库导出
  3519. public function _excelr()
  3520. {
  3521. if (isset($_GET['excel'])) {
  3522. $category = $this->input->get('category', true);
  3523. $size = $this->input->get('size', true);
  3524. $grade = $this->input->get('grade', true);
  3525. $color = $this->input->get('color', true);
  3526. $lowe = $this->input->get('lowe', true);
  3527. $sku = $this->input->get('sku', true);
  3528. $warehouse = $this->input->get('warehouse', true);
  3529. $purchase = $this->input->get('purchase', true);
  3530. $ktime = $this->input->get('ktime', true);
  3531. $jtime = $this->input->get('jtime', true);
  3532. $ktime = strtotime($ktime);
  3533. $jtime = strtotime($jtime);
  3534. $where = "1=1";
  3535. $gj = "";
  3536. $ck = "";
  3537. if ($category) {
  3538. $where .= " and features like '%-$category-%'";
  3539. }
  3540. if ($size) {
  3541. $where .= " and features like '%-$size-%'";
  3542. }
  3543. if ($grade) {
  3544. $where .= " and features like '%-$grade-%'";
  3545. }
  3546. if ($color) {
  3547. $where .= " and features like '%-$color-%'";
  3548. }
  3549. if ($lowe) {
  3550. $where .= " and features like '%-$lowe-%'";
  3551. }
  3552. if ($warehouse) {
  3553. $where .= " and warehouse = '$warehouse'";
  3554. }
  3555. if ($purchase) {
  3556. $where .= " and purchase = '$purchase'";
  3557. }
  3558. if ($sku) {
  3559. $where .= " and sku = '$sku'";
  3560. }
  3561. if ($ktime && $jtime) {
  3562. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3563. }
  3564. //数据排序
  3565. $order_str = "id desc";
  3566. if (empty($page)) {
  3567. $start = 0;
  3568. $perpage = 1;
  3569. } else {
  3570. $start = ($page - 1) * $perpage;
  3571. }
  3572. $list = array();
  3573. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3574. foreach ($rows as $value) {
  3575. $ck = $this->warehouse->read($value['warehouse']);
  3576. $warehouse = $ck['title'];
  3577. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3578. $retreatwarehouse = $tkck['title'];
  3579. $gy = $this->purchase->read($value['purchase']);
  3580. $purchase = $gy['title'];
  3581. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3582. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3583. }
  3584. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3585. $titlename = "<table border=1>
  3586. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3587. <tr align='center'>
  3588. <td>仓库</td>
  3589. <td>SKU</td>
  3590. <td>产品</td>
  3591. <td>时间</td>
  3592. <td>数量</td>
  3593. </tr>
  3594. </table>";
  3595. $filename = $title . ".xls";
  3596. $tail = "";
  3597. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3598. }
  3599. }
  3600. //出库、退库导出
  3601. public function _excelct()
  3602. {
  3603. $classid = $this->classid->sku();
  3604. $pm = $classid;
  3605. $typeclass = array();
  3606. $tc = $this->typeclass->find_all();
  3607. foreach ($tc as $v) {
  3608. $typeclass[$v['id']] = $v;
  3609. }
  3610. $prc = array();
  3611. $purchase = $this->purchase->find_all();
  3612. foreach ($purchase as $k => $v) {
  3613. $prc[$v['id']] = $v['title'];
  3614. }
  3615. if (isset($_GET['excel'])) {
  3616. $wh = array();
  3617. $w = $this->warehouse->find_all('1=1', 'id,title');
  3618. foreach ($w as $v) {
  3619. $wh[$v['id']] = $v['title'];
  3620. }
  3621. $type = $this->input->get('excel', true);
  3622. $category = $this->input->get('category', true);
  3623. $size = $this->input->get('size', true);
  3624. $grade = $this->input->get('grade', true);
  3625. $color = $this->input->get('color', true);
  3626. $lowe = $this->input->get('lowe', true);
  3627. $sku = $this->input->get('sku', true);
  3628. $warehouse = $this->input->get('warehouse', true);
  3629. $lacetype = $this->input->get('lacetype', true);
  3630. $lacecolor = $this->input->get('lacecolor', true);
  3631. $density = $this->input->get('density', true);
  3632. $haircap = $this->input->get('haircap', true);
  3633. $purchase = $this->input->get('purchase', true);
  3634. $title = $this->input->get('title', true);
  3635. $state = $this->input->get('state', true);
  3636. $sid = $this->input->get('sid', true);
  3637. $ktime = $this->input->get('ktime', true);
  3638. $jtime = $this->input->get('jtime', true);
  3639. $ktime = strtotime($ktime);
  3640. $jtime = strtotime($jtime);
  3641. $where = "1=1";
  3642. $gj = "";
  3643. $ck = "";
  3644. if ($category) {
  3645. $where .= " and features like '%-$category-%'";
  3646. }
  3647. if ($size) {
  3648. $where .= " and features like '%-$size-%'";
  3649. }
  3650. if ($grade) {
  3651. $where .= " and features like '%-$grade-%'";
  3652. }
  3653. if ($color) {
  3654. $where .= " and features like '%-$color-%'";
  3655. }
  3656. if ($lowe) {
  3657. $where .= " and features like '%-$lowe-%'";
  3658. }
  3659. if ($warehouse) {
  3660. $where .= " and warehouse = '$warehouse'";
  3661. }
  3662. if ($purchase) {
  3663. $where .= " and purchase = '$purchase'";
  3664. }
  3665. if ($state) {
  3666. $where .= " and state = '$state'";
  3667. }
  3668. if ($lacetype) {
  3669. $where .= " and features like '%-$lacetype-%'";
  3670. }
  3671. if ($lacecolor) {
  3672. $where .= " and features like '%-$lacecolor-%'";
  3673. }
  3674. if ($density) {
  3675. $where .= " and features like '%-$density-%'";
  3676. }
  3677. if ($haircap) {
  3678. $where .= " and features like '%-$haircap-%'";
  3679. }
  3680. if ($title) {
  3681. $title = trim($title, ' ');
  3682. $title = trim($title, ' ');
  3683. $where .= " and title like '%$title%'";
  3684. }
  3685. if ($sku) {
  3686. $sku = trim($sku, ' ');
  3687. $sku = trim($sku, ' ');
  3688. $where .= " and sku like '%$sku%'";
  3689. }
  3690. if ($ktime && $jtime) {
  3691. if ($type == 1) {
  3692. $tl = '出库';
  3693. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3694. } else if ($type == 2) {
  3695. $tl = '退库';
  3696. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3697. } else if ($type == 3) {
  3698. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3699. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3700. } else if ($type == 4) {
  3701. $tl = '出库+零售';
  3702. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3703. } else if ($type == 5) {
  3704. $tl = '零售';
  3705. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3706. }
  3707. }
  3708. $sidwhere = '';
  3709. if ($sid) {
  3710. $sd = "";
  3711. $s = explode(',', trim($sid, ','));
  3712. foreach ($s as $value) {
  3713. $sd .= " id = " . $value . " or";
  3714. }
  3715. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3716. }
  3717. //数据排序
  3718. $order_str = "time desc";
  3719. if (empty($page)) {
  3720. $start = 0;
  3721. $perpage = 1;
  3722. } else {
  3723. $start = ($page - 1) * $perpage;
  3724. }
  3725. //$this->logic_ding->sendToDing("导出出入库分类数据".$where);
  3726. //取得信息列表
  3727. if ($type != 3 && $type != 5) {
  3728. if ($type == 1 || $type == 4) {
  3729. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3730. foreach ($info_list as $key => $value) {
  3731. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3732. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3733. $warehouse = $this->warehouse->read($value['warehouse']);
  3734. $info_list[$key]['warehouse'] = $warehouse['title'];
  3735. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3736. $features = explode('-', trim($features, '-'));
  3737. $pm = $classid;
  3738. foreach ($features as $k => $v) {
  3739. if ($v != 0) {
  3740. if (!isset($typeclass[$v])) {
  3741. continue;
  3742. }
  3743. if (isset($pm[$typeclass[$v]['classid']])) {
  3744. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3745. $tz = explode('|', $typeclass[$v]['zh']);
  3746. $pm[$typeclass[$v]['classid']] = $tz[0];
  3747. } else {
  3748. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3749. }
  3750. }
  3751. }
  3752. }
  3753. $zh = implode(" ", $pm);
  3754. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3755. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3756. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3757. $info_list[$key]['features'] = $zh;
  3758. }
  3759. $final_list = [];
  3760. foreach($info_list as $k=>$v){
  3761. $number = "";
  3762. if(!empty($v['orderinfo'])){
  3763. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3764. if(!empty($tmp_info['number'])){
  3765. $number = $tmp_info['number'];
  3766. }
  3767. }
  3768. $final_list[] = [
  3769. 'warehouse'=>$v['warehouse'],
  3770. 'purchase'=>$v['purchase'],
  3771. 'sku'=>$v['sku'],
  3772. 'title'=>$v['title'],
  3773. 'features'=>$v['features'],
  3774. 'label'=>$v['label'],
  3775. 'orderinfo'=>$v['orderinfo'],
  3776. 'number'=>$number,
  3777. 'waybill'=>$v['waybill'],
  3778. 'outk'=>$v['outk'],
  3779. ];
  3780. }
  3781. } else {
  3782. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3783. foreach ($info_list as $key => $value) {
  3784. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3785. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3786. $warehouse = $this->warehouse->read($value['warehouse']);
  3787. $info_list[$key]['warehouse'] = $warehouse['title'];
  3788. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3789. $features = explode('-', trim($features, '-'));
  3790. $pm = $classid;
  3791. foreach ($features as $k => $v) {
  3792. if ($v != 0) {
  3793. if (!isset($typeclass[$v])) {
  3794. continue;
  3795. }
  3796. if (isset($pm[$typeclass[$v]['classid']])) {
  3797. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3798. $tz = explode('|', $typeclass[$v]['zh']);
  3799. $pm[$typeclass[$v]['classid']] = $tz[0];
  3800. } else {
  3801. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3802. }
  3803. }
  3804. }
  3805. }
  3806. $zh = implode(" ", $pm);
  3807. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3808. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3809. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3810. $info_list[$key]['features'] = $zh;
  3811. }
  3812. $final_list = [];
  3813. foreach($info_list as $k=>$v){
  3814. $number = "";
  3815. if(!empty($v['orderinfo'])){
  3816. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3817. if(!empty($tmp_info['number'])){
  3818. $number = $tmp_info['number'];
  3819. }
  3820. }
  3821. $final_list[] = [
  3822. 'warehouse'=>$v['warehouse'],
  3823. 'purchase'=>$v['purchase'],
  3824. 'sku'=>$v['sku'],
  3825. 'title'=>$v['title'],
  3826. 'features'=>$v['features'],
  3827. 'label'=>$v['label'],
  3828. 'orderinfo'=>$v['orderinfo'],
  3829. 'number'=>$number,
  3830. 'waybill'=>$v['waybill'],
  3831. 'retreat'=>$v['retreat'],
  3832. ];
  3833. }
  3834. }
  3835. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3836. $titlename = "<table border=1>
  3837. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3838. <tr align='center'>
  3839. <td>仓库</td>
  3840. <td>供应商</td>
  3841. <td>SKU</td>
  3842. <td>商品名称</td>
  3843. <td>商品中文</td>
  3844. <td>标签</td>
  3845. <td>订单号</td>
  3846. <td>订单编码</td>
  3847. <td>运单号</td>
  3848. <td>" . $tl . "时间(中国时间)</td>
  3849. </tr>
  3850. </table>";
  3851. $filename = $title . ".xls";
  3852. $tail = "";
  3853. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3854. } else if ($type == 5) {
  3855. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3856. //$this->logic_ding->sendToDing("导出出入库分类数据".json_encode($info_list));
  3857. foreach ($info_list as $key => $value) {
  3858. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3859. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3860. $warehouse = $this->warehouse->read($value['warehouse']);
  3861. $info_list[$key]['warehouse'] = $warehouse['title'];
  3862. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3863. $features = explode('-', trim($features, '-'));
  3864. $pm = $classid;
  3865. foreach ($features as $k => $v) {
  3866. if ($v != 0) {
  3867. if (!isset($typeclass[$v])) {
  3868. continue;
  3869. }
  3870. if (isset($pm[$typeclass[$v]['classid']])) {
  3871. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3872. $tz = explode('|', $typeclass[$v]['zh']);
  3873. $pm[$typeclass[$v]['classid']] = $tz[0];
  3874. } else {
  3875. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3876. }
  3877. }
  3878. }
  3879. }
  3880. $zh = implode(" ", $pm);
  3881. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3882. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3883. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3884. $info_list[$key]['features'] = $zh;
  3885. }
  3886. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3887. $titlename = "<table border=1>
  3888. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3889. <tr align='center'>
  3890. <td>仓库</td>
  3891. <td>供应商</td>
  3892. <td>SKU</td>
  3893. <td>商品名称</td>
  3894. <td>商品中文</td>
  3895. <td>标签</td>
  3896. <td>" . $tl . "时间(中国时间)</td>
  3897. </tr>
  3898. </table>";
  3899. $filename = $title . ".xls";
  3900. $tail = "";
  3901. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3902. } else {
  3903. /**
  3904. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3905. $rows = array();$list = array();
  3906. foreach ($info_list as $key=>$value)
  3907. {
  3908. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3909. }
  3910. **/
  3911. $wh = array();
  3912. $w = $this->warehouse->find_all('1=1', 'id,title');
  3913. foreach ($w as $v) {
  3914. $wh[$v['id']] = $v['title'];
  3915. }
  3916. $wt = array();
  3917. $whlabel_type = $this->whlabel_type->find_all();
  3918. foreach ($whlabel_type as $v) {
  3919. $wt[$v['id']] = $v['title'];
  3920. }
  3921. $classid = $this->classid->sku();
  3922. $list = array();
  3923. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3924. foreach ($rows as $key => $value) {
  3925. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3926. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3927. $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');
  3928. $details = array();
  3929. $cpid = array();
  3930. $cpbz = array();
  3931. $c = 0;
  3932. $g = 0;
  3933. $x = 0;
  3934. $t = 0;
  3935. $s = 0;
  3936. $q = 0;
  3937. foreach ($sd as $k => $v) {
  3938. if ($v['state'] == 0) {
  3939. $c++;
  3940. }
  3941. if ($v['state'] != 9) {
  3942. $g++;
  3943. }
  3944. if ($v['outk'] > 1) {
  3945. $x++;
  3946. }
  3947. if ($v['retreat'] > 0) {
  3948. $t++;
  3949. }
  3950. if ($v['state'] == 8) {
  3951. $s++;
  3952. }
  3953. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3954. $q++;
  3955. }
  3956. $details[$v['details']] = $v['details'];
  3957. if ($v['cpid'] != 0) {
  3958. $cpid[$v['cpid']] = $v['cpid'];
  3959. }
  3960. if ($v['cpbz'] != '') {
  3961. $cpbz[$v['cpbz']] = $v['cpbz'];
  3962. }
  3963. }
  3964. if (isset($wt[$value['type']])) {
  3965. $rows[$key]['type'] = $wt[$value['type']];
  3966. } else {
  3967. $rows[$key]['type'] = '未设置';
  3968. }
  3969. $rows[$key]['details'] = implode("、", $details);
  3970. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3971. $ftime = time() - 15 * 24 * 3600;
  3972. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3973. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3974. $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);
  3975. $rows[$key]['c'] = $c;
  3976. $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);
  3977. $rows[$key]['t'] = $t;
  3978. $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'] . '"');
  3979. $rows[$key]['z'] = $z;
  3980. // $jm = $classid;
  3981. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3982. $features = explode('-', trim($features, '-'));
  3983. // $pm = $classid;
  3984. // foreach ($features as $k => $v) {
  3985. // if ($v != 0) {
  3986. // if (!isset($typeclass[$v])) {
  3987. // continue;
  3988. // }
  3989. // if (isset($pm[$typeclass[$v]['classid']])) {
  3990. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3991. // $tz = explode('|', $typeclass[$v]['zh']);
  3992. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3993. // } else {
  3994. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3995. // }
  3996. // if (isset($jm[$typeclass[$v]['classid']])) {
  3997. // if ($typeclass[$v]['jm']) {
  3998. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3999. // }
  4000. // }
  4001. // }
  4002. // }
  4003. // }
  4004. // $zh = implode(" ", $pm);
  4005. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4006. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4007. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4008. // $rows[$key]['features'] = $zh;
  4009. // $jm = array_filter($jm); //去除空值
  4010. // $jm = implode("-", $jm);
  4011. // $rows[$key]['jm'] = $jm;
  4012. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4013. }
  4014. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4015. // echo "<pre>";
  4016. // print_r($tmp_list);
  4017. // die;
  4018. $final_list =[];
  4019. foreach($tmp_list as $k=>$v){
  4020. $final_list[] = [
  4021. "warehouse"=>$v['warehouse'],
  4022. "purchase"=>$v['purchase'],
  4023. "details"=>$v['details'],
  4024. "cpid"=>$v['cpid'],
  4025. "sku"=>$v['sku'],
  4026. "title"=>$v['title'],
  4027. "features"=>$v['pm'],
  4028. "cpbz"=>$v['cpbz'],
  4029. "sm"=>$v['sm'],
  4030. "type"=>$v['type'],
  4031. "g"=>$v["g"],
  4032. "c"=>$v["c"],
  4033. "x"=>$v["x"],
  4034. "t"=>$v["t"],
  4035. "z"=>$v["z"],
  4036. "jm"=>$v["jm"],
  4037. "weight"=>$v["weight"],
  4038. "asd"=>$v["asd"],
  4039. ];
  4040. }
  4041. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4042. $titlename = "<table border=1>
  4043. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4044. <tr align='center'>
  4045. <td>仓库</td>
  4046. <td>供应商</td>
  4047. <td>位置</td>
  4048. <td>库存编码</td>
  4049. <td>SKU</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. <td>退货数量</td>
  4059. <td>占单数量</td>
  4060. <td>料号</td>
  4061. <td>重量</td>
  4062. <td>类目</td>
  4063. </tr>
  4064. </table>";
  4065. $filename = $title . ".xls";
  4066. $tail = "";
  4067. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4068. }
  4069. }
  4070. }
  4071. //出库+入库数据整合
  4072. public function _excelcr()
  4073. {
  4074. if (isset($_GET['excel'])) {
  4075. $type = $this->input->get('excel', true);
  4076. $category = $this->input->get('category', true);
  4077. $size = $this->input->get('size', true);
  4078. $grade = $this->input->get('grade', true);
  4079. $color = $this->input->get('color', true);
  4080. $lowe = $this->input->get('lowe', true);
  4081. $sku = $this->input->get('sku', true);
  4082. $warehouse = $this->input->get('warehouse', true);
  4083. $purchase = $this->input->get('purchase', true);
  4084. $state = $this->input->get('state', true);
  4085. $sid = $this->input->get('sid', true);
  4086. $ktime = $this->input->get('ktime', true);
  4087. $jtime = $this->input->get('jtime', true);
  4088. $ktime = strtotime($ktime);
  4089. $jtime = strtotime($jtime);
  4090. $where = "1=1";
  4091. $gj = "";
  4092. $ck = "";
  4093. if ($category) {
  4094. $where .= " and features like '%-$category-%'";
  4095. }
  4096. if ($size) {
  4097. $where .= " and features like '%-$size-%'";
  4098. }
  4099. if ($grade) {
  4100. $where .= " and features like '%-$grade-%'";
  4101. }
  4102. if ($color) {
  4103. $where .= " and features like '%-$color-%'";
  4104. }
  4105. if ($lowe) {
  4106. $where .= " and features like '%-$lowe-%'";
  4107. }
  4108. if ($warehouse) {
  4109. $where .= " and warehouse = '$warehouse'";
  4110. }
  4111. if ($purchase) {
  4112. $where .= " and purchase = '$purchase'";
  4113. }
  4114. if ($state) {
  4115. $where .= " and state = '$state'";
  4116. }
  4117. if ($sku) {
  4118. $where .= " and sku like '%$sku%'";
  4119. }
  4120. if ($ktime && $jtime) {
  4121. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4122. }
  4123. $sidwhere = '';
  4124. if ($sid) {
  4125. $sd = "";
  4126. $s = explode(',', trim($sid, ','));
  4127. foreach ($s as $value) {
  4128. $sd .= " id = " . $value . " or";
  4129. }
  4130. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4131. }
  4132. //取得信息列表
  4133. $timeread = $ktime;
  4134. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4135. $timelist = array();
  4136. for ($i = 0; $i < $timenum; $i++) {
  4137. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4138. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4139. }
  4140. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4141. //echo "<pre>";
  4142. //print_r($info_list);
  4143. //exit();
  4144. $rows = array();
  4145. $list = array();
  4146. foreach ($info_list as $key => $value) {
  4147. $thistime = $timelist;
  4148. if (isset($rows[strtolower($value['sku'])])) {
  4149. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4150. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4151. }
  4152. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4153. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4154. }
  4155. } else {
  4156. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4157. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4158. }
  4159. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4160. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4161. }
  4162. $rows[strtolower($value['sku'])] = $thistime;
  4163. }
  4164. }
  4165. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4166. <head>
  4167. <!--[if gte mso 9]><xml>
  4168. <x:ExcelWorkbook>
  4169. <x:ExcelWorksheets>
  4170. <x:ExcelWorksheet>
  4171. <x:Name>EXCEL</x:Name>
  4172. <x:WorksheetOptions>
  4173. <x:Print>
  4174. <x:ValidPrinterInfo />
  4175. </x:Print>
  4176. </x:WorksheetOptions>
  4177. </x:ExcelWorksheet>
  4178. </x:ExcelWorksheets>
  4179. </x:ExcelWorkbook>
  4180. </xml>
  4181. <![endif]-->
  4182. </head><body>";
  4183. $str .= "<table border=1><tr><td>SKU</td>";
  4184. foreach ($timelist as $k => $v) {
  4185. $str .= "<td>" . $k . "出库</td>";
  4186. $str .= "<td>" . $k . "入库</td>";
  4187. }
  4188. $str .= "</tr></table>";
  4189. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4190. foreach ($rows as $key => $val) {
  4191. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4192. foreach ($val as $k => $v) {
  4193. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4194. if ($val[$k]['r'] > 0) {
  4195. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4196. } else {
  4197. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4198. }
  4199. }
  4200. $str .= "</tr>";
  4201. }
  4202. $str .= "</table>";
  4203. $str .= "</body></html>";
  4204. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4205. header("Content-type: application/octet-stream");
  4206. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4207. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4208. header("Pragma: no-cache");
  4209. header("Expires: 0");
  4210. exit($str);
  4211. }
  4212. }
  4213. //数量调整模板导出
  4214. public function _presetout()
  4215. {
  4216. if (isset($_GET['excel'])) {
  4217. $where = "sku != 'Preset' and purchase != 0";
  4218. //数据排序
  4219. $order_str = "id desc";
  4220. if (empty($page)) {
  4221. $start = 0;
  4222. $perpage = 1;
  4223. } else {
  4224. $start = ($page - 1) * $perpage;
  4225. }
  4226. //取得信息列表
  4227. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4228. $rows = array();
  4229. $list = array();
  4230. foreach ($info_list as $value) {
  4231. $warehouse = $this->warehouse->read($value['warehouse']);
  4232. $number = $value['number'];
  4233. $ftime = time() - 15 * 24 * 3600;
  4234. $purchase = $this->purchase->read($value['purchase']);
  4235. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4236. }
  4237. $title = "库存模板";
  4238. $titlename = "<table border=1>
  4239. <tr align='center'>
  4240. <td>仓库</td>
  4241. <td>供应商编码</td>
  4242. <td>SKU</td>
  4243. <td>增减数量(正数或负数)</td>
  4244. <td>增减备注</td>
  4245. <td>扣减方式:0减少库存1删除库存</td>
  4246. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4247. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4248. </tr>
  4249. </table>";
  4250. $filename = $title . ".xls";
  4251. $tail = "";
  4252. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4253. }
  4254. }
  4255. //数量调整模板导入
  4256. public function _presetedit()
  4257. {
  4258. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4259. $config['upload_path'] = '.' . $dir;
  4260. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4261. $config['allowed_types'] = 'xls|xlsx|csv';
  4262. $config['max_size'] = 10240;
  4263. $this->load->library('upload', $config);
  4264. $this->upload->initialize($config);
  4265. if ($this->upload->do_upload('userfile')) {
  4266. $full_path = $dir . $this->upload->data('file_name');
  4267. $fileName = '.' . $full_path;
  4268. if (!file_exists($fileName)) {
  4269. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4270. exit;
  4271. } else {
  4272. require_once "./data/excel/PHPExcel/IOFactory.php";
  4273. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4274. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4275. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4276. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4277. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4278. ++$column; //如果列数大于26行
  4279. $list = array();
  4280. for ($i = 2; $i <= $row; $i++) // 行数循环
  4281. {
  4282. $data = array();
  4283. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4284. {
  4285. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4286. }
  4287. $list[] = $data;
  4288. }
  4289. }
  4290. $i = 0;
  4291. $j = 0;
  4292. $ed = array();
  4293. foreach ($list as $key => $value) {
  4294. $time = time();
  4295. if ($value['0'] == "") {
  4296. continue;
  4297. }
  4298. $warehouse = $this->warehouse->get_title($value['0']);
  4299. $purchase = $this->purchase->get_bm($value['1']);
  4300. $sku = $value['2'];
  4301. $num = $value['3']; //调整数量
  4302. $text = $value['4']; //扣减说明
  4303. $type = $value['5']; //调整方式0扣减1删除
  4304. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4305. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4306. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4307. if (!$purchase) //如果没有这个SKU
  4308. {
  4309. $ed[] = array($purchase . '-不存在此供应商编码');
  4310. $j++;
  4311. continue;
  4312. }
  4313. if (!$d) //如果没有这个SKU
  4314. {
  4315. $ed[] = array($sku . '-库存中不存在此SKU');
  4316. $j++;
  4317. continue;
  4318. }
  4319. if (!isset($warehouse['id'])) {
  4320. $ed[] = array($sku . '-仓库名错误!');
  4321. $j++;
  4322. continue;
  4323. }
  4324. if ($type != '0' && $type != '1') {
  4325. $ed[] = array($sku . '-扣减方式填写错误!');
  4326. $j++;
  4327. continue;
  4328. }
  4329. if ($num < 0) //扣减库存
  4330. {
  4331. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4332. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4333. $j++;
  4334. continue;
  4335. }
  4336. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4337. if (count($data) < abs($num)) {
  4338. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4339. $j++;
  4340. continue;
  4341. }
  4342. if ($type == 0) //如果扣减方式为 扣减库存
  4343. {
  4344. for ($i = 0; $i < abs($num); $i++) {
  4345. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4346. }
  4347. } else if ($type == 1) {
  4348. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4349. if (count($zt) > 0) {
  4350. $ed[] = array($sku . '-有在途库存无法删除!');
  4351. $j++;
  4352. continue;
  4353. }
  4354. for ($i = 0; $i < abs($num); $i++) {
  4355. $this->whlabel->remove($data[$i]['id']);
  4356. }
  4357. }
  4358. } else if ($num > 0) //增加库存
  4359. {
  4360. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4361. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4362. $j++;
  4363. continue;
  4364. }
  4365. $post['sku'] = $d['sku'];
  4366. $post['shop'] = $d['shop'];
  4367. $post['warehouse'] = $warehouse['id'];
  4368. $post['purchase'] = $purchase['id'];
  4369. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4370. $post['state'] = 0;
  4371. $post['title'] = $d['title'];
  4372. $post['number'] = $d['number'];
  4373. $post['features'] = $d['features'];
  4374. $post['enter'] = $time;
  4375. $post['time'] = $time; //操作时间
  4376. $post['rktype'] = $rktype;
  4377. for ($i = 0; $i < $num; $i++) {
  4378. $post['label'] = time() . rand(100, 999) . $i;
  4379. $this->whlabel->insert($post);
  4380. }
  4381. }
  4382. sleep(1); //防止入库时间一样,需要延迟1秒
  4383. }
  4384. if ($j > 0) {
  4385. $tt = date('Ymd', time());
  4386. $title = '库存导入错误信息-' . $tt;
  4387. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4388. $tail = "\n";
  4389. $filename = $title . ".xls";
  4390. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4391. $dir = '/data/excel/' . $time . '/';
  4392. $file_name = 'error_' . $time . rand(1000, 9999);
  4393. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4394. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4395. fwrite($myfile, $ecl);
  4396. fclose($myfile);
  4397. $error = $dir . $file_name . '.xls';
  4398. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4399. exit;
  4400. } else {
  4401. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4402. exit;
  4403. }
  4404. }
  4405. }
  4406. //笛卡儿积
  4407. function cp($ps, $sets, $list)
  4408. {
  4409. $result = array();
  4410. $j = 0;
  4411. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4412. if ($i == 0) {
  4413. $result = $sets[$i];
  4414. }
  4415. $tmp = array();
  4416. foreach ($result as $res) {
  4417. foreach ($sets[$i + 1] as $set) {
  4418. $tmp[] = $res . ',' . $set;
  4419. }
  4420. }
  4421. $result = $tmp;
  4422. }
  4423. $this->db->trans_begin();
  4424. foreach ($result as $v) {
  4425. $post = array();
  4426. $title = "";
  4427. $num = "";
  4428. $data = explode(',', $v);
  4429. for ($i = 0; $i < count($list); $i++) {
  4430. $post[$list[$i]] = $data[$i];
  4431. $typeclass = $this->typeclass->read($data[$i]);
  4432. $title = $title . $typeclass['title'] . " ";
  4433. if ($data[$i] != 0) {
  4434. $num .= $data[$i]; //所有数据ID拼接
  4435. }
  4436. }
  4437. foreach ($ps as $kp => $vp) {
  4438. $post[$kp] = $vp;
  4439. }
  4440. $post['number'] = $num;
  4441. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4442. if ($info_list) {
  4443. $j++;
  4444. } else {
  4445. $skunum = $this->whlabel->find_count();
  4446. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4447. $post['title'] = rtrim($title, ' ');
  4448. $this->whlabel->insert($post);
  4449. }
  4450. }
  4451. if ($this->db->trans_status() === FALSE) {
  4452. $this->db->trans_commit();
  4453. return NULL;
  4454. } else {
  4455. $this->db->trans_commit();
  4456. return $j;
  4457. }
  4458. }
  4459. public function _kj($arg_array)
  4460. {
  4461. if (isset($_POST['sku'])) {
  4462. $time = time();
  4463. $sku = $this->input->post('sku', true);
  4464. $warehouse = $this->input->post('warehouse', true);
  4465. $num = $this->input->post('num', true);
  4466. $text = $this->input->post('text', true);
  4467. $purchase = $this->input->post('purchase', true);
  4468. $cktype = $this->input->post('cktype', true);
  4469. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4470. if ($cktype != 1 && $text == '') {
  4471. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4472. exit;
  4473. }
  4474. if ($num > count($order)) {
  4475. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4476. exit;
  4477. } else {
  4478. for ($i = 0; $i < $num; $i++) {
  4479. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4480. }
  4481. }
  4482. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4483. exit;
  4484. }
  4485. $uid = $this->whlabel->read($arg_array[0]);
  4486. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4487. $this->data['data'] = $uid;
  4488. $this->_Template('whlabel_kj', $this->data);
  4489. }
  4490. public function _summary($arg_array)
  4491. {
  4492. $prc = array();
  4493. $purchase = $this->purchase->find_all();
  4494. foreach ($purchase as $k => $v) {
  4495. $prc[$v['id']] = $v['title'];
  4496. }
  4497. if (isset($_GET['excel'])) {
  4498. $ktime = $this->input->get('ktime', true);
  4499. $jtime = $this->input->get('jtime', true);
  4500. $ktime = strtotime($ktime);
  4501. $jtime = strtotime($jtime);
  4502. $where = "1=1";
  4503. if ($ktime && $jtime) {
  4504. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4505. }
  4506. //数据排序
  4507. $order_str = "time desc";
  4508. if (empty($page)) {
  4509. $start = 0;
  4510. $perpage = 1;
  4511. } else {
  4512. $start = ($page - 1) * $perpage;
  4513. }
  4514. //取得信息列表
  4515. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4516. foreach ($info_list as $key => $value) {
  4517. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4518. $warehouse = $this->warehouse->read($value['warehouse']);
  4519. $info_list[$key]['warehouse'] = $warehouse['title'];
  4520. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4521. $details = array();
  4522. $cpid = array();
  4523. foreach ($x as $k => $v) {
  4524. if ($v['details'] != '') {
  4525. $details[$v['details']] = $v['details'];
  4526. }
  4527. if ($v['cpid'] != 0) {
  4528. $cpid[$v['cpid']] = $v['cpid'];
  4529. }
  4530. }
  4531. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4532. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4533. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4534. $info_list[$key]['s'] = $s;
  4535. $info_list[$key]['x'] = count($x);
  4536. }
  4537. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4538. $titlename = "<table border=1>
  4539. <tr align='center'>
  4540. <td>仓库</td>
  4541. <td>供应商</td>
  4542. <td>出库位置</td>
  4543. <td>出库编码</td>
  4544. <td>SKU</td>
  4545. <td>产品名</td>
  4546. <td>总剩余库存</td>
  4547. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4548. </tr>
  4549. </table>";
  4550. $filename = $title . ".xls";
  4551. $tail = "";
  4552. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4553. }
  4554. }
  4555. //usps发货清单
  4556. public function _manifest()
  4557. {
  4558. if (isset($_POST['manifest'])) {
  4559. $wltext = $this->input->post('wltext', true);
  4560. $time = time() - 16 * 3600;
  4561. $ptime = strtotime(date('Y-m-d', $time));
  4562. $waybill = array();
  4563. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4564. foreach ($fullorder as $v) {
  4565. $waybill[$v['waybill']] = $v['waybill'];
  4566. }
  4567. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4568. foreach ($fullordersmt as $v) {
  4569. $waybill[$v['waybill']] = $v['waybill'];
  4570. }
  4571. $wltext = explode(';', $wltext);
  4572. foreach ($wltext as $v) {
  4573. if (isset($waybill[$v])) {
  4574. unset($waybill[$v]);
  4575. }
  4576. }
  4577. $data = $this->usps->get_manifest($waybill);
  4578. if (isset($data['Description'])) {
  4579. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4580. exit;
  4581. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4582. $bctime = date('Ymd', time());
  4583. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4584. echo json_encode(array('msg' => $pdf, 'success' => true));
  4585. exit;
  4586. } else {
  4587. echo json_encode(array('msg' => $data, 'success' => false));
  4588. exit;
  4589. }
  4590. }
  4591. }
  4592. public function _pdf($pdf, $title, $bctime)
  4593. {
  4594. $pdf_path = './data/pdf/' . $bctime . '/';
  4595. $file_base64 = $pdf;
  4596. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4597. $file_base64 = base64_decode($file_base64);
  4598. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4599. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4600. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4601. }
  4602. /**
  4603. *
  4604. *
  4605. *
  4606. 进销存占单异常索引
  4607. *
  4608. *
  4609. *
  4610. **/
  4611. public function _abnormal()
  4612. {
  4613. $post = $this->input->post(NULL, TRUE);
  4614. if (isset($post['page'])) {
  4615. $page = $this->input->post('page', true);
  4616. $perpage = $this->input->post('perpage', true);
  4617. $sku = $this->input->post('sku', true);
  4618. $where = "1=1";
  4619. //数据排序
  4620. $order_str = "id desc";
  4621. if (empty($page)) {
  4622. $start = 0;
  4623. $perpage = 1;
  4624. } else {
  4625. $start = ($page - 1) * $perpage;
  4626. }
  4627. //取得信息列表
  4628. $info_list = $this->whlabel->find_all($where, '*');
  4629. $rows = array();
  4630. $list = array();
  4631. foreach ($info_list as $key => $value) {
  4632. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4633. }
  4634. foreach ($rows as $value) {
  4635. $warehouse = $this->warehouse->read($value['warehouse']);
  4636. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4637. $number = $value['number'];
  4638. $ftime = time() - 15 * 24 * 3600;
  4639. if ($value['shop'] != '') {
  4640. $shop = $value['shop'];
  4641. $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');
  4642. $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');
  4643. $order = array_merge($orderdlz, $ordersmt);
  4644. $od = 0;
  4645. $a = '';
  4646. $orid = '';
  4647. foreach ($order as $v) {
  4648. $or = explode('|', ltrim($v['whlabel'], '|'));
  4649. for ($i = 0; $i < count($or); $i++) {
  4650. $orod = explode('-', $or[$i]);
  4651. if ($orod[0] == $number) {
  4652. $od += $orod[1];
  4653. }
  4654. }
  4655. $orid .= $v['number'] . '-';
  4656. }
  4657. } else {
  4658. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4659. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4660. $order = array_merge($orderdlz, $ordersmt);
  4661. $od = 0;
  4662. $a = '';
  4663. $orid = '';
  4664. $qt = array();
  4665. foreach ($order as $v) {
  4666. $or = explode('|', ltrim($v['whlabel'], '|'));
  4667. for ($i = 0; $i < count($or); $i++) {
  4668. $orod = explode('-', $or[$i]);
  4669. if ($orod[0] == $number) {
  4670. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4671. if ($czzs > 0) {
  4672. if (isset($qt[$v['shop']])) {
  4673. if ($qt[$v['shop']] < $orod[1]) {
  4674. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4675. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4676. } else {
  4677. $qt[$v['shop']] -= $orod[1];
  4678. }
  4679. } else {
  4680. $qt[$v['shop']] = $czzs;
  4681. }
  4682. } else {
  4683. $od += $orod[1];
  4684. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4685. }
  4686. }
  4687. }
  4688. }
  4689. }
  4690. $z = $od . '(' . $orid . ')'; //查看订单号
  4691. //$z = $od;
  4692. if ($od > $c) {
  4693. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4694. }
  4695. }
  4696. $listdata = array_slice($list, $start, $perpage);
  4697. $total = count($list);
  4698. $pagenum = ceil($total / $perpage);
  4699. $over = $total - ($start + $perpage);
  4700. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4701. echo json_encode($rows);
  4702. exit;
  4703. }
  4704. $this->_Template('whlabel_abnormal', $this->data);
  4705. }
  4706. /**
  4707. *
  4708. *
  4709. *
  4710. 进销存占单异常索引
  4711. *
  4712. *
  4713. *
  4714. **/
  4715. public function _error()
  4716. {
  4717. $post = $this->input->post(NULL, TRUE);
  4718. if (isset($post['page'])) {
  4719. $page = $this->input->post('page', true);
  4720. $perpage = $this->input->post('perpage', true);
  4721. $sku = $this->input->post('sku', true);
  4722. $warehouse = $this->input->post('warehouse', true);
  4723. $ktime = $this->input->post('ktime', true);
  4724. $jtime = $this->input->post('jtime', true);
  4725. $ktime = strtotime($ktime);
  4726. $jtime = strtotime($jtime);
  4727. $where = "sku != 'Preset'";
  4728. $gj = '';
  4729. if ($sku) {
  4730. $where .= " and sku like '%$sku%'";
  4731. } else {
  4732. if ($ktime && $jtime) {
  4733. $gj = " and time > '$ktime' and time < '$jtime'";
  4734. }
  4735. }
  4736. if ($warehouse) {
  4737. $where .= " and warehouse = '$warehouse'";
  4738. }
  4739. //数据排序
  4740. $order_str = "id desc";
  4741. if (empty($page)) {
  4742. $start = 0;
  4743. $perpage = 1;
  4744. } else {
  4745. $start = ($page - 1) * $perpage;
  4746. }
  4747. //取得信息列表
  4748. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4749. $rows = array();
  4750. $list = array();
  4751. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4752. // foreach ($info_list as $value)
  4753. // {
  4754. // $warehouse = $this->warehouse->read($value['warehouse']);
  4755. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4756. // $number = $value['number'];$ftime = time()-15*24*3600;
  4757. // if($c < 1)
  4758. // {
  4759. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4760. // }
  4761. // }
  4762. $warehouse_list = $this->warehouse->find_all();
  4763. $warehouse_list = array_column($warehouse_list, null, 'id');
  4764. foreach ($info_list as $value) {
  4765. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4766. 'title' => "",
  4767. ];
  4768. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4769. $number = $value['number'];
  4770. $ftime = time() - 15 * 24 * 3600;
  4771. if ($c < 1) {
  4772. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4773. }
  4774. }
  4775. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4776. // $query = $this->db->query($sql);
  4777. // $info_list = $query->result_array();
  4778. // $sql_two = "select title,id from crowd_warehouse";
  4779. // $query_two = $this->db->query($sql_two);
  4780. // $warehouse_list = $query_two->result_array();
  4781. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4782. // foreach ($info_list as $value)
  4783. // {
  4784. // if(isset($warehouse_arr[$value['warehouse']])){
  4785. // $warehouse = $warehouse_arr[$value['warehouse']];
  4786. // }else{
  4787. // $warehouse = [
  4788. // 'id'=>0,
  4789. // 'title'=>"异常",
  4790. // ];
  4791. // }
  4792. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4793. // $number = $value['number'];$ftime = time()-15*24*3600;
  4794. // if($c < 1)
  4795. // {
  4796. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4797. // }
  4798. // }
  4799. $listdata = array_slice($list, $start, $perpage);
  4800. $total = count($list);
  4801. $pagenum = ceil($total / $perpage);
  4802. $over = $total - ($start + $perpage);
  4803. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4804. echo json_encode($rows);
  4805. exit;
  4806. }
  4807. if (isset($post['s'])) {
  4808. $id_arr = $this->input->post('s');
  4809. $id_arr = explode(',', trim($id_arr, ','));
  4810. if (!$id_arr) {
  4811. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4812. exit;
  4813. }
  4814. //循环删除记录
  4815. foreach ($id_arr as $v) {
  4816. $dd = $this->whlabel->read($v);
  4817. if (!isset($dd['id'])) {
  4818. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4819. exit;
  4820. }
  4821. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4822. if (isset($zt[0])) {
  4823. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4824. exit;
  4825. }
  4826. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4827. foreach ($deldd as $vv) {
  4828. $this->whlabel->remove($vv['id']);
  4829. }
  4830. }
  4831. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4832. exit;
  4833. }
  4834. $this->_Template('whlabel_error', $this->data);
  4835. }
  4836. public function _errorexcel()
  4837. {
  4838. $post = $this->input->post(NULL, TRUE);
  4839. if (isset($_GET['page'])) {
  4840. $page = $this->input->get('page', true);
  4841. $perpage = $this->input->get('perpage', true);
  4842. $sku = $this->input->get('sku', true);
  4843. $warehouse = $this->input->get('warehouse', true);
  4844. $ktime = $this->input->get('ktime', true);
  4845. $jtime = $this->input->get('jtime', true);
  4846. $ktime = strtotime($ktime);
  4847. $jtime = strtotime($jtime);
  4848. $where = "sku != 'Preset'";
  4849. $gj = '';
  4850. if ($sku) {
  4851. $where .= " and sku like '%$sku%'";
  4852. } else {
  4853. if ($ktime && $jtime) {
  4854. $gj = " and time > '$ktime' and time < '$jtime'";
  4855. }
  4856. }
  4857. if ($warehouse) {
  4858. $where .= " and warehouse = '$warehouse'";
  4859. }
  4860. //数据排序
  4861. $order_str = "id desc";
  4862. if (empty($page)) {
  4863. $start = 0;
  4864. $perpage = 1;
  4865. } else {
  4866. $start = ($page - 1) * $perpage;
  4867. }
  4868. //取得信息列表
  4869. $rows = array();
  4870. $list = array();
  4871. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4872. foreach ($info_list as $value) {
  4873. $warehouse = $this->warehouse->read($value['warehouse']);
  4874. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4875. $number = $value['number'];
  4876. $ftime = time() - 15 * 24 * 3600;
  4877. if ($c < 1) {
  4878. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4879. }
  4880. }
  4881. $title = "0库存汇总";
  4882. $titlename = "<table border=1>
  4883. <tr align='center'>
  4884. <td>仓库</td>
  4885. <td>SKU</td>
  4886. <td>产品</td>
  4887. <td>当前库存</td>
  4888. </tr>
  4889. </table>";
  4890. $filename = $title . ".xls";
  4891. $tail = "";
  4892. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4893. }
  4894. }
  4895. /**
  4896. *
  4897. *
  4898. * 占单
  4899. *
  4900. *
  4901. **/
  4902. public function _kcyz()
  4903. {
  4904. $post = $this->input->post(NULL, TRUE);
  4905. if (isset($post['warehouse'])) {
  4906. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4907. exit; //不再使用
  4908. $warehouse = $this->input->post('warehouse', true);
  4909. $whlabel = $this->input->post('whlabel', true);
  4910. $id = $this->input->post('id', true);
  4911. $shop = $this->input->post('shop', true);
  4912. $number = $this->input->post('number', true);
  4913. if (!$whlabel || $whlabel == '|') {
  4914. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4915. exit;
  4916. }
  4917. $pp = explode('|', trim($whlabel, '|'));
  4918. $x = 0;
  4919. $save = array();
  4920. foreach ($pp as $va) {
  4921. $num = explode('-', $va);
  4922. if ($number) {
  4923. $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 = '')"); //通用
  4924. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4925. } else {
  4926. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4927. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4928. }
  4929. $x++;
  4930. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4931. $save[] = $x - 1;
  4932. continue; //提前先加X不然出错,所以要减1
  4933. }
  4934. }
  4935. if (isset($save[0])) {
  4936. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4937. exit;
  4938. } else {
  4939. echo json_encode(array('success' => true));
  4940. exit;
  4941. }
  4942. }
  4943. }
  4944. public function _db()
  4945. {
  4946. $post = $this->input->post(NULL, TRUE);
  4947. if (isset($post['page'])) {
  4948. $page = $this->input->post('page', true);
  4949. $perpage = $this->input->post('perpage', true);
  4950. $sku = $this->input->post('sku', true);
  4951. $number = $this->input->post('number', true);
  4952. $warehouse = $this->input->post('warehouse', true);
  4953. $purchase = $this->input->post('purchase', true);
  4954. $orderinfo = $this->input->post('orderinfo', true);
  4955. $waybill = $this->input->post('waybill', true);
  4956. $category = $this->input->post('category', true);
  4957. $size = $this->input->post('size', true);
  4958. $grade = $this->input->post('grade', true);
  4959. $color = $this->input->post('color', true);
  4960. $lowe = $this->input->post('lowe', true);
  4961. $state = $this->input->post('state', true);
  4962. $label = $this->input->post('label', true);
  4963. $timetk = $this->input->post('timetkk', true);
  4964. $timetj = $this->input->post('timetjj', true);
  4965. $timetk = strtotime($timetk);
  4966. $timetj = strtotime($timetj);
  4967. $where = "dbtime > 0";
  4968. if ($timetk && $timetj) {
  4969. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4970. }
  4971. if ($sku) {
  4972. $where .= " and sku = '$sku'";
  4973. }
  4974. if ($warehouse) {
  4975. $where .= " and warehouse = '$warehouse'";
  4976. if ($warehouse == 12) {
  4977. $w = 'specialstock';
  4978. } else {
  4979. $w = 'whlabel';
  4980. }
  4981. }
  4982. if ($purchase) {
  4983. $where .= " and purchase = '$purchase'";
  4984. }
  4985. if ($category) {
  4986. $where .= " and features like '%-$category-%'";
  4987. }
  4988. if ($size) {
  4989. $where .= " and features like '%-$size-%'";
  4990. }
  4991. if ($grade) {
  4992. $where .= " and features like '%-$grade-%'";
  4993. }
  4994. if ($color) {
  4995. $where .= " and features like '%-$color-%'";
  4996. }
  4997. if ($lowe) {
  4998. $where .= " and features like '%-$lowe-%'";
  4999. }
  5000. if ($state != '') {
  5001. $where .= " and state = '$state'";
  5002. }
  5003. //数据排序
  5004. $order_str = "dbtime desc";
  5005. if (empty($page)) {
  5006. $start = 0;
  5007. $perpage = 1;
  5008. } else {
  5009. $start = ($page - 1) * $perpage;
  5010. }
  5011. //取得信息列表
  5012. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5013. foreach ($info_list as $key => $value) {
  5014. $warehouse = $this->$w->read($value['warehouse']);
  5015. $info_list[$key]['warehouse'] = $warehouse['title'];
  5016. $purchase = $this->purchase->read($value['purchase']);
  5017. $info_list[$key]['purchase'] = $purchase['title'];
  5018. if ($value['enter'] != 0) {
  5019. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5020. } else {
  5021. $info_list[$key]['enter'] = "";
  5022. }
  5023. if ($value['dbtime'] != 0) {
  5024. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5025. } else {
  5026. $info_list[$key]['dbtime'] = "";
  5027. }
  5028. if ($value['state'] == 0) {
  5029. $info_list[$key]['state'] = "在库";
  5030. } else if ($value['state'] == 1) {
  5031. $info_list[$key]['state'] = "出库";
  5032. } else if ($value['state'] == 2) {
  5033. $info_list[$key]['state'] = "退库";
  5034. } else if ($value['state'] == 3) {
  5035. $info_list[$key]['state'] = "调拨中";
  5036. } else if ($value['state'] == 4) {
  5037. $info_list[$key]['state'] = "再加工";
  5038. } else if ($value['state'] == 5) {
  5039. $info_list[$key]['state'] = "维修中";
  5040. } else if ($value['state'] == 6) {
  5041. $info_list[$key]['state'] = "盘亏";
  5042. } else if ($value['state'] == 7) {
  5043. $info_list[$key]['state'] = "更换标签";
  5044. } else if ($value['state'] == 8) {
  5045. $info_list[$key]['state'] = "其它";
  5046. } else if ($value['state'] == 9) {
  5047. $info_list[$key]['state'] = "预设";
  5048. }
  5049. }
  5050. $total = $this->whlabel->find_count($where);
  5051. $pagenum = ceil($total / $perpage);
  5052. $over = $total - ($start + $perpage);
  5053. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5054. echo json_encode($rows);
  5055. exit;
  5056. }
  5057. if (isset($post['outsku'])) {
  5058. $time = time();
  5059. $cz = $this->input->post('cz', true);
  5060. $label = $this->input->post('outsku', true);
  5061. $sl = $this->input->post('sl', true);
  5062. $num = $this->input->post('num', true);
  5063. //$warehouse = $this->input->post('warehouse',true);
  5064. if (!$sl) {
  5065. $sl = 1;
  5066. }
  5067. if (!$warehouse) {
  5068. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5069. exit;
  5070. }
  5071. $dblabel = $this->whlabellabel->get_label($label);
  5072. if ($dblabel) {
  5073. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5074. if (count($data) < 1) {
  5075. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5076. exit;
  5077. }
  5078. if (count($data) < $num) {
  5079. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5080. exit;
  5081. }
  5082. for ($i = 0; $i < $sl; $i++) {
  5083. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5084. }
  5085. echo json_encode(array('success' => true));
  5086. exit;
  5087. } else {
  5088. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5089. exit;
  5090. }
  5091. }
  5092. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5093. $this->_Template('whlabel_db', $this->data);
  5094. }
  5095. public function _dbrk()
  5096. {
  5097. $post = $this->input->post(NULL, TRUE);
  5098. if (isset($post['page'])) {
  5099. $page = $this->input->post('page', true);
  5100. $perpage = $this->input->post('perpage', true);
  5101. $sku = $this->input->post('sku', true);
  5102. $number = $this->input->post('number', true);
  5103. $warehouse = $this->input->post('warehouse', true);
  5104. $purchase = $this->input->post('purchase', true);
  5105. $orderinfo = $this->input->post('orderinfo', true);
  5106. $waybill = $this->input->post('waybill', true);
  5107. $category = $this->input->post('category', true);
  5108. $size = $this->input->post('size', true);
  5109. $grade = $this->input->post('grade', true);
  5110. $color = $this->input->post('color', true);
  5111. $lowe = $this->input->post('lowe', true);
  5112. $state = $this->input->post('state', true);
  5113. $label = $this->input->post('label', true);
  5114. $ctime = $this->input->post('ctime', true);
  5115. $timetk = $this->input->post('timetkk', true);
  5116. $timetj = $this->input->post('timetjj', true);
  5117. $timetk = strtotime($timetk);
  5118. $timetj = strtotime($timetj);
  5119. $where = "dbtime > 0";
  5120. if ($timetk && $timetj) {
  5121. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5122. }
  5123. if ($sku) {
  5124. $where .= " and sku = '$sku'";
  5125. }
  5126. if ($warehouse) {
  5127. $where .= " and warehouse = '$warehouse'";
  5128. }
  5129. if ($purchase) {
  5130. $where .= " and purchase = '$purchase'";
  5131. }
  5132. if ($category) {
  5133. $where .= " and features like '%-$category-%'";
  5134. }
  5135. if ($size) {
  5136. $where .= " and features like '%-$size-%'";
  5137. }
  5138. if ($grade) {
  5139. $where .= " and features like '%-$grade-%'";
  5140. }
  5141. if ($color) {
  5142. $where .= " and features like '%-$color-%'";
  5143. }
  5144. if ($lowe) {
  5145. $where .= " and features like '%-$lowe-%'";
  5146. }
  5147. if ($state != '') {
  5148. $where .= " and state = '$state'";
  5149. }
  5150. //数据排序
  5151. $order_str = "dbtime desc";
  5152. if (empty($page)) {
  5153. $start = 0;
  5154. $perpage = 1;
  5155. } else {
  5156. $start = ($page - 1) * $perpage;
  5157. }
  5158. //取得信息列表
  5159. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5160. foreach ($info_list as $key => $value) {
  5161. $warehouse = $this->warehouse->read($value['warehouse']);
  5162. $info_list[$key]['warehouse'] = $warehouse['title'];
  5163. $purchase = $this->purchase->read($value['purchase']);
  5164. $info_list[$key]['purchase'] = $purchase['title'];
  5165. if ($value['enter'] != 0) {
  5166. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5167. } else {
  5168. $info_list[$key]['enter'] = "";
  5169. }
  5170. if ($value['dbtime'] != 0) {
  5171. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5172. } else {
  5173. $info_list[$key]['dbtime'] = "";
  5174. }
  5175. if ($value['state'] == 0) {
  5176. $info_list[$key]['state'] = "在库";
  5177. } else if ($value['state'] == 1) {
  5178. $info_list[$key]['state'] = "出库";
  5179. } else if ($value['state'] == 2) {
  5180. $info_list[$key]['state'] = "退库";
  5181. } else if ($value['state'] == 3) {
  5182. $info_list[$key]['state'] = "调拨中";
  5183. } else if ($value['state'] == 4) {
  5184. $info_list[$key]['state'] = "再加工";
  5185. } else if ($value['state'] == 5) {
  5186. $info_list[$key]['state'] = "维修中";
  5187. } else if ($value['state'] == 6) {
  5188. $info_list[$key]['state'] = "盘亏";
  5189. } else if ($value['state'] == 7) {
  5190. $info_list[$key]['state'] = "更换标签";
  5191. } else if ($value['state'] == 8) {
  5192. $info_list[$key]['state'] = "其它";
  5193. } else if ($value['state'] == 9) {
  5194. $info_list[$key]['state'] = "预设";
  5195. }
  5196. }
  5197. $total = $this->whlabel->find_count($where);
  5198. $pagenum = ceil($total / $perpage);
  5199. $over = $total - ($start + $perpage);
  5200. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5201. echo json_encode($rows);
  5202. exit;
  5203. }
  5204. if (isset($post['rsku'])) {
  5205. $cz = $this->input->post('cz', true);
  5206. $label = $this->input->post('rsku', true);
  5207. $sl = $this->input->post('sl', true);
  5208. $warehouse = $this->input->post('warehouse', true);
  5209. if (!$sl) {
  5210. $sl = 1;
  5211. }
  5212. if (!$warehouse) {
  5213. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5214. exit;
  5215. }
  5216. $dblabel = $this->whlabellabel->get_label($label);
  5217. if ($dblabel) {
  5218. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5219. if (count($data) < 1) {
  5220. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5221. exit;
  5222. }
  5223. if ($sl > count($data)) {
  5224. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5225. exit;
  5226. }
  5227. $time = time();
  5228. for ($i = 0; $i < $sl; $i++) {
  5229. $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']);
  5230. }
  5231. echo json_encode(array('success' => true));
  5232. exit;
  5233. } else {
  5234. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5235. exit;
  5236. }
  5237. }
  5238. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5239. $this->_Template('whlabel_dbrk', $this->data);
  5240. }
  5241. public function _whlabelczdc()
  5242. {
  5243. if (isset($_GET['excel'])) {
  5244. //数据排序
  5245. $order_str = "id desc";
  5246. if (empty($page)) {
  5247. $start = 0;
  5248. $perpage = 1;
  5249. } else {
  5250. $start = ($page - 1) * $perpage;
  5251. }
  5252. $state = $this->input->get('state', true);
  5253. $sku = $this->input->get('sku', true);
  5254. $ctime = $this->input->get('ctime', true);
  5255. $category = $this->input->get('category', true);
  5256. $size = $this->input->get('size', true);
  5257. $grade = $this->input->get('grade', true);
  5258. $color = $this->input->get('color', true);
  5259. $lowe = $this->input->get('lowe', true);
  5260. $timetk = $this->input->get('timetkk', true);
  5261. $timetj = $this->input->get('timetjj', true);
  5262. $timetk = strtotime($timetk);
  5263. $timetj = strtotime($timetj);
  5264. $where = "dbtime > 0";
  5265. if ($timetk && $timetj) {
  5266. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5267. }
  5268. if ($category) {
  5269. $where .= " and features like '%-$category-%'";
  5270. }
  5271. if ($size) {
  5272. $where .= " and features like '%-$size-%'";
  5273. }
  5274. if ($grade) {
  5275. $where .= " and features like '%-$grade-%'";
  5276. }
  5277. if ($color) {
  5278. $where .= " and features like '%-$color-%'";
  5279. }
  5280. if ($lowe) {
  5281. $where .= " and features like '%-$lowe-%'";
  5282. }
  5283. //取得信息列表
  5284. $info_list = $this->whlabel->find_all($where, '*');
  5285. $rows = array();
  5286. $list = array();
  5287. foreach ($info_list as $key => $value) {
  5288. $rows[$value['sku']] = $value; //所有数据sku
  5289. }
  5290. foreach ($rows as $value) {
  5291. $warehouse = $this->warehouse->read($value['warehouse']);
  5292. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5293. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5294. if ($value['orderinfo'] == 0) {
  5295. $info_list[$key]['orderinfo'] = "";
  5296. }
  5297. if ($value['waybill'] == 0) {
  5298. $info_list[$key]['waybill'] = "";
  5299. }
  5300. if ($value['state'] == 0) {
  5301. $value['state'] = "在库";
  5302. } else if ($value['state'] == 3) {
  5303. $value['state'] = "调拨中";
  5304. }
  5305. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5306. }
  5307. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5308. $titlename = "<table border=1>
  5309. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5310. <tr align='center'>
  5311. <td>SKU</td>
  5312. <td>产品</td>
  5313. <td>调拨数量</td>
  5314. <td>入库数量</td>
  5315. </tr>
  5316. </table>";
  5317. $filename = $title . ".xls";
  5318. $tail = "";
  5319. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5320. }
  5321. }
  5322. public function _print($arg_array)
  5323. {
  5324. if (isset($_SESSION['api'])) {
  5325. $user = $this->user->get_api($_SESSION['api']);
  5326. $usp = $user;
  5327. $fgshop = "";
  5328. $sid = "";
  5329. $wid = "";
  5330. $wtype = "";
  5331. $usersp = explode('|', trim($user['shop'], '|'));
  5332. $userwh = explode('|', trim($user['warehouse'], '|'));
  5333. foreach ($usersp as $value) {
  5334. $fgshop .= " shop = " . $value . " or";
  5335. $sid .= " id = " . $value . " or";
  5336. }
  5337. foreach ($userwh as $value) {
  5338. $wid .= " id = " . $value . " or";
  5339. $wtype .= " type = " . $value . " or";
  5340. }
  5341. }
  5342. $post = $this->input->post(NULL, TRUE);
  5343. if (isset($post['tmsku'])) {
  5344. $tmsku = $this->input->post('tmsku', true);
  5345. if (is_numeric($tmsku)) {
  5346. $yyh = $this->whlabellabel->get_label($tmsku);
  5347. } else {
  5348. $yyh = $this->whlabellabel->get_sku($tmsku);
  5349. }
  5350. if ($yyh) {
  5351. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5352. exit;
  5353. } else {
  5354. echo json_encode(array('success' => false));
  5355. exit;
  5356. }
  5357. }
  5358. $classid = $this->classid->sku();
  5359. $pm = $classid;
  5360. $scsku = $classid;
  5361. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5362. if (isset($post['warehouse'])) {
  5363. if ($post['warehouse']) {
  5364. $list = array();
  5365. $num = "";
  5366. $title = "";
  5367. $features = "";
  5368. $order = 0;
  5369. $post['shop'] = '';
  5370. $brand = $this->input->post('brand', true);
  5371. if ($brand != '0,') {
  5372. $b = $this->brand->read(rtrim($brand, ','));
  5373. if ($b) {
  5374. $post['shop'] = str_replace('|', ',', $b['shop']);
  5375. }
  5376. }
  5377. $post['details'] = $this->input->post('details', true); //打印数量
  5378. $xbqnum = $this->input->post('xbqnum', true);
  5379. $post['purchase'] = $this->input->post('purchase', true);
  5380. $post['warehouse'] = $this->input->post('warehouse', true);
  5381. $post['purchase'] = $this->input->post('purchase', true);
  5382. $post['retreatwarehouse'] = $post['warehouse'];
  5383. $post['cpbz'] = $this->input->post('cpbz', true);
  5384. $post['state'] = 9;
  5385. $category = $this->input->post('category', true);
  5386. $list['category'] = $category;
  5387. $list['hairtype'] = $this->input->post('hairtype', true);
  5388. $list['grade'] = $this->input->post('grade', true);
  5389. $size = $this->input->post('size', true);
  5390. $list['size'] = rtrim($size, ',');
  5391. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5392. $list['extension'] = $this->input->post('extension', true);
  5393. if ($category == 1297) {
  5394. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5395. }
  5396. if ($category == 1702) {
  5397. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5398. $list['syother'] = $this->input->post('syother', true);
  5399. }
  5400. if ($category == 133) {
  5401. $list['fittype'] = $this->input->post('fittype', true);
  5402. $list['acother'] = $this->input->post('acother', true);
  5403. }
  5404. $list['color'] = $this->input->post('color', true);
  5405. $list['lowe'] = $this->input->post('lowe', true);
  5406. if ($category == 127) {
  5407. $list['type'] = $this->input->post('type', true);
  5408. $list['headroad'] = $this->input->post('headroad', true);
  5409. $list['density'] = $this->input->post('density', true);
  5410. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5411. $list['lacesize'] = $this->input->post('lacesize', true);
  5412. }
  5413. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5414. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5415. }
  5416. if ($category == 128) {
  5417. $list['lacetype'] = $this->input->post('lacetype', true);
  5418. $list['haircap'] = $this->input->post('haircap', true);
  5419. $list['density'] = $this->input->post('density', true);
  5420. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5421. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5422. $list['wigother'] = $this->input->post('wigother', true);
  5423. $list['wigother1'] = $this->input->post('wigother1', true);
  5424. $list['wigother2'] = $this->input->post('wigother2', true);
  5425. }
  5426. if ($category == 129) {
  5427. $list['wide'] = $this->input->post('wide', true);
  5428. }
  5429. if ($category == 131) {
  5430. $list['gifttype'] = $this->input->post('gifttype', true);
  5431. $list['giftother'] = $this->input->post('giftother', true);
  5432. }
  5433. if ($category == 134) {
  5434. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5435. }
  5436. if ($category == 1297) {
  5437. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5438. $list['sywigother'] = $this->input->post('sywigother', true);
  5439. }
  5440. if ($category == 130 || $category == 133 || $category == 1702) {
  5441. $list['items'] = $this->input->post('items', true);
  5442. $list['weight'] = $this->input->post('weight', true);
  5443. }
  5444. if ($category == 1702) {
  5445. $list['syhairther'] = $this->input->post('syhairther', true);
  5446. }
  5447. foreach ($list as $k => $v) {
  5448. if ($v != 0) {
  5449. $num .= $v;
  5450. $features .= $v . '-';
  5451. $post[$k] = $v;
  5452. $typeclass = $this->typeclass->read($v);
  5453. if (isset($pm[$typeclass['classid']])) {
  5454. if (stripos($typeclass['zh'], '|') !== false) {
  5455. $exzh = explode('|', $typeclass['zh']);
  5456. $pm[$typeclass['classid']] = $exzh[0];
  5457. } else {
  5458. $pm[$typeclass['classid']] = $typeclass['zh'];
  5459. }
  5460. }
  5461. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5462. if ($k != 'size') {
  5463. $title .= $typeclass['title'] . " ";
  5464. }
  5465. }
  5466. }
  5467. $typeclass = $this->typeclass->read($list['size']);
  5468. $title .= $typeclass['title'];
  5469. $time = time();
  5470. $post['title'] = rtrim($title, ' ');
  5471. $post['number'] = $num;
  5472. $post['features'] = '-' . $features;
  5473. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5474. $featurespp = explode('-', trim($featurespp, '-'));
  5475. if (isset($featurespp[5])) {
  5476. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5477. } else {
  5478. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5479. }
  5480. $post['enter'] = $time;
  5481. $post['time'] = $time; //操作时间
  5482. $scsku = implode("-", $scsku);
  5483. $zh = implode(" ", $pm);
  5484. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5485. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5486. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5487. $post['sku'] = $bqsku;
  5488. $label = time() . rand(0, 9);
  5489. $post['label'] = $label;
  5490. $cpid = $this->whlabellabel->find_count();
  5491. $post['cpid'] = $cpid + 1;
  5492. $cpid = $post['cpid'];
  5493. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5494. //if($whlabelbarcode)
  5495. //{
  5496. //$post['label'] = $whlabelbarcode['label'];
  5497. //if(!$this->whlabellabel->insert($post))
  5498. //{
  5499. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5500. //}
  5501. //}
  5502. //else
  5503. //{
  5504. $this->db->trans_begin();
  5505. $this->whlabellabel->insert($post);
  5506. //$this->whlabelbarcode->insert($post);
  5507. if ($this->db->trans_status() === TRUE) {
  5508. $this->db->trans_commit();
  5509. } else {
  5510. $this->db->trans_rollback();
  5511. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5512. exit;
  5513. }
  5514. //}
  5515. $warehouse_name = "";
  5516. $warehouse = $post['warehouse'];
  5517. if($warehouse == 12){
  5518. $warehouse_name = "特殊库存库";
  5519. }
  5520. // if($warehouse == 13){
  5521. // $warehouse_name = "许昌仓";
  5522. // }
  5523. // if($warehouse == 5){
  5524. // $warehouse_name = "美国店";
  5525. // }
  5526. // if($warehouse == 16){
  5527. // $warehouse_name = "定制头套仓";
  5528. // }
  5529. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5530. if(!empty($warehouse_name)){
  5531. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5532. }
  5533. $purchase = $this->purchase->read($post['purchase']);
  5534. 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));
  5535. exit; //特殊仓目前不需要仓库选项
  5536. }
  5537. }
  5538. if (isset($_SESSION['api'])) {
  5539. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5540. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5541. $this->data['wlshop'] = $wlshop;
  5542. $this->data['warehouse'] = $warehouse;
  5543. }
  5544. $whlabelwz = $this->whlabelwz->find_all();
  5545. $this->data['whlabelwz'] = $whlabelwz;
  5546. $this->_Template('whlabel_print', $this->data);
  5547. }
  5548. public function _usaprint($arg_array)
  5549. {
  5550. if (isset($_SESSION['api'])) {
  5551. $user = $this->user->get_api($_SESSION['api']);
  5552. $usp = $user;
  5553. $fgshop = "";
  5554. $sid = "";
  5555. $wid = "";
  5556. $wtype = "";
  5557. $usersp = explode('|', trim($user['shop'], '|'));
  5558. $userwh = explode('|', trim($user['warehouse'], '|'));
  5559. foreach ($usersp as $value) {
  5560. $fgshop .= " shop = " . $value . " or";
  5561. $sid .= " id = " . $value . " or";
  5562. }
  5563. foreach ($userwh as $value) {
  5564. $wid .= " id = " . $value . " or";
  5565. $wtype .= " type = " . $value . " or";
  5566. }
  5567. }
  5568. $post = $this->input->post(NULL, TRUE);
  5569. if (isset($post['tmsku'])) {
  5570. $tmsku = $this->input->post('tmsku', true);
  5571. if (is_numeric($tmsku)) {
  5572. $yyh = $this->whlabellabel->get_label($tmsku);
  5573. } else {
  5574. $yyh = $this->whlabellabel->get_sku($tmsku);
  5575. }
  5576. if ($yyh) {
  5577. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5578. exit;
  5579. } else {
  5580. echo json_encode(array('success' => false));
  5581. exit;
  5582. }
  5583. }
  5584. $classid = $this->classid->sku();
  5585. $pm = $classid;
  5586. $scsku = $classid;
  5587. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5588. if (isset($post['warehouse'])) {
  5589. if ($post['warehouse']) {
  5590. $list = array();
  5591. $num = "";
  5592. $title = "";
  5593. $features = "";
  5594. $order = 0;
  5595. $post['shop'] = '';
  5596. $brand = $this->input->post('brand', true);
  5597. if ($brand != '0,') {
  5598. $b = $this->brand->read(rtrim($brand, ','));
  5599. if ($b) {
  5600. $post['shop'] = str_replace('|', ',', $b['shop']);
  5601. }
  5602. }
  5603. $post['details'] = $this->input->post('details', true); //打印数量
  5604. $xbqnum = $this->input->post('xbqnum', true);
  5605. $post['purchase'] = $this->input->post('purchase', true);
  5606. $post['warehouse'] = $this->input->post('warehouse', true);
  5607. $post['purchase'] = $this->input->post('purchase', true);
  5608. $post['retreatwarehouse'] = $post['warehouse'];
  5609. $post['cpbz'] = $this->input->post('cpbz', true);
  5610. $post['state'] = 9;
  5611. $category = $this->input->post('category', true);
  5612. $list['category'] = $category;
  5613. $list['hairtype'] = $this->input->post('hairtype', true);
  5614. $list['grade'] = $this->input->post('grade', true);
  5615. $size = $this->input->post('size', true);
  5616. $list['size'] = rtrim($size, ',');
  5617. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5618. $list['extension'] = $this->input->post('extension', true);
  5619. if ($category == 1297) {
  5620. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5621. }
  5622. if ($category == 1702) {
  5623. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5624. $list['syother'] = $this->input->post('syother', true);
  5625. }
  5626. if ($category == 133) {
  5627. $list['fittype'] = $this->input->post('fittype', true);
  5628. $list['acother'] = $this->input->post('acother', true);
  5629. }
  5630. $list['color'] = $this->input->post('color', true);
  5631. $list['lowe'] = $this->input->post('lowe', true);
  5632. if ($category == 127) {
  5633. $list['type'] = $this->input->post('type', true);
  5634. $list['headroad'] = $this->input->post('headroad', true);
  5635. $list['density'] = $this->input->post('density', true);
  5636. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5637. $list['lacesize'] = $this->input->post('lacesize', true);
  5638. }
  5639. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5640. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5641. }
  5642. if ($category == 128) {
  5643. $list['lacetype'] = $this->input->post('lacetype', true);
  5644. $list['haircap'] = $this->input->post('haircap', true);
  5645. $list['density'] = $this->input->post('density', true);
  5646. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5647. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5648. $list['wigother'] = $this->input->post('wigother', true);
  5649. $list['wigother1'] = $this->input->post('wigother1', true);
  5650. $list['wigother2'] = $this->input->post('wigother2', true);
  5651. }
  5652. if ($category == 129) {
  5653. $list['wide'] = $this->input->post('wide', true);
  5654. }
  5655. if ($category == 131) {
  5656. $list['gifttype'] = $this->input->post('gifttype', true);
  5657. $list['giftother'] = $this->input->post('giftother', true);
  5658. }
  5659. if ($category == 134) {
  5660. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5661. }
  5662. if ($category == 1297) {
  5663. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5664. $list['sywigother'] = $this->input->post('sywigother', true);
  5665. }
  5666. if ($category == 130 || $category == 133 || $category == 1702) {
  5667. $list['items'] = $this->input->post('items', true);
  5668. $list['weight'] = $this->input->post('weight', true);
  5669. }
  5670. if ($category == 1702) {
  5671. $list['syhairther'] = $this->input->post('syhairther', true);
  5672. }
  5673. foreach ($list as $k => $v) {
  5674. if ($v != 0) {
  5675. $num .= $v;
  5676. $features .= $v . '-';
  5677. $post[$k] = $v;
  5678. $typeclass = $this->typeclass->read($v);
  5679. if (isset($pm[$typeclass['classid']])) {
  5680. if (stripos($typeclass['zh'], '|') !== false) {
  5681. $exzh = explode('|', $typeclass['zh']);
  5682. $pm[$typeclass['classid']] = $exzh[0];
  5683. } else {
  5684. $pm[$typeclass['classid']] = $typeclass['zh'];
  5685. }
  5686. }
  5687. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5688. if ($k != 'size') {
  5689. $title .= $typeclass['title'] . " ";
  5690. }
  5691. }
  5692. }
  5693. $typeclass = $this->typeclass->read($list['size']);
  5694. $title .= $typeclass['title'];
  5695. $time = time();
  5696. $post['title'] = rtrim($title, ' ');
  5697. $post['number'] = $num;
  5698. $post['features'] = '-' . $features;
  5699. $fp = $this->whlabel->get_features($post['features']);
  5700. if (!$fp) {
  5701. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5702. exit;
  5703. }
  5704. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5705. $featurespp = explode('-', trim($featurespp, '-'));
  5706. if (isset($featurespp[5])) {
  5707. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5708. } else {
  5709. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5710. }
  5711. $post['enter'] = $time;
  5712. $post['time'] = $time; //操作时间
  5713. $scsku = implode("-", $scsku);
  5714. $zh = implode(" ", $pm);
  5715. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5716. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5717. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5718. $post['sku'] = $fp['sku'];
  5719. $post['label'] = $fp['sku'];
  5720. $cpid = $this->whlabellabel->find_count();
  5721. $post['cpid'] = $cpid + 1;
  5722. $cpid = $post['cpid'];
  5723. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5724. //if($whlabelbarcode)
  5725. //{
  5726. //$post['label'] = $whlabelbarcode['label'];
  5727. //if(!$this->whlabellabel->insert($post))
  5728. //{
  5729. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5730. //}
  5731. //}
  5732. //else
  5733. //{
  5734. $this->db->trans_begin();
  5735. $this->whlabellabel->insert($post);
  5736. //$this->whlabelbarcode->insert($post);
  5737. if ($this->db->trans_status() === TRUE) {
  5738. $this->db->trans_commit();
  5739. } else {
  5740. $this->db->trans_rollback();
  5741. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5742. exit;
  5743. }
  5744. //}
  5745. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5746. $purchase = $this->purchase->read($post['purchase']);
  5747. 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));
  5748. exit; //特殊仓目前不需要仓库选项
  5749. }
  5750. }
  5751. if (isset($_SESSION['api'])) {
  5752. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5753. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5754. $this->data['wlshop'] = $wlshop;
  5755. $this->data['warehouse'] = $warehouse;
  5756. }
  5757. $whlabelwz = $this->whlabelwz->find_all();
  5758. $this->data['whlabelwz'] = $whlabelwz;
  5759. $this->_Template('whlabel_usaprint', $this->data);
  5760. }
  5761. public function _printrk($arg_array)
  5762. {
  5763. $prc = array();
  5764. $purchase = $this->purchase->find_all();
  5765. foreach ($purchase as $k => $v) {
  5766. $prc[$v['id']] = $v['title'];
  5767. }
  5768. $post = $this->input->post(NULL, TRUE);
  5769. if (isset($post['page'])) {
  5770. $page = $this->input->post('page', true);
  5771. $perpage = $this->input->post('perpage', true);
  5772. $sku = $this->input->post('sku', true);
  5773. $bs = $this->input->post('bs', true);
  5774. $number = $this->input->post('number', true);
  5775. $warehouse = $this->input->post('warehouse', true);
  5776. $purchase = $this->input->post('purchase', true);
  5777. $orderinfo = $this->input->post('orderinfo', true);
  5778. $waybill = $this->input->post('waybill', true);
  5779. $category = $this->input->post('category', true);
  5780. $size = $this->input->post('size', true);
  5781. $grade = $this->input->post('grade', true);
  5782. $color = $this->input->post('color', true);
  5783. $lowe = $this->input->post('lowe', true);
  5784. $state = $this->input->post('state', true);
  5785. $label = $this->input->post('label', true);
  5786. $timetk = $this->input->post('ktime', true);
  5787. $timetj = $this->input->post('jtime', true);
  5788. $timetk = strtotime($timetk);
  5789. $timetj = strtotime($timetj);
  5790. $where = "1=1 ";
  5791. if ($timetk && $timetj) {
  5792. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5793. }
  5794. if ($sku) {
  5795. $where .= " and sku = '$sku'";
  5796. }
  5797. if ($bs != '') {
  5798. $where .= " and bs = '$bs'";
  5799. }
  5800. if ($number) {
  5801. $where .= " and number = '$number'";
  5802. }
  5803. if ($warehouse) {
  5804. $where .= " and warehouse = '$warehouse'";
  5805. }
  5806. if ($purchase) {
  5807. $where .= " and purchase = '$purchase'";
  5808. }
  5809. if ($orderinfo) {
  5810. $where .= " and orderinfo = '$orderinfo'";
  5811. }
  5812. if ($waybill) {
  5813. $where .= " and waybill = '$waybill'";
  5814. }
  5815. if ($category) {
  5816. $where .= " and features like '%-$category-%'";
  5817. }
  5818. if ($size) {
  5819. $where .= " and features like '%-$size-%'";
  5820. }
  5821. if ($grade) {
  5822. $where .= " and features like '%-$grade-%'";
  5823. }
  5824. if ($color) {
  5825. $where .= " and features like '%-$color-%'";
  5826. }
  5827. if ($lowe) {
  5828. $where .= " and features like '%-$lowe-%'";
  5829. }
  5830. if ($label) {
  5831. $where .= " and label = '$label'";
  5832. }
  5833. if ($state || $state == 0) {
  5834. $where .= " and state = '$state'";
  5835. }
  5836. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5837. //数据排序
  5838. $order_str = "enter desc";
  5839. if (empty($page)) {
  5840. $start = 0;
  5841. $perpage = 1;
  5842. } else {
  5843. $start = ($page - 1) * $perpage;
  5844. }
  5845. //取得信息列表
  5846. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5847. foreach ($info_list as $key => $value) {
  5848. $warehouse = $this->warehouse->read($value['warehouse']);
  5849. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5850. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5851. if ($value['state'] == 0) {
  5852. $info_list[$key]['state'] = "在库";
  5853. } else if ($value['state'] == 1) {
  5854. $info_list[$key]['state'] = "出库";
  5855. } else if ($value['state'] == 2) {
  5856. $info_list[$key]['state'] = "退库";
  5857. } else if ($value['state'] == 3) {
  5858. $info_list[$key]['state'] = "调拨中";
  5859. } else if ($value['state'] == 4) {
  5860. $info_list[$key]['state'] = "再加工";
  5861. } else if ($value['state'] == 5) {
  5862. $info_list[$key]['state'] = "维修中";
  5863. } else if ($value['state'] == 6) {
  5864. $info_list[$key]['state'] = "盘亏";
  5865. } else if ($value['state'] == 7) {
  5866. $info_list[$key]['state'] = "更换标签";
  5867. } else if ($value['state'] == 8) {
  5868. $info_list[$key]['state'] = "其它";
  5869. } else if ($value['state'] == 9) {
  5870. $info_list[$key]['state'] = "预设";
  5871. } else if ($value['state'] == 10) {
  5872. $info_list[$key]['state'] = "美店零售";
  5873. }
  5874. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5875. }
  5876. $total = $this->$ck->find_count($where);
  5877. $pagenum = ceil($total / $perpage);
  5878. $over = $total - ($start + $perpage);
  5879. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5880. echo json_encode($rows);
  5881. exit;
  5882. }
  5883. if (isset($post['tmsku'])) {
  5884. $time = time();
  5885. $tmsku = $this->input->post('tmsku', true);
  5886. //$post['shop'] = $this->input->post('shop',true);
  5887. $num = $this->input->post('num', true);
  5888. $rktype = $this->input->post('rktype', true);
  5889. if ($num > 200) {
  5890. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5891. exit;
  5892. }
  5893. if (!$rktype) {
  5894. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5895. }
  5896. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5897. /**
  5898. $wz = array();
  5899. foreach ($rk as $key=>$value)
  5900. {
  5901. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5902. }
  5903. if(count($wz) > 1)
  5904. {
  5905. $wz = array_values($wz);
  5906. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5907. }
  5908. **/
  5909. if (isset($rk[0]['purchase'])) {
  5910. $rk = $rk[0];
  5911. $j = 0;
  5912. $post['purchase'] = $rk['purchase'];
  5913. $post['warehouse'] = $rk['warehouse'];
  5914. $post['retreatwarehouse'] = $rk['warehouse'];
  5915. $post['sku'] = $rk['sku'];
  5916. $post['number'] = $rk['number'];
  5917. $post['features'] = $rk['features'];
  5918. $post['title'] = $rk['title'];
  5919. $post['enter'] = $time;
  5920. $post['time'] = $time;
  5921. $post['bs'] = 1;
  5922. $post['shop'] = $rk['shop'];
  5923. $post['details'] = $rk['details'];
  5924. $post['cpid'] = $rk['cpid'];
  5925. $post['cpbz'] = $rk['cpbz'];
  5926. //$post['rktype'] = $rktype;
  5927. $warehouse = $this->warehouse->read($rk['warehouse']);
  5928. if ($warehouse['bdck'] == '') {
  5929. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5930. exit;
  5931. } else {
  5932. $bdck = $warehouse['bdck'];
  5933. }
  5934. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5935. if (isset($pdwz['details'])) {
  5936. if ($pdwz['details'] != $post['details']) {
  5937. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5938. exit;
  5939. }
  5940. }
  5941. $post['featurespp'] = $rk['featurespp'];
  5942. if ($post['warehouse'] == '5') {
  5943. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5944. if ($yza) {
  5945. if ($post['features'] != $yza[0]['features']) {
  5946. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5947. exit;
  5948. }
  5949. }
  5950. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5951. if ($yzb) {
  5952. if ($post['sku'] != $yzb[0]['sku']) {
  5953. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5954. exit;
  5955. }
  5956. }
  5957. }
  5958. for ($i = 0; $i < $num; $i++) {
  5959. $post['label'] = time() . rand(100, 999) . $i;
  5960. if ($this->$bdck->insert($post)) {
  5961. $j++;
  5962. }
  5963. }
  5964. /**
  5965. if($post['warehouse'] != 12)
  5966. {
  5967. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5968. }
  5969. **/
  5970. if ($j == $num) {
  5971. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5972. exit;
  5973. } else {
  5974. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5975. exit;
  5976. }
  5977. } else {
  5978. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5979. exit;
  5980. }
  5981. }
  5982. $this->_Template('whlabel_printrk', $this->data);
  5983. }
  5984. public function _printxzrk($arg_array)
  5985. {
  5986. $post = $this->input->post(NULL, TRUE);
  5987. if (isset($post['wzid'])) {
  5988. $time = time();
  5989. $id = $this->input->post('wzid', true);
  5990. //$post['shop'] = $this->input->post('shop',true);
  5991. $num = 1;
  5992. $rk = $this->whlabellabel->read($id);
  5993. if (isset($rk['purchase'])) {
  5994. $x = 0;
  5995. $post['purchase'] = $rk['purchase'];
  5996. $post['warehouse'] = $rk['warehouse'];
  5997. $post['retreatwarehouse'] = $rk['warehouse'];
  5998. $post['sku'] = $rk['sku'];
  5999. $post['number'] = $rk['number'];
  6000. $post['features'] = $rk['features'];
  6001. $post['title'] = $rk['title'];
  6002. $post['enter'] = $time;
  6003. $post['time'] = $time;
  6004. $post['bs'] = 1;
  6005. $post['shop'] = $rk['shop'];
  6006. $post['details'] = $rk['details'];
  6007. $post['cpid'] = $rk['cpid'];
  6008. $post['cpbz'] = $rk['cpbz'];
  6009. $warehouse = $this->warehouse->read($rk['warehouse']);
  6010. if ($warehouse['bdck'] == '') {
  6011. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6012. exit;
  6013. } else {
  6014. $bdck = $warehouse['bdck'];
  6015. }
  6016. $post['featurespp'] = $rk['featurespp'];
  6017. $this->db->trans_begin();
  6018. for ($i = 0; $i < $num; $i++) {
  6019. $post['label'] = time() . rand(100, 999) . $i;
  6020. $this->$bdck->insert($post);
  6021. }
  6022. /**
  6023. if($post['warehouse'] != 12)
  6024. {
  6025. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6026. }
  6027. **/
  6028. if ($this->db->trans_status() === TRUE) {
  6029. $this->db->trans_commit();
  6030. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6031. exit;
  6032. } else {
  6033. $this->db->trans_rollback();
  6034. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6035. exit;
  6036. }
  6037. } else {
  6038. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6039. exit;
  6040. }
  6041. }
  6042. }
  6043. public function _printck($arg_array)
  6044. {
  6045. $prc = array();
  6046. $purchase = $this->purchase->find_all();
  6047. foreach ($purchase as $k => $v) {
  6048. $prc[$v['id']] = $v['title'];
  6049. }
  6050. $post = $this->input->post(NULL, TRUE);
  6051. if (isset($post['page'])) {
  6052. $page = $this->input->post('page', true);
  6053. $perpage = $this->input->post('perpage', true);
  6054. $sku = $this->input->post('sku', true);
  6055. $bs = $this->input->post('bs', true);
  6056. $number = $this->input->post('number', true);
  6057. $warehouse = $this->input->post('warehouse', true);
  6058. $purchase = $this->input->post('purchase', true);
  6059. $orderinfo = $this->input->post('orderinfo', true);
  6060. $waybill = $this->input->post('waybill', true);
  6061. $category = $this->input->post('category', true);
  6062. $size = $this->input->post('size', true);
  6063. $grade = $this->input->post('grade', true);
  6064. $color = $this->input->post('color', true);
  6065. $lowe = $this->input->post('lowe', true);
  6066. $state = $this->input->post('state', true);
  6067. $label = $this->input->post('label', true);
  6068. $timetk = $this->input->post('ktime', true);
  6069. $timetj = $this->input->post('jtime', true);
  6070. $timetk = strtotime($timetk);
  6071. $timetj = strtotime($timetj);
  6072. $where = "state=1 ";
  6073. if ($timetk && $timetj) {
  6074. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6075. }
  6076. if ($sku) {
  6077. $where .= " and sku = '$sku'";
  6078. }
  6079. if ($bs != '') {
  6080. $where .= " and bs = '$bs'";
  6081. }
  6082. if ($number) {
  6083. $where .= " and number = '$number'";
  6084. }
  6085. if ($warehouse) {
  6086. $where .= " and warehouse = '$warehouse'";
  6087. }
  6088. if ($purchase) {
  6089. $where .= " and purchase = '$purchase'";
  6090. }
  6091. if ($orderinfo) {
  6092. $where .= " and orderinfo = '$orderinfo'";
  6093. }
  6094. if ($waybill) {
  6095. $where .= " and waybill = '$waybill'";
  6096. }
  6097. if ($category) {
  6098. $where .= " and features like '%-$category-%'";
  6099. }
  6100. if ($size) {
  6101. $where .= " and features like '%-$size-%'";
  6102. }
  6103. if ($grade) {
  6104. $where .= " and features like '%-$grade-%'";
  6105. }
  6106. if ($color) {
  6107. $where .= " and features like '%-$color-%'";
  6108. }
  6109. if ($lowe) {
  6110. $where .= " and features like '%-$lowe-%'";
  6111. }
  6112. if ($label) {
  6113. $where .= " and label = '$label'";
  6114. }
  6115. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6116. //数据排序
  6117. $order_str = "outk desc";
  6118. if (empty($page)) {
  6119. $start = 0;
  6120. $perpage = 1;
  6121. } else {
  6122. $start = ($page - 1) * $perpage;
  6123. }
  6124. //取得信息列表
  6125. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6126. foreach ($info_list as $key => $value) {
  6127. $warehouse = $this->warehouse->read($value['warehouse']);
  6128. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6129. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6130. if ($value['state'] == 0) {
  6131. $info_list[$key]['state'] = "在库";
  6132. } else if ($value['state'] == 1) {
  6133. $info_list[$key]['state'] = "出库";
  6134. } else if ($value['state'] == 2) {
  6135. $info_list[$key]['state'] = "退库";
  6136. } else if ($value['state'] == 3) {
  6137. $info_list[$key]['state'] = "调拨中";
  6138. } else if ($value['state'] == 4) {
  6139. $info_list[$key]['state'] = "再加工";
  6140. } else if ($value['state'] == 5) {
  6141. $info_list[$key]['state'] = "维修中";
  6142. } else if ($value['state'] == 6) {
  6143. $info_list[$key]['state'] = "盘亏";
  6144. } else if ($value['state'] == 7) {
  6145. $info_list[$key]['state'] = "更换标签";
  6146. } else if ($value['state'] == 8) {
  6147. $info_list[$key]['state'] = "其它";
  6148. } else if ($value['state'] == 9) {
  6149. $info_list[$key]['state'] = "预设";
  6150. } else if ($value['state'] == 10) {
  6151. $info_list[$key]['state'] = "美店零售";
  6152. }
  6153. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6154. }
  6155. $total = $this->$ck->find_count($where);
  6156. $pagenum = ceil($total / $perpage);
  6157. $over = $total - ($start + $perpage);
  6158. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6159. echo json_encode($rows);
  6160. exit;
  6161. }
  6162. if (isset($post['tmsku'])) {
  6163. $time = time();
  6164. $tmsku = $this->input->post('tmsku', true);
  6165. //$post['shop'] = $this->input->post('shop',true);
  6166. $num = $this->input->post('num', true);
  6167. $cktype = $this->input->post('cktype', true);
  6168. $label = $this->whlabellabel->get_label($tmsku);
  6169. if (!$cktype) {
  6170. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6171. }
  6172. if (!isset($label['warehouse'])) {
  6173. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6174. exit;
  6175. }
  6176. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6177. if (stripos($label['features'], '-126-') !== false) {
  6178. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6179. } else {
  6180. $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 = ''");
  6181. }
  6182. $j = 0;
  6183. if (count($ck) >= $num) {
  6184. for ($i = 0; $i < $num; $i++) {
  6185. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6186. {
  6187. $j++;
  6188. }
  6189. }
  6190. if ($j == $num) {
  6191. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6192. exit;
  6193. } else {
  6194. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6195. exit;
  6196. }
  6197. } else {
  6198. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6199. exit;
  6200. }
  6201. }
  6202. if(isset($_SESSION['api']))
  6203. {
  6204. $user = $this->user->get_api($_SESSION['api']);
  6205. if(in_array($user['power'],[1,27])){
  6206. $vip = 1;
  6207. }
  6208. }
  6209. else
  6210. {
  6211. $vip = 0;
  6212. header('Location: /');exit;
  6213. }
  6214. $this->data['vip'] = $vip;
  6215. $this->_Template('whlabel_printck', $this->data);
  6216. }
  6217. public function _printexcel()
  6218. {
  6219. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6220. $config['upload_path'] = '.' . $dir;
  6221. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6222. $config['allowed_types'] = 'xls|xlsx|csv';
  6223. $config['max_size'] = 10240;
  6224. $this->load->library('upload', $config);
  6225. $this->upload->initialize($config);
  6226. if ($this->upload->do_upload('userfile')) {
  6227. $full_path = $dir . $this->upload->data('file_name');
  6228. $fileName = '.' . $full_path;
  6229. if (!file_exists($fileName)) {
  6230. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6231. exit;
  6232. } else {
  6233. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6234. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6235. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6236. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6237. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6238. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6239. ++$column; //如果列数大于26行
  6240. $list = array();
  6241. for ($i = 2; $i <= $row; $i++) // 行数循环
  6242. {
  6243. $data = array();
  6244. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6245. {
  6246. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6247. }
  6248. $list[] = $data;
  6249. }
  6250. }
  6251. $ed = array();
  6252. $i = 0;
  6253. $j = 0;
  6254. $dcdata = array();
  6255. $yc = '';
  6256. $cmf_arr = array_column($list, '1');
  6257. array_multisort($cmf_arr, SORT_ASC, $list);
  6258. foreach ($list as $key => $value) {
  6259. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6260. if ($typeclass) {
  6261. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6262. } else {
  6263. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6264. $i++;
  6265. continue;
  6266. }
  6267. }
  6268. if ($i > 0) {
  6269. $yc = $i . '条异常';
  6270. }
  6271. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6272. exit;
  6273. }
  6274. }
  6275. public function _uck()
  6276. {
  6277. if (isset($_GET['excel'])) {
  6278. $tc = array();
  6279. $typeclass = $this->typeclass->find_all();
  6280. foreach ($typeclass as $v) {
  6281. $tc[$v['id']] = $v['zh'];
  6282. }
  6283. $data = array();
  6284. $t = array();
  6285. $rq = '';
  6286. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6287. $ts = $ts / (24 * 3600);
  6288. for ($i = 0; $i < $ts; $i++) {
  6289. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6290. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6291. }
  6292. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6293. foreach ($info_list as $k => $v) {
  6294. $features = explode('-', trim($v['features'], '-'));
  6295. if (!isset($features[3]) || !isset($features[4])) {
  6296. continue;
  6297. }
  6298. $data[$k][0] = $tc[$features[0]]; //类型
  6299. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6300. $data[$k][2] = $tc[$features[4]]; //曲度
  6301. $data[$k][3] = '';
  6302. if (isset($data[$k][1])) {
  6303. $data[$k][3] .= $data[$k][1];
  6304. }
  6305. if (isset($data[$k][2])) {
  6306. $data[$k][3] .= $data[$k][2];
  6307. }
  6308. if (isset($features[5])) {
  6309. $data[$k][3] .= $tc[$features[5]];
  6310. }
  6311. if (isset($features[2])) {
  6312. $data[$k][3] .= $tc[$features[2]];
  6313. }
  6314. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6315. $data[$k][4] = $v['sku'];
  6316. $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())) . '))'); //月初库存
  6317. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6318. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6319. $ztrq = '';
  6320. $ztsl = '';
  6321. if (count($zt) > 0) {
  6322. foreach ($zt as $vv) {
  6323. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6324. $ztsl .= $vv['num'] . '<br>';
  6325. }
  6326. }
  6327. $data[$k][] = trim($ztsl, '<br>');
  6328. $data[$k][] = trim($ztrq, '<br>');
  6329. $byck = 0;
  6330. foreach ($t as $vv) {
  6331. $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));
  6332. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6333. $byck += $sl;
  6334. }
  6335. $data[$k][] = ($byck > 0) ? $byck : '';
  6336. }
  6337. $title = "详情 " . date("Y-m-d", time());
  6338. $titlename = "<table border=1>
  6339. <tr align='center'>
  6340. <td>类别</td>
  6341. <td>颜色</td>
  6342. <td>曲度</td>
  6343. <td>名称</td>
  6344. <td>SKU</td>
  6345. <td>月初库存</td>
  6346. <td>剩余库存</td>
  6347. <td>在途数量</td>
  6348. <td>预达日期</td>" .
  6349. $rq
  6350. . "<td>本月出库</td></tr>
  6351. </table>";
  6352. $filename = $title . ".xls";
  6353. $tail = "";
  6354. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6355. }
  6356. }
  6357. public function _whlabelexcelzh()
  6358. {
  6359. if (isset($_GET['excel'])) {
  6360. $where = "sku != 'Preset'";
  6361. //数据排序
  6362. $order_str = "id desc";
  6363. if (empty($page)) {
  6364. $start = 0;
  6365. $perpage = 1;
  6366. } else {
  6367. $start = ($page - 1) * $perpage;
  6368. }
  6369. $category = $this->input->get('category', true);
  6370. $warehouse = $this->input->get('warehouse', true);
  6371. $excelid = $this->input->get('sid', true);
  6372. if ($category) {
  6373. $where .= " and features like '%-$category-%'";
  6374. }
  6375. if ($warehouse) {
  6376. $where .= " and warehouse = '$warehouse'";
  6377. }
  6378. $xzid = '';
  6379. if ($excelid) {
  6380. $excelid = explode(',', trim($excelid, ','));
  6381. foreach ($excelid as $key => $value) {
  6382. $xzid .= " id = " . $value . " or";
  6383. }
  6384. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6385. }
  6386. //取得信息列表
  6387. /**
  6388. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6389. $rows = array();$list = array();
  6390. foreach ($info_list as $key=>$value)
  6391. {
  6392. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6393. }
  6394. **/
  6395. $list = array();
  6396. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6397. foreach ($rows as $key => $value) {
  6398. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6399. $zh = '';
  6400. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6401. foreach ($zt as $v) {
  6402. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6403. }
  6404. $zt = array_sum(array_column($zt, 'num'));
  6405. $number = $value['number'];
  6406. $ftime = time() - 15 * 24 * 3600;
  6407. $warehouse = $this->warehouse->read($value['warehouse']);
  6408. $rows[$key]['warehouse'] = $warehouse['title'];
  6409. $rows[$key]['number'] = $c;
  6410. $rows[$key]['features'] = $zh;
  6411. $rows[$key]['hb'] = $c + $zt;
  6412. }
  6413. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6414. $titlename = "<table border=1>
  6415. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6416. <tr align='center'>
  6417. <td>仓库</td>
  6418. <td>SKU</td>
  6419. <td>产品</td>
  6420. <td>库存数量</td>
  6421. <td>在途数量及预达日期</td>
  6422. <td>在途+库存数量</td>
  6423. </tr>
  6424. </table>";
  6425. $filename = $title . ".xls";
  6426. $tail = "";
  6427. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6428. }
  6429. if (isset($_GET['excel'])) {
  6430. $warehouse = $this->input->get('warehouse', true);
  6431. $sku = $this->input->get('sku', true);
  6432. $cz = $this->input->get('cz', true);
  6433. $text = $this->input->post('text', true);
  6434. $xztime = $this->input->get('xztime', true);
  6435. $timetk = $this->input->get('timetk', true);
  6436. $timetj = $this->input->get('timetj', true);
  6437. $timetk = strtotime($timetk);
  6438. $timetj = strtotime($timetj);
  6439. $where = "time = '0' ";
  6440. if ($warehouse) {
  6441. $where .= " and warehouse = '$warehouse'";
  6442. }
  6443. if ($sku) {
  6444. $where .= " and sku = '$sku'";
  6445. }
  6446. if ($text) {
  6447. $where .= " and text like '%$text%'";
  6448. }
  6449. if ($cz != '') {
  6450. $where .= " and cz = '$cz'";
  6451. }
  6452. if ($timetk && $timetj) {
  6453. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6454. }
  6455. //数据排序
  6456. $order_str = $xztime . " desc";
  6457. //取得信息列表
  6458. $zh = array();
  6459. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6460. foreach ($info_list as $v) {
  6461. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6462. $warehouse = $this->warehouse->read($v['warehouse']);
  6463. $v['warehouse'] = $warehouse['title'];
  6464. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6465. $v['stime'] = date('Y-m-d', $v['stime']);
  6466. if (isset($zh[$v['features']])) {
  6467. $zh[$v['features']]['num'] += $v['num'];
  6468. } else {
  6469. $zh[$v['features']] = $v;
  6470. }
  6471. $zh[$v['features']]['features'] = $c;
  6472. }
  6473. $title = "在途数据" . date('Y-m-d', time());
  6474. $titlename = "<table border=1>
  6475. <tr align='center'>
  6476. <td>仓库</td>
  6477. <td>SKU</td>
  6478. <td>名称</td>
  6479. <td>在途数量</td>
  6480. <td>库存数量</td>
  6481. <td>添加在途日期</td>
  6482. <td>预达日期</td>
  6483. <td>备注</td>
  6484. </tr>
  6485. </table>";
  6486. $filename = $title . ".xls";
  6487. $tail = "";
  6488. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6489. }
  6490. }
  6491. public function _fc()
  6492. {
  6493. $vip = 0;
  6494. if (isset($_SESSION['api'])) {
  6495. $user = $this->user->get_api($_SESSION['api']);
  6496. if ($user['vip'] == 1) {
  6497. $vip = 1;
  6498. }
  6499. } else {
  6500. header('Location: /');
  6501. exit;
  6502. }
  6503. $post = $this->input->post(NULL, TRUE);
  6504. if (isset($post['page'])) {
  6505. $page = $this->input->post('page', true);
  6506. $perpage = $this->input->post('perpage', true);
  6507. $category = $this->input->post('category', true);
  6508. $size = $this->input->post('size', true);
  6509. $grade = $this->input->post('grade', true);
  6510. $color = $this->input->post('color', true);
  6511. $lowe = $this->input->post('lowe', true);
  6512. $sku = $this->input->post('sku');
  6513. $title = $this->input->post('title');
  6514. $warehouse = $this->input->post('warehouse', true);
  6515. $usa = $this->input->post('usa', true);
  6516. $purchase = $this->input->post('purchase', true);
  6517. $lacetype = $this->input->post('lacetype', true);
  6518. $haircap = $this->input->post('haircap', true);
  6519. $density = $this->input->post('density', true);
  6520. $details = $this->input->post('details', true);
  6521. $state = $this->input->post('state', true);
  6522. $ktime = $this->input->post('ktime', true);
  6523. $jtime = $this->input->post('jtime', true);
  6524. $ktime = strtotime($ktime);
  6525. $jtime = strtotime($jtime);
  6526. $where = "state = '11'";
  6527. $gj = "";
  6528. $ck = "";
  6529. if ($lacetype) {
  6530. $where .= " and features like '%-$lacetype-%'";
  6531. }
  6532. if ($category) {
  6533. $where .= " and features like '%-$category-%'";
  6534. }
  6535. if ($size) {
  6536. $where .= " and features like '%-$size-%'";
  6537. }
  6538. if ($grade) {
  6539. $where .= " and features like '%-$grade-%'";
  6540. }
  6541. if ($color) {
  6542. $where .= " and features like '%-$color-%'";
  6543. }
  6544. if ($lowe) {
  6545. $where .= " and features like '%-$lowe-%'";
  6546. }
  6547. if ($haircap) {
  6548. $where .= " and features like '%-$haircap-%'";
  6549. }
  6550. if ($density) {
  6551. $where .= " and features like '%-$density-%'";
  6552. }
  6553. if ($usa) {
  6554. if (!$warehouse) {
  6555. $where .= " and (warehouse = '5' or warehouse = '8')";
  6556. }
  6557. }
  6558. if ($warehouse) {
  6559. $where .= " and warehouse = '$warehouse'";
  6560. }
  6561. if ($details) {
  6562. $where .= " and details = '$details'";
  6563. }
  6564. if ($purchase) {
  6565. $where .= " and purchase = '$purchase'";
  6566. }
  6567. if ($state) {
  6568. $where .= " and state = '$state'";
  6569. }
  6570. if ($ktime && $jtime) {
  6571. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6572. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6573. }
  6574. //数据排序
  6575. $order_str = "id desc";
  6576. if (empty($page)) {
  6577. $start = 0;
  6578. $perpage = 1;
  6579. } else {
  6580. $start = ($page - 1) * $perpage;
  6581. }
  6582. if ($sku) {
  6583. $sku = trim($sku, ' ');
  6584. $sku = trim($sku, ' ');
  6585. $where .= " and sku like '%$sku%'";
  6586. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6587. } else if ($title) {
  6588. $title = trim($title, ' ');
  6589. $title = trim($title, ' ');
  6590. $where .= " and title like '%$title%'";
  6591. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6592. } else {
  6593. //$where .= " and time > '$ktime' and time < '$jtime'";
  6594. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6595. }
  6596. //取得信息列表
  6597. $rows = array();
  6598. $list = array();
  6599. foreach ($info_list as $key => $value) {
  6600. $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'] . '"');
  6601. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6602. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6603. $warehouse = $this->warehouse->read($value['warehouse']);
  6604. $info_list[$key]['warehouse'] = $warehouse['title'];
  6605. $info_list[$key]['number'] = $g;
  6606. $info_list[$key]['features'] = $x;
  6607. $info_list[$key]['x'] = $s;
  6608. }
  6609. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6610. $pagenum = ceil($total / $perpage);
  6611. $over = $total - ($start + $perpage);
  6612. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6613. echo json_encode($rows);
  6614. exit;
  6615. }
  6616. $this->data['vip'] = $vip;
  6617. $this->_Template('whlabel_fc', $this->data);
  6618. }
  6619. public function _fcmb()
  6620. {
  6621. $where = "sku != 'Preset'";
  6622. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6623. foreach ($rows as $k => $v) {
  6624. $warehouse = $this->warehouse->read($v['warehouse']);
  6625. $rows[$k]['warehouse'] = $warehouse['title'];
  6626. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6627. $rows[$k]['t'] = '';
  6628. $rows[$k]['n'] = '';
  6629. }
  6630. $title = "封货产品数据导入模板";
  6631. $titlename = "<table border=1>
  6632. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6633. <tr align='center'>
  6634. <td>仓库</td>
  6635. <td>SKU</td>
  6636. <td>产品</td>
  6637. <td>封存产品总数量</td>
  6638. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6639. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6640. </tr>
  6641. </table>";
  6642. $filename = $title . ".xls";
  6643. $tail = "";
  6644. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6645. }
  6646. public function _fcexcel()
  6647. {
  6648. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6649. $config['upload_path'] = '.' . $dir;
  6650. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6651. $config['allowed_types'] = 'xls|xlsx|csv';
  6652. $config['max_size'] = 10240;
  6653. $this->load->library('upload', $config);
  6654. $this->upload->initialize($config);
  6655. if ($this->upload->do_upload('userfile')) {
  6656. $full_path = $dir . $this->upload->data('file_name');
  6657. $fileName = '.' . $full_path;
  6658. if (!file_exists($fileName)) {
  6659. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6660. exit;
  6661. } else {
  6662. libxml_use_internal_errors(true);
  6663. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6664. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6665. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6666. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6667. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6668. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6669. ++$column; //如果列数大于26行
  6670. $list = array();
  6671. for ($i = 2; $i <= $row; $i++) // 行数循环
  6672. {
  6673. $data = array();
  6674. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6675. {
  6676. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6677. }
  6678. $list[] = $data;
  6679. }
  6680. }
  6681. $i = 0;
  6682. $j = 0;
  6683. $ed = array();
  6684. foreach ($list as $key => $value) {
  6685. $time = time();
  6686. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6687. continue;
  6688. }
  6689. $warehouse = $this->warehouse->get_title($value['0']);
  6690. $sku = $value['1'];
  6691. $type = $value['4']; //调整方式0扣减1删除
  6692. $num = $value['5']; //调整数量
  6693. //$text = $value['4'];//扣减说明
  6694. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6695. if (!$d) //如果没有这个SKU
  6696. {
  6697. $ed[] = array($sku . '-库存中不存在此SKU');
  6698. $j++;
  6699. continue;
  6700. }
  6701. if (!isset($warehouse['id'])) {
  6702. $ed[] = array($sku . '-仓库名错误!');
  6703. $j++;
  6704. continue;
  6705. }
  6706. if ($type == 1 || $type == 2) //扣减库存
  6707. {
  6708. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6709. if (count($data) < abs($num)) {
  6710. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6711. $j++;
  6712. continue;
  6713. }
  6714. if ($type == 1) //转入库存
  6715. {
  6716. for ($i = 0; $i < abs($num); $i++) {
  6717. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6718. }
  6719. } else if ($type == 2) //删除
  6720. {
  6721. for ($i = 0; $i < abs($num); $i++) {
  6722. $this->whlabel->remove($data[$i]['id']);
  6723. }
  6724. }
  6725. } else if ($type == 0) //增加库存
  6726. {
  6727. $post['sku'] = $d['sku'];
  6728. $post['shop'] = '';
  6729. $post['warehouse'] = $warehouse['id'];
  6730. $post['purchase'] = $d['purchase'];
  6731. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6732. $post['state'] = 11;
  6733. $post['title'] = $d['title'];
  6734. $post['number'] = $d['number'];
  6735. $post['features'] = $d['features'];
  6736. $post['enter'] = $time;
  6737. $post['time'] = $time; //操作时间
  6738. for ($i = 0; $i < $num; $i++) {
  6739. $post['label'] = time() . rand(100, 999) . $i;
  6740. $this->whlabel->insert($post);
  6741. }
  6742. }
  6743. sleep(1); //防止入库时间一样,需要延迟1秒
  6744. }
  6745. if ($j > 0) {
  6746. $tt = date('Ymd', time());
  6747. $title = '库存导入错误信息-' . $tt;
  6748. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6749. $tail = "\n";
  6750. $filename = $title . ".xls";
  6751. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6752. $dir = '/data/excel/' . $time . '/';
  6753. $file_name = 'error_' . $time . rand(1000, 9999);
  6754. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6755. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6756. fwrite($myfile, $ecl);
  6757. fclose($myfile);
  6758. $error = $dir . $file_name . '.xls';
  6759. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6760. exit;
  6761. } else {
  6762. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6763. exit;
  6764. }
  6765. }
  6766. }
  6767. public function _fcjxc($arg_array)
  6768. {
  6769. if (isset($_GET['excel'])) {
  6770. $category = $this->input->get('category', true);
  6771. $size = $this->input->get('size', true);
  6772. $grade = $this->input->get('grade', true);
  6773. $color = $this->input->get('color', true);
  6774. $lowe = $this->input->get('lowe', true);
  6775. $sku = $this->input->get('sku');
  6776. $title = $this->input->get('title');
  6777. $warehouse = $arg_array[0];
  6778. $usa = $this->input->get('usa', true);
  6779. $purchase = $this->input->get('purchase', true);
  6780. $lacetype = $this->input->get('lacetype', true);
  6781. $haircap = $this->input->get('haircap', true);
  6782. $density = $this->input->get('density', true);
  6783. $title = $this->input->get('title', true);
  6784. $state = $this->input->get('state', true);
  6785. $ktime = $this->input->get('ktime', true);
  6786. $jtime = $this->input->get('jtime', true);
  6787. $where = "state=11";
  6788. $gj = "";
  6789. $ck = "";
  6790. if ($lacetype) {
  6791. $where .= " and features like '%-$lacetype-%'";
  6792. }
  6793. if ($category) {
  6794. $where .= " and features like '%-$category-%'";
  6795. }
  6796. if ($size) {
  6797. $where .= " and features like '%-$size-%'";
  6798. }
  6799. if ($grade) {
  6800. $where .= " and features like '%-$grade-%'";
  6801. }
  6802. if ($color) {
  6803. $where .= " and features like '%-$color-%'";
  6804. }
  6805. if ($lowe) {
  6806. $where .= " and features like '%-$lowe-%'";
  6807. }
  6808. if ($haircap) {
  6809. $where .= " and features like '%-$haircap-%'";
  6810. }
  6811. if ($density) {
  6812. $where .= " and features like '%-$density-%'";
  6813. }
  6814. if ($usa) {
  6815. if (!$warehouse) {
  6816. $where .= " and (warehouse = '5' or warehouse = '8')";
  6817. }
  6818. }
  6819. if ($warehouse) {
  6820. $where .= " and warehouse = '$warehouse'";
  6821. }
  6822. if ($purchase) {
  6823. $where .= " and purchase = '$purchase'";
  6824. }
  6825. if ($state) {
  6826. $where .= " and state = '$state'";
  6827. }
  6828. $order_str = "id desc";
  6829. if ($sku) {
  6830. $sku = trim($sku, ' ');
  6831. $sku = trim($sku, ' ');
  6832. $where .= " and sku like '%$sku%'";
  6833. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6834. } else if ($title) {
  6835. $title = trim($title, ' ');
  6836. $title = trim($title, ' ');
  6837. $where .= " and title like '%$title%'";
  6838. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6839. } else {
  6840. //$where .= " and time > '$ktime' and time < '$jtime'";
  6841. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6842. }
  6843. //取得信息列表
  6844. $rows = array();
  6845. $list = array();
  6846. foreach ($info_list as $key => $value) {
  6847. $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'] . '"');
  6848. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6849. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6850. $rows[$key] = $value;
  6851. $warehouse = $this->warehouse->read($value['warehouse']);
  6852. $rows[$key]['warehouse'] = $warehouse['title'];
  6853. $rows[$key]['features'] = $g;
  6854. $rows[$key]['a'] = $x;
  6855. $rows[$key]['b'] = $s;
  6856. }
  6857. $title = "总统计表";
  6858. $titlename = "<table border=1>
  6859. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6860. <tr align='center'>
  6861. <td>仓库</td>
  6862. <td>SKU</td>
  6863. <td>产品名称</td>
  6864. <td>录入总量</td>
  6865. <td>取出总量</td>
  6866. <td>剩余总量</td>
  6867. </tr>
  6868. </table>";
  6869. $filename = $title . ".xls";
  6870. $tail = "";
  6871. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6872. }
  6873. $vip = 0;
  6874. if (isset($_SESSION['api'])) {
  6875. $user = $this->user->get_api($_SESSION['api']);
  6876. if ($user['vip'] == 1) {
  6877. $vip = 1;
  6878. }
  6879. } else {
  6880. header('Location: /');
  6881. exit;
  6882. }
  6883. $post = $this->input->post(NULL, TRUE);
  6884. if (isset($post['page'])) {
  6885. $page = $this->input->post('page', true);
  6886. $perpage = $this->input->post('perpage', true);
  6887. $category = $this->input->post('category', true);
  6888. $size = $this->input->post('size', true);
  6889. $grade = $this->input->post('grade', true);
  6890. $color = $this->input->post('color', true);
  6891. $lowe = $this->input->post('lowe', true);
  6892. $sku = $this->input->post('sku');
  6893. $title = $this->input->post('title');
  6894. $warehouse = $arg_array[0];
  6895. $usa = $this->input->post('usa', true);
  6896. $purchase = $this->input->post('purchase', true);
  6897. $lacetype = $this->input->post('lacetype', true);
  6898. $haircap = $this->input->post('haircap', true);
  6899. $density = $this->input->post('density', true);
  6900. $title = $this->input->post('title', true);
  6901. $state = $this->input->post('state', true);
  6902. $ktime = $this->input->post('ktime', true);
  6903. $jtime = $this->input->post('jtime', true);
  6904. $ktime = strtotime($ktime);
  6905. $jtime = strtotime($jtime);
  6906. $where = "state=11";
  6907. $gj = "";
  6908. $ck = "";
  6909. if ($lacetype) {
  6910. $where .= " and features like '%-$lacetype-%'";
  6911. }
  6912. if ($category) {
  6913. $where .= " and features like '%-$category-%'";
  6914. }
  6915. if ($size) {
  6916. $where .= " and features like '%-$size-%'";
  6917. }
  6918. if ($grade) {
  6919. $where .= " and features like '%-$grade-%'";
  6920. }
  6921. if ($color) {
  6922. $where .= " and features like '%-$color-%'";
  6923. }
  6924. if ($lowe) {
  6925. $where .= " and features like '%-$lowe-%'";
  6926. }
  6927. if ($haircap) {
  6928. $where .= " and features like '%-$haircap-%'";
  6929. }
  6930. if ($density) {
  6931. $where .= " and features like '%-$density-%'";
  6932. }
  6933. if ($usa) {
  6934. if (!$warehouse) {
  6935. $where .= " and (warehouse = '5' or warehouse = '8')";
  6936. }
  6937. }
  6938. if ($warehouse) {
  6939. $where .= " and warehouse = '$warehouse'";
  6940. }
  6941. if ($purchase) {
  6942. $where .= " and purchase = '$purchase'";
  6943. }
  6944. if ($state) {
  6945. $where .= " and state = '$state'";
  6946. }
  6947. if ($ktime && $jtime) {
  6948. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6949. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6950. }
  6951. //数据排序
  6952. $order_str = "id desc";
  6953. $xs = 0;
  6954. $rows = array();
  6955. $list = array();
  6956. if (empty($page)) {
  6957. $start = 0;
  6958. $perpage = 1;
  6959. } else {
  6960. $start = ($page - 1) * $perpage;
  6961. }
  6962. if ($sku || $title) {
  6963. if ($title) {
  6964. $title = trim($title, ' ');
  6965. $title = trim($title, ' ');
  6966. $where .= " and title like '%$title%'";
  6967. } else {
  6968. $sku = trim($sku, ' ');
  6969. $sku = trim($sku, ' ');
  6970. $where .= " and sku like '%$sku%'";
  6971. }
  6972. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6973. foreach ($info_list as $key => $value) {
  6974. $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'] . '"');
  6975. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6976. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6977. $rows[$key] = $value;
  6978. $warehouse = $this->warehouse->read($value['warehouse']);
  6979. $rows[$key]['warehouse'] = $warehouse['title'];
  6980. $rows[$key]['features'] = $g;
  6981. $rows[$key]['a'] = $x;
  6982. $rows[$key]['b'] = $s;
  6983. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6984. $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天销量
  6985. $yj = $c / ($xl / 30);
  6986. if ($yj < 7) {
  6987. $rows[$key]['y'] = round($yj) . '天销量';
  6988. } else {
  6989. $rows[$key]['y'] = '正常';
  6990. }
  6991. }
  6992. } else {
  6993. //$where .= " and time > '$ktime' and time < '$jtime'";
  6994. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6995. foreach ($info_list as $key => $value) {
  6996. $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'] . '"');
  6997. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6998. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6999. $zs[$key] = $value;
  7000. $warehouse = $this->warehouse->read($value['warehouse']);
  7001. $zs[$key]['warehouse'] = $warehouse['title'];
  7002. $zs[$key]['features'] = $g;
  7003. $zs[$key]['a'] = $x;
  7004. $zs[$key]['b'] = $s;
  7005. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7006. $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天销量
  7007. $yj = $c / ($xl / 30);
  7008. if ($yj < 7) {
  7009. $zs[$key]['y'] = round($yj) . '天销量';
  7010. $rows[$key] = $zs[$key];
  7011. }
  7012. }
  7013. }
  7014. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7015. $pagenum = ceil($total / $perpage);
  7016. $over = $total - ($start + $perpage);
  7017. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7018. echo json_encode($rows);
  7019. exit;
  7020. }
  7021. $this->data['arg_array'] = $arg_array[0];
  7022. $this->_Template('whlabel_fcjxc', $this->data);
  7023. }
  7024. public function _0kcdel()
  7025. {
  7026. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7027. $config['upload_path'] = '.' . $dir;
  7028. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7029. $config['allowed_types'] = 'xls|xlsx|csv';
  7030. $config['max_size'] = 10240;
  7031. $this->load->library('upload', $config);
  7032. $this->upload->initialize($config);
  7033. if ($this->upload->do_upload('userfile')) {
  7034. $full_path = $dir . $this->upload->data('file_name');
  7035. $fileName = '.' . $full_path;
  7036. if (!file_exists($fileName)) {
  7037. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7038. exit;
  7039. } else {
  7040. require_once "./data/excel/PHPExcel/IOFactory.php";
  7041. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7042. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7043. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7044. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7045. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7046. ++$column; //如果列数大于26行
  7047. $list = array();
  7048. for ($i = 2; $i <= $row; $i++) // 行数循环
  7049. {
  7050. $data = array();
  7051. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7052. {
  7053. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7054. }
  7055. $list[] = $data;
  7056. }
  7057. }
  7058. $i = 0;
  7059. $j = 0;
  7060. $ed = array();
  7061. foreach ($list as $key => $value) {
  7062. $time = time();
  7063. if ($value['0'] == "" || $value['1'] == "") {
  7064. continue;
  7065. }
  7066. $warehouse = $this->warehouse->get_title($value['0']);
  7067. $sku = $value['1'];
  7068. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7069. if (!$d) //如果没有这个SKU
  7070. {
  7071. $ed[] = array($sku . '-库存中不存在此SKU');
  7072. $j++;
  7073. continue;
  7074. }
  7075. if (!isset($warehouse['id'])) {
  7076. $ed[] = array($sku . '-仓库名错误!');
  7077. $j++;
  7078. continue;
  7079. }
  7080. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7081. if ($z < 1) {
  7082. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7083. foreach ($z as $v) {
  7084. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7085. if (count($zt) > 0) {
  7086. $ed[] = array($sku . '-有在途库存无法删除!');
  7087. $j++;
  7088. continue;
  7089. }
  7090. $this->whlabel->remove($v['id']);
  7091. }
  7092. } else {
  7093. $ed[] = array($sku . '-非0库存!');
  7094. $j++;
  7095. continue;
  7096. }
  7097. }
  7098. if ($j > 0) {
  7099. $tt = date('Ymd', time());
  7100. $title = '删除0库存错误信息-' . $tt;
  7101. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7102. $tail = "\n";
  7103. $filename = $title . ".xls";
  7104. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7105. $dir = '/data/excel/' . $time . '/';
  7106. $file_name = 'error_' . $time . rand(1000, 9999);
  7107. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7108. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7109. fwrite($myfile, $ecl);
  7110. fclose($myfile);
  7111. $error = $dir . $file_name . '.xls';
  7112. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7113. exit;
  7114. } else {
  7115. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7116. exit;
  7117. }
  7118. }
  7119. }
  7120. public function _gbhtype()
  7121. {
  7122. $post = $this->input->post(NULL, TRUE);
  7123. if (isset($post['s'])) {
  7124. $n = $this->input->post('n');
  7125. $d = $this->input->post('s');
  7126. if (!$d) {
  7127. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7128. exit;
  7129. }
  7130. $d = explode(',', trim($d, ','));
  7131. $t = $this->whlabel_type->read($n);
  7132. //循环删除记录
  7133. foreach ($d as $v) {
  7134. $u = $this->whlabel->read($v);
  7135. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7136. foreach ($data as $val) {
  7137. $this->whlabel->save(array('type' => $n), $val['id']);
  7138. }
  7139. }
  7140. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7141. }
  7142. }
  7143. //出库、退库导出
  7144. public function _dccrtype()
  7145. {
  7146. $classid = $this->classid->sku();
  7147. $pm = $classid;
  7148. $typeclass = array();
  7149. $tc = $this->typeclass->find_all();
  7150. foreach ($tc as $v) {
  7151. $typeclass[$v['id']] = $v;
  7152. }
  7153. $prc = array();
  7154. $purchase = $this->purchase->find_all();
  7155. foreach ($purchase as $k => $v) {
  7156. $prc[$v['id']] = $v['title'];
  7157. }
  7158. if (isset($_GET['sid'])) {
  7159. $wh = array();
  7160. $w = $this->warehouse->find_all('1=1', 'id,title');
  7161. foreach ($w as $v) {
  7162. $wh[$v['id']] = $v['title'];
  7163. }
  7164. $type = $this->input->get('excel', true);
  7165. $category = $this->input->get('category', true);
  7166. $size = $this->input->get('size', true);
  7167. $grade = $this->input->get('grade', true);
  7168. $color = $this->input->get('color', true);
  7169. $lowe = $this->input->get('lowe', true);
  7170. $sku = $this->input->get('sku', true);
  7171. $warehouse = $this->input->get('warehouse', true);
  7172. $lacetype = $this->input->get('lacetype', true);
  7173. $lacecolor = $this->input->get('lacecolor', true);
  7174. $density = $this->input->get('density', true);
  7175. $haircap = $this->input->get('haircap', true);
  7176. $purchase = $this->input->get('purchase', true);
  7177. $title = $this->input->get('title', true);
  7178. $state = $this->input->get('state', true);
  7179. $sid = $this->input->get('sid', true);
  7180. $ktime = $this->input->get('ktime', true);
  7181. $jtime = $this->input->get('jtime', true);
  7182. $ktime = strtotime($ktime);
  7183. $jtime = strtotime($jtime);
  7184. $where = "1=1";
  7185. $gj = "";
  7186. $ck = "";
  7187. if ($category) {
  7188. $where .= " and features like '%-$category-%'";
  7189. }
  7190. if ($size) {
  7191. $where .= " and features like '%-$size-%'";
  7192. }
  7193. if ($grade) {
  7194. $where .= " and features like '%-$grade-%'";
  7195. }
  7196. if ($color) {
  7197. $where .= " and features like '%-$color-%'";
  7198. }
  7199. if ($lowe) {
  7200. $where .= " and features like '%-$lowe-%'";
  7201. }
  7202. if ($warehouse) {
  7203. $where .= " and warehouse = '$warehouse'";
  7204. }
  7205. if ($purchase) {
  7206. $where .= " and purchase = '$purchase'";
  7207. }
  7208. if ($state) {
  7209. $where .= " and state = '$state'";
  7210. }
  7211. if ($lacetype) {
  7212. $where .= " and features like '%-$lacetype-%'";
  7213. }
  7214. if ($lacecolor) {
  7215. $where .= " and features like '%-$lacecolor-%'";
  7216. }
  7217. if ($density) {
  7218. $where .= " and features like '%-$density-%'";
  7219. }
  7220. if ($haircap) {
  7221. $where .= " and features like '%-$haircap-%'";
  7222. }
  7223. if ($title) {
  7224. $title = trim($title, ' ');
  7225. $title = trim($title, ' ');
  7226. $where .= " and title like '%$title%'";
  7227. }
  7228. if ($sku) {
  7229. $sku = trim($sku, ' ');
  7230. $sku = trim($sku, ' ');
  7231. $where .= " and sku like '%$sku%'";
  7232. }
  7233. if ($ktime && $jtime) {
  7234. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7235. }
  7236. $sidwhere = '';
  7237. if ($sid) {
  7238. $sd = "";
  7239. $s = explode(',', trim($sid, ','));
  7240. foreach ($s as $value) {
  7241. $sd .= " id = " . $value . " or";
  7242. }
  7243. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7244. }
  7245. //数据排序
  7246. $order_str = "time desc";
  7247. if (empty($page)) {
  7248. $start = 0;
  7249. $perpage = 1;
  7250. } else {
  7251. $start = ($page - 1) * $perpage;
  7252. }
  7253. $wh = array();
  7254. $w = $this->warehouse->find_all('1=1', 'id,title');
  7255. foreach ($w as $v) {
  7256. $wh[$v['id']] = $v['title'];
  7257. }
  7258. $wt = array();
  7259. $whlabel_type = $this->whlabel_type->find_all();
  7260. foreach ($whlabel_type as $v) {
  7261. $wt[$v['id']] = $v['title'];
  7262. }
  7263. $classid = $this->classid->sku();
  7264. $list = array();
  7265. $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');
  7266. foreach ($rows_r as $key => $value) {
  7267. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7268. $pm = $classid;
  7269. $jm = $classid;
  7270. $rows_r[$key]['enter'] = '入库';
  7271. $rows_r[$key]['time'] = $value['enter'];
  7272. if ($value['rktype'] == 1) {
  7273. $rows_r[$key]['rktype'] = '采购入库';
  7274. } else if ($value['rktype'] == 2) {
  7275. $rows_r[$key]['rktype'] = '盘盈调整';
  7276. } else if ($value['rktype'] == 3) {
  7277. $rows_r[$key]['rktype'] = '其他调整入库';
  7278. } else if ($value['rktype'] == 4) {
  7279. $rows_r[$key]['rktype'] = '其他调整入库';
  7280. } else if ($value['rktype'] == 5) {
  7281. $rows_r[$key]['rktype'] = '退库入库';
  7282. } else if ($value['rktype'] == 6) {
  7283. $rows_r[$key]['rktype'] = '退货可用入库';
  7284. } else if ($value['rktype'] == 7) {
  7285. $rows_r[$key]['rktype'] = '形态转换入库';
  7286. } else {
  7287. $rows_r[$key]['rktype'] = '';
  7288. }
  7289. $features = explode('-', trim($value['features'], '-'));
  7290. foreach ($features as $v) {
  7291. if (isset($typeclass[$v])) {
  7292. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7293. $pm[$typeclass[$v]['classid']] = $zh[0];
  7294. }
  7295. if (isset($typeclass[$v])) {
  7296. if (isset($jm[$typeclass[$v]['classid']])) {
  7297. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7298. }
  7299. }
  7300. }
  7301. $zh = implode(" ", $pm);
  7302. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7303. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7304. $rows_r[$key]['zh'] = $zh;
  7305. $jm = array_filter($jm);
  7306. $rows_r[$key]['features'] = implode("-", $jm);
  7307. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7308. }
  7309. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7310. foreach ($rows_c as $key => $value) {
  7311. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7312. $pm = $classid;
  7313. $jm = $classid;
  7314. $rows_c[$key]['time'] = $value['outk'];
  7315. $rows_c[$key]['outk'] = '出库';
  7316. if ($value['cktype'] == 1) {
  7317. $rows_c[$key]['cktype'] = '销售出库';
  7318. } else if ($value['cktype'] == 2) {
  7319. $rows_c[$key]['cktype'] = '销售美国出库';
  7320. } else if ($value['cktype'] == 3) {
  7321. $rows_c[$key]['cktype'] = '盘亏调整';
  7322. } else if ($value['cktype'] == 4) {
  7323. $rows_c[$key]['cktype'] = '其他调整出库';
  7324. } else if ($value['cktype'] == 5) {
  7325. $rows_c[$key]['cktype'] = '形态转换出库';
  7326. } else {
  7327. $rows_c[$key]['cktype'] = '';
  7328. }
  7329. $features = explode('-', trim($value['features'], '-'));
  7330. foreach ($features as $v) {
  7331. if (isset($typeclass[$v])) {
  7332. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7333. $pm[$typeclass[$v]['classid']] = $zh[0];
  7334. }
  7335. if (isset($typeclass[$v])) {
  7336. if (isset($jm[$typeclass[$v]['classid']])) {
  7337. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7338. }
  7339. }
  7340. }
  7341. $zh = implode(" ", $pm);
  7342. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7343. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7344. $rows_c[$key]['zh'] = $zh;
  7345. $jm = array_filter($jm);
  7346. $rows_c[$key]['features'] = implode("-", $jm);
  7347. $rows_c[$key]['number'] = 1;
  7348. }
  7349. $merged = $rows_r;
  7350. foreach ($rows_c as $key => $value) {
  7351. if (isset($merged[$key])) {
  7352. $merged[] = $value;
  7353. } else {
  7354. $merged[$key] = $value;
  7355. }
  7356. }
  7357. usort($merged, function ($a, $b) {
  7358. return $a['time'] - $b['time'];
  7359. });
  7360. foreach ($merged as $key => $value) {
  7361. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7362. }
  7363. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7364. $titlename = "<table border=1>
  7365. <tr align='center'>
  7366. <td>仓库</td>
  7367. <td>SKU</td>
  7368. <td>商品名称</td>
  7369. <td>仓库品名</td>
  7370. <td>料号</td>
  7371. <td>时间</td>
  7372. <td>操作</td>
  7373. <td>类型</td>
  7374. <td>数量</td>
  7375. <td>备注</td>
  7376. </tr>
  7377. </table>";
  7378. $filename = $title . ".xlsx";
  7379. $tail = "";
  7380. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7381. }
  7382. }
  7383. }