Whlabel.php 259 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $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. $cz = $this->input->post('cz', true);
  333. if ($cz == '1') {
  334. $sku = $this->input->post('outsku', true);
  335. if ($sku) {
  336. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  337. if (count($data) < 1) {
  338. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  339. exit;
  340. }
  341. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 1), $data[0]['id']);
  342. echo json_encode(array('success' => true));
  343. exit;
  344. }
  345. } else {
  346. $sku = $this->input->post('outsku', true);
  347. if ($sku) {
  348. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  349. if (count($data) < 1) {
  350. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  351. exit;
  352. }
  353. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  354. echo json_encode(array('success' => true));
  355. exit;
  356. }
  357. }
  358. }
  359. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  360. $this->_Template('whlabel', $this->data);
  361. }
  362. //在库标签
  363. public function _existence()
  364. {
  365. $post = $this->input->post(NULL, TRUE);
  366. if (isset($post['s'])) {
  367. $id_arr = $this->input->post('s');
  368. $id_arr = explode(',', $id_arr);
  369. if (!$id_arr) {
  370. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  371. exit;
  372. }
  373. //循环删除记录
  374. foreach ($id_arr as $v) {
  375. $sid = $this->whlabel->read($v);
  376. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  377. if ($count > 0) {
  378. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  379. exit;
  380. }
  381. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  382. if (count($zt) > 0) {
  383. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  384. exit;
  385. }
  386. $this->whlabel->remove($v);
  387. }
  388. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  389. exit;
  390. }
  391. if (isset($post['page'])) {
  392. $page = $this->input->post('page', true);
  393. $perpage = $this->input->post('perpage', true);
  394. $warehouse = $this->input->post('warehouse', true);
  395. $label = $this->input->post('label', true);
  396. $where = "1=1 and state = 0";
  397. if ($warehouse) {
  398. $where .= " and warehouse = '$warehouse'";
  399. }
  400. if ($label) {
  401. $where .= " and label = '$label'";
  402. }
  403. //数据排序
  404. $order_str = "time asc";
  405. if (empty($page)) {
  406. $start = 0;
  407. $perpage = 1;
  408. } else {
  409. $start = ($page - 1) * $perpage;
  410. }
  411. //取得信息列表
  412. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  413. foreach ($info_list as $key => $value) {
  414. if ($value['enter'] != 0) {
  415. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  416. } else {
  417. $info_list[$key]['enter'] = "";
  418. }
  419. if ($value['printing'] != 0) {
  420. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  421. } else {
  422. $info_list[$key]['printing'] = "";
  423. }
  424. }
  425. $total = $this->whlabel->find_count($where);
  426. $pagenum = ceil($total / $perpage);
  427. $over = $total - ($start + $perpage);
  428. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  429. echo json_encode($rows);
  430. exit;
  431. }
  432. $this->_Template('whlabel_existence', $this->data);
  433. }
  434. //进销存浏览
  435. public function _typedy($arg_array)
  436. {
  437. $prc = array();
  438. $purchase = $this->purchase->find_all();
  439. foreach ($purchase as $k => $v) {
  440. $prc[$v['id']] = $v['title'];
  441. }
  442. $post = $this->input->post(NULL, TRUE);
  443. if (isset($post['page'])) {
  444. $page = $this->input->post('page', true);
  445. $perpage = $this->input->post('perpage', true);
  446. $category = $this->input->post('category', true);
  447. $size = $this->input->post('size', true);
  448. $grade = $this->input->post('grade', true);
  449. $color = $this->input->post('color', true);
  450. $lowe = $this->input->post('lowe', true);
  451. $sku = $this->input->post('sku');
  452. $title = $this->input->post('title');
  453. $warehouse = $this->input->post('warehouse', true);
  454. $usa = $this->input->post('usa', true);
  455. $purchase = $this->input->post('purchase', true);
  456. $lacetype = $this->input->post('lacetype', true);
  457. $haircap = $this->input->post('haircap', true);
  458. $density = $this->input->post('density', true);
  459. $details = $this->input->post('details', true);
  460. $state = $this->input->post('state', true);
  461. $lacecolor = $this->input->post('lacecolor', true);
  462. $hairnumber = $this->input->post('hairnumber', true);
  463. $cklx = $this->input->post('cklx', true);
  464. $ktime = $this->input->post('ktime', true);
  465. $jtime = $this->input->post('jtime', true);
  466. $sm = $this->input->post('sm', true);
  467. $cpbz = $this->input->post('cpbz', true);
  468. $type = $this->input->post('type', true);
  469. $ktime = strtotime($ktime);
  470. $jtime = strtotime($jtime);
  471. $where = "1=1";
  472. $gj = "";
  473. $ck = "";
  474. if ($usa) {
  475. if (!$warehouse) {
  476. $where .= " and (warehouse = '5' or warehouse = '8')";
  477. }
  478. }
  479. if ($warehouse) {
  480. $where .= " and warehouse = '$warehouse'";
  481. }
  482. if ($details) {
  483. $where .= " and details = '$details'";
  484. }
  485. if ($purchase) {
  486. $where .= " and purchase = '$purchase'";
  487. }
  488. if ($state) {
  489. $where .= " and state = '$state'";
  490. }
  491. if ($lacetype) {
  492. $where .= " and features like '%-$lacetype-%'";
  493. }
  494. if ($category) {
  495. $where .= " and features like '%-$category-%'";
  496. }
  497. if ($size) {
  498. $where .= " and features like '%-$size-%'";
  499. }
  500. if ($grade) {
  501. $where .= " and features like '%-$grade-%'";
  502. }
  503. if ($color) {
  504. $where .= " and features like '%-$color-%'";
  505. }
  506. if ($lowe) {
  507. $where .= " and features like '%-$lowe-%'";
  508. }
  509. if ($haircap) {
  510. $where .= " and features like '%-$haircap-%'";
  511. }
  512. if ($density) {
  513. $where .= " and features like '%-$density-%'";
  514. }
  515. if ($lacecolor) {
  516. $where .= " and features like '%-$lacecolor-%'";
  517. }
  518. if($sm){
  519. $where .= " and sm like '%".$sm."%'";
  520. }
  521. if($cpbz){
  522. $where .= " and cpbz like '%".$cpbz."%'";
  523. }
  524. if($type){
  525. $where .= " and type = ".$type."";
  526. }
  527. if (!empty($hairnumber)) {
  528. $where .= " and features like '%-128-%' ";
  529. if ($hairnumber < 0) {
  530. $class_list = $this->typeclass->find_all('classid = 43');
  531. foreach ($class_list as $v) {
  532. $where .= " and features not like '%-" . $v['id'] . "-%'";
  533. }
  534. } else {
  535. $where .= " and features like '%-$hairnumber-%'";
  536. }
  537. }
  538. $where_add = '';
  539. if ($cklx) {
  540. $shop = $this->shop->read($cklx);
  541. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  542. }
  543. if ($ktime && $jtime) {
  544. $gj = " and enter > '$ktime' and enter < '$jtime'";
  545. $ck = " and outk > '$ktime' and outk < '$jtime'";
  546. }
  547. //数据排序
  548. $order_str = "id desc";
  549. if (empty($page)) {
  550. $start = 0;
  551. $perpage = 1;
  552. } else {
  553. $start = ($page - 1) * $perpage;
  554. }
  555. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  556. if ($sku) {
  557. $sku = trim($sku, ' ');
  558. $sku = trim($sku, ' ');
  559. $where .= " and sku like '%$sku%'";
  560. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  561. } else if ($title) {
  562. $title = trim($title, ' ');
  563. $title = trim($title, ' ');
  564. $where .= " and title like '%$title%'";
  565. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  566. } else {
  567. //$where .= " and time > '$ktime' and time < '$jtime'";
  568. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  569. }
  570. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  571. foreach ($info_list as $k => $v) {
  572. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  573. unset($info_list[$k]['pm']);
  574. unset($info_list[$k]['jm']);
  575. unset($info_list[$k]['bm']);
  576. }
  577. //取得信息列表
  578. $rows = array();
  579. $list = array();
  580. foreach ($info_list as $key => $value) {
  581. $warehouse = $this->warehouse->read($value['warehouse']);
  582. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  583. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  584. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  585. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  586. $info_list[$key]['label'] = $value['sm'];
  587. $number = $value['number'];
  588. $ftime = time() - 15 * 24 * 3600;
  589. $info_list[$key]['warehouse'] = $warehouse['title'];
  590. $info_list[$key]['features'] = count($c);
  591. $z = count($z); //查看订单号
  592. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  593. $ztdata = '';
  594. if (count($zt) > 0) {
  595. foreach ($zt as $vv) {
  596. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  597. }
  598. }
  599. $info_list[$key]['number'] = $ztdata;
  600. $info_list[$key]['sm'] = $z;
  601. $details = array();
  602. $cpid = array();
  603. foreach ($c as $k => $v) {
  604. $details[$v['details']] = $v['details'];
  605. if ($v['cpid'] != 0) {
  606. $cpid[$v['cpid']] = $v['cpid'];
  607. }
  608. }
  609. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  610. if ($value['shop'] != '') {
  611. $shop = explode(',', trim($value['shop'], ','));
  612. $shop = $this->shop->read($shop[0]);
  613. $info_list[$key]['shop'] = $shop['shopname'];
  614. }
  615. }
  616. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  617. $pagenum = ceil($total / $perpage);
  618. $over = $total - ($start + $perpage);
  619. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  620. echo json_encode($rows);
  621. exit;
  622. }
  623. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  624. $this->_Template('whlabel_typedy', $this->data);
  625. }
  626. //进销存浏览
  627. public function _typedy_ck($arg_array)
  628. {
  629. $prc = array();
  630. $purchase = $this->purchase->find_all();
  631. foreach ($purchase as $k => $v) {
  632. $prc[$v['id']] = $v['title'];
  633. }
  634. $post = $this->input->post(NULL, TRUE);
  635. if (isset($post['page'])) {
  636. $page = $this->input->post('page', true);
  637. $perpage = $this->input->post('perpage', true);
  638. $category = $this->input->post('category', true);
  639. $size = $this->input->post('size', true);
  640. $grade = $this->input->post('grade', true);
  641. $color = $this->input->post('color', true);
  642. $lowe = $this->input->post('lowe', true);
  643. $sku = $this->input->post('sku');
  644. $title = $this->input->post('title');
  645. $warehouse = $this->input->post('warehouse', true);
  646. $usa = $this->input->post('usa', true);
  647. $purchase = $this->input->post('purchase', true);
  648. $lacetype = $this->input->post('lacetype', true);
  649. $haircap = $this->input->post('haircap', true);
  650. $density = $this->input->post('density', true);
  651. $details = $this->input->post('details', true);
  652. $state = $this->input->post('state', true);
  653. $lacecolor = $this->input->post('lacecolor', true);
  654. $cklx = $this->input->post('cklx', true);
  655. $ktime = $this->input->post('ktime', true);
  656. $jtime = $this->input->post('jtime', true);
  657. $ktime = strtotime($ktime);
  658. $jtime = strtotime($jtime);
  659. $where = "1=1";
  660. $gj = "";
  661. $ck = "";
  662. if ($lacetype) {
  663. $where .= " and features like '%-$lacetype-%'";
  664. }
  665. if ($category) {
  666. $where .= " and features like '%-$category-%'";
  667. }
  668. if ($size) {
  669. $where .= " and features like '%-$size-%'";
  670. }
  671. if ($grade) {
  672. $where .= " and features like '%-$grade-%'";
  673. }
  674. if ($color) {
  675. $where .= " and features like '%-$color-%'";
  676. }
  677. if ($lowe) {
  678. $where .= " and features like '%-$lowe-%'";
  679. }
  680. if ($haircap) {
  681. $where .= " and features like '%-$haircap-%'";
  682. }
  683. if ($density) {
  684. $where .= " and features like '%-$density-%'";
  685. }
  686. if ($lacecolor) {
  687. $where .= " and features like '%-$lacecolor-%'";
  688. }
  689. if ($usa) {
  690. if (!$warehouse) {
  691. $where .= " and (warehouse = '5' or warehouse = '8')";
  692. }
  693. }
  694. if ($warehouse) {
  695. $where .= " and warehouse = '$warehouse'";
  696. }
  697. if ($details) {
  698. $where .= " and details = '$details'";
  699. }
  700. if ($purchase) {
  701. $where .= " and purchase = '$purchase'";
  702. }
  703. if ($state) {
  704. $where .= " and state = '$state'";
  705. }
  706. $where_add = '';
  707. if ($cklx) {
  708. $shop = $this->shop->read($cklx);
  709. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  710. }
  711. if ($ktime && $jtime) {
  712. $gj = " and enter > '$ktime' and enter < '$jtime'";
  713. $ck = " and outk > '$ktime' and outk < '$jtime'";
  714. }
  715. //数据排序
  716. $order_str = "id desc";
  717. if (empty($page)) {
  718. $start = 0;
  719. $perpage = 1;
  720. } else {
  721. $start = ($page - 1) * $perpage;
  722. }
  723. if ($sku) {
  724. $sku = trim($sku, ' ');
  725. $sku = trim($sku, ' ');
  726. $where .= " and sku like '%$sku%'";
  727. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  728. } else if ($title) {
  729. $title = trim($title, ' ');
  730. $title = trim($title, ' ');
  731. $where .= " and title like '%$title%'";
  732. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  733. } else {
  734. //$where .= " and time > '$ktime' and time < '$jtime'";
  735. $info_list = $this->whlabel->find_pc($where . $where_add . ' and zd != ""', 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,zd,COUNT(CASE WHEN zd != "" and state = 0 THEN 1 ELSE NULL END) AS zd', 'zd desc', $start, $perpage);
  736. }
  737. //取得信息列表
  738. $rows = array();
  739. $list = array();
  740. foreach ($info_list as $key => $value) {
  741. $warehouse = $this->warehouse->read($value['warehouse']);
  742. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  743. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  744. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  745. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  746. $ftime = time() - 15 * 24 * 3600;
  747. $info_list[$key]['warehouse'] = $warehouse['title'];
  748. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  749. //$z = count($z);//查看订单号
  750. //$info_list[$key]['zd'] = $z;
  751. $details = array();
  752. $cpid = array();
  753. foreach ($c as $k => $v) {
  754. $details[$v['details']] = $v['details'];
  755. if ($v['cpid'] != 0) {
  756. $cpid[$v['cpid']] = $v['cpid'];
  757. }
  758. }
  759. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  760. if ($value['shop'] != '') {
  761. $shop = explode(',', trim($value['shop'], ','));
  762. $shop = $this->shop->read($shop[0]);
  763. $info_list[$key]['shop'] = $shop['shopname'];
  764. }
  765. }
  766. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  767. $pagenum = ceil($total / $perpage);
  768. $over = $total - ($start + $perpage);
  769. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  770. echo json_encode($rows);
  771. exit;
  772. }
  773. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  774. $this->_Template('whlabel_typedy_ck', $this->data);
  775. }
  776. public function _typeck($arg_array)
  777. {
  778. $prc = array();
  779. $purchase = $this->purchase->find_all();
  780. foreach ($purchase as $k => $v) {
  781. $prc[$v['id']] = $v['title'];
  782. }
  783. $post = $this->input->post(NULL, TRUE);
  784. if (isset($post['page'])) {
  785. $page = $this->input->post('page', true);
  786. $perpage = $this->input->post('perpage', true);
  787. $category = $this->input->post('category', true);
  788. $size = $this->input->post('size', true);
  789. $grade = $this->input->post('grade', true);
  790. $color = $this->input->post('color', true);
  791. $lacecolor = $this->input->post('lacecolor', true);
  792. $lowe = $this->input->post('lowe', true);
  793. $sku = $this->input->post('sku');
  794. $title = $this->input->post('title');
  795. $warehouse = 13;
  796. $usa = $this->input->post('usa', true);
  797. $purchase = $this->input->post('purchase', true);
  798. $lacetype = $this->input->post('lacetype', true);
  799. $haircap = $this->input->post('haircap', true);
  800. $density = $this->input->post('density', true);
  801. $details = $this->input->post('details', true);
  802. $state = $this->input->post('state', true);
  803. $ktime = $this->input->post('ktime', true);
  804. $jtime = $this->input->post('jtime', true);
  805. $ktime = strtotime($ktime);
  806. $jtime = strtotime($jtime);
  807. $where = "1=1";
  808. $gj = "";
  809. $ck = "";
  810. if ($lacetype) {
  811. $where .= " and features like '%-$lacetype-%'";
  812. }
  813. if ($category) {
  814. $where .= " and features like '%-$category-%'";
  815. }
  816. if ($size) {
  817. $where .= " and features like '%-$size-%'";
  818. }
  819. if ($grade) {
  820. $where .= " and features like '%-$grade-%'";
  821. }
  822. if ($color) {
  823. $where .= " and features like '%-$color-%'";
  824. }
  825. if ($lacecolor) {
  826. $where .= " and features like '%-$lacecolor-%'";
  827. }
  828. if ($lowe) {
  829. $where .= " and features like '%-$lowe-%'";
  830. }
  831. if ($haircap) {
  832. $where .= " and features like '%-$haircap-%'";
  833. }
  834. if ($density) {
  835. $where .= " and features like '%-$density-%'";
  836. }
  837. if ($warehouse) {
  838. $where .= " and warehouse = '$warehouse'";
  839. }
  840. if ($details) {
  841. $where .= " and details = '$details'";
  842. }
  843. if ($purchase) {
  844. $where .= " and purchase = '$purchase'";
  845. }
  846. if ($state) {
  847. $where .= " and state = '$state'";
  848. }
  849. if ($ktime && $jtime) {
  850. $gj = " and enter > '$ktime' and enter < '$jtime'";
  851. $ck = " and outk > '$ktime' and outk < '$jtime'";
  852. }
  853. //数据排序
  854. $order_str = "id desc";
  855. if (empty($page)) {
  856. $start = 0;
  857. $perpage = 1;
  858. } else {
  859. $start = ($page - 1) * $perpage;
  860. }
  861. if ($sku) {
  862. $sku = trim($sku, ' ');
  863. $sku = trim($sku, ' ');
  864. $where .= " and sku like '%$sku%'";
  865. } else if ($title) {
  866. $title = trim($title, ' ');
  867. $title = trim($title, ' ');
  868. $where .= " and title like '%$title%'";
  869. }
  870. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  871. //取得信息列表
  872. $t = array();
  873. $typeclass = $this->typeclass->find_all();
  874. foreach ($typeclass as $v) {
  875. $t[$v['id']] = $v;
  876. }
  877. $rows = array();
  878. $list = array();
  879. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  880. foreach ($info_list as $key => $value) {
  881. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  882. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  883. $warehouse = $this->warehouse->read($value['warehouse']);
  884. $c = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  885. $z = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  886. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  887. $number = $value['number'];
  888. $ftime = time() - 15 * 24 * 3600;
  889. $z = count($z); //查看订单号
  890. $info_list[$key]['warehouse'] = $warehouse['title'];
  891. $info_list[$key]['features'] = count($c);
  892. $info_list[$key]['number'] = $z;
  893. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  894. $details = array();
  895. $cpid = array();
  896. foreach ($c as $k => $v) {
  897. $details[$v['details']] = $v['details'];
  898. if ($v['cpid'] != 0) {
  899. $cpid[$v['cpid']] = $v['cpid'];
  900. }
  901. }
  902. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  903. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  904. unset($info_list[$key]['pm']);
  905. unset($info_list[$key]['jm']);
  906. unset($info_list[$key]['bm']);
  907. }
  908. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  909. $pagenum = ceil($total / $perpage);
  910. $over = $total - ($start + $perpage);
  911. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  912. echo json_encode($rows);
  913. exit;
  914. }
  915. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  916. $this->_Template('whlabel_typeck', $this->data);
  917. }
  918. //进销存导出
  919. public function _whlabeckdc()
  920. {
  921. $prc = array();
  922. $purchase = $this->purchase->find_all();
  923. foreach ($purchase as $k => $v) {
  924. $prc[$v['id']] = $v['title'];
  925. }
  926. if (isset($_GET['excel'])) {
  927. $where = "sku != 'Preset'";
  928. //数据排序
  929. $order_str = "id desc";
  930. if (empty($page)) {
  931. $start = 0;
  932. $perpage = 1;
  933. } else {
  934. $start = ($page - 1) * $perpage;
  935. }
  936. $category = $this->input->get('category', true);
  937. $color = $this->input->get('color', true);
  938. $lowe = $this->input->get('lowe', true);
  939. $lacetype = $this->input->get('lacetype', true);
  940. $size = $this->input->get('size', true);
  941. $density = $this->input->get('density', true);
  942. $haircap = $this->input->get('haircap', true);
  943. $sku = $this->input->get('sku', true);
  944. $details = $this->input->get('details', true);
  945. $warehouse = 13;
  946. $excelid = $this->input->get('sid', true);
  947. if ($category) {
  948. $where .= " and features like '%-$category-%'";
  949. }
  950. if ($color) {
  951. $where .= " and features like '%-$color-%'";
  952. }
  953. if ($lowe) {
  954. $where .= " and features like '%-$lowe-%'";
  955. }
  956. if ($lacetype) {
  957. $where .= " and features like '%-$lacetype-%'";
  958. }
  959. if ($size) {
  960. $where .= " and features like '%-$size-%'";
  961. }
  962. if ($density) {
  963. $where .= " and features like '%-$density-%'";
  964. }
  965. if ($haircap) {
  966. $where .= " and features like '%-$haircap-%'";
  967. }
  968. if ($warehouse) {
  969. $where .= " and warehouse = '$warehouse'";
  970. }
  971. if ($sku) {
  972. $where .= " and sku like '%$sku%'";
  973. }
  974. if ($details) {
  975. $where .= " and details = '$details'";
  976. }
  977. $xzid = '';
  978. if ($excelid) {
  979. $excelid = explode(',', trim($excelid, ','));
  980. foreach ($excelid as $key => $value) {
  981. $xzid .= " id = " . $value . " or";
  982. }
  983. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  984. }
  985. //取得信息列表
  986. /**
  987. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  988. $rows = array();$list = array();
  989. foreach ($info_list as $key=>$value)
  990. {
  991. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  992. }
  993. **/
  994. $wh = array();
  995. $w = $this->warehouse->find_all('1=1', 'id,title');
  996. foreach ($w as $v) {
  997. $wh[$v['id']] = $v['title'];
  998. }
  999. $tc = array();
  1000. $tcdata = array();
  1001. $list = array();
  1002. $classid = $this->classid->sku();
  1003. $tcall = $this->typeclass->find_all();
  1004. $typeclass = array();
  1005. foreach ($tcall as $v)
  1006. {
  1007. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1008. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1009. }
  1010. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1011. foreach ($rows as $key => $value) {
  1012. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1013. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1014. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1015. $rows[$key]['cpbz'] = $u9_info['bm'];
  1016. $rows[$key]['cs'] = $u9_info['jm'];
  1017. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1018. $details = array();
  1019. $cpid = array();
  1020. $cpbz = array();
  1021. $c = 0;
  1022. $g = 0;
  1023. $x = 0;
  1024. $t = 0;
  1025. $s = 0;
  1026. $q = 0;
  1027. foreach ($sd as $k => $v) {
  1028. if ($v['state'] == 0) {
  1029. $c++;
  1030. }
  1031. if ($v['state'] != 9) {
  1032. $g++;
  1033. }
  1034. if ($v['state'] == 1) {
  1035. $x++;
  1036. }
  1037. if ($v['state'] == 2) {
  1038. $t++;
  1039. }
  1040. if ($v['state'] == 8) {
  1041. $s++;
  1042. }
  1043. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1044. $q++;
  1045. }
  1046. $details[$v['details']] = $v['details'];
  1047. if ($v['cpid'] != 0) {
  1048. $cpid[$v['cpid']] = $v['cpid'];
  1049. }
  1050. if ($v['cpbz'] != '') {
  1051. $cpbz[$v['cpbz']] = $v['cpbz'];
  1052. }
  1053. }
  1054. $rows[$key]['details'] = implode("、", $details);
  1055. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1056. $number = $value['number'];
  1057. $ftime = time() - 15 * 24 * 3600;
  1058. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1059. $rows[$key]['number'] = $g;
  1060. $rows[$key]['features'] = $c;
  1061. $rows[$key]['x'] = $x;
  1062. $rows[$key]['t'] = $t;
  1063. $rows[$key]['s'] = $s;
  1064. $rows[$key]['q'] = $q;
  1065. $rows[$key]['wzsl'] = count($details);
  1066. }
  1067. $title = "进销存统计表" . date('Y-m-d', time());
  1068. $titlename = "<table border=1>
  1069. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1070. <tr align='center'>
  1071. <td>仓库</td>
  1072. <td>供应商</td>
  1073. <td>位置</td>
  1074. <td>库存编码</td>
  1075. <td>SKU</td>
  1076. <td>用友编码</td>
  1077. <td>用友料号</td>
  1078. <td>产品英文名</td>
  1079. <td>产品中文名</td>
  1080. <td>入库总量</td>
  1081. <td>库存数量</td>
  1082. <td>销售数量</td>
  1083. <td>退货数量</td>
  1084. <td>删除数量</td>
  1085. <td>其它操作</td>
  1086. <td>位置数量</td>
  1087. </tr>
  1088. </table>";
  1089. $filename = $title . ".xls";
  1090. $tail = "";
  1091. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1092. }
  1093. }
  1094. public function _type()
  1095. {
  1096. $vip = 0;
  1097. if (isset($_SESSION['api'])) {
  1098. $user = $this->user->get_api($_SESSION['api']);
  1099. $fgshop = "";
  1100. $sid = "";
  1101. $usersp = explode('|', trim($user['shop'], '|'));
  1102. foreach ($usersp as $value) {
  1103. $fgshop .= " shop = " . $value . " or";
  1104. $sid .= " id = " . $value . " or";
  1105. }
  1106. if ($user['vip'] == 1) {
  1107. $vip = 1;
  1108. }
  1109. } else {
  1110. header('Location: /');
  1111. exit;
  1112. }
  1113. $prc = array();
  1114. $purchase = $this->purchase->find_all();
  1115. foreach ($purchase as $k => $v) {
  1116. $prc[$v['id']] = $v['title'];
  1117. }
  1118. $company = array();
  1119. $ct = $this->company->find_all();
  1120. foreach ($ct as $k => $v) {
  1121. $company[$v['id']] = $v['title'];
  1122. }
  1123. $sp = array();
  1124. $s = $this->shop->find_all('1=1', 'id,shopname');
  1125. foreach ($s as $v) {
  1126. $sp[$v['id']] = $v['shopname'];
  1127. }
  1128. $wh = array();
  1129. $w = $this->warehouse->find_all('1=1', 'id,title');
  1130. foreach ($w as $v) {
  1131. $wh[$v['id']] = $v['title'];
  1132. }
  1133. $post = $this->input->post(NULL, TRUE);
  1134. if (isset($post['page'])) {
  1135. $page = $this->input->post('page', true);
  1136. $perpage = $this->input->post('perpage', true);
  1137. $category = $this->input->post('category', true);
  1138. $size = $this->input->post('size', true);
  1139. $grade = $this->input->post('grade', true);
  1140. $color = $this->input->post('color', true);
  1141. $lowe = $this->input->post('lowe', true);
  1142. $sku = $this->input->post('sku');
  1143. $title = $this->input->post('title');
  1144. $warehouse = $this->input->post('warehouse', true);
  1145. $usa = $this->input->post('usa', true);
  1146. $purchase = $this->input->post('purchase', true);
  1147. $lacetype = $this->input->post('lacetype', true);
  1148. $haircap = $this->input->post('haircap', true);
  1149. $density = $this->input->post('density', true);
  1150. $details = $this->input->post('details', true);
  1151. $state = $this->input->post('state', true);
  1152. $shop = $this->input->post('shop', true);
  1153. $lacecolor = $this->input->post('lacecolor', true);
  1154. $hairnumber = $this->input->post('hairnumber', true);
  1155. $type = $this->input->post('type', true);
  1156. $ktime = $this->input->post('ktime', true);
  1157. $jtime = $this->input->post('jtime', true);
  1158. $ktime = strtotime($ktime);
  1159. $jtime = strtotime($jtime);
  1160. $cpbz = $this->input->post('cpbz', true);
  1161. $sm = $this->input->post('sm', true);
  1162. $where = "1=1";
  1163. $gj = "";
  1164. $ck = "";
  1165. if ($usa) {
  1166. if (!$warehouse) {
  1167. $where .= " and (warehouse = '5' or warehouse = '8')";
  1168. }
  1169. }
  1170. if ($warehouse) {
  1171. $where .= " and warehouse = '$warehouse'";
  1172. }
  1173. if ($details) {
  1174. $where .= " and details = '$details'";
  1175. }
  1176. if ($purchase) {
  1177. $where .= " and purchase = '$purchase'";
  1178. }
  1179. if ($state) {
  1180. $where .= " and state = '$state'";
  1181. }
  1182. if ($shop) {
  1183. $where .= " and shop like '%$shop%'";
  1184. }
  1185. if ($type) {
  1186. $where .= " and type = '$type'";
  1187. }
  1188. if ($ktime && $jtime) {
  1189. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1190. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1191. }
  1192. if ($cpbz) {
  1193. $where .= " and cpbz like '%$cpbz%' ";
  1194. }
  1195. if ($sm) {
  1196. $where .= " and sm like '%$sm%' ";
  1197. }
  1198. if ($lacecolor) {
  1199. $where .= " and features like '%-$lacecolor-%'";
  1200. }
  1201. if ($lacetype) {
  1202. $where .= " and features like '%-$lacetype-%'";
  1203. }
  1204. if ($category) {
  1205. $where .= " and features like '%-$category-%'";
  1206. }
  1207. if ($size) {
  1208. $where .= " and features like '%-$size-%'";
  1209. }
  1210. if ($grade) {
  1211. $where .= " and features like '%-$grade-%'";
  1212. }
  1213. if ($color) {
  1214. $where .= " and features like '%-$color-%'";
  1215. }
  1216. if ($lowe) {
  1217. $where .= " and features like '%-$lowe-%'";
  1218. }
  1219. if ($haircap) {
  1220. $where .= " and features like '%-$haircap-%'";
  1221. }
  1222. if ($density) {
  1223. $where .= " and features like '%-$density-%'";
  1224. }
  1225. if (!empty($hairnumber)) {
  1226. $where .= " and features like '%-128-%' ";
  1227. if ($hairnumber < 0) {
  1228. $class_list = $this->typeclass->find_all('classid = 43');
  1229. foreach ($class_list as $v) {
  1230. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1231. }
  1232. } else {
  1233. $where .= " and features like '%-$hairnumber-%'";
  1234. }
  1235. }
  1236. //数据排序
  1237. $order_str = "id desc";
  1238. if (empty($page)) {
  1239. $start = 0;
  1240. $perpage = 1;
  1241. } else {
  1242. $start = ($page - 1) * $perpage;
  1243. }
  1244. $fjnr = '';
  1245. if ($sku) {
  1246. $sku = trim($sku, ' ');
  1247. $sku = trim($sku, ' ');
  1248. $fjnr .= " and sku like '%$sku%'";
  1249. }
  1250. if ($title) {
  1251. $title = trim($title, ' ');
  1252. $title = trim($title, ' ');
  1253. $fjnr .= " and title like '%$title%'";
  1254. }
  1255. $wt = array();
  1256. $whlabel_type = $this->whlabel_type->find_all();
  1257. foreach ($whlabel_type as $v) {
  1258. $wt[$v['id']] = $v['title'];
  1259. }
  1260. //$where .= " and time > '$ktime' and time < '$jtime'";
  1261. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1262. //取得信息列表
  1263. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1264. $rows = array();
  1265. $list = array();
  1266. foreach ($info_list as $key => $value) {
  1267. if (isset($wt[$value['type']])) {
  1268. $info_list[$key]['type'] = $wt[$value['type']];
  1269. } else {
  1270. $info_list[$key]['type'] = '未设置';
  1271. }
  1272. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1273. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1274. $ztdata = '';
  1275. if (count($zt) > 0) {
  1276. foreach ($zt as $vv) {
  1277. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1278. }
  1279. }
  1280. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1281. $cdata = array_filter($qbdata, function ($item) {
  1282. return $item['state'] < 1;
  1283. });
  1284. $c = array_sum(array_column($cdata, 'jnum'));
  1285. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1286. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1287. });
  1288. $g = array_sum(array_column($gdata, 'jnum'));
  1289. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1290. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1291. });
  1292. $x = array_sum(array_column($xdata, 'jnum'));
  1293. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1294. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1295. });
  1296. $t = array_sum(array_column($tdata, 'jnum'));
  1297. $zdata = array_filter($qbdata, function ($item) {
  1298. return $item['zd'] != "" && $item['state'] < 1;
  1299. });
  1300. $z = array_sum(array_column($zdata, 'jnum'));
  1301. $zdata = array_filter($qbdata, function ($item) {
  1302. return $item['zd'] != "" && $item['state'] < 1;
  1303. });
  1304. $z = array_sum(array_column($zdata, 'jnum'));
  1305. //$c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  1306. //$g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1307. //$x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1308. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1309. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1310. $details = array();
  1311. $cpid = array();
  1312. $od = array();
  1313. $odid = '';
  1314. $companytitle = '';
  1315. $shop_list = [];
  1316. foreach ($qbdata as $v) {
  1317. if ($v['zd'] != "" && $v['state'] < 1) {
  1318. if (!isset($od[$v['zd']])) {
  1319. $od[$v['zd']] = 1; //所有数据sku
  1320. } else {
  1321. $od[$v['zd']] = $od[$v['zd']] + 1;
  1322. }
  1323. }
  1324. if ($v['state'] < 1) {
  1325. $details[$v['details']] = $v['details'];
  1326. if ($v['cpid'] != 0) {
  1327. $cpid[$v['cpid']] = $v['cpid'];
  1328. }
  1329. }
  1330. if($v['state'] == 0){
  1331. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1332. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1333. }
  1334. if ($v['shop'] != '') {
  1335. $shop = explode(',', trim($v['shop'], ','));
  1336. foreach ($shop as $vv) {
  1337. if (!in_array($vv, $shop_list)) {
  1338. $shop_list[] = $vv;
  1339. }
  1340. }
  1341. }
  1342. }
  1343. }
  1344. foreach ($od as $k => $vv) {
  1345. $odid .= $k . '数量' . $vv;
  1346. }
  1347. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1348. $info_list[$key]['label'] = $value['sm'];
  1349. $number = $value['number'];
  1350. $ftime = time() - 15 * 24 * 3600;
  1351. $z = $z . '(' . $odid . ')'; //查看订单号
  1352. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1353. $info_list[$key]['features'] = $c;
  1354. $info_list[$key]['number'] = $ztdata;
  1355. $info_list[$key]['sm'] = $g;
  1356. $info_list[$key]['x'] = $x;
  1357. $info_list[$key]['t'] = $t;
  1358. $info_list[$key]['z'] = $z;
  1359. /**
  1360. foreach ($cdata as $k=>$v)
  1361. {
  1362. $details[$v['details']] = $v['details'];
  1363. if($v['cpid'] != 0)
  1364. {
  1365. $cpid[$v['cpid']] = $v['cpid'];
  1366. }
  1367. }
  1368. **/
  1369. $info_list[$key]['shop'] = '';
  1370. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1371. // if ($value['shop'] != '') {
  1372. // $shop = explode(',', trim($value['shop'], ','));
  1373. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1374. // }
  1375. $shop_list = array_unique($shop_list);
  1376. $shop_str = '';
  1377. foreach ($shop_list as $v) {
  1378. if(isset($sp[$v])){
  1379. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1380. }
  1381. }
  1382. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1383. /**
  1384. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1385. if(isset($companytitle[0]))
  1386. {
  1387. foreach ($companytitle as $k=>$v)
  1388. {
  1389. if($v['companytitle'] != '')
  1390. {
  1391. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1392. }
  1393. }
  1394. }
  1395. **/
  1396. }
  1397. $final_all_list = [];
  1398. foreach ($info_list as $k => $v) {
  1399. $final_all_list[] = [
  1400. 'id' => $v['id'],
  1401. "warehouse" => $v["warehouse"],
  1402. "purchase" => $v["purchase"],
  1403. "sku" => $v["sku"],
  1404. "title" => $v["title"] . "<br/>" . $v["pm"],
  1405. "details" => $v["details"],
  1406. "shop" => $v["shop"],
  1407. "cpbz" => $v["cpbz"],
  1408. 'label' => $v['label'],
  1409. "type" => $v["type"],
  1410. "features" => $v["features"],
  1411. "number" => $v["number"],
  1412. "sm" => $v["sm"],
  1413. "x" => $v["x"],
  1414. "t" => $v["t"],
  1415. "z" => $v["z"]
  1416. ];
  1417. }
  1418. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1419. $pagenum = ceil($total / $perpage);
  1420. $over = $total - ($start + $perpage);
  1421. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1422. echo json_encode($rows);
  1423. exit;
  1424. }
  1425. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1426. $this->data['shop'] = $wlshop;
  1427. $this->data['vip'] = $vip;
  1428. $this->_Template('whlabel_type', $this->data);
  1429. }
  1430. //美仓进销存浏览
  1431. public function _usatype()
  1432. {
  1433. if (isset($_SESSION['api'])) {
  1434. $user = $this->user->get_api($_SESSION['api']);
  1435. $usp = $user;
  1436. $fgshop = "";
  1437. $sid = "";
  1438. $wid = "";
  1439. $wtype = "";
  1440. $userwh = explode('|', trim($user['warehouse'], '|'));
  1441. foreach ($userwh as $value) {
  1442. $wid .= " id = " . $value . " or";
  1443. $wtype .= " type = " . $value . " or";
  1444. }
  1445. }
  1446. $prc = array();
  1447. $purchase = $this->purchase->find_all();
  1448. foreach ($purchase as $k => $v) {
  1449. $prc[$v['id']] = $v['title'];
  1450. }
  1451. $post = $this->input->post(NULL, TRUE);
  1452. if (isset($post['page'])) {
  1453. $page = $this->input->post('page', true);
  1454. $perpage = $this->input->post('perpage', true);
  1455. $category = $this->input->post('category', true);
  1456. $size = $this->input->post('size', true);
  1457. $grade = $this->input->post('grade', true);
  1458. $color = $this->input->post('color', true);
  1459. $lowe = $this->input->post('lowe', true);
  1460. $sku = $this->input->post('sku');
  1461. $title = $this->input->post('title');
  1462. $warehouse = $this->input->post('warehouse', true);
  1463. $usa = $this->input->post('usa', true);
  1464. $purchase = $this->input->post('purchase', true);
  1465. $lacetype = $this->input->post('lacetype', true);
  1466. $haircap = $this->input->post('haircap', true);
  1467. $density = $this->input->post('density', true);
  1468. $details = $this->input->post('details', true);
  1469. $state = $this->input->post('state', true);
  1470. $lacecolor = $this->input->post('lacecolor', true);
  1471. $cklx = $this->input->post('cklx', true);
  1472. $ktime = $this->input->post('ktime', true);
  1473. $jtime = $this->input->post('jtime', true);
  1474. $ktime = strtotime($ktime);
  1475. $jtime = strtotime($jtime);
  1476. $where = "1=1";
  1477. $gj = "";
  1478. $ck = "";
  1479. if ($lacetype) {
  1480. $where .= " and features like '%-$lacetype-%'";
  1481. }
  1482. if ($category) {
  1483. $where .= " and features like '%-$category-%'";
  1484. }
  1485. if ($size) {
  1486. $where .= " and features like '%-$size-%'";
  1487. }
  1488. if ($grade) {
  1489. $where .= " and features like '%-$grade-%'";
  1490. }
  1491. if ($color) {
  1492. $where .= " and features like '%-$color-%'";
  1493. }
  1494. if ($lowe) {
  1495. $where .= " and features like '%-$lowe-%'";
  1496. }
  1497. if ($haircap) {
  1498. $where .= " and features like '%-$haircap-%'";
  1499. }
  1500. if ($density) {
  1501. $where .= " and features like '%-$density-%'";
  1502. }
  1503. if ($lacecolor) {
  1504. $where .= " and features like '%-$lacecolor-%'";
  1505. }
  1506. if ($usa) {
  1507. if (!$warehouse) {
  1508. $where .= " and (warehouse = '5' or warehouse = '8')";
  1509. }
  1510. }
  1511. if ($warehouse) {
  1512. $where .= " and warehouse = '$warehouse'";
  1513. }
  1514. if ($details) {
  1515. $where .= " and details = '$details'";
  1516. }
  1517. if ($purchase) {
  1518. $where .= " and purchase = '$purchase'";
  1519. }
  1520. if ($state) {
  1521. $where .= " and state = '$state'";
  1522. }
  1523. $where_add = '';
  1524. if ($cklx) {
  1525. $shop = $this->shop->read($cklx);
  1526. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1527. }
  1528. if ($ktime && $jtime) {
  1529. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1530. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1531. }
  1532. //数据排序
  1533. $order_str = "id desc";
  1534. if (empty($page)) {
  1535. $start = 0;
  1536. $perpage = 1;
  1537. } else {
  1538. $start = ($page - 1) * $perpage;
  1539. }
  1540. if ($sku) {
  1541. $sku = trim($sku, ' ');
  1542. $sku = trim($sku, ' ');
  1543. $where .= " and sku like '%$sku%'";
  1544. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1545. } else if ($title) {
  1546. $title = trim($title, ' ');
  1547. $title = trim($title, ' ');
  1548. $where .= " and title like '%$title%'";
  1549. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1550. } else {
  1551. //$where .= " and time > '$ktime' and time < '$jtime'";
  1552. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1553. }
  1554. //取得信息列表
  1555. $rows = array();
  1556. $list = array();
  1557. foreach ($info_list as $key => $value) {
  1558. $warehouse = $this->warehouse->read($value['warehouse']);
  1559. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1560. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1561. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1562. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1563. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1564. $od = array();
  1565. $odid = '';
  1566. foreach ($z as $v) {
  1567. if (!isset($od[$v['zd']])) {
  1568. $od[$v['zd']] = 1; //所有数据sku
  1569. } else {
  1570. $od[$v['zd']] = $od[$v['zd']] + 1;
  1571. }
  1572. }
  1573. foreach ($od as $k => $vv) {
  1574. $odid .= $k . '数量' . $vv . ' ';
  1575. }
  1576. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1577. $info_list[$key]['features'] = $c;
  1578. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1579. $ztdata = '';
  1580. if (count($zt) > 0) {
  1581. foreach ($zt as $vv) {
  1582. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1583. }
  1584. }
  1585. $info_list[$key]['warehouse'] = $ztdata;
  1586. $info_list[$key]['g'] = $g;
  1587. $info_list[$key]['x'] = $x;
  1588. $info_list[$key]['t'] = $t;
  1589. $info_list[$key]['z'] = $z;
  1590. }
  1591. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1592. $pagenum = ceil($total / $perpage);
  1593. $over = $total - ($start + $perpage);
  1594. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1595. echo json_encode($rows);
  1596. exit;
  1597. }
  1598. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1599. $this->data['warehouse'] = $warehouse;
  1600. $this->_Template('whlabel_typeusa', $this->data);
  1601. }
  1602. //美仓进销存浏览
  1603. public function _usatypeapp()
  1604. {
  1605. $post = $this->input->post(NULL, TRUE);
  1606. if (isset($post['page'])) {
  1607. $page = $this->input->post('page', true);
  1608. $perpage = $this->input->post('perpage', true);
  1609. $sku = $this->input->post('sku', true);
  1610. $warehouse = 5;
  1611. $title = $this->input->post('title', true);
  1612. $state = $this->input->post('state', true);
  1613. $ktime = $this->input->post('ktime', true);
  1614. $jtime = $this->input->post('jtime', true);
  1615. $ktime = strtotime($ktime);
  1616. $jtime = strtotime($jtime);
  1617. $where = "1=1";
  1618. $gj = "";
  1619. $ck = "";
  1620. if ($title) {
  1621. $st = explode(' ', trim($title, ' '));
  1622. foreach ($st as $v) {
  1623. $where .= " and title like '%$v%'";
  1624. }
  1625. }
  1626. if ($warehouse) {
  1627. $where .= " and warehouse = '$warehouse'";
  1628. }
  1629. if ($state) {
  1630. $where .= " and state = '$state'";
  1631. }
  1632. if ($sku) {
  1633. $where .= " and sku like '%$sku%'";
  1634. }
  1635. if ($ktime && $jtime) {
  1636. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1637. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1638. }
  1639. //数据排序
  1640. $order_str = "id desc";
  1641. if (empty($page)) {
  1642. $start = 0;
  1643. $perpage = 1;
  1644. } else {
  1645. $start = ($page - 1) * $perpage;
  1646. }
  1647. //取得信息列表
  1648. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1649. $rows = array();
  1650. $list = array();
  1651. foreach ($info_list as $key => $value) {
  1652. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1653. }
  1654. $rowsdq = array_slice($rows, $start, $perpage);
  1655. foreach ($rowsdq as $value) {
  1656. $warehouse = $this->warehouse->read($value['warehouse']);
  1657. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1658. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1659. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1660. $od = array();
  1661. $odid = '';
  1662. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1663. }
  1664. $total = count($rows);
  1665. $pagenum = ceil($total / $perpage);
  1666. $over = $total - ($start + $perpage);
  1667. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1668. echo json_encode($rows);
  1669. exit;
  1670. }
  1671. $this->_Template('phone/p_usatypeapp', $this->data);
  1672. }
  1673. //入库操作
  1674. public function _enteradd()
  1675. {
  1676. $dt = 0;
  1677. if (isset($_SESSION['api'])) {
  1678. $user = $this->user->get_api($_SESSION['api']);
  1679. $usp = $user;
  1680. $fgshop = "";
  1681. $sid = "";
  1682. $user = explode('|', trim($user['shop'], '|'));
  1683. foreach ($user as $value) {
  1684. $fgshop .= " shop = " . $value . " or";
  1685. $sid .= " id = " . $value . " or";
  1686. }
  1687. }
  1688. $tc = $this->typeclass->find_all();
  1689. $typeclass = array();
  1690. foreach ($tc as $v) {
  1691. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1692. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1693. }
  1694. $post = $this->input->post(NULL, TRUE);
  1695. if (isset($post['sku'])) {
  1696. $list = array();
  1697. $num = "";
  1698. $title = "";
  1699. $features = "";
  1700. $order = $this->input->post('order', true);
  1701. $shop = $this->input->post('shop', true);
  1702. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1703. $sku = $this->input->post('sku', true);
  1704. $post['sm'] = $this->input->post('sm', true);
  1705. $post['warehouse'] = $this->input->post('warehouse', true);
  1706. $post['purchase'] = $this->input->post('purchase', true);
  1707. $post['retreatwarehouse'] = $post['warehouse'];
  1708. $post['state'] = $this->input->post('state', true);
  1709. $post['rktype'] = $this->input->post('rktype', true);
  1710. $post['text'] = $this->input->post('text', true);
  1711. $category = $this->input->post('category', true);
  1712. $list['category'] = $category;
  1713. $list['hairtype'] = $this->input->post('hairtype', true);
  1714. $list['grade'] = $this->input->post('grade', true);
  1715. $size = $this->input->post('size', true);
  1716. $xzsku = $this->input->post('xzsku', true);
  1717. $list['size'] = rtrim($size, ',');
  1718. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1719. $list['extension'] = $this->input->post('extension', true);
  1720. if ($category == 1297) {
  1721. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1722. }
  1723. if ($category == 1702) {
  1724. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1725. $list['syother'] = $this->input->post('syother', true);
  1726. }
  1727. if ($category == 133) {
  1728. $list['fittype'] = $this->input->post('fittype', true);
  1729. $list['acother'] = $this->input->post('acother', true);
  1730. }
  1731. $list['color'] = $this->input->post('color', true);
  1732. $list['lowe'] = $this->input->post('lowe', true);
  1733. if (!$post['purchase']) {
  1734. $post['purchase'] = 1;
  1735. }
  1736. if ($category == 127) {
  1737. $list['type'] = $this->input->post('type', true);
  1738. $list['headroad'] = $this->input->post('headroad', true);
  1739. $list['density'] = $this->input->post('density', true);
  1740. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1741. $list['lacesize'] = $this->input->post('lacesize', true);
  1742. }
  1743. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1744. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1745. }
  1746. if ($category == 128) {
  1747. $list['lacetype'] = $this->input->post('lacetype', true);
  1748. $list['haircap'] = $this->input->post('haircap', true);
  1749. $list['density'] = $this->input->post('density', true);
  1750. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1751. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1752. $list['wigother'] = $this->input->post('wigother', true);
  1753. $list['wigother1'] = $this->input->post('wigother1', true);
  1754. $list['wigother2'] = $this->input->post('wigother2', true);
  1755. }
  1756. if ($category == 129) {
  1757. $list['wide'] = $this->input->post('wide', true);
  1758. }
  1759. if ($category == 131) {
  1760. $list['gifttype'] = $this->input->post('gifttype', true);
  1761. $list['giftother'] = $this->input->post('giftother', true);
  1762. }
  1763. if ($category == 134) {
  1764. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1765. }
  1766. if ($category == 1297) {
  1767. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1768. $list['sywigother'] = $this->input->post('sywigother', true);
  1769. }
  1770. if ($category == 130 || $category == 133 || $category == 1702) {
  1771. $list['items'] = $this->input->post('items', true);
  1772. $list['weight'] = $this->input->post('weight', true);
  1773. }
  1774. if ($category == 1702) {
  1775. $list['syhairther'] = $this->input->post('syhairther', true);
  1776. }
  1777. $classid = $this->classid->sku();
  1778. $scsku = $classid;
  1779. $pm = $classid;
  1780. foreach ($list as $k => $v) {
  1781. if ($v != 0) {
  1782. $num .= $v;
  1783. $features .= $v . '-';
  1784. $post[$k] = $v;
  1785. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1786. if ($k != 'size') {
  1787. $title .= $typeclass[$v]['title'] . " ";
  1788. }
  1789. if (isset($pm[$typeclass[$v]['classid']])) {
  1790. if ($typeclass[$v]['title'] == '9A') {
  1791. $pm[$typeclass[$v]['classid']] = '9A';
  1792. } else if ($typeclass[$v]['title'] == '10A') {
  1793. $pm[$typeclass[$v]['classid']] = '10A';
  1794. } else {
  1795. $clzh = $typeclass[$v]['zh'];
  1796. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1797. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1798. $clzh = $clzh[0];
  1799. }
  1800. $pm[$typeclass[$v]['classid']] = $clzh;
  1801. }
  1802. }
  1803. }
  1804. }
  1805. $zh = implode(" ", $pm);
  1806. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1807. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1808. if ($list['size']) {
  1809. $typeclass = $this->typeclass->read($list['size']);
  1810. $title .= $typeclass['title'];
  1811. }
  1812. $time = time();
  1813. if ($xzsku) {
  1814. $scsku = implode("-", $scsku);
  1815. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1816. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1817. $post['sku'] = trim($scsku, ' ');
  1818. } else {
  1819. $post['sku'] = $sku;
  1820. }
  1821. //$post['sku'] = trim($sku,' ');
  1822. $post['title'] = rtrim($title, ' ');
  1823. $post['number'] = $num;
  1824. $post['features'] = '-' . $features;
  1825. $post['enter'] = $time;
  1826. $post['time'] = $time; //操作时间
  1827. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1828. if ($yza) {
  1829. if ($post['features'] != $yza[0]['features']) {
  1830. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1831. exit;
  1832. }
  1833. }
  1834. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1835. if ($yzb) {
  1836. if ($post['sku'] != $yzb[0]['sku']) {
  1837. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1838. exit;
  1839. }
  1840. }
  1841. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1842. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1843. exit;
  1844. }
  1845. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1846. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1847. exit;
  1848. }
  1849. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1850. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1851. exit;
  1852. }
  1853. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1854. if (isset($yz[0]['type'])) {
  1855. $post['type'] = $yz[0]['type'];
  1856. }
  1857. if ($post['state'] == 9) //如果选择预设库存
  1858. {
  1859. $this->whlabel->insert($post);
  1860. } else {
  1861. /**
  1862. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1863. if($ljg == 1)
  1864. {
  1865. for($i=0;$i<$order;$i++)
  1866. {
  1867. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1868. $this->whlabel->insert($post);
  1869. }
  1870. }
  1871. **/
  1872. //if($post['warehouse'] == '5')
  1873. //{
  1874. //}
  1875. $yydata = $post;
  1876. $yydata['zh'] = $zh;
  1877. /**
  1878. $wl = $this->apiyy->get_cjlp($yydata);
  1879. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1880. {
  1881. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1882. }
  1883. if($wl['Data'][0]['m_isSucess'] != 1)
  1884. {
  1885. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1886. }
  1887. **/
  1888. for ($i = 0; $i < $order; $i++) {
  1889. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1890. $this->whlabel->insert($post);
  1891. }
  1892. }
  1893. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1894. exit;
  1895. }
  1896. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1897. $this->data['wlshop'] = $wlshop;
  1898. $this->_Template('whlabel_enteradd', $this->data);
  1899. }
  1900. //修改产品
  1901. public function _enteredit($arg_array)
  1902. {
  1903. $dt = 0;
  1904. if (isset($_SESSION['api'])) {
  1905. $user = $this->user->get_api($_SESSION['api']);
  1906. $usp = $user;
  1907. $fgshop = "";
  1908. $sid = "";
  1909. $user = explode('|', trim($user['shop'], '|'));
  1910. foreach ($user as $value) {
  1911. $fgshop .= " shop = " . $value . " or";
  1912. $sid .= " id = " . $value . " or";
  1913. }
  1914. }
  1915. $post = $this->input->post(NULL, TRUE);
  1916. if (isset($post['sku'])) {
  1917. $list = array();
  1918. $num = "";
  1919. $title = "";
  1920. $features = "";
  1921. $id = $this->input->post('id', true);
  1922. $order = $this->input->post('order', true);
  1923. $shop = $this->input->post('shop', true);
  1924. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1925. $post['sku'] = $this->input->post('sku', true);
  1926. $post['sm'] = $this->input->post('sm', true);
  1927. $post['warehouse'] = $this->input->post('warehouse', true);
  1928. $post['purchase'] = $this->input->post('purchase', true);
  1929. $post['retreatwarehouse'] = $post['warehouse'];
  1930. $category = $this->input->post('category', true);
  1931. $list['category'] = $category;
  1932. $list['hairtype'] = $this->input->post('hairtype', true);
  1933. $list['grade'] = $this->input->post('grade', true);
  1934. $size = $this->input->post('size', true);
  1935. $list['size'] = rtrim($size, ',');
  1936. $post['rktype'] = $this->input->post('rktype', true);
  1937. $post['text'] = $this->input->post('text', true);
  1938. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1939. $list['extension'] = $this->input->post('extension', true);
  1940. if ($category == 1297) {
  1941. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1942. }
  1943. if ($category == 1702) {
  1944. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1945. $list['syother'] = $this->input->post('syother', true);
  1946. }
  1947. if ($category == 133) {
  1948. $list['fittype'] = $this->input->post('fittype', true);
  1949. $list['acother'] = $this->input->post('acother', true);
  1950. }
  1951. $list['color'] = $this->input->post('color', true);
  1952. $list['lowe'] = $this->input->post('lowe', true);
  1953. if (!$post['purchase']) {
  1954. $post['purchase'] = 1;
  1955. }
  1956. if ($category == 127) {
  1957. $list['type'] = $this->input->post('type', true);
  1958. $list['headroad'] = $this->input->post('headroad', true);
  1959. $list['density'] = $this->input->post('density', true);
  1960. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1961. $list['lacesize'] = $this->input->post('lacesize', true);
  1962. }
  1963. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1964. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1965. }
  1966. if ($category == 128) {
  1967. $list['lacetype'] = $this->input->post('lacetype', true);
  1968. $list['haircap'] = $this->input->post('haircap', true);
  1969. $list['density'] = $this->input->post('density', true);
  1970. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1971. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1972. $list['wigother'] = $this->input->post('wigother', true);
  1973. $list['wigother1'] = $this->input->post('wigother1', true);
  1974. $list['wigother2'] = $this->input->post('wigother2', true);
  1975. }
  1976. if ($category == 129) {
  1977. $list['wide'] = $this->input->post('wide', true);
  1978. }
  1979. if ($category == 131) {
  1980. $list['gifttype'] = $this->input->post('gifttype', true);
  1981. $list['giftother'] = $this->input->post('giftother', true);
  1982. }
  1983. if ($category == 134) {
  1984. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1985. }
  1986. if ($category == 1297) {
  1987. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1988. $list['sywigother'] = $this->input->post('sywigother', true);
  1989. }
  1990. if ($category == 130 || $category == 133 || $category == 1702) {
  1991. $list['items'] = $this->input->post('items', true);
  1992. $list['weight'] = $this->input->post('weight', true);
  1993. }
  1994. if ($category == 1702) {
  1995. $list['syhairther'] = $this->input->post('syhairther', true);
  1996. }
  1997. foreach ($list as $k => $v) {
  1998. if ($v != 0) {
  1999. $num .= $v;
  2000. $features .= $v . '-';
  2001. $typeclass = $this->typeclass->read($v);
  2002. if ($k != 'size') {
  2003. $title .= $typeclass['title'] . " ";
  2004. }
  2005. }
  2006. }
  2007. $typeclass = $this->typeclass->read($list['size']);
  2008. $title .= $typeclass['title'];
  2009. $time = time();
  2010. $post['title'] = rtrim($title, ' ');
  2011. $post['number'] = $num;
  2012. $post['features'] = '-' . $features;
  2013. $post['time'] = $time; //操作时间
  2014. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2015. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2016. exit;
  2017. }
  2018. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2019. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2020. exit;
  2021. }
  2022. $uid = $this->whlabel->read($id);
  2023. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2024. if ($datanum > 0) {
  2025. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2026. exit;
  2027. }
  2028. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2029. {
  2030. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2031. if ($yza) {
  2032. if ($post['features'] != $yza[0]['features']) {
  2033. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2034. exit;
  2035. }
  2036. }
  2037. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2038. if ($yzb) {
  2039. if ($post['sku'] != $yzb[0]['sku']) {
  2040. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2041. exit;
  2042. }
  2043. }
  2044. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2045. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2046. exit;
  2047. }
  2048. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2049. foreach ($data as $v) {
  2050. $post['id'] = $v['id'];
  2051. $this->whlabel->save($post, $v['id']);
  2052. }
  2053. } else {
  2054. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2055. if ($data > 0) {
  2056. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2057. exit;
  2058. } else {
  2059. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2060. foreach ($data as $v) {
  2061. $post['id'] = $v['id'];
  2062. $this->whlabel->save($post, $v['id']);
  2063. }
  2064. }
  2065. }
  2066. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2067. exit;
  2068. }
  2069. $uid = $this->whlabel->read($arg_array[0]);
  2070. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2071. $this->data['enter'] = $uid;
  2072. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2073. $this->data['wlshop'] = $wlshop;
  2074. $this->_Template('whlabel_enteredit', $this->data);
  2075. }
  2076. //入库浏览
  2077. public function _enter()
  2078. {
  2079. $post = $this->input->post(NULL, TRUE);
  2080. if (isset($post['s'])) {
  2081. $id_arr = $this->input->post('s');
  2082. $id_arr = explode(',', $id_arr);
  2083. if (!$id_arr) {
  2084. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2085. exit;
  2086. }
  2087. //循环删除记录
  2088. foreach ($id_arr as $v) {
  2089. $sid = $this->whlabel->read($v);
  2090. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2091. if ($count > 0) {
  2092. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2093. exit;
  2094. }
  2095. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2096. foreach ($info_list as $va) {
  2097. $this->whlabel->remove($va['id']);
  2098. }
  2099. }
  2100. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2101. exit;
  2102. }
  2103. $sp = array();
  2104. $s = $this->shop->find_all('1=1', 'id,shopname');
  2105. foreach ($s as $v) {
  2106. $sp[$v['id']] = $v['shopname'];
  2107. }
  2108. $wh = array();
  2109. $w = $this->warehouse->find_all('1=1', 'id,title');
  2110. foreach ($w as $v) {
  2111. $wh[$v['id']] = $v['title'];
  2112. }
  2113. if (isset($post['page'])) {
  2114. $page = $this->input->post('page', true);
  2115. $perpage = $this->input->post('perpage', true);
  2116. $category = $this->input->post('category', true);
  2117. $size = $this->input->post('size', true);
  2118. $grade = $this->input->post('grade', true);
  2119. $color = $this->input->post('color', true);
  2120. $lowe = $this->input->post('lowe', true);
  2121. $sku = $this->input->post('sku', true);
  2122. $warehouse = $this->input->post('warehouse', true);
  2123. $purchase = $this->input->post('purchase', true);
  2124. $ktime = $this->input->post('ktime', true);
  2125. $jtime = $this->input->post('jtime', true);
  2126. $ktime = strtotime($ktime);
  2127. $jtime = strtotime($jtime);
  2128. $where = "1=1";
  2129. $gj = "";
  2130. $ck = "";
  2131. if ($category) {
  2132. $where .= " and features like '%-$category-%'";
  2133. }
  2134. if ($size) {
  2135. $where .= " and features like '%-$size-%'";
  2136. }
  2137. if ($grade) {
  2138. $where .= " and features like '%-$grade-%'";
  2139. }
  2140. if ($color) {
  2141. $where .= " and features like '%-$color-%'";
  2142. }
  2143. if ($lowe) {
  2144. $where .= " and features like '%-$lowe-%'";
  2145. }
  2146. if ($warehouse) {
  2147. $where .= " and warehouse = '$warehouse'";
  2148. }
  2149. if ($purchase) {
  2150. $where .= " and purchase = '$purchase'";
  2151. }
  2152. if ($sku) {
  2153. $where .= " and sku like '%$sku%'";
  2154. }
  2155. if ($ktime && $jtime) {
  2156. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2157. }
  2158. //数据排序
  2159. $order_str = "enter desc";
  2160. if (empty($page)) {
  2161. $start = 0;
  2162. $perpage = 1;
  2163. } else {
  2164. $start = ($page - 1) * $perpage;
  2165. }
  2166. //取得信息列表
  2167. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2168. foreach ($info_list as $k => $v) {
  2169. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2170. if ($v['shop'] == '') {
  2171. $s = '通用';
  2172. } else {
  2173. $info_list[$k]['shop'] = '';
  2174. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2175. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2176. }
  2177. }
  2178. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2179. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2180. $info_list[$k]['g'] = $g;
  2181. }
  2182. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2183. $total = count($this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,sku,title,features,number'));
  2184. $pagenum = ceil($total / $perpage);
  2185. $over = $total - ($start + $perpage);
  2186. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2187. echo json_encode($rows);
  2188. exit;
  2189. }
  2190. $this->_Template('whlabel_enter', $this->data);
  2191. }
  2192. //出库浏览
  2193. public function _out()
  2194. {
  2195. $post = $this->input->post(NULL, TRUE);
  2196. if (isset($post['page'])) {
  2197. $page = $this->input->post('page', true);
  2198. $perpage = $this->input->post('perpage', true);
  2199. $category = $this->input->post('category', true);
  2200. $size = $this->input->post('size', true);
  2201. $grade = $this->input->post('grade', true);
  2202. $color = $this->input->post('color', true);
  2203. $lowe = $this->input->post('lowe', true);
  2204. $sku = $this->input->post('sku', true);
  2205. $warehouse = $this->input->post('warehouse', true);
  2206. $purchase = $this->input->post('purchase', true);
  2207. $state = $this->input->post('state', true);
  2208. $ktime = $this->input->post('ktime', true);
  2209. $jtime = $this->input->post('jtime', true);
  2210. $ktime = strtotime($ktime);
  2211. $jtime = strtotime($jtime);
  2212. $where = "state=3";
  2213. $gj = "";
  2214. $ck = "";
  2215. if ($category) {
  2216. $where .= " and features like '%-$category-%'";
  2217. }
  2218. if ($size) {
  2219. $where .= " and features like '%-$size-%'";
  2220. }
  2221. if ($grade) {
  2222. $where .= " and features like '%-$grade-%'";
  2223. }
  2224. if ($color) {
  2225. $where .= " and features like '%-$color-%'";
  2226. }
  2227. if ($lowe) {
  2228. $where .= " and features like '%-$lowe-%'";
  2229. }
  2230. if ($state) {
  2231. $where .= " and state = '$state'";
  2232. }
  2233. if ($warehouse) {
  2234. $where .= " and warehouse = '$warehouse'";
  2235. }
  2236. if ($purchase) {
  2237. $where .= " and purchase = '$purchase'";
  2238. }
  2239. if ($sku) {
  2240. $where .= " and sku = '$sku'";
  2241. }
  2242. if ($ktime && $jtime) {
  2243. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2244. }
  2245. //数据排序
  2246. $order_str = "id desc";
  2247. if (empty($page)) {
  2248. $start = 0;
  2249. $perpage = 1;
  2250. } else {
  2251. $start = ($page - 1) * $perpage;
  2252. }
  2253. //取得信息列表
  2254. $info_list = $this->whlabel->find_all($where, 'sku');
  2255. $rows = array();
  2256. $list = array();
  2257. foreach ($info_list as $key => $value) {
  2258. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2259. }
  2260. $rows = array_unique($rows); //删除重复记录
  2261. foreach ($rows as $key => $value) {
  2262. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2263. $ck = $this->warehouse->read($data['warehouse']);
  2264. $warehouse = $ck['title'];
  2265. $gy = $this->purchase->read($data['purchase']);
  2266. $purchase = $gy['purchase'];
  2267. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2268. $list[] = array('id' => $data['id'], 'warehouse' => $warehouse, 'purchase' => $purchase, 'sku' => $data['sku'], 'title' => $data['title'], 'time' => date('Y-m-d H:i:s', $data['enter']), 'number' => $g);
  2269. }
  2270. $total = count($list);
  2271. $pagenum = ceil($total / $perpage);
  2272. $over = $total - ($start + $perpage);
  2273. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2274. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2275. echo json_encode($rows);
  2276. exit;
  2277. }
  2278. $this->_Template('whlabel_out', $this->data);
  2279. }
  2280. //出库标签浏览
  2281. public function _label()
  2282. {
  2283. $post = $this->input->post(NULL, TRUE);
  2284. if (isset($post['page'])) {
  2285. $page = $this->input->post('page', true);
  2286. $perpage = $this->input->post('perpage', true);
  2287. $sku = $this->input->post('sku', true);
  2288. $warehouse = $this->input->post('warehouse', true);
  2289. $purchase = $this->input->post('purchase', true);
  2290. $orderinfo = $this->input->post('orderinfo', true);
  2291. $waybill = $this->input->post('waybill', true);
  2292. $category = $this->input->post('category', true);
  2293. $size = $this->input->post('size', true);
  2294. $grade = $this->input->post('grade', true);
  2295. $color = $this->input->post('color', true);
  2296. $lowe = $this->input->post('lowe', true);
  2297. $where = "state=1";
  2298. if ($sku) {
  2299. $where .= " and sku = '$sku'";
  2300. }
  2301. if ($warehouse) {
  2302. $where .= " and warehouse = '$warehouse'";
  2303. }
  2304. if ($purchase) {
  2305. $where .= " and purchase = '$purchase'";
  2306. }
  2307. if ($orderinfo) {
  2308. $where .= " and orderinfo = '$orderinfo'";
  2309. }
  2310. if ($waybill) {
  2311. $where .= " and waybill = '$waybill'";
  2312. }
  2313. if ($category) {
  2314. $where .= " and features like '%-$category-%'";
  2315. }
  2316. if ($size) {
  2317. $where .= " and features like '%-$size-%'";
  2318. }
  2319. if ($grade) {
  2320. $where .= " and features like '%-$grade-%'";
  2321. }
  2322. if ($color) {
  2323. $where .= " and features like '%-$color-%'";
  2324. }
  2325. if ($lowe) {
  2326. $where .= " and features like '%-$lowe-%'";
  2327. }
  2328. //数据排序
  2329. $order_str = "outk desc";
  2330. if (empty($page)) {
  2331. $start = 0;
  2332. $perpage = 1;
  2333. } else {
  2334. $start = ($page - 1) * $perpage;
  2335. }
  2336. //取得信息列表
  2337. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2338. foreach ($info_list as $key => $value) {
  2339. $warehouse = $this->warehouse->read($value['warehouse']);
  2340. $info_list[$key]['warehouse'] = $warehouse['title'];
  2341. $purchase = $this->purchase->read($value['purchase']);
  2342. $info_list[$key]['purchase'] = $purchase['title'];
  2343. if ($value['outk'] != 0) {
  2344. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2345. } else {
  2346. $info_list[$key]['outk'] = "";
  2347. }
  2348. if ($value['orderinfo'] == 0) {
  2349. $info_list[$key]['orderinfo'] = "";
  2350. }
  2351. if ($value['waybill'] == 0) {
  2352. $info_list[$key]['waybill'] = "";
  2353. }
  2354. }
  2355. $total = $this->whlabel->find_count($where);
  2356. $pagenum = ceil($total / $perpage);
  2357. $over = $total - ($start + $perpage);
  2358. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2359. echo json_encode($rows);
  2360. exit;
  2361. }
  2362. $this->_Template('whlabel_label', $this->data);
  2363. }
  2364. //独立站出库订单
  2365. public function _outorder()
  2366. {
  2367. if (isset($_SESSION['api'])) {
  2368. $user = $this->user->get_api($_SESSION['api']);
  2369. $usp = $user;
  2370. $fgshop = "";
  2371. $sid = "";
  2372. $user = explode('|', trim($user['shop'], '|'));
  2373. foreach ($user as $value) {
  2374. $fgshop .= " shop = " . $value . " or";
  2375. $sid .= " id = " . $value . " or";
  2376. }
  2377. } else {
  2378. echo "请重新登录";
  2379. }
  2380. $post = $this->input->post(NULL, TRUE);
  2381. if (isset($post['page'])) {
  2382. $page = $this->input->post('page', true);
  2383. $perpage = $this->input->post('perpage', true);
  2384. $warehouse = $this->input->post('warehouse', true);
  2385. $xztime = $this->input->post('xztime', true);
  2386. $timetk = $this->input->post('timetkk', true);
  2387. $timetj = $this->input->post('timetjj', true);
  2388. $shop = $this->input->post('shop', true);
  2389. $source = $this->input->post('source', true);
  2390. $orderinfo = $this->input->post('orderinfo', true);
  2391. $number = $this->input->post('number', true);
  2392. $sfxh = $this->input->post('sfxh', true);
  2393. $express = $this->input->post('express', true);
  2394. $waybill = $this->input->post('waybill', true);
  2395. $library = $this->input->post('library', true);
  2396. $country = $this->input->post('country', true);
  2397. $so = $this->input->post('so', true);
  2398. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2399. $print = $this->input->post('print', true);
  2400. $state = $this->input->post('state', true);
  2401. $orderurl = $this->input->post('orderurl', true);
  2402. $timetk = strtotime($timetk);
  2403. $timetj = strtotime($timetj);
  2404. /**
  2405. $sj = $this->input->post('sj',true);
  2406. if($sj)
  2407. {
  2408. $sj = $this->input->post('sj',true);
  2409. }
  2410. else
  2411. {
  2412. $sj = "fullorder";
  2413. }
  2414. **/
  2415. $sj = "fullorder";
  2416. $where = "1=1";
  2417. if ($warehouse) {
  2418. $where .= " and type = '$warehouse'";
  2419. }
  2420. if ($timetk && $timetj) {
  2421. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2422. }
  2423. if ($orderinfo) {
  2424. $where .= " and orderinfo = '$orderinfo'";
  2425. }
  2426. if ($number) {
  2427. $where .= " and number = '$number'";
  2428. }
  2429. if ($express) {
  2430. $where .= " and express = '$express'";
  2431. }
  2432. if ($waybill) {
  2433. $where .= " and waybill = '$waybill'";
  2434. }
  2435. if ($library) {
  2436. $where .= " and library = '$library'";
  2437. }
  2438. if ($print) {
  2439. $where .= " and print = '$print'";
  2440. }
  2441. if ($libraryconfirm) {
  2442. $where .= " and libraryconfirm = '$libraryconfirm'";
  2443. }
  2444. if ($state) {
  2445. $where .= " and state = '$state'";
  2446. }
  2447. if ($shop) {
  2448. $where .= " and shop = '$shop'";
  2449. }
  2450. if ($country) {
  2451. $where .= " and country = '$country'";
  2452. }
  2453. if ($sfxh != '') {
  2454. $where .= " and sfxh = '$sfxh'";
  2455. }
  2456. if ($so) {
  2457. $where .= " and shipremarks like '%$so%'";
  2458. }
  2459. if ($source) {
  2460. if ($source == '2d') {
  2461. $where .= " and source >= '2'";
  2462. } else {
  2463. $where .= " and source = '$source'";
  2464. }
  2465. }
  2466. if (isset($_SESSION['api'])) {
  2467. foreach ($user as $value) {
  2468. $fgshop .= " shop = " . $value . " or";
  2469. }
  2470. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2471. }
  2472. if ($orderurl) {
  2473. $url = $this->orderurl->read($orderurl);
  2474. $where .= " and link like '%" . $url['url'] . "%'";
  2475. }
  2476. //数据排序
  2477. $order_str = "librarytime desc";
  2478. if (empty($page)) {
  2479. $start = 0;
  2480. $perpage = 1;
  2481. } else {
  2482. $start = ($page - 1) * $perpage;
  2483. }
  2484. //取得信息列表
  2485. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2486. //格式化数据
  2487. foreach ($info_list as $key => $value) {
  2488. $shop = $this->shop->read($value['shop']);
  2489. $info_list[$key]['shop'] = $shop['shopname'];
  2490. $express = $this->express->read($value['express']);
  2491. $info_list[$key]['express'] = $express['servicename'];
  2492. $warehouse = $this->warehouse->read($value['type']);
  2493. $info_list[$key]['type'] = $warehouse['title'];
  2494. if ($value['librarytime'] == '0') {
  2495. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2496. } else {
  2497. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2498. }
  2499. }
  2500. $total = $this->$sj->find_count($where);
  2501. $pagenum = ceil($total / $perpage);
  2502. $over = $total - ($start + $perpage);
  2503. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2504. echo json_encode($rows);
  2505. exit;
  2506. }
  2507. $this->data['express'] = $this->express->find_all();
  2508. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2509. $this->data['wlshop'] = $wlshop;
  2510. $user = $this->user->get_api($_SESSION['api']);
  2511. $powerid = $this->power->read($user['power']);
  2512. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2513. $pid = '';
  2514. foreach ($powertext as $v) {
  2515. $pid .= " id = " . $v . " or";
  2516. }
  2517. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2518. $this->data['fullorderexcel'] = $fullorderexcel;
  2519. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2520. $this->data['orderurl'] = $orderurl;
  2521. $this->_Template('whlabel_outorder', $this->data);
  2522. }
  2523. //tt出库
  2524. public function _toutorder()
  2525. {
  2526. if (isset($_SESSION['api'])) {
  2527. $user = $this->user->get_api($_SESSION['api']);
  2528. $usp = $user;
  2529. $fgshop = "";
  2530. $sid = "";
  2531. $user = explode('|', trim($user['shop'], '|'));
  2532. foreach ($user as $value) {
  2533. $fgshop .= " shop = " . $value . " or";
  2534. $sid .= " id = " . $value . " or";
  2535. }
  2536. } else {
  2537. echo "请重新登录";
  2538. }
  2539. $post = $this->input->post(NULL, TRUE);
  2540. if (isset($post['page'])) {
  2541. $page = $this->input->post('page', true);
  2542. $perpage = $this->input->post('perpage', true);
  2543. $warehouse = $this->input->post('warehouse', true);
  2544. $xztime = $this->input->post('xztime', true);
  2545. $timetk = $this->input->post('timetkk', true);
  2546. $timetj = $this->input->post('timetjj', true);
  2547. $shop = $this->input->post('shop', true);
  2548. $source = $this->input->post('source', true);
  2549. $orderinfo = $this->input->post('orderinfo', true);
  2550. $number = $this->input->post('number', true);
  2551. $sfxh = $this->input->post('sfxh', true);
  2552. $express = $this->input->post('express', true);
  2553. $waybill = $this->input->post('waybill', true);
  2554. $library = $this->input->post('library', true);
  2555. $country = $this->input->post('country', true);
  2556. $so = $this->input->post('so', true);
  2557. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2558. $print = $this->input->post('print', true);
  2559. $state = $this->input->post('state', true);
  2560. $orderurl = $this->input->post('orderurl', true);
  2561. $timetk = strtotime($timetk);
  2562. $timetj = strtotime($timetj);
  2563. /**
  2564. $sj = $this->input->post('sj',true);
  2565. if($sj)
  2566. {
  2567. $sj = $this->input->post('sj',true);
  2568. }
  2569. else
  2570. {
  2571. $sj = "fullorder";
  2572. }
  2573. **/
  2574. $sj = "fullordertt";
  2575. $where = "1=1";
  2576. if ($warehouse) {
  2577. $where .= " and type = '$warehouse'";
  2578. }
  2579. if ($timetk && $timetj) {
  2580. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2581. }
  2582. if ($orderinfo) {
  2583. $where .= " and orderinfo = '$orderinfo'";
  2584. }
  2585. if ($number) {
  2586. $where .= " and number = '$number'";
  2587. }
  2588. if ($express) {
  2589. $where .= " and express = '$express'";
  2590. }
  2591. if ($waybill) {
  2592. $where .= " and waybill = '$waybill'";
  2593. }
  2594. if ($library) {
  2595. $where .= " and library = '$library'";
  2596. }
  2597. if ($print) {
  2598. $where .= " and print = '$print'";
  2599. }
  2600. if ($libraryconfirm) {
  2601. $where .= " and libraryconfirm = '$libraryconfirm'";
  2602. }
  2603. if ($state) {
  2604. $where .= " and state = '$state'";
  2605. }
  2606. if ($shop) {
  2607. $where .= " and shop = '$shop'";
  2608. }
  2609. if ($country) {
  2610. $where .= " and country = '$country'";
  2611. }
  2612. if ($sfxh != '') {
  2613. $where .= " and sfxh = '$sfxh'";
  2614. }
  2615. if ($so) {
  2616. $where .= " and shipremarks like '%$so%'";
  2617. }
  2618. if ($source) {
  2619. if ($source == '2d') {
  2620. $where .= " and source >= '2'";
  2621. } else {
  2622. $where .= " and source = '$source'";
  2623. }
  2624. }
  2625. if (isset($_SESSION['api'])) {
  2626. foreach ($user as $value) {
  2627. $fgshop .= " shop = " . $value . " or";
  2628. }
  2629. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2630. }
  2631. if ($orderurl) {
  2632. $url = $this->orderurl->read($orderurl);
  2633. $where .= " and link like '%" . $url['url'] . "%'";
  2634. }
  2635. //数据排序
  2636. $order_str = "librarytime desc";
  2637. if (empty($page)) {
  2638. $start = 0;
  2639. $perpage = 1;
  2640. } else {
  2641. $start = ($page - 1) * $perpage;
  2642. }
  2643. //取得信息列表
  2644. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2645. //格式化数据
  2646. foreach ($info_list as $key => $value) {
  2647. $shop = $this->shop->read($value['shop']);
  2648. $info_list[$key]['shop'] = $shop['shopname'];
  2649. $express = $this->express->read($value['express']);
  2650. $info_list[$key]['express'] = $express['servicename'];
  2651. $warehouse = $this->warehouse->read($value['type']);
  2652. $info_list[$key]['type'] = $warehouse['title'];
  2653. if ($value['librarytime'] == '0') {
  2654. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2655. } else {
  2656. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2657. }
  2658. }
  2659. $total = $this->$sj->find_count($where);
  2660. $pagenum = ceil($total / $perpage);
  2661. $over = $total - ($start + $perpage);
  2662. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2663. echo json_encode($rows);
  2664. exit;
  2665. }
  2666. $this->data['express'] = $this->express->find_all();
  2667. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2668. $this->data['wlshop'] = $wlshop;
  2669. $user = $this->user->get_api($_SESSION['api']);
  2670. $powerid = $this->power->read($user['power']);
  2671. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2672. $pid = '';
  2673. foreach ($powertext as $v) {
  2674. $pid .= " id = " . $v . " or";
  2675. }
  2676. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2677. $this->data['fullorderexcel'] = $fullorderexcel;
  2678. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2679. $this->data['orderurl'] = $orderurl;
  2680. $this->_Template('whlabel_toutorder', $this->data);
  2681. }
  2682. //tt出库
  2683. public function _aoutorder()
  2684. {
  2685. if (isset($_SESSION['api'])) {
  2686. $user = $this->user->get_api($_SESSION['api']);
  2687. $usp = $user;
  2688. $fgshop = "";
  2689. $sid = "";
  2690. $user = explode('|', trim($user['shop'], '|'));
  2691. foreach ($user as $value) {
  2692. $fgshop .= " shop = " . $value . " or";
  2693. $sid .= " id = " . $value . " or";
  2694. }
  2695. } else {
  2696. echo "请重新登录";
  2697. }
  2698. $post = $this->input->post(NULL, TRUE);
  2699. if (isset($post['page'])) {
  2700. $page = $this->input->post('page', true);
  2701. $perpage = $this->input->post('perpage', true);
  2702. $warehouse = $this->input->post('warehouse', true);
  2703. $xztime = $this->input->post('xztime', true);
  2704. $timetk = $this->input->post('timetkk', true);
  2705. $timetj = $this->input->post('timetjj', true);
  2706. $shop = $this->input->post('shop', true);
  2707. $source = $this->input->post('source', true);
  2708. $orderinfo = $this->input->post('orderinfo', true);
  2709. $number = $this->input->post('number', true);
  2710. $sfxh = $this->input->post('sfxh', true);
  2711. $express = $this->input->post('express', true);
  2712. $waybill = $this->input->post('waybill', true);
  2713. $library = $this->input->post('library', true);
  2714. $country = $this->input->post('country', true);
  2715. $so = $this->input->post('so', true);
  2716. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2717. $print = $this->input->post('print', true);
  2718. $state = $this->input->post('state', true);
  2719. $orderurl = $this->input->post('orderurl', true);
  2720. $timetk = strtotime($timetk);
  2721. $timetj = strtotime($timetj);
  2722. /**
  2723. $sj = $this->input->post('sj',true);
  2724. if($sj)
  2725. {
  2726. $sj = $this->input->post('sj',true);
  2727. }
  2728. else
  2729. {
  2730. $sj = "fullorder";
  2731. }
  2732. **/
  2733. $sj = "fullorderamz";
  2734. $where = "1=1";
  2735. if ($warehouse) {
  2736. $where .= " and type = '$warehouse'";
  2737. }
  2738. if ($timetk && $timetj) {
  2739. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2740. }
  2741. if ($orderinfo) {
  2742. $where .= " and orderinfo = '$orderinfo'";
  2743. }
  2744. if ($number) {
  2745. $where .= " and number = '$number'";
  2746. }
  2747. if ($express) {
  2748. $where .= " and express = '$express'";
  2749. }
  2750. if ($waybill) {
  2751. $where .= " and waybill = '$waybill'";
  2752. }
  2753. if ($library) {
  2754. $where .= " and library = '$library'";
  2755. }
  2756. if ($print) {
  2757. $where .= " and print = '$print'";
  2758. }
  2759. if ($libraryconfirm) {
  2760. $where .= " and libraryconfirm = '$libraryconfirm'";
  2761. }
  2762. if ($state) {
  2763. $where .= " and state = '$state'";
  2764. }
  2765. if ($shop) {
  2766. $where .= " and shop = '$shop'";
  2767. }
  2768. if ($country) {
  2769. $where .= " and country = '$country'";
  2770. }
  2771. if ($sfxh != '') {
  2772. $where .= " and sfxh = '$sfxh'";
  2773. }
  2774. if ($so) {
  2775. $where .= " and shipremarks like '%$so%'";
  2776. }
  2777. if ($source) {
  2778. if ($source == '2d') {
  2779. $where .= " and source >= '2'";
  2780. } else {
  2781. $where .= " and source = '$source'";
  2782. }
  2783. }
  2784. if (isset($_SESSION['api'])) {
  2785. foreach ($user as $value) {
  2786. $fgshop .= " shop = " . $value . " or";
  2787. }
  2788. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2789. }
  2790. if ($orderurl) {
  2791. $url = $this->orderurl->read($orderurl);
  2792. $where .= " and link like '%" . $url['url'] . "%'";
  2793. }
  2794. //数据排序
  2795. $order_str = "librarytime desc";
  2796. if (empty($page)) {
  2797. $start = 0;
  2798. $perpage = 1;
  2799. } else {
  2800. $start = ($page - 1) * $perpage;
  2801. }
  2802. //取得信息列表
  2803. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2804. //格式化数据
  2805. foreach ($info_list as $key => $value) {
  2806. $shop = $this->shop->read($value['shop']);
  2807. $info_list[$key]['shop'] = $shop['shopname'];
  2808. $express = $this->express->read($value['express']);
  2809. $info_list[$key]['express'] = $express['servicename'];
  2810. $warehouse = $this->warehouse->read($value['type']);
  2811. $info_list[$key]['type'] = $warehouse['title'];
  2812. if ($value['librarytime'] == '0') {
  2813. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2814. } else {
  2815. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2816. }
  2817. }
  2818. $total = $this->$sj->find_count($where);
  2819. $pagenum = ceil($total / $perpage);
  2820. $over = $total - ($start + $perpage);
  2821. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2822. echo json_encode($rows);
  2823. exit;
  2824. }
  2825. $this->data['express'] = $this->express->find_all();
  2826. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2827. $this->data['wlshop'] = $wlshop;
  2828. $user = $this->user->get_api($_SESSION['api']);
  2829. $powerid = $this->power->read($user['power']);
  2830. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2831. $pid = '';
  2832. foreach ($powertext as $v) {
  2833. $pid .= " id = " . $v . " or";
  2834. }
  2835. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2836. $this->data['fullorderexcel'] = $fullorderexcel;
  2837. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2838. $this->data['orderurl'] = $orderurl;
  2839. $this->_Template('whlabel_aoutorder', $this->data);
  2840. }
  2841. //速卖通出库订单
  2842. public function _soutorder()
  2843. {
  2844. if (isset($_SESSION['api'])) {
  2845. $user = $this->user->get_api($_SESSION['api']);
  2846. $usp = $user;
  2847. $fgshop = "";
  2848. $sid = "";
  2849. $user = explode('|', trim($user['shop'], '|'));
  2850. foreach ($user as $value) {
  2851. $sid .= " id = " . $value . " or";
  2852. }
  2853. }
  2854. $post = $this->input->post(NULL, TRUE);
  2855. if (isset($post['page'])) {
  2856. $page = $this->input->post('page', true);
  2857. $perpage = $this->input->post('perpage', true);
  2858. $warehouse = $this->input->post('warehouse', true);
  2859. $xztime = $this->input->post('xztime', true);
  2860. $timetk = $this->input->post('timetkk', true);
  2861. $timetj = $this->input->post('timetjj', true);
  2862. $shop = $this->input->post('shop', true);
  2863. $source = $this->input->post('source', true);
  2864. $orderinfo = $this->input->post('orderinfo', true);
  2865. $number = $this->input->post('number', true);
  2866. $express = $this->input->post('express', true);
  2867. $waybill = $this->input->post('waybill', true);
  2868. $library = $this->input->post('library', true);
  2869. $country = $this->input->post('country', true);
  2870. $sfxh = $this->input->post('sfxh', true);
  2871. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2872. $print = $this->input->post('print', true);
  2873. $state = $this->input->post('state', true);
  2874. $so = $this->input->post('so', true);
  2875. $timetk = strtotime($timetk);
  2876. $timetj = strtotime($timetj);
  2877. /**
  2878. $sj = $this->input->post('sj',true);
  2879. if($sj)
  2880. {
  2881. $sj = $this->input->post('sj',true);
  2882. }
  2883. else
  2884. {
  2885. $sj = "fullorder";
  2886. }
  2887. **/
  2888. $sj = "fullordersmt";
  2889. $where = "1=1";
  2890. if ($warehouse) {
  2891. $where .= " and type = '$warehouse'";
  2892. }
  2893. if ($timetk && $timetj) {
  2894. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2895. }
  2896. if ($orderinfo) {
  2897. $where .= " and orderinfo = '$orderinfo'";
  2898. }
  2899. if ($number) {
  2900. $where .= " and number = '$number'";
  2901. }
  2902. if ($express) {
  2903. $where .= " and express = '$express'";
  2904. }
  2905. if ($waybill) {
  2906. $where .= " and waybill = '$waybill'";
  2907. }
  2908. if ($library) {
  2909. $where .= " and library = '$library'";
  2910. }
  2911. if ($print) {
  2912. $where .= " and print = '$print'";
  2913. }
  2914. if ($libraryconfirm) {
  2915. $where .= " and libraryconfirm = '$libraryconfirm'";
  2916. }
  2917. if ($state) {
  2918. $where .= " and state = '$state'";
  2919. }
  2920. if ($shop) {
  2921. $where .= " and shop = '$shop'";
  2922. }
  2923. if ($sfxh != '') {
  2924. $where .= " and sfxh = '$sfxh'";
  2925. }
  2926. if ($so) {
  2927. $where .= " and shipremarks like '%$so%'";
  2928. }
  2929. if ($source) {
  2930. $where .= " and source = '$source'";
  2931. }
  2932. if ($country) {
  2933. $where .= " and country = '$country'";
  2934. } else {
  2935. if (isset($_SESSION['api'])) {
  2936. foreach ($user as $value) {
  2937. $fgshop .= " shop = " . $value . " or";
  2938. }
  2939. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2940. }
  2941. }
  2942. //数据排序
  2943. $order_str = "librarytime desc";
  2944. if (empty($page)) {
  2945. $start = 0;
  2946. $perpage = 1;
  2947. } else {
  2948. $start = ($page - 1) * $perpage;
  2949. }
  2950. //取得信息列表
  2951. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2952. //格式化数据
  2953. foreach ($info_list as $key => $value) {
  2954. $shop = $this->shop->read($value['shop']);
  2955. $info_list[$key]['shop'] = $shop['shopname'];
  2956. $express = $this->express->read($value['express']);
  2957. $info_list[$key]['express'] = $express['servicename'];
  2958. $warehouse = $this->warehouse->read($value['type']);
  2959. $info_list[$key]['type'] = $warehouse['title'];
  2960. if ($value['librarytime'] == '0') {
  2961. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2962. } else {
  2963. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2964. }
  2965. }
  2966. $total = $this->$sj->find_count($where);
  2967. $pagenum = ceil($total / $perpage);
  2968. $over = $total - ($start + $perpage);
  2969. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2970. echo json_encode($rows);
  2971. exit;
  2972. }
  2973. $this->data['express'] = $this->express->find_all();
  2974. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2975. $this->data['wlshop'] = $wlshop;
  2976. $user = $this->user->get_api($_SESSION['api']);
  2977. $powerid = $this->power->read($user['power']);
  2978. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2979. $pid = '';
  2980. foreach ($powertext as $v) {
  2981. $pid .= " id = " . $v . " or";
  2982. }
  2983. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2984. $this->data['fullorderexcel'] = $fullorderexcel;
  2985. $this->_Template('whlabel_soutorder', $this->data);
  2986. }
  2987. //订单退库
  2988. public function _retreat()
  2989. {
  2990. $post = $this->input->post(NULL, TRUE);
  2991. if (isset($post['page'])) {
  2992. $page = $this->input->post('page', true);
  2993. $perpage = $this->input->post('perpage', true);
  2994. $warehouse = $this->input->post('warehouse', true);
  2995. $timetk = $this->input->post('timetk', true);
  2996. $timetj = $this->input->post('timetj', true);
  2997. $shop = $this->input->post('shop', true);
  2998. $source = $this->input->post('source', true);
  2999. $state = $this->input->post('state', true);
  3000. $review = $this->input->post('review', true);
  3001. $state = $this->input->post('state', true);
  3002. $express = $this->input->post('express', true);
  3003. $orderinfo = $this->input->post('orderinfo', true);
  3004. $user = $this->input->post('user', true);
  3005. $name = $this->input->post('name', true);
  3006. $waybill = $this->input->post('waybill', true);
  3007. $timetk = strtotime($timetk);
  3008. $timetj = strtotime($timetj);
  3009. $where = "(state=206 or state=210) and mergeid = 0";
  3010. if ($warehouse) {
  3011. $where .= " and state = '$warehouse'";
  3012. }
  3013. if ($timetk && $timetj) {
  3014. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3015. }
  3016. if ($shop) {
  3017. $where .= " and shop = '$shop'";
  3018. }
  3019. if ($source) {
  3020. $where .= " and source = '$source'";
  3021. }
  3022. if ($state) {
  3023. $where .= " and state = '$state'";
  3024. }
  3025. if ($review) {
  3026. $where .= " and review = '$review'";
  3027. }
  3028. if ($state) {
  3029. $where .= " and state = '$state'";
  3030. }
  3031. if ($express) {
  3032. $where .= " and express = '$express'";
  3033. }
  3034. if ($orderinfo) {
  3035. $where .= " and orderinfo = '$orderinfo'";
  3036. }
  3037. if ($user) {
  3038. $where .= " and user = '$user'";
  3039. }
  3040. if ($name) {
  3041. $where .= " and name = '$name'";
  3042. }
  3043. if ($waybill) {
  3044. $where .= " and waybill = '$waybill'";
  3045. }
  3046. //数据排序
  3047. $order_str = "id desc";
  3048. if (empty($page)) {
  3049. $start = 0;
  3050. $perpage = 1;
  3051. } else {
  3052. $start = ($page - 1) * $perpage;
  3053. }
  3054. //取得信息列表
  3055. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3056. //格式化数据
  3057. foreach ($info_list as $key => $value) {
  3058. $shop = $this->shop->read($value['shop']);
  3059. $info_list[$key]['shop'] = $shop['shopname'];
  3060. $warehouse = $this->warehouse->read($value['warehouse']);
  3061. $info_list[$key]['warehouse'] = $warehouse['title'];
  3062. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3063. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3064. if ($value['waybill'] == 0) {
  3065. $info_list[$key]['waybill'] = "";
  3066. }
  3067. $express = $this->express->read($value['express']);
  3068. $info_list[$key]['express'] = $express['title'];
  3069. $typeclass = $this->typeclass->read($value['state']);
  3070. $info_list[$key]['state'] = $typeclass['title'];
  3071. }
  3072. $total = $this->fullorder->find_count($where);
  3073. $pagenum = ceil($total / $perpage);
  3074. $over = $total - ($start + $perpage);
  3075. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3076. echo json_encode($rows);
  3077. exit;
  3078. }
  3079. $this->data['express'] = $this->express->find_all();
  3080. $this->_Template('whlabel_retreat', $this->data);
  3081. }
  3082. //退库标签浏览
  3083. public function _retreatlk()
  3084. {
  3085. $post = $this->input->post(NULL, TRUE);
  3086. if (isset($post['page'])) {
  3087. $page = $this->input->post('page', true);
  3088. $perpage = $this->input->post('perpage', true);
  3089. $timetk = $this->input->post('timetk', true);
  3090. $timetj = $this->input->post('timetj', true);
  3091. $sku = $this->input->post('sku', true);
  3092. $warehouse = $this->input->post('warehouse', true);
  3093. $purchase = $this->input->post('purchase', true);
  3094. $orderinfo = $this->input->post('orderinfo', true);
  3095. $waybill = $this->input->post('waybill', true);
  3096. $category = $this->input->post('category', true);
  3097. $size = $this->input->post('size', true);
  3098. $grade = $this->input->post('grade', true);
  3099. $color = $this->input->post('color', true);
  3100. $lowe = $this->input->post('lowe', true);
  3101. $state = $this->input->post('state', true);
  3102. $timetk = strtotime($timetk);
  3103. $timetj = strtotime($timetj);
  3104. $where = "state=2";
  3105. if ($timetk && $timetj) {
  3106. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3107. }
  3108. if ($sku) {
  3109. $where .= " and sku = '$sku'";
  3110. }
  3111. if ($warehouse) {
  3112. $where .= " and warehouse = '$warehouse'";
  3113. }
  3114. if ($purchase) {
  3115. $where .= " and purchase = '$purchase'";
  3116. }
  3117. if ($orderinfo) {
  3118. $where .= " and orderinfo = '$orderinfo'";
  3119. }
  3120. if ($waybill) {
  3121. $where .= " and waybill = '$waybill'";
  3122. }
  3123. if ($category) {
  3124. $where .= " and features like '%-$category-%'";
  3125. }
  3126. if ($size) {
  3127. $where .= " and features like '%-$size-%'";
  3128. }
  3129. if ($grade) {
  3130. $where .= " and features like '%-$grade-%'";
  3131. }
  3132. if ($color) {
  3133. $where .= " and features like '%-$color-%'";
  3134. }
  3135. if ($lowe) {
  3136. $where .= " and features like '%-$lowe-%'";
  3137. }
  3138. //数据排序
  3139. $order_str = "time desc";
  3140. if (empty($page)) {
  3141. $start = 0;
  3142. $perpage = 1;
  3143. } else {
  3144. $start = ($page - 1) * $perpage;
  3145. }
  3146. //取得信息列表
  3147. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3148. foreach ($info_list as $key => $value) {
  3149. $warehouse = $this->warehouse->read($value['warehouse']);
  3150. $info_list[$key]['warehouse'] = $warehouse['title'];
  3151. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3152. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3153. $purchase = $this->purchase->read($value['purchase']);
  3154. $info_list[$key]['purchase'] = $purchase['title'];
  3155. if ($value['outk'] != 0) {
  3156. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3157. } else {
  3158. $info_list[$key]['outk'] = "";
  3159. }
  3160. if ($value['retreat'] != 0) {
  3161. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3162. } else {
  3163. $info_list[$key]['retreat'] = "";
  3164. }
  3165. if ($value['orderinfo'] == 0) {
  3166. $info_list[$key]['orderinfo'] = "";
  3167. }
  3168. if ($value['waybill'] == 0) {
  3169. $info_list[$key]['waybill'] = "";
  3170. }
  3171. }
  3172. $total = $this->whlabel->find_count($where);
  3173. $pagenum = ceil($total / $perpage);
  3174. $over = $total - ($start + $perpage);
  3175. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3176. echo json_encode($rows);
  3177. exit;
  3178. }
  3179. $this->_Template('whlabel_retreatlk', $this->data);
  3180. }
  3181. //更换标签及浏览
  3182. public function _change()
  3183. {
  3184. $post = $this->input->post(NULL, TRUE);
  3185. if (isset($post['page'])) {
  3186. $page = $this->input->post('page', true);
  3187. $perpage = $this->input->post('perpage', true);
  3188. $timetk = $this->input->post('timetk', true);
  3189. $timetj = $this->input->post('timetj', true);
  3190. $label = $this->input->post('label', true);
  3191. $oldlabel = $this->input->post('oldlabel', true);
  3192. $timetk = strtotime($timetk);
  3193. $timetj = strtotime($timetj);
  3194. $where = "state=10 ";
  3195. if ($timetk && $timetj) {
  3196. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3197. }
  3198. if ($label) {
  3199. $where .= " and label = '$label'";
  3200. }
  3201. if ($oldlabel) {
  3202. $where .= " and oldlabel = '$oldlabel'";
  3203. }
  3204. //数据排序
  3205. $order_str = "time asc";
  3206. if (empty($page)) {
  3207. $start = 0;
  3208. $perpage = 1;
  3209. } else {
  3210. $start = ($page - 1) * $perpage;
  3211. }
  3212. //取得信息列表
  3213. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3214. foreach ($info_list as $key => $value) {
  3215. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3216. }
  3217. $total = $this->whlabel->find_count($where);
  3218. $pagenum = ceil($total / $perpage);
  3219. $over = $total - ($start + $perpage);
  3220. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3221. echo json_encode($rows);
  3222. exit;
  3223. }
  3224. $this->_Template('whlabel_change', $this->data);
  3225. }
  3226. //产品标签
  3227. public function _cpbqdc()
  3228. {
  3229. if (isset($_GET['excel'])) {
  3230. $where = "1=1";
  3231. //数据排序
  3232. $order_str = "id desc";
  3233. if (empty($page)) {
  3234. $start = 0;
  3235. $perpage = 1;
  3236. } else {
  3237. $start = ($page - 1) * $perpage;
  3238. }
  3239. $warehouse = $this->input->get('warehouse', true);
  3240. $state = $this->input->get('state', true);
  3241. $timetk = $this->input->get('timetkk', true);
  3242. $timetj = $this->input->get('timetjj', true);
  3243. $timetk = strtotime($timetk);
  3244. $timetj = strtotime($timetj);
  3245. if ($warehouse) {
  3246. $where .= " and warehouse = '$warehouse'";
  3247. }
  3248. if ($state || $state == 0) {
  3249. $where .= " and state = '$state'";
  3250. }
  3251. if ($timetk && $timetj) {
  3252. $where .= " and time > '$timetk' and time < '$timetj'";
  3253. }
  3254. //取得信息列表
  3255. $info_list = $this->whlabel->find_all($where, '*');
  3256. $rows = array();
  3257. $list = array();
  3258. foreach ($info_list as $key => $value) {
  3259. $rows[$value['time']] = $value; //所有数据sku
  3260. }
  3261. foreach ($rows as $value) {
  3262. $warehouse = $this->warehouse->read($value['warehouse']);
  3263. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3264. $list[] = array($warehouse['title'], $value['sku'], $value['title'], date('Y-m-d H:i:s', $value['enter']), date('Y-m-d H:i:s', $value['time']), $value['text'], $s);
  3265. }
  3266. $title = "产品标签统计表";
  3267. $titlename = "<table border=1>
  3268. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3269. <tr align='center'>
  3270. <td>仓库</td>
  3271. <td>SKU</td>
  3272. <td>产品</td>
  3273. <td>入库时间</td>
  3274. <td>操作时间</td>
  3275. <td>备注</td>
  3276. <td>数量</td>
  3277. </tr>
  3278. </table>";
  3279. $filename = $title . ".xls";
  3280. $tail = "";
  3281. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3282. }
  3283. }
  3284. //进销存导出
  3285. public function _exceljxc()
  3286. {
  3287. $classid = $this->classid->sku();
  3288. $pm = $classid;
  3289. $typeclass = array();
  3290. $tc = $this->typeclass->find_all();
  3291. foreach ($tc as $v) {
  3292. $typeclass[$v['id']] = $v;
  3293. }
  3294. $prc = array();
  3295. $purchase = $this->purchase->find_all();
  3296. foreach ($purchase as $k => $v) {
  3297. $prc[$v['id']] = $v['title'];
  3298. }
  3299. if (isset($_GET['excel'])) {
  3300. $where = "sku != 'Preset'";
  3301. //数据排序
  3302. $order_str = "id desc";
  3303. if (empty($page)) {
  3304. $start = 0;
  3305. $perpage = 1;
  3306. } else {
  3307. $start = ($page - 1) * $perpage;
  3308. }
  3309. $category = $this->input->get('category', true);
  3310. $warehouse = $this->input->get('warehouse', true);
  3311. $excelid = $this->input->get('sid', true);
  3312. if ($category) {
  3313. $where .= " and features like '%-$category-%'";
  3314. }
  3315. if ($warehouse) {
  3316. $where .= " and warehouse = '$warehouse'";
  3317. }
  3318. $xzid = '';
  3319. if ($excelid) {
  3320. $excelid = explode(',', trim($excelid, ','));
  3321. foreach ($excelid as $key => $value) {
  3322. $xzid .= " id = " . $value . " or";
  3323. }
  3324. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3325. }
  3326. //取得信息列表
  3327. /**
  3328. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3329. $rows = array();$list = array();
  3330. foreach ($info_list as $key=>$value)
  3331. {
  3332. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3333. }
  3334. **/
  3335. $wt = array();
  3336. $whlabel_type = $this->whlabel_type->find_all();
  3337. foreach ($whlabel_type as $v) {
  3338. $wt[$v['id']] = $v['title'];
  3339. }
  3340. $wh = array();
  3341. $w = $this->warehouse->find_all('1=1', 'id,title');
  3342. foreach ($w as $v) {
  3343. $wh[$v['id']] = $v['title'];
  3344. }
  3345. $list = array();
  3346. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3347. foreach ($rows as $key => $value) {
  3348. if (isset($wt[$value['type']])) {
  3349. $rows[$key]['type'] = $wt[$value['type']];
  3350. } else {
  3351. $rows[$key]['type'] = '未设置';
  3352. }
  3353. $bm = '03';
  3354. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3355. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3356. $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  3357. $details = array();
  3358. $cpid = array();
  3359. $cpbz = array();
  3360. $c = 0;
  3361. $g = 0;
  3362. $x = 0;
  3363. $t = 0;
  3364. $s = 0;
  3365. $q = 0;
  3366. foreach ($sd as $k => $v) {
  3367. if ($v['state'] == 0) {
  3368. $c++;
  3369. if ($v['cpid'] != 0) {
  3370. $cpid[$v['cpid']] = $v['cpid'];
  3371. }
  3372. if ($v['cpbz'] != '') {
  3373. $cpbz[$v['cpbz']] = $v['cpbz'];
  3374. }
  3375. }
  3376. if ($v['state'] != 9) {
  3377. $g++;
  3378. }
  3379. if ($v['state'] == 1) {
  3380. $x++;
  3381. }
  3382. if ($v['state'] == 2) {
  3383. $t++;
  3384. }
  3385. if ($v['state'] == 8) {
  3386. $s++;
  3387. }
  3388. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3389. $q++;
  3390. }
  3391. $details[$v['details']] = $v['details'];
  3392. }
  3393. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  3394. $rows[$key]['details'] = implode("、", $details);
  3395. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3396. $number = $value['number'];
  3397. $ftime = time() - 15 * 24 * 3600;
  3398. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3399. $rows[$key]['number'] = $g;
  3400. $rows[$key]['c'] = $c;
  3401. $rows[$key]['x'] = $x;
  3402. $rows[$key]['t'] = $t;
  3403. $rows[$key]['s'] = $s;
  3404. $rows[$key]['q'] = $q;
  3405. $rows[$key]['z'] = $z;
  3406. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3407. $features = explode('-', trim($features, '-'));
  3408. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3409. // $pm = $classid;
  3410. // $jm = $classid;
  3411. // foreach($features as $k=>$v)
  3412. // {
  3413. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3414. // {
  3415. // if($typeclass[$v]['bm'] != '')
  3416. // {
  3417. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3418. // }
  3419. // }
  3420. // if($v != 0)
  3421. // {
  3422. // if(!isset($typeclass[$v]))
  3423. // {
  3424. // continue;
  3425. // }
  3426. // if(isset($pm[$typeclass[$v]['classid']]))
  3427. // {
  3428. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3429. // {
  3430. // $tz = explode('|',$typeclass[$v]['zh']);
  3431. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3432. // }
  3433. // else
  3434. // {
  3435. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3436. // }
  3437. // }
  3438. // if(isset($jm[$typeclass[$v]['classid']]))
  3439. // {
  3440. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3441. // }
  3442. // }
  3443. // }
  3444. // $jm = array_filter($jm);
  3445. // $rows[$key]['bs'] = implode("-",$jm);
  3446. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3447. // $zh = implode(" ",$pm);
  3448. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3449. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3450. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3451. // $rows[$key]['features'] = $zh;
  3452. }
  3453. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3454. $final_list = [];
  3455. foreach ($list as $k => $v) {
  3456. if (empty($v['sku'])) {
  3457. continue;
  3458. }
  3459. $final_list[] = [
  3460. "warehouse" => $v["warehouse"],
  3461. "purchase" => $v["purchase"],
  3462. "details" => $v["details"],
  3463. "cpid" => $v["cpid"],
  3464. "dbcontent" => $v["dbcontent"],
  3465. "sku" => $v["sku"],
  3466. "cs" => $v["bm"],
  3467. "bs" => $v["jm"],
  3468. "title" => $v["title"],
  3469. "features" => $v["pm"],
  3470. "cpbz" => $v["cpbz"],
  3471. "sm" => $v["sm"],
  3472. "type" => $v["type"],
  3473. "number" => $v["number"],
  3474. "c" => $v["c"],
  3475. "x" => $v["x"],
  3476. "t" => $v["t"],
  3477. "s" => $v["s"],
  3478. "q" => $v["q"],
  3479. "z" => $v["z"],
  3480. "weight" => $v['weight'],
  3481. ];
  3482. }
  3483. $title = "总进销存统计表";
  3484. $titlename = "<table border=1>
  3485. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3486. <tr align='center'>
  3487. <td>仓库</td>
  3488. <td>供应商</td>
  3489. <td>位置</td>
  3490. <td>库存编码</td>
  3491. <td>类目</td>
  3492. <td>SKU</td>
  3493. <td>用友编码</td>
  3494. <td>用友料号</td>
  3495. <td>商品名称</td>
  3496. <td>商品中文</td>
  3497. <td>产品备注</td>
  3498. <td>说明</td>
  3499. <td>类型</td>
  3500. <td>入库总量</td>
  3501. <td>库存数量</td>
  3502. <td>销售数量</td>
  3503. <td>退货数量</td>
  3504. <td>删除数量</td>
  3505. <td>其它操作</td>
  3506. <td>占单数量</td>
  3507. <td>重量(g)</td>
  3508. </tr>
  3509. </table>";
  3510. $filename = $title . ".xls";
  3511. $tail = "";
  3512. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3513. }
  3514. }
  3515. //入库导出
  3516. public function _excelr()
  3517. {
  3518. if (isset($_GET['excel'])) {
  3519. $category = $this->input->get('category', true);
  3520. $size = $this->input->get('size', true);
  3521. $grade = $this->input->get('grade', true);
  3522. $color = $this->input->get('color', true);
  3523. $lowe = $this->input->get('lowe', true);
  3524. $sku = $this->input->get('sku', true);
  3525. $warehouse = $this->input->get('warehouse', true);
  3526. $purchase = $this->input->get('purchase', true);
  3527. $ktime = $this->input->get('ktime', true);
  3528. $jtime = $this->input->get('jtime', true);
  3529. $ktime = strtotime($ktime);
  3530. $jtime = strtotime($jtime);
  3531. $where = "1=1";
  3532. $gj = "";
  3533. $ck = "";
  3534. if ($category) {
  3535. $where .= " and features like '%-$category-%'";
  3536. }
  3537. if ($size) {
  3538. $where .= " and features like '%-$size-%'";
  3539. }
  3540. if ($grade) {
  3541. $where .= " and features like '%-$grade-%'";
  3542. }
  3543. if ($color) {
  3544. $where .= " and features like '%-$color-%'";
  3545. }
  3546. if ($lowe) {
  3547. $where .= " and features like '%-$lowe-%'";
  3548. }
  3549. if ($warehouse) {
  3550. $where .= " and warehouse = '$warehouse'";
  3551. }
  3552. if ($purchase) {
  3553. $where .= " and purchase = '$purchase'";
  3554. }
  3555. if ($sku) {
  3556. $where .= " and sku = '$sku'";
  3557. }
  3558. if ($ktime && $jtime) {
  3559. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3560. }
  3561. //数据排序
  3562. $order_str = "id desc";
  3563. if (empty($page)) {
  3564. $start = 0;
  3565. $perpage = 1;
  3566. } else {
  3567. $start = ($page - 1) * $perpage;
  3568. }
  3569. $list = array();
  3570. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3571. foreach ($rows as $value) {
  3572. $ck = $this->warehouse->read($value['warehouse']);
  3573. $warehouse = $ck['title'];
  3574. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3575. $retreatwarehouse = $tkck['title'];
  3576. $gy = $this->purchase->read($value['purchase']);
  3577. $purchase = $gy['title'];
  3578. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3579. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3580. }
  3581. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3582. $titlename = "<table border=1>
  3583. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3584. <tr align='center'>
  3585. <td>仓库</td>
  3586. <td>SKU</td>
  3587. <td>产品</td>
  3588. <td>时间</td>
  3589. <td>数量</td>
  3590. </tr>
  3591. </table>";
  3592. $filename = $title . ".xls";
  3593. $tail = "";
  3594. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3595. }
  3596. }
  3597. //出库、退库导出
  3598. public function _excelct()
  3599. {
  3600. $classid = $this->classid->sku();
  3601. $pm = $classid;
  3602. $typeclass = array();
  3603. $tc = $this->typeclass->find_all();
  3604. foreach ($tc as $v) {
  3605. $typeclass[$v['id']] = $v;
  3606. }
  3607. $prc = array();
  3608. $purchase = $this->purchase->find_all();
  3609. foreach ($purchase as $k => $v) {
  3610. $prc[$v['id']] = $v['title'];
  3611. }
  3612. if (isset($_GET['excel'])) {
  3613. $wh = array();
  3614. $w = $this->warehouse->find_all('1=1', 'id,title');
  3615. foreach ($w as $v) {
  3616. $wh[$v['id']] = $v['title'];
  3617. }
  3618. $type = $this->input->get('excel', true);
  3619. $category = $this->input->get('category', true);
  3620. $size = $this->input->get('size', true);
  3621. $grade = $this->input->get('grade', true);
  3622. $color = $this->input->get('color', true);
  3623. $lowe = $this->input->get('lowe', true);
  3624. $sku = $this->input->get('sku', true);
  3625. $warehouse = $this->input->get('warehouse', true);
  3626. $lacetype = $this->input->get('lacetype', true);
  3627. $lacecolor = $this->input->get('lacecolor', true);
  3628. $density = $this->input->get('density', true);
  3629. $haircap = $this->input->get('haircap', true);
  3630. $purchase = $this->input->get('purchase', true);
  3631. $title = $this->input->get('title', true);
  3632. $state = $this->input->get('state', true);
  3633. $sid = $this->input->get('sid', true);
  3634. $ktime = $this->input->get('ktime', true);
  3635. $jtime = $this->input->get('jtime', true);
  3636. $ktime = strtotime($ktime);
  3637. $jtime = strtotime($jtime);
  3638. $where = "1=1";
  3639. $gj = "";
  3640. $ck = "";
  3641. if ($category) {
  3642. $where .= " and features like '%-$category-%'";
  3643. }
  3644. if ($size) {
  3645. $where .= " and features like '%-$size-%'";
  3646. }
  3647. if ($grade) {
  3648. $where .= " and features like '%-$grade-%'";
  3649. }
  3650. if ($color) {
  3651. $where .= " and features like '%-$color-%'";
  3652. }
  3653. if ($lowe) {
  3654. $where .= " and features like '%-$lowe-%'";
  3655. }
  3656. if ($warehouse) {
  3657. $where .= " and warehouse = '$warehouse'";
  3658. }
  3659. if ($purchase) {
  3660. $where .= " and purchase = '$purchase'";
  3661. }
  3662. if ($state) {
  3663. $where .= " and state = '$state'";
  3664. }
  3665. if ($lacetype) {
  3666. $where .= " and features like '%-$lacetype-%'";
  3667. }
  3668. if ($lacecolor) {
  3669. $where .= " and features like '%-$lacecolor-%'";
  3670. }
  3671. if ($density) {
  3672. $where .= " and features like '%-$density-%'";
  3673. }
  3674. if ($haircap) {
  3675. $where .= " and features like '%-$haircap-%'";
  3676. }
  3677. if ($title) {
  3678. $title = trim($title, ' ');
  3679. $title = trim($title, ' ');
  3680. $where .= " and title like '%$title%'";
  3681. }
  3682. if ($sku) {
  3683. $sku = trim($sku, ' ');
  3684. $sku = trim($sku, ' ');
  3685. $where .= " and sku like '%$sku%'";
  3686. }
  3687. if ($ktime && $jtime) {
  3688. if ($type == 1) {
  3689. $tl = '出库';
  3690. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3691. } else if ($type == 2) {
  3692. $tl = '退库';
  3693. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3694. } else if ($type == 3) {
  3695. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3696. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3697. } else if ($type == 4) {
  3698. $tl = '出库+零售';
  3699. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3700. } else if ($type == 5) {
  3701. $tl = '零售';
  3702. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3703. }
  3704. }
  3705. $sidwhere = '';
  3706. if ($sid) {
  3707. $sd = "";
  3708. $s = explode(',', trim($sid, ','));
  3709. foreach ($s as $value) {
  3710. $sd .= " id = " . $value . " or";
  3711. }
  3712. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3713. }
  3714. //数据排序
  3715. $order_str = "time desc";
  3716. if (empty($page)) {
  3717. $start = 0;
  3718. $perpage = 1;
  3719. } else {
  3720. $start = ($page - 1) * $perpage;
  3721. }
  3722. $this->logic_ding->sendToDing("导出出入库分类数据".$where);
  3723. //取得信息列表
  3724. if ($type != 3 && $type != 5) {
  3725. if ($type == 1 || $type == 4) {
  3726. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3727. foreach ($info_list as $key => $value) {
  3728. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3729. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3730. $warehouse = $this->warehouse->read($value['warehouse']);
  3731. $info_list[$key]['warehouse'] = $warehouse['title'];
  3732. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3733. $features = explode('-', trim($features, '-'));
  3734. $pm = $classid;
  3735. foreach ($features as $k => $v) {
  3736. if ($v != 0) {
  3737. if (!isset($typeclass[$v])) {
  3738. continue;
  3739. }
  3740. if (isset($pm[$typeclass[$v]['classid']])) {
  3741. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3742. $tz = explode('|', $typeclass[$v]['zh']);
  3743. $pm[$typeclass[$v]['classid']] = $tz[0];
  3744. } else {
  3745. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3746. }
  3747. }
  3748. }
  3749. }
  3750. $zh = implode(" ", $pm);
  3751. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3752. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3753. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3754. $info_list[$key]['features'] = $zh;
  3755. }
  3756. $final_list = [];
  3757. foreach($info_list as $k=>$v){
  3758. $number = "";
  3759. if(!empty($v['orderinfo'])){
  3760. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3761. if(!empty($tmp_info['number'])){
  3762. $number = $tmp_info['number'];
  3763. }
  3764. }
  3765. $final_list[] = [
  3766. 'warehouse'=>$v['warehouse'],
  3767. 'purchase'=>$v['purchase'],
  3768. 'sku'=>$v['sku'],
  3769. 'title'=>$v['title'],
  3770. 'features'=>$v['features'],
  3771. 'label'=>$v['label'],
  3772. 'orderinfo'=>$v['orderinfo'],
  3773. 'number'=>$number,
  3774. 'waybill'=>$v['waybill'],
  3775. 'outk'=>$v['outk'],
  3776. ];
  3777. }
  3778. } else {
  3779. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3780. foreach ($info_list as $key => $value) {
  3781. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3782. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3783. $warehouse = $this->warehouse->read($value['warehouse']);
  3784. $info_list[$key]['warehouse'] = $warehouse['title'];
  3785. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3786. $features = explode('-', trim($features, '-'));
  3787. $pm = $classid;
  3788. foreach ($features as $k => $v) {
  3789. if ($v != 0) {
  3790. if (!isset($typeclass[$v])) {
  3791. continue;
  3792. }
  3793. if (isset($pm[$typeclass[$v]['classid']])) {
  3794. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3795. $tz = explode('|', $typeclass[$v]['zh']);
  3796. $pm[$typeclass[$v]['classid']] = $tz[0];
  3797. } else {
  3798. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3799. }
  3800. }
  3801. }
  3802. }
  3803. $zh = implode(" ", $pm);
  3804. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3805. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3806. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3807. $info_list[$key]['features'] = $zh;
  3808. }
  3809. $final_list = [];
  3810. foreach($info_list as $k=>$v){
  3811. $number = "";
  3812. if(!empty($v['orderinfo'])){
  3813. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3814. if(!empty($tmp_info['number'])){
  3815. $number = $tmp_info['number'];
  3816. }
  3817. }
  3818. $final_list[] = [
  3819. 'warehouse'=>$v['warehouse'],
  3820. 'purchase'=>$v['purchase'],
  3821. 'sku'=>$v['sku'],
  3822. 'title'=>$v['title'],
  3823. 'features'=>$v['features'],
  3824. 'label'=>$v['label'],
  3825. 'orderinfo'=>$v['orderinfo'],
  3826. 'number'=>$number,
  3827. 'waybill'=>$v['waybill'],
  3828. 'retreat'=>$v['retreat'],
  3829. ];
  3830. }
  3831. }
  3832. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3833. $titlename = "<table border=1>
  3834. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3835. <tr align='center'>
  3836. <td>仓库</td>
  3837. <td>供应商</td>
  3838. <td>SKU</td>
  3839. <td>商品名称</td>
  3840. <td>商品中文</td>
  3841. <td>标签</td>
  3842. <td>订单号</td>
  3843. <td>订单编码</td>
  3844. <td>运单号</td>
  3845. <td>" . $tl . "时间(中国时间)</td>
  3846. </tr>
  3847. </table>";
  3848. $filename = $title . ".xls";
  3849. $tail = "";
  3850. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3851. } else if ($type == 5) {
  3852. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3853. foreach ($info_list as $key => $value) {
  3854. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3855. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3856. $warehouse = $this->warehouse->read($value['warehouse']);
  3857. $info_list[$key]['warehouse'] = $warehouse['title'];
  3858. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3859. $features = explode('-', trim($features, '-'));
  3860. $pm = $classid;
  3861. foreach ($features as $k => $v) {
  3862. if ($v != 0) {
  3863. if (!isset($typeclass[$v])) {
  3864. continue;
  3865. }
  3866. if (isset($pm[$typeclass[$v]['classid']])) {
  3867. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3868. $tz = explode('|', $typeclass[$v]['zh']);
  3869. $pm[$typeclass[$v]['classid']] = $tz[0];
  3870. } else {
  3871. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3872. }
  3873. }
  3874. }
  3875. }
  3876. $zh = implode(" ", $pm);
  3877. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3878. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3879. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3880. $info_list[$key]['features'] = $zh;
  3881. }
  3882. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3883. $titlename = "<table border=1>
  3884. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3885. <tr align='center'>
  3886. <td>仓库</td>
  3887. <td>供应商</td>
  3888. <td>SKU</td>
  3889. <td>商品名称</td>
  3890. <td>商品中文</td>
  3891. <td>标签</td>
  3892. <td>" . $tl . "时间(中国时间)</td>
  3893. </tr>
  3894. </table>";
  3895. $filename = $title . ".xls";
  3896. $tail = "";
  3897. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3898. } else {
  3899. /**
  3900. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3901. $rows = array();$list = array();
  3902. foreach ($info_list as $key=>$value)
  3903. {
  3904. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3905. }
  3906. **/
  3907. $wh = array();
  3908. $w = $this->warehouse->find_all('1=1', 'id,title');
  3909. foreach ($w as $v) {
  3910. $wh[$v['id']] = $v['title'];
  3911. }
  3912. $wt = array();
  3913. $whlabel_type = $this->whlabel_type->find_all();
  3914. foreach ($whlabel_type as $v) {
  3915. $wt[$v['id']] = $v['title'];
  3916. }
  3917. $classid = $this->classid->sku();
  3918. $list = array();
  3919. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3920. foreach ($rows as $key => $value) {
  3921. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3922. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3923. $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');
  3924. $details = array();
  3925. $cpid = array();
  3926. $cpbz = array();
  3927. $c = 0;
  3928. $g = 0;
  3929. $x = 0;
  3930. $t = 0;
  3931. $s = 0;
  3932. $q = 0;
  3933. foreach ($sd as $k => $v) {
  3934. if ($v['state'] == 0) {
  3935. $c++;
  3936. }
  3937. if ($v['state'] != 9) {
  3938. $g++;
  3939. }
  3940. if ($v['outk'] > 1) {
  3941. $x++;
  3942. }
  3943. if ($v['retreat'] > 0) {
  3944. $t++;
  3945. }
  3946. if ($v['state'] == 8) {
  3947. $s++;
  3948. }
  3949. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3950. $q++;
  3951. }
  3952. $details[$v['details']] = $v['details'];
  3953. if ($v['cpid'] != 0) {
  3954. $cpid[$v['cpid']] = $v['cpid'];
  3955. }
  3956. if ($v['cpbz'] != '') {
  3957. $cpbz[$v['cpbz']] = $v['cpbz'];
  3958. }
  3959. }
  3960. if (isset($wt[$value['type']])) {
  3961. $rows[$key]['type'] = $wt[$value['type']];
  3962. } else {
  3963. $rows[$key]['type'] = '未设置';
  3964. }
  3965. $rows[$key]['details'] = implode("、", $details);
  3966. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3967. $ftime = time() - 15 * 24 * 3600;
  3968. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3969. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3970. $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);
  3971. $rows[$key]['c'] = $c;
  3972. $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);
  3973. $rows[$key]['t'] = $t;
  3974. $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'] . '"');
  3975. $rows[$key]['z'] = $z;
  3976. // $jm = $classid;
  3977. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3978. $features = explode('-', trim($features, '-'));
  3979. // $pm = $classid;
  3980. // foreach ($features as $k => $v) {
  3981. // if ($v != 0) {
  3982. // if (!isset($typeclass[$v])) {
  3983. // continue;
  3984. // }
  3985. // if (isset($pm[$typeclass[$v]['classid']])) {
  3986. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3987. // $tz = explode('|', $typeclass[$v]['zh']);
  3988. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3989. // } else {
  3990. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3991. // }
  3992. // if (isset($jm[$typeclass[$v]['classid']])) {
  3993. // if ($typeclass[$v]['jm']) {
  3994. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3995. // }
  3996. // }
  3997. // }
  3998. // }
  3999. // }
  4000. // $zh = implode(" ", $pm);
  4001. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4002. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4003. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4004. // $rows[$key]['features'] = $zh;
  4005. // $jm = array_filter($jm); //去除空值
  4006. // $jm = implode("-", $jm);
  4007. // $rows[$key]['jm'] = $jm;
  4008. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4009. }
  4010. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4011. // echo "<pre>";
  4012. // print_r($tmp_list);
  4013. // die;
  4014. $final_list =[];
  4015. foreach($tmp_list as $k=>$v){
  4016. $final_list[] = [
  4017. "warehouse"=>$v['warehouse'],
  4018. "purchase"=>$v['purchase'],
  4019. "details"=>$v['details'],
  4020. "cpid"=>$v['cpid'],
  4021. "sku"=>$v['sku'],
  4022. "title"=>$v['title'],
  4023. "features"=>$v['pm'],
  4024. "cpbz"=>$v['cpbz'],
  4025. "sm"=>$v['sm'],
  4026. "type"=>$v['type'],
  4027. "g"=>$v["g"],
  4028. "c"=>$v["c"],
  4029. "x"=>$v["x"],
  4030. "t"=>$v["t"],
  4031. "z"=>$v["z"],
  4032. "jm"=>$v["jm"],
  4033. "weight"=>$v["weight"],
  4034. "asd"=>$v["asd"],
  4035. ];
  4036. }
  4037. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4038. $titlename = "<table border=1>
  4039. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4040. <tr align='center'>
  4041. <td>仓库</td>
  4042. <td>供应商</td>
  4043. <td>位置</td>
  4044. <td>库存编码</td>
  4045. <td>SKU</td>
  4046. <td>商品名称</td>
  4047. <td>商品中文</td>
  4048. <td>产品备注</td>
  4049. <td>说明</td>
  4050. <td>类型</td>
  4051. <td>入库总量</td>
  4052. <td>库存数量</td>
  4053. <td>销售数量</td>
  4054. <td>退货数量</td>
  4055. <td>占单数量</td>
  4056. <td>料号</td>
  4057. <td>重量</td>
  4058. <td>类目</td>
  4059. </tr>
  4060. </table>";
  4061. $filename = $title . ".xls";
  4062. $tail = "";
  4063. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4064. }
  4065. }
  4066. }
  4067. //出库+入库数据整合
  4068. public function _excelcr()
  4069. {
  4070. if (isset($_GET['excel'])) {
  4071. $type = $this->input->get('excel', true);
  4072. $category = $this->input->get('category', true);
  4073. $size = $this->input->get('size', true);
  4074. $grade = $this->input->get('grade', true);
  4075. $color = $this->input->get('color', true);
  4076. $lowe = $this->input->get('lowe', true);
  4077. $sku = $this->input->get('sku', true);
  4078. $warehouse = $this->input->get('warehouse', true);
  4079. $purchase = $this->input->get('purchase', true);
  4080. $state = $this->input->get('state', true);
  4081. $sid = $this->input->get('sid', true);
  4082. $ktime = $this->input->get('ktime', true);
  4083. $jtime = $this->input->get('jtime', true);
  4084. $ktime = strtotime($ktime);
  4085. $jtime = strtotime($jtime);
  4086. $where = "1=1";
  4087. $gj = "";
  4088. $ck = "";
  4089. if ($category) {
  4090. $where .= " and features like '%-$category-%'";
  4091. }
  4092. if ($size) {
  4093. $where .= " and features like '%-$size-%'";
  4094. }
  4095. if ($grade) {
  4096. $where .= " and features like '%-$grade-%'";
  4097. }
  4098. if ($color) {
  4099. $where .= " and features like '%-$color-%'";
  4100. }
  4101. if ($lowe) {
  4102. $where .= " and features like '%-$lowe-%'";
  4103. }
  4104. if ($warehouse) {
  4105. $where .= " and warehouse = '$warehouse'";
  4106. }
  4107. if ($purchase) {
  4108. $where .= " and purchase = '$purchase'";
  4109. }
  4110. if ($state) {
  4111. $where .= " and state = '$state'";
  4112. }
  4113. if ($sku) {
  4114. $where .= " and sku like '%$sku%'";
  4115. }
  4116. if ($ktime && $jtime) {
  4117. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4118. }
  4119. $sidwhere = '';
  4120. if ($sid) {
  4121. $sd = "";
  4122. $s = explode(',', trim($sid, ','));
  4123. foreach ($s as $value) {
  4124. $sd .= " id = " . $value . " or";
  4125. }
  4126. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4127. }
  4128. //取得信息列表
  4129. $timeread = $ktime;
  4130. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4131. $timelist = array();
  4132. for ($i = 0; $i < $timenum; $i++) {
  4133. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4134. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4135. }
  4136. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4137. //echo "<pre>";
  4138. //print_r($info_list);
  4139. //exit();
  4140. $rows = array();
  4141. $list = array();
  4142. foreach ($info_list as $key => $value) {
  4143. $thistime = $timelist;
  4144. if (isset($rows[strtolower($value['sku'])])) {
  4145. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4146. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4147. }
  4148. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4149. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4150. }
  4151. } else {
  4152. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4153. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4154. }
  4155. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4156. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4157. }
  4158. $rows[strtolower($value['sku'])] = $thistime;
  4159. }
  4160. }
  4161. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4162. <head>
  4163. <!--[if gte mso 9]><xml>
  4164. <x:ExcelWorkbook>
  4165. <x:ExcelWorksheets>
  4166. <x:ExcelWorksheet>
  4167. <x:Name>EXCEL</x:Name>
  4168. <x:WorksheetOptions>
  4169. <x:Print>
  4170. <x:ValidPrinterInfo />
  4171. </x:Print>
  4172. </x:WorksheetOptions>
  4173. </x:ExcelWorksheet>
  4174. </x:ExcelWorksheets>
  4175. </x:ExcelWorkbook>
  4176. </xml>
  4177. <![endif]-->
  4178. </head><body>";
  4179. $str .= "<table border=1><tr><td>SKU</td>";
  4180. foreach ($timelist as $k => $v) {
  4181. $str .= "<td>" . $k . "出库</td>";
  4182. $str .= "<td>" . $k . "入库</td>";
  4183. }
  4184. $str .= "</tr></table>";
  4185. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4186. foreach ($rows as $key => $val) {
  4187. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4188. foreach ($val as $k => $v) {
  4189. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4190. if ($val[$k]['r'] > 0) {
  4191. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4192. } else {
  4193. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4194. }
  4195. }
  4196. $str .= "</tr>";
  4197. }
  4198. $str .= "</table>";
  4199. $str .= "</body></html>";
  4200. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4201. header("Content-type: application/octet-stream");
  4202. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4203. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4204. header("Pragma: no-cache");
  4205. header("Expires: 0");
  4206. exit($str);
  4207. }
  4208. }
  4209. //数量调整模板导出
  4210. public function _presetout()
  4211. {
  4212. if (isset($_GET['excel'])) {
  4213. $where = "sku != 'Preset' and purchase != 0";
  4214. //数据排序
  4215. $order_str = "id desc";
  4216. if (empty($page)) {
  4217. $start = 0;
  4218. $perpage = 1;
  4219. } else {
  4220. $start = ($page - 1) * $perpage;
  4221. }
  4222. //取得信息列表
  4223. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4224. $rows = array();
  4225. $list = array();
  4226. foreach ($info_list as $value) {
  4227. $warehouse = $this->warehouse->read($value['warehouse']);
  4228. $number = $value['number'];
  4229. $ftime = time() - 15 * 24 * 3600;
  4230. $purchase = $this->purchase->read($value['purchase']);
  4231. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4232. }
  4233. $title = "库存模板";
  4234. $titlename = "<table border=1>
  4235. <tr align='center'>
  4236. <td>仓库</td>
  4237. <td>供应商编码</td>
  4238. <td>SKU</td>
  4239. <td>增减数量(正数或负数)</td>
  4240. <td>增减备注</td>
  4241. <td>扣减方式:0减少库存1删除库存</td>
  4242. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4243. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4244. </tr>
  4245. </table>";
  4246. $filename = $title . ".xls";
  4247. $tail = "";
  4248. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4249. }
  4250. }
  4251. //数量调整模板导入
  4252. public function _presetedit()
  4253. {
  4254. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4255. $config['upload_path'] = '.' . $dir;
  4256. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4257. $config['allowed_types'] = 'xls|xlsx|csv';
  4258. $config['max_size'] = 10240;
  4259. $this->load->library('upload', $config);
  4260. $this->upload->initialize($config);
  4261. if ($this->upload->do_upload('userfile')) {
  4262. $full_path = $dir . $this->upload->data('file_name');
  4263. $fileName = '.' . $full_path;
  4264. if (!file_exists($fileName)) {
  4265. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4266. exit;
  4267. } else {
  4268. require_once "./data/excel/PHPExcel/IOFactory.php";
  4269. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4270. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4271. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4272. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4273. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4274. ++$column; //如果列数大于26行
  4275. $list = array();
  4276. for ($i = 2; $i <= $row; $i++) // 行数循环
  4277. {
  4278. $data = array();
  4279. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4280. {
  4281. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4282. }
  4283. $list[] = $data;
  4284. }
  4285. }
  4286. $i = 0;
  4287. $j = 0;
  4288. $ed = array();
  4289. foreach ($list as $key => $value) {
  4290. $time = time();
  4291. if ($value['0'] == "") {
  4292. continue;
  4293. }
  4294. $warehouse = $this->warehouse->get_title($value['0']);
  4295. $purchase = $this->purchase->get_bm($value['1']);
  4296. $sku = $value['2'];
  4297. $num = $value['3']; //调整数量
  4298. $text = $value['4']; //扣减说明
  4299. $type = $value['5']; //调整方式0扣减1删除
  4300. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4301. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4302. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4303. if (!$purchase) //如果没有这个SKU
  4304. {
  4305. $ed[] = array($purchase . '-不存在此供应商编码');
  4306. $j++;
  4307. continue;
  4308. }
  4309. if (!$d) //如果没有这个SKU
  4310. {
  4311. $ed[] = array($sku . '-库存中不存在此SKU');
  4312. $j++;
  4313. continue;
  4314. }
  4315. if (!isset($warehouse['id'])) {
  4316. $ed[] = array($sku . '-仓库名错误!');
  4317. $j++;
  4318. continue;
  4319. }
  4320. if ($type != '0' && $type != '1') {
  4321. $ed[] = array($sku . '-扣减方式填写错误!');
  4322. $j++;
  4323. continue;
  4324. }
  4325. if ($num < 0) //扣减库存
  4326. {
  4327. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4328. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4329. $j++;
  4330. continue;
  4331. }
  4332. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4333. if (count($data) < abs($num)) {
  4334. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4335. $j++;
  4336. continue;
  4337. }
  4338. if ($type == 0) //如果扣减方式为 扣减库存
  4339. {
  4340. for ($i = 0; $i < abs($num); $i++) {
  4341. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4342. }
  4343. } else if ($type == 1) {
  4344. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4345. if (count($zt) > 0) {
  4346. $ed[] = array($sku . '-有在途库存无法删除!');
  4347. $j++;
  4348. continue;
  4349. }
  4350. for ($i = 0; $i < abs($num); $i++) {
  4351. $this->whlabel->remove($data[$i]['id']);
  4352. }
  4353. }
  4354. } else if ($num > 0) //增加库存
  4355. {
  4356. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4357. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4358. $j++;
  4359. continue;
  4360. }
  4361. $post['sku'] = $d['sku'];
  4362. $post['shop'] = $d['shop'];
  4363. $post['warehouse'] = $warehouse['id'];
  4364. $post['purchase'] = $purchase['id'];
  4365. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4366. $post['state'] = 0;
  4367. $post['title'] = $d['title'];
  4368. $post['number'] = $d['number'];
  4369. $post['features'] = $d['features'];
  4370. $post['enter'] = $time;
  4371. $post['time'] = $time; //操作时间
  4372. $post['rktype'] = $rktype;
  4373. for ($i = 0; $i < $num; $i++) {
  4374. $post['label'] = time() . rand(100, 999) . $i;
  4375. $this->whlabel->insert($post);
  4376. }
  4377. }
  4378. sleep(1); //防止入库时间一样,需要延迟1秒
  4379. }
  4380. if ($j > 0) {
  4381. $tt = date('Ymd', time());
  4382. $title = '库存导入错误信息-' . $tt;
  4383. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4384. $tail = "\n";
  4385. $filename = $title . ".xls";
  4386. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4387. $dir = '/data/excel/' . $time . '/';
  4388. $file_name = 'error_' . $time . rand(1000, 9999);
  4389. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4390. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4391. fwrite($myfile, $ecl);
  4392. fclose($myfile);
  4393. $error = $dir . $file_name . '.xls';
  4394. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4395. exit;
  4396. } else {
  4397. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4398. exit;
  4399. }
  4400. }
  4401. }
  4402. //笛卡儿积
  4403. function cp($ps, $sets, $list)
  4404. {
  4405. $result = array();
  4406. $j = 0;
  4407. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4408. if ($i == 0) {
  4409. $result = $sets[$i];
  4410. }
  4411. $tmp = array();
  4412. foreach ($result as $res) {
  4413. foreach ($sets[$i + 1] as $set) {
  4414. $tmp[] = $res . ',' . $set;
  4415. }
  4416. }
  4417. $result = $tmp;
  4418. }
  4419. $this->db->trans_begin();
  4420. foreach ($result as $v) {
  4421. $post = array();
  4422. $title = "";
  4423. $num = "";
  4424. $data = explode(',', $v);
  4425. for ($i = 0; $i < count($list); $i++) {
  4426. $post[$list[$i]] = $data[$i];
  4427. $typeclass = $this->typeclass->read($data[$i]);
  4428. $title = $title . $typeclass['title'] . " ";
  4429. if ($data[$i] != 0) {
  4430. $num .= $data[$i]; //所有数据ID拼接
  4431. }
  4432. }
  4433. foreach ($ps as $kp => $vp) {
  4434. $post[$kp] = $vp;
  4435. }
  4436. $post['number'] = $num;
  4437. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4438. if ($info_list) {
  4439. $j++;
  4440. } else {
  4441. $skunum = $this->whlabel->find_count();
  4442. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4443. $post['title'] = rtrim($title, ' ');
  4444. $this->whlabel->insert($post);
  4445. }
  4446. }
  4447. if ($this->db->trans_status() === FALSE) {
  4448. $this->db->trans_commit();
  4449. return NULL;
  4450. } else {
  4451. $this->db->trans_commit();
  4452. return $j;
  4453. }
  4454. }
  4455. public function _kj($arg_array)
  4456. {
  4457. if (isset($_POST['sku'])) {
  4458. $time = time();
  4459. $sku = $this->input->post('sku', true);
  4460. $warehouse = $this->input->post('warehouse', true);
  4461. $num = $this->input->post('num', true);
  4462. $text = $this->input->post('text', true);
  4463. $purchase = $this->input->post('purchase', true);
  4464. $cktype = $this->input->post('cktype', true);
  4465. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4466. if ($cktype != 1 && $text == '') {
  4467. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4468. exit;
  4469. }
  4470. if ($num > count($order)) {
  4471. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4472. exit;
  4473. } else {
  4474. for ($i = 0; $i < $num; $i++) {
  4475. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4476. }
  4477. }
  4478. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4479. exit;
  4480. }
  4481. $uid = $this->whlabel->read($arg_array[0]);
  4482. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4483. $this->data['data'] = $uid;
  4484. $this->_Template('whlabel_kj', $this->data);
  4485. }
  4486. public function _summary($arg_array)
  4487. {
  4488. $prc = array();
  4489. $purchase = $this->purchase->find_all();
  4490. foreach ($purchase as $k => $v) {
  4491. $prc[$v['id']] = $v['title'];
  4492. }
  4493. if (isset($_GET['excel'])) {
  4494. $ktime = $this->input->get('ktime', true);
  4495. $jtime = $this->input->get('jtime', true);
  4496. $ktime = strtotime($ktime);
  4497. $jtime = strtotime($jtime);
  4498. $where = "1=1";
  4499. if ($ktime && $jtime) {
  4500. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4501. }
  4502. //数据排序
  4503. $order_str = "time desc";
  4504. if (empty($page)) {
  4505. $start = 0;
  4506. $perpage = 1;
  4507. } else {
  4508. $start = ($page - 1) * $perpage;
  4509. }
  4510. //取得信息列表
  4511. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4512. foreach ($info_list as $key => $value) {
  4513. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4514. $warehouse = $this->warehouse->read($value['warehouse']);
  4515. $info_list[$key]['warehouse'] = $warehouse['title'];
  4516. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4517. $details = array();
  4518. $cpid = array();
  4519. foreach ($x as $k => $v) {
  4520. if ($v['details'] != '') {
  4521. $details[$v['details']] = $v['details'];
  4522. }
  4523. if ($v['cpid'] != 0) {
  4524. $cpid[$v['cpid']] = $v['cpid'];
  4525. }
  4526. }
  4527. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4528. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4529. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4530. $info_list[$key]['s'] = $s;
  4531. $info_list[$key]['x'] = count($x);
  4532. }
  4533. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4534. $titlename = "<table border=1>
  4535. <tr align='center'>
  4536. <td>仓库</td>
  4537. <td>供应商</td>
  4538. <td>出库位置</td>
  4539. <td>出库编码</td>
  4540. <td>SKU</td>
  4541. <td>产品名</td>
  4542. <td>总剩余库存</td>
  4543. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4544. </tr>
  4545. </table>";
  4546. $filename = $title . ".xls";
  4547. $tail = "";
  4548. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4549. }
  4550. }
  4551. //usps发货清单
  4552. public function _manifest()
  4553. {
  4554. if (isset($_POST['manifest'])) {
  4555. $wltext = $this->input->post('wltext', true);
  4556. $time = time() - 16 * 3600;
  4557. $ptime = strtotime(date('Y-m-d', $time));
  4558. $waybill = array();
  4559. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4560. foreach ($fullorder as $v) {
  4561. $waybill[$v['waybill']] = $v['waybill'];
  4562. }
  4563. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4564. foreach ($fullordersmt as $v) {
  4565. $waybill[$v['waybill']] = $v['waybill'];
  4566. }
  4567. $wltext = explode(';', $wltext);
  4568. foreach ($wltext as $v) {
  4569. if (isset($waybill[$v])) {
  4570. unset($waybill[$v]);
  4571. }
  4572. }
  4573. $data = $this->usps->get_manifest($waybill);
  4574. if (isset($data['Description'])) {
  4575. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4576. exit;
  4577. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4578. $bctime = date('Ymd', time());
  4579. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4580. echo json_encode(array('msg' => $pdf, 'success' => true));
  4581. exit;
  4582. } else {
  4583. echo json_encode(array('msg' => $data, 'success' => false));
  4584. exit;
  4585. }
  4586. }
  4587. }
  4588. public function _pdf($pdf, $title, $bctime)
  4589. {
  4590. $pdf_path = './data/pdf/' . $bctime . '/';
  4591. $file_base64 = $pdf;
  4592. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4593. $file_base64 = base64_decode($file_base64);
  4594. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4595. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4596. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4597. }
  4598. /**
  4599. *
  4600. *
  4601. *
  4602. 进销存占单异常索引
  4603. *
  4604. *
  4605. *
  4606. **/
  4607. public function _abnormal()
  4608. {
  4609. $post = $this->input->post(NULL, TRUE);
  4610. if (isset($post['page'])) {
  4611. $page = $this->input->post('page', true);
  4612. $perpage = $this->input->post('perpage', true);
  4613. $sku = $this->input->post('sku', true);
  4614. $where = "1=1";
  4615. //数据排序
  4616. $order_str = "id desc";
  4617. if (empty($page)) {
  4618. $start = 0;
  4619. $perpage = 1;
  4620. } else {
  4621. $start = ($page - 1) * $perpage;
  4622. }
  4623. //取得信息列表
  4624. $info_list = $this->whlabel->find_all($where, '*');
  4625. $rows = array();
  4626. $list = array();
  4627. foreach ($info_list as $key => $value) {
  4628. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4629. }
  4630. foreach ($rows as $value) {
  4631. $warehouse = $this->warehouse->read($value['warehouse']);
  4632. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4633. $number = $value['number'];
  4634. $ftime = time() - 15 * 24 * 3600;
  4635. if ($value['shop'] != '') {
  4636. $shop = $value['shop'];
  4637. $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');
  4638. $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');
  4639. $order = array_merge($orderdlz, $ordersmt);
  4640. $od = 0;
  4641. $a = '';
  4642. $orid = '';
  4643. foreach ($order as $v) {
  4644. $or = explode('|', ltrim($v['whlabel'], '|'));
  4645. for ($i = 0; $i < count($or); $i++) {
  4646. $orod = explode('-', $or[$i]);
  4647. if ($orod[0] == $number) {
  4648. $od += $orod[1];
  4649. }
  4650. }
  4651. $orid .= $v['number'] . '-';
  4652. }
  4653. } else {
  4654. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4655. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4656. $order = array_merge($orderdlz, $ordersmt);
  4657. $od = 0;
  4658. $a = '';
  4659. $orid = '';
  4660. $qt = array();
  4661. foreach ($order as $v) {
  4662. $or = explode('|', ltrim($v['whlabel'], '|'));
  4663. for ($i = 0; $i < count($or); $i++) {
  4664. $orod = explode('-', $or[$i]);
  4665. if ($orod[0] == $number) {
  4666. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4667. if ($czzs > 0) {
  4668. if (isset($qt[$v['shop']])) {
  4669. if ($qt[$v['shop']] < $orod[1]) {
  4670. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4671. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4672. } else {
  4673. $qt[$v['shop']] -= $orod[1];
  4674. }
  4675. } else {
  4676. $qt[$v['shop']] = $czzs;
  4677. }
  4678. } else {
  4679. $od += $orod[1];
  4680. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4681. }
  4682. }
  4683. }
  4684. }
  4685. }
  4686. $z = $od . '(' . $orid . ')'; //查看订单号
  4687. //$z = $od;
  4688. if ($od > $c) {
  4689. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4690. }
  4691. }
  4692. $listdata = array_slice($list, $start, $perpage);
  4693. $total = count($list);
  4694. $pagenum = ceil($total / $perpage);
  4695. $over = $total - ($start + $perpage);
  4696. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4697. echo json_encode($rows);
  4698. exit;
  4699. }
  4700. $this->_Template('whlabel_abnormal', $this->data);
  4701. }
  4702. /**
  4703. *
  4704. *
  4705. *
  4706. 进销存占单异常索引
  4707. *
  4708. *
  4709. *
  4710. **/
  4711. public function _error()
  4712. {
  4713. $post = $this->input->post(NULL, TRUE);
  4714. if (isset($post['page'])) {
  4715. $page = $this->input->post('page', true);
  4716. $perpage = $this->input->post('perpage', true);
  4717. $sku = $this->input->post('sku', true);
  4718. $warehouse = $this->input->post('warehouse', true);
  4719. $ktime = $this->input->post('ktime', true);
  4720. $jtime = $this->input->post('jtime', true);
  4721. $ktime = strtotime($ktime);
  4722. $jtime = strtotime($jtime);
  4723. $where = "sku != 'Preset'";
  4724. $gj = '';
  4725. if ($sku) {
  4726. $where .= " and sku like '%$sku%'";
  4727. } else {
  4728. if ($ktime && $jtime) {
  4729. $gj = " and time > '$ktime' and time < '$jtime'";
  4730. }
  4731. }
  4732. if ($warehouse) {
  4733. $where .= " and warehouse = '$warehouse'";
  4734. }
  4735. //数据排序
  4736. $order_str = "id desc";
  4737. if (empty($page)) {
  4738. $start = 0;
  4739. $perpage = 1;
  4740. } else {
  4741. $start = ($page - 1) * $perpage;
  4742. }
  4743. //取得信息列表
  4744. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4745. $rows = array();
  4746. $list = array();
  4747. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4748. // foreach ($info_list as $value)
  4749. // {
  4750. // $warehouse = $this->warehouse->read($value['warehouse']);
  4751. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4752. // $number = $value['number'];$ftime = time()-15*24*3600;
  4753. // if($c < 1)
  4754. // {
  4755. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4756. // }
  4757. // }
  4758. $warehouse_list = $this->warehouse->find_all();
  4759. $warehouse_list = array_column($warehouse_list, null, 'id');
  4760. foreach ($info_list as $value) {
  4761. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4762. 'title' => "",
  4763. ];
  4764. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4765. $number = $value['number'];
  4766. $ftime = time() - 15 * 24 * 3600;
  4767. if ($c < 1) {
  4768. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4769. }
  4770. }
  4771. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4772. // $query = $this->db->query($sql);
  4773. // $info_list = $query->result_array();
  4774. // $sql_two = "select title,id from crowd_warehouse";
  4775. // $query_two = $this->db->query($sql_two);
  4776. // $warehouse_list = $query_two->result_array();
  4777. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4778. // foreach ($info_list as $value)
  4779. // {
  4780. // if(isset($warehouse_arr[$value['warehouse']])){
  4781. // $warehouse = $warehouse_arr[$value['warehouse']];
  4782. // }else{
  4783. // $warehouse = [
  4784. // 'id'=>0,
  4785. // 'title'=>"异常",
  4786. // ];
  4787. // }
  4788. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4789. // $number = $value['number'];$ftime = time()-15*24*3600;
  4790. // if($c < 1)
  4791. // {
  4792. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4793. // }
  4794. // }
  4795. $listdata = array_slice($list, $start, $perpage);
  4796. $total = count($list);
  4797. $pagenum = ceil($total / $perpage);
  4798. $over = $total - ($start + $perpage);
  4799. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4800. echo json_encode($rows);
  4801. exit;
  4802. }
  4803. if (isset($post['s'])) {
  4804. $id_arr = $this->input->post('s');
  4805. $id_arr = explode(',', trim($id_arr, ','));
  4806. if (!$id_arr) {
  4807. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4808. exit;
  4809. }
  4810. //循环删除记录
  4811. foreach ($id_arr as $v) {
  4812. $dd = $this->whlabel->read($v);
  4813. if (!isset($dd['id'])) {
  4814. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4815. exit;
  4816. }
  4817. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4818. if (isset($zt[0])) {
  4819. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4820. exit;
  4821. }
  4822. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4823. foreach ($deldd as $vv) {
  4824. $this->whlabel->remove($vv['id']);
  4825. }
  4826. }
  4827. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4828. exit;
  4829. }
  4830. $this->_Template('whlabel_error', $this->data);
  4831. }
  4832. public function _errorexcel()
  4833. {
  4834. $post = $this->input->post(NULL, TRUE);
  4835. if (isset($_GET['page'])) {
  4836. $page = $this->input->get('page', true);
  4837. $perpage = $this->input->get('perpage', true);
  4838. $sku = $this->input->get('sku', true);
  4839. $warehouse = $this->input->get('warehouse', true);
  4840. $ktime = $this->input->get('ktime', true);
  4841. $jtime = $this->input->get('jtime', true);
  4842. $ktime = strtotime($ktime);
  4843. $jtime = strtotime($jtime);
  4844. $where = "sku != 'Preset'";
  4845. $gj = '';
  4846. if ($sku) {
  4847. $where .= " and sku like '%$sku%'";
  4848. } else {
  4849. if ($ktime && $jtime) {
  4850. $gj = " and time > '$ktime' and time < '$jtime'";
  4851. }
  4852. }
  4853. if ($warehouse) {
  4854. $where .= " and warehouse = '$warehouse'";
  4855. }
  4856. //数据排序
  4857. $order_str = "id desc";
  4858. if (empty($page)) {
  4859. $start = 0;
  4860. $perpage = 1;
  4861. } else {
  4862. $start = ($page - 1) * $perpage;
  4863. }
  4864. //取得信息列表
  4865. $rows = array();
  4866. $list = array();
  4867. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4868. foreach ($info_list as $value) {
  4869. $warehouse = $this->warehouse->read($value['warehouse']);
  4870. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4871. $number = $value['number'];
  4872. $ftime = time() - 15 * 24 * 3600;
  4873. if ($c < 1) {
  4874. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4875. }
  4876. }
  4877. $title = "0库存汇总";
  4878. $titlename = "<table border=1>
  4879. <tr align='center'>
  4880. <td>仓库</td>
  4881. <td>SKU</td>
  4882. <td>产品</td>
  4883. <td>当前库存</td>
  4884. </tr>
  4885. </table>";
  4886. $filename = $title . ".xls";
  4887. $tail = "";
  4888. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4889. }
  4890. }
  4891. /**
  4892. *
  4893. *
  4894. * 占单
  4895. *
  4896. *
  4897. **/
  4898. public function _kcyz()
  4899. {
  4900. $post = $this->input->post(NULL, TRUE);
  4901. if (isset($post['warehouse'])) {
  4902. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4903. exit; //不再使用
  4904. $warehouse = $this->input->post('warehouse', true);
  4905. $whlabel = $this->input->post('whlabel', true);
  4906. $id = $this->input->post('id', true);
  4907. $shop = $this->input->post('shop', true);
  4908. $number = $this->input->post('number', true);
  4909. if (!$whlabel || $whlabel == '|') {
  4910. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4911. exit;
  4912. }
  4913. $pp = explode('|', trim($whlabel, '|'));
  4914. $x = 0;
  4915. $save = array();
  4916. foreach ($pp as $va) {
  4917. $num = explode('-', $va);
  4918. if ($number) {
  4919. $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 = '')"); //通用
  4920. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4921. } else {
  4922. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4923. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4924. }
  4925. $x++;
  4926. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4927. $save[] = $x - 1;
  4928. continue; //提前先加X不然出错,所以要减1
  4929. }
  4930. }
  4931. if (isset($save[0])) {
  4932. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4933. exit;
  4934. } else {
  4935. echo json_encode(array('success' => true));
  4936. exit;
  4937. }
  4938. }
  4939. }
  4940. public function _db()
  4941. {
  4942. $post = $this->input->post(NULL, TRUE);
  4943. if (isset($post['page'])) {
  4944. $page = $this->input->post('page', true);
  4945. $perpage = $this->input->post('perpage', true);
  4946. $sku = $this->input->post('sku', true);
  4947. $number = $this->input->post('number', true);
  4948. $warehouse = $this->input->post('warehouse', true);
  4949. $purchase = $this->input->post('purchase', true);
  4950. $orderinfo = $this->input->post('orderinfo', true);
  4951. $waybill = $this->input->post('waybill', true);
  4952. $category = $this->input->post('category', true);
  4953. $size = $this->input->post('size', true);
  4954. $grade = $this->input->post('grade', true);
  4955. $color = $this->input->post('color', true);
  4956. $lowe = $this->input->post('lowe', true);
  4957. $state = $this->input->post('state', true);
  4958. $label = $this->input->post('label', true);
  4959. $timetk = $this->input->post('timetkk', true);
  4960. $timetj = $this->input->post('timetjj', true);
  4961. $timetk = strtotime($timetk);
  4962. $timetj = strtotime($timetj);
  4963. $where = "dbtime > 0";
  4964. if ($timetk && $timetj) {
  4965. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4966. }
  4967. if ($sku) {
  4968. $where .= " and sku = '$sku'";
  4969. }
  4970. if ($warehouse) {
  4971. $where .= " and warehouse = '$warehouse'";
  4972. if ($warehouse == 12) {
  4973. $w = 'specialstock';
  4974. } else {
  4975. $w = 'whlabel';
  4976. }
  4977. }
  4978. if ($purchase) {
  4979. $where .= " and purchase = '$purchase'";
  4980. }
  4981. if ($category) {
  4982. $where .= " and features like '%-$category-%'";
  4983. }
  4984. if ($size) {
  4985. $where .= " and features like '%-$size-%'";
  4986. }
  4987. if ($grade) {
  4988. $where .= " and features like '%-$grade-%'";
  4989. }
  4990. if ($color) {
  4991. $where .= " and features like '%-$color-%'";
  4992. }
  4993. if ($lowe) {
  4994. $where .= " and features like '%-$lowe-%'";
  4995. }
  4996. if ($state != '') {
  4997. $where .= " and state = '$state'";
  4998. }
  4999. //数据排序
  5000. $order_str = "dbtime desc";
  5001. if (empty($page)) {
  5002. $start = 0;
  5003. $perpage = 1;
  5004. } else {
  5005. $start = ($page - 1) * $perpage;
  5006. }
  5007. //取得信息列表
  5008. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5009. foreach ($info_list as $key => $value) {
  5010. $warehouse = $this->$w->read($value['warehouse']);
  5011. $info_list[$key]['warehouse'] = $warehouse['title'];
  5012. $purchase = $this->purchase->read($value['purchase']);
  5013. $info_list[$key]['purchase'] = $purchase['title'];
  5014. if ($value['enter'] != 0) {
  5015. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5016. } else {
  5017. $info_list[$key]['enter'] = "";
  5018. }
  5019. if ($value['dbtime'] != 0) {
  5020. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5021. } else {
  5022. $info_list[$key]['dbtime'] = "";
  5023. }
  5024. if ($value['state'] == 0) {
  5025. $info_list[$key]['state'] = "在库";
  5026. } else if ($value['state'] == 1) {
  5027. $info_list[$key]['state'] = "出库";
  5028. } else if ($value['state'] == 2) {
  5029. $info_list[$key]['state'] = "退库";
  5030. } else if ($value['state'] == 3) {
  5031. $info_list[$key]['state'] = "调拨中";
  5032. } else if ($value['state'] == 4) {
  5033. $info_list[$key]['state'] = "再加工";
  5034. } else if ($value['state'] == 5) {
  5035. $info_list[$key]['state'] = "维修中";
  5036. } else if ($value['state'] == 6) {
  5037. $info_list[$key]['state'] = "盘亏";
  5038. } else if ($value['state'] == 7) {
  5039. $info_list[$key]['state'] = "更换标签";
  5040. } else if ($value['state'] == 8) {
  5041. $info_list[$key]['state'] = "其它";
  5042. } else if ($value['state'] == 9) {
  5043. $info_list[$key]['state'] = "预设";
  5044. }
  5045. }
  5046. $total = $this->whlabel->find_count($where);
  5047. $pagenum = ceil($total / $perpage);
  5048. $over = $total - ($start + $perpage);
  5049. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5050. echo json_encode($rows);
  5051. exit;
  5052. }
  5053. if (isset($post['outsku'])) {
  5054. $time = time();
  5055. $cz = $this->input->post('cz', true);
  5056. $label = $this->input->post('outsku', true);
  5057. $sl = $this->input->post('sl', true);
  5058. $num = $this->input->post('num', true);
  5059. //$warehouse = $this->input->post('warehouse',true);
  5060. if (!$sl) {
  5061. $sl = 1;
  5062. }
  5063. if (!$warehouse) {
  5064. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5065. exit;
  5066. }
  5067. $dblabel = $this->whlabellabel->get_label($label);
  5068. if ($dblabel) {
  5069. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5070. if (count($data) < 1) {
  5071. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5072. exit;
  5073. }
  5074. if (count($data) < $num) {
  5075. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5076. exit;
  5077. }
  5078. for ($i = 0; $i < $sl; $i++) {
  5079. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5080. }
  5081. echo json_encode(array('success' => true));
  5082. exit;
  5083. } else {
  5084. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5085. exit;
  5086. }
  5087. }
  5088. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5089. $this->_Template('whlabel_db', $this->data);
  5090. }
  5091. public function _dbrk()
  5092. {
  5093. $post = $this->input->post(NULL, TRUE);
  5094. if (isset($post['page'])) {
  5095. $page = $this->input->post('page', true);
  5096. $perpage = $this->input->post('perpage', true);
  5097. $sku = $this->input->post('sku', true);
  5098. $number = $this->input->post('number', true);
  5099. $warehouse = $this->input->post('warehouse', true);
  5100. $purchase = $this->input->post('purchase', true);
  5101. $orderinfo = $this->input->post('orderinfo', true);
  5102. $waybill = $this->input->post('waybill', true);
  5103. $category = $this->input->post('category', true);
  5104. $size = $this->input->post('size', true);
  5105. $grade = $this->input->post('grade', true);
  5106. $color = $this->input->post('color', true);
  5107. $lowe = $this->input->post('lowe', true);
  5108. $state = $this->input->post('state', true);
  5109. $label = $this->input->post('label', true);
  5110. $ctime = $this->input->post('ctime', true);
  5111. $timetk = $this->input->post('timetkk', true);
  5112. $timetj = $this->input->post('timetjj', true);
  5113. $timetk = strtotime($timetk);
  5114. $timetj = strtotime($timetj);
  5115. $where = "dbtime > 0";
  5116. if ($timetk && $timetj) {
  5117. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5118. }
  5119. if ($sku) {
  5120. $where .= " and sku = '$sku'";
  5121. }
  5122. if ($warehouse) {
  5123. $where .= " and warehouse = '$warehouse'";
  5124. }
  5125. if ($purchase) {
  5126. $where .= " and purchase = '$purchase'";
  5127. }
  5128. if ($category) {
  5129. $where .= " and features like '%-$category-%'";
  5130. }
  5131. if ($size) {
  5132. $where .= " and features like '%-$size-%'";
  5133. }
  5134. if ($grade) {
  5135. $where .= " and features like '%-$grade-%'";
  5136. }
  5137. if ($color) {
  5138. $where .= " and features like '%-$color-%'";
  5139. }
  5140. if ($lowe) {
  5141. $where .= " and features like '%-$lowe-%'";
  5142. }
  5143. if ($state != '') {
  5144. $where .= " and state = '$state'";
  5145. }
  5146. //数据排序
  5147. $order_str = "dbtime desc";
  5148. if (empty($page)) {
  5149. $start = 0;
  5150. $perpage = 1;
  5151. } else {
  5152. $start = ($page - 1) * $perpage;
  5153. }
  5154. //取得信息列表
  5155. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5156. foreach ($info_list as $key => $value) {
  5157. $warehouse = $this->warehouse->read($value['warehouse']);
  5158. $info_list[$key]['warehouse'] = $warehouse['title'];
  5159. $purchase = $this->purchase->read($value['purchase']);
  5160. $info_list[$key]['purchase'] = $purchase['title'];
  5161. if ($value['enter'] != 0) {
  5162. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5163. } else {
  5164. $info_list[$key]['enter'] = "";
  5165. }
  5166. if ($value['dbtime'] != 0) {
  5167. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5168. } else {
  5169. $info_list[$key]['dbtime'] = "";
  5170. }
  5171. if ($value['state'] == 0) {
  5172. $info_list[$key]['state'] = "在库";
  5173. } else if ($value['state'] == 1) {
  5174. $info_list[$key]['state'] = "出库";
  5175. } else if ($value['state'] == 2) {
  5176. $info_list[$key]['state'] = "退库";
  5177. } else if ($value['state'] == 3) {
  5178. $info_list[$key]['state'] = "调拨中";
  5179. } else if ($value['state'] == 4) {
  5180. $info_list[$key]['state'] = "再加工";
  5181. } else if ($value['state'] == 5) {
  5182. $info_list[$key]['state'] = "维修中";
  5183. } else if ($value['state'] == 6) {
  5184. $info_list[$key]['state'] = "盘亏";
  5185. } else if ($value['state'] == 7) {
  5186. $info_list[$key]['state'] = "更换标签";
  5187. } else if ($value['state'] == 8) {
  5188. $info_list[$key]['state'] = "其它";
  5189. } else if ($value['state'] == 9) {
  5190. $info_list[$key]['state'] = "预设";
  5191. }
  5192. }
  5193. $total = $this->whlabel->find_count($where);
  5194. $pagenum = ceil($total / $perpage);
  5195. $over = $total - ($start + $perpage);
  5196. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5197. echo json_encode($rows);
  5198. exit;
  5199. }
  5200. if (isset($post['rsku'])) {
  5201. $cz = $this->input->post('cz', true);
  5202. $label = $this->input->post('rsku', true);
  5203. $sl = $this->input->post('sl', true);
  5204. $warehouse = $this->input->post('warehouse', true);
  5205. if (!$sl) {
  5206. $sl = 1;
  5207. }
  5208. if (!$warehouse) {
  5209. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5210. exit;
  5211. }
  5212. $dblabel = $this->whlabellabel->get_label($label);
  5213. if ($dblabel) {
  5214. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5215. if (count($data) < 1) {
  5216. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5217. exit;
  5218. }
  5219. if ($sl > count($data)) {
  5220. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5221. exit;
  5222. }
  5223. $time = time();
  5224. for ($i = 0; $i < $sl; $i++) {
  5225. $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']);
  5226. }
  5227. echo json_encode(array('success' => true));
  5228. exit;
  5229. } else {
  5230. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5231. exit;
  5232. }
  5233. }
  5234. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5235. $this->_Template('whlabel_dbrk', $this->data);
  5236. }
  5237. public function _whlabelczdc()
  5238. {
  5239. if (isset($_GET['excel'])) {
  5240. //数据排序
  5241. $order_str = "id desc";
  5242. if (empty($page)) {
  5243. $start = 0;
  5244. $perpage = 1;
  5245. } else {
  5246. $start = ($page - 1) * $perpage;
  5247. }
  5248. $state = $this->input->get('state', true);
  5249. $sku = $this->input->get('sku', true);
  5250. $ctime = $this->input->get('ctime', true);
  5251. $category = $this->input->get('category', true);
  5252. $size = $this->input->get('size', true);
  5253. $grade = $this->input->get('grade', true);
  5254. $color = $this->input->get('color', true);
  5255. $lowe = $this->input->get('lowe', true);
  5256. $timetk = $this->input->get('timetkk', true);
  5257. $timetj = $this->input->get('timetjj', true);
  5258. $timetk = strtotime($timetk);
  5259. $timetj = strtotime($timetj);
  5260. $where = "dbtime > 0";
  5261. if ($timetk && $timetj) {
  5262. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5263. }
  5264. if ($category) {
  5265. $where .= " and features like '%-$category-%'";
  5266. }
  5267. if ($size) {
  5268. $where .= " and features like '%-$size-%'";
  5269. }
  5270. if ($grade) {
  5271. $where .= " and features like '%-$grade-%'";
  5272. }
  5273. if ($color) {
  5274. $where .= " and features like '%-$color-%'";
  5275. }
  5276. if ($lowe) {
  5277. $where .= " and features like '%-$lowe-%'";
  5278. }
  5279. //取得信息列表
  5280. $info_list = $this->whlabel->find_all($where, '*');
  5281. $rows = array();
  5282. $list = array();
  5283. foreach ($info_list as $key => $value) {
  5284. $rows[$value['sku']] = $value; //所有数据sku
  5285. }
  5286. foreach ($rows as $value) {
  5287. $warehouse = $this->warehouse->read($value['warehouse']);
  5288. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5289. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5290. if ($value['orderinfo'] == 0) {
  5291. $info_list[$key]['orderinfo'] = "";
  5292. }
  5293. if ($value['waybill'] == 0) {
  5294. $info_list[$key]['waybill'] = "";
  5295. }
  5296. if ($value['state'] == 0) {
  5297. $value['state'] = "在库";
  5298. } else if ($value['state'] == 3) {
  5299. $value['state'] = "调拨中";
  5300. }
  5301. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5302. }
  5303. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5304. $titlename = "<table border=1>
  5305. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5306. <tr align='center'>
  5307. <td>SKU</td>
  5308. <td>产品</td>
  5309. <td>调拨数量</td>
  5310. <td>入库数量</td>
  5311. </tr>
  5312. </table>";
  5313. $filename = $title . ".xls";
  5314. $tail = "";
  5315. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5316. }
  5317. }
  5318. public function _print($arg_array)
  5319. {
  5320. if (isset($_SESSION['api'])) {
  5321. $user = $this->user->get_api($_SESSION['api']);
  5322. $usp = $user;
  5323. $fgshop = "";
  5324. $sid = "";
  5325. $wid = "";
  5326. $wtype = "";
  5327. $usersp = explode('|', trim($user['shop'], '|'));
  5328. $userwh = explode('|', trim($user['warehouse'], '|'));
  5329. foreach ($usersp as $value) {
  5330. $fgshop .= " shop = " . $value . " or";
  5331. $sid .= " id = " . $value . " or";
  5332. }
  5333. foreach ($userwh as $value) {
  5334. $wid .= " id = " . $value . " or";
  5335. $wtype .= " type = " . $value . " or";
  5336. }
  5337. }
  5338. $post = $this->input->post(NULL, TRUE);
  5339. if (isset($post['tmsku'])) {
  5340. $tmsku = $this->input->post('tmsku', true);
  5341. if (is_numeric($tmsku)) {
  5342. $yyh = $this->whlabellabel->get_label($tmsku);
  5343. } else {
  5344. $yyh = $this->whlabellabel->get_sku($tmsku);
  5345. }
  5346. if ($yyh) {
  5347. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5348. exit;
  5349. } else {
  5350. echo json_encode(array('success' => false));
  5351. exit;
  5352. }
  5353. }
  5354. $classid = $this->classid->sku();
  5355. $pm = $classid;
  5356. $scsku = $classid;
  5357. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5358. if (isset($post['warehouse'])) {
  5359. if ($post['warehouse']) {
  5360. $list = array();
  5361. $num = "";
  5362. $title = "";
  5363. $features = "";
  5364. $order = 0;
  5365. $post['shop'] = '';
  5366. $brand = $this->input->post('brand', true);
  5367. if ($brand != '0,') {
  5368. $b = $this->brand->read(rtrim($brand, ','));
  5369. if ($b) {
  5370. $post['shop'] = str_replace('|', ',', $b['shop']);
  5371. }
  5372. }
  5373. $post['details'] = $this->input->post('details', true); //打印数量
  5374. $xbqnum = $this->input->post('xbqnum', true);
  5375. $post['purchase'] = $this->input->post('purchase', true);
  5376. $post['warehouse'] = $this->input->post('warehouse', true);
  5377. $post['purchase'] = $this->input->post('purchase', true);
  5378. $post['retreatwarehouse'] = $post['warehouse'];
  5379. $post['cpbz'] = $this->input->post('cpbz', true);
  5380. $post['state'] = 9;
  5381. $category = $this->input->post('category', true);
  5382. $list['category'] = $category;
  5383. $list['hairtype'] = $this->input->post('hairtype', true);
  5384. $list['grade'] = $this->input->post('grade', true);
  5385. $size = $this->input->post('size', true);
  5386. $list['size'] = rtrim($size, ',');
  5387. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5388. $list['extension'] = $this->input->post('extension', true);
  5389. if ($category == 1297) {
  5390. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5391. }
  5392. if ($category == 1702) {
  5393. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5394. $list['syother'] = $this->input->post('syother', true);
  5395. }
  5396. if ($category == 133) {
  5397. $list['fittype'] = $this->input->post('fittype', true);
  5398. $list['acother'] = $this->input->post('acother', true);
  5399. }
  5400. $list['color'] = $this->input->post('color', true);
  5401. $list['lowe'] = $this->input->post('lowe', true);
  5402. if ($category == 127) {
  5403. $list['type'] = $this->input->post('type', true);
  5404. $list['headroad'] = $this->input->post('headroad', true);
  5405. $list['density'] = $this->input->post('density', true);
  5406. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5407. $list['lacesize'] = $this->input->post('lacesize', true);
  5408. }
  5409. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5410. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5411. }
  5412. if ($category == 128) {
  5413. $list['lacetype'] = $this->input->post('lacetype', true);
  5414. $list['haircap'] = $this->input->post('haircap', true);
  5415. $list['density'] = $this->input->post('density', true);
  5416. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5417. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5418. $list['wigother'] = $this->input->post('wigother', true);
  5419. $list['wigother1'] = $this->input->post('wigother1', true);
  5420. $list['wigother2'] = $this->input->post('wigother2', true);
  5421. }
  5422. if ($category == 129) {
  5423. $list['wide'] = $this->input->post('wide', true);
  5424. }
  5425. if ($category == 131) {
  5426. $list['gifttype'] = $this->input->post('gifttype', true);
  5427. $list['giftother'] = $this->input->post('giftother', true);
  5428. }
  5429. if ($category == 134) {
  5430. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5431. }
  5432. if ($category == 1297) {
  5433. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5434. $list['sywigother'] = $this->input->post('sywigother', true);
  5435. }
  5436. if ($category == 130 || $category == 133 || $category == 1702) {
  5437. $list['items'] = $this->input->post('items', true);
  5438. $list['weight'] = $this->input->post('weight', true);
  5439. }
  5440. if ($category == 1702) {
  5441. $list['syhairther'] = $this->input->post('syhairther', true);
  5442. }
  5443. foreach ($list as $k => $v) {
  5444. if ($v != 0) {
  5445. $num .= $v;
  5446. $features .= $v . '-';
  5447. $post[$k] = $v;
  5448. $typeclass = $this->typeclass->read($v);
  5449. if (isset($pm[$typeclass['classid']])) {
  5450. if (stripos($typeclass['zh'], '|') !== false) {
  5451. $exzh = explode('|', $typeclass['zh']);
  5452. $pm[$typeclass['classid']] = $exzh[0];
  5453. } else {
  5454. $pm[$typeclass['classid']] = $typeclass['zh'];
  5455. }
  5456. }
  5457. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5458. if ($k != 'size') {
  5459. $title .= $typeclass['title'] . " ";
  5460. }
  5461. }
  5462. }
  5463. $typeclass = $this->typeclass->read($list['size']);
  5464. $title .= $typeclass['title'];
  5465. $time = time();
  5466. $post['title'] = rtrim($title, ' ');
  5467. $post['number'] = $num;
  5468. $post['features'] = '-' . $features;
  5469. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5470. $featurespp = explode('-', trim($featurespp, '-'));
  5471. if (isset($featurespp[5])) {
  5472. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5473. } else {
  5474. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5475. }
  5476. $post['enter'] = $time;
  5477. $post['time'] = $time; //操作时间
  5478. $scsku = implode("-", $scsku);
  5479. $zh = implode(" ", $pm);
  5480. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5481. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5482. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5483. $post['sku'] = $bqsku;
  5484. $label = time() . rand(0, 9);
  5485. $post['label'] = $label;
  5486. $cpid = $this->whlabellabel->find_count();
  5487. $post['cpid'] = $cpid + 1;
  5488. $cpid = $post['cpid'];
  5489. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5490. //if($whlabelbarcode)
  5491. //{
  5492. //$post['label'] = $whlabelbarcode['label'];
  5493. //if(!$this->whlabellabel->insert($post))
  5494. //{
  5495. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5496. //}
  5497. //}
  5498. //else
  5499. //{
  5500. $this->db->trans_begin();
  5501. $this->whlabellabel->insert($post);
  5502. //$this->whlabelbarcode->insert($post);
  5503. if ($this->db->trans_status() === TRUE) {
  5504. $this->db->trans_commit();
  5505. } else {
  5506. $this->db->trans_rollback();
  5507. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5508. exit;
  5509. }
  5510. //}
  5511. $warehouse_name = "";
  5512. $warehouse = $post['warehouse'];
  5513. if($warehouse == 12){
  5514. $warehouse_name = "特殊库存库";
  5515. }
  5516. // if($warehouse == 13){
  5517. // $warehouse_name = "许昌仓";
  5518. // }
  5519. // if($warehouse == 5){
  5520. // $warehouse_name = "美国店";
  5521. // }
  5522. // if($warehouse == 16){
  5523. // $warehouse_name = "定制头套仓";
  5524. // }
  5525. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5526. if(!empty($warehouse_name)){
  5527. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5528. }
  5529. $purchase = $this->purchase->read($post['purchase']);
  5530. 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));
  5531. exit; //特殊仓目前不需要仓库选项
  5532. }
  5533. }
  5534. if (isset($_SESSION['api'])) {
  5535. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5536. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5537. $this->data['wlshop'] = $wlshop;
  5538. $this->data['warehouse'] = $warehouse;
  5539. }
  5540. $whlabelwz = $this->whlabelwz->find_all();
  5541. $this->data['whlabelwz'] = $whlabelwz;
  5542. $this->_Template('whlabel_print', $this->data);
  5543. }
  5544. public function _usaprint($arg_array)
  5545. {
  5546. if (isset($_SESSION['api'])) {
  5547. $user = $this->user->get_api($_SESSION['api']);
  5548. $usp = $user;
  5549. $fgshop = "";
  5550. $sid = "";
  5551. $wid = "";
  5552. $wtype = "";
  5553. $usersp = explode('|', trim($user['shop'], '|'));
  5554. $userwh = explode('|', trim($user['warehouse'], '|'));
  5555. foreach ($usersp as $value) {
  5556. $fgshop .= " shop = " . $value . " or";
  5557. $sid .= " id = " . $value . " or";
  5558. }
  5559. foreach ($userwh as $value) {
  5560. $wid .= " id = " . $value . " or";
  5561. $wtype .= " type = " . $value . " or";
  5562. }
  5563. }
  5564. $post = $this->input->post(NULL, TRUE);
  5565. if (isset($post['tmsku'])) {
  5566. $tmsku = $this->input->post('tmsku', true);
  5567. if (is_numeric($tmsku)) {
  5568. $yyh = $this->whlabellabel->get_label($tmsku);
  5569. } else {
  5570. $yyh = $this->whlabellabel->get_sku($tmsku);
  5571. }
  5572. if ($yyh) {
  5573. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5574. exit;
  5575. } else {
  5576. echo json_encode(array('success' => false));
  5577. exit;
  5578. }
  5579. }
  5580. $classid = $this->classid->sku();
  5581. $pm = $classid;
  5582. $scsku = $classid;
  5583. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5584. if (isset($post['warehouse'])) {
  5585. if ($post['warehouse']) {
  5586. $list = array();
  5587. $num = "";
  5588. $title = "";
  5589. $features = "";
  5590. $order = 0;
  5591. $post['shop'] = '';
  5592. $brand = $this->input->post('brand', true);
  5593. if ($brand != '0,') {
  5594. $b = $this->brand->read(rtrim($brand, ','));
  5595. if ($b) {
  5596. $post['shop'] = str_replace('|', ',', $b['shop']);
  5597. }
  5598. }
  5599. $post['details'] = $this->input->post('details', true); //打印数量
  5600. $xbqnum = $this->input->post('xbqnum', true);
  5601. $post['purchase'] = $this->input->post('purchase', true);
  5602. $post['warehouse'] = $this->input->post('warehouse', true);
  5603. $post['purchase'] = $this->input->post('purchase', true);
  5604. $post['retreatwarehouse'] = $post['warehouse'];
  5605. $post['cpbz'] = $this->input->post('cpbz', true);
  5606. $post['state'] = 9;
  5607. $category = $this->input->post('category', true);
  5608. $list['category'] = $category;
  5609. $list['hairtype'] = $this->input->post('hairtype', true);
  5610. $list['grade'] = $this->input->post('grade', true);
  5611. $size = $this->input->post('size', true);
  5612. $list['size'] = rtrim($size, ',');
  5613. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5614. $list['extension'] = $this->input->post('extension', true);
  5615. if ($category == 1297) {
  5616. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5617. }
  5618. if ($category == 1702) {
  5619. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5620. $list['syother'] = $this->input->post('syother', true);
  5621. }
  5622. if ($category == 133) {
  5623. $list['fittype'] = $this->input->post('fittype', true);
  5624. $list['acother'] = $this->input->post('acother', true);
  5625. }
  5626. $list['color'] = $this->input->post('color', true);
  5627. $list['lowe'] = $this->input->post('lowe', true);
  5628. if ($category == 127) {
  5629. $list['type'] = $this->input->post('type', true);
  5630. $list['headroad'] = $this->input->post('headroad', true);
  5631. $list['density'] = $this->input->post('density', true);
  5632. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5633. $list['lacesize'] = $this->input->post('lacesize', true);
  5634. }
  5635. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5636. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5637. }
  5638. if ($category == 128) {
  5639. $list['lacetype'] = $this->input->post('lacetype', true);
  5640. $list['haircap'] = $this->input->post('haircap', true);
  5641. $list['density'] = $this->input->post('density', true);
  5642. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5643. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5644. $list['wigother'] = $this->input->post('wigother', true);
  5645. $list['wigother1'] = $this->input->post('wigother1', true);
  5646. $list['wigother2'] = $this->input->post('wigother2', true);
  5647. }
  5648. if ($category == 129) {
  5649. $list['wide'] = $this->input->post('wide', true);
  5650. }
  5651. if ($category == 131) {
  5652. $list['gifttype'] = $this->input->post('gifttype', true);
  5653. $list['giftother'] = $this->input->post('giftother', true);
  5654. }
  5655. if ($category == 134) {
  5656. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5657. }
  5658. if ($category == 1297) {
  5659. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5660. $list['sywigother'] = $this->input->post('sywigother', true);
  5661. }
  5662. if ($category == 130 || $category == 133 || $category == 1702) {
  5663. $list['items'] = $this->input->post('items', true);
  5664. $list['weight'] = $this->input->post('weight', true);
  5665. }
  5666. if ($category == 1702) {
  5667. $list['syhairther'] = $this->input->post('syhairther', true);
  5668. }
  5669. foreach ($list as $k => $v) {
  5670. if ($v != 0) {
  5671. $num .= $v;
  5672. $features .= $v . '-';
  5673. $post[$k] = $v;
  5674. $typeclass = $this->typeclass->read($v);
  5675. if (isset($pm[$typeclass['classid']])) {
  5676. if (stripos($typeclass['zh'], '|') !== false) {
  5677. $exzh = explode('|', $typeclass['zh']);
  5678. $pm[$typeclass['classid']] = $exzh[0];
  5679. } else {
  5680. $pm[$typeclass['classid']] = $typeclass['zh'];
  5681. }
  5682. }
  5683. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5684. if ($k != 'size') {
  5685. $title .= $typeclass['title'] . " ";
  5686. }
  5687. }
  5688. }
  5689. $typeclass = $this->typeclass->read($list['size']);
  5690. $title .= $typeclass['title'];
  5691. $time = time();
  5692. $post['title'] = rtrim($title, ' ');
  5693. $post['number'] = $num;
  5694. $post['features'] = '-' . $features;
  5695. $fp = $this->whlabel->get_features($post['features']);
  5696. if (!$fp) {
  5697. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5698. exit;
  5699. }
  5700. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5701. $featurespp = explode('-', trim($featurespp, '-'));
  5702. if (isset($featurespp[5])) {
  5703. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5704. } else {
  5705. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5706. }
  5707. $post['enter'] = $time;
  5708. $post['time'] = $time; //操作时间
  5709. $scsku = implode("-", $scsku);
  5710. $zh = implode(" ", $pm);
  5711. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5712. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5713. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5714. $post['sku'] = $fp['sku'];
  5715. $post['label'] = $fp['sku'];
  5716. $cpid = $this->whlabellabel->find_count();
  5717. $post['cpid'] = $cpid + 1;
  5718. $cpid = $post['cpid'];
  5719. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5720. //if($whlabelbarcode)
  5721. //{
  5722. //$post['label'] = $whlabelbarcode['label'];
  5723. //if(!$this->whlabellabel->insert($post))
  5724. //{
  5725. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5726. //}
  5727. //}
  5728. //else
  5729. //{
  5730. $this->db->trans_begin();
  5731. $this->whlabellabel->insert($post);
  5732. //$this->whlabelbarcode->insert($post);
  5733. if ($this->db->trans_status() === TRUE) {
  5734. $this->db->trans_commit();
  5735. } else {
  5736. $this->db->trans_rollback();
  5737. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5738. exit;
  5739. }
  5740. //}
  5741. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5742. $purchase = $this->purchase->read($post['purchase']);
  5743. 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));
  5744. exit; //特殊仓目前不需要仓库选项
  5745. }
  5746. }
  5747. if (isset($_SESSION['api'])) {
  5748. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5749. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5750. $this->data['wlshop'] = $wlshop;
  5751. $this->data['warehouse'] = $warehouse;
  5752. }
  5753. $whlabelwz = $this->whlabelwz->find_all();
  5754. $this->data['whlabelwz'] = $whlabelwz;
  5755. $this->_Template('whlabel_usaprint', $this->data);
  5756. }
  5757. public function _printrk($arg_array)
  5758. {
  5759. $prc = array();
  5760. $purchase = $this->purchase->find_all();
  5761. foreach ($purchase as $k => $v) {
  5762. $prc[$v['id']] = $v['title'];
  5763. }
  5764. $post = $this->input->post(NULL, TRUE);
  5765. if (isset($post['page'])) {
  5766. $page = $this->input->post('page', true);
  5767. $perpage = $this->input->post('perpage', true);
  5768. $sku = $this->input->post('sku', true);
  5769. $bs = $this->input->post('bs', true);
  5770. $number = $this->input->post('number', true);
  5771. $warehouse = $this->input->post('warehouse', true);
  5772. $purchase = $this->input->post('purchase', true);
  5773. $orderinfo = $this->input->post('orderinfo', true);
  5774. $waybill = $this->input->post('waybill', true);
  5775. $category = $this->input->post('category', true);
  5776. $size = $this->input->post('size', true);
  5777. $grade = $this->input->post('grade', true);
  5778. $color = $this->input->post('color', true);
  5779. $lowe = $this->input->post('lowe', true);
  5780. $state = $this->input->post('state', true);
  5781. $label = $this->input->post('label', true);
  5782. $timetk = $this->input->post('ktime', true);
  5783. $timetj = $this->input->post('jtime', true);
  5784. $timetk = strtotime($timetk);
  5785. $timetj = strtotime($timetj);
  5786. $where = "1=1 ";
  5787. if ($timetk && $timetj) {
  5788. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5789. }
  5790. if ($sku) {
  5791. $where .= " and sku = '$sku'";
  5792. }
  5793. if ($bs != '') {
  5794. $where .= " and bs = '$bs'";
  5795. }
  5796. if ($number) {
  5797. $where .= " and number = '$number'";
  5798. }
  5799. if ($warehouse) {
  5800. $where .= " and warehouse = '$warehouse'";
  5801. }
  5802. if ($purchase) {
  5803. $where .= " and purchase = '$purchase'";
  5804. }
  5805. if ($orderinfo) {
  5806. $where .= " and orderinfo = '$orderinfo'";
  5807. }
  5808. if ($waybill) {
  5809. $where .= " and waybill = '$waybill'";
  5810. }
  5811. if ($category) {
  5812. $where .= " and features like '%-$category-%'";
  5813. }
  5814. if ($size) {
  5815. $where .= " and features like '%-$size-%'";
  5816. }
  5817. if ($grade) {
  5818. $where .= " and features like '%-$grade-%'";
  5819. }
  5820. if ($color) {
  5821. $where .= " and features like '%-$color-%'";
  5822. }
  5823. if ($lowe) {
  5824. $where .= " and features like '%-$lowe-%'";
  5825. }
  5826. if ($label) {
  5827. $where .= " and label = '$label'";
  5828. }
  5829. if ($state || $state == 0) {
  5830. $where .= " and state = '$state'";
  5831. }
  5832. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5833. //数据排序
  5834. $order_str = "enter desc";
  5835. if (empty($page)) {
  5836. $start = 0;
  5837. $perpage = 1;
  5838. } else {
  5839. $start = ($page - 1) * $perpage;
  5840. }
  5841. //取得信息列表
  5842. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5843. foreach ($info_list as $key => $value) {
  5844. $warehouse = $this->warehouse->read($value['warehouse']);
  5845. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5846. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5847. if ($value['state'] == 0) {
  5848. $info_list[$key]['state'] = "在库";
  5849. } else if ($value['state'] == 1) {
  5850. $info_list[$key]['state'] = "出库";
  5851. } else if ($value['state'] == 2) {
  5852. $info_list[$key]['state'] = "退库";
  5853. } else if ($value['state'] == 3) {
  5854. $info_list[$key]['state'] = "调拨中";
  5855. } else if ($value['state'] == 4) {
  5856. $info_list[$key]['state'] = "再加工";
  5857. } else if ($value['state'] == 5) {
  5858. $info_list[$key]['state'] = "维修中";
  5859. } else if ($value['state'] == 6) {
  5860. $info_list[$key]['state'] = "盘亏";
  5861. } else if ($value['state'] == 7) {
  5862. $info_list[$key]['state'] = "更换标签";
  5863. } else if ($value['state'] == 8) {
  5864. $info_list[$key]['state'] = "其它";
  5865. } else if ($value['state'] == 9) {
  5866. $info_list[$key]['state'] = "预设";
  5867. } else if ($value['state'] == 10) {
  5868. $info_list[$key]['state'] = "美店零售";
  5869. }
  5870. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5871. }
  5872. $total = $this->$ck->find_count($where);
  5873. $pagenum = ceil($total / $perpage);
  5874. $over = $total - ($start + $perpage);
  5875. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5876. echo json_encode($rows);
  5877. exit;
  5878. }
  5879. if (isset($post['tmsku'])) {
  5880. $time = time();
  5881. $tmsku = $this->input->post('tmsku', true);
  5882. //$post['shop'] = $this->input->post('shop',true);
  5883. $num = $this->input->post('num', true);
  5884. $rktype = $this->input->post('rktype', true);
  5885. if ($num > 200) {
  5886. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5887. exit;
  5888. }
  5889. if (!$rktype) {
  5890. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5891. }
  5892. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5893. /**
  5894. $wz = array();
  5895. foreach ($rk as $key=>$value)
  5896. {
  5897. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5898. }
  5899. if(count($wz) > 1)
  5900. {
  5901. $wz = array_values($wz);
  5902. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5903. }
  5904. **/
  5905. if (isset($rk[0]['purchase'])) {
  5906. $rk = $rk[0];
  5907. $j = 0;
  5908. $post['purchase'] = $rk['purchase'];
  5909. $post['warehouse'] = $rk['warehouse'];
  5910. $post['retreatwarehouse'] = $rk['warehouse'];
  5911. $post['sku'] = $rk['sku'];
  5912. $post['number'] = $rk['number'];
  5913. $post['features'] = $rk['features'];
  5914. $post['title'] = $rk['title'];
  5915. $post['enter'] = $time;
  5916. $post['time'] = $time;
  5917. $post['bs'] = 1;
  5918. $post['shop'] = $rk['shop'];
  5919. $post['details'] = $rk['details'];
  5920. $post['cpid'] = $rk['cpid'];
  5921. $post['cpbz'] = $rk['cpbz'];
  5922. //$post['rktype'] = $rktype;
  5923. $warehouse = $this->warehouse->read($rk['warehouse']);
  5924. if ($warehouse['bdck'] == '') {
  5925. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5926. exit;
  5927. } else {
  5928. $bdck = $warehouse['bdck'];
  5929. }
  5930. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5931. if (isset($pdwz['details'])) {
  5932. if ($pdwz['details'] != $post['details']) {
  5933. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5934. exit;
  5935. }
  5936. }
  5937. $post['featurespp'] = $rk['featurespp'];
  5938. if ($post['warehouse'] == '5') {
  5939. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5940. if ($yza) {
  5941. if ($post['features'] != $yza[0]['features']) {
  5942. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5943. exit;
  5944. }
  5945. }
  5946. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5947. if ($yzb) {
  5948. if ($post['sku'] != $yzb[0]['sku']) {
  5949. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5950. exit;
  5951. }
  5952. }
  5953. }
  5954. for ($i = 0; $i < $num; $i++) {
  5955. $post['label'] = time() . rand(100, 999) . $i;
  5956. if ($this->$bdck->insert($post)) {
  5957. $j++;
  5958. }
  5959. }
  5960. /**
  5961. if($post['warehouse'] != 12)
  5962. {
  5963. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5964. }
  5965. **/
  5966. if ($j == $num) {
  5967. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5968. exit;
  5969. } else {
  5970. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5971. exit;
  5972. }
  5973. } else {
  5974. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5975. exit;
  5976. }
  5977. }
  5978. $this->_Template('whlabel_printrk', $this->data);
  5979. }
  5980. public function _printxzrk($arg_array)
  5981. {
  5982. $post = $this->input->post(NULL, TRUE);
  5983. if (isset($post['wzid'])) {
  5984. $time = time();
  5985. $id = $this->input->post('wzid', true);
  5986. //$post['shop'] = $this->input->post('shop',true);
  5987. $num = 1;
  5988. $rk = $this->whlabellabel->read($id);
  5989. if (isset($rk['purchase'])) {
  5990. $x = 0;
  5991. $post['purchase'] = $rk['purchase'];
  5992. $post['warehouse'] = $rk['warehouse'];
  5993. $post['retreatwarehouse'] = $rk['warehouse'];
  5994. $post['sku'] = $rk['sku'];
  5995. $post['number'] = $rk['number'];
  5996. $post['features'] = $rk['features'];
  5997. $post['title'] = $rk['title'];
  5998. $post['enter'] = $time;
  5999. $post['time'] = $time;
  6000. $post['bs'] = 1;
  6001. $post['shop'] = $rk['shop'];
  6002. $post['details'] = $rk['details'];
  6003. $post['cpid'] = $rk['cpid'];
  6004. $post['cpbz'] = $rk['cpbz'];
  6005. $warehouse = $this->warehouse->read($rk['warehouse']);
  6006. if ($warehouse['bdck'] == '') {
  6007. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6008. exit;
  6009. } else {
  6010. $bdck = $warehouse['bdck'];
  6011. }
  6012. $post['featurespp'] = $rk['featurespp'];
  6013. $this->db->trans_begin();
  6014. for ($i = 0; $i < $num; $i++) {
  6015. $post['label'] = time() . rand(100, 999) . $i;
  6016. $this->$bdck->insert($post);
  6017. }
  6018. /**
  6019. if($post['warehouse'] != 12)
  6020. {
  6021. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6022. }
  6023. **/
  6024. if ($this->db->trans_status() === TRUE) {
  6025. $this->db->trans_commit();
  6026. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6027. exit;
  6028. } else {
  6029. $this->db->trans_rollback();
  6030. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6031. exit;
  6032. }
  6033. } else {
  6034. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6035. exit;
  6036. }
  6037. }
  6038. }
  6039. public function _printck($arg_array)
  6040. {
  6041. $prc = array();
  6042. $purchase = $this->purchase->find_all();
  6043. foreach ($purchase as $k => $v) {
  6044. $prc[$v['id']] = $v['title'];
  6045. }
  6046. $post = $this->input->post(NULL, TRUE);
  6047. if (isset($post['page'])) {
  6048. $page = $this->input->post('page', true);
  6049. $perpage = $this->input->post('perpage', true);
  6050. $sku = $this->input->post('sku', true);
  6051. $bs = $this->input->post('bs', true);
  6052. $number = $this->input->post('number', true);
  6053. $warehouse = $this->input->post('warehouse', true);
  6054. $purchase = $this->input->post('purchase', true);
  6055. $orderinfo = $this->input->post('orderinfo', true);
  6056. $waybill = $this->input->post('waybill', true);
  6057. $category = $this->input->post('category', true);
  6058. $size = $this->input->post('size', true);
  6059. $grade = $this->input->post('grade', true);
  6060. $color = $this->input->post('color', true);
  6061. $lowe = $this->input->post('lowe', true);
  6062. $state = $this->input->post('state', true);
  6063. $label = $this->input->post('label', true);
  6064. $timetk = $this->input->post('ktime', true);
  6065. $timetj = $this->input->post('jtime', true);
  6066. $timetk = strtotime($timetk);
  6067. $timetj = strtotime($timetj);
  6068. $where = "state=1 ";
  6069. if ($timetk && $timetj) {
  6070. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6071. }
  6072. if ($sku) {
  6073. $where .= " and sku = '$sku'";
  6074. }
  6075. if ($bs != '') {
  6076. $where .= " and bs = '$bs'";
  6077. }
  6078. if ($number) {
  6079. $where .= " and number = '$number'";
  6080. }
  6081. if ($warehouse) {
  6082. $where .= " and warehouse = '$warehouse'";
  6083. }
  6084. if ($purchase) {
  6085. $where .= " and purchase = '$purchase'";
  6086. }
  6087. if ($orderinfo) {
  6088. $where .= " and orderinfo = '$orderinfo'";
  6089. }
  6090. if ($waybill) {
  6091. $where .= " and waybill = '$waybill'";
  6092. }
  6093. if ($category) {
  6094. $where .= " and features like '%-$category-%'";
  6095. }
  6096. if ($size) {
  6097. $where .= " and features like '%-$size-%'";
  6098. }
  6099. if ($grade) {
  6100. $where .= " and features like '%-$grade-%'";
  6101. }
  6102. if ($color) {
  6103. $where .= " and features like '%-$color-%'";
  6104. }
  6105. if ($lowe) {
  6106. $where .= " and features like '%-$lowe-%'";
  6107. }
  6108. if ($label) {
  6109. $where .= " and label = '$label'";
  6110. }
  6111. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6112. //数据排序
  6113. $order_str = "outk desc";
  6114. if (empty($page)) {
  6115. $start = 0;
  6116. $perpage = 1;
  6117. } else {
  6118. $start = ($page - 1) * $perpage;
  6119. }
  6120. //取得信息列表
  6121. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6122. foreach ($info_list as $key => $value) {
  6123. $warehouse = $this->warehouse->read($value['warehouse']);
  6124. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6125. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6126. if ($value['state'] == 0) {
  6127. $info_list[$key]['state'] = "在库";
  6128. } else if ($value['state'] == 1) {
  6129. $info_list[$key]['state'] = "出库";
  6130. } else if ($value['state'] == 2) {
  6131. $info_list[$key]['state'] = "退库";
  6132. } else if ($value['state'] == 3) {
  6133. $info_list[$key]['state'] = "调拨中";
  6134. } else if ($value['state'] == 4) {
  6135. $info_list[$key]['state'] = "再加工";
  6136. } else if ($value['state'] == 5) {
  6137. $info_list[$key]['state'] = "维修中";
  6138. } else if ($value['state'] == 6) {
  6139. $info_list[$key]['state'] = "盘亏";
  6140. } else if ($value['state'] == 7) {
  6141. $info_list[$key]['state'] = "更换标签";
  6142. } else if ($value['state'] == 8) {
  6143. $info_list[$key]['state'] = "其它";
  6144. } else if ($value['state'] == 9) {
  6145. $info_list[$key]['state'] = "预设";
  6146. } else if ($value['state'] == 10) {
  6147. $info_list[$key]['state'] = "美店零售";
  6148. }
  6149. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6150. }
  6151. $total = $this->$ck->find_count($where);
  6152. $pagenum = ceil($total / $perpage);
  6153. $over = $total - ($start + $perpage);
  6154. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6155. echo json_encode($rows);
  6156. exit;
  6157. }
  6158. if (isset($post['tmsku'])) {
  6159. $time = time();
  6160. $tmsku = $this->input->post('tmsku', true);
  6161. //$post['shop'] = $this->input->post('shop',true);
  6162. $num = $this->input->post('num', true);
  6163. $cktype = $this->input->post('cktype', true);
  6164. $label = $this->whlabellabel->get_label($tmsku);
  6165. if (!$cktype) {
  6166. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6167. }
  6168. if (!isset($label['warehouse'])) {
  6169. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6170. exit;
  6171. }
  6172. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6173. if (stripos($label['features'], '-126-') !== false) {
  6174. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6175. } else {
  6176. $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 = ''");
  6177. }
  6178. $j = 0;
  6179. if (count($ck) >= $num) {
  6180. for ($i = 0; $i < $num; $i++) {
  6181. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6182. {
  6183. $j++;
  6184. }
  6185. }
  6186. if ($j == $num) {
  6187. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6188. exit;
  6189. } else {
  6190. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6191. exit;
  6192. }
  6193. } else {
  6194. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6195. exit;
  6196. }
  6197. }
  6198. if(isset($_SESSION['api']))
  6199. {
  6200. $user = $this->user->get_api($_SESSION['api']);
  6201. if(in_array($user['power'],[1,27])){
  6202. $vip = 1;
  6203. }
  6204. }
  6205. else
  6206. {
  6207. $vip = 0;
  6208. header('Location: /');exit;
  6209. }
  6210. $this->data['vip'] = $vip;
  6211. $this->_Template('whlabel_printck', $this->data);
  6212. }
  6213. public function _printexcel()
  6214. {
  6215. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6216. $config['upload_path'] = '.' . $dir;
  6217. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6218. $config['allowed_types'] = 'xls|xlsx|csv';
  6219. $config['max_size'] = 10240;
  6220. $this->load->library('upload', $config);
  6221. $this->upload->initialize($config);
  6222. if ($this->upload->do_upload('userfile')) {
  6223. $full_path = $dir . $this->upload->data('file_name');
  6224. $fileName = '.' . $full_path;
  6225. if (!file_exists($fileName)) {
  6226. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6227. exit;
  6228. } else {
  6229. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6230. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6231. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6232. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6233. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6234. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6235. ++$column; //如果列数大于26行
  6236. $list = array();
  6237. for ($i = 2; $i <= $row; $i++) // 行数循环
  6238. {
  6239. $data = array();
  6240. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6241. {
  6242. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6243. }
  6244. $list[] = $data;
  6245. }
  6246. }
  6247. $ed = array();
  6248. $i = 0;
  6249. $j = 0;
  6250. $dcdata = array();
  6251. $yc = '';
  6252. $cmf_arr = array_column($list, '1');
  6253. array_multisort($cmf_arr, SORT_ASC, $list);
  6254. foreach ($list as $key => $value) {
  6255. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6256. if ($typeclass) {
  6257. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6258. } else {
  6259. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6260. $i++;
  6261. continue;
  6262. }
  6263. }
  6264. if ($i > 0) {
  6265. $yc = $i . '条异常';
  6266. }
  6267. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6268. exit;
  6269. }
  6270. }
  6271. public function _uck()
  6272. {
  6273. if (isset($_GET['excel'])) {
  6274. $tc = array();
  6275. $typeclass = $this->typeclass->find_all();
  6276. foreach ($typeclass as $v) {
  6277. $tc[$v['id']] = $v['zh'];
  6278. }
  6279. $data = array();
  6280. $t = array();
  6281. $rq = '';
  6282. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6283. $ts = $ts / (24 * 3600);
  6284. for ($i = 0; $i < $ts; $i++) {
  6285. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6286. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6287. }
  6288. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6289. foreach ($info_list as $k => $v) {
  6290. $features = explode('-', trim($v['features'], '-'));
  6291. if (!isset($features[3]) || !isset($features[4])) {
  6292. continue;
  6293. }
  6294. $data[$k][0] = $tc[$features[0]]; //类型
  6295. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6296. $data[$k][2] = $tc[$features[4]]; //曲度
  6297. $data[$k][3] = '';
  6298. if (isset($data[$k][1])) {
  6299. $data[$k][3] .= $data[$k][1];
  6300. }
  6301. if (isset($data[$k][2])) {
  6302. $data[$k][3] .= $data[$k][2];
  6303. }
  6304. if (isset($features[5])) {
  6305. $data[$k][3] .= $tc[$features[5]];
  6306. }
  6307. if (isset($features[2])) {
  6308. $data[$k][3] .= $tc[$features[2]];
  6309. }
  6310. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6311. $data[$k][4] = $v['sku'];
  6312. $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())) . '))'); //月初库存
  6313. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6314. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6315. $ztrq = '';
  6316. $ztsl = '';
  6317. if (count($zt) > 0) {
  6318. foreach ($zt as $vv) {
  6319. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6320. $ztsl .= $vv['num'] . '<br>';
  6321. }
  6322. }
  6323. $data[$k][] = trim($ztsl, '<br>');
  6324. $data[$k][] = trim($ztrq, '<br>');
  6325. $byck = 0;
  6326. foreach ($t as $vv) {
  6327. $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));
  6328. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6329. $byck += $sl;
  6330. }
  6331. $data[$k][] = ($byck > 0) ? $byck : '';
  6332. }
  6333. $title = "详情 " . date("Y-m-d", time());
  6334. $titlename = "<table border=1>
  6335. <tr align='center'>
  6336. <td>类别</td>
  6337. <td>颜色</td>
  6338. <td>曲度</td>
  6339. <td>名称</td>
  6340. <td>SKU</td>
  6341. <td>月初库存</td>
  6342. <td>剩余库存</td>
  6343. <td>在途数量</td>
  6344. <td>预达日期</td>" .
  6345. $rq
  6346. . "<td>本月出库</td></tr>
  6347. </table>";
  6348. $filename = $title . ".xls";
  6349. $tail = "";
  6350. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6351. }
  6352. }
  6353. public function _whlabelexcelzh()
  6354. {
  6355. if (isset($_GET['excel'])) {
  6356. $where = "sku != 'Preset'";
  6357. //数据排序
  6358. $order_str = "id desc";
  6359. if (empty($page)) {
  6360. $start = 0;
  6361. $perpage = 1;
  6362. } else {
  6363. $start = ($page - 1) * $perpage;
  6364. }
  6365. $category = $this->input->get('category', true);
  6366. $warehouse = $this->input->get('warehouse', true);
  6367. $excelid = $this->input->get('sid', true);
  6368. if ($category) {
  6369. $where .= " and features like '%-$category-%'";
  6370. }
  6371. if ($warehouse) {
  6372. $where .= " and warehouse = '$warehouse'";
  6373. }
  6374. $xzid = '';
  6375. if ($excelid) {
  6376. $excelid = explode(',', trim($excelid, ','));
  6377. foreach ($excelid as $key => $value) {
  6378. $xzid .= " id = " . $value . " or";
  6379. }
  6380. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6381. }
  6382. //取得信息列表
  6383. /**
  6384. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6385. $rows = array();$list = array();
  6386. foreach ($info_list as $key=>$value)
  6387. {
  6388. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6389. }
  6390. **/
  6391. $list = array();
  6392. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6393. foreach ($rows as $key => $value) {
  6394. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6395. $zh = '';
  6396. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6397. foreach ($zt as $v) {
  6398. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6399. }
  6400. $zt = array_sum(array_column($zt, 'num'));
  6401. $number = $value['number'];
  6402. $ftime = time() - 15 * 24 * 3600;
  6403. $warehouse = $this->warehouse->read($value['warehouse']);
  6404. $rows[$key]['warehouse'] = $warehouse['title'];
  6405. $rows[$key]['number'] = $c;
  6406. $rows[$key]['features'] = $zh;
  6407. $rows[$key]['hb'] = $c + $zt;
  6408. }
  6409. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6410. $titlename = "<table border=1>
  6411. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6412. <tr align='center'>
  6413. <td>仓库</td>
  6414. <td>SKU</td>
  6415. <td>产品</td>
  6416. <td>库存数量</td>
  6417. <td>在途数量及预达日期</td>
  6418. <td>在途+库存数量</td>
  6419. </tr>
  6420. </table>";
  6421. $filename = $title . ".xls";
  6422. $tail = "";
  6423. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6424. }
  6425. if (isset($_GET['excel'])) {
  6426. $warehouse = $this->input->get('warehouse', true);
  6427. $sku = $this->input->get('sku', true);
  6428. $cz = $this->input->get('cz', true);
  6429. $text = $this->input->post('text', true);
  6430. $xztime = $this->input->get('xztime', true);
  6431. $timetk = $this->input->get('timetk', true);
  6432. $timetj = $this->input->get('timetj', true);
  6433. $timetk = strtotime($timetk);
  6434. $timetj = strtotime($timetj);
  6435. $where = "time = '0' ";
  6436. if ($warehouse) {
  6437. $where .= " and warehouse = '$warehouse'";
  6438. }
  6439. if ($sku) {
  6440. $where .= " and sku = '$sku'";
  6441. }
  6442. if ($text) {
  6443. $where .= " and text like '%$text%'";
  6444. }
  6445. if ($cz != '') {
  6446. $where .= " and cz = '$cz'";
  6447. }
  6448. if ($timetk && $timetj) {
  6449. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6450. }
  6451. //数据排序
  6452. $order_str = $xztime . " desc";
  6453. //取得信息列表
  6454. $zh = array();
  6455. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6456. foreach ($info_list as $v) {
  6457. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6458. $warehouse = $this->warehouse->read($v['warehouse']);
  6459. $v['warehouse'] = $warehouse['title'];
  6460. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6461. $v['stime'] = date('Y-m-d', $v['stime']);
  6462. if (isset($zh[$v['features']])) {
  6463. $zh[$v['features']]['num'] += $v['num'];
  6464. } else {
  6465. $zh[$v['features']] = $v;
  6466. }
  6467. $zh[$v['features']]['features'] = $c;
  6468. }
  6469. $title = "在途数据" . date('Y-m-d', time());
  6470. $titlename = "<table border=1>
  6471. <tr align='center'>
  6472. <td>仓库</td>
  6473. <td>SKU</td>
  6474. <td>名称</td>
  6475. <td>在途数量</td>
  6476. <td>库存数量</td>
  6477. <td>添加在途日期</td>
  6478. <td>预达日期</td>
  6479. <td>备注</td>
  6480. </tr>
  6481. </table>";
  6482. $filename = $title . ".xls";
  6483. $tail = "";
  6484. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6485. }
  6486. }
  6487. public function _fc()
  6488. {
  6489. $vip = 0;
  6490. if (isset($_SESSION['api'])) {
  6491. $user = $this->user->get_api($_SESSION['api']);
  6492. if ($user['vip'] == 1) {
  6493. $vip = 1;
  6494. }
  6495. } else {
  6496. header('Location: /');
  6497. exit;
  6498. }
  6499. $post = $this->input->post(NULL, TRUE);
  6500. if (isset($post['page'])) {
  6501. $page = $this->input->post('page', true);
  6502. $perpage = $this->input->post('perpage', true);
  6503. $category = $this->input->post('category', true);
  6504. $size = $this->input->post('size', true);
  6505. $grade = $this->input->post('grade', true);
  6506. $color = $this->input->post('color', true);
  6507. $lowe = $this->input->post('lowe', true);
  6508. $sku = $this->input->post('sku');
  6509. $title = $this->input->post('title');
  6510. $warehouse = $this->input->post('warehouse', true);
  6511. $usa = $this->input->post('usa', true);
  6512. $purchase = $this->input->post('purchase', true);
  6513. $lacetype = $this->input->post('lacetype', true);
  6514. $haircap = $this->input->post('haircap', true);
  6515. $density = $this->input->post('density', true);
  6516. $details = $this->input->post('details', true);
  6517. $state = $this->input->post('state', true);
  6518. $ktime = $this->input->post('ktime', true);
  6519. $jtime = $this->input->post('jtime', true);
  6520. $ktime = strtotime($ktime);
  6521. $jtime = strtotime($jtime);
  6522. $where = "state = '11'";
  6523. $gj = "";
  6524. $ck = "";
  6525. if ($lacetype) {
  6526. $where .= " and features like '%-$lacetype-%'";
  6527. }
  6528. if ($category) {
  6529. $where .= " and features like '%-$category-%'";
  6530. }
  6531. if ($size) {
  6532. $where .= " and features like '%-$size-%'";
  6533. }
  6534. if ($grade) {
  6535. $where .= " and features like '%-$grade-%'";
  6536. }
  6537. if ($color) {
  6538. $where .= " and features like '%-$color-%'";
  6539. }
  6540. if ($lowe) {
  6541. $where .= " and features like '%-$lowe-%'";
  6542. }
  6543. if ($haircap) {
  6544. $where .= " and features like '%-$haircap-%'";
  6545. }
  6546. if ($density) {
  6547. $where .= " and features like '%-$density-%'";
  6548. }
  6549. if ($usa) {
  6550. if (!$warehouse) {
  6551. $where .= " and (warehouse = '5' or warehouse = '8')";
  6552. }
  6553. }
  6554. if ($warehouse) {
  6555. $where .= " and warehouse = '$warehouse'";
  6556. }
  6557. if ($details) {
  6558. $where .= " and details = '$details'";
  6559. }
  6560. if ($purchase) {
  6561. $where .= " and purchase = '$purchase'";
  6562. }
  6563. if ($state) {
  6564. $where .= " and state = '$state'";
  6565. }
  6566. if ($ktime && $jtime) {
  6567. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6568. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6569. }
  6570. //数据排序
  6571. $order_str = "id desc";
  6572. if (empty($page)) {
  6573. $start = 0;
  6574. $perpage = 1;
  6575. } else {
  6576. $start = ($page - 1) * $perpage;
  6577. }
  6578. if ($sku) {
  6579. $sku = trim($sku, ' ');
  6580. $sku = trim($sku, ' ');
  6581. $where .= " and sku like '%$sku%'";
  6582. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6583. } else if ($title) {
  6584. $title = trim($title, ' ');
  6585. $title = trim($title, ' ');
  6586. $where .= " and title like '%$title%'";
  6587. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6588. } else {
  6589. //$where .= " and time > '$ktime' and time < '$jtime'";
  6590. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6591. }
  6592. //取得信息列表
  6593. $rows = array();
  6594. $list = array();
  6595. foreach ($info_list as $key => $value) {
  6596. $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'] . '"');
  6597. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6598. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6599. $warehouse = $this->warehouse->read($value['warehouse']);
  6600. $info_list[$key]['warehouse'] = $warehouse['title'];
  6601. $info_list[$key]['number'] = $g;
  6602. $info_list[$key]['features'] = $x;
  6603. $info_list[$key]['x'] = $s;
  6604. }
  6605. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6606. $pagenum = ceil($total / $perpage);
  6607. $over = $total - ($start + $perpage);
  6608. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6609. echo json_encode($rows);
  6610. exit;
  6611. }
  6612. $this->data['vip'] = $vip;
  6613. $this->_Template('whlabel_fc', $this->data);
  6614. }
  6615. public function _fcmb()
  6616. {
  6617. $where = "sku != 'Preset'";
  6618. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6619. foreach ($rows as $k => $v) {
  6620. $warehouse = $this->warehouse->read($v['warehouse']);
  6621. $rows[$k]['warehouse'] = $warehouse['title'];
  6622. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6623. $rows[$k]['t'] = '';
  6624. $rows[$k]['n'] = '';
  6625. }
  6626. $title = "封货产品数据导入模板";
  6627. $titlename = "<table border=1>
  6628. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6629. <tr align='center'>
  6630. <td>仓库</td>
  6631. <td>SKU</td>
  6632. <td>产品</td>
  6633. <td>封存产品总数量</td>
  6634. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6635. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6636. </tr>
  6637. </table>";
  6638. $filename = $title . ".xls";
  6639. $tail = "";
  6640. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6641. }
  6642. public function _fcexcel()
  6643. {
  6644. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6645. $config['upload_path'] = '.' . $dir;
  6646. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6647. $config['allowed_types'] = 'xls|xlsx|csv';
  6648. $config['max_size'] = 10240;
  6649. $this->load->library('upload', $config);
  6650. $this->upload->initialize($config);
  6651. if ($this->upload->do_upload('userfile')) {
  6652. $full_path = $dir . $this->upload->data('file_name');
  6653. $fileName = '.' . $full_path;
  6654. if (!file_exists($fileName)) {
  6655. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6656. exit;
  6657. } else {
  6658. libxml_use_internal_errors(true);
  6659. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6660. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6661. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6662. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6663. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6664. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6665. ++$column; //如果列数大于26行
  6666. $list = array();
  6667. for ($i = 2; $i <= $row; $i++) // 行数循环
  6668. {
  6669. $data = array();
  6670. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6671. {
  6672. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6673. }
  6674. $list[] = $data;
  6675. }
  6676. }
  6677. $i = 0;
  6678. $j = 0;
  6679. $ed = array();
  6680. foreach ($list as $key => $value) {
  6681. $time = time();
  6682. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6683. continue;
  6684. }
  6685. $warehouse = $this->warehouse->get_title($value['0']);
  6686. $sku = $value['1'];
  6687. $type = $value['4']; //调整方式0扣减1删除
  6688. $num = $value['5']; //调整数量
  6689. //$text = $value['4'];//扣减说明
  6690. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6691. if (!$d) //如果没有这个SKU
  6692. {
  6693. $ed[] = array($sku . '-库存中不存在此SKU');
  6694. $j++;
  6695. continue;
  6696. }
  6697. if (!isset($warehouse['id'])) {
  6698. $ed[] = array($sku . '-仓库名错误!');
  6699. $j++;
  6700. continue;
  6701. }
  6702. if ($type == 1 || $type == 2) //扣减库存
  6703. {
  6704. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6705. if (count($data) < abs($num)) {
  6706. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6707. $j++;
  6708. continue;
  6709. }
  6710. if ($type == 1) //转入库存
  6711. {
  6712. for ($i = 0; $i < abs($num); $i++) {
  6713. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6714. }
  6715. } else if ($type == 2) //删除
  6716. {
  6717. for ($i = 0; $i < abs($num); $i++) {
  6718. $this->whlabel->remove($data[$i]['id']);
  6719. }
  6720. }
  6721. } else if ($type == 0) //增加库存
  6722. {
  6723. $post['sku'] = $d['sku'];
  6724. $post['shop'] = '';
  6725. $post['warehouse'] = $warehouse['id'];
  6726. $post['purchase'] = $d['purchase'];
  6727. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6728. $post['state'] = 11;
  6729. $post['title'] = $d['title'];
  6730. $post['number'] = $d['number'];
  6731. $post['features'] = $d['features'];
  6732. $post['enter'] = $time;
  6733. $post['time'] = $time; //操作时间
  6734. for ($i = 0; $i < $num; $i++) {
  6735. $post['label'] = time() . rand(100, 999) . $i;
  6736. $this->whlabel->insert($post);
  6737. }
  6738. }
  6739. sleep(1); //防止入库时间一样,需要延迟1秒
  6740. }
  6741. if ($j > 0) {
  6742. $tt = date('Ymd', time());
  6743. $title = '库存导入错误信息-' . $tt;
  6744. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6745. $tail = "\n";
  6746. $filename = $title . ".xls";
  6747. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6748. $dir = '/data/excel/' . $time . '/';
  6749. $file_name = 'error_' . $time . rand(1000, 9999);
  6750. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6751. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6752. fwrite($myfile, $ecl);
  6753. fclose($myfile);
  6754. $error = $dir . $file_name . '.xls';
  6755. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6756. exit;
  6757. } else {
  6758. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6759. exit;
  6760. }
  6761. }
  6762. }
  6763. public function _fcjxc($arg_array)
  6764. {
  6765. if (isset($_GET['excel'])) {
  6766. $category = $this->input->get('category', true);
  6767. $size = $this->input->get('size', true);
  6768. $grade = $this->input->get('grade', true);
  6769. $color = $this->input->get('color', true);
  6770. $lowe = $this->input->get('lowe', true);
  6771. $sku = $this->input->get('sku');
  6772. $title = $this->input->get('title');
  6773. $warehouse = $arg_array[0];
  6774. $usa = $this->input->get('usa', true);
  6775. $purchase = $this->input->get('purchase', true);
  6776. $lacetype = $this->input->get('lacetype', true);
  6777. $haircap = $this->input->get('haircap', true);
  6778. $density = $this->input->get('density', true);
  6779. $title = $this->input->get('title', true);
  6780. $state = $this->input->get('state', true);
  6781. $ktime = $this->input->get('ktime', true);
  6782. $jtime = $this->input->get('jtime', true);
  6783. $where = "state=11";
  6784. $gj = "";
  6785. $ck = "";
  6786. if ($lacetype) {
  6787. $where .= " and features like '%-$lacetype-%'";
  6788. }
  6789. if ($category) {
  6790. $where .= " and features like '%-$category-%'";
  6791. }
  6792. if ($size) {
  6793. $where .= " and features like '%-$size-%'";
  6794. }
  6795. if ($grade) {
  6796. $where .= " and features like '%-$grade-%'";
  6797. }
  6798. if ($color) {
  6799. $where .= " and features like '%-$color-%'";
  6800. }
  6801. if ($lowe) {
  6802. $where .= " and features like '%-$lowe-%'";
  6803. }
  6804. if ($haircap) {
  6805. $where .= " and features like '%-$haircap-%'";
  6806. }
  6807. if ($density) {
  6808. $where .= " and features like '%-$density-%'";
  6809. }
  6810. if ($usa) {
  6811. if (!$warehouse) {
  6812. $where .= " and (warehouse = '5' or warehouse = '8')";
  6813. }
  6814. }
  6815. if ($warehouse) {
  6816. $where .= " and warehouse = '$warehouse'";
  6817. }
  6818. if ($purchase) {
  6819. $where .= " and purchase = '$purchase'";
  6820. }
  6821. if ($state) {
  6822. $where .= " and state = '$state'";
  6823. }
  6824. $order_str = "id desc";
  6825. if ($sku) {
  6826. $sku = trim($sku, ' ');
  6827. $sku = trim($sku, ' ');
  6828. $where .= " and sku like '%$sku%'";
  6829. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6830. } else if ($title) {
  6831. $title = trim($title, ' ');
  6832. $title = trim($title, ' ');
  6833. $where .= " and title like '%$title%'";
  6834. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6835. } else {
  6836. //$where .= " and time > '$ktime' and time < '$jtime'";
  6837. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6838. }
  6839. //取得信息列表
  6840. $rows = array();
  6841. $list = array();
  6842. foreach ($info_list as $key => $value) {
  6843. $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'] . '"');
  6844. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6845. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6846. $rows[$key] = $value;
  6847. $warehouse = $this->warehouse->read($value['warehouse']);
  6848. $rows[$key]['warehouse'] = $warehouse['title'];
  6849. $rows[$key]['features'] = $g;
  6850. $rows[$key]['a'] = $x;
  6851. $rows[$key]['b'] = $s;
  6852. }
  6853. $title = "总统计表";
  6854. $titlename = "<table border=1>
  6855. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6856. <tr align='center'>
  6857. <td>仓库</td>
  6858. <td>SKU</td>
  6859. <td>产品名称</td>
  6860. <td>录入总量</td>
  6861. <td>取出总量</td>
  6862. <td>剩余总量</td>
  6863. </tr>
  6864. </table>";
  6865. $filename = $title . ".xls";
  6866. $tail = "";
  6867. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6868. }
  6869. $vip = 0;
  6870. if (isset($_SESSION['api'])) {
  6871. $user = $this->user->get_api($_SESSION['api']);
  6872. if ($user['vip'] == 1) {
  6873. $vip = 1;
  6874. }
  6875. } else {
  6876. header('Location: /');
  6877. exit;
  6878. }
  6879. $post = $this->input->post(NULL, TRUE);
  6880. if (isset($post['page'])) {
  6881. $page = $this->input->post('page', true);
  6882. $perpage = $this->input->post('perpage', true);
  6883. $category = $this->input->post('category', true);
  6884. $size = $this->input->post('size', true);
  6885. $grade = $this->input->post('grade', true);
  6886. $color = $this->input->post('color', true);
  6887. $lowe = $this->input->post('lowe', true);
  6888. $sku = $this->input->post('sku');
  6889. $title = $this->input->post('title');
  6890. $warehouse = $arg_array[0];
  6891. $usa = $this->input->post('usa', true);
  6892. $purchase = $this->input->post('purchase', true);
  6893. $lacetype = $this->input->post('lacetype', true);
  6894. $haircap = $this->input->post('haircap', true);
  6895. $density = $this->input->post('density', true);
  6896. $title = $this->input->post('title', true);
  6897. $state = $this->input->post('state', true);
  6898. $ktime = $this->input->post('ktime', true);
  6899. $jtime = $this->input->post('jtime', true);
  6900. $ktime = strtotime($ktime);
  6901. $jtime = strtotime($jtime);
  6902. $where = "state=11";
  6903. $gj = "";
  6904. $ck = "";
  6905. if ($lacetype) {
  6906. $where .= " and features like '%-$lacetype-%'";
  6907. }
  6908. if ($category) {
  6909. $where .= " and features like '%-$category-%'";
  6910. }
  6911. if ($size) {
  6912. $where .= " and features like '%-$size-%'";
  6913. }
  6914. if ($grade) {
  6915. $where .= " and features like '%-$grade-%'";
  6916. }
  6917. if ($color) {
  6918. $where .= " and features like '%-$color-%'";
  6919. }
  6920. if ($lowe) {
  6921. $where .= " and features like '%-$lowe-%'";
  6922. }
  6923. if ($haircap) {
  6924. $where .= " and features like '%-$haircap-%'";
  6925. }
  6926. if ($density) {
  6927. $where .= " and features like '%-$density-%'";
  6928. }
  6929. if ($usa) {
  6930. if (!$warehouse) {
  6931. $where .= " and (warehouse = '5' or warehouse = '8')";
  6932. }
  6933. }
  6934. if ($warehouse) {
  6935. $where .= " and warehouse = '$warehouse'";
  6936. }
  6937. if ($purchase) {
  6938. $where .= " and purchase = '$purchase'";
  6939. }
  6940. if ($state) {
  6941. $where .= " and state = '$state'";
  6942. }
  6943. if ($ktime && $jtime) {
  6944. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6945. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6946. }
  6947. //数据排序
  6948. $order_str = "id desc";
  6949. $xs = 0;
  6950. $rows = array();
  6951. $list = array();
  6952. if (empty($page)) {
  6953. $start = 0;
  6954. $perpage = 1;
  6955. } else {
  6956. $start = ($page - 1) * $perpage;
  6957. }
  6958. if ($sku || $title) {
  6959. if ($title) {
  6960. $title = trim($title, ' ');
  6961. $title = trim($title, ' ');
  6962. $where .= " and title like '%$title%'";
  6963. } else {
  6964. $sku = trim($sku, ' ');
  6965. $sku = trim($sku, ' ');
  6966. $where .= " and sku like '%$sku%'";
  6967. }
  6968. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6969. foreach ($info_list as $key => $value) {
  6970. $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'] . '"');
  6971. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6972. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6973. $rows[$key] = $value;
  6974. $warehouse = $this->warehouse->read($value['warehouse']);
  6975. $rows[$key]['warehouse'] = $warehouse['title'];
  6976. $rows[$key]['features'] = $g;
  6977. $rows[$key]['a'] = $x;
  6978. $rows[$key]['b'] = $s;
  6979. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6980. $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天销量
  6981. $yj = $c / ($xl / 30);
  6982. if ($yj < 7) {
  6983. $rows[$key]['y'] = round($yj) . '天销量';
  6984. } else {
  6985. $rows[$key]['y'] = '正常';
  6986. }
  6987. }
  6988. } else {
  6989. //$where .= " and time > '$ktime' and time < '$jtime'";
  6990. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6991. foreach ($info_list as $key => $value) {
  6992. $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'] . '"');
  6993. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6994. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6995. $zs[$key] = $value;
  6996. $warehouse = $this->warehouse->read($value['warehouse']);
  6997. $zs[$key]['warehouse'] = $warehouse['title'];
  6998. $zs[$key]['features'] = $g;
  6999. $zs[$key]['a'] = $x;
  7000. $zs[$key]['b'] = $s;
  7001. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7002. $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天销量
  7003. $yj = $c / ($xl / 30);
  7004. if ($yj < 7) {
  7005. $zs[$key]['y'] = round($yj) . '天销量';
  7006. $rows[$key] = $zs[$key];
  7007. }
  7008. }
  7009. }
  7010. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7011. $pagenum = ceil($total / $perpage);
  7012. $over = $total - ($start + $perpage);
  7013. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7014. echo json_encode($rows);
  7015. exit;
  7016. }
  7017. $this->data['arg_array'] = $arg_array[0];
  7018. $this->_Template('whlabel_fcjxc', $this->data);
  7019. }
  7020. public function _0kcdel()
  7021. {
  7022. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7023. $config['upload_path'] = '.' . $dir;
  7024. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7025. $config['allowed_types'] = 'xls|xlsx|csv';
  7026. $config['max_size'] = 10240;
  7027. $this->load->library('upload', $config);
  7028. $this->upload->initialize($config);
  7029. if ($this->upload->do_upload('userfile')) {
  7030. $full_path = $dir . $this->upload->data('file_name');
  7031. $fileName = '.' . $full_path;
  7032. if (!file_exists($fileName)) {
  7033. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7034. exit;
  7035. } else {
  7036. require_once "./data/excel/PHPExcel/IOFactory.php";
  7037. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7038. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7039. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7040. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7041. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7042. ++$column; //如果列数大于26行
  7043. $list = array();
  7044. for ($i = 2; $i <= $row; $i++) // 行数循环
  7045. {
  7046. $data = array();
  7047. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7048. {
  7049. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7050. }
  7051. $list[] = $data;
  7052. }
  7053. }
  7054. $i = 0;
  7055. $j = 0;
  7056. $ed = array();
  7057. foreach ($list as $key => $value) {
  7058. $time = time();
  7059. if ($value['0'] == "" || $value['1'] == "") {
  7060. continue;
  7061. }
  7062. $warehouse = $this->warehouse->get_title($value['0']);
  7063. $sku = $value['1'];
  7064. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7065. if (!$d) //如果没有这个SKU
  7066. {
  7067. $ed[] = array($sku . '-库存中不存在此SKU');
  7068. $j++;
  7069. continue;
  7070. }
  7071. if (!isset($warehouse['id'])) {
  7072. $ed[] = array($sku . '-仓库名错误!');
  7073. $j++;
  7074. continue;
  7075. }
  7076. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7077. if ($z < 1) {
  7078. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7079. foreach ($z as $v) {
  7080. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7081. if (count($zt) > 0) {
  7082. $ed[] = array($sku . '-有在途库存无法删除!');
  7083. $j++;
  7084. continue;
  7085. }
  7086. $this->whlabel->remove($v['id']);
  7087. }
  7088. } else {
  7089. $ed[] = array($sku . '-非0库存!');
  7090. $j++;
  7091. continue;
  7092. }
  7093. }
  7094. if ($j > 0) {
  7095. $tt = date('Ymd', time());
  7096. $title = '删除0库存错误信息-' . $tt;
  7097. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7098. $tail = "\n";
  7099. $filename = $title . ".xls";
  7100. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7101. $dir = '/data/excel/' . $time . '/';
  7102. $file_name = 'error_' . $time . rand(1000, 9999);
  7103. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7104. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7105. fwrite($myfile, $ecl);
  7106. fclose($myfile);
  7107. $error = $dir . $file_name . '.xls';
  7108. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7109. exit;
  7110. } else {
  7111. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7112. exit;
  7113. }
  7114. }
  7115. }
  7116. public function _gbhtype()
  7117. {
  7118. $post = $this->input->post(NULL, TRUE);
  7119. if (isset($post['s'])) {
  7120. $n = $this->input->post('n');
  7121. $d = $this->input->post('s');
  7122. if (!$d) {
  7123. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7124. exit;
  7125. }
  7126. $d = explode(',', trim($d, ','));
  7127. $t = $this->whlabel_type->read($n);
  7128. //循环删除记录
  7129. foreach ($d as $v) {
  7130. $u = $this->whlabel->read($v);
  7131. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7132. foreach ($data as $val) {
  7133. $this->whlabel->save(array('type' => $n), $val['id']);
  7134. }
  7135. }
  7136. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7137. }
  7138. }
  7139. //出库、退库导出
  7140. public function _dccrtype()
  7141. {
  7142. $classid = $this->classid->sku();
  7143. $pm = $classid;
  7144. $typeclass = array();
  7145. $tc = $this->typeclass->find_all();
  7146. foreach ($tc as $v) {
  7147. $typeclass[$v['id']] = $v;
  7148. }
  7149. $prc = array();
  7150. $purchase = $this->purchase->find_all();
  7151. foreach ($purchase as $k => $v) {
  7152. $prc[$v['id']] = $v['title'];
  7153. }
  7154. if (isset($_GET['sid'])) {
  7155. $wh = array();
  7156. $w = $this->warehouse->find_all('1=1', 'id,title');
  7157. foreach ($w as $v) {
  7158. $wh[$v['id']] = $v['title'];
  7159. }
  7160. $type = $this->input->get('excel', true);
  7161. $category = $this->input->get('category', true);
  7162. $size = $this->input->get('size', true);
  7163. $grade = $this->input->get('grade', true);
  7164. $color = $this->input->get('color', true);
  7165. $lowe = $this->input->get('lowe', true);
  7166. $sku = $this->input->get('sku', true);
  7167. $warehouse = $this->input->get('warehouse', true);
  7168. $lacetype = $this->input->get('lacetype', true);
  7169. $lacecolor = $this->input->get('lacecolor', true);
  7170. $density = $this->input->get('density', true);
  7171. $haircap = $this->input->get('haircap', true);
  7172. $purchase = $this->input->get('purchase', true);
  7173. $title = $this->input->get('title', true);
  7174. $state = $this->input->get('state', true);
  7175. $sid = $this->input->get('sid', true);
  7176. $ktime = $this->input->get('ktime', true);
  7177. $jtime = $this->input->get('jtime', true);
  7178. $ktime = strtotime($ktime);
  7179. $jtime = strtotime($jtime);
  7180. $where = "1=1";
  7181. $gj = "";
  7182. $ck = "";
  7183. if ($category) {
  7184. $where .= " and features like '%-$category-%'";
  7185. }
  7186. if ($size) {
  7187. $where .= " and features like '%-$size-%'";
  7188. }
  7189. if ($grade) {
  7190. $where .= " and features like '%-$grade-%'";
  7191. }
  7192. if ($color) {
  7193. $where .= " and features like '%-$color-%'";
  7194. }
  7195. if ($lowe) {
  7196. $where .= " and features like '%-$lowe-%'";
  7197. }
  7198. if ($warehouse) {
  7199. $where .= " and warehouse = '$warehouse'";
  7200. }
  7201. if ($purchase) {
  7202. $where .= " and purchase = '$purchase'";
  7203. }
  7204. if ($state) {
  7205. $where .= " and state = '$state'";
  7206. }
  7207. if ($lacetype) {
  7208. $where .= " and features like '%-$lacetype-%'";
  7209. }
  7210. if ($lacecolor) {
  7211. $where .= " and features like '%-$lacecolor-%'";
  7212. }
  7213. if ($density) {
  7214. $where .= " and features like '%-$density-%'";
  7215. }
  7216. if ($haircap) {
  7217. $where .= " and features like '%-$haircap-%'";
  7218. }
  7219. if ($title) {
  7220. $title = trim($title, ' ');
  7221. $title = trim($title, ' ');
  7222. $where .= " and title like '%$title%'";
  7223. }
  7224. if ($sku) {
  7225. $sku = trim($sku, ' ');
  7226. $sku = trim($sku, ' ');
  7227. $where .= " and sku like '%$sku%'";
  7228. }
  7229. if ($ktime && $jtime) {
  7230. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7231. }
  7232. $sidwhere = '';
  7233. if ($sid) {
  7234. $sd = "";
  7235. $s = explode(',', trim($sid, ','));
  7236. foreach ($s as $value) {
  7237. $sd .= " id = " . $value . " or";
  7238. }
  7239. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7240. }
  7241. //数据排序
  7242. $order_str = "time desc";
  7243. if (empty($page)) {
  7244. $start = 0;
  7245. $perpage = 1;
  7246. } else {
  7247. $start = ($page - 1) * $perpage;
  7248. }
  7249. $wh = array();
  7250. $w = $this->warehouse->find_all('1=1', 'id,title');
  7251. foreach ($w as $v) {
  7252. $wh[$v['id']] = $v['title'];
  7253. }
  7254. $wt = array();
  7255. $whlabel_type = $this->whlabel_type->find_all();
  7256. foreach ($whlabel_type as $v) {
  7257. $wt[$v['id']] = $v['title'];
  7258. }
  7259. $classid = $this->classid->sku();
  7260. $list = array();
  7261. $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');
  7262. foreach ($rows_r as $key => $value) {
  7263. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7264. $pm = $classid;
  7265. $jm = $classid;
  7266. $rows_r[$key]['enter'] = '入库';
  7267. $rows_r[$key]['time'] = $value['enter'];
  7268. if ($value['rktype'] == 1) {
  7269. $rows_r[$key]['rktype'] = '采购入库';
  7270. } else if ($value['rktype'] == 2) {
  7271. $rows_r[$key]['rktype'] = '盘盈调整';
  7272. } else if ($value['rktype'] == 3) {
  7273. $rows_r[$key]['rktype'] = '其他调整入库';
  7274. } else if ($value['rktype'] == 4) {
  7275. $rows_r[$key]['rktype'] = '其他调整入库';
  7276. } else if ($value['rktype'] == 5) {
  7277. $rows_r[$key]['rktype'] = '退库入库';
  7278. } else if ($value['rktype'] == 6) {
  7279. $rows_r[$key]['rktype'] = '退货可用入库';
  7280. } else if ($value['rktype'] == 7) {
  7281. $rows_r[$key]['rktype'] = '形态转换入库';
  7282. } else {
  7283. $rows_r[$key]['rktype'] = '';
  7284. }
  7285. $features = explode('-', trim($value['features'], '-'));
  7286. foreach ($features as $v) {
  7287. if (isset($typeclass[$v])) {
  7288. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7289. $pm[$typeclass[$v]['classid']] = $zh[0];
  7290. }
  7291. if (isset($typeclass[$v])) {
  7292. if (isset($jm[$typeclass[$v]['classid']])) {
  7293. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7294. }
  7295. }
  7296. }
  7297. $zh = implode(" ", $pm);
  7298. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7299. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7300. $rows_r[$key]['zh'] = $zh;
  7301. $jm = array_filter($jm);
  7302. $rows_r[$key]['features'] = implode("-", $jm);
  7303. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7304. }
  7305. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7306. foreach ($rows_c as $key => $value) {
  7307. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7308. $pm = $classid;
  7309. $jm = $classid;
  7310. $rows_c[$key]['time'] = $value['outk'];
  7311. $rows_c[$key]['outk'] = '出库';
  7312. if ($value['cktype'] == 1) {
  7313. $rows_c[$key]['cktype'] = '销售出库';
  7314. } else if ($value['cktype'] == 2) {
  7315. $rows_c[$key]['cktype'] = '销售美国出库';
  7316. } else if ($value['cktype'] == 3) {
  7317. $rows_c[$key]['cktype'] = '盘亏调整';
  7318. } else if ($value['cktype'] == 4) {
  7319. $rows_c[$key]['cktype'] = '其他调整出库';
  7320. } else if ($value['cktype'] == 5) {
  7321. $rows_c[$key]['cktype'] = '形态转换出库';
  7322. } else {
  7323. $rows_c[$key]['cktype'] = '';
  7324. }
  7325. $features = explode('-', trim($value['features'], '-'));
  7326. foreach ($features as $v) {
  7327. if (isset($typeclass[$v])) {
  7328. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7329. $pm[$typeclass[$v]['classid']] = $zh[0];
  7330. }
  7331. if (isset($typeclass[$v])) {
  7332. if (isset($jm[$typeclass[$v]['classid']])) {
  7333. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7334. }
  7335. }
  7336. }
  7337. $zh = implode(" ", $pm);
  7338. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7339. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7340. $rows_c[$key]['zh'] = $zh;
  7341. $jm = array_filter($jm);
  7342. $rows_c[$key]['features'] = implode("-", $jm);
  7343. $rows_c[$key]['number'] = 1;
  7344. }
  7345. $merged = $rows_r;
  7346. foreach ($rows_c as $key => $value) {
  7347. if (isset($merged[$key])) {
  7348. $merged[] = $value;
  7349. } else {
  7350. $merged[$key] = $value;
  7351. }
  7352. }
  7353. usort($merged, function ($a, $b) {
  7354. return $a['time'] - $b['time'];
  7355. });
  7356. foreach ($merged as $key => $value) {
  7357. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7358. }
  7359. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7360. $titlename = "<table border=1>
  7361. <tr align='center'>
  7362. <td>仓库</td>
  7363. <td>SKU</td>
  7364. <td>商品名称</td>
  7365. <td>仓库品名</td>
  7366. <td>料号</td>
  7367. <td>时间</td>
  7368. <td>操作</td>
  7369. <td>类型</td>
  7370. <td>数量</td>
  7371. <td>备注</td>
  7372. </tr>
  7373. </table>";
  7374. $filename = $title . ".xlsx";
  7375. $tail = "";
  7376. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7377. }
  7378. }
  7379. }