Whlabel.php 264 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688
  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 if($arg == 'excelrjs'){
  190. $this->_excelrjs();
  191. }else if($arg == "w_t_cs"){
  192. $this->_w_t_cs(); //首页
  193. }else {
  194. $this->_index();
  195. }
  196. }
  197. public function _w_t_cs(){
  198. $vip = 0;
  199. if (isset($_SESSION['api'])) {
  200. $user = $this->user->get_api($_SESSION['api']);
  201. $fgshop = "";
  202. $sid = "";
  203. $usersp = explode('|', trim($user['shop'], '|'));
  204. foreach ($usersp as $value) {
  205. $fgshop .= " shop = " . $value . " or";
  206. $sid .= " id = " . $value . " or";
  207. }
  208. if ($user['vip'] == 1) {
  209. $vip = 1;
  210. }
  211. } else {
  212. header('Location: /');
  213. exit;
  214. }
  215. $prc = array();
  216. $purchase = $this->purchase->find_all();
  217. foreach ($purchase as $k => $v) {
  218. $prc[$v['id']] = $v['title'];
  219. }
  220. $company = array();
  221. $ct = $this->company->find_all();
  222. foreach ($ct as $k => $v) {
  223. $company[$v['id']] = $v['title'];
  224. }
  225. $sp = array();
  226. $s = $this->shop->find_all('1=1', 'id,shopname');
  227. foreach ($s as $v) {
  228. $sp[$v['id']] = $v['shopname'];
  229. }
  230. $wh = array();
  231. $w = $this->warehouse->find_all('1=1', 'id,title');
  232. foreach ($w as $v) {
  233. $wh[$v['id']] = $v['title'];
  234. }
  235. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  236. $this->data['shop'] = $wlshop;
  237. $this->data['vip'] = $vip;
  238. $this->_Template('whlabel_typejs', $this->data);
  239. }
  240. //管理
  241. public function _index()
  242. {
  243. $post = $this->input->post(NULL, TRUE);
  244. if (isset($post['page'])) {
  245. $page = $this->input->post('page', true);
  246. $perpage = $this->input->post('perpage', true);
  247. $sku = $this->input->post('sku', true);
  248. $number = $this->input->post('number', true);
  249. $warehouse = $this->input->post('warehouse', true);
  250. $purchase = $this->input->post('purchase', true);
  251. $orderinfo = $this->input->post('orderinfo', true);
  252. $waybill = $this->input->post('waybill', true);
  253. $category = $this->input->post('category', true);
  254. $size = $this->input->post('size', true);
  255. $grade = $this->input->post('grade', true);
  256. $color = $this->input->post('color', true);
  257. $lowe = $this->input->post('lowe', true);
  258. $state = $this->input->post('state', true);
  259. $label = $this->input->post('label', true);
  260. $timetk = $this->input->post('timetkk', true);
  261. $timetj = $this->input->post('timetjj', true);
  262. $timetk = strtotime($timetk);
  263. $timetj = strtotime($timetj);
  264. $where = "1=1 ";
  265. if ($timetk && $timetj) {
  266. $where .= " and time > '$timetk' and time < '$timetj'";
  267. }
  268. if ($sku) {
  269. $where .= " and sku = '$sku'";
  270. }
  271. if ($number) {
  272. $where .= " and number = '$number'";
  273. }
  274. if ($warehouse) {
  275. $where .= " and warehouse = '$warehouse'";
  276. }
  277. if ($purchase) {
  278. $where .= " and purchase = '$purchase'";
  279. }
  280. if ($orderinfo) {
  281. $where .= " and orderinfo = '$orderinfo'";
  282. }
  283. if ($waybill) {
  284. $where .= " and waybill = '$waybill'";
  285. }
  286. if ($category) {
  287. $where .= " and features like '%-$category-%'";
  288. }
  289. if ($size) {
  290. $where .= " and features like '%-$size-%'";
  291. }
  292. if ($grade) {
  293. $where .= " and features like '%-$grade-%'";
  294. }
  295. if ($color) {
  296. $where .= " and features like '%-$color-%'";
  297. }
  298. if ($lowe) {
  299. $where .= " and features like '%-$lowe-%'";
  300. }
  301. if ($label) {
  302. $where .= " and label = '$label'";
  303. }
  304. if ($state != '') {
  305. $where .= " and state = '$state'";
  306. }
  307. //数据排序
  308. $order_str = "time desc";
  309. if (empty($page)) {
  310. $start = 0;
  311. $perpage = 1;
  312. } else {
  313. $start = ($page - 1) * $perpage;
  314. }
  315. //取得信息列表
  316. $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);
  317. foreach ($info_list as $key => $value) {
  318. $warehouse = $this->warehouse->read($value['warehouse']);
  319. $info_list[$key]['warehouse'] = $warehouse['title'];
  320. $purchase = $this->purchase->read($value['purchase']);
  321. $info_list[$key]['purchase'] = $purchase['title'];
  322. if ($value['enter'] != 0) {
  323. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  324. } else {
  325. $info_list[$key]['enter'] = "";
  326. }
  327. if ($value['outk'] != 0) {
  328. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  329. } else {
  330. $info_list[$key]['outk'] = "";
  331. }
  332. if ($value['printing'] != 0) {
  333. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  334. } else {
  335. $info_list[$key]['printing'] = "";
  336. }
  337. if ($value['orderinfo'] == 0) {
  338. $info_list[$key]['orderinfo'] = "";
  339. }
  340. if ($value['waybill'] == 0) {
  341. $info_list[$key]['waybill'] = "";
  342. }
  343. if ($value['state'] == 0) {
  344. $info_list[$key]['state'] = "在库";
  345. } else if ($value['state'] == 1) {
  346. $info_list[$key]['state'] = "出库";
  347. } else if ($value['state'] == 2) {
  348. $info_list[$key]['state'] = "退库";
  349. } else if ($value['state'] == 3) {
  350. $info_list[$key]['state'] = "调拨中";
  351. } else if ($value['state'] == 4) {
  352. $info_list[$key]['state'] = "再加工";
  353. } else if ($value['state'] == 5) {
  354. $info_list[$key]['state'] = "维修中";
  355. } else if ($value['state'] == 6) {
  356. $info_list[$key]['state'] = "盘亏";
  357. } else if ($value['state'] == 7) {
  358. $info_list[$key]['state'] = "更换标签";
  359. } else if ($value['state'] == 8) {
  360. $info_list[$key]['state'] = "其它";
  361. } else if ($value['state'] == 9) {
  362. $info_list[$key]['state'] = "预设";
  363. } else if ($value['state'] == 10) {
  364. $info_list[$key]['state'] = "美店零售";
  365. }
  366. if ($value['text'] == "") {
  367. $info_list[$key]['text'] = "";
  368. }
  369. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  370. }
  371. $total = $this->whlabel->find_count($where);
  372. $pagenum = ceil($total / $perpage);
  373. $over = $total - ($start + $perpage);
  374. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  375. echo json_encode($rows);
  376. exit;
  377. }
  378. if (isset($post['outsku'])) {
  379. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  380. $cz = $this->input->post('cz', true);
  381. if ($cz == '1') {
  382. $sku = $this->input->post('outsku', true);
  383. if ($sku) {
  384. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  385. if (count($data) < 1) {
  386. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  387. exit;
  388. }
  389. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  390. echo json_encode(array('success' => true));
  391. exit;
  392. }
  393. } else {
  394. echo json_encode(array('msg' => '此方法禁用!', 'success' => false));
  395. exit;
  396. $sku = $this->input->post('outsku', true);
  397. if ($sku) {
  398. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  399. if (count($data) < 1) {
  400. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  401. exit;
  402. }
  403. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  404. echo json_encode(array('success' => true));
  405. exit;
  406. }
  407. }
  408. }
  409. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  410. $this->_Template('whlabel', $this->data);
  411. }
  412. //在库标签
  413. public function _existence()
  414. {
  415. $post = $this->input->post(NULL, TRUE);
  416. if (isset($post['s'])) {
  417. $id_arr = $this->input->post('s');
  418. $id_arr = explode(',', $id_arr);
  419. if (!$id_arr) {
  420. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  421. exit;
  422. }
  423. //循环删除记录
  424. foreach ($id_arr as $v) {
  425. $sid = $this->whlabel->read($v);
  426. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  427. if ($count > 0) {
  428. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  429. exit;
  430. }
  431. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  432. if (count($zt) > 0) {
  433. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  434. exit;
  435. }
  436. $this->whlabel->remove($v);
  437. }
  438. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  439. exit;
  440. }
  441. if (isset($post['page'])) {
  442. $page = $this->input->post('page', true);
  443. $perpage = $this->input->post('perpage', true);
  444. $warehouse = $this->input->post('warehouse', true);
  445. $label = $this->input->post('label', true);
  446. $where = "1=1 and state = 0";
  447. if ($warehouse) {
  448. $where .= " and warehouse = '$warehouse'";
  449. }
  450. if ($label) {
  451. $where .= " and label = '$label'";
  452. }
  453. //数据排序
  454. $order_str = "time asc";
  455. if (empty($page)) {
  456. $start = 0;
  457. $perpage = 1;
  458. } else {
  459. $start = ($page - 1) * $perpage;
  460. }
  461. //取得信息列表
  462. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  463. foreach ($info_list as $key => $value) {
  464. if ($value['enter'] != 0) {
  465. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  466. } else {
  467. $info_list[$key]['enter'] = "";
  468. }
  469. if ($value['printing'] != 0) {
  470. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  471. } else {
  472. $info_list[$key]['printing'] = "";
  473. }
  474. }
  475. $total = $this->whlabel->find_count($where);
  476. $pagenum = ceil($total / $perpage);
  477. $over = $total - ($start + $perpage);
  478. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  479. echo json_encode($rows);
  480. exit;
  481. }
  482. $this->_Template('whlabel_existence', $this->data);
  483. }
  484. //进销存浏览
  485. public function _typedy($arg_array)
  486. {
  487. $prc = array();
  488. $purchase = $this->purchase->find_all();
  489. foreach ($purchase as $k => $v) {
  490. $prc[$v['id']] = $v['title'];
  491. }
  492. $post = $this->input->post(NULL, TRUE);
  493. if (isset($post['page'])) {
  494. $page = $this->input->post('page', true);
  495. $perpage = $this->input->post('perpage', true);
  496. $category = $this->input->post('category', true);
  497. $size = $this->input->post('size', true);
  498. $grade = $this->input->post('grade', true);
  499. $color = $this->input->post('color', true);
  500. $lowe = $this->input->post('lowe', true);
  501. $sku = $this->input->post('sku');
  502. $title = $this->input->post('title');
  503. $warehouse = $this->input->post('warehouse', true);
  504. $usa = $this->input->post('usa', true);
  505. $purchase = $this->input->post('purchase', true);
  506. $lacetype = $this->input->post('lacetype', true);
  507. $haircap = $this->input->post('haircap', true);
  508. $density = $this->input->post('density', true);
  509. $details = $this->input->post('details', true);
  510. $state = $this->input->post('state', true);
  511. $lacecolor = $this->input->post('lacecolor', true);
  512. $hairnumber = $this->input->post('hairnumber', true);
  513. $cklx = $this->input->post('cklx', true);
  514. $ktime = $this->input->post('ktime', true);
  515. $jtime = $this->input->post('jtime', true);
  516. $sm = $this->input->post('sm', true);
  517. $cpbz = $this->input->post('cpbz', true);
  518. $type = $this->input->post('type', true);
  519. $ktime = strtotime($ktime);
  520. $jtime = strtotime($jtime);
  521. $where = "1=1";
  522. $gj = "";
  523. $ck = "";
  524. if ($usa) {
  525. if (!$warehouse) {
  526. $where .= " and (warehouse = '5' or warehouse = '8')";
  527. }
  528. }
  529. if ($warehouse) {
  530. $where .= " and warehouse = '$warehouse'";
  531. }
  532. if ($details) {
  533. $where .= " and details = '$details'";
  534. }
  535. if ($purchase) {
  536. $where .= " and purchase = '$purchase'";
  537. }
  538. if (isset($state)) {
  539. if($state >-1){
  540. $where .= " and state = '$state'";
  541. }
  542. }
  543. if ($lacetype) {
  544. $where .= " and features like '%-$lacetype-%'";
  545. }
  546. if ($category) {
  547. $where .= " and features like '%-$category-%'";
  548. }
  549. if ($size) {
  550. $where .= " and features like '%-$size-%'";
  551. }
  552. if ($grade) {
  553. $where .= " and features like '%-$grade-%'";
  554. }
  555. if ($color) {
  556. $where .= " and features like '%-$color-%'";
  557. }
  558. if ($lowe) {
  559. $where .= " and features like '%-$lowe-%'";
  560. }
  561. if ($haircap) {
  562. $where .= " and features like '%-$haircap-%'";
  563. }
  564. if ($density) {
  565. $where .= " and features like '%-$density-%'";
  566. }
  567. if ($lacecolor) {
  568. $where .= " and features like '%-$lacecolor-%'";
  569. }
  570. if($sm){
  571. $where .= " and sm like '%".$sm."%'";
  572. }
  573. if($cpbz){
  574. $where .= " and cpbz like '%".$cpbz."%'";
  575. }
  576. if($type){
  577. $where .= " and type = ".$type."";
  578. }
  579. if (!empty($hairnumber)) {
  580. $where .= " and features like '%-128-%' ";
  581. if ($hairnumber < 0) {
  582. $class_list = $this->typeclass->find_all('classid = 43');
  583. foreach ($class_list as $v) {
  584. $where .= " and features not like '%-" . $v['id'] . "-%'";
  585. }
  586. } else {
  587. $where .= " and features like '%-$hairnumber-%'";
  588. }
  589. }
  590. $where_add = '';
  591. if ($cklx) {
  592. $shop = $this->shop->read($cklx);
  593. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  594. }
  595. if ($ktime && $jtime) {
  596. $gj = " and enter > '$ktime' and enter < '$jtime'";
  597. $ck = " and outk > '$ktime' and outk < '$jtime'";
  598. }
  599. //数据排序
  600. $order_str = "id desc";
  601. if (empty($page)) {
  602. $start = 0;
  603. $perpage = 1;
  604. } else {
  605. $start = ($page - 1) * $perpage;
  606. }
  607. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  608. if ($sku) {
  609. $sku = trim($sku, ' ');
  610. $sku = trim($sku, ' ');
  611. $where .= " and sku like '%$sku%'";
  612. $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);
  613. } else if ($title) {
  614. $title = trim($title, ' ');
  615. $title = trim($title, ' ');
  616. $where .= " and title like '%$title%'";
  617. $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);
  618. } else {
  619. //$where .= " and time > '$ktime' and time < '$jtime'";
  620. $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);
  621. }
  622. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  623. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  624. foreach ($info_list as $k => $v) {
  625. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  626. unset($info_list[$k]['pm']);
  627. unset($info_list[$k]['jm']);
  628. unset($info_list[$k]['bm']);
  629. }
  630. //取得信息列表
  631. $rows = array();
  632. $list = array();
  633. foreach ($info_list as $key => $value) {
  634. $warehouse = $this->warehouse->read($value['warehouse']);
  635. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  636. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  637. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  638. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  639. $info_list[$key]['label'] = $value['sm'];
  640. $number = $value['number'];
  641. $ftime = time() - 15 * 24 * 3600;
  642. $info_list[$key]['warehouse'] = $warehouse['title'];
  643. $info_list[$key]['features'] = count($c);
  644. $z = count($z); //查看订单号
  645. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  646. $ztdata = '';
  647. if (count($zt) > 0) {
  648. foreach ($zt as $vv) {
  649. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  650. }
  651. }
  652. $info_list[$key]['number'] = $ztdata;
  653. $info_list[$key]['sm'] = $z;
  654. $details = array();
  655. $cpid = array();
  656. foreach ($c as $k => $v) {
  657. $details[$v['details']] = $v['details'];
  658. if ($v['cpid'] != 0) {
  659. $cpid[$v['cpid']] = $v['cpid'];
  660. }
  661. }
  662. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  663. if ($value['shop'] != '') {
  664. $shop = explode(',', trim($value['shop'], ','));
  665. $shop = $this->shop->read($shop[0]);
  666. $info_list[$key]['shop'] = $shop['shopname'];
  667. }
  668. }
  669. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  670. $pagenum = ceil($total / $perpage);
  671. $over = $total - ($start + $perpage);
  672. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  673. echo json_encode($rows);
  674. exit;
  675. }
  676. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  677. $this->_Template('whlabel_typedy', $this->data);
  678. }
  679. //进销存浏览
  680. public function _typedy_ck($arg_array)
  681. {
  682. $prc = array();
  683. $purchase = $this->purchase->find_all();
  684. foreach ($purchase as $k => $v) {
  685. $prc[$v['id']] = $v['title'];
  686. }
  687. $post = $this->input->post(NULL, TRUE);
  688. if (isset($post['page'])) {
  689. $page = $this->input->post('page', true);
  690. $perpage = $this->input->post('perpage', true);
  691. $category = $this->input->post('category', true);
  692. $size = $this->input->post('size', true);
  693. $grade = $this->input->post('grade', true);
  694. $color = $this->input->post('color', true);
  695. $lowe = $this->input->post('lowe', true);
  696. $sku = $this->input->post('sku');
  697. $title = $this->input->post('title');
  698. $warehouse = $this->input->post('warehouse', true);
  699. $usa = $this->input->post('usa', true);
  700. $purchase = $this->input->post('purchase', true);
  701. $lacetype = $this->input->post('lacetype', true);
  702. $haircap = $this->input->post('haircap', true);
  703. $density = $this->input->post('density', true);
  704. $details = $this->input->post('details', true);
  705. $state = $this->input->post('state', true);
  706. $lacecolor = $this->input->post('lacecolor', true);
  707. $cklx = $this->input->post('cklx', true);
  708. $ktime = $this->input->post('ktime', true);
  709. $jtime = $this->input->post('jtime', true);
  710. $ktime = strtotime($ktime);
  711. $jtime = strtotime($jtime);
  712. $where = "1=1";
  713. $gj = "";
  714. $ck = "";
  715. if ($lacetype) {
  716. $where .= " and features like '%-$lacetype-%'";
  717. }
  718. if ($category) {
  719. $where .= " and features like '%-$category-%'";
  720. }
  721. if ($size) {
  722. $where .= " and features like '%-$size-%'";
  723. }
  724. if ($grade) {
  725. $where .= " and features like '%-$grade-%'";
  726. }
  727. if ($color) {
  728. $where .= " and features like '%-$color-%'";
  729. }
  730. if ($lowe) {
  731. $where .= " and features like '%-$lowe-%'";
  732. }
  733. if ($haircap) {
  734. $where .= " and features like '%-$haircap-%'";
  735. }
  736. if ($density) {
  737. $where .= " and features like '%-$density-%'";
  738. }
  739. if ($lacecolor) {
  740. $where .= " and features like '%-$lacecolor-%'";
  741. }
  742. if ($usa) {
  743. if (!$warehouse) {
  744. $where .= " and (warehouse = '5' or warehouse = '8')";
  745. }
  746. }
  747. if ($warehouse) {
  748. $where .= " and warehouse = '$warehouse'";
  749. }
  750. if ($details) {
  751. $where .= " and details = '$details'";
  752. }
  753. if ($purchase) {
  754. $where .= " and purchase = '$purchase'";
  755. }
  756. if ($state) {
  757. $where .= " and state = '$state'";
  758. }
  759. $where_add = '';
  760. if ($cklx) {
  761. $shop = $this->shop->read($cklx);
  762. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  763. }
  764. if ($ktime && $jtime) {
  765. $gj = " and enter > '$ktime' and enter < '$jtime'";
  766. $ck = " and outk > '$ktime' and outk < '$jtime'";
  767. }
  768. //数据排序
  769. $order_str = "id desc";
  770. if (empty($page)) {
  771. $start = 0;
  772. $perpage = 1;
  773. } else {
  774. $start = ($page - 1) * $perpage;
  775. }
  776. if ($sku) {
  777. $sku = trim($sku, ' ');
  778. $sku = trim($sku, ' ');
  779. $where .= " and sku like '%$sku%'";
  780. $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);
  781. } else if ($title) {
  782. $title = trim($title, ' ');
  783. $title = trim($title, ' ');
  784. $where .= " and title like '%$title%'";
  785. $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);
  786. } else {
  787. //$where .= " and time > '$ktime' and time < '$jtime'";
  788. $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);
  789. }
  790. //取得信息列表
  791. $rows = array();
  792. $list = array();
  793. foreach ($info_list as $key => $value) {
  794. $warehouse = $this->warehouse->read($value['warehouse']);
  795. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  796. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  797. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  798. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  799. $ftime = time() - 15 * 24 * 3600;
  800. $info_list[$key]['warehouse'] = $warehouse['title'];
  801. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  802. //$z = count($z);//查看订单号
  803. //$info_list[$key]['zd'] = $z;
  804. $details = array();
  805. $cpid = array();
  806. foreach ($c as $k => $v) {
  807. $details[$v['details']] = $v['details'];
  808. if ($v['cpid'] != 0) {
  809. $cpid[$v['cpid']] = $v['cpid'];
  810. }
  811. }
  812. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  813. if ($value['shop'] != '') {
  814. $shop = explode(',', trim($value['shop'], ','));
  815. $shop = $this->shop->read($shop[0]);
  816. $info_list[$key]['shop'] = $shop['shopname'];
  817. }
  818. }
  819. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  820. $pagenum = ceil($total / $perpage);
  821. $over = $total - ($start + $perpage);
  822. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  823. echo json_encode($rows);
  824. exit;
  825. }
  826. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  827. $this->_Template('whlabel_typedy_ck', $this->data);
  828. }
  829. public function _typeck($arg_array)
  830. {
  831. $prc = array();
  832. $purchase = $this->purchase->find_all();
  833. foreach ($purchase as $k => $v) {
  834. $prc[$v['id']] = $v['title'];
  835. }
  836. $post = $this->input->post(NULL, TRUE);
  837. if (isset($post['page'])) {
  838. $page = $this->input->post('page', true);
  839. $perpage = $this->input->post('perpage', true);
  840. $category = $this->input->post('category', true);
  841. $size = $this->input->post('size', true);
  842. $grade = $this->input->post('grade', true);
  843. $color = $this->input->post('color', true);
  844. $lacecolor = $this->input->post('lacecolor', true);
  845. $lowe = $this->input->post('lowe', true);
  846. $sku = $this->input->post('sku');
  847. $title = $this->input->post('title');
  848. $warehouse = 13;
  849. $usa = $this->input->post('usa', true);
  850. $purchase = $this->input->post('purchase', true);
  851. $lacetype = $this->input->post('lacetype', true);
  852. $haircap = $this->input->post('haircap', true);
  853. $density = $this->input->post('density', true);
  854. $details = $this->input->post('details', true);
  855. $state = $this->input->post('state', true);
  856. $ktime = $this->input->post('ktime', true);
  857. $jtime = $this->input->post('jtime', true);
  858. $ktime = strtotime($ktime);
  859. $jtime = strtotime($jtime);
  860. $where = "1=1";
  861. $gj = "";
  862. $ck = "";
  863. if ($lacetype) {
  864. $where .= " and features like '%-$lacetype-%'";
  865. }
  866. if ($category) {
  867. $where .= " and features like '%-$category-%'";
  868. }
  869. if ($size) {
  870. $where .= " and features like '%-$size-%'";
  871. }
  872. if ($grade) {
  873. $where .= " and features like '%-$grade-%'";
  874. }
  875. if ($color) {
  876. $where .= " and features like '%-$color-%'";
  877. }
  878. if ($lacecolor) {
  879. $where .= " and features like '%-$lacecolor-%'";
  880. }
  881. if ($lowe) {
  882. $where .= " and features like '%-$lowe-%'";
  883. }
  884. if ($haircap) {
  885. $where .= " and features like '%-$haircap-%'";
  886. }
  887. if ($density) {
  888. $where .= " and features like '%-$density-%'";
  889. }
  890. if ($warehouse) {
  891. $where .= " and warehouse = '$warehouse'";
  892. }
  893. if ($details) {
  894. $where .= " and details = '$details'";
  895. }
  896. if ($purchase) {
  897. $where .= " and purchase = '$purchase'";
  898. }
  899. if ($state) {
  900. $where .= " and state = '$state'";
  901. }
  902. if ($ktime && $jtime) {
  903. $gj = " and enter > '$ktime' and enter < '$jtime'";
  904. $ck = " and outk > '$ktime' and outk < '$jtime'";
  905. }
  906. //数据排序
  907. $order_str = "id desc";
  908. if (empty($page)) {
  909. $start = 0;
  910. $perpage = 1;
  911. } else {
  912. $start = ($page - 1) * $perpage;
  913. }
  914. if ($sku) {
  915. $sku = trim($sku, ' ');
  916. $sku = trim($sku, ' ');
  917. $where .= " and sku like '%$sku%'";
  918. } else if ($title) {
  919. $title = trim($title, ' ');
  920. $title = trim($title, ' ');
  921. $where .= " and title like '%$title%'";
  922. }
  923. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  924. //取得信息列表
  925. $t = array();
  926. $typeclass = $this->typeclass->find_all();
  927. foreach ($typeclass as $v) {
  928. $t[$v['id']] = $v;
  929. }
  930. $rows = array();
  931. $list = array();
  932. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  933. foreach ($info_list as $key => $value) {
  934. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  935. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  936. $warehouse = $this->warehouse->read($value['warehouse']);
  937. $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');
  938. $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'] . '"');
  939. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  940. $number = $value['number'];
  941. $ftime = time() - 15 * 24 * 3600;
  942. $z = count($z); //查看订单号
  943. $info_list[$key]['warehouse'] = $warehouse['title'];
  944. $info_list[$key]['features'] = count($c);
  945. $info_list[$key]['number'] = $z;
  946. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  947. $details = array();
  948. $cpid = array();
  949. foreach ($c as $k => $v) {
  950. $details[$v['details']] = $v['details'];
  951. if ($v['cpid'] != 0) {
  952. $cpid[$v['cpid']] = $v['cpid'];
  953. }
  954. }
  955. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  956. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  957. unset($info_list[$key]['pm']);
  958. unset($info_list[$key]['jm']);
  959. unset($info_list[$key]['bm']);
  960. }
  961. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  962. $pagenum = ceil($total / $perpage);
  963. $over = $total - ($start + $perpage);
  964. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  965. echo json_encode($rows);
  966. exit;
  967. }
  968. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  969. $this->_Template('whlabel_typeck', $this->data);
  970. }
  971. //进销存导出
  972. public function _whlabeckdc()
  973. {
  974. $prc = array();
  975. $purchase = $this->purchase->find_all();
  976. foreach ($purchase as $k => $v) {
  977. $prc[$v['id']] = $v['title'];
  978. }
  979. if (isset($_GET['excel'])) {
  980. $where = "sku != 'Preset'";
  981. //数据排序
  982. $order_str = "id desc";
  983. if (empty($page)) {
  984. $start = 0;
  985. $perpage = 1;
  986. } else {
  987. $start = ($page - 1) * $perpage;
  988. }
  989. $category = $this->input->get('category', true);
  990. $color = $this->input->get('color', true);
  991. $lowe = $this->input->get('lowe', true);
  992. $lacetype = $this->input->get('lacetype', true);
  993. $size = $this->input->get('size', true);
  994. $density = $this->input->get('density', true);
  995. $haircap = $this->input->get('haircap', true);
  996. $sku = $this->input->get('sku', true);
  997. $details = $this->input->get('details', true);
  998. $warehouse = 13;
  999. $excelid = $this->input->get('sid', true);
  1000. if ($category) {
  1001. $where .= " and features like '%-$category-%'";
  1002. }
  1003. if ($color) {
  1004. $where .= " and features like '%-$color-%'";
  1005. }
  1006. if ($lowe) {
  1007. $where .= " and features like '%-$lowe-%'";
  1008. }
  1009. if ($lacetype) {
  1010. $where .= " and features like '%-$lacetype-%'";
  1011. }
  1012. if ($size) {
  1013. $where .= " and features like '%-$size-%'";
  1014. }
  1015. if ($density) {
  1016. $where .= " and features like '%-$density-%'";
  1017. }
  1018. if ($haircap) {
  1019. $where .= " and features like '%-$haircap-%'";
  1020. }
  1021. if ($warehouse) {
  1022. $where .= " and warehouse = '$warehouse'";
  1023. }
  1024. if ($sku) {
  1025. $where .= " and sku like '%$sku%'";
  1026. }
  1027. if ($details) {
  1028. $where .= " and details = '$details'";
  1029. }
  1030. $xzid = '';
  1031. if ($excelid) {
  1032. $excelid = explode(',', trim($excelid, ','));
  1033. foreach ($excelid as $key => $value) {
  1034. $xzid .= " id = " . $value . " or";
  1035. }
  1036. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1037. }
  1038. //取得信息列表
  1039. /**
  1040. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1041. $rows = array();$list = array();
  1042. foreach ($info_list as $key=>$value)
  1043. {
  1044. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1045. }
  1046. **/
  1047. $wh = array();
  1048. $w = $this->warehouse->find_all('1=1', 'id,title');
  1049. foreach ($w as $v) {
  1050. $wh[$v['id']] = $v['title'];
  1051. }
  1052. $tc = array();
  1053. $tcdata = array();
  1054. $list = array();
  1055. $classid = $this->classid->sku();
  1056. $tcall = $this->typeclass->find_all();
  1057. $typeclass = array();
  1058. foreach ($tcall as $v)
  1059. {
  1060. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1061. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1062. }
  1063. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1064. foreach ($rows as $key => $value) {
  1065. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1066. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1067. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1068. $rows[$key]['cpbz'] = $u9_info['bm'];
  1069. $rows[$key]['cs'] = $u9_info['jm'];
  1070. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1071. $details = array();
  1072. $cpid = array();
  1073. $cpbz = array();
  1074. $c = 0;
  1075. $g = 0;
  1076. $x = 0;
  1077. $t = 0;
  1078. $s = 0;
  1079. $q = 0;
  1080. foreach ($sd as $k => $v) {
  1081. if ($v['state'] == 0) {
  1082. $c++;
  1083. }
  1084. if ($v['state'] != 9) {
  1085. $g++;
  1086. }
  1087. if ($v['state'] == 1) {
  1088. $x++;
  1089. }
  1090. if ($v['state'] == 2) {
  1091. $t++;
  1092. }
  1093. if ($v['state'] == 8) {
  1094. $s++;
  1095. }
  1096. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1097. $q++;
  1098. }
  1099. $details[$v['details']] = $v['details'];
  1100. if ($v['cpid'] != 0) {
  1101. $cpid[$v['cpid']] = $v['cpid'];
  1102. }
  1103. if ($v['cpbz'] != '') {
  1104. $cpbz[$v['cpbz']] = $v['cpbz'];
  1105. }
  1106. }
  1107. $rows[$key]['details'] = implode("、", $details);
  1108. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1109. $number = $value['number'];
  1110. $ftime = time() - 15 * 24 * 3600;
  1111. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1112. $rows[$key]['number'] = $g;
  1113. $rows[$key]['features'] = $c;
  1114. $rows[$key]['x'] = $x;
  1115. $rows[$key]['t'] = $t;
  1116. $rows[$key]['s'] = $s;
  1117. $rows[$key]['q'] = $q;
  1118. $rows[$key]['wzsl'] = count($details);
  1119. }
  1120. $title = "进销存统计表" . date('Y-m-d', time());
  1121. $titlename = "<table border=1>
  1122. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1123. <tr align='center'>
  1124. <td>仓库</td>
  1125. <td>供应商</td>
  1126. <td>位置</td>
  1127. <td>库存编码</td>
  1128. <td>SKU</td>
  1129. <td>用友编码</td>
  1130. <td>用友料号</td>
  1131. <td>产品英文名</td>
  1132. <td>产品中文名</td>
  1133. <td>入库总量</td>
  1134. <td>库存数量</td>
  1135. <td>销售数量</td>
  1136. <td>退货数量</td>
  1137. <td>删除数量</td>
  1138. <td>其它操作</td>
  1139. <td>位置数量</td>
  1140. </tr>
  1141. </table>";
  1142. $filename = $title . ".xls";
  1143. $tail = "";
  1144. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1145. }
  1146. }
  1147. public function _type()
  1148. {
  1149. $vip = 0;
  1150. if (isset($_SESSION['api'])) {
  1151. $user = $this->user->get_api($_SESSION['api']);
  1152. $fgshop = "";
  1153. $sid = "";
  1154. $usersp = explode('|', trim($user['shop'], '|'));
  1155. foreach ($usersp as $value) {
  1156. $fgshop .= " shop = " . $value . " or";
  1157. $sid .= " id = " . $value . " or";
  1158. }
  1159. if ($user['vip'] == 1) {
  1160. $vip = 1;
  1161. }
  1162. } else {
  1163. header('Location: /');
  1164. exit;
  1165. }
  1166. $prc = array();
  1167. $purchase = $this->purchase->find_all();
  1168. foreach ($purchase as $k => $v) {
  1169. $prc[$v['id']] = $v['title'];
  1170. }
  1171. $company = array();
  1172. $ct = $this->company->find_all();
  1173. foreach ($ct as $k => $v) {
  1174. $company[$v['id']] = $v['title'];
  1175. }
  1176. $sp = array();
  1177. $s = $this->shop->find_all('1=1', 'id,shopname');
  1178. foreach ($s as $v) {
  1179. $sp[$v['id']] = $v['shopname'];
  1180. }
  1181. $wh = array();
  1182. $w = $this->warehouse->find_all('1=1', 'id,title');
  1183. foreach ($w as $v) {
  1184. $wh[$v['id']] = $v['title'];
  1185. }
  1186. $post = $this->input->post(NULL, TRUE);
  1187. if (isset($post['page'])) {
  1188. $page = $this->input->post('page', true);
  1189. $perpage = $this->input->post('perpage', true);
  1190. $category = $this->input->post('category', true);
  1191. $size = $this->input->post('size', true);
  1192. $grade = $this->input->post('grade', true);
  1193. $color = $this->input->post('color', true);
  1194. $lowe = $this->input->post('lowe', true);
  1195. $sku = $this->input->post('sku');
  1196. $title = $this->input->post('title');
  1197. $warehouse = $this->input->post('warehouse', true);
  1198. $usa = $this->input->post('usa', true);
  1199. $purchase = $this->input->post('purchase', true);
  1200. $lacetype = $this->input->post('lacetype', true);
  1201. $haircap = $this->input->post('haircap', true);
  1202. $density = $this->input->post('density', true);
  1203. $details = $this->input->post('details', true);
  1204. $state = $this->input->post('state', true);
  1205. $shop = $this->input->post('shop', true);
  1206. $lacecolor = $this->input->post('lacecolor', true);
  1207. $hairnumber = $this->input->post('hairnumber', true);
  1208. $type = $this->input->post('type', true);
  1209. $ktime = $this->input->post('ktime', true);
  1210. $jtime = $this->input->post('jtime', true);
  1211. $ktime = strtotime($ktime);
  1212. $jtime = strtotime($jtime);
  1213. $cpbz = $this->input->post('cpbz', true);
  1214. $sm = $this->input->post('sm', true);
  1215. $where = "1=1";
  1216. $gj = "";
  1217. $ck = "";
  1218. if ($usa) {
  1219. if (!$warehouse) {
  1220. $where .= " and (warehouse = '5' or warehouse = '8')";
  1221. }
  1222. }
  1223. if ($warehouse) {
  1224. $where .= " and warehouse = '$warehouse'";
  1225. }
  1226. if ($details) {
  1227. $where .= " and details = '$details'";
  1228. }
  1229. if ($purchase) {
  1230. $where .= " and purchase = '$purchase'";
  1231. }
  1232. if ($state) {
  1233. $where .= " and state = '$state'";
  1234. }
  1235. if ($shop) {
  1236. $where .= " and shop like '%$shop%'";
  1237. }
  1238. if ($type) {
  1239. $where .= " and type = '$type'";
  1240. }
  1241. if ($ktime && $jtime) {
  1242. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1243. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1244. }
  1245. if ($cpbz) {
  1246. $where .= " and cpbz like '%$cpbz%' ";
  1247. }
  1248. if ($sm) {
  1249. $where .= " and sm like '%$sm%' ";
  1250. }
  1251. if ($lacecolor) {
  1252. $where .= " and features like '%-$lacecolor-%'";
  1253. }
  1254. if ($lacetype) {
  1255. $where .= " and features like '%-$lacetype-%'";
  1256. }
  1257. if ($category) {
  1258. $where .= " and features like '%-$category-%'";
  1259. }
  1260. if ($size) {
  1261. $where .= " and features like '%-$size-%'";
  1262. }
  1263. if ($grade) {
  1264. $where .= " and features like '%-$grade-%'";
  1265. }
  1266. if ($color) {
  1267. $where .= " and features like '%-$color-%'";
  1268. }
  1269. if ($lowe) {
  1270. $where .= " and features like '%-$lowe-%'";
  1271. }
  1272. if ($haircap) {
  1273. $where .= " and features like '%-$haircap-%'";
  1274. }
  1275. if ($density) {
  1276. $where .= " and features like '%-$density-%'";
  1277. }
  1278. if (!empty($hairnumber)) {
  1279. $where .= " and features like '%-128-%' ";
  1280. if ($hairnumber < 0) {
  1281. $class_list = $this->typeclass->find_all('classid = 43');
  1282. foreach ($class_list as $v) {
  1283. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1284. }
  1285. } else {
  1286. $where .= " and features like '%-$hairnumber-%'";
  1287. }
  1288. }
  1289. //数据排序
  1290. $order_str = "id desc";
  1291. if (empty($page)) {
  1292. $start = 0;
  1293. $perpage = 1;
  1294. } else {
  1295. $start = ($page - 1) * $perpage;
  1296. }
  1297. $fjnr = '';
  1298. if ($sku) {
  1299. $sku = trim($sku, ' ');
  1300. $sku = trim($sku, ' ');
  1301. $fjnr .= " and sku like '%$sku%'";
  1302. }
  1303. if ($title) {
  1304. $title = trim($title, ' ');
  1305. $title = trim($title, ' ');
  1306. $fjnr .= " and title like '%$title%'";
  1307. }
  1308. $wt = array();
  1309. $whlabel_type = $this->whlabel_type->find_all();
  1310. foreach ($whlabel_type as $v) {
  1311. $wt[$v['id']] = $v['title'];
  1312. }
  1313. //$where .= " and time > '$ktime' and time < '$jtime'";
  1314. $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
  1315. //取得信息列表
  1316. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1317. $rows = array();
  1318. $list = array();
  1319. foreach ($info_list as $key => $value) {
  1320. if (isset($wt[$value['type']])) {
  1321. $info_list[$key]['type'] = $wt[$value['type']];
  1322. } else {
  1323. $info_list[$key]['type'] = '未设置';
  1324. }
  1325. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1326. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1327. $ztdata = '';
  1328. if (count($zt) > 0) {
  1329. foreach ($zt as $vv) {
  1330. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1331. }
  1332. }
  1333. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1334. $cdata = array_filter($qbdata, function ($item) {
  1335. return $item['state'] < 1;
  1336. });
  1337. $c = array_sum(array_column($cdata, 'jnum'));
  1338. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1339. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1340. });
  1341. $g = array_sum(array_column($gdata, 'jnum'));
  1342. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1343. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1344. });
  1345. $x = array_sum(array_column($xdata, 'jnum'));
  1346. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1347. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1348. });
  1349. $t = array_sum(array_column($tdata, 'jnum'));
  1350. $zdata = array_filter($qbdata, function ($item) {
  1351. return $item['zd'] != "" && $item['state'] < 1;
  1352. });
  1353. $z = array_sum(array_column($zdata, 'jnum'));
  1354. $zdata = array_filter($qbdata, function ($item) {
  1355. return $item['zd'] != "" && $item['state'] < 1;
  1356. });
  1357. $z = array_sum(array_column($zdata, 'jnum'));
  1358. //$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');
  1359. //$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'].'"');
  1360. //$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'].'"');
  1361. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1362. //$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'].'"');
  1363. $details = array();
  1364. $cpid = array();
  1365. $od = array();
  1366. $odid = '';
  1367. $companytitle = '';
  1368. $shop_list = [];
  1369. foreach ($qbdata as $v) {
  1370. if ($v['zd'] != "" && $v['state'] < 1) {
  1371. if (!isset($od[$v['zd']])) {
  1372. $od[$v['zd']] = 1; //所有数据sku
  1373. } else {
  1374. $od[$v['zd']] = $od[$v['zd']] + 1;
  1375. }
  1376. }
  1377. if ($v['state'] < 1) {
  1378. $details[$v['details']] = $v['details'];
  1379. if ($v['cpid'] != 0) {
  1380. $cpid[$v['cpid']] = $v['cpid'];
  1381. }
  1382. }
  1383. if($v['state'] == 0){
  1384. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1385. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1386. }
  1387. if ($v['shop'] != '') {
  1388. $shop = explode(',', trim($v['shop'], ','));
  1389. foreach ($shop as $vv) {
  1390. if (!in_array($vv, $shop_list)) {
  1391. $shop_list[] = $vv;
  1392. }
  1393. }
  1394. }
  1395. }
  1396. }
  1397. foreach ($od as $k => $vv) {
  1398. $odid .= $k . '数量' . $vv;
  1399. }
  1400. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1401. $info_list[$key]['label'] = $value['sm'];
  1402. $number = $value['number'];
  1403. $ftime = time() - 15 * 24 * 3600;
  1404. $z = $z . '(' . $odid . ')'; //查看订单号
  1405. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1406. $info_list[$key]['features'] = $c;
  1407. $info_list[$key]['number'] = $ztdata;
  1408. $info_list[$key]['sm'] = $g;
  1409. $info_list[$key]['x'] = $x;
  1410. $info_list[$key]['t'] = $t;
  1411. $info_list[$key]['z'] = $z;
  1412. /**
  1413. foreach ($cdata as $k=>$v)
  1414. {
  1415. $details[$v['details']] = $v['details'];
  1416. if($v['cpid'] != 0)
  1417. {
  1418. $cpid[$v['cpid']] = $v['cpid'];
  1419. }
  1420. }
  1421. **/
  1422. $info_list[$key]['shop'] = '';
  1423. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1424. // if ($value['shop'] != '') {
  1425. // $shop = explode(',', trim($value['shop'], ','));
  1426. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1427. // }
  1428. $shop_list = array_unique($shop_list);
  1429. $shop_str = '';
  1430. foreach ($shop_list as $v) {
  1431. if(isset($sp[$v])){
  1432. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1433. }
  1434. }
  1435. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1436. /**
  1437. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1438. if(isset($companytitle[0]))
  1439. {
  1440. foreach ($companytitle as $k=>$v)
  1441. {
  1442. if($v['companytitle'] != '')
  1443. {
  1444. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1445. }
  1446. }
  1447. }
  1448. **/
  1449. }
  1450. $final_all_list = [];
  1451. foreach ($info_list as $k => $v) {
  1452. $final_all_list[] = [
  1453. 'id' => $v['id'],
  1454. "warehouse" => $v["warehouse"],
  1455. "purchase" => $v["purchase"],
  1456. "sku" => $v["sku"],
  1457. "title" => $v["title"] . "<br/>" . $v["pm"],
  1458. "details" => $v["details"],
  1459. "shop" => $v["shop"],
  1460. "cpbz" => $v["cpbz"],
  1461. 'label' => $v['label'],
  1462. "type" => $v["type"],
  1463. "features" => $v["features"],
  1464. "number" => $v["number"],
  1465. "sm" => $v["sm"],
  1466. "x" => $v["x"],
  1467. "t" => $v["t"],
  1468. "z" => $v["z"]
  1469. ];
  1470. }
  1471. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1472. $pagenum = ceil($total / $perpage);
  1473. $over = $total - ($start + $perpage);
  1474. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1475. echo json_encode($rows);
  1476. exit;
  1477. }
  1478. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1479. $this->data['shop'] = $wlshop;
  1480. $this->data['vip'] = $vip;
  1481. $this->_Template('whlabel_type', $this->data);
  1482. }
  1483. //美仓进销存浏览
  1484. public function _usatype()
  1485. {
  1486. if (isset($_SESSION['api'])) {
  1487. $user = $this->user->get_api($_SESSION['api']);
  1488. $usp = $user;
  1489. $fgshop = "";
  1490. $sid = "";
  1491. $wid = "";
  1492. $wtype = "";
  1493. $userwh = explode('|', trim($user['warehouse'], '|'));
  1494. foreach ($userwh as $value) {
  1495. $wid .= " id = " . $value . " or";
  1496. $wtype .= " type = " . $value . " or";
  1497. }
  1498. }
  1499. $prc = array();
  1500. $purchase = $this->purchase->find_all();
  1501. foreach ($purchase as $k => $v) {
  1502. $prc[$v['id']] = $v['title'];
  1503. }
  1504. $post = $this->input->post(NULL, TRUE);
  1505. if (isset($post['page'])) {
  1506. $page = $this->input->post('page', true);
  1507. $perpage = $this->input->post('perpage', true);
  1508. $category = $this->input->post('category', true);
  1509. $size = $this->input->post('size', true);
  1510. $grade = $this->input->post('grade', true);
  1511. $color = $this->input->post('color', true);
  1512. $lowe = $this->input->post('lowe', true);
  1513. $sku = $this->input->post('sku');
  1514. $title = $this->input->post('title');
  1515. $warehouse = $this->input->post('warehouse', true);
  1516. $usa = $this->input->post('usa', true);
  1517. $purchase = $this->input->post('purchase', true);
  1518. $lacetype = $this->input->post('lacetype', true);
  1519. $haircap = $this->input->post('haircap', true);
  1520. $density = $this->input->post('density', true);
  1521. $details = $this->input->post('details', true);
  1522. $state = $this->input->post('state', true);
  1523. $lacecolor = $this->input->post('lacecolor', true);
  1524. $cklx = $this->input->post('cklx', true);
  1525. $ktime = $this->input->post('ktime', true);
  1526. $jtime = $this->input->post('jtime', true);
  1527. $ktime = strtotime($ktime);
  1528. $jtime = strtotime($jtime);
  1529. $where = "1=1";
  1530. $gj = "";
  1531. $ck = "";
  1532. if ($lacetype) {
  1533. $where .= " and features like '%-$lacetype-%'";
  1534. }
  1535. if ($category) {
  1536. $where .= " and features like '%-$category-%'";
  1537. }
  1538. if ($size) {
  1539. $where .= " and features like '%-$size-%'";
  1540. }
  1541. if ($grade) {
  1542. $where .= " and features like '%-$grade-%'";
  1543. }
  1544. if ($color) {
  1545. $where .= " and features like '%-$color-%'";
  1546. }
  1547. if ($lowe) {
  1548. $where .= " and features like '%-$lowe-%'";
  1549. }
  1550. if ($haircap) {
  1551. $where .= " and features like '%-$haircap-%'";
  1552. }
  1553. if ($density) {
  1554. $where .= " and features like '%-$density-%'";
  1555. }
  1556. if ($lacecolor) {
  1557. $where .= " and features like '%-$lacecolor-%'";
  1558. }
  1559. if ($usa) {
  1560. if (!$warehouse) {
  1561. $where .= " and (warehouse = '5' or warehouse = '8')";
  1562. }
  1563. }
  1564. if ($warehouse) {
  1565. $where .= " and warehouse = '$warehouse'";
  1566. }
  1567. if ($details) {
  1568. $where .= " and details = '$details'";
  1569. }
  1570. if ($purchase) {
  1571. $where .= " and purchase = '$purchase'";
  1572. }
  1573. if ($state) {
  1574. $where .= " and state = '$state'";
  1575. }
  1576. $where_add = '';
  1577. if ($cklx) {
  1578. $shop = $this->shop->read($cklx);
  1579. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1580. }
  1581. if ($ktime && $jtime) {
  1582. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1583. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1584. }
  1585. //数据排序
  1586. $order_str = "id desc";
  1587. if (empty($page)) {
  1588. $start = 0;
  1589. $perpage = 1;
  1590. } else {
  1591. $start = ($page - 1) * $perpage;
  1592. }
  1593. if ($sku) {
  1594. $sku = trim($sku, ' ');
  1595. $sku = trim($sku, ' ');
  1596. $where .= " and sku like '%$sku%'";
  1597. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1598. } else if ($title) {
  1599. $title = trim($title, ' ');
  1600. $title = trim($title, ' ');
  1601. $where .= " and title like '%$title%'";
  1602. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1603. } else {
  1604. //$where .= " and time > '$ktime' and time < '$jtime'";
  1605. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1606. }
  1607. //取得信息列表
  1608. $rows = array();
  1609. $list = array();
  1610. foreach ($info_list as $key => $value) {
  1611. $warehouse = $this->warehouse->read($value['warehouse']);
  1612. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1613. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1614. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1615. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1616. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1617. $od = array();
  1618. $odid = '';
  1619. foreach ($z as $v) {
  1620. if (!isset($od[$v['zd']])) {
  1621. $od[$v['zd']] = 1; //所有数据sku
  1622. } else {
  1623. $od[$v['zd']] = $od[$v['zd']] + 1;
  1624. }
  1625. }
  1626. foreach ($od as $k => $vv) {
  1627. $odid .= $k . '数量' . $vv . ' ';
  1628. }
  1629. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1630. $info_list[$key]['features'] = $c;
  1631. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1632. $ztdata = '';
  1633. if (count($zt) > 0) {
  1634. foreach ($zt as $vv) {
  1635. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1636. }
  1637. }
  1638. $info_list[$key]['warehouse'] = $ztdata;
  1639. $info_list[$key]['g'] = $g;
  1640. $info_list[$key]['x'] = $x;
  1641. $info_list[$key]['t'] = $t;
  1642. $info_list[$key]['z'] = $z;
  1643. }
  1644. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1645. $pagenum = ceil($total / $perpage);
  1646. $over = $total - ($start + $perpage);
  1647. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1648. echo json_encode($rows);
  1649. exit;
  1650. }
  1651. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1652. $this->data['warehouse'] = $warehouse;
  1653. $this->_Template('whlabel_typeusa', $this->data);
  1654. }
  1655. //美仓进销存浏览
  1656. public function _usatypeapp()
  1657. {
  1658. $post = $this->input->post(NULL, TRUE);
  1659. if (isset($post['page'])) {
  1660. $page = $this->input->post('page', true);
  1661. $perpage = $this->input->post('perpage', true);
  1662. $sku = $this->input->post('sku', true);
  1663. $warehouse = 5;
  1664. $title = $this->input->post('title', true);
  1665. $state = $this->input->post('state', true);
  1666. $ktime = $this->input->post('ktime', true);
  1667. $jtime = $this->input->post('jtime', true);
  1668. $ktime = strtotime($ktime);
  1669. $jtime = strtotime($jtime);
  1670. $where = "1=1";
  1671. $gj = "";
  1672. $ck = "";
  1673. if ($title) {
  1674. $st = explode(' ', trim($title, ' '));
  1675. foreach ($st as $v) {
  1676. $where .= " and title like '%$v%'";
  1677. }
  1678. }
  1679. if ($warehouse) {
  1680. $where .= " and warehouse = '$warehouse'";
  1681. }
  1682. if ($state) {
  1683. $where .= " and state = '$state'";
  1684. }
  1685. if ($sku) {
  1686. $where .= " and sku like '%$sku%'";
  1687. }
  1688. if ($ktime && $jtime) {
  1689. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1690. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1691. }
  1692. //数据排序
  1693. $order_str = "id desc";
  1694. if (empty($page)) {
  1695. $start = 0;
  1696. $perpage = 1;
  1697. } else {
  1698. $start = ($page - 1) * $perpage;
  1699. }
  1700. //取得信息列表
  1701. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1702. $rows = array();
  1703. $list = array();
  1704. foreach ($info_list as $key => $value) {
  1705. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1706. }
  1707. $rowsdq = array_slice($rows, $start, $perpage);
  1708. foreach ($rowsdq as $value) {
  1709. $warehouse = $this->warehouse->read($value['warehouse']);
  1710. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1711. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1712. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1713. $od = array();
  1714. $odid = '';
  1715. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1716. }
  1717. $total = count($rows);
  1718. $pagenum = ceil($total / $perpage);
  1719. $over = $total - ($start + $perpage);
  1720. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1721. echo json_encode($rows);
  1722. exit;
  1723. }
  1724. $this->_Template('phone/p_usatypeapp', $this->data);
  1725. }
  1726. //入库操作
  1727. public function _enteradd()
  1728. {
  1729. $dt = 0;
  1730. if (isset($_SESSION['api'])) {
  1731. $user = $this->user->get_api($_SESSION['api']);
  1732. $usp = $user;
  1733. $fgshop = "";
  1734. $sid = "";
  1735. $user = explode('|', trim($user['shop'], '|'));
  1736. foreach ($user as $value) {
  1737. $fgshop .= " shop = " . $value . " or";
  1738. $sid .= " id = " . $value . " or";
  1739. }
  1740. }
  1741. $tc = $this->typeclass->find_all();
  1742. $typeclass = array();
  1743. foreach ($tc as $v) {
  1744. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1745. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1746. }
  1747. $post = $this->input->post(NULL, TRUE);
  1748. if (isset($post['sku'])) {
  1749. $list = array();
  1750. $num = "";
  1751. $title = "";
  1752. $features = "";
  1753. $order = $this->input->post('order', true);
  1754. $shop = $this->input->post('shop', true);
  1755. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1756. $sku = $this->input->post('sku', true);
  1757. $post['sm'] = $this->input->post('sm', true);
  1758. $post['warehouse'] = $this->input->post('warehouse', true);
  1759. $post['purchase'] = $this->input->post('purchase', true);
  1760. $post['retreatwarehouse'] = $post['warehouse'];
  1761. $post['state'] = $this->input->post('state', true);
  1762. $post['rktype'] = $this->input->post('rktype', true);
  1763. $post['text'] = $this->input->post('text', true);
  1764. $category = $this->input->post('category', true);
  1765. $list['category'] = $category;
  1766. $list['hairtype'] = $this->input->post('hairtype', true);
  1767. $list['grade'] = $this->input->post('grade', true);
  1768. $size = $this->input->post('size', true);
  1769. $xzsku = $this->input->post('xzsku', true);
  1770. $list['size'] = rtrim($size, ',');
  1771. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1772. $list['extension'] = $this->input->post('extension', true);
  1773. if ($category == 1297) {
  1774. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1775. }
  1776. if ($category == 1702) {
  1777. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1778. $list['syother'] = $this->input->post('syother', true);
  1779. }
  1780. if ($category == 133) {
  1781. $list['fittype'] = $this->input->post('fittype', true);
  1782. $list['acother'] = $this->input->post('acother', true);
  1783. }
  1784. $list['color'] = $this->input->post('color', true);
  1785. $list['lowe'] = $this->input->post('lowe', true);
  1786. if (!$post['purchase']) {
  1787. $post['purchase'] = 1;
  1788. }
  1789. if ($category == 127) {
  1790. $list['type'] = $this->input->post('type', true);
  1791. $list['headroad'] = $this->input->post('headroad', true);
  1792. $list['density'] = $this->input->post('density', true);
  1793. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1794. $list['lacesize'] = $this->input->post('lacesize', true);
  1795. }
  1796. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1797. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1798. }
  1799. if ($category == 128) {
  1800. $list['lacetype'] = $this->input->post('lacetype', true);
  1801. $list['haircap'] = $this->input->post('haircap', true);
  1802. $list['density'] = $this->input->post('density', true);
  1803. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1804. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1805. $list['wigother'] = $this->input->post('wigother', true);
  1806. $list['wigother1'] = $this->input->post('wigother1', true);
  1807. $list['wigother2'] = $this->input->post('wigother2', true);
  1808. }
  1809. if ($category == 129) {
  1810. $list['wide'] = $this->input->post('wide', true);
  1811. }
  1812. if ($category == 131) {
  1813. $list['gifttype'] = $this->input->post('gifttype', true);
  1814. $list['giftother'] = $this->input->post('giftother', true);
  1815. }
  1816. if ($category == 134) {
  1817. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1818. }
  1819. if ($category == 1297) {
  1820. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1821. $list['sywigother'] = $this->input->post('sywigother', true);
  1822. }
  1823. if ($category == 130 || $category == 133 || $category == 1702) {
  1824. $list['items'] = $this->input->post('items', true);
  1825. $list['weight'] = $this->input->post('weight', true);
  1826. }
  1827. if ($category == 1702) {
  1828. $list['syhairther'] = $this->input->post('syhairther', true);
  1829. }
  1830. $classid = $this->classid->sku();
  1831. $scsku = $classid;
  1832. $pm = $classid;
  1833. foreach ($list as $k => $v) {
  1834. if ($v != 0) {
  1835. $num .= $v;
  1836. $features .= $v . '-';
  1837. $post[$k] = $v;
  1838. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1839. if ($k != 'size') {
  1840. $title .= $typeclass[$v]['title'] . " ";
  1841. }
  1842. if (isset($pm[$typeclass[$v]['classid']])) {
  1843. if ($typeclass[$v]['title'] == '9A') {
  1844. $pm[$typeclass[$v]['classid']] = '9A';
  1845. } else if ($typeclass[$v]['title'] == '10A') {
  1846. $pm[$typeclass[$v]['classid']] = '10A';
  1847. } else {
  1848. $clzh = $typeclass[$v]['zh'];
  1849. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1850. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1851. $clzh = $clzh[0];
  1852. }
  1853. $pm[$typeclass[$v]['classid']] = $clzh;
  1854. }
  1855. }
  1856. }
  1857. }
  1858. $zh = implode(" ", $pm);
  1859. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1860. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1861. if ($list['size']) {
  1862. $typeclass = $this->typeclass->read($list['size']);
  1863. $title .= $typeclass['title'];
  1864. }
  1865. $time = time();
  1866. if ($xzsku) {
  1867. $scsku = implode("-", $scsku);
  1868. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1869. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1870. $post['sku'] = trim($scsku, ' ');
  1871. } else {
  1872. $post['sku'] = $sku;
  1873. }
  1874. //$post['sku'] = trim($sku,' ');
  1875. $post['title'] = rtrim($title, ' ');
  1876. $post['number'] = $num;
  1877. $post['features'] = '-' . $features;
  1878. $post['enter'] = $time;
  1879. $post['time'] = $time; //操作时间
  1880. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1881. if ($yza) {
  1882. if ($post['features'] != $yza[0]['features']) {
  1883. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1884. exit;
  1885. }
  1886. }
  1887. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1888. if ($yzb) {
  1889. if ($post['sku'] != $yzb[0]['sku']) {
  1890. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1891. exit;
  1892. }
  1893. }
  1894. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1895. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1896. exit;
  1897. }
  1898. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1899. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1900. exit;
  1901. }
  1902. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1903. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1904. exit;
  1905. }
  1906. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1907. if (isset($yz[0]['type'])) {
  1908. $post['type'] = $yz[0]['type'];
  1909. }
  1910. if ($post['state'] == 9) //如果选择预设库存
  1911. {
  1912. $this->whlabel->insert($post);
  1913. } else {
  1914. /**
  1915. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1916. if($ljg == 1)
  1917. {
  1918. for($i=0;$i<$order;$i++)
  1919. {
  1920. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1921. $this->whlabel->insert($post);
  1922. }
  1923. }
  1924. **/
  1925. //if($post['warehouse'] == '5')
  1926. //{
  1927. //}
  1928. $yydata = $post;
  1929. $yydata['zh'] = $zh;
  1930. /**
  1931. $wl = $this->apiyy->get_cjlp($yydata);
  1932. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1933. {
  1934. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1935. }
  1936. if($wl['Data'][0]['m_isSucess'] != 1)
  1937. {
  1938. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1939. }
  1940. **/
  1941. for ($i = 0; $i < $order; $i++) {
  1942. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1943. $this->whlabel->insert($post);
  1944. }
  1945. }
  1946. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1947. exit;
  1948. }
  1949. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1950. $this->data['wlshop'] = $wlshop;
  1951. $this->_Template('whlabel_enteradd', $this->data);
  1952. }
  1953. //修改产品
  1954. public function _enteredit($arg_array)
  1955. {
  1956. $dt = 0;
  1957. if (isset($_SESSION['api'])) {
  1958. $user = $this->user->get_api($_SESSION['api']);
  1959. $usp = $user;
  1960. $fgshop = "";
  1961. $sid = "";
  1962. $user = explode('|', trim($user['shop'], '|'));
  1963. foreach ($user as $value) {
  1964. $fgshop .= " shop = " . $value . " or";
  1965. $sid .= " id = " . $value . " or";
  1966. }
  1967. }
  1968. $post = $this->input->post(NULL, TRUE);
  1969. if (isset($post['sku'])) {
  1970. $list = array();
  1971. $num = "";
  1972. $title = "";
  1973. $features = "";
  1974. $id = $this->input->post('id', true);
  1975. $order = $this->input->post('order', true);
  1976. $shop = $this->input->post('shop', true);
  1977. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1978. $post['sku'] = $this->input->post('sku', true);
  1979. $post['sm'] = $this->input->post('sm', true);
  1980. $post['warehouse'] = $this->input->post('warehouse', true);
  1981. $post['purchase'] = $this->input->post('purchase', true);
  1982. $post['retreatwarehouse'] = $post['warehouse'];
  1983. $category = $this->input->post('category', true);
  1984. $list['category'] = $category;
  1985. $list['hairtype'] = $this->input->post('hairtype', true);
  1986. $list['grade'] = $this->input->post('grade', true);
  1987. $size = $this->input->post('size', true);
  1988. $list['size'] = rtrim($size, ',');
  1989. $post['rktype'] = $this->input->post('rktype', true);
  1990. $post['text'] = $this->input->post('text', true);
  1991. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1992. $list['extension'] = $this->input->post('extension', true);
  1993. if ($category == 1297) {
  1994. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1995. }
  1996. if ($category == 1702) {
  1997. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1998. $list['syother'] = $this->input->post('syother', true);
  1999. }
  2000. if ($category == 133) {
  2001. $list['fittype'] = $this->input->post('fittype', true);
  2002. $list['acother'] = $this->input->post('acother', true);
  2003. }
  2004. $list['color'] = $this->input->post('color', true);
  2005. $list['lowe'] = $this->input->post('lowe', true);
  2006. if (!$post['purchase']) {
  2007. $post['purchase'] = 1;
  2008. }
  2009. if ($category == 127) {
  2010. $list['type'] = $this->input->post('type', true);
  2011. $list['headroad'] = $this->input->post('headroad', true);
  2012. $list['density'] = $this->input->post('density', true);
  2013. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2014. $list['lacesize'] = $this->input->post('lacesize', true);
  2015. }
  2016. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2017. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2018. }
  2019. if ($category == 128) {
  2020. $list['lacetype'] = $this->input->post('lacetype', true);
  2021. $list['haircap'] = $this->input->post('haircap', true);
  2022. $list['density'] = $this->input->post('density', true);
  2023. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2024. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2025. $list['wigother'] = $this->input->post('wigother', true);
  2026. $list['wigother1'] = $this->input->post('wigother1', true);
  2027. $list['wigother2'] = $this->input->post('wigother2', true);
  2028. }
  2029. if ($category == 129) {
  2030. $list['wide'] = $this->input->post('wide', true);
  2031. }
  2032. if ($category == 131) {
  2033. $list['gifttype'] = $this->input->post('gifttype', true);
  2034. $list['giftother'] = $this->input->post('giftother', true);
  2035. }
  2036. if ($category == 134) {
  2037. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2038. }
  2039. if ($category == 1297) {
  2040. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2041. $list['sywigother'] = $this->input->post('sywigother', true);
  2042. }
  2043. if ($category == 130 || $category == 133 || $category == 1702) {
  2044. $list['items'] = $this->input->post('items', true);
  2045. $list['weight'] = $this->input->post('weight', true);
  2046. }
  2047. if ($category == 1702) {
  2048. $list['syhairther'] = $this->input->post('syhairther', true);
  2049. }
  2050. foreach ($list as $k => $v) {
  2051. if ($v != 0) {
  2052. $num .= $v;
  2053. $features .= $v . '-';
  2054. $typeclass = $this->typeclass->read($v);
  2055. if ($k != 'size') {
  2056. $title .= $typeclass['title'] . " ";
  2057. }
  2058. }
  2059. }
  2060. $typeclass = $this->typeclass->read($list['size']);
  2061. $title .= $typeclass['title'];
  2062. $time = time();
  2063. $post['title'] = rtrim($title, ' ');
  2064. $post['number'] = $num;
  2065. $post['features'] = '-' . $features;
  2066. $post['time'] = $time; //操作时间
  2067. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2068. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2069. exit;
  2070. }
  2071. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2072. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2073. exit;
  2074. }
  2075. $uid = $this->whlabel->read($id);
  2076. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2077. if ($datanum > 0) {
  2078. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2079. exit;
  2080. }
  2081. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2082. {
  2083. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2084. if ($yza) {
  2085. if ($post['features'] != $yza[0]['features']) {
  2086. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2087. exit;
  2088. }
  2089. }
  2090. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2091. if ($yzb) {
  2092. if ($post['sku'] != $yzb[0]['sku']) {
  2093. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2094. exit;
  2095. }
  2096. }
  2097. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2098. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2099. exit;
  2100. }
  2101. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2102. foreach ($data as $v) {
  2103. $post['id'] = $v['id'];
  2104. $this->whlabel->save($post, $v['id']);
  2105. }
  2106. } else {
  2107. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2108. if ($data > 0) {
  2109. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2110. exit;
  2111. } else {
  2112. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2113. foreach ($data as $v) {
  2114. $post['id'] = $v['id'];
  2115. $this->whlabel->save($post, $v['id']);
  2116. }
  2117. }
  2118. }
  2119. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2120. exit;
  2121. }
  2122. $uid = $this->whlabel->read($arg_array[0]);
  2123. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2124. $this->data['enter'] = $uid;
  2125. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2126. $this->data['wlshop'] = $wlshop;
  2127. $this->_Template('whlabel_enteredit', $this->data);
  2128. }
  2129. //入库浏览
  2130. public function _enter()
  2131. {
  2132. $post = $this->input->post(NULL, TRUE);
  2133. if (isset($post['s'])) {
  2134. $id_arr = $this->input->post('s');
  2135. $id_arr = explode(',', $id_arr);
  2136. if (!$id_arr) {
  2137. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2138. exit;
  2139. }
  2140. //循环删除记录
  2141. foreach ($id_arr as $v) {
  2142. $sid = $this->whlabel->read($v);
  2143. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2144. if ($count > 0) {
  2145. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2146. exit;
  2147. }
  2148. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2149. foreach ($info_list as $va) {
  2150. $this->whlabel->remove($va['id']);
  2151. }
  2152. }
  2153. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2154. exit;
  2155. }
  2156. $sp = array();
  2157. $s = $this->shop->find_all('1=1', 'id,shopname');
  2158. foreach ($s as $v) {
  2159. $sp[$v['id']] = $v['shopname'];
  2160. }
  2161. $wh = array();
  2162. $w = $this->warehouse->find_all('1=1', 'id,title');
  2163. foreach ($w as $v) {
  2164. $wh[$v['id']] = $v['title'];
  2165. }
  2166. if (isset($post['page'])) {
  2167. $page = $this->input->post('page', true);
  2168. $perpage = $this->input->post('perpage', true);
  2169. $category = $this->input->post('category', true);
  2170. $size = $this->input->post('size', true);
  2171. $grade = $this->input->post('grade', true);
  2172. $color = $this->input->post('color', true);
  2173. $lowe = $this->input->post('lowe', true);
  2174. $sku = $this->input->post('sku', true);
  2175. $warehouse = $this->input->post('warehouse', true);
  2176. $purchase = $this->input->post('purchase', true);
  2177. $ktime = $this->input->post('ktime', true);
  2178. $jtime = $this->input->post('jtime', true);
  2179. $ktime = strtotime($ktime);
  2180. $jtime = strtotime($jtime);
  2181. $where = "1=1";
  2182. $gj = "";
  2183. $ck = "";
  2184. if ($category) {
  2185. $where .= " and features like '%-$category-%'";
  2186. }
  2187. if ($size) {
  2188. $where .= " and features like '%-$size-%'";
  2189. }
  2190. if ($grade) {
  2191. $where .= " and features like '%-$grade-%'";
  2192. }
  2193. if ($color) {
  2194. $where .= " and features like '%-$color-%'";
  2195. }
  2196. if ($lowe) {
  2197. $where .= " and features like '%-$lowe-%'";
  2198. }
  2199. if ($warehouse) {
  2200. $where .= " and warehouse = '$warehouse'";
  2201. }
  2202. if ($purchase) {
  2203. $where .= " and purchase = '$purchase'";
  2204. }
  2205. if ($sku) {
  2206. $where .= " and sku like '%$sku%'";
  2207. }
  2208. if ($ktime && $jtime) {
  2209. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2210. }
  2211. //数据排序
  2212. $order_str = "enter desc";
  2213. if (empty($page)) {
  2214. $start = 0;
  2215. $perpage = 1;
  2216. } else {
  2217. $start = ($page - 1) * $perpage;
  2218. }
  2219. //取得信息列表
  2220. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2221. foreach ($info_list as $k => $v) {
  2222. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2223. if ($v['shop'] == '') {
  2224. $s = '通用';
  2225. } else {
  2226. $info_list[$k]['shop'] = '';
  2227. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2228. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2229. }
  2230. }
  2231. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2232. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2233. $info_list[$k]['g'] = $g;
  2234. }
  2235. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2236. $total = count($this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,sku,title,features,number'));
  2237. $pagenum = ceil($total / $perpage);
  2238. $over = $total - ($start + $perpage);
  2239. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2240. echo json_encode($rows);
  2241. exit;
  2242. }
  2243. $this->_Template('whlabel_enter', $this->data);
  2244. }
  2245. //出库浏览
  2246. public function _out()
  2247. {
  2248. $post = $this->input->post(NULL, TRUE);
  2249. if (isset($post['page'])) {
  2250. $page = $this->input->post('page', true);
  2251. $perpage = $this->input->post('perpage', true);
  2252. $category = $this->input->post('category', true);
  2253. $size = $this->input->post('size', true);
  2254. $grade = $this->input->post('grade', true);
  2255. $color = $this->input->post('color', true);
  2256. $lowe = $this->input->post('lowe', true);
  2257. $sku = $this->input->post('sku', true);
  2258. $warehouse = $this->input->post('warehouse', true);
  2259. $purchase = $this->input->post('purchase', true);
  2260. $state = $this->input->post('state', true);
  2261. $ktime = $this->input->post('ktime', true);
  2262. $jtime = $this->input->post('jtime', true);
  2263. $ktime = strtotime($ktime);
  2264. $jtime = strtotime($jtime);
  2265. $where = "state=3";
  2266. $gj = "";
  2267. $ck = "";
  2268. if ($category) {
  2269. $where .= " and features like '%-$category-%'";
  2270. }
  2271. if ($size) {
  2272. $where .= " and features like '%-$size-%'";
  2273. }
  2274. if ($grade) {
  2275. $where .= " and features like '%-$grade-%'";
  2276. }
  2277. if ($color) {
  2278. $where .= " and features like '%-$color-%'";
  2279. }
  2280. if ($lowe) {
  2281. $where .= " and features like '%-$lowe-%'";
  2282. }
  2283. if ($state) {
  2284. $where .= " and state = '$state'";
  2285. }
  2286. if ($warehouse) {
  2287. $where .= " and warehouse = '$warehouse'";
  2288. }
  2289. if ($purchase) {
  2290. $where .= " and purchase = '$purchase'";
  2291. }
  2292. if ($sku) {
  2293. $where .= " and sku = '$sku'";
  2294. }
  2295. if ($ktime && $jtime) {
  2296. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2297. }
  2298. //数据排序
  2299. $order_str = "id desc";
  2300. if (empty($page)) {
  2301. $start = 0;
  2302. $perpage = 1;
  2303. } else {
  2304. $start = ($page - 1) * $perpage;
  2305. }
  2306. //取得信息列表
  2307. $info_list = $this->whlabel->find_all($where, 'sku');
  2308. $rows = array();
  2309. $list = array();
  2310. foreach ($info_list as $key => $value) {
  2311. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2312. }
  2313. $rows = array_unique($rows); //删除重复记录
  2314. foreach ($rows as $key => $value) {
  2315. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2316. $ck = $this->warehouse->read($data['warehouse']);
  2317. $warehouse = $ck['title'];
  2318. $gy = $this->purchase->read($data['purchase']);
  2319. $purchase = $gy['purchase'];
  2320. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2321. $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);
  2322. }
  2323. $total = count($list);
  2324. $pagenum = ceil($total / $perpage);
  2325. $over = $total - ($start + $perpage);
  2326. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2327. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2328. echo json_encode($rows);
  2329. exit;
  2330. }
  2331. $this->_Template('whlabel_out', $this->data);
  2332. }
  2333. //出库标签浏览
  2334. public function _label()
  2335. {
  2336. $post = $this->input->post(NULL, TRUE);
  2337. if (isset($post['page'])) {
  2338. $page = $this->input->post('page', true);
  2339. $perpage = $this->input->post('perpage', true);
  2340. $sku = $this->input->post('sku', true);
  2341. $warehouse = $this->input->post('warehouse', true);
  2342. $purchase = $this->input->post('purchase', true);
  2343. $orderinfo = $this->input->post('orderinfo', true);
  2344. $waybill = $this->input->post('waybill', true);
  2345. $category = $this->input->post('category', true);
  2346. $size = $this->input->post('size', true);
  2347. $grade = $this->input->post('grade', true);
  2348. $color = $this->input->post('color', true);
  2349. $lowe = $this->input->post('lowe', true);
  2350. $where = "state=1";
  2351. if ($sku) {
  2352. $where .= " and sku = '$sku'";
  2353. }
  2354. if ($warehouse) {
  2355. $where .= " and warehouse = '$warehouse'";
  2356. }
  2357. if ($purchase) {
  2358. $where .= " and purchase = '$purchase'";
  2359. }
  2360. if ($orderinfo) {
  2361. $where .= " and orderinfo = '$orderinfo'";
  2362. }
  2363. if ($waybill) {
  2364. $where .= " and waybill = '$waybill'";
  2365. }
  2366. if ($category) {
  2367. $where .= " and features like '%-$category-%'";
  2368. }
  2369. if ($size) {
  2370. $where .= " and features like '%-$size-%'";
  2371. }
  2372. if ($grade) {
  2373. $where .= " and features like '%-$grade-%'";
  2374. }
  2375. if ($color) {
  2376. $where .= " and features like '%-$color-%'";
  2377. }
  2378. if ($lowe) {
  2379. $where .= " and features like '%-$lowe-%'";
  2380. }
  2381. //数据排序
  2382. $order_str = "outk desc";
  2383. if (empty($page)) {
  2384. $start = 0;
  2385. $perpage = 1;
  2386. } else {
  2387. $start = ($page - 1) * $perpage;
  2388. }
  2389. //取得信息列表
  2390. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2391. foreach ($info_list as $key => $value) {
  2392. $warehouse = $this->warehouse->read($value['warehouse']);
  2393. $info_list[$key]['warehouse'] = $warehouse['title'];
  2394. $purchase = $this->purchase->read($value['purchase']);
  2395. $info_list[$key]['purchase'] = $purchase['title'];
  2396. if ($value['outk'] != 0) {
  2397. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2398. } else {
  2399. $info_list[$key]['outk'] = "";
  2400. }
  2401. if ($value['orderinfo'] == 0) {
  2402. $info_list[$key]['orderinfo'] = "";
  2403. }
  2404. if ($value['waybill'] == 0) {
  2405. $info_list[$key]['waybill'] = "";
  2406. }
  2407. }
  2408. $total = $this->whlabel->find_count($where);
  2409. $pagenum = ceil($total / $perpage);
  2410. $over = $total - ($start + $perpage);
  2411. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2412. echo json_encode($rows);
  2413. exit;
  2414. }
  2415. $this->_Template('whlabel_label', $this->data);
  2416. }
  2417. //独立站出库订单
  2418. public function _outorder()
  2419. {
  2420. if (isset($_SESSION['api'])) {
  2421. $user = $this->user->get_api($_SESSION['api']);
  2422. $usp = $user;
  2423. $fgshop = "";
  2424. $sid = "";
  2425. $user = explode('|', trim($user['shop'], '|'));
  2426. foreach ($user as $value) {
  2427. $fgshop .= " shop = " . $value . " or";
  2428. $sid .= " id = " . $value . " or";
  2429. }
  2430. } else {
  2431. echo "请重新登录";
  2432. }
  2433. $post = $this->input->post(NULL, TRUE);
  2434. if (isset($post['page'])) {
  2435. $page = $this->input->post('page', true);
  2436. $perpage = $this->input->post('perpage', true);
  2437. $warehouse = $this->input->post('warehouse', true);
  2438. $xztime = $this->input->post('xztime', true);
  2439. $timetk = $this->input->post('timetkk', true);
  2440. $timetj = $this->input->post('timetjj', true);
  2441. $shop = $this->input->post('shop', true);
  2442. $source = $this->input->post('source', true);
  2443. $orderinfo = $this->input->post('orderinfo', true);
  2444. $number = $this->input->post('number', true);
  2445. $sfxh = $this->input->post('sfxh', true);
  2446. $express = $this->input->post('express', true);
  2447. $waybill = $this->input->post('waybill', true);
  2448. $library = $this->input->post('library', true);
  2449. $country = $this->input->post('country', true);
  2450. $so = $this->input->post('so', true);
  2451. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2452. $print = $this->input->post('print', true);
  2453. $state = $this->input->post('state', true);
  2454. $orderurl = $this->input->post('orderurl', true);
  2455. $productid = $this->input->post('productid', true);
  2456. $timetk = strtotime($timetk);
  2457. $timetj = strtotime($timetj);
  2458. /**
  2459. $sj = $this->input->post('sj',true);
  2460. if($sj)
  2461. {
  2462. $sj = $this->input->post('sj',true);
  2463. }
  2464. else
  2465. {
  2466. $sj = "fullorder";
  2467. }
  2468. **/
  2469. $sj = "fullorder";
  2470. $where = "1=1";
  2471. if ($warehouse) {
  2472. $where .= " and type = '$warehouse'";
  2473. }
  2474. if ($timetk && $timetj) {
  2475. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2476. }
  2477. if ($orderinfo) {
  2478. $where .= " and orderinfo = '$orderinfo'";
  2479. }
  2480. if ($number) {
  2481. $where .= " and number = '$number'";
  2482. }
  2483. if ($express) {
  2484. $where .= " and express = '$express'";
  2485. }
  2486. if ($waybill) {
  2487. $where .= " and waybill = '$waybill'";
  2488. }
  2489. if ($library) {
  2490. $where .= " and library = '$library'";
  2491. }
  2492. if ($print) {
  2493. $where .= " and print = '$print'";
  2494. }
  2495. if ($libraryconfirm) {
  2496. $where .= " and libraryconfirm = '$libraryconfirm'";
  2497. }
  2498. if ($state) {
  2499. $where .= " and state = '$state'";
  2500. }
  2501. if ($shop) {
  2502. $where .= " and shop = '$shop'";
  2503. }
  2504. if ($country) {
  2505. $where .= " and country = '$country'";
  2506. }
  2507. if ($sfxh != '') {
  2508. $where .= " and sfxh = '$sfxh'";
  2509. }
  2510. if ($so) {
  2511. $where .= " and shipremarks like '%$so%'";
  2512. }
  2513. if ($source) {
  2514. if ($source == '2d') {
  2515. $where .= " and source >= '2'";
  2516. } else {
  2517. $where .= " and source = '$source'";
  2518. }
  2519. }
  2520. if (isset($_SESSION['api'])) {
  2521. foreach ($user as $value) {
  2522. $fgshop .= " shop = " . $value . " or";
  2523. }
  2524. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2525. }
  2526. if ($orderurl) {
  2527. $url = $this->orderurl->read($orderurl);
  2528. $where .= " and link like '%" . $url['url'] . "%'";
  2529. }
  2530. if($productid){
  2531. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2532. }
  2533. //数据排序
  2534. $order_str = "librarytime desc";
  2535. if (empty($page)) {
  2536. $start = 0;
  2537. $perpage = 1;
  2538. } else {
  2539. $start = ($page - 1) * $perpage;
  2540. }
  2541. //取得信息列表
  2542. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2543. //格式化数据
  2544. foreach ($info_list as $key => $value) {
  2545. $shop = $this->shop->read($value['shop']);
  2546. $info_list[$key]['shop'] = $shop['shopname'];
  2547. $express = $this->express->read($value['express']);
  2548. $info_list[$key]['express'] = $express['servicename'];
  2549. $warehouse = $this->warehouse->read($value['type']);
  2550. $info_list[$key]['type'] = $warehouse['title'];
  2551. if ($value['librarytime'] == '0') {
  2552. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2553. } else {
  2554. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2555. }
  2556. }
  2557. $total = $this->$sj->find_count($where);
  2558. $pagenum = ceil($total / $perpage);
  2559. $over = $total - ($start + $perpage);
  2560. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2561. echo json_encode($rows);
  2562. exit;
  2563. }
  2564. $this->data['express'] = $this->express->find_all();
  2565. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2566. $this->data['wlshop'] = $wlshop;
  2567. $user = $this->user->get_api($_SESSION['api']);
  2568. $powerid = $this->power->read($user['power']);
  2569. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2570. $pid = '';
  2571. foreach ($powertext as $v) {
  2572. $pid .= " id = " . $v . " or";
  2573. }
  2574. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2575. $this->data['fullorderexcel'] = $fullorderexcel;
  2576. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2577. $this->data['orderurl'] = $orderurl;
  2578. $this->_Template('whlabel_outorder', $this->data);
  2579. }
  2580. //tt出库
  2581. public function _toutorder()
  2582. {
  2583. $fgshop = "";
  2584. $sid = "";
  2585. if (isset($_SESSION['api'])) {
  2586. $user = $this->user->get_api($_SESSION['api']);
  2587. $usp = $user;
  2588. $user = explode('|', trim($user['shop'], '|'));
  2589. foreach ($user as $value) {
  2590. $fgshop .= " shop = " . $value . " or";
  2591. $sid .= " id = " . $value . " or";
  2592. }
  2593. } else {
  2594. echo "请重新登录";
  2595. }
  2596. $post = $this->input->post(NULL, TRUE);
  2597. if (isset($post['page'])) {
  2598. $page = $this->input->post('page', true);
  2599. $perpage = $this->input->post('perpage', true);
  2600. $warehouse = $this->input->post('warehouse', true);
  2601. $xztime = $this->input->post('xztime', true);
  2602. $timetk = $this->input->post('timetkk', true);
  2603. $timetj = $this->input->post('timetjj', true);
  2604. $shop = $this->input->post('shop', true);
  2605. $source = $this->input->post('source', true);
  2606. $orderinfo = $this->input->post('orderinfo', true);
  2607. $number = $this->input->post('number', true);
  2608. $sfxh = $this->input->post('sfxh', true);
  2609. $express = $this->input->post('express', true);
  2610. $waybill = $this->input->post('waybill', true);
  2611. $library = $this->input->post('library', true);
  2612. $country = $this->input->post('country', true);
  2613. $so = $this->input->post('so', true);
  2614. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2615. $print = $this->input->post('print', true);
  2616. $state = $this->input->post('state', true);
  2617. $orderurl = $this->input->post('orderurl', true);
  2618. $timetk = strtotime($timetk);
  2619. $timetj = strtotime($timetj);
  2620. /**
  2621. $sj = $this->input->post('sj',true);
  2622. if($sj)
  2623. {
  2624. $sj = $this->input->post('sj',true);
  2625. }
  2626. else
  2627. {
  2628. $sj = "fullorder";
  2629. }
  2630. **/
  2631. $sj = "fullordertt";
  2632. $where = "1=1";
  2633. if ($warehouse) {
  2634. $where .= " and type = '$warehouse'";
  2635. }
  2636. if ($timetk && $timetj) {
  2637. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2638. }
  2639. if ($orderinfo) {
  2640. $where .= " and orderinfo = '$orderinfo'";
  2641. }
  2642. if ($number) {
  2643. $where .= " and number = '$number'";
  2644. }
  2645. if ($express) {
  2646. $where .= " and express = '$express'";
  2647. }
  2648. if ($waybill) {
  2649. $where .= " and waybill = '$waybill'";
  2650. }
  2651. if ($library) {
  2652. $where .= " and library = '$library'";
  2653. }
  2654. if ($print) {
  2655. $where .= " and print = '$print'";
  2656. }
  2657. if ($libraryconfirm) {
  2658. $where .= " and libraryconfirm = '$libraryconfirm'";
  2659. }
  2660. if ($state) {
  2661. $where .= " and state = '$state'";
  2662. }
  2663. if ($shop) {
  2664. $where .= " and shop = '$shop'";
  2665. }
  2666. if ($country) {
  2667. $where .= " and country = '$country'";
  2668. }
  2669. if ($sfxh != '') {
  2670. $where .= " and sfxh = '$sfxh'";
  2671. }
  2672. if ($so) {
  2673. $where .= " and shipremarks like '%$so%'";
  2674. }
  2675. if ($source) {
  2676. if ($source == '2d') {
  2677. $where .= " and source >= '2'";
  2678. } else {
  2679. $where .= " and source = '$source'";
  2680. }
  2681. }
  2682. if (isset($_SESSION['api'])) {
  2683. foreach ($user as $value) {
  2684. $fgshop .= " shop = " . $value . " or";
  2685. }
  2686. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2687. }
  2688. if ($orderurl) {
  2689. $url = $this->orderurl->read($orderurl);
  2690. $where .= " and link like '%" . $url['url'] . "%'";
  2691. }
  2692. //数据排序
  2693. $order_str = "librarytime desc";
  2694. if (empty($page)) {
  2695. $start = 0;
  2696. $perpage = 1;
  2697. } else {
  2698. $start = ($page - 1) * $perpage;
  2699. }
  2700. //取得信息列表
  2701. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2702. //格式化数据
  2703. foreach ($info_list as $key => $value) {
  2704. $shop = $this->shop->read($value['shop']);
  2705. $info_list[$key]['shop'] = $shop['shopname'];
  2706. $express = $this->express->read($value['express']);
  2707. $info_list[$key]['express'] = $express['servicename'];
  2708. $warehouse = $this->warehouse->read($value['type']);
  2709. $info_list[$key]['type'] = $warehouse['title'];
  2710. if ($value['librarytime'] == '0') {
  2711. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2712. } else {
  2713. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2714. }
  2715. }
  2716. $total = $this->$sj->find_count($where);
  2717. $pagenum = ceil($total / $perpage);
  2718. $over = $total - ($start + $perpage);
  2719. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2720. echo json_encode($rows);
  2721. exit;
  2722. }
  2723. $this->data['express'] = $this->express->find_all();
  2724. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2725. $this->data['wlshop'] = $wlshop;
  2726. $user = $this->user->get_api($_SESSION['api']);
  2727. $powerid = $this->power->read($user['power']);
  2728. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2729. $pid = '';
  2730. foreach ($powertext as $v) {
  2731. $pid .= " id = " . $v . " or";
  2732. }
  2733. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2734. $this->data['fullorderexcel'] = $fullorderexcel;
  2735. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2736. $this->data['orderurl'] = $orderurl;
  2737. $this->_Template('whlabel_toutorder', $this->data);
  2738. }
  2739. //tt出库
  2740. public function _aoutorder()
  2741. {
  2742. if (isset($_SESSION['api'])) {
  2743. $user = $this->user->get_api($_SESSION['api']);
  2744. $usp = $user;
  2745. $fgshop = "";
  2746. $sid = "";
  2747. $user = explode('|', trim($user['shop'], '|'));
  2748. foreach ($user as $value) {
  2749. $fgshop .= " shop = " . $value . " or";
  2750. $sid .= " id = " . $value . " or";
  2751. }
  2752. } else {
  2753. echo "请重新登录";
  2754. }
  2755. $post = $this->input->post(NULL, TRUE);
  2756. if (isset($post['page'])) {
  2757. $page = $this->input->post('page', true);
  2758. $perpage = $this->input->post('perpage', true);
  2759. $warehouse = $this->input->post('warehouse', true);
  2760. $xztime = $this->input->post('xztime', true);
  2761. $timetk = $this->input->post('timetkk', true);
  2762. $timetj = $this->input->post('timetjj', true);
  2763. $shop = $this->input->post('shop', true);
  2764. $source = $this->input->post('source', true);
  2765. $orderinfo = $this->input->post('orderinfo', true);
  2766. $number = $this->input->post('number', true);
  2767. $sfxh = $this->input->post('sfxh', true);
  2768. $express = $this->input->post('express', true);
  2769. $waybill = $this->input->post('waybill', true);
  2770. $library = $this->input->post('library', true);
  2771. $country = $this->input->post('country', true);
  2772. $so = $this->input->post('so', true);
  2773. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2774. $print = $this->input->post('print', true);
  2775. $state = $this->input->post('state', true);
  2776. $orderurl = $this->input->post('orderurl', true);
  2777. $timetk = strtotime($timetk);
  2778. $timetj = strtotime($timetj);
  2779. /**
  2780. $sj = $this->input->post('sj',true);
  2781. if($sj)
  2782. {
  2783. $sj = $this->input->post('sj',true);
  2784. }
  2785. else
  2786. {
  2787. $sj = "fullorder";
  2788. }
  2789. **/
  2790. $sj = "fullorderamz";
  2791. $where = "1=1";
  2792. if ($warehouse) {
  2793. $where .= " and type = '$warehouse'";
  2794. }
  2795. if ($timetk && $timetj) {
  2796. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2797. }
  2798. if ($orderinfo) {
  2799. $where .= " and orderinfo = '$orderinfo'";
  2800. }
  2801. if ($number) {
  2802. $where .= " and number = '$number'";
  2803. }
  2804. if ($express) {
  2805. $where .= " and express = '$express'";
  2806. }
  2807. if ($waybill) {
  2808. $where .= " and waybill = '$waybill'";
  2809. }
  2810. if ($library) {
  2811. $where .= " and library = '$library'";
  2812. }
  2813. if ($print) {
  2814. $where .= " and print = '$print'";
  2815. }
  2816. if ($libraryconfirm) {
  2817. $where .= " and libraryconfirm = '$libraryconfirm'";
  2818. }
  2819. if ($state) {
  2820. $where .= " and state = '$state'";
  2821. }
  2822. if ($shop) {
  2823. $where .= " and shop = '$shop'";
  2824. }
  2825. if ($country) {
  2826. $where .= " and country = '$country'";
  2827. }
  2828. if ($sfxh != '') {
  2829. $where .= " and sfxh = '$sfxh'";
  2830. }
  2831. if ($so) {
  2832. $where .= " and shipremarks like '%$so%'";
  2833. }
  2834. if ($source) {
  2835. if ($source == '2d') {
  2836. $where .= " and source >= '2'";
  2837. } else {
  2838. $where .= " and source = '$source'";
  2839. }
  2840. }
  2841. if (isset($_SESSION['api'])) {
  2842. foreach ($user as $value) {
  2843. $fgshop .= " shop = " . $value . " or";
  2844. }
  2845. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2846. }
  2847. if ($orderurl) {
  2848. $url = $this->orderurl->read($orderurl);
  2849. $where .= " and link like '%" . $url['url'] . "%'";
  2850. }
  2851. //数据排序
  2852. $order_str = "librarytime desc";
  2853. if (empty($page)) {
  2854. $start = 0;
  2855. $perpage = 1;
  2856. } else {
  2857. $start = ($page - 1) * $perpage;
  2858. }
  2859. //取得信息列表
  2860. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2861. //格式化数据
  2862. foreach ($info_list as $key => $value) {
  2863. $shop = $this->shop->read($value['shop']);
  2864. $info_list[$key]['shop'] = $shop['shopname'];
  2865. $express = $this->express->read($value['express']);
  2866. $info_list[$key]['express'] = $express['servicename'];
  2867. $warehouse = $this->warehouse->read($value['type']);
  2868. $info_list[$key]['type'] = $warehouse['title'];
  2869. if ($value['librarytime'] == '0') {
  2870. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2871. } else {
  2872. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2873. }
  2874. }
  2875. $total = $this->$sj->find_count($where);
  2876. $pagenum = ceil($total / $perpage);
  2877. $over = $total - ($start + $perpage);
  2878. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2879. echo json_encode($rows);
  2880. exit;
  2881. }
  2882. $this->data['express'] = $this->express->find_all();
  2883. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2884. $this->data['wlshop'] = $wlshop;
  2885. $user = $this->user->get_api($_SESSION['api']);
  2886. $powerid = $this->power->read($user['power']);
  2887. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2888. $pid = '';
  2889. foreach ($powertext as $v) {
  2890. $pid .= " id = " . $v . " or";
  2891. }
  2892. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2893. $this->data['fullorderexcel'] = $fullorderexcel;
  2894. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2895. $this->data['orderurl'] = $orderurl;
  2896. $this->_Template('whlabel_aoutorder', $this->data);
  2897. }
  2898. //速卖通出库订单
  2899. public function _soutorder()
  2900. {
  2901. if (isset($_SESSION['api'])) {
  2902. $user = $this->user->get_api($_SESSION['api']);
  2903. $usp = $user;
  2904. $fgshop = "";
  2905. $sid = "";
  2906. $user = explode('|', trim($user['shop'], '|'));
  2907. foreach ($user as $value) {
  2908. $sid .= " id = " . $value . " or";
  2909. }
  2910. }
  2911. $post = $this->input->post(NULL, TRUE);
  2912. if (isset($post['page'])) {
  2913. $page = $this->input->post('page', true);
  2914. $perpage = $this->input->post('perpage', true);
  2915. $warehouse = $this->input->post('warehouse', true);
  2916. $xztime = $this->input->post('xztime', true);
  2917. $timetk = $this->input->post('timetkk', true);
  2918. $timetj = $this->input->post('timetjj', true);
  2919. $shop = $this->input->post('shop', true);
  2920. $source = $this->input->post('source', true);
  2921. $orderinfo = $this->input->post('orderinfo', true);
  2922. $number = $this->input->post('number', true);
  2923. $express = $this->input->post('express', true);
  2924. $waybill = $this->input->post('waybill', true);
  2925. $library = $this->input->post('library', true);
  2926. $country = $this->input->post('country', true);
  2927. $sfxh = $this->input->post('sfxh', true);
  2928. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2929. $print = $this->input->post('print', true);
  2930. $state = $this->input->post('state', true);
  2931. $so = $this->input->post('so', true);
  2932. $timetk = strtotime($timetk);
  2933. $timetj = strtotime($timetj);
  2934. /**
  2935. $sj = $this->input->post('sj',true);
  2936. if($sj)
  2937. {
  2938. $sj = $this->input->post('sj',true);
  2939. }
  2940. else
  2941. {
  2942. $sj = "fullorder";
  2943. }
  2944. **/
  2945. $sj = "fullordersmt";
  2946. $where = "1=1";
  2947. if ($warehouse) {
  2948. $where .= " and type = '$warehouse'";
  2949. }
  2950. if ($timetk && $timetj) {
  2951. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2952. }
  2953. if ($orderinfo) {
  2954. $where .= " and orderinfo = '$orderinfo'";
  2955. }
  2956. if ($number) {
  2957. $where .= " and number = '$number'";
  2958. }
  2959. if ($express) {
  2960. $where .= " and express = '$express'";
  2961. }
  2962. if ($waybill) {
  2963. $where .= " and waybill = '$waybill'";
  2964. }
  2965. if ($library) {
  2966. $where .= " and library = '$library'";
  2967. }
  2968. if ($print) {
  2969. $where .= " and print = '$print'";
  2970. }
  2971. if ($libraryconfirm) {
  2972. $where .= " and libraryconfirm = '$libraryconfirm'";
  2973. }
  2974. if ($state) {
  2975. $where .= " and state = '$state'";
  2976. }
  2977. if ($shop) {
  2978. $where .= " and shop = '$shop'";
  2979. }
  2980. if ($sfxh != '') {
  2981. $where .= " and sfxh = '$sfxh'";
  2982. }
  2983. if ($so) {
  2984. $where .= " and shipremarks like '%$so%'";
  2985. }
  2986. if ($source) {
  2987. $where .= " and source = '$source'";
  2988. }
  2989. if ($country) {
  2990. $where .= " and country = '$country'";
  2991. } else {
  2992. if (isset($_SESSION['api'])) {
  2993. foreach ($user as $value) {
  2994. $fgshop .= " shop = " . $value . " or";
  2995. }
  2996. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2997. }
  2998. }
  2999. //数据排序
  3000. $order_str = "librarytime desc";
  3001. if (empty($page)) {
  3002. $start = 0;
  3003. $perpage = 1;
  3004. } else {
  3005. $start = ($page - 1) * $perpage;
  3006. }
  3007. //取得信息列表
  3008. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3009. //格式化数据
  3010. foreach ($info_list as $key => $value) {
  3011. $shop = $this->shop->read($value['shop']);
  3012. $info_list[$key]['shop'] = $shop['shopname'];
  3013. $express = $this->express->read($value['express']);
  3014. $info_list[$key]['express'] = $express['servicename'];
  3015. $warehouse = $this->warehouse->read($value['type']);
  3016. $info_list[$key]['type'] = $warehouse['title'];
  3017. if ($value['librarytime'] == '0') {
  3018. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3019. } else {
  3020. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3021. }
  3022. }
  3023. $total = $this->$sj->find_count($where);
  3024. $pagenum = ceil($total / $perpage);
  3025. $over = $total - ($start + $perpage);
  3026. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3027. echo json_encode($rows);
  3028. exit;
  3029. }
  3030. $this->data['express'] = $this->express->find_all();
  3031. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3032. $this->data['wlshop'] = $wlshop;
  3033. $user = $this->user->get_api($_SESSION['api']);
  3034. $powerid = $this->power->read($user['power']);
  3035. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3036. $pid = '';
  3037. foreach ($powertext as $v) {
  3038. $pid .= " id = " . $v . " or";
  3039. }
  3040. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3041. $this->data['fullorderexcel'] = $fullorderexcel;
  3042. $this->_Template('whlabel_soutorder', $this->data);
  3043. }
  3044. //订单退库
  3045. public function _retreat()
  3046. {
  3047. $post = $this->input->post(NULL, TRUE);
  3048. if (isset($post['page'])) {
  3049. $page = $this->input->post('page', true);
  3050. $perpage = $this->input->post('perpage', true);
  3051. $warehouse = $this->input->post('warehouse', true);
  3052. $timetk = $this->input->post('timetk', true);
  3053. $timetj = $this->input->post('timetj', true);
  3054. $shop = $this->input->post('shop', true);
  3055. $source = $this->input->post('source', true);
  3056. $state = $this->input->post('state', true);
  3057. $review = $this->input->post('review', true);
  3058. $state = $this->input->post('state', true);
  3059. $express = $this->input->post('express', true);
  3060. $orderinfo = $this->input->post('orderinfo', true);
  3061. $user = $this->input->post('user', true);
  3062. $name = $this->input->post('name', true);
  3063. $waybill = $this->input->post('waybill', true);
  3064. $timetk = strtotime($timetk);
  3065. $timetj = strtotime($timetj);
  3066. $where = "(state=206 or state=210) and mergeid = 0";
  3067. if ($warehouse) {
  3068. $where .= " and state = '$warehouse'";
  3069. }
  3070. if ($timetk && $timetj) {
  3071. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3072. }
  3073. if ($shop) {
  3074. $where .= " and shop = '$shop'";
  3075. }
  3076. if ($source) {
  3077. $where .= " and source = '$source'";
  3078. }
  3079. if ($state) {
  3080. $where .= " and state = '$state'";
  3081. }
  3082. if ($review) {
  3083. $where .= " and review = '$review'";
  3084. }
  3085. if ($state) {
  3086. $where .= " and state = '$state'";
  3087. }
  3088. if ($express) {
  3089. $where .= " and express = '$express'";
  3090. }
  3091. if ($orderinfo) {
  3092. $where .= " and orderinfo = '$orderinfo'";
  3093. }
  3094. if ($user) {
  3095. $where .= " and user = '$user'";
  3096. }
  3097. if ($name) {
  3098. $where .= " and name = '$name'";
  3099. }
  3100. if ($waybill) {
  3101. $where .= " and waybill = '$waybill'";
  3102. }
  3103. //数据排序
  3104. $order_str = "id desc";
  3105. if (empty($page)) {
  3106. $start = 0;
  3107. $perpage = 1;
  3108. } else {
  3109. $start = ($page - 1) * $perpage;
  3110. }
  3111. //取得信息列表
  3112. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3113. //格式化数据
  3114. foreach ($info_list as $key => $value) {
  3115. $shop = $this->shop->read($value['shop']);
  3116. $info_list[$key]['shop'] = $shop['shopname'];
  3117. $warehouse = $this->warehouse->read($value['warehouse']);
  3118. $info_list[$key]['warehouse'] = $warehouse['title'];
  3119. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3120. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3121. if ($value['waybill'] == 0) {
  3122. $info_list[$key]['waybill'] = "";
  3123. }
  3124. $express = $this->express->read($value['express']);
  3125. $info_list[$key]['express'] = $express['title'];
  3126. $typeclass = $this->typeclass->read($value['state']);
  3127. $info_list[$key]['state'] = $typeclass['title'];
  3128. }
  3129. $total = $this->fullorder->find_count($where);
  3130. $pagenum = ceil($total / $perpage);
  3131. $over = $total - ($start + $perpage);
  3132. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3133. echo json_encode($rows);
  3134. exit;
  3135. }
  3136. $this->data['express'] = $this->express->find_all();
  3137. $this->_Template('whlabel_retreat', $this->data);
  3138. }
  3139. //退库标签浏览
  3140. public function _retreatlk()
  3141. {
  3142. $post = $this->input->post(NULL, TRUE);
  3143. if (isset($post['page'])) {
  3144. $page = $this->input->post('page', true);
  3145. $perpage = $this->input->post('perpage', true);
  3146. $timetk = $this->input->post('timetk', true);
  3147. $timetj = $this->input->post('timetj', true);
  3148. $sku = $this->input->post('sku', true);
  3149. $warehouse = $this->input->post('warehouse', true);
  3150. $purchase = $this->input->post('purchase', true);
  3151. $orderinfo = $this->input->post('orderinfo', true);
  3152. $waybill = $this->input->post('waybill', true);
  3153. $category = $this->input->post('category', true);
  3154. $size = $this->input->post('size', true);
  3155. $grade = $this->input->post('grade', true);
  3156. $color = $this->input->post('color', true);
  3157. $lowe = $this->input->post('lowe', true);
  3158. $state = $this->input->post('state', true);
  3159. $timetk = strtotime($timetk);
  3160. $timetj = strtotime($timetj);
  3161. $where = "state=2";
  3162. if ($timetk && $timetj) {
  3163. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3164. }
  3165. if ($sku) {
  3166. $where .= " and sku = '$sku'";
  3167. }
  3168. if ($warehouse) {
  3169. $where .= " and warehouse = '$warehouse'";
  3170. }
  3171. if ($purchase) {
  3172. $where .= " and purchase = '$purchase'";
  3173. }
  3174. if ($orderinfo) {
  3175. $where .= " and orderinfo = '$orderinfo'";
  3176. }
  3177. if ($waybill) {
  3178. $where .= " and waybill = '$waybill'";
  3179. }
  3180. if ($category) {
  3181. $where .= " and features like '%-$category-%'";
  3182. }
  3183. if ($size) {
  3184. $where .= " and features like '%-$size-%'";
  3185. }
  3186. if ($grade) {
  3187. $where .= " and features like '%-$grade-%'";
  3188. }
  3189. if ($color) {
  3190. $where .= " and features like '%-$color-%'";
  3191. }
  3192. if ($lowe) {
  3193. $where .= " and features like '%-$lowe-%'";
  3194. }
  3195. //数据排序
  3196. $order_str = "time desc";
  3197. if (empty($page)) {
  3198. $start = 0;
  3199. $perpage = 1;
  3200. } else {
  3201. $start = ($page - 1) * $perpage;
  3202. }
  3203. //取得信息列表
  3204. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3205. foreach ($info_list as $key => $value) {
  3206. $warehouse = $this->warehouse->read($value['warehouse']);
  3207. $info_list[$key]['warehouse'] = $warehouse['title'];
  3208. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3209. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3210. $purchase = $this->purchase->read($value['purchase']);
  3211. $info_list[$key]['purchase'] = $purchase['title'];
  3212. if ($value['outk'] != 0) {
  3213. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3214. } else {
  3215. $info_list[$key]['outk'] = "";
  3216. }
  3217. if ($value['retreat'] != 0) {
  3218. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3219. } else {
  3220. $info_list[$key]['retreat'] = "";
  3221. }
  3222. if ($value['orderinfo'] == 0) {
  3223. $info_list[$key]['orderinfo'] = "";
  3224. }
  3225. if ($value['waybill'] == 0) {
  3226. $info_list[$key]['waybill'] = "";
  3227. }
  3228. }
  3229. $total = $this->whlabel->find_count($where);
  3230. $pagenum = ceil($total / $perpage);
  3231. $over = $total - ($start + $perpage);
  3232. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3233. echo json_encode($rows);
  3234. exit;
  3235. }
  3236. $this->_Template('whlabel_retreatlk', $this->data);
  3237. }
  3238. //更换标签及浏览
  3239. public function _change()
  3240. {
  3241. $post = $this->input->post(NULL, TRUE);
  3242. if (isset($post['page'])) {
  3243. $page = $this->input->post('page', true);
  3244. $perpage = $this->input->post('perpage', true);
  3245. $timetk = $this->input->post('timetk', true);
  3246. $timetj = $this->input->post('timetj', true);
  3247. $label = $this->input->post('label', true);
  3248. $oldlabel = $this->input->post('oldlabel', true);
  3249. $timetk = strtotime($timetk);
  3250. $timetj = strtotime($timetj);
  3251. $where = "state=10 ";
  3252. if ($timetk && $timetj) {
  3253. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3254. }
  3255. if ($label) {
  3256. $where .= " and label = '$label'";
  3257. }
  3258. if ($oldlabel) {
  3259. $where .= " and oldlabel = '$oldlabel'";
  3260. }
  3261. //数据排序
  3262. $order_str = "time asc";
  3263. if (empty($page)) {
  3264. $start = 0;
  3265. $perpage = 1;
  3266. } else {
  3267. $start = ($page - 1) * $perpage;
  3268. }
  3269. //取得信息列表
  3270. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3271. foreach ($info_list as $key => $value) {
  3272. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3273. }
  3274. $total = $this->whlabel->find_count($where);
  3275. $pagenum = ceil($total / $perpage);
  3276. $over = $total - ($start + $perpage);
  3277. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3278. echo json_encode($rows);
  3279. exit;
  3280. }
  3281. $this->_Template('whlabel_change', $this->data);
  3282. }
  3283. //产品标签
  3284. public function _cpbqdc()
  3285. {
  3286. if (isset($_GET['excel'])) {
  3287. $where = "1=1";
  3288. //数据排序
  3289. $order_str = "id desc";
  3290. if (empty($page)) {
  3291. $start = 0;
  3292. $perpage = 1;
  3293. } else {
  3294. $start = ($page - 1) * $perpage;
  3295. }
  3296. $warehouse = $this->input->get('warehouse', true);
  3297. $state = $this->input->get('state', true);
  3298. $timetk = $this->input->get('timetkk', true);
  3299. $timetj = $this->input->get('timetjj', true);
  3300. $timetk = strtotime($timetk);
  3301. $timetj = strtotime($timetj);
  3302. if ($warehouse) {
  3303. $where .= " and warehouse = '$warehouse'";
  3304. }
  3305. if ($state || $state == 0) {
  3306. $where .= " and state = '$state'";
  3307. }
  3308. if ($timetk && $timetj) {
  3309. $where .= " and time > '$timetk' and time < '$timetj'";
  3310. }
  3311. //取得信息列表
  3312. $info_list = $this->whlabel->find_all($where, '*');
  3313. $rows = array();
  3314. $list = array();
  3315. foreach ($info_list as $key => $value) {
  3316. $rows[$value['time']] = $value; //所有数据sku
  3317. }
  3318. foreach ($rows as $value) {
  3319. $warehouse = $this->warehouse->read($value['warehouse']);
  3320. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3321. $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);
  3322. }
  3323. $title = "产品标签统计表";
  3324. $titlename = "<table border=1>
  3325. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3326. <tr align='center'>
  3327. <td>仓库</td>
  3328. <td>SKU</td>
  3329. <td>产品</td>
  3330. <td>入库时间</td>
  3331. <td>操作时间</td>
  3332. <td>备注</td>
  3333. <td>数量</td>
  3334. </tr>
  3335. </table>";
  3336. $filename = $title . ".xls";
  3337. $tail = "";
  3338. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3339. }
  3340. }
  3341. //进销存导出
  3342. public function _exceljxc()
  3343. {
  3344. $classid = $this->classid->sku();
  3345. $pm = $classid;
  3346. $typeclass = array();
  3347. $tc = $this->typeclass->find_all();
  3348. foreach ($tc as $v) {
  3349. $typeclass[$v['id']] = $v;
  3350. }
  3351. $prc = array();
  3352. $purchase = $this->purchase->find_all();
  3353. foreach ($purchase as $k => $v) {
  3354. $prc[$v['id']] = $v['title'];
  3355. }
  3356. if (isset($_GET['excel'])) {
  3357. $where = "sku != 'Preset'";
  3358. //数据排序
  3359. $order_str = "id desc";
  3360. if (empty($page)) {
  3361. $start = 0;
  3362. $perpage = 1;
  3363. } else {
  3364. $start = ($page - 1) * $perpage;
  3365. }
  3366. $category = $this->input->get('category', true);
  3367. $warehouse = $this->input->get('warehouse', true);
  3368. $excelid = $this->input->get('sid', true);
  3369. if ($category) {
  3370. $where .= " and features like '%-$category-%'";
  3371. }
  3372. if ($warehouse) {
  3373. $where .= " and warehouse = '$warehouse'";
  3374. }
  3375. $xzid = '';
  3376. if ($excelid) {
  3377. $excelid = explode(',', trim($excelid, ','));
  3378. foreach ($excelid as $key => $value) {
  3379. $xzid .= " id = " . $value . " or";
  3380. }
  3381. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3382. }
  3383. //取得信息列表
  3384. /**
  3385. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3386. $rows = array();$list = array();
  3387. foreach ($info_list as $key=>$value)
  3388. {
  3389. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3390. }
  3391. **/
  3392. $wt = array();
  3393. $whlabel_type = $this->whlabel_type->find_all();
  3394. foreach ($whlabel_type as $v) {
  3395. $wt[$v['id']] = $v['title'];
  3396. }
  3397. $wh = array();
  3398. $w = $this->warehouse->find_all('1=1', 'id,title');
  3399. foreach ($w as $v) {
  3400. $wh[$v['id']] = $v['title'];
  3401. }
  3402. $list = array();
  3403. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3404. foreach ($rows as $key => $value) {
  3405. if (isset($wt[$value['type']])) {
  3406. $rows[$key]['type'] = $wt[$value['type']];
  3407. } else {
  3408. $rows[$key]['type'] = '未设置';
  3409. }
  3410. $bm = '03';
  3411. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3412. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3413. $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');
  3414. $details = array();
  3415. $cpid = array();
  3416. $cpbz = array();
  3417. $c = 0;
  3418. $g = 0;
  3419. $x = 0;
  3420. $t = 0;
  3421. $s = 0;
  3422. $q = 0;
  3423. foreach ($sd as $k => $v) {
  3424. if ($v['state'] == 0) {
  3425. $c++;
  3426. if ($v['cpid'] != 0) {
  3427. $cpid[$v['cpid']] = $v['cpid'];
  3428. }
  3429. if ($v['cpbz'] != '') {
  3430. $cpbz[$v['cpbz']] = $v['cpbz'];
  3431. }
  3432. }
  3433. if ($v['state'] != 9) {
  3434. $g++;
  3435. }
  3436. if ($v['state'] == 1) {
  3437. $x++;
  3438. }
  3439. if ($v['state'] == 2) {
  3440. $t++;
  3441. }
  3442. if ($v['state'] == 8) {
  3443. $s++;
  3444. }
  3445. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3446. $q++;
  3447. }
  3448. $details[$v['details']] = $v['details'];
  3449. }
  3450. $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'] . '"');
  3451. $rows[$key]['details'] = implode("、", $details);
  3452. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3453. $number = $value['number'];
  3454. $ftime = time() - 15 * 24 * 3600;
  3455. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3456. $rows[$key]['number'] = $g;
  3457. $rows[$key]['c'] = $c;
  3458. $rows[$key]['x'] = $x;
  3459. $rows[$key]['t'] = $t;
  3460. $rows[$key]['s'] = $s;
  3461. $rows[$key]['q'] = $q;
  3462. $rows[$key]['z'] = $z;
  3463. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3464. $features = explode('-', trim($features, '-'));
  3465. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3466. // $pm = $classid;
  3467. // $jm = $classid;
  3468. // foreach($features as $k=>$v)
  3469. // {
  3470. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3471. // {
  3472. // if($typeclass[$v]['bm'] != '')
  3473. // {
  3474. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3475. // }
  3476. // }
  3477. // if($v != 0)
  3478. // {
  3479. // if(!isset($typeclass[$v]))
  3480. // {
  3481. // continue;
  3482. // }
  3483. // if(isset($pm[$typeclass[$v]['classid']]))
  3484. // {
  3485. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3486. // {
  3487. // $tz = explode('|',$typeclass[$v]['zh']);
  3488. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3489. // }
  3490. // else
  3491. // {
  3492. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3493. // }
  3494. // }
  3495. // if(isset($jm[$typeclass[$v]['classid']]))
  3496. // {
  3497. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3498. // }
  3499. // }
  3500. // }
  3501. // $jm = array_filter($jm);
  3502. // $rows[$key]['bs'] = implode("-",$jm);
  3503. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3504. // $zh = implode(" ",$pm);
  3505. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3506. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3507. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3508. // $rows[$key]['features'] = $zh;
  3509. }
  3510. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3511. $final_list = [];
  3512. foreach ($list as $k => $v) {
  3513. if (empty($v['sku'])) {
  3514. continue;
  3515. }
  3516. $final_list[] = [
  3517. "warehouse" => $v["warehouse"],
  3518. "purchase" => $v["purchase"],
  3519. "details" => $v["details"],
  3520. "cpid" => $v["cpid"],
  3521. "dbcontent" => $v["dbcontent"],
  3522. "sku" => $v["sku"],
  3523. "cs" => $v["bm"],
  3524. "bs" => $v["jm"],
  3525. "title" => $v["title"],
  3526. "features" => $v["pm"],
  3527. "cpbz" => $v["cpbz"],
  3528. "sm" => $v["sm"],
  3529. "type" => $v["type"],
  3530. "number" => $v["number"],
  3531. "c" => $v["c"],
  3532. "x" => $v["x"],
  3533. "t" => $v["t"],
  3534. "s" => $v["s"],
  3535. "q" => $v["q"],
  3536. "z" => $v["z"],
  3537. "weight" => $v['weight'],
  3538. ];
  3539. }
  3540. $title = "总进销存统计表";
  3541. $titlename = "<table border=1>
  3542. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3543. <tr align='center'>
  3544. <td>仓库</td>
  3545. <td>供应商</td>
  3546. <td>位置</td>
  3547. <td>库存编码</td>
  3548. <td>类目</td>
  3549. <td>SKU</td>
  3550. <td>用友编码</td>
  3551. <td>用友料号</td>
  3552. <td>商品名称</td>
  3553. <td>商品中文</td>
  3554. <td>产品备注</td>
  3555. <td>说明</td>
  3556. <td>类型</td>
  3557. <td>入库总量</td>
  3558. <td>库存数量</td>
  3559. <td>销售数量</td>
  3560. <td>退货数量</td>
  3561. <td>删除数量</td>
  3562. <td>其它操作</td>
  3563. <td>占单数量</td>
  3564. <td>重量(g)</td>
  3565. </tr>
  3566. </table>";
  3567. $filename = $title . ".xls";
  3568. $tail = "";
  3569. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3570. }
  3571. }
  3572. //入库导出
  3573. public function _excelr()
  3574. {
  3575. if (isset($_GET['excel'])) {
  3576. $category = $this->input->get('category', true);
  3577. $size = $this->input->get('size', true);
  3578. $grade = $this->input->get('grade', true);
  3579. $color = $this->input->get('color', true);
  3580. $lowe = $this->input->get('lowe', true);
  3581. $sku = $this->input->get('sku', true);
  3582. $warehouse = $this->input->get('warehouse', true);
  3583. $purchase = $this->input->get('purchase', true);
  3584. $ktime = $this->input->get('ktime', true);
  3585. $jtime = $this->input->get('jtime', true);
  3586. $ktime = strtotime($ktime);
  3587. $jtime = strtotime($jtime);
  3588. $where = "1=1";
  3589. $gj = "";
  3590. $ck = "";
  3591. if ($category) {
  3592. $where .= " and features like '%-$category-%'";
  3593. }
  3594. if ($size) {
  3595. $where .= " and features like '%-$size-%'";
  3596. }
  3597. if ($grade) {
  3598. $where .= " and features like '%-$grade-%'";
  3599. }
  3600. if ($color) {
  3601. $where .= " and features like '%-$color-%'";
  3602. }
  3603. if ($lowe) {
  3604. $where .= " and features like '%-$lowe-%'";
  3605. }
  3606. if ($warehouse) {
  3607. $where .= " and warehouse = '$warehouse'";
  3608. }
  3609. if ($purchase) {
  3610. $where .= " and purchase = '$purchase'";
  3611. }
  3612. if ($sku) {
  3613. $where .= " and sku = '$sku'";
  3614. }
  3615. if ($ktime && $jtime) {
  3616. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3617. }
  3618. //数据排序
  3619. $order_str = "id desc";
  3620. if (empty($page)) {
  3621. $start = 0;
  3622. $perpage = 1;
  3623. } else {
  3624. $start = ($page - 1) * $perpage;
  3625. }
  3626. $list = array();
  3627. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3628. foreach ($rows as $value) {
  3629. $ck = $this->warehouse->read($value['warehouse']);
  3630. $warehouse = $ck['title'];
  3631. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3632. $retreatwarehouse = $tkck['title'];
  3633. $gy = $this->purchase->read($value['purchase']);
  3634. $purchase = $gy['title'];
  3635. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3636. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3637. }
  3638. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3639. $titlename = "<table border=1>
  3640. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3641. <tr align='center'>
  3642. <td>仓库</td>
  3643. <td>SKU</td>
  3644. <td>产品</td>
  3645. <td>时间</td>
  3646. <td>数量</td>
  3647. </tr>
  3648. </table>";
  3649. $filename = $title . ".xls";
  3650. $tail = "";
  3651. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3652. }
  3653. }
  3654. //出库、退库导出
  3655. public function _excelct()
  3656. {
  3657. $classid = $this->classid->sku();
  3658. $pm = $classid;
  3659. $typeclass = array();
  3660. $tc = $this->typeclass->find_all();
  3661. foreach ($tc as $v) {
  3662. $typeclass[$v['id']] = $v;
  3663. }
  3664. $prc = array();
  3665. $purchase = $this->purchase->find_all();
  3666. foreach ($purchase as $k => $v) {
  3667. $prc[$v['id']] = $v['title'];
  3668. }
  3669. if (isset($_GET['excel'])) {
  3670. $wh = array();
  3671. $w = $this->warehouse->find_all('1=1', 'id,title');
  3672. foreach ($w as $v) {
  3673. $wh[$v['id']] = $v['title'];
  3674. }
  3675. $type = $this->input->get('excel', true);
  3676. $category = $this->input->get('category', true);
  3677. $size = $this->input->get('size', true);
  3678. $grade = $this->input->get('grade', true);
  3679. $color = $this->input->get('color', true);
  3680. $lowe = $this->input->get('lowe', true);
  3681. $sku = $this->input->get('sku', true);
  3682. $warehouse = $this->input->get('warehouse', true);
  3683. $lacetype = $this->input->get('lacetype', true);
  3684. $lacecolor = $this->input->get('lacecolor', true);
  3685. $density = $this->input->get('density', true);
  3686. $haircap = $this->input->get('haircap', true);
  3687. $purchase = $this->input->get('purchase', true);
  3688. $title = $this->input->get('title', true);
  3689. $state = $this->input->get('state', true);
  3690. $sid = $this->input->get('sid', true);
  3691. $ktime = $this->input->get('ktime', true);
  3692. $jtime = $this->input->get('jtime', true);
  3693. $ktime = strtotime($ktime);
  3694. $jtime = strtotime($jtime);
  3695. $where = "1=1";
  3696. $gj = "";
  3697. $ck = "";
  3698. if ($category) {
  3699. $where .= " and features like '%-$category-%'";
  3700. }
  3701. if ($size) {
  3702. $where .= " and features like '%-$size-%'";
  3703. }
  3704. if ($grade) {
  3705. $where .= " and features like '%-$grade-%'";
  3706. }
  3707. if ($color) {
  3708. $where .= " and features like '%-$color-%'";
  3709. }
  3710. if ($lowe) {
  3711. $where .= " and features like '%-$lowe-%'";
  3712. }
  3713. if ($warehouse) {
  3714. $where .= " and warehouse = '$warehouse'";
  3715. }
  3716. if ($purchase) {
  3717. $where .= " and purchase = '$purchase'";
  3718. }
  3719. if ($state) {
  3720. $where .= " and state = '$state'";
  3721. }
  3722. if ($lacetype) {
  3723. $where .= " and features like '%-$lacetype-%'";
  3724. }
  3725. if ($lacecolor) {
  3726. $where .= " and features like '%-$lacecolor-%'";
  3727. }
  3728. if ($density) {
  3729. $where .= " and features like '%-$density-%'";
  3730. }
  3731. if ($haircap) {
  3732. $where .= " and features like '%-$haircap-%'";
  3733. }
  3734. if ($title) {
  3735. $title = trim($title, ' ');
  3736. $title = trim($title, ' ');
  3737. $where .= " and title like '%$title%'";
  3738. }
  3739. if ($sku) {
  3740. $sku = trim($sku, ' ');
  3741. $sku = trim($sku, ' ');
  3742. $where .= " and sku like '%$sku%'";
  3743. }
  3744. if ($ktime && $jtime) {
  3745. if ($type == 1) {
  3746. $tl = '出库';
  3747. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3748. } else if ($type == 2) {
  3749. $tl = '退库';
  3750. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3751. } else if ($type == 3) {
  3752. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3753. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3754. } else if ($type == 4) {
  3755. $tl = '出库+零售';
  3756. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3757. } else if ($type == 5) {
  3758. $tl = '零售';
  3759. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3760. }
  3761. }
  3762. $sidwhere = '';
  3763. if ($sid) {
  3764. $sd = "";
  3765. $s = explode(',', trim($sid, ','));
  3766. foreach ($s as $value) {
  3767. $sd .= " id = " . $value . " or";
  3768. }
  3769. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3770. }
  3771. //数据排序
  3772. $order_str = "time desc";
  3773. if (empty($page)) {
  3774. $start = 0;
  3775. $perpage = 1;
  3776. } else {
  3777. $start = ($page - 1) * $perpage;
  3778. }
  3779. //取得信息列表
  3780. if ($type != 3 && $type != 5) {
  3781. if ($type == 1 || $type == 4) {
  3782. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3783. foreach ($info_list as $key => $value) {
  3784. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3785. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3786. $warehouse = $this->warehouse->read($value['warehouse']);
  3787. $info_list[$key]['warehouse'] = $warehouse['title'];
  3788. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3789. $features = explode('-', trim($features, '-'));
  3790. $pm = $classid;
  3791. foreach ($features as $k => $v) {
  3792. if ($v != 0) {
  3793. if (!isset($typeclass[$v])) {
  3794. continue;
  3795. }
  3796. if (isset($pm[$typeclass[$v]['classid']])) {
  3797. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3798. $tz = explode('|', $typeclass[$v]['zh']);
  3799. $pm[$typeclass[$v]['classid']] = $tz[0];
  3800. } else {
  3801. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3802. }
  3803. }
  3804. }
  3805. }
  3806. $zh = implode(" ", $pm);
  3807. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3808. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3809. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3810. $info_list[$key]['features'] = $zh;
  3811. }
  3812. $final_list = [];
  3813. foreach($info_list as $k=>$v){
  3814. $number = "";
  3815. if(!empty($v['orderinfo'])){
  3816. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3817. if(!empty($tmp_info['number'])){
  3818. $number = $tmp_info['number'];
  3819. }
  3820. }
  3821. $final_list[] = [
  3822. 'warehouse'=>$v['warehouse'],
  3823. 'purchase'=>$v['purchase'],
  3824. 'sku'=>$v['sku'],
  3825. 'title'=>$v['title'],
  3826. 'features'=>$v['features'],
  3827. 'label'=>$v['label'],
  3828. 'orderinfo'=>$v['orderinfo'],
  3829. 'number'=>$number,
  3830. 'waybill'=>$v['waybill'],
  3831. 'outk'=>$v['outk'],
  3832. ];
  3833. }
  3834. } else {
  3835. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3836. foreach ($info_list as $key => $value) {
  3837. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3838. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3839. $warehouse = $this->warehouse->read($value['warehouse']);
  3840. $info_list[$key]['warehouse'] = $warehouse['title'];
  3841. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3842. $features = explode('-', trim($features, '-'));
  3843. $pm = $classid;
  3844. foreach ($features as $k => $v) {
  3845. if ($v != 0) {
  3846. if (!isset($typeclass[$v])) {
  3847. continue;
  3848. }
  3849. if (isset($pm[$typeclass[$v]['classid']])) {
  3850. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3851. $tz = explode('|', $typeclass[$v]['zh']);
  3852. $pm[$typeclass[$v]['classid']] = $tz[0];
  3853. } else {
  3854. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3855. }
  3856. }
  3857. }
  3858. }
  3859. $zh = implode(" ", $pm);
  3860. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3861. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3862. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3863. $info_list[$key]['features'] = $zh;
  3864. }
  3865. $final_list = [];
  3866. foreach($info_list as $k=>$v){
  3867. $number = "";
  3868. if(!empty($v['orderinfo'])){
  3869. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3870. if(!empty($tmp_info['number'])){
  3871. $number = $tmp_info['number'];
  3872. }
  3873. }
  3874. $final_list[] = [
  3875. 'warehouse'=>$v['warehouse'],
  3876. 'purchase'=>$v['purchase'],
  3877. 'sku'=>$v['sku'],
  3878. 'title'=>$v['title'],
  3879. 'features'=>$v['features'],
  3880. 'label'=>$v['label'],
  3881. 'orderinfo'=>$v['orderinfo'],
  3882. 'number'=>$number,
  3883. 'waybill'=>$v['waybill'],
  3884. 'retreat'=>$v['retreat'],
  3885. ];
  3886. }
  3887. }
  3888. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3889. $titlename = "<table border=1>
  3890. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3891. <tr align='center'>
  3892. <td>仓库</td>
  3893. <td>供应商</td>
  3894. <td>SKU</td>
  3895. <td>商品名称</td>
  3896. <td>商品中文</td>
  3897. <td>标签</td>
  3898. <td>订单号</td>
  3899. <td>订单编码</td>
  3900. <td>运单号</td>
  3901. <td>" . $tl . "时间(中国时间)</td>
  3902. </tr>
  3903. </table>";
  3904. $filename = $title . ".xls";
  3905. $tail = "";
  3906. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3907. } else if ($type == 5) {
  3908. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3909. foreach ($info_list as $key => $value) {
  3910. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3911. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3912. $warehouse = $this->warehouse->read($value['warehouse']);
  3913. $info_list[$key]['warehouse'] = $warehouse['title'];
  3914. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3915. $features = explode('-', trim($features, '-'));
  3916. $pm = $classid;
  3917. foreach ($features as $k => $v) {
  3918. if ($v != 0) {
  3919. if (!isset($typeclass[$v])) {
  3920. continue;
  3921. }
  3922. if (isset($pm[$typeclass[$v]['classid']])) {
  3923. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3924. $tz = explode('|', $typeclass[$v]['zh']);
  3925. $pm[$typeclass[$v]['classid']] = $tz[0];
  3926. } else {
  3927. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3928. }
  3929. }
  3930. }
  3931. }
  3932. $zh = implode(" ", $pm);
  3933. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3934. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3935. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3936. $info_list[$key]['features'] = $zh;
  3937. }
  3938. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3939. $titlename = "<table border=1>
  3940. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3941. <tr align='center'>
  3942. <td>仓库</td>
  3943. <td>供应商</td>
  3944. <td>SKU</td>
  3945. <td>商品名称</td>
  3946. <td>商品中文</td>
  3947. <td>标签</td>
  3948. <td>" . $tl . "时间(中国时间)</td>
  3949. </tr>
  3950. </table>";
  3951. $filename = $title . ".xls";
  3952. $tail = "";
  3953. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3954. } else {
  3955. /**
  3956. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3957. $rows = array();$list = array();
  3958. foreach ($info_list as $key=>$value)
  3959. {
  3960. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3961. }
  3962. **/
  3963. $wh = array();
  3964. $w = $this->warehouse->find_all('1=1', 'id,title');
  3965. foreach ($w as $v) {
  3966. $wh[$v['id']] = $v['title'];
  3967. }
  3968. $wt = array();
  3969. $whlabel_type = $this->whlabel_type->find_all();
  3970. foreach ($whlabel_type as $v) {
  3971. $wt[$v['id']] = $v['title'];
  3972. }
  3973. $classid = $this->classid->sku();
  3974. $list = array();
  3975. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3976. foreach ($rows as $key => $value) {
  3977. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3978. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3979. $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');
  3980. $details = array();
  3981. $cpid = array();
  3982. $cpbz = array();
  3983. $c = 0;
  3984. $g = 0;
  3985. $x = 0;
  3986. $t = 0;
  3987. $s = 0;
  3988. $q = 0;
  3989. foreach ($sd as $k => $v) {
  3990. if ($v['state'] == 0) {
  3991. $c++;
  3992. }
  3993. if ($v['state'] != 9) {
  3994. $g++;
  3995. }
  3996. if ($v['outk'] > 1) {
  3997. $x++;
  3998. }
  3999. if ($v['retreat'] > 0) {
  4000. $t++;
  4001. }
  4002. if ($v['state'] == 8) {
  4003. $s++;
  4004. }
  4005. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4006. $q++;
  4007. }
  4008. $details[$v['details']] = $v['details'];
  4009. if ($v['cpid'] != 0) {
  4010. $cpid[$v['cpid']] = $v['cpid'];
  4011. }
  4012. if ($v['cpbz'] != '') {
  4013. $cpbz[$v['cpbz']] = $v['cpbz'];
  4014. }
  4015. }
  4016. if (isset($wt[$value['type']])) {
  4017. $rows[$key]['type'] = $wt[$value['type']];
  4018. } else {
  4019. $rows[$key]['type'] = '未设置';
  4020. }
  4021. $rows[$key]['details'] = implode("、", $details);
  4022. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4023. $ftime = time() - 15 * 24 * 3600;
  4024. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4025. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4026. $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);
  4027. $rows[$key]['c'] = $c;
  4028. $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);
  4029. $rows[$key]['t'] = $t;
  4030. $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'] . '"');
  4031. $rows[$key]['z'] = $z;
  4032. // $jm = $classid;
  4033. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4034. $features = explode('-', trim($features, '-'));
  4035. // $pm = $classid;
  4036. // foreach ($features as $k => $v) {
  4037. // if ($v != 0) {
  4038. // if (!isset($typeclass[$v])) {
  4039. // continue;
  4040. // }
  4041. // if (isset($pm[$typeclass[$v]['classid']])) {
  4042. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4043. // $tz = explode('|', $typeclass[$v]['zh']);
  4044. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4045. // } else {
  4046. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4047. // }
  4048. // if (isset($jm[$typeclass[$v]['classid']])) {
  4049. // if ($typeclass[$v]['jm']) {
  4050. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4051. // }
  4052. // }
  4053. // }
  4054. // }
  4055. // }
  4056. // $zh = implode(" ", $pm);
  4057. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4058. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4059. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4060. // $rows[$key]['features'] = $zh;
  4061. // $jm = array_filter($jm); //去除空值
  4062. // $jm = implode("-", $jm);
  4063. // $rows[$key]['jm'] = $jm;
  4064. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4065. }
  4066. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4067. // echo "<pre>";
  4068. // print_r($tmp_list);
  4069. // die;
  4070. $final_list =[];
  4071. foreach($tmp_list as $k=>$v){
  4072. $final_list[] = [
  4073. "warehouse"=>$v['warehouse'],
  4074. "purchase"=>$v['purchase'],
  4075. "details"=>$v['details'],
  4076. "cpid"=>$v['cpid'],
  4077. "sku"=>$v['sku'],
  4078. "title"=>$v['title'],
  4079. "features"=>$v['pm'],
  4080. "cpbz"=>$v['cpbz'],
  4081. "sm"=>$v['sm'],
  4082. "type"=>$v['type'],
  4083. "g"=>$v["g"],
  4084. "c"=>$v["c"],
  4085. "x"=>$v["x"],
  4086. "t"=>$v["t"],
  4087. "z"=>$v["z"],
  4088. "jm"=>$v["jm"],
  4089. "weight"=>$v["weight"],
  4090. "asd"=>$v["asd"],
  4091. ];
  4092. }
  4093. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4094. $titlename = "<table border=1>
  4095. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4096. <tr align='center'>
  4097. <td>仓库</td>
  4098. <td>供应商</td>
  4099. <td>位置</td>
  4100. <td>库存编码</td>
  4101. <td>SKU</td>
  4102. <td>商品名称</td>
  4103. <td>商品中文</td>
  4104. <td>产品备注</td>
  4105. <td>说明</td>
  4106. <td>类型</td>
  4107. <td>入库总量</td>
  4108. <td>库存数量</td>
  4109. <td>销售数量</td>
  4110. <td>退货数量</td>
  4111. <td>占单数量</td>
  4112. <td>料号</td>
  4113. <td>重量</td>
  4114. <td>类目</td>
  4115. </tr>
  4116. </table>";
  4117. $filename = $title . ".xls";
  4118. $tail = "";
  4119. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4120. }
  4121. }
  4122. }
  4123. //出库+入库数据整合
  4124. public function _excelcr()
  4125. {
  4126. if (isset($_GET['excel'])) {
  4127. $type = $this->input->get('excel', true);
  4128. $category = $this->input->get('category', true);
  4129. $size = $this->input->get('size', true);
  4130. $grade = $this->input->get('grade', true);
  4131. $color = $this->input->get('color', true);
  4132. $lowe = $this->input->get('lowe', true);
  4133. $sku = $this->input->get('sku', true);
  4134. $warehouse = $this->input->get('warehouse', true);
  4135. $purchase = $this->input->get('purchase', true);
  4136. $state = $this->input->get('state', true);
  4137. $sid = $this->input->get('sid', true);
  4138. $ktime = $this->input->get('ktime', true);
  4139. $jtime = $this->input->get('jtime', true);
  4140. $ktime = strtotime($ktime);
  4141. $jtime = strtotime($jtime);
  4142. $where = "1=1";
  4143. $gj = "";
  4144. $ck = "";
  4145. if ($category) {
  4146. $where .= " and features like '%-$category-%'";
  4147. }
  4148. if ($size) {
  4149. $where .= " and features like '%-$size-%'";
  4150. }
  4151. if ($grade) {
  4152. $where .= " and features like '%-$grade-%'";
  4153. }
  4154. if ($color) {
  4155. $where .= " and features like '%-$color-%'";
  4156. }
  4157. if ($lowe) {
  4158. $where .= " and features like '%-$lowe-%'";
  4159. }
  4160. if ($warehouse) {
  4161. $where .= " and warehouse = '$warehouse'";
  4162. }
  4163. if ($purchase) {
  4164. $where .= " and purchase = '$purchase'";
  4165. }
  4166. if ($state) {
  4167. $where .= " and state = '$state'";
  4168. }
  4169. if ($sku) {
  4170. $where .= " and sku like '%$sku%'";
  4171. }
  4172. if ($ktime && $jtime) {
  4173. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4174. }
  4175. $sidwhere = '';
  4176. if ($sid) {
  4177. $sd = "";
  4178. $s = explode(',', trim($sid, ','));
  4179. foreach ($s as $value) {
  4180. $sd .= " id = " . $value . " or";
  4181. }
  4182. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4183. }
  4184. //取得信息列表
  4185. $timeread = $ktime;
  4186. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4187. $timelist = array();
  4188. for ($i = 0; $i < $timenum; $i++) {
  4189. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4190. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4191. }
  4192. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4193. //echo "<pre>";
  4194. //print_r($info_list);
  4195. //exit();
  4196. $rows = array();
  4197. $list = array();
  4198. foreach ($info_list as $key => $value) {
  4199. $thistime = $timelist;
  4200. if (isset($rows[strtolower($value['sku'])])) {
  4201. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4202. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4203. }
  4204. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4205. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4206. }
  4207. } else {
  4208. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4209. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4210. }
  4211. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4212. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4213. }
  4214. $rows[strtolower($value['sku'])] = $thistime;
  4215. }
  4216. }
  4217. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4218. <head>
  4219. <!--[if gte mso 9]><xml>
  4220. <x:ExcelWorkbook>
  4221. <x:ExcelWorksheets>
  4222. <x:ExcelWorksheet>
  4223. <x:Name>EXCEL</x:Name>
  4224. <x:WorksheetOptions>
  4225. <x:Print>
  4226. <x:ValidPrinterInfo />
  4227. </x:Print>
  4228. </x:WorksheetOptions>
  4229. </x:ExcelWorksheet>
  4230. </x:ExcelWorksheets>
  4231. </x:ExcelWorkbook>
  4232. </xml>
  4233. <![endif]-->
  4234. </head><body>";
  4235. $str .= "<table border=1><tr><td>SKU</td>";
  4236. foreach ($timelist as $k => $v) {
  4237. $str .= "<td>" . $k . "出库</td>";
  4238. $str .= "<td>" . $k . "入库</td>";
  4239. }
  4240. $str .= "</tr></table>";
  4241. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4242. foreach ($rows as $key => $val) {
  4243. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4244. foreach ($val as $k => $v) {
  4245. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4246. if ($val[$k]['r'] > 0) {
  4247. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4248. } else {
  4249. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4250. }
  4251. }
  4252. $str .= "</tr>";
  4253. }
  4254. $str .= "</table>";
  4255. $str .= "</body></html>";
  4256. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4257. header("Content-type: application/octet-stream");
  4258. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4259. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4260. header("Pragma: no-cache");
  4261. header("Expires: 0");
  4262. exit($str);
  4263. }
  4264. }
  4265. //数量调整模板导出
  4266. public function _presetout()
  4267. {
  4268. if (isset($_GET['excel'])) {
  4269. $where = "sku != 'Preset' and purchase != 0";
  4270. //数据排序
  4271. $order_str = "id desc";
  4272. if (empty($page)) {
  4273. $start = 0;
  4274. $perpage = 1;
  4275. } else {
  4276. $start = ($page - 1) * $perpage;
  4277. }
  4278. //取得信息列表
  4279. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4280. $rows = array();
  4281. $list = array();
  4282. foreach ($info_list as $value) {
  4283. $warehouse = $this->warehouse->read($value['warehouse']);
  4284. $number = $value['number'];
  4285. $ftime = time() - 15 * 24 * 3600;
  4286. $purchase = $this->purchase->read($value['purchase']);
  4287. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4288. }
  4289. $title = "库存模板";
  4290. $titlename = "<table border=1>
  4291. <tr align='center'>
  4292. <td>仓库</td>
  4293. <td>供应商编码</td>
  4294. <td>SKU</td>
  4295. <td>增减数量(正数或负数)</td>
  4296. <td>增减备注</td>
  4297. <td>扣减方式:0减少库存1删除库存</td>
  4298. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4299. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4300. </tr>
  4301. </table>";
  4302. $filename = $title . ".xls";
  4303. $tail = "";
  4304. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4305. }
  4306. }
  4307. //数量调整模板导入
  4308. public function _presetedit()
  4309. {
  4310. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4311. $config['upload_path'] = '.' . $dir;
  4312. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4313. $config['allowed_types'] = 'xls|xlsx|csv';
  4314. $config['max_size'] = 10240;
  4315. $this->load->library('upload', $config);
  4316. $this->upload->initialize($config);
  4317. if ($this->upload->do_upload('userfile')) {
  4318. $full_path = $dir . $this->upload->data('file_name');
  4319. $fileName = '.' . $full_path;
  4320. if (!file_exists($fileName)) {
  4321. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4322. exit;
  4323. } else {
  4324. require_once "./data/excel/PHPExcel/IOFactory.php";
  4325. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4326. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4327. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4328. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4329. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4330. ++$column; //如果列数大于26行
  4331. $list = array();
  4332. for ($i = 2; $i <= $row; $i++) // 行数循环
  4333. {
  4334. $data = array();
  4335. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4336. {
  4337. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4338. }
  4339. $list[] = $data;
  4340. }
  4341. }
  4342. $i = 0;
  4343. $j = 0;
  4344. $ed = array();
  4345. foreach ($list as $key => $value) {
  4346. $time = time();
  4347. if ($value['0'] == "") {
  4348. continue;
  4349. }
  4350. $warehouse = $this->warehouse->get_title($value['0']);
  4351. $purchase = $this->purchase->get_bm($value['1']);
  4352. $sku = $value['2'];
  4353. $num = $value['3']; //调整数量
  4354. $text = $value['4']; //扣减说明
  4355. $type = $value['5']; //调整方式0扣减1删除
  4356. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4357. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4358. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4359. if (!$purchase) //如果没有这个SKU
  4360. {
  4361. $ed[] = array($purchase . '-不存在此供应商编码');
  4362. $j++;
  4363. continue;
  4364. }
  4365. if (!$d) //如果没有这个SKU
  4366. {
  4367. $ed[] = array($sku . '-库存中不存在此SKU');
  4368. $j++;
  4369. continue;
  4370. }
  4371. if (!isset($warehouse['id'])) {
  4372. $ed[] = array($sku . '-仓库名错误!');
  4373. $j++;
  4374. continue;
  4375. }
  4376. if ($type != '0' && $type != '1') {
  4377. $ed[] = array($sku . '-扣减方式填写错误!');
  4378. $j++;
  4379. continue;
  4380. }
  4381. if ($num < 0) //扣减库存
  4382. {
  4383. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4384. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4385. $j++;
  4386. continue;
  4387. }
  4388. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4389. if (count($data) < abs($num)) {
  4390. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4391. $j++;
  4392. continue;
  4393. }
  4394. if ($type == 0) //如果扣减方式为 扣减库存
  4395. {
  4396. for ($i = 0; $i < abs($num); $i++) {
  4397. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4398. }
  4399. } else if ($type == 1) {
  4400. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4401. if (count($zt) > 0) {
  4402. $ed[] = array($sku . '-有在途库存无法删除!');
  4403. $j++;
  4404. continue;
  4405. }
  4406. for ($i = 0; $i < abs($num); $i++) {
  4407. $this->whlabel->remove($data[$i]['id']);
  4408. }
  4409. }
  4410. } else if ($num > 0) //增加库存
  4411. {
  4412. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4413. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4414. $j++;
  4415. continue;
  4416. }
  4417. $post['sku'] = $d['sku'];
  4418. $post['shop'] = $d['shop'];
  4419. $post['warehouse'] = $warehouse['id'];
  4420. $post['purchase'] = $purchase['id'];
  4421. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4422. $post['state'] = 0;
  4423. $post['title'] = $d['title'];
  4424. $post['number'] = $d['number'];
  4425. $post['features'] = $d['features'];
  4426. $post['enter'] = $time;
  4427. $post['time'] = $time; //操作时间
  4428. $post['rktype'] = $rktype;
  4429. for ($i = 0; $i < $num; $i++) {
  4430. $post['label'] = time() . rand(100, 999) . $i;
  4431. $this->whlabel->insert($post);
  4432. }
  4433. }
  4434. sleep(1); //防止入库时间一样,需要延迟1秒
  4435. }
  4436. if ($j > 0) {
  4437. $tt = date('Ymd', time());
  4438. $title = '库存导入错误信息-' . $tt;
  4439. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4440. $tail = "\n";
  4441. $filename = $title . ".xls";
  4442. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4443. $dir = '/data/excel/' . $time . '/';
  4444. $file_name = 'error_' . $time . rand(1000, 9999);
  4445. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4446. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4447. fwrite($myfile, $ecl);
  4448. fclose($myfile);
  4449. $error = $dir . $file_name . '.xls';
  4450. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4451. exit;
  4452. } else {
  4453. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4454. exit;
  4455. }
  4456. }
  4457. }
  4458. //笛卡儿积
  4459. function cp($ps, $sets, $list)
  4460. {
  4461. $result = array();
  4462. $j = 0;
  4463. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4464. if ($i == 0) {
  4465. $result = $sets[$i];
  4466. }
  4467. $tmp = array();
  4468. foreach ($result as $res) {
  4469. foreach ($sets[$i + 1] as $set) {
  4470. $tmp[] = $res . ',' . $set;
  4471. }
  4472. }
  4473. $result = $tmp;
  4474. }
  4475. $this->db->trans_begin();
  4476. foreach ($result as $v) {
  4477. $post = array();
  4478. $title = "";
  4479. $num = "";
  4480. $data = explode(',', $v);
  4481. for ($i = 0; $i < count($list); $i++) {
  4482. $post[$list[$i]] = $data[$i];
  4483. $typeclass = $this->typeclass->read($data[$i]);
  4484. $title = $title . $typeclass['title'] . " ";
  4485. if ($data[$i] != 0) {
  4486. $num .= $data[$i]; //所有数据ID拼接
  4487. }
  4488. }
  4489. foreach ($ps as $kp => $vp) {
  4490. $post[$kp] = $vp;
  4491. }
  4492. $post['number'] = $num;
  4493. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4494. if ($info_list) {
  4495. $j++;
  4496. } else {
  4497. $skunum = $this->whlabel->find_count();
  4498. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4499. $post['title'] = rtrim($title, ' ');
  4500. $this->whlabel->insert($post);
  4501. }
  4502. }
  4503. if ($this->db->trans_status() === FALSE) {
  4504. $this->db->trans_commit();
  4505. return NULL;
  4506. } else {
  4507. $this->db->trans_commit();
  4508. return $j;
  4509. }
  4510. }
  4511. public function _kj($arg_array)
  4512. {
  4513. if (isset($_POST['sku'])) {
  4514. $time = time();
  4515. $sku = $this->input->post('sku', true);
  4516. $warehouse = $this->input->post('warehouse', true);
  4517. $num = $this->input->post('num', true);
  4518. $text = $this->input->post('text', true);
  4519. $purchase = $this->input->post('purchase', true);
  4520. $cktype = $this->input->post('cktype', true);
  4521. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4522. if ($cktype != 1 && $text == '') {
  4523. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4524. exit;
  4525. }
  4526. if ($num > count($order)) {
  4527. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4528. exit;
  4529. } else {
  4530. for ($i = 0; $i < $num; $i++) {
  4531. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4532. }
  4533. }
  4534. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4535. exit;
  4536. }
  4537. $uid = $this->whlabel->read($arg_array[0]);
  4538. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4539. $this->data['data'] = $uid;
  4540. $this->_Template('whlabel_kj', $this->data);
  4541. }
  4542. public function _summary($arg_array)
  4543. {
  4544. $prc = array();
  4545. $purchase = $this->purchase->find_all();
  4546. foreach ($purchase as $k => $v) {
  4547. $prc[$v['id']] = $v['title'];
  4548. }
  4549. if (isset($_GET['excel'])) {
  4550. $ktime = $this->input->get('ktime', true);
  4551. $jtime = $this->input->get('jtime', true);
  4552. $ktime = strtotime($ktime);
  4553. $jtime = strtotime($jtime);
  4554. $where = "1=1";
  4555. if ($ktime && $jtime) {
  4556. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4557. }
  4558. //数据排序
  4559. $order_str = "time desc";
  4560. if (empty($page)) {
  4561. $start = 0;
  4562. $perpage = 1;
  4563. } else {
  4564. $start = ($page - 1) * $perpage;
  4565. }
  4566. //取得信息列表
  4567. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4568. foreach ($info_list as $key => $value) {
  4569. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4570. $warehouse = $this->warehouse->read($value['warehouse']);
  4571. $info_list[$key]['warehouse'] = $warehouse['title'];
  4572. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4573. $details = array();
  4574. $cpid = array();
  4575. foreach ($x as $k => $v) {
  4576. if ($v['details'] != '') {
  4577. $details[$v['details']] = $v['details'];
  4578. }
  4579. if ($v['cpid'] != 0) {
  4580. $cpid[$v['cpid']] = $v['cpid'];
  4581. }
  4582. }
  4583. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4584. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4585. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4586. $info_list[$key]['s'] = $s;
  4587. $info_list[$key]['x'] = count($x);
  4588. }
  4589. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4590. $titlename = "<table border=1>
  4591. <tr align='center'>
  4592. <td>仓库</td>
  4593. <td>供应商</td>
  4594. <td>出库位置</td>
  4595. <td>出库编码</td>
  4596. <td>SKU</td>
  4597. <td>产品名</td>
  4598. <td>总剩余库存</td>
  4599. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4600. </tr>
  4601. </table>";
  4602. $filename = $title . ".xls";
  4603. $tail = "";
  4604. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4605. }
  4606. }
  4607. //usps发货清单
  4608. public function _manifest()
  4609. {
  4610. if (isset($_POST['manifest'])) {
  4611. $wltext = $this->input->post('wltext', true);
  4612. $time = time() - 16 * 3600;
  4613. $ptime = strtotime(date('Y-m-d', $time));
  4614. $waybill = array();
  4615. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4616. foreach ($fullorder as $v) {
  4617. $waybill[$v['waybill']] = $v['waybill'];
  4618. }
  4619. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4620. foreach ($fullordersmt as $v) {
  4621. $waybill[$v['waybill']] = $v['waybill'];
  4622. }
  4623. $wltext = explode(';', $wltext);
  4624. foreach ($wltext as $v) {
  4625. if (isset($waybill[$v])) {
  4626. unset($waybill[$v]);
  4627. }
  4628. }
  4629. $data = $this->usps->get_manifest($waybill);
  4630. if (isset($data['Description'])) {
  4631. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4632. exit;
  4633. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4634. $bctime = date('Ymd', time());
  4635. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4636. echo json_encode(array('msg' => $pdf, 'success' => true));
  4637. exit;
  4638. } else {
  4639. echo json_encode(array('msg' => $data, 'success' => false));
  4640. exit;
  4641. }
  4642. }
  4643. }
  4644. public function _pdf($pdf, $title, $bctime)
  4645. {
  4646. $pdf_path = './data/pdf/' . $bctime . '/';
  4647. $file_base64 = $pdf;
  4648. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4649. $file_base64 = base64_decode($file_base64);
  4650. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4651. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4652. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4653. }
  4654. /**
  4655. *
  4656. *
  4657. *
  4658. 进销存占单异常索引
  4659. *
  4660. *
  4661. *
  4662. **/
  4663. public function _abnormal()
  4664. {
  4665. $post = $this->input->post(NULL, TRUE);
  4666. if (isset($post['page'])) {
  4667. $page = $this->input->post('page', true);
  4668. $perpage = $this->input->post('perpage', true);
  4669. $sku = $this->input->post('sku', true);
  4670. $where = "1=1";
  4671. //数据排序
  4672. $order_str = "id desc";
  4673. if (empty($page)) {
  4674. $start = 0;
  4675. $perpage = 1;
  4676. } else {
  4677. $start = ($page - 1) * $perpage;
  4678. }
  4679. //取得信息列表
  4680. $info_list = $this->whlabel->find_all($where, '*');
  4681. $rows = array();
  4682. $list = array();
  4683. foreach ($info_list as $key => $value) {
  4684. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4685. }
  4686. foreach ($rows as $value) {
  4687. $warehouse = $this->warehouse->read($value['warehouse']);
  4688. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4689. $number = $value['number'];
  4690. $ftime = time() - 15 * 24 * 3600;
  4691. if ($value['shop'] != '') {
  4692. $shop = $value['shop'];
  4693. $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');
  4694. $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');
  4695. $order = array_merge($orderdlz, $ordersmt);
  4696. $od = 0;
  4697. $a = '';
  4698. $orid = '';
  4699. foreach ($order as $v) {
  4700. $or = explode('|', ltrim($v['whlabel'], '|'));
  4701. for ($i = 0; $i < count($or); $i++) {
  4702. $orod = explode('-', $or[$i]);
  4703. if ($orod[0] == $number) {
  4704. $od += $orod[1];
  4705. }
  4706. }
  4707. $orid .= $v['number'] . '-';
  4708. }
  4709. } else {
  4710. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4711. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4712. $order = array_merge($orderdlz, $ordersmt);
  4713. $od = 0;
  4714. $a = '';
  4715. $orid = '';
  4716. $qt = array();
  4717. foreach ($order as $v) {
  4718. $or = explode('|', ltrim($v['whlabel'], '|'));
  4719. for ($i = 0; $i < count($or); $i++) {
  4720. $orod = explode('-', $or[$i]);
  4721. if ($orod[0] == $number) {
  4722. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4723. if ($czzs > 0) {
  4724. if (isset($qt[$v['shop']])) {
  4725. if ($qt[$v['shop']] < $orod[1]) {
  4726. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4727. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4728. } else {
  4729. $qt[$v['shop']] -= $orod[1];
  4730. }
  4731. } else {
  4732. $qt[$v['shop']] = $czzs;
  4733. }
  4734. } else {
  4735. $od += $orod[1];
  4736. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4737. }
  4738. }
  4739. }
  4740. }
  4741. }
  4742. $z = $od . '(' . $orid . ')'; //查看订单号
  4743. //$z = $od;
  4744. if ($od > $c) {
  4745. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4746. }
  4747. }
  4748. $listdata = array_slice($list, $start, $perpage);
  4749. $total = count($list);
  4750. $pagenum = ceil($total / $perpage);
  4751. $over = $total - ($start + $perpage);
  4752. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4753. echo json_encode($rows);
  4754. exit;
  4755. }
  4756. $this->_Template('whlabel_abnormal', $this->data);
  4757. }
  4758. /**
  4759. *
  4760. *
  4761. *
  4762. 进销存占单异常索引
  4763. *
  4764. *
  4765. *
  4766. **/
  4767. public function _error()
  4768. {
  4769. $post = $this->input->post(NULL, TRUE);
  4770. if (isset($post['page'])) {
  4771. $page = $this->input->post('page', true);
  4772. $perpage = $this->input->post('perpage', true);
  4773. $sku = $this->input->post('sku', true);
  4774. $warehouse = $this->input->post('warehouse', true);
  4775. $ktime = $this->input->post('ktime', true);
  4776. $jtime = $this->input->post('jtime', true);
  4777. $ktime = strtotime($ktime);
  4778. $jtime = strtotime($jtime);
  4779. $where = "sku != 'Preset'";
  4780. $gj = '';
  4781. if ($sku) {
  4782. $where .= " and sku like '%$sku%'";
  4783. } else {
  4784. if ($ktime && $jtime) {
  4785. $gj = " and time > '$ktime' and time < '$jtime'";
  4786. }
  4787. }
  4788. if ($warehouse) {
  4789. $where .= " and warehouse = '$warehouse'";
  4790. }
  4791. //数据排序
  4792. $order_str = "id desc";
  4793. if (empty($page)) {
  4794. $start = 0;
  4795. $perpage = 1;
  4796. } else {
  4797. $start = ($page - 1) * $perpage;
  4798. }
  4799. //取得信息列表
  4800. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4801. $rows = array();
  4802. $list = array();
  4803. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4804. // foreach ($info_list as $value)
  4805. // {
  4806. // $warehouse = $this->warehouse->read($value['warehouse']);
  4807. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4808. // $number = $value['number'];$ftime = time()-15*24*3600;
  4809. // if($c < 1)
  4810. // {
  4811. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4812. // }
  4813. // }
  4814. $warehouse_list = $this->warehouse->find_all();
  4815. $warehouse_list = array_column($warehouse_list, null, 'id');
  4816. foreach ($info_list as $value) {
  4817. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4818. 'title' => "",
  4819. ];
  4820. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4821. $number = $value['number'];
  4822. $ftime = time() - 15 * 24 * 3600;
  4823. if ($c < 1) {
  4824. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4825. }
  4826. }
  4827. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4828. // $query = $this->db->query($sql);
  4829. // $info_list = $query->result_array();
  4830. // $sql_two = "select title,id from crowd_warehouse";
  4831. // $query_two = $this->db->query($sql_two);
  4832. // $warehouse_list = $query_two->result_array();
  4833. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4834. // foreach ($info_list as $value)
  4835. // {
  4836. // if(isset($warehouse_arr[$value['warehouse']])){
  4837. // $warehouse = $warehouse_arr[$value['warehouse']];
  4838. // }else{
  4839. // $warehouse = [
  4840. // 'id'=>0,
  4841. // 'title'=>"异常",
  4842. // ];
  4843. // }
  4844. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4845. // $number = $value['number'];$ftime = time()-15*24*3600;
  4846. // if($c < 1)
  4847. // {
  4848. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4849. // }
  4850. // }
  4851. $listdata = array_slice($list, $start, $perpage);
  4852. $total = count($list);
  4853. $pagenum = ceil($total / $perpage);
  4854. $over = $total - ($start + $perpage);
  4855. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4856. echo json_encode($rows);
  4857. exit;
  4858. }
  4859. if (isset($post['s'])) {
  4860. $id_arr = $this->input->post('s');
  4861. $id_arr = explode(',', trim($id_arr, ','));
  4862. if (!$id_arr) {
  4863. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4864. exit;
  4865. }
  4866. //循环删除记录
  4867. foreach ($id_arr as $v) {
  4868. $dd = $this->whlabel->read($v);
  4869. if (!isset($dd['id'])) {
  4870. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4871. exit;
  4872. }
  4873. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4874. if (isset($zt[0])) {
  4875. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4876. exit;
  4877. }
  4878. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4879. foreach ($deldd as $vv) {
  4880. $this->whlabel->remove($vv['id']);
  4881. }
  4882. }
  4883. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4884. exit;
  4885. }
  4886. $this->_Template('whlabel_error', $this->data);
  4887. }
  4888. public function _errorexcel()
  4889. {
  4890. $post = $this->input->post(NULL, TRUE);
  4891. if (isset($_GET['page'])) {
  4892. $page = $this->input->get('page', true);
  4893. $perpage = $this->input->get('perpage', true);
  4894. $sku = $this->input->get('sku', true);
  4895. $warehouse = $this->input->get('warehouse', true);
  4896. $ktime = $this->input->get('ktime', true);
  4897. $jtime = $this->input->get('jtime', true);
  4898. $ktime = strtotime($ktime);
  4899. $jtime = strtotime($jtime);
  4900. $where = "sku != 'Preset'";
  4901. $gj = '';
  4902. if ($sku) {
  4903. $where .= " and sku like '%$sku%'";
  4904. } else {
  4905. if ($ktime && $jtime) {
  4906. $gj = " and time > '$ktime' and time < '$jtime'";
  4907. }
  4908. }
  4909. if ($warehouse) {
  4910. $where .= " and warehouse = '$warehouse'";
  4911. }
  4912. //数据排序
  4913. $order_str = "id desc";
  4914. if (empty($page)) {
  4915. $start = 0;
  4916. $perpage = 1;
  4917. } else {
  4918. $start = ($page - 1) * $perpage;
  4919. }
  4920. //取得信息列表
  4921. $rows = array();
  4922. $list = array();
  4923. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4924. foreach ($info_list as $value) {
  4925. $warehouse = $this->warehouse->read($value['warehouse']);
  4926. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4927. $number = $value['number'];
  4928. $ftime = time() - 15 * 24 * 3600;
  4929. if ($c < 1) {
  4930. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4931. }
  4932. }
  4933. $title = "0库存汇总";
  4934. $titlename = "<table border=1>
  4935. <tr align='center'>
  4936. <td>仓库</td>
  4937. <td>SKU</td>
  4938. <td>产品</td>
  4939. <td>当前库存</td>
  4940. </tr>
  4941. </table>";
  4942. $filename = $title . ".xls";
  4943. $tail = "";
  4944. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4945. }
  4946. }
  4947. /**
  4948. *
  4949. *
  4950. * 占单
  4951. *
  4952. *
  4953. **/
  4954. public function _kcyz()
  4955. {
  4956. $post = $this->input->post(NULL, TRUE);
  4957. if (isset($post['warehouse'])) {
  4958. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4959. exit; //不再使用
  4960. $warehouse = $this->input->post('warehouse', true);
  4961. $whlabel = $this->input->post('whlabel', true);
  4962. $id = $this->input->post('id', true);
  4963. $shop = $this->input->post('shop', true);
  4964. $number = $this->input->post('number', true);
  4965. if (!$whlabel || $whlabel == '|') {
  4966. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4967. exit;
  4968. }
  4969. $pp = explode('|', trim($whlabel, '|'));
  4970. $x = 0;
  4971. $save = array();
  4972. foreach ($pp as $va) {
  4973. $num = explode('-', $va);
  4974. if ($number) {
  4975. $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 = '')"); //通用
  4976. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4977. } else {
  4978. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4979. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4980. }
  4981. $x++;
  4982. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4983. $save[] = $x - 1;
  4984. continue; //提前先加X不然出错,所以要减1
  4985. }
  4986. }
  4987. if (isset($save[0])) {
  4988. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4989. exit;
  4990. } else {
  4991. echo json_encode(array('success' => true));
  4992. exit;
  4993. }
  4994. }
  4995. }
  4996. public function _db()
  4997. {
  4998. $post = $this->input->post(NULL, TRUE);
  4999. if (isset($post['page'])) {
  5000. $page = $this->input->post('page', true);
  5001. $perpage = $this->input->post('perpage', true);
  5002. $sku = $this->input->post('sku', true);
  5003. $number = $this->input->post('number', true);
  5004. $warehouse = $this->input->post('warehouse', true);
  5005. $purchase = $this->input->post('purchase', true);
  5006. $orderinfo = $this->input->post('orderinfo', true);
  5007. $waybill = $this->input->post('waybill', true);
  5008. $category = $this->input->post('category', true);
  5009. $size = $this->input->post('size', true);
  5010. $grade = $this->input->post('grade', true);
  5011. $color = $this->input->post('color', true);
  5012. $lowe = $this->input->post('lowe', true);
  5013. $state = $this->input->post('state', true);
  5014. $label = $this->input->post('label', true);
  5015. $timetk = $this->input->post('timetkk', true);
  5016. $timetj = $this->input->post('timetjj', true);
  5017. $timetk = strtotime($timetk);
  5018. $timetj = strtotime($timetj);
  5019. $where = "dbtime > 0";
  5020. if ($timetk && $timetj) {
  5021. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5022. }
  5023. if ($sku) {
  5024. $where .= " and sku = '$sku'";
  5025. }
  5026. if ($warehouse) {
  5027. $where .= " and warehouse = '$warehouse'";
  5028. if ($warehouse == 12) {
  5029. $w = 'specialstock';
  5030. } else {
  5031. $w = 'whlabel';
  5032. }
  5033. }
  5034. if ($purchase) {
  5035. $where .= " and purchase = '$purchase'";
  5036. }
  5037. if ($category) {
  5038. $where .= " and features like '%-$category-%'";
  5039. }
  5040. if ($size) {
  5041. $where .= " and features like '%-$size-%'";
  5042. }
  5043. if ($grade) {
  5044. $where .= " and features like '%-$grade-%'";
  5045. }
  5046. if ($color) {
  5047. $where .= " and features like '%-$color-%'";
  5048. }
  5049. if ($lowe) {
  5050. $where .= " and features like '%-$lowe-%'";
  5051. }
  5052. if ($state != '') {
  5053. $where .= " and state = '$state'";
  5054. }
  5055. //数据排序
  5056. $order_str = "dbtime desc";
  5057. if (empty($page)) {
  5058. $start = 0;
  5059. $perpage = 1;
  5060. } else {
  5061. $start = ($page - 1) * $perpage;
  5062. }
  5063. //取得信息列表
  5064. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5065. foreach ($info_list as $key => $value) {
  5066. $warehouse = $this->$w->read($value['warehouse']);
  5067. $info_list[$key]['warehouse'] = $warehouse['title'];
  5068. $purchase = $this->purchase->read($value['purchase']);
  5069. $info_list[$key]['purchase'] = $purchase['title'];
  5070. if ($value['enter'] != 0) {
  5071. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5072. } else {
  5073. $info_list[$key]['enter'] = "";
  5074. }
  5075. if ($value['dbtime'] != 0) {
  5076. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5077. } else {
  5078. $info_list[$key]['dbtime'] = "";
  5079. }
  5080. if ($value['state'] == 0) {
  5081. $info_list[$key]['state'] = "在库";
  5082. } else if ($value['state'] == 1) {
  5083. $info_list[$key]['state'] = "出库";
  5084. } else if ($value['state'] == 2) {
  5085. $info_list[$key]['state'] = "退库";
  5086. } else if ($value['state'] == 3) {
  5087. $info_list[$key]['state'] = "调拨中";
  5088. } else if ($value['state'] == 4) {
  5089. $info_list[$key]['state'] = "再加工";
  5090. } else if ($value['state'] == 5) {
  5091. $info_list[$key]['state'] = "维修中";
  5092. } else if ($value['state'] == 6) {
  5093. $info_list[$key]['state'] = "盘亏";
  5094. } else if ($value['state'] == 7) {
  5095. $info_list[$key]['state'] = "更换标签";
  5096. } else if ($value['state'] == 8) {
  5097. $info_list[$key]['state'] = "其它";
  5098. } else if ($value['state'] == 9) {
  5099. $info_list[$key]['state'] = "预设";
  5100. }
  5101. }
  5102. $total = $this->whlabel->find_count($where);
  5103. $pagenum = ceil($total / $perpage);
  5104. $over = $total - ($start + $perpage);
  5105. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5106. echo json_encode($rows);
  5107. exit;
  5108. }
  5109. if (isset($post['outsku'])) {
  5110. $time = time();
  5111. $cz = $this->input->post('cz', true);
  5112. $label = $this->input->post('outsku', true);
  5113. $sl = $this->input->post('sl', true);
  5114. $num = $this->input->post('num', true);
  5115. //$warehouse = $this->input->post('warehouse',true);
  5116. if (!$sl) {
  5117. $sl = 1;
  5118. }
  5119. if (!$warehouse) {
  5120. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5121. exit;
  5122. }
  5123. $dblabel = $this->whlabellabel->get_label($label);
  5124. if ($dblabel) {
  5125. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5126. if (count($data) < 1) {
  5127. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5128. exit;
  5129. }
  5130. if (count($data) < $num) {
  5131. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5132. exit;
  5133. }
  5134. for ($i = 0; $i < $sl; $i++) {
  5135. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5136. }
  5137. echo json_encode(array('success' => true));
  5138. exit;
  5139. } else {
  5140. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5141. exit;
  5142. }
  5143. }
  5144. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5145. $this->_Template('whlabel_db', $this->data);
  5146. }
  5147. public function _dbrk()
  5148. {
  5149. $post = $this->input->post(NULL, TRUE);
  5150. if (isset($post['page'])) {
  5151. $page = $this->input->post('page', true);
  5152. $perpage = $this->input->post('perpage', true);
  5153. $sku = $this->input->post('sku', true);
  5154. $number = $this->input->post('number', true);
  5155. $warehouse = $this->input->post('warehouse', true);
  5156. $purchase = $this->input->post('purchase', true);
  5157. $orderinfo = $this->input->post('orderinfo', true);
  5158. $waybill = $this->input->post('waybill', true);
  5159. $category = $this->input->post('category', true);
  5160. $size = $this->input->post('size', true);
  5161. $grade = $this->input->post('grade', true);
  5162. $color = $this->input->post('color', true);
  5163. $lowe = $this->input->post('lowe', true);
  5164. $state = $this->input->post('state', true);
  5165. $label = $this->input->post('label', true);
  5166. $ctime = $this->input->post('ctime', true);
  5167. $timetk = $this->input->post('timetkk', true);
  5168. $timetj = $this->input->post('timetjj', true);
  5169. $timetk = strtotime($timetk);
  5170. $timetj = strtotime($timetj);
  5171. $where = "dbtime > 0";
  5172. if ($timetk && $timetj) {
  5173. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5174. }
  5175. if ($sku) {
  5176. $where .= " and sku = '$sku'";
  5177. }
  5178. if ($warehouse) {
  5179. $where .= " and warehouse = '$warehouse'";
  5180. }
  5181. if ($purchase) {
  5182. $where .= " and purchase = '$purchase'";
  5183. }
  5184. if ($category) {
  5185. $where .= " and features like '%-$category-%'";
  5186. }
  5187. if ($size) {
  5188. $where .= " and features like '%-$size-%'";
  5189. }
  5190. if ($grade) {
  5191. $where .= " and features like '%-$grade-%'";
  5192. }
  5193. if ($color) {
  5194. $where .= " and features like '%-$color-%'";
  5195. }
  5196. if ($lowe) {
  5197. $where .= " and features like '%-$lowe-%'";
  5198. }
  5199. if ($state != '') {
  5200. $where .= " and state = '$state'";
  5201. }
  5202. //数据排序
  5203. $order_str = "dbtime desc";
  5204. if (empty($page)) {
  5205. $start = 0;
  5206. $perpage = 1;
  5207. } else {
  5208. $start = ($page - 1) * $perpage;
  5209. }
  5210. //取得信息列表
  5211. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5212. foreach ($info_list as $key => $value) {
  5213. $warehouse = $this->warehouse->read($value['warehouse']);
  5214. $info_list[$key]['warehouse'] = $warehouse['title'];
  5215. $purchase = $this->purchase->read($value['purchase']);
  5216. $info_list[$key]['purchase'] = $purchase['title'];
  5217. if ($value['enter'] != 0) {
  5218. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5219. } else {
  5220. $info_list[$key]['enter'] = "";
  5221. }
  5222. if ($value['dbtime'] != 0) {
  5223. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5224. } else {
  5225. $info_list[$key]['dbtime'] = "";
  5226. }
  5227. if ($value['state'] == 0) {
  5228. $info_list[$key]['state'] = "在库";
  5229. } else if ($value['state'] == 1) {
  5230. $info_list[$key]['state'] = "出库";
  5231. } else if ($value['state'] == 2) {
  5232. $info_list[$key]['state'] = "退库";
  5233. } else if ($value['state'] == 3) {
  5234. $info_list[$key]['state'] = "调拨中";
  5235. } else if ($value['state'] == 4) {
  5236. $info_list[$key]['state'] = "再加工";
  5237. } else if ($value['state'] == 5) {
  5238. $info_list[$key]['state'] = "维修中";
  5239. } else if ($value['state'] == 6) {
  5240. $info_list[$key]['state'] = "盘亏";
  5241. } else if ($value['state'] == 7) {
  5242. $info_list[$key]['state'] = "更换标签";
  5243. } else if ($value['state'] == 8) {
  5244. $info_list[$key]['state'] = "其它";
  5245. } else if ($value['state'] == 9) {
  5246. $info_list[$key]['state'] = "预设";
  5247. }
  5248. }
  5249. $total = $this->whlabel->find_count($where);
  5250. $pagenum = ceil($total / $perpage);
  5251. $over = $total - ($start + $perpage);
  5252. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5253. echo json_encode($rows);
  5254. exit;
  5255. }
  5256. if (isset($post['rsku'])) {
  5257. $cz = $this->input->post('cz', true);
  5258. $label = $this->input->post('rsku', true);
  5259. $sl = $this->input->post('sl', true);
  5260. $warehouse = $this->input->post('warehouse', true);
  5261. if (!$sl) {
  5262. $sl = 1;
  5263. }
  5264. if (!$warehouse) {
  5265. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5266. exit;
  5267. }
  5268. $dblabel = $this->whlabellabel->get_label($label);
  5269. if ($dblabel) {
  5270. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5271. if (count($data) < 1) {
  5272. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5273. exit;
  5274. }
  5275. if ($sl > count($data)) {
  5276. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5277. exit;
  5278. }
  5279. $time = time();
  5280. for ($i = 0; $i < $sl; $i++) {
  5281. $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']);
  5282. }
  5283. echo json_encode(array('success' => true));
  5284. exit;
  5285. } else {
  5286. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5287. exit;
  5288. }
  5289. }
  5290. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5291. $this->_Template('whlabel_dbrk', $this->data);
  5292. }
  5293. public function _whlabelczdc()
  5294. {
  5295. if (isset($_GET['excel'])) {
  5296. //数据排序
  5297. $order_str = "id desc";
  5298. if (empty($page)) {
  5299. $start = 0;
  5300. $perpage = 1;
  5301. } else {
  5302. $start = ($page - 1) * $perpage;
  5303. }
  5304. $state = $this->input->get('state', true);
  5305. $sku = $this->input->get('sku', true);
  5306. $ctime = $this->input->get('ctime', true);
  5307. $category = $this->input->get('category', true);
  5308. $size = $this->input->get('size', true);
  5309. $grade = $this->input->get('grade', true);
  5310. $color = $this->input->get('color', true);
  5311. $lowe = $this->input->get('lowe', true);
  5312. $timetk = $this->input->get('timetkk', true);
  5313. $timetj = $this->input->get('timetjj', true);
  5314. $timetk = strtotime($timetk);
  5315. $timetj = strtotime($timetj);
  5316. $where = "dbtime > 0";
  5317. if ($timetk && $timetj) {
  5318. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5319. }
  5320. if ($category) {
  5321. $where .= " and features like '%-$category-%'";
  5322. }
  5323. if ($size) {
  5324. $where .= " and features like '%-$size-%'";
  5325. }
  5326. if ($grade) {
  5327. $where .= " and features like '%-$grade-%'";
  5328. }
  5329. if ($color) {
  5330. $where .= " and features like '%-$color-%'";
  5331. }
  5332. if ($lowe) {
  5333. $where .= " and features like '%-$lowe-%'";
  5334. }
  5335. //取得信息列表
  5336. $info_list = $this->whlabel->find_all($where, '*');
  5337. $rows = array();
  5338. $list = array();
  5339. foreach ($info_list as $key => $value) {
  5340. $rows[$value['sku']] = $value; //所有数据sku
  5341. }
  5342. foreach ($rows as $value) {
  5343. $warehouse = $this->warehouse->read($value['warehouse']);
  5344. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5345. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5346. if ($value['orderinfo'] == 0) {
  5347. $info_list[$key]['orderinfo'] = "";
  5348. }
  5349. if ($value['waybill'] == 0) {
  5350. $info_list[$key]['waybill'] = "";
  5351. }
  5352. if ($value['state'] == 0) {
  5353. $value['state'] = "在库";
  5354. } else if ($value['state'] == 3) {
  5355. $value['state'] = "调拨中";
  5356. }
  5357. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5358. }
  5359. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5360. $titlename = "<table border=1>
  5361. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5362. <tr align='center'>
  5363. <td>SKU</td>
  5364. <td>产品</td>
  5365. <td>调拨数量</td>
  5366. <td>入库数量</td>
  5367. </tr>
  5368. </table>";
  5369. $filename = $title . ".xls";
  5370. $tail = "";
  5371. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5372. }
  5373. }
  5374. public function _print($arg_array)
  5375. {
  5376. if (isset($_SESSION['api'])) {
  5377. $user = $this->user->get_api($_SESSION['api']);
  5378. $usp = $user;
  5379. $fgshop = "";
  5380. $sid = "";
  5381. $wid = "";
  5382. $wtype = "";
  5383. $usersp = explode('|', trim($user['shop'], '|'));
  5384. $userwh = explode('|', trim($user['warehouse'], '|'));
  5385. foreach ($usersp as $value) {
  5386. $fgshop .= " shop = " . $value . " or";
  5387. $sid .= " id = " . $value . " or";
  5388. }
  5389. foreach ($userwh as $value) {
  5390. $wid .= " id = " . $value . " or";
  5391. $wtype .= " type = " . $value . " or";
  5392. }
  5393. }
  5394. $post = $this->input->post(NULL, TRUE);
  5395. if (isset($post['tmsku'])) {
  5396. $tmsku = $this->input->post('tmsku', true);
  5397. if (is_numeric($tmsku)) {
  5398. $yyh = $this->whlabellabel->get_label($tmsku);
  5399. } else {
  5400. $yyh = $this->whlabellabel->get_sku($tmsku);
  5401. }
  5402. if ($yyh) {
  5403. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5404. exit;
  5405. } else {
  5406. echo json_encode(array('success' => false));
  5407. exit;
  5408. }
  5409. }
  5410. $classid = $this->classid->sku();
  5411. $pm = $classid;
  5412. $scsku = $classid;
  5413. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5414. if (isset($post['warehouse'])) {
  5415. if ($post['warehouse']) {
  5416. $list = array();
  5417. $num = "";
  5418. $title = "";
  5419. $features = "";
  5420. $order = 0;
  5421. $post['shop'] = '';
  5422. $brand = $this->input->post('brand', true);
  5423. if ($brand != '0,') {
  5424. $b = $this->brand->read(rtrim($brand, ','));
  5425. if ($b) {
  5426. $post['shop'] = str_replace('|', ',', $b['shop']);
  5427. }
  5428. }
  5429. $post['details'] = $this->input->post('details', true); //打印数量
  5430. $xbqnum = $this->input->post('xbqnum', true);
  5431. $post['purchase'] = $this->input->post('purchase', true);
  5432. $post['warehouse'] = $this->input->post('warehouse', true);
  5433. $post['purchase'] = $this->input->post('purchase', true);
  5434. $post['retreatwarehouse'] = $post['warehouse'];
  5435. $post['cpbz'] = $this->input->post('cpbz', true);
  5436. $post['state'] = 9;
  5437. $category = $this->input->post('category', true);
  5438. $list['category'] = $category;
  5439. $list['hairtype'] = $this->input->post('hairtype', true);
  5440. $list['grade'] = $this->input->post('grade', true);
  5441. $size = $this->input->post('size', true);
  5442. $list['size'] = rtrim($size, ',');
  5443. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5444. $list['extension'] = $this->input->post('extension', true);
  5445. if ($category == 1297) {
  5446. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5447. }
  5448. if ($category == 1702) {
  5449. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5450. $list['syother'] = $this->input->post('syother', true);
  5451. }
  5452. if ($category == 133) {
  5453. $list['fittype'] = $this->input->post('fittype', true);
  5454. $list['acother'] = $this->input->post('acother', true);
  5455. }
  5456. $list['color'] = $this->input->post('color', true);
  5457. $list['lowe'] = $this->input->post('lowe', true);
  5458. if ($category == 127) {
  5459. $list['type'] = $this->input->post('type', true);
  5460. $list['headroad'] = $this->input->post('headroad', true);
  5461. $list['density'] = $this->input->post('density', true);
  5462. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5463. $list['lacesize'] = $this->input->post('lacesize', true);
  5464. }
  5465. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5466. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5467. }
  5468. if ($category == 128) {
  5469. $list['lacetype'] = $this->input->post('lacetype', true);
  5470. $list['haircap'] = $this->input->post('haircap', true);
  5471. $list['density'] = $this->input->post('density', true);
  5472. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5473. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5474. $list['wigother'] = $this->input->post('wigother', true);
  5475. $list['wigother1'] = $this->input->post('wigother1', true);
  5476. $list['wigother2'] = $this->input->post('wigother2', true);
  5477. }
  5478. if ($category == 129) {
  5479. $list['wide'] = $this->input->post('wide', true);
  5480. }
  5481. if ($category == 131) {
  5482. $list['gifttype'] = $this->input->post('gifttype', true);
  5483. $list['giftother'] = $this->input->post('giftother', true);
  5484. }
  5485. if ($category == 134) {
  5486. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5487. }
  5488. if ($category == 1297) {
  5489. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5490. $list['sywigother'] = $this->input->post('sywigother', true);
  5491. }
  5492. if ($category == 130 || $category == 133 || $category == 1702) {
  5493. $list['items'] = $this->input->post('items', true);
  5494. $list['weight'] = $this->input->post('weight', true);
  5495. }
  5496. if ($category == 1702) {
  5497. $list['syhairther'] = $this->input->post('syhairther', true);
  5498. }
  5499. foreach ($list as $k => $v) {
  5500. if ($v != 0) {
  5501. $num .= $v;
  5502. $features .= $v . '-';
  5503. $post[$k] = $v;
  5504. $typeclass = $this->typeclass->read($v);
  5505. if (isset($pm[$typeclass['classid']])) {
  5506. if (stripos($typeclass['zh'], '|') !== false) {
  5507. $exzh = explode('|', $typeclass['zh']);
  5508. $pm[$typeclass['classid']] = $exzh[0];
  5509. } else {
  5510. $pm[$typeclass['classid']] = $typeclass['zh'];
  5511. }
  5512. }
  5513. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5514. if ($k != 'size') {
  5515. $title .= $typeclass['title'] . " ";
  5516. }
  5517. }
  5518. }
  5519. $typeclass = $this->typeclass->read($list['size']);
  5520. $title .= $typeclass['title'];
  5521. $time = time();
  5522. $post['title'] = rtrim($title, ' ');
  5523. $post['number'] = $num;
  5524. $post['features'] = '-' . $features;
  5525. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5526. $featurespp = explode('-', trim($featurespp, '-'));
  5527. if (isset($featurespp[5])) {
  5528. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5529. } else {
  5530. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5531. }
  5532. $post['enter'] = $time;
  5533. $post['time'] = $time; //操作时间
  5534. $scsku = implode("-", $scsku);
  5535. $zh = implode(" ", $pm);
  5536. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5537. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5538. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5539. $post['sku'] = $bqsku;
  5540. $label = time() . rand(0, 9);
  5541. $post['label'] = $label;
  5542. $cpid = $this->whlabellabel->find_count();
  5543. $post['cpid'] = $cpid + 1;
  5544. $cpid = $post['cpid'];
  5545. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5546. //if($whlabelbarcode)
  5547. //{
  5548. //$post['label'] = $whlabelbarcode['label'];
  5549. //if(!$this->whlabellabel->insert($post))
  5550. //{
  5551. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5552. //}
  5553. //}
  5554. //else
  5555. //{
  5556. $this->db->trans_begin();
  5557. $this->whlabellabel->insert($post);
  5558. //$this->whlabelbarcode->insert($post);
  5559. if ($this->db->trans_status() === TRUE) {
  5560. $this->db->trans_commit();
  5561. } else {
  5562. $this->db->trans_rollback();
  5563. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5564. exit;
  5565. }
  5566. //}
  5567. $warehouse_name = "";
  5568. $warehouse = $post['warehouse'];
  5569. if($warehouse == 12){
  5570. $warehouse_name = "特殊库存库";
  5571. }
  5572. // if($warehouse == 13){
  5573. // $warehouse_name = "许昌仓";
  5574. // }
  5575. // if($warehouse == 5){
  5576. // $warehouse_name = "美国店";
  5577. // }
  5578. // if($warehouse == 16){
  5579. // $warehouse_name = "定制头套仓";
  5580. // }
  5581. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5582. if(!empty($warehouse_name)){
  5583. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5584. }
  5585. $purchase = $this->purchase->read($post['purchase']);
  5586. 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));
  5587. exit; //特殊仓目前不需要仓库选项
  5588. }
  5589. }
  5590. if (isset($_SESSION['api'])) {
  5591. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5592. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5593. $this->data['wlshop'] = $wlshop;
  5594. $this->data['warehouse'] = $warehouse;
  5595. }
  5596. $whlabelwz = $this->whlabelwz->find_all();
  5597. $this->data['whlabelwz'] = $whlabelwz;
  5598. $this->_Template('whlabel_print', $this->data);
  5599. }
  5600. public function _usaprint($arg_array)
  5601. {
  5602. if (isset($_SESSION['api'])) {
  5603. $user = $this->user->get_api($_SESSION['api']);
  5604. $usp = $user;
  5605. $fgshop = "";
  5606. $sid = "";
  5607. $wid = "";
  5608. $wtype = "";
  5609. $usersp = explode('|', trim($user['shop'], '|'));
  5610. $userwh = explode('|', trim($user['warehouse'], '|'));
  5611. foreach ($usersp as $value) {
  5612. $fgshop .= " shop = " . $value . " or";
  5613. $sid .= " id = " . $value . " or";
  5614. }
  5615. foreach ($userwh as $value) {
  5616. $wid .= " id = " . $value . " or";
  5617. $wtype .= " type = " . $value . " or";
  5618. }
  5619. }
  5620. $post = $this->input->post(NULL, TRUE);
  5621. if (isset($post['tmsku'])) {
  5622. $tmsku = $this->input->post('tmsku', true);
  5623. if (is_numeric($tmsku)) {
  5624. $yyh = $this->whlabellabel->get_label($tmsku);
  5625. } else {
  5626. $yyh = $this->whlabellabel->get_sku($tmsku);
  5627. }
  5628. if ($yyh) {
  5629. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5630. exit;
  5631. } else {
  5632. echo json_encode(array('success' => false));
  5633. exit;
  5634. }
  5635. }
  5636. $classid = $this->classid->sku();
  5637. $pm = $classid;
  5638. $scsku = $classid;
  5639. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5640. if (isset($post['warehouse'])) {
  5641. if ($post['warehouse']) {
  5642. $list = array();
  5643. $num = "";
  5644. $title = "";
  5645. $features = "";
  5646. $order = 0;
  5647. $post['shop'] = '';
  5648. $brand = $this->input->post('brand', true);
  5649. if ($brand != '0,') {
  5650. $b = $this->brand->read(rtrim($brand, ','));
  5651. if ($b) {
  5652. $post['shop'] = str_replace('|', ',', $b['shop']);
  5653. }
  5654. }
  5655. $post['details'] = $this->input->post('details', true); //打印数量
  5656. $xbqnum = $this->input->post('xbqnum', true);
  5657. $post['purchase'] = $this->input->post('purchase', true);
  5658. $post['warehouse'] = $this->input->post('warehouse', true);
  5659. $post['purchase'] = $this->input->post('purchase', true);
  5660. $post['retreatwarehouse'] = $post['warehouse'];
  5661. $post['cpbz'] = $this->input->post('cpbz', true);
  5662. $post['state'] = 9;
  5663. $category = $this->input->post('category', true);
  5664. $list['category'] = $category;
  5665. $list['hairtype'] = $this->input->post('hairtype', true);
  5666. $list['grade'] = $this->input->post('grade', true);
  5667. $size = $this->input->post('size', true);
  5668. $list['size'] = rtrim($size, ',');
  5669. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5670. $list['extension'] = $this->input->post('extension', true);
  5671. if ($category == 1297) {
  5672. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5673. }
  5674. if ($category == 1702) {
  5675. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5676. $list['syother'] = $this->input->post('syother', true);
  5677. }
  5678. if ($category == 133) {
  5679. $list['fittype'] = $this->input->post('fittype', true);
  5680. $list['acother'] = $this->input->post('acother', true);
  5681. }
  5682. $list['color'] = $this->input->post('color', true);
  5683. $list['lowe'] = $this->input->post('lowe', true);
  5684. if ($category == 127) {
  5685. $list['type'] = $this->input->post('type', true);
  5686. $list['headroad'] = $this->input->post('headroad', true);
  5687. $list['density'] = $this->input->post('density', true);
  5688. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5689. $list['lacesize'] = $this->input->post('lacesize', true);
  5690. }
  5691. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5692. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5693. }
  5694. if ($category == 128) {
  5695. $list['lacetype'] = $this->input->post('lacetype', true);
  5696. $list['haircap'] = $this->input->post('haircap', true);
  5697. $list['density'] = $this->input->post('density', true);
  5698. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5699. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5700. $list['wigother'] = $this->input->post('wigother', true);
  5701. $list['wigother1'] = $this->input->post('wigother1', true);
  5702. $list['wigother2'] = $this->input->post('wigother2', true);
  5703. }
  5704. if ($category == 129) {
  5705. $list['wide'] = $this->input->post('wide', true);
  5706. }
  5707. if ($category == 131) {
  5708. $list['gifttype'] = $this->input->post('gifttype', true);
  5709. $list['giftother'] = $this->input->post('giftother', true);
  5710. }
  5711. if ($category == 134) {
  5712. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5713. }
  5714. if ($category == 1297) {
  5715. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5716. $list['sywigother'] = $this->input->post('sywigother', true);
  5717. }
  5718. if ($category == 130 || $category == 133 || $category == 1702) {
  5719. $list['items'] = $this->input->post('items', true);
  5720. $list['weight'] = $this->input->post('weight', true);
  5721. }
  5722. if ($category == 1702) {
  5723. $list['syhairther'] = $this->input->post('syhairther', true);
  5724. }
  5725. foreach ($list as $k => $v) {
  5726. if ($v != 0) {
  5727. $num .= $v;
  5728. $features .= $v . '-';
  5729. $post[$k] = $v;
  5730. $typeclass = $this->typeclass->read($v);
  5731. if (isset($pm[$typeclass['classid']])) {
  5732. if (stripos($typeclass['zh'], '|') !== false) {
  5733. $exzh = explode('|', $typeclass['zh']);
  5734. $pm[$typeclass['classid']] = $exzh[0];
  5735. } else {
  5736. $pm[$typeclass['classid']] = $typeclass['zh'];
  5737. }
  5738. }
  5739. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5740. if ($k != 'size') {
  5741. $title .= $typeclass['title'] . " ";
  5742. }
  5743. }
  5744. }
  5745. $typeclass = $this->typeclass->read($list['size']);
  5746. $title .= $typeclass['title'];
  5747. $time = time();
  5748. $post['title'] = rtrim($title, ' ');
  5749. $post['number'] = $num;
  5750. $post['features'] = '-' . $features;
  5751. $fp = $this->whlabel->get_features($post['features']);
  5752. if (!$fp) {
  5753. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5754. exit;
  5755. }
  5756. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5757. $featurespp = explode('-', trim($featurespp, '-'));
  5758. if (isset($featurespp[5])) {
  5759. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5760. } else {
  5761. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5762. }
  5763. $post['enter'] = $time;
  5764. $post['time'] = $time; //操作时间
  5765. $scsku = implode("-", $scsku);
  5766. $zh = implode(" ", $pm);
  5767. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5768. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5769. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5770. $post['sku'] = $fp['sku'];
  5771. $post['label'] = $fp['sku'];
  5772. $cpid = $this->whlabellabel->find_count();
  5773. $post['cpid'] = $cpid + 1;
  5774. $cpid = $post['cpid'];
  5775. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5776. //if($whlabelbarcode)
  5777. //{
  5778. //$post['label'] = $whlabelbarcode['label'];
  5779. //if(!$this->whlabellabel->insert($post))
  5780. //{
  5781. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5782. //}
  5783. //}
  5784. //else
  5785. //{
  5786. $this->db->trans_begin();
  5787. $this->whlabellabel->insert($post);
  5788. //$this->whlabelbarcode->insert($post);
  5789. if ($this->db->trans_status() === TRUE) {
  5790. $this->db->trans_commit();
  5791. } else {
  5792. $this->db->trans_rollback();
  5793. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5794. exit;
  5795. }
  5796. //}
  5797. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5798. $purchase = $this->purchase->read($post['purchase']);
  5799. 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));
  5800. exit; //特殊仓目前不需要仓库选项
  5801. }
  5802. }
  5803. if (isset($_SESSION['api'])) {
  5804. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5805. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5806. $this->data['wlshop'] = $wlshop;
  5807. $this->data['warehouse'] = $warehouse;
  5808. }
  5809. $whlabelwz = $this->whlabelwz->find_all();
  5810. $this->data['whlabelwz'] = $whlabelwz;
  5811. $this->_Template('whlabel_usaprint', $this->data);
  5812. }
  5813. public function _printrk($arg_array)
  5814. {
  5815. $prc = array();
  5816. $purchase = $this->purchase->find_all();
  5817. foreach ($purchase as $k => $v) {
  5818. $prc[$v['id']] = $v['title'];
  5819. }
  5820. $post = $this->input->post(NULL, TRUE);
  5821. if (isset($post['page'])) {
  5822. $page = $this->input->post('page', true);
  5823. $perpage = $this->input->post('perpage', true);
  5824. $sku = $this->input->post('sku', true);
  5825. $bs = $this->input->post('bs', true);
  5826. $number = $this->input->post('number', true);
  5827. $warehouse = $this->input->post('warehouse', true);
  5828. $purchase = $this->input->post('purchase', true);
  5829. $orderinfo = $this->input->post('orderinfo', true);
  5830. $waybill = $this->input->post('waybill', true);
  5831. $category = $this->input->post('category', true);
  5832. $size = $this->input->post('size', true);
  5833. $grade = $this->input->post('grade', true);
  5834. $color = $this->input->post('color', true);
  5835. $lowe = $this->input->post('lowe', true);
  5836. $state = $this->input->post('state', true);
  5837. $label = $this->input->post('label', true);
  5838. $timetk = $this->input->post('ktime', true);
  5839. $timetj = $this->input->post('jtime', true);
  5840. $timetk = strtotime($timetk);
  5841. $timetj = strtotime($timetj);
  5842. $where = "1=1 ";
  5843. if ($timetk && $timetj) {
  5844. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5845. }
  5846. if ($sku) {
  5847. $where .= " and sku = '$sku'";
  5848. }
  5849. if ($bs != '') {
  5850. $where .= " and bs = '$bs'";
  5851. }
  5852. if ($number) {
  5853. $where .= " and number = '$number'";
  5854. }
  5855. if ($warehouse) {
  5856. $where .= " and warehouse = '$warehouse'";
  5857. }
  5858. if ($purchase) {
  5859. $where .= " and purchase = '$purchase'";
  5860. }
  5861. if ($orderinfo) {
  5862. $where .= " and orderinfo = '$orderinfo'";
  5863. }
  5864. if ($waybill) {
  5865. $where .= " and waybill = '$waybill'";
  5866. }
  5867. if ($category) {
  5868. $where .= " and features like '%-$category-%'";
  5869. }
  5870. if ($size) {
  5871. $where .= " and features like '%-$size-%'";
  5872. }
  5873. if ($grade) {
  5874. $where .= " and features like '%-$grade-%'";
  5875. }
  5876. if ($color) {
  5877. $where .= " and features like '%-$color-%'";
  5878. }
  5879. if ($lowe) {
  5880. $where .= " and features like '%-$lowe-%'";
  5881. }
  5882. if ($label) {
  5883. $where .= " and label = '$label'";
  5884. }
  5885. if ($state || $state == 0) {
  5886. $where .= " and state = '$state'";
  5887. }
  5888. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5889. //数据排序
  5890. $order_str = "enter desc";
  5891. if (empty($page)) {
  5892. $start = 0;
  5893. $perpage = 1;
  5894. } else {
  5895. $start = ($page - 1) * $perpage;
  5896. }
  5897. //取得信息列表
  5898. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5899. foreach ($info_list as $key => $value) {
  5900. $warehouse = $this->warehouse->read($value['warehouse']);
  5901. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5902. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5903. if ($value['state'] == 0) {
  5904. $info_list[$key]['state'] = "在库";
  5905. } else if ($value['state'] == 1) {
  5906. $info_list[$key]['state'] = "出库";
  5907. } else if ($value['state'] == 2) {
  5908. $info_list[$key]['state'] = "退库";
  5909. } else if ($value['state'] == 3) {
  5910. $info_list[$key]['state'] = "调拨中";
  5911. } else if ($value['state'] == 4) {
  5912. $info_list[$key]['state'] = "再加工";
  5913. } else if ($value['state'] == 5) {
  5914. $info_list[$key]['state'] = "维修中";
  5915. } else if ($value['state'] == 6) {
  5916. $info_list[$key]['state'] = "盘亏";
  5917. } else if ($value['state'] == 7) {
  5918. $info_list[$key]['state'] = "更换标签";
  5919. } else if ($value['state'] == 8) {
  5920. $info_list[$key]['state'] = "其它";
  5921. } else if ($value['state'] == 9) {
  5922. $info_list[$key]['state'] = "预设";
  5923. } else if ($value['state'] == 10) {
  5924. $info_list[$key]['state'] = "美店零售";
  5925. }
  5926. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5927. }
  5928. $total = $this->$ck->find_count($where);
  5929. $pagenum = ceil($total / $perpage);
  5930. $over = $total - ($start + $perpage);
  5931. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5932. echo json_encode($rows);
  5933. exit;
  5934. }
  5935. if (isset($post['tmsku'])) {
  5936. $time = time();
  5937. $tmsku = $this->input->post('tmsku', true);
  5938. //$post['shop'] = $this->input->post('shop',true);
  5939. $num = $this->input->post('num', true);
  5940. $rktype = $this->input->post('rktype', true);
  5941. if ($num > 200) {
  5942. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5943. exit;
  5944. }
  5945. if (!$rktype) {
  5946. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5947. }
  5948. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5949. /**
  5950. $wz = array();
  5951. foreach ($rk as $key=>$value)
  5952. {
  5953. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5954. }
  5955. if(count($wz) > 1)
  5956. {
  5957. $wz = array_values($wz);
  5958. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5959. }
  5960. **/
  5961. if (isset($rk[0]['purchase'])) {
  5962. $rk = $rk[0];
  5963. $j = 0;
  5964. $post['purchase'] = $rk['purchase'];
  5965. $post['warehouse'] = $rk['warehouse'];
  5966. $post['retreatwarehouse'] = $rk['warehouse'];
  5967. $post['sku'] = $rk['sku'];
  5968. $post['number'] = $rk['number'];
  5969. $post['features'] = $rk['features'];
  5970. $post['title'] = $rk['title'];
  5971. $post['enter'] = $time;
  5972. $post['time'] = $time;
  5973. $post['bs'] = 1;
  5974. $post['shop'] = $rk['shop'];
  5975. $post['details'] = $rk['details'];
  5976. $post['cpid'] = $rk['cpid'];
  5977. $post['cpbz'] = $rk['cpbz'];
  5978. //$post['rktype'] = $rktype;
  5979. $warehouse = $this->warehouse->read($rk['warehouse']);
  5980. if ($warehouse['bdck'] == '') {
  5981. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5982. exit;
  5983. } else {
  5984. $bdck = $warehouse['bdck'];
  5985. }
  5986. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5987. if (isset($pdwz['details'])) {
  5988. if ($pdwz['details'] != $post['details']) {
  5989. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5990. exit;
  5991. }
  5992. }
  5993. $post['featurespp'] = $rk['featurespp'];
  5994. if ($post['warehouse'] == '5') {
  5995. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5996. if ($yza) {
  5997. if ($post['features'] != $yza[0]['features']) {
  5998. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5999. exit;
  6000. }
  6001. }
  6002. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6003. if ($yzb) {
  6004. if ($post['sku'] != $yzb[0]['sku']) {
  6005. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6006. exit;
  6007. }
  6008. }
  6009. }
  6010. for ($i = 0; $i < $num; $i++) {
  6011. $post['label'] = time() . rand(100, 999) . $i;
  6012. if ($this->$bdck->insert($post)) {
  6013. $j++;
  6014. }
  6015. }
  6016. /**
  6017. if($post['warehouse'] != 12)
  6018. {
  6019. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6020. }
  6021. **/
  6022. if ($j == $num) {
  6023. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6024. exit;
  6025. } else {
  6026. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6027. exit;
  6028. }
  6029. } else {
  6030. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6031. exit;
  6032. }
  6033. }
  6034. $this->_Template('whlabel_printrk', $this->data);
  6035. }
  6036. public function _printxzrk($arg_array)
  6037. {
  6038. $post = $this->input->post(NULL, TRUE);
  6039. if (isset($post['wzid'])) {
  6040. $time = time();
  6041. $id = $this->input->post('wzid', true);
  6042. //$post['shop'] = $this->input->post('shop',true);
  6043. $num = 1;
  6044. $rk = $this->whlabellabel->read($id);
  6045. if (isset($rk['purchase'])) {
  6046. $x = 0;
  6047. $post['purchase'] = $rk['purchase'];
  6048. $post['warehouse'] = $rk['warehouse'];
  6049. $post['retreatwarehouse'] = $rk['warehouse'];
  6050. $post['sku'] = $rk['sku'];
  6051. $post['number'] = $rk['number'];
  6052. $post['features'] = $rk['features'];
  6053. $post['title'] = $rk['title'];
  6054. $post['enter'] = $time;
  6055. $post['time'] = $time;
  6056. $post['bs'] = 1;
  6057. $post['shop'] = $rk['shop'];
  6058. $post['details'] = $rk['details'];
  6059. $post['cpid'] = $rk['cpid'];
  6060. $post['cpbz'] = $rk['cpbz'];
  6061. $warehouse = $this->warehouse->read($rk['warehouse']);
  6062. if ($warehouse['bdck'] == '') {
  6063. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6064. exit;
  6065. } else {
  6066. $bdck = $warehouse['bdck'];
  6067. }
  6068. $post['featurespp'] = $rk['featurespp'];
  6069. $this->db->trans_begin();
  6070. for ($i = 0; $i < $num; $i++) {
  6071. $post['label'] = time() . rand(100, 999) . $i;
  6072. $this->$bdck->insert($post);
  6073. }
  6074. /**
  6075. if($post['warehouse'] != 12)
  6076. {
  6077. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6078. }
  6079. **/
  6080. if ($this->db->trans_status() === TRUE) {
  6081. $this->db->trans_commit();
  6082. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6083. exit;
  6084. } else {
  6085. $this->db->trans_rollback();
  6086. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6087. exit;
  6088. }
  6089. } else {
  6090. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6091. exit;
  6092. }
  6093. }
  6094. }
  6095. public function _printck($arg_array)
  6096. {
  6097. $prc = array();
  6098. $purchase = $this->purchase->find_all();
  6099. foreach ($purchase as $k => $v) {
  6100. $prc[$v['id']] = $v['title'];
  6101. }
  6102. $post = $this->input->post(NULL, TRUE);
  6103. if (isset($post['page'])) {
  6104. $page = $this->input->post('page', true);
  6105. $perpage = $this->input->post('perpage', true);
  6106. $sku = $this->input->post('sku', true);
  6107. $bs = $this->input->post('bs', true);
  6108. $number = $this->input->post('number', true);
  6109. $warehouse = $this->input->post('warehouse', true);
  6110. $purchase = $this->input->post('purchase', true);
  6111. $orderinfo = $this->input->post('orderinfo', true);
  6112. $waybill = $this->input->post('waybill', true);
  6113. $category = $this->input->post('category', true);
  6114. $size = $this->input->post('size', true);
  6115. $grade = $this->input->post('grade', true);
  6116. $color = $this->input->post('color', true);
  6117. $lowe = $this->input->post('lowe', true);
  6118. $state = $this->input->post('state', true);
  6119. $label = $this->input->post('label', true);
  6120. $timetk = $this->input->post('ktime', true);
  6121. $timetj = $this->input->post('jtime', true);
  6122. $timetk = strtotime($timetk);
  6123. $timetj = strtotime($timetj);
  6124. $where = "state=1 ";
  6125. if ($timetk && $timetj) {
  6126. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6127. }
  6128. if ($sku) {
  6129. $where .= " and sku = '$sku'";
  6130. }
  6131. if ($bs != '') {
  6132. $where .= " and bs = '$bs'";
  6133. }
  6134. if ($number) {
  6135. $where .= " and number = '$number'";
  6136. }
  6137. if ($warehouse) {
  6138. $where .= " and warehouse = '$warehouse'";
  6139. }
  6140. if ($purchase) {
  6141. $where .= " and purchase = '$purchase'";
  6142. }
  6143. if ($orderinfo) {
  6144. $where .= " and orderinfo = '$orderinfo'";
  6145. }
  6146. if ($waybill) {
  6147. $where .= " and waybill = '$waybill'";
  6148. }
  6149. if ($category) {
  6150. $where .= " and features like '%-$category-%'";
  6151. }
  6152. if ($size) {
  6153. $where .= " and features like '%-$size-%'";
  6154. }
  6155. if ($grade) {
  6156. $where .= " and features like '%-$grade-%'";
  6157. }
  6158. if ($color) {
  6159. $where .= " and features like '%-$color-%'";
  6160. }
  6161. if ($lowe) {
  6162. $where .= " and features like '%-$lowe-%'";
  6163. }
  6164. if ($label) {
  6165. $where .= " and label = '$label'";
  6166. }
  6167. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6168. //数据排序
  6169. $order_str = "outk desc";
  6170. if (empty($page)) {
  6171. $start = 0;
  6172. $perpage = 1;
  6173. } else {
  6174. $start = ($page - 1) * $perpage;
  6175. }
  6176. //取得信息列表
  6177. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6178. foreach ($info_list as $key => $value) {
  6179. $warehouse = $this->warehouse->read($value['warehouse']);
  6180. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6181. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6182. if ($value['state'] == 0) {
  6183. $info_list[$key]['state'] = "在库";
  6184. } else if ($value['state'] == 1) {
  6185. $info_list[$key]['state'] = "出库";
  6186. } else if ($value['state'] == 2) {
  6187. $info_list[$key]['state'] = "退库";
  6188. } else if ($value['state'] == 3) {
  6189. $info_list[$key]['state'] = "调拨中";
  6190. } else if ($value['state'] == 4) {
  6191. $info_list[$key]['state'] = "再加工";
  6192. } else if ($value['state'] == 5) {
  6193. $info_list[$key]['state'] = "维修中";
  6194. } else if ($value['state'] == 6) {
  6195. $info_list[$key]['state'] = "盘亏";
  6196. } else if ($value['state'] == 7) {
  6197. $info_list[$key]['state'] = "更换标签";
  6198. } else if ($value['state'] == 8) {
  6199. $info_list[$key]['state'] = "其它";
  6200. } else if ($value['state'] == 9) {
  6201. $info_list[$key]['state'] = "预设";
  6202. } else if ($value['state'] == 10) {
  6203. $info_list[$key]['state'] = "美店零售";
  6204. }
  6205. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6206. }
  6207. $total = $this->$ck->find_count($where);
  6208. $pagenum = ceil($total / $perpage);
  6209. $over = $total - ($start + $perpage);
  6210. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6211. echo json_encode($rows);
  6212. exit;
  6213. }
  6214. if (isset($post['tmsku'])) {
  6215. $time = time();
  6216. $tmsku = $this->input->post('tmsku', true);
  6217. //$post['shop'] = $this->input->post('shop',true);
  6218. $num = $this->input->post('num', true);
  6219. $cktype = $this->input->post('cktype', true);
  6220. $label = $this->whlabellabel->get_label($tmsku);
  6221. if (!$cktype) {
  6222. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6223. }
  6224. if (!isset($label['warehouse'])) {
  6225. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6226. exit;
  6227. }
  6228. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6229. if (stripos($label['features'], '-126-') !== false) {
  6230. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6231. } else {
  6232. $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 = ''");
  6233. }
  6234. $j = 0;
  6235. if (count($ck) >= $num) {
  6236. for ($i = 0; $i < $num; $i++) {
  6237. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6238. {
  6239. $j++;
  6240. }
  6241. }
  6242. if ($j == $num) {
  6243. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6244. exit;
  6245. } else {
  6246. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6247. exit;
  6248. }
  6249. } else {
  6250. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6251. exit;
  6252. }
  6253. }
  6254. if(isset($_SESSION['api']))
  6255. {
  6256. $user = $this->user->get_api($_SESSION['api']);
  6257. if(in_array($user['power'],[1,27])){
  6258. $vip = 1;
  6259. }
  6260. }
  6261. else
  6262. {
  6263. $vip = 0;
  6264. header('Location: /');exit;
  6265. }
  6266. $this->data['vip'] = $vip;
  6267. $this->_Template('whlabel_printck', $this->data);
  6268. }
  6269. public function _printexcel()
  6270. {
  6271. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6272. $config['upload_path'] = '.' . $dir;
  6273. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6274. $config['allowed_types'] = 'xls|xlsx|csv';
  6275. $config['max_size'] = 10240;
  6276. $this->load->library('upload', $config);
  6277. $this->upload->initialize($config);
  6278. if ($this->upload->do_upload('userfile')) {
  6279. $full_path = $dir . $this->upload->data('file_name');
  6280. $fileName = '.' . $full_path;
  6281. if (!file_exists($fileName)) {
  6282. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6283. exit;
  6284. } else {
  6285. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6286. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6287. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6288. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6289. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6290. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6291. ++$column; //如果列数大于26行
  6292. $list = array();
  6293. for ($i = 2; $i <= $row; $i++) // 行数循环
  6294. {
  6295. $data = array();
  6296. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6297. {
  6298. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6299. }
  6300. $list[] = $data;
  6301. }
  6302. }
  6303. $ed = array();
  6304. $i = 0;
  6305. $j = 0;
  6306. $dcdata = array();
  6307. $yc = '';
  6308. $cmf_arr = array_column($list, '1');
  6309. array_multisort($cmf_arr, SORT_ASC, $list);
  6310. foreach ($list as $key => $value) {
  6311. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6312. if ($typeclass) {
  6313. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6314. } else {
  6315. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6316. $i++;
  6317. continue;
  6318. }
  6319. }
  6320. if ($i > 0) {
  6321. $yc = $i . '条异常';
  6322. }
  6323. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6324. exit;
  6325. }
  6326. }
  6327. public function _uck()
  6328. {
  6329. if (isset($_GET['excel'])) {
  6330. $tc = array();
  6331. $typeclass = $this->typeclass->find_all();
  6332. foreach ($typeclass as $v) {
  6333. $tc[$v['id']] = $v['zh'];
  6334. }
  6335. $data = array();
  6336. $t = array();
  6337. $rq = '';
  6338. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6339. $ts = $ts / (24 * 3600);
  6340. for ($i = 0; $i < $ts; $i++) {
  6341. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6342. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6343. }
  6344. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6345. foreach ($info_list as $k => $v) {
  6346. $features = explode('-', trim($v['features'], '-'));
  6347. if (!isset($features[3]) || !isset($features[4])) {
  6348. continue;
  6349. }
  6350. $data[$k][0] = $tc[$features[0]]; //类型
  6351. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6352. $data[$k][2] = $tc[$features[4]]; //曲度
  6353. $data[$k][3] = '';
  6354. if (isset($data[$k][1])) {
  6355. $data[$k][3] .= $data[$k][1];
  6356. }
  6357. if (isset($data[$k][2])) {
  6358. $data[$k][3] .= $data[$k][2];
  6359. }
  6360. if (isset($features[5])) {
  6361. $data[$k][3] .= $tc[$features[5]];
  6362. }
  6363. if (isset($features[2])) {
  6364. $data[$k][3] .= $tc[$features[2]];
  6365. }
  6366. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6367. $data[$k][4] = $v['sku'];
  6368. $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())) . '))'); //月初库存
  6369. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6370. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6371. $ztrq = '';
  6372. $ztsl = '';
  6373. if (count($zt) > 0) {
  6374. foreach ($zt as $vv) {
  6375. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6376. $ztsl .= $vv['num'] . '<br>';
  6377. }
  6378. }
  6379. $data[$k][] = trim($ztsl, '<br>');
  6380. $data[$k][] = trim($ztrq, '<br>');
  6381. $byck = 0;
  6382. foreach ($t as $vv) {
  6383. $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));
  6384. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6385. $byck += $sl;
  6386. }
  6387. $data[$k][] = ($byck > 0) ? $byck : '';
  6388. }
  6389. $title = "详情 " . date("Y-m-d", time());
  6390. $titlename = "<table border=1>
  6391. <tr align='center'>
  6392. <td>类别</td>
  6393. <td>颜色</td>
  6394. <td>曲度</td>
  6395. <td>名称</td>
  6396. <td>SKU</td>
  6397. <td>月初库存</td>
  6398. <td>剩余库存</td>
  6399. <td>在途数量</td>
  6400. <td>预达日期</td>" .
  6401. $rq
  6402. . "<td>本月出库</td></tr>
  6403. </table>";
  6404. $filename = $title . ".xls";
  6405. $tail = "";
  6406. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6407. }
  6408. }
  6409. public function _whlabelexcelzh()
  6410. {
  6411. if (isset($_GET['excel'])) {
  6412. $where = "sku != 'Preset'";
  6413. //数据排序
  6414. $order_str = "id desc";
  6415. if (empty($page)) {
  6416. $start = 0;
  6417. $perpage = 1;
  6418. } else {
  6419. $start = ($page - 1) * $perpage;
  6420. }
  6421. $category = $this->input->get('category', true);
  6422. $warehouse = $this->input->get('warehouse', true);
  6423. $excelid = $this->input->get('sid', true);
  6424. if ($category) {
  6425. $where .= " and features like '%-$category-%'";
  6426. }
  6427. if ($warehouse) {
  6428. $where .= " and warehouse = '$warehouse'";
  6429. }
  6430. $xzid = '';
  6431. if ($excelid) {
  6432. $excelid = explode(',', trim($excelid, ','));
  6433. foreach ($excelid as $key => $value) {
  6434. $xzid .= " id = " . $value . " or";
  6435. }
  6436. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6437. }
  6438. //取得信息列表
  6439. /**
  6440. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6441. $rows = array();$list = array();
  6442. foreach ($info_list as $key=>$value)
  6443. {
  6444. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6445. }
  6446. **/
  6447. $list = array();
  6448. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6449. foreach ($rows as $key => $value) {
  6450. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6451. $zh = '';
  6452. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6453. foreach ($zt as $v) {
  6454. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6455. }
  6456. $zt = array_sum(array_column($zt, 'num'));
  6457. $number = $value['number'];
  6458. $ftime = time() - 15 * 24 * 3600;
  6459. $warehouse = $this->warehouse->read($value['warehouse']);
  6460. $rows[$key]['warehouse'] = $warehouse['title'];
  6461. $rows[$key]['number'] = $c;
  6462. $rows[$key]['features'] = $zh;
  6463. $rows[$key]['hb'] = $c + $zt;
  6464. }
  6465. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6466. $titlename = "<table border=1>
  6467. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6468. <tr align='center'>
  6469. <td>仓库</td>
  6470. <td>SKU</td>
  6471. <td>产品</td>
  6472. <td>库存数量</td>
  6473. <td>在途数量及预达日期</td>
  6474. <td>在途+库存数量</td>
  6475. </tr>
  6476. </table>";
  6477. $filename = $title . ".xls";
  6478. $tail = "";
  6479. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6480. }
  6481. if (isset($_GET['excel'])) {
  6482. $warehouse = $this->input->get('warehouse', true);
  6483. $sku = $this->input->get('sku', true);
  6484. $cz = $this->input->get('cz', true);
  6485. $text = $this->input->post('text', true);
  6486. $xztime = $this->input->get('xztime', true);
  6487. $timetk = $this->input->get('timetk', true);
  6488. $timetj = $this->input->get('timetj', true);
  6489. $timetk = strtotime($timetk);
  6490. $timetj = strtotime($timetj);
  6491. $where = "time = '0' ";
  6492. if ($warehouse) {
  6493. $where .= " and warehouse = '$warehouse'";
  6494. }
  6495. if ($sku) {
  6496. $where .= " and sku = '$sku'";
  6497. }
  6498. if ($text) {
  6499. $where .= " and text like '%$text%'";
  6500. }
  6501. if ($cz != '') {
  6502. $where .= " and cz = '$cz'";
  6503. }
  6504. if ($timetk && $timetj) {
  6505. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6506. }
  6507. //数据排序
  6508. $order_str = $xztime . " desc";
  6509. //取得信息列表
  6510. $zh = array();
  6511. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6512. foreach ($info_list as $v) {
  6513. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6514. $warehouse = $this->warehouse->read($v['warehouse']);
  6515. $v['warehouse'] = $warehouse['title'];
  6516. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6517. $v['stime'] = date('Y-m-d', $v['stime']);
  6518. if (isset($zh[$v['features']])) {
  6519. $zh[$v['features']]['num'] += $v['num'];
  6520. } else {
  6521. $zh[$v['features']] = $v;
  6522. }
  6523. $zh[$v['features']]['features'] = $c;
  6524. }
  6525. $title = "在途数据" . date('Y-m-d', time());
  6526. $titlename = "<table border=1>
  6527. <tr align='center'>
  6528. <td>仓库</td>
  6529. <td>SKU</td>
  6530. <td>名称</td>
  6531. <td>在途数量</td>
  6532. <td>库存数量</td>
  6533. <td>添加在途日期</td>
  6534. <td>预达日期</td>
  6535. <td>备注</td>
  6536. </tr>
  6537. </table>";
  6538. $filename = $title . ".xls";
  6539. $tail = "";
  6540. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6541. }
  6542. }
  6543. public function _fc()
  6544. {
  6545. $vip = 0;
  6546. if (isset($_SESSION['api'])) {
  6547. $user = $this->user->get_api($_SESSION['api']);
  6548. if ($user['vip'] == 1) {
  6549. $vip = 1;
  6550. }
  6551. } else {
  6552. header('Location: /');
  6553. exit;
  6554. }
  6555. $post = $this->input->post(NULL, TRUE);
  6556. if (isset($post['page'])) {
  6557. $page = $this->input->post('page', true);
  6558. $perpage = $this->input->post('perpage', true);
  6559. $category = $this->input->post('category', true);
  6560. $size = $this->input->post('size', true);
  6561. $grade = $this->input->post('grade', true);
  6562. $color = $this->input->post('color', true);
  6563. $lowe = $this->input->post('lowe', true);
  6564. $sku = $this->input->post('sku');
  6565. $title = $this->input->post('title');
  6566. $warehouse = $this->input->post('warehouse', true);
  6567. $usa = $this->input->post('usa', true);
  6568. $purchase = $this->input->post('purchase', true);
  6569. $lacetype = $this->input->post('lacetype', true);
  6570. $haircap = $this->input->post('haircap', true);
  6571. $density = $this->input->post('density', true);
  6572. $details = $this->input->post('details', true);
  6573. $state = $this->input->post('state', true);
  6574. $ktime = $this->input->post('ktime', true);
  6575. $jtime = $this->input->post('jtime', true);
  6576. $ktime = strtotime($ktime);
  6577. $jtime = strtotime($jtime);
  6578. $where = "state = '11'";
  6579. $gj = "";
  6580. $ck = "";
  6581. if ($lacetype) {
  6582. $where .= " and features like '%-$lacetype-%'";
  6583. }
  6584. if ($category) {
  6585. $where .= " and features like '%-$category-%'";
  6586. }
  6587. if ($size) {
  6588. $where .= " and features like '%-$size-%'";
  6589. }
  6590. if ($grade) {
  6591. $where .= " and features like '%-$grade-%'";
  6592. }
  6593. if ($color) {
  6594. $where .= " and features like '%-$color-%'";
  6595. }
  6596. if ($lowe) {
  6597. $where .= " and features like '%-$lowe-%'";
  6598. }
  6599. if ($haircap) {
  6600. $where .= " and features like '%-$haircap-%'";
  6601. }
  6602. if ($density) {
  6603. $where .= " and features like '%-$density-%'";
  6604. }
  6605. if ($usa) {
  6606. if (!$warehouse) {
  6607. $where .= " and (warehouse = '5' or warehouse = '8')";
  6608. }
  6609. }
  6610. if ($warehouse) {
  6611. $where .= " and warehouse = '$warehouse'";
  6612. }
  6613. if ($details) {
  6614. $where .= " and details = '$details'";
  6615. }
  6616. if ($purchase) {
  6617. $where .= " and purchase = '$purchase'";
  6618. }
  6619. if ($state) {
  6620. $where .= " and state = '$state'";
  6621. }
  6622. if ($ktime && $jtime) {
  6623. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6624. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6625. }
  6626. //数据排序
  6627. $order_str = "id desc";
  6628. if (empty($page)) {
  6629. $start = 0;
  6630. $perpage = 1;
  6631. } else {
  6632. $start = ($page - 1) * $perpage;
  6633. }
  6634. if ($sku) {
  6635. $sku = trim($sku, ' ');
  6636. $sku = trim($sku, ' ');
  6637. $where .= " and sku like '%$sku%'";
  6638. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6639. } else if ($title) {
  6640. $title = trim($title, ' ');
  6641. $title = trim($title, ' ');
  6642. $where .= " and title like '%$title%'";
  6643. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6644. } else {
  6645. //$where .= " and time > '$ktime' and time < '$jtime'";
  6646. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6647. }
  6648. //取得信息列表
  6649. $rows = array();
  6650. $list = array();
  6651. foreach ($info_list as $key => $value) {
  6652. $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'] . '"');
  6653. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6654. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6655. $warehouse = $this->warehouse->read($value['warehouse']);
  6656. $info_list[$key]['warehouse'] = $warehouse['title'];
  6657. $info_list[$key]['number'] = $g;
  6658. $info_list[$key]['features'] = $x;
  6659. $info_list[$key]['x'] = $s;
  6660. }
  6661. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6662. $pagenum = ceil($total / $perpage);
  6663. $over = $total - ($start + $perpage);
  6664. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6665. echo json_encode($rows);
  6666. exit;
  6667. }
  6668. $this->data['vip'] = $vip;
  6669. $this->_Template('whlabel_fc', $this->data);
  6670. }
  6671. public function _fcmb()
  6672. {
  6673. $where = "sku != 'Preset'";
  6674. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6675. foreach ($rows as $k => $v) {
  6676. $warehouse = $this->warehouse->read($v['warehouse']);
  6677. $rows[$k]['warehouse'] = $warehouse['title'];
  6678. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6679. $rows[$k]['t'] = '';
  6680. $rows[$k]['n'] = '';
  6681. }
  6682. $title = "封货产品数据导入模板";
  6683. $titlename = "<table border=1>
  6684. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6685. <tr align='center'>
  6686. <td>仓库</td>
  6687. <td>SKU</td>
  6688. <td>产品</td>
  6689. <td>封存产品总数量</td>
  6690. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6691. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6692. </tr>
  6693. </table>";
  6694. $filename = $title . ".xls";
  6695. $tail = "";
  6696. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6697. }
  6698. public function _fcexcel()
  6699. {
  6700. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6701. $config['upload_path'] = '.' . $dir;
  6702. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6703. $config['allowed_types'] = 'xls|xlsx|csv';
  6704. $config['max_size'] = 10240;
  6705. $this->load->library('upload', $config);
  6706. $this->upload->initialize($config);
  6707. if ($this->upload->do_upload('userfile')) {
  6708. $full_path = $dir . $this->upload->data('file_name');
  6709. $fileName = '.' . $full_path;
  6710. if (!file_exists($fileName)) {
  6711. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6712. exit;
  6713. } else {
  6714. libxml_use_internal_errors(true);
  6715. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6716. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6717. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6718. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6719. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6720. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6721. ++$column; //如果列数大于26行
  6722. $list = array();
  6723. for ($i = 2; $i <= $row; $i++) // 行数循环
  6724. {
  6725. $data = array();
  6726. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6727. {
  6728. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6729. }
  6730. $list[] = $data;
  6731. }
  6732. }
  6733. $i = 0;
  6734. $j = 0;
  6735. $ed = array();
  6736. foreach ($list as $key => $value) {
  6737. $time = time();
  6738. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6739. continue;
  6740. }
  6741. $warehouse = $this->warehouse->get_title($value['0']);
  6742. $sku = $value['1'];
  6743. $type = $value['4']; //调整方式0扣减1删除
  6744. $num = $value['5']; //调整数量
  6745. //$text = $value['4'];//扣减说明
  6746. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6747. if (!$d) //如果没有这个SKU
  6748. {
  6749. $ed[] = array($sku . '-库存中不存在此SKU');
  6750. $j++;
  6751. continue;
  6752. }
  6753. if (!isset($warehouse['id'])) {
  6754. $ed[] = array($sku . '-仓库名错误!');
  6755. $j++;
  6756. continue;
  6757. }
  6758. if ($type == 1 || $type == 2) //扣减库存
  6759. {
  6760. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6761. if (count($data) < abs($num)) {
  6762. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6763. $j++;
  6764. continue;
  6765. }
  6766. if ($type == 1) //转入库存
  6767. {
  6768. for ($i = 0; $i < abs($num); $i++) {
  6769. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6770. }
  6771. } else if ($type == 2) //删除
  6772. {
  6773. for ($i = 0; $i < abs($num); $i++) {
  6774. $this->whlabel->remove($data[$i]['id']);
  6775. }
  6776. }
  6777. } else if ($type == 0) //增加库存
  6778. {
  6779. $post['sku'] = $d['sku'];
  6780. $post['shop'] = '';
  6781. $post['warehouse'] = $warehouse['id'];
  6782. $post['purchase'] = $d['purchase'];
  6783. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6784. $post['state'] = 11;
  6785. $post['title'] = $d['title'];
  6786. $post['number'] = $d['number'];
  6787. $post['features'] = $d['features'];
  6788. $post['enter'] = $time;
  6789. $post['time'] = $time; //操作时间
  6790. for ($i = 0; $i < $num; $i++) {
  6791. $post['label'] = time() . rand(100, 999) . $i;
  6792. $this->whlabel->insert($post);
  6793. }
  6794. }
  6795. sleep(1); //防止入库时间一样,需要延迟1秒
  6796. }
  6797. if ($j > 0) {
  6798. $tt = date('Ymd', time());
  6799. $title = '库存导入错误信息-' . $tt;
  6800. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6801. $tail = "\n";
  6802. $filename = $title . ".xls";
  6803. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6804. $dir = '/data/excel/' . $time . '/';
  6805. $file_name = 'error_' . $time . rand(1000, 9999);
  6806. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6807. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6808. fwrite($myfile, $ecl);
  6809. fclose($myfile);
  6810. $error = $dir . $file_name . '.xls';
  6811. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6812. exit;
  6813. } else {
  6814. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6815. exit;
  6816. }
  6817. }
  6818. }
  6819. public function _fcjxc($arg_array)
  6820. {
  6821. if (isset($_GET['excel'])) {
  6822. $category = $this->input->get('category', true);
  6823. $size = $this->input->get('size', true);
  6824. $grade = $this->input->get('grade', true);
  6825. $color = $this->input->get('color', true);
  6826. $lowe = $this->input->get('lowe', true);
  6827. $sku = $this->input->get('sku');
  6828. $title = $this->input->get('title');
  6829. $warehouse = $arg_array[0];
  6830. $usa = $this->input->get('usa', true);
  6831. $purchase = $this->input->get('purchase', true);
  6832. $lacetype = $this->input->get('lacetype', true);
  6833. $haircap = $this->input->get('haircap', true);
  6834. $density = $this->input->get('density', true);
  6835. $title = $this->input->get('title', true);
  6836. $state = $this->input->get('state', true);
  6837. $ktime = $this->input->get('ktime', true);
  6838. $jtime = $this->input->get('jtime', true);
  6839. $where = "state=11";
  6840. $gj = "";
  6841. $ck = "";
  6842. if ($lacetype) {
  6843. $where .= " and features like '%-$lacetype-%'";
  6844. }
  6845. if ($category) {
  6846. $where .= " and features like '%-$category-%'";
  6847. }
  6848. if ($size) {
  6849. $where .= " and features like '%-$size-%'";
  6850. }
  6851. if ($grade) {
  6852. $where .= " and features like '%-$grade-%'";
  6853. }
  6854. if ($color) {
  6855. $where .= " and features like '%-$color-%'";
  6856. }
  6857. if ($lowe) {
  6858. $where .= " and features like '%-$lowe-%'";
  6859. }
  6860. if ($haircap) {
  6861. $where .= " and features like '%-$haircap-%'";
  6862. }
  6863. if ($density) {
  6864. $where .= " and features like '%-$density-%'";
  6865. }
  6866. if ($usa) {
  6867. if (!$warehouse) {
  6868. $where .= " and (warehouse = '5' or warehouse = '8')";
  6869. }
  6870. }
  6871. if ($warehouse) {
  6872. $where .= " and warehouse = '$warehouse'";
  6873. }
  6874. if ($purchase) {
  6875. $where .= " and purchase = '$purchase'";
  6876. }
  6877. if ($state) {
  6878. $where .= " and state = '$state'";
  6879. }
  6880. $order_str = "id desc";
  6881. if ($sku) {
  6882. $sku = trim($sku, ' ');
  6883. $sku = trim($sku, ' ');
  6884. $where .= " and sku like '%$sku%'";
  6885. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6886. } else if ($title) {
  6887. $title = trim($title, ' ');
  6888. $title = trim($title, ' ');
  6889. $where .= " and title like '%$title%'";
  6890. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6891. } else {
  6892. //$where .= " and time > '$ktime' and time < '$jtime'";
  6893. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6894. }
  6895. //取得信息列表
  6896. $rows = array();
  6897. $list = array();
  6898. foreach ($info_list as $key => $value) {
  6899. $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'] . '"');
  6900. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6901. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6902. $rows[$key] = $value;
  6903. $warehouse = $this->warehouse->read($value['warehouse']);
  6904. $rows[$key]['warehouse'] = $warehouse['title'];
  6905. $rows[$key]['features'] = $g;
  6906. $rows[$key]['a'] = $x;
  6907. $rows[$key]['b'] = $s;
  6908. }
  6909. $title = "总统计表";
  6910. $titlename = "<table border=1>
  6911. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6912. <tr align='center'>
  6913. <td>仓库</td>
  6914. <td>SKU</td>
  6915. <td>产品名称</td>
  6916. <td>录入总量</td>
  6917. <td>取出总量</td>
  6918. <td>剩余总量</td>
  6919. </tr>
  6920. </table>";
  6921. $filename = $title . ".xls";
  6922. $tail = "";
  6923. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6924. }
  6925. $vip = 0;
  6926. if (isset($_SESSION['api'])) {
  6927. $user = $this->user->get_api($_SESSION['api']);
  6928. if ($user['vip'] == 1) {
  6929. $vip = 1;
  6930. }
  6931. } else {
  6932. header('Location: /');
  6933. exit;
  6934. }
  6935. $post = $this->input->post(NULL, TRUE);
  6936. if (isset($post['page'])) {
  6937. $page = $this->input->post('page', true);
  6938. $perpage = $this->input->post('perpage', true);
  6939. $category = $this->input->post('category', true);
  6940. $size = $this->input->post('size', true);
  6941. $grade = $this->input->post('grade', true);
  6942. $color = $this->input->post('color', true);
  6943. $lowe = $this->input->post('lowe', true);
  6944. $sku = $this->input->post('sku');
  6945. $title = $this->input->post('title');
  6946. $warehouse = $arg_array[0];
  6947. $usa = $this->input->post('usa', true);
  6948. $purchase = $this->input->post('purchase', true);
  6949. $lacetype = $this->input->post('lacetype', true);
  6950. $haircap = $this->input->post('haircap', true);
  6951. $density = $this->input->post('density', true);
  6952. $title = $this->input->post('title', true);
  6953. $state = $this->input->post('state', true);
  6954. $ktime = $this->input->post('ktime', true);
  6955. $jtime = $this->input->post('jtime', true);
  6956. $ktime = strtotime($ktime);
  6957. $jtime = strtotime($jtime);
  6958. $where = "state=11";
  6959. $gj = "";
  6960. $ck = "";
  6961. if ($lacetype) {
  6962. $where .= " and features like '%-$lacetype-%'";
  6963. }
  6964. if ($category) {
  6965. $where .= " and features like '%-$category-%'";
  6966. }
  6967. if ($size) {
  6968. $where .= " and features like '%-$size-%'";
  6969. }
  6970. if ($grade) {
  6971. $where .= " and features like '%-$grade-%'";
  6972. }
  6973. if ($color) {
  6974. $where .= " and features like '%-$color-%'";
  6975. }
  6976. if ($lowe) {
  6977. $where .= " and features like '%-$lowe-%'";
  6978. }
  6979. if ($haircap) {
  6980. $where .= " and features like '%-$haircap-%'";
  6981. }
  6982. if ($density) {
  6983. $where .= " and features like '%-$density-%'";
  6984. }
  6985. if ($usa) {
  6986. if (!$warehouse) {
  6987. $where .= " and (warehouse = '5' or warehouse = '8')";
  6988. }
  6989. }
  6990. if ($warehouse) {
  6991. $where .= " and warehouse = '$warehouse'";
  6992. }
  6993. if ($purchase) {
  6994. $where .= " and purchase = '$purchase'";
  6995. }
  6996. if ($state) {
  6997. $where .= " and state = '$state'";
  6998. }
  6999. if ($ktime && $jtime) {
  7000. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7001. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7002. }
  7003. //数据排序
  7004. $order_str = "id desc";
  7005. $xs = 0;
  7006. $rows = array();
  7007. $list = array();
  7008. if (empty($page)) {
  7009. $start = 0;
  7010. $perpage = 1;
  7011. } else {
  7012. $start = ($page - 1) * $perpage;
  7013. }
  7014. if ($sku || $title) {
  7015. if ($title) {
  7016. $title = trim($title, ' ');
  7017. $title = trim($title, ' ');
  7018. $where .= " and title like '%$title%'";
  7019. } else {
  7020. $sku = trim($sku, ' ');
  7021. $sku = trim($sku, ' ');
  7022. $where .= " and sku like '%$sku%'";
  7023. }
  7024. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7025. foreach ($info_list as $key => $value) {
  7026. $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'] . '"');
  7027. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7028. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7029. $rows[$key] = $value;
  7030. $warehouse = $this->warehouse->read($value['warehouse']);
  7031. $rows[$key]['warehouse'] = $warehouse['title'];
  7032. $rows[$key]['features'] = $g;
  7033. $rows[$key]['a'] = $x;
  7034. $rows[$key]['b'] = $s;
  7035. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7036. $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天销量
  7037. $yj = $c / ($xl / 30);
  7038. if ($yj < 7) {
  7039. $rows[$key]['y'] = round($yj) . '天销量';
  7040. } else {
  7041. $rows[$key]['y'] = '正常';
  7042. }
  7043. }
  7044. } else {
  7045. //$where .= " and time > '$ktime' and time < '$jtime'";
  7046. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7047. foreach ($info_list as $key => $value) {
  7048. $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'] . '"');
  7049. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7050. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7051. $zs[$key] = $value;
  7052. $warehouse = $this->warehouse->read($value['warehouse']);
  7053. $zs[$key]['warehouse'] = $warehouse['title'];
  7054. $zs[$key]['features'] = $g;
  7055. $zs[$key]['a'] = $x;
  7056. $zs[$key]['b'] = $s;
  7057. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7058. $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天销量
  7059. $yj = $c / ($xl / 30);
  7060. if ($yj < 7) {
  7061. $zs[$key]['y'] = round($yj) . '天销量';
  7062. $rows[$key] = $zs[$key];
  7063. }
  7064. }
  7065. }
  7066. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7067. $pagenum = ceil($total / $perpage);
  7068. $over = $total - ($start + $perpage);
  7069. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7070. echo json_encode($rows);
  7071. exit;
  7072. }
  7073. $this->data['arg_array'] = $arg_array[0];
  7074. $this->_Template('whlabel_fcjxc', $this->data);
  7075. }
  7076. public function _0kcdel()
  7077. {
  7078. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7079. $config['upload_path'] = '.' . $dir;
  7080. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7081. $config['allowed_types'] = 'xls|xlsx|csv';
  7082. $config['max_size'] = 10240;
  7083. $this->load->library('upload', $config);
  7084. $this->upload->initialize($config);
  7085. if ($this->upload->do_upload('userfile')) {
  7086. $full_path = $dir . $this->upload->data('file_name');
  7087. $fileName = '.' . $full_path;
  7088. if (!file_exists($fileName)) {
  7089. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7090. exit;
  7091. } else {
  7092. require_once "./data/excel/PHPExcel/IOFactory.php";
  7093. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7094. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7095. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7096. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7097. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7098. ++$column; //如果列数大于26行
  7099. $list = array();
  7100. for ($i = 2; $i <= $row; $i++) // 行数循环
  7101. {
  7102. $data = array();
  7103. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7104. {
  7105. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7106. }
  7107. $list[] = $data;
  7108. }
  7109. }
  7110. $i = 0;
  7111. $j = 0;
  7112. $ed = array();
  7113. foreach ($list as $key => $value) {
  7114. $time = time();
  7115. if ($value['0'] == "" || $value['1'] == "") {
  7116. continue;
  7117. }
  7118. $warehouse = $this->warehouse->get_title($value['0']);
  7119. $sku = $value['1'];
  7120. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7121. if (!$d) //如果没有这个SKU
  7122. {
  7123. $ed[] = array($sku . '-库存中不存在此SKU');
  7124. $j++;
  7125. continue;
  7126. }
  7127. if (!isset($warehouse['id'])) {
  7128. $ed[] = array($sku . '-仓库名错误!');
  7129. $j++;
  7130. continue;
  7131. }
  7132. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7133. if ($z < 1) {
  7134. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7135. foreach ($z as $v) {
  7136. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7137. if (count($zt) > 0) {
  7138. $ed[] = array($sku . '-有在途库存无法删除!');
  7139. $j++;
  7140. continue;
  7141. }
  7142. $this->whlabel->remove($v['id']);
  7143. }
  7144. } else {
  7145. $ed[] = array($sku . '-非0库存!');
  7146. $j++;
  7147. continue;
  7148. }
  7149. }
  7150. if ($j > 0) {
  7151. $tt = date('Ymd', time());
  7152. $title = '删除0库存错误信息-' . $tt;
  7153. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7154. $tail = "\n";
  7155. $filename = $title . ".xls";
  7156. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7157. $dir = '/data/excel/' . $time . '/';
  7158. $file_name = 'error_' . $time . rand(1000, 9999);
  7159. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7160. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7161. fwrite($myfile, $ecl);
  7162. fclose($myfile);
  7163. $error = $dir . $file_name . '.xls';
  7164. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7165. exit;
  7166. } else {
  7167. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7168. exit;
  7169. }
  7170. }
  7171. }
  7172. public function _gbhtype()
  7173. {
  7174. $post = $this->input->post(NULL, TRUE);
  7175. if (isset($post['s'])) {
  7176. $n = $this->input->post('n');
  7177. $d = $this->input->post('s');
  7178. if (!$d) {
  7179. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7180. exit;
  7181. }
  7182. $d = explode(',', trim($d, ','));
  7183. $t = $this->whlabel_type->read($n);
  7184. //循环删除记录
  7185. foreach ($d as $v) {
  7186. $u = $this->whlabel->read($v);
  7187. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7188. foreach ($data as $val) {
  7189. $this->whlabel->save(array('type' => $n), $val['id']);
  7190. }
  7191. }
  7192. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7193. }
  7194. }
  7195. //出库、退库导出
  7196. public function _dccrtype()
  7197. {
  7198. $classid = $this->classid->sku();
  7199. $pm = $classid;
  7200. $typeclass = array();
  7201. $tc = $this->typeclass->find_all();
  7202. foreach ($tc as $v) {
  7203. $typeclass[$v['id']] = $v;
  7204. }
  7205. $prc = array();
  7206. $purchase = $this->purchase->find_all();
  7207. foreach ($purchase as $k => $v) {
  7208. $prc[$v['id']] = $v['title'];
  7209. }
  7210. if (isset($_GET['sid'])) {
  7211. $wh = array();
  7212. $w = $this->warehouse->find_all('1=1', 'id,title');
  7213. foreach ($w as $v) {
  7214. $wh[$v['id']] = $v['title'];
  7215. }
  7216. $type = $this->input->get('excel', true);
  7217. $category = $this->input->get('category', true);
  7218. $size = $this->input->get('size', true);
  7219. $grade = $this->input->get('grade', true);
  7220. $color = $this->input->get('color', true);
  7221. $lowe = $this->input->get('lowe', true);
  7222. $sku = $this->input->get('sku', true);
  7223. $warehouse = $this->input->get('warehouse', true);
  7224. $lacetype = $this->input->get('lacetype', true);
  7225. $lacecolor = $this->input->get('lacecolor', true);
  7226. $density = $this->input->get('density', true);
  7227. $haircap = $this->input->get('haircap', true);
  7228. $purchase = $this->input->get('purchase', true);
  7229. $title = $this->input->get('title', true);
  7230. $state = $this->input->get('state', true);
  7231. $sid = $this->input->get('sid', true);
  7232. $ktime = $this->input->get('ktime', true);
  7233. $jtime = $this->input->get('jtime', true);
  7234. $ktime = strtotime($ktime);
  7235. $jtime = strtotime($jtime);
  7236. $where = "1=1";
  7237. $gj = "";
  7238. $ck = "";
  7239. if ($category) {
  7240. $where .= " and features like '%-$category-%'";
  7241. }
  7242. if ($size) {
  7243. $where .= " and features like '%-$size-%'";
  7244. }
  7245. if ($grade) {
  7246. $where .= " and features like '%-$grade-%'";
  7247. }
  7248. if ($color) {
  7249. $where .= " and features like '%-$color-%'";
  7250. }
  7251. if ($lowe) {
  7252. $where .= " and features like '%-$lowe-%'";
  7253. }
  7254. if ($warehouse) {
  7255. $where .= " and warehouse = '$warehouse'";
  7256. }
  7257. if ($purchase) {
  7258. $where .= " and purchase = '$purchase'";
  7259. }
  7260. if ($state) {
  7261. $where .= " and state = '$state'";
  7262. }
  7263. if ($lacetype) {
  7264. $where .= " and features like '%-$lacetype-%'";
  7265. }
  7266. if ($lacecolor) {
  7267. $where .= " and features like '%-$lacecolor-%'";
  7268. }
  7269. if ($density) {
  7270. $where .= " and features like '%-$density-%'";
  7271. }
  7272. if ($haircap) {
  7273. $where .= " and features like '%-$haircap-%'";
  7274. }
  7275. if ($title) {
  7276. $title = trim($title, ' ');
  7277. $title = trim($title, ' ');
  7278. $where .= " and title like '%$title%'";
  7279. }
  7280. if ($sku) {
  7281. $sku = trim($sku, ' ');
  7282. $sku = trim($sku, ' ');
  7283. $where .= " and sku like '%$sku%'";
  7284. }
  7285. if ($ktime && $jtime) {
  7286. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7287. }
  7288. $sidwhere = '';
  7289. if ($sid) {
  7290. $sd = "";
  7291. $s = explode(',', trim($sid, ','));
  7292. foreach ($s as $value) {
  7293. $sd .= " id = " . $value . " or";
  7294. }
  7295. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7296. }
  7297. //数据排序
  7298. $order_str = "time desc";
  7299. if (empty($page)) {
  7300. $start = 0;
  7301. $perpage = 1;
  7302. } else {
  7303. $start = ($page - 1) * $perpage;
  7304. }
  7305. $wh = array();
  7306. $w = $this->warehouse->find_all('1=1', 'id,title');
  7307. foreach ($w as $v) {
  7308. $wh[$v['id']] = $v['title'];
  7309. }
  7310. $wt = array();
  7311. $whlabel_type = $this->whlabel_type->find_all();
  7312. foreach ($whlabel_type as $v) {
  7313. $wt[$v['id']] = $v['title'];
  7314. }
  7315. $classid = $this->classid->sku();
  7316. $list = array();
  7317. $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');
  7318. foreach ($rows_r as $key => $value) {
  7319. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7320. $pm = $classid;
  7321. $jm = $classid;
  7322. $rows_r[$key]['enter'] = '入库';
  7323. $rows_r[$key]['time'] = $value['enter'];
  7324. if ($value['rktype'] == 1) {
  7325. $rows_r[$key]['rktype'] = '采购入库';
  7326. } else if ($value['rktype'] == 2) {
  7327. $rows_r[$key]['rktype'] = '盘盈调整';
  7328. } else if ($value['rktype'] == 3) {
  7329. $rows_r[$key]['rktype'] = '其他调整入库';
  7330. } else if ($value['rktype'] == 4) {
  7331. $rows_r[$key]['rktype'] = '其他调整入库';
  7332. } else if ($value['rktype'] == 5) {
  7333. $rows_r[$key]['rktype'] = '退库入库';
  7334. } else if ($value['rktype'] == 6) {
  7335. $rows_r[$key]['rktype'] = '退货可用入库';
  7336. } else if ($value['rktype'] == 7) {
  7337. $rows_r[$key]['rktype'] = '形态转换入库';
  7338. } else {
  7339. $rows_r[$key]['rktype'] = '';
  7340. }
  7341. $features = explode('-', trim($value['features'], '-'));
  7342. foreach ($features as $v) {
  7343. if (isset($typeclass[$v])) {
  7344. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7345. $pm[$typeclass[$v]['classid']] = $zh[0];
  7346. }
  7347. if (isset($typeclass[$v])) {
  7348. if (isset($jm[$typeclass[$v]['classid']])) {
  7349. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7350. }
  7351. }
  7352. }
  7353. $zh = implode(" ", $pm);
  7354. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7355. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7356. $rows_r[$key]['zh'] = $zh;
  7357. $jm = array_filter($jm);
  7358. $rows_r[$key]['features'] = implode("-", $jm);
  7359. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7360. }
  7361. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout,state');
  7362. foreach ($rows_c as $key => $value) {
  7363. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7364. $pm = $classid;
  7365. $jm = $classid;
  7366. $rows_c[$key]['time'] = $value['outk'];
  7367. $rows_c[$key]['outk'] = '出库';
  7368. if ($value['cktype'] == 1) {
  7369. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7370. } else if ($value['cktype'] == 2) {
  7371. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7372. } else if ($value['cktype'] == 3) {
  7373. $rows_c[$key]['cktype'] = '盘亏调整';
  7374. } else if ($value['cktype'] == 4) {
  7375. $rows_c[$key]['cktype'] = '其他调整出库';
  7376. } else if ($value['cktype'] == 5) {
  7377. $rows_c[$key]['cktype'] = '形态转换出库';
  7378. } else {
  7379. $rows_c[$key]['cktype'] = '';
  7380. }
  7381. unset($rows_c[$key]['state']);
  7382. $features = explode('-', trim($value['features'], '-'));
  7383. foreach ($features as $v) {
  7384. if (isset($typeclass[$v])) {
  7385. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7386. $pm[$typeclass[$v]['classid']] = $zh[0];
  7387. }
  7388. if (isset($typeclass[$v])) {
  7389. if (isset($jm[$typeclass[$v]['classid']])) {
  7390. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7391. }
  7392. }
  7393. }
  7394. $zh = implode(" ", $pm);
  7395. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7396. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7397. $rows_c[$key]['zh'] = $zh;
  7398. $jm = array_filter($jm);
  7399. $rows_c[$key]['features'] = implode("-", $jm);
  7400. $rows_c[$key]['number'] = 1;
  7401. }
  7402. $merged = $rows_r;
  7403. foreach ($rows_c as $key => $value) {
  7404. if (isset($merged[$key])) {
  7405. $merged[] = $value;
  7406. } else {
  7407. $merged[$key] = $value;
  7408. }
  7409. }
  7410. usort($merged, function ($a, $b) {
  7411. return $a['time'] - $b['time'];
  7412. });
  7413. foreach ($merged as $key => $value) {
  7414. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7415. }
  7416. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7417. $titlename = "<table border=1>
  7418. <tr align='center'>
  7419. <td>仓库</td>
  7420. <td>SKU</td>
  7421. <td>商品名称</td>
  7422. <td>仓库品名</td>
  7423. <td>料号</td>
  7424. <td>时间</td>
  7425. <td>操作</td>
  7426. <td>类型</td>
  7427. <td>数量</td>
  7428. <td>备注</td>
  7429. </tr>
  7430. </table>";
  7431. $filename = $title . ".xlsx";
  7432. $tail = "";
  7433. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7434. }
  7435. }
  7436. /*************************************处理exceljs导出****************************************************/
  7437. public function _excelrjs(){
  7438. if (isset($_GET['excel'])) {
  7439. $category = $this->input->get('category', true);
  7440. $size = $this->input->get('size', true);
  7441. $grade = $this->input->get('grade', true);
  7442. $color = $this->input->get('color', true);
  7443. $lowe = $this->input->get('lowe', true);
  7444. $sku = $this->input->get('sku', true);
  7445. $warehouse = $this->input->get('warehouse', true);
  7446. $purchase = $this->input->get('purchase', true);
  7447. $ktime = $this->input->get('ktime', true);
  7448. $jtime = $this->input->get('jtime', true);
  7449. $ktime = strtotime($ktime);
  7450. $jtime = strtotime($jtime);
  7451. $where = "1=1";
  7452. $gj = "";
  7453. $ck = "";
  7454. if ($category) {
  7455. $where .= " and features like '%-$category-%'";
  7456. }
  7457. if ($size) {
  7458. $where .= " and features like '%-$size-%'";
  7459. }
  7460. if ($grade) {
  7461. $where .= " and features like '%-$grade-%'";
  7462. }
  7463. if ($color) {
  7464. $where .= " and features like '%-$color-%'";
  7465. }
  7466. if ($lowe) {
  7467. $where .= " and features like '%-$lowe-%'";
  7468. }
  7469. if ($warehouse) {
  7470. $where .= " and warehouse = '$warehouse'";
  7471. }
  7472. if ($purchase) {
  7473. $where .= " and purchase = '$purchase'";
  7474. }
  7475. if ($sku) {
  7476. $where .= " and sku = '$sku'";
  7477. }
  7478. if ($ktime && $jtime) {
  7479. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7480. }
  7481. //数据排序
  7482. $order_str = "id desc";
  7483. if (empty($page)) {
  7484. $start = 0;
  7485. $perpage = 1;
  7486. } else {
  7487. $start = ($page - 1) * $perpage;
  7488. }
  7489. $list = array();
  7490. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7491. foreach ($rows as $value) {
  7492. $ck = $this->warehouse->read($value['warehouse']);
  7493. $warehouse = $ck['title'];
  7494. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7495. $retreatwarehouse = $tkck['title'];
  7496. $gy = $this->purchase->read($value['purchase']);
  7497. $purchase = $gy['title'];
  7498. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7499. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7500. }
  7501. $list = array_values($list);
  7502. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7503. array_unshift($list,[
  7504. "仓库","SKU","商品名称","时间","数量"
  7505. ]);
  7506. array_unshift($list,[
  7507. $title,"","","",""
  7508. ]);
  7509. exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $list,'title'=>$title)));
  7510. if(empty($list)){
  7511. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7512. }else{
  7513. $list = array_values($list);
  7514. foreach($list as $v){
  7515. $final_list[] = array_values($v);
  7516. }
  7517. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7518. array_unshift($list,[
  7519. "仓库","SKU","商品名称","时间","数量"
  7520. ]);
  7521. array_unshift($list,[
  7522. $title,"","","",""
  7523. ]);
  7524. exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $final_list,'title'=>$title)));
  7525. }
  7526. }
  7527. }
  7528. }