Whlabel.php 267 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_whlabel','whlabel');
  7. $this->load->_model('Model_warehouse','warehouse');
  8. $this->load->_model('Model_purchase','purchase');
  9. $this->load->_model('Model_excel','excel');
  10. $this->load->_model('Model_fullorder','fullorder');
  11. $this->load->_model('Model_fullordertt','fullordertt');
  12. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_shop','shop');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. $this->load->_model('Model_country','country');
  18. $this->load->_model('Model_warehouse','warehouse');
  19. $this->load->_model('Model_kdniao','kdniao');
  20. $this->load->_model('Model_notice','notice');
  21. $this->load->_model('Model_dhl','dhl');
  22. $this->load->_model('Model_shop','shop');
  23. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  24. $this->load->_model('Model_ljg','ljg');
  25. $this->load->_model('Model_usps','usps');
  26. $this->load->_model('Model_specialstock','specialstock');
  27. $this->load->_model('Model_whlabellabel','whlabellabel');
  28. $this->load->_model('Model_whlabelwz','whlabelwz');
  29. $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
  30. $this->load->_model('Model_whlabeltransport','whlabeltransport');
  31. $this->load->_model('Model_orderurl','orderurl');
  32. $this->load->_model('Model_brand','brand');
  33. $this->load->_model('Model_classid','classid');
  34. $this->load->_model('Model_apiyy','apiyy');
  35. $this->load->_model('Model_power','power');
  36. $this->load->_model('Model_whlabel_type','whlabel_type');
  37. $this->load->_model('Model_company','company');
  38. $this->load->_model('Model_whlabel_list','whlabel_list');
  39. $this->load->_model("Model_logic_whlabel","logic_whlabel");
  40. }
  41. //定义方法的调用规则 获取URI第二段值
  42. public function _remap($arg,$arg_array)
  43. {
  44. if($arg == 'existence')//在库标签
  45. {
  46. $this->_existence();
  47. }
  48. else if($arg == 'cpbqdc')//在库标签
  49. {
  50. $this->_cpbqdc();
  51. }
  52. else if($arg == 'type')//进销存浏览
  53. {
  54. $this->_type();
  55. }
  56. else if($arg == 'typedy')//进销存浏览店员页面
  57. {
  58. $this->_typedy($arg_array);
  59. }
  60. else if($arg == 'typedy_ck')//进销存浏览店员页面
  61. {
  62. $this->_typedy_ck($arg_array);
  63. }
  64. else if($arg == 'typeck')
  65. {
  66. $this->_typeck($arg_array);
  67. }
  68. else if($arg == 'whlabeckdc')
  69. {
  70. $this->_whlabeckdc($arg_array);
  71. }
  72. else if($arg == 'usatype')//美仓进销存浏览
  73. {
  74. $this->_usatype();
  75. }
  76. else if($arg == 'usatypeapp')//美仓APP进销存浏览
  77. {
  78. $this->_usatypeapp();
  79. }
  80. else if($arg == 'enteradd')//入库操作
  81. {
  82. $this->_enteradd();
  83. }
  84. else if($arg == 'enteredit')//修改
  85. {
  86. $this->_enteredit($arg_array);
  87. }
  88. else if($arg == 'enter')//入库浏览
  89. {
  90. $this->_enter();
  91. }
  92. else if($arg == 'out')//出库浏览
  93. {
  94. $this->_out();
  95. }
  96. else if($arg == 'label')//出库标签浏览
  97. {
  98. $this->_label();
  99. }
  100. else if($arg == 'outorder')//独立站出库订单
  101. {
  102. $this->_outorder();
  103. }
  104. else if($arg == 'soutorder')//速卖通出库订单
  105. {
  106. $this->_soutorder();
  107. }
  108. else if($arg == 'toutorder')//TT出库订单
  109. {
  110. $this->_toutorder();
  111. }
  112. else if($arg == 'retreat')//退库订单
  113. {
  114. $this->_retreat();
  115. }
  116. else if($arg == 'retreatlk')//退库订单
  117. {
  118. $this->_retreatlk();
  119. }
  120. else if($arg == 'change')//更换标签
  121. {
  122. $this->_change();
  123. }
  124. else if($arg == 'del')//删除
  125. {
  126. $this->_del();
  127. }
  128. else if($arg == 'exceljxc')//进销存信息导出
  129. {
  130. $this->_exceljxc();
  131. }
  132. else if($arg == 'excelr')//入库信息导出
  133. {
  134. $this->_excelr();
  135. }
  136. else if($arg == 'excelct')//出库、退库信息导出
  137. {
  138. $this->_excelct();
  139. }
  140. else if($arg == 'dccrtype')//根据出入库类型导出
  141. {
  142. $this->_dccrtype();
  143. }
  144. else if($arg == 'excelcr')//出库、退库信息导出
  145. {
  146. $this->_excelcr();
  147. }
  148. else if($arg == 'kcyz')//库存验证
  149. {
  150. $this->_kcyz();
  151. }
  152. else if($arg == 'kj')//库存扣减
  153. {
  154. $this->_kj($arg_array);
  155. }
  156. else if($arg == 'presetout')//预设库存导入
  157. {
  158. $this->_presetout($arg_array);
  159. }
  160. else if($arg == 'presetedit')//预设库存导入
  161. {
  162. $this->_presetedit($arg_array);
  163. }
  164. else if($arg == 'summary')//汇总导出
  165. {
  166. $this->_summary($arg_array);
  167. }
  168. else if($arg == 'manifest')//usps发货清单
  169. {
  170. $this->_manifest();
  171. }
  172. else if($arg == 'abnormal')//占单异常
  173. {
  174. $this->_abnormal();
  175. }
  176. else if($arg == 'error')//0库存SKU
  177. {
  178. $this->_error();
  179. }
  180. else if($arg == 'errorexcel')//0库存SKU导出
  181. {
  182. $this->_errorexcel();
  183. }
  184. else if($arg == 'db')
  185. {
  186. $this->_db();
  187. }
  188. else if($arg == 'dbrk')
  189. {
  190. $this->_dbrk();
  191. }
  192. else if($arg == 'whlabelczdc')
  193. {
  194. $this->_whlabelczdc();
  195. }
  196. else if($arg == 'print')
  197. {
  198. $this->_print($arg_array);
  199. }
  200. else if($arg == 'usaprint')
  201. {
  202. $this->_usaprint($arg_array);
  203. }
  204. else if($arg == 'printck')
  205. {
  206. $this->_printck($arg_array);
  207. }
  208. else if($arg == 'printrk')
  209. {
  210. $this->_printrk($arg_array);
  211. }
  212. else if($arg == 'printxzrk')
  213. {
  214. $this->_printxzrk($arg_array);
  215. }
  216. else if($arg == 'printexcel')
  217. {
  218. $this->_printexcel($arg_array);
  219. }
  220. else if($arg == 'uck')
  221. {
  222. $this->_uck();
  223. }
  224. else if($arg == 'whlabelexcelzh')
  225. {
  226. $this->_whlabelexcelzh();
  227. }
  228. else if($arg == 'fc')
  229. {
  230. $this->_fc();
  231. }
  232. else if($arg == 'fcmb')
  233. {
  234. $this->_fcmb();
  235. }
  236. else if($arg == 'fcexcel')
  237. {
  238. $this->_fcexcel();
  239. }
  240. else if($arg == 'fcjxc')
  241. {
  242. $this->_fcjxc($arg_array);
  243. }
  244. else if($arg == '0kcdel')
  245. {
  246. $this->_0kcdel();//导表删除0库存
  247. }
  248. else if($arg == 'gbhtype')
  249. {
  250. $this->_gbhtype();//更改备货状态
  251. }
  252. else
  253. {
  254. $this->_index();
  255. }
  256. }
  257. //管理
  258. public function _index()
  259. {
  260. $post = $this->input->post(NULL, TRUE);
  261. if(isset($post['page']))
  262. {
  263. $page = $this->input->post('page',true);
  264. $perpage = $this->input->post('perpage',true);
  265. $sku = $this->input->post('sku',true);
  266. $number = $this->input->post('number',true);
  267. $warehouse = $this->input->post('warehouse',true);
  268. $purchase = $this->input->post('purchase',true);
  269. $orderinfo = $this->input->post('orderinfo',true);
  270. $waybill = $this->input->post('waybill',true);
  271. $category = $this->input->post('category',true);
  272. $size = $this->input->post('size',true);
  273. $grade = $this->input->post('grade',true);
  274. $color = $this->input->post('color',true);
  275. $lowe = $this->input->post('lowe',true);
  276. $state = $this->input->post('state',true);
  277. $label = $this->input->post('label',true);
  278. $timetk = $this->input->post('timetkk',true);
  279. $timetj = $this->input->post('timetjj',true);
  280. $timetk = strtotime($timetk);
  281. $timetj = strtotime($timetj);
  282. $where = "1=1 ";
  283. if($timetk && $timetj)
  284. {
  285. $where .= " and time > '$timetk' and time < '$timetj'";
  286. }
  287. if($sku)
  288. {
  289. $where .= " and sku = '$sku'";
  290. }
  291. if($number)
  292. {
  293. $where .= " and number = '$number'";
  294. }
  295. if($warehouse)
  296. {
  297. $where .= " and warehouse = '$warehouse'";
  298. }
  299. if($purchase)
  300. {
  301. $where .= " and purchase = '$purchase'";
  302. }
  303. if($orderinfo)
  304. {
  305. $where .= " and orderinfo = '$orderinfo'";
  306. }
  307. if($waybill)
  308. {
  309. $where .= " and waybill = '$waybill'";
  310. }
  311. if($category)
  312. {
  313. $where .= " and features like '%-$category-%'";
  314. }
  315. if($size)
  316. {
  317. $where .= " and features like '%-$size-%'";
  318. }
  319. if($grade)
  320. {
  321. $where .= " and features like '%-$grade-%'";
  322. }
  323. if($color)
  324. {
  325. $where .= " and features like '%-$color-%'";
  326. }
  327. if($lowe)
  328. {
  329. $where .= " and features like '%-$lowe-%'";
  330. }
  331. if($label)
  332. {
  333. $where .= " and label = '$label'";
  334. }
  335. if($state != '')
  336. {
  337. $where .= " and state = '$state'";
  338. }
  339. //数据排序
  340. $order_str = "time desc";
  341. if(empty($page))
  342. {
  343. $start = 0;
  344. $perpage = 1;
  345. }
  346. else
  347. {
  348. $start = ($page - 1)*$perpage;
  349. }
  350. //取得信息列表
  351. $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);
  352. foreach ($info_list as $key=>$value)
  353. {
  354. $warehouse = $this->warehouse->read($value['warehouse']);
  355. $info_list[$key]['warehouse'] = $warehouse['title'];
  356. $purchase = $this->purchase->read($value['purchase']);
  357. $info_list[$key]['purchase'] = $purchase['title'];
  358. if($value['enter'] != 0)
  359. {
  360. $info_list[$key]['enter'] = '<p>'.date('Y-m-d',$value['enter']).'</p><p>'.date('H:i:s',$value['enter']).'</p>';
  361. }
  362. else
  363. {
  364. $info_list[$key]['enter'] = "";
  365. }
  366. if($value['outk'] != 0)
  367. {
  368. $info_list[$key]['outk'] = '<p>'.date('Y-m-d',$value['outk']).'</p><p>'.date('H:i:s',$value['outk']).'</p>';
  369. }
  370. else
  371. {
  372. $info_list[$key]['outk'] = "";
  373. }
  374. if($value['printing'] != 0)
  375. {
  376. $info_list[$key]['printing'] = '<p>'.date('Y-m-d',$value['printing']).'</p><p>'.date('H:i:s',$value['printing']).'</p>';
  377. }
  378. else
  379. {
  380. $info_list[$key]['printing'] = "";
  381. }
  382. if($value['orderinfo'] == 0)
  383. {
  384. $info_list[$key]['orderinfo'] = "";
  385. }
  386. if($value['waybill'] == 0)
  387. {
  388. $info_list[$key]['waybill'] = "";
  389. }
  390. if($value['state'] == 0)
  391. {
  392. $info_list[$key]['state'] = "在库";
  393. }
  394. else if($value['state'] == 1)
  395. {
  396. $info_list[$key]['state'] = "出库";
  397. }
  398. else if($value['state'] == 2)
  399. {
  400. $info_list[$key]['state'] = "退库";
  401. }
  402. else if($value['state'] == 3)
  403. {
  404. $info_list[$key]['state'] = "调拨中";
  405. }
  406. else if($value['state'] == 4)
  407. {
  408. $info_list[$key]['state'] = "再加工";
  409. }
  410. else if($value['state'] == 5)
  411. {
  412. $info_list[$key]['state'] = "维修中";
  413. }
  414. else if($value['state'] == 6)
  415. {
  416. $info_list[$key]['state'] = "盘亏";
  417. }
  418. else if($value['state'] == 7)
  419. {
  420. $info_list[$key]['state'] = "更换标签";
  421. }
  422. else if($value['state'] == 8)
  423. {
  424. $info_list[$key]['state'] = "其它";
  425. }
  426. else if($value['state'] == 9)
  427. {
  428. $info_list[$key]['state'] = "预设";
  429. }
  430. else if($value['state'] == 10)
  431. {
  432. $info_list[$key]['state'] = "美店零售";
  433. }
  434. if($value['text'] == "")
  435. {
  436. $info_list[$key]['text'] = "";
  437. }
  438. $info_list[$key]['time'] = '<p>'.date('Y-m-d',$value['time']).'</p><p>'.date('H:i:s',$value['time']).'</p>';
  439. }
  440. $total = $this->whlabel->find_count($where);
  441. $pagenum = ceil($total/$perpage);
  442. $over = $total-($start+$perpage);
  443. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  444. echo json_encode($rows);exit;
  445. }
  446. if(isset($post['outsku']))
  447. {
  448. $cz = $this->input->post('cz',true);
  449. if($cz == '1')
  450. {
  451. $sku = $this->input->post('outsku',true);
  452. if($sku)
  453. {
  454. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  455. if(count($data) < 1)
  456. {
  457. echo json_encode(array('msg'=>'库存不足!','success'=>false));exit;
  458. }
  459. $this->whlabel->save(array('state'=>10,'outk'=>time(),'time'=>time(),'cktype'=>1),$data[0]['id']);
  460. echo json_encode(array('success'=>true));exit;
  461. }
  462. }
  463. else
  464. {
  465. $sku = $this->input->post('outsku',true);
  466. if($sku)
  467. {
  468. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  469. if(count($data) < 1)
  470. {
  471. echo json_encode(array('msg'=>'没有此SKU出库数据!','success'=>false));exit;
  472. }
  473. $this->whlabel->save(array('state'=>0,'outk'=>0,'time'=>time()),$data[0]['id']);
  474. echo json_encode(array('success'=>true));exit;
  475. }
  476. }
  477. }
  478. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  479. $this->_Template('whlabel',$this->data);
  480. }
  481. //在库标签
  482. public function _existence()
  483. {
  484. $post = $this->input->post(NULL, TRUE);
  485. if(isset($post['s']))
  486. {
  487. $id_arr = $this->input->post('s');
  488. $id_arr = explode(',',$id_arr);
  489. if(!$id_arr)
  490. {
  491. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  492. }
  493. //循环删除记录
  494. foreach ($id_arr as $v)
  495. {
  496. $sid = $this->whlabel->read($v);
  497. $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
  498. if($count > 0)
  499. {
  500. echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
  501. }
  502. $zt = $this->whlabeltransport->find_all('sku = "'.$sid['sku'].'" and warehouse = "'.$sid['warehouse'].'" and features = "'.$sid['features'].'" and cz = "0"');
  503. if(count($zt) > 0)
  504. {
  505. echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
  506. }
  507. $this->whlabel->remove($v);
  508. }
  509. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  510. }
  511. if(isset($post['page']))
  512. {
  513. $page = $this->input->post('page',true);
  514. $perpage = $this->input->post('perpage',true);
  515. $warehouse = $this->input->post('warehouse',true);
  516. $label = $this->input->post('label',true);
  517. $where = "1=1 and state = 0";
  518. if($warehouse)
  519. {
  520. $where .= " and warehouse = '$warehouse'";
  521. }
  522. if($label)
  523. {
  524. $where .= " and label = '$label'";
  525. }
  526. //数据排序
  527. $order_str = "time asc";
  528. if(empty($page))
  529. {
  530. $start = 0;
  531. $perpage = 1;
  532. }
  533. else
  534. {
  535. $start = ($page - 1)*$perpage;
  536. }
  537. //取得信息列表
  538. $info_list = $this->whlabel->find_all($where,'id,sku,title,label,printing,enter',$order_str,$start,$perpage);
  539. foreach ($info_list as $key=>$value)
  540. {
  541. if($value['enter'] != 0)
  542. {
  543. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  544. }
  545. else
  546. {
  547. $info_list[$key]['enter'] = "";
  548. }
  549. if($value['printing'] != 0)
  550. {
  551. $info_list[$key]['printing'] = date('Y-m-d H:i:s',$value['printing']);
  552. }
  553. else
  554. {
  555. $info_list[$key]['printing'] = "";
  556. }
  557. }
  558. $total = $this->whlabel->find_count($where);
  559. $pagenum = ceil($total/$perpage);
  560. $over = $total-($start+$perpage);
  561. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  562. echo json_encode($rows);exit;
  563. }
  564. $this->_Template('whlabel_existence',$this->data);
  565. }
  566. //进销存浏览
  567. public function _typedy($arg_array)
  568. {
  569. $prc = array();
  570. $purchase = $this->purchase->find_all();
  571. foreach($purchase as $k=>$v)
  572. {
  573. $prc[$v['id']] = $v['title'];
  574. }
  575. $post = $this->input->post(NULL, TRUE);
  576. if(isset($post['page']))
  577. {
  578. $page = $this->input->post('page',true);
  579. $perpage = $this->input->post('perpage',true);
  580. $category = $this->input->post('category',true);
  581. $size = $this->input->post('size',true);
  582. $grade = $this->input->post('grade',true);
  583. $color = $this->input->post('color',true);
  584. $lowe = $this->input->post('lowe',true);
  585. $sku = $this->input->post('sku');
  586. $title = $this->input->post('title');
  587. $warehouse = $this->input->post('warehouse',true);
  588. $usa = $this->input->post('usa',true);
  589. $purchase = $this->input->post('purchase',true);
  590. $lacetype = $this->input->post('lacetype',true);
  591. $haircap = $this->input->post('haircap',true);
  592. $density = $this->input->post('density',true);
  593. $details = $this->input->post('details',true);
  594. $state = $this->input->post('state',true);
  595. $lacecolor = $this->input->post('lacecolor',true);
  596. $hairnumber = $this->input->post('hairnumber',true);
  597. $cklx = $this->input->post('cklx',true);
  598. $ktime = $this->input->post('ktime',true);
  599. $jtime = $this->input->post('jtime',true);
  600. $ktime = strtotime($ktime);
  601. $jtime = strtotime($jtime);
  602. $where = "1=1";$gj = "";$ck = "";
  603. if($usa)
  604. {
  605. if(!$warehouse)
  606. {
  607. $where .= " and (warehouse = '5' or warehouse = '8')";
  608. }
  609. }
  610. if($warehouse)
  611. {
  612. $where .= " and warehouse = '$warehouse'";
  613. }
  614. if($details)
  615. {
  616. $where .= " and details = '$details'";
  617. }
  618. if($purchase)
  619. {
  620. $where .= " and purchase = '$purchase'";
  621. }
  622. if($state)
  623. {
  624. $where .= " and state = '$state'";
  625. }
  626. if($lacetype)
  627. {
  628. $where .= " and features like '%-$lacetype-%'";
  629. }
  630. if($category)
  631. {
  632. $where .= " and features like '%-$category-%'";
  633. }
  634. if($size)
  635. {
  636. $where .= " and features like '%-$size-%'";
  637. }
  638. if($grade)
  639. {
  640. $where .= " and features like '%-$grade-%'";
  641. }
  642. if($color)
  643. {
  644. $where .= " and features like '%-$color-%'";
  645. }
  646. if($lowe)
  647. {
  648. $where .= " and features like '%-$lowe-%'";
  649. }
  650. if($haircap)
  651. {
  652. $where .= " and features like '%-$haircap-%'";
  653. }
  654. if($density)
  655. {
  656. $where .= " and features like '%-$density-%'";
  657. }
  658. if($lacecolor)
  659. {
  660. $where .= " and features like '%-$lacecolor-%'";
  661. }
  662. if(!empty($hairnumber)){
  663. $where .= " and features like '%-128-%' ";
  664. if($hairnumber < 0){
  665. $class_list = $this->typeclass->find_all('classid = 43');
  666. foreach($class_list as $v){
  667. $where .= " and features not like '%-".$v['id']."-%'";
  668. }
  669. }else{
  670. $where .= " and features like '%-$hairnumber-%'";
  671. }
  672. }
  673. $where_add = '';
  674. if($cklx)
  675. {
  676. $shop = $this->shop->read($cklx);
  677. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  678. }
  679. if($ktime && $jtime)
  680. {
  681. $gj = " and enter > '$ktime' and enter < '$jtime'";
  682. $ck = " and outk > '$ktime' and outk < '$jtime'";
  683. }
  684. //数据排序
  685. $order_str = "id desc";
  686. if(empty($page))
  687. {
  688. $start = 0;
  689. $perpage = 1;
  690. }
  691. else
  692. {
  693. $start = ($page - 1)*$perpage;
  694. }
  695. if($sku)
  696. {
  697. $sku = trim($sku,' ');
  698. $sku = trim($sku,' ');
  699. $where .= " and sku like '%$sku%'";
  700. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
  701. }
  702. else if($title)
  703. {
  704. $title = trim($title,' ');
  705. $title = trim($title,' ');
  706. $where .= " and title like '%$title%'";
  707. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
  708. }
  709. else
  710. {
  711. //$where .= " and time > '$ktime' and time < '$jtime'";
  712. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm',$order_str,$start,$perpage);
  713. }
  714. //取得信息列表
  715. $rows = array();$list = array();
  716. foreach ($info_list as $key=>$value)
  717. {
  718. $warehouse = $this->warehouse->read($value['warehouse']);
  719. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  720. $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  721. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  722. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  723. $number = $value['number'];$ftime = time()-15*24*3600;
  724. $info_list[$key]['warehouse'] = $warehouse['title'];
  725. $info_list[$key]['features'] = count($c);
  726. $z = count($z);//查看订单号
  727. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  728. $ztdata = '';
  729. if(count($zt) > 0)
  730. {
  731. foreach ($zt as $vv)
  732. {
  733. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  734. }
  735. }
  736. $info_list[$key]['number'] = $ztdata;
  737. $info_list[$key]['sm'] = $z;
  738. $details = array();
  739. $cpid = array();
  740. foreach ($c as $k=>$v)
  741. {
  742. $details[$v['details']] = $v['details'];
  743. if($v['cpid'] != 0)
  744. {
  745. $cpid[$v['cpid']] = $v['cpid'];
  746. }
  747. }
  748. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  749. if($value['shop'] != '')
  750. {
  751. $shop = explode(',',trim($value['shop'],','));
  752. $shop = $this->shop->read($shop[0]);
  753. $info_list[$key]['shop'] = $shop['shopname'];
  754. }
  755. }
  756. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  757. $pagenum = ceil($total/$perpage);
  758. $over = $total-($start+$perpage);
  759. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  760. echo json_encode($rows);exit;
  761. }
  762. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  763. $this->_Template('whlabel_typedy',$this->data);
  764. }
  765. //进销存浏览
  766. public function _typedy_ck($arg_array)
  767. {
  768. $prc = array();
  769. $purchase = $this->purchase->find_all();
  770. foreach($purchase as $k=>$v)
  771. {
  772. $prc[$v['id']] = $v['title'];
  773. }
  774. $post = $this->input->post(NULL, TRUE);
  775. if(isset($post['page']))
  776. {
  777. $page = $this->input->post('page',true);
  778. $perpage = $this->input->post('perpage',true);
  779. $category = $this->input->post('category',true);
  780. $size = $this->input->post('size',true);
  781. $grade = $this->input->post('grade',true);
  782. $color = $this->input->post('color',true);
  783. $lowe = $this->input->post('lowe',true);
  784. $sku = $this->input->post('sku');
  785. $title = $this->input->post('title');
  786. $warehouse = $this->input->post('warehouse',true);
  787. $usa = $this->input->post('usa',true);
  788. $purchase = $this->input->post('purchase',true);
  789. $lacetype = $this->input->post('lacetype',true);
  790. $haircap = $this->input->post('haircap',true);
  791. $density = $this->input->post('density',true);
  792. $details = $this->input->post('details',true);
  793. $state = $this->input->post('state',true);
  794. $lacecolor = $this->input->post('lacecolor',true);
  795. $cklx = $this->input->post('cklx',true);
  796. $ktime = $this->input->post('ktime',true);
  797. $jtime = $this->input->post('jtime',true);
  798. $ktime = strtotime($ktime);
  799. $jtime = strtotime($jtime);
  800. $where = "1=1";$gj = "";$ck = "";
  801. if($lacetype)
  802. {
  803. $where .= " and features like '%-$lacetype-%'";
  804. }
  805. if($category)
  806. {
  807. $where .= " and features like '%-$category-%'";
  808. }
  809. if($size)
  810. {
  811. $where .= " and features like '%-$size-%'";
  812. }
  813. if($grade)
  814. {
  815. $where .= " and features like '%-$grade-%'";
  816. }
  817. if($color)
  818. {
  819. $where .= " and features like '%-$color-%'";
  820. }
  821. if($lowe)
  822. {
  823. $where .= " and features like '%-$lowe-%'";
  824. }
  825. if($haircap)
  826. {
  827. $where .= " and features like '%-$haircap-%'";
  828. }
  829. if($density)
  830. {
  831. $where .= " and features like '%-$density-%'";
  832. }
  833. if($lacecolor)
  834. {
  835. $where .= " and features like '%-$lacecolor-%'";
  836. }
  837. if($usa)
  838. {
  839. if(!$warehouse)
  840. {
  841. $where .= " and (warehouse = '5' or warehouse = '8')";
  842. }
  843. }
  844. if($warehouse)
  845. {
  846. $where .= " and warehouse = '$warehouse'";
  847. }
  848. if($details)
  849. {
  850. $where .= " and details = '$details'";
  851. }
  852. if($purchase)
  853. {
  854. $where .= " and purchase = '$purchase'";
  855. }
  856. if($state)
  857. {
  858. $where .= " and state = '$state'";
  859. }
  860. $where_add = '';
  861. if($cklx)
  862. {
  863. $shop = $this->shop->read($cklx);
  864. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  865. }
  866. if($ktime && $jtime)
  867. {
  868. $gj = " and enter > '$ktime' and enter < '$jtime'";
  869. $ck = " and outk > '$ktime' and outk < '$jtime'";
  870. }
  871. //数据排序
  872. $order_str = "id desc";
  873. if(empty($page))
  874. {
  875. $start = 0;
  876. $perpage = 1;
  877. }
  878. else
  879. {
  880. $start = ($page - 1)*$perpage;
  881. }
  882. if($sku)
  883. {
  884. $sku = trim($sku,' ');
  885. $sku = trim($sku,' ');
  886. $where .= " and sku like '%$sku%'";
  887. $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);
  888. }
  889. else if($title)
  890. {
  891. $title = trim($title,' ');
  892. $title = trim($title,' ');
  893. $where .= " and title like '%$title%'";
  894. $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);
  895. }
  896. else
  897. {
  898. //$where .= " and time > '$ktime' and time < '$jtime'";
  899. $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);
  900. }
  901. //取得信息列表
  902. $rows = array();$list = array();
  903. foreach ($info_list as $key=>$value)
  904. {
  905. $warehouse = $this->warehouse->read($value['warehouse']);
  906. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  907. $c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,text');
  908. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  909. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$c[0]['text'].'</p>';
  910. $ftime = time()-15*24*3600;
  911. $info_list[$key]['warehouse'] = $warehouse['title'];
  912. $info_list[$key]['features'] = count($c)<10?"<em style='color:#F00'>".count($c)."</em>":count($c);
  913. //$z = count($z);//查看订单号
  914. //$info_list[$key]['zd'] = $z;
  915. $details = array();
  916. $cpid = array();
  917. foreach ($c as $k=>$v)
  918. {
  919. $details[$v['details']] = $v['details'];
  920. if($v['cpid'] != 0)
  921. {
  922. $cpid[$v['cpid']] = $v['cpid'];
  923. }
  924. }
  925. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  926. if($value['shop'] != '')
  927. {
  928. $shop = explode(',',trim($value['shop'],','));
  929. $shop = $this->shop->read($shop[0]);
  930. $info_list[$key]['shop'] = $shop['shopname'];
  931. }
  932. }
  933. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  934. $pagenum = ceil($total/$perpage);
  935. $over = $total-($start+$perpage);
  936. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  937. echo json_encode($rows);exit;
  938. }
  939. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  940. $this->_Template('whlabel_typedy_ck',$this->data);
  941. }
  942. public function _typeck($arg_array)
  943. {
  944. $prc = array();
  945. $purchase = $this->purchase->find_all();
  946. foreach($purchase as $k=>$v)
  947. {
  948. $prc[$v['id']] = $v['title'];
  949. }
  950. $post = $this->input->post(NULL, TRUE);
  951. if(isset($post['page']))
  952. {
  953. $page = $this->input->post('page',true);
  954. $perpage = $this->input->post('perpage',true);
  955. $category = $this->input->post('category',true);
  956. $size = $this->input->post('size',true);
  957. $grade = $this->input->post('grade',true);
  958. $color = $this->input->post('color',true);
  959. $lacecolor = $this->input->post('lacecolor',true);
  960. $lowe = $this->input->post('lowe',true);
  961. $sku = $this->input->post('sku');
  962. $title = $this->input->post('title');
  963. $warehouse = 13;
  964. $usa = $this->input->post('usa',true);
  965. $purchase = $this->input->post('purchase',true);
  966. $lacetype = $this->input->post('lacetype',true);
  967. $haircap = $this->input->post('haircap',true);
  968. $density = $this->input->post('density',true);
  969. $details = $this->input->post('details',true);
  970. $state = $this->input->post('state',true);
  971. $ktime = $this->input->post('ktime',true);
  972. $jtime = $this->input->post('jtime',true);
  973. $ktime = strtotime($ktime);
  974. $jtime = strtotime($jtime);
  975. $where = "1=1";$gj = "";$ck = "";
  976. if($lacetype)
  977. {
  978. $where .= " and features like '%-$lacetype-%'";
  979. }
  980. if($category)
  981. {
  982. $where .= " and features like '%-$category-%'";
  983. }
  984. if($size)
  985. {
  986. $where .= " and features like '%-$size-%'";
  987. }
  988. if($grade)
  989. {
  990. $where .= " and features like '%-$grade-%'";
  991. }
  992. if($color)
  993. {
  994. $where .= " and features like '%-$color-%'";
  995. }
  996. if($lacecolor)
  997. {
  998. $where .= " and features like '%-$lacecolor-%'";
  999. }
  1000. if($lowe)
  1001. {
  1002. $where .= " and features like '%-$lowe-%'";
  1003. }
  1004. if($haircap)
  1005. {
  1006. $where .= " and features like '%-$haircap-%'";
  1007. }
  1008. if($density)
  1009. {
  1010. $where .= " and features like '%-$density-%'";
  1011. }
  1012. if($warehouse)
  1013. {
  1014. $where .= " and warehouse = '$warehouse'";
  1015. }
  1016. if($details)
  1017. {
  1018. $where .= " and details = '$details'";
  1019. }
  1020. if($purchase)
  1021. {
  1022. $where .= " and purchase = '$purchase'";
  1023. }
  1024. if($state)
  1025. {
  1026. $where .= " and state = '$state'";
  1027. }
  1028. if($ktime && $jtime)
  1029. {
  1030. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1031. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1032. }
  1033. //数据排序
  1034. $order_str = "id desc";
  1035. if(empty($page))
  1036. {
  1037. $start = 0;
  1038. $perpage = 1;
  1039. }
  1040. else
  1041. {
  1042. $start = ($page - 1)*$perpage;
  1043. }
  1044. if($sku)
  1045. {
  1046. $sku = trim($sku,' ');
  1047. $sku = trim($sku,' ');
  1048. $where .= " and sku like '%$sku%'";
  1049. }
  1050. else if($title)
  1051. {
  1052. $title = trim($title,' ');
  1053. $title = trim($title,' ');
  1054. $where .= " and title like '%$title%'";
  1055. }
  1056. $info_list = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,sm,details,cpbz,features,number,',$order_str,$start,$perpage);
  1057. //取得信息列表
  1058. $t = array();
  1059. $typeclass = $this->typeclass->find_all();
  1060. foreach ($typeclass as $v)
  1061. {
  1062. $t[$v['id']] = $v;
  1063. }
  1064. $rows = array();$list = array();
  1065. foreach ($info_list as $key=>$value)
  1066. {
  1067. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1068. $mc = $this->whlabel->find_all("sku = '".$value['sku']."' and features = '".$value['features']."' and warehouse = '".$value['warehouse']."'",'cpbz','id desc',0,1);
  1069. $warehouse = $this->warehouse->read($value['warehouse']);
  1070. $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');
  1071. $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'].'"');
  1072. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  1073. $number = $value['number'];$ftime = time()-15*24*3600;
  1074. $z = count($z);//查看订单号
  1075. $info_list[$key]['warehouse'] = $warehouse['title'];
  1076. $info_list[$key]['features'] = count($c);
  1077. $info_list[$key]['number'] = $z;
  1078. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  1079. $details = array();
  1080. $cpid = array();
  1081. foreach ($c as $k=>$v)
  1082. {
  1083. $details[$v['details']] = $v['details'];
  1084. if($v['cpid'] != 0)
  1085. {
  1086. $cpid[$v['cpid']] = $v['cpid'];
  1087. }
  1088. }
  1089. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1090. $classid = $this->classid->sku();
  1091. $pm = $classid;
  1092. $features = explode('-',trim($value['features'],'-'));
  1093. foreach($features as $v)
  1094. {
  1095. $zh = explode('|',trim($t[$v]['zh'],'|'));
  1096. $pm[$t[$v]['classid']] = $zh[0];
  1097. }
  1098. $zh = implode(" ",$pm);
  1099. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1100. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1101. $info_list[$key]['sm'] = $zh;
  1102. }
  1103. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  1104. $pagenum = ceil($total/$perpage);
  1105. $over = $total-($start+$perpage);
  1106. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1107. echo json_encode($rows);exit;
  1108. }
  1109. $this->data['warehouse'] = (isset($arg_array[0]))?$arg_array[0]:5;
  1110. $this->_Template('whlabel_typeck',$this->data);
  1111. }
  1112. //进销存导出
  1113. public function _whlabeckdc()
  1114. {
  1115. $prc = array();
  1116. $purchase = $this->purchase->find_all();
  1117. foreach($purchase as $k=>$v)
  1118. {
  1119. $prc[$v['id']] = $v['title'];
  1120. }
  1121. if(isset($_GET['excel']))
  1122. {
  1123. $where = "sku != 'Preset'";
  1124. //数据排序
  1125. $order_str = "id desc";
  1126. if(empty($page))
  1127. {
  1128. $start = 0;
  1129. $perpage = 1;
  1130. }
  1131. else
  1132. {
  1133. $start = ($page - 1)*$perpage;
  1134. }
  1135. $category = $this->input->get('category',true);
  1136. $color = $this->input->get('color',true);
  1137. $lowe = $this->input->get('lowe',true);
  1138. $lacetype = $this->input->get('lacetype',true);
  1139. $size = $this->input->get('size',true);
  1140. $density = $this->input->get('density',true);
  1141. $haircap = $this->input->get('haircap',true);
  1142. $sku = $this->input->get('sku',true);
  1143. $details = $this->input->get('details',true);
  1144. $warehouse = 13;
  1145. $excelid = $this->input->get('sid',true);
  1146. if($category)
  1147. {
  1148. $where .= " and features like '%-$category-%'";
  1149. }
  1150. if($color)
  1151. {
  1152. $where .= " and features like '%-$color-%'";
  1153. }
  1154. if($lowe)
  1155. {
  1156. $where .= " and features like '%-$lowe-%'";
  1157. }
  1158. if($lacetype)
  1159. {
  1160. $where .= " and features like '%-$lacetype-%'";
  1161. }
  1162. if($size)
  1163. {
  1164. $where .= " and features like '%-$size-%'";
  1165. }
  1166. if($density)
  1167. {
  1168. $where .= " and features like '%-$density-%'";
  1169. }
  1170. if($haircap)
  1171. {
  1172. $where .= " and features like '%-$haircap-%'";
  1173. }
  1174. if($warehouse)
  1175. {
  1176. $where .= " and warehouse = '$warehouse'";
  1177. }
  1178. if($sku)
  1179. {
  1180. $where .= " and sku like '%$sku%'";
  1181. }
  1182. if($details)
  1183. {
  1184. $where .= " and details = '$details'";
  1185. }
  1186. $xzid = '';
  1187. if($excelid)
  1188. {
  1189. $excelid = explode(',',trim($excelid,','));
  1190. foreach ($excelid as $key=>$value)
  1191. {
  1192. $xzid .= " id = ".$value." or";
  1193. }
  1194. $xzid = " and (".rtrim($xzid,'or').")";;
  1195. }
  1196. //取得信息列表
  1197. /**
  1198. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1199. $rows = array();$list = array();
  1200. foreach ($info_list as $key=>$value)
  1201. {
  1202. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1203. }
  1204. **/
  1205. $wh = array();
  1206. $w = $this->warehouse->find_all('1=1','id,title');
  1207. foreach ($w as $v)
  1208. {
  1209. $wh[$v['id']] = $v['title'];
  1210. }
  1211. $tc = array();$tcdata = array();
  1212. $typeclass = $this->typeclass->find_all();
  1213. foreach ($typeclass as $v)
  1214. {
  1215. $tc[$v['id']] = $v;
  1216. }
  1217. $list = array();
  1218. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1219. foreach ($rows as $key=>$value)
  1220. {
  1221. $bm = '03';
  1222. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1223. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1224. $classid = $this->classid->sku();
  1225. $pm = $classid;
  1226. $jm = $classid;
  1227. $features = explode('-',trim($value['features'],'-'));
  1228. foreach($features as $v)
  1229. {
  1230. if(isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']]))
  1231. {
  1232. if($tc[$v]['bm'] != '')
  1233. {
  1234. $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
  1235. }
  1236. }
  1237. if(isset($tc[$v]))
  1238. {
  1239. $zh = explode('|',trim($tc[$v]['zh'],'|'));
  1240. $pm[$tc[$v]['classid']] = $zh[0];
  1241. }
  1242. if(isset($tc[$v]))
  1243. {
  1244. if(isset($jm[$tc[$v]['classid']]))
  1245. {
  1246. $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
  1247. }
  1248. }
  1249. }
  1250. $zh = implode(" ",$pm);
  1251. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  1252. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  1253. $rows[$key]['dbcontent'] = $zh;
  1254. $rows[$key]['cpbz'] = $bm.implode("",$bmpx);
  1255. $jm = array_filter($jm);
  1256. $rows[$key]['cs'] = implode("-",$jm);
  1257. $sd = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid,cpbz,state');
  1258. $details = array();
  1259. $cpid = array();
  1260. $cpbz = array();
  1261. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  1262. foreach ($sd as $k=>$v)
  1263. {
  1264. if($v['state'] == 0)
  1265. {
  1266. $c++;
  1267. }
  1268. if($v['state'] != 9)
  1269. {
  1270. $g++;
  1271. }
  1272. if($v['state'] == 1)
  1273. {
  1274. $x++;
  1275. }
  1276. if($v['state'] == 2)
  1277. {
  1278. $t++;
  1279. }
  1280. if($v['state'] == 8)
  1281. {
  1282. $s++;
  1283. }
  1284. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  1285. {
  1286. $q++;
  1287. }
  1288. $details[$v['details']] = $v['details'];
  1289. if($v['cpid'] != 0)
  1290. {
  1291. $cpid[$v['cpid']] = $v['cpid'];
  1292. }
  1293. if($v['cpbz'] != '')
  1294. {
  1295. $cpbz[$v['cpbz']] = $v['cpbz'];
  1296. }
  1297. }
  1298. $rows[$key]['details'] = implode("、",$details);
  1299. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  1300. $number = $value['number'];
  1301. $ftime = time()-15*24*3600;
  1302. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1303. $rows[$key]['number'] = $g;
  1304. $rows[$key]['features'] = $c;
  1305. $rows[$key]['x'] = $x;
  1306. $rows[$key]['t'] = $t;
  1307. $rows[$key]['s'] = $s;
  1308. $rows[$key]['q'] = $q;
  1309. $rows[$key]['wzsl'] = count($details);
  1310. }
  1311. $title = "进销存统计表".date('Y-m-d',time());
  1312. $titlename = "<table border=1>
  1313. <tr><th colspan='12' align='center'><h3>".$title."<h3></th></tr>
  1314. <tr align='center'>
  1315. <td>仓库</td>
  1316. <td>供应商</td>
  1317. <td>位置</td>
  1318. <td>库存编码</td>
  1319. <td>SKU</td>
  1320. <td>用友编码</td>
  1321. <td>用友料号</td>
  1322. <td>产品英文名</td>
  1323. <td>产品中文名</td>
  1324. <td>入库总量</td>
  1325. <td>库存数量</td>
  1326. <td>销售数量</td>
  1327. <td>退货数量</td>
  1328. <td>删除数量</td>
  1329. <td>其它操作</td>
  1330. <td>位置数量</td>
  1331. </tr>
  1332. </table>";
  1333. $filename = $title.".xls";
  1334. $tail = "";
  1335. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1336. }
  1337. }
  1338. public function _type()
  1339. {
  1340. $vip = 0;
  1341. if(isset($_SESSION['api']))
  1342. {
  1343. $user = $this->user->get_api($_SESSION['api']);
  1344. $fgshop = "";$sid = "";
  1345. $usersp = explode('|',trim($user['shop'],'|'));
  1346. foreach ($usersp as $value)
  1347. {
  1348. $fgshop .= " shop = ".$value." or";
  1349. $sid .= " id = ".$value." or";
  1350. }
  1351. if($user['vip'] == 1)
  1352. {
  1353. $vip = 1;
  1354. }
  1355. }
  1356. else
  1357. {
  1358. header('Location: /');exit;
  1359. }
  1360. $prc = array();
  1361. $purchase = $this->purchase->find_all();
  1362. foreach($purchase as $k=>$v)
  1363. {
  1364. $prc[$v['id']] = $v['title'];
  1365. }
  1366. $company = array();
  1367. $ct = $this->company->find_all();
  1368. foreach($ct as $k=>$v)
  1369. {
  1370. $company[$v['id']] = $v['title'];
  1371. }
  1372. $sp = array();
  1373. $s = $this->shop->find_all('1=1','id,shopname');
  1374. foreach ($s as $v)
  1375. {
  1376. $sp[$v['id']] = $v['shopname'];
  1377. }
  1378. $wh = array();
  1379. $w = $this->warehouse->find_all('1=1','id,title');
  1380. foreach ($w as $v)
  1381. {
  1382. $wh[$v['id']] = $v['title'];
  1383. }
  1384. $post = $this->input->post(NULL, TRUE);
  1385. if(isset($post['page']))
  1386. {
  1387. $page = $this->input->post('page',true);
  1388. $perpage = $this->input->post('perpage',true);
  1389. $category = $this->input->post('category',true);
  1390. $size = $this->input->post('size',true);
  1391. $grade = $this->input->post('grade',true);
  1392. $color = $this->input->post('color',true);
  1393. $lowe = $this->input->post('lowe',true);
  1394. $sku = $this->input->post('sku');
  1395. $title = $this->input->post('title');
  1396. $warehouse = $this->input->post('warehouse',true);
  1397. $usa = $this->input->post('usa',true);
  1398. $purchase = $this->input->post('purchase',true);
  1399. $lacetype = $this->input->post('lacetype',true);
  1400. $haircap = $this->input->post('haircap',true);
  1401. $density = $this->input->post('density',true);
  1402. $details = $this->input->post('details',true);
  1403. $state = $this->input->post('state',true);
  1404. $shop = $this->input->post('shop',true);
  1405. $lacecolor = $this->input->post('lacecolor',true);
  1406. $hairnumber = $this->input->post('hairnumber',true);
  1407. $type = $this->input->post('type',true);
  1408. $ktime = $this->input->post('ktime',true);
  1409. $jtime = $this->input->post('jtime',true);
  1410. $ktime = strtotime($ktime);
  1411. $jtime = strtotime($jtime);
  1412. $cpbz = $this->input->post('cpbz',true);
  1413. $where = "1=1";$gj = "";$ck = "";
  1414. if($usa)
  1415. {
  1416. if(!$warehouse)
  1417. {
  1418. $where .= " and (warehouse = '5' or warehouse = '8')";
  1419. }
  1420. }
  1421. if($warehouse)
  1422. {
  1423. $where .= " and warehouse = '$warehouse'";
  1424. }
  1425. if($details)
  1426. {
  1427. $where .= " and details = '$details'";
  1428. }
  1429. if($purchase)
  1430. {
  1431. $where .= " and purchase = '$purchase'";
  1432. }
  1433. if($state)
  1434. {
  1435. $where .= " and state = '$state'";
  1436. }
  1437. if($shop)
  1438. {
  1439. $where .= " and shop like '%$shop%'";
  1440. }
  1441. if($type)
  1442. {
  1443. $where .= " and type = '$type'";
  1444. }
  1445. if($ktime && $jtime)
  1446. {
  1447. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1448. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1449. }
  1450. if($cpbz){
  1451. $where .= " and cpbz like '%$cpbz%' ";
  1452. }
  1453. if($lacecolor)
  1454. {
  1455. $where .= " and features like '%-$lacecolor-%'";
  1456. }
  1457. if($lacetype)
  1458. {
  1459. $where .= " and features like '%-$lacetype-%'";
  1460. }
  1461. if($category)
  1462. {
  1463. $where .= " and features like '%-$category-%'";
  1464. }
  1465. if($size)
  1466. {
  1467. $where .= " and features like '%-$size-%'";
  1468. }
  1469. if($grade)
  1470. {
  1471. $where .= " and features like '%-$grade-%'";
  1472. }
  1473. if($color)
  1474. {
  1475. $where .= " and features like '%-$color-%'";
  1476. }
  1477. if($lowe)
  1478. {
  1479. $where .= " and features like '%-$lowe-%'";
  1480. }
  1481. if($haircap)
  1482. {
  1483. $where .= " and features like '%-$haircap-%'";
  1484. }
  1485. if($density)
  1486. {
  1487. $where .= " and features like '%-$density-%'";
  1488. }
  1489. if(!empty($hairnumber)){
  1490. $where .= " and features like '%-128-%' ";
  1491. if($hairnumber < 0){
  1492. $class_list = $this->typeclass->find_all('classid = 43');
  1493. foreach($class_list as $v){
  1494. $where .= " and features not like '%-".$v['id']."-%'";
  1495. }
  1496. }else{
  1497. $where .= " and features like '%-$hairnumber-%'";
  1498. }
  1499. }
  1500. //数据排序
  1501. $order_str = "id desc";
  1502. if(empty($page))
  1503. {
  1504. $start = 0;
  1505. $perpage = 1;
  1506. }
  1507. else
  1508. {
  1509. $start = ($page - 1)*$perpage;
  1510. }
  1511. $fjnr = '';
  1512. if($sku)
  1513. {
  1514. $sku = trim($sku,' ');
  1515. $sku = trim($sku,' ');
  1516. $fjnr .= " and sku like '%$sku%'";
  1517. }
  1518. if($title)
  1519. {
  1520. $title = trim($title,' ');
  1521. $title = trim($title,' ');
  1522. $fjnr .= " and title like '%$title%'";
  1523. }
  1524. $wt = array();
  1525. $whlabel_type = $this->whlabel_type->find_all();
  1526. foreach ($whlabel_type as $v)
  1527. {
  1528. $wt[$v['id']] = $v['title'];
  1529. }
  1530. //$where .= " and time > '$ktime' and time < '$jtime'";
  1531. $info_list = $this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,purchase,sku,title,details,shop,cpbz,type,features,number,sm',$order_str,$start,$perpage);//改这需要修改_gbhtype
  1532. //取得信息列表
  1533. $info_list = $this->logic_whlabel->dataTran($info_list,['pm']);
  1534. $rows = array();$list = array();
  1535. foreach ($info_list as $key=>$value)
  1536. {
  1537. if(isset($wt[$value['type']]))
  1538. {
  1539. $info_list[$key]['type'] = $wt[$value['type']];
  1540. }
  1541. else
  1542. {
  1543. $info_list[$key]['type'] = '未设置';
  1544. }
  1545. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  1546. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1547. $ztdata = '';
  1548. if(count($zt) > 0)
  1549. {
  1550. foreach ($zt as $vv)
  1551. {
  1552. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1553. }
  1554. }
  1555. $qbdata = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1556. $cdata = array_filter($qbdata, function($item) {
  1557. return $item['state'] < 1;
  1558. });
  1559. $c = array_sum(array_column($cdata, 'jnum'));
  1560. $gdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1561. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1562. });
  1563. $g = array_sum(array_column($gdata, 'jnum'));
  1564. $xdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1565. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1566. });
  1567. $x = array_sum(array_column($xdata, 'jnum'));
  1568. $tdata = array_filter($qbdata, function($item) use ($ktime, $jtime) {
  1569. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1570. });
  1571. $t = array_sum(array_column($tdata, 'jnum'));
  1572. $zdata = array_filter($qbdata, function($item) {
  1573. return $item['zd'] != "" && $item['state'] < 1;
  1574. });
  1575. $z = array_sum(array_column($zdata, 'jnum'));
  1576. $zdata = array_filter($qbdata, function($item) {
  1577. return $item['zd'] != "" && $item['state'] < 1;
  1578. });
  1579. $z = array_sum(array_column($zdata, 'jnum'));
  1580. //$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');
  1581. //$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'].'"');
  1582. //$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'].'"');
  1583. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1584. //$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'].'"');
  1585. $details = array();
  1586. $cpid = array();
  1587. $od = array();$odid = '';
  1588. $companytitle = '';
  1589. foreach ($qbdata as $v)
  1590. {
  1591. if($v['zd'] != "" && $v['state'] < 1)
  1592. {
  1593. if(!isset($od[$v['zd']]))
  1594. {
  1595. $od[$v['zd']] = 1;//所有数据sku
  1596. }
  1597. else
  1598. {
  1599. $od[$v['zd']] = $od[$v['zd']]+1;
  1600. }
  1601. }
  1602. if($v['state'] < 1)
  1603. {
  1604. $details[$v['details']] = $v['details'];
  1605. if($v['cpid'] != 0)
  1606. {
  1607. $cpid[$v['cpid']] = $v['cpid'];
  1608. }
  1609. }
  1610. if($v['companytitle'] != '' && stripos($companytitle,$company[$v['companytitle']]) === false)
  1611. {
  1612. $companytitle .= '<p>'.$company[$v['companytitle']].'</p>';
  1613. }
  1614. }
  1615. foreach ($od as $k=>$vv)
  1616. {
  1617. $odid .= $k.'数量'.$vv;
  1618. }
  1619. $info_list[$key]['cpbz'] = '<p>'.$value['cpbz'].'</p><p>'.$value['sm'].'</p>';
  1620. $number = $value['number'];$ftime = time()-15*24*3600;
  1621. $z = $z.'('.$odid.')';//查看订单号
  1622. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:'无';
  1623. $info_list[$key]['features'] = $c;
  1624. $info_list[$key]['number'] = $ztdata;
  1625. $info_list[$key]['sm'] = $g;
  1626. $info_list[$key]['x'] = $x;
  1627. $info_list[$key]['t'] = $t;
  1628. $info_list[$key]['z'] = $z;
  1629. /**
  1630. foreach ($cdata as $k=>$v)
  1631. {
  1632. $details[$v['details']] = $v['details'];
  1633. if($v['cpid'] != 0)
  1634. {
  1635. $cpid[$v['cpid']] = $v['cpid'];
  1636. }
  1637. }
  1638. **/
  1639. $info_list[$key]['shop'] = '';
  1640. $info_list[$key]['details'] = ($cpid)?implode(" ",$details).'<p>'.implode(" ",$cpid).'</p>':implode(" ",$details);
  1641. if($value['shop'] != '')
  1642. {
  1643. $shop = explode(',',trim($value['shop'],','));
  1644. $info_list[$key]['shop'] = '<p>'.$sp[$shop[0]].'</p>';
  1645. }
  1646. $info_list[$key]['shop'] .= $companytitle;
  1647. /**
  1648. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1649. if(isset($companytitle[0]))
  1650. {
  1651. foreach ($companytitle as $k=>$v)
  1652. {
  1653. if($v['companytitle'] != '')
  1654. {
  1655. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1656. }
  1657. }
  1658. }
  1659. **/
  1660. }
  1661. $final_all_list = [];
  1662. foreach($info_list as $k=>$v){
  1663. $final_all_list[] = [
  1664. 'id'=>$v['id'],
  1665. "warehouse"=>$v["warehouse"],
  1666. "purchase"=>$v["purchase"],
  1667. "sku"=>$v["sku"],
  1668. "title"=>$v["title"]."<br/>".$v["pm"],
  1669. "details"=>$v["details"],
  1670. "shop"=>$v["shop"],
  1671. "cpbz"=>$v["cpbz"],
  1672. "type"=>$v["type"],
  1673. "features"=>$v["features"],
  1674. "number"=>$v["number"],
  1675. "sm"=>$v["sm"],
  1676. "x"=>$v["x"],
  1677. "t"=>$v["t"],
  1678. "z"=>$v["z"]
  1679. ];
  1680. }
  1681. $total = count($this->whlabel->find_pc($where.$fjnr,'sku,purchase,features,warehouse','id,warehouse,sku,title,features,number'));
  1682. $pagenum = ceil($total/$perpage);
  1683. $over = $total-($start+$perpage);
  1684. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($final_all_list));
  1685. echo json_encode($rows);exit;
  1686. }
  1687. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1688. $this->data['shop'] = $wlshop;
  1689. $this->data['vip'] = $vip;
  1690. $this->_Template('whlabel_type',$this->data);
  1691. }
  1692. //美仓进销存浏览
  1693. public function _usatype()
  1694. {
  1695. if(isset($_SESSION['api']))
  1696. {
  1697. $user = $this->user->get_api($_SESSION['api']);
  1698. $usp = $user;
  1699. $fgshop = "";$sid = "";$wid="";$wtype="";
  1700. $userwh = explode('|',trim($user['warehouse'],'|'));
  1701. foreach ($userwh as $value)
  1702. {
  1703. $wid .= " id = ".$value." or";
  1704. $wtype .= " type = ".$value." or";
  1705. }
  1706. }
  1707. $prc = array();
  1708. $purchase = $this->purchase->find_all();
  1709. foreach($purchase as $k=>$v)
  1710. {
  1711. $prc[$v['id']] = $v['title'];
  1712. }
  1713. $post = $this->input->post(NULL, TRUE);
  1714. if(isset($post['page']))
  1715. {
  1716. $page = $this->input->post('page',true);
  1717. $perpage = $this->input->post('perpage',true);
  1718. $category = $this->input->post('category',true);
  1719. $size = $this->input->post('size',true);
  1720. $grade = $this->input->post('grade',true);
  1721. $color = $this->input->post('color',true);
  1722. $lowe = $this->input->post('lowe',true);
  1723. $sku = $this->input->post('sku');
  1724. $title = $this->input->post('title');
  1725. $warehouse = $this->input->post('warehouse',true);
  1726. $usa = $this->input->post('usa',true);
  1727. $purchase = $this->input->post('purchase',true);
  1728. $lacetype = $this->input->post('lacetype',true);
  1729. $haircap = $this->input->post('haircap',true);
  1730. $density = $this->input->post('density',true);
  1731. $details = $this->input->post('details',true);
  1732. $state = $this->input->post('state',true);
  1733. $lacecolor = $this->input->post('lacecolor',true);
  1734. $cklx = $this->input->post('cklx',true);
  1735. $ktime = $this->input->post('ktime',true);
  1736. $jtime = $this->input->post('jtime',true);
  1737. $ktime = strtotime($ktime);
  1738. $jtime = strtotime($jtime);
  1739. $where = "1=1";$gj = "";$ck = "";
  1740. if($lacetype)
  1741. {
  1742. $where .= " and features like '%-$lacetype-%'";
  1743. }
  1744. if($category)
  1745. {
  1746. $where .= " and features like '%-$category-%'";
  1747. }
  1748. if($size)
  1749. {
  1750. $where .= " and features like '%-$size-%'";
  1751. }
  1752. if($grade)
  1753. {
  1754. $where .= " and features like '%-$grade-%'";
  1755. }
  1756. if($color)
  1757. {
  1758. $where .= " and features like '%-$color-%'";
  1759. }
  1760. if($lowe)
  1761. {
  1762. $where .= " and features like '%-$lowe-%'";
  1763. }
  1764. if($haircap)
  1765. {
  1766. $where .= " and features like '%-$haircap-%'";
  1767. }
  1768. if($density)
  1769. {
  1770. $where .= " and features like '%-$density-%'";
  1771. }
  1772. if($lacecolor)
  1773. {
  1774. $where .= " and features like '%-$lacecolor-%'";
  1775. }
  1776. if($usa)
  1777. {
  1778. if(!$warehouse)
  1779. {
  1780. $where .= " and (warehouse = '5' or warehouse = '8')";
  1781. }
  1782. }
  1783. if($warehouse)
  1784. {
  1785. $where .= " and warehouse = '$warehouse'";
  1786. }
  1787. if($details)
  1788. {
  1789. $where .= " and details = '$details'";
  1790. }
  1791. if($purchase)
  1792. {
  1793. $where .= " and purchase = '$purchase'";
  1794. }
  1795. if($state)
  1796. {
  1797. $where .= " and state = '$state'";
  1798. }
  1799. $where_add = '';
  1800. if($cklx)
  1801. {
  1802. $shop = $this->shop->read($cklx);
  1803. $where_add .= " and zd like '".$shop['shortname']."%' and state = 0";
  1804. }
  1805. if($ktime && $jtime)
  1806. {
  1807. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1808. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1809. }
  1810. //数据排序
  1811. $order_str = "id desc";
  1812. if(empty($page))
  1813. {
  1814. $start = 0;
  1815. $perpage = 1;
  1816. }
  1817. else
  1818. {
  1819. $start = ($page - 1)*$perpage;
  1820. }
  1821. if($sku)
  1822. {
  1823. $sku = trim($sku,' ');
  1824. $sku = trim($sku,' ');
  1825. $where .= " and sku like '%$sku%'";
  1826. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1827. }
  1828. else if($title)
  1829. {
  1830. $title = trim($title,' ');
  1831. $title = trim($title,' ');
  1832. $where .= " and title like '%$title%'";
  1833. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1834. }
  1835. else
  1836. {
  1837. //$where .= " and time > '$ktime' and time < '$jtime'";
  1838. $info_list = $this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,sku,title,features,warehouse',$order_str,$start,$perpage);
  1839. }
  1840. //取得信息列表
  1841. $rows = array();$list = array();
  1842. foreach ($info_list as $key=>$value)
  1843. {
  1844. $warehouse = $this->warehouse->read($value['warehouse']);
  1845. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1846. $g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1847. $x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1848. $t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1849. $z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1850. $od = array();$odid = '';
  1851. foreach ($z as $v)
  1852. {
  1853. if(!isset($od[$v['zd']]))
  1854. {
  1855. $od[$v['zd']] = 1;//所有数据sku
  1856. }
  1857. else
  1858. {
  1859. $od[$v['zd']] = $od[$v['zd']]+1;
  1860. }
  1861. }
  1862. foreach ($od as $k=>$vv)
  1863. {
  1864. $odid .= $k.'数量'.$vv.' ';
  1865. }
  1866. $z = count($z).'('.$odid.')';//查看订单号
  1867. $info_list[$key]['features'] = $c;
  1868. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'" and cz = "0"');
  1869. $ztdata = '';
  1870. if(count($zt) > 0)
  1871. {
  1872. foreach ($zt as $vv)
  1873. {
  1874. $ztdata .= '<p>'.$vv['num'].' - '.date('Y-m-d',$vv['stime']).'</p>';
  1875. }
  1876. }
  1877. $info_list[$key]['warehouse'] = $ztdata;
  1878. $info_list[$key]['g'] = $g;
  1879. $info_list[$key]['x'] = $x;
  1880. $info_list[$key]['t'] = $t;
  1881. $info_list[$key]['z'] = $z;
  1882. }
  1883. $total = count($this->whlabel->find_pc($where.$where_add,'sku,features,warehouse','id,warehouse,sku,title'));
  1884. $pagenum = ceil($total/$perpage);
  1885. $over = $total-($start+$perpage);
  1886. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'CS'=>$warehouse);
  1887. echo json_encode($rows);exit;
  1888. }
  1889. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1890. $this->data['warehouse'] = $warehouse;
  1891. $this->_Template('whlabel_typeusa',$this->data);
  1892. }
  1893. //美仓进销存浏览
  1894. public function _usatypeapp()
  1895. {
  1896. $post = $this->input->post(NULL, TRUE);
  1897. if(isset($post['page']))
  1898. {
  1899. $page = $this->input->post('page',true);
  1900. $perpage = $this->input->post('perpage',true);
  1901. $sku = $this->input->post('sku',true);
  1902. $warehouse = 5;
  1903. $title = $this->input->post('title',true);
  1904. $state = $this->input->post('state',true);
  1905. $ktime = $this->input->post('ktime',true);
  1906. $jtime = $this->input->post('jtime',true);
  1907. $ktime = strtotime($ktime);
  1908. $jtime = strtotime($jtime);
  1909. $where = "1=1";$gj = "";$ck = "";
  1910. if($title)
  1911. {
  1912. $st = explode(' ',trim($title,' '));
  1913. foreach ($st as $v)
  1914. {
  1915. $where .= " and title like '%$v%'";
  1916. }
  1917. }
  1918. if($warehouse)
  1919. {
  1920. $where .= " and warehouse = '$warehouse'";
  1921. }
  1922. if($state)
  1923. {
  1924. $where .= " and state = '$state'";
  1925. }
  1926. if($sku)
  1927. {
  1928. $where .= " and sku like '%$sku%'";
  1929. }
  1930. if($ktime && $jtime)
  1931. {
  1932. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1933. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1934. }
  1935. //数据排序
  1936. $order_str = "id desc";
  1937. if(empty($page))
  1938. {
  1939. $start = 0;
  1940. $perpage = 1;
  1941. }
  1942. else
  1943. {
  1944. $start = ($page - 1)*$perpage;
  1945. }
  1946. //取得信息列表
  1947. $info_list = $this->whlabel->find_all($where.' and '.rtrim($wid,'or'),'*');
  1948. $rows = array();$list = array();
  1949. foreach ($info_list as $key=>$value)
  1950. {
  1951. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1952. }
  1953. $rowsdq = array_slice($rows,$start,$perpage);
  1954. foreach ($rowsdq as $value)
  1955. {
  1956. $warehouse = $this->warehouse->read($value['warehouse']);
  1957. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'"');
  1958. $x = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and state = 1 and warehouse = "'.$value['warehouse'].'"');
  1959. $t = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and retreat > 0 and warehouse = "'.$value['warehouse'].'"');
  1960. $od = array();$odid = '';
  1961. $list[] = array('id'=>$value['id'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'x'=>$x,'t'=>$t);
  1962. }
  1963. $total = count($rows);
  1964. $pagenum = ceil($total/$perpage);
  1965. $over = $total-($start+$perpage);
  1966. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  1967. echo json_encode($rows);exit;
  1968. }
  1969. $this->_Template('phone/p_usatypeapp',$this->data);
  1970. }
  1971. //入库操作
  1972. public function _enteradd()
  1973. {
  1974. $dt = 0;
  1975. if(isset($_SESSION['api']))
  1976. {
  1977. $user = $this->user->get_api($_SESSION['api']);
  1978. $usp = $user;
  1979. $fgshop = "";$sid = "";
  1980. $user = explode('|',trim($user['shop'],'|'));
  1981. foreach ($user as $value)
  1982. {
  1983. $fgshop .= " shop = ".$value." or";
  1984. $sid .= " id = ".$value." or";
  1985. }
  1986. }
  1987. $tc = $this->typeclass->find_all();
  1988. $typeclass = array();
  1989. foreach ($tc as $v)
  1990. {
  1991. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1992. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'bqsku'=>$v['bqsku']);
  1993. }
  1994. $post = $this->input->post(NULL, TRUE);
  1995. if(isset($post['sku']))
  1996. {
  1997. $list = array();$num = "";$title = "";$features = "";
  1998. $order = $this->input->post('order',true);
  1999. $shop = $this->input->post('shop',true);
  2000. $post['shop'] = ($shop!="")?','.$shop:"";
  2001. $sku = $this->input->post('sku',true);
  2002. $post['sm'] = $this->input->post('sm',true);
  2003. $post['warehouse'] = $this->input->post('warehouse',true);
  2004. $post['purchase'] = $this->input->post('purchase',true);
  2005. $post['retreatwarehouse'] = $post['warehouse'];
  2006. $post['state'] = $this->input->post('state',true);
  2007. $post['rktype'] = $this->input->post('rktype',true);
  2008. $post['text'] = $this->input->post('text',true);
  2009. $category = $this->input->post('category',true);
  2010. $list['category'] = $category;
  2011. $list['hairtype'] = $this->input->post('hairtype',true);
  2012. $list['grade'] = $this->input->post('grade',true);
  2013. $size = $this->input->post('size',true);
  2014. $xzsku = $this->input->post('xzsku',true);
  2015. $list['size'] = rtrim($size,',');
  2016. $list['hairnumber'] = $this->input->post('hairnumber',true);
  2017. $list['extension'] = $this->input->post('extension',true);
  2018. if($category == 1297)
  2019. {
  2020. $list['sywignumber'] = $this->input->post('sywignumber',true);
  2021. }
  2022. if($category == 1702)
  2023. {
  2024. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  2025. $list['syother'] = $this->input->post('syother',true);
  2026. }
  2027. if($category == 133)
  2028. {
  2029. $list['fittype'] = $this->input->post('fittype',true);
  2030. $list['acother'] = $this->input->post('acother',true);
  2031. }
  2032. $list['color'] = $this->input->post('color',true);
  2033. $list['lowe'] = $this->input->post('lowe',true);
  2034. if(!$post['purchase'])
  2035. {
  2036. $post['purchase'] = 1;
  2037. }
  2038. if($category == 127)
  2039. {
  2040. $list['type'] = $this->input->post('type',true);
  2041. $list['headroad'] = $this->input->post('headroad',true);
  2042. $list['density'] = $this->input->post('density',true);
  2043. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  2044. {
  2045. $list['lacesize'] = $this->input->post('lacesize',true);
  2046. }
  2047. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2048. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2049. }
  2050. if($category == 128)
  2051. {
  2052. $list['lacetype'] = $this->input->post('lacetype',true);
  2053. $list['haircap'] = $this->input->post('haircap',true);
  2054. $list['density'] = $this->input->post('density',true);
  2055. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2056. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2057. $list['wigother'] = $this->input->post('wigother',true);
  2058. $list['wigother2'] = $this->input->post('wigother2',true);
  2059. }
  2060. if($category == 129)
  2061. {
  2062. $list['wide'] = $this->input->post('wide',true);
  2063. }
  2064. if($category == 131)
  2065. {
  2066. $list['gifttype'] = $this->input->post('gifttype',true);
  2067. $list['giftother'] = $this->input->post('giftother',true);
  2068. }
  2069. if($category == 134)
  2070. {
  2071. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2072. }
  2073. if($category == 1297)
  2074. {
  2075. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2076. $list['sywigother'] = $this->input->post('sywigother',true);
  2077. }
  2078. if($category == 130 || $category == 133 || $category == 1702)
  2079. {
  2080. $list['items'] = $this->input->post('items',true);
  2081. $list['weight'] = $this->input->post('weight',true);
  2082. }
  2083. if($category == 1702)
  2084. {
  2085. $list['syhairther'] = $this->input->post('syhairther',true);
  2086. }
  2087. $classid = $this->classid->sku();
  2088. $scsku = $classid;
  2089. $pm = $classid;
  2090. foreach($list as $k=>$v)
  2091. {
  2092. if($v != 0)
  2093. {
  2094. $num .=$v;
  2095. $features .=$v.'-';
  2096. $post[$k] = $v;
  2097. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2098. if($k != 'size')
  2099. {
  2100. $title .= $typeclass[$v]['title']." ";
  2101. }
  2102. if(isset($pm[$typeclass[$v]['classid']]))
  2103. {
  2104. if($typeclass[$v]['title'] == '9A')
  2105. {
  2106. $pm[$typeclass[$v]['classid']] = '9A';
  2107. }
  2108. else if($typeclass[$v]['title'] == '10A')
  2109. {
  2110. $pm[$typeclass[$v]['classid']] = '10A';
  2111. }
  2112. else
  2113. {
  2114. $clzh = $typeclass[$v]['zh'];
  2115. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2116. {
  2117. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2118. $clzh = $clzh[0];
  2119. }
  2120. $pm[$typeclass[$v]['classid']] = $clzh;
  2121. }
  2122. }
  2123. }
  2124. }
  2125. $zh = implode(" ",$pm);
  2126. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  2127. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2128. if($list['size'])
  2129. {
  2130. $typeclass = $this->typeclass->read($list['size']);
  2131. $title .= $typeclass['title'];
  2132. }
  2133. $time = time();
  2134. if($xzsku)
  2135. {
  2136. $scsku = implode("-",$scsku);
  2137. $scsku = str_replace('- ','-',trim($scsku,'-'));
  2138. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  2139. $post['sku'] = trim($scsku,' ');
  2140. }
  2141. else
  2142. {
  2143. $post['sku'] = $sku;
  2144. }
  2145. //$post['sku'] = trim($sku,' ');
  2146. $post['title'] = rtrim($title,' ');
  2147. $post['number'] = $num;
  2148. $post['features'] = '-'.$features;
  2149. $post['enter'] = $time;
  2150. $post['time'] = $time;//操作时间
  2151. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2152. if($yza)
  2153. {
  2154. if($post['features'] != $yza[0]['features'])
  2155. {
  2156. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'success'=>false));exit;
  2157. }
  2158. }
  2159. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  2160. if($yzb)
  2161. {
  2162. if($post['sku'] != $yzb[0]['sku'])
  2163. {
  2164. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','success'=>false));exit;
  2165. }
  2166. }
  2167. if(isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
  2168. {
  2169. echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
  2170. }
  2171. if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
  2172. {
  2173. echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
  2174. }
  2175. if($post['rktype'] == '' && $post['warehouse'] == 5)
  2176. {
  2177. echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
  2178. }
  2179. $yz = $this->whlabel->find_all("sku = '".$post['sku']."' and features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'",'type');
  2180. if(isset($yz[0]['type']))
  2181. {
  2182. $post['type'] = $yz[0]['type'];
  2183. }
  2184. if($post['state'] == 9)//如果选择预设库存
  2185. {
  2186. $this->whlabel->insert($post);
  2187. }
  2188. else
  2189. {
  2190. /**
  2191. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2192. if($ljg == 1)
  2193. {
  2194. for($i=0;$i<$order;$i++)
  2195. {
  2196. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2197. $this->whlabel->insert($post);
  2198. }
  2199. }
  2200. **/
  2201. //if($post['warehouse'] == '5')
  2202. //{
  2203. //}
  2204. $yydata = $post;
  2205. $yydata['zh'] = $zh;
  2206. /**
  2207. $wl = $this->apiyy->get_cjlp($yydata);
  2208. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2209. {
  2210. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2211. }
  2212. if($wl['Data'][0]['m_isSucess'] != 1)
  2213. {
  2214. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2215. }
  2216. **/
  2217. for($i=0;$i<$order;$i++)
  2218. {
  2219. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2220. $this->whlabel->insert($post);
  2221. }
  2222. }
  2223. echo json_encode(array('msg'=>'入库成功','success'=>true));exit;
  2224. }
  2225. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2226. $this->data['wlshop'] = $wlshop;
  2227. $this->_Template('whlabel_enteradd',$this->data);
  2228. }
  2229. //修改产品
  2230. public function _enteredit($arg_array)
  2231. {
  2232. $dt = 0;
  2233. if(isset($_SESSION['api']))
  2234. {
  2235. $user = $this->user->get_api($_SESSION['api']);
  2236. $usp = $user;
  2237. $fgshop = "";$sid = "";
  2238. $user = explode('|',trim($user['shop'],'|'));
  2239. foreach ($user as $value)
  2240. {
  2241. $fgshop .= " shop = ".$value." or";
  2242. $sid .= " id = ".$value." or";
  2243. }
  2244. }
  2245. $post = $this->input->post(NULL, TRUE);
  2246. if(isset($post['sku']))
  2247. {
  2248. $list = array();$num = "";$title = "";$features = "";
  2249. $id = $this->input->post('id',true);
  2250. $order = $this->input->post('order',true);
  2251. $shop = $this->input->post('shop',true);
  2252. $post['shop'] = ($shop!="")?','.$shop:"";
  2253. $post['sku'] = $this->input->post('sku',true);
  2254. $post['sm'] = $this->input->post('sm',true);
  2255. $post['warehouse'] = $this->input->post('warehouse',true);
  2256. $post['purchase'] = $this->input->post('purchase',true);
  2257. $post['retreatwarehouse'] = $post['warehouse'];
  2258. $category = $this->input->post('category',true);
  2259. $list['category'] = $category;
  2260. $list['hairtype'] = $this->input->post('hairtype',true);
  2261. $list['grade'] = $this->input->post('grade',true);
  2262. $size = $this->input->post('size',true);
  2263. $list['size'] = rtrim($size,',');
  2264. $post['rktype'] = $this->input->post('rktype',true);
  2265. $post['text'] = $this->input->post('text',true);
  2266. $list['hairnumber'] = $this->input->post('hairnumber',true);
  2267. $list['extension'] = $this->input->post('extension',true);
  2268. if($category == 1297)
  2269. {
  2270. $list['sywignumber'] = $this->input->post('sywignumber',true);
  2271. }
  2272. if($category == 1702)
  2273. {
  2274. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  2275. $list['syother'] = $this->input->post('syother',true);
  2276. }
  2277. if($category == 133)
  2278. {
  2279. $list['fittype'] = $this->input->post('fittype',true);
  2280. $list['acother'] = $this->input->post('acother',true);
  2281. }
  2282. $list['color'] = $this->input->post('color',true);
  2283. $list['lowe'] = $this->input->post('lowe',true);
  2284. if(!$post['purchase'])
  2285. {
  2286. $post['purchase'] = 1;
  2287. }
  2288. if($category == 127)
  2289. {
  2290. $list['type'] = $this->input->post('type',true);
  2291. $list['headroad'] = $this->input->post('headroad',true);
  2292. $list['density'] = $this->input->post('density',true);
  2293. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  2294. {
  2295. $list['lacesize'] = $this->input->post('lacesize',true);
  2296. }
  2297. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2298. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2299. }
  2300. if($category == 128)
  2301. {
  2302. $list['lacetype'] = $this->input->post('lacetype',true);
  2303. $list['haircap'] = $this->input->post('haircap',true);
  2304. $list['density'] = $this->input->post('density',true);
  2305. $list['lacecolor'] = $this->input->post('lacecolor',true);
  2306. $list['lacetypes'] = $this->input->post('lacetypes',true);
  2307. $list['wigother'] = $this->input->post('wigother',true);
  2308. $list['wigother2'] = $this->input->post('wigother2',true);
  2309. }
  2310. if($category == 129)
  2311. {
  2312. $list['wide'] = $this->input->post('wide',true);
  2313. }
  2314. if($category == 131)
  2315. {
  2316. $list['gifttype'] = $this->input->post('gifttype',true);
  2317. $list['giftother'] = $this->input->post('giftother',true);
  2318. }
  2319. if($category == 134)
  2320. {
  2321. $list['pieceweight'] = $this->input->post('pieceweight',true);
  2322. }
  2323. if($category == 1297)
  2324. {
  2325. $list['synthetictype'] = $this->input->post('synthetictype',true);
  2326. $list['sywigother'] = $this->input->post('sywigother',true);
  2327. }
  2328. if($category == 130 || $category == 133 || $category == 1702)
  2329. {
  2330. $list['items'] = $this->input->post('items',true);
  2331. $list['weight'] = $this->input->post('weight',true);
  2332. }
  2333. if($category == 1702)
  2334. {
  2335. $list['syhairther'] = $this->input->post('syhairther',true);
  2336. }
  2337. foreach($list as $k=>$v)
  2338. {
  2339. if($v != 0)
  2340. {
  2341. $num .=$v;
  2342. $features .=$v.'-';
  2343. $typeclass = $this->typeclass->read($v);
  2344. if($k != 'size')
  2345. {
  2346. $title .= $typeclass['title']." ";
  2347. }
  2348. }
  2349. }
  2350. $typeclass = $this->typeclass->read($list['size']);
  2351. $title .= $typeclass['title'];
  2352. $time = time();
  2353. $post['title'] = rtrim($title,' ');
  2354. $post['number'] = $num;
  2355. $post['features'] = '-'.$features;
  2356. $post['time'] = $time;//操作时间
  2357. if($post['rktype'] == '' && $post['warehouse'] == 5)
  2358. {
  2359. echo json_encode(array('msg'=>'美仓必须填写入库分类!','success'=>false));exit;
  2360. }
  2361. if($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5)
  2362. {
  2363. echo json_encode(array('msg'=>'非采购入库必须填写入库分类备注!','success'=>false));exit;
  2364. }
  2365. $uid = $this->whlabel->read($id);
  2366. $datanum = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2367. if($datanum > 0)
  2368. {
  2369. echo json_encode(array('msg'=>'此SKU有占单,请解除占单后再修改!','success'=>false));exit;
  2370. }
  2371. if($post['warehouse'] != '99999')//现在所有仓都检测,之前只有美仓5检测
  2372. {
  2373. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."'");
  2374. if($yza)
  2375. {
  2376. if($post['features'] != $yza[0]['features'])
  2377. {
  2378. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','success'=>false));exit;
  2379. }
  2380. }
  2381. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."'");
  2382. if($yzb)
  2383. {
  2384. if($post['sku'] != $yzb[0]['sku'])
  2385. {
  2386. echo json_encode(array('msg'=>'此产品信息的SKU和现有不一致!','success'=>false));exit;
  2387. }
  2388. }
  2389. if($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop'])
  2390. {
  2391. echo json_encode(array('msg'=>'此产品店铺信息和现有不一致!','success'=>false));exit;
  2392. }
  2393. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2394. foreach ($data as $v)
  2395. {
  2396. $post['id'] = $v['id'];
  2397. $this->whlabel->save($post,$v['id']);
  2398. }
  2399. }
  2400. else
  2401. {
  2402. $data = $this->whlabel->find_count("state = 0 and sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."' and zd != ''");
  2403. if($data > 0)
  2404. {
  2405. echo json_encode(array('msg'=>'此产品有占单,无法修改!','success'=>false));exit;
  2406. }
  2407. else
  2408. {
  2409. $data = $this->whlabel->find_all("sku = '".$uid['sku']."' and warehouse = '".$uid['warehouse']."'");// and enter = '".$uid['enter']."'
  2410. foreach ($data as $v)
  2411. {
  2412. $post['id'] = $v['id'];
  2413. $this->whlabel->save($post,$v['id']);
  2414. }
  2415. }
  2416. }
  2417. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  2418. }
  2419. $uid = $this->whlabel->read($arg_array[0]);
  2420. $uid['order'] = $this->whlabel->find_count('enter = "'.$uid['enter'].'" and sku = "'.$uid['sku'].'" and state = "0"');
  2421. $this->data['enter'] = $uid ;
  2422. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2423. $this->data['wlshop'] = $wlshop;
  2424. $this->_Template('whlabel_enteredit',$this->data);
  2425. }
  2426. //入库浏览
  2427. public function _enter()
  2428. {
  2429. $post = $this->input->post(NULL, TRUE);
  2430. if(isset($post['s']))
  2431. {
  2432. $id_arr = $this->input->post('s');
  2433. $id_arr = explode(',',$id_arr);
  2434. if(!$id_arr)
  2435. {
  2436. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2437. }
  2438. //循环删除记录
  2439. foreach ($id_arr as $v)
  2440. {
  2441. $sid = $this->whlabel->read($v);
  2442. $count = $this->whlabel->find_count("state = 0 and sku = '".$sid['sku']."' and warehouse = '".$sid['warehouse']."' and zd != ''");
  2443. if($count > 0)
  2444. {
  2445. echo json_encode(array('msg'=>'有占单,需要先解除占单!','success'=>true));exit;
  2446. }
  2447. $info_list = $this->whlabel->find_all('enter ='.$sid['enter']);
  2448. foreach ($info_list as $va)
  2449. {
  2450. $this->whlabel->remove($va['id']);
  2451. }
  2452. }
  2453. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  2454. }
  2455. $sp = array();
  2456. $s = $this->shop->find_all('1=1','id,shopname');
  2457. foreach ($s as $v)
  2458. {
  2459. $sp[$v['id']] = $v['shopname'];
  2460. }
  2461. $wh = array();
  2462. $w = $this->warehouse->find_all('1=1','id,title');
  2463. foreach ($w as $v)
  2464. {
  2465. $wh[$v['id']] = $v['title'];
  2466. }
  2467. if(isset($post['page']))
  2468. {
  2469. $page = $this->input->post('page',true);
  2470. $perpage = $this->input->post('perpage',true);
  2471. $category = $this->input->post('category',true);
  2472. $size = $this->input->post('size',true);
  2473. $grade = $this->input->post('grade',true);
  2474. $color = $this->input->post('color',true);
  2475. $lowe = $this->input->post('lowe',true);
  2476. $sku = $this->input->post('sku',true);
  2477. $warehouse = $this->input->post('warehouse',true);
  2478. $purchase = $this->input->post('purchase',true);
  2479. $ktime = $this->input->post('ktime',true);
  2480. $jtime = $this->input->post('jtime',true);
  2481. $ktime = strtotime($ktime);
  2482. $jtime = strtotime($jtime);
  2483. $where = "1=1";$gj = "";$ck = "";
  2484. if($category)
  2485. {
  2486. $where .= " and features like '%-$category-%'";
  2487. }
  2488. if($size)
  2489. {
  2490. $where .= " and features like '%-$size-%'";
  2491. }
  2492. if($grade)
  2493. {
  2494. $where .= " and features like '%-$grade-%'";
  2495. }
  2496. if($color)
  2497. {
  2498. $where .= " and features like '%-$color-%'";
  2499. }
  2500. if($lowe)
  2501. {
  2502. $where .= " and features like '%-$lowe-%'";
  2503. }
  2504. if($warehouse)
  2505. {
  2506. $where .= " and warehouse = '$warehouse'";
  2507. }
  2508. if($purchase)
  2509. {
  2510. $where .= " and purchase = '$purchase'";
  2511. }
  2512. if($sku)
  2513. {
  2514. $where .= " and sku like '%$sku%'";
  2515. }
  2516. if($ktime && $jtime)
  2517. {
  2518. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2519. }
  2520. //数据排序
  2521. $order_str = "enter desc";
  2522. if(empty($page))
  2523. {
  2524. $start = 0;
  2525. $perpage = 1;
  2526. }
  2527. else
  2528. {
  2529. $start = ($page - 1)*$perpage;
  2530. }
  2531. //取得信息列表
  2532. $info_list = $this->whlabel->find_pc($where,'enter,warehouse,sku','id,warehouse,shop,sku,title,enter',$order_str,$start,$perpage);
  2533. foreach ($info_list as $k=>$v)
  2534. {
  2535. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2536. if($v['shop']=='')
  2537. {
  2538. $s = '通用';
  2539. }
  2540. else
  2541. {
  2542. $info_list[$k]['shop'] = '';
  2543. foreach (explode(',',trim($v['shop'],',')) as $val)
  2544. {
  2545. $info_list[$k]['shop'] .= $sp[$val].'</br>';
  2546. }
  2547. }
  2548. $info_list[$k]['enter'] = date('Y-m-d H:i:s',$v['enter']);
  2549. $g = $this->whlabel->find_count($where.' and enter = "'.$v['enter'].'" and sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'"');
  2550. $info_list[$k]['g'] = $g;
  2551. }
  2552. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  2553. $pagenum = ceil($total/$perpage);
  2554. $over = $total-($start+$perpage);
  2555. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2556. echo json_encode($rows);exit;
  2557. }
  2558. $this->_Template('whlabel_enter',$this->data);
  2559. }
  2560. //出库浏览
  2561. public function _out()
  2562. {
  2563. $post = $this->input->post(NULL, TRUE);
  2564. if(isset($post['page']))
  2565. {
  2566. $page = $this->input->post('page',true);
  2567. $perpage = $this->input->post('perpage',true);
  2568. $category = $this->input->post('category',true);
  2569. $size = $this->input->post('size',true);
  2570. $grade = $this->input->post('grade',true);
  2571. $color = $this->input->post('color',true);
  2572. $lowe = $this->input->post('lowe',true);
  2573. $sku = $this->input->post('sku',true);
  2574. $warehouse = $this->input->post('warehouse',true);
  2575. $purchase = $this->input->post('purchase',true);
  2576. $state = $this->input->post('state',true);
  2577. $ktime = $this->input->post('ktime',true);
  2578. $jtime = $this->input->post('jtime',true);
  2579. $ktime = strtotime($ktime);
  2580. $jtime = strtotime($jtime);
  2581. $where = "state=3";$gj = "";$ck = "";
  2582. if($category)
  2583. {
  2584. $where .= " and features like '%-$category-%'";
  2585. }
  2586. if($size)
  2587. {
  2588. $where .= " and features like '%-$size-%'";
  2589. }
  2590. if($grade)
  2591. {
  2592. $where .= " and features like '%-$grade-%'";
  2593. }
  2594. if($color)
  2595. {
  2596. $where .= " and features like '%-$color-%'";
  2597. }
  2598. if($lowe)
  2599. {
  2600. $where .= " and features like '%-$lowe-%'";
  2601. }
  2602. if($state)
  2603. {
  2604. $where .= " and state = '$state'";
  2605. }
  2606. if($warehouse)
  2607. {
  2608. $where .= " and warehouse = '$warehouse'";
  2609. }
  2610. if($purchase)
  2611. {
  2612. $where .= " and purchase = '$purchase'";
  2613. }
  2614. if($sku)
  2615. {
  2616. $where .= " and sku = '$sku'";
  2617. }
  2618. if($ktime && $jtime)
  2619. {
  2620. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2621. }
  2622. //数据排序
  2623. $order_str = "id desc";
  2624. if(empty($page))
  2625. {
  2626. $start = 0;
  2627. $perpage = 1;
  2628. }
  2629. else
  2630. {
  2631. $start = ($page - 1)*$perpage;
  2632. }
  2633. //取得信息列表
  2634. $info_list = $this->whlabel->find_all($where,'sku');
  2635. $rows = array();$list = array();
  2636. foreach ($info_list as $key=>$value)
  2637. {
  2638. $rows[] = $value['sku'].'warehouse'.$value['warehouse'];//所有数据sku
  2639. }
  2640. $rows = array_unique($rows);//删除重复记录
  2641. foreach ($rows as $key=>$value)
  2642. {
  2643. $data = $this->whlabel->get_sku($value);//获取目前sku的所有数据
  2644. $ck = $this->warehouse->read($data['warehouse']);
  2645. $warehouse = $ck['title'];
  2646. $gy = $this->purchase->read($data['purchase']);
  2647. $purchase = $gy['purchase'];
  2648. $g = $this->whlabel->find_count($where.' and sku = "'.$value.'" and state = 3');
  2649. $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);
  2650. }
  2651. $total = count($list);
  2652. $pagenum = ceil($total/$perpage);
  2653. $over = $total-($start+$perpage);
  2654. $list = array_slice($list,$start,$perpage);//数组中提取分页指定的内容 +true key排序不变
  2655. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
  2656. echo json_encode($rows);exit;
  2657. }
  2658. $this->_Template('whlabel_out',$this->data);
  2659. }
  2660. //出库标签浏览
  2661. public function _label()
  2662. {
  2663. $post = $this->input->post(NULL, TRUE);
  2664. if(isset($post['page']))
  2665. {
  2666. $page = $this->input->post('page',true);
  2667. $perpage = $this->input->post('perpage',true);
  2668. $sku = $this->input->post('sku',true);
  2669. $warehouse = $this->input->post('warehouse',true);
  2670. $purchase = $this->input->post('purchase',true);
  2671. $orderinfo = $this->input->post('orderinfo',true);
  2672. $waybill = $this->input->post('waybill',true);
  2673. $category = $this->input->post('category',true);
  2674. $size = $this->input->post('size',true);
  2675. $grade = $this->input->post('grade',true);
  2676. $color = $this->input->post('color',true);
  2677. $lowe = $this->input->post('lowe',true);
  2678. $where = "state=1";
  2679. if($sku)
  2680. {
  2681. $where .= " and sku = '$sku'";
  2682. }
  2683. if($warehouse)
  2684. {
  2685. $where .= " and warehouse = '$warehouse'";
  2686. }
  2687. if($purchase)
  2688. {
  2689. $where .= " and purchase = '$purchase'";
  2690. }
  2691. if($orderinfo)
  2692. {
  2693. $where .= " and orderinfo = '$orderinfo'";
  2694. }
  2695. if($waybill)
  2696. {
  2697. $where .= " and waybill = '$waybill'";
  2698. }
  2699. if($category)
  2700. {
  2701. $where .= " and features like '%-$category-%'";
  2702. }
  2703. if($size)
  2704. {
  2705. $where .= " and features like '%-$size-%'";
  2706. }
  2707. if($grade)
  2708. {
  2709. $where .= " and features like '%-$grade-%'";
  2710. }
  2711. if($color)
  2712. {
  2713. $where .= " and features like '%-$color-%'";
  2714. }
  2715. if($lowe)
  2716. {
  2717. $where .= " and features like '%-$lowe-%'";
  2718. }
  2719. //数据排序
  2720. $order_str = "outk desc";
  2721. if(empty($page))
  2722. {
  2723. $start = 0;
  2724. $perpage = 1;
  2725. }
  2726. else
  2727. {
  2728. $start = ($page - 1)*$perpage;
  2729. }
  2730. //取得信息列表
  2731. $info_list = $this->whlabel->find_all($where,'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk',$order_str,$start,$perpage);
  2732. foreach ($info_list as $key=>$value)
  2733. {
  2734. $warehouse = $this->warehouse->read($value['warehouse']);
  2735. $info_list[$key]['warehouse'] = $warehouse['title'];
  2736. $purchase = $this->purchase->read($value['purchase']);
  2737. $info_list[$key]['purchase'] = $purchase['title'];
  2738. if($value['outk'] != 0)
  2739. {
  2740. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  2741. }
  2742. else
  2743. {
  2744. $info_list[$key]['outk'] = "";
  2745. }
  2746. if($value['orderinfo'] == 0)
  2747. {
  2748. $info_list[$key]['orderinfo'] = "";
  2749. }
  2750. if($value['waybill'] == 0)
  2751. {
  2752. $info_list[$key]['waybill'] = "";
  2753. }
  2754. }
  2755. $total = $this->whlabel->find_count($where);
  2756. $pagenum = ceil($total/$perpage);
  2757. $over = $total-($start+$perpage);
  2758. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2759. echo json_encode($rows);exit;
  2760. }
  2761. $this->_Template('whlabel_label',$this->data);
  2762. }
  2763. //独立站出库订单
  2764. public function _outorder()
  2765. {
  2766. if(isset($_SESSION['api']))
  2767. {
  2768. $user = $this->user->get_api($_SESSION['api']);
  2769. $usp = $user;
  2770. $fgshop = "";$sid = "";
  2771. $user = explode('|',trim($user['shop'],'|'));
  2772. foreach ($user as $value)
  2773. {
  2774. $fgshop .= " shop = ".$value." or";
  2775. $sid .= " id = ".$value." or";
  2776. }
  2777. }
  2778. else
  2779. {
  2780. echo "请重新登录";
  2781. }
  2782. $post = $this->input->post(NULL, TRUE);
  2783. if(isset($post['page']))
  2784. {
  2785. $page = $this->input->post('page',true);
  2786. $perpage = $this->input->post('perpage',true);
  2787. $warehouse = $this->input->post('warehouse',true);
  2788. $xztime = $this->input->post('xztime',true);
  2789. $timetk = $this->input->post('timetkk',true);
  2790. $timetj = $this->input->post('timetjj',true);
  2791. $shop = $this->input->post('shop',true);
  2792. $source = $this->input->post('source',true);
  2793. $orderinfo = $this->input->post('orderinfo',true);
  2794. $number = $this->input->post('number',true);
  2795. $sfxh = $this->input->post('sfxh',true);
  2796. $express = $this->input->post('express',true);
  2797. $waybill = $this->input->post('waybill',true);
  2798. $library = $this->input->post('library',true);
  2799. $country = $this->input->post('country',true);
  2800. $so = $this->input->post('so',true);
  2801. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2802. $print = $this->input->post('print',true);
  2803. $state = $this->input->post('state',true);
  2804. $orderurl = $this->input->post('orderurl',true);
  2805. $timetk = strtotime($timetk);
  2806. $timetj = strtotime($timetj);
  2807. /**
  2808. $sj = $this->input->post('sj',true);
  2809. if($sj)
  2810. {
  2811. $sj = $this->input->post('sj',true);
  2812. }
  2813. else
  2814. {
  2815. $sj = "fullorder";
  2816. }
  2817. **/
  2818. $sj = "fullorder";
  2819. $where = "1=1";
  2820. if($warehouse)
  2821. {
  2822. $where .= " and type = '$warehouse'";
  2823. }
  2824. if($timetk && $timetj)
  2825. {
  2826. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  2827. }
  2828. if($orderinfo)
  2829. {
  2830. $where .= " and orderinfo = '$orderinfo'";
  2831. }
  2832. if($number)
  2833. {
  2834. $where .= " and number = '$number'";
  2835. }
  2836. if($express)
  2837. {
  2838. $where .= " and express = '$express'";
  2839. }
  2840. if($waybill)
  2841. {
  2842. $where .= " and waybill = '$waybill'";
  2843. }
  2844. if($library)
  2845. {
  2846. $where .= " and library = '$library'";
  2847. }
  2848. if($print)
  2849. {
  2850. $where .= " and print = '$print'";
  2851. }
  2852. if($libraryconfirm)
  2853. {
  2854. $where .= " and libraryconfirm = '$libraryconfirm'";
  2855. }
  2856. if($state)
  2857. {
  2858. $where .= " and state = '$state'";
  2859. }
  2860. if($shop)
  2861. {
  2862. $where .= " and shop = '$shop'";
  2863. }
  2864. if($country)
  2865. {
  2866. $where .= " and country = '$country'";
  2867. }
  2868. if($sfxh != '')
  2869. {
  2870. $where .= " and sfxh = '$sfxh'";
  2871. }
  2872. if($so)
  2873. {
  2874. $where .= " and shipremarks like '%$so%'";
  2875. }
  2876. if($source)
  2877. {
  2878. if($source == '2d')
  2879. {
  2880. $where .= " and source >= '2'";
  2881. }
  2882. else
  2883. {
  2884. $where .= " and source = '$source'";
  2885. }
  2886. }
  2887. if(isset($_SESSION['api']))
  2888. {
  2889. foreach ($user as $value)
  2890. {
  2891. $fgshop .= " shop = ".$value." or";
  2892. }
  2893. $where .= " and (".rtrim($fgshop,'or').")";
  2894. }
  2895. if($orderurl)
  2896. {
  2897. $url = $this->orderurl->read($orderurl);
  2898. $where .= " and link like '%".$url['url']."%'";
  2899. }
  2900. //数据排序
  2901. $order_str = "librarytime desc";
  2902. if(empty($page))
  2903. {
  2904. $start = 0;
  2905. $perpage = 1;
  2906. }
  2907. else
  2908. {
  2909. $start = ($page - 1)*$perpage;
  2910. }
  2911. //取得信息列表
  2912. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  2913. //格式化数据
  2914. foreach ($info_list as $key=>$value)
  2915. {
  2916. $shop = $this->shop->read($value['shop']);
  2917. $info_list[$key]['shop'] = $shop['shopname'];
  2918. $express = $this->express->read($value['express']);
  2919. $info_list[$key]['express'] = $express['servicename'];
  2920. $warehouse = $this->warehouse->read($value['type']);
  2921. $info_list[$key]['type'] = $warehouse['title'];
  2922. if($value['librarytime'] == '0')
  2923. {
  2924. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2925. }
  2926. else
  2927. {
  2928. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  2929. }
  2930. }
  2931. $total = $this->$sj->find_count($where);
  2932. $pagenum = ceil($total/$perpage);
  2933. $over = $total-($start+$perpage);
  2934. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2935. echo json_encode($rows);exit;
  2936. }
  2937. $this->data['express'] = $this->express->find_all();
  2938. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2939. $this->data['wlshop'] = $wlshop;
  2940. $user = $this->user->get_api($_SESSION['api']);
  2941. $powerid = $this->power->read($user['power']);
  2942. $powertext = explode('|',trim($powerid['excelid'],'|'));
  2943. $pid = '';
  2944. foreach ($powertext as $v)
  2945. {
  2946. $pid .= " id = ".$v." or";
  2947. }
  2948. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  2949. $this->data['fullorderexcel'] = $fullorderexcel;
  2950. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  2951. $this->data['orderurl'] = $orderurl;
  2952. $this->_Template('whlabel_outorder',$this->data);
  2953. }
  2954. //tt出库
  2955. public function _toutorder()
  2956. {
  2957. if(isset($_SESSION['api']))
  2958. {
  2959. $user = $this->user->get_api($_SESSION['api']);
  2960. $usp = $user;
  2961. $fgshop = "";$sid = "";
  2962. $user = explode('|',trim($user['shop'],'|'));
  2963. foreach ($user as $value)
  2964. {
  2965. $fgshop .= " shop = ".$value." or";
  2966. $sid .= " id = ".$value." or";
  2967. }
  2968. }
  2969. else
  2970. {
  2971. echo "请重新登录";
  2972. }
  2973. $post = $this->input->post(NULL, TRUE);
  2974. if(isset($post['page']))
  2975. {
  2976. $page = $this->input->post('page',true);
  2977. $perpage = $this->input->post('perpage',true);
  2978. $warehouse = $this->input->post('warehouse',true);
  2979. $xztime = $this->input->post('xztime',true);
  2980. $timetk = $this->input->post('timetkk',true);
  2981. $timetj = $this->input->post('timetjj',true);
  2982. $shop = $this->input->post('shop',true);
  2983. $source = $this->input->post('source',true);
  2984. $orderinfo = $this->input->post('orderinfo',true);
  2985. $number = $this->input->post('number',true);
  2986. $sfxh = $this->input->post('sfxh',true);
  2987. $express = $this->input->post('express',true);
  2988. $waybill = $this->input->post('waybill',true);
  2989. $library = $this->input->post('library',true);
  2990. $country = $this->input->post('country',true);
  2991. $so = $this->input->post('so',true);
  2992. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2993. $print = $this->input->post('print',true);
  2994. $state = $this->input->post('state',true);
  2995. $orderurl = $this->input->post('orderurl',true);
  2996. $timetk = strtotime($timetk);
  2997. $timetj = strtotime($timetj);
  2998. /**
  2999. $sj = $this->input->post('sj',true);
  3000. if($sj)
  3001. {
  3002. $sj = $this->input->post('sj',true);
  3003. }
  3004. else
  3005. {
  3006. $sj = "fullorder";
  3007. }
  3008. **/
  3009. $sj = "fullordertt";
  3010. $where = "1=1";
  3011. if($warehouse)
  3012. {
  3013. $where .= " and type = '$warehouse'";
  3014. }
  3015. if($timetk && $timetj)
  3016. {
  3017. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3018. }
  3019. if($orderinfo)
  3020. {
  3021. $where .= " and orderinfo = '$orderinfo'";
  3022. }
  3023. if($number)
  3024. {
  3025. $where .= " and number = '$number'";
  3026. }
  3027. if($express)
  3028. {
  3029. $where .= " and express = '$express'";
  3030. }
  3031. if($waybill)
  3032. {
  3033. $where .= " and waybill = '$waybill'";
  3034. }
  3035. if($library)
  3036. {
  3037. $where .= " and library = '$library'";
  3038. }
  3039. if($print)
  3040. {
  3041. $where .= " and print = '$print'";
  3042. }
  3043. if($libraryconfirm)
  3044. {
  3045. $where .= " and libraryconfirm = '$libraryconfirm'";
  3046. }
  3047. if($state)
  3048. {
  3049. $where .= " and state = '$state'";
  3050. }
  3051. if($shop)
  3052. {
  3053. $where .= " and shop = '$shop'";
  3054. }
  3055. if($country)
  3056. {
  3057. $where .= " and country = '$country'";
  3058. }
  3059. if($sfxh != '')
  3060. {
  3061. $where .= " and sfxh = '$sfxh'";
  3062. }
  3063. if($so)
  3064. {
  3065. $where .= " and shipremarks like '%$so%'";
  3066. }
  3067. if($source)
  3068. {
  3069. if($source == '2d')
  3070. {
  3071. $where .= " and source >= '2'";
  3072. }
  3073. else
  3074. {
  3075. $where .= " and source = '$source'";
  3076. }
  3077. }
  3078. if(isset($_SESSION['api']))
  3079. {
  3080. foreach ($user as $value)
  3081. {
  3082. $fgshop .= " shop = ".$value." or";
  3083. }
  3084. $where .= " and (".rtrim($fgshop,'or').")";
  3085. }
  3086. if($orderurl)
  3087. {
  3088. $url = $this->orderurl->read($orderurl);
  3089. $where .= " and link like '%".$url['url']."%'";
  3090. }
  3091. //数据排序
  3092. $order_str = "librarytime desc";
  3093. if(empty($page))
  3094. {
  3095. $start = 0;
  3096. $perpage = 1;
  3097. }
  3098. else
  3099. {
  3100. $start = ($page - 1)*$perpage;
  3101. }
  3102. //取得信息列表
  3103. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3104. //格式化数据
  3105. foreach ($info_list as $key=>$value)
  3106. {
  3107. $shop = $this->shop->read($value['shop']);
  3108. $info_list[$key]['shop'] = $shop['shopname'];
  3109. $express = $this->express->read($value['express']);
  3110. $info_list[$key]['express'] = $express['servicename'];
  3111. $warehouse = $this->warehouse->read($value['type']);
  3112. $info_list[$key]['type'] = $warehouse['title'];
  3113. if($value['librarytime'] == '0')
  3114. {
  3115. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3116. }
  3117. else
  3118. {
  3119. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3120. }
  3121. }
  3122. $total = $this->$sj->find_count($where);
  3123. $pagenum = ceil($total/$perpage);
  3124. $over = $total-($start+$perpage);
  3125. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3126. echo json_encode($rows);exit;
  3127. }
  3128. $this->data['express'] = $this->express->find_all();
  3129. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3130. $this->data['wlshop'] = $wlshop;
  3131. $user = $this->user->get_api($_SESSION['api']);
  3132. $powerid = $this->power->read($user['power']);
  3133. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3134. $pid = '';
  3135. foreach ($powertext as $v)
  3136. {
  3137. $pid .= " id = ".$v." or";
  3138. }
  3139. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3140. $this->data['fullorderexcel'] = $fullorderexcel;
  3141. $orderurl = $this->orderurl->find_all(rtrim($fgshop,'or'));
  3142. $this->data['orderurl'] = $orderurl;
  3143. $this->_Template('whlabel_toutorder',$this->data);
  3144. }
  3145. //速卖通出库订单
  3146. public function _soutorder()
  3147. {
  3148. if(isset($_SESSION['api']))
  3149. {
  3150. $user = $this->user->get_api($_SESSION['api']);
  3151. $usp = $user;
  3152. $fgshop = "";$sid = "";
  3153. $user = explode('|',trim($user['shop'],'|'));
  3154. foreach ($user as $value)
  3155. {
  3156. $sid .= " id = ".$value." or";
  3157. }
  3158. }
  3159. $post = $this->input->post(NULL, TRUE);
  3160. if(isset($post['page']))
  3161. {
  3162. $page = $this->input->post('page',true);
  3163. $perpage = $this->input->post('perpage',true);
  3164. $warehouse = $this->input->post('warehouse',true);
  3165. $xztime = $this->input->post('xztime',true);
  3166. $timetk = $this->input->post('timetkk',true);
  3167. $timetj = $this->input->post('timetjj',true);
  3168. $shop = $this->input->post('shop',true);
  3169. $source = $this->input->post('source',true);
  3170. $orderinfo = $this->input->post('orderinfo',true);
  3171. $number = $this->input->post('number',true);
  3172. $express = $this->input->post('express',true);
  3173. $waybill = $this->input->post('waybill',true);
  3174. $library = $this->input->post('library',true);
  3175. $country = $this->input->post('country',true);
  3176. $sfxh = $this->input->post('sfxh',true);
  3177. $libraryconfirm = $this->input->post('libraryconfirm',true);
  3178. $print = $this->input->post('print',true);
  3179. $state = $this->input->post('state',true);
  3180. $so = $this->input->post('so',true);
  3181. $timetk = strtotime($timetk);
  3182. $timetj = strtotime($timetj);
  3183. /**
  3184. $sj = $this->input->post('sj',true);
  3185. if($sj)
  3186. {
  3187. $sj = $this->input->post('sj',true);
  3188. }
  3189. else
  3190. {
  3191. $sj = "fullorder";
  3192. }
  3193. **/
  3194. $sj = "fullordersmt";
  3195. $where = "1=1";
  3196. if($warehouse)
  3197. {
  3198. $where .= " and type = '$warehouse'";
  3199. }
  3200. if($timetk && $timetj)
  3201. {
  3202. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3203. }
  3204. if($orderinfo)
  3205. {
  3206. $where .= " and orderinfo = '$orderinfo'";
  3207. }
  3208. if($number)
  3209. {
  3210. $where .= " and number = '$number'";
  3211. }
  3212. if($express)
  3213. {
  3214. $where .= " and express = '$express'";
  3215. }
  3216. if($waybill)
  3217. {
  3218. $where .= " and waybill = '$waybill'";
  3219. }
  3220. if($library)
  3221. {
  3222. $where .= " and library = '$library'";
  3223. }
  3224. if($print)
  3225. {
  3226. $where .= " and print = '$print'";
  3227. }
  3228. if($libraryconfirm)
  3229. {
  3230. $where .= " and libraryconfirm = '$libraryconfirm'";
  3231. }
  3232. if($state)
  3233. {
  3234. $where .= " and state = '$state'";
  3235. }
  3236. if($shop)
  3237. {
  3238. $where .= " and shop = '$shop'";
  3239. }
  3240. if($sfxh != '')
  3241. {
  3242. $where .= " and sfxh = '$sfxh'";
  3243. }
  3244. if($so)
  3245. {
  3246. $where .= " and shipremarks like '%$so%'";
  3247. }
  3248. if($source)
  3249. {
  3250. $where .= " and source = '$source'";
  3251. }
  3252. if($country)
  3253. {
  3254. $where .= " and country = '$country'";
  3255. }
  3256. else
  3257. {
  3258. if(isset($_SESSION['api']))
  3259. {
  3260. foreach ($user as $value)
  3261. {
  3262. $fgshop .= " shop = ".$value." or";
  3263. }
  3264. $where .= " and (".rtrim($fgshop,'or').")";
  3265. }
  3266. }
  3267. //数据排序
  3268. $order_str = "librarytime desc";
  3269. if(empty($page))
  3270. {
  3271. $start = 0;
  3272. $perpage = 1;
  3273. }
  3274. else
  3275. {
  3276. $start = ($page - 1)*$perpage;
  3277. }
  3278. //取得信息列表
  3279. $info_list = $this->$sj->find_all($where,'id,shop,type,orderinfo,number,waybill,express,librarytime',$order_str,$start,$perpage);
  3280. //格式化数据
  3281. foreach ($info_list as $key=>$value)
  3282. {
  3283. $shop = $this->shop->read($value['shop']);
  3284. $info_list[$key]['shop'] = $shop['shopname'];
  3285. $express = $this->express->read($value['express']);
  3286. $info_list[$key]['express'] = $express['servicename'];
  3287. $warehouse = $this->warehouse->read($value['type']);
  3288. $info_list[$key]['type'] = $warehouse['title'];
  3289. if($value['librarytime'] == '0')
  3290. {
  3291. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3292. }
  3293. else
  3294. {
  3295. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  3296. }
  3297. }
  3298. $total = $this->$sj->find_count($where);
  3299. $pagenum = ceil($total/$perpage);
  3300. $over = $total-($start+$perpage);
  3301. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3302. echo json_encode($rows);exit;
  3303. }
  3304. $this->data['express'] = $this->express->find_all();
  3305. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3306. $this->data['wlshop'] = $wlshop;
  3307. $user = $this->user->get_api($_SESSION['api']);
  3308. $powerid = $this->power->read($user['power']);
  3309. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3310. $pid = '';
  3311. foreach ($powertext as $v)
  3312. {
  3313. $pid .= " id = ".$v." or";
  3314. }
  3315. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3316. $this->data['fullorderexcel'] = $fullorderexcel;
  3317. $this->_Template('whlabel_soutorder',$this->data);
  3318. }
  3319. //订单退库
  3320. public function _retreat()
  3321. {
  3322. $post = $this->input->post(NULL, TRUE);
  3323. if(isset($post['page']))
  3324. {
  3325. $page = $this->input->post('page',true);
  3326. $perpage = $this->input->post('perpage',true);
  3327. $warehouse = $this->input->post('warehouse',true);
  3328. $timetk = $this->input->post('timetk',true);
  3329. $timetj = $this->input->post('timetj',true);
  3330. $shop = $this->input->post('shop',true);
  3331. $source = $this->input->post('source',true);
  3332. $state = $this->input->post('state',true);
  3333. $review = $this->input->post('review',true);
  3334. $state = $this->input->post('state',true);
  3335. $express = $this->input->post('express',true);
  3336. $orderinfo = $this->input->post('orderinfo',true);
  3337. $user = $this->input->post('user',true);
  3338. $name = $this->input->post('name',true);
  3339. $waybill = $this->input->post('waybill',true);
  3340. $timetk = strtotime($timetk);
  3341. $timetj = strtotime($timetj);
  3342. $where = "(state=206 or state=210) and mergeid = 0";
  3343. if($warehouse)
  3344. {
  3345. $where .= " and state = '$warehouse'";
  3346. }
  3347. if($timetk && $timetj)
  3348. {
  3349. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3350. }
  3351. if($shop)
  3352. {
  3353. $where .= " and shop = '$shop'";
  3354. }
  3355. if($source)
  3356. {
  3357. $where .= " and source = '$source'";
  3358. }
  3359. if($state)
  3360. {
  3361. $where .= " and state = '$state'";
  3362. }
  3363. if($review)
  3364. {
  3365. $where .= " and review = '$review'";
  3366. }
  3367. if($state)
  3368. {
  3369. $where .= " and state = '$state'";
  3370. }
  3371. if($express)
  3372. {
  3373. $where .= " and express = '$express'";
  3374. }
  3375. if($orderinfo)
  3376. {
  3377. $where .= " and orderinfo = '$orderinfo'";
  3378. }
  3379. if($user)
  3380. {
  3381. $where .= " and user = '$user'";
  3382. }
  3383. if($name)
  3384. {
  3385. $where .= " and name = '$name'";
  3386. }
  3387. if($waybill)
  3388. {
  3389. $where .= " and waybill = '$waybill'";
  3390. }
  3391. //数据排序
  3392. $order_str = "id desc";
  3393. if(empty($page))
  3394. {
  3395. $start = 0;
  3396. $perpage = 1;
  3397. }
  3398. else
  3399. {
  3400. $start = ($page - 1)*$perpage;
  3401. }
  3402. //取得信息列表
  3403. $info_list = $this->fullorder->find_all($where,'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime',$order_str,$start,$perpage);
  3404. //格式化数据
  3405. foreach ($info_list as $key=>$value)
  3406. {
  3407. $shop = $this->shop->read($value['shop']);
  3408. $info_list[$key]['shop'] = $shop['shopname'];
  3409. $warehouse = $this->warehouse->read($value['warehouse']);
  3410. $info_list[$key]['warehouse'] = $warehouse['title'];
  3411. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/".$value['id']."'>".$value['orderinfo']."</a>";
  3412. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  3413. if($value['waybill'] == 0)
  3414. {
  3415. $info_list[$key]['waybill'] = "";
  3416. }
  3417. $express = $this->express->read($value['express']);
  3418. $info_list[$key]['express'] = $express['title'];
  3419. $typeclass = $this->typeclass->read($value['state']);
  3420. $info_list[$key]['state'] = $typeclass['title'];
  3421. }
  3422. $total = $this->fullorder->find_count($where);
  3423. $pagenum = ceil($total/$perpage);
  3424. $over = $total-($start+$perpage);
  3425. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3426. echo json_encode($rows);exit;
  3427. }
  3428. $this->data['express'] = $this->express->find_all();
  3429. $this->_Template('whlabel_retreat',$this->data);
  3430. }
  3431. //退库标签浏览
  3432. public function _retreatlk()
  3433. {
  3434. $post = $this->input->post(NULL, TRUE);
  3435. if(isset($post['page']))
  3436. {
  3437. $page = $this->input->post('page',true);
  3438. $perpage = $this->input->post('perpage',true);
  3439. $timetk = $this->input->post('timetk',true);
  3440. $timetj = $this->input->post('timetj',true);
  3441. $sku = $this->input->post('sku',true);
  3442. $warehouse = $this->input->post('warehouse',true);
  3443. $purchase = $this->input->post('purchase',true);
  3444. $orderinfo = $this->input->post('orderinfo',true);
  3445. $waybill = $this->input->post('waybill',true);
  3446. $category = $this->input->post('category',true);
  3447. $size = $this->input->post('size',true);
  3448. $grade = $this->input->post('grade',true);
  3449. $color = $this->input->post('color',true);
  3450. $lowe = $this->input->post('lowe',true);
  3451. $state = $this->input->post('state',true);
  3452. $timetk = strtotime($timetk);
  3453. $timetj = strtotime($timetj);
  3454. $where = "state=2";
  3455. if($timetk && $timetj)
  3456. {
  3457. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3458. }
  3459. if($sku)
  3460. {
  3461. $where .= " and sku = '$sku'";
  3462. }
  3463. if($warehouse)
  3464. {
  3465. $where .= " and warehouse = '$warehouse'";
  3466. }
  3467. if($purchase)
  3468. {
  3469. $where .= " and purchase = '$purchase'";
  3470. }
  3471. if($orderinfo)
  3472. {
  3473. $where .= " and orderinfo = '$orderinfo'";
  3474. }
  3475. if($waybill)
  3476. {
  3477. $where .= " and waybill = '$waybill'";
  3478. }
  3479. if($category)
  3480. {
  3481. $where .= " and features like '%-$category-%'";
  3482. }
  3483. if($size)
  3484. {
  3485. $where .= " and features like '%-$size-%'";
  3486. }
  3487. if($grade)
  3488. {
  3489. $where .= " and features like '%-$grade-%'";
  3490. }
  3491. if($color)
  3492. {
  3493. $where .= " and features like '%-$color-%'";
  3494. }
  3495. if($lowe)
  3496. {
  3497. $where .= " and features like '%-$lowe-%'";
  3498. }
  3499. //数据排序
  3500. $order_str = "time desc";
  3501. if(empty($page))
  3502. {
  3503. $start = 0;
  3504. $perpage = 1;
  3505. }
  3506. else
  3507. {
  3508. $start = ($page - 1)*$perpage;
  3509. }
  3510. //取得信息列表
  3511. $info_list = $this->whlabel->find_all($where,'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk',$order_str,$start,$perpage);
  3512. foreach ($info_list as $key=>$value)
  3513. {
  3514. $warehouse = $this->warehouse->read($value['warehouse']);
  3515. $info_list[$key]['warehouse'] = $warehouse['title'];
  3516. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3517. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3518. $purchase = $this->purchase->read($value['purchase']);
  3519. $info_list[$key]['purchase'] = $purchase['title'];
  3520. if($value['outk'] != 0)
  3521. {
  3522. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  3523. }
  3524. else
  3525. {
  3526. $info_list[$key]['outk'] = "";
  3527. }
  3528. if($value['retreat'] != 0)
  3529. {
  3530. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);
  3531. }
  3532. else
  3533. {
  3534. $info_list[$key]['retreat'] = "";
  3535. }
  3536. if($value['orderinfo'] == 0)
  3537. {
  3538. $info_list[$key]['orderinfo'] = "";
  3539. }
  3540. if($value['waybill'] == 0)
  3541. {
  3542. $info_list[$key]['waybill'] = "";
  3543. }
  3544. }
  3545. $total = $this->whlabel->find_count($where);
  3546. $pagenum = ceil($total/$perpage);
  3547. $over = $total-($start+$perpage);
  3548. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3549. echo json_encode($rows);exit;
  3550. }
  3551. $this->_Template('whlabel_retreatlk',$this->data);
  3552. }
  3553. //更换标签及浏览
  3554. public function _change()
  3555. {
  3556. $post = $this->input->post(NULL, TRUE);
  3557. if(isset($post['page']))
  3558. {
  3559. $page = $this->input->post('page',true);
  3560. $perpage = $this->input->post('perpage',true);
  3561. $timetk = $this->input->post('timetk',true);
  3562. $timetj = $this->input->post('timetj',true);
  3563. $label = $this->input->post('label',true);
  3564. $oldlabel = $this->input->post('oldlabel',true);
  3565. $timetk = strtotime($timetk);
  3566. $timetj = strtotime($timetj);
  3567. $where = "state=10 ";
  3568. if($timetk && $timetj)
  3569. {
  3570. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3571. }
  3572. if($label)
  3573. {
  3574. $where .= " and label = '$label'";
  3575. }
  3576. if($oldlabel)
  3577. {
  3578. $where .= " and oldlabel = '$oldlabel'";
  3579. }
  3580. //数据排序
  3581. $order_str = "time asc";
  3582. if(empty($page))
  3583. {
  3584. $start = 0;
  3585. $perpage = 1;
  3586. }
  3587. else
  3588. {
  3589. $start = ($page - 1)*$perpage;
  3590. }
  3591. //取得信息列表
  3592. $info_list = $this->whlabel->find_all($where,'id,oldlabel,oldtitle,label,title, labeltime',$order_str,$start,$perpage);
  3593. foreach ($info_list as $key=>$value)
  3594. {
  3595. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s',$value['labeltime']);
  3596. }
  3597. $total = $this->whlabel->find_count($where);
  3598. $pagenum = ceil($total/$perpage);
  3599. $over = $total-($start+$perpage);
  3600. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3601. echo json_encode($rows);exit;
  3602. }
  3603. $this->_Template('whlabel_change',$this->data);
  3604. }
  3605. //产品标签
  3606. public function _cpbqdc()
  3607. {
  3608. if(isset($_GET['excel']))
  3609. {
  3610. $where = "1=1";
  3611. //数据排序
  3612. $order_str = "id desc";
  3613. if(empty($page))
  3614. {
  3615. $start = 0;
  3616. $perpage = 1;
  3617. }
  3618. else
  3619. {
  3620. $start = ($page - 1)*$perpage;
  3621. }
  3622. $warehouse = $this->input->get('warehouse',true);
  3623. $state = $this->input->get('state',true);
  3624. $timetk = $this->input->get('timetkk',true);
  3625. $timetj = $this->input->get('timetjj',true);
  3626. $timetk = strtotime($timetk);
  3627. $timetj = strtotime($timetj);
  3628. if($warehouse)
  3629. {
  3630. $where .= " and warehouse = '$warehouse'";
  3631. }
  3632. if($state || $state == 0)
  3633. {
  3634. $where .= " and state = '$state'";
  3635. }
  3636. if($timetk && $timetj)
  3637. {
  3638. $where .= " and time > '$timetk' and time < '$timetj'";
  3639. }
  3640. //取得信息列表
  3641. $info_list = $this->whlabel->find_all($where,'*');
  3642. $rows = array();$list = array();
  3643. foreach ($info_list as $key=>$value)
  3644. {
  3645. $rows[$value['time']] = $value;//所有数据sku
  3646. }
  3647. foreach ($rows as $value)
  3648. {
  3649. $warehouse = $this->warehouse->read($value['warehouse']);
  3650. $s = $this->whlabel->find_count($where.' and time = "'.$value['time'].'"');
  3651. $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);
  3652. }
  3653. $title = "产品标签统计表";
  3654. $titlename = "<table border=1>
  3655. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  3656. <tr align='center'>
  3657. <td>仓库</td>
  3658. <td>SKU</td>
  3659. <td>产品</td>
  3660. <td>入库时间</td>
  3661. <td>操作时间</td>
  3662. <td>备注</td>
  3663. <td>数量</td>
  3664. </tr>
  3665. </table>";
  3666. $filename = $title.".xls";
  3667. $tail = "";
  3668. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  3669. }
  3670. }
  3671. //进销存导出
  3672. public function _exceljxc()
  3673. {
  3674. $classid = $this->classid->sku();
  3675. $pm = $classid;
  3676. $typeclass = array();
  3677. $tc = $this->typeclass->find_all();
  3678. foreach ($tc as $v)
  3679. {
  3680. $typeclass[$v['id']] = $v;
  3681. }
  3682. $prc = array();
  3683. $purchase = $this->purchase->find_all();
  3684. foreach($purchase as $k=>$v)
  3685. {
  3686. $prc[$v['id']] = $v['title'];
  3687. }
  3688. if(isset($_GET['excel']))
  3689. {
  3690. $where = "sku != 'Preset'";
  3691. //数据排序
  3692. $order_str = "id desc";
  3693. if(empty($page))
  3694. {
  3695. $start = 0;
  3696. $perpage = 1;
  3697. }
  3698. else
  3699. {
  3700. $start = ($page - 1)*$perpage;
  3701. }
  3702. $category = $this->input->get('category',true);
  3703. $warehouse = $this->input->get('warehouse',true);
  3704. $excelid = $this->input->get('sid',true);
  3705. if($category)
  3706. {
  3707. $where .= " and features like '%-$category-%'";
  3708. }
  3709. if($warehouse)
  3710. {
  3711. $where .= " and warehouse = '$warehouse'";
  3712. }
  3713. $xzid = '';
  3714. if($excelid)
  3715. {
  3716. $excelid = explode(',',trim($excelid,','));
  3717. foreach ($excelid as $key=>$value)
  3718. {
  3719. $xzid .= " id = ".$value." or";
  3720. }
  3721. $xzid = " and (".rtrim($xzid,'or').")";;
  3722. }
  3723. //取得信息列表
  3724. /**
  3725. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3726. $rows = array();$list = array();
  3727. foreach ($info_list as $key=>$value)
  3728. {
  3729. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3730. }
  3731. **/
  3732. $wt = array();
  3733. $whlabel_type = $this->whlabel_type->find_all();
  3734. foreach ($whlabel_type as $v)
  3735. {
  3736. $wt[$v['id']] = $v['title'];
  3737. }
  3738. $wh = array();
  3739. $w = $this->warehouse->find_all('1=1','id,title');
  3740. foreach ($w as $v)
  3741. {
  3742. $wh[$v['id']] = $v['title'];
  3743. }
  3744. $list = array();
  3745. $rows = $this->whlabel->find_pc($where,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3746. foreach ($rows as $key=>$value)
  3747. {
  3748. if(isset($wt[$value['type']]))
  3749. {
  3750. $rows[$key]['type'] = $wt[$value['type']];
  3751. }
  3752. else
  3753. {
  3754. $rows[$key]['type'] = '未设置';
  3755. }
  3756. $bm = '03';
  3757. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  3758. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  3759. $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');
  3760. $details = array();
  3761. $cpid = array();
  3762. $cpbz = array();
  3763. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  3764. foreach ($sd as $k=>$v)
  3765. {
  3766. if($v['state'] == 0)
  3767. {
  3768. $c++;
  3769. if($v['cpid'] != 0)
  3770. {
  3771. $cpid[$v['cpid']] = $v['cpid'];
  3772. }
  3773. if($v['cpbz'] != '')
  3774. {
  3775. $cpbz[$v['cpbz']] = $v['cpbz'];
  3776. }
  3777. }
  3778. if($v['state'] != 9)
  3779. {
  3780. $g++;
  3781. }
  3782. if($v['state'] == 1)
  3783. {
  3784. $x++;
  3785. }
  3786. if($v['state'] == 2)
  3787. {
  3788. $t++;
  3789. }
  3790. if($v['state'] == 8)
  3791. {
  3792. $s++;
  3793. }
  3794. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  3795. {
  3796. $q++;
  3797. }
  3798. $details[$v['details']] = $v['details'];
  3799. }
  3800. $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'].'"');
  3801. $rows[$key]['details'] = implode("、",$details);
  3802. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  3803. $number = $value['number'];
  3804. $ftime = time()-15*24*3600;
  3805. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3806. $rows[$key]['number'] = $g;
  3807. $rows[$key]['c'] = $c;
  3808. $rows[$key]['x'] = $x;
  3809. $rows[$key]['t'] = $t;
  3810. $rows[$key]['s'] = $s;
  3811. $rows[$key]['q'] = $q;
  3812. $rows[$key]['z'] = $z;
  3813. // $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  3814. // $features = explode('-',trim($features,'-'));
  3815. // $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3816. // $pm = $classid;
  3817. // $jm = $classid;
  3818. // foreach($features as $k=>$v)
  3819. // {
  3820. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3821. // {
  3822. // if($typeclass[$v]['bm'] != '')
  3823. // {
  3824. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3825. // }
  3826. // }
  3827. // if($v != 0)
  3828. // {
  3829. // if(!isset($typeclass[$v]))
  3830. // {
  3831. // continue;
  3832. // }
  3833. // if(isset($pm[$typeclass[$v]['classid']]))
  3834. // {
  3835. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3836. // {
  3837. // $tz = explode('|',$typeclass[$v]['zh']);
  3838. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3839. // }
  3840. // else
  3841. // {
  3842. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3843. // }
  3844. // }
  3845. // if(isset($jm[$typeclass[$v]['classid']]))
  3846. // {
  3847. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3848. // }
  3849. // }
  3850. // }
  3851. // $jm = array_filter($jm);
  3852. // $rows[$key]['bs'] = implode("-",$jm);
  3853. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3854. // $zh = implode(" ",$pm);
  3855. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3856. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3857. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3858. // $rows[$key]['features'] = $zh;
  3859. }
  3860. $list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  3861. $final_list = [];
  3862. foreach($list as $k=>$v){
  3863. $final_list[] = [
  3864. "warehouse"=>$v["warehouse"],
  3865. "purchase"=>$v["purchase"],
  3866. "details"=>$v["details"],
  3867. "cpid"=>$v["cpid"],
  3868. "dbcontent"=>$v["dbcontent"],
  3869. "sku"=>$v["sku"],
  3870. "cs"=>$v["bm"],
  3871. "bs"=>$v["jm"],
  3872. "title"=>$v["title"],
  3873. "features"=>$v["pm"],
  3874. "cpbz"=>$v["cpbz"],
  3875. "sm"=>$v["sm"],
  3876. "type"=>$v["type"],
  3877. "number"=>$v["number"],
  3878. "c"=>$v["c"],
  3879. "x"=>$v["x"],
  3880. "t"=>$v["t"],
  3881. "s"=>$v["s"],
  3882. "q"=>$v["q"],
  3883. "z"=>$v["z"],
  3884. "weight"=>$v['weight'],
  3885. ];
  3886. }
  3887. $title = "总进销存统计表";
  3888. $titlename = "<table border=1>
  3889. <tr><th colspan='20' align='center'><h3>".$title."<h3></th></tr>
  3890. <tr align='center'>
  3891. <td>仓库</td>
  3892. <td>供应商</td>
  3893. <td>位置</td>
  3894. <td>库存编码</td>
  3895. <td>类目</td>
  3896. <td>SKU</td>
  3897. <td>用友编码</td>
  3898. <td>用友料号</td>
  3899. <td>商品名称</td>
  3900. <td>商品中文</td>
  3901. <td>产品备注</td>
  3902. <td>说明</td>
  3903. <td>类型</td>
  3904. <td>入库总量</td>
  3905. <td>库存数量</td>
  3906. <td>销售数量</td>
  3907. <td>退货数量</td>
  3908. <td>删除数量</td>
  3909. <td>其它操作</td>
  3910. <td>占单数量</td>
  3911. <td>重量(g)</td>
  3912. </tr>
  3913. </table>";
  3914. $filename = $title.".xls";
  3915. $tail = "";
  3916. $this->excel->get_fz2($final_list,$titlename,$filename,$tail);
  3917. }
  3918. }
  3919. //入库导出
  3920. public function _excelr()
  3921. {
  3922. if(isset($_GET['excel']))
  3923. {
  3924. $category = $this->input->get('category',true);
  3925. $size = $this->input->get('size',true);
  3926. $grade = $this->input->get('grade',true);
  3927. $color = $this->input->get('color',true);
  3928. $lowe = $this->input->get('lowe',true);
  3929. $sku = $this->input->get('sku',true);
  3930. $warehouse = $this->input->get('warehouse',true);
  3931. $purchase = $this->input->get('purchase',true);
  3932. $ktime = $this->input->get('ktime',true);
  3933. $jtime = $this->input->get('jtime',true);
  3934. $ktime = strtotime($ktime);
  3935. $jtime = strtotime($jtime);
  3936. $where = "1=1";$gj = "";$ck = "";
  3937. if($category)
  3938. {
  3939. $where .= " and features like '%-$category-%'";
  3940. }
  3941. if($size)
  3942. {
  3943. $where .= " and features like '%-$size-%'";
  3944. }
  3945. if($grade)
  3946. {
  3947. $where .= " and features like '%-$grade-%'";
  3948. }
  3949. if($color)
  3950. {
  3951. $where .= " and features like '%-$color-%'";
  3952. }
  3953. if($lowe)
  3954. {
  3955. $where .= " and features like '%-$lowe-%'";
  3956. }
  3957. if($warehouse)
  3958. {
  3959. $where .= " and warehouse = '$warehouse'";
  3960. }
  3961. if($purchase)
  3962. {
  3963. $where .= " and purchase = '$purchase'";
  3964. }
  3965. if($sku)
  3966. {
  3967. $where .= " and sku = '$sku'";
  3968. }
  3969. if($ktime && $jtime)
  3970. {
  3971. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3972. }
  3973. //数据排序
  3974. $order_str = "id desc";
  3975. if(empty($page))
  3976. {
  3977. $start = 0;
  3978. $perpage = 1;
  3979. }
  3980. else
  3981. {
  3982. $start = ($page - 1)*$perpage;
  3983. }
  3984. $list = array();
  3985. $rows = $this->whlabel->find_pc($where,'enter,sku,warehouse','*',$order_str);
  3986. foreach ($rows as $value)
  3987. {
  3988. $ck = $this->warehouse->read($value['warehouse']);
  3989. $warehouse = $ck['title'];
  3990. $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
  3991. $retreatwarehouse = $tkck['title'];
  3992. $gy = $this->purchase->read($value['purchase']);
  3993. $purchase = $gy['title'];
  3994. $g = $this->whlabel->find_count($where.' and enter = "'.$value['enter'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'"');
  3995. $list[] = array('warehouse'=>$warehouse,'sku'=>$value['sku'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
  3996. }
  3997. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
  3998. $titlename = "<table border=1>
  3999. <tr><th colspan='5' align='center'><h3>".$title."<h3></th></tr>
  4000. <tr align='center'>
  4001. <td>仓库</td>
  4002. <td>SKU</td>
  4003. <td>产品</td>
  4004. <td>时间</td>
  4005. <td>数量</td>
  4006. </tr>
  4007. </table>";
  4008. $filename = $title.".xls";
  4009. $tail = "";
  4010. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4011. }
  4012. }
  4013. //出库、退库导出
  4014. public function _excelct()
  4015. {
  4016. $classid = $this->classid->sku();
  4017. $pm = $classid;
  4018. $typeclass = array();
  4019. $tc = $this->typeclass->find_all();
  4020. foreach ($tc as $v)
  4021. {
  4022. $typeclass[$v['id']] = $v;
  4023. }
  4024. $prc = array();
  4025. $purchase = $this->purchase->find_all();
  4026. foreach($purchase as $k=>$v)
  4027. {
  4028. $prc[$v['id']] = $v['title'];
  4029. }
  4030. if(isset($_GET['excel']))
  4031. {
  4032. $wh = array();
  4033. $w = $this->warehouse->find_all('1=1','id,title');
  4034. foreach ($w as $v)
  4035. {
  4036. $wh[$v['id']] = $v['title'];
  4037. }
  4038. $type = $this->input->get('excel',true);
  4039. $category = $this->input->get('category',true);
  4040. $size = $this->input->get('size',true);
  4041. $grade = $this->input->get('grade',true);
  4042. $color = $this->input->get('color',true);
  4043. $lowe = $this->input->get('lowe',true);
  4044. $sku = $this->input->get('sku',true);
  4045. $warehouse = $this->input->get('warehouse',true);
  4046. $lacetype = $this->input->get('lacetype',true);
  4047. $lacecolor = $this->input->get('lacecolor',true);
  4048. $density = $this->input->get('density',true);
  4049. $haircap = $this->input->get('haircap',true);
  4050. $purchase = $this->input->get('purchase',true);
  4051. $title = $this->input->get('title',true);
  4052. $state = $this->input->get('state',true);
  4053. $sid = $this->input->get('sid',true);
  4054. $ktime = $this->input->get('ktime',true);
  4055. $jtime = $this->input->get('jtime',true);
  4056. $ktime = strtotime($ktime);
  4057. $jtime = strtotime($jtime);
  4058. $where = "1=1";$gj = "";$ck = "";
  4059. if($category)
  4060. {
  4061. $where .= " and features like '%-$category-%'";
  4062. }
  4063. if($size)
  4064. {
  4065. $where .= " and features like '%-$size-%'";
  4066. }
  4067. if($grade)
  4068. {
  4069. $where .= " and features like '%-$grade-%'";
  4070. }
  4071. if($color)
  4072. {
  4073. $where .= " and features like '%-$color-%'";
  4074. }
  4075. if($lowe)
  4076. {
  4077. $where .= " and features like '%-$lowe-%'";
  4078. }
  4079. if($warehouse)
  4080. {
  4081. $where .= " and warehouse = '$warehouse'";
  4082. }
  4083. if($purchase)
  4084. {
  4085. $where .= " and purchase = '$purchase'";
  4086. }
  4087. if($state)
  4088. {
  4089. $where .= " and state = '$state'";
  4090. }
  4091. if($lacetype)
  4092. {
  4093. $where .= " and features like '%-$lacetype-%'";
  4094. }
  4095. if($lacecolor)
  4096. {
  4097. $where .= " and features like '%-$lacecolor-%'";
  4098. }
  4099. if($density)
  4100. {
  4101. $where .= " and features like '%-$density-%'";
  4102. }
  4103. if($haircap)
  4104. {
  4105. $where .= " and features like '%-$haircap-%'";
  4106. }
  4107. if($title)
  4108. {
  4109. $title = trim($title,' ');
  4110. $title = trim($title,' ');
  4111. $where .= " and title like '%$title%'";
  4112. }
  4113. if($sku)
  4114. {
  4115. $sku = trim($sku,' ');
  4116. $sku = trim($sku,' ');
  4117. $where .= " and sku like '%$sku%'";
  4118. }
  4119. if($ktime && $jtime)
  4120. {
  4121. if($type == 1)
  4122. {
  4123. $tl = '出库';
  4124. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4125. }
  4126. else if($type == 2)
  4127. {
  4128. $tl = '退库';
  4129. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4130. }
  4131. else if($type == 3)
  4132. {
  4133. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4134. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4135. }
  4136. else if($type == 4)
  4137. {
  4138. $tl = '出库+零售';
  4139. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4140. }
  4141. else if($type == 5)
  4142. {
  4143. $tl = '零售';
  4144. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4145. }
  4146. }
  4147. $sidwhere = '';
  4148. if($sid)
  4149. {
  4150. $sd = "";
  4151. $s = explode(',',trim($sid,','));
  4152. foreach ($s as $value)
  4153. {
  4154. $sd .= " id = ".$value." or";
  4155. }
  4156. $sidwhere = " and (".rtrim($sd,'or').")";
  4157. }
  4158. //数据排序
  4159. $order_str = "time desc";
  4160. if(empty($page))
  4161. {
  4162. $start = 0;
  4163. $perpage = 1;
  4164. }
  4165. else
  4166. {
  4167. $start = ($page - 1)*$perpage;
  4168. }
  4169. //取得信息列表
  4170. if($type != 3 && $type != 5)
  4171. {
  4172. if($type == 1 || $type == 4)
  4173. {
  4174. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk',$order_str);
  4175. foreach ($info_list as $key=>$value)
  4176. {
  4177. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4178. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4179. $warehouse = $this->warehouse->read($value['warehouse']);
  4180. $info_list[$key]['warehouse'] = $warehouse['title'];
  4181. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4182. $features = explode('-',trim($features,'-'));
  4183. $pm = $classid;
  4184. foreach($features as $k=>$v)
  4185. {
  4186. if($v != 0)
  4187. {
  4188. if(!isset($typeclass[$v]))
  4189. {
  4190. continue;
  4191. }
  4192. if(isset($pm[$typeclass[$v]['classid']]))
  4193. {
  4194. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4195. {
  4196. $tz = explode('|',$typeclass[$v]['zh']);
  4197. $pm[$typeclass[$v]['classid']] = $tz[0];
  4198. }
  4199. else
  4200. {
  4201. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4202. }
  4203. }
  4204. }
  4205. }
  4206. $zh = implode(" ",$pm);
  4207. $zh = str_replace('自然色 ','',trim($zh,' '));
  4208. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4209. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4210. $info_list[$key]['features'] = $zh;
  4211. }
  4212. }
  4213. else
  4214. {
  4215. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat',$order_str);
  4216. foreach ($info_list as $key=>$value)
  4217. {
  4218. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4219. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
  4220. $warehouse = $this->warehouse->read($value['warehouse']);
  4221. $info_list[$key]['warehouse'] = $warehouse['title'];
  4222. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4223. $features = explode('-',trim($features,'-'));
  4224. $pm = $classid;
  4225. foreach($features as $k=>$v)
  4226. {
  4227. if($v != 0)
  4228. {
  4229. if(!isset($typeclass[$v]))
  4230. {
  4231. continue;
  4232. }
  4233. if(isset($pm[$typeclass[$v]['classid']]))
  4234. {
  4235. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4236. {
  4237. $tz = explode('|',$typeclass[$v]['zh']);
  4238. $pm[$typeclass[$v]['classid']] = $tz[0];
  4239. }
  4240. else
  4241. {
  4242. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4243. }
  4244. }
  4245. }
  4246. }
  4247. $zh = implode(" ",$pm);
  4248. $zh = str_replace('自然色 ','',trim($zh,' '));
  4249. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4250. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4251. $info_list[$key]['features'] = $zh;
  4252. }
  4253. }
  4254. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4255. $titlename = "<table border=1>
  4256. <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
  4257. <tr align='center'>
  4258. <td>仓库</td>
  4259. <td>供应商</td>
  4260. <td>SKU</td>
  4261. <td>商品名称</td>
  4262. <td>商品中文</td>
  4263. <td>标签</td>
  4264. <td>订单号</td>
  4265. <td>运单号</td>
  4266. <td>".$tl."时间(中国时间)</td>
  4267. </tr>
  4268. </table>";
  4269. $filename = $title.".xls";
  4270. $tail = "";
  4271. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4272. }
  4273. else if($type == 5)
  4274. {
  4275. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,outk',$order_str);
  4276. foreach ($info_list as $key=>$value)
  4277. {
  4278. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4279. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4280. $warehouse = $this->warehouse->read($value['warehouse']);
  4281. $info_list[$key]['warehouse'] = $warehouse['title'];
  4282. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4283. $features = explode('-',trim($features,'-'));
  4284. $pm = $classid;
  4285. foreach($features as $k=>$v)
  4286. {
  4287. if($v != 0)
  4288. {
  4289. if(!isset($typeclass[$v]))
  4290. {
  4291. continue;
  4292. }
  4293. if(isset($pm[$typeclass[$v]['classid']]))
  4294. {
  4295. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4296. {
  4297. $tz = explode('|',$typeclass[$v]['zh']);
  4298. $pm[$typeclass[$v]['classid']] = $tz[0];
  4299. }
  4300. else
  4301. {
  4302. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4303. }
  4304. }
  4305. }
  4306. }
  4307. $zh = implode(" ",$pm);
  4308. $zh = str_replace('自然色 ','',trim($zh,' '));
  4309. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4310. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4311. $info_list[$key]['features'] = $zh;
  4312. }
  4313. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4314. $titlename = "<table border=1>
  4315. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  4316. <tr align='center'>
  4317. <td>仓库</td>
  4318. <td>供应商</td>
  4319. <td>SKU</td>
  4320. <td>商品名称</td>
  4321. <td>商品中文</td>
  4322. <td>标签</td>
  4323. <td>".$tl."时间(中国时间)</td>
  4324. </tr>
  4325. </table>";
  4326. $filename = $title.".xls";
  4327. $tail = "";
  4328. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4329. }
  4330. else
  4331. {
  4332. /**
  4333. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4334. $rows = array();$list = array();
  4335. foreach ($info_list as $key=>$value)
  4336. {
  4337. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4338. }
  4339. **/
  4340. $wh = array();
  4341. $w = $this->warehouse->find_all('1=1','id,title');
  4342. foreach ($w as $v)
  4343. {
  4344. $wh[$v['id']] = $v['title'];
  4345. }
  4346. $wt = array();
  4347. $whlabel_type = $this->whlabel_type->find_all();
  4348. foreach ($whlabel_type as $v)
  4349. {
  4350. $wt[$v['id']] = $v['title'];
  4351. }
  4352. $classid = $this->classid->sku();
  4353. $list = array();
  4354. $rows = $this->whlabel->find_pc($where.$sidwhere,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4355. foreach ($rows as $key=>$value)
  4356. {
  4357. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4358. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4359. $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');
  4360. $details = array();
  4361. $cpid = array();
  4362. $cpbz = array();
  4363. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  4364. foreach ($sd as $k=>$v)
  4365. {
  4366. if($v['state'] == 0)
  4367. {
  4368. $c++;
  4369. }
  4370. if($v['state'] != 9)
  4371. {
  4372. $g++;
  4373. }
  4374. if($v['outk'] > 1)
  4375. {
  4376. $x++;
  4377. }
  4378. if($v['retreat'] > 0)
  4379. {
  4380. $t++;
  4381. }
  4382. if($v['state'] == 8)
  4383. {
  4384. $s++;
  4385. }
  4386. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  4387. {
  4388. $q++;
  4389. }
  4390. $details[$v['details']] = $v['details'];
  4391. if($v['cpid'] != 0)
  4392. {
  4393. $cpid[$v['cpid']] = $v['cpid'];
  4394. }
  4395. if($v['cpbz'] != '')
  4396. {
  4397. $cpbz[$v['cpbz']] = $v['cpbz'];
  4398. }
  4399. }
  4400. if(isset($wt[$value['type']]))
  4401. {
  4402. $rows[$key]['type'] = $wt[$value['type']];
  4403. }
  4404. else
  4405. {
  4406. $rows[$key]['type'] = '未设置';
  4407. }
  4408. $rows[$key]['details'] = implode("、",$details);
  4409. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4410. $ftime = time()-15*24*3600;
  4411. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4412. $rows[$key]['cpbz'] = ($cpbz)?implode(" ",$cpbz):'';
  4413. $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);
  4414. $rows[$key]['c'] = $c;
  4415. $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);
  4416. $rows[$key]['t'] = $t;
  4417. $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'].'"');
  4418. $rows[$key]['z'] = $z;
  4419. $jm = $classid;
  4420. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4421. $features = explode('-',trim($features,'-'));
  4422. $pm = $classid;
  4423. foreach($features as $k=>$v)
  4424. {
  4425. if($v != 0)
  4426. {
  4427. if(!isset($typeclass[$v]))
  4428. {
  4429. continue;
  4430. }
  4431. if(isset($pm[$typeclass[$v]['classid']]))
  4432. {
  4433. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4434. {
  4435. $tz = explode('|',$typeclass[$v]['zh']);
  4436. $pm[$typeclass[$v]['classid']] = $tz[0];
  4437. }
  4438. else
  4439. {
  4440. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4441. }
  4442. if(isset($jm[$typeclass[$v]['classid']]))
  4443. {
  4444. if($typeclass[$v]['jm'])
  4445. {
  4446. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4447. }
  4448. }
  4449. }
  4450. }
  4451. }
  4452. $zh = implode(" ",$pm);
  4453. $zh = str_replace('自然色 ','',trim($zh,' '));
  4454. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4455. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4456. $rows[$key]['features'] = $zh;
  4457. $jm = array_filter($jm);//去除空值
  4458. $jm = implode("-",$jm);
  4459. $rows[$key]['jm'] = $jm;
  4460. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4461. }
  4462. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
  4463. $titlename = "<table border=1>
  4464. <tr><th colspan='17' align='center'><h3>".$title."<h3></th></tr>
  4465. <tr align='center'>
  4466. <td>仓库</td>
  4467. <td>供应商</td>
  4468. <td>位置</td>
  4469. <td>库存编码</td>
  4470. <td>SKU</td>
  4471. <td>商品名称</td>
  4472. <td>商品中文</td>
  4473. <td>产品备注</td>
  4474. <td>说明</td>
  4475. <td>类型</td>
  4476. <td>入库总量</td>
  4477. <td>库存数量</td>
  4478. <td>销售数量</td>
  4479. <td>退货数量</td>
  4480. <td>占单数量</td>
  4481. <td>料号</td>
  4482. <td>类目</td>
  4483. </tr>
  4484. </table>";
  4485. $filename = $title.".xls";
  4486. $tail = "";
  4487. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  4488. }
  4489. }
  4490. }
  4491. //出库+入库数据整合
  4492. public function _excelcr()
  4493. {
  4494. if(isset($_GET['excel']))
  4495. {
  4496. $type = $this->input->get('excel',true);
  4497. $category = $this->input->get('category',true);
  4498. $size = $this->input->get('size',true);
  4499. $grade = $this->input->get('grade',true);
  4500. $color = $this->input->get('color',true);
  4501. $lowe = $this->input->get('lowe',true);
  4502. $sku = $this->input->get('sku',true);
  4503. $warehouse = $this->input->get('warehouse',true);
  4504. $purchase = $this->input->get('purchase',true);
  4505. $state = $this->input->get('state',true);
  4506. $sid = $this->input->get('sid',true);
  4507. $ktime = $this->input->get('ktime',true);
  4508. $jtime = $this->input->get('jtime',true);
  4509. $ktime = strtotime($ktime);
  4510. $jtime = strtotime($jtime);
  4511. $where = "1=1";$gj = "";$ck = "";
  4512. if($category)
  4513. {
  4514. $where .= " and features like '%-$category-%'";
  4515. }
  4516. if($size)
  4517. {
  4518. $where .= " and features like '%-$size-%'";
  4519. }
  4520. if($grade)
  4521. {
  4522. $where .= " and features like '%-$grade-%'";
  4523. }
  4524. if($color)
  4525. {
  4526. $where .= " and features like '%-$color-%'";
  4527. }
  4528. if($lowe)
  4529. {
  4530. $where .= " and features like '%-$lowe-%'";
  4531. }
  4532. if($warehouse)
  4533. {
  4534. $where .= " and warehouse = '$warehouse'";
  4535. }
  4536. if($purchase)
  4537. {
  4538. $where .= " and purchase = '$purchase'";
  4539. }
  4540. if($state)
  4541. {
  4542. $where .= " and state = '$state'";
  4543. }
  4544. if($sku)
  4545. {
  4546. $where .= " and sku like '%$sku%'";
  4547. }
  4548. if($ktime && $jtime)
  4549. {
  4550. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4551. }
  4552. $sidwhere = '';
  4553. if($sid)
  4554. {
  4555. $sd = "";
  4556. $s = explode(',',trim($sid,','));
  4557. foreach ($s as $value)
  4558. {
  4559. $sd .= " id = ".$value." or";
  4560. }
  4561. $sidwhere .= " and (".rtrim($sd,'or').")";
  4562. }
  4563. //取得信息列表
  4564. $timeread = $ktime;
  4565. $timenum = ceil(($jtime - $ktime) / (24*3600));
  4566. $timelist = array();
  4567. for($i=0;$i<$timenum;$i++)
  4568. {
  4569. $timeread = ($i>0)?$ktime+$i*24*3600:$ktime;
  4570. $timelist[date('Y-m-d',$timeread)] = array('c'=>0,'r'=>0);
  4571. }
  4572. $info_list = $this->whlabel->find_all($where.$sidwhere,'outk,enter,sku,state');
  4573. //echo "<pre>";
  4574. //print_r($info_list);
  4575. //exit();
  4576. $rows = array();$list = array();
  4577. foreach ($info_list as $key=>$value)
  4578. {
  4579. $thistime = $timelist;
  4580. if(isset($rows[strtolower($value['sku'])]))
  4581. {
  4582. if($value['outk'] > $ktime && $value['state'] < $jtime)
  4583. {
  4584. $rows[strtolower($value['sku'])][date('Y-m-d',$value['outk'])]['c'] += 1;
  4585. }
  4586. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4587. {
  4588. $rows[strtolower($value['sku'])][date('Y-m-d',$value['enter'])]['r'] += 1;
  4589. }
  4590. }
  4591. else
  4592. {
  4593. if($value['outk'] > $ktime && $value['outk'] < $jtime)
  4594. {
  4595. $thistime[date('Y-m-d',$value['outk'])]['c'] += 1;
  4596. }
  4597. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4598. {
  4599. $thistime[date('Y-m-d',$value['enter'])]['r'] += 1;
  4600. }
  4601. $rows[strtolower($value['sku'])] = $thistime;
  4602. }
  4603. }
  4604. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4605. <head>
  4606. <!--[if gte mso 9]><xml>
  4607. <x:ExcelWorkbook>
  4608. <x:ExcelWorksheets>
  4609. <x:ExcelWorksheet>
  4610. <x:Name>EXCEL</x:Name>
  4611. <x:WorksheetOptions>
  4612. <x:Print>
  4613. <x:ValidPrinterInfo />
  4614. </x:Print>
  4615. </x:WorksheetOptions>
  4616. </x:ExcelWorksheet>
  4617. </x:ExcelWorksheets>
  4618. </x:ExcelWorkbook>
  4619. </xml>
  4620. <![endif]-->
  4621. </head><body>";
  4622. $str .= "<table border=1><tr><td>SKU</td>";
  4623. foreach ($timelist as $k=>$v)
  4624. {
  4625. $str .="<td>".$k."出库</td>";
  4626. $str .="<td>".$k."入库</td>";
  4627. }
  4628. $str .= "</tr></table>";
  4629. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4630. foreach ($rows as $key=>$val)
  4631. {
  4632. $str .= "<tr><td>".strtoupper($key)."</td>";
  4633. foreach ($val as $k=>$v)
  4634. {
  4635. $str .= "<td>".$val[$k]['c']."</td>";
  4636. if($val[$k]['r'] > 0)
  4637. {
  4638. $str .= "<td style='color:#f00'>-".$val[$k]['r']."</td>";
  4639. }
  4640. else
  4641. {
  4642. $str .= "<td>".$val[$k]['r']."</td>";
  4643. }
  4644. }
  4645. $str .= "</tr>";
  4646. }
  4647. $str .= "</table>";
  4648. $str .= "</body></html>";
  4649. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  4650. header( "Content-type: application/octet-stream" );
  4651. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  4652. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  4653. header( "Pragma: no-cache" );
  4654. header( "Expires: 0" );
  4655. exit($str);
  4656. }
  4657. }
  4658. //数量调整模板导出
  4659. public function _presetout()
  4660. {
  4661. if(isset($_GET['excel']))
  4662. {
  4663. $where = "sku != 'Preset' and purchase != 0";
  4664. //数据排序
  4665. $order_str = "id desc";
  4666. if(empty($page))
  4667. {
  4668. $start = 0;
  4669. $perpage = 1;
  4670. }
  4671. else
  4672. {
  4673. $start = ($page - 1)*$perpage;
  4674. }
  4675. //取得信息列表
  4676. $info_list = $this->whlabel->find_pc($where,'warehouse,purchase,sku','*','id desc',0,1);
  4677. $rows = array();$list = array();
  4678. foreach ($info_list as $value)
  4679. {
  4680. $warehouse = $this->warehouse->read($value['warehouse']);
  4681. $number = $value['number'];$ftime = time()-15*24*3600;
  4682. $purchase = $this->purchase->read($value['purchase']);
  4683. $list[] = array($warehouse['title'],$purchase['bm'],$value['sku'],'0','','0','','');
  4684. }
  4685. $title = "库存模板";
  4686. $titlename = "<table border=1>
  4687. <tr align='center'>
  4688. <td>仓库</td>
  4689. <td>供应商编码</td>
  4690. <td>SKU</td>
  4691. <td>增减数量(正数或负数)</td>
  4692. <td>增减备注</td>
  4693. <td>扣减方式:0减少库存1删除库存</td>
  4694. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4695. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4696. </tr>
  4697. </table>";
  4698. $filename = $title.".xls";
  4699. $tail = "";
  4700. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4701. }
  4702. }
  4703. //数量调整模板导入
  4704. public function _presetedit()
  4705. {
  4706. $dir = '/data/excel/'.date('Ymd',time()).'/';
  4707. $config['upload_path'] = '.'.$dir ;
  4708. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  4709. $config['allowed_types'] = 'xls|xlsx|csv';
  4710. $config['max_size'] = 10240;
  4711. $this->load->library('upload', $config);
  4712. $this->upload->initialize($config);
  4713. if ($this->upload->do_upload('userfile'))
  4714. {
  4715. $full_path = $dir.$this->upload->data('file_name');
  4716. $fileName = '.' . $full_path;
  4717. if (!file_exists($fileName))
  4718. {
  4719. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  4720. }
  4721. else
  4722. {
  4723. require_once "./data/excel/PHPExcel/IOFactory.php";
  4724. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  4725. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  4726. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  4727. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  4728. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  4729. ++$column;//如果列数大于26行
  4730. $list = array();
  4731. for ($i = 2; $i <= $row; $i++) // 行数循环
  4732. {
  4733. $data = array();
  4734. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4735. {
  4736. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4737. }
  4738. $list[] = $data;
  4739. }
  4740. }
  4741. $i = 0;$j = 0;$ed = array();
  4742. foreach ($list as $key=>$value)
  4743. {
  4744. $time = time();
  4745. if($value['0'] == "")
  4746. {
  4747. continue;
  4748. }
  4749. $warehouse = $this->warehouse->get_title($value['0']);
  4750. $purchase = $this->purchase->get_bm($value['1']);
  4751. $sku = $value['2'];
  4752. $num = $value['3'];//调整数量
  4753. $text = $value['4'];//扣减说明
  4754. $type = $value['5'];//调整方式0扣减1删除
  4755. $rktype = $value['6']!=''?$value['6']:0;//增加库存
  4756. $cktype = $value['7']!=''?$value['7']:0;//减少库存
  4757. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  4758. if(!$purchase)//如果没有这个SKU
  4759. {
  4760. $ed[] = array($purchase.'-不存在此供应商编码');
  4761. $j++;
  4762. continue;
  4763. }
  4764. if(!$d)//如果没有这个SKU
  4765. {
  4766. $ed[] = array($sku.'-库存中不存在此SKU');
  4767. $j++;
  4768. continue;
  4769. }
  4770. if(!isset($warehouse['id']))
  4771. {
  4772. $ed[] = array($sku.'-仓库名错误!');
  4773. $j++;
  4774. continue;
  4775. }
  4776. if($type != '0' && $type != '1')
  4777. {
  4778. $ed[] = array($sku.'-扣减方式填写错误!');
  4779. $j++;
  4780. continue;
  4781. }
  4782. if($num < 0)//扣减库存
  4783. {
  4784. if($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == '')))
  4785. {
  4786. $ed[] = array($sku.'-扣减必须填写扣减类型,非类型1必须填写备注');
  4787. $j++;
  4788. continue;
  4789. }
  4790. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and zd = "" and state = 0');
  4791. if(count($data) < abs($num))
  4792. {
  4793. $ed[] = array($sku.'-扣减数量大于库存剩余数量!');
  4794. $j++;
  4795. continue;
  4796. }
  4797. if($type == 0)//如果扣减方式为 扣减库存
  4798. {
  4799. for($i=0;$i<abs($num);$i++)
  4800. {
  4801. $this->whlabel->save(array('state'=>8,'textout'=>$text,'deltime'=>$time,'cktype'=>$cktype,'time'=>$time,'outk'=>$time),$data[$i]['id']);
  4802. }
  4803. }
  4804. else if($type == 1)
  4805. {
  4806. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  4807. if(count($zt) > 0)
  4808. {
  4809. $ed[] = array($sku.'-有在途库存无法删除!');
  4810. $j++;
  4811. continue;
  4812. }
  4813. for($i=0;$i<abs($num);$i++)
  4814. {
  4815. $this->whlabel->remove($data[$i]['id']);
  4816. }
  4817. }
  4818. }
  4819. else if($num > 0)//增加库存
  4820. {
  4821. if($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == '')))
  4822. {
  4823. $ed[] = array($sku.'-增加必须填写增加类型,非类型1必须填写备注');
  4824. $j++;
  4825. continue;
  4826. }
  4827. $post['sku'] = $d['sku'];
  4828. $post['shop'] = $d['shop'];
  4829. $post['warehouse'] = $warehouse['id'];
  4830. $post['purchase'] = $purchase['id'];
  4831. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4832. $post['state'] = 0;
  4833. $post['title'] = $d['title'];
  4834. $post['number'] = $d['number'];
  4835. $post['features'] = $d['features'];
  4836. $post['enter'] = $time;
  4837. $post['time'] = $time;//操作时间
  4838. $post['rktype'] = $rktype;
  4839. for($i=0;$i<$num;$i++)
  4840. {
  4841. $post['label'] = time().rand(100,999).$i;
  4842. $this->whlabel->insert($post);
  4843. }
  4844. }
  4845. sleep(1);//防止入库时间一样,需要延迟1秒
  4846. }
  4847. if($j > 0)
  4848. {
  4849. $tt = date('Ymd',time());
  4850. $title = '库存导入错误信息-'.$tt;
  4851. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4852. $tail = "\n";
  4853. $filename = $title.".xls";
  4854. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  4855. $dir = '/data/excel/'.$time.'/';
  4856. $file_name = 'error_'.$time.rand(1000,9999);
  4857. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  4858. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  4859. fwrite($myfile,$ecl);
  4860. fclose($myfile);
  4861. $error = $dir.$file_name.'.xls';
  4862. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  4863. }
  4864. else
  4865. {
  4866. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  4867. }
  4868. }
  4869. }
  4870. //笛卡儿积
  4871. function cp($ps,$sets,$list)
  4872. {
  4873. $result = array();$j=0;
  4874. for($i=0,$count=count($sets); $i<$count-1; $i++)
  4875. {
  4876. if($i==0)
  4877. {
  4878. $result = $sets[$i];
  4879. }
  4880. $tmp = array();
  4881. foreach($result as $res)
  4882. {
  4883. foreach($sets[$i+1] as $set)
  4884. {
  4885. $tmp[] = $res.','.$set;
  4886. }
  4887. }
  4888. $result = $tmp;
  4889. }
  4890. $this->db->trans_begin();
  4891. foreach ($result as $v)
  4892. {
  4893. $post = array();$title = "";$num="";
  4894. $data = explode(',',$v);
  4895. for($i=0;$i<count($list); $i++)
  4896. {
  4897. $post[$list[$i]] = $data[$i];
  4898. $typeclass = $this->typeclass->read($data[$i]);
  4899. $title = $title.$typeclass['title']." ";
  4900. if($data[$i] != 0)
  4901. {
  4902. $num .=$data[$i];//所有数据ID拼接
  4903. }
  4904. }
  4905. foreach ($ps as $kp=>$vp)
  4906. {
  4907. $post[$kp] = $vp;
  4908. }
  4909. $post['number'] = $num;
  4910. $info_list = $this->whlabel->get_number($num);//查询whlabel是否存在此拼接的数据ID
  4911. if($info_list)
  4912. {
  4913. $j++;
  4914. }
  4915. else
  4916. {
  4917. $skunum = $this->whlabel->find_count();
  4918. $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
  4919. $post['title'] = rtrim($title,' ');
  4920. $this->whlabel->insert($post);
  4921. }
  4922. }
  4923. if ($this->db->trans_status() === FALSE)
  4924. {
  4925. $this->db->trans_commit();
  4926. return NULL;
  4927. }
  4928. else
  4929. {
  4930. $this->db->trans_commit();
  4931. return $j;
  4932. }
  4933. }
  4934. public function _kj($arg_array)
  4935. {
  4936. if(isset($_POST['sku']))
  4937. {
  4938. $time = time();
  4939. $sku = $this->input->post('sku',true);
  4940. $warehouse = $this->input->post('warehouse',true);
  4941. $num = $this->input->post('num',true);
  4942. $text = $this->input->post('text',true);
  4943. $purchase = $this->input->post('purchase',true);
  4944. $cktype = $this->input->post('cktype',true);
  4945. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4946. if($cktype != 1 && $text == '')
  4947. {
  4948. echo json_encode(array('msg'=>"非销售出库必须填写备注!",'success'=>false));exit;
  4949. }
  4950. if($num > count($order))
  4951. {
  4952. echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
  4953. }
  4954. else
  4955. {
  4956. for($i=0;$i<$num;$i++)
  4957. {
  4958. $this->whlabel->save(array('state'=>8,'cktype'=>$cktype,'textout'=>$text,'deltime'=>$time,'time'=>$time,'outk'=>$time),$order[$i]['id']);
  4959. }
  4960. }
  4961. echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
  4962. }
  4963. $uid = $this->whlabel->read($arg_array[0]);
  4964. $uid['num'] = $this->whlabel->find_count('purchase = "'.$uid['purchase']. '" and sku = "'.$uid['sku']. '" and warehouse = "'.$uid['warehouse']. '" and zd = "" and state = 0');
  4965. $this->data['data'] = $uid ;
  4966. $this->_Template('whlabel_kj',$this->data);
  4967. }
  4968. public function _summary($arg_array)
  4969. {
  4970. $prc = array();
  4971. $purchase = $this->purchase->find_all();
  4972. foreach($purchase as $k=>$v)
  4973. {
  4974. $prc[$v['id']] = $v['title'];
  4975. }
  4976. if(isset($_GET['excel']))
  4977. {
  4978. $ktime = $this->input->get('ktime',true);
  4979. $jtime = $this->input->get('jtime',true);
  4980. $ktime = strtotime($ktime);
  4981. $jtime = strtotime($jtime);
  4982. $where = "1=1";
  4983. if($ktime && $jtime)
  4984. {
  4985. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4986. }
  4987. //数据排序
  4988. $order_str = "time desc";
  4989. if(empty($page))
  4990. {
  4991. $start = 0;
  4992. $perpage = 1;
  4993. }
  4994. else
  4995. {
  4996. $start = ($page - 1)*$perpage;
  4997. }
  4998. //取得信息列表
  4999. $info_list = $this->whlabel->find_pc($where,'sku','warehouse,purchase,details,cpid,sku,title');
  5000. foreach ($info_list as $key=>$value)
  5001. {
  5002. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  5003. $warehouse = $this->warehouse->read($value['warehouse']);
  5004. $info_list[$key]['warehouse'] = $warehouse['title'];
  5005. $x = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'"','details,cpid');
  5006. $details = array();
  5007. $cpid = array();
  5008. foreach ($x as $k=>$v)
  5009. {
  5010. if($v['details'] != '')
  5011. {
  5012. $details[$v['details']] = $v['details'];
  5013. }
  5014. if($v['cpid'] != 0)
  5015. {
  5016. $cpid[$v['cpid']] = $v['cpid'];
  5017. }
  5018. }
  5019. $info_list[$key]['details'] = ($details)?implode(" ",$details):'';
  5020. $info_list[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  5021. $s = $this->whlabel->find_count('state = 0 and sku = "'.$value['sku'].'"');
  5022. $info_list[$key]['s'] = $s;
  5023. $info_list[$key]['x'] = count($x);
  5024. }
  5025. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
  5026. $titlename = "<table border=1>
  5027. <tr align='center'>
  5028. <td>仓库</td>
  5029. <td>供应商</td>
  5030. <td>出库位置</td>
  5031. <td>出库编码</td>
  5032. <td>SKU</td>
  5033. <td>产品名</td>
  5034. <td>总剩余库存</td>
  5035. <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
  5036. </tr>
  5037. </table>";
  5038. $filename = $title.".xls";
  5039. $tail = "";
  5040. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5041. }
  5042. }
  5043. //usps发货清单
  5044. public function _manifest()
  5045. {
  5046. if(isset($_POST['manifest']))
  5047. {
  5048. $wltext = $this->input->post('wltext',true);
  5049. $time = time()-16*3600;
  5050. $ptime = strtotime(date('Y-m-d',$time));
  5051. $waybill = array();
  5052. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  5053. foreach ($fullorder as $v)
  5054. {
  5055. $waybill[$v['waybill']] = $v['waybill'];
  5056. }
  5057. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  5058. foreach ($fullordersmt as $v)
  5059. {
  5060. $waybill[$v['waybill']] = $v['waybill'];
  5061. }
  5062. $wltext = explode(';',$wltext);
  5063. foreach ($wltext as $v)
  5064. {
  5065. if(isset($waybill[$v]))
  5066. {
  5067. unset($waybill[$v]);
  5068. }
  5069. }
  5070. $data = $this->usps->get_manifest($waybill);
  5071. if(isset($data['Description']))
  5072. {
  5073. echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
  5074. }
  5075. else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
  5076. {
  5077. $bctime = date('Ymd',time());
  5078. $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
  5079. echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
  5080. }
  5081. else
  5082. {
  5083. echo json_encode(array('msg'=>$data,'success'=>false));exit;
  5084. }
  5085. }
  5086. }
  5087. public function _pdf($pdf,$title,$bctime)
  5088. {
  5089. $pdf_path = './data/pdf/'.$bctime.'/';
  5090. $file_base64 = $pdf;
  5091. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5092. $file_base64 = base64_decode($file_base64);
  5093. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  5094. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  5095. return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
  5096. }
  5097. /**
  5098. *
  5099. *
  5100. *
  5101. 进销存占单异常索引
  5102. *
  5103. *
  5104. *
  5105. **/
  5106. public function _abnormal()
  5107. {
  5108. $post = $this->input->post(NULL, TRUE);
  5109. if(isset($post['page']))
  5110. {
  5111. $page = $this->input->post('page',true);
  5112. $perpage = $this->input->post('perpage',true);
  5113. $sku = $this->input->post('sku',true);
  5114. $where = "1=1";
  5115. //数据排序
  5116. $order_str = "id desc";
  5117. if(empty($page))
  5118. {
  5119. $start = 0;
  5120. $perpage = 1;
  5121. }
  5122. else
  5123. {
  5124. $start = ($page - 1)*$perpage;
  5125. }
  5126. //取得信息列表
  5127. $info_list = $this->whlabel->find_all($where,'*');
  5128. $rows = array();$list = array();
  5129. foreach ($info_list as $key=>$value)
  5130. {
  5131. $rows[strtolower($value['sku'])] = $value;//所有数据sku
  5132. }
  5133. foreach ($rows as $value)
  5134. {
  5135. $warehouse = $this->warehouse->read($value['warehouse']);
  5136. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
  5137. $number = $value['number'];$ftime = time()-15*24*3600;
  5138. if($value['shop'] != '')
  5139. {
  5140. $shop = $value['shop'];
  5141. $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');
  5142. $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');
  5143. $order = array_merge($orderdlz,$ordersmt);
  5144. $od = 0;$a = '';$orid = '';
  5145. foreach ($order as $v)
  5146. {
  5147. $or = explode('|',ltrim($v['whlabel'],'|'));
  5148. for($i=0;$i<count($or);$i++)
  5149. {
  5150. $orod = explode('-',$or[$i]);
  5151. if($orod[0] == $number)
  5152. {
  5153. $od += $orod[1];
  5154. }
  5155. }
  5156. $orid .= $v['number'].'-';
  5157. }
  5158. }
  5159. else
  5160. {
  5161. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5162. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5163. $order = array_merge($orderdlz,$ordersmt);
  5164. $od = 0;$a = '';$orid = '';$qt = array();
  5165. foreach ($order as $v)
  5166. {
  5167. $or = explode('|',ltrim($v['whlabel'],'|'));
  5168. for($i=0;$i<count($or);$i++)
  5169. {
  5170. $orod = explode('-',$or[$i]);
  5171. if($orod[0] == $number)
  5172. {
  5173. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
  5174. if($czzs > 0)
  5175. {
  5176. if(isset($qt[$v['shop']]))
  5177. {
  5178. if($qt[$v['shop']] < $orod[1])
  5179. {
  5180. $od += $orod[1];//专属小于单量不计算剩余直接归入通用
  5181. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5182. }
  5183. else
  5184. {
  5185. $qt[$v['shop']] -= $orod[1];
  5186. }
  5187. }
  5188. else
  5189. {
  5190. $qt[$v['shop']] = $czzs;
  5191. }
  5192. }
  5193. else
  5194. {
  5195. $od += $orod[1];
  5196. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5197. }
  5198. }
  5199. }
  5200. }
  5201. }
  5202. $z = $od.'('.$orid.')';//查看订单号
  5203. //$z = $od;
  5204. if($od > $c)
  5205. {
  5206. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
  5207. }
  5208. }
  5209. $listdata = array_slice($list,$start,$perpage);
  5210. $total = count($list);
  5211. $pagenum = ceil($total/$perpage);
  5212. $over = $total-($start+$perpage);
  5213. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5214. echo json_encode($rows);exit;
  5215. }
  5216. $this->_Template('whlabel_abnormal',$this->data);
  5217. }
  5218. /**
  5219. *
  5220. *
  5221. *
  5222. 进销存占单异常索引
  5223. *
  5224. *
  5225. *
  5226. **/
  5227. public function _error()
  5228. {
  5229. $post = $this->input->post(NULL, TRUE);
  5230. if(isset($post['page']))
  5231. {
  5232. $page = $this->input->post('page',true);
  5233. $perpage = $this->input->post('perpage',true);
  5234. $sku = $this->input->post('sku',true);
  5235. $warehouse = $this->input->post('warehouse',true);
  5236. $ktime = $this->input->post('ktime',true);
  5237. $jtime = $this->input->post('jtime',true);
  5238. $ktime = strtotime($ktime);
  5239. $jtime = strtotime($jtime);
  5240. $where = "sku != 'Preset'";
  5241. $gj = '';
  5242. if($sku)
  5243. {
  5244. $where .= " and sku like '%$sku%'";
  5245. }
  5246. else
  5247. {
  5248. if($ktime && $jtime)
  5249. {
  5250. $gj = " and time > '$ktime' and time < '$jtime'";
  5251. }
  5252. }
  5253. if($warehouse)
  5254. {
  5255. $where .= " and warehouse = '$warehouse'";
  5256. }
  5257. //数据排序
  5258. $order_str = "id desc";
  5259. if(empty($page))
  5260. {
  5261. $start = 0;
  5262. $perpage = 1;
  5263. }
  5264. else
  5265. {
  5266. $start = ($page - 1)*$perpage;
  5267. }
  5268. //取得信息列表
  5269. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5270. $rows = array();$list = array();
  5271. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5272. // foreach ($info_list as $value)
  5273. // {
  5274. // $warehouse = $this->warehouse->read($value['warehouse']);
  5275. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5276. // $number = $value['number'];$ftime = time()-15*24*3600;
  5277. // if($c < 1)
  5278. // {
  5279. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5280. // }
  5281. // }
  5282. $warehouse_list = $this->warehouse->find_all();
  5283. $warehouse_list = array_column($warehouse_list,null,'id');
  5284. foreach ($info_list as $value)
  5285. {
  5286. $warehouse = isset($warehouse_list[$value['warehouse']])?$warehouse_list[$value['warehouse']]:[
  5287. 'title'=>"",
  5288. ];
  5289. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5290. $number = $value['number'];$ftime = time()-15*24*3600;
  5291. if($c < 1)
  5292. {
  5293. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5294. }
  5295. }
  5296. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5297. // $query = $this->db->query($sql);
  5298. // $info_list = $query->result_array();
  5299. // $sql_two = "select title,id from crowd_warehouse";
  5300. // $query_two = $this->db->query($sql_two);
  5301. // $warehouse_list = $query_two->result_array();
  5302. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5303. // foreach ($info_list as $value)
  5304. // {
  5305. // if(isset($warehouse_arr[$value['warehouse']])){
  5306. // $warehouse = $warehouse_arr[$value['warehouse']];
  5307. // }else{
  5308. // $warehouse = [
  5309. // 'id'=>0,
  5310. // 'title'=>"异常",
  5311. // ];
  5312. // }
  5313. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5314. // $number = $value['number'];$ftime = time()-15*24*3600;
  5315. // if($c < 1)
  5316. // {
  5317. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5318. // }
  5319. // }
  5320. $listdata = array_slice($list,$start,$perpage);
  5321. $total = count($list);
  5322. $pagenum = ceil($total/$perpage);
  5323. $over = $total-($start+$perpage);
  5324. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5325. echo json_encode($rows);exit;
  5326. }
  5327. if(isset($post['s']))
  5328. {
  5329. $id_arr = $this->input->post('s');
  5330. $id_arr = explode(',',trim($id_arr,','));
  5331. if(!$id_arr)
  5332. {
  5333. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  5334. }
  5335. //循环删除记录
  5336. foreach ($id_arr as $v)
  5337. {
  5338. $dd = $this->whlabel->read($v);
  5339. if(!isset($dd['id']))
  5340. {
  5341. echo json_encode(array('msg'=>$dd['sku'].'已被删除,请刷新页面','success'=>false));exit;
  5342. }
  5343. $zt = $this->whlabeltransport->find_all('sku = "'.$dd['sku'].'" and warehouse = "'.$dd['warehouse'].'" and features = "'.$dd['features'].'" and cz = "0"');
  5344. if(isset($zt[0]))
  5345. {
  5346. echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
  5347. }
  5348. $deldd = $this->whlabel->find_all("sku = '".$dd['sku']."' and warehouse = '".$dd['warehouse']."'");
  5349. foreach ($deldd as $vv)
  5350. {
  5351. $this->whlabel->remove($vv['id']);
  5352. }
  5353. }
  5354. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  5355. }
  5356. $this->_Template('whlabel_error',$this->data);
  5357. }
  5358. public function _errorexcel()
  5359. {
  5360. $post = $this->input->post(NULL, TRUE);
  5361. if(isset($_GET['page']))
  5362. {
  5363. $page = $this->input->get('page',true);
  5364. $perpage = $this->input->get('perpage',true);
  5365. $sku = $this->input->get('sku',true);
  5366. $warehouse = $this->input->get('warehouse',true);
  5367. $ktime = $this->input->get('ktime',true);
  5368. $jtime = $this->input->get('jtime',true);
  5369. $ktime = strtotime($ktime);
  5370. $jtime = strtotime($jtime);
  5371. $where = "sku != 'Preset'";
  5372. $gj = '';
  5373. if($sku)
  5374. {
  5375. $where .= " and sku like '%$sku%'";
  5376. }
  5377. else
  5378. {
  5379. if($ktime && $jtime)
  5380. {
  5381. $gj = " and time > '$ktime' and time < '$jtime'";
  5382. }
  5383. }
  5384. if($warehouse)
  5385. {
  5386. $where .= " and warehouse = '$warehouse'";
  5387. }
  5388. //数据排序
  5389. $order_str = "id desc";
  5390. if(empty($page))
  5391. {
  5392. $start = 0;
  5393. $perpage = 1;
  5394. }
  5395. else
  5396. {
  5397. $start = ($page - 1)*$perpage;
  5398. }
  5399. //取得信息列表
  5400. $rows = array();$list = array();
  5401. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5402. foreach ($info_list as $value)
  5403. {
  5404. $warehouse = $this->warehouse->read($value['warehouse']);
  5405. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5406. $number = $value['number'];$ftime = time()-15*24*3600;
  5407. if($c < 1)
  5408. {
  5409. $list[] = array('warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5410. }
  5411. }
  5412. $title = "0库存汇总";
  5413. $titlename = "<table border=1>
  5414. <tr align='center'>
  5415. <td>仓库</td>
  5416. <td>SKU</td>
  5417. <td>产品</td>
  5418. <td>当前库存</td>
  5419. </tr>
  5420. </table>";
  5421. $filename = $title.".xls";
  5422. $tail = "";
  5423. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5424. }
  5425. }
  5426. /**
  5427. *
  5428. *
  5429. * 占单
  5430. *
  5431. *
  5432. **/
  5433. public function _kcyz()
  5434. {
  5435. $post = $this->input->post(NULL, TRUE);
  5436. if(isset($post['warehouse']))
  5437. {
  5438. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请更新浏览器缓存!','success'=>false)));exit;//不再使用
  5439. $warehouse = $this->input->post('warehouse',true);
  5440. $whlabel = $this->input->post('whlabel',true);
  5441. $id = $this->input->post('id',true);
  5442. $shop = $this->input->post('shop',true);
  5443. $number = $this->input->post('number',true);
  5444. if(!$whlabel || $whlabel == '|')
  5445. {
  5446. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  5447. }
  5448. $pp = explode('|',trim($whlabel,'|'));
  5449. $x = 0;$save = array();
  5450. foreach ($pp as $va)
  5451. {
  5452. $num = explode('-',$va);
  5453. if($number)
  5454. {
  5455. $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 = '')");//通用
  5456. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  5457. }
  5458. else
  5459. {
  5460. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  5461. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  5462. }
  5463. $x++;
  5464. if(count($whlabel)+count($shopwhlabel) < $num[1])
  5465. {
  5466. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  5467. }
  5468. }
  5469. if(isset($save[0]))
  5470. {
  5471. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
  5472. }
  5473. else
  5474. {
  5475. echo json_encode(array('success'=>true));exit;
  5476. }
  5477. }
  5478. }
  5479. public function _db()
  5480. {
  5481. $post = $this->input->post(NULL, TRUE);
  5482. if(isset($post['page']))
  5483. {
  5484. $page = $this->input->post('page',true);
  5485. $perpage = $this->input->post('perpage',true);
  5486. $sku = $this->input->post('sku',true);
  5487. $number = $this->input->post('number',true);
  5488. $warehouse = $this->input->post('warehouse',true);
  5489. $purchase = $this->input->post('purchase',true);
  5490. $orderinfo = $this->input->post('orderinfo',true);
  5491. $waybill = $this->input->post('waybill',true);
  5492. $category = $this->input->post('category',true);
  5493. $size = $this->input->post('size',true);
  5494. $grade = $this->input->post('grade',true);
  5495. $color = $this->input->post('color',true);
  5496. $lowe = $this->input->post('lowe',true);
  5497. $state = $this->input->post('state',true);
  5498. $label = $this->input->post('label',true);
  5499. $timetk = $this->input->post('timetkk',true);
  5500. $timetj = $this->input->post('timetjj',true);
  5501. $timetk = strtotime($timetk);
  5502. $timetj = strtotime($timetj);
  5503. $where = "dbtime > 0";
  5504. if($timetk && $timetj)
  5505. {
  5506. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5507. }
  5508. if($sku)
  5509. {
  5510. $where .= " and sku = '$sku'";
  5511. }
  5512. if($warehouse)
  5513. {
  5514. $where .= " and warehouse = '$warehouse'";
  5515. if($warehouse == 12)
  5516. {
  5517. $w = 'specialstock';
  5518. }
  5519. else
  5520. {
  5521. $w = 'whlabel';
  5522. }
  5523. }
  5524. if($purchase)
  5525. {
  5526. $where .= " and purchase = '$purchase'";
  5527. }
  5528. if($category)
  5529. {
  5530. $where .= " and features like '%-$category-%'";
  5531. }
  5532. if($size)
  5533. {
  5534. $where .= " and features like '%-$size-%'";
  5535. }
  5536. if($grade)
  5537. {
  5538. $where .= " and features like '%-$grade-%'";
  5539. }
  5540. if($color)
  5541. {
  5542. $where .= " and features like '%-$color-%'";
  5543. }
  5544. if($lowe)
  5545. {
  5546. $where .= " and features like '%-$lowe-%'";
  5547. }
  5548. if($state != '')
  5549. {
  5550. $where .= " and state = '$state'";
  5551. }
  5552. //数据排序
  5553. $order_str = "dbtime desc";
  5554. if(empty($page))
  5555. {
  5556. $start = 0;
  5557. $perpage = 1;
  5558. }
  5559. else
  5560. {
  5561. $start = ($page - 1)*$perpage;
  5562. }
  5563. //取得信息列表
  5564. $info_list = $this->$w->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5565. foreach ($info_list as $key=>$value)
  5566. {
  5567. $warehouse = $this->$w->read($value['warehouse']);
  5568. $info_list[$key]['warehouse'] = $warehouse['title'];
  5569. $purchase = $this->purchase->read($value['purchase']);
  5570. $info_list[$key]['purchase'] = $purchase['title'];
  5571. if($value['enter'] != 0)
  5572. {
  5573. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5574. }
  5575. else
  5576. {
  5577. $info_list[$key]['enter'] = "";
  5578. }
  5579. if($value['dbtime'] != 0)
  5580. {
  5581. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5582. }
  5583. else
  5584. {
  5585. $info_list[$key]['dbtime'] = "";
  5586. }
  5587. if($value['state'] == 0)
  5588. {
  5589. $info_list[$key]['state'] = "在库";
  5590. }
  5591. else if($value['state'] == 1)
  5592. {
  5593. $info_list[$key]['state'] = "出库";
  5594. }
  5595. else if($value['state'] == 2)
  5596. {
  5597. $info_list[$key]['state'] = "退库";
  5598. }
  5599. else if($value['state'] == 3)
  5600. {
  5601. $info_list[$key]['state'] = "调拨中";
  5602. }
  5603. else if($value['state'] == 4)
  5604. {
  5605. $info_list[$key]['state'] = "再加工";
  5606. }
  5607. else if($value['state'] == 5)
  5608. {
  5609. $info_list[$key]['state'] = "维修中";
  5610. }
  5611. else if($value['state'] == 6)
  5612. {
  5613. $info_list[$key]['state'] = "盘亏";
  5614. }
  5615. else if($value['state'] == 7)
  5616. {
  5617. $info_list[$key]['state'] = "更换标签";
  5618. }
  5619. else if($value['state'] == 8)
  5620. {
  5621. $info_list[$key]['state'] = "其它";
  5622. }
  5623. else if($value['state'] == 9)
  5624. {
  5625. $info_list[$key]['state'] = "预设";
  5626. }
  5627. }
  5628. $total = $this->whlabel->find_count($where);
  5629. $pagenum = ceil($total/$perpage);
  5630. $over = $total-($start+$perpage);
  5631. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5632. echo json_encode($rows);exit;
  5633. }
  5634. if(isset($post['outsku']))
  5635. {
  5636. $time = time();
  5637. $cz = $this->input->post('cz',true);
  5638. $label = $this->input->post('outsku',true);
  5639. $sl = $this->input->post('sl',true);
  5640. $num = $this->input->post('num',true);
  5641. //$warehouse = $this->input->post('warehouse',true);
  5642. if(!$sl)
  5643. {
  5644. $sl = 1;
  5645. }
  5646. if(!$warehouse)
  5647. {
  5648. echo json_encode(array('msg'=>'请选择调拨到的仓库','success'=>false));exit;
  5649. }
  5650. $dblabel = $this->whlabellabel->get_label($label);
  5651. if($dblabel)
  5652. {
  5653. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '0' and zd = ''");
  5654. if(count($data) < 1)
  5655. {
  5656. echo json_encode(array('msg'=>'没有此产品数据!','success'=>false));exit;
  5657. }
  5658. if(count($data) < $num)
  5659. {
  5660. echo json_encode(array('msg'=>'库存数量少于调拨数量!','success'=>false));exit;
  5661. }
  5662. for($i=0;$i<$sl;$i++)
  5663. {
  5664. $this->whlabel->save(array('state'=>3,'dbtime'=>$dbtime,'dbcontent'=>$data[$i]['warehouse'].'-'.$time.'|','time'=>$time),$data[$i]['id']);
  5665. }
  5666. echo json_encode(array('success'=>true));exit;
  5667. }
  5668. else
  5669. {
  5670. echo json_encode(array('msg'=>'未找到此条码产品!','success'=>false));exit;
  5671. }
  5672. }
  5673. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5674. $this->_Template('whlabel_db',$this->data);
  5675. }
  5676. public function _dbrk()
  5677. {
  5678. $post = $this->input->post(NULL, TRUE);
  5679. if(isset($post['page']))
  5680. {
  5681. $page = $this->input->post('page',true);
  5682. $perpage = $this->input->post('perpage',true);
  5683. $sku = $this->input->post('sku',true);
  5684. $number = $this->input->post('number',true);
  5685. $warehouse = $this->input->post('warehouse',true);
  5686. $purchase = $this->input->post('purchase',true);
  5687. $orderinfo = $this->input->post('orderinfo',true);
  5688. $waybill = $this->input->post('waybill',true);
  5689. $category = $this->input->post('category',true);
  5690. $size = $this->input->post('size',true);
  5691. $grade = $this->input->post('grade',true);
  5692. $color = $this->input->post('color',true);
  5693. $lowe = $this->input->post('lowe',true);
  5694. $state = $this->input->post('state',true);
  5695. $label = $this->input->post('label',true);
  5696. $ctime = $this->input->post('ctime',true);
  5697. $timetk = $this->input->post('timetkk',true);
  5698. $timetj = $this->input->post('timetjj',true);
  5699. $timetk = strtotime($timetk);
  5700. $timetj = strtotime($timetj);
  5701. $where = "dbtime > 0";
  5702. if($timetk && $timetj)
  5703. {
  5704. $where .= " and ".$ctime." > '$timetk' and ".$ctime." < '$timetj'";
  5705. }
  5706. if($sku)
  5707. {
  5708. $where .= " and sku = '$sku'";
  5709. }
  5710. if($warehouse)
  5711. {
  5712. $where .= " and warehouse = '$warehouse'";
  5713. }
  5714. if($purchase)
  5715. {
  5716. $where .= " and purchase = '$purchase'";
  5717. }
  5718. if($category)
  5719. {
  5720. $where .= " and features like '%-$category-%'";
  5721. }
  5722. if($size)
  5723. {
  5724. $where .= " and features like '%-$size-%'";
  5725. }
  5726. if($grade)
  5727. {
  5728. $where .= " and features like '%-$grade-%'";
  5729. }
  5730. if($color)
  5731. {
  5732. $where .= " and features like '%-$color-%'";
  5733. }
  5734. if($lowe)
  5735. {
  5736. $where .= " and features like '%-$lowe-%'";
  5737. }
  5738. if($state != '')
  5739. {
  5740. $where .= " and state = '$state'";
  5741. }
  5742. //数据排序
  5743. $order_str = "dbtime desc";
  5744. if(empty($page))
  5745. {
  5746. $start = 0;
  5747. $perpage = 1;
  5748. }
  5749. else
  5750. {
  5751. $start = ($page - 1)*$perpage;
  5752. }
  5753. //取得信息列表
  5754. $info_list = $this->whlabel->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5755. foreach ($info_list as $key=>$value)
  5756. {
  5757. $warehouse = $this->warehouse->read($value['warehouse']);
  5758. $info_list[$key]['warehouse'] = $warehouse['title'];
  5759. $purchase = $this->purchase->read($value['purchase']);
  5760. $info_list[$key]['purchase'] = $purchase['title'];
  5761. if($value['enter'] != 0)
  5762. {
  5763. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5764. }
  5765. else
  5766. {
  5767. $info_list[$key]['enter'] = "";
  5768. }
  5769. if($value['dbtime'] != 0)
  5770. {
  5771. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5772. }
  5773. else
  5774. {
  5775. $info_list[$key]['dbtime'] = "";
  5776. }
  5777. if($value['state'] == 0)
  5778. {
  5779. $info_list[$key]['state'] = "在库";
  5780. }
  5781. else if($value['state'] == 1)
  5782. {
  5783. $info_list[$key]['state'] = "出库";
  5784. }
  5785. else if($value['state'] == 2)
  5786. {
  5787. $info_list[$key]['state'] = "退库";
  5788. }
  5789. else if($value['state'] == 3)
  5790. {
  5791. $info_list[$key]['state'] = "调拨中";
  5792. }
  5793. else if($value['state'] == 4)
  5794. {
  5795. $info_list[$key]['state'] = "再加工";
  5796. }
  5797. else if($value['state'] == 5)
  5798. {
  5799. $info_list[$key]['state'] = "维修中";
  5800. }
  5801. else if($value['state'] == 6)
  5802. {
  5803. $info_list[$key]['state'] = "盘亏";
  5804. }
  5805. else if($value['state'] == 7)
  5806. {
  5807. $info_list[$key]['state'] = "更换标签";
  5808. }
  5809. else if($value['state'] == 8)
  5810. {
  5811. $info_list[$key]['state'] = "其它";
  5812. }
  5813. else if($value['state'] == 9)
  5814. {
  5815. $info_list[$key]['state'] = "预设";
  5816. }
  5817. }
  5818. $total = $this->whlabel->find_count($where);
  5819. $pagenum = ceil($total/$perpage);
  5820. $over = $total-($start+$perpage);
  5821. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5822. echo json_encode($rows);exit;
  5823. }
  5824. if(isset($post['rsku']))
  5825. {
  5826. $cz = $this->input->post('cz',true);
  5827. $label = $this->input->post('rsku',true);
  5828. $sl = $this->input->post('sl',true);
  5829. $warehouse = $this->input->post('warehouse',true);
  5830. if(!$sl)
  5831. {
  5832. $sl = 1;
  5833. }
  5834. if(!$warehouse)
  5835. {
  5836. echo json_encode(array('msg'=>'请选择入库仓库','success'=>false));exit;
  5837. }
  5838. $dblabel = $this->whlabellabel->get_label($label);
  5839. if($dblabel)
  5840. {
  5841. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '3' and zd = ''");
  5842. if(count($data) < 1)
  5843. {
  5844. echo json_encode(array('msg'=>'没有此SKU调拨数据!','success'=>false));exit;
  5845. }
  5846. if($sl > count($data))
  5847. {
  5848. echo json_encode(array('msg'=>'入库数量大于调拨数量!','success'=>false));exit;
  5849. }
  5850. $time = time();
  5851. for($i=0;$i<$sl;$i++)
  5852. {
  5853. $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']);
  5854. }
  5855. echo json_encode(array('success'=>true));exit;
  5856. }
  5857. else
  5858. {
  5859. echo json_encode(array('msg'=>'没有此条码的库存信息!','success'=>false));exit;
  5860. }
  5861. }
  5862. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5863. $this->_Template('whlabel_dbrk',$this->data);
  5864. }
  5865. public function _whlabelczdc()
  5866. {
  5867. if(isset($_GET['excel']))
  5868. {
  5869. //数据排序
  5870. $order_str = "id desc";
  5871. if(empty($page))
  5872. {
  5873. $start = 0;
  5874. $perpage = 1;
  5875. }
  5876. else
  5877. {
  5878. $start = ($page - 1)*$perpage;
  5879. }
  5880. $state = $this->input->get('state',true);
  5881. $sku = $this->input->get('sku',true);
  5882. $ctime = $this->input->get('ctime',true);
  5883. $category = $this->input->get('category',true);
  5884. $size = $this->input->get('size',true);
  5885. $grade = $this->input->get('grade',true);
  5886. $color = $this->input->get('color',true);
  5887. $lowe = $this->input->get('lowe',true);
  5888. $timetk = $this->input->get('timetkk',true);
  5889. $timetj = $this->input->get('timetjj',true);
  5890. $timetk = strtotime($timetk);
  5891. $timetj = strtotime($timetj);
  5892. $where = "dbtime > 0";
  5893. if($timetk && $timetj)
  5894. {
  5895. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5896. }
  5897. if($category)
  5898. {
  5899. $where .= " and features like '%-$category-%'";
  5900. }
  5901. if($size)
  5902. {
  5903. $where .= " and features like '%-$size-%'";
  5904. }
  5905. if($grade)
  5906. {
  5907. $where .= " and features like '%-$grade-%'";
  5908. }
  5909. if($color)
  5910. {
  5911. $where .= " and features like '%-$color-%'";
  5912. }
  5913. if($lowe)
  5914. {
  5915. $where .= " and features like '%-$lowe-%'";
  5916. }
  5917. //取得信息列表
  5918. $info_list = $this->whlabel->find_all($where,'*');
  5919. $rows = array();$list = array();
  5920. foreach ($info_list as $key=>$value)
  5921. {
  5922. $rows[$value['sku']] = $value;//所有数据sku
  5923. }
  5924. foreach ($rows as $value)
  5925. {
  5926. $warehouse = $this->warehouse->read($value['warehouse']);
  5927. $db = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'"');
  5928. $rk = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and enter > 0');
  5929. if($value['orderinfo'] == 0)
  5930. {
  5931. $info_list[$key]['orderinfo'] = "";
  5932. }
  5933. if($value['waybill'] == 0)
  5934. {
  5935. $info_list[$key]['waybill'] = "";
  5936. }
  5937. if($value['state'] == 0)
  5938. {
  5939. $value['state'] = "在库";
  5940. }
  5941. else if($value['state'] == 3)
  5942. {
  5943. $value['state'] = "调拨中";
  5944. }
  5945. $list[] = array($value['sku'],$value['title'],$db,$rk);
  5946. }
  5947. $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj)."统计表";
  5948. $titlename = "<table border=1>
  5949. <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
  5950. <tr align='center'>
  5951. <td>SKU</td>
  5952. <td>产品</td>
  5953. <td>调拨数量</td>
  5954. <td>入库数量</td>
  5955. </tr>
  5956. </table>";
  5957. $filename = $title.".xls";
  5958. $tail = "";
  5959. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5960. }
  5961. }
  5962. public function _print($arg_array)
  5963. {
  5964. if(isset($_SESSION['api']))
  5965. {
  5966. $user = $this->user->get_api($_SESSION['api']);
  5967. $usp = $user;
  5968. $fgshop = "";$sid = "";$wid="";$wtype="";
  5969. $usersp = explode('|',trim($user['shop'],'|'));
  5970. $userwh = explode('|',trim($user['warehouse'],'|'));
  5971. foreach ($usersp as $value)
  5972. {
  5973. $fgshop .= " shop = ".$value." or";
  5974. $sid .= " id = ".$value." or";
  5975. }
  5976. foreach ($userwh as $value)
  5977. {
  5978. $wid .= " id = ".$value." or";
  5979. $wtype .= " type = ".$value." or";
  5980. }
  5981. }
  5982. $post = $this->input->post(NULL, TRUE);
  5983. if(isset($post['tmsku']))
  5984. {
  5985. $tmsku = $this->input->post('tmsku',true);
  5986. if(is_numeric($tmsku))
  5987. {
  5988. $yyh = $this->whlabellabel->get_label($tmsku);
  5989. }
  5990. else
  5991. {
  5992. $yyh = $this->whlabellabel->get_sku($tmsku);
  5993. }
  5994. if($yyh)
  5995. {
  5996. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  5997. }
  5998. else
  5999. {
  6000. echo json_encode(array('success'=>false));exit;
  6001. }
  6002. }
  6003. $classid = $this->classid->sku();
  6004. $pm = $classid;
  6005. $scsku = $classid;
  6006. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6007. if(isset($post['warehouse']))
  6008. {
  6009. if($post['warehouse'])
  6010. {
  6011. $list = array();$num = "";$title = "";$features = "";
  6012. $order = 0;
  6013. $post['shop'] = '';
  6014. $brand = $this->input->post('brand',true);
  6015. if($brand != '0,')
  6016. {
  6017. $b = $this->brand->read(rtrim($brand,','));
  6018. if($b)
  6019. {
  6020. $post['shop'] = str_replace('|',',',$b['shop']);
  6021. }
  6022. }
  6023. $post['details'] = $this->input->post('details',true);//打印数量
  6024. $xbqnum = $this->input->post('xbqnum',true);
  6025. $post['purchase'] = $this->input->post('purchase',true);
  6026. $post['warehouse'] = $this->input->post('warehouse',true);
  6027. $post['purchase'] = $this->input->post('purchase',true);
  6028. $post['retreatwarehouse'] = $post['warehouse'];
  6029. $post['cpbz'] = $this->input->post('cpbz',true);
  6030. $post['state'] = 9;
  6031. $category = $this->input->post('category',true);
  6032. $list['category'] = $category;
  6033. $list['hairtype'] = $this->input->post('hairtype',true);
  6034. $list['grade'] = $this->input->post('grade',true);
  6035. $size = $this->input->post('size',true);
  6036. $list['size'] = rtrim($size,',');
  6037. $list['hairnumber'] = $this->input->post('hairnumber',true);
  6038. $list['extension'] = $this->input->post('extension',true);
  6039. if($category == 1297)
  6040. {
  6041. $list['sywignumber'] = $this->input->post('sywignumber',true);
  6042. }
  6043. if($category == 1702)
  6044. {
  6045. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  6046. $list['syother'] = $this->input->post('syother',true);
  6047. }
  6048. if($category == 133)
  6049. {
  6050. $list['fittype'] = $this->input->post('fittype',true);
  6051. $list['acother'] = $this->input->post('acother',true);
  6052. }
  6053. $list['color'] = $this->input->post('color',true);
  6054. $list['lowe'] = $this->input->post('lowe',true);
  6055. if($category == 127)
  6056. {
  6057. $list['type'] = $this->input->post('type',true);
  6058. $list['headroad'] = $this->input->post('headroad',true);
  6059. $list['density'] = $this->input->post('density',true);
  6060. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  6061. {
  6062. $list['lacesize'] = $this->input->post('lacesize',true);
  6063. }
  6064. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6065. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6066. }
  6067. if($category == 128)
  6068. {
  6069. $list['lacetype'] = $this->input->post('lacetype',true);
  6070. $list['haircap'] = $this->input->post('haircap',true);
  6071. $list['density'] = $this->input->post('density',true);
  6072. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6073. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6074. $list['wigother'] = $this->input->post('wigother',true);
  6075. $list['wigother2'] = $this->input->post('wigother2',true);
  6076. }
  6077. if($category == 129)
  6078. {
  6079. $list['wide'] = $this->input->post('wide',true);
  6080. }
  6081. if($category == 131)
  6082. {
  6083. $list['gifttype'] = $this->input->post('gifttype',true);
  6084. $list['giftother'] = $this->input->post('giftother',true);
  6085. }
  6086. if($category == 134)
  6087. {
  6088. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6089. }
  6090. if($category == 1297)
  6091. {
  6092. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6093. $list['sywigother'] = $this->input->post('sywigother',true);
  6094. }
  6095. if($category == 130 || $category == 133 || $category == 1702)
  6096. {
  6097. $list['items'] = $this->input->post('items',true);
  6098. $list['weight'] = $this->input->post('weight',true);
  6099. }
  6100. if($category == 1702)
  6101. {
  6102. $list['syhairther'] = $this->input->post('syhairther',true);
  6103. }
  6104. foreach($list as $k=>$v)
  6105. {
  6106. if($v != 0)
  6107. {
  6108. $num .=$v;
  6109. $features .=$v.'-';
  6110. $post[$k] = $v;
  6111. $typeclass = $this->typeclass->read($v);
  6112. if(isset($pm[$typeclass['classid']]))
  6113. {
  6114. if(stripos($typeclass['zh'],'|') !== false)
  6115. {
  6116. $exzh = explode('|',$typeclass['zh']);
  6117. $pm[$typeclass['classid']] = $exzh[0];
  6118. }
  6119. else
  6120. {
  6121. $pm[$typeclass['classid']] = $typeclass['zh'];
  6122. }
  6123. }
  6124. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6125. if($k != 'size')
  6126. {
  6127. $title .= $typeclass['title']." ";
  6128. }
  6129. }
  6130. }
  6131. $typeclass = $this->typeclass->read($list['size']);
  6132. $title .= $typeclass['title'];
  6133. $time = time();
  6134. $post['title'] = rtrim($title,' ');
  6135. $post['number'] = $num;
  6136. $post['features'] = '-'.$features;
  6137. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6138. $featurespp = explode('-',trim($featurespp,'-'));
  6139. if(isset($featurespp[5]))
  6140. {
  6141. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6142. }
  6143. else
  6144. {
  6145. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6146. }
  6147. $post['enter'] = $time;
  6148. $post['time'] = $time;//操作时间
  6149. $scsku = implode("-",$scsku);
  6150. $zh = implode(" ",$pm);
  6151. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6152. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6153. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6154. $post['sku'] = $bqsku;
  6155. $label = time().rand(0,9);
  6156. $post['label'] = $label;
  6157. $cpid = $this->whlabellabel->find_count();
  6158. $post['cpid'] = $cpid+1;
  6159. $cpid = $post['cpid'];
  6160. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6161. //if($whlabelbarcode)
  6162. //{
  6163. //$post['label'] = $whlabelbarcode['label'];
  6164. //if(!$this->whlabellabel->insert($post))
  6165. //{
  6166. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6167. //}
  6168. //}
  6169. //else
  6170. //{
  6171. $this->db->trans_begin();
  6172. $this->whlabellabel->insert($post);
  6173. //$this->whlabelbarcode->insert($post);
  6174. if ($this->db->trans_status() === TRUE)
  6175. {
  6176. $this->db->trans_commit();
  6177. }
  6178. else
  6179. {
  6180. $this->db->trans_rollback();
  6181. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6182. }
  6183. //}
  6184. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6185. $purchase = $this->purchase->read($post['purchase']);
  6186. 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));exit;//特殊仓目前不需要仓库选项
  6187. }
  6188. }
  6189. if(isset($_SESSION['api']))
  6190. {
  6191. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6192. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6193. $this->data['wlshop'] = $wlshop;
  6194. $this->data['warehouse'] = $warehouse;
  6195. }
  6196. $whlabelwz = $this->whlabelwz->find_all();
  6197. $this->data['whlabelwz'] = $whlabelwz;
  6198. $this->_Template('whlabel_print',$this->data);
  6199. }
  6200. public function _usaprint($arg_array)
  6201. {
  6202. if(isset($_SESSION['api']))
  6203. {
  6204. $user = $this->user->get_api($_SESSION['api']);
  6205. $usp = $user;
  6206. $fgshop = "";$sid = "";$wid="";$wtype="";
  6207. $usersp = explode('|',trim($user['shop'],'|'));
  6208. $userwh = explode('|',trim($user['warehouse'],'|'));
  6209. foreach ($usersp as $value)
  6210. {
  6211. $fgshop .= " shop = ".$value." or";
  6212. $sid .= " id = ".$value." or";
  6213. }
  6214. foreach ($userwh as $value)
  6215. {
  6216. $wid .= " id = ".$value." or";
  6217. $wtype .= " type = ".$value." or";
  6218. }
  6219. }
  6220. $post = $this->input->post(NULL, TRUE);
  6221. if(isset($post['tmsku']))
  6222. {
  6223. $tmsku = $this->input->post('tmsku',true);
  6224. if(is_numeric($tmsku))
  6225. {
  6226. $yyh = $this->whlabellabel->get_label($tmsku);
  6227. }
  6228. else
  6229. {
  6230. $yyh = $this->whlabellabel->get_sku($tmsku);
  6231. }
  6232. if($yyh)
  6233. {
  6234. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  6235. }
  6236. else
  6237. {
  6238. echo json_encode(array('success'=>false));exit;
  6239. }
  6240. }
  6241. $classid = $this->classid->sku();
  6242. $pm = $classid;
  6243. $scsku = $classid;
  6244. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6245. if(isset($post['warehouse']))
  6246. {
  6247. if($post['warehouse'])
  6248. {
  6249. $list = array();$num = "";$title = "";$features = "";
  6250. $order = 0;
  6251. $post['shop'] = '';
  6252. $brand = $this->input->post('brand',true);
  6253. if($brand != '0,')
  6254. {
  6255. $b = $this->brand->read(rtrim($brand,','));
  6256. if($b)
  6257. {
  6258. $post['shop'] = str_replace('|',',',$b['shop']);
  6259. }
  6260. }
  6261. $post['details'] = $this->input->post('details',true);//打印数量
  6262. $xbqnum = $this->input->post('xbqnum',true);
  6263. $post['purchase'] = $this->input->post('purchase',true);
  6264. $post['warehouse'] = $this->input->post('warehouse',true);
  6265. $post['purchase'] = $this->input->post('purchase',true);
  6266. $post['retreatwarehouse'] = $post['warehouse'];
  6267. $post['cpbz'] = $this->input->post('cpbz',true);
  6268. $post['state'] = 9;
  6269. $category = $this->input->post('category',true);
  6270. $list['category'] = $category;
  6271. $list['hairtype'] = $this->input->post('hairtype',true);
  6272. $list['grade'] = $this->input->post('grade',true);
  6273. $size = $this->input->post('size',true);
  6274. $list['size'] = rtrim($size,',');
  6275. $list['hairnumber'] = $this->input->post('hairnumber',true);
  6276. $list['extension'] = $this->input->post('extension',true);
  6277. if($category == 1297)
  6278. {
  6279. $list['sywignumber'] = $this->input->post('sywignumber',true);
  6280. }
  6281. if($category == 1702)
  6282. {
  6283. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  6284. $list['syother'] = $this->input->post('syother',true);
  6285. }
  6286. if($category == 133)
  6287. {
  6288. $list['fittype'] = $this->input->post('fittype',true);
  6289. $list['acother'] = $this->input->post('acother',true);
  6290. }
  6291. $list['color'] = $this->input->post('color',true);
  6292. $list['lowe'] = $this->input->post('lowe',true);
  6293. if($category == 127)
  6294. {
  6295. $list['type'] = $this->input->post('type',true);
  6296. $list['headroad'] = $this->input->post('headroad',true);
  6297. $list['density'] = $this->input->post('density',true);
  6298. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  6299. {
  6300. $list['lacesize'] = $this->input->post('lacesize',true);
  6301. }
  6302. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6303. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6304. }
  6305. if($category == 128)
  6306. {
  6307. $list['lacetype'] = $this->input->post('lacetype',true);
  6308. $list['haircap'] = $this->input->post('haircap',true);
  6309. $list['density'] = $this->input->post('density',true);
  6310. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6311. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6312. $list['wigother'] = $this->input->post('wigother',true);
  6313. $list['wigother2'] = $this->input->post('wigother2',true);
  6314. }
  6315. if($category == 129)
  6316. {
  6317. $list['wide'] = $this->input->post('wide',true);
  6318. }
  6319. if($category == 131)
  6320. {
  6321. $list['gifttype'] = $this->input->post('gifttype',true);
  6322. $list['giftother'] = $this->input->post('giftother',true);
  6323. }
  6324. if($category == 134)
  6325. {
  6326. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6327. }
  6328. if($category == 1297)
  6329. {
  6330. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6331. $list['sywigother'] = $this->input->post('sywigother',true);
  6332. }
  6333. if($category == 130 || $category == 133 || $category == 1702)
  6334. {
  6335. $list['items'] = $this->input->post('items',true);
  6336. $list['weight'] = $this->input->post('weight',true);
  6337. }
  6338. if($category == 1702)
  6339. {
  6340. $list['syhairther'] = $this->input->post('syhairther',true);
  6341. }
  6342. foreach($list as $k=>$v)
  6343. {
  6344. if($v != 0)
  6345. {
  6346. $num .=$v;
  6347. $features .=$v.'-';
  6348. $post[$k] = $v;
  6349. $typeclass = $this->typeclass->read($v);
  6350. if(isset($pm[$typeclass['classid']]))
  6351. {
  6352. if(stripos($typeclass['zh'],'|') !== false)
  6353. {
  6354. $exzh = explode('|',$typeclass['zh']);
  6355. $pm[$typeclass['classid']] = $exzh[0];
  6356. }
  6357. else
  6358. {
  6359. $pm[$typeclass['classid']] = $typeclass['zh'];
  6360. }
  6361. }
  6362. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6363. if($k != 'size')
  6364. {
  6365. $title .= $typeclass['title']." ";
  6366. }
  6367. }
  6368. }
  6369. $typeclass = $this->typeclass->read($list['size']);
  6370. $title .= $typeclass['title'];
  6371. $time = time();
  6372. $post['title'] = rtrim($title,' ');
  6373. $post['number'] = $num;
  6374. $post['features'] = '-'.$features;
  6375. $fp = $this->whlabel->get_features($post['features']);
  6376. if(!$fp)
  6377. {
  6378. echo json_encode(array('msg'=>'美仓无此产品,需要添加后才可打印','success'=>false));exit;
  6379. }
  6380. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6381. $featurespp = explode('-',trim($featurespp,'-'));
  6382. if(isset($featurespp[5]))
  6383. {
  6384. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6385. }
  6386. else
  6387. {
  6388. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6389. }
  6390. $post['enter'] = $time;
  6391. $post['time'] = $time;//操作时间
  6392. $scsku = implode("-",$scsku);
  6393. $zh = implode(" ",$pm);
  6394. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6395. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6396. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6397. $post['sku'] = $fp['sku'];
  6398. $post['label'] = $fp['sku'];
  6399. $cpid = $this->whlabellabel->find_count();
  6400. $post['cpid'] = $cpid+1;
  6401. $cpid = $post['cpid'];
  6402. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6403. //if($whlabelbarcode)
  6404. //{
  6405. //$post['label'] = $whlabelbarcode['label'];
  6406. //if(!$this->whlabellabel->insert($post))
  6407. //{
  6408. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6409. //}
  6410. //}
  6411. //else
  6412. //{
  6413. $this->db->trans_begin();
  6414. $this->whlabellabel->insert($post);
  6415. //$this->whlabelbarcode->insert($post);
  6416. if ($this->db->trans_status() === TRUE)
  6417. {
  6418. $this->db->trans_commit();
  6419. }
  6420. else
  6421. {
  6422. $this->db->trans_rollback();
  6423. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6424. }
  6425. //}
  6426. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6427. $purchase = $this->purchase->read($post['purchase']);
  6428. 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));exit;//特殊仓目前不需要仓库选项
  6429. }
  6430. }
  6431. if(isset($_SESSION['api']))
  6432. {
  6433. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6434. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6435. $this->data['wlshop'] = $wlshop;
  6436. $this->data['warehouse'] = $warehouse;
  6437. }
  6438. $whlabelwz = $this->whlabelwz->find_all();
  6439. $this->data['whlabelwz'] = $whlabelwz;
  6440. $this->_Template('whlabel_usaprint',$this->data);
  6441. }
  6442. public function _printrk($arg_array)
  6443. {
  6444. $prc = array();
  6445. $purchase = $this->purchase->find_all();
  6446. foreach($purchase as $k=>$v)
  6447. {
  6448. $prc[$v['id']] = $v['title'];
  6449. }
  6450. $post = $this->input->post(NULL, TRUE);
  6451. if(isset($post['page']))
  6452. {
  6453. $page = $this->input->post('page',true);
  6454. $perpage = $this->input->post('perpage',true);
  6455. $sku = $this->input->post('sku',true);
  6456. $bs = $this->input->post('bs',true);
  6457. $number = $this->input->post('number',true);
  6458. $warehouse = $this->input->post('warehouse',true);
  6459. $purchase = $this->input->post('purchase',true);
  6460. $orderinfo = $this->input->post('orderinfo',true);
  6461. $waybill = $this->input->post('waybill',true);
  6462. $category = $this->input->post('category',true);
  6463. $size = $this->input->post('size',true);
  6464. $grade = $this->input->post('grade',true);
  6465. $color = $this->input->post('color',true);
  6466. $lowe = $this->input->post('lowe',true);
  6467. $state = $this->input->post('state',true);
  6468. $label = $this->input->post('label',true);
  6469. $timetk = $this->input->post('ktime',true);
  6470. $timetj = $this->input->post('jtime',true);
  6471. $timetk = strtotime($timetk);
  6472. $timetj = strtotime($timetj);
  6473. $where = "1=1 ";
  6474. if($timetk && $timetj)
  6475. {
  6476. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6477. }
  6478. if($sku)
  6479. {
  6480. $where .= " and sku = '$sku'";
  6481. }
  6482. if($bs != '')
  6483. {
  6484. $where .= " and bs = '$bs'";
  6485. }
  6486. if($number)
  6487. {
  6488. $where .= " and number = '$number'";
  6489. }
  6490. if($warehouse)
  6491. {
  6492. $where .= " and warehouse = '$warehouse'";
  6493. }
  6494. if($purchase)
  6495. {
  6496. $where .= " and purchase = '$purchase'";
  6497. }
  6498. if($orderinfo)
  6499. {
  6500. $where .= " and orderinfo = '$orderinfo'";
  6501. }
  6502. if($waybill)
  6503. {
  6504. $where .= " and waybill = '$waybill'";
  6505. }
  6506. if($category)
  6507. {
  6508. $where .= " and features like '%-$category-%'";
  6509. }
  6510. if($size)
  6511. {
  6512. $where .= " and features like '%-$size-%'";
  6513. }
  6514. if($grade)
  6515. {
  6516. $where .= " and features like '%-$grade-%'";
  6517. }
  6518. if($color)
  6519. {
  6520. $where .= " and features like '%-$color-%'";
  6521. }
  6522. if($lowe)
  6523. {
  6524. $where .= " and features like '%-$lowe-%'";
  6525. }
  6526. if($label)
  6527. {
  6528. $where .= " and label = '$label'";
  6529. }
  6530. if($state || $state == 0)
  6531. {
  6532. $where .= " and state = '$state'";
  6533. }
  6534. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6535. //数据排序
  6536. $order_str = "enter desc";
  6537. if(empty($page))
  6538. {
  6539. $start = 0;
  6540. $perpage = 1;
  6541. }
  6542. else
  6543. {
  6544. $start = ($page - 1)*$perpage;
  6545. }
  6546. //取得信息列表
  6547. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,enter,details',$order_str,$start,$perpage);
  6548. foreach ($info_list as $key=>$value)
  6549. {
  6550. $warehouse = $this->warehouse->read($value['warehouse']);
  6551. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6552. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6553. if($value['state'] == 0)
  6554. {
  6555. $info_list[$key]['state'] = "在库";
  6556. }
  6557. else if($value['state'] == 1)
  6558. {
  6559. $info_list[$key]['state'] = "出库";
  6560. }
  6561. else if($value['state'] == 2)
  6562. {
  6563. $info_list[$key]['state'] = "退库";
  6564. }
  6565. else if($value['state'] == 3)
  6566. {
  6567. $info_list[$key]['state'] = "调拨中";
  6568. }
  6569. else if($value['state'] == 4)
  6570. {
  6571. $info_list[$key]['state'] = "再加工";
  6572. }
  6573. else if($value['state'] == 5)
  6574. {
  6575. $info_list[$key]['state'] = "维修中";
  6576. }
  6577. else if($value['state'] == 6)
  6578. {
  6579. $info_list[$key]['state'] = "盘亏";
  6580. }
  6581. else if($value['state'] == 7)
  6582. {
  6583. $info_list[$key]['state'] = "更换标签";
  6584. }
  6585. else if($value['state'] == 8)
  6586. {
  6587. $info_list[$key]['state'] = "其它";
  6588. }
  6589. else if($value['state'] == 9)
  6590. {
  6591. $info_list[$key]['state'] = "预设";
  6592. }
  6593. else if($value['state'] == 10)
  6594. {
  6595. $info_list[$key]['state'] = "美店零售";
  6596. }
  6597. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  6598. }
  6599. $total = $this->$ck->find_count($where);
  6600. $pagenum = ceil($total/$perpage);
  6601. $over = $total-($start+$perpage);
  6602. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6603. echo json_encode($rows);exit;
  6604. }
  6605. if(isset($post['tmsku']))
  6606. {
  6607. $time = time();
  6608. $tmsku = $this->input->post('tmsku',true);
  6609. //$post['shop'] = $this->input->post('shop',true);
  6610. $num = $this->input->post('num',true);
  6611. $rktype = $this->input->post('rktype',true);
  6612. if($num > 200)
  6613. {
  6614. echo json_encode(array('msg'=>'入库数量不允许超过200!','c'=>0,'success'=>false));exit;
  6615. }
  6616. if(!$rktype)
  6617. {
  6618. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6619. }
  6620. $rk = $this->whlabellabel->find_all("label = '$tmsku'","*","id desc");
  6621. /**
  6622. $wz = array();
  6623. foreach ($rk as $key=>$value)
  6624. {
  6625. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6626. }
  6627. if(count($wz) > 1)
  6628. {
  6629. $wz = array_values($wz);
  6630. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6631. }
  6632. **/
  6633. if(isset($rk[0]['purchase']))
  6634. {
  6635. $rk = $rk[0];
  6636. $j = 0;
  6637. $post['purchase'] = $rk['purchase'];
  6638. $post['warehouse'] = $rk['warehouse'];
  6639. $post['retreatwarehouse'] = $rk['warehouse'];
  6640. $post['sku'] = $rk['sku'];
  6641. $post['number'] = $rk['number'];
  6642. $post['features'] = $rk['features'];
  6643. $post['title'] = $rk['title'];
  6644. $post['enter'] = $time;
  6645. $post['time'] = $time;
  6646. $post['bs'] = 1;
  6647. $post['shop'] = $rk['shop'];
  6648. $post['details'] = $rk['details'];
  6649. $post['cpid'] = $rk['cpid'];
  6650. $post['cpbz'] = $rk['cpbz'];
  6651. //$post['rktype'] = $rktype;
  6652. $warehouse = $this->warehouse->read($rk['warehouse']);
  6653. if($warehouse['bdck'] == '')
  6654. {
  6655. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','c'=>0,'success'=>false));exit;
  6656. }
  6657. else
  6658. {
  6659. $bdck = $warehouse['bdck'];
  6660. }
  6661. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'],$post['sku']);
  6662. if(isset($pdwz['details']))
  6663. {
  6664. if($pdwz['details'] != $post['details'])
  6665. {
  6666. echo json_encode(array('msg'=>'此产品位置应为:'.$pdwz['details'],'c'=>0,'cs'=>$pdwz['details'].' - '.$post['details'],'success'=>false));exit;
  6667. }
  6668. }
  6669. $post['featurespp'] = $rk['featurespp'];
  6670. if($post['warehouse'] == '5')
  6671. {
  6672. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6673. if($yza)
  6674. {
  6675. if($post['features'] != $yza[0]['features'])
  6676. {
  6677. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'c'=>0,'success'=>false));exit;
  6678. }
  6679. }
  6680. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6681. if($yzb)
  6682. {
  6683. if($post['sku'] != $yzb[0]['sku'])
  6684. {
  6685. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','c'=>0,'success'=>false));exit;
  6686. }
  6687. }
  6688. }
  6689. for($i=0;$i<$num;$i++)
  6690. {
  6691. $post['label'] = time().rand(100,999).$i;
  6692. if($this->$bdck->insert($post))
  6693. {
  6694. $j++;
  6695. }
  6696. }
  6697. /**
  6698. if($post['warehouse'] != 12)
  6699. {
  6700. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6701. }
  6702. **/
  6703. if($j == $num)
  6704. {
  6705. echo json_encode(array('msg'=>'入库成功!','success'=>true));exit;
  6706. }
  6707. else
  6708. {
  6709. echo json_encode(array('msg'=>'未成功入库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6710. }
  6711. }
  6712. else
  6713. {
  6714. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6715. }
  6716. }
  6717. $this->_Template('whlabel_printrk',$this->data);
  6718. }
  6719. public function _printxzrk($arg_array)
  6720. {
  6721. $post = $this->input->post(NULL, TRUE);
  6722. if(isset($post['wzid']))
  6723. {
  6724. $time = time();
  6725. $id = $this->input->post('wzid',true);
  6726. //$post['shop'] = $this->input->post('shop',true);
  6727. $num = 1;
  6728. $rk = $this->whlabellabel->read($id);
  6729. if(isset($rk['purchase']))
  6730. {
  6731. $x = 0;
  6732. $post['purchase'] = $rk['purchase'];
  6733. $post['warehouse'] = $rk['warehouse'];
  6734. $post['retreatwarehouse'] = $rk['warehouse'];
  6735. $post['sku'] = $rk['sku'];
  6736. $post['number'] = $rk['number'];
  6737. $post['features'] = $rk['features'];
  6738. $post['title'] = $rk['title'];
  6739. $post['enter'] = $time;
  6740. $post['time'] = $time;
  6741. $post['bs'] = 1;
  6742. $post['shop'] = $rk['shop'];
  6743. $post['details'] = $rk['details'];
  6744. $post['cpid'] = $rk['cpid'];
  6745. $post['cpbz'] = $rk['cpbz'];
  6746. $warehouse = $this->warehouse->read($rk['warehouse']);
  6747. if($warehouse['bdck'] == '')
  6748. {
  6749. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','success'=>false));exit;
  6750. }
  6751. else
  6752. {
  6753. $bdck = $warehouse['bdck'];
  6754. }
  6755. $post['featurespp'] = $rk['featurespp'];
  6756. $this->db->trans_begin();
  6757. for($i=0;$i<$num;$i++)
  6758. {
  6759. $post['label'] = time().rand(100,999).$i;
  6760. $this->$bdck->insert($post);
  6761. }
  6762. /**
  6763. if($post['warehouse'] != 12)
  6764. {
  6765. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6766. }
  6767. **/
  6768. if ($this->db->trans_status() === TRUE)
  6769. {
  6770. $this->db->trans_commit();
  6771. echo json_encode(array('msg'=>'入库成功!','cs'=>$post,'cs2'=>$warehouse,'success'=>true));exit;
  6772. }
  6773. else
  6774. {
  6775. $this->db->trans_rollback();
  6776. echo json_encode(array('msg'=>'入库失败,请重试','c'=>0,'success'=>false));exit;
  6777. }
  6778. }
  6779. else
  6780. {
  6781. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6782. }
  6783. }
  6784. }
  6785. public function _printck($arg_array)
  6786. {
  6787. $prc = array();
  6788. $purchase = $this->purchase->find_all();
  6789. foreach($purchase as $k=>$v)
  6790. {
  6791. $prc[$v['id']] = $v['title'];
  6792. }
  6793. $post = $this->input->post(NULL, TRUE);
  6794. if(isset($post['page']))
  6795. {
  6796. $page = $this->input->post('page',true);
  6797. $perpage = $this->input->post('perpage',true);
  6798. $sku = $this->input->post('sku',true);
  6799. $bs = $this->input->post('bs',true);
  6800. $number = $this->input->post('number',true);
  6801. $warehouse = $this->input->post('warehouse',true);
  6802. $purchase = $this->input->post('purchase',true);
  6803. $orderinfo = $this->input->post('orderinfo',true);
  6804. $waybill = $this->input->post('waybill',true);
  6805. $category = $this->input->post('category',true);
  6806. $size = $this->input->post('size',true);
  6807. $grade = $this->input->post('grade',true);
  6808. $color = $this->input->post('color',true);
  6809. $lowe = $this->input->post('lowe',true);
  6810. $state = $this->input->post('state',true);
  6811. $label = $this->input->post('label',true);
  6812. $timetk = $this->input->post('ktime',true);
  6813. $timetj = $this->input->post('jtime',true);
  6814. $timetk = strtotime($timetk);
  6815. $timetj = strtotime($timetj);
  6816. $where = "state=1 ";
  6817. if($timetk && $timetj)
  6818. {
  6819. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6820. }
  6821. if($sku)
  6822. {
  6823. $where .= " and sku = '$sku'";
  6824. }
  6825. if($bs != '')
  6826. {
  6827. $where .= " and bs = '$bs'";
  6828. }
  6829. if($number)
  6830. {
  6831. $where .= " and number = '$number'";
  6832. }
  6833. if($warehouse)
  6834. {
  6835. $where .= " and warehouse = '$warehouse'";
  6836. }
  6837. if($purchase)
  6838. {
  6839. $where .= " and purchase = '$purchase'";
  6840. }
  6841. if($orderinfo)
  6842. {
  6843. $where .= " and orderinfo = '$orderinfo'";
  6844. }
  6845. if($waybill)
  6846. {
  6847. $where .= " and waybill = '$waybill'";
  6848. }
  6849. if($category)
  6850. {
  6851. $where .= " and features like '%-$category-%'";
  6852. }
  6853. if($size)
  6854. {
  6855. $where .= " and features like '%-$size-%'";
  6856. }
  6857. if($grade)
  6858. {
  6859. $where .= " and features like '%-$grade-%'";
  6860. }
  6861. if($color)
  6862. {
  6863. $where .= " and features like '%-$color-%'";
  6864. }
  6865. if($lowe)
  6866. {
  6867. $where .= " and features like '%-$lowe-%'";
  6868. }
  6869. if($label)
  6870. {
  6871. $where .= " and label = '$label'";
  6872. }
  6873. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6874. //数据排序
  6875. $order_str = "outk desc";
  6876. if(empty($page))
  6877. {
  6878. $start = 0;
  6879. $perpage = 1;
  6880. }
  6881. else
  6882. {
  6883. $start = ($page - 1)*$perpage;
  6884. }
  6885. //取得信息列表
  6886. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,outk,details',$order_str,$start,$perpage);
  6887. foreach ($info_list as $key=>$value)
  6888. {
  6889. $warehouse = $this->warehouse->read($value['warehouse']);
  6890. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6891. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6892. if($value['state'] == 0)
  6893. {
  6894. $info_list[$key]['state'] = "在库";
  6895. }
  6896. else if($value['state'] == 1)
  6897. {
  6898. $info_list[$key]['state'] = "出库";
  6899. }
  6900. else if($value['state'] == 2)
  6901. {
  6902. $info_list[$key]['state'] = "退库";
  6903. }
  6904. else if($value['state'] == 3)
  6905. {
  6906. $info_list[$key]['state'] = "调拨中";
  6907. }
  6908. else if($value['state'] == 4)
  6909. {
  6910. $info_list[$key]['state'] = "再加工";
  6911. }
  6912. else if($value['state'] == 5)
  6913. {
  6914. $info_list[$key]['state'] = "维修中";
  6915. }
  6916. else if($value['state'] == 6)
  6917. {
  6918. $info_list[$key]['state'] = "盘亏";
  6919. }
  6920. else if($value['state'] == 7)
  6921. {
  6922. $info_list[$key]['state'] = "更换标签";
  6923. }
  6924. else if($value['state'] == 8)
  6925. {
  6926. $info_list[$key]['state'] = "其它";
  6927. }
  6928. else if($value['state'] == 9)
  6929. {
  6930. $info_list[$key]['state'] = "预设";
  6931. }
  6932. else if($value['state'] == 10)
  6933. {
  6934. $info_list[$key]['state'] = "美店零售";
  6935. }
  6936. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  6937. }
  6938. $total = $this->$ck->find_count($where);
  6939. $pagenum = ceil($total/$perpage);
  6940. $over = $total-($start+$perpage);
  6941. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6942. echo json_encode($rows);exit;
  6943. }
  6944. if(isset($post['tmsku']))
  6945. {
  6946. $time = time();
  6947. $tmsku = $this->input->post('tmsku',true);
  6948. //$post['shop'] = $this->input->post('shop',true);
  6949. $num = $this->input->post('num',true);
  6950. $cktype = $this->input->post('cktype',true);
  6951. $label = $this->whlabellabel->get_label($tmsku);
  6952. if(!$cktype)
  6953. {
  6954. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6955. }
  6956. if(!isset($label['warehouse']))
  6957. {
  6958. echo json_encode(array('msg'=>'没有此条码信息!','success'=>false));exit;
  6959. }
  6960. $xzck = ($label['warehouse'] == '12')?'specialstock':'whlabel';
  6961. if(stripos($label['features'],'-126-') !== false)
  6962. {
  6963. $ck = $this->$xzck->find_all("state = '0' and shop = '".$label['shop']."' and number = '".$label['number']."' and warehouse = '".$label['warehouse']."' and zd = ''");
  6964. }
  6965. else
  6966. {
  6967. $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 = ''");
  6968. }
  6969. $j = 0;
  6970. if(count($ck) >= $num)
  6971. {
  6972. for($i=0;$i<$num;$i++)
  6973. {
  6974. if($this->$xzck->save(array('state'=>1,'outk'=>$time,'time'=>$time),$ck[$i]['id']))//,'cktype'=>$cktype
  6975. {
  6976. $j++;
  6977. }
  6978. }
  6979. if($j == $num)
  6980. {
  6981. echo json_encode(array('msg'=>'出库成功!','success'=>true));exit;
  6982. }
  6983. else
  6984. {
  6985. echo json_encode(array('msg'=>'未成功出库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6986. }
  6987. }
  6988. else
  6989. {
  6990. echo json_encode(array('msg'=>'没有足够的库存!','cs'=>$label['sku'].' - '.$label['purchase'],'success'=>false));exit;
  6991. }
  6992. }
  6993. $this->_Template('whlabel_printck',$this->data);
  6994. }
  6995. public function _printexcel()
  6996. {
  6997. $dir = '/data/excel/'.date('Ymd',time()).'/';
  6998. $config['upload_path'] = '.'.$dir ;
  6999. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7000. $config['allowed_types'] = 'xls|xlsx|csv';
  7001. $config['max_size'] = 10240;
  7002. $this->load->library('upload', $config);
  7003. $this->upload->initialize($config);
  7004. if ($this->upload->do_upload('userfile'))
  7005. {
  7006. $full_path = $dir.$this->upload->data('file_name');
  7007. $fileName = '.' . $full_path;
  7008. if (!file_exists($fileName))
  7009. {
  7010. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7011. }
  7012. else
  7013. {
  7014. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7015. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7016. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7017. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7018. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7019. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7020. ++$column;//如果列数大于26行
  7021. $list = array();
  7022. for ($i = 2; $i <= $row; $i++) // 行数循环
  7023. {
  7024. $data = array();
  7025. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7026. {
  7027. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7028. }
  7029. $list[] = $data;
  7030. }
  7031. }
  7032. $ed = array();$i = 0;$j = 0;$dcdata = array();$yc = '';
  7033. $cmf_arr = array_column($list, '1');
  7034. array_multisort($cmf_arr, SORT_ASC, $list);
  7035. foreach ($list as $key=>$value)
  7036. {
  7037. $typeclass = $this->typeclass->get_bqsku($value['1'],$value['2']);
  7038. if($typeclass)
  7039. {
  7040. $this->typeclass->save(array('bqsku'=>$value['3']),$typeclass['id']);
  7041. }
  7042. else
  7043. {
  7044. $ed[] = array($value['1'].'-系统未找到此订单信息');
  7045. $i++;
  7046. continue;
  7047. }
  7048. }
  7049. if($i > 0)
  7050. {
  7051. $yc = $i.'条异常';
  7052. }
  7053. echo json_encode(array('msg'=>'操作成功 '.$yc,'yc'=>$ed,'success'=>true));exit;
  7054. }
  7055. }
  7056. public function _uck()
  7057. {
  7058. if(isset($_GET['excel']))
  7059. {
  7060. $tc = array();
  7061. $typeclass = $this->typeclass->find_all();
  7062. foreach ($typeclass as $v)
  7063. {
  7064. $tc[$v['id']] = $v['zh'];
  7065. }
  7066. $data = array();$t = array();$rq = '';
  7067. $ts = strtotime(date("Y-m-d",time()))-strtotime(date("Y-m",time()));
  7068. $ts = $ts/(24*3600);
  7069. for($i=0;$i<$ts;$i++)
  7070. {
  7071. $t[] = date("Y-m-d",strtotime('-'.($ts-$i).' day'));
  7072. $rq .= "<td>".date("Y-m-d",strtotime('-'.($ts-$i).' day'))."</td>";
  7073. }
  7074. $info_list = $this->whlabel->find_pc("warehouse = '5'",'sku','warehouse,sku,features');
  7075. foreach ($info_list as $k=>$v)
  7076. {
  7077. $features = explode('-',trim($v['features'],'-'));
  7078. if(!isset($features[3]) || !isset($features[4]))
  7079. {
  7080. continue;
  7081. }
  7082. $data[$k][0] = $tc[$features[0]];//类型
  7083. $data[$k][1] = ($features[3] != 57)?$tc[$features[3]]:'';//颜色,自然色不显示
  7084. $data[$k][2] = $tc[$features[4]];//曲度
  7085. $data[$k][3] = '';
  7086. if(isset($data[$k][1]))
  7087. {
  7088. $data[$k][3] .= $data[$k][1];
  7089. }
  7090. if(isset($data[$k][2]))
  7091. {
  7092. $data[$k][3] .= $data[$k][2];
  7093. }
  7094. if(isset($features[5]))
  7095. {
  7096. $data[$k][3] .= $tc[$features[5]];
  7097. }
  7098. if(isset($features[2]))
  7099. {
  7100. $data[$k][3] .= $tc[$features[2]];
  7101. }
  7102. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7103. $data[$k][4] = $v['sku'];
  7104. $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())).'))');//月初库存
  7105. $data[$k][] = $this->whlabel->find_count('sku = "'.$v['sku'].'" and state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');//剩余库存
  7106. $zt = $this->whlabeltransport->find_all('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and cz = "0"');
  7107. $ztrq = '';$ztsl = '';
  7108. if(count($zt) > 0)
  7109. {
  7110. foreach ($zt as $vv)
  7111. {
  7112. $ztrq .= date('Y-m-d',$vv['stime']).'<br>';
  7113. $ztsl .= $vv['num'].'<br>';
  7114. }
  7115. }
  7116. $data[$k][] = trim($ztsl,'<br>');
  7117. $data[$k][] = trim($ztrq,'<br>');
  7118. $byck = 0;
  7119. foreach ($t as $vv)
  7120. {
  7121. $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));
  7122. $data[$k][] = ($sl > 0)?'<b>'.$sl.'</b>':'';
  7123. $byck += $sl;
  7124. }
  7125. $data[$k][] = ($byck > 0)?$byck:'';
  7126. }
  7127. $title = "详情 ".date("Y-m-d",time());
  7128. $titlename = "<table border=1>
  7129. <tr align='center'>
  7130. <td>类别</td>
  7131. <td>颜色</td>
  7132. <td>曲度</td>
  7133. <td>名称</td>
  7134. <td>SKU</td>
  7135. <td>月初库存</td>
  7136. <td>剩余库存</td>
  7137. <td>在途数量</td>
  7138. <td>预达日期</td>".
  7139. $rq
  7140. ."<td>本月出库</td></tr>
  7141. </table>";
  7142. $filename = $title.".xls";
  7143. $tail = "";
  7144. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  7145. }
  7146. }
  7147. public function _whlabelexcelzh()
  7148. {
  7149. if(isset($_GET['excel']))
  7150. {
  7151. $where = "sku != 'Preset'";
  7152. //数据排序
  7153. $order_str = "id desc";
  7154. if(empty($page))
  7155. {
  7156. $start = 0;
  7157. $perpage = 1;
  7158. }
  7159. else
  7160. {
  7161. $start = ($page - 1)*$perpage;
  7162. }
  7163. $category = $this->input->get('category',true);
  7164. $warehouse = $this->input->get('warehouse',true);
  7165. $excelid = $this->input->get('sid',true);
  7166. if($category)
  7167. {
  7168. $where .= " and features like '%-$category-%'";
  7169. }
  7170. if($warehouse)
  7171. {
  7172. $where .= " and warehouse = '$warehouse'";
  7173. }
  7174. $xzid = '';
  7175. if($excelid)
  7176. {
  7177. $excelid = explode(',',trim($excelid,','));
  7178. foreach ($excelid as $key=>$value)
  7179. {
  7180. $xzid .= " id = ".$value." or";
  7181. }
  7182. $xzid = " and (".rtrim($xzid,'or').")";;
  7183. }
  7184. //取得信息列表
  7185. /**
  7186. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7187. $rows = array();$list = array();
  7188. foreach ($info_list as $key=>$value)
  7189. {
  7190. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7191. }
  7192. **/
  7193. $list = array();
  7194. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,number,features');
  7195. foreach ($rows as $key=>$value)
  7196. {
  7197. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"');
  7198. $zh = '';
  7199. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and time = "0" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','num,stime');
  7200. foreach ($zt as $v)
  7201. {
  7202. $zh .= $v['num']." / ".date('Y-m-d',$v['stime'])."<br>";
  7203. }
  7204. $zt = array_sum(array_column($zt,'num'));
  7205. $number = $value['number'];
  7206. $ftime = time()-15*24*3600;
  7207. $warehouse = $this->warehouse->read($value['warehouse']);
  7208. $rows[$key]['warehouse'] = $warehouse['title'];
  7209. $rows[$key]['number'] = $c;
  7210. $rows[$key]['features'] = $zh;
  7211. $rows[$key]['hb'] = $c+$zt;
  7212. }
  7213. $title = "导出库存数据及在途中数据".date('Y-m-d',time());
  7214. $titlename = "<table border=1>
  7215. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7216. <tr align='center'>
  7217. <td>仓库</td>
  7218. <td>SKU</td>
  7219. <td>产品</td>
  7220. <td>库存数量</td>
  7221. <td>在途数量及预达日期</td>
  7222. <td>在途+库存数量</td>
  7223. </tr>
  7224. </table>";
  7225. $filename = $title.".xls";
  7226. $tail = "";
  7227. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7228. }
  7229. if(isset($_GET['excel']))
  7230. {
  7231. $warehouse = $this->input->get('warehouse',true);
  7232. $sku = $this->input->get('sku',true);
  7233. $cz = $this->input->get('cz',true);
  7234. $text = $this->input->post('text',true);
  7235. $xztime = $this->input->get('xztime',true);
  7236. $timetk = $this->input->get('timetk',true);
  7237. $timetj = $this->input->get('timetj',true);
  7238. $timetk = strtotime($timetk);
  7239. $timetj = strtotime($timetj);
  7240. $where = "time = '0' ";
  7241. if($warehouse)
  7242. {
  7243. $where .= " and warehouse = '$warehouse'";
  7244. }
  7245. if($sku)
  7246. {
  7247. $where .= " and sku = '$sku'";
  7248. }
  7249. if($text)
  7250. {
  7251. $where .= " and text like '%$text%'";
  7252. }
  7253. if($cz != '')
  7254. {
  7255. $where .= " and cz = '$cz'";
  7256. }
  7257. if($timetk && $timetj)
  7258. {
  7259. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  7260. }
  7261. //数据排序
  7262. $order_str = $xztime." desc";
  7263. //取得信息列表
  7264. $zh = array();
  7265. $info_list = $this->whlabeltransport->find_all($where,'warehouse,sku,title,num,features,enter,stime,text');
  7266. foreach ($info_list as $v)
  7267. {
  7268. $c = $this->whlabel->find_count('state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');
  7269. $warehouse = $this->warehouse->read($v['warehouse']);
  7270. $v['warehouse'] = $warehouse['title'];
  7271. $v['enter'] = date('Y-m-d H:i:s',$v['enter']);
  7272. $v['stime'] = date('Y-m-d',$v['stime']);
  7273. if(isset($zh[$v['features']]))
  7274. {
  7275. $zh[$v['features']]['num'] += $v['num'];
  7276. }
  7277. else
  7278. {
  7279. $zh[$v['features']] = $v;
  7280. }
  7281. $zh[$v['features']]['features'] = $c;
  7282. }
  7283. $title = "在途数据".date('Y-m-d',time());
  7284. $titlename = "<table border=1>
  7285. <tr align='center'>
  7286. <td>仓库</td>
  7287. <td>SKU</td>
  7288. <td>名称</td>
  7289. <td>在途数量</td>
  7290. <td>库存数量</td>
  7291. <td>添加在途日期</td>
  7292. <td>预达日期</td>
  7293. <td>备注</td>
  7294. </tr>
  7295. </table>";
  7296. $filename = $title.".xls";
  7297. $tail = "";
  7298. $this->excel->get_fz2($zh,$titlename,$filename,$tail);
  7299. }
  7300. }
  7301. public function _fc()
  7302. {
  7303. $vip = 0;
  7304. if(isset($_SESSION['api']))
  7305. {
  7306. $user = $this->user->get_api($_SESSION['api']);
  7307. if($user['vip'] == 1)
  7308. {
  7309. $vip = 1;
  7310. }
  7311. }
  7312. else
  7313. {
  7314. header('Location: /');exit;
  7315. }
  7316. $post = $this->input->post(NULL, TRUE);
  7317. if(isset($post['page']))
  7318. {
  7319. $page = $this->input->post('page',true);
  7320. $perpage = $this->input->post('perpage',true);
  7321. $category = $this->input->post('category',true);
  7322. $size = $this->input->post('size',true);
  7323. $grade = $this->input->post('grade',true);
  7324. $color = $this->input->post('color',true);
  7325. $lowe = $this->input->post('lowe',true);
  7326. $sku = $this->input->post('sku');
  7327. $title = $this->input->post('title');
  7328. $warehouse = $this->input->post('warehouse',true);
  7329. $usa = $this->input->post('usa',true);
  7330. $purchase = $this->input->post('purchase',true);
  7331. $lacetype = $this->input->post('lacetype',true);
  7332. $haircap = $this->input->post('haircap',true);
  7333. $density = $this->input->post('density',true);
  7334. $details = $this->input->post('details',true);
  7335. $state = $this->input->post('state',true);
  7336. $ktime = $this->input->post('ktime',true);
  7337. $jtime = $this->input->post('jtime',true);
  7338. $ktime = strtotime($ktime);
  7339. $jtime = strtotime($jtime);
  7340. $where = "state = '11'";$gj = "";$ck = "";
  7341. if($lacetype)
  7342. {
  7343. $where .= " and features like '%-$lacetype-%'";
  7344. }
  7345. if($category)
  7346. {
  7347. $where .= " and features like '%-$category-%'";
  7348. }
  7349. if($size)
  7350. {
  7351. $where .= " and features like '%-$size-%'";
  7352. }
  7353. if($grade)
  7354. {
  7355. $where .= " and features like '%-$grade-%'";
  7356. }
  7357. if($color)
  7358. {
  7359. $where .= " and features like '%-$color-%'";
  7360. }
  7361. if($lowe)
  7362. {
  7363. $where .= " and features like '%-$lowe-%'";
  7364. }
  7365. if($haircap)
  7366. {
  7367. $where .= " and features like '%-$haircap-%'";
  7368. }
  7369. if($density)
  7370. {
  7371. $where .= " and features like '%-$density-%'";
  7372. }
  7373. if($usa)
  7374. {
  7375. if(!$warehouse)
  7376. {
  7377. $where .= " and (warehouse = '5' or warehouse = '8')";
  7378. }
  7379. }
  7380. if($warehouse)
  7381. {
  7382. $where .= " and warehouse = '$warehouse'";
  7383. }
  7384. if($details)
  7385. {
  7386. $where .= " and details = '$details'";
  7387. }
  7388. if($purchase)
  7389. {
  7390. $where .= " and purchase = '$purchase'";
  7391. }
  7392. if($state)
  7393. {
  7394. $where .= " and state = '$state'";
  7395. }
  7396. if($ktime && $jtime)
  7397. {
  7398. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7399. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7400. }
  7401. //数据排序
  7402. $order_str = "id desc";
  7403. if(empty($page))
  7404. {
  7405. $start = 0;
  7406. $perpage = 1;
  7407. }
  7408. else
  7409. {
  7410. $start = ($page - 1)*$perpage;
  7411. }
  7412. if($sku)
  7413. {
  7414. $sku = trim($sku,' ');
  7415. $sku = trim($sku,' ');
  7416. $where .= " and sku like '%$sku%'";
  7417. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7418. }
  7419. else if($title)
  7420. {
  7421. $title = trim($title,' ');
  7422. $title = trim($title,' ');
  7423. $where .= " and title like '%$title%'";
  7424. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7425. }
  7426. else
  7427. {
  7428. //$where .= " and time > '$ktime' and time < '$jtime'";
  7429. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7430. }
  7431. //取得信息列表
  7432. $rows = array();$list = array();
  7433. foreach ($info_list as $key=>$value)
  7434. {
  7435. $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'].'"');
  7436. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7437. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7438. $warehouse = $this->warehouse->read($value['warehouse']);
  7439. $info_list[$key]['warehouse'] = $warehouse['title'];
  7440. $info_list[$key]['number'] = $g;
  7441. $info_list[$key]['features'] = $x;
  7442. $info_list[$key]['x'] = $s;
  7443. }
  7444. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  7445. $pagenum = ceil($total/$perpage);
  7446. $over = $total-($start+$perpage);
  7447. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  7448. echo json_encode($rows);exit;
  7449. }
  7450. $this->data['vip'] = $vip;
  7451. $this->_Template('whlabel_fc',$this->data);
  7452. }
  7453. public function _fcmb()
  7454. {
  7455. $where = "sku != 'Preset'";
  7456. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title');
  7457. foreach ($rows as $k=>$v)
  7458. {
  7459. $warehouse = $this->warehouse->read($v['warehouse']);
  7460. $rows[$k]['warehouse'] = $warehouse['title'];
  7461. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "'.$v['warehouse'].'" and sku = "'.$v['sku'].'" and state = 11');
  7462. $rows[$k]['t'] = '';
  7463. $rows[$k]['n'] = '';
  7464. }
  7465. $title = "封货产品数据导入模板";
  7466. $titlename = "<table border=1>
  7467. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7468. <tr align='center'>
  7469. <td>仓库</td>
  7470. <td>SKU</td>
  7471. <td>产品</td>
  7472. <td>封存产品总数量</td>
  7473. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7474. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7475. </tr>
  7476. </table>";
  7477. $filename = $title.".xls";
  7478. $tail = "";
  7479. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7480. }
  7481. public function _fcexcel()
  7482. {
  7483. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7484. $config['upload_path'] = '.'.$dir ;
  7485. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7486. $config['allowed_types'] = 'xls|xlsx|csv';
  7487. $config['max_size'] = 10240;
  7488. $this->load->library('upload', $config);
  7489. $this->upload->initialize($config);
  7490. if ($this->upload->do_upload('userfile'))
  7491. {
  7492. $full_path = $dir.$this->upload->data('file_name');
  7493. $fileName = '.' . $full_path;
  7494. if (!file_exists($fileName))
  7495. {
  7496. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7497. }
  7498. else
  7499. {
  7500. libxml_use_internal_errors(true);
  7501. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7502. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7503. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7504. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7505. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7506. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7507. ++$column;//如果列数大于26行
  7508. $list = array();
  7509. for ($i = 2; $i <= $row; $i++) // 行数循环
  7510. {
  7511. $data = array();
  7512. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7513. {
  7514. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7515. }
  7516. $list[] = $data;
  7517. }
  7518. }
  7519. $i = 0;$j = 0;$ed = array();
  7520. foreach ($list as $key=>$value)
  7521. {
  7522. $time = time();
  7523. if($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4']))
  7524. {
  7525. continue;
  7526. }
  7527. $warehouse = $this->warehouse->get_title($value['0']);
  7528. $sku = $value['1'];
  7529. $type = $value['4'];//调整方式0扣减1删除
  7530. $num = $value['5'];//调整数量
  7531. //$text = $value['4'];//扣减说明
  7532. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7533. if(!$d)//如果没有这个SKU
  7534. {
  7535. $ed[] = array($sku.'-库存中不存在此SKU');
  7536. $j++;
  7537. continue;
  7538. }
  7539. if(!isset($warehouse['id']))
  7540. {
  7541. $ed[] = array($sku.'-仓库名错误!');
  7542. $j++;
  7543. continue;
  7544. }
  7545. if($type == 1 || $type == 2)//扣减库存
  7546. {
  7547. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and state = 11');
  7548. if(count($data) < abs($num))
  7549. {
  7550. $ed[] = array($sku.'-数量大于封存产品剩余数量!');
  7551. $j++;
  7552. continue;
  7553. }
  7554. if($type == 1)//转入库存
  7555. {
  7556. for($i=0;$i<abs($num);$i++)
  7557. {
  7558. $this->whlabel->save(array('state'=>0,'oldstate'=>11,'time'=>$time),$data[$i]['id']);
  7559. }
  7560. }
  7561. else if($type == 2)//删除
  7562. {
  7563. for($i=0;$i<abs($num);$i++)
  7564. {
  7565. $this->whlabel->remove($data[$i]['id']);
  7566. }
  7567. }
  7568. }
  7569. else if($type == 0)//增加库存
  7570. {
  7571. $post['sku'] = $d['sku'];
  7572. $post['shop'] = '';
  7573. $post['warehouse'] = $warehouse['id'];
  7574. $post['purchase'] = $d['purchase'];
  7575. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7576. $post['state'] = 11;
  7577. $post['title'] = $d['title'];
  7578. $post['number'] = $d['number'];
  7579. $post['features'] = $d['features'];
  7580. $post['enter'] = $time;
  7581. $post['time'] = $time;//操作时间
  7582. for($i=0;$i<$num;$i++)
  7583. {
  7584. $post['label'] = time().rand(100,999).$i;
  7585. $this->whlabel->insert($post);
  7586. }
  7587. }
  7588. sleep(1);//防止入库时间一样,需要延迟1秒
  7589. }
  7590. if($j > 0)
  7591. {
  7592. $tt = date('Ymd',time());
  7593. $title = '库存导入错误信息-'.$tt;
  7594. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7595. $tail = "\n";
  7596. $filename = $title.".xls";
  7597. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7598. $dir = '/data/excel/'.$time.'/';
  7599. $file_name = 'error_'.$time.rand(1000,9999);
  7600. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7601. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7602. fwrite($myfile,$ecl);
  7603. fclose($myfile);
  7604. $error = $dir.$file_name.'.xls';
  7605. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7606. }
  7607. else
  7608. {
  7609. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7610. }
  7611. }
  7612. }
  7613. public function _fcjxc($arg_array)
  7614. {
  7615. if(isset($_GET['excel']))
  7616. {
  7617. $category = $this->input->get('category',true);
  7618. $size = $this->input->get('size',true);
  7619. $grade = $this->input->get('grade',true);
  7620. $color = $this->input->get('color',true);
  7621. $lowe = $this->input->get('lowe',true);
  7622. $sku = $this->input->get('sku');
  7623. $title = $this->input->get('title');
  7624. $warehouse = $arg_array[0];
  7625. $usa = $this->input->get('usa',true);
  7626. $purchase = $this->input->get('purchase',true);
  7627. $lacetype = $this->input->get('lacetype',true);
  7628. $haircap = $this->input->get('haircap',true);
  7629. $density = $this->input->get('density',true);
  7630. $title = $this->input->get('title',true);
  7631. $state = $this->input->get('state',true);
  7632. $ktime = $this->input->get('ktime',true);
  7633. $jtime = $this->input->get('jtime',true);
  7634. $where = "state=11";$gj = "";$ck = "";
  7635. if($lacetype)
  7636. {
  7637. $where .= " and features like '%-$lacetype-%'";
  7638. }
  7639. if($category)
  7640. {
  7641. $where .= " and features like '%-$category-%'";
  7642. }
  7643. if($size)
  7644. {
  7645. $where .= " and features like '%-$size-%'";
  7646. }
  7647. if($grade)
  7648. {
  7649. $where .= " and features like '%-$grade-%'";
  7650. }
  7651. if($color)
  7652. {
  7653. $where .= " and features like '%-$color-%'";
  7654. }
  7655. if($lowe)
  7656. {
  7657. $where .= " and features like '%-$lowe-%'";
  7658. }
  7659. if($haircap)
  7660. {
  7661. $where .= " and features like '%-$haircap-%'";
  7662. }
  7663. if($density)
  7664. {
  7665. $where .= " and features like '%-$density-%'";
  7666. }
  7667. if($usa)
  7668. {
  7669. if(!$warehouse)
  7670. {
  7671. $where .= " and (warehouse = '5' or warehouse = '8')";
  7672. }
  7673. }
  7674. if($warehouse)
  7675. {
  7676. $where .= " and warehouse = '$warehouse'";
  7677. }
  7678. if($purchase)
  7679. {
  7680. $where .= " and purchase = '$purchase'";
  7681. }
  7682. if($state)
  7683. {
  7684. $where .= " and state = '$state'";
  7685. }
  7686. $order_str = "id desc";
  7687. if($sku)
  7688. {
  7689. $sku = trim($sku,' ');
  7690. $sku = trim($sku,' ');
  7691. $where .= " and sku like '%$sku%'";
  7692. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7693. }
  7694. else if($title)
  7695. {
  7696. $title = trim($title,' ');
  7697. $title = trim($title,' ');
  7698. $where .= " and title like '%$title%'";
  7699. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7700. }
  7701. else
  7702. {
  7703. //$where .= " and time > '$ktime' and time < '$jtime'";
  7704. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7705. }
  7706. //取得信息列表
  7707. $rows = array();$list = array();
  7708. foreach ($info_list as $key=>$value)
  7709. {
  7710. $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'].'"');
  7711. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7712. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7713. $rows[$key] = $value;
  7714. $warehouse = $this->warehouse->read($value['warehouse']);
  7715. $rows[$key]['warehouse'] = $warehouse['title'];
  7716. $rows[$key]['features'] = $g;
  7717. $rows[$key]['a'] = $x;
  7718. $rows[$key]['b'] = $s;
  7719. }
  7720. $title = "总统计表";
  7721. $titlename = "<table border=1>
  7722. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7723. <tr align='center'>
  7724. <td>仓库</td>
  7725. <td>SKU</td>
  7726. <td>产品名称</td>
  7727. <td>录入总量</td>
  7728. <td>取出总量</td>
  7729. <td>剩余总量</td>
  7730. </tr>
  7731. </table>";
  7732. $filename = $title.".xls";
  7733. $tail = "";
  7734. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7735. }
  7736. $vip = 0;
  7737. if(isset($_SESSION['api']))
  7738. {
  7739. $user = $this->user->get_api($_SESSION['api']);
  7740. if($user['vip'] == 1)
  7741. {
  7742. $vip = 1;
  7743. }
  7744. }
  7745. else
  7746. {
  7747. header('Location: /');exit;
  7748. }
  7749. $post = $this->input->post(NULL, TRUE);
  7750. if(isset($post['page']))
  7751. {
  7752. $page = $this->input->post('page',true);
  7753. $perpage = $this->input->post('perpage',true);
  7754. $category = $this->input->post('category',true);
  7755. $size = $this->input->post('size',true);
  7756. $grade = $this->input->post('grade',true);
  7757. $color = $this->input->post('color',true);
  7758. $lowe = $this->input->post('lowe',true);
  7759. $sku = $this->input->post('sku');
  7760. $title = $this->input->post('title');
  7761. $warehouse = $arg_array[0];
  7762. $usa = $this->input->post('usa',true);
  7763. $purchase = $this->input->post('purchase',true);
  7764. $lacetype = $this->input->post('lacetype',true);
  7765. $haircap = $this->input->post('haircap',true);
  7766. $density = $this->input->post('density',true);
  7767. $title = $this->input->post('title',true);
  7768. $state = $this->input->post('state',true);
  7769. $ktime = $this->input->post('ktime',true);
  7770. $jtime = $this->input->post('jtime',true);
  7771. $ktime = strtotime($ktime);
  7772. $jtime = strtotime($jtime);
  7773. $where = "state=11";$gj = "";$ck = "";
  7774. if($lacetype)
  7775. {
  7776. $where .= " and features like '%-$lacetype-%'";
  7777. }
  7778. if($category)
  7779. {
  7780. $where .= " and features like '%-$category-%'";
  7781. }
  7782. if($size)
  7783. {
  7784. $where .= " and features like '%-$size-%'";
  7785. }
  7786. if($grade)
  7787. {
  7788. $where .= " and features like '%-$grade-%'";
  7789. }
  7790. if($color)
  7791. {
  7792. $where .= " and features like '%-$color-%'";
  7793. }
  7794. if($lowe)
  7795. {
  7796. $where .= " and features like '%-$lowe-%'";
  7797. }
  7798. if($haircap)
  7799. {
  7800. $where .= " and features like '%-$haircap-%'";
  7801. }
  7802. if($density)
  7803. {
  7804. $where .= " and features like '%-$density-%'";
  7805. }
  7806. if($usa)
  7807. {
  7808. if(!$warehouse)
  7809. {
  7810. $where .= " and (warehouse = '5' or warehouse = '8')";
  7811. }
  7812. }
  7813. if($warehouse)
  7814. {
  7815. $where .= " and warehouse = '$warehouse'";
  7816. }
  7817. if($purchase)
  7818. {
  7819. $where .= " and purchase = '$purchase'";
  7820. }
  7821. if($state)
  7822. {
  7823. $where .= " and state = '$state'";
  7824. }
  7825. if($ktime && $jtime)
  7826. {
  7827. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7828. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7829. }
  7830. //数据排序
  7831. $order_str = "id desc";$xs=0;
  7832. $rows = array();$list = array();
  7833. if(empty($page))
  7834. {
  7835. $start = 0;
  7836. $perpage = 1;
  7837. }
  7838. else
  7839. {
  7840. $start = ($page - 1)*$perpage;
  7841. }
  7842. if($sku || $title)
  7843. {
  7844. if($title)
  7845. {
  7846. $title = trim($title,' ');
  7847. $title = trim($title,' ');
  7848. $where .= " and title like '%$title%'";
  7849. }
  7850. else
  7851. {
  7852. $sku = trim($sku,' ');
  7853. $sku = trim($sku,' ');
  7854. $where .= " and sku like '%$sku%'";
  7855. }
  7856. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7857. foreach ($info_list as $key=>$value)
  7858. {
  7859. $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'].'"');
  7860. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7861. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7862. $rows[$key] = $value;
  7863. $warehouse = $this->warehouse->read($value['warehouse']);
  7864. $rows[$key]['warehouse'] = $warehouse['title'];
  7865. $rows[$key]['features'] = $g;
  7866. $rows[$key]['a'] = $x;
  7867. $rows[$key]['b'] = $s;
  7868. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7869. $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天销量
  7870. $yj = $c/($xl/30);
  7871. if($yj < 7)
  7872. {
  7873. $rows[$key]['y'] = round($yj).'天销量';
  7874. }
  7875. else
  7876. {
  7877. $rows[$key]['y'] = '正常';
  7878. }
  7879. }
  7880. }
  7881. else
  7882. {
  7883. //$where .= " and time > '$ktime' and time < '$jtime'";
  7884. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7885. foreach ($info_list as $key=>$value)
  7886. {
  7887. $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'].'"');
  7888. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7889. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7890. $zs[$key] = $value;
  7891. $warehouse = $this->warehouse->read($value['warehouse']);
  7892. $zs[$key]['warehouse'] = $warehouse['title'];
  7893. $zs[$key]['features'] = $g;
  7894. $zs[$key]['a'] = $x;
  7895. $zs[$key]['b'] = $s;
  7896. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7897. $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天销量
  7898. $yj = $c/($xl/30);
  7899. if($yj < 7)
  7900. {
  7901. $zs[$key]['y'] = round($yj).'天销量';
  7902. $rows[$key] = $zs[$key];
  7903. }
  7904. }
  7905. }
  7906. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id'));
  7907. $pagenum = ceil($total/$perpage);
  7908. $over = $total-($start+$perpage);
  7909. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
  7910. echo json_encode($rows);exit;
  7911. }
  7912. $this->data['arg_array'] = $arg_array[0];
  7913. $this->_Template('whlabel_fcjxc',$this->data);
  7914. }
  7915. public function _0kcdel()
  7916. {
  7917. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7918. $config['upload_path'] = '.'.$dir ;
  7919. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7920. $config['allowed_types'] = 'xls|xlsx|csv';
  7921. $config['max_size'] = 10240;
  7922. $this->load->library('upload', $config);
  7923. $this->upload->initialize($config);
  7924. if ($this->upload->do_upload('userfile'))
  7925. {
  7926. $full_path = $dir.$this->upload->data('file_name');
  7927. $fileName = '.' . $full_path;
  7928. if (!file_exists($fileName))
  7929. {
  7930. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7931. }
  7932. else
  7933. {
  7934. require_once "./data/excel/PHPExcel/IOFactory.php";
  7935. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7936. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7937. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7938. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7939. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7940. ++$column;//如果列数大于26行
  7941. $list = array();
  7942. for ($i = 2; $i <= $row; $i++) // 行数循环
  7943. {
  7944. $data = array();
  7945. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7946. {
  7947. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7948. }
  7949. $list[] = $data;
  7950. }
  7951. }
  7952. $i = 0;$j = 0;$ed = array();
  7953. foreach ($list as $key=>$value)
  7954. {
  7955. $time = time();
  7956. if($value['0'] == "" || $value['1'] == "")
  7957. {
  7958. continue;
  7959. }
  7960. $warehouse = $this->warehouse->get_title($value['0']);
  7961. $sku = $value['1'];
  7962. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7963. if(!$d)//如果没有这个SKU
  7964. {
  7965. $ed[] = array($sku.'-库存中不存在此SKU');
  7966. $j++;
  7967. continue;
  7968. }
  7969. if(!isset($warehouse['id']))
  7970. {
  7971. $ed[] = array($sku.'-仓库名错误!');
  7972. $j++;
  7973. continue;
  7974. }
  7975. $z = $this->whlabel->find_count('sku = "'.$sku.'" and zd = "" and state = 0 and warehouse = "'.$warehouse['id'].'"');
  7976. if($z < 1)
  7977. {
  7978. $z = $this->whlabel->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'"');
  7979. foreach ($z as $v)
  7980. {
  7981. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  7982. if(count($zt) > 0)
  7983. {
  7984. $ed[] = array($sku.'-有在途库存无法删除!');
  7985. $j++;
  7986. continue;
  7987. }
  7988. $this->whlabel->remove($v['id']);
  7989. }
  7990. }
  7991. else
  7992. {
  7993. $ed[] = array($sku.'-非0库存!');
  7994. $j++;
  7995. continue;
  7996. }
  7997. }
  7998. if($j > 0)
  7999. {
  8000. $tt = date('Ymd',time());
  8001. $title = '删除0库存错误信息-'.$tt;
  8002. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  8003. $tail = "\n";
  8004. $filename = $title.".xls";
  8005. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  8006. $dir = '/data/excel/'.$time.'/';
  8007. $file_name = 'error_'.$time.rand(1000,9999);
  8008. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  8009. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  8010. fwrite($myfile,$ecl);
  8011. fclose($myfile);
  8012. $error = $dir.$file_name.'.xls';
  8013. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  8014. }
  8015. else
  8016. {
  8017. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  8018. }
  8019. }
  8020. }
  8021. public function _gbhtype()
  8022. {
  8023. $post = $this->input->post(NULL, TRUE);
  8024. if(isset($post['s']))
  8025. {
  8026. $n = $this->input->post('n');
  8027. $d = $this->input->post('s');
  8028. if(!$d)
  8029. {
  8030. echo json_encode(array('msg'=>'未选择需要更改的商品','success'=>false));exit;
  8031. }
  8032. $d = explode(',',trim($d,','));
  8033. $t = $this->whlabel_type->read($n);
  8034. //循环删除记录
  8035. foreach ($d as $v)
  8036. {
  8037. $u = $this->whlabel->read($v);
  8038. $data = $this->whlabel->find_all("sku = '".$u['sku']."' and purchase = '".$u['purchase']."' and features = '".$u['features']."' and warehouse = '".$u['warehouse']."'");
  8039. foreach ($data as $val)
  8040. {
  8041. $this->whlabel->save(array('type'=>$n),$val['id']);
  8042. }
  8043. }
  8044. echo json_encode(array('d'=>$d,'t'=>$t['title'],'msg'=>'修改成功!','success'=>true));
  8045. }
  8046. }
  8047. //出库、退库导出
  8048. public function _dccrtype()
  8049. {
  8050. $classid = $this->classid->sku();
  8051. $pm = $classid;
  8052. $typeclass = array();
  8053. $tc = $this->typeclass->find_all();
  8054. foreach ($tc as $v)
  8055. {
  8056. $typeclass[$v['id']] = $v;
  8057. }
  8058. $prc = array();
  8059. $purchase = $this->purchase->find_all();
  8060. foreach($purchase as $k=>$v)
  8061. {
  8062. $prc[$v['id']] = $v['title'];
  8063. }
  8064. if(isset($_GET['sid']))
  8065. {
  8066. $wh = array();
  8067. $w = $this->warehouse->find_all('1=1','id,title');
  8068. foreach ($w as $v)
  8069. {
  8070. $wh[$v['id']] = $v['title'];
  8071. }
  8072. $type = $this->input->get('excel',true);
  8073. $category = $this->input->get('category',true);
  8074. $size = $this->input->get('size',true);
  8075. $grade = $this->input->get('grade',true);
  8076. $color = $this->input->get('color',true);
  8077. $lowe = $this->input->get('lowe',true);
  8078. $sku = $this->input->get('sku',true);
  8079. $warehouse = $this->input->get('warehouse',true);
  8080. $lacetype = $this->input->get('lacetype',true);
  8081. $lacecolor = $this->input->get('lacecolor',true);
  8082. $density = $this->input->get('density',true);
  8083. $haircap = $this->input->get('haircap',true);
  8084. $purchase = $this->input->get('purchase',true);
  8085. $title = $this->input->get('title',true);
  8086. $state = $this->input->get('state',true);
  8087. $sid = $this->input->get('sid',true);
  8088. $ktime = $this->input->get('ktime',true);
  8089. $jtime = $this->input->get('jtime',true);
  8090. $ktime = strtotime($ktime);
  8091. $jtime = strtotime($jtime);
  8092. $where = "1=1";$gj = "";$ck = "";
  8093. if($category)
  8094. {
  8095. $where .= " and features like '%-$category-%'";
  8096. }
  8097. if($size)
  8098. {
  8099. $where .= " and features like '%-$size-%'";
  8100. }
  8101. if($grade)
  8102. {
  8103. $where .= " and features like '%-$grade-%'";
  8104. }
  8105. if($color)
  8106. {
  8107. $where .= " and features like '%-$color-%'";
  8108. }
  8109. if($lowe)
  8110. {
  8111. $where .= " and features like '%-$lowe-%'";
  8112. }
  8113. if($warehouse)
  8114. {
  8115. $where .= " and warehouse = '$warehouse'";
  8116. }
  8117. if($purchase)
  8118. {
  8119. $where .= " and purchase = '$purchase'";
  8120. }
  8121. if($state)
  8122. {
  8123. $where .= " and state = '$state'";
  8124. }
  8125. if($lacetype)
  8126. {
  8127. $where .= " and features like '%-$lacetype-%'";
  8128. }
  8129. if($lacecolor)
  8130. {
  8131. $where .= " and features like '%-$lacecolor-%'";
  8132. }
  8133. if($density)
  8134. {
  8135. $where .= " and features like '%-$density-%'";
  8136. }
  8137. if($haircap)
  8138. {
  8139. $where .= " and features like '%-$haircap-%'";
  8140. }
  8141. if($title)
  8142. {
  8143. $title = trim($title,' ');
  8144. $title = trim($title,' ');
  8145. $where .= " and title like '%$title%'";
  8146. }
  8147. if($sku)
  8148. {
  8149. $sku = trim($sku,' ');
  8150. $sku = trim($sku,' ');
  8151. $where .= " and sku like '%$sku%'";
  8152. }
  8153. if($ktime && $jtime)
  8154. {
  8155. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8156. }
  8157. $sidwhere = '';
  8158. if($sid)
  8159. {
  8160. $sd = "";
  8161. $s = explode(',',trim($sid,','));
  8162. foreach ($s as $value)
  8163. {
  8164. $sd .= " id = ".$value." or";
  8165. }
  8166. $sidwhere = " and (".rtrim($sd,'or').")";
  8167. }
  8168. //数据排序
  8169. $order_str = "time desc";
  8170. if(empty($page))
  8171. {
  8172. $start = 0;
  8173. $perpage = 1;
  8174. }
  8175. else
  8176. {
  8177. $start = ($page - 1)*$perpage;
  8178. }
  8179. $wh = array();
  8180. $w = $this->warehouse->find_all('1=1','id,title');
  8181. foreach ($w as $v)
  8182. {
  8183. $wh[$v['id']] = $v['title'];
  8184. }
  8185. $wt = array();
  8186. $whlabel_type = $this->whlabel_type->find_all();
  8187. foreach ($whlabel_type as $v)
  8188. {
  8189. $wt[$v['id']] = $v['title'];
  8190. }
  8191. $classid = $this->classid->sku();
  8192. $list = array();
  8193. $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');
  8194. foreach ($rows_r as $key=>$value)
  8195. {
  8196. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8197. $pm = $classid;
  8198. $jm = $classid;
  8199. $rows_r[$key]['enter'] = '入库';
  8200. $rows_r[$key]['time'] = $value['enter'];
  8201. if($value['rktype'] == 1)
  8202. {
  8203. $rows_r[$key]['rktype'] = '采购入库';
  8204. }
  8205. else if($value['rktype'] == 2)
  8206. {
  8207. $rows_r[$key]['rktype'] = '盘盈调整';
  8208. }
  8209. else if($value['rktype'] == 3)
  8210. {
  8211. $rows_r[$key]['rktype'] = '其他调整入库';
  8212. }
  8213. else if($value['rktype'] == 4)
  8214. {
  8215. $rows_r[$key]['rktype'] = '其他调整入库';
  8216. }
  8217. else if($value['rktype'] == 5)
  8218. {
  8219. $rows_r[$key]['rktype'] = '退库入库';
  8220. }
  8221. else if($value['rktype'] == 6)
  8222. {
  8223. $rows_r[$key]['rktype'] = '退货可用入库';
  8224. }
  8225. else if($value['rktype'] == 7)
  8226. {
  8227. $rows_r[$key]['rktype'] = '形态转换入库';
  8228. }
  8229. else
  8230. {
  8231. $rows_r[$key]['rktype'] = '';
  8232. }
  8233. $features = explode('-',trim($value['features'],'-'));
  8234. foreach($features as $v)
  8235. {
  8236. if(isset($typeclass[$v]))
  8237. {
  8238. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8239. $pm[$typeclass[$v]['classid']] = $zh[0];
  8240. }
  8241. if(isset($typeclass[$v]))
  8242. {
  8243. if(isset($jm[$typeclass[$v]['classid']]))
  8244. {
  8245. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8246. }
  8247. }
  8248. }
  8249. $zh = implode(" ",$pm);
  8250. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8251. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8252. $rows_r[$key]['zh'] = $zh;
  8253. $jm = array_filter($jm);
  8254. $rows_r[$key]['features'] = implode("-",$jm);
  8255. $rows_r[$key]['number'] = $this->whlabel->find_count($where." and enter = '".$value['enter']."' ".$sidwhere);
  8256. }
  8257. $rows_c = $this->whlabel->find_all($where." and outk > '$ktime' and outk < '$jtime' ".$sidwhere,'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  8258. foreach ($rows_c as $key=>$value)
  8259. {
  8260. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8261. $pm = $classid;
  8262. $jm = $classid;
  8263. $rows_c[$key]['time'] = $value['outk'];
  8264. $rows_c[$key]['outk'] = '出库';
  8265. if($value['cktype'] == 1)
  8266. {
  8267. $rows_c[$key]['cktype'] = '销售出库';
  8268. }
  8269. else if($value['cktype'] == 2)
  8270. {
  8271. $rows_c[$key]['cktype'] = '销售美国出库';
  8272. }
  8273. else if($value['cktype'] == 3)
  8274. {
  8275. $rows_c[$key]['cktype'] = '盘亏调整';
  8276. }
  8277. else if($value['cktype'] == 4)
  8278. {
  8279. $rows_c[$key]['cktype'] = '其他调整出库';
  8280. }
  8281. else if($value['cktype'] == 5)
  8282. {
  8283. $rows_c[$key]['cktype'] = '形态转换出库';
  8284. }
  8285. else
  8286. {
  8287. $rows_c[$key]['cktype'] = '';
  8288. }
  8289. $features = explode('-',trim($value['features'],'-'));
  8290. foreach($features as $v)
  8291. {
  8292. if(isset($typeclass[$v]))
  8293. {
  8294. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8295. $pm[$typeclass[$v]['classid']] = $zh[0];
  8296. }
  8297. if(isset($typeclass[$v]))
  8298. {
  8299. if(isset($jm[$typeclass[$v]['classid']]))
  8300. {
  8301. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8302. }
  8303. }
  8304. }
  8305. $zh = implode(" ",$pm);
  8306. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8307. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8308. $rows_c[$key]['zh'] = $zh;
  8309. $jm = array_filter($jm);
  8310. $rows_c[$key]['features'] = implode("-",$jm);
  8311. $rows_c[$key]['number'] = 1;
  8312. }
  8313. $merged = $rows_r;
  8314. foreach ($rows_c as $key => $value)
  8315. {
  8316. if (isset($merged[$key]))
  8317. {
  8318. $merged[] = $value;
  8319. }
  8320. else
  8321. {
  8322. $merged[$key] = $value;
  8323. }
  8324. }
  8325. usort($merged, function($a, $b)
  8326. {
  8327. return $a['time'] - $b['time'];
  8328. });
  8329. foreach ($merged as $key=>$value)
  8330. {
  8331. $merged[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  8332. }
  8333. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime);
  8334. $titlename = "<table border=1>
  8335. <tr align='center'>
  8336. <td>仓库</td>
  8337. <td>SKU</td>
  8338. <td>商品名称</td>
  8339. <td>仓库品名</td>
  8340. <td>料号</td>
  8341. <td>时间</td>
  8342. <td>操作</td>
  8343. <td>类型</td>
  8344. <td>数量</td>
  8345. <td>备注</td>
  8346. </tr>
  8347. </table>";
  8348. $filename = $title.".xlsx";
  8349. $tail = "";
  8350. $this->excel->get_fz2($merged,$titlename,$filename,$tail);
  8351. }
  8352. }
  8353. }