Whlabel.php 267 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496
  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. if(empty($v['sku'])){
  3864. continue;
  3865. }
  3866. $final_list[] = [
  3867. "warehouse"=>$v["warehouse"],
  3868. "purchase"=>$v["purchase"],
  3869. "details"=>$v["details"],
  3870. "cpid"=>$v["cpid"],
  3871. "dbcontent"=>$v["dbcontent"],
  3872. "sku"=>$v["sku"],
  3873. "cs"=>$v["bm"],
  3874. "bs"=>$v["jm"],
  3875. "title"=>$v["title"],
  3876. "features"=>$v["pm"],
  3877. "cpbz"=>$v["cpbz"],
  3878. "sm"=>$v["sm"],
  3879. "type"=>$v["type"],
  3880. "number"=>$v["number"],
  3881. "c"=>$v["c"],
  3882. "x"=>$v["x"],
  3883. "t"=>$v["t"],
  3884. "s"=>$v["s"],
  3885. "q"=>$v["q"],
  3886. "z"=>$v["z"],
  3887. "weight"=>$v['weight'],
  3888. ];
  3889. }
  3890. $title = "总进销存统计表";
  3891. $titlename = "<table border=1>
  3892. <tr><th colspan='20' align='center'><h3>".$title."<h3></th></tr>
  3893. <tr align='center'>
  3894. <td>仓库</td>
  3895. <td>供应商</td>
  3896. <td>位置</td>
  3897. <td>库存编码</td>
  3898. <td>类目</td>
  3899. <td>SKU</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>删除数量</td>
  3912. <td>其它操作</td>
  3913. <td>占单数量</td>
  3914. <td>重量(g)</td>
  3915. </tr>
  3916. </table>";
  3917. $filename = $title.".xls";
  3918. $tail = "";
  3919. $this->excel->get_fz2($final_list,$titlename,$filename,$tail);
  3920. }
  3921. }
  3922. //入库导出
  3923. public function _excelr()
  3924. {
  3925. if(isset($_GET['excel']))
  3926. {
  3927. $category = $this->input->get('category',true);
  3928. $size = $this->input->get('size',true);
  3929. $grade = $this->input->get('grade',true);
  3930. $color = $this->input->get('color',true);
  3931. $lowe = $this->input->get('lowe',true);
  3932. $sku = $this->input->get('sku',true);
  3933. $warehouse = $this->input->get('warehouse',true);
  3934. $purchase = $this->input->get('purchase',true);
  3935. $ktime = $this->input->get('ktime',true);
  3936. $jtime = $this->input->get('jtime',true);
  3937. $ktime = strtotime($ktime);
  3938. $jtime = strtotime($jtime);
  3939. $where = "1=1";$gj = "";$ck = "";
  3940. if($category)
  3941. {
  3942. $where .= " and features like '%-$category-%'";
  3943. }
  3944. if($size)
  3945. {
  3946. $where .= " and features like '%-$size-%'";
  3947. }
  3948. if($grade)
  3949. {
  3950. $where .= " and features like '%-$grade-%'";
  3951. }
  3952. if($color)
  3953. {
  3954. $where .= " and features like '%-$color-%'";
  3955. }
  3956. if($lowe)
  3957. {
  3958. $where .= " and features like '%-$lowe-%'";
  3959. }
  3960. if($warehouse)
  3961. {
  3962. $where .= " and warehouse = '$warehouse'";
  3963. }
  3964. if($purchase)
  3965. {
  3966. $where .= " and purchase = '$purchase'";
  3967. }
  3968. if($sku)
  3969. {
  3970. $where .= " and sku = '$sku'";
  3971. }
  3972. if($ktime && $jtime)
  3973. {
  3974. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3975. }
  3976. //数据排序
  3977. $order_str = "id desc";
  3978. if(empty($page))
  3979. {
  3980. $start = 0;
  3981. $perpage = 1;
  3982. }
  3983. else
  3984. {
  3985. $start = ($page - 1)*$perpage;
  3986. }
  3987. $list = array();
  3988. $rows = $this->whlabel->find_pc($where,'enter,sku,warehouse','*',$order_str);
  3989. foreach ($rows as $value)
  3990. {
  3991. $ck = $this->warehouse->read($value['warehouse']);
  3992. $warehouse = $ck['title'];
  3993. $tkck = $this->warehouse->read($value['retreatwarehouse']);//退库仓库
  3994. $retreatwarehouse = $tkck['title'];
  3995. $gy = $this->purchase->read($value['purchase']);
  3996. $purchase = $gy['title'];
  3997. $g = $this->whlabel->find_count($where.' and enter = "'.$value['enter'].'" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'"');
  3998. $list[] = array('warehouse'=>$warehouse,'sku'=>$value['sku'],'title'=>$value['title'],'time'=>date('Y-m-d H:i:s',$value['enter']),'number'=>$g);
  3999. }
  4000. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."入库详情";
  4001. $titlename = "<table border=1>
  4002. <tr><th colspan='5' align='center'><h3>".$title."<h3></th></tr>
  4003. <tr align='center'>
  4004. <td>仓库</td>
  4005. <td>SKU</td>
  4006. <td>产品</td>
  4007. <td>时间</td>
  4008. <td>数量</td>
  4009. </tr>
  4010. </table>";
  4011. $filename = $title.".xls";
  4012. $tail = "";
  4013. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4014. }
  4015. }
  4016. //出库、退库导出
  4017. public function _excelct()
  4018. {
  4019. $classid = $this->classid->sku();
  4020. $pm = $classid;
  4021. $typeclass = array();
  4022. $tc = $this->typeclass->find_all();
  4023. foreach ($tc as $v)
  4024. {
  4025. $typeclass[$v['id']] = $v;
  4026. }
  4027. $prc = array();
  4028. $purchase = $this->purchase->find_all();
  4029. foreach($purchase as $k=>$v)
  4030. {
  4031. $prc[$v['id']] = $v['title'];
  4032. }
  4033. if(isset($_GET['excel']))
  4034. {
  4035. $wh = array();
  4036. $w = $this->warehouse->find_all('1=1','id,title');
  4037. foreach ($w as $v)
  4038. {
  4039. $wh[$v['id']] = $v['title'];
  4040. }
  4041. $type = $this->input->get('excel',true);
  4042. $category = $this->input->get('category',true);
  4043. $size = $this->input->get('size',true);
  4044. $grade = $this->input->get('grade',true);
  4045. $color = $this->input->get('color',true);
  4046. $lowe = $this->input->get('lowe',true);
  4047. $sku = $this->input->get('sku',true);
  4048. $warehouse = $this->input->get('warehouse',true);
  4049. $lacetype = $this->input->get('lacetype',true);
  4050. $lacecolor = $this->input->get('lacecolor',true);
  4051. $density = $this->input->get('density',true);
  4052. $haircap = $this->input->get('haircap',true);
  4053. $purchase = $this->input->get('purchase',true);
  4054. $title = $this->input->get('title',true);
  4055. $state = $this->input->get('state',true);
  4056. $sid = $this->input->get('sid',true);
  4057. $ktime = $this->input->get('ktime',true);
  4058. $jtime = $this->input->get('jtime',true);
  4059. $ktime = strtotime($ktime);
  4060. $jtime = strtotime($jtime);
  4061. $where = "1=1";$gj = "";$ck = "";
  4062. if($category)
  4063. {
  4064. $where .= " and features like '%-$category-%'";
  4065. }
  4066. if($size)
  4067. {
  4068. $where .= " and features like '%-$size-%'";
  4069. }
  4070. if($grade)
  4071. {
  4072. $where .= " and features like '%-$grade-%'";
  4073. }
  4074. if($color)
  4075. {
  4076. $where .= " and features like '%-$color-%'";
  4077. }
  4078. if($lowe)
  4079. {
  4080. $where .= " and features like '%-$lowe-%'";
  4081. }
  4082. if($warehouse)
  4083. {
  4084. $where .= " and warehouse = '$warehouse'";
  4085. }
  4086. if($purchase)
  4087. {
  4088. $where .= " and purchase = '$purchase'";
  4089. }
  4090. if($state)
  4091. {
  4092. $where .= " and state = '$state'";
  4093. }
  4094. if($lacetype)
  4095. {
  4096. $where .= " and features like '%-$lacetype-%'";
  4097. }
  4098. if($lacecolor)
  4099. {
  4100. $where .= " and features like '%-$lacecolor-%'";
  4101. }
  4102. if($density)
  4103. {
  4104. $where .= " and features like '%-$density-%'";
  4105. }
  4106. if($haircap)
  4107. {
  4108. $where .= " and features like '%-$haircap-%'";
  4109. }
  4110. if($title)
  4111. {
  4112. $title = trim($title,' ');
  4113. $title = trim($title,' ');
  4114. $where .= " and title like '%$title%'";
  4115. }
  4116. if($sku)
  4117. {
  4118. $sku = trim($sku,' ');
  4119. $sku = trim($sku,' ');
  4120. $where .= " and sku like '%$sku%'";
  4121. }
  4122. if($ktime && $jtime)
  4123. {
  4124. if($type == 1)
  4125. {
  4126. $tl = '出库';
  4127. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4128. }
  4129. else if($type == 2)
  4130. {
  4131. $tl = '退库';
  4132. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4133. }
  4134. else if($type == 3)
  4135. {
  4136. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4137. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4138. }
  4139. else if($type == 4)
  4140. {
  4141. $tl = '出库+零售';
  4142. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4143. }
  4144. else if($type == 5)
  4145. {
  4146. $tl = '零售';
  4147. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4148. }
  4149. }
  4150. $sidwhere = '';
  4151. if($sid)
  4152. {
  4153. $sd = "";
  4154. $s = explode(',',trim($sid,','));
  4155. foreach ($s as $value)
  4156. {
  4157. $sd .= " id = ".$value." or";
  4158. }
  4159. $sidwhere = " and (".rtrim($sd,'or').")";
  4160. }
  4161. //数据排序
  4162. $order_str = "time desc";
  4163. if(empty($page))
  4164. {
  4165. $start = 0;
  4166. $perpage = 1;
  4167. }
  4168. else
  4169. {
  4170. $start = ($page - 1)*$perpage;
  4171. }
  4172. //取得信息列表
  4173. if($type != 3 && $type != 5)
  4174. {
  4175. if($type == 1 || $type == 4)
  4176. {
  4177. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk',$order_str);
  4178. foreach ($info_list as $key=>$value)
  4179. {
  4180. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4181. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4182. $warehouse = $this->warehouse->read($value['warehouse']);
  4183. $info_list[$key]['warehouse'] = $warehouse['title'];
  4184. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4185. $features = explode('-',trim($features,'-'));
  4186. $pm = $classid;
  4187. foreach($features as $k=>$v)
  4188. {
  4189. if($v != 0)
  4190. {
  4191. if(!isset($typeclass[$v]))
  4192. {
  4193. continue;
  4194. }
  4195. if(isset($pm[$typeclass[$v]['classid']]))
  4196. {
  4197. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4198. {
  4199. $tz = explode('|',$typeclass[$v]['zh']);
  4200. $pm[$typeclass[$v]['classid']] = $tz[0];
  4201. }
  4202. else
  4203. {
  4204. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4205. }
  4206. }
  4207. }
  4208. }
  4209. $zh = implode(" ",$pm);
  4210. $zh = str_replace('自然色 ','',trim($zh,' '));
  4211. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4212. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4213. $info_list[$key]['features'] = $zh;
  4214. }
  4215. }
  4216. else
  4217. {
  4218. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat',$order_str);
  4219. foreach ($info_list as $key=>$value)
  4220. {
  4221. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4222. $info_list[$key]['retreat'] = date('Y-m-d H:i:s',$value['retreat']);//减12调整美国时间
  4223. $warehouse = $this->warehouse->read($value['warehouse']);
  4224. $info_list[$key]['warehouse'] = $warehouse['title'];
  4225. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4226. $features = explode('-',trim($features,'-'));
  4227. $pm = $classid;
  4228. foreach($features as $k=>$v)
  4229. {
  4230. if($v != 0)
  4231. {
  4232. if(!isset($typeclass[$v]))
  4233. {
  4234. continue;
  4235. }
  4236. if(isset($pm[$typeclass[$v]['classid']]))
  4237. {
  4238. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4239. {
  4240. $tz = explode('|',$typeclass[$v]['zh']);
  4241. $pm[$typeclass[$v]['classid']] = $tz[0];
  4242. }
  4243. else
  4244. {
  4245. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4246. }
  4247. }
  4248. }
  4249. }
  4250. $zh = implode(" ",$pm);
  4251. $zh = str_replace('自然色 ','',trim($zh,' '));
  4252. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4253. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4254. $info_list[$key]['features'] = $zh;
  4255. }
  4256. }
  4257. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4258. $titlename = "<table border=1>
  4259. <tr><th colspan='8' align='center'><h3>".$title."<h3></th></tr>
  4260. <tr align='center'>
  4261. <td>仓库</td>
  4262. <td>供应商</td>
  4263. <td>SKU</td>
  4264. <td>商品名称</td>
  4265. <td>商品中文</td>
  4266. <td>标签</td>
  4267. <td>订单号</td>
  4268. <td>运单号</td>
  4269. <td>".$tl."时间(中国时间)</td>
  4270. </tr>
  4271. </table>";
  4272. $filename = $title.".xls";
  4273. $tail = "";
  4274. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4275. }
  4276. else if($type == 5)
  4277. {
  4278. $info_list = $this->whlabel->find_all($where,'warehouse,purchase,sku,title,features,label,outk',$order_str);
  4279. foreach ($info_list as $key=>$value)
  4280. {
  4281. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4282. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);//减12调整美国时间
  4283. $warehouse = $this->warehouse->read($value['warehouse']);
  4284. $info_list[$key]['warehouse'] = $warehouse['title'];
  4285. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4286. $features = explode('-',trim($features,'-'));
  4287. $pm = $classid;
  4288. foreach($features as $k=>$v)
  4289. {
  4290. if($v != 0)
  4291. {
  4292. if(!isset($typeclass[$v]))
  4293. {
  4294. continue;
  4295. }
  4296. if(isset($pm[$typeclass[$v]['classid']]))
  4297. {
  4298. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4299. {
  4300. $tz = explode('|',$typeclass[$v]['zh']);
  4301. $pm[$typeclass[$v]['classid']] = $tz[0];
  4302. }
  4303. else
  4304. {
  4305. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4306. }
  4307. }
  4308. }
  4309. }
  4310. $zh = implode(" ",$pm);
  4311. $zh = str_replace('自然色 ','',trim($zh,' '));
  4312. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4313. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4314. $info_list[$key]['features'] = $zh;
  4315. }
  4316. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).$tl.'详情';
  4317. $titlename = "<table border=1>
  4318. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  4319. <tr align='center'>
  4320. <td>仓库</td>
  4321. <td>供应商</td>
  4322. <td>SKU</td>
  4323. <td>商品名称</td>
  4324. <td>商品中文</td>
  4325. <td>标签</td>
  4326. <td>".$tl."时间(中国时间)</td>
  4327. </tr>
  4328. </table>";
  4329. $filename = $title.".xls";
  4330. $tail = "";
  4331. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4332. }
  4333. else
  4334. {
  4335. /**
  4336. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4337. $rows = array();$list = array();
  4338. foreach ($info_list as $key=>$value)
  4339. {
  4340. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4341. }
  4342. **/
  4343. $wh = array();
  4344. $w = $this->warehouse->find_all('1=1','id,title');
  4345. foreach ($w as $v)
  4346. {
  4347. $wh[$v['id']] = $v['title'];
  4348. }
  4349. $wt = array();
  4350. $whlabel_type = $this->whlabel_type->find_all();
  4351. foreach ($whlabel_type as $v)
  4352. {
  4353. $wt[$v['id']] = $v['title'];
  4354. }
  4355. $classid = $this->classid->sku();
  4356. $list = array();
  4357. $rows = $this->whlabel->find_pc($where.$sidwhere,'sku,purchase,features,warehouse','warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4358. foreach ($rows as $key=>$value)
  4359. {
  4360. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4361. $rows[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  4362. $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');
  4363. $details = array();
  4364. $cpid = array();
  4365. $cpbz = array();
  4366. $c = 0;$g = 0;$x = 0;$t = 0;$s = 0;$q = 0;
  4367. foreach ($sd as $k=>$v)
  4368. {
  4369. if($v['state'] == 0)
  4370. {
  4371. $c++;
  4372. }
  4373. if($v['state'] != 9)
  4374. {
  4375. $g++;
  4376. }
  4377. if($v['outk'] > 1)
  4378. {
  4379. $x++;
  4380. }
  4381. if($v['retreat'] > 0)
  4382. {
  4383. $t++;
  4384. }
  4385. if($v['state'] == 8)
  4386. {
  4387. $s++;
  4388. }
  4389. if($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7")
  4390. {
  4391. $q++;
  4392. }
  4393. $details[$v['details']] = $v['details'];
  4394. if($v['cpid'] != 0)
  4395. {
  4396. $cpid[$v['cpid']] = $v['cpid'];
  4397. }
  4398. if($v['cpbz'] != '')
  4399. {
  4400. $cpbz[$v['cpbz']] = $v['cpbz'];
  4401. }
  4402. }
  4403. if(isset($wt[$value['type']]))
  4404. {
  4405. $rows[$key]['type'] = $wt[$value['type']];
  4406. }
  4407. else
  4408. {
  4409. $rows[$key]['type'] = '未设置';
  4410. }
  4411. $rows[$key]['details'] = implode("、",$details);
  4412. $rows[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  4413. $ftime = time()-15*24*3600;
  4414. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4415. $rows[$key]['cpbz'] = ($cpbz)?implode(" ",$cpbz):'';
  4416. $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);
  4417. $rows[$key]['c'] = $c;
  4418. $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);
  4419. $rows[$key]['t'] = $t;
  4420. $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'].'"');
  4421. $rows[$key]['z'] = $z;
  4422. $jm = $classid;
  4423. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$value['features']);
  4424. $features = explode('-',trim($features,'-'));
  4425. $pm = $classid;
  4426. foreach($features as $k=>$v)
  4427. {
  4428. if($v != 0)
  4429. {
  4430. if(!isset($typeclass[$v]))
  4431. {
  4432. continue;
  4433. }
  4434. if(isset($pm[$typeclass[$v]['classid']]))
  4435. {
  4436. if(stripos($typeclass[$v]['zh'],'|') !== false)
  4437. {
  4438. $tz = explode('|',$typeclass[$v]['zh']);
  4439. $pm[$typeclass[$v]['classid']] = $tz[0];
  4440. }
  4441. else
  4442. {
  4443. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4444. }
  4445. if(isset($jm[$typeclass[$v]['classid']]))
  4446. {
  4447. if($typeclass[$v]['jm'])
  4448. {
  4449. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4450. }
  4451. }
  4452. }
  4453. }
  4454. }
  4455. $zh = implode(" ",$pm);
  4456. $zh = str_replace('自然色 ','',trim($zh,' '));
  4457. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  4458. $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  4459. $rows[$key]['features'] = $zh;
  4460. $jm = array_filter($jm);//去除空值
  4461. $jm = implode("-",$jm);
  4462. $rows[$key]['jm'] = $jm;
  4463. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4464. }
  4465. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'进销存详情';
  4466. $titlename = "<table border=1>
  4467. <tr><th colspan='17' align='center'><h3>".$title."<h3></th></tr>
  4468. <tr align='center'>
  4469. <td>仓库</td>
  4470. <td>供应商</td>
  4471. <td>位置</td>
  4472. <td>库存编码</td>
  4473. <td>SKU</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. <td>占单数量</td>
  4484. <td>料号</td>
  4485. <td>类目</td>
  4486. </tr>
  4487. </table>";
  4488. $filename = $title.".xls";
  4489. $tail = "";
  4490. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  4491. }
  4492. }
  4493. }
  4494. //出库+入库数据整合
  4495. public function _excelcr()
  4496. {
  4497. if(isset($_GET['excel']))
  4498. {
  4499. $type = $this->input->get('excel',true);
  4500. $category = $this->input->get('category',true);
  4501. $size = $this->input->get('size',true);
  4502. $grade = $this->input->get('grade',true);
  4503. $color = $this->input->get('color',true);
  4504. $lowe = $this->input->get('lowe',true);
  4505. $sku = $this->input->get('sku',true);
  4506. $warehouse = $this->input->get('warehouse',true);
  4507. $purchase = $this->input->get('purchase',true);
  4508. $state = $this->input->get('state',true);
  4509. $sid = $this->input->get('sid',true);
  4510. $ktime = $this->input->get('ktime',true);
  4511. $jtime = $this->input->get('jtime',true);
  4512. $ktime = strtotime($ktime);
  4513. $jtime = strtotime($jtime);
  4514. $where = "1=1";$gj = "";$ck = "";
  4515. if($category)
  4516. {
  4517. $where .= " and features like '%-$category-%'";
  4518. }
  4519. if($size)
  4520. {
  4521. $where .= " and features like '%-$size-%'";
  4522. }
  4523. if($grade)
  4524. {
  4525. $where .= " and features like '%-$grade-%'";
  4526. }
  4527. if($color)
  4528. {
  4529. $where .= " and features like '%-$color-%'";
  4530. }
  4531. if($lowe)
  4532. {
  4533. $where .= " and features like '%-$lowe-%'";
  4534. }
  4535. if($warehouse)
  4536. {
  4537. $where .= " and warehouse = '$warehouse'";
  4538. }
  4539. if($purchase)
  4540. {
  4541. $where .= " and purchase = '$purchase'";
  4542. }
  4543. if($state)
  4544. {
  4545. $where .= " and state = '$state'";
  4546. }
  4547. if($sku)
  4548. {
  4549. $where .= " and sku like '%$sku%'";
  4550. }
  4551. if($ktime && $jtime)
  4552. {
  4553. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4554. }
  4555. $sidwhere = '';
  4556. if($sid)
  4557. {
  4558. $sd = "";
  4559. $s = explode(',',trim($sid,','));
  4560. foreach ($s as $value)
  4561. {
  4562. $sd .= " id = ".$value." or";
  4563. }
  4564. $sidwhere .= " and (".rtrim($sd,'or').")";
  4565. }
  4566. //取得信息列表
  4567. $timeread = $ktime;
  4568. $timenum = ceil(($jtime - $ktime) / (24*3600));
  4569. $timelist = array();
  4570. for($i=0;$i<$timenum;$i++)
  4571. {
  4572. $timeread = ($i>0)?$ktime+$i*24*3600:$ktime;
  4573. $timelist[date('Y-m-d',$timeread)] = array('c'=>0,'r'=>0);
  4574. }
  4575. $info_list = $this->whlabel->find_all($where.$sidwhere,'outk,enter,sku,state');
  4576. //echo "<pre>";
  4577. //print_r($info_list);
  4578. //exit();
  4579. $rows = array();$list = array();
  4580. foreach ($info_list as $key=>$value)
  4581. {
  4582. $thistime = $timelist;
  4583. if(isset($rows[strtolower($value['sku'])]))
  4584. {
  4585. if($value['outk'] > $ktime && $value['state'] < $jtime)
  4586. {
  4587. $rows[strtolower($value['sku'])][date('Y-m-d',$value['outk'])]['c'] += 1;
  4588. }
  4589. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4590. {
  4591. $rows[strtolower($value['sku'])][date('Y-m-d',$value['enter'])]['r'] += 1;
  4592. }
  4593. }
  4594. else
  4595. {
  4596. if($value['outk'] > $ktime && $value['outk'] < $jtime)
  4597. {
  4598. $thistime[date('Y-m-d',$value['outk'])]['c'] += 1;
  4599. }
  4600. if($value['enter'] > $ktime && $value['enter'] < $jtime)
  4601. {
  4602. $thistime[date('Y-m-d',$value['enter'])]['r'] += 1;
  4603. }
  4604. $rows[strtolower($value['sku'])] = $thistime;
  4605. }
  4606. }
  4607. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4608. <head>
  4609. <!--[if gte mso 9]><xml>
  4610. <x:ExcelWorkbook>
  4611. <x:ExcelWorksheets>
  4612. <x:ExcelWorksheet>
  4613. <x:Name>EXCEL</x:Name>
  4614. <x:WorksheetOptions>
  4615. <x:Print>
  4616. <x:ValidPrinterInfo />
  4617. </x:Print>
  4618. </x:WorksheetOptions>
  4619. </x:ExcelWorksheet>
  4620. </x:ExcelWorksheets>
  4621. </x:ExcelWorkbook>
  4622. </xml>
  4623. <![endif]-->
  4624. </head><body>";
  4625. $str .= "<table border=1><tr><td>SKU</td>";
  4626. foreach ($timelist as $k=>$v)
  4627. {
  4628. $str .="<td>".$k."出库</td>";
  4629. $str .="<td>".$k."入库</td>";
  4630. }
  4631. $str .= "</tr></table>";
  4632. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4633. foreach ($rows as $key=>$val)
  4634. {
  4635. $str .= "<tr><td>".strtoupper($key)."</td>";
  4636. foreach ($val as $k=>$v)
  4637. {
  4638. $str .= "<td>".$val[$k]['c']."</td>";
  4639. if($val[$k]['r'] > 0)
  4640. {
  4641. $str .= "<td style='color:#f00'>-".$val[$k]['r']."</td>";
  4642. }
  4643. else
  4644. {
  4645. $str .= "<td>".$val[$k]['r']."</td>";
  4646. }
  4647. }
  4648. $str .= "</tr>";
  4649. }
  4650. $str .= "</table>";
  4651. $str .= "</body></html>";
  4652. header( "Content-Type: application/vnd.ms-excel; name='excel'" );
  4653. header( "Content-type: application/octet-stream" );
  4654. header( "Content-Disposition: attachment; filename=".time().'.xls' );
  4655. header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
  4656. header( "Pragma: no-cache" );
  4657. header( "Expires: 0" );
  4658. exit($str);
  4659. }
  4660. }
  4661. //数量调整模板导出
  4662. public function _presetout()
  4663. {
  4664. if(isset($_GET['excel']))
  4665. {
  4666. $where = "sku != 'Preset' and purchase != 0";
  4667. //数据排序
  4668. $order_str = "id desc";
  4669. if(empty($page))
  4670. {
  4671. $start = 0;
  4672. $perpage = 1;
  4673. }
  4674. else
  4675. {
  4676. $start = ($page - 1)*$perpage;
  4677. }
  4678. //取得信息列表
  4679. $info_list = $this->whlabel->find_pc($where,'warehouse,purchase,sku','*','id desc',0,1);
  4680. $rows = array();$list = array();
  4681. foreach ($info_list as $value)
  4682. {
  4683. $warehouse = $this->warehouse->read($value['warehouse']);
  4684. $number = $value['number'];$ftime = time()-15*24*3600;
  4685. $purchase = $this->purchase->read($value['purchase']);
  4686. $list[] = array($warehouse['title'],$purchase['bm'],$value['sku'],'0','','0','','');
  4687. }
  4688. $title = "库存模板";
  4689. $titlename = "<table border=1>
  4690. <tr align='center'>
  4691. <td>仓库</td>
  4692. <td>供应商编码</td>
  4693. <td>SKU</td>
  4694. <td>增减数量(正数或负数)</td>
  4695. <td>增减备注</td>
  4696. <td>扣减方式:0减少库存1删除库存</td>
  4697. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4698. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4699. </tr>
  4700. </table>";
  4701. $filename = $title.".xls";
  4702. $tail = "";
  4703. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  4704. }
  4705. }
  4706. //数量调整模板导入
  4707. public function _presetedit()
  4708. {
  4709. $dir = '/data/excel/'.date('Ymd',time()).'/';
  4710. $config['upload_path'] = '.'.$dir ;
  4711. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  4712. $config['allowed_types'] = 'xls|xlsx|csv';
  4713. $config['max_size'] = 10240;
  4714. $this->load->library('upload', $config);
  4715. $this->upload->initialize($config);
  4716. if ($this->upload->do_upload('userfile'))
  4717. {
  4718. $full_path = $dir.$this->upload->data('file_name');
  4719. $fileName = '.' . $full_path;
  4720. if (!file_exists($fileName))
  4721. {
  4722. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  4723. }
  4724. else
  4725. {
  4726. require_once "./data/excel/PHPExcel/IOFactory.php";
  4727. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  4728. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  4729. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  4730. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  4731. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  4732. ++$column;//如果列数大于26行
  4733. $list = array();
  4734. for ($i = 2; $i <= $row; $i++) // 行数循环
  4735. {
  4736. $data = array();
  4737. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4738. {
  4739. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4740. }
  4741. $list[] = $data;
  4742. }
  4743. }
  4744. $i = 0;$j = 0;$ed = array();
  4745. foreach ($list as $key=>$value)
  4746. {
  4747. $time = time();
  4748. if($value['0'] == "")
  4749. {
  4750. continue;
  4751. }
  4752. $warehouse = $this->warehouse->get_title($value['0']);
  4753. $purchase = $this->purchase->get_bm($value['1']);
  4754. $sku = $value['2'];
  4755. $num = $value['3'];//调整数量
  4756. $text = $value['4'];//扣减说明
  4757. $type = $value['5'];//调整方式0扣减1删除
  4758. $rktype = $value['6']!=''?$value['6']:0;//增加库存
  4759. $cktype = $value['7']!=''?$value['7']:0;//减少库存
  4760. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  4761. if(!$purchase)//如果没有这个SKU
  4762. {
  4763. $ed[] = array($purchase.'-不存在此供应商编码');
  4764. $j++;
  4765. continue;
  4766. }
  4767. if(!$d)//如果没有这个SKU
  4768. {
  4769. $ed[] = array($sku.'-库存中不存在此SKU');
  4770. $j++;
  4771. continue;
  4772. }
  4773. if(!isset($warehouse['id']))
  4774. {
  4775. $ed[] = array($sku.'-仓库名错误!');
  4776. $j++;
  4777. continue;
  4778. }
  4779. if($type != '0' && $type != '1')
  4780. {
  4781. $ed[] = array($sku.'-扣减方式填写错误!');
  4782. $j++;
  4783. continue;
  4784. }
  4785. if($num < 0)//扣减库存
  4786. {
  4787. if($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == '')))
  4788. {
  4789. $ed[] = array($sku.'-扣减必须填写扣减类型,非类型1必须填写备注');
  4790. $j++;
  4791. continue;
  4792. }
  4793. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and zd = "" and state = 0');
  4794. if(count($data) < abs($num))
  4795. {
  4796. $ed[] = array($sku.'-扣减数量大于库存剩余数量!');
  4797. $j++;
  4798. continue;
  4799. }
  4800. if($type == 0)//如果扣减方式为 扣减库存
  4801. {
  4802. for($i=0;$i<abs($num);$i++)
  4803. {
  4804. $this->whlabel->save(array('state'=>8,'textout'=>$text,'deltime'=>$time,'cktype'=>$cktype,'time'=>$time,'outk'=>$time),$data[$i]['id']);
  4805. }
  4806. }
  4807. else if($type == 1)
  4808. {
  4809. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  4810. if(count($zt) > 0)
  4811. {
  4812. $ed[] = array($sku.'-有在途库存无法删除!');
  4813. $j++;
  4814. continue;
  4815. }
  4816. for($i=0;$i<abs($num);$i++)
  4817. {
  4818. $this->whlabel->remove($data[$i]['id']);
  4819. }
  4820. }
  4821. }
  4822. else if($num > 0)//增加库存
  4823. {
  4824. if($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == '')))
  4825. {
  4826. $ed[] = array($sku.'-增加必须填写增加类型,非类型1必须填写备注');
  4827. $j++;
  4828. continue;
  4829. }
  4830. $post['sku'] = $d['sku'];
  4831. $post['shop'] = $d['shop'];
  4832. $post['warehouse'] = $warehouse['id'];
  4833. $post['purchase'] = $purchase['id'];
  4834. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4835. $post['state'] = 0;
  4836. $post['title'] = $d['title'];
  4837. $post['number'] = $d['number'];
  4838. $post['features'] = $d['features'];
  4839. $post['enter'] = $time;
  4840. $post['time'] = $time;//操作时间
  4841. $post['rktype'] = $rktype;
  4842. for($i=0;$i<$num;$i++)
  4843. {
  4844. $post['label'] = time().rand(100,999).$i;
  4845. $this->whlabel->insert($post);
  4846. }
  4847. }
  4848. sleep(1);//防止入库时间一样,需要延迟1秒
  4849. }
  4850. if($j > 0)
  4851. {
  4852. $tt = date('Ymd',time());
  4853. $title = '库存导入错误信息-'.$tt;
  4854. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4855. $tail = "\n";
  4856. $filename = $title.".xls";
  4857. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  4858. $dir = '/data/excel/'.$time.'/';
  4859. $file_name = 'error_'.$time.rand(1000,9999);
  4860. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  4861. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  4862. fwrite($myfile,$ecl);
  4863. fclose($myfile);
  4864. $error = $dir.$file_name.'.xls';
  4865. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  4866. }
  4867. else
  4868. {
  4869. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  4870. }
  4871. }
  4872. }
  4873. //笛卡儿积
  4874. function cp($ps,$sets,$list)
  4875. {
  4876. $result = array();$j=0;
  4877. for($i=0,$count=count($sets); $i<$count-1; $i++)
  4878. {
  4879. if($i==0)
  4880. {
  4881. $result = $sets[$i];
  4882. }
  4883. $tmp = array();
  4884. foreach($result as $res)
  4885. {
  4886. foreach($sets[$i+1] as $set)
  4887. {
  4888. $tmp[] = $res.','.$set;
  4889. }
  4890. }
  4891. $result = $tmp;
  4892. }
  4893. $this->db->trans_begin();
  4894. foreach ($result as $v)
  4895. {
  4896. $post = array();$title = "";$num="";
  4897. $data = explode(',',$v);
  4898. for($i=0;$i<count($list); $i++)
  4899. {
  4900. $post[$list[$i]] = $data[$i];
  4901. $typeclass = $this->typeclass->read($data[$i]);
  4902. $title = $title.$typeclass['title']." ";
  4903. if($data[$i] != 0)
  4904. {
  4905. $num .=$data[$i];//所有数据ID拼接
  4906. }
  4907. }
  4908. foreach ($ps as $kp=>$vp)
  4909. {
  4910. $post[$kp] = $vp;
  4911. }
  4912. $post['number'] = $num;
  4913. $info_list = $this->whlabel->get_number($num);//查询whlabel是否存在此拼接的数据ID
  4914. if($info_list)
  4915. {
  4916. $j++;
  4917. }
  4918. else
  4919. {
  4920. $skunum = $this->whlabel->find_count();
  4921. $post['sku'] = 'LY'.substr(strval($skunum+1+10000000),1,7);
  4922. $post['title'] = rtrim($title,' ');
  4923. $this->whlabel->insert($post);
  4924. }
  4925. }
  4926. if ($this->db->trans_status() === FALSE)
  4927. {
  4928. $this->db->trans_commit();
  4929. return NULL;
  4930. }
  4931. else
  4932. {
  4933. $this->db->trans_commit();
  4934. return $j;
  4935. }
  4936. }
  4937. public function _kj($arg_array)
  4938. {
  4939. if(isset($_POST['sku']))
  4940. {
  4941. $time = time();
  4942. $sku = $this->input->post('sku',true);
  4943. $warehouse = $this->input->post('warehouse',true);
  4944. $num = $this->input->post('num',true);
  4945. $text = $this->input->post('text',true);
  4946. $purchase = $this->input->post('purchase',true);
  4947. $cktype = $this->input->post('cktype',true);
  4948. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4949. if($cktype != 1 && $text == '')
  4950. {
  4951. echo json_encode(array('msg'=>"非销售出库必须填写备注!",'success'=>false));exit;
  4952. }
  4953. if($num > count($order))
  4954. {
  4955. echo json_encode(array('msg'=>"扣减数量大于剩余库存数量!",'success'=>false));exit;
  4956. }
  4957. else
  4958. {
  4959. for($i=0;$i<$num;$i++)
  4960. {
  4961. $this->whlabel->save(array('state'=>8,'cktype'=>$cktype,'textout'=>$text,'deltime'=>$time,'time'=>$time,'outk'=>$time),$order[$i]['id']);
  4962. }
  4963. }
  4964. echo json_encode(array('msg'=>"扣减成功!",'success'=>false));exit;
  4965. }
  4966. $uid = $this->whlabel->read($arg_array[0]);
  4967. $uid['num'] = $this->whlabel->find_count('purchase = "'.$uid['purchase']. '" and sku = "'.$uid['sku']. '" and warehouse = "'.$uid['warehouse']. '" and zd = "" and state = 0');
  4968. $this->data['data'] = $uid ;
  4969. $this->_Template('whlabel_kj',$this->data);
  4970. }
  4971. public function _summary($arg_array)
  4972. {
  4973. $prc = array();
  4974. $purchase = $this->purchase->find_all();
  4975. foreach($purchase as $k=>$v)
  4976. {
  4977. $prc[$v['id']] = $v['title'];
  4978. }
  4979. if(isset($_GET['excel']))
  4980. {
  4981. $ktime = $this->input->get('ktime',true);
  4982. $jtime = $this->input->get('jtime',true);
  4983. $ktime = strtotime($ktime);
  4984. $jtime = strtotime($jtime);
  4985. $where = "1=1";
  4986. if($ktime && $jtime)
  4987. {
  4988. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4989. }
  4990. //数据排序
  4991. $order_str = "time desc";
  4992. if(empty($page))
  4993. {
  4994. $start = 0;
  4995. $perpage = 1;
  4996. }
  4997. else
  4998. {
  4999. $start = ($page - 1)*$perpage;
  5000. }
  5001. //取得信息列表
  5002. $info_list = $this->whlabel->find_pc($where,'sku','warehouse,purchase,details,cpid,sku,title');
  5003. foreach ($info_list as $key=>$value)
  5004. {
  5005. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  5006. $warehouse = $this->warehouse->read($value['warehouse']);
  5007. $info_list[$key]['warehouse'] = $warehouse['title'];
  5008. $x = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'"','details,cpid');
  5009. $details = array();
  5010. $cpid = array();
  5011. foreach ($x as $k=>$v)
  5012. {
  5013. if($v['details'] != '')
  5014. {
  5015. $details[$v['details']] = $v['details'];
  5016. }
  5017. if($v['cpid'] != 0)
  5018. {
  5019. $cpid[$v['cpid']] = $v['cpid'];
  5020. }
  5021. }
  5022. $info_list[$key]['details'] = ($details)?implode(" ",$details):'';
  5023. $info_list[$key]['cpid'] = ($cpid)?implode(" ",$cpid):'';
  5024. $s = $this->whlabel->find_count('state = 0 and sku = "'.$value['sku'].'"');
  5025. $info_list[$key]['s'] = $s;
  5026. $info_list[$key]['x'] = count($x);
  5027. }
  5028. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime).'出库汇总详情';
  5029. $titlename = "<table border=1>
  5030. <tr align='center'>
  5031. <td>仓库</td>
  5032. <td>供应商</td>
  5033. <td>出库位置</td>
  5034. <td>出库编码</td>
  5035. <td>SKU</td>
  5036. <td>产品名</td>
  5037. <td>总剩余库存</td>
  5038. <td>".date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime)."销售数量</td>
  5039. </tr>
  5040. </table>";
  5041. $filename = $title.".xls";
  5042. $tail = "";
  5043. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5044. }
  5045. }
  5046. //usps发货清单
  5047. public function _manifest()
  5048. {
  5049. if(isset($_POST['manifest']))
  5050. {
  5051. $wltext = $this->input->post('wltext',true);
  5052. $time = time()-16*3600;
  5053. $ptime = strtotime(date('Y-m-d',$time));
  5054. $waybill = array();
  5055. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  5056. foreach ($fullorder as $v)
  5057. {
  5058. $waybill[$v['waybill']] = $v['waybill'];
  5059. }
  5060. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)",'number,waybill');
  5061. foreach ($fullordersmt as $v)
  5062. {
  5063. $waybill[$v['waybill']] = $v['waybill'];
  5064. }
  5065. $wltext = explode(';',$wltext);
  5066. foreach ($wltext as $v)
  5067. {
  5068. if(isset($waybill[$v]))
  5069. {
  5070. unset($waybill[$v]);
  5071. }
  5072. }
  5073. $data = $this->usps->get_manifest($waybill);
  5074. if(isset($data['Description']))
  5075. {
  5076. echo json_encode(array('msg'=>$data['Description'],'success'=>false));exit;
  5077. }
  5078. else if(isset($data['SCANFormImage']) && isset($data['SCANFormNumber']))
  5079. {
  5080. $bctime = date('Ymd',time());
  5081. $pdf = $this->_pdf($data['SCANFormImage'],$data['SCANFormNumber'],$bctime);
  5082. echo json_encode(array('msg'=>$pdf,'success'=>true));exit;
  5083. }
  5084. else
  5085. {
  5086. echo json_encode(array('msg'=>$data,'success'=>false));exit;
  5087. }
  5088. }
  5089. }
  5090. public function _pdf($pdf,$title,$bctime)
  5091. {
  5092. $pdf_path = './data/pdf/'.$bctime.'/';
  5093. $file_base64 = $pdf;
  5094. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5095. $file_base64 = base64_decode($file_base64);
  5096. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  5097. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  5098. return 'http://'.$_SERVER['HTTP_HOST'].'/data/pdf/'.$bctime.'/'.$title.'.pdf';
  5099. }
  5100. /**
  5101. *
  5102. *
  5103. *
  5104. 进销存占单异常索引
  5105. *
  5106. *
  5107. *
  5108. **/
  5109. public function _abnormal()
  5110. {
  5111. $post = $this->input->post(NULL, TRUE);
  5112. if(isset($post['page']))
  5113. {
  5114. $page = $this->input->post('page',true);
  5115. $perpage = $this->input->post('perpage',true);
  5116. $sku = $this->input->post('sku',true);
  5117. $where = "1=1";
  5118. //数据排序
  5119. $order_str = "id desc";
  5120. if(empty($page))
  5121. {
  5122. $start = 0;
  5123. $perpage = 1;
  5124. }
  5125. else
  5126. {
  5127. $start = ($page - 1)*$perpage;
  5128. }
  5129. //取得信息列表
  5130. $info_list = $this->whlabel->find_all($where,'*');
  5131. $rows = array();$list = array();
  5132. foreach ($info_list as $key=>$value)
  5133. {
  5134. $rows[strtolower($value['sku'])] = $value;//所有数据sku
  5135. }
  5136. foreach ($rows as $value)
  5137. {
  5138. $warehouse = $this->warehouse->read($value['warehouse']);
  5139. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "5"');
  5140. $number = $value['number'];$ftime = time()-15*24*3600;
  5141. if($value['shop'] != '')
  5142. {
  5143. $shop = $value['shop'];
  5144. $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');
  5145. $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');
  5146. $order = array_merge($orderdlz,$ordersmt);
  5147. $od = 0;$a = '';$orid = '';
  5148. foreach ($order as $v)
  5149. {
  5150. $or = explode('|',ltrim($v['whlabel'],'|'));
  5151. for($i=0;$i<count($or);$i++)
  5152. {
  5153. $orod = explode('-',$or[$i]);
  5154. if($orod[0] == $number)
  5155. {
  5156. $od += $orod[1];
  5157. }
  5158. }
  5159. $orid .= $v['number'].'-';
  5160. }
  5161. }
  5162. else
  5163. {
  5164. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5165. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'",'whlabel,shop,orderinfo,number');
  5166. $order = array_merge($orderdlz,$ordersmt);
  5167. $od = 0;$a = '';$orid = '';$qt = array();
  5168. foreach ($order as $v)
  5169. {
  5170. $or = explode('|',ltrim($v['whlabel'],'|'));
  5171. for($i=0;$i<count($or);$i++)
  5172. {
  5173. $orod = explode('-',$or[$i]);
  5174. if($orod[0] == $number)
  5175. {
  5176. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '".$v['shop']."' and state = 0");
  5177. if($czzs > 0)
  5178. {
  5179. if(isset($qt[$v['shop']]))
  5180. {
  5181. if($qt[$v['shop']] < $orod[1])
  5182. {
  5183. $od += $orod[1];//专属小于单量不计算剩余直接归入通用
  5184. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5185. }
  5186. else
  5187. {
  5188. $qt[$v['shop']] -= $orod[1];
  5189. }
  5190. }
  5191. else
  5192. {
  5193. $qt[$v['shop']] = $czzs;
  5194. }
  5195. }
  5196. else
  5197. {
  5198. $od += $orod[1];
  5199. $orid .= $v['number'].'+数量'.$orod[1].'-';
  5200. }
  5201. }
  5202. }
  5203. }
  5204. }
  5205. $z = $od.'('.$orid.')';//查看订单号
  5206. //$z = $od;
  5207. if($od > $c)
  5208. {
  5209. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c,'z'=>$z);
  5210. }
  5211. }
  5212. $listdata = array_slice($list,$start,$perpage);
  5213. $total = count($list);
  5214. $pagenum = ceil($total/$perpage);
  5215. $over = $total-($start+$perpage);
  5216. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5217. echo json_encode($rows);exit;
  5218. }
  5219. $this->_Template('whlabel_abnormal',$this->data);
  5220. }
  5221. /**
  5222. *
  5223. *
  5224. *
  5225. 进销存占单异常索引
  5226. *
  5227. *
  5228. *
  5229. **/
  5230. public function _error()
  5231. {
  5232. $post = $this->input->post(NULL, TRUE);
  5233. if(isset($post['page']))
  5234. {
  5235. $page = $this->input->post('page',true);
  5236. $perpage = $this->input->post('perpage',true);
  5237. $sku = $this->input->post('sku',true);
  5238. $warehouse = $this->input->post('warehouse',true);
  5239. $ktime = $this->input->post('ktime',true);
  5240. $jtime = $this->input->post('jtime',true);
  5241. $ktime = strtotime($ktime);
  5242. $jtime = strtotime($jtime);
  5243. $where = "sku != 'Preset'";
  5244. $gj = '';
  5245. if($sku)
  5246. {
  5247. $where .= " and sku like '%$sku%'";
  5248. }
  5249. else
  5250. {
  5251. if($ktime && $jtime)
  5252. {
  5253. $gj = " and time > '$ktime' and time < '$jtime'";
  5254. }
  5255. }
  5256. if($warehouse)
  5257. {
  5258. $where .= " and warehouse = '$warehouse'";
  5259. }
  5260. //数据排序
  5261. $order_str = "id desc";
  5262. if(empty($page))
  5263. {
  5264. $start = 0;
  5265. $perpage = 1;
  5266. }
  5267. else
  5268. {
  5269. $start = ($page - 1)*$perpage;
  5270. }
  5271. //取得信息列表
  5272. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5273. $rows = array();$list = array();
  5274. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5275. // foreach ($info_list as $value)
  5276. // {
  5277. // $warehouse = $this->warehouse->read($value['warehouse']);
  5278. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5279. // $number = $value['number'];$ftime = time()-15*24*3600;
  5280. // if($c < 1)
  5281. // {
  5282. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5283. // }
  5284. // }
  5285. $warehouse_list = $this->warehouse->find_all();
  5286. $warehouse_list = array_column($warehouse_list,null,'id');
  5287. foreach ($info_list as $value)
  5288. {
  5289. $warehouse = isset($warehouse_list[$value['warehouse']])?$warehouse_list[$value['warehouse']]:[
  5290. 'title'=>"",
  5291. ];
  5292. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5293. $number = $value['number'];$ftime = time()-15*24*3600;
  5294. if($c < 1)
  5295. {
  5296. $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5297. }
  5298. }
  5299. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5300. // $query = $this->db->query($sql);
  5301. // $info_list = $query->result_array();
  5302. // $sql_two = "select title,id from crowd_warehouse";
  5303. // $query_two = $this->db->query($sql_two);
  5304. // $warehouse_list = $query_two->result_array();
  5305. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5306. // foreach ($info_list as $value)
  5307. // {
  5308. // if(isset($warehouse_arr[$value['warehouse']])){
  5309. // $warehouse = $warehouse_arr[$value['warehouse']];
  5310. // }else{
  5311. // $warehouse = [
  5312. // 'id'=>0,
  5313. // 'title'=>"异常",
  5314. // ];
  5315. // }
  5316. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5317. // $number = $value['number'];$ftime = time()-15*24*3600;
  5318. // if($c < 1)
  5319. // {
  5320. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5321. // }
  5322. // }
  5323. $listdata = array_slice($list,$start,$perpage);
  5324. $total = count($list);
  5325. $pagenum = ceil($total/$perpage);
  5326. $over = $total-($start+$perpage);
  5327. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($listdata));
  5328. echo json_encode($rows);exit;
  5329. }
  5330. if(isset($post['s']))
  5331. {
  5332. $id_arr = $this->input->post('s');
  5333. $id_arr = explode(',',trim($id_arr,','));
  5334. if(!$id_arr)
  5335. {
  5336. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  5337. }
  5338. //循环删除记录
  5339. foreach ($id_arr as $v)
  5340. {
  5341. $dd = $this->whlabel->read($v);
  5342. if(!isset($dd['id']))
  5343. {
  5344. echo json_encode(array('msg'=>$dd['sku'].'已被删除,请刷新页面','success'=>false));exit;
  5345. }
  5346. $zt = $this->whlabeltransport->find_all('sku = "'.$dd['sku'].'" and warehouse = "'.$dd['warehouse'].'" and features = "'.$dd['features'].'" and cz = "0"');
  5347. if(isset($zt[0]))
  5348. {
  5349. echo json_encode(array('msg'=>'有在途库存无法删除!','success'=>false));exit;
  5350. }
  5351. $deldd = $this->whlabel->find_all("sku = '".$dd['sku']."' and warehouse = '".$dd['warehouse']."'");
  5352. foreach ($deldd as $vv)
  5353. {
  5354. $this->whlabel->remove($vv['id']);
  5355. }
  5356. }
  5357. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));exit;
  5358. }
  5359. $this->_Template('whlabel_error',$this->data);
  5360. }
  5361. public function _errorexcel()
  5362. {
  5363. $post = $this->input->post(NULL, TRUE);
  5364. if(isset($_GET['page']))
  5365. {
  5366. $page = $this->input->get('page',true);
  5367. $perpage = $this->input->get('perpage',true);
  5368. $sku = $this->input->get('sku',true);
  5369. $warehouse = $this->input->get('warehouse',true);
  5370. $ktime = $this->input->get('ktime',true);
  5371. $jtime = $this->input->get('jtime',true);
  5372. $ktime = strtotime($ktime);
  5373. $jtime = strtotime($jtime);
  5374. $where = "sku != 'Preset'";
  5375. $gj = '';
  5376. if($sku)
  5377. {
  5378. $where .= " and sku like '%$sku%'";
  5379. }
  5380. else
  5381. {
  5382. if($ktime && $jtime)
  5383. {
  5384. $gj = " and time > '$ktime' and time < '$jtime'";
  5385. }
  5386. }
  5387. if($warehouse)
  5388. {
  5389. $where .= " and warehouse = '$warehouse'";
  5390. }
  5391. //数据排序
  5392. $order_str = "id desc";
  5393. if(empty($page))
  5394. {
  5395. $start = 0;
  5396. $perpage = 1;
  5397. }
  5398. else
  5399. {
  5400. $start = ($page - 1)*$perpage;
  5401. }
  5402. //取得信息列表
  5403. $rows = array();$list = array();
  5404. $info_list = $this->whlabel->find_pc($where,'warehouse,features,sku','*');
  5405. foreach ($info_list as $value)
  5406. {
  5407. $warehouse = $this->warehouse->read($value['warehouse']);
  5408. $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5409. $number = $value['number'];$ftime = time()-15*24*3600;
  5410. if($c < 1)
  5411. {
  5412. $list[] = array('warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5413. }
  5414. }
  5415. $title = "0库存汇总";
  5416. $titlename = "<table border=1>
  5417. <tr align='center'>
  5418. <td>仓库</td>
  5419. <td>SKU</td>
  5420. <td>产品</td>
  5421. <td>当前库存</td>
  5422. </tr>
  5423. </table>";
  5424. $filename = $title.".xls";
  5425. $tail = "";
  5426. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5427. }
  5428. }
  5429. /**
  5430. *
  5431. *
  5432. * 占单
  5433. *
  5434. *
  5435. **/
  5436. public function _kcyz()
  5437. {
  5438. $post = $this->input->post(NULL, TRUE);
  5439. if(isset($post['warehouse']))
  5440. {
  5441. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请更新浏览器缓存!','success'=>false)));exit;//不再使用
  5442. $warehouse = $this->input->post('warehouse',true);
  5443. $whlabel = $this->input->post('whlabel',true);
  5444. $id = $this->input->post('id',true);
  5445. $shop = $this->input->post('shop',true);
  5446. $number = $this->input->post('number',true);
  5447. if(!$whlabel || $whlabel == '|')
  5448. {
  5449. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  5450. }
  5451. $pp = explode('|',trim($whlabel,'|'));
  5452. $x = 0;$save = array();
  5453. foreach ($pp as $va)
  5454. {
  5455. $num = explode('-',$va);
  5456. if($number)
  5457. {
  5458. $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 = '')");//通用
  5459. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  5460. }
  5461. else
  5462. {
  5463. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  5464. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  5465. }
  5466. $x++;
  5467. if(count($whlabel)+count($shopwhlabel) < $num[1])
  5468. {
  5469. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  5470. }
  5471. }
  5472. if(isset($save[0]))
  5473. {
  5474. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$save,'success'=>false));exit;
  5475. }
  5476. else
  5477. {
  5478. echo json_encode(array('success'=>true));exit;
  5479. }
  5480. }
  5481. }
  5482. public function _db()
  5483. {
  5484. $post = $this->input->post(NULL, TRUE);
  5485. if(isset($post['page']))
  5486. {
  5487. $page = $this->input->post('page',true);
  5488. $perpage = $this->input->post('perpage',true);
  5489. $sku = $this->input->post('sku',true);
  5490. $number = $this->input->post('number',true);
  5491. $warehouse = $this->input->post('warehouse',true);
  5492. $purchase = $this->input->post('purchase',true);
  5493. $orderinfo = $this->input->post('orderinfo',true);
  5494. $waybill = $this->input->post('waybill',true);
  5495. $category = $this->input->post('category',true);
  5496. $size = $this->input->post('size',true);
  5497. $grade = $this->input->post('grade',true);
  5498. $color = $this->input->post('color',true);
  5499. $lowe = $this->input->post('lowe',true);
  5500. $state = $this->input->post('state',true);
  5501. $label = $this->input->post('label',true);
  5502. $timetk = $this->input->post('timetkk',true);
  5503. $timetj = $this->input->post('timetjj',true);
  5504. $timetk = strtotime($timetk);
  5505. $timetj = strtotime($timetj);
  5506. $where = "dbtime > 0";
  5507. if($timetk && $timetj)
  5508. {
  5509. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5510. }
  5511. if($sku)
  5512. {
  5513. $where .= " and sku = '$sku'";
  5514. }
  5515. if($warehouse)
  5516. {
  5517. $where .= " and warehouse = '$warehouse'";
  5518. if($warehouse == 12)
  5519. {
  5520. $w = 'specialstock';
  5521. }
  5522. else
  5523. {
  5524. $w = 'whlabel';
  5525. }
  5526. }
  5527. if($purchase)
  5528. {
  5529. $where .= " and purchase = '$purchase'";
  5530. }
  5531. if($category)
  5532. {
  5533. $where .= " and features like '%-$category-%'";
  5534. }
  5535. if($size)
  5536. {
  5537. $where .= " and features like '%-$size-%'";
  5538. }
  5539. if($grade)
  5540. {
  5541. $where .= " and features like '%-$grade-%'";
  5542. }
  5543. if($color)
  5544. {
  5545. $where .= " and features like '%-$color-%'";
  5546. }
  5547. if($lowe)
  5548. {
  5549. $where .= " and features like '%-$lowe-%'";
  5550. }
  5551. if($state != '')
  5552. {
  5553. $where .= " and state = '$state'";
  5554. }
  5555. //数据排序
  5556. $order_str = "dbtime desc";
  5557. if(empty($page))
  5558. {
  5559. $start = 0;
  5560. $perpage = 1;
  5561. }
  5562. else
  5563. {
  5564. $start = ($page - 1)*$perpage;
  5565. }
  5566. //取得信息列表
  5567. $info_list = $this->$w->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5568. foreach ($info_list as $key=>$value)
  5569. {
  5570. $warehouse = $this->$w->read($value['warehouse']);
  5571. $info_list[$key]['warehouse'] = $warehouse['title'];
  5572. $purchase = $this->purchase->read($value['purchase']);
  5573. $info_list[$key]['purchase'] = $purchase['title'];
  5574. if($value['enter'] != 0)
  5575. {
  5576. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5577. }
  5578. else
  5579. {
  5580. $info_list[$key]['enter'] = "";
  5581. }
  5582. if($value['dbtime'] != 0)
  5583. {
  5584. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5585. }
  5586. else
  5587. {
  5588. $info_list[$key]['dbtime'] = "";
  5589. }
  5590. if($value['state'] == 0)
  5591. {
  5592. $info_list[$key]['state'] = "在库";
  5593. }
  5594. else if($value['state'] == 1)
  5595. {
  5596. $info_list[$key]['state'] = "出库";
  5597. }
  5598. else if($value['state'] == 2)
  5599. {
  5600. $info_list[$key]['state'] = "退库";
  5601. }
  5602. else if($value['state'] == 3)
  5603. {
  5604. $info_list[$key]['state'] = "调拨中";
  5605. }
  5606. else if($value['state'] == 4)
  5607. {
  5608. $info_list[$key]['state'] = "再加工";
  5609. }
  5610. else if($value['state'] == 5)
  5611. {
  5612. $info_list[$key]['state'] = "维修中";
  5613. }
  5614. else if($value['state'] == 6)
  5615. {
  5616. $info_list[$key]['state'] = "盘亏";
  5617. }
  5618. else if($value['state'] == 7)
  5619. {
  5620. $info_list[$key]['state'] = "更换标签";
  5621. }
  5622. else if($value['state'] == 8)
  5623. {
  5624. $info_list[$key]['state'] = "其它";
  5625. }
  5626. else if($value['state'] == 9)
  5627. {
  5628. $info_list[$key]['state'] = "预设";
  5629. }
  5630. }
  5631. $total = $this->whlabel->find_count($where);
  5632. $pagenum = ceil($total/$perpage);
  5633. $over = $total-($start+$perpage);
  5634. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5635. echo json_encode($rows);exit;
  5636. }
  5637. if(isset($post['outsku']))
  5638. {
  5639. $time = time();
  5640. $cz = $this->input->post('cz',true);
  5641. $label = $this->input->post('outsku',true);
  5642. $sl = $this->input->post('sl',true);
  5643. $num = $this->input->post('num',true);
  5644. //$warehouse = $this->input->post('warehouse',true);
  5645. if(!$sl)
  5646. {
  5647. $sl = 1;
  5648. }
  5649. if(!$warehouse)
  5650. {
  5651. echo json_encode(array('msg'=>'请选择调拨到的仓库','success'=>false));exit;
  5652. }
  5653. $dblabel = $this->whlabellabel->get_label($label);
  5654. if($dblabel)
  5655. {
  5656. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '0' and zd = ''");
  5657. if(count($data) < 1)
  5658. {
  5659. echo json_encode(array('msg'=>'没有此产品数据!','success'=>false));exit;
  5660. }
  5661. if(count($data) < $num)
  5662. {
  5663. echo json_encode(array('msg'=>'库存数量少于调拨数量!','success'=>false));exit;
  5664. }
  5665. for($i=0;$i<$sl;$i++)
  5666. {
  5667. $this->whlabel->save(array('state'=>3,'dbtime'=>$dbtime,'dbcontent'=>$data[$i]['warehouse'].'-'.$time.'|','time'=>$time),$data[$i]['id']);
  5668. }
  5669. echo json_encode(array('success'=>true));exit;
  5670. }
  5671. else
  5672. {
  5673. echo json_encode(array('msg'=>'未找到此条码产品!','success'=>false));exit;
  5674. }
  5675. }
  5676. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5677. $this->_Template('whlabel_db',$this->data);
  5678. }
  5679. public function _dbrk()
  5680. {
  5681. $post = $this->input->post(NULL, TRUE);
  5682. if(isset($post['page']))
  5683. {
  5684. $page = $this->input->post('page',true);
  5685. $perpage = $this->input->post('perpage',true);
  5686. $sku = $this->input->post('sku',true);
  5687. $number = $this->input->post('number',true);
  5688. $warehouse = $this->input->post('warehouse',true);
  5689. $purchase = $this->input->post('purchase',true);
  5690. $orderinfo = $this->input->post('orderinfo',true);
  5691. $waybill = $this->input->post('waybill',true);
  5692. $category = $this->input->post('category',true);
  5693. $size = $this->input->post('size',true);
  5694. $grade = $this->input->post('grade',true);
  5695. $color = $this->input->post('color',true);
  5696. $lowe = $this->input->post('lowe',true);
  5697. $state = $this->input->post('state',true);
  5698. $label = $this->input->post('label',true);
  5699. $ctime = $this->input->post('ctime',true);
  5700. $timetk = $this->input->post('timetkk',true);
  5701. $timetj = $this->input->post('timetjj',true);
  5702. $timetk = strtotime($timetk);
  5703. $timetj = strtotime($timetj);
  5704. $where = "dbtime > 0";
  5705. if($timetk && $timetj)
  5706. {
  5707. $where .= " and ".$ctime." > '$timetk' and ".$ctime." < '$timetj'";
  5708. }
  5709. if($sku)
  5710. {
  5711. $where .= " and sku = '$sku'";
  5712. }
  5713. if($warehouse)
  5714. {
  5715. $where .= " and warehouse = '$warehouse'";
  5716. }
  5717. if($purchase)
  5718. {
  5719. $where .= " and purchase = '$purchase'";
  5720. }
  5721. if($category)
  5722. {
  5723. $where .= " and features like '%-$category-%'";
  5724. }
  5725. if($size)
  5726. {
  5727. $where .= " and features like '%-$size-%'";
  5728. }
  5729. if($grade)
  5730. {
  5731. $where .= " and features like '%-$grade-%'";
  5732. }
  5733. if($color)
  5734. {
  5735. $where .= " and features like '%-$color-%'";
  5736. }
  5737. if($lowe)
  5738. {
  5739. $where .= " and features like '%-$lowe-%'";
  5740. }
  5741. if($state != '')
  5742. {
  5743. $where .= " and state = '$state'";
  5744. }
  5745. //数据排序
  5746. $order_str = "dbtime desc";
  5747. if(empty($page))
  5748. {
  5749. $start = 0;
  5750. $perpage = 1;
  5751. }
  5752. else
  5753. {
  5754. $start = ($page - 1)*$perpage;
  5755. }
  5756. //取得信息列表
  5757. $info_list = $this->whlabel->find_all($where,'id,state,purchase,sku,title,warehouse,dbtime,enter',$order_str,$start,$perpage);
  5758. foreach ($info_list as $key=>$value)
  5759. {
  5760. $warehouse = $this->warehouse->read($value['warehouse']);
  5761. $info_list[$key]['warehouse'] = $warehouse['title'];
  5762. $purchase = $this->purchase->read($value['purchase']);
  5763. $info_list[$key]['purchase'] = $purchase['title'];
  5764. if($value['enter'] != 0)
  5765. {
  5766. $info_list[$key]['enter'] = '<p>'.date('Y-m-d H:i:s',$value['enter']).'</p>';
  5767. }
  5768. else
  5769. {
  5770. $info_list[$key]['enter'] = "";
  5771. }
  5772. if($value['dbtime'] != 0)
  5773. {
  5774. $info_list[$key]['dbtime'] = '<p>'.date('Y-m-d H:i:s',$value['dbtime']).'</p>';
  5775. }
  5776. else
  5777. {
  5778. $info_list[$key]['dbtime'] = "";
  5779. }
  5780. if($value['state'] == 0)
  5781. {
  5782. $info_list[$key]['state'] = "在库";
  5783. }
  5784. else if($value['state'] == 1)
  5785. {
  5786. $info_list[$key]['state'] = "出库";
  5787. }
  5788. else if($value['state'] == 2)
  5789. {
  5790. $info_list[$key]['state'] = "退库";
  5791. }
  5792. else if($value['state'] == 3)
  5793. {
  5794. $info_list[$key]['state'] = "调拨中";
  5795. }
  5796. else if($value['state'] == 4)
  5797. {
  5798. $info_list[$key]['state'] = "再加工";
  5799. }
  5800. else if($value['state'] == 5)
  5801. {
  5802. $info_list[$key]['state'] = "维修中";
  5803. }
  5804. else if($value['state'] == 6)
  5805. {
  5806. $info_list[$key]['state'] = "盘亏";
  5807. }
  5808. else if($value['state'] == 7)
  5809. {
  5810. $info_list[$key]['state'] = "更换标签";
  5811. }
  5812. else if($value['state'] == 8)
  5813. {
  5814. $info_list[$key]['state'] = "其它";
  5815. }
  5816. else if($value['state'] == 9)
  5817. {
  5818. $info_list[$key]['state'] = "预设";
  5819. }
  5820. }
  5821. $total = $this->whlabel->find_count($where);
  5822. $pagenum = ceil($total/$perpage);
  5823. $over = $total-($start+$perpage);
  5824. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5825. echo json_encode($rows);exit;
  5826. }
  5827. if(isset($post['rsku']))
  5828. {
  5829. $cz = $this->input->post('cz',true);
  5830. $label = $this->input->post('rsku',true);
  5831. $sl = $this->input->post('sl',true);
  5832. $warehouse = $this->input->post('warehouse',true);
  5833. if(!$sl)
  5834. {
  5835. $sl = 1;
  5836. }
  5837. if(!$warehouse)
  5838. {
  5839. echo json_encode(array('msg'=>'请选择入库仓库','success'=>false));exit;
  5840. }
  5841. $dblabel = $this->whlabellabel->get_label($label);
  5842. if($dblabel)
  5843. {
  5844. $data = $this->whlabel->find_all("features = '".$dblabel['features']."' and warehouse = '".$dblabel['warehouse']."' and shop = '".$dblabel['shop']."' and state = '3' and zd = ''");
  5845. if(count($data) < 1)
  5846. {
  5847. echo json_encode(array('msg'=>'没有此SKU调拨数据!','success'=>false));exit;
  5848. }
  5849. if($sl > count($data))
  5850. {
  5851. echo json_encode(array('msg'=>'入库数量大于调拨数量!','success'=>false));exit;
  5852. }
  5853. $time = time();
  5854. for($i=0;$i<$sl;$i++)
  5855. {
  5856. $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']);
  5857. }
  5858. echo json_encode(array('success'=>true));exit;
  5859. }
  5860. else
  5861. {
  5862. echo json_encode(array('msg'=>'没有此条码的库存信息!','success'=>false));exit;
  5863. }
  5864. }
  5865. $this->data['url'] = str_replace('/','',$this->uri->slash_segment(2));
  5866. $this->_Template('whlabel_dbrk',$this->data);
  5867. }
  5868. public function _whlabelczdc()
  5869. {
  5870. if(isset($_GET['excel']))
  5871. {
  5872. //数据排序
  5873. $order_str = "id desc";
  5874. if(empty($page))
  5875. {
  5876. $start = 0;
  5877. $perpage = 1;
  5878. }
  5879. else
  5880. {
  5881. $start = ($page - 1)*$perpage;
  5882. }
  5883. $state = $this->input->get('state',true);
  5884. $sku = $this->input->get('sku',true);
  5885. $ctime = $this->input->get('ctime',true);
  5886. $category = $this->input->get('category',true);
  5887. $size = $this->input->get('size',true);
  5888. $grade = $this->input->get('grade',true);
  5889. $color = $this->input->get('color',true);
  5890. $lowe = $this->input->get('lowe',true);
  5891. $timetk = $this->input->get('timetkk',true);
  5892. $timetj = $this->input->get('timetjj',true);
  5893. $timetk = strtotime($timetk);
  5894. $timetj = strtotime($timetj);
  5895. $where = "dbtime > 0";
  5896. if($timetk && $timetj)
  5897. {
  5898. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5899. }
  5900. if($category)
  5901. {
  5902. $where .= " and features like '%-$category-%'";
  5903. }
  5904. if($size)
  5905. {
  5906. $where .= " and features like '%-$size-%'";
  5907. }
  5908. if($grade)
  5909. {
  5910. $where .= " and features like '%-$grade-%'";
  5911. }
  5912. if($color)
  5913. {
  5914. $where .= " and features like '%-$color-%'";
  5915. }
  5916. if($lowe)
  5917. {
  5918. $where .= " and features like '%-$lowe-%'";
  5919. }
  5920. //取得信息列表
  5921. $info_list = $this->whlabel->find_all($where,'*');
  5922. $rows = array();$list = array();
  5923. foreach ($info_list as $key=>$value)
  5924. {
  5925. $rows[$value['sku']] = $value;//所有数据sku
  5926. }
  5927. foreach ($rows as $value)
  5928. {
  5929. $warehouse = $this->warehouse->read($value['warehouse']);
  5930. $db = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'"');
  5931. $rk = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and enter > 0');
  5932. if($value['orderinfo'] == 0)
  5933. {
  5934. $info_list[$key]['orderinfo'] = "";
  5935. }
  5936. if($value['waybill'] == 0)
  5937. {
  5938. $info_list[$key]['waybill'] = "";
  5939. }
  5940. if($value['state'] == 0)
  5941. {
  5942. $value['state'] = "在库";
  5943. }
  5944. else if($value['state'] == 3)
  5945. {
  5946. $value['state'] = "调拨中";
  5947. }
  5948. $list[] = array($value['sku'],$value['title'],$db,$rk);
  5949. }
  5950. $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj)."统计表";
  5951. $titlename = "<table border=1>
  5952. <tr><th colspan='4' align='center'><h3>".$title."<h3></th></tr>
  5953. <tr align='center'>
  5954. <td>SKU</td>
  5955. <td>产品</td>
  5956. <td>调拨数量</td>
  5957. <td>入库数量</td>
  5958. </tr>
  5959. </table>";
  5960. $filename = $title.".xls";
  5961. $tail = "";
  5962. $this->excel->get_fz2($list,$titlename,$filename,$tail);
  5963. }
  5964. }
  5965. public function _print($arg_array)
  5966. {
  5967. if(isset($_SESSION['api']))
  5968. {
  5969. $user = $this->user->get_api($_SESSION['api']);
  5970. $usp = $user;
  5971. $fgshop = "";$sid = "";$wid="";$wtype="";
  5972. $usersp = explode('|',trim($user['shop'],'|'));
  5973. $userwh = explode('|',trim($user['warehouse'],'|'));
  5974. foreach ($usersp as $value)
  5975. {
  5976. $fgshop .= " shop = ".$value." or";
  5977. $sid .= " id = ".$value." or";
  5978. }
  5979. foreach ($userwh as $value)
  5980. {
  5981. $wid .= " id = ".$value." or";
  5982. $wtype .= " type = ".$value." or";
  5983. }
  5984. }
  5985. $post = $this->input->post(NULL, TRUE);
  5986. if(isset($post['tmsku']))
  5987. {
  5988. $tmsku = $this->input->post('tmsku',true);
  5989. if(is_numeric($tmsku))
  5990. {
  5991. $yyh = $this->whlabellabel->get_label($tmsku);
  5992. }
  5993. else
  5994. {
  5995. $yyh = $this->whlabellabel->get_sku($tmsku);
  5996. }
  5997. if($yyh)
  5998. {
  5999. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  6000. }
  6001. else
  6002. {
  6003. echo json_encode(array('success'=>false));exit;
  6004. }
  6005. }
  6006. $classid = $this->classid->sku();
  6007. $pm = $classid;
  6008. $scsku = $classid;
  6009. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6010. if(isset($post['warehouse']))
  6011. {
  6012. if($post['warehouse'])
  6013. {
  6014. $list = array();$num = "";$title = "";$features = "";
  6015. $order = 0;
  6016. $post['shop'] = '';
  6017. $brand = $this->input->post('brand',true);
  6018. if($brand != '0,')
  6019. {
  6020. $b = $this->brand->read(rtrim($brand,','));
  6021. if($b)
  6022. {
  6023. $post['shop'] = str_replace('|',',',$b['shop']);
  6024. }
  6025. }
  6026. $post['details'] = $this->input->post('details',true);//打印数量
  6027. $xbqnum = $this->input->post('xbqnum',true);
  6028. $post['purchase'] = $this->input->post('purchase',true);
  6029. $post['warehouse'] = $this->input->post('warehouse',true);
  6030. $post['purchase'] = $this->input->post('purchase',true);
  6031. $post['retreatwarehouse'] = $post['warehouse'];
  6032. $post['cpbz'] = $this->input->post('cpbz',true);
  6033. $post['state'] = 9;
  6034. $category = $this->input->post('category',true);
  6035. $list['category'] = $category;
  6036. $list['hairtype'] = $this->input->post('hairtype',true);
  6037. $list['grade'] = $this->input->post('grade',true);
  6038. $size = $this->input->post('size',true);
  6039. $list['size'] = rtrim($size,',');
  6040. $list['hairnumber'] = $this->input->post('hairnumber',true);
  6041. $list['extension'] = $this->input->post('extension',true);
  6042. if($category == 1297)
  6043. {
  6044. $list['sywignumber'] = $this->input->post('sywignumber',true);
  6045. }
  6046. if($category == 1702)
  6047. {
  6048. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  6049. $list['syother'] = $this->input->post('syother',true);
  6050. }
  6051. if($category == 133)
  6052. {
  6053. $list['fittype'] = $this->input->post('fittype',true);
  6054. $list['acother'] = $this->input->post('acother',true);
  6055. }
  6056. $list['color'] = $this->input->post('color',true);
  6057. $list['lowe'] = $this->input->post('lowe',true);
  6058. if($category == 127)
  6059. {
  6060. $list['type'] = $this->input->post('type',true);
  6061. $list['headroad'] = $this->input->post('headroad',true);
  6062. $list['density'] = $this->input->post('density',true);
  6063. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  6064. {
  6065. $list['lacesize'] = $this->input->post('lacesize',true);
  6066. }
  6067. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6068. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6069. }
  6070. if($category == 128)
  6071. {
  6072. $list['lacetype'] = $this->input->post('lacetype',true);
  6073. $list['haircap'] = $this->input->post('haircap',true);
  6074. $list['density'] = $this->input->post('density',true);
  6075. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6076. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6077. $list['wigother'] = $this->input->post('wigother',true);
  6078. $list['wigother2'] = $this->input->post('wigother2',true);
  6079. }
  6080. if($category == 129)
  6081. {
  6082. $list['wide'] = $this->input->post('wide',true);
  6083. }
  6084. if($category == 131)
  6085. {
  6086. $list['gifttype'] = $this->input->post('gifttype',true);
  6087. $list['giftother'] = $this->input->post('giftother',true);
  6088. }
  6089. if($category == 134)
  6090. {
  6091. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6092. }
  6093. if($category == 1297)
  6094. {
  6095. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6096. $list['sywigother'] = $this->input->post('sywigother',true);
  6097. }
  6098. if($category == 130 || $category == 133 || $category == 1702)
  6099. {
  6100. $list['items'] = $this->input->post('items',true);
  6101. $list['weight'] = $this->input->post('weight',true);
  6102. }
  6103. if($category == 1702)
  6104. {
  6105. $list['syhairther'] = $this->input->post('syhairther',true);
  6106. }
  6107. foreach($list as $k=>$v)
  6108. {
  6109. if($v != 0)
  6110. {
  6111. $num .=$v;
  6112. $features .=$v.'-';
  6113. $post[$k] = $v;
  6114. $typeclass = $this->typeclass->read($v);
  6115. if(isset($pm[$typeclass['classid']]))
  6116. {
  6117. if(stripos($typeclass['zh'],'|') !== false)
  6118. {
  6119. $exzh = explode('|',$typeclass['zh']);
  6120. $pm[$typeclass['classid']] = $exzh[0];
  6121. }
  6122. else
  6123. {
  6124. $pm[$typeclass['classid']] = $typeclass['zh'];
  6125. }
  6126. }
  6127. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6128. if($k != 'size')
  6129. {
  6130. $title .= $typeclass['title']." ";
  6131. }
  6132. }
  6133. }
  6134. $typeclass = $this->typeclass->read($list['size']);
  6135. $title .= $typeclass['title'];
  6136. $time = time();
  6137. $post['title'] = rtrim($title,' ');
  6138. $post['number'] = $num;
  6139. $post['features'] = '-'.$features;
  6140. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6141. $featurespp = explode('-',trim($featurespp,'-'));
  6142. if(isset($featurespp[5]))
  6143. {
  6144. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6145. }
  6146. else
  6147. {
  6148. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6149. }
  6150. $post['enter'] = $time;
  6151. $post['time'] = $time;//操作时间
  6152. $scsku = implode("-",$scsku);
  6153. $zh = implode(" ",$pm);
  6154. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6155. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6156. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6157. $post['sku'] = $bqsku;
  6158. $label = time().rand(0,9);
  6159. $post['label'] = $label;
  6160. $cpid = $this->whlabellabel->find_count();
  6161. $post['cpid'] = $cpid+1;
  6162. $cpid = $post['cpid'];
  6163. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6164. //if($whlabelbarcode)
  6165. //{
  6166. //$post['label'] = $whlabelbarcode['label'];
  6167. //if(!$this->whlabellabel->insert($post))
  6168. //{
  6169. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6170. //}
  6171. //}
  6172. //else
  6173. //{
  6174. $this->db->trans_begin();
  6175. $this->whlabellabel->insert($post);
  6176. //$this->whlabelbarcode->insert($post);
  6177. if ($this->db->trans_status() === TRUE)
  6178. {
  6179. $this->db->trans_commit();
  6180. }
  6181. else
  6182. {
  6183. $this->db->trans_rollback();
  6184. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6185. }
  6186. //}
  6187. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6188. $purchase = $this->purchase->read($post['purchase']);
  6189. 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;//特殊仓目前不需要仓库选项
  6190. }
  6191. }
  6192. if(isset($_SESSION['api']))
  6193. {
  6194. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6195. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6196. $this->data['wlshop'] = $wlshop;
  6197. $this->data['warehouse'] = $warehouse;
  6198. }
  6199. $whlabelwz = $this->whlabelwz->find_all();
  6200. $this->data['whlabelwz'] = $whlabelwz;
  6201. $this->_Template('whlabel_print',$this->data);
  6202. }
  6203. public function _usaprint($arg_array)
  6204. {
  6205. if(isset($_SESSION['api']))
  6206. {
  6207. $user = $this->user->get_api($_SESSION['api']);
  6208. $usp = $user;
  6209. $fgshop = "";$sid = "";$wid="";$wtype="";
  6210. $usersp = explode('|',trim($user['shop'],'|'));
  6211. $userwh = explode('|',trim($user['warehouse'],'|'));
  6212. foreach ($usersp as $value)
  6213. {
  6214. $fgshop .= " shop = ".$value." or";
  6215. $sid .= " id = ".$value." or";
  6216. }
  6217. foreach ($userwh as $value)
  6218. {
  6219. $wid .= " id = ".$value." or";
  6220. $wtype .= " type = ".$value." or";
  6221. }
  6222. }
  6223. $post = $this->input->post(NULL, TRUE);
  6224. if(isset($post['tmsku']))
  6225. {
  6226. $tmsku = $this->input->post('tmsku',true);
  6227. if(is_numeric($tmsku))
  6228. {
  6229. $yyh = $this->whlabellabel->get_label($tmsku);
  6230. }
  6231. else
  6232. {
  6233. $yyh = $this->whlabellabel->get_sku($tmsku);
  6234. }
  6235. if($yyh)
  6236. {
  6237. echo json_encode(array('features'=>$yyh['features'],'success'=>true));exit;
  6238. }
  6239. else
  6240. {
  6241. echo json_encode(array('success'=>false));exit;
  6242. }
  6243. }
  6244. $classid = $this->classid->sku();
  6245. $pm = $classid;
  6246. $scsku = $classid;
  6247. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6248. if(isset($post['warehouse']))
  6249. {
  6250. if($post['warehouse'])
  6251. {
  6252. $list = array();$num = "";$title = "";$features = "";
  6253. $order = 0;
  6254. $post['shop'] = '';
  6255. $brand = $this->input->post('brand',true);
  6256. if($brand != '0,')
  6257. {
  6258. $b = $this->brand->read(rtrim($brand,','));
  6259. if($b)
  6260. {
  6261. $post['shop'] = str_replace('|',',',$b['shop']);
  6262. }
  6263. }
  6264. $post['details'] = $this->input->post('details',true);//打印数量
  6265. $xbqnum = $this->input->post('xbqnum',true);
  6266. $post['purchase'] = $this->input->post('purchase',true);
  6267. $post['warehouse'] = $this->input->post('warehouse',true);
  6268. $post['purchase'] = $this->input->post('purchase',true);
  6269. $post['retreatwarehouse'] = $post['warehouse'];
  6270. $post['cpbz'] = $this->input->post('cpbz',true);
  6271. $post['state'] = 9;
  6272. $category = $this->input->post('category',true);
  6273. $list['category'] = $category;
  6274. $list['hairtype'] = $this->input->post('hairtype',true);
  6275. $list['grade'] = $this->input->post('grade',true);
  6276. $size = $this->input->post('size',true);
  6277. $list['size'] = rtrim($size,',');
  6278. $list['hairnumber'] = $this->input->post('hairnumber',true);
  6279. $list['extension'] = $this->input->post('extension',true);
  6280. if($category == 1297)
  6281. {
  6282. $list['sywignumber'] = $this->input->post('sywignumber',true);
  6283. }
  6284. if($category == 1702)
  6285. {
  6286. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  6287. $list['syother'] = $this->input->post('syother',true);
  6288. }
  6289. if($category == 133)
  6290. {
  6291. $list['fittype'] = $this->input->post('fittype',true);
  6292. $list['acother'] = $this->input->post('acother',true);
  6293. }
  6294. $list['color'] = $this->input->post('color',true);
  6295. $list['lowe'] = $this->input->post('lowe',true);
  6296. if($category == 127)
  6297. {
  6298. $list['type'] = $this->input->post('type',true);
  6299. $list['headroad'] = $this->input->post('headroad',true);
  6300. $list['density'] = $this->input->post('density',true);
  6301. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  6302. {
  6303. $list['lacesize'] = $this->input->post('lacesize',true);
  6304. }
  6305. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6306. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6307. }
  6308. if($category == 128)
  6309. {
  6310. $list['lacetype'] = $this->input->post('lacetype',true);
  6311. $list['haircap'] = $this->input->post('haircap',true);
  6312. $list['density'] = $this->input->post('density',true);
  6313. $list['lacecolor'] = $this->input->post('lacecolor',true);
  6314. $list['lacetypes'] = $this->input->post('lacetypes',true);
  6315. $list['wigother'] = $this->input->post('wigother',true);
  6316. $list['wigother2'] = $this->input->post('wigother2',true);
  6317. }
  6318. if($category == 129)
  6319. {
  6320. $list['wide'] = $this->input->post('wide',true);
  6321. }
  6322. if($category == 131)
  6323. {
  6324. $list['gifttype'] = $this->input->post('gifttype',true);
  6325. $list['giftother'] = $this->input->post('giftother',true);
  6326. }
  6327. if($category == 134)
  6328. {
  6329. $list['pieceweight'] = $this->input->post('pieceweight',true);
  6330. }
  6331. if($category == 1297)
  6332. {
  6333. $list['synthetictype'] = $this->input->post('synthetictype',true);
  6334. $list['sywigother'] = $this->input->post('sywigother',true);
  6335. }
  6336. if($category == 130 || $category == 133 || $category == 1702)
  6337. {
  6338. $list['items'] = $this->input->post('items',true);
  6339. $list['weight'] = $this->input->post('weight',true);
  6340. }
  6341. if($category == 1702)
  6342. {
  6343. $list['syhairther'] = $this->input->post('syhairther',true);
  6344. }
  6345. foreach($list as $k=>$v)
  6346. {
  6347. if($v != 0)
  6348. {
  6349. $num .=$v;
  6350. $features .=$v.'-';
  6351. $post[$k] = $v;
  6352. $typeclass = $this->typeclass->read($v);
  6353. if(isset($pm[$typeclass['classid']]))
  6354. {
  6355. if(stripos($typeclass['zh'],'|') !== false)
  6356. {
  6357. $exzh = explode('|',$typeclass['zh']);
  6358. $pm[$typeclass['classid']] = $exzh[0];
  6359. }
  6360. else
  6361. {
  6362. $pm[$typeclass['classid']] = $typeclass['zh'];
  6363. }
  6364. }
  6365. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6366. if($k != 'size')
  6367. {
  6368. $title .= $typeclass['title']." ";
  6369. }
  6370. }
  6371. }
  6372. $typeclass = $this->typeclass->read($list['size']);
  6373. $title .= $typeclass['title'];
  6374. $time = time();
  6375. $post['title'] = rtrim($title,' ');
  6376. $post['number'] = $num;
  6377. $post['features'] = '-'.$features;
  6378. $fp = $this->whlabel->get_features($post['features']);
  6379. if(!$fp)
  6380. {
  6381. echo json_encode(array('msg'=>'美仓无此产品,需要添加后才可打印','success'=>false));exit;
  6382. }
  6383. $featurespp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$features);
  6384. $featurespp = explode('-',trim($featurespp,'-'));
  6385. if(isset($featurespp[5]))
  6386. {
  6387. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4].'-'.$featurespp[5];
  6388. }
  6389. else
  6390. {
  6391. $post['featurespp'] = $featurespp[0].'-'.$featurespp[3].'-'.$featurespp[4];
  6392. }
  6393. $post['enter'] = $time;
  6394. $post['time'] = $time;//操作时间
  6395. $scsku = implode("-",$scsku);
  6396. $zh = implode(" ",$pm);
  6397. $scsku = str_replace('- ','-',trim($scsku,'-'));
  6398. $scsku = str_replace(array('--------','-------','------','-----','----','---','--'),'-',$scsku);
  6399. $bqsku = (isset($b['title']))?$b['title'].'-'.$scsku:$scsku;;
  6400. $post['sku'] = $fp['sku'];
  6401. $post['label'] = $fp['sku'];
  6402. $cpid = $this->whlabellabel->find_count();
  6403. $post['cpid'] = $cpid+1;
  6404. $cpid = $post['cpid'];
  6405. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6406. //if($whlabelbarcode)
  6407. //{
  6408. //$post['label'] = $whlabelbarcode['label'];
  6409. //if(!$this->whlabellabel->insert($post))
  6410. //{
  6411. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6412. //}
  6413. //}
  6414. //else
  6415. //{
  6416. $this->db->trans_begin();
  6417. $this->whlabellabel->insert($post);
  6418. //$this->whlabelbarcode->insert($post);
  6419. if ($this->db->trans_status() === TRUE)
  6420. {
  6421. $this->db->trans_commit();
  6422. }
  6423. else
  6424. {
  6425. $this->db->trans_rollback();
  6426. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6427. }
  6428. //}
  6429. $details = ($post['details'] != '')?'位置:('.$post['details'].') <font style="font-size: 18px;">'.$cpid.'</font>':'';
  6430. $purchase = $this->purchase->read($post['purchase']);
  6431. 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;//特殊仓目前不需要仓库选项
  6432. }
  6433. }
  6434. if(isset($_SESSION['api']))
  6435. {
  6436. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  6437. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  6438. $this->data['wlshop'] = $wlshop;
  6439. $this->data['warehouse'] = $warehouse;
  6440. }
  6441. $whlabelwz = $this->whlabelwz->find_all();
  6442. $this->data['whlabelwz'] = $whlabelwz;
  6443. $this->_Template('whlabel_usaprint',$this->data);
  6444. }
  6445. public function _printrk($arg_array)
  6446. {
  6447. $prc = array();
  6448. $purchase = $this->purchase->find_all();
  6449. foreach($purchase as $k=>$v)
  6450. {
  6451. $prc[$v['id']] = $v['title'];
  6452. }
  6453. $post = $this->input->post(NULL, TRUE);
  6454. if(isset($post['page']))
  6455. {
  6456. $page = $this->input->post('page',true);
  6457. $perpage = $this->input->post('perpage',true);
  6458. $sku = $this->input->post('sku',true);
  6459. $bs = $this->input->post('bs',true);
  6460. $number = $this->input->post('number',true);
  6461. $warehouse = $this->input->post('warehouse',true);
  6462. $purchase = $this->input->post('purchase',true);
  6463. $orderinfo = $this->input->post('orderinfo',true);
  6464. $waybill = $this->input->post('waybill',true);
  6465. $category = $this->input->post('category',true);
  6466. $size = $this->input->post('size',true);
  6467. $grade = $this->input->post('grade',true);
  6468. $color = $this->input->post('color',true);
  6469. $lowe = $this->input->post('lowe',true);
  6470. $state = $this->input->post('state',true);
  6471. $label = $this->input->post('label',true);
  6472. $timetk = $this->input->post('ktime',true);
  6473. $timetj = $this->input->post('jtime',true);
  6474. $timetk = strtotime($timetk);
  6475. $timetj = strtotime($timetj);
  6476. $where = "1=1 ";
  6477. if($timetk && $timetj)
  6478. {
  6479. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6480. }
  6481. if($sku)
  6482. {
  6483. $where .= " and sku = '$sku'";
  6484. }
  6485. if($bs != '')
  6486. {
  6487. $where .= " and bs = '$bs'";
  6488. }
  6489. if($number)
  6490. {
  6491. $where .= " and number = '$number'";
  6492. }
  6493. if($warehouse)
  6494. {
  6495. $where .= " and warehouse = '$warehouse'";
  6496. }
  6497. if($purchase)
  6498. {
  6499. $where .= " and purchase = '$purchase'";
  6500. }
  6501. if($orderinfo)
  6502. {
  6503. $where .= " and orderinfo = '$orderinfo'";
  6504. }
  6505. if($waybill)
  6506. {
  6507. $where .= " and waybill = '$waybill'";
  6508. }
  6509. if($category)
  6510. {
  6511. $where .= " and features like '%-$category-%'";
  6512. }
  6513. if($size)
  6514. {
  6515. $where .= " and features like '%-$size-%'";
  6516. }
  6517. if($grade)
  6518. {
  6519. $where .= " and features like '%-$grade-%'";
  6520. }
  6521. if($color)
  6522. {
  6523. $where .= " and features like '%-$color-%'";
  6524. }
  6525. if($lowe)
  6526. {
  6527. $where .= " and features like '%-$lowe-%'";
  6528. }
  6529. if($label)
  6530. {
  6531. $where .= " and label = '$label'";
  6532. }
  6533. if($state || $state == 0)
  6534. {
  6535. $where .= " and state = '$state'";
  6536. }
  6537. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6538. //数据排序
  6539. $order_str = "enter desc";
  6540. if(empty($page))
  6541. {
  6542. $start = 0;
  6543. $perpage = 1;
  6544. }
  6545. else
  6546. {
  6547. $start = ($page - 1)*$perpage;
  6548. }
  6549. //取得信息列表
  6550. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,enter,details',$order_str,$start,$perpage);
  6551. foreach ($info_list as $key=>$value)
  6552. {
  6553. $warehouse = $this->warehouse->read($value['warehouse']);
  6554. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6555. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6556. if($value['state'] == 0)
  6557. {
  6558. $info_list[$key]['state'] = "在库";
  6559. }
  6560. else if($value['state'] == 1)
  6561. {
  6562. $info_list[$key]['state'] = "出库";
  6563. }
  6564. else if($value['state'] == 2)
  6565. {
  6566. $info_list[$key]['state'] = "退库";
  6567. }
  6568. else if($value['state'] == 3)
  6569. {
  6570. $info_list[$key]['state'] = "调拨中";
  6571. }
  6572. else if($value['state'] == 4)
  6573. {
  6574. $info_list[$key]['state'] = "再加工";
  6575. }
  6576. else if($value['state'] == 5)
  6577. {
  6578. $info_list[$key]['state'] = "维修中";
  6579. }
  6580. else if($value['state'] == 6)
  6581. {
  6582. $info_list[$key]['state'] = "盘亏";
  6583. }
  6584. else if($value['state'] == 7)
  6585. {
  6586. $info_list[$key]['state'] = "更换标签";
  6587. }
  6588. else if($value['state'] == 8)
  6589. {
  6590. $info_list[$key]['state'] = "其它";
  6591. }
  6592. else if($value['state'] == 9)
  6593. {
  6594. $info_list[$key]['state'] = "预设";
  6595. }
  6596. else if($value['state'] == 10)
  6597. {
  6598. $info_list[$key]['state'] = "美店零售";
  6599. }
  6600. $info_list[$key]['enter'] = date('Y-m-d H:i:s',$value['enter']);
  6601. }
  6602. $total = $this->$ck->find_count($where);
  6603. $pagenum = ceil($total/$perpage);
  6604. $over = $total-($start+$perpage);
  6605. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6606. echo json_encode($rows);exit;
  6607. }
  6608. if(isset($post['tmsku']))
  6609. {
  6610. $time = time();
  6611. $tmsku = $this->input->post('tmsku',true);
  6612. //$post['shop'] = $this->input->post('shop',true);
  6613. $num = $this->input->post('num',true);
  6614. $rktype = $this->input->post('rktype',true);
  6615. if($num > 200)
  6616. {
  6617. echo json_encode(array('msg'=>'入库数量不允许超过200!','c'=>0,'success'=>false));exit;
  6618. }
  6619. if(!$rktype)
  6620. {
  6621. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6622. }
  6623. $rk = $this->whlabellabel->find_all("label = '$tmsku'","*","id desc");
  6624. /**
  6625. $wz = array();
  6626. foreach ($rk as $key=>$value)
  6627. {
  6628. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6629. }
  6630. if(count($wz) > 1)
  6631. {
  6632. $wz = array_values($wz);
  6633. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6634. }
  6635. **/
  6636. if(isset($rk[0]['purchase']))
  6637. {
  6638. $rk = $rk[0];
  6639. $j = 0;
  6640. $post['purchase'] = $rk['purchase'];
  6641. $post['warehouse'] = $rk['warehouse'];
  6642. $post['retreatwarehouse'] = $rk['warehouse'];
  6643. $post['sku'] = $rk['sku'];
  6644. $post['number'] = $rk['number'];
  6645. $post['features'] = $rk['features'];
  6646. $post['title'] = $rk['title'];
  6647. $post['enter'] = $time;
  6648. $post['time'] = $time;
  6649. $post['bs'] = 1;
  6650. $post['shop'] = $rk['shop'];
  6651. $post['details'] = $rk['details'];
  6652. $post['cpid'] = $rk['cpid'];
  6653. $post['cpbz'] = $rk['cpbz'];
  6654. //$post['rktype'] = $rktype;
  6655. $warehouse = $this->warehouse->read($rk['warehouse']);
  6656. if($warehouse['bdck'] == '')
  6657. {
  6658. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','c'=>0,'success'=>false));exit;
  6659. }
  6660. else
  6661. {
  6662. $bdck = $warehouse['bdck'];
  6663. }
  6664. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'],$post['sku']);
  6665. if(isset($pdwz['details']))
  6666. {
  6667. if($pdwz['details'] != $post['details'])
  6668. {
  6669. echo json_encode(array('msg'=>'此产品位置应为:'.$pdwz['details'],'c'=>0,'cs'=>$pdwz['details'].' - '.$post['details'],'success'=>false));exit;
  6670. }
  6671. }
  6672. $post['featurespp'] = $rk['featurespp'];
  6673. if($post['warehouse'] == '5')
  6674. {
  6675. $yza = $this->whlabel->find_all("sku = '".$post['sku']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6676. if($yza)
  6677. {
  6678. if($post['features'] != $yza[0]['features'])
  6679. {
  6680. echo json_encode(array('msg'=>'此SKU的产品信息和现有不一致!','new'=>$post['features'].'-'.$post['sku'],'old'=>$yza[0]['features'],'c'=>0,'success'=>false));exit;
  6681. }
  6682. }
  6683. $yzb = $this->whlabel->find_all("features = '".$post['features']."' and warehouse = '".$post['warehouse']."' and shop = '".$post['shop']."'");
  6684. if($yzb)
  6685. {
  6686. if($post['sku'] != $yzb[0]['sku'])
  6687. {
  6688. echo json_encode(array('msg'=>'此产品信息的SKU和现有'.$yzb[0]['sku'].'不一致!','c'=>0,'success'=>false));exit;
  6689. }
  6690. }
  6691. }
  6692. for($i=0;$i<$num;$i++)
  6693. {
  6694. $post['label'] = time().rand(100,999).$i;
  6695. if($this->$bdck->insert($post))
  6696. {
  6697. $j++;
  6698. }
  6699. }
  6700. /**
  6701. if($post['warehouse'] != 12)
  6702. {
  6703. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6704. }
  6705. **/
  6706. if($j == $num)
  6707. {
  6708. echo json_encode(array('msg'=>'入库成功!','success'=>true));exit;
  6709. }
  6710. else
  6711. {
  6712. echo json_encode(array('msg'=>'未成功入库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6713. }
  6714. }
  6715. else
  6716. {
  6717. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6718. }
  6719. }
  6720. $this->_Template('whlabel_printrk',$this->data);
  6721. }
  6722. public function _printxzrk($arg_array)
  6723. {
  6724. $post = $this->input->post(NULL, TRUE);
  6725. if(isset($post['wzid']))
  6726. {
  6727. $time = time();
  6728. $id = $this->input->post('wzid',true);
  6729. //$post['shop'] = $this->input->post('shop',true);
  6730. $num = 1;
  6731. $rk = $this->whlabellabel->read($id);
  6732. if(isset($rk['purchase']))
  6733. {
  6734. $x = 0;
  6735. $post['purchase'] = $rk['purchase'];
  6736. $post['warehouse'] = $rk['warehouse'];
  6737. $post['retreatwarehouse'] = $rk['warehouse'];
  6738. $post['sku'] = $rk['sku'];
  6739. $post['number'] = $rk['number'];
  6740. $post['features'] = $rk['features'];
  6741. $post['title'] = $rk['title'];
  6742. $post['enter'] = $time;
  6743. $post['time'] = $time;
  6744. $post['bs'] = 1;
  6745. $post['shop'] = $rk['shop'];
  6746. $post['details'] = $rk['details'];
  6747. $post['cpid'] = $rk['cpid'];
  6748. $post['cpbz'] = $rk['cpbz'];
  6749. $warehouse = $this->warehouse->read($rk['warehouse']);
  6750. if($warehouse['bdck'] == '')
  6751. {
  6752. echo json_encode(array('msg'=>'此仓库没有设置现货,无法入库!','success'=>false));exit;
  6753. }
  6754. else
  6755. {
  6756. $bdck = $warehouse['bdck'];
  6757. }
  6758. $post['featurespp'] = $rk['featurespp'];
  6759. $this->db->trans_begin();
  6760. for($i=0;$i<$num;$i++)
  6761. {
  6762. $post['label'] = time().rand(100,999).$i;
  6763. $this->$bdck->insert($post);
  6764. }
  6765. /**
  6766. if($post['warehouse'] != 12)
  6767. {
  6768. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6769. }
  6770. **/
  6771. if ($this->db->trans_status() === TRUE)
  6772. {
  6773. $this->db->trans_commit();
  6774. echo json_encode(array('msg'=>'入库成功!','cs'=>$post,'cs2'=>$warehouse,'success'=>true));exit;
  6775. }
  6776. else
  6777. {
  6778. $this->db->trans_rollback();
  6779. echo json_encode(array('msg'=>'入库失败,请重试','c'=>0,'success'=>false));exit;
  6780. }
  6781. }
  6782. else
  6783. {
  6784. echo json_encode(array('msg'=>'未找到此条码数据!','c'=>0,'success'=>false));exit;
  6785. }
  6786. }
  6787. }
  6788. public function _printck($arg_array)
  6789. {
  6790. $prc = array();
  6791. $purchase = $this->purchase->find_all();
  6792. foreach($purchase as $k=>$v)
  6793. {
  6794. $prc[$v['id']] = $v['title'];
  6795. }
  6796. $post = $this->input->post(NULL, TRUE);
  6797. if(isset($post['page']))
  6798. {
  6799. $page = $this->input->post('page',true);
  6800. $perpage = $this->input->post('perpage',true);
  6801. $sku = $this->input->post('sku',true);
  6802. $bs = $this->input->post('bs',true);
  6803. $number = $this->input->post('number',true);
  6804. $warehouse = $this->input->post('warehouse',true);
  6805. $purchase = $this->input->post('purchase',true);
  6806. $orderinfo = $this->input->post('orderinfo',true);
  6807. $waybill = $this->input->post('waybill',true);
  6808. $category = $this->input->post('category',true);
  6809. $size = $this->input->post('size',true);
  6810. $grade = $this->input->post('grade',true);
  6811. $color = $this->input->post('color',true);
  6812. $lowe = $this->input->post('lowe',true);
  6813. $state = $this->input->post('state',true);
  6814. $label = $this->input->post('label',true);
  6815. $timetk = $this->input->post('ktime',true);
  6816. $timetj = $this->input->post('jtime',true);
  6817. $timetk = strtotime($timetk);
  6818. $timetj = strtotime($timetj);
  6819. $where = "state=1 ";
  6820. if($timetk && $timetj)
  6821. {
  6822. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6823. }
  6824. if($sku)
  6825. {
  6826. $where .= " and sku = '$sku'";
  6827. }
  6828. if($bs != '')
  6829. {
  6830. $where .= " and bs = '$bs'";
  6831. }
  6832. if($number)
  6833. {
  6834. $where .= " and number = '$number'";
  6835. }
  6836. if($warehouse)
  6837. {
  6838. $where .= " and warehouse = '$warehouse'";
  6839. }
  6840. if($purchase)
  6841. {
  6842. $where .= " and purchase = '$purchase'";
  6843. }
  6844. if($orderinfo)
  6845. {
  6846. $where .= " and orderinfo = '$orderinfo'";
  6847. }
  6848. if($waybill)
  6849. {
  6850. $where .= " and waybill = '$waybill'";
  6851. }
  6852. if($category)
  6853. {
  6854. $where .= " and features like '%-$category-%'";
  6855. }
  6856. if($size)
  6857. {
  6858. $where .= " and features like '%-$size-%'";
  6859. }
  6860. if($grade)
  6861. {
  6862. $where .= " and features like '%-$grade-%'";
  6863. }
  6864. if($color)
  6865. {
  6866. $where .= " and features like '%-$color-%'";
  6867. }
  6868. if($lowe)
  6869. {
  6870. $where .= " and features like '%-$lowe-%'";
  6871. }
  6872. if($label)
  6873. {
  6874. $where .= " and label = '$label'";
  6875. }
  6876. $ck = ($warehouse == '12')?'specialstock':'whlabel';
  6877. //数据排序
  6878. $order_str = "outk desc";
  6879. if(empty($page))
  6880. {
  6881. $start = 0;
  6882. $perpage = 1;
  6883. }
  6884. else
  6885. {
  6886. $start = ($page - 1)*$perpage;
  6887. }
  6888. //取得信息列表
  6889. $info_list = $this->$ck->find_all($where,'id,warehouse,purchase,sku,title,state,outk,details',$order_str,$start,$perpage);
  6890. foreach ($info_list as $key=>$value)
  6891. {
  6892. $warehouse = $this->warehouse->read($value['warehouse']);
  6893. $info_list[$key]['warehouse'] = ($ck=='specialstock')?'特殊仓':$warehouse['title'];
  6894. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']]))?$prc[$value['purchase']]:'未知';
  6895. if($value['state'] == 0)
  6896. {
  6897. $info_list[$key]['state'] = "在库";
  6898. }
  6899. else if($value['state'] == 1)
  6900. {
  6901. $info_list[$key]['state'] = "出库";
  6902. }
  6903. else if($value['state'] == 2)
  6904. {
  6905. $info_list[$key]['state'] = "退库";
  6906. }
  6907. else if($value['state'] == 3)
  6908. {
  6909. $info_list[$key]['state'] = "调拨中";
  6910. }
  6911. else if($value['state'] == 4)
  6912. {
  6913. $info_list[$key]['state'] = "再加工";
  6914. }
  6915. else if($value['state'] == 5)
  6916. {
  6917. $info_list[$key]['state'] = "维修中";
  6918. }
  6919. else if($value['state'] == 6)
  6920. {
  6921. $info_list[$key]['state'] = "盘亏";
  6922. }
  6923. else if($value['state'] == 7)
  6924. {
  6925. $info_list[$key]['state'] = "更换标签";
  6926. }
  6927. else if($value['state'] == 8)
  6928. {
  6929. $info_list[$key]['state'] = "其它";
  6930. }
  6931. else if($value['state'] == 9)
  6932. {
  6933. $info_list[$key]['state'] = "预设";
  6934. }
  6935. else if($value['state'] == 10)
  6936. {
  6937. $info_list[$key]['state'] = "美店零售";
  6938. }
  6939. $info_list[$key]['outk'] = date('Y-m-d H:i:s',$value['outk']);
  6940. }
  6941. $total = $this->$ck->find_count($where);
  6942. $pagenum = ceil($total/$perpage);
  6943. $over = $total-($start+$perpage);
  6944. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  6945. echo json_encode($rows);exit;
  6946. }
  6947. if(isset($post['tmsku']))
  6948. {
  6949. $time = time();
  6950. $tmsku = $this->input->post('tmsku',true);
  6951. //$post['shop'] = $this->input->post('shop',true);
  6952. $num = $this->input->post('num',true);
  6953. $cktype = $this->input->post('cktype',true);
  6954. $label = $this->whlabellabel->get_label($tmsku);
  6955. if(!$cktype)
  6956. {
  6957. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6958. }
  6959. if(!isset($label['warehouse']))
  6960. {
  6961. echo json_encode(array('msg'=>'没有此条码信息!','success'=>false));exit;
  6962. }
  6963. $xzck = ($label['warehouse'] == '12')?'specialstock':'whlabel';
  6964. if(stripos($label['features'],'-126-') !== false)
  6965. {
  6966. $ck = $this->$xzck->find_all("state = '0' and shop = '".$label['shop']."' and number = '".$label['number']."' and warehouse = '".$label['warehouse']."' and zd = ''");
  6967. }
  6968. else
  6969. {
  6970. $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 = ''");
  6971. }
  6972. $j = 0;
  6973. if(count($ck) >= $num)
  6974. {
  6975. for($i=0;$i<$num;$i++)
  6976. {
  6977. if($this->$xzck->save(array('state'=>1,'outk'=>$time,'time'=>$time),$ck[$i]['id']))//,'cktype'=>$cktype
  6978. {
  6979. $j++;
  6980. }
  6981. }
  6982. if($j == $num)
  6983. {
  6984. echo json_encode(array('msg'=>'出库成功!','success'=>true));exit;
  6985. }
  6986. else
  6987. {
  6988. echo json_encode(array('msg'=>'未成功出库数量:'.$num-$j.',请补入','c'=>0,'success'=>false));exit;
  6989. }
  6990. }
  6991. else
  6992. {
  6993. echo json_encode(array('msg'=>'没有足够的库存!','cs'=>$label['sku'].' - '.$label['purchase'],'success'=>false));exit;
  6994. }
  6995. }
  6996. $this->_Template('whlabel_printck',$this->data);
  6997. }
  6998. public function _printexcel()
  6999. {
  7000. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7001. $config['upload_path'] = '.'.$dir ;
  7002. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7003. $config['allowed_types'] = 'xls|xlsx|csv';
  7004. $config['max_size'] = 10240;
  7005. $this->load->library('upload', $config);
  7006. $this->upload->initialize($config);
  7007. if ($this->upload->do_upload('userfile'))
  7008. {
  7009. $full_path = $dir.$this->upload->data('file_name');
  7010. $fileName = '.' . $full_path;
  7011. if (!file_exists($fileName))
  7012. {
  7013. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7014. }
  7015. else
  7016. {
  7017. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7018. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7019. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7020. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7021. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7022. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7023. ++$column;//如果列数大于26行
  7024. $list = array();
  7025. for ($i = 2; $i <= $row; $i++) // 行数循环
  7026. {
  7027. $data = array();
  7028. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7029. {
  7030. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7031. }
  7032. $list[] = $data;
  7033. }
  7034. }
  7035. $ed = array();$i = 0;$j = 0;$dcdata = array();$yc = '';
  7036. $cmf_arr = array_column($list, '1');
  7037. array_multisort($cmf_arr, SORT_ASC, $list);
  7038. foreach ($list as $key=>$value)
  7039. {
  7040. $typeclass = $this->typeclass->get_bqsku($value['1'],$value['2']);
  7041. if($typeclass)
  7042. {
  7043. $this->typeclass->save(array('bqsku'=>$value['3']),$typeclass['id']);
  7044. }
  7045. else
  7046. {
  7047. $ed[] = array($value['1'].'-系统未找到此订单信息');
  7048. $i++;
  7049. continue;
  7050. }
  7051. }
  7052. if($i > 0)
  7053. {
  7054. $yc = $i.'条异常';
  7055. }
  7056. echo json_encode(array('msg'=>'操作成功 '.$yc,'yc'=>$ed,'success'=>true));exit;
  7057. }
  7058. }
  7059. public function _uck()
  7060. {
  7061. if(isset($_GET['excel']))
  7062. {
  7063. $tc = array();
  7064. $typeclass = $this->typeclass->find_all();
  7065. foreach ($typeclass as $v)
  7066. {
  7067. $tc[$v['id']] = $v['zh'];
  7068. }
  7069. $data = array();$t = array();$rq = '';
  7070. $ts = strtotime(date("Y-m-d",time()))-strtotime(date("Y-m",time()));
  7071. $ts = $ts/(24*3600);
  7072. for($i=0;$i<$ts;$i++)
  7073. {
  7074. $t[] = date("Y-m-d",strtotime('-'.($ts-$i).' day'));
  7075. $rq .= "<td>".date("Y-m-d",strtotime('-'.($ts-$i).' day'))."</td>";
  7076. }
  7077. $info_list = $this->whlabel->find_pc("warehouse = '5'",'sku','warehouse,sku,features');
  7078. foreach ($info_list as $k=>$v)
  7079. {
  7080. $features = explode('-',trim($v['features'],'-'));
  7081. if(!isset($features[3]) || !isset($features[4]))
  7082. {
  7083. continue;
  7084. }
  7085. $data[$k][0] = $tc[$features[0]];//类型
  7086. $data[$k][1] = ($features[3] != 57)?$tc[$features[3]]:'';//颜色,自然色不显示
  7087. $data[$k][2] = $tc[$features[4]];//曲度
  7088. $data[$k][3] = '';
  7089. if(isset($data[$k][1]))
  7090. {
  7091. $data[$k][3] .= $data[$k][1];
  7092. }
  7093. if(isset($data[$k][2]))
  7094. {
  7095. $data[$k][3] .= $data[$k][2];
  7096. }
  7097. if(isset($features[5]))
  7098. {
  7099. $data[$k][3] .= $tc[$features[5]];
  7100. }
  7101. if(isset($features[2]))
  7102. {
  7103. $data[$k][3] .= $tc[$features[2]];
  7104. }
  7105. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7106. $data[$k][4] = $v['sku'];
  7107. $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())).'))');//月初库存
  7108. $data[$k][] = $this->whlabel->find_count('sku = "'.$v['sku'].'" and state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');//剩余库存
  7109. $zt = $this->whlabeltransport->find_all('sku = "'.$v['sku'].'" and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'" and cz = "0"');
  7110. $ztrq = '';$ztsl = '';
  7111. if(count($zt) > 0)
  7112. {
  7113. foreach ($zt as $vv)
  7114. {
  7115. $ztrq .= date('Y-m-d',$vv['stime']).'<br>';
  7116. $ztsl .= $vv['num'].'<br>';
  7117. }
  7118. }
  7119. $data[$k][] = trim($ztsl,'<br>');
  7120. $data[$k][] = trim($ztrq,'<br>');
  7121. $byck = 0;
  7122. foreach ($t as $vv)
  7123. {
  7124. $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));
  7125. $data[$k][] = ($sl > 0)?'<b>'.$sl.'</b>':'';
  7126. $byck += $sl;
  7127. }
  7128. $data[$k][] = ($byck > 0)?$byck:'';
  7129. }
  7130. $title = "详情 ".date("Y-m-d",time());
  7131. $titlename = "<table border=1>
  7132. <tr align='center'>
  7133. <td>类别</td>
  7134. <td>颜色</td>
  7135. <td>曲度</td>
  7136. <td>名称</td>
  7137. <td>SKU</td>
  7138. <td>月初库存</td>
  7139. <td>剩余库存</td>
  7140. <td>在途数量</td>
  7141. <td>预达日期</td>".
  7142. $rq
  7143. ."<td>本月出库</td></tr>
  7144. </table>";
  7145. $filename = $title.".xls";
  7146. $tail = "";
  7147. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  7148. }
  7149. }
  7150. public function _whlabelexcelzh()
  7151. {
  7152. if(isset($_GET['excel']))
  7153. {
  7154. $where = "sku != 'Preset'";
  7155. //数据排序
  7156. $order_str = "id desc";
  7157. if(empty($page))
  7158. {
  7159. $start = 0;
  7160. $perpage = 1;
  7161. }
  7162. else
  7163. {
  7164. $start = ($page - 1)*$perpage;
  7165. }
  7166. $category = $this->input->get('category',true);
  7167. $warehouse = $this->input->get('warehouse',true);
  7168. $excelid = $this->input->get('sid',true);
  7169. if($category)
  7170. {
  7171. $where .= " and features like '%-$category-%'";
  7172. }
  7173. if($warehouse)
  7174. {
  7175. $where .= " and warehouse = '$warehouse'";
  7176. }
  7177. $xzid = '';
  7178. if($excelid)
  7179. {
  7180. $excelid = explode(',',trim($excelid,','));
  7181. foreach ($excelid as $key=>$value)
  7182. {
  7183. $xzid .= " id = ".$value." or";
  7184. }
  7185. $xzid = " and (".rtrim($xzid,'or').")";;
  7186. }
  7187. //取得信息列表
  7188. /**
  7189. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7190. $rows = array();$list = array();
  7191. foreach ($info_list as $key=>$value)
  7192. {
  7193. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7194. }
  7195. **/
  7196. $list = array();
  7197. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,number,features');
  7198. foreach ($rows as $key=>$value)
  7199. {
  7200. $c = $this->whlabel->find_count($where.' and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "0" and features = "'.$value['features'].'"');
  7201. $zh = '';
  7202. $zt = $this->whlabeltransport->find_all('sku = "'.$value['sku'].'" and time = "0" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','num,stime');
  7203. foreach ($zt as $v)
  7204. {
  7205. $zh .= $v['num']." / ".date('Y-m-d',$v['stime'])."<br>";
  7206. }
  7207. $zt = array_sum(array_column($zt,'num'));
  7208. $number = $value['number'];
  7209. $ftime = time()-15*24*3600;
  7210. $warehouse = $this->warehouse->read($value['warehouse']);
  7211. $rows[$key]['warehouse'] = $warehouse['title'];
  7212. $rows[$key]['number'] = $c;
  7213. $rows[$key]['features'] = $zh;
  7214. $rows[$key]['hb'] = $c+$zt;
  7215. }
  7216. $title = "导出库存数据及在途中数据".date('Y-m-d',time());
  7217. $titlename = "<table border=1>
  7218. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7219. <tr align='center'>
  7220. <td>仓库</td>
  7221. <td>SKU</td>
  7222. <td>产品</td>
  7223. <td>库存数量</td>
  7224. <td>在途数量及预达日期</td>
  7225. <td>在途+库存数量</td>
  7226. </tr>
  7227. </table>";
  7228. $filename = $title.".xls";
  7229. $tail = "";
  7230. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7231. }
  7232. if(isset($_GET['excel']))
  7233. {
  7234. $warehouse = $this->input->get('warehouse',true);
  7235. $sku = $this->input->get('sku',true);
  7236. $cz = $this->input->get('cz',true);
  7237. $text = $this->input->post('text',true);
  7238. $xztime = $this->input->get('xztime',true);
  7239. $timetk = $this->input->get('timetk',true);
  7240. $timetj = $this->input->get('timetj',true);
  7241. $timetk = strtotime($timetk);
  7242. $timetj = strtotime($timetj);
  7243. $where = "time = '0' ";
  7244. if($warehouse)
  7245. {
  7246. $where .= " and warehouse = '$warehouse'";
  7247. }
  7248. if($sku)
  7249. {
  7250. $where .= " and sku = '$sku'";
  7251. }
  7252. if($text)
  7253. {
  7254. $where .= " and text like '%$text%'";
  7255. }
  7256. if($cz != '')
  7257. {
  7258. $where .= " and cz = '$cz'";
  7259. }
  7260. if($timetk && $timetj)
  7261. {
  7262. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  7263. }
  7264. //数据排序
  7265. $order_str = $xztime." desc";
  7266. //取得信息列表
  7267. $zh = array();
  7268. $info_list = $this->whlabeltransport->find_all($where,'warehouse,sku,title,num,features,enter,stime,text');
  7269. foreach ($info_list as $v)
  7270. {
  7271. $c = $this->whlabel->find_count('state = 0 and warehouse = "'.$v['warehouse'].'" and features = "'.$v['features'].'"');
  7272. $warehouse = $this->warehouse->read($v['warehouse']);
  7273. $v['warehouse'] = $warehouse['title'];
  7274. $v['enter'] = date('Y-m-d H:i:s',$v['enter']);
  7275. $v['stime'] = date('Y-m-d',$v['stime']);
  7276. if(isset($zh[$v['features']]))
  7277. {
  7278. $zh[$v['features']]['num'] += $v['num'];
  7279. }
  7280. else
  7281. {
  7282. $zh[$v['features']] = $v;
  7283. }
  7284. $zh[$v['features']]['features'] = $c;
  7285. }
  7286. $title = "在途数据".date('Y-m-d',time());
  7287. $titlename = "<table border=1>
  7288. <tr align='center'>
  7289. <td>仓库</td>
  7290. <td>SKU</td>
  7291. <td>名称</td>
  7292. <td>在途数量</td>
  7293. <td>库存数量</td>
  7294. <td>添加在途日期</td>
  7295. <td>预达日期</td>
  7296. <td>备注</td>
  7297. </tr>
  7298. </table>";
  7299. $filename = $title.".xls";
  7300. $tail = "";
  7301. $this->excel->get_fz2($zh,$titlename,$filename,$tail);
  7302. }
  7303. }
  7304. public function _fc()
  7305. {
  7306. $vip = 0;
  7307. if(isset($_SESSION['api']))
  7308. {
  7309. $user = $this->user->get_api($_SESSION['api']);
  7310. if($user['vip'] == 1)
  7311. {
  7312. $vip = 1;
  7313. }
  7314. }
  7315. else
  7316. {
  7317. header('Location: /');exit;
  7318. }
  7319. $post = $this->input->post(NULL, TRUE);
  7320. if(isset($post['page']))
  7321. {
  7322. $page = $this->input->post('page',true);
  7323. $perpage = $this->input->post('perpage',true);
  7324. $category = $this->input->post('category',true);
  7325. $size = $this->input->post('size',true);
  7326. $grade = $this->input->post('grade',true);
  7327. $color = $this->input->post('color',true);
  7328. $lowe = $this->input->post('lowe',true);
  7329. $sku = $this->input->post('sku');
  7330. $title = $this->input->post('title');
  7331. $warehouse = $this->input->post('warehouse',true);
  7332. $usa = $this->input->post('usa',true);
  7333. $purchase = $this->input->post('purchase',true);
  7334. $lacetype = $this->input->post('lacetype',true);
  7335. $haircap = $this->input->post('haircap',true);
  7336. $density = $this->input->post('density',true);
  7337. $details = $this->input->post('details',true);
  7338. $state = $this->input->post('state',true);
  7339. $ktime = $this->input->post('ktime',true);
  7340. $jtime = $this->input->post('jtime',true);
  7341. $ktime = strtotime($ktime);
  7342. $jtime = strtotime($jtime);
  7343. $where = "state = '11'";$gj = "";$ck = "";
  7344. if($lacetype)
  7345. {
  7346. $where .= " and features like '%-$lacetype-%'";
  7347. }
  7348. if($category)
  7349. {
  7350. $where .= " and features like '%-$category-%'";
  7351. }
  7352. if($size)
  7353. {
  7354. $where .= " and features like '%-$size-%'";
  7355. }
  7356. if($grade)
  7357. {
  7358. $where .= " and features like '%-$grade-%'";
  7359. }
  7360. if($color)
  7361. {
  7362. $where .= " and features like '%-$color-%'";
  7363. }
  7364. if($lowe)
  7365. {
  7366. $where .= " and features like '%-$lowe-%'";
  7367. }
  7368. if($haircap)
  7369. {
  7370. $where .= " and features like '%-$haircap-%'";
  7371. }
  7372. if($density)
  7373. {
  7374. $where .= " and features like '%-$density-%'";
  7375. }
  7376. if($usa)
  7377. {
  7378. if(!$warehouse)
  7379. {
  7380. $where .= " and (warehouse = '5' or warehouse = '8')";
  7381. }
  7382. }
  7383. if($warehouse)
  7384. {
  7385. $where .= " and warehouse = '$warehouse'";
  7386. }
  7387. if($details)
  7388. {
  7389. $where .= " and details = '$details'";
  7390. }
  7391. if($purchase)
  7392. {
  7393. $where .= " and purchase = '$purchase'";
  7394. }
  7395. if($state)
  7396. {
  7397. $where .= " and state = '$state'";
  7398. }
  7399. if($ktime && $jtime)
  7400. {
  7401. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7402. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7403. }
  7404. //数据排序
  7405. $order_str = "id desc";
  7406. if(empty($page))
  7407. {
  7408. $start = 0;
  7409. $perpage = 1;
  7410. }
  7411. else
  7412. {
  7413. $start = ($page - 1)*$perpage;
  7414. }
  7415. if($sku)
  7416. {
  7417. $sku = trim($sku,' ');
  7418. $sku = trim($sku,' ');
  7419. $where .= " and sku like '%$sku%'";
  7420. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7421. }
  7422. else if($title)
  7423. {
  7424. $title = trim($title,' ');
  7425. $title = trim($title,' ');
  7426. $where .= " and title like '%$title%'";
  7427. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7428. }
  7429. else
  7430. {
  7431. //$where .= " and time > '$ktime' and time < '$jtime'";
  7432. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,number,features',$order_str,$start,$perpage);
  7433. }
  7434. //取得信息列表
  7435. $rows = array();$list = array();
  7436. foreach ($info_list as $key=>$value)
  7437. {
  7438. $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'].'"');
  7439. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7440. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7441. $warehouse = $this->warehouse->read($value['warehouse']);
  7442. $info_list[$key]['warehouse'] = $warehouse['title'];
  7443. $info_list[$key]['number'] = $g;
  7444. $info_list[$key]['features'] = $x;
  7445. $info_list[$key]['x'] = $s;
  7446. }
  7447. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features,number'));
  7448. $pagenum = ceil($total/$perpage);
  7449. $over = $total-($start+$perpage);
  7450. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  7451. echo json_encode($rows);exit;
  7452. }
  7453. $this->data['vip'] = $vip;
  7454. $this->_Template('whlabel_fc',$this->data);
  7455. }
  7456. public function _fcmb()
  7457. {
  7458. $where = "sku != 'Preset'";
  7459. $rows = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title');
  7460. foreach ($rows as $k=>$v)
  7461. {
  7462. $warehouse = $this->warehouse->read($v['warehouse']);
  7463. $rows[$k]['warehouse'] = $warehouse['title'];
  7464. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "'.$v['warehouse'].'" and sku = "'.$v['sku'].'" and state = 11');
  7465. $rows[$k]['t'] = '';
  7466. $rows[$k]['n'] = '';
  7467. }
  7468. $title = "封货产品数据导入模板";
  7469. $titlename = "<table border=1>
  7470. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7471. <tr align='center'>
  7472. <td>仓库</td>
  7473. <td>SKU</td>
  7474. <td>产品</td>
  7475. <td>封存产品总数量</td>
  7476. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7477. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7478. </tr>
  7479. </table>";
  7480. $filename = $title.".xls";
  7481. $tail = "";
  7482. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7483. }
  7484. public function _fcexcel()
  7485. {
  7486. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7487. $config['upload_path'] = '.'.$dir ;
  7488. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7489. $config['allowed_types'] = 'xls|xlsx|csv';
  7490. $config['max_size'] = 10240;
  7491. $this->load->library('upload', $config);
  7492. $this->upload->initialize($config);
  7493. if ($this->upload->do_upload('userfile'))
  7494. {
  7495. $full_path = $dir.$this->upload->data('file_name');
  7496. $fileName = '.' . $full_path;
  7497. if (!file_exists($fileName))
  7498. {
  7499. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7500. }
  7501. else
  7502. {
  7503. libxml_use_internal_errors(true);
  7504. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7505. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7506. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7507. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7508. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7509. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7510. ++$column;//如果列数大于26行
  7511. $list = array();
  7512. for ($i = 2; $i <= $row; $i++) // 行数循环
  7513. {
  7514. $data = array();
  7515. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7516. {
  7517. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7518. }
  7519. $list[] = $data;
  7520. }
  7521. }
  7522. $i = 0;$j = 0;$ed = array();
  7523. foreach ($list as $key=>$value)
  7524. {
  7525. $time = time();
  7526. if($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4']))
  7527. {
  7528. continue;
  7529. }
  7530. $warehouse = $this->warehouse->get_title($value['0']);
  7531. $sku = $value['1'];
  7532. $type = $value['4'];//调整方式0扣减1删除
  7533. $num = $value['5'];//调整数量
  7534. //$text = $value['4'];//扣减说明
  7535. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7536. if(!$d)//如果没有这个SKU
  7537. {
  7538. $ed[] = array($sku.'-库存中不存在此SKU');
  7539. $j++;
  7540. continue;
  7541. }
  7542. if(!isset($warehouse['id']))
  7543. {
  7544. $ed[] = array($sku.'-仓库名错误!');
  7545. $j++;
  7546. continue;
  7547. }
  7548. if($type == 1 || $type == 2)//扣减库存
  7549. {
  7550. $data = $this->whlabel->find_all('warehouse = "'.$warehouse['id'].'" and sku = "'.$sku.'" and state = 11');
  7551. if(count($data) < abs($num))
  7552. {
  7553. $ed[] = array($sku.'-数量大于封存产品剩余数量!');
  7554. $j++;
  7555. continue;
  7556. }
  7557. if($type == 1)//转入库存
  7558. {
  7559. for($i=0;$i<abs($num);$i++)
  7560. {
  7561. $this->whlabel->save(array('state'=>0,'oldstate'=>11,'time'=>$time),$data[$i]['id']);
  7562. }
  7563. }
  7564. else if($type == 2)//删除
  7565. {
  7566. for($i=0;$i<abs($num);$i++)
  7567. {
  7568. $this->whlabel->remove($data[$i]['id']);
  7569. }
  7570. }
  7571. }
  7572. else if($type == 0)//增加库存
  7573. {
  7574. $post['sku'] = $d['sku'];
  7575. $post['shop'] = '';
  7576. $post['warehouse'] = $warehouse['id'];
  7577. $post['purchase'] = $d['purchase'];
  7578. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7579. $post['state'] = 11;
  7580. $post['title'] = $d['title'];
  7581. $post['number'] = $d['number'];
  7582. $post['features'] = $d['features'];
  7583. $post['enter'] = $time;
  7584. $post['time'] = $time;//操作时间
  7585. for($i=0;$i<$num;$i++)
  7586. {
  7587. $post['label'] = time().rand(100,999).$i;
  7588. $this->whlabel->insert($post);
  7589. }
  7590. }
  7591. sleep(1);//防止入库时间一样,需要延迟1秒
  7592. }
  7593. if($j > 0)
  7594. {
  7595. $tt = date('Ymd',time());
  7596. $title = '库存导入错误信息-'.$tt;
  7597. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7598. $tail = "\n";
  7599. $filename = $title.".xls";
  7600. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  7601. $dir = '/data/excel/'.$time.'/';
  7602. $file_name = 'error_'.$time.rand(1000,9999);
  7603. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  7604. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  7605. fwrite($myfile,$ecl);
  7606. fclose($myfile);
  7607. $error = $dir.$file_name.'.xls';
  7608. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  7609. }
  7610. else
  7611. {
  7612. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  7613. }
  7614. }
  7615. }
  7616. public function _fcjxc($arg_array)
  7617. {
  7618. if(isset($_GET['excel']))
  7619. {
  7620. $category = $this->input->get('category',true);
  7621. $size = $this->input->get('size',true);
  7622. $grade = $this->input->get('grade',true);
  7623. $color = $this->input->get('color',true);
  7624. $lowe = $this->input->get('lowe',true);
  7625. $sku = $this->input->get('sku');
  7626. $title = $this->input->get('title');
  7627. $warehouse = $arg_array[0];
  7628. $usa = $this->input->get('usa',true);
  7629. $purchase = $this->input->get('purchase',true);
  7630. $lacetype = $this->input->get('lacetype',true);
  7631. $haircap = $this->input->get('haircap',true);
  7632. $density = $this->input->get('density',true);
  7633. $title = $this->input->get('title',true);
  7634. $state = $this->input->get('state',true);
  7635. $ktime = $this->input->get('ktime',true);
  7636. $jtime = $this->input->get('jtime',true);
  7637. $where = "state=11";$gj = "";$ck = "";
  7638. if($lacetype)
  7639. {
  7640. $where .= " and features like '%-$lacetype-%'";
  7641. }
  7642. if($category)
  7643. {
  7644. $where .= " and features like '%-$category-%'";
  7645. }
  7646. if($size)
  7647. {
  7648. $where .= " and features like '%-$size-%'";
  7649. }
  7650. if($grade)
  7651. {
  7652. $where .= " and features like '%-$grade-%'";
  7653. }
  7654. if($color)
  7655. {
  7656. $where .= " and features like '%-$color-%'";
  7657. }
  7658. if($lowe)
  7659. {
  7660. $where .= " and features like '%-$lowe-%'";
  7661. }
  7662. if($haircap)
  7663. {
  7664. $where .= " and features like '%-$haircap-%'";
  7665. }
  7666. if($density)
  7667. {
  7668. $where .= " and features like '%-$density-%'";
  7669. }
  7670. if($usa)
  7671. {
  7672. if(!$warehouse)
  7673. {
  7674. $where .= " and (warehouse = '5' or warehouse = '8')";
  7675. }
  7676. }
  7677. if($warehouse)
  7678. {
  7679. $where .= " and warehouse = '$warehouse'";
  7680. }
  7681. if($purchase)
  7682. {
  7683. $where .= " and purchase = '$purchase'";
  7684. }
  7685. if($state)
  7686. {
  7687. $where .= " and state = '$state'";
  7688. }
  7689. $order_str = "id desc";
  7690. if($sku)
  7691. {
  7692. $sku = trim($sku,' ');
  7693. $sku = trim($sku,' ');
  7694. $where .= " and sku like '%$sku%'";
  7695. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7696. }
  7697. else if($title)
  7698. {
  7699. $title = trim($title,' ');
  7700. $title = trim($title,' ');
  7701. $where .= " and title like '%$title%'";
  7702. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7703. }
  7704. else
  7705. {
  7706. //$where .= " and time > '$ktime' and time < '$jtime'";
  7707. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','warehouse,sku,title,features',$order_str,$start,$perpage);
  7708. }
  7709. //取得信息列表
  7710. $rows = array();$list = array();
  7711. foreach ($info_list as $key=>$value)
  7712. {
  7713. $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'].'"');
  7714. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7715. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7716. $rows[$key] = $value;
  7717. $warehouse = $this->warehouse->read($value['warehouse']);
  7718. $rows[$key]['warehouse'] = $warehouse['title'];
  7719. $rows[$key]['features'] = $g;
  7720. $rows[$key]['a'] = $x;
  7721. $rows[$key]['b'] = $s;
  7722. }
  7723. $title = "总统计表";
  7724. $titlename = "<table border=1>
  7725. <tr><th colspan='6' align='center'><h3>".$title."<h3></th></tr>
  7726. <tr align='center'>
  7727. <td>仓库</td>
  7728. <td>SKU</td>
  7729. <td>产品名称</td>
  7730. <td>录入总量</td>
  7731. <td>取出总量</td>
  7732. <td>剩余总量</td>
  7733. </tr>
  7734. </table>";
  7735. $filename = $title.".xls";
  7736. $tail = "";
  7737. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  7738. }
  7739. $vip = 0;
  7740. if(isset($_SESSION['api']))
  7741. {
  7742. $user = $this->user->get_api($_SESSION['api']);
  7743. if($user['vip'] == 1)
  7744. {
  7745. $vip = 1;
  7746. }
  7747. }
  7748. else
  7749. {
  7750. header('Location: /');exit;
  7751. }
  7752. $post = $this->input->post(NULL, TRUE);
  7753. if(isset($post['page']))
  7754. {
  7755. $page = $this->input->post('page',true);
  7756. $perpage = $this->input->post('perpage',true);
  7757. $category = $this->input->post('category',true);
  7758. $size = $this->input->post('size',true);
  7759. $grade = $this->input->post('grade',true);
  7760. $color = $this->input->post('color',true);
  7761. $lowe = $this->input->post('lowe',true);
  7762. $sku = $this->input->post('sku');
  7763. $title = $this->input->post('title');
  7764. $warehouse = $arg_array[0];
  7765. $usa = $this->input->post('usa',true);
  7766. $purchase = $this->input->post('purchase',true);
  7767. $lacetype = $this->input->post('lacetype',true);
  7768. $haircap = $this->input->post('haircap',true);
  7769. $density = $this->input->post('density',true);
  7770. $title = $this->input->post('title',true);
  7771. $state = $this->input->post('state',true);
  7772. $ktime = $this->input->post('ktime',true);
  7773. $jtime = $this->input->post('jtime',true);
  7774. $ktime = strtotime($ktime);
  7775. $jtime = strtotime($jtime);
  7776. $where = "state=11";$gj = "";$ck = "";
  7777. if($lacetype)
  7778. {
  7779. $where .= " and features like '%-$lacetype-%'";
  7780. }
  7781. if($category)
  7782. {
  7783. $where .= " and features like '%-$category-%'";
  7784. }
  7785. if($size)
  7786. {
  7787. $where .= " and features like '%-$size-%'";
  7788. }
  7789. if($grade)
  7790. {
  7791. $where .= " and features like '%-$grade-%'";
  7792. }
  7793. if($color)
  7794. {
  7795. $where .= " and features like '%-$color-%'";
  7796. }
  7797. if($lowe)
  7798. {
  7799. $where .= " and features like '%-$lowe-%'";
  7800. }
  7801. if($haircap)
  7802. {
  7803. $where .= " and features like '%-$haircap-%'";
  7804. }
  7805. if($density)
  7806. {
  7807. $where .= " and features like '%-$density-%'";
  7808. }
  7809. if($usa)
  7810. {
  7811. if(!$warehouse)
  7812. {
  7813. $where .= " and (warehouse = '5' or warehouse = '8')";
  7814. }
  7815. }
  7816. if($warehouse)
  7817. {
  7818. $where .= " and warehouse = '$warehouse'";
  7819. }
  7820. if($purchase)
  7821. {
  7822. $where .= " and purchase = '$purchase'";
  7823. }
  7824. if($state)
  7825. {
  7826. $where .= " and state = '$state'";
  7827. }
  7828. if($ktime && $jtime)
  7829. {
  7830. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7831. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7832. }
  7833. //数据排序
  7834. $order_str = "id desc";$xs=0;
  7835. $rows = array();$list = array();
  7836. if(empty($page))
  7837. {
  7838. $start = 0;
  7839. $perpage = 1;
  7840. }
  7841. else
  7842. {
  7843. $start = ($page - 1)*$perpage;
  7844. }
  7845. if($sku || $title)
  7846. {
  7847. if($title)
  7848. {
  7849. $title = trim($title,' ');
  7850. $title = trim($title,' ');
  7851. $where .= " and title like '%$title%'";
  7852. }
  7853. else
  7854. {
  7855. $sku = trim($sku,' ');
  7856. $sku = trim($sku,' ');
  7857. $where .= " and sku like '%$sku%'";
  7858. }
  7859. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7860. foreach ($info_list as $key=>$value)
  7861. {
  7862. $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'].'"');
  7863. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7864. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7865. $rows[$key] = $value;
  7866. $warehouse = $this->warehouse->read($value['warehouse']);
  7867. $rows[$key]['warehouse'] = $warehouse['title'];
  7868. $rows[$key]['features'] = $g;
  7869. $rows[$key]['a'] = $x;
  7870. $rows[$key]['b'] = $s;
  7871. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7872. $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天销量
  7873. $yj = $c/($xl/30);
  7874. if($yj < 7)
  7875. {
  7876. $rows[$key]['y'] = round($yj).'天销量';
  7877. }
  7878. else
  7879. {
  7880. $rows[$key]['y'] = '正常';
  7881. }
  7882. }
  7883. }
  7884. else
  7885. {
  7886. //$where .= " and time > '$ktime' and time < '$jtime'";
  7887. $info_list = $this->whlabel->find_pc($where,'sku,features,warehouse','id,warehouse,sku,title,features',$order_str,$start,$perpage);
  7888. foreach ($info_list as $key=>$value)
  7889. {
  7890. $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'].'"');
  7891. $x = $this->whlabel->find_count($where.' and oldstate = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "1" and features = "'.$value['features'].'"');
  7892. $s = $this->whlabel->find_count($where.' and state = "11" and sku = "'.$value['sku'].'" and warehouse = "'.$value['warehouse'].'" and state = "8" and features = "'.$value['features'].'"');
  7893. $zs[$key] = $value;
  7894. $warehouse = $this->warehouse->read($value['warehouse']);
  7895. $zs[$key]['warehouse'] = $warehouse['title'];
  7896. $zs[$key]['features'] = $g;
  7897. $zs[$key]['a'] = $x;
  7898. $zs[$key]['b'] = $s;
  7899. $kc = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');//现有库存
  7900. $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天销量
  7901. $yj = $c/($xl/30);
  7902. if($yj < 7)
  7903. {
  7904. $zs[$key]['y'] = round($yj).'天销量';
  7905. $rows[$key] = $zs[$key];
  7906. }
  7907. }
  7908. }
  7909. $total = count($this->whlabel->find_pc($where,'sku,features,warehouse','id'));
  7910. $pagenum = ceil($total/$perpage);
  7911. $over = $total-($start+$perpage);
  7912. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows));
  7913. echo json_encode($rows);exit;
  7914. }
  7915. $this->data['arg_array'] = $arg_array[0];
  7916. $this->_Template('whlabel_fcjxc',$this->data);
  7917. }
  7918. public function _0kcdel()
  7919. {
  7920. $dir = '/data/excel/'.date('Ymd',time()).'/';
  7921. $config['upload_path'] = '.'.$dir ;
  7922. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  7923. $config['allowed_types'] = 'xls|xlsx|csv';
  7924. $config['max_size'] = 10240;
  7925. $this->load->library('upload', $config);
  7926. $this->upload->initialize($config);
  7927. if ($this->upload->do_upload('userfile'))
  7928. {
  7929. $full_path = $dir.$this->upload->data('file_name');
  7930. $fileName = '.' . $full_path;
  7931. if (!file_exists($fileName))
  7932. {
  7933. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  7934. }
  7935. else
  7936. {
  7937. require_once "./data/excel/PHPExcel/IOFactory.php";
  7938. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  7939. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  7940. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  7941. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  7942. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  7943. ++$column;//如果列数大于26行
  7944. $list = array();
  7945. for ($i = 2; $i <= $row; $i++) // 行数循环
  7946. {
  7947. $data = array();
  7948. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7949. {
  7950. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7951. }
  7952. $list[] = $data;
  7953. }
  7954. }
  7955. $i = 0;$j = 0;$ed = array();
  7956. foreach ($list as $key=>$value)
  7957. {
  7958. $time = time();
  7959. if($value['0'] == "" || $value['1'] == "")
  7960. {
  7961. continue;
  7962. }
  7963. $warehouse = $this->warehouse->get_title($value['0']);
  7964. $sku = $value['1'];
  7965. $d = $this->whlabel->get_warehousesku($warehouse['id'],$sku);
  7966. if(!$d)//如果没有这个SKU
  7967. {
  7968. $ed[] = array($sku.'-库存中不存在此SKU');
  7969. $j++;
  7970. continue;
  7971. }
  7972. if(!isset($warehouse['id']))
  7973. {
  7974. $ed[] = array($sku.'-仓库名错误!');
  7975. $j++;
  7976. continue;
  7977. }
  7978. $z = $this->whlabel->find_count('sku = "'.$sku.'" and zd = "" and state = 0 and warehouse = "'.$warehouse['id'].'"');
  7979. if($z < 1)
  7980. {
  7981. $z = $this->whlabel->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'"');
  7982. foreach ($z as $v)
  7983. {
  7984. $zt = $this->whlabeltransport->find_all('sku = "'.$sku.'" and warehouse = "'.$warehouse['id'].'" and features = "'.$d['features'].'" and cz = "0"');
  7985. if(count($zt) > 0)
  7986. {
  7987. $ed[] = array($sku.'-有在途库存无法删除!');
  7988. $j++;
  7989. continue;
  7990. }
  7991. $this->whlabel->remove($v['id']);
  7992. }
  7993. }
  7994. else
  7995. {
  7996. $ed[] = array($sku.'-非0库存!');
  7997. $j++;
  7998. continue;
  7999. }
  8000. }
  8001. if($j > 0)
  8002. {
  8003. $tt = date('Ymd',time());
  8004. $title = '删除0库存错误信息-'.$tt;
  8005. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  8006. $tail = "\n";
  8007. $filename = $title.".xls";
  8008. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  8009. $dir = '/data/excel/'.$time.'/';
  8010. $file_name = 'error_'.$time.rand(1000,9999);
  8011. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  8012. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  8013. fwrite($myfile,$ecl);
  8014. fclose($myfile);
  8015. $error = $dir.$file_name.'.xls';
  8016. echo json_encode(array('msg'=>'导入成功,'.$j.'条异常,','error'=>$error,'success'=>true));exit;
  8017. }
  8018. else
  8019. {
  8020. echo json_encode(array('msg'=>'导入成功!','error'=>1,'success'=>true));exit;
  8021. }
  8022. }
  8023. }
  8024. public function _gbhtype()
  8025. {
  8026. $post = $this->input->post(NULL, TRUE);
  8027. if(isset($post['s']))
  8028. {
  8029. $n = $this->input->post('n');
  8030. $d = $this->input->post('s');
  8031. if(!$d)
  8032. {
  8033. echo json_encode(array('msg'=>'未选择需要更改的商品','success'=>false));exit;
  8034. }
  8035. $d = explode(',',trim($d,','));
  8036. $t = $this->whlabel_type->read($n);
  8037. //循环删除记录
  8038. foreach ($d as $v)
  8039. {
  8040. $u = $this->whlabel->read($v);
  8041. $data = $this->whlabel->find_all("sku = '".$u['sku']."' and purchase = '".$u['purchase']."' and features = '".$u['features']."' and warehouse = '".$u['warehouse']."'");
  8042. foreach ($data as $val)
  8043. {
  8044. $this->whlabel->save(array('type'=>$n),$val['id']);
  8045. }
  8046. }
  8047. echo json_encode(array('d'=>$d,'t'=>$t['title'],'msg'=>'修改成功!','success'=>true));
  8048. }
  8049. }
  8050. //出库、退库导出
  8051. public function _dccrtype()
  8052. {
  8053. $classid = $this->classid->sku();
  8054. $pm = $classid;
  8055. $typeclass = array();
  8056. $tc = $this->typeclass->find_all();
  8057. foreach ($tc as $v)
  8058. {
  8059. $typeclass[$v['id']] = $v;
  8060. }
  8061. $prc = array();
  8062. $purchase = $this->purchase->find_all();
  8063. foreach($purchase as $k=>$v)
  8064. {
  8065. $prc[$v['id']] = $v['title'];
  8066. }
  8067. if(isset($_GET['sid']))
  8068. {
  8069. $wh = array();
  8070. $w = $this->warehouse->find_all('1=1','id,title');
  8071. foreach ($w as $v)
  8072. {
  8073. $wh[$v['id']] = $v['title'];
  8074. }
  8075. $type = $this->input->get('excel',true);
  8076. $category = $this->input->get('category',true);
  8077. $size = $this->input->get('size',true);
  8078. $grade = $this->input->get('grade',true);
  8079. $color = $this->input->get('color',true);
  8080. $lowe = $this->input->get('lowe',true);
  8081. $sku = $this->input->get('sku',true);
  8082. $warehouse = $this->input->get('warehouse',true);
  8083. $lacetype = $this->input->get('lacetype',true);
  8084. $lacecolor = $this->input->get('lacecolor',true);
  8085. $density = $this->input->get('density',true);
  8086. $haircap = $this->input->get('haircap',true);
  8087. $purchase = $this->input->get('purchase',true);
  8088. $title = $this->input->get('title',true);
  8089. $state = $this->input->get('state',true);
  8090. $sid = $this->input->get('sid',true);
  8091. $ktime = $this->input->get('ktime',true);
  8092. $jtime = $this->input->get('jtime',true);
  8093. $ktime = strtotime($ktime);
  8094. $jtime = strtotime($jtime);
  8095. $where = "1=1";$gj = "";$ck = "";
  8096. if($category)
  8097. {
  8098. $where .= " and features like '%-$category-%'";
  8099. }
  8100. if($size)
  8101. {
  8102. $where .= " and features like '%-$size-%'";
  8103. }
  8104. if($grade)
  8105. {
  8106. $where .= " and features like '%-$grade-%'";
  8107. }
  8108. if($color)
  8109. {
  8110. $where .= " and features like '%-$color-%'";
  8111. }
  8112. if($lowe)
  8113. {
  8114. $where .= " and features like '%-$lowe-%'";
  8115. }
  8116. if($warehouse)
  8117. {
  8118. $where .= " and warehouse = '$warehouse'";
  8119. }
  8120. if($purchase)
  8121. {
  8122. $where .= " and purchase = '$purchase'";
  8123. }
  8124. if($state)
  8125. {
  8126. $where .= " and state = '$state'";
  8127. }
  8128. if($lacetype)
  8129. {
  8130. $where .= " and features like '%-$lacetype-%'";
  8131. }
  8132. if($lacecolor)
  8133. {
  8134. $where .= " and features like '%-$lacecolor-%'";
  8135. }
  8136. if($density)
  8137. {
  8138. $where .= " and features like '%-$density-%'";
  8139. }
  8140. if($haircap)
  8141. {
  8142. $where .= " and features like '%-$haircap-%'";
  8143. }
  8144. if($title)
  8145. {
  8146. $title = trim($title,' ');
  8147. $title = trim($title,' ');
  8148. $where .= " and title like '%$title%'";
  8149. }
  8150. if($sku)
  8151. {
  8152. $sku = trim($sku,' ');
  8153. $sku = trim($sku,' ');
  8154. $where .= " and sku like '%$sku%'";
  8155. }
  8156. if($ktime && $jtime)
  8157. {
  8158. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8159. }
  8160. $sidwhere = '';
  8161. if($sid)
  8162. {
  8163. $sd = "";
  8164. $s = explode(',',trim($sid,','));
  8165. foreach ($s as $value)
  8166. {
  8167. $sd .= " id = ".$value." or";
  8168. }
  8169. $sidwhere = " and (".rtrim($sd,'or').")";
  8170. }
  8171. //数据排序
  8172. $order_str = "time desc";
  8173. if(empty($page))
  8174. {
  8175. $start = 0;
  8176. $perpage = 1;
  8177. }
  8178. else
  8179. {
  8180. $start = ($page - 1)*$perpage;
  8181. }
  8182. $wh = array();
  8183. $w = $this->warehouse->find_all('1=1','id,title');
  8184. foreach ($w as $v)
  8185. {
  8186. $wh[$v['id']] = $v['title'];
  8187. }
  8188. $wt = array();
  8189. $whlabel_type = $this->whlabel_type->find_all();
  8190. foreach ($whlabel_type as $v)
  8191. {
  8192. $wt[$v['id']] = $v['title'];
  8193. }
  8194. $classid = $this->classid->sku();
  8195. $list = array();
  8196. $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');
  8197. foreach ($rows_r as $key=>$value)
  8198. {
  8199. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8200. $pm = $classid;
  8201. $jm = $classid;
  8202. $rows_r[$key]['enter'] = '入库';
  8203. $rows_r[$key]['time'] = $value['enter'];
  8204. if($value['rktype'] == 1)
  8205. {
  8206. $rows_r[$key]['rktype'] = '采购入库';
  8207. }
  8208. else if($value['rktype'] == 2)
  8209. {
  8210. $rows_r[$key]['rktype'] = '盘盈调整';
  8211. }
  8212. else if($value['rktype'] == 3)
  8213. {
  8214. $rows_r[$key]['rktype'] = '其他调整入库';
  8215. }
  8216. else if($value['rktype'] == 4)
  8217. {
  8218. $rows_r[$key]['rktype'] = '其他调整入库';
  8219. }
  8220. else if($value['rktype'] == 5)
  8221. {
  8222. $rows_r[$key]['rktype'] = '退库入库';
  8223. }
  8224. else if($value['rktype'] == 6)
  8225. {
  8226. $rows_r[$key]['rktype'] = '退货可用入库';
  8227. }
  8228. else if($value['rktype'] == 7)
  8229. {
  8230. $rows_r[$key]['rktype'] = '形态转换入库';
  8231. }
  8232. else
  8233. {
  8234. $rows_r[$key]['rktype'] = '';
  8235. }
  8236. $features = explode('-',trim($value['features'],'-'));
  8237. foreach($features as $v)
  8238. {
  8239. if(isset($typeclass[$v]))
  8240. {
  8241. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8242. $pm[$typeclass[$v]['classid']] = $zh[0];
  8243. }
  8244. if(isset($typeclass[$v]))
  8245. {
  8246. if(isset($jm[$typeclass[$v]['classid']]))
  8247. {
  8248. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8249. }
  8250. }
  8251. }
  8252. $zh = implode(" ",$pm);
  8253. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8254. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8255. $rows_r[$key]['zh'] = $zh;
  8256. $jm = array_filter($jm);
  8257. $rows_r[$key]['features'] = implode("-",$jm);
  8258. $rows_r[$key]['number'] = $this->whlabel->find_count($where." and enter = '".$value['enter']."' ".$sidwhere);
  8259. }
  8260. $rows_c = $this->whlabel->find_all($where." and outk > '$ktime' and outk < '$jtime' ".$sidwhere,'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  8261. foreach ($rows_c as $key=>$value)
  8262. {
  8263. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8264. $pm = $classid;
  8265. $jm = $classid;
  8266. $rows_c[$key]['time'] = $value['outk'];
  8267. $rows_c[$key]['outk'] = '出库';
  8268. if($value['cktype'] == 1)
  8269. {
  8270. $rows_c[$key]['cktype'] = '销售出库';
  8271. }
  8272. else if($value['cktype'] == 2)
  8273. {
  8274. $rows_c[$key]['cktype'] = '销售美国出库';
  8275. }
  8276. else if($value['cktype'] == 3)
  8277. {
  8278. $rows_c[$key]['cktype'] = '盘亏调整';
  8279. }
  8280. else if($value['cktype'] == 4)
  8281. {
  8282. $rows_c[$key]['cktype'] = '其他调整出库';
  8283. }
  8284. else if($value['cktype'] == 5)
  8285. {
  8286. $rows_c[$key]['cktype'] = '形态转换出库';
  8287. }
  8288. else
  8289. {
  8290. $rows_c[$key]['cktype'] = '';
  8291. }
  8292. $features = explode('-',trim($value['features'],'-'));
  8293. foreach($features as $v)
  8294. {
  8295. if(isset($typeclass[$v]))
  8296. {
  8297. $zh = explode('|',trim($typeclass[$v]['zh'],'|'));
  8298. $pm[$typeclass[$v]['classid']] = $zh[0];
  8299. }
  8300. if(isset($typeclass[$v]))
  8301. {
  8302. if(isset($jm[$typeclass[$v]['classid']]))
  8303. {
  8304. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8305. }
  8306. }
  8307. }
  8308. $zh = implode(" ",$pm);
  8309. $zh = str_replace('自然色 ','',rtrim($zh,' '));
  8310. $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  8311. $rows_c[$key]['zh'] = $zh;
  8312. $jm = array_filter($jm);
  8313. $rows_c[$key]['features'] = implode("-",$jm);
  8314. $rows_c[$key]['number'] = 1;
  8315. }
  8316. $merged = $rows_r;
  8317. foreach ($rows_c as $key => $value)
  8318. {
  8319. if (isset($merged[$key]))
  8320. {
  8321. $merged[] = $value;
  8322. }
  8323. else
  8324. {
  8325. $merged[$key] = $value;
  8326. }
  8327. }
  8328. usort($merged, function($a, $b)
  8329. {
  8330. return $a['time'] - $b['time'];
  8331. });
  8332. foreach ($merged as $key=>$value)
  8333. {
  8334. $merged[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  8335. }
  8336. $title = date('Y-m-d',$ktime).'至'.date('Y-m-d',$jtime);
  8337. $titlename = "<table border=1>
  8338. <tr align='center'>
  8339. <td>仓库</td>
  8340. <td>SKU</td>
  8341. <td>商品名称</td>
  8342. <td>仓库品名</td>
  8343. <td>料号</td>
  8344. <td>时间</td>
  8345. <td>操作</td>
  8346. <td>类型</td>
  8347. <td>数量</td>
  8348. <td>备注</td>
  8349. </tr>
  8350. </table>";
  8351. $filename = $title.".xlsx";
  8352. $tail = "";
  8353. $this->excel->get_fz2($merged,$titlename,$filename,$tail);
  8354. }
  8355. }
  8356. }