Whlabel.php 315 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  46. }
  47. //定义方法的调用规则 获取URI第二段值
  48. public function _remap($arg, $arg_array)
  49. {
  50. if ($arg == 'existence') //在库标签
  51. {
  52. $this->_existence();
  53. } else if ($arg == 'cpbqdc') //在库标签
  54. {
  55. $this->_cpbqdc();
  56. } else if ($arg == 'type') //进销存浏览
  57. {
  58. $this->_type();
  59. } else if ($arg == 'typedy') //进销存浏览店员页面
  60. {
  61. $this->_typedy($arg_array);
  62. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  63. {
  64. $this->_typedy_ck($arg_array);
  65. } else if ($arg == 'typeck') {
  66. $this->_typeck($arg_array);
  67. } else if ($arg == 'whlabeckdc') {
  68. $this->_whlabeckdc($arg_array);
  69. } else if ($arg == 'usatype') //美仓进销存浏览
  70. {
  71. $this->_usatype();
  72. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  73. {
  74. $this->_usatypeapp();
  75. } else if ($arg == 'enteradd') //入库操作
  76. {
  77. $this->_enteradd();
  78. } else if ($arg == 'enteredit') //修改
  79. {
  80. $this->_enteredit($arg_array);
  81. } else if ($arg == 'enter') //入库浏览
  82. {
  83. $this->_enter();
  84. } else if ($arg == 'out') //出库浏览
  85. {
  86. $this->_out();
  87. } else if ($arg == 'label') //出库标签浏览
  88. {
  89. $this->_label();
  90. } else if ($arg == 'outorder') //独立站出库订单
  91. {
  92. $this->_outorder();
  93. } else if ($arg == 'soutorder') //速卖通出库订单
  94. {
  95. $this->_soutorder();
  96. } else if ($arg == 'toutorder') //TT出库订单
  97. {
  98. $this->_toutorder();
  99. }else if ($arg == 'aoutorder') //amz出库订单
  100. {
  101. $this->_aoutorder();
  102. } else if ($arg == 'retreat') //退库订单
  103. {
  104. $this->_retreat();
  105. } else if ($arg == 'retreatlk') //退库订单
  106. {
  107. $this->_retreatlk();
  108. } else if ($arg == 'change') //更换标签
  109. {
  110. $this->_change();
  111. } else if ($arg == 'del') //删除
  112. {
  113. $this->_del();
  114. } else if ($arg == 'exceljxc') //进销存信息导出
  115. {
  116. $this->_exceljxc();
  117. } else if ($arg == 'excelr') //入库信息导出
  118. {
  119. $this->_excelr();
  120. } else if ($arg == 'excelct') //出库、退库信息导出
  121. {
  122. $this->_excelct();
  123. } else if ($arg == 'dccrtype') //根据出入库类型导出
  124. {
  125. $this->_dccrtype();
  126. } else if ($arg == 'excelcr') //出库、退库信息导出
  127. {
  128. $this->_excelcr();
  129. } else if ($arg == 'kcyz') //库存验证
  130. {
  131. $this->_kcyz();
  132. } else if ($arg == 'kj') //库存扣减
  133. {
  134. $this->_kj($arg_array);
  135. } else if ($arg == 'presetout') //预设库存导入
  136. {
  137. $this->_presetout($arg_array);
  138. } else if ($arg == 'presetedit') //预设库存导入
  139. {
  140. $this->_presetedit($arg_array);
  141. }else if ($arg == 'presetedittwo') //预设库存导入
  142. {
  143. $this->_presetedittwo($arg_array);
  144. } else if ($arg == 'summary') //汇总导出
  145. {
  146. $this->_summary($arg_array);
  147. } else if ($arg == 'manifest') //usps发货清单
  148. {
  149. $this->_manifest();
  150. } else if ($arg == 'abnormal') //占单异常
  151. {
  152. $this->_abnormal();
  153. } else if ($arg == 'error') //0库存SKU
  154. {
  155. $this->_error();
  156. } else if ($arg == 'errorexcel') //0库存SKU导出
  157. {
  158. $this->_errorexcel();
  159. } else if ($arg == 'db') {
  160. $this->_db();
  161. } else if ($arg == 'dbrk') {
  162. $this->_dbrk();
  163. } else if ($arg == 'whlabelczdc') {
  164. $this->_whlabelczdc();
  165. } else if ($arg == 'print') {
  166. $this->_print($arg_array);
  167. } else if ($arg == 'usaprint') {
  168. $this->_usaprint($arg_array);
  169. } else if ($arg == 'printck') {
  170. $this->_printck($arg_array);
  171. } else if ($arg == 'printrk') {
  172. $this->_printrk($arg_array);
  173. } else if ($arg == 'printxzrk') {
  174. $this->_printxzrk($arg_array);
  175. } else if ($arg == 'printexcel') {
  176. $this->_printexcel($arg_array);
  177. } else if ($arg == 'uck') {
  178. $this->_uck();
  179. } else if ($arg == 'whlabelexcelzh') {
  180. $this->_whlabelexcelzh();
  181. } else if ($arg == 'fc') {
  182. $this->_fc();
  183. } else if ($arg == 'fcmb') {
  184. $this->_fcmb();
  185. } else if ($arg == 'fcexcel') {
  186. $this->_fcexcel();
  187. } else if ($arg == 'fcjxc') {
  188. $this->_fcjxc($arg_array);
  189. } else if ($arg == '0kcdel') {
  190. $this->_0kcdel(); //导表删除0库存
  191. } else if ($arg == 'gbhtype') {
  192. $this->_gbhtype(); //更改备货状态
  193. } else if($arg == 'excelrjs'){
  194. $this->_excelrjs();
  195. } else if($arg == 'excelctjs'){
  196. $this->_excelctjs();
  197. }else if ($arg == 'exceljxcjs') //进销存信息导出
  198. {
  199. $this->_exceljxcjs();
  200. } else if ($arg == 'summaryjs') //汇总导出
  201. {
  202. $this->_summaryjs($arg_array);
  203. }else if($arg == 'uckjs'){
  204. $this->_uckjs();
  205. }else if ($arg == 'whlabelexcelzhjs') {
  206. $this->_whlabelexcelzhjs();
  207. }else if($arg == 'dccrtypejs'){
  208. $this->_dccrtypejs();
  209. }else if($arg == 'errorexceljs'){
  210. $this->_errorexceljs();
  211. }else if($arg == "w_t_cs"){
  212. $this->_w_t_cs(); //首页
  213. }else {
  214. $this->_index();
  215. }
  216. }
  217. public function _w_t_cs(){
  218. $vip = 0;
  219. if (isset($_SESSION['api'])) {
  220. $user = $this->user->get_api($_SESSION['api']);
  221. $fgshop = "";
  222. $sid = "";
  223. $usersp = explode('|', trim($user['shop'], '|'));
  224. foreach ($usersp as $value) {
  225. $fgshop .= " shop = " . $value . " or";
  226. $sid .= " id = " . $value . " or";
  227. }
  228. if ($user['vip'] == 1) {
  229. $vip = 1;
  230. }
  231. } else {
  232. header('Location: /');
  233. exit;
  234. }
  235. $prc = array();
  236. $purchase = $this->purchase->find_all();
  237. foreach ($purchase as $k => $v) {
  238. $prc[$v['id']] = $v['title'];
  239. }
  240. $company = array();
  241. $ct = $this->company->find_all();
  242. foreach ($ct as $k => $v) {
  243. $company[$v['id']] = $v['title'];
  244. }
  245. $sp = array();
  246. $s = $this->shop->find_all('1=1', 'id,shopname');
  247. foreach ($s as $v) {
  248. $sp[$v['id']] = $v['shopname'];
  249. }
  250. $wh = array();
  251. $w = $this->warehouse->find_all('1=1', 'id,title');
  252. foreach ($w as $v) {
  253. $wh[$v['id']] = $v['title'];
  254. }
  255. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  256. $this->data['shop'] = $wlshop;
  257. $this->data['vip'] = $vip;
  258. $this->_Template('whlabel_typejs', $this->data);
  259. }
  260. //管理
  261. public function _index()
  262. {
  263. $post = $this->input->post(NULL, TRUE);
  264. if (isset($post['page'])) {
  265. $page = $this->input->post('page', true);
  266. $perpage = $this->input->post('perpage', true);
  267. $sku = $this->input->post('sku', true);
  268. $number = $this->input->post('number', true);
  269. $warehouse = $this->input->post('warehouse', true);
  270. $purchase = $this->input->post('purchase', true);
  271. $orderinfo = $this->input->post('orderinfo', true);
  272. $waybill = $this->input->post('waybill', true);
  273. $category = $this->input->post('category', true);
  274. $size = $this->input->post('size', true);
  275. $grade = $this->input->post('grade', true);
  276. $color = $this->input->post('color', true);
  277. $lowe = $this->input->post('lowe', true);
  278. $state = $this->input->post('state', true);
  279. $label = $this->input->post('label', true);
  280. $timetk = $this->input->post('timetkk', true);
  281. $timetj = $this->input->post('timetjj', true);
  282. $timetk = strtotime($timetk);
  283. $timetj = strtotime($timetj);
  284. $where = "1=1 ";
  285. if ($timetk && $timetj) {
  286. $where .= " and time > '$timetk' and time < '$timetj'";
  287. }
  288. if ($sku) {
  289. $where .= " and sku = '$sku'";
  290. }
  291. if ($number) {
  292. $where .= " and number = '$number'";
  293. }
  294. if ($warehouse) {
  295. $where .= " and warehouse = '$warehouse'";
  296. }
  297. if ($purchase) {
  298. $where .= " and purchase = '$purchase'";
  299. }
  300. if ($orderinfo) {
  301. $where .= " and orderinfo = '$orderinfo'";
  302. }
  303. if ($waybill) {
  304. $where .= " and waybill = '$waybill'";
  305. }
  306. if ($category) {
  307. $where .= " and features like '%-$category-%'";
  308. }
  309. if ($size) {
  310. $where .= " and features like '%-$size-%'";
  311. }
  312. if ($grade) {
  313. $where .= " and features like '%-$grade-%'";
  314. }
  315. if ($color) {
  316. $where .= " and features like '%-$color-%'";
  317. }
  318. if ($lowe) {
  319. $where .= " and features like '%-$lowe-%'";
  320. }
  321. if ($label) {
  322. $where .= " and label = '$label'";
  323. }
  324. if ($state != '') {
  325. $where .= " and state = '$state'";
  326. }
  327. //数据排序
  328. $order_str = "time desc";
  329. if (empty($page)) {
  330. $start = 0;
  331. $perpage = 1;
  332. } else {
  333. $start = ($page - 1) * $perpage;
  334. }
  335. //取得信息列表
  336. $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);
  337. foreach ($info_list as $key => $value) {
  338. $warehouse = $this->warehouse->read($value['warehouse']);
  339. $info_list[$key]['warehouse'] = $warehouse['title'];
  340. $purchase = $this->purchase->read($value['purchase']);
  341. $info_list[$key]['purchase'] = $purchase['title'];
  342. if ($value['enter'] != 0) {
  343. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  344. } else {
  345. $info_list[$key]['enter'] = "";
  346. }
  347. if ($value['outk'] != 0) {
  348. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  349. } else {
  350. $info_list[$key]['outk'] = "";
  351. }
  352. if ($value['printing'] != 0) {
  353. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  354. } else {
  355. $info_list[$key]['printing'] = "";
  356. }
  357. if ($value['orderinfo'] == 0) {
  358. $info_list[$key]['orderinfo'] = "";
  359. }
  360. if ($value['waybill'] == 0) {
  361. $info_list[$key]['waybill'] = "";
  362. }
  363. if ($value['state'] == 0) {
  364. $info_list[$key]['state'] = "在库";
  365. } else if ($value['state'] == 1) {
  366. $info_list[$key]['state'] = "出库";
  367. } else if ($value['state'] == 2) {
  368. $info_list[$key]['state'] = "退库";
  369. } else if ($value['state'] == 3) {
  370. $info_list[$key]['state'] = "调拨中";
  371. } else if ($value['state'] == 4) {
  372. $info_list[$key]['state'] = "再加工";
  373. } else if ($value['state'] == 5) {
  374. $info_list[$key]['state'] = "维修中";
  375. } else if ($value['state'] == 6) {
  376. $info_list[$key]['state'] = "盘亏";
  377. } else if ($value['state'] == 7) {
  378. $info_list[$key]['state'] = "更换标签";
  379. } else if ($value['state'] == 8) {
  380. $info_list[$key]['state'] = "其它";
  381. } else if ($value['state'] == 9) {
  382. $info_list[$key]['state'] = "预设";
  383. } else if ($value['state'] == 10) {
  384. $info_list[$key]['state'] = "美店零售";
  385. }
  386. if ($value['text'] == "") {
  387. $info_list[$key]['text'] = "";
  388. }
  389. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  390. }
  391. $total = $this->whlabel->find_count($where);
  392. $pagenum = ceil($total / $perpage);
  393. $over = $total - ($start + $perpage);
  394. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  395. echo json_encode($rows);
  396. exit;
  397. }
  398. if (isset($post['outsku'])) {
  399. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  400. $cz = $this->input->post('cz', true);
  401. if ($cz == '1') {
  402. $sku = $this->input->post('outsku', true);
  403. if ($sku) {
  404. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  405. if (count($data) < 1) {
  406. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  407. exit;
  408. }
  409. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  410. echo json_encode(array('success' => true));
  411. exit;
  412. }
  413. } else {
  414. $sku = $this->input->post('outsku', true);
  415. if ($sku) {
  416. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  417. if (count($data) < 1) {
  418. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  419. exit;
  420. }
  421. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  422. echo json_encode(array('success' => true));
  423. exit;
  424. }
  425. }
  426. }
  427. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  428. $this->_Template('whlabel', $this->data);
  429. }
  430. //在库标签
  431. public function _existence()
  432. {
  433. $post = $this->input->post(NULL, TRUE);
  434. if (isset($post['s'])) {
  435. $id_arr = $this->input->post('s');
  436. $id_arr = explode(',', $id_arr);
  437. if (!$id_arr) {
  438. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  439. exit;
  440. }
  441. //循环删除记录
  442. foreach ($id_arr as $v) {
  443. $sid = $this->whlabel->read($v);
  444. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  445. if ($count > 0) {
  446. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  447. exit;
  448. }
  449. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  450. if (count($zt) > 0) {
  451. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  452. exit;
  453. }
  454. $this->whlabel->remove($v);
  455. }
  456. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  457. exit;
  458. }
  459. if (isset($post['page'])) {
  460. $page = $this->input->post('page', true);
  461. $perpage = $this->input->post('perpage', true);
  462. $warehouse = $this->input->post('warehouse', true);
  463. $label = $this->input->post('label', true);
  464. $where = "1=1 and state = 0";
  465. if ($warehouse) {
  466. $where .= " and warehouse = '$warehouse'";
  467. }
  468. if ($label) {
  469. $where .= " and label = '$label'";
  470. }
  471. //数据排序
  472. $order_str = "time asc";
  473. if (empty($page)) {
  474. $start = 0;
  475. $perpage = 1;
  476. } else {
  477. $start = ($page - 1) * $perpage;
  478. }
  479. //取得信息列表
  480. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  481. foreach ($info_list as $key => $value) {
  482. if ($value['enter'] != 0) {
  483. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  484. } else {
  485. $info_list[$key]['enter'] = "";
  486. }
  487. if ($value['printing'] != 0) {
  488. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  489. } else {
  490. $info_list[$key]['printing'] = "";
  491. }
  492. }
  493. $total = $this->whlabel->find_count($where);
  494. $pagenum = ceil($total / $perpage);
  495. $over = $total - ($start + $perpage);
  496. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  497. echo json_encode($rows);
  498. exit;
  499. }
  500. $this->_Template('whlabel_existence', $this->data);
  501. }
  502. //进销存浏览
  503. public function _typedy($arg_array)
  504. {
  505. $prc = array();
  506. $purchase = $this->purchase->find_all();
  507. foreach ($purchase as $k => $v) {
  508. $prc[$v['id']] = $v['title'];
  509. }
  510. $post = $this->input->post(NULL, TRUE);
  511. if (isset($post['page'])) {
  512. $page = $this->input->post('page', true);
  513. $perpage = $this->input->post('perpage', true);
  514. $category = $this->input->post('category', true);
  515. $size = $this->input->post('size', true);
  516. $grade = $this->input->post('grade', true);
  517. $color = $this->input->post('color', true);
  518. $lowe = $this->input->post('lowe', true);
  519. $sku = $this->input->post('sku');
  520. $title = $this->input->post('title');
  521. $warehouse = $this->input->post('warehouse', true);
  522. $usa = $this->input->post('usa', true);
  523. $purchase = $this->input->post('purchase', true);
  524. $lacetype = $this->input->post('lacetype', true);
  525. $haircap = $this->input->post('haircap', true);
  526. $density = $this->input->post('density', true);
  527. $details = $this->input->post('details', true);
  528. $state = $this->input->post('state', true);
  529. $lacecolor = $this->input->post('lacecolor', true);
  530. $hairnumber = $this->input->post('hairnumber', true);
  531. $cklx = $this->input->post('cklx', true);
  532. $ktime = $this->input->post('ktime', true);
  533. $jtime = $this->input->post('jtime', true);
  534. $sm = $this->input->post('sm', true);
  535. $cpbz = $this->input->post('cpbz', true);
  536. $type = $this->input->post('type', true);
  537. $ktime = strtotime($ktime);
  538. $jtime = strtotime($jtime);
  539. $where = "1=1";
  540. $gj = "";
  541. $ck = "";
  542. if ($usa) {
  543. if (!$warehouse) {
  544. $where .= " and (warehouse = '5' or warehouse = '8')";
  545. }
  546. }
  547. if ($warehouse) {
  548. $where .= " and warehouse = '$warehouse'";
  549. }
  550. if ($details) {
  551. $where .= " and details = '$details'";
  552. }
  553. if ($purchase) {
  554. $where .= " and purchase = '$purchase'";
  555. }
  556. if (isset($state)) {
  557. if($state >-1){
  558. $where .= " and state = '$state'";
  559. }
  560. }
  561. if ($lacetype) {
  562. $where .= " and features like '%-$lacetype-%'";
  563. }
  564. if ($category) {
  565. $where .= " and features like '%-$category-%'";
  566. }
  567. if ($size) {
  568. $where .= " and features like '%-$size-%'";
  569. }
  570. if ($grade) {
  571. $where .= " and features like '%-$grade-%'";
  572. }
  573. if ($color) {
  574. $where .= " and features like '%-$color-%'";
  575. }
  576. if ($lowe) {
  577. $where .= " and features like '%-$lowe-%'";
  578. }
  579. if ($haircap) {
  580. $where .= " and features like '%-$haircap-%'";
  581. }
  582. if ($density) {
  583. $where .= " and features like '%-$density-%'";
  584. }
  585. if ($lacecolor) {
  586. $where .= " and features like '%-$lacecolor-%'";
  587. }
  588. if($sm){
  589. $where .= " and sm like '%".$sm."%'";
  590. }
  591. if($cpbz){
  592. $where .= " and cpbz like '%".$cpbz."%'";
  593. }
  594. if($type){
  595. $where .= " and type = ".$type."";
  596. }
  597. if (!empty($hairnumber)) {
  598. $where .= " and features like '%-128-%' ";
  599. if ($hairnumber < 0) {
  600. $class_list = $this->typeclass->find_all('classid = 43');
  601. foreach ($class_list as $v) {
  602. $where .= " and features not like '%-" . $v['id'] . "-%'";
  603. }
  604. } else {
  605. $where .= " and features like '%-$hairnumber-%'";
  606. }
  607. }
  608. $where_add = '';
  609. if ($cklx) {
  610. $shop = $this->shop->read($cklx);
  611. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  612. }
  613. if ($ktime && $jtime) {
  614. $gj = " and enter > '$ktime' and enter < '$jtime'";
  615. $ck = " and outk > '$ktime' and outk < '$jtime'";
  616. }
  617. //数据排序
  618. $order_str = "id desc";
  619. if (empty($page)) {
  620. $start = 0;
  621. $perpage = 1;
  622. } else {
  623. $start = ($page - 1) * $perpage;
  624. }
  625. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  626. if ($sku) {
  627. $sku = trim($sku, ' ');
  628. $sku = trim($sku, ' ');
  629. $where .= " and sku like '%$sku%'";
  630. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  631. } else if ($title) {
  632. $title = trim($title, ' ');
  633. $title = trim($title, ' ');
  634. $where .= " and title like '%$title%'";
  635. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  636. } else {
  637. //$where .= " and time > '$ktime' and time < '$jtime'";
  638. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  639. }
  640. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  641. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  642. foreach ($info_list as $k => $v) {
  643. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  644. unset($info_list[$k]['pm']);
  645. unset($info_list[$k]['jm']);
  646. unset($info_list[$k]['bm']);
  647. }
  648. //取得信息列表
  649. $rows = array();
  650. $list = array();
  651. foreach ($info_list as $key => $value) {
  652. $warehouse = $this->warehouse->read($value['warehouse']);
  653. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  654. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  655. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  656. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  657. $info_list[$key]['label'] = $value['sm'];
  658. $number = $value['number'];
  659. $ftime = time() - 15 * 24 * 3600;
  660. $info_list[$key]['warehouse'] = $warehouse['title'];
  661. $info_list[$key]['features'] = count($c);
  662. $z = count($z); //查看订单号
  663. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  664. $ztdata = '';
  665. if (count($zt) > 0) {
  666. foreach ($zt as $vv) {
  667. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  668. }
  669. }
  670. $info_list[$key]['number'] = $ztdata;
  671. $info_list[$key]['sm'] = $z;
  672. $details = array();
  673. $cpid = array();
  674. foreach ($c as $k => $v) {
  675. $details[$v['details']] = $v['details'];
  676. if ($v['cpid'] != 0) {
  677. $cpid[$v['cpid']] = $v['cpid'];
  678. }
  679. }
  680. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  681. if ($value['shop'] != '') {
  682. $shop = explode(',', trim($value['shop'], ','));
  683. $shop = $this->shop->read($shop[0]);
  684. $info_list[$key]['shop'] = $shop['shopname'];
  685. }
  686. }
  687. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  688. $pagenum = ceil($total / $perpage);
  689. $over = $total - ($start + $perpage);
  690. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  691. echo json_encode($rows);
  692. exit;
  693. }
  694. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  695. $this->_Template('whlabel_typedy', $this->data);
  696. }
  697. //进销存浏览
  698. public function _typedy_ck($arg_array)
  699. {
  700. $prc = array();
  701. $purchase = $this->purchase->find_all();
  702. foreach ($purchase as $k => $v) {
  703. $prc[$v['id']] = $v['title'];
  704. }
  705. $post = $this->input->post(NULL, TRUE);
  706. if (isset($post['page'])) {
  707. $page = $this->input->post('page', true);
  708. $perpage = $this->input->post('perpage', true);
  709. $category = $this->input->post('category', true);
  710. $size = $this->input->post('size', true);
  711. $grade = $this->input->post('grade', true);
  712. $color = $this->input->post('color', true);
  713. $lowe = $this->input->post('lowe', true);
  714. $sku = $this->input->post('sku');
  715. $title = $this->input->post('title');
  716. $warehouse = $this->input->post('warehouse', true);
  717. $usa = $this->input->post('usa', true);
  718. $purchase = $this->input->post('purchase', true);
  719. $lacetype = $this->input->post('lacetype', true);
  720. $haircap = $this->input->post('haircap', true);
  721. $density = $this->input->post('density', true);
  722. $details = $this->input->post('details', true);
  723. $state = $this->input->post('state', true);
  724. $lacecolor = $this->input->post('lacecolor', true);
  725. $cklx = $this->input->post('cklx', true);
  726. $ktime = $this->input->post('ktime', true);
  727. $jtime = $this->input->post('jtime', true);
  728. $ktime = strtotime($ktime);
  729. $jtime = strtotime($jtime);
  730. $where = "1=1";
  731. $gj = "";
  732. $ck = "";
  733. if ($lacetype) {
  734. $where .= " and features like '%-$lacetype-%'";
  735. }
  736. if ($category) {
  737. $where .= " and features like '%-$category-%'";
  738. }
  739. if ($size) {
  740. $where .= " and features like '%-$size-%'";
  741. }
  742. if ($grade) {
  743. $where .= " and features like '%-$grade-%'";
  744. }
  745. if ($color) {
  746. $where .= " and features like '%-$color-%'";
  747. }
  748. if ($lowe) {
  749. $where .= " and features like '%-$lowe-%'";
  750. }
  751. if ($haircap) {
  752. $where .= " and features like '%-$haircap-%'";
  753. }
  754. if ($density) {
  755. $where .= " and features like '%-$density-%'";
  756. }
  757. if ($lacecolor) {
  758. $where .= " and features like '%-$lacecolor-%'";
  759. }
  760. if ($usa) {
  761. if (!$warehouse) {
  762. $where .= " and (warehouse = '5' or warehouse = '8')";
  763. }
  764. }
  765. if ($warehouse) {
  766. $where .= " and warehouse = '$warehouse'";
  767. }
  768. if ($details) {
  769. $where .= " and details = '$details'";
  770. }
  771. if ($purchase) {
  772. $where .= " and purchase = '$purchase'";
  773. }
  774. if ($state) {
  775. $where .= " and state = '$state'";
  776. }
  777. $where_add = '';
  778. if ($cklx) {
  779. $shop = $this->shop->read($cklx);
  780. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  781. }
  782. if ($ktime && $jtime) {
  783. $gj = " and enter > '$ktime' and enter < '$jtime'";
  784. $ck = " and outk > '$ktime' and outk < '$jtime'";
  785. }
  786. //数据排序
  787. $order_str = "id desc";
  788. if (empty($page)) {
  789. $start = 0;
  790. $perpage = 1;
  791. } else {
  792. $start = ($page - 1) * $perpage;
  793. }
  794. if ($sku) {
  795. $sku = trim($sku, ' ');
  796. $sku = trim($sku, ' ');
  797. $where .= " and sku like '%$sku%'";
  798. $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);
  799. } else if ($title) {
  800. $title = trim($title, ' ');
  801. $title = trim($title, ' ');
  802. $where .= " and title like '%$title%'";
  803. $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);
  804. } else {
  805. //$where .= " and time > '$ktime' and time < '$jtime'";
  806. $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);
  807. }
  808. //取得信息列表
  809. $rows = array();
  810. $list = array();
  811. foreach ($info_list as $key => $value) {
  812. $warehouse = $this->warehouse->read($value['warehouse']);
  813. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  814. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  815. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  816. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  817. $ftime = time() - 15 * 24 * 3600;
  818. $info_list[$key]['warehouse'] = $warehouse['title'];
  819. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  820. //$z = count($z);//查看订单号
  821. //$info_list[$key]['zd'] = $z;
  822. $details = array();
  823. $cpid = array();
  824. foreach ($c as $k => $v) {
  825. $details[$v['details']] = $v['details'];
  826. if ($v['cpid'] != 0) {
  827. $cpid[$v['cpid']] = $v['cpid'];
  828. }
  829. }
  830. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  831. if ($value['shop'] != '') {
  832. $shop = explode(',', trim($value['shop'], ','));
  833. $shop = $this->shop->read($shop[0]);
  834. $info_list[$key]['shop'] = $shop['shopname'];
  835. }
  836. }
  837. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  838. $pagenum = ceil($total / $perpage);
  839. $over = $total - ($start + $perpage);
  840. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  841. echo json_encode($rows);
  842. exit;
  843. }
  844. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  845. $this->_Template('whlabel_typedy_ck', $this->data);
  846. }
  847. public function _typeck($arg_array)
  848. {
  849. $prc = array();
  850. $purchase = $this->purchase->find_all();
  851. foreach ($purchase as $k => $v) {
  852. $prc[$v['id']] = $v['title'];
  853. }
  854. $post = $this->input->post(NULL, TRUE);
  855. if (isset($post['page'])) {
  856. $page = $this->input->post('page', true);
  857. $perpage = $this->input->post('perpage', true);
  858. $category = $this->input->post('category', true);
  859. $size = $this->input->post('size', true);
  860. $grade = $this->input->post('grade', true);
  861. $color = $this->input->post('color', true);
  862. $lacecolor = $this->input->post('lacecolor', true);
  863. $lowe = $this->input->post('lowe', true);
  864. $sku = $this->input->post('sku');
  865. $title = $this->input->post('title');
  866. $warehouse = 13;
  867. $usa = $this->input->post('usa', true);
  868. $purchase = $this->input->post('purchase', true);
  869. $lacetype = $this->input->post('lacetype', true);
  870. $haircap = $this->input->post('haircap', true);
  871. $density = $this->input->post('density', true);
  872. $details = $this->input->post('details', true);
  873. $state = $this->input->post('state', true);
  874. $ktime = $this->input->post('ktime', true);
  875. $jtime = $this->input->post('jtime', true);
  876. $ktime = strtotime($ktime);
  877. $jtime = strtotime($jtime);
  878. $where = "1=1";
  879. $gj = "";
  880. $ck = "";
  881. if ($lacetype) {
  882. $where .= " and features like '%-$lacetype-%'";
  883. }
  884. if ($category) {
  885. $where .= " and features like '%-$category-%'";
  886. }
  887. if ($size) {
  888. $where .= " and features like '%-$size-%'";
  889. }
  890. if ($grade) {
  891. $where .= " and features like '%-$grade-%'";
  892. }
  893. if ($color) {
  894. $where .= " and features like '%-$color-%'";
  895. }
  896. if ($lacecolor) {
  897. $where .= " and features like '%-$lacecolor-%'";
  898. }
  899. if ($lowe) {
  900. $where .= " and features like '%-$lowe-%'";
  901. }
  902. if ($haircap) {
  903. $where .= " and features like '%-$haircap-%'";
  904. }
  905. if ($density) {
  906. $where .= " and features like '%-$density-%'";
  907. }
  908. if ($warehouse) {
  909. $where .= " and warehouse = '$warehouse'";
  910. }
  911. if ($details) {
  912. $where .= " and details = '$details'";
  913. }
  914. if ($purchase) {
  915. $where .= " and purchase = '$purchase'";
  916. }
  917. if ($state) {
  918. $where .= " and state = '$state'";
  919. }
  920. if ($ktime && $jtime) {
  921. $gj = " and enter > '$ktime' and enter < '$jtime'";
  922. $ck = " and outk > '$ktime' and outk < '$jtime'";
  923. }
  924. //数据排序
  925. $order_str = "id desc";
  926. if (empty($page)) {
  927. $start = 0;
  928. $perpage = 1;
  929. } else {
  930. $start = ($page - 1) * $perpage;
  931. }
  932. if ($sku) {
  933. $sku = trim($sku, ' ');
  934. $sku = trim($sku, ' ');
  935. $where .= " and sku like '%$sku%'";
  936. } else if ($title) {
  937. $title = trim($title, ' ');
  938. $title = trim($title, ' ');
  939. $where .= " and title like '%$title%'";
  940. }
  941. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  942. //取得信息列表
  943. $t = array();
  944. $typeclass = $this->typeclass->find_all();
  945. foreach ($typeclass as $v) {
  946. $t[$v['id']] = $v;
  947. }
  948. $rows = array();
  949. $list = array();
  950. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  951. foreach ($info_list as $key => $value) {
  952. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  953. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  954. $warehouse = $this->warehouse->read($value['warehouse']);
  955. $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');
  956. $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'] . '"');
  957. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  958. $number = $value['number'];
  959. $ftime = time() - 15 * 24 * 3600;
  960. $z = count($z); //查看订单号
  961. $info_list[$key]['warehouse'] = $warehouse['title'];
  962. $info_list[$key]['features'] = count($c);
  963. $info_list[$key]['number'] = $z;
  964. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  965. $details = array();
  966. $cpid = array();
  967. foreach ($c as $k => $v) {
  968. $details[$v['details']] = $v['details'];
  969. if ($v['cpid'] != 0) {
  970. $cpid[$v['cpid']] = $v['cpid'];
  971. }
  972. }
  973. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  974. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  975. unset($info_list[$key]['pm']);
  976. unset($info_list[$key]['jm']);
  977. unset($info_list[$key]['bm']);
  978. }
  979. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  980. $pagenum = ceil($total / $perpage);
  981. $over = $total - ($start + $perpage);
  982. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  983. echo json_encode($rows);
  984. exit;
  985. }
  986. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  987. $this->_Template('whlabel_typeck', $this->data);
  988. }
  989. //进销存导出
  990. public function _whlabeckdc()
  991. {
  992. $prc = array();
  993. $purchase = $this->purchase->find_all();
  994. foreach ($purchase as $k => $v) {
  995. $prc[$v['id']] = $v['title'];
  996. }
  997. if (isset($_GET['excel'])) {
  998. $where = "sku != 'Preset'";
  999. //数据排序
  1000. $order_str = "id desc";
  1001. if (empty($page)) {
  1002. $start = 0;
  1003. $perpage = 1;
  1004. } else {
  1005. $start = ($page - 1) * $perpage;
  1006. }
  1007. $category = $this->input->get('category', true);
  1008. $color = $this->input->get('color', true);
  1009. $lowe = $this->input->get('lowe', true);
  1010. $lacetype = $this->input->get('lacetype', true);
  1011. $size = $this->input->get('size', true);
  1012. $density = $this->input->get('density', true);
  1013. $haircap = $this->input->get('haircap', true);
  1014. $sku = $this->input->get('sku', true);
  1015. $details = $this->input->get('details', true);
  1016. $warehouse = 13;
  1017. $excelid = $this->input->get('sid', true);
  1018. if ($category) {
  1019. $where .= " and features like '%-$category-%'";
  1020. }
  1021. if ($color) {
  1022. $where .= " and features like '%-$color-%'";
  1023. }
  1024. if ($lowe) {
  1025. $where .= " and features like '%-$lowe-%'";
  1026. }
  1027. if ($lacetype) {
  1028. $where .= " and features like '%-$lacetype-%'";
  1029. }
  1030. if ($size) {
  1031. $where .= " and features like '%-$size-%'";
  1032. }
  1033. if ($density) {
  1034. $where .= " and features like '%-$density-%'";
  1035. }
  1036. if ($haircap) {
  1037. $where .= " and features like '%-$haircap-%'";
  1038. }
  1039. if ($warehouse) {
  1040. $where .= " and warehouse = '$warehouse'";
  1041. }
  1042. if ($sku) {
  1043. $where .= " and sku like '%$sku%'";
  1044. }
  1045. if ($details) {
  1046. $where .= " and details = '$details'";
  1047. }
  1048. $xzid = '';
  1049. if ($excelid) {
  1050. $excelid = explode(',', trim($excelid, ','));
  1051. foreach ($excelid as $key => $value) {
  1052. $xzid .= " id = " . $value . " or";
  1053. }
  1054. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1055. }
  1056. //取得信息列表
  1057. /**
  1058. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1059. $rows = array();$list = array();
  1060. foreach ($info_list as $key=>$value)
  1061. {
  1062. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1063. }
  1064. **/
  1065. $wh = array();
  1066. $w = $this->warehouse->find_all('1=1', 'id,title');
  1067. foreach ($w as $v) {
  1068. $wh[$v['id']] = $v['title'];
  1069. }
  1070. $tc = array();
  1071. $tcdata = array();
  1072. $list = array();
  1073. $classid = $this->classid->sku();
  1074. $tcall = $this->typeclass->find_all();
  1075. $typeclass = array();
  1076. foreach ($tcall as $v)
  1077. {
  1078. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1079. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1080. }
  1081. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1082. foreach ($rows as $key => $value) {
  1083. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1084. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1085. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1086. $rows[$key]['cpbz'] = $u9_info['bm'];
  1087. $rows[$key]['cs'] = $u9_info['jm'];
  1088. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1089. $details = array();
  1090. $cpid = array();
  1091. $cpbz = array();
  1092. $c = 0;
  1093. $g = 0;
  1094. $x = 0;
  1095. $t = 0;
  1096. $s = 0;
  1097. $q = 0;
  1098. foreach ($sd as $k => $v) {
  1099. if ($v['state'] == 0) {
  1100. $c++;
  1101. }
  1102. if ($v['state'] != 9) {
  1103. $g++;
  1104. }
  1105. if ($v['state'] == 1) {
  1106. $x++;
  1107. }
  1108. if ($v['state'] == 2) {
  1109. $t++;
  1110. }
  1111. if ($v['state'] == 8) {
  1112. $s++;
  1113. }
  1114. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1115. $q++;
  1116. }
  1117. $details[$v['details']] = $v['details'];
  1118. if ($v['cpid'] != 0) {
  1119. $cpid[$v['cpid']] = $v['cpid'];
  1120. }
  1121. if ($v['cpbz'] != '') {
  1122. $cpbz[$v['cpbz']] = $v['cpbz'];
  1123. }
  1124. }
  1125. $rows[$key]['details'] = implode("、", $details);
  1126. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1127. $number = $value['number'];
  1128. $ftime = time() - 15 * 24 * 3600;
  1129. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1130. $rows[$key]['number'] = $g;
  1131. $rows[$key]['features'] = $c;
  1132. $rows[$key]['x'] = $x;
  1133. $rows[$key]['t'] = $t;
  1134. $rows[$key]['s'] = $s;
  1135. $rows[$key]['q'] = $q;
  1136. $rows[$key]['wzsl'] = count($details);
  1137. }
  1138. $title = "进销存统计表" . date('Y-m-d', time());
  1139. $titlename = "<table border=1>
  1140. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1141. <tr align='center'>
  1142. <td>仓库</td>
  1143. <td>供应商</td>
  1144. <td>位置</td>
  1145. <td>库存编码</td>
  1146. <td>SKU</td>
  1147. <td>用友编码</td>
  1148. <td>用友料号</td>
  1149. <td>产品英文名</td>
  1150. <td>产品中文名</td>
  1151. <td>入库总量</td>
  1152. <td>库存数量</td>
  1153. <td>销售数量</td>
  1154. <td>退货数量</td>
  1155. <td>删除数量</td>
  1156. <td>其它操作</td>
  1157. <td>位置数量</td>
  1158. </tr>
  1159. </table>";
  1160. $filename = $title . ".xls";
  1161. $tail = "";
  1162. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1163. }
  1164. }
  1165. public function _type()
  1166. {
  1167. $vip = 0;
  1168. if (isset($_SESSION['api'])) {
  1169. $user = $this->user->get_api($_SESSION['api']);
  1170. $fgshop = "";
  1171. $sid = "";
  1172. $usersp = explode('|', trim($user['shop'], '|'));
  1173. foreach ($usersp as $value) {
  1174. $fgshop .= " shop = " . $value . " or";
  1175. $sid .= " id = " . $value . " or";
  1176. }
  1177. if ($user['vip'] == 1) {
  1178. $vip = 1;
  1179. }
  1180. } else {
  1181. header('Location: /');
  1182. exit;
  1183. }
  1184. $prc = array();
  1185. $purchase = $this->purchase->find_all();
  1186. foreach ($purchase as $k => $v) {
  1187. $prc[$v['id']] = $v['title'];
  1188. }
  1189. $company = array();
  1190. $ct = $this->company->find_all();
  1191. foreach ($ct as $k => $v) {
  1192. $company[$v['id']] = $v['title'];
  1193. }
  1194. $sp = array();
  1195. $s = $this->shop->find_all('1=1', 'id,shopname');
  1196. foreach ($s as $v) {
  1197. $sp[$v['id']] = $v['shopname'];
  1198. }
  1199. $wh = array();
  1200. $w = $this->warehouse->find_all('1=1', 'id,title');
  1201. foreach ($w as $v) {
  1202. $wh[$v['id']] = $v['title'];
  1203. }
  1204. $post = $this->input->post(NULL, TRUE);
  1205. if (isset($post['page'])) {
  1206. $page = $this->input->post('page', true);
  1207. $perpage = $this->input->post('perpage', true);
  1208. $category = $this->input->post('category', true);
  1209. $size = $this->input->post('size', true);
  1210. $grade = $this->input->post('grade', true);
  1211. $color = $this->input->post('color', true);
  1212. $lowe = $this->input->post('lowe', true);
  1213. $sku = $this->input->post('sku');
  1214. $title = $this->input->post('title');
  1215. $warehouse = $this->input->post('warehouse', true);
  1216. $usa = $this->input->post('usa', true);
  1217. $purchase = $this->input->post('purchase', true);
  1218. $lacetype = $this->input->post('lacetype', true);
  1219. $haircap = $this->input->post('haircap', true);
  1220. $density = $this->input->post('density', true);
  1221. $details = $this->input->post('details', true);
  1222. $state = $this->input->post('state', true);
  1223. $shop = $this->input->post('shop', true);
  1224. $lacecolor = $this->input->post('lacecolor', true);
  1225. $hairnumber = $this->input->post('hairnumber', true);
  1226. $type = $this->input->post('type', true);
  1227. $ktime = $this->input->post('ktime', true);
  1228. $jtime = $this->input->post('jtime', true);
  1229. $ktime = strtotime($ktime);
  1230. $jtime = strtotime($jtime);
  1231. $cpbz = $this->input->post('cpbz', true);
  1232. $sm = $this->input->post('sm', true);
  1233. $where = "1=1";
  1234. $gj = "";
  1235. $ck = "";
  1236. if ($usa) {
  1237. if (!$warehouse) {
  1238. $where .= " and (warehouse = '5' or warehouse = '8')";
  1239. }
  1240. }
  1241. if ($warehouse) {
  1242. $where .= " and warehouse = '$warehouse'";
  1243. }
  1244. if ($details) {
  1245. $where .= " and details = '$details'";
  1246. }
  1247. if ($purchase) {
  1248. $where .= " and purchase = '$purchase'";
  1249. }
  1250. if ($state) {
  1251. $where .= " and state = '$state'";
  1252. }
  1253. if ($shop) {
  1254. $where .= " and shop like '%$shop%'";
  1255. }
  1256. if ($type) {
  1257. $where .= " and type = '$type'";
  1258. }
  1259. if ($ktime && $jtime) {
  1260. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1261. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1262. }
  1263. if ($cpbz) {
  1264. $where .= " and cpbz like '%$cpbz%' ";
  1265. }
  1266. if ($sm) {
  1267. $where .= " and sm like '%$sm%' ";
  1268. }
  1269. if ($lacecolor) {
  1270. $where .= " and features like '%-$lacecolor-%'";
  1271. }
  1272. if ($lacetype) {
  1273. $where .= " and features like '%-$lacetype-%'";
  1274. }
  1275. if ($category) {
  1276. $where .= " and features like '%-$category-%'";
  1277. }
  1278. if ($size) {
  1279. $where .= " and features like '%-$size-%'";
  1280. }
  1281. if ($grade) {
  1282. $where .= " and features like '%-$grade-%'";
  1283. }
  1284. if ($color) {
  1285. $where .= " and features like '%-$color-%'";
  1286. }
  1287. if ($lowe) {
  1288. $where .= " and features like '%-$lowe-%'";
  1289. }
  1290. if ($haircap) {
  1291. $where .= " and features like '%-$haircap-%'";
  1292. }
  1293. if ($density) {
  1294. $where .= " and features like '%-$density-%'";
  1295. }
  1296. if (!empty($hairnumber)) {
  1297. $where .= " and features like '%-128-%' ";
  1298. if ($hairnumber < 0) {
  1299. $class_list = $this->typeclass->find_all('classid = 43');
  1300. foreach ($class_list as $v) {
  1301. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1302. }
  1303. } else {
  1304. $where .= " and features like '%-$hairnumber-%'";
  1305. }
  1306. }
  1307. //数据排序
  1308. $order_str = "id desc";
  1309. if (empty($page)) {
  1310. $start = 0;
  1311. $perpage = 1;
  1312. } else {
  1313. $start = ($page - 1) * $perpage;
  1314. }
  1315. $fjnr = '';
  1316. if ($sku) {
  1317. $sku = trim($sku, ' ');
  1318. $sku = trim($sku, ' ');
  1319. $fjnr .= " and sku like '%$sku%'";
  1320. }
  1321. if ($title) {
  1322. $title = trim($title, ' ');
  1323. $title = trim($title, ' ');
  1324. $fjnr .= " and title like '%$title%'";
  1325. }
  1326. $wt = array();
  1327. $whlabel_type = $this->whlabel_type->find_all();
  1328. foreach ($whlabel_type as $v) {
  1329. $wt[$v['id']] = $v['title'];
  1330. }
  1331. //$where .= " and time > '$ktime' and time < '$jtime'";
  1332. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1333. //取得信息列表
  1334. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1335. $rows = array();
  1336. $list = array();
  1337. foreach ($info_list as $key => $value) {
  1338. if (isset($wt[$value['type']])) {
  1339. $info_list[$key]['type'] = $wt[$value['type']];
  1340. } else {
  1341. $info_list[$key]['type'] = '未设置';
  1342. }
  1343. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1344. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1345. $ztdata = '';
  1346. if (count($zt) > 0) {
  1347. foreach ($zt as $vv) {
  1348. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1349. }
  1350. }
  1351. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1352. $cdata = array_filter($qbdata, function ($item) {
  1353. return $item['state'] < 1;
  1354. });
  1355. $c = array_sum(array_column($cdata, 'jnum'));
  1356. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1357. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1358. });
  1359. $g = array_sum(array_column($gdata, 'jnum'));
  1360. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1361. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1362. });
  1363. $x = array_sum(array_column($xdata, 'jnum'));
  1364. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1365. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1366. });
  1367. $t = array_sum(array_column($tdata, 'jnum'));
  1368. // $zdata = array_filter($qbdata, function ($item) {
  1369. // return $item['zd'] != "" && $item['state'] < 1;
  1370. // });
  1371. // $z = array_sum(array_column($zdata, 'jnum'));
  1372. $zdata = array_filter($qbdata, function ($item) {
  1373. return $item['zd'] != "" && $item['state'] < 1;
  1374. });
  1375. $z = array_sum(array_column($zdata, 'jnum'));
  1376. //$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');
  1377. //$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'].'"');
  1378. //$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'].'"');
  1379. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1380. //$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'].'"');
  1381. $details = array();
  1382. $cpid = array();
  1383. $od = array();
  1384. $odid = '';
  1385. $companytitle = '';
  1386. $shop_list = [];
  1387. foreach ($qbdata as $v) {
  1388. if ($v['zd'] != "" && $v['state'] < 1) {
  1389. if (!isset($od[$v['zd']])) {
  1390. $od[$v['zd']] = 1; //所有数据sku
  1391. } else {
  1392. $od[$v['zd']] = $od[$v['zd']] + 1;
  1393. }
  1394. }
  1395. $details[$v['details']] = $v['details'];
  1396. if ($v['state'] < 1) {
  1397. //$details[$v['details']] = $v['details'];
  1398. if ($v['cpid'] != 0) {
  1399. $cpid[$v['cpid']] = $v['cpid'];
  1400. }
  1401. }
  1402. if($v['state'] == 0){
  1403. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1404. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1405. }
  1406. if ($v['shop'] != '') {
  1407. $shop = explode(',', trim($v['shop'], ','));
  1408. foreach ($shop as $vv) {
  1409. if (!in_array($vv, $shop_list)) {
  1410. $shop_list[] = $vv;
  1411. }
  1412. }
  1413. }
  1414. }
  1415. }
  1416. foreach ($od as $k => $vv) {
  1417. $odid .= $k . '数量' . $vv;
  1418. }
  1419. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1420. $info_list[$key]['label'] = $value['sm'];
  1421. $number = $value['number'];
  1422. $ftime = time() - 15 * 24 * 3600;
  1423. $z = $z . '(' . $odid . ')'; //查看订单号
  1424. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1425. $info_list[$key]['features'] = $c;
  1426. $info_list[$key]['number'] = $ztdata;
  1427. $info_list[$key]['sm'] = $g;
  1428. $info_list[$key]['x'] = $x;
  1429. $info_list[$key]['t'] = $t;
  1430. $info_list[$key]['z'] = $z;
  1431. /**
  1432. foreach ($cdata as $k=>$v)
  1433. {
  1434. $details[$v['details']] = $v['details'];
  1435. if($v['cpid'] != 0)
  1436. {
  1437. $cpid[$v['cpid']] = $v['cpid'];
  1438. }
  1439. }
  1440. **/
  1441. $info_list[$key]['shop'] = '';
  1442. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1443. // if ($value['shop'] != '') {
  1444. // $shop = explode(',', trim($value['shop'], ','));
  1445. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1446. // }
  1447. $shop_list = array_unique($shop_list);
  1448. $shop_str = '';
  1449. foreach ($shop_list as $v) {
  1450. if(isset($sp[$v])){
  1451. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1452. }
  1453. }
  1454. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1455. /**
  1456. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1457. if(isset($companytitle[0]))
  1458. {
  1459. foreach ($companytitle as $k=>$v)
  1460. {
  1461. if($v['companytitle'] != '')
  1462. {
  1463. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1464. }
  1465. }
  1466. }
  1467. **/
  1468. }
  1469. $final_all_list = [];
  1470. foreach ($info_list as $k => $v) {
  1471. $final_all_list[] = [
  1472. 'id' => $v['id'],
  1473. "warehouse" => $v["warehouse"],
  1474. "purchase" => $v["purchase"],
  1475. "sku" => $v["sku"],
  1476. "title" => $v["title"] . "<br/>" . $v["pm"],
  1477. "details" => $v["details"],
  1478. "shop" => $v["shop"],
  1479. "cpbz" => $v["cpbz"],
  1480. 'label' => $v['label'],
  1481. "type" => $v["type"],
  1482. "features" => $v["features"],
  1483. "number" => $v["number"],
  1484. "sm" => $v["sm"],
  1485. "x" => $v["x"],
  1486. "t" => $v["t"],
  1487. "z" => $v["z"]
  1488. ];
  1489. }
  1490. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1491. $pagenum = ceil($total / $perpage);
  1492. $over = $total - ($start + $perpage);
  1493. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1494. echo json_encode($rows);
  1495. exit;
  1496. }
  1497. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1498. $this->data['shop'] = $wlshop;
  1499. $this->data['vip'] = $vip;
  1500. $this->_Template('whlabel_type', $this->data);
  1501. }
  1502. //美仓进销存浏览
  1503. public function _usatype()
  1504. {
  1505. if (isset($_SESSION['api'])) {
  1506. $user = $this->user->get_api($_SESSION['api']);
  1507. $usp = $user;
  1508. $fgshop = "";
  1509. $sid = "";
  1510. $wid = "";
  1511. $wtype = "";
  1512. $userwh = explode('|', trim($user['warehouse'], '|'));
  1513. foreach ($userwh as $value) {
  1514. $wid .= " id = " . $value . " or";
  1515. $wtype .= " type = " . $value . " or";
  1516. }
  1517. }
  1518. $prc = array();
  1519. $purchase = $this->purchase->find_all();
  1520. foreach ($purchase as $k => $v) {
  1521. $prc[$v['id']] = $v['title'];
  1522. }
  1523. $post = $this->input->post(NULL, TRUE);
  1524. if (isset($post['page'])) {
  1525. $page = $this->input->post('page', true);
  1526. $perpage = $this->input->post('perpage', true);
  1527. $category = $this->input->post('category', true);
  1528. $size = $this->input->post('size', true);
  1529. $grade = $this->input->post('grade', true);
  1530. $color = $this->input->post('color', true);
  1531. $lowe = $this->input->post('lowe', true);
  1532. $sku = $this->input->post('sku');
  1533. $title = $this->input->post('title');
  1534. $warehouse = $this->input->post('warehouse', true);
  1535. $usa = $this->input->post('usa', true);
  1536. $purchase = $this->input->post('purchase', true);
  1537. $lacetype = $this->input->post('lacetype', true);
  1538. $haircap = $this->input->post('haircap', true);
  1539. $density = $this->input->post('density', true);
  1540. $details = $this->input->post('details', true);
  1541. $state = $this->input->post('state', true);
  1542. $lacecolor = $this->input->post('lacecolor', true);
  1543. $cklx = $this->input->post('cklx', true);
  1544. $ktime = $this->input->post('ktime', true);
  1545. $jtime = $this->input->post('jtime', true);
  1546. $ktime = strtotime($ktime);
  1547. $jtime = strtotime($jtime);
  1548. $where = "1=1";
  1549. $gj = "";
  1550. $ck = "";
  1551. if ($lacetype) {
  1552. $where .= " and features like '%-$lacetype-%'";
  1553. }
  1554. if ($category) {
  1555. $where .= " and features like '%-$category-%'";
  1556. }
  1557. if ($size) {
  1558. $where .= " and features like '%-$size-%'";
  1559. }
  1560. if ($grade) {
  1561. $where .= " and features like '%-$grade-%'";
  1562. }
  1563. if ($color) {
  1564. $where .= " and features like '%-$color-%'";
  1565. }
  1566. if ($lowe) {
  1567. $where .= " and features like '%-$lowe-%'";
  1568. }
  1569. if ($haircap) {
  1570. $where .= " and features like '%-$haircap-%'";
  1571. }
  1572. if ($density) {
  1573. $where .= " and features like '%-$density-%'";
  1574. }
  1575. if ($lacecolor) {
  1576. $where .= " and features like '%-$lacecolor-%'";
  1577. }
  1578. if ($usa) {
  1579. if (!$warehouse) {
  1580. $where .= " and (warehouse = '5' or warehouse = '8')";
  1581. }
  1582. }
  1583. if ($warehouse) {
  1584. $where .= " and warehouse = '$warehouse'";
  1585. }
  1586. if ($details) {
  1587. $where .= " and details = '$details'";
  1588. }
  1589. if ($purchase) {
  1590. $where .= " and purchase = '$purchase'";
  1591. }
  1592. if ($state) {
  1593. $where .= " and state = '$state'";
  1594. }
  1595. $where_add = '';
  1596. if ($cklx) {
  1597. $shop = $this->shop->read($cklx);
  1598. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1599. }
  1600. if ($ktime && $jtime) {
  1601. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1602. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1603. }
  1604. //数据排序
  1605. $order_str = "id desc";
  1606. if (empty($page)) {
  1607. $start = 0;
  1608. $perpage = 1;
  1609. } else {
  1610. $start = ($page - 1) * $perpage;
  1611. }
  1612. if ($sku) {
  1613. $sku = trim($sku, ' ');
  1614. $sku = trim($sku, ' ');
  1615. $where .= " and sku like '%$sku%'";
  1616. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1617. } else if ($title) {
  1618. $title = trim($title, ' ');
  1619. $title = trim($title, ' ');
  1620. $where .= " and title like '%$title%'";
  1621. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1622. } else {
  1623. //$where .= " and time > '$ktime' and time < '$jtime'";
  1624. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1625. }
  1626. //取得信息列表
  1627. $rows = array();
  1628. $list = array();
  1629. foreach ($info_list as $key => $value) {
  1630. $warehouse = $this->warehouse->read($value['warehouse']);
  1631. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1632. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1633. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1634. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1635. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1636. $od = array();
  1637. $odid = '';
  1638. foreach ($z as $v) {
  1639. if (!isset($od[$v['zd']])) {
  1640. $od[$v['zd']] = 1; //所有数据sku
  1641. } else {
  1642. $od[$v['zd']] = $od[$v['zd']] + 1;
  1643. }
  1644. }
  1645. foreach ($od as $k => $vv) {
  1646. $odid .= $k . '数量' . $vv . ' ';
  1647. }
  1648. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1649. $info_list[$key]['features'] = $c;
  1650. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1651. $ztdata = '';
  1652. if (count($zt) > 0) {
  1653. foreach ($zt as $vv) {
  1654. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1655. }
  1656. }
  1657. $info_list[$key]['warehouse'] = $ztdata;
  1658. $info_list[$key]['g'] = $g;
  1659. $info_list[$key]['x'] = $x;
  1660. $info_list[$key]['t'] = $t;
  1661. $info_list[$key]['z'] = $z;
  1662. }
  1663. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1664. $pagenum = ceil($total / $perpage);
  1665. $over = $total - ($start + $perpage);
  1666. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1667. echo json_encode($rows);
  1668. exit;
  1669. }
  1670. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1671. $this->data['warehouse'] = $warehouse;
  1672. $this->_Template('whlabel_typeusa', $this->data);
  1673. }
  1674. //美仓进销存浏览
  1675. public function _usatypeapp()
  1676. {
  1677. $post = $this->input->post(NULL, TRUE);
  1678. if (isset($post['page'])) {
  1679. $page = $this->input->post('page', true);
  1680. $perpage = $this->input->post('perpage', true);
  1681. $sku = $this->input->post('sku', true);
  1682. $warehouse = 5;
  1683. $title = $this->input->post('title', true);
  1684. $state = $this->input->post('state', true);
  1685. $ktime = $this->input->post('ktime', true);
  1686. $jtime = $this->input->post('jtime', true);
  1687. $ktime = strtotime($ktime);
  1688. $jtime = strtotime($jtime);
  1689. $where = "1=1";
  1690. $gj = "";
  1691. $ck = "";
  1692. if ($title) {
  1693. $st = explode(' ', trim($title, ' '));
  1694. foreach ($st as $v) {
  1695. $where .= " and title like '%$v%'";
  1696. }
  1697. }
  1698. if ($warehouse) {
  1699. $where .= " and warehouse = '$warehouse'";
  1700. }
  1701. if ($state) {
  1702. $where .= " and state = '$state'";
  1703. }
  1704. if ($sku) {
  1705. $where .= " and sku like '%$sku%'";
  1706. }
  1707. if ($ktime && $jtime) {
  1708. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1709. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1710. }
  1711. //数据排序
  1712. $order_str = "id desc";
  1713. if (empty($page)) {
  1714. $start = 0;
  1715. $perpage = 1;
  1716. } else {
  1717. $start = ($page - 1) * $perpage;
  1718. }
  1719. //取得信息列表
  1720. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1721. $rows = array();
  1722. $list = array();
  1723. foreach ($info_list as $key => $value) {
  1724. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1725. }
  1726. $rowsdq = array_slice($rows, $start, $perpage);
  1727. foreach ($rowsdq as $value) {
  1728. $warehouse = $this->warehouse->read($value['warehouse']);
  1729. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1730. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1731. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1732. $od = array();
  1733. $odid = '';
  1734. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1735. }
  1736. $total = count($rows);
  1737. $pagenum = ceil($total / $perpage);
  1738. $over = $total - ($start + $perpage);
  1739. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1740. echo json_encode($rows);
  1741. exit;
  1742. }
  1743. $this->_Template('phone/p_usatypeapp', $this->data);
  1744. }
  1745. //入库操作
  1746. public function _enteradd()
  1747. {
  1748. $dt = 0;
  1749. if (isset($_SESSION['api'])) {
  1750. $user = $this->user->get_api($_SESSION['api']);
  1751. $usp = $user;
  1752. $fgshop = "";
  1753. $sid = "";
  1754. $user = explode('|', trim($user['shop'], '|'));
  1755. foreach ($user as $value) {
  1756. $fgshop .= " shop = " . $value . " or";
  1757. $sid .= " id = " . $value . " or";
  1758. }
  1759. }
  1760. $tc = $this->typeclass->find_all();
  1761. $typeclass = array();
  1762. foreach ($tc as $v) {
  1763. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1764. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1765. }
  1766. $post = $this->input->post(NULL, TRUE);
  1767. if (isset($post['sku'])) {
  1768. $list = array();
  1769. $num = "";
  1770. $title = "";
  1771. $features = "";
  1772. $order = $this->input->post('order', true);
  1773. $shop = $this->input->post('shop', true);
  1774. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1775. $sku = $this->input->post('sku', true);
  1776. $post['sm'] = $this->input->post('sm', true);
  1777. $post['warehouse'] = $this->input->post('warehouse', true);
  1778. $post['purchase'] = $this->input->post('purchase', true);
  1779. $post['retreatwarehouse'] = $post['warehouse'];
  1780. $post['state'] = $this->input->post('state', true);
  1781. $post['rktype'] = $this->input->post('rktype', true);
  1782. $post['text'] = $this->input->post('text', true);
  1783. $category = $this->input->post('category', true);
  1784. $list['category'] = $category;
  1785. $list['hairtype'] = $this->input->post('hairtype', true);
  1786. $list['grade'] = $this->input->post('grade', true);
  1787. $size = $this->input->post('size', true);
  1788. $xzsku = $this->input->post('xzsku', true);
  1789. $list['size'] = rtrim($size, ',');
  1790. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1791. $list['extension'] = $this->input->post('extension', true);
  1792. if ($category == 1297) {
  1793. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1794. }
  1795. if ($category == 1702) {
  1796. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1797. $list['syother'] = $this->input->post('syother', true);
  1798. }
  1799. if ($category == 133) {
  1800. $list['fittype'] = $this->input->post('fittype', true);
  1801. $list['acother'] = $this->input->post('acother', true);
  1802. }
  1803. $list['color'] = $this->input->post('color', true);
  1804. $list['lowe'] = $this->input->post('lowe', true);
  1805. if (!$post['purchase']) {
  1806. $post['purchase'] = 1;
  1807. }
  1808. if ($category == 127) {
  1809. $list['type'] = $this->input->post('type', true);
  1810. $list['headroad'] = $this->input->post('headroad', true);
  1811. $list['density'] = $this->input->post('density', true);
  1812. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1813. $list['lacesize'] = $this->input->post('lacesize', true);
  1814. }
  1815. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1816. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1817. }
  1818. if ($category == 128) {
  1819. $list['lacetype'] = $this->input->post('lacetype', true);
  1820. $list['haircap'] = $this->input->post('haircap', true);
  1821. $list['density'] = $this->input->post('density', true);
  1822. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1823. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1824. $list['wigother'] = $this->input->post('wigother', true);
  1825. $list['wigother1'] = $this->input->post('wigother1', true);
  1826. $list['wigother2'] = $this->input->post('wigother2', true);
  1827. }
  1828. if ($category == 129) {
  1829. $list['wide'] = $this->input->post('wide', true);
  1830. }
  1831. if ($category == 131) {
  1832. $list['gifttype'] = $this->input->post('gifttype', true);
  1833. $list['giftother'] = $this->input->post('giftother', true);
  1834. }
  1835. if ($category == 134) {
  1836. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1837. }
  1838. if ($category == 1297) {
  1839. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1840. $list['sywigother'] = $this->input->post('sywigother', true);
  1841. }
  1842. if ($category == 130 || $category == 133 || $category == 1702) {
  1843. $list['items'] = $this->input->post('items', true);
  1844. $list['weight'] = $this->input->post('weight', true);
  1845. }
  1846. if ($category == 1702) {
  1847. $list['syhairther'] = $this->input->post('syhairther', true);
  1848. }
  1849. $classid = $this->classid->sku();
  1850. $scsku = $classid;
  1851. $pm = $classid;
  1852. foreach ($list as $k => $v) {
  1853. if ($v != 0) {
  1854. $num .= $v;
  1855. $features .= $v . '-';
  1856. $post[$k] = $v;
  1857. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1858. if ($k != 'size') {
  1859. $title .= $typeclass[$v]['title'] . " ";
  1860. }
  1861. if (isset($pm[$typeclass[$v]['classid']])) {
  1862. if ($typeclass[$v]['title'] == '9A') {
  1863. $pm[$typeclass[$v]['classid']] = '9A';
  1864. } else if ($typeclass[$v]['title'] == '10A') {
  1865. $pm[$typeclass[$v]['classid']] = '10A';
  1866. } else {
  1867. $clzh = $typeclass[$v]['zh'];
  1868. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1869. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1870. $clzh = $clzh[0];
  1871. }
  1872. $pm[$typeclass[$v]['classid']] = $clzh;
  1873. }
  1874. }
  1875. }
  1876. }
  1877. $zh = implode(" ", $pm);
  1878. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1879. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1880. if ($list['size']) {
  1881. $typeclass = $this->typeclass->read($list['size']);
  1882. $title .= $typeclass['title'];
  1883. }
  1884. $time = time();
  1885. if ($xzsku) {
  1886. $scsku = implode("-", $scsku);
  1887. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1888. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1889. $post['sku'] = trim($scsku, ' ');
  1890. } else {
  1891. $post['sku'] = $sku;
  1892. }
  1893. //$post['sku'] = trim($sku,' ');
  1894. $post['title'] = rtrim($title, ' ');
  1895. $post['number'] = $num;
  1896. $post['features'] = '-' . $features;
  1897. $post['enter'] = $time;
  1898. $post['time'] = $time; //操作时间
  1899. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1900. if ($yza) {
  1901. if ($post['features'] != $yza[0]['features']) {
  1902. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1903. exit;
  1904. }
  1905. }
  1906. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1907. if ($yzb) {
  1908. if ($post['sku'] != $yzb[0]['sku']) {
  1909. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1910. exit;
  1911. }
  1912. }
  1913. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1914. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1915. exit;
  1916. }
  1917. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1918. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1919. exit;
  1920. }
  1921. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1922. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1923. exit;
  1924. }
  1925. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1926. if (isset($yz[0]['type'])) {
  1927. $post['type'] = $yz[0]['type'];
  1928. }
  1929. if ($post['state'] == 9) //如果选择预设库存
  1930. {
  1931. $this->whlabel->insert($post);
  1932. } else {
  1933. /**
  1934. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1935. if($ljg == 1)
  1936. {
  1937. for($i=0;$i<$order;$i++)
  1938. {
  1939. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1940. $this->whlabel->insert($post);
  1941. }
  1942. }
  1943. **/
  1944. //if($post['warehouse'] == '5')
  1945. //{
  1946. //}
  1947. $yydata = $post;
  1948. $yydata['zh'] = $zh;
  1949. /**
  1950. $wl = $this->apiyy->get_cjlp($yydata);
  1951. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1952. {
  1953. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1954. }
  1955. if($wl['Data'][0]['m_isSucess'] != 1)
  1956. {
  1957. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1958. }
  1959. **/
  1960. for ($i = 0; $i < $order; $i++) {
  1961. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1962. $this->whlabel->insert($post);
  1963. }
  1964. }
  1965. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1966. exit;
  1967. }
  1968. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1969. $this->data['wlshop'] = $wlshop;
  1970. $this->_Template('whlabel_enteradd', $this->data);
  1971. }
  1972. //修改产品
  1973. public function _enteredit($arg_array)
  1974. {
  1975. $dt = 0;
  1976. if (isset($_SESSION['api'])) {
  1977. $user = $this->user->get_api($_SESSION['api']);
  1978. $usp = $user;
  1979. $fgshop = "";
  1980. $sid = "";
  1981. $user = explode('|', trim($user['shop'], '|'));
  1982. foreach ($user as $value) {
  1983. $fgshop .= " shop = " . $value . " or";
  1984. $sid .= " id = " . $value . " or";
  1985. }
  1986. }
  1987. $post = $this->input->post(NULL, TRUE);
  1988. if (isset($post['sku'])) {
  1989. $list = array();
  1990. $num = "";
  1991. $title = "";
  1992. $features = "";
  1993. $id = $this->input->post('id', true);
  1994. $order = $this->input->post('order', true);
  1995. $shop = $this->input->post('shop', true);
  1996. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1997. $post['sku'] = $this->input->post('sku', true);
  1998. $post['sm'] = $this->input->post('sm', true);
  1999. $post['warehouse'] = $this->input->post('warehouse', true);
  2000. $post['purchase'] = $this->input->post('purchase', true);
  2001. $post['retreatwarehouse'] = $post['warehouse'];
  2002. $category = $this->input->post('category', true);
  2003. $list['category'] = $category;
  2004. $list['hairtype'] = $this->input->post('hairtype', true);
  2005. $list['grade'] = $this->input->post('grade', true);
  2006. $size = $this->input->post('size', true);
  2007. $list['size'] = rtrim($size, ',');
  2008. $post['rktype'] = $this->input->post('rktype', true);
  2009. $post['text'] = $this->input->post('text', true);
  2010. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2011. $list['extension'] = $this->input->post('extension', true);
  2012. if ($category == 1297) {
  2013. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2014. }
  2015. if ($category == 1702) {
  2016. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2017. $list['syother'] = $this->input->post('syother', true);
  2018. }
  2019. if ($category == 133) {
  2020. $list['fittype'] = $this->input->post('fittype', true);
  2021. $list['acother'] = $this->input->post('acother', true);
  2022. }
  2023. $list['color'] = $this->input->post('color', true);
  2024. $list['lowe'] = $this->input->post('lowe', true);
  2025. if (!$post['purchase']) {
  2026. $post['purchase'] = 1;
  2027. }
  2028. if ($category == 127) {
  2029. $list['type'] = $this->input->post('type', true);
  2030. $list['headroad'] = $this->input->post('headroad', true);
  2031. $list['density'] = $this->input->post('density', true);
  2032. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2033. $list['lacesize'] = $this->input->post('lacesize', true);
  2034. }
  2035. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2036. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2037. }
  2038. if ($category == 128) {
  2039. $list['lacetype'] = $this->input->post('lacetype', true);
  2040. $list['haircap'] = $this->input->post('haircap', true);
  2041. $list['density'] = $this->input->post('density', true);
  2042. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2043. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2044. $list['wigother'] = $this->input->post('wigother', true);
  2045. $list['wigother1'] = $this->input->post('wigother1', true);
  2046. $list['wigother2'] = $this->input->post('wigother2', true);
  2047. }
  2048. if ($category == 129) {
  2049. $list['wide'] = $this->input->post('wide', true);
  2050. }
  2051. if ($category == 131) {
  2052. $list['gifttype'] = $this->input->post('gifttype', true);
  2053. $list['giftother'] = $this->input->post('giftother', true);
  2054. }
  2055. if ($category == 134) {
  2056. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2057. }
  2058. if ($category == 1297) {
  2059. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2060. $list['sywigother'] = $this->input->post('sywigother', true);
  2061. }
  2062. if ($category == 130 || $category == 133 || $category == 1702) {
  2063. $list['items'] = $this->input->post('items', true);
  2064. $list['weight'] = $this->input->post('weight', true);
  2065. }
  2066. if ($category == 1702) {
  2067. $list['syhairther'] = $this->input->post('syhairther', true);
  2068. }
  2069. foreach ($list as $k => $v) {
  2070. if ($v != 0) {
  2071. $num .= $v;
  2072. $features .= $v . '-';
  2073. $typeclass = $this->typeclass->read($v);
  2074. if ($k != 'size') {
  2075. $title .= $typeclass['title'] . " ";
  2076. }
  2077. }
  2078. }
  2079. $typeclass = $this->typeclass->read($list['size']);
  2080. $title .= $typeclass['title'];
  2081. $time = time();
  2082. $post['title'] = rtrim($title, ' ');
  2083. $post['number'] = $num;
  2084. $post['features'] = '-' . $features;
  2085. $post['time'] = $time; //操作时间
  2086. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2087. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2088. exit;
  2089. }
  2090. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2091. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2092. exit;
  2093. }
  2094. $uid = $this->whlabel->read($id);
  2095. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2096. if ($datanum > 0) {
  2097. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2098. exit;
  2099. }
  2100. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2101. {
  2102. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2103. if ($yza) {
  2104. if ($post['features'] != $yza[0]['features']) {
  2105. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2106. exit;
  2107. }
  2108. }
  2109. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2110. if ($yzb) {
  2111. if ($post['sku'] != $yzb[0]['sku']) {
  2112. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2113. exit;
  2114. }
  2115. }
  2116. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2117. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2118. exit;
  2119. }
  2120. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2121. foreach ($data as $v) {
  2122. $post['id'] = $v['id'];
  2123. $this->whlabel->save($post, $v['id']);
  2124. }
  2125. } else {
  2126. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2127. if ($data > 0) {
  2128. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2129. exit;
  2130. } else {
  2131. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2132. foreach ($data as $v) {
  2133. $post['id'] = $v['id'];
  2134. $this->whlabel->save($post, $v['id']);
  2135. }
  2136. }
  2137. }
  2138. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2139. exit;
  2140. }
  2141. $uid = $this->whlabel->read($arg_array[0]);
  2142. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2143. $this->data['enter'] = $uid;
  2144. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2145. $this->data['wlshop'] = $wlshop;
  2146. $this->_Template('whlabel_enteredit', $this->data);
  2147. }
  2148. //入库浏览
  2149. public function _enter()
  2150. {
  2151. $post = $this->input->post(NULL, TRUE);
  2152. if (isset($post['s'])) {
  2153. $id_arr = $this->input->post('s');
  2154. $id_arr = explode(',', $id_arr);
  2155. if (!$id_arr) {
  2156. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2157. exit;
  2158. }
  2159. //循环删除记录
  2160. foreach ($id_arr as $v) {
  2161. $sid = $this->whlabel->read($v);
  2162. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2163. if ($count > 0) {
  2164. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2165. exit;
  2166. }
  2167. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2168. foreach ($info_list as $va) {
  2169. $this->whlabel->remove($va['id']);
  2170. }
  2171. }
  2172. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2173. exit;
  2174. }
  2175. $sp = array();
  2176. $s = $this->shop->find_all('1=1', 'id,shopname');
  2177. foreach ($s as $v) {
  2178. $sp[$v['id']] = $v['shopname'];
  2179. }
  2180. $wh = array();
  2181. $w = $this->warehouse->find_all('1=1', 'id,title');
  2182. foreach ($w as $v) {
  2183. $wh[$v['id']] = $v['title'];
  2184. }
  2185. if (isset($post['page'])) {
  2186. $page = $this->input->post('page', true);
  2187. $perpage = $this->input->post('perpage', true);
  2188. $category = $this->input->post('category', true);
  2189. $size = $this->input->post('size', true);
  2190. $grade = $this->input->post('grade', true);
  2191. $color = $this->input->post('color', true);
  2192. $lowe = $this->input->post('lowe', true);
  2193. $sku = $this->input->post('sku', true);
  2194. $warehouse = $this->input->post('warehouse', true);
  2195. $purchase = $this->input->post('purchase', true);
  2196. $ktime = $this->input->post('ktime', true);
  2197. $jtime = $this->input->post('jtime', true);
  2198. $ktime = strtotime($ktime);
  2199. $jtime = strtotime($jtime);
  2200. $where = "1=1";
  2201. $gj = "";
  2202. $ck = "";
  2203. if ($category) {
  2204. $where .= " and features like '%-$category-%'";
  2205. }
  2206. if ($size) {
  2207. $where .= " and features like '%-$size-%'";
  2208. }
  2209. if ($grade) {
  2210. $where .= " and features like '%-$grade-%'";
  2211. }
  2212. if ($color) {
  2213. $where .= " and features like '%-$color-%'";
  2214. }
  2215. if ($lowe) {
  2216. $where .= " and features like '%-$lowe-%'";
  2217. }
  2218. if ($warehouse) {
  2219. $where .= " and warehouse = '$warehouse'";
  2220. }
  2221. if ($purchase) {
  2222. $where .= " and purchase = '$purchase'";
  2223. }
  2224. if ($sku) {
  2225. $where .= " and sku like '%$sku%'";
  2226. }
  2227. if ($ktime && $jtime) {
  2228. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2229. }
  2230. //数据排序
  2231. $order_str = "enter desc";
  2232. if (empty($page)) {
  2233. $start = 0;
  2234. $perpage = 1;
  2235. } else {
  2236. $start = ($page - 1) * $perpage;
  2237. }
  2238. //取得信息列表
  2239. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2240. foreach ($info_list as $k => $v) {
  2241. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2242. if ($v['shop'] == '') {
  2243. $s = '通用';
  2244. } else {
  2245. $info_list[$k]['shop'] = '';
  2246. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2247. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2248. }
  2249. }
  2250. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2251. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2252. $info_list[$k]['g'] = $g;
  2253. }
  2254. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2255. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2256. $pagenum = ceil($total / $perpage);
  2257. $over = $total - ($start + $perpage);
  2258. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2259. echo json_encode($rows);
  2260. exit;
  2261. }
  2262. $this->_Template('whlabel_enter', $this->data);
  2263. }
  2264. //出库浏览
  2265. public function _out()
  2266. {
  2267. $post = $this->input->post(NULL, TRUE);
  2268. if (isset($post['page'])) {
  2269. $page = $this->input->post('page', true);
  2270. $perpage = $this->input->post('perpage', true);
  2271. $category = $this->input->post('category', true);
  2272. $size = $this->input->post('size', true);
  2273. $grade = $this->input->post('grade', true);
  2274. $color = $this->input->post('color', true);
  2275. $lowe = $this->input->post('lowe', true);
  2276. $sku = $this->input->post('sku', true);
  2277. $warehouse = $this->input->post('warehouse', true);
  2278. $purchase = $this->input->post('purchase', true);
  2279. $state = $this->input->post('state', true);
  2280. $ktime = $this->input->post('ktime', true);
  2281. $jtime = $this->input->post('jtime', true);
  2282. $ktime = strtotime($ktime);
  2283. $jtime = strtotime($jtime);
  2284. $where = "state=3";
  2285. $gj = "";
  2286. $ck = "";
  2287. if ($category) {
  2288. $where .= " and features like '%-$category-%'";
  2289. }
  2290. if ($size) {
  2291. $where .= " and features like '%-$size-%'";
  2292. }
  2293. if ($grade) {
  2294. $where .= " and features like '%-$grade-%'";
  2295. }
  2296. if ($color) {
  2297. $where .= " and features like '%-$color-%'";
  2298. }
  2299. if ($lowe) {
  2300. $where .= " and features like '%-$lowe-%'";
  2301. }
  2302. if ($state) {
  2303. $where .= " and state = '$state'";
  2304. }
  2305. if ($warehouse) {
  2306. $where .= " and warehouse = '$warehouse'";
  2307. }
  2308. if ($purchase) {
  2309. $where .= " and purchase = '$purchase'";
  2310. }
  2311. if ($sku) {
  2312. $where .= " and sku = '$sku'";
  2313. }
  2314. if ($ktime && $jtime) {
  2315. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2316. }
  2317. //数据排序
  2318. $order_str = "id desc";
  2319. if (empty($page)) {
  2320. $start = 0;
  2321. $perpage = 1;
  2322. } else {
  2323. $start = ($page - 1) * $perpage;
  2324. }
  2325. //取得信息列表
  2326. $info_list = $this->whlabel->find_all($where, 'sku');
  2327. $rows = array();
  2328. $list = array();
  2329. foreach ($info_list as $key => $value) {
  2330. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2331. }
  2332. $rows = array_unique($rows); //删除重复记录
  2333. foreach ($rows as $key => $value) {
  2334. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2335. $ck = $this->warehouse->read($data['warehouse']);
  2336. $warehouse = $ck['title'];
  2337. $gy = $this->purchase->read($data['purchase']);
  2338. $purchase = $gy['purchase'];
  2339. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2340. $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);
  2341. }
  2342. $total = count($list);
  2343. $pagenum = ceil($total / $perpage);
  2344. $over = $total - ($start + $perpage);
  2345. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2346. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2347. echo json_encode($rows);
  2348. exit;
  2349. }
  2350. $this->_Template('whlabel_out', $this->data);
  2351. }
  2352. //出库标签浏览
  2353. public function _label()
  2354. {
  2355. $post = $this->input->post(NULL, TRUE);
  2356. if (isset($post['page'])) {
  2357. $page = $this->input->post('page', true);
  2358. $perpage = $this->input->post('perpage', true);
  2359. $sku = $this->input->post('sku', true);
  2360. $warehouse = $this->input->post('warehouse', true);
  2361. $purchase = $this->input->post('purchase', true);
  2362. $orderinfo = $this->input->post('orderinfo', true);
  2363. $waybill = $this->input->post('waybill', true);
  2364. $category = $this->input->post('category', true);
  2365. $size = $this->input->post('size', true);
  2366. $grade = $this->input->post('grade', true);
  2367. $color = $this->input->post('color', true);
  2368. $lowe = $this->input->post('lowe', true);
  2369. $where = "state=1";
  2370. if ($sku) {
  2371. $where .= " and sku = '$sku'";
  2372. }
  2373. if ($warehouse) {
  2374. $where .= " and warehouse = '$warehouse'";
  2375. }
  2376. if ($purchase) {
  2377. $where .= " and purchase = '$purchase'";
  2378. }
  2379. if ($orderinfo) {
  2380. $where .= " and orderinfo = '$orderinfo'";
  2381. }
  2382. if ($waybill) {
  2383. $where .= " and waybill = '$waybill'";
  2384. }
  2385. if ($category) {
  2386. $where .= " and features like '%-$category-%'";
  2387. }
  2388. if ($size) {
  2389. $where .= " and features like '%-$size-%'";
  2390. }
  2391. if ($grade) {
  2392. $where .= " and features like '%-$grade-%'";
  2393. }
  2394. if ($color) {
  2395. $where .= " and features like '%-$color-%'";
  2396. }
  2397. if ($lowe) {
  2398. $where .= " and features like '%-$lowe-%'";
  2399. }
  2400. //数据排序
  2401. $order_str = "outk desc";
  2402. if (empty($page)) {
  2403. $start = 0;
  2404. $perpage = 1;
  2405. } else {
  2406. $start = ($page - 1) * $perpage;
  2407. }
  2408. //取得信息列表
  2409. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2410. foreach ($info_list as $key => $value) {
  2411. $warehouse = $this->warehouse->read($value['warehouse']);
  2412. $info_list[$key]['warehouse'] = $warehouse['title'];
  2413. $purchase = $this->purchase->read($value['purchase']);
  2414. $info_list[$key]['purchase'] = $purchase['title'];
  2415. if ($value['outk'] != 0) {
  2416. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2417. } else {
  2418. $info_list[$key]['outk'] = "";
  2419. }
  2420. if ($value['orderinfo'] == 0) {
  2421. $info_list[$key]['orderinfo'] = "";
  2422. }
  2423. if ($value['waybill'] == 0) {
  2424. $info_list[$key]['waybill'] = "";
  2425. }
  2426. }
  2427. $total = $this->whlabel->find_count($where);
  2428. $pagenum = ceil($total / $perpage);
  2429. $over = $total - ($start + $perpage);
  2430. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2431. echo json_encode($rows);
  2432. exit;
  2433. }
  2434. $this->_Template('whlabel_label', $this->data);
  2435. }
  2436. //独立站出库订单
  2437. public function _outorder()
  2438. {
  2439. if (isset($_SESSION['api'])) {
  2440. $user = $this->user->get_api($_SESSION['api']);
  2441. $usp = $user;
  2442. $fgshop = "";
  2443. $sid = "";
  2444. $user = explode('|', trim($user['shop'], '|'));
  2445. foreach ($user as $value) {
  2446. $fgshop .= " shop = " . $value . " or";
  2447. $sid .= " id = " . $value . " or";
  2448. }
  2449. } else {
  2450. echo "请重新登录";
  2451. }
  2452. $post = $this->input->post(NULL, TRUE);
  2453. if (isset($post['page'])) {
  2454. $page = $this->input->post('page', true);
  2455. $perpage = $this->input->post('perpage', true);
  2456. $warehouse = $this->input->post('warehouse', true);
  2457. $xztime = $this->input->post('xztime', true);
  2458. $timetk = $this->input->post('timetkk', true);
  2459. $timetj = $this->input->post('timetjj', true);
  2460. $shop = $this->input->post('shop', true);
  2461. $source = $this->input->post('source', true);
  2462. $orderinfo = $this->input->post('orderinfo', true);
  2463. $number = $this->input->post('number', true);
  2464. $sfxh = $this->input->post('sfxh', true);
  2465. $express = $this->input->post('express', true);
  2466. $waybill = $this->input->post('waybill', true);
  2467. $library = $this->input->post('library', true);
  2468. $country = $this->input->post('country', true);
  2469. $so = $this->input->post('so', true);
  2470. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2471. $print = $this->input->post('print', true);
  2472. $state = $this->input->post('state', true);
  2473. $orderurl = $this->input->post('orderurl', true);
  2474. $productid = $this->input->post('productid', true);
  2475. $timetk = strtotime($timetk);
  2476. $timetj = strtotime($timetj);
  2477. /**
  2478. $sj = $this->input->post('sj',true);
  2479. if($sj)
  2480. {
  2481. $sj = $this->input->post('sj',true);
  2482. }
  2483. else
  2484. {
  2485. $sj = "fullorder";
  2486. }
  2487. **/
  2488. $sj = "fullorder";
  2489. $where = "1=1";
  2490. if ($warehouse) {
  2491. $where .= " and type = '$warehouse'";
  2492. }
  2493. if ($timetk && $timetj) {
  2494. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2495. }
  2496. if ($orderinfo) {
  2497. $where .= " and orderinfo = '$orderinfo'";
  2498. }
  2499. if ($number) {
  2500. $where .= " and number = '$number'";
  2501. }
  2502. if ($express) {
  2503. $where .= " and express = '$express'";
  2504. }
  2505. if ($waybill) {
  2506. $where .= " and waybill = '$waybill'";
  2507. }
  2508. if ($library) {
  2509. $where .= " and library = '$library'";
  2510. }
  2511. if ($print) {
  2512. $where .= " and print = '$print'";
  2513. }
  2514. if ($libraryconfirm) {
  2515. $where .= " and libraryconfirm = '$libraryconfirm'";
  2516. }
  2517. if ($state) {
  2518. $where .= " and state = '$state'";
  2519. }
  2520. if ($shop) {
  2521. $where .= " and shop = '$shop'";
  2522. }
  2523. if ($country) {
  2524. $where .= " and country = '$country'";
  2525. }
  2526. if ($sfxh != '') {
  2527. $where .= " and sfxh = '$sfxh'";
  2528. }
  2529. if ($so) {
  2530. $where .= " and shipremarks like '%$so%'";
  2531. }
  2532. if ($source) {
  2533. if ($source == '2d') {
  2534. $where .= " and source >= '2'";
  2535. } else {
  2536. $where .= " and source = '$source'";
  2537. }
  2538. }
  2539. if (isset($_SESSION['api'])) {
  2540. foreach ($user as $value) {
  2541. $fgshop .= " shop = " . $value . " or";
  2542. }
  2543. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2544. }
  2545. if ($orderurl) {
  2546. $url = $this->orderurl->read($orderurl);
  2547. $where .= " and link like '%" . $url['url'] . "%'";
  2548. }
  2549. if($productid){
  2550. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2551. }
  2552. //数据排序
  2553. $order_str = "librarytime desc";
  2554. if (empty($page)) {
  2555. $start = 0;
  2556. $perpage = 1;
  2557. } else {
  2558. $start = ($page - 1) * $perpage;
  2559. }
  2560. //取得信息列表
  2561. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2562. //格式化数据
  2563. foreach ($info_list as $key => $value) {
  2564. $shop = $this->shop->read($value['shop']);
  2565. $info_list[$key]['shop'] = $shop['shopname'];
  2566. $express = $this->express->read($value['express']);
  2567. $info_list[$key]['express'] = $express['servicename'];
  2568. $warehouse = $this->warehouse->read($value['type']);
  2569. $info_list[$key]['type'] = $warehouse['title'];
  2570. if ($value['librarytime'] == '0') {
  2571. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2572. } else {
  2573. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2574. }
  2575. }
  2576. $total = $this->$sj->find_count($where);
  2577. $pagenum = ceil($total / $perpage);
  2578. $over = $total - ($start + $perpage);
  2579. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2580. echo json_encode($rows);
  2581. exit;
  2582. }
  2583. $this->data['express'] = $this->express->find_all();
  2584. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2585. $this->data['wlshop'] = $wlshop;
  2586. $user = $this->user->get_api($_SESSION['api']);
  2587. $powerid = $this->power->read($user['power']);
  2588. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2589. $pid = '';
  2590. foreach ($powertext as $v) {
  2591. $pid .= " id = " . $v . " or";
  2592. }
  2593. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2594. $this->data['fullorderexcel'] = $fullorderexcel;
  2595. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2596. $this->data['orderurl'] = $orderurl;
  2597. $this->_Template('whlabel_outorder', $this->data);
  2598. }
  2599. //tt出库
  2600. public function _toutorder()
  2601. {
  2602. $fgshop = "";
  2603. $sid = "";
  2604. if (isset($_SESSION['api'])) {
  2605. $user = $this->user->get_api($_SESSION['api']);
  2606. $usp = $user;
  2607. $user = explode('|', trim($user['shop'], '|'));
  2608. foreach ($user as $value) {
  2609. $fgshop .= " shop = " . $value . " or";
  2610. $sid .= " id = " . $value . " or";
  2611. }
  2612. } else {
  2613. echo "请重新登录";
  2614. die;
  2615. }
  2616. $post = $this->input->post(NULL, TRUE);
  2617. if (isset($post['page'])) {
  2618. $page = $this->input->post('page', true);
  2619. $perpage = $this->input->post('perpage', true);
  2620. $warehouse = $this->input->post('warehouse', true);
  2621. $xztime = $this->input->post('xztime', true);
  2622. $timetk = $this->input->post('timetkk', true);
  2623. $timetj = $this->input->post('timetjj', true);
  2624. $shop = $this->input->post('shop', true);
  2625. $source = $this->input->post('source', true);
  2626. $orderinfo = $this->input->post('orderinfo', true);
  2627. $number = $this->input->post('number', true);
  2628. $sfxh = $this->input->post('sfxh', true);
  2629. $express = $this->input->post('express', true);
  2630. $waybill = $this->input->post('waybill', true);
  2631. $library = $this->input->post('library', true);
  2632. $country = $this->input->post('country', true);
  2633. $so = $this->input->post('so', true);
  2634. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2635. $print = $this->input->post('print', true);
  2636. $state = $this->input->post('state', true);
  2637. $orderurl = $this->input->post('orderurl', true);
  2638. $timetk = strtotime($timetk);
  2639. $timetj = strtotime($timetj);
  2640. /**
  2641. $sj = $this->input->post('sj',true);
  2642. if($sj)
  2643. {
  2644. $sj = $this->input->post('sj',true);
  2645. }
  2646. else
  2647. {
  2648. $sj = "fullorder";
  2649. }
  2650. **/
  2651. $sj = "fullordertt";
  2652. $where = "1=1";
  2653. if ($warehouse) {
  2654. $where .= " and type = '$warehouse'";
  2655. }
  2656. if ($timetk && $timetj) {
  2657. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2658. }
  2659. if ($orderinfo) {
  2660. $where .= " and orderinfo = '$orderinfo'";
  2661. }
  2662. if ($number) {
  2663. $where .= " and number = '$number'";
  2664. }
  2665. if ($express) {
  2666. $where .= " and express = '$express'";
  2667. }
  2668. if ($waybill) {
  2669. $where .= " and waybill = '$waybill'";
  2670. }
  2671. if ($library) {
  2672. $where .= " and library = '$library'";
  2673. }
  2674. if ($print) {
  2675. $where .= " and print = '$print'";
  2676. }
  2677. if ($libraryconfirm) {
  2678. $where .= " and libraryconfirm = '$libraryconfirm'";
  2679. }
  2680. if ($state) {
  2681. $where .= " and state = '$state'";
  2682. }
  2683. if ($shop) {
  2684. $where .= " and shop = '$shop'";
  2685. }
  2686. if ($country) {
  2687. $where .= " and country = '$country'";
  2688. }
  2689. if ($sfxh != '') {
  2690. $where .= " and sfxh = '$sfxh'";
  2691. }
  2692. if ($so) {
  2693. $where .= " and shipremarks like '%$so%'";
  2694. }
  2695. if ($source) {
  2696. if ($source == '2d') {
  2697. $where .= " and source >= '2'";
  2698. } else {
  2699. $where .= " and source = '$source'";
  2700. }
  2701. }
  2702. if (isset($_SESSION['api'])) {
  2703. foreach ($user as $value) {
  2704. $fgshop .= " shop = " . $value . " or";
  2705. }
  2706. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2707. }
  2708. if ($orderurl) {
  2709. $url = $this->orderurl->read($orderurl);
  2710. $where .= " and link like '%" . $url['url'] . "%'";
  2711. }
  2712. //数据排序
  2713. $order_str = "librarytime desc";
  2714. if (empty($page)) {
  2715. $start = 0;
  2716. $perpage = 1;
  2717. } else {
  2718. $start = ($page - 1) * $perpage;
  2719. }
  2720. //取得信息列表
  2721. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2722. //格式化数据
  2723. foreach ($info_list as $key => $value) {
  2724. $shop = $this->shop->read($value['shop']);
  2725. $info_list[$key]['shop'] = $shop['shopname'];
  2726. $express = $this->express->read($value['express']);
  2727. $info_list[$key]['express'] = $express['servicename'];
  2728. $warehouse = $this->warehouse->read($value['type']);
  2729. $info_list[$key]['type'] = $warehouse['title'];
  2730. if ($value['librarytime'] == '0') {
  2731. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2732. } else {
  2733. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2734. }
  2735. }
  2736. $total = $this->$sj->find_count($where);
  2737. $pagenum = ceil($total / $perpage);
  2738. $over = $total - ($start + $perpage);
  2739. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2740. echo json_encode($rows);
  2741. exit;
  2742. }
  2743. $this->data['express'] = $this->express->find_all();
  2744. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2745. $this->data['wlshop'] = $wlshop;
  2746. $user = $this->user->get_api($_SESSION['api']);
  2747. $powerid = $this->power->read($user['power']);
  2748. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2749. $pid = '';
  2750. foreach ($powertext as $v) {
  2751. $pid .= " id = " . $v . " or";
  2752. }
  2753. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2754. $this->data['fullorderexcel'] = $fullorderexcel;
  2755. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2756. $this->data['orderurl'] = $orderurl;
  2757. $this->_Template('whlabel_toutorder', $this->data);
  2758. }
  2759. //tt出库
  2760. public function _aoutorder()
  2761. {
  2762. if (isset($_SESSION['api'])) {
  2763. $user = $this->user->get_api($_SESSION['api']);
  2764. $usp = $user;
  2765. $fgshop = "";
  2766. $sid = "";
  2767. $user = explode('|', trim($user['shop'], '|'));
  2768. foreach ($user as $value) {
  2769. $fgshop .= " shop = " . $value . " or";
  2770. $sid .= " id = " . $value . " or";
  2771. }
  2772. } else {
  2773. echo "请重新登录";
  2774. }
  2775. $post = $this->input->post(NULL, TRUE);
  2776. if (isset($post['page'])) {
  2777. $page = $this->input->post('page', true);
  2778. $perpage = $this->input->post('perpage', true);
  2779. $warehouse = $this->input->post('warehouse', true);
  2780. $xztime = $this->input->post('xztime', true);
  2781. $timetk = $this->input->post('timetkk', true);
  2782. $timetj = $this->input->post('timetjj', true);
  2783. $shop = $this->input->post('shop', true);
  2784. $source = $this->input->post('source', true);
  2785. $orderinfo = $this->input->post('orderinfo', true);
  2786. $number = $this->input->post('number', true);
  2787. $sfxh = $this->input->post('sfxh', true);
  2788. $express = $this->input->post('express', true);
  2789. $waybill = $this->input->post('waybill', true);
  2790. $library = $this->input->post('library', true);
  2791. $country = $this->input->post('country', true);
  2792. $so = $this->input->post('so', true);
  2793. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2794. $print = $this->input->post('print', true);
  2795. $state = $this->input->post('state', true);
  2796. $orderurl = $this->input->post('orderurl', true);
  2797. $timetk = strtotime($timetk);
  2798. $timetj = strtotime($timetj);
  2799. /**
  2800. $sj = $this->input->post('sj',true);
  2801. if($sj)
  2802. {
  2803. $sj = $this->input->post('sj',true);
  2804. }
  2805. else
  2806. {
  2807. $sj = "fullorder";
  2808. }
  2809. **/
  2810. $sj = "fullorderamz";
  2811. $where = "1=1";
  2812. if ($warehouse) {
  2813. $where .= " and type = '$warehouse'";
  2814. }
  2815. if ($timetk && $timetj) {
  2816. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2817. }
  2818. if ($orderinfo) {
  2819. $where .= " and orderinfo = '$orderinfo'";
  2820. }
  2821. if ($number) {
  2822. $where .= " and number = '$number'";
  2823. }
  2824. if ($express) {
  2825. $where .= " and express = '$express'";
  2826. }
  2827. if ($waybill) {
  2828. $where .= " and waybill = '$waybill'";
  2829. }
  2830. if ($library) {
  2831. $where .= " and library = '$library'";
  2832. }
  2833. if ($print) {
  2834. $where .= " and print = '$print'";
  2835. }
  2836. if ($libraryconfirm) {
  2837. $where .= " and libraryconfirm = '$libraryconfirm'";
  2838. }
  2839. if ($state) {
  2840. $where .= " and state = '$state'";
  2841. }
  2842. if ($shop) {
  2843. $where .= " and shop = '$shop'";
  2844. }
  2845. if ($country) {
  2846. $where .= " and country = '$country'";
  2847. }
  2848. if ($sfxh != '') {
  2849. $where .= " and sfxh = '$sfxh'";
  2850. }
  2851. if ($so) {
  2852. $where .= " and shipremarks like '%$so%'";
  2853. }
  2854. if ($source) {
  2855. if ($source == '2d') {
  2856. $where .= " and source >= '2'";
  2857. } else {
  2858. $where .= " and source = '$source'";
  2859. }
  2860. }
  2861. if (isset($_SESSION['api'])) {
  2862. foreach ($user as $value) {
  2863. $fgshop .= " shop = " . $value . " or";
  2864. }
  2865. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2866. }
  2867. if ($orderurl) {
  2868. $url = $this->orderurl->read($orderurl);
  2869. $where .= " and link like '%" . $url['url'] . "%'";
  2870. }
  2871. //数据排序
  2872. $order_str = "librarytime desc";
  2873. if (empty($page)) {
  2874. $start = 0;
  2875. $perpage = 1;
  2876. } else {
  2877. $start = ($page - 1) * $perpage;
  2878. }
  2879. //取得信息列表
  2880. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2881. //格式化数据
  2882. foreach ($info_list as $key => $value) {
  2883. $shop = $this->shop->read($value['shop']);
  2884. $info_list[$key]['shop'] = $shop['shopname'];
  2885. $express = $this->express->read($value['express']);
  2886. $info_list[$key]['express'] = $express['servicename'];
  2887. $warehouse = $this->warehouse->read($value['type']);
  2888. $info_list[$key]['type'] = $warehouse['title'];
  2889. if ($value['librarytime'] == '0') {
  2890. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2891. } else {
  2892. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2893. }
  2894. }
  2895. $total = $this->$sj->find_count($where);
  2896. $pagenum = ceil($total / $perpage);
  2897. $over = $total - ($start + $perpage);
  2898. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2899. echo json_encode($rows);
  2900. exit;
  2901. }
  2902. $this->data['express'] = $this->express->find_all();
  2903. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2904. $this->data['wlshop'] = $wlshop;
  2905. $user = $this->user->get_api($_SESSION['api']);
  2906. $powerid = $this->power->read($user['power']);
  2907. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2908. $pid = '';
  2909. foreach ($powertext as $v) {
  2910. $pid .= " id = " . $v . " or";
  2911. }
  2912. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2913. $this->data['fullorderexcel'] = $fullorderexcel;
  2914. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2915. $this->data['orderurl'] = $orderurl;
  2916. $this->_Template('whlabel_aoutorder', $this->data);
  2917. }
  2918. //速卖通出库订单
  2919. public function _soutorder()
  2920. {
  2921. if (isset($_SESSION['api'])) {
  2922. $user = $this->user->get_api($_SESSION['api']);
  2923. $usp = $user;
  2924. $fgshop = "";
  2925. $sid = "";
  2926. $user = explode('|', trim($user['shop'], '|'));
  2927. foreach ($user as $value) {
  2928. $sid .= " id = " . $value . " or";
  2929. }
  2930. }
  2931. $post = $this->input->post(NULL, TRUE);
  2932. if (isset($post['page'])) {
  2933. $page = $this->input->post('page', true);
  2934. $perpage = $this->input->post('perpage', true);
  2935. $warehouse = $this->input->post('warehouse', true);
  2936. $xztime = $this->input->post('xztime', true);
  2937. $timetk = $this->input->post('timetkk', true);
  2938. $timetj = $this->input->post('timetjj', true);
  2939. $shop = $this->input->post('shop', true);
  2940. $source = $this->input->post('source', true);
  2941. $orderinfo = $this->input->post('orderinfo', true);
  2942. $number = $this->input->post('number', true);
  2943. $express = $this->input->post('express', true);
  2944. $waybill = $this->input->post('waybill', true);
  2945. $library = $this->input->post('library', true);
  2946. $country = $this->input->post('country', true);
  2947. $sfxh = $this->input->post('sfxh', true);
  2948. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2949. $print = $this->input->post('print', true);
  2950. $state = $this->input->post('state', true);
  2951. $so = $this->input->post('so', true);
  2952. $timetk = strtotime($timetk);
  2953. $timetj = strtotime($timetj);
  2954. /**
  2955. $sj = $this->input->post('sj',true);
  2956. if($sj)
  2957. {
  2958. $sj = $this->input->post('sj',true);
  2959. }
  2960. else
  2961. {
  2962. $sj = "fullorder";
  2963. }
  2964. **/
  2965. $sj = "fullordersmt";
  2966. $where = "1=1";
  2967. if ($warehouse) {
  2968. $where .= " and type = '$warehouse'";
  2969. }
  2970. if ($timetk && $timetj) {
  2971. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2972. }
  2973. if ($orderinfo) {
  2974. $where .= " and orderinfo = '$orderinfo'";
  2975. }
  2976. if ($number) {
  2977. $where .= " and number = '$number'";
  2978. }
  2979. if ($express) {
  2980. $where .= " and express = '$express'";
  2981. }
  2982. if ($waybill) {
  2983. $where .= " and waybill = '$waybill'";
  2984. }
  2985. if ($library) {
  2986. $where .= " and library = '$library'";
  2987. }
  2988. if ($print) {
  2989. $where .= " and print = '$print'";
  2990. }
  2991. if ($libraryconfirm) {
  2992. $where .= " and libraryconfirm = '$libraryconfirm'";
  2993. }
  2994. if ($state) {
  2995. $where .= " and state = '$state'";
  2996. }
  2997. if ($shop) {
  2998. $where .= " and shop = '$shop'";
  2999. }
  3000. if ($sfxh != '') {
  3001. $where .= " and sfxh = '$sfxh'";
  3002. }
  3003. if ($so) {
  3004. $where .= " and shipremarks like '%$so%'";
  3005. }
  3006. if ($source) {
  3007. $where .= " and source = '$source'";
  3008. }
  3009. if ($country) {
  3010. $where .= " and country = '$country'";
  3011. } else {
  3012. if (isset($_SESSION['api'])) {
  3013. foreach ($user as $value) {
  3014. $fgshop .= " shop = " . $value . " or";
  3015. }
  3016. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3017. }
  3018. }
  3019. //数据排序
  3020. $order_str = "librarytime desc";
  3021. if (empty($page)) {
  3022. $start = 0;
  3023. $perpage = 1;
  3024. } else {
  3025. $start = ($page - 1) * $perpage;
  3026. }
  3027. //取得信息列表
  3028. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3029. //格式化数据
  3030. foreach ($info_list as $key => $value) {
  3031. $shop = $this->shop->read($value['shop']);
  3032. $info_list[$key]['shop'] = $shop['shopname'];
  3033. $express = $this->express->read($value['express']);
  3034. $info_list[$key]['express'] = $express['servicename'];
  3035. $warehouse = $this->warehouse->read($value['type']);
  3036. $info_list[$key]['type'] = $warehouse['title'];
  3037. if ($value['librarytime'] == '0') {
  3038. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3039. } else {
  3040. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3041. }
  3042. }
  3043. $total = $this->$sj->find_count($where);
  3044. $pagenum = ceil($total / $perpage);
  3045. $over = $total - ($start + $perpage);
  3046. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3047. echo json_encode($rows);
  3048. exit;
  3049. }
  3050. $this->data['express'] = $this->express->find_all();
  3051. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3052. $this->data['wlshop'] = $wlshop;
  3053. $user = $this->user->get_api($_SESSION['api']);
  3054. $powerid = $this->power->read($user['power']);
  3055. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3056. $pid = '';
  3057. foreach ($powertext as $v) {
  3058. $pid .= " id = " . $v . " or";
  3059. }
  3060. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3061. $this->data['fullorderexcel'] = $fullorderexcel;
  3062. $this->_Template('whlabel_soutorder', $this->data);
  3063. }
  3064. //订单退库
  3065. public function _retreat()
  3066. {
  3067. $post = $this->input->post(NULL, TRUE);
  3068. if (isset($post['page'])) {
  3069. $page = $this->input->post('page', true);
  3070. $perpage = $this->input->post('perpage', true);
  3071. $warehouse = $this->input->post('warehouse', true);
  3072. $timetk = $this->input->post('timetk', true);
  3073. $timetj = $this->input->post('timetj', true);
  3074. $shop = $this->input->post('shop', true);
  3075. $source = $this->input->post('source', true);
  3076. $state = $this->input->post('state', true);
  3077. $review = $this->input->post('review', true);
  3078. $state = $this->input->post('state', true);
  3079. $express = $this->input->post('express', true);
  3080. $orderinfo = $this->input->post('orderinfo', true);
  3081. $user = $this->input->post('user', true);
  3082. $name = $this->input->post('name', true);
  3083. $waybill = $this->input->post('waybill', true);
  3084. $timetk = strtotime($timetk);
  3085. $timetj = strtotime($timetj);
  3086. $where = "(state=206 or state=210) and mergeid = 0";
  3087. if ($warehouse) {
  3088. $where .= " and state = '$warehouse'";
  3089. }
  3090. if ($timetk && $timetj) {
  3091. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3092. }
  3093. if ($shop) {
  3094. $where .= " and shop = '$shop'";
  3095. }
  3096. if ($source) {
  3097. $where .= " and source = '$source'";
  3098. }
  3099. if ($state) {
  3100. $where .= " and state = '$state'";
  3101. }
  3102. if ($review) {
  3103. $where .= " and review = '$review'";
  3104. }
  3105. if ($state) {
  3106. $where .= " and state = '$state'";
  3107. }
  3108. if ($express) {
  3109. $where .= " and express = '$express'";
  3110. }
  3111. if ($orderinfo) {
  3112. $where .= " and orderinfo = '$orderinfo'";
  3113. }
  3114. if ($user) {
  3115. $where .= " and user = '$user'";
  3116. }
  3117. if ($name) {
  3118. $where .= " and name = '$name'";
  3119. }
  3120. if ($waybill) {
  3121. $where .= " and waybill = '$waybill'";
  3122. }
  3123. //数据排序
  3124. $order_str = "id desc";
  3125. if (empty($page)) {
  3126. $start = 0;
  3127. $perpage = 1;
  3128. } else {
  3129. $start = ($page - 1) * $perpage;
  3130. }
  3131. //取得信息列表
  3132. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3133. //格式化数据
  3134. foreach ($info_list as $key => $value) {
  3135. $shop = $this->shop->read($value['shop']);
  3136. $info_list[$key]['shop'] = $shop['shopname'];
  3137. $warehouse = $this->warehouse->read($value['warehouse']);
  3138. $info_list[$key]['warehouse'] = $warehouse['title'];
  3139. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3140. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3141. if ($value['waybill'] == 0) {
  3142. $info_list[$key]['waybill'] = "";
  3143. }
  3144. $express = $this->express->read($value['express']);
  3145. $info_list[$key]['express'] = $express['title'];
  3146. $typeclass = $this->typeclass->read($value['state']);
  3147. $info_list[$key]['state'] = $typeclass['title'];
  3148. }
  3149. $total = $this->fullorder->find_count($where);
  3150. $pagenum = ceil($total / $perpage);
  3151. $over = $total - ($start + $perpage);
  3152. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3153. echo json_encode($rows);
  3154. exit;
  3155. }
  3156. $this->data['express'] = $this->express->find_all();
  3157. $this->_Template('whlabel_retreat', $this->data);
  3158. }
  3159. //退库标签浏览
  3160. public function _retreatlk()
  3161. {
  3162. $post = $this->input->post(NULL, TRUE);
  3163. if (isset($post['page'])) {
  3164. $page = $this->input->post('page', true);
  3165. $perpage = $this->input->post('perpage', true);
  3166. $timetk = $this->input->post('timetk', true);
  3167. $timetj = $this->input->post('timetj', true);
  3168. $sku = $this->input->post('sku', true);
  3169. $warehouse = $this->input->post('warehouse', true);
  3170. $purchase = $this->input->post('purchase', true);
  3171. $orderinfo = $this->input->post('orderinfo', true);
  3172. $waybill = $this->input->post('waybill', true);
  3173. $category = $this->input->post('category', true);
  3174. $size = $this->input->post('size', true);
  3175. $grade = $this->input->post('grade', true);
  3176. $color = $this->input->post('color', true);
  3177. $lowe = $this->input->post('lowe', true);
  3178. $state = $this->input->post('state', true);
  3179. $timetk = strtotime($timetk);
  3180. $timetj = strtotime($timetj);
  3181. $where = "state=2";
  3182. if ($timetk && $timetj) {
  3183. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3184. }
  3185. if ($sku) {
  3186. $where .= " and sku = '$sku'";
  3187. }
  3188. if ($warehouse) {
  3189. $where .= " and warehouse = '$warehouse'";
  3190. }
  3191. if ($purchase) {
  3192. $where .= " and purchase = '$purchase'";
  3193. }
  3194. if ($orderinfo) {
  3195. $where .= " and orderinfo = '$orderinfo'";
  3196. }
  3197. if ($waybill) {
  3198. $where .= " and waybill = '$waybill'";
  3199. }
  3200. if ($category) {
  3201. $where .= " and features like '%-$category-%'";
  3202. }
  3203. if ($size) {
  3204. $where .= " and features like '%-$size-%'";
  3205. }
  3206. if ($grade) {
  3207. $where .= " and features like '%-$grade-%'";
  3208. }
  3209. if ($color) {
  3210. $where .= " and features like '%-$color-%'";
  3211. }
  3212. if ($lowe) {
  3213. $where .= " and features like '%-$lowe-%'";
  3214. }
  3215. //数据排序
  3216. $order_str = "time desc";
  3217. if (empty($page)) {
  3218. $start = 0;
  3219. $perpage = 1;
  3220. } else {
  3221. $start = ($page - 1) * $perpage;
  3222. }
  3223. //取得信息列表
  3224. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3225. foreach ($info_list as $key => $value) {
  3226. $warehouse = $this->warehouse->read($value['warehouse']);
  3227. $info_list[$key]['warehouse'] = $warehouse['title'];
  3228. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3229. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3230. $purchase = $this->purchase->read($value['purchase']);
  3231. $info_list[$key]['purchase'] = $purchase['title'];
  3232. if ($value['outk'] != 0) {
  3233. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3234. } else {
  3235. $info_list[$key]['outk'] = "";
  3236. }
  3237. if ($value['retreat'] != 0) {
  3238. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3239. } else {
  3240. $info_list[$key]['retreat'] = "";
  3241. }
  3242. if ($value['orderinfo'] == 0) {
  3243. $info_list[$key]['orderinfo'] = "";
  3244. }
  3245. if ($value['waybill'] == 0) {
  3246. $info_list[$key]['waybill'] = "";
  3247. }
  3248. }
  3249. $total = $this->whlabel->find_count($where);
  3250. $pagenum = ceil($total / $perpage);
  3251. $over = $total - ($start + $perpage);
  3252. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3253. echo json_encode($rows);
  3254. exit;
  3255. }
  3256. $this->_Template('whlabel_retreatlk', $this->data);
  3257. }
  3258. //更换标签及浏览
  3259. public function _change()
  3260. {
  3261. $post = $this->input->post(NULL, TRUE);
  3262. if (isset($post['page'])) {
  3263. $page = $this->input->post('page', true);
  3264. $perpage = $this->input->post('perpage', true);
  3265. $timetk = $this->input->post('timetk', true);
  3266. $timetj = $this->input->post('timetj', true);
  3267. $label = $this->input->post('label', true);
  3268. $oldlabel = $this->input->post('oldlabel', true);
  3269. $timetk = strtotime($timetk);
  3270. $timetj = strtotime($timetj);
  3271. $where = "state=10 ";
  3272. if ($timetk && $timetj) {
  3273. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3274. }
  3275. if ($label) {
  3276. $where .= " and label = '$label'";
  3277. }
  3278. if ($oldlabel) {
  3279. $where .= " and oldlabel = '$oldlabel'";
  3280. }
  3281. //数据排序
  3282. $order_str = "time asc";
  3283. if (empty($page)) {
  3284. $start = 0;
  3285. $perpage = 1;
  3286. } else {
  3287. $start = ($page - 1) * $perpage;
  3288. }
  3289. //取得信息列表
  3290. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3291. foreach ($info_list as $key => $value) {
  3292. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3293. }
  3294. $total = $this->whlabel->find_count($where);
  3295. $pagenum = ceil($total / $perpage);
  3296. $over = $total - ($start + $perpage);
  3297. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3298. echo json_encode($rows);
  3299. exit;
  3300. }
  3301. $this->_Template('whlabel_change', $this->data);
  3302. }
  3303. //产品标签
  3304. public function _cpbqdc()
  3305. {
  3306. if (isset($_GET['excel'])) {
  3307. $where = "1=1";
  3308. //数据排序
  3309. $order_str = "id desc";
  3310. if (empty($page)) {
  3311. $start = 0;
  3312. $perpage = 1;
  3313. } else {
  3314. $start = ($page - 1) * $perpage;
  3315. }
  3316. $warehouse = $this->input->get('warehouse', true);
  3317. $state = $this->input->get('state', true);
  3318. $timetk = $this->input->get('timetkk', true);
  3319. $timetj = $this->input->get('timetjj', true);
  3320. $timetk = strtotime($timetk);
  3321. $timetj = strtotime($timetj);
  3322. if ($warehouse) {
  3323. $where .= " and warehouse = '$warehouse'";
  3324. }
  3325. if ($state || $state == 0) {
  3326. $where .= " and state = '$state'";
  3327. }
  3328. if ($timetk && $timetj) {
  3329. $where .= " and time > '$timetk' and time < '$timetj'";
  3330. }
  3331. //取得信息列表
  3332. $info_list = $this->whlabel->find_all($where, '*');
  3333. $rows = array();
  3334. $list = array();
  3335. foreach ($info_list as $key => $value) {
  3336. $rows[$value['time']] = $value; //所有数据sku
  3337. }
  3338. foreach ($rows as $value) {
  3339. $warehouse = $this->warehouse->read($value['warehouse']);
  3340. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3341. $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);
  3342. }
  3343. $title = "产品标签统计表";
  3344. $titlename = "<table border=1>
  3345. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3346. <tr align='center'>
  3347. <td>仓库</td>
  3348. <td>SKU</td>
  3349. <td>产品</td>
  3350. <td>入库时间</td>
  3351. <td>操作时间</td>
  3352. <td>备注</td>
  3353. <td>数量</td>
  3354. </tr>
  3355. </table>";
  3356. $filename = $title . ".xls";
  3357. $tail = "";
  3358. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3359. }
  3360. }
  3361. //进销存导出
  3362. public function _exceljxc()
  3363. {
  3364. $classid = $this->classid->sku();
  3365. $pm = $classid;
  3366. $typeclass = array();
  3367. $tc = $this->typeclass->find_all();
  3368. foreach ($tc as $v) {
  3369. $typeclass[$v['id']] = $v;
  3370. }
  3371. $prc = array();
  3372. $purchase = $this->purchase->find_all();
  3373. foreach ($purchase as $k => $v) {
  3374. $prc[$v['id']] = $v['title'];
  3375. }
  3376. if (isset($_GET['excel'])) {
  3377. $where = "sku != 'Preset'";
  3378. //数据排序
  3379. $order_str = "id desc";
  3380. if (empty($page)) {
  3381. $start = 0;
  3382. $perpage = 1;
  3383. } else {
  3384. $start = ($page - 1) * $perpage;
  3385. }
  3386. $category = $this->input->get('category', true);
  3387. $warehouse = $this->input->get('warehouse', true);
  3388. $excelid = $this->input->get('sid', true);
  3389. if ($category) {
  3390. $where .= " and features like '%-$category-%'";
  3391. }
  3392. if ($warehouse) {
  3393. $where .= " and warehouse = '$warehouse'";
  3394. }
  3395. $xzid = '';
  3396. if ($excelid) {
  3397. $excelid = explode(',', trim($excelid, ','));
  3398. foreach ($excelid as $key => $value) {
  3399. $xzid .= " id = " . $value . " or";
  3400. }
  3401. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3402. }
  3403. //取得信息列表
  3404. /**
  3405. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3406. $rows = array();$list = array();
  3407. foreach ($info_list as $key=>$value)
  3408. {
  3409. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3410. }
  3411. **/
  3412. $wt = array();
  3413. $whlabel_type = $this->whlabel_type->find_all();
  3414. foreach ($whlabel_type as $v) {
  3415. $wt[$v['id']] = $v['title'];
  3416. }
  3417. $wh = array();
  3418. $w = $this->warehouse->find_all('1=1', 'id,title');
  3419. foreach ($w as $v) {
  3420. $wh[$v['id']] = $v['title'];
  3421. }
  3422. $list = array();
  3423. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3424. foreach ($rows as $key => $value) {
  3425. if (isset($wt[$value['type']])) {
  3426. $rows[$key]['type'] = $wt[$value['type']];
  3427. } else {
  3428. $rows[$key]['type'] = '未设置';
  3429. }
  3430. $bm = '03';
  3431. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3432. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3433. $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');
  3434. $details = array();
  3435. $cpid = array();
  3436. $cpbz = array();
  3437. $c = 0;
  3438. $g = 0;
  3439. $x = 0;
  3440. $t = 0;
  3441. $s = 0;
  3442. $q = 0;
  3443. foreach ($sd as $k => $v) {
  3444. if ($v['state'] == 0) {
  3445. $c++;
  3446. if ($v['cpid'] != 0) {
  3447. $cpid[$v['cpid']] = $v['cpid'];
  3448. }
  3449. if ($v['cpbz'] != '') {
  3450. $cpbz[$v['cpbz']] = $v['cpbz'];
  3451. }
  3452. }
  3453. if ($v['state'] != 9) {
  3454. $g++;
  3455. }
  3456. if ($v['state'] == 1) {
  3457. $x++;
  3458. }
  3459. if ($v['state'] == 2) {
  3460. $t++;
  3461. }
  3462. if ($v['state'] == 8) {
  3463. $s++;
  3464. }
  3465. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3466. $q++;
  3467. }
  3468. $details[$v['details']] = $v['details'];
  3469. }
  3470. $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'] . '"');
  3471. $rows[$key]['details'] = implode("、", $details);
  3472. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3473. $number = $value['number'];
  3474. $ftime = time() - 15 * 24 * 3600;
  3475. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3476. $rows[$key]['number'] = $g;
  3477. $rows[$key]['c'] = $c;
  3478. $rows[$key]['x'] = $x;
  3479. $rows[$key]['t'] = $t;
  3480. $rows[$key]['s'] = $s;
  3481. $rows[$key]['q'] = $q;
  3482. $rows[$key]['z'] = $z;
  3483. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3484. $features = explode('-', trim($features, '-'));
  3485. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3486. // $pm = $classid;
  3487. // $jm = $classid;
  3488. // foreach($features as $k=>$v)
  3489. // {
  3490. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3491. // {
  3492. // if($typeclass[$v]['bm'] != '')
  3493. // {
  3494. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3495. // }
  3496. // }
  3497. // if($v != 0)
  3498. // {
  3499. // if(!isset($typeclass[$v]))
  3500. // {
  3501. // continue;
  3502. // }
  3503. // if(isset($pm[$typeclass[$v]['classid']]))
  3504. // {
  3505. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3506. // {
  3507. // $tz = explode('|',$typeclass[$v]['zh']);
  3508. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3509. // }
  3510. // else
  3511. // {
  3512. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3513. // }
  3514. // }
  3515. // if(isset($jm[$typeclass[$v]['classid']]))
  3516. // {
  3517. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3518. // }
  3519. // }
  3520. // }
  3521. // $jm = array_filter($jm);
  3522. // $rows[$key]['bs'] = implode("-",$jm);
  3523. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3524. // $zh = implode(" ",$pm);
  3525. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3526. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3527. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3528. // $rows[$key]['features'] = $zh;
  3529. }
  3530. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3531. $final_list = [];
  3532. foreach ($list as $k => $v) {
  3533. if (empty($v['sku'])) {
  3534. continue;
  3535. }
  3536. $final_list[] = [
  3537. "warehouse" => $v["warehouse"],
  3538. "purchase" => $v["purchase"],
  3539. "details" => $v["details"],
  3540. "cpid" => $v["cpid"],
  3541. "dbcontent" => $v["dbcontent"],
  3542. "sku" => $v["sku"],
  3543. "cs" => $v["bm"],
  3544. "bs" => $v["jm"],
  3545. "title" => $v["title"],
  3546. "features" => $v["pm"],
  3547. "cpbz" => $v["cpbz"],
  3548. "sm" => $v["sm"],
  3549. "type" => $v["type"],
  3550. "number" => $v["number"],
  3551. "c" => $v["c"],
  3552. "x" => $v["x"],
  3553. "t" => $v["t"],
  3554. "s" => $v["s"],
  3555. "q" => $v["q"],
  3556. "z" => $v["z"],
  3557. "weight" => $v['weight'],
  3558. ];
  3559. }
  3560. $title = "总进销存统计表";
  3561. $titlename = "<table border=1>
  3562. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3563. <tr align='center'>
  3564. <td>仓库</td>
  3565. <td>供应商</td>
  3566. <td>位置</td>
  3567. <td>库存编码</td>
  3568. <td>类目</td>
  3569. <td>SKU</td>
  3570. <td>用友编码</td>
  3571. <td>用友料号</td>
  3572. <td>商品名称</td>
  3573. <td>商品中文</td>
  3574. <td>产品备注</td>
  3575. <td>说明</td>
  3576. <td>类型</td>
  3577. <td>入库总量</td>
  3578. <td>库存数量</td>
  3579. <td>销售数量</td>
  3580. <td>退货数量</td>
  3581. <td>删除数量</td>
  3582. <td>其它操作</td>
  3583. <td>占单数量</td>
  3584. <td>重量(g)</td>
  3585. </tr>
  3586. </table>";
  3587. $filename = $title . ".xls";
  3588. $tail = "";
  3589. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3590. }
  3591. }
  3592. //入库导出
  3593. public function _excelr()
  3594. {
  3595. if (isset($_GET['excel'])) {
  3596. $category = $this->input->get('category', true);
  3597. $size = $this->input->get('size', true);
  3598. $grade = $this->input->get('grade', true);
  3599. $color = $this->input->get('color', true);
  3600. $lowe = $this->input->get('lowe', true);
  3601. $sku = $this->input->get('sku', true);
  3602. $warehouse = $this->input->get('warehouse', true);
  3603. $purchase = $this->input->get('purchase', true);
  3604. $ktime = $this->input->get('ktime', true);
  3605. $jtime = $this->input->get('jtime', true);
  3606. $ktime = strtotime($ktime);
  3607. $jtime = strtotime($jtime);
  3608. $where = "1=1";
  3609. $gj = "";
  3610. $ck = "";
  3611. if ($category) {
  3612. $where .= " and features like '%-$category-%'";
  3613. }
  3614. if ($size) {
  3615. $where .= " and features like '%-$size-%'";
  3616. }
  3617. if ($grade) {
  3618. $where .= " and features like '%-$grade-%'";
  3619. }
  3620. if ($color) {
  3621. $where .= " and features like '%-$color-%'";
  3622. }
  3623. if ($lowe) {
  3624. $where .= " and features like '%-$lowe-%'";
  3625. }
  3626. if ($warehouse) {
  3627. $where .= " and warehouse = '$warehouse'";
  3628. }
  3629. if ($purchase) {
  3630. $where .= " and purchase = '$purchase'";
  3631. }
  3632. if ($sku) {
  3633. $where .= " and sku = '$sku'";
  3634. }
  3635. if ($ktime && $jtime) {
  3636. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3637. }
  3638. //数据排序
  3639. $order_str = "id desc";
  3640. if (empty($page)) {
  3641. $start = 0;
  3642. $perpage = 1;
  3643. } else {
  3644. $start = ($page - 1) * $perpage;
  3645. }
  3646. $list = array();
  3647. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3648. foreach ($rows as $value) {
  3649. $ck = $this->warehouse->read($value['warehouse']);
  3650. $warehouse = $ck['title'];
  3651. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3652. $retreatwarehouse = $tkck['title'];
  3653. $gy = $this->purchase->read($value['purchase']);
  3654. $purchase = $gy['title'];
  3655. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3656. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3657. }
  3658. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3659. $titlename = "<table border=1>
  3660. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3661. <tr align='center'>
  3662. <td>仓库</td>
  3663. <td>SKU</td>
  3664. <td>产品</td>
  3665. <td>时间</td>
  3666. <td>数量</td>
  3667. </tr>
  3668. </table>";
  3669. $filename = $title . ".xls";
  3670. $tail = "";
  3671. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3672. }
  3673. }
  3674. //出库、退库导出
  3675. public function _excelct()
  3676. {
  3677. $classid = $this->classid->sku();
  3678. $pm = $classid;
  3679. $typeclass = array();
  3680. $tc = $this->typeclass->find_all();
  3681. foreach ($tc as $v) {
  3682. $typeclass[$v['id']] = $v;
  3683. }
  3684. $prc = array();
  3685. $purchase = $this->purchase->find_all();
  3686. foreach ($purchase as $k => $v) {
  3687. $prc[$v['id']] = $v['title'];
  3688. }
  3689. if (isset($_GET['excel'])) {
  3690. $wh = array();
  3691. $w = $this->warehouse->find_all('1=1', 'id,title');
  3692. foreach ($w as $v) {
  3693. $wh[$v['id']] = $v['title'];
  3694. }
  3695. $type = $this->input->get('excel', true);
  3696. $category = $this->input->get('category', true);
  3697. $size = $this->input->get('size', true);
  3698. $grade = $this->input->get('grade', true);
  3699. $color = $this->input->get('color', true);
  3700. $lowe = $this->input->get('lowe', true);
  3701. $sku = $this->input->get('sku', true);
  3702. $title = $this->input->get('title', true);
  3703. $warehouse = $this->input->get('warehouse', true);
  3704. $purchase = $this->input->get('purchase', true);
  3705. $lacetype = $this->input->get('lacetype', true);
  3706. $haircap = $this->input->get('haircap', true);
  3707. $lacecolor = $this->input->get('lacecolor', true);
  3708. $density = $this->input->get('density', true);
  3709. $details = $this->input->get('details', true);
  3710. $state = $this->input->get('state', true);
  3711. $shop = $this->input->get('shop', true);
  3712. $hairnumber = $this->input->get('hairnumber', true);
  3713. $type_leixi = $this->input->get('type', true);
  3714. $cpbz = $this->input->get('cpbz', true);
  3715. $sm = $this->input->get('sm', true);
  3716. $sid = $this->input->get('sid', true);
  3717. $ktime = $this->input->get('ktime', true);
  3718. $jtime = $this->input->get('jtime', true);
  3719. $ktime = strtotime($ktime);
  3720. $jtime = strtotime($jtime);
  3721. //$where = " 1=1 ";
  3722. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3723. $where = " sku != '' ";
  3724. $gj = "";
  3725. $ck = "";
  3726. if ($category) {
  3727. $where .= " and features like '%-$category-%'";
  3728. }
  3729. if ($size) {
  3730. $where .= " and features like '%-$size-%'";
  3731. }
  3732. if ($grade) {
  3733. $where .= " and features like '%-$grade-%'";
  3734. }
  3735. if ($color) {
  3736. $where .= " and features like '%-$color-%'";
  3737. }
  3738. if ($lowe) {
  3739. $where .= " and features like '%-$lowe-%'";
  3740. }
  3741. if ($warehouse) {
  3742. $where .= " and warehouse = '$warehouse'";
  3743. }
  3744. if ($purchase) {
  3745. $where .= " and purchase = '$purchase'";
  3746. }
  3747. if ($state) {
  3748. $where .= " and state = '$state'";
  3749. }
  3750. if ($lacetype) {
  3751. $where .= " and features like '%-$lacetype-%'";
  3752. }
  3753. if ($lacecolor) {
  3754. $where .= " and features like '%-$lacecolor-%'";
  3755. }
  3756. if ($density) {
  3757. $where .= " and features like '%-$density-%'";
  3758. }
  3759. if ($haircap) {
  3760. $where .= " and features like '%-$haircap-%'";
  3761. }
  3762. if ($details) {
  3763. $where .= " and details = '$details'";
  3764. }
  3765. if ($shop) {
  3766. $where .= " and shop like '%$shop%'";
  3767. }
  3768. if ($title) {
  3769. $title = trim($title, ' ');
  3770. $title = trim($title, ' ');
  3771. $where .= " and title like '%$title%'";
  3772. }
  3773. if (!empty($hairnumber)) {
  3774. $where .= " and features like '%-128-%' ";
  3775. if ($hairnumber < 0) {
  3776. $class_list = $this->typeclass->find_all('classid = 43');
  3777. foreach ($class_list as $v) {
  3778. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3779. }
  3780. } else {
  3781. $where .= " and features like '%-$hairnumber-%'";
  3782. }
  3783. }
  3784. if ($type_leixi) {
  3785. $where .= " and type = '$type_leixi'";
  3786. }
  3787. if ($cpbz) {
  3788. $where .= " and cpbz like '%$cpbz%' ";
  3789. }
  3790. if ($sm) {
  3791. $where .= " and sm like '%$sm%' ";
  3792. }
  3793. if ($sku) {
  3794. $sku = trim($sku, ' ');
  3795. $sku = trim($sku, ' ');
  3796. $where .= " and sku like '%$sku%'";
  3797. }
  3798. if ($ktime && $jtime) {
  3799. if ($type == 1) {
  3800. $tl = '出库';
  3801. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3802. } else if ($type == 2) {
  3803. $tl = '退库';
  3804. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3805. } else if ($type == 3) {
  3806. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3807. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3808. } else if ($type == 4) {
  3809. $tl = '出库+零售';
  3810. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3811. } else if ($type == 5) {
  3812. $tl = '零售';
  3813. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3814. }
  3815. }
  3816. $sidwhere = '';
  3817. if ($sid) {
  3818. $sd = "";
  3819. $s = explode(',', trim($sid, ','));
  3820. foreach ($s as $value) {
  3821. $sd .= " id = " . $value . " or";
  3822. }
  3823. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3824. }
  3825. //数据排序
  3826. $order_str = "time desc";
  3827. if (empty($page)) {
  3828. $start = 0;
  3829. $perpage = 1;
  3830. } else {
  3831. $start = ($page - 1) * $perpage;
  3832. }
  3833. //取得信息列表
  3834. if ($type != 3 && $type != 5) {
  3835. if ($type == 1 || $type == 4) {
  3836. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3837. foreach ($info_list as $key => $value) {
  3838. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3839. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3840. $warehouse = $this->warehouse->read($value['warehouse']);
  3841. $info_list[$key]['warehouse'] = $warehouse['title'];
  3842. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3843. $features = explode('-', trim($features, '-'));
  3844. $pm = $classid;
  3845. foreach ($features as $k => $v) {
  3846. if ($v != 0) {
  3847. if (!isset($typeclass[$v])) {
  3848. continue;
  3849. }
  3850. if (isset($pm[$typeclass[$v]['classid']])) {
  3851. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3852. $tz = explode('|', $typeclass[$v]['zh']);
  3853. $pm[$typeclass[$v]['classid']] = $tz[0];
  3854. } else {
  3855. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3856. }
  3857. }
  3858. }
  3859. }
  3860. $zh = implode(" ", $pm);
  3861. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3862. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3863. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3864. $info_list[$key]['features'] = $zh;
  3865. }
  3866. $final_list = [];
  3867. foreach($info_list as $k=>$v){
  3868. $number = "";
  3869. if(!empty($v['orderinfo'])){
  3870. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3871. if(!empty($tmp_info['number'])){
  3872. $number = $tmp_info['number'];
  3873. }
  3874. }
  3875. $final_list[] = [
  3876. 'warehouse'=>$v['warehouse'],
  3877. 'purchase'=>$v['purchase'],
  3878. 'sku'=>$v['sku'],
  3879. 'title'=>$v['title'],
  3880. 'features'=>$v['features'],
  3881. 'label'=>$v['label'],
  3882. 'orderinfo'=>$v['orderinfo'],
  3883. 'number'=>$number,
  3884. 'waybill'=>$v['waybill'],
  3885. 'outk'=>$v['outk'],
  3886. ];
  3887. }
  3888. } else {
  3889. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3890. foreach ($info_list as $key => $value) {
  3891. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3892. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3893. $warehouse = $this->warehouse->read($value['warehouse']);
  3894. $info_list[$key]['warehouse'] = $warehouse['title'];
  3895. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3896. $features = explode('-', trim($features, '-'));
  3897. $pm = $classid;
  3898. foreach ($features as $k => $v) {
  3899. if ($v != 0) {
  3900. if (!isset($typeclass[$v])) {
  3901. continue;
  3902. }
  3903. if (isset($pm[$typeclass[$v]['classid']])) {
  3904. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3905. $tz = explode('|', $typeclass[$v]['zh']);
  3906. $pm[$typeclass[$v]['classid']] = $tz[0];
  3907. } else {
  3908. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3909. }
  3910. }
  3911. }
  3912. }
  3913. $zh = implode(" ", $pm);
  3914. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3915. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3916. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3917. $info_list[$key]['features'] = $zh;
  3918. }
  3919. $final_list = [];
  3920. foreach($info_list as $k=>$v){
  3921. $number = "";
  3922. if(!empty($v['orderinfo'])){
  3923. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3924. if(!empty($tmp_info['number'])){
  3925. $number = $tmp_info['number'];
  3926. }
  3927. }
  3928. $final_list[] = [
  3929. 'warehouse'=>$v['warehouse'],
  3930. 'purchase'=>$v['purchase'],
  3931. 'sku'=>$v['sku'],
  3932. 'title'=>$v['title'],
  3933. 'features'=>$v['features'],
  3934. 'label'=>$v['label'],
  3935. 'orderinfo'=>$v['orderinfo'],
  3936. 'number'=>$number,
  3937. 'waybill'=>$v['waybill'],
  3938. 'retreat'=>$v['retreat'],
  3939. ];
  3940. }
  3941. }
  3942. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3943. $titlename = "<table border=1>
  3944. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3945. <tr align='center'>
  3946. <td>仓库</td>
  3947. <td>供应商</td>
  3948. <td>SKU</td>
  3949. <td>商品名称</td>
  3950. <td>商品中文</td>
  3951. <td>标签</td>
  3952. <td>订单号</td>
  3953. <td>订单编码</td>
  3954. <td>运单号</td>
  3955. <td>" . $tl . "时间(中国时间)</td>
  3956. </tr>
  3957. </table>";
  3958. $filename = $title . ".xls";
  3959. $tail = "";
  3960. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3961. } else if ($type == 5) {
  3962. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3963. foreach ($info_list as $key => $value) {
  3964. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3965. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3966. $warehouse = $this->warehouse->read($value['warehouse']);
  3967. $info_list[$key]['warehouse'] = $warehouse['title'];
  3968. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3969. $features = explode('-', trim($features, '-'));
  3970. $pm = $classid;
  3971. foreach ($features as $k => $v) {
  3972. if ($v != 0) {
  3973. if (!isset($typeclass[$v])) {
  3974. continue;
  3975. }
  3976. if (isset($pm[$typeclass[$v]['classid']])) {
  3977. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3978. $tz = explode('|', $typeclass[$v]['zh']);
  3979. $pm[$typeclass[$v]['classid']] = $tz[0];
  3980. } else {
  3981. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3982. }
  3983. }
  3984. }
  3985. }
  3986. $zh = implode(" ", $pm);
  3987. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3988. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3989. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3990. $info_list[$key]['features'] = $zh;
  3991. }
  3992. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3993. $titlename = "<table border=1>
  3994. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3995. <tr align='center'>
  3996. <td>仓库</td>
  3997. <td>供应商</td>
  3998. <td>SKU</td>
  3999. <td>商品名称</td>
  4000. <td>商品中文</td>
  4001. <td>标签</td>
  4002. <td>" . $tl . "时间(中国时间)</td>
  4003. </tr>
  4004. </table>";
  4005. $filename = $title . ".xls";
  4006. $tail = "";
  4007. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4008. } else {
  4009. /**
  4010. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4011. $rows = array();$list = array();
  4012. foreach ($info_list as $key=>$value)
  4013. {
  4014. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4015. }
  4016. **/
  4017. $wh = array();
  4018. $w = $this->warehouse->find_all('1=1', 'id,title');
  4019. foreach ($w as $v) {
  4020. $wh[$v['id']] = $v['title'];
  4021. }
  4022. $wt = array();
  4023. $whlabel_type = $this->whlabel_type->find_all();
  4024. foreach ($whlabel_type as $v) {
  4025. $wt[$v['id']] = $v['title'];
  4026. }
  4027. $classid = $this->classid->sku();
  4028. $list = array();
  4029. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4030. foreach ($rows as $key => $value) {
  4031. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4032. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4033. $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');
  4034. $details = array();
  4035. $cpid = array();
  4036. $cpbz = array();
  4037. $c = 0;
  4038. $g = 0;
  4039. $x = 0;
  4040. $t = 0;
  4041. $s = 0;
  4042. $q = 0;
  4043. foreach ($sd as $k => $v) {
  4044. if ($v['state'] == 0) {
  4045. $c++;
  4046. }
  4047. if ($v['state'] != 9) {
  4048. $g++;
  4049. }
  4050. if ($v['outk'] > 1) {
  4051. $x++;
  4052. }
  4053. if ($v['retreat'] > 0) {
  4054. $t++;
  4055. }
  4056. if ($v['state'] == 8) {
  4057. $s++;
  4058. }
  4059. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4060. $q++;
  4061. }
  4062. $details[$v['details']] = $v['details'];
  4063. if ($v['cpid'] != 0) {
  4064. $cpid[$v['cpid']] = $v['cpid'];
  4065. }
  4066. if ($v['cpbz'] != '') {
  4067. $cpbz[$v['cpbz']] = $v['cpbz'];
  4068. }
  4069. }
  4070. if (isset($wt[$value['type']])) {
  4071. $rows[$key]['type'] = $wt[$value['type']];
  4072. } else {
  4073. $rows[$key]['type'] = '未设置';
  4074. }
  4075. $rows[$key]['details'] = implode("、", $details);
  4076. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4077. $ftime = time() - 15 * 24 * 3600;
  4078. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4079. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4080. $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);
  4081. $rows[$key]['c'] = $c;
  4082. $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);
  4083. $rows[$key]['t'] = $t;
  4084. $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'] . '"');
  4085. $rows[$key]['z'] = $z;
  4086. // $jm = $classid;
  4087. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4088. $features = explode('-', trim($features, '-'));
  4089. // $pm = $classid;
  4090. // foreach ($features as $k => $v) {
  4091. // if ($v != 0) {
  4092. // if (!isset($typeclass[$v])) {
  4093. // continue;
  4094. // }
  4095. // if (isset($pm[$typeclass[$v]['classid']])) {
  4096. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4097. // $tz = explode('|', $typeclass[$v]['zh']);
  4098. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4099. // } else {
  4100. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4101. // }
  4102. // if (isset($jm[$typeclass[$v]['classid']])) {
  4103. // if ($typeclass[$v]['jm']) {
  4104. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4105. // }
  4106. // }
  4107. // }
  4108. // }
  4109. // }
  4110. // $zh = implode(" ", $pm);
  4111. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4112. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4113. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4114. // $rows[$key]['features'] = $zh;
  4115. // $jm = array_filter($jm); //去除空值
  4116. // $jm = implode("-", $jm);
  4117. // $rows[$key]['jm'] = $jm;
  4118. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4119. }
  4120. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4121. // echo "<pre>";
  4122. // print_r($tmp_list);
  4123. // die;
  4124. $final_list =[];
  4125. foreach($tmp_list as $k=>$v){
  4126. $final_list[] = [
  4127. "warehouse"=>$v['warehouse'],
  4128. "purchase"=>$v['purchase'],
  4129. "details"=>$v['details'],
  4130. "cpid"=>$v['cpid'],
  4131. "sku"=>$v['sku'],
  4132. "title"=>$v['title'],
  4133. "features"=>$v['pm'],
  4134. "cpbz"=>$v['cpbz'],
  4135. "sm"=>$v['sm'],
  4136. "type"=>$v['type'],
  4137. "g"=>$v["g"],
  4138. "c"=>$v["c"],
  4139. "x"=>$v["x"],
  4140. "t"=>$v["t"],
  4141. "z"=>$v["z"],
  4142. "jm"=>$v["jm"],
  4143. "weight"=>$v["weight"],
  4144. "asd"=>$v["asd"],
  4145. ];
  4146. }
  4147. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4148. $titlename = "<table border=1>
  4149. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4150. <tr align='center'>
  4151. <td>仓库</td>
  4152. <td>供应商</td>
  4153. <td>位置</td>
  4154. <td>库存编码</td>
  4155. <td>SKU</td>
  4156. <td>商品名称</td>
  4157. <td>商品中文</td>
  4158. <td>产品备注</td>
  4159. <td>说明</td>
  4160. <td>类型</td>
  4161. <td>入库总量</td>
  4162. <td>库存数量</td>
  4163. <td>销售数量</td>
  4164. <td>退货数量</td>
  4165. <td>占单数量</td>
  4166. <td>料号</td>
  4167. <td>重量</td>
  4168. <td>类目</td>
  4169. </tr>
  4170. </table>";
  4171. $filename = $title . ".xls";
  4172. $tail = "";
  4173. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4174. }
  4175. }
  4176. }
  4177. //出库+入库数据整合
  4178. public function _excelcr()
  4179. {
  4180. if (isset($_GET['excel'])) {
  4181. $type = $this->input->get('excel', true);
  4182. $category = $this->input->get('category', true);
  4183. $size = $this->input->get('size', true);
  4184. $grade = $this->input->get('grade', true);
  4185. $color = $this->input->get('color', true);
  4186. $lowe = $this->input->get('lowe', true);
  4187. $sku = $this->input->get('sku', true);
  4188. $warehouse = $this->input->get('warehouse', true);
  4189. $purchase = $this->input->get('purchase', true);
  4190. $state = $this->input->get('state', true);
  4191. $sid = $this->input->get('sid', true);
  4192. $ktime = $this->input->get('ktime', true);
  4193. $jtime = $this->input->get('jtime', true);
  4194. $ktime = strtotime($ktime);
  4195. $jtime = strtotime($jtime);
  4196. $where = "1=1";
  4197. $gj = "";
  4198. $ck = "";
  4199. if ($category) {
  4200. $where .= " and features like '%-$category-%'";
  4201. }
  4202. if ($size) {
  4203. $where .= " and features like '%-$size-%'";
  4204. }
  4205. if ($grade) {
  4206. $where .= " and features like '%-$grade-%'";
  4207. }
  4208. if ($color) {
  4209. $where .= " and features like '%-$color-%'";
  4210. }
  4211. if ($lowe) {
  4212. $where .= " and features like '%-$lowe-%'";
  4213. }
  4214. if ($warehouse) {
  4215. $where .= " and warehouse = '$warehouse'";
  4216. }
  4217. if ($purchase) {
  4218. $where .= " and purchase = '$purchase'";
  4219. }
  4220. if ($state) {
  4221. $where .= " and state = '$state'";
  4222. }
  4223. if ($sku) {
  4224. $where .= " and sku like '%$sku%'";
  4225. }
  4226. if ($ktime && $jtime) {
  4227. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4228. }
  4229. $sidwhere = '';
  4230. if ($sid) {
  4231. $sd = "";
  4232. $s = explode(',', trim($sid, ','));
  4233. foreach ($s as $value) {
  4234. $sd .= " id = " . $value . " or";
  4235. }
  4236. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4237. }
  4238. //取得信息列表
  4239. $timeread = $ktime;
  4240. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4241. $timelist = array();
  4242. for ($i = 0; $i < $timenum; $i++) {
  4243. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4244. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4245. }
  4246. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4247. //echo "<pre>";
  4248. //print_r($info_list);
  4249. //exit();
  4250. $rows = array();
  4251. $list = array();
  4252. foreach ($info_list as $key => $value) {
  4253. $thistime = $timelist;
  4254. if (isset($rows[strtolower($value['sku'])])) {
  4255. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4256. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4257. }
  4258. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4259. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4260. }
  4261. } else {
  4262. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4263. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4264. }
  4265. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4266. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4267. }
  4268. $rows[strtolower($value['sku'])] = $thistime;
  4269. }
  4270. }
  4271. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4272. <head>
  4273. <!--[if gte mso 9]><xml>
  4274. <x:ExcelWorkbook>
  4275. <x:ExcelWorksheets>
  4276. <x:ExcelWorksheet>
  4277. <x:Name>EXCEL</x:Name>
  4278. <x:WorksheetOptions>
  4279. <x:Print>
  4280. <x:ValidPrinterInfo />
  4281. </x:Print>
  4282. </x:WorksheetOptions>
  4283. </x:ExcelWorksheet>
  4284. </x:ExcelWorksheets>
  4285. </x:ExcelWorkbook>
  4286. </xml>
  4287. <![endif]-->
  4288. </head><body>";
  4289. $str .= "<table border=1><tr><td>SKU</td>";
  4290. foreach ($timelist as $k => $v) {
  4291. $str .= "<td>" . $k . "出库</td>";
  4292. $str .= "<td>" . $k . "入库</td>";
  4293. }
  4294. $str .= "</tr></table>";
  4295. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4296. foreach ($rows as $key => $val) {
  4297. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4298. foreach ($val as $k => $v) {
  4299. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4300. if ($val[$k]['r'] > 0) {
  4301. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4302. } else {
  4303. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4304. }
  4305. }
  4306. $str .= "</tr>";
  4307. }
  4308. $str .= "</table>";
  4309. $str .= "</body></html>";
  4310. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4311. header("Content-type: application/octet-stream");
  4312. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4313. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4314. header("Pragma: no-cache");
  4315. header("Expires: 0");
  4316. exit($str);
  4317. }
  4318. }
  4319. //数量调整模板导出
  4320. public function _presetout()
  4321. {
  4322. if (isset($_GET['excel'])) {
  4323. $where = "sku != 'Preset' and purchase != 0";
  4324. //数据排序
  4325. $order_str = "id desc";
  4326. if (empty($page)) {
  4327. $start = 0;
  4328. $perpage = 1;
  4329. } else {
  4330. $start = ($page - 1) * $perpage;
  4331. }
  4332. //取得信息列表
  4333. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4334. $rows = array();
  4335. $list = array();
  4336. foreach ($info_list as $value) {
  4337. $warehouse = $this->warehouse->read($value['warehouse']);
  4338. $number = $value['number'];
  4339. $ftime = time() - 15 * 24 * 3600;
  4340. $purchase = $this->purchase->read($value['purchase']);
  4341. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4342. }
  4343. $title = "库存模板";
  4344. $titlename = "<table border=1>
  4345. <tr align='center'>
  4346. <td>仓库</td>
  4347. <td>供应商编码</td>
  4348. <td>SKU</td>
  4349. <td>增减数量(正数或负数)</td>
  4350. <td>增减备注</td>
  4351. <td>扣减方式:0减少库存1删除库存</td>
  4352. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4353. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4354. </tr>
  4355. </table>";
  4356. $filename = $title . ".xls";
  4357. $tail = "";
  4358. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4359. }
  4360. }
  4361. //数量调整模板导入
  4362. public function _presetedit()
  4363. {
  4364. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4365. $config['upload_path'] = '.' . $dir;
  4366. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4367. $config['allowed_types'] = 'xls|xlsx|csv';
  4368. $config['max_size'] = 10240;
  4369. $this->load->library('upload', $config);
  4370. $this->upload->initialize($config);
  4371. if ($this->upload->do_upload('userfile')) {
  4372. $full_path = $dir . $this->upload->data('file_name');
  4373. $fileName = '.' . $full_path;
  4374. if (!file_exists($fileName)) {
  4375. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4376. exit;
  4377. } else {
  4378. require_once "./data/excel/PHPExcel/IOFactory.php";
  4379. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4380. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4381. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4382. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4383. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4384. ++$column; //如果列数大于26行
  4385. $list = array();
  4386. for ($i = 2; $i <= $row; $i++) // 行数循环
  4387. {
  4388. $data = array();
  4389. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4390. {
  4391. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4392. }
  4393. $list[] = $data;
  4394. }
  4395. }
  4396. $i = 0;
  4397. $j = 0;
  4398. $ed = array();
  4399. foreach ($list as $key => $value) {
  4400. $time = time();
  4401. if ($value['0'] == "") {
  4402. continue;
  4403. }
  4404. $warehouse = $this->warehouse->get_title($value['0']);
  4405. $purchase = $this->purchase->get_bm($value['1']);
  4406. $sku = $value['2'];
  4407. $num = $value['3']; //调整数量
  4408. $text = $value['4']; //扣减说明
  4409. $type = $value['5']; //调整方式0扣减1删除
  4410. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4411. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4412. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4413. if (!$purchase) //如果没有这个SKU
  4414. {
  4415. $ed[] = array($purchase . '-不存在此供应商编码');
  4416. $j++;
  4417. continue;
  4418. }
  4419. if (!$d) //如果没有这个SKU
  4420. {
  4421. $ed[] = array($sku . '-库存中不存在此SKU');
  4422. $j++;
  4423. continue;
  4424. }
  4425. if (!isset($warehouse['id'])) {
  4426. $ed[] = array($sku . '-仓库名错误!');
  4427. $j++;
  4428. continue;
  4429. }
  4430. if ($type != '0' && $type != '1') {
  4431. $ed[] = array($sku . '-扣减方式填写错误!');
  4432. $j++;
  4433. continue;
  4434. }
  4435. if ($num < 0) //扣减库存
  4436. {
  4437. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4438. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4439. $j++;
  4440. continue;
  4441. }
  4442. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4443. if (count($data) < abs($num)) {
  4444. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4445. $j++;
  4446. continue;
  4447. }
  4448. if ($type == 0) //如果扣减方式为 扣减库存
  4449. {
  4450. for ($i = 0; $i < abs($num); $i++) {
  4451. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4452. }
  4453. } else if ($type == 1) {
  4454. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4455. if (count($zt) > 0) {
  4456. $ed[] = array($sku . '-有在途库存无法删除!');
  4457. $j++;
  4458. continue;
  4459. }
  4460. for ($i = 0; $i < abs($num); $i++) {
  4461. $this->whlabel->remove($data[$i]['id']);
  4462. }
  4463. }
  4464. } else if ($num > 0) //增加库存
  4465. {
  4466. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4467. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4468. $j++;
  4469. continue;
  4470. }
  4471. $post['sku'] = $d['sku'];
  4472. $post['shop'] = $d['shop'];
  4473. $post['warehouse'] = $warehouse['id'];
  4474. $post['purchase'] = $purchase['id'];
  4475. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4476. $post['state'] = 0;
  4477. $post['title'] = $d['title'];
  4478. $post['number'] = $d['number'];
  4479. $post['features'] = $d['features'];
  4480. $post['enter'] = $time;
  4481. $post['time'] = $time; //操作时间
  4482. $post['rktype'] = $rktype;
  4483. for ($i = 0; $i < $num; $i++) {
  4484. $post['label'] = time() . rand(100, 999) . $i;
  4485. $this->whlabel->insert($post);
  4486. }
  4487. }
  4488. sleep(1); //防止入库时间一样,需要延迟1秒
  4489. }
  4490. if ($j > 0) {
  4491. $tt = date('Ymd', time());
  4492. $title = '库存导入错误信息-' . $tt;
  4493. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4494. $tail = "\n";
  4495. $filename = $title . ".xls";
  4496. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4497. $dir = '/data/excel/' . $time . '/';
  4498. $file_name = 'error_' . $time . rand(1000, 9999);
  4499. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4500. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4501. fwrite($myfile, $ecl);
  4502. fclose($myfile);
  4503. $error = $dir . $file_name . '.xls';
  4504. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4505. exit;
  4506. } else {
  4507. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4508. exit;
  4509. }
  4510. }
  4511. }
  4512. public function _presetedittwo(){
  4513. $data = $this->input->post(NULL, TRUE);
  4514. if(empty($list)){
  4515. $raw_data = $this->input->raw_input_stream;
  4516. // 解码 JSON
  4517. $data = json_decode($raw_data, true);
  4518. }
  4519. if(empty($data)){
  4520. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4521. }
  4522. $list = [];
  4523. if(isset($data['list'])){
  4524. $list = $data['list'];
  4525. }
  4526. $i = 0;
  4527. $j = 0;
  4528. $ed = array();
  4529. foreach ($list as $key => $value) {
  4530. $time = time();
  4531. if ($value['0'] == "") {
  4532. continue;
  4533. }
  4534. $warehouse = $this->warehouse->get_title($value['0']);
  4535. $purchase = $this->purchase->get_bm($value['1']);
  4536. $sku = $value['2'];
  4537. $num = $value['3']; //调整数量
  4538. $text = $value['4']; //扣减说明
  4539. $type = $value['5']; //调整方式0扣减1删除
  4540. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4541. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4542. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4543. if (!$purchase) //如果没有这个SKU
  4544. {
  4545. $ed[] = array($value['1'] . '-不存在此供应商编码');
  4546. $j++;
  4547. continue;
  4548. }
  4549. if (!$d) //如果没有这个SKU
  4550. {
  4551. $ed[] = array($sku . '-库存中不存在此SKU');
  4552. $j++;
  4553. continue;
  4554. }
  4555. if (!isset($warehouse['id'])) {
  4556. $ed[] = array($sku . '-仓库名错误!');
  4557. $j++;
  4558. continue;
  4559. }
  4560. if ($type != '0' && $type != '1') {
  4561. $ed[] = array($sku . '-扣减方式填写错误!');
  4562. $j++;
  4563. continue;
  4564. }
  4565. if ($num < 0) //扣减库存
  4566. {
  4567. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4568. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4569. $j++;
  4570. continue;
  4571. }
  4572. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4573. if (count($data) < abs($num)) {
  4574. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4575. $j++;
  4576. continue;
  4577. }
  4578. if ($type == 0) //如果扣减方式为 扣减库存
  4579. {
  4580. for ($i = 0; $i < abs($num); $i++) {
  4581. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4582. }
  4583. } else if ($type == 1) {
  4584. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4585. if (count($zt) > 0) {
  4586. $ed[] = array($sku . '-有在途库存无法删除!');
  4587. $j++;
  4588. continue;
  4589. }
  4590. for ($i = 0; $i < abs($num); $i++) {
  4591. $this->whlabel->remove($data[$i]['id']);
  4592. }
  4593. }
  4594. } else if ($num > 0) //增加库存
  4595. {
  4596. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4597. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4598. $j++;
  4599. continue;
  4600. }
  4601. $post['sku'] = $d['sku'];
  4602. $post['shop'] = $d['shop'];
  4603. $post['warehouse'] = $warehouse['id'];
  4604. $post['purchase'] = $purchase['id'];
  4605. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4606. $post['state'] = 0;
  4607. $post['title'] = $d['title'];
  4608. $post['number'] = $d['number'];
  4609. $post['features'] = $d['features'];
  4610. $post['enter'] = $time;
  4611. $post['time'] = $time; //操作时间
  4612. $post['rktype'] = $rktype;
  4613. $post['sku_master_id'] = $d['sku_master_id'];
  4614. $post['sku_shop_id'] = $d['sku_shop_id'];
  4615. for ($i = 0; $i < $num; $i++) {
  4616. $post['label'] = time() . rand(100, 999) . $i;
  4617. $this->whlabel->insert($post);
  4618. }
  4619. }
  4620. sleep(1); //防止入库时间一样,需要延迟1秒
  4621. }
  4622. if ($j > 0) {
  4623. $tt = date('Ymd', time());
  4624. $title = '库存导入错误信息-' . $tt;
  4625. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4626. $tail = "\n";
  4627. $filename = $title . ".xls";
  4628. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4629. $dir = '/data/excel/' . $time . '/';
  4630. $file_name = 'error_' . $time . rand(1000, 9999);
  4631. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4632. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4633. fwrite($myfile, $ecl);
  4634. fclose($myfile);
  4635. $error = $dir . $file_name . '.xls';
  4636. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4637. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4638. exit;
  4639. } else {
  4640. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4641. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4642. exit;
  4643. }
  4644. }
  4645. //笛卡儿积
  4646. function cp($ps, $sets, $list)
  4647. {
  4648. $result = array();
  4649. $j = 0;
  4650. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4651. if ($i == 0) {
  4652. $result = $sets[$i];
  4653. }
  4654. $tmp = array();
  4655. foreach ($result as $res) {
  4656. foreach ($sets[$i + 1] as $set) {
  4657. $tmp[] = $res . ',' . $set;
  4658. }
  4659. }
  4660. $result = $tmp;
  4661. }
  4662. $this->db->trans_begin();
  4663. foreach ($result as $v) {
  4664. $post = array();
  4665. $title = "";
  4666. $num = "";
  4667. $data = explode(',', $v);
  4668. for ($i = 0; $i < count($list); $i++) {
  4669. $post[$list[$i]] = $data[$i];
  4670. $typeclass = $this->typeclass->read($data[$i]);
  4671. $title = $title . $typeclass['title'] . " ";
  4672. if ($data[$i] != 0) {
  4673. $num .= $data[$i]; //所有数据ID拼接
  4674. }
  4675. }
  4676. foreach ($ps as $kp => $vp) {
  4677. $post[$kp] = $vp;
  4678. }
  4679. $post['number'] = $num;
  4680. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4681. if ($info_list) {
  4682. $j++;
  4683. } else {
  4684. $skunum = $this->whlabel->find_count();
  4685. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4686. $post['title'] = rtrim($title, ' ');
  4687. $this->whlabel->insert($post);
  4688. }
  4689. }
  4690. if ($this->db->trans_status() === FALSE) {
  4691. $this->db->trans_commit();
  4692. return NULL;
  4693. } else {
  4694. $this->db->trans_commit();
  4695. return $j;
  4696. }
  4697. }
  4698. public function _kj($arg_array)
  4699. {
  4700. if (isset($_POST['sku'])) {
  4701. $time = time();
  4702. $sku = $this->input->post('sku', true);
  4703. $warehouse = $this->input->post('warehouse', true);
  4704. $num = $this->input->post('num', true);
  4705. $text = $this->input->post('text', true);
  4706. $purchase = $this->input->post('purchase', true);
  4707. $cktype = $this->input->post('cktype', true);
  4708. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4709. if ($cktype != 1 && $text == '') {
  4710. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4711. exit;
  4712. }
  4713. if ($num > count($order)) {
  4714. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4715. exit;
  4716. } else {
  4717. for ($i = 0; $i < $num; $i++) {
  4718. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4719. }
  4720. }
  4721. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4722. exit;
  4723. }
  4724. $uid = $this->whlabel->read($arg_array[0]);
  4725. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4726. $this->data['data'] = $uid;
  4727. $this->_Template('whlabel_kj', $this->data);
  4728. }
  4729. public function _summary($arg_array)
  4730. {
  4731. $prc = array();
  4732. $purchase = $this->purchase->find_all();
  4733. foreach ($purchase as $k => $v) {
  4734. $prc[$v['id']] = $v['title'];
  4735. }
  4736. if (isset($_GET['excel'])) {
  4737. $ktime = $this->input->get('ktime', true);
  4738. $jtime = $this->input->get('jtime', true);
  4739. $ktime = strtotime($ktime);
  4740. $jtime = strtotime($jtime);
  4741. $where = "1=1";
  4742. if ($ktime && $jtime) {
  4743. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4744. }
  4745. //数据排序
  4746. $order_str = "time desc";
  4747. if (empty($page)) {
  4748. $start = 0;
  4749. $perpage = 1;
  4750. } else {
  4751. $start = ($page - 1) * $perpage;
  4752. }
  4753. //取得信息列表
  4754. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4755. foreach ($info_list as $key => $value) {
  4756. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4757. $warehouse = $this->warehouse->read($value['warehouse']);
  4758. $info_list[$key]['warehouse'] = $warehouse['title'];
  4759. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4760. $details = array();
  4761. $cpid = array();
  4762. foreach ($x as $k => $v) {
  4763. if ($v['details'] != '') {
  4764. $details[$v['details']] = $v['details'];
  4765. }
  4766. if ($v['cpid'] != 0) {
  4767. $cpid[$v['cpid']] = $v['cpid'];
  4768. }
  4769. }
  4770. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4771. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4772. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4773. $info_list[$key]['s'] = $s;
  4774. $info_list[$key]['x'] = count($x);
  4775. }
  4776. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4777. $titlename = "<table border=1>
  4778. <tr align='center'>
  4779. <td>仓库</td>
  4780. <td>供应商</td>
  4781. <td>出库位置</td>
  4782. <td>出库编码</td>
  4783. <td>SKU</td>
  4784. <td>产品名</td>
  4785. <td>总剩余库存</td>
  4786. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4787. </tr>
  4788. </table>";
  4789. $filename = $title . ".xls";
  4790. $tail = "";
  4791. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4792. }
  4793. }
  4794. //usps发货清单
  4795. public function _manifest()
  4796. {
  4797. if (isset($_POST['manifest'])) {
  4798. $wltext = $this->input->post('wltext', true);
  4799. $time = time() - 16 * 3600;
  4800. $ptime = strtotime(date('Y-m-d', $time));
  4801. $waybill = array();
  4802. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4803. foreach ($fullorder as $v) {
  4804. $waybill[$v['waybill']] = $v['waybill'];
  4805. }
  4806. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4807. foreach ($fullordersmt as $v) {
  4808. $waybill[$v['waybill']] = $v['waybill'];
  4809. }
  4810. $wltext = explode(';', $wltext);
  4811. foreach ($wltext as $v) {
  4812. if (isset($waybill[$v])) {
  4813. unset($waybill[$v]);
  4814. }
  4815. }
  4816. $data = $this->usps->get_manifest($waybill);
  4817. if (isset($data['Description'])) {
  4818. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4819. exit;
  4820. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4821. $bctime = date('Ymd', time());
  4822. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4823. echo json_encode(array('msg' => $pdf, 'success' => true));
  4824. exit;
  4825. } else {
  4826. echo json_encode(array('msg' => $data, 'success' => false));
  4827. exit;
  4828. }
  4829. }
  4830. }
  4831. public function _pdf($pdf, $title, $bctime)
  4832. {
  4833. $pdf_path = './data/pdf/' . $bctime . '/';
  4834. $file_base64 = $pdf;
  4835. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4836. $file_base64 = base64_decode($file_base64);
  4837. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4838. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4839. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4840. }
  4841. /**
  4842. *
  4843. *
  4844. *
  4845. 进销存占单异常索引
  4846. *
  4847. *
  4848. *
  4849. **/
  4850. public function _abnormal()
  4851. {
  4852. $post = $this->input->post(NULL, TRUE);
  4853. if (isset($post['page'])) {
  4854. $page = $this->input->post('page', true);
  4855. $perpage = $this->input->post('perpage', true);
  4856. $sku = $this->input->post('sku', true);
  4857. $where = "1=1";
  4858. //数据排序
  4859. $order_str = "id desc";
  4860. if (empty($page)) {
  4861. $start = 0;
  4862. $perpage = 1;
  4863. } else {
  4864. $start = ($page - 1) * $perpage;
  4865. }
  4866. //取得信息列表
  4867. $info_list = $this->whlabel->find_all($where, '*');
  4868. $rows = array();
  4869. $list = array();
  4870. foreach ($info_list as $key => $value) {
  4871. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4872. }
  4873. foreach ($rows as $value) {
  4874. $warehouse = $this->warehouse->read($value['warehouse']);
  4875. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4876. $number = $value['number'];
  4877. $ftime = time() - 15 * 24 * 3600;
  4878. if ($value['shop'] != '') {
  4879. $shop = $value['shop'];
  4880. $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');
  4881. $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');
  4882. $order = array_merge($orderdlz, $ordersmt);
  4883. $od = 0;
  4884. $a = '';
  4885. $orid = '';
  4886. foreach ($order as $v) {
  4887. $or = explode('|', ltrim($v['whlabel'], '|'));
  4888. for ($i = 0; $i < count($or); $i++) {
  4889. $orod = explode('-', $or[$i]);
  4890. if ($orod[0] == $number) {
  4891. $od += $orod[1];
  4892. }
  4893. }
  4894. $orid .= $v['number'] . '-';
  4895. }
  4896. } else {
  4897. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4898. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4899. $order = array_merge($orderdlz, $ordersmt);
  4900. $od = 0;
  4901. $a = '';
  4902. $orid = '';
  4903. $qt = array();
  4904. foreach ($order as $v) {
  4905. $or = explode('|', ltrim($v['whlabel'], '|'));
  4906. for ($i = 0; $i < count($or); $i++) {
  4907. $orod = explode('-', $or[$i]);
  4908. if ($orod[0] == $number) {
  4909. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4910. if ($czzs > 0) {
  4911. if (isset($qt[$v['shop']])) {
  4912. if ($qt[$v['shop']] < $orod[1]) {
  4913. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4914. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4915. } else {
  4916. $qt[$v['shop']] -= $orod[1];
  4917. }
  4918. } else {
  4919. $qt[$v['shop']] = $czzs;
  4920. }
  4921. } else {
  4922. $od += $orod[1];
  4923. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4924. }
  4925. }
  4926. }
  4927. }
  4928. }
  4929. $z = $od . '(' . $orid . ')'; //查看订单号
  4930. //$z = $od;
  4931. if ($od > $c) {
  4932. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4933. }
  4934. }
  4935. $listdata = array_slice($list, $start, $perpage);
  4936. $total = count($list);
  4937. $pagenum = ceil($total / $perpage);
  4938. $over = $total - ($start + $perpage);
  4939. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4940. echo json_encode($rows);
  4941. exit;
  4942. }
  4943. $this->_Template('whlabel_abnormal', $this->data);
  4944. }
  4945. /**
  4946. *
  4947. *
  4948. *
  4949. 进销存占单异常索引
  4950. *
  4951. *
  4952. *
  4953. **/
  4954. public function _error()
  4955. {
  4956. $post = $this->input->post(NULL, TRUE);
  4957. if (isset($post['page'])) {
  4958. $page = $this->input->post('page', true);
  4959. $perpage = $this->input->post('perpage', true);
  4960. $sku = $this->input->post('sku', true);
  4961. $warehouse = $this->input->post('warehouse', true);
  4962. $ktime = $this->input->post('ktime', true);
  4963. $jtime = $this->input->post('jtime', true);
  4964. $ktime = strtotime($ktime);
  4965. $jtime = strtotime($jtime);
  4966. $where = "sku != 'Preset'";
  4967. $gj = '';
  4968. if ($sku) {
  4969. $where .= " and sku like '%$sku%'";
  4970. } else {
  4971. if ($ktime && $jtime) {
  4972. $gj = " and time > '$ktime' and time < '$jtime'";
  4973. }
  4974. }
  4975. if ($warehouse) {
  4976. $where .= " and warehouse = '$warehouse'";
  4977. }
  4978. //数据排序
  4979. $order_str = "id desc";
  4980. if (empty($page)) {
  4981. $start = 0;
  4982. $perpage = 1;
  4983. } else {
  4984. $start = ($page - 1) * $perpage;
  4985. }
  4986. //取得信息列表
  4987. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4988. $rows = array();
  4989. $list = array();
  4990. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4991. // foreach ($info_list as $value)
  4992. // {
  4993. // $warehouse = $this->warehouse->read($value['warehouse']);
  4994. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4995. // $number = $value['number'];$ftime = time()-15*24*3600;
  4996. // if($c < 1)
  4997. // {
  4998. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4999. // }
  5000. // }
  5001. $warehouse_list = $this->warehouse->find_all();
  5002. $warehouse_list = array_column($warehouse_list, null, 'id');
  5003. foreach ($info_list as $value) {
  5004. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5005. 'title' => "",
  5006. ];
  5007. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5008. $number = $value['number'];
  5009. $ftime = time() - 15 * 24 * 3600;
  5010. if ($c < 1) {
  5011. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5012. }
  5013. }
  5014. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5015. // $query = $this->db->query($sql);
  5016. // $info_list = $query->result_array();
  5017. // $sql_two = "select title,id from crowd_warehouse";
  5018. // $query_two = $this->db->query($sql_two);
  5019. // $warehouse_list = $query_two->result_array();
  5020. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5021. // foreach ($info_list as $value)
  5022. // {
  5023. // if(isset($warehouse_arr[$value['warehouse']])){
  5024. // $warehouse = $warehouse_arr[$value['warehouse']];
  5025. // }else{
  5026. // $warehouse = [
  5027. // 'id'=>0,
  5028. // 'title'=>"异常",
  5029. // ];
  5030. // }
  5031. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5032. // $number = $value['number'];$ftime = time()-15*24*3600;
  5033. // if($c < 1)
  5034. // {
  5035. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5036. // }
  5037. // }
  5038. $listdata = array_slice($list, $start, $perpage);
  5039. $total = count($list);
  5040. $pagenum = ceil($total / $perpage);
  5041. $over = $total - ($start + $perpage);
  5042. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5043. echo json_encode($rows);
  5044. exit;
  5045. }
  5046. if (isset($post['s'])) {
  5047. $id_arr = $this->input->post('s');
  5048. $id_arr = explode(',', trim($id_arr, ','));
  5049. if (!$id_arr) {
  5050. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5051. exit;
  5052. }
  5053. //循环删除记录
  5054. foreach ($id_arr as $v) {
  5055. $dd = $this->whlabel->read($v);
  5056. if (!isset($dd['id'])) {
  5057. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5058. exit;
  5059. }
  5060. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5061. if (isset($zt[0])) {
  5062. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5063. exit;
  5064. }
  5065. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5066. foreach ($deldd as $vv) {
  5067. $this->whlabel->remove($vv['id']);
  5068. }
  5069. }
  5070. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5071. exit;
  5072. }
  5073. $this->_Template('whlabel_error', $this->data);
  5074. }
  5075. public function _errorexcel()
  5076. {
  5077. $post = $this->input->post(NULL, TRUE);
  5078. if (isset($_GET['page'])) {
  5079. $page = $this->input->get('page', true);
  5080. $perpage = $this->input->get('perpage', true);
  5081. $sku = $this->input->get('sku', true);
  5082. $warehouse = $this->input->get('warehouse', true);
  5083. $ktime = $this->input->get('ktime', true);
  5084. $jtime = $this->input->get('jtime', true);
  5085. $ktime = strtotime($ktime);
  5086. $jtime = strtotime($jtime);
  5087. $where = "sku != 'Preset'";
  5088. $gj = '';
  5089. if ($sku) {
  5090. $where .= " and sku like '%$sku%'";
  5091. } else {
  5092. if ($ktime && $jtime) {
  5093. $gj = " and time > '$ktime' and time < '$jtime'";
  5094. }
  5095. }
  5096. if ($warehouse) {
  5097. $where .= " and warehouse = '$warehouse'";
  5098. }
  5099. //数据排序
  5100. $order_str = "id desc";
  5101. if (empty($page)) {
  5102. $start = 0;
  5103. $perpage = 1;
  5104. } else {
  5105. $start = ($page - 1) * $perpage;
  5106. }
  5107. //取得信息列表
  5108. $rows = array();
  5109. $list = array();
  5110. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5111. foreach ($info_list as $value) {
  5112. $warehouse = $this->warehouse->read($value['warehouse']);
  5113. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5114. $number = $value['number'];
  5115. $ftime = time() - 15 * 24 * 3600;
  5116. if ($c < 1) {
  5117. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5118. }
  5119. }
  5120. $title = "0库存汇总";
  5121. $titlename = "<table border=1>
  5122. <tr align='center'>
  5123. <td>仓库</td>
  5124. <td>SKU</td>
  5125. <td>产品</td>
  5126. <td>当前库存</td>
  5127. </tr>
  5128. </table>";
  5129. $filename = $title . ".xls";
  5130. $tail = "";
  5131. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5132. }
  5133. }
  5134. /**
  5135. *
  5136. *
  5137. * 占单
  5138. *
  5139. *
  5140. **/
  5141. public function _kcyz()
  5142. {
  5143. $post = $this->input->post(NULL, TRUE);
  5144. if (isset($post['warehouse'])) {
  5145. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5146. exit; //不再使用
  5147. $warehouse = $this->input->post('warehouse', true);
  5148. $whlabel = $this->input->post('whlabel', true);
  5149. $id = $this->input->post('id', true);
  5150. $shop = $this->input->post('shop', true);
  5151. $number = $this->input->post('number', true);
  5152. if (!$whlabel || $whlabel == '|') {
  5153. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5154. exit;
  5155. }
  5156. $pp = explode('|', trim($whlabel, '|'));
  5157. $x = 0;
  5158. $save = array();
  5159. foreach ($pp as $va) {
  5160. $num = explode('-', $va);
  5161. if ($number) {
  5162. $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 = '')"); //通用
  5163. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5164. } else {
  5165. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5166. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5167. }
  5168. $x++;
  5169. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5170. $save[] = $x - 1;
  5171. continue; //提前先加X不然出错,所以要减1
  5172. }
  5173. }
  5174. if (isset($save[0])) {
  5175. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5176. exit;
  5177. } else {
  5178. echo json_encode(array('success' => true));
  5179. exit;
  5180. }
  5181. }
  5182. }
  5183. public function _db()
  5184. {
  5185. $post = $this->input->post(NULL, TRUE);
  5186. if (isset($post['page'])) {
  5187. $page = $this->input->post('page', true);
  5188. $perpage = $this->input->post('perpage', true);
  5189. $sku = $this->input->post('sku', true);
  5190. $number = $this->input->post('number', true);
  5191. $warehouse = $this->input->post('warehouse', true);
  5192. $purchase = $this->input->post('purchase', true);
  5193. $orderinfo = $this->input->post('orderinfo', true);
  5194. $waybill = $this->input->post('waybill', true);
  5195. $category = $this->input->post('category', true);
  5196. $size = $this->input->post('size', true);
  5197. $grade = $this->input->post('grade', true);
  5198. $color = $this->input->post('color', true);
  5199. $lowe = $this->input->post('lowe', true);
  5200. $state = $this->input->post('state', true);
  5201. $label = $this->input->post('label', true);
  5202. $timetk = $this->input->post('timetkk', true);
  5203. $timetj = $this->input->post('timetjj', true);
  5204. $timetk = strtotime($timetk);
  5205. $timetj = strtotime($timetj);
  5206. $where = "dbtime > 0";
  5207. if ($timetk && $timetj) {
  5208. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5209. }
  5210. if ($sku) {
  5211. $where .= " and sku = '$sku'";
  5212. }
  5213. if ($warehouse) {
  5214. $where .= " and warehouse = '$warehouse'";
  5215. if ($warehouse == 12) {
  5216. $w = 'specialstock';
  5217. } else {
  5218. $w = 'whlabel';
  5219. }
  5220. }
  5221. if ($purchase) {
  5222. $where .= " and purchase = '$purchase'";
  5223. }
  5224. if ($category) {
  5225. $where .= " and features like '%-$category-%'";
  5226. }
  5227. if ($size) {
  5228. $where .= " and features like '%-$size-%'";
  5229. }
  5230. if ($grade) {
  5231. $where .= " and features like '%-$grade-%'";
  5232. }
  5233. if ($color) {
  5234. $where .= " and features like '%-$color-%'";
  5235. }
  5236. if ($lowe) {
  5237. $where .= " and features like '%-$lowe-%'";
  5238. }
  5239. if ($state != '') {
  5240. $where .= " and state = '$state'";
  5241. }
  5242. //数据排序
  5243. $order_str = "dbtime desc";
  5244. if (empty($page)) {
  5245. $start = 0;
  5246. $perpage = 1;
  5247. } else {
  5248. $start = ($page - 1) * $perpage;
  5249. }
  5250. //取得信息列表
  5251. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5252. foreach ($info_list as $key => $value) {
  5253. $warehouse = $this->$w->read($value['warehouse']);
  5254. $info_list[$key]['warehouse'] = $warehouse['title'];
  5255. $purchase = $this->purchase->read($value['purchase']);
  5256. $info_list[$key]['purchase'] = $purchase['title'];
  5257. if ($value['enter'] != 0) {
  5258. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5259. } else {
  5260. $info_list[$key]['enter'] = "";
  5261. }
  5262. if ($value['dbtime'] != 0) {
  5263. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5264. } else {
  5265. $info_list[$key]['dbtime'] = "";
  5266. }
  5267. if ($value['state'] == 0) {
  5268. $info_list[$key]['state'] = "在库";
  5269. } else if ($value['state'] == 1) {
  5270. $info_list[$key]['state'] = "出库";
  5271. } else if ($value['state'] == 2) {
  5272. $info_list[$key]['state'] = "退库";
  5273. } else if ($value['state'] == 3) {
  5274. $info_list[$key]['state'] = "调拨中";
  5275. } else if ($value['state'] == 4) {
  5276. $info_list[$key]['state'] = "再加工";
  5277. } else if ($value['state'] == 5) {
  5278. $info_list[$key]['state'] = "维修中";
  5279. } else if ($value['state'] == 6) {
  5280. $info_list[$key]['state'] = "盘亏";
  5281. } else if ($value['state'] == 7) {
  5282. $info_list[$key]['state'] = "更换标签";
  5283. } else if ($value['state'] == 8) {
  5284. $info_list[$key]['state'] = "其它";
  5285. } else if ($value['state'] == 9) {
  5286. $info_list[$key]['state'] = "预设";
  5287. }
  5288. }
  5289. $total = $this->whlabel->find_count($where);
  5290. $pagenum = ceil($total / $perpage);
  5291. $over = $total - ($start + $perpage);
  5292. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5293. echo json_encode($rows);
  5294. exit;
  5295. }
  5296. if (isset($post['outsku'])) {
  5297. $time = time();
  5298. $cz = $this->input->post('cz', true);
  5299. $label = $this->input->post('outsku', true);
  5300. $sl = $this->input->post('sl', true);
  5301. $num = $this->input->post('num', true);
  5302. //$warehouse = $this->input->post('warehouse',true);
  5303. if (!$sl) {
  5304. $sl = 1;
  5305. }
  5306. if (!$warehouse) {
  5307. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5308. exit;
  5309. }
  5310. $dblabel = $this->whlabellabel->get_label($label);
  5311. if ($dblabel) {
  5312. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5313. if (count($data) < 1) {
  5314. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5315. exit;
  5316. }
  5317. if (count($data) < $num) {
  5318. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5319. exit;
  5320. }
  5321. for ($i = 0; $i < $sl; $i++) {
  5322. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5323. }
  5324. echo json_encode(array('success' => true));
  5325. exit;
  5326. } else {
  5327. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5328. exit;
  5329. }
  5330. }
  5331. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5332. $this->_Template('whlabel_db', $this->data);
  5333. }
  5334. public function _dbrk()
  5335. {
  5336. $post = $this->input->post(NULL, TRUE);
  5337. if (isset($post['page'])) {
  5338. $page = $this->input->post('page', true);
  5339. $perpage = $this->input->post('perpage', true);
  5340. $sku = $this->input->post('sku', true);
  5341. $number = $this->input->post('number', true);
  5342. $warehouse = $this->input->post('warehouse', true);
  5343. $purchase = $this->input->post('purchase', true);
  5344. $orderinfo = $this->input->post('orderinfo', true);
  5345. $waybill = $this->input->post('waybill', true);
  5346. $category = $this->input->post('category', true);
  5347. $size = $this->input->post('size', true);
  5348. $grade = $this->input->post('grade', true);
  5349. $color = $this->input->post('color', true);
  5350. $lowe = $this->input->post('lowe', true);
  5351. $state = $this->input->post('state', true);
  5352. $label = $this->input->post('label', true);
  5353. $ctime = $this->input->post('ctime', true);
  5354. $timetk = $this->input->post('timetkk', true);
  5355. $timetj = $this->input->post('timetjj', true);
  5356. $timetk = strtotime($timetk);
  5357. $timetj = strtotime($timetj);
  5358. $where = "dbtime > 0";
  5359. if ($timetk && $timetj) {
  5360. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5361. }
  5362. if ($sku) {
  5363. $where .= " and sku = '$sku'";
  5364. }
  5365. if ($warehouse) {
  5366. $where .= " and warehouse = '$warehouse'";
  5367. }
  5368. if ($purchase) {
  5369. $where .= " and purchase = '$purchase'";
  5370. }
  5371. if ($category) {
  5372. $where .= " and features like '%-$category-%'";
  5373. }
  5374. if ($size) {
  5375. $where .= " and features like '%-$size-%'";
  5376. }
  5377. if ($grade) {
  5378. $where .= " and features like '%-$grade-%'";
  5379. }
  5380. if ($color) {
  5381. $where .= " and features like '%-$color-%'";
  5382. }
  5383. if ($lowe) {
  5384. $where .= " and features like '%-$lowe-%'";
  5385. }
  5386. if ($state != '') {
  5387. $where .= " and state = '$state'";
  5388. }
  5389. //数据排序
  5390. $order_str = "dbtime desc";
  5391. if (empty($page)) {
  5392. $start = 0;
  5393. $perpage = 1;
  5394. } else {
  5395. $start = ($page - 1) * $perpage;
  5396. }
  5397. //取得信息列表
  5398. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5399. foreach ($info_list as $key => $value) {
  5400. $warehouse = $this->warehouse->read($value['warehouse']);
  5401. $info_list[$key]['warehouse'] = $warehouse['title'];
  5402. $purchase = $this->purchase->read($value['purchase']);
  5403. $info_list[$key]['purchase'] = $purchase['title'];
  5404. if ($value['enter'] != 0) {
  5405. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5406. } else {
  5407. $info_list[$key]['enter'] = "";
  5408. }
  5409. if ($value['dbtime'] != 0) {
  5410. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5411. } else {
  5412. $info_list[$key]['dbtime'] = "";
  5413. }
  5414. if ($value['state'] == 0) {
  5415. $info_list[$key]['state'] = "在库";
  5416. } else if ($value['state'] == 1) {
  5417. $info_list[$key]['state'] = "出库";
  5418. } else if ($value['state'] == 2) {
  5419. $info_list[$key]['state'] = "退库";
  5420. } else if ($value['state'] == 3) {
  5421. $info_list[$key]['state'] = "调拨中";
  5422. } else if ($value['state'] == 4) {
  5423. $info_list[$key]['state'] = "再加工";
  5424. } else if ($value['state'] == 5) {
  5425. $info_list[$key]['state'] = "维修中";
  5426. } else if ($value['state'] == 6) {
  5427. $info_list[$key]['state'] = "盘亏";
  5428. } else if ($value['state'] == 7) {
  5429. $info_list[$key]['state'] = "更换标签";
  5430. } else if ($value['state'] == 8) {
  5431. $info_list[$key]['state'] = "其它";
  5432. } else if ($value['state'] == 9) {
  5433. $info_list[$key]['state'] = "预设";
  5434. }
  5435. }
  5436. $total = $this->whlabel->find_count($where);
  5437. $pagenum = ceil($total / $perpage);
  5438. $over = $total - ($start + $perpage);
  5439. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5440. echo json_encode($rows);
  5441. exit;
  5442. }
  5443. if (isset($post['rsku'])) {
  5444. $cz = $this->input->post('cz', true);
  5445. $label = $this->input->post('rsku', true);
  5446. $sl = $this->input->post('sl', true);
  5447. $warehouse = $this->input->post('warehouse', true);
  5448. if (!$sl) {
  5449. $sl = 1;
  5450. }
  5451. if (!$warehouse) {
  5452. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5453. exit;
  5454. }
  5455. $dblabel = $this->whlabellabel->get_label($label);
  5456. if ($dblabel) {
  5457. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5458. if (count($data) < 1) {
  5459. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5460. exit;
  5461. }
  5462. if ($sl > count($data)) {
  5463. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5464. exit;
  5465. }
  5466. $time = time();
  5467. for ($i = 0; $i < $sl; $i++) {
  5468. $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']);
  5469. }
  5470. echo json_encode(array('success' => true));
  5471. exit;
  5472. } else {
  5473. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5474. exit;
  5475. }
  5476. }
  5477. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5478. $this->_Template('whlabel_dbrk', $this->data);
  5479. }
  5480. public function _whlabelczdc()
  5481. {
  5482. if (isset($_GET['excel'])) {
  5483. //数据排序
  5484. $order_str = "id desc";
  5485. if (empty($page)) {
  5486. $start = 0;
  5487. $perpage = 1;
  5488. } else {
  5489. $start = ($page - 1) * $perpage;
  5490. }
  5491. $state = $this->input->get('state', true);
  5492. $sku = $this->input->get('sku', true);
  5493. $ctime = $this->input->get('ctime', true);
  5494. $category = $this->input->get('category', true);
  5495. $size = $this->input->get('size', true);
  5496. $grade = $this->input->get('grade', true);
  5497. $color = $this->input->get('color', true);
  5498. $lowe = $this->input->get('lowe', true);
  5499. $timetk = $this->input->get('timetkk', true);
  5500. $timetj = $this->input->get('timetjj', true);
  5501. $timetk = strtotime($timetk);
  5502. $timetj = strtotime($timetj);
  5503. $where = "dbtime > 0";
  5504. if ($timetk && $timetj) {
  5505. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5506. }
  5507. if ($category) {
  5508. $where .= " and features like '%-$category-%'";
  5509. }
  5510. if ($size) {
  5511. $where .= " and features like '%-$size-%'";
  5512. }
  5513. if ($grade) {
  5514. $where .= " and features like '%-$grade-%'";
  5515. }
  5516. if ($color) {
  5517. $where .= " and features like '%-$color-%'";
  5518. }
  5519. if ($lowe) {
  5520. $where .= " and features like '%-$lowe-%'";
  5521. }
  5522. //取得信息列表
  5523. $info_list = $this->whlabel->find_all($where, '*');
  5524. $rows = array();
  5525. $list = array();
  5526. foreach ($info_list as $key => $value) {
  5527. $rows[$value['sku']] = $value; //所有数据sku
  5528. }
  5529. foreach ($rows as $value) {
  5530. $warehouse = $this->warehouse->read($value['warehouse']);
  5531. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5532. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5533. if ($value['orderinfo'] == 0) {
  5534. $info_list[$key]['orderinfo'] = "";
  5535. }
  5536. if ($value['waybill'] == 0) {
  5537. $info_list[$key]['waybill'] = "";
  5538. }
  5539. if ($value['state'] == 0) {
  5540. $value['state'] = "在库";
  5541. } else if ($value['state'] == 3) {
  5542. $value['state'] = "调拨中";
  5543. }
  5544. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5545. }
  5546. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5547. $titlename = "<table border=1>
  5548. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5549. <tr align='center'>
  5550. <td>SKU</td>
  5551. <td>产品</td>
  5552. <td>调拨数量</td>
  5553. <td>入库数量</td>
  5554. </tr>
  5555. </table>";
  5556. $filename = $title . ".xls";
  5557. $tail = "";
  5558. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5559. }
  5560. }
  5561. public function _print($arg_array)
  5562. {
  5563. if (isset($_SESSION['api'])) {
  5564. $user = $this->user->get_api($_SESSION['api']);
  5565. $usp = $user;
  5566. $fgshop = "";
  5567. $sid = "";
  5568. $wid = "";
  5569. $wtype = "";
  5570. $usersp = explode('|', trim($user['shop'], '|'));
  5571. $userwh = explode('|', trim($user['warehouse'], '|'));
  5572. foreach ($usersp as $value) {
  5573. $fgshop .= " shop = " . $value . " or";
  5574. $sid .= " id = " . $value . " or";
  5575. }
  5576. foreach ($userwh as $value) {
  5577. $wid .= " id = " . $value . " or";
  5578. $wtype .= " type = " . $value . " or";
  5579. }
  5580. }
  5581. $post = $this->input->post(NULL, TRUE);
  5582. if (isset($post['tmsku'])) {
  5583. $tmsku = $this->input->post('tmsku', true);
  5584. if (is_numeric($tmsku)) {
  5585. $yyh = $this->whlabellabel->get_label($tmsku);
  5586. } else {
  5587. $yyh = $this->whlabellabel->get_sku($tmsku);
  5588. if(empty($yyh)){
  5589. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  5590. if($r['code'] == -1 ){
  5591. echo json_encode(array('success' => false));
  5592. exit;
  5593. }else{
  5594. echo json_encode(array('features' => $r['data'], 'success' => true));
  5595. exit;
  5596. }
  5597. }
  5598. }
  5599. if ($yyh) {
  5600. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5601. exit;
  5602. } else {
  5603. echo json_encode(array('success' => false));
  5604. exit;
  5605. }
  5606. }
  5607. $classid = $this->classid->sku();
  5608. $pm = $classid;
  5609. $scsku = $classid;
  5610. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5611. if (isset($post['warehouse'])) {
  5612. if ($post['warehouse']) {
  5613. $list = array();
  5614. $num = "";
  5615. $title = "";
  5616. $features = "";
  5617. $order = 0;
  5618. $post['shop'] = '';
  5619. $brand = $this->input->post('brand', true);
  5620. if ($brand != '0,') {
  5621. $b = $this->brand->read(rtrim($brand, ','));
  5622. if ($b) {
  5623. $post['shop'] = str_replace('|', ',', $b['shop']);
  5624. }
  5625. }
  5626. $post['details'] = $this->input->post('details', true); //打印数量
  5627. $xbqnum = $this->input->post('xbqnum', true);
  5628. $post['purchase'] = $this->input->post('purchase', true);
  5629. $post['warehouse'] = $this->input->post('warehouse', true);
  5630. $post['purchase'] = $this->input->post('purchase', true);
  5631. $post['retreatwarehouse'] = $post['warehouse'];
  5632. $post['cpbz'] = $this->input->post('cpbz', true);
  5633. $post['state'] = 9;
  5634. $category = $this->input->post('category', true);
  5635. $list['category'] = $category;
  5636. $list['hairtype'] = $this->input->post('hairtype', true);
  5637. $list['grade'] = $this->input->post('grade', true);
  5638. $size = $this->input->post('size', true);
  5639. $list['size'] = rtrim($size, ',');
  5640. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5641. $list['extension'] = $this->input->post('extension', true);
  5642. if ($category == 1297) {
  5643. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5644. }
  5645. if ($category == 1702) {
  5646. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5647. $list['syother'] = $this->input->post('syother', true);
  5648. }
  5649. if ($category == 133) {
  5650. $list['fittype'] = $this->input->post('fittype', true);
  5651. $list['acother'] = $this->input->post('acother', true);
  5652. }
  5653. $list['color'] = $this->input->post('color', true);
  5654. $list['lowe'] = $this->input->post('lowe', true);
  5655. if ($category == 127) {
  5656. $list['type'] = $this->input->post('type', true);
  5657. $list['headroad'] = $this->input->post('headroad', true);
  5658. $list['density'] = $this->input->post('density', true);
  5659. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5660. $list['lacesize'] = $this->input->post('lacesize', true);
  5661. }
  5662. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5663. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5664. }
  5665. if ($category == 128) {
  5666. $list['lacetype'] = $this->input->post('lacetype', true);
  5667. $list['haircap'] = $this->input->post('haircap', true);
  5668. $list['density'] = $this->input->post('density', true);
  5669. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5670. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5671. $list['wigother'] = $this->input->post('wigother', true);
  5672. $list['wigother1'] = $this->input->post('wigother1', true);
  5673. $list['wigother2'] = $this->input->post('wigother2', true);
  5674. }
  5675. if ($category == 129) {
  5676. $list['wide'] = $this->input->post('wide', true);
  5677. }
  5678. if ($category == 131) {
  5679. $list['gifttype'] = $this->input->post('gifttype', true);
  5680. $list['giftother'] = $this->input->post('giftother', true);
  5681. }
  5682. if ($category == 134) {
  5683. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5684. }
  5685. if ($category == 1297) {
  5686. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5687. $list['sywigother'] = $this->input->post('sywigother', true);
  5688. }
  5689. if ($category == 130 || $category == 133 || $category == 1702) {
  5690. $list['items'] = $this->input->post('items', true);
  5691. $list['weight'] = $this->input->post('weight', true);
  5692. }
  5693. if ($category == 1702) {
  5694. $list['syhairther'] = $this->input->post('syhairther', true);
  5695. }
  5696. foreach ($list as $k => $v) {
  5697. if ($v != 0) {
  5698. $num .= $v;
  5699. $features .= $v . '-';
  5700. $post[$k] = $v;
  5701. $typeclass = $this->typeclass->read($v);
  5702. if (isset($pm[$typeclass['classid']])) {
  5703. if (stripos($typeclass['zh'], '|') !== false) {
  5704. $exzh = explode('|', $typeclass['zh']);
  5705. $pm[$typeclass['classid']] = $exzh[0];
  5706. } else {
  5707. $pm[$typeclass['classid']] = $typeclass['zh'];
  5708. }
  5709. }
  5710. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5711. if ($k != 'size') {
  5712. $title .= $typeclass['title'] . " ";
  5713. }
  5714. }
  5715. }
  5716. $typeclass = $this->typeclass->read($list['size']);
  5717. $title .= $typeclass['title'];
  5718. $time = time();
  5719. $post['title'] = rtrim($title, ' ');
  5720. $post['number'] = $num;
  5721. $post['features'] = '-' . $features;
  5722. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5723. $featurespp = explode('-', trim($featurespp, '-'));
  5724. if (isset($featurespp[5])) {
  5725. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5726. } else {
  5727. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5728. }
  5729. $post['enter'] = $time;
  5730. $post['time'] = $time; //操作时间
  5731. $scsku = implode("-", $scsku);
  5732. $zh = implode(" ", $pm);
  5733. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5734. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5735. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5736. $post['sku'] = $bqsku;
  5737. $label = time() . rand(0, 9);
  5738. $post['label'] = $label;
  5739. $cpid = $this->whlabellabel->find_count();
  5740. $post['cpid'] = $cpid + 1;
  5741. $cpid = $post['cpid'];
  5742. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5743. //if($whlabelbarcode)
  5744. //{
  5745. //$post['label'] = $whlabelbarcode['label'];
  5746. //if(!$this->whlabellabel->insert($post))
  5747. //{
  5748. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5749. //}
  5750. //}
  5751. //else
  5752. //{
  5753. $this->db->trans_begin();
  5754. $this->whlabellabel->insert($post);
  5755. //$this->whlabelbarcode->insert($post);
  5756. if ($this->db->trans_status() === TRUE) {
  5757. $this->db->trans_commit();
  5758. } else {
  5759. $this->db->trans_rollback();
  5760. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5761. exit;
  5762. }
  5763. //}
  5764. $warehouse_name = "";
  5765. $warehouse = $post['warehouse'];
  5766. if($warehouse == 12){
  5767. $warehouse_name = "特殊库存库";
  5768. }
  5769. // if($warehouse == 13){
  5770. // $warehouse_name = "许昌仓";
  5771. // }
  5772. // if($warehouse == 5){
  5773. // $warehouse_name = "美国店";
  5774. // }
  5775. // if($warehouse == 16){
  5776. // $warehouse_name = "定制头套仓";
  5777. // }
  5778. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5779. if(!empty($warehouse_name)){
  5780. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5781. }
  5782. $purchase = $this->purchase->read($post['purchase']);
  5783. 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));
  5784. exit; //特殊仓目前不需要仓库选项
  5785. }
  5786. }
  5787. if (isset($_SESSION['api'])) {
  5788. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5789. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5790. $this->data['wlshop'] = $wlshop;
  5791. $this->data['warehouse'] = $warehouse;
  5792. }
  5793. $whlabelwz = $this->whlabelwz->find_all();
  5794. $this->data['whlabelwz'] = $whlabelwz;
  5795. $this->_Template('whlabel_print', $this->data);
  5796. }
  5797. public function _usaprint($arg_array)
  5798. {
  5799. if (isset($_SESSION['api'])) {
  5800. $user = $this->user->get_api($_SESSION['api']);
  5801. $usp = $user;
  5802. $fgshop = "";
  5803. $sid = "";
  5804. $wid = "";
  5805. $wtype = "";
  5806. $usersp = explode('|', trim($user['shop'], '|'));
  5807. $userwh = explode('|', trim($user['warehouse'], '|'));
  5808. foreach ($usersp as $value) {
  5809. $fgshop .= " shop = " . $value . " or";
  5810. $sid .= " id = " . $value . " or";
  5811. }
  5812. foreach ($userwh as $value) {
  5813. $wid .= " id = " . $value . " or";
  5814. $wtype .= " type = " . $value . " or";
  5815. }
  5816. }
  5817. $post = $this->input->post(NULL, TRUE);
  5818. if (isset($post['tmsku'])) {
  5819. $tmsku = $this->input->post('tmsku', true);
  5820. if (is_numeric($tmsku)) {
  5821. $yyh = $this->whlabellabel->get_label($tmsku);
  5822. } else {
  5823. $yyh = $this->whlabellabel->get_sku($tmsku);
  5824. }
  5825. if ($yyh) {
  5826. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5827. exit;
  5828. } else {
  5829. echo json_encode(array('success' => false));
  5830. exit;
  5831. }
  5832. }
  5833. $classid = $this->classid->sku();
  5834. $pm = $classid;
  5835. $scsku = $classid;
  5836. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5837. if (isset($post['warehouse'])) {
  5838. if ($post['warehouse']) {
  5839. $list = array();
  5840. $num = "";
  5841. $title = "";
  5842. $features = "";
  5843. $order = 0;
  5844. $post['shop'] = '';
  5845. $brand = $this->input->post('brand', true);
  5846. if ($brand != '0,') {
  5847. $b = $this->brand->read(rtrim($brand, ','));
  5848. if ($b) {
  5849. $post['shop'] = str_replace('|', ',', $b['shop']);
  5850. }
  5851. }
  5852. $post['details'] = $this->input->post('details', true); //打印数量
  5853. $xbqnum = $this->input->post('xbqnum', true);
  5854. $post['purchase'] = $this->input->post('purchase', true);
  5855. $post['warehouse'] = $this->input->post('warehouse', true);
  5856. $post['purchase'] = $this->input->post('purchase', true);
  5857. $post['retreatwarehouse'] = $post['warehouse'];
  5858. $post['cpbz'] = $this->input->post('cpbz', true);
  5859. $post['state'] = 9;
  5860. $category = $this->input->post('category', true);
  5861. $list['category'] = $category;
  5862. $list['hairtype'] = $this->input->post('hairtype', true);
  5863. $list['grade'] = $this->input->post('grade', true);
  5864. $size = $this->input->post('size', true);
  5865. $list['size'] = rtrim($size, ',');
  5866. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5867. $list['extension'] = $this->input->post('extension', true);
  5868. if ($category == 1297) {
  5869. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5870. }
  5871. if ($category == 1702) {
  5872. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5873. $list['syother'] = $this->input->post('syother', true);
  5874. }
  5875. if ($category == 133) {
  5876. $list['fittype'] = $this->input->post('fittype', true);
  5877. $list['acother'] = $this->input->post('acother', true);
  5878. }
  5879. $list['color'] = $this->input->post('color', true);
  5880. $list['lowe'] = $this->input->post('lowe', true);
  5881. if ($category == 127) {
  5882. $list['type'] = $this->input->post('type', true);
  5883. $list['headroad'] = $this->input->post('headroad', true);
  5884. $list['density'] = $this->input->post('density', true);
  5885. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5886. $list['lacesize'] = $this->input->post('lacesize', true);
  5887. }
  5888. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5889. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5890. }
  5891. if ($category == 128) {
  5892. $list['lacetype'] = $this->input->post('lacetype', true);
  5893. $list['haircap'] = $this->input->post('haircap', true);
  5894. $list['density'] = $this->input->post('density', true);
  5895. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5896. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5897. $list['wigother'] = $this->input->post('wigother', true);
  5898. $list['wigother1'] = $this->input->post('wigother1', true);
  5899. $list['wigother2'] = $this->input->post('wigother2', true);
  5900. }
  5901. if ($category == 129) {
  5902. $list['wide'] = $this->input->post('wide', true);
  5903. }
  5904. if ($category == 131) {
  5905. $list['gifttype'] = $this->input->post('gifttype', true);
  5906. $list['giftother'] = $this->input->post('giftother', true);
  5907. }
  5908. if ($category == 134) {
  5909. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5910. }
  5911. if ($category == 1297) {
  5912. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5913. $list['sywigother'] = $this->input->post('sywigother', true);
  5914. }
  5915. if ($category == 130 || $category == 133 || $category == 1702) {
  5916. $list['items'] = $this->input->post('items', true);
  5917. $list['weight'] = $this->input->post('weight', true);
  5918. }
  5919. if ($category == 1702) {
  5920. $list['syhairther'] = $this->input->post('syhairther', true);
  5921. }
  5922. foreach ($list as $k => $v) {
  5923. if ($v != 0) {
  5924. $num .= $v;
  5925. $features .= $v . '-';
  5926. $post[$k] = $v;
  5927. $typeclass = $this->typeclass->read($v);
  5928. if (isset($pm[$typeclass['classid']])) {
  5929. if (stripos($typeclass['zh'], '|') !== false) {
  5930. $exzh = explode('|', $typeclass['zh']);
  5931. $pm[$typeclass['classid']] = $exzh[0];
  5932. } else {
  5933. $pm[$typeclass['classid']] = $typeclass['zh'];
  5934. }
  5935. }
  5936. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5937. if ($k != 'size') {
  5938. $title .= $typeclass['title'] . " ";
  5939. }
  5940. }
  5941. }
  5942. $typeclass = $this->typeclass->read($list['size']);
  5943. $title .= $typeclass['title'];
  5944. $time = time();
  5945. $post['title'] = rtrim($title, ' ');
  5946. $post['number'] = $num;
  5947. $post['features'] = '-' . $features;
  5948. $fp = $this->whlabel->get_features($post['features']);
  5949. if (!$fp) {
  5950. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5951. exit;
  5952. }
  5953. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5954. $featurespp = explode('-', trim($featurespp, '-'));
  5955. if (isset($featurespp[5])) {
  5956. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5957. } else {
  5958. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5959. }
  5960. $post['enter'] = $time;
  5961. $post['time'] = $time; //操作时间
  5962. $scsku = implode("-", $scsku);
  5963. $zh = implode(" ", $pm);
  5964. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5965. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5966. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5967. $post['sku'] = $fp['sku'];
  5968. $post['label'] = $fp['sku'];
  5969. $cpid = $this->whlabellabel->find_count();
  5970. $post['cpid'] = $cpid + 1;
  5971. $cpid = $post['cpid'];
  5972. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5973. //if($whlabelbarcode)
  5974. //{
  5975. //$post['label'] = $whlabelbarcode['label'];
  5976. //if(!$this->whlabellabel->insert($post))
  5977. //{
  5978. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5979. //}
  5980. //}
  5981. //else
  5982. //{
  5983. $this->db->trans_begin();
  5984. $this->whlabellabel->insert($post);
  5985. //$this->whlabelbarcode->insert($post);
  5986. if ($this->db->trans_status() === TRUE) {
  5987. $this->db->trans_commit();
  5988. } else {
  5989. $this->db->trans_rollback();
  5990. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5991. exit;
  5992. }
  5993. //}
  5994. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5995. $purchase = $this->purchase->read($post['purchase']);
  5996. 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));
  5997. exit; //特殊仓目前不需要仓库选项
  5998. }
  5999. }
  6000. if (isset($_SESSION['api'])) {
  6001. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6002. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6003. $this->data['wlshop'] = $wlshop;
  6004. $this->data['warehouse'] = $warehouse;
  6005. }
  6006. $whlabelwz = $this->whlabelwz->find_all();
  6007. $this->data['whlabelwz'] = $whlabelwz;
  6008. $this->_Template('whlabel_usaprint', $this->data);
  6009. }
  6010. public function _printrk($arg_array)
  6011. {
  6012. $prc = array();
  6013. $purchase = $this->purchase->find_all();
  6014. foreach ($purchase as $k => $v) {
  6015. $prc[$v['id']] = $v['title'];
  6016. }
  6017. $post = $this->input->post(NULL, TRUE);
  6018. if (isset($post['page'])) {
  6019. $page = $this->input->post('page', true);
  6020. $perpage = $this->input->post('perpage', true);
  6021. $sku = $this->input->post('sku', true);
  6022. $bs = $this->input->post('bs', true);
  6023. $number = $this->input->post('number', true);
  6024. $warehouse = $this->input->post('warehouse', true);
  6025. $purchase = $this->input->post('purchase', true);
  6026. $orderinfo = $this->input->post('orderinfo', true);
  6027. $waybill = $this->input->post('waybill', true);
  6028. $category = $this->input->post('category', true);
  6029. $size = $this->input->post('size', true);
  6030. $grade = $this->input->post('grade', true);
  6031. $color = $this->input->post('color', true);
  6032. $lowe = $this->input->post('lowe', true);
  6033. $state = $this->input->post('state', true);
  6034. $label = $this->input->post('label', true);
  6035. $timetk = $this->input->post('ktime', true);
  6036. $timetj = $this->input->post('jtime', true);
  6037. $timetk = strtotime($timetk);
  6038. $timetj = strtotime($timetj);
  6039. $where = "1=1 ";
  6040. if ($timetk && $timetj) {
  6041. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6042. }
  6043. if ($sku) {
  6044. $where .= " and sku = '$sku'";
  6045. }
  6046. if ($bs != '') {
  6047. $where .= " and bs = '$bs'";
  6048. }
  6049. if ($number) {
  6050. $where .= " and number = '$number'";
  6051. }
  6052. if ($warehouse) {
  6053. $where .= " and warehouse = '$warehouse'";
  6054. }
  6055. if ($purchase) {
  6056. $where .= " and purchase = '$purchase'";
  6057. }
  6058. if ($orderinfo) {
  6059. $where .= " and orderinfo = '$orderinfo'";
  6060. }
  6061. if ($waybill) {
  6062. $where .= " and waybill = '$waybill'";
  6063. }
  6064. if ($category) {
  6065. $where .= " and features like '%-$category-%'";
  6066. }
  6067. if ($size) {
  6068. $where .= " and features like '%-$size-%'";
  6069. }
  6070. if ($grade) {
  6071. $where .= " and features like '%-$grade-%'";
  6072. }
  6073. if ($color) {
  6074. $where .= " and features like '%-$color-%'";
  6075. }
  6076. if ($lowe) {
  6077. $where .= " and features like '%-$lowe-%'";
  6078. }
  6079. if ($label) {
  6080. $where .= " and label = '$label'";
  6081. }
  6082. if ($state || $state == 0) {
  6083. $where .= " and state = '$state'";
  6084. }
  6085. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6086. //数据排序
  6087. $order_str = "enter desc";
  6088. if (empty($page)) {
  6089. $start = 0;
  6090. $perpage = 1;
  6091. } else {
  6092. $start = ($page - 1) * $perpage;
  6093. }
  6094. //取得信息列表
  6095. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6096. foreach ($info_list as $key => $value) {
  6097. $warehouse = $this->warehouse->read($value['warehouse']);
  6098. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6099. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6100. if ($value['state'] == 0) {
  6101. $info_list[$key]['state'] = "在库";
  6102. } else if ($value['state'] == 1) {
  6103. $info_list[$key]['state'] = "出库";
  6104. } else if ($value['state'] == 2) {
  6105. $info_list[$key]['state'] = "退库";
  6106. } else if ($value['state'] == 3) {
  6107. $info_list[$key]['state'] = "调拨中";
  6108. } else if ($value['state'] == 4) {
  6109. $info_list[$key]['state'] = "再加工";
  6110. } else if ($value['state'] == 5) {
  6111. $info_list[$key]['state'] = "维修中";
  6112. } else if ($value['state'] == 6) {
  6113. $info_list[$key]['state'] = "盘亏";
  6114. } else if ($value['state'] == 7) {
  6115. $info_list[$key]['state'] = "更换标签";
  6116. } else if ($value['state'] == 8) {
  6117. $info_list[$key]['state'] = "其它";
  6118. } else if ($value['state'] == 9) {
  6119. $info_list[$key]['state'] = "预设";
  6120. } else if ($value['state'] == 10) {
  6121. $info_list[$key]['state'] = "美店零售";
  6122. }
  6123. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6124. }
  6125. $total = $this->$ck->find_count($where);
  6126. $pagenum = ceil($total / $perpage);
  6127. $over = $total - ($start + $perpage);
  6128. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6129. echo json_encode($rows);
  6130. exit;
  6131. }
  6132. if (isset($post['tmsku'])) {
  6133. $time = time();
  6134. $tmsku = $this->input->post('tmsku', true);
  6135. //$post['shop'] = $this->input->post('shop',true);
  6136. $num = $this->input->post('num', true);
  6137. $rktype = $this->input->post('rktype', true);
  6138. if ($num > 200) {
  6139. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6140. exit;
  6141. }
  6142. if (!$rktype) {
  6143. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6144. }
  6145. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6146. /**
  6147. $wz = array();
  6148. foreach ($rk as $key=>$value)
  6149. {
  6150. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6151. }
  6152. if(count($wz) > 1)
  6153. {
  6154. $wz = array_values($wz);
  6155. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6156. }
  6157. **/
  6158. if (isset($rk[0]['purchase'])) {
  6159. $rk = $rk[0];
  6160. $j = 0;
  6161. $post['purchase'] = $rk['purchase'];
  6162. $post['warehouse'] = $rk['warehouse'];
  6163. $post['retreatwarehouse'] = $rk['warehouse'];
  6164. $post['sku'] = $rk['sku'];
  6165. $post['number'] = $rk['number'];
  6166. $post['features'] = $rk['features'];
  6167. $post['title'] = $rk['title'];
  6168. $post['enter'] = $time;
  6169. $post['time'] = $time;
  6170. $post['bs'] = 1;
  6171. $post['shop'] = $rk['shop'];
  6172. $post['details'] = $rk['details'];
  6173. $post['cpid'] = $rk['cpid'];
  6174. $post['cpbz'] = $rk['cpbz'];
  6175. //$post['rktype'] = $rktype;
  6176. $warehouse = $this->warehouse->read($rk['warehouse']);
  6177. if ($warehouse['bdck'] == '') {
  6178. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6179. exit;
  6180. } else {
  6181. $bdck = $warehouse['bdck'];
  6182. }
  6183. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6184. if (isset($pdwz['details'])) {
  6185. if ($pdwz['details'] != $post['details']) {
  6186. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6187. exit;
  6188. }
  6189. }
  6190. $post['featurespp'] = $rk['featurespp'];
  6191. if ($post['warehouse'] == '5') {
  6192. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6193. if ($yza) {
  6194. if ($post['features'] != $yza[0]['features']) {
  6195. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6196. exit;
  6197. }
  6198. }
  6199. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6200. if ($yzb) {
  6201. if ($post['sku'] != $yzb[0]['sku']) {
  6202. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6203. exit;
  6204. }
  6205. }
  6206. }
  6207. for ($i = 0; $i < $num; $i++) {
  6208. $post['label'] = time() . rand(100, 999) . $i;
  6209. if ($this->$bdck->insert($post)) {
  6210. $j++;
  6211. }
  6212. }
  6213. /**
  6214. if($post['warehouse'] != 12)
  6215. {
  6216. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6217. }
  6218. **/
  6219. if ($j == $num) {
  6220. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6221. exit;
  6222. } else {
  6223. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6224. exit;
  6225. }
  6226. } else {
  6227. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6228. exit;
  6229. }
  6230. }
  6231. $this->_Template('whlabel_printrk', $this->data);
  6232. }
  6233. public function _printxzrk($arg_array)
  6234. {
  6235. $post = $this->input->post(NULL, TRUE);
  6236. if (isset($post['wzid'])) {
  6237. $time = time();
  6238. $id = $this->input->post('wzid', true);
  6239. //$post['shop'] = $this->input->post('shop',true);
  6240. $num = 1;
  6241. $rk = $this->whlabellabel->read($id);
  6242. if (isset($rk['purchase'])) {
  6243. $x = 0;
  6244. $post['purchase'] = $rk['purchase'];
  6245. $post['warehouse'] = $rk['warehouse'];
  6246. $post['retreatwarehouse'] = $rk['warehouse'];
  6247. $post['sku'] = $rk['sku'];
  6248. $post['number'] = $rk['number'];
  6249. $post['features'] = $rk['features'];
  6250. $post['title'] = $rk['title'];
  6251. $post['enter'] = $time;
  6252. $post['time'] = $time;
  6253. $post['bs'] = 1;
  6254. $post['shop'] = $rk['shop'];
  6255. $post['details'] = $rk['details'];
  6256. $post['cpid'] = $rk['cpid'];
  6257. $post['cpbz'] = $rk['cpbz'];
  6258. $warehouse = $this->warehouse->read($rk['warehouse']);
  6259. if ($warehouse['bdck'] == '') {
  6260. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6261. exit;
  6262. } else {
  6263. $bdck = $warehouse['bdck'];
  6264. }
  6265. $post['featurespp'] = $rk['featurespp'];
  6266. $this->db->trans_begin();
  6267. for ($i = 0; $i < $num; $i++) {
  6268. $post['label'] = time() . rand(100, 999) . $i;
  6269. $this->$bdck->insert($post);
  6270. }
  6271. /**
  6272. if($post['warehouse'] != 12)
  6273. {
  6274. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6275. }
  6276. **/
  6277. if ($this->db->trans_status() === TRUE) {
  6278. $this->db->trans_commit();
  6279. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6280. exit;
  6281. } else {
  6282. $this->db->trans_rollback();
  6283. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6284. exit;
  6285. }
  6286. } else {
  6287. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6288. exit;
  6289. }
  6290. }
  6291. }
  6292. public function _printck($arg_array)
  6293. {
  6294. $prc = array();
  6295. $purchase = $this->purchase->find_all();
  6296. foreach ($purchase as $k => $v) {
  6297. $prc[$v['id']] = $v['title'];
  6298. }
  6299. $post = $this->input->post(NULL, TRUE);
  6300. if (isset($post['page'])) {
  6301. $page = $this->input->post('page', true);
  6302. $perpage = $this->input->post('perpage', true);
  6303. $sku = $this->input->post('sku', true);
  6304. $bs = $this->input->post('bs', true);
  6305. $number = $this->input->post('number', true);
  6306. $warehouse = $this->input->post('warehouse', true);
  6307. $purchase = $this->input->post('purchase', true);
  6308. $orderinfo = $this->input->post('orderinfo', true);
  6309. $waybill = $this->input->post('waybill', true);
  6310. $category = $this->input->post('category', true);
  6311. $size = $this->input->post('size', true);
  6312. $grade = $this->input->post('grade', true);
  6313. $color = $this->input->post('color', true);
  6314. $lowe = $this->input->post('lowe', true);
  6315. $state = $this->input->post('state', true);
  6316. $label = $this->input->post('label', true);
  6317. $timetk = $this->input->post('ktime', true);
  6318. $timetj = $this->input->post('jtime', true);
  6319. $timetk = strtotime($timetk);
  6320. $timetj = strtotime($timetj);
  6321. $where = "state=1 ";
  6322. if ($timetk && $timetj) {
  6323. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6324. }
  6325. if ($sku) {
  6326. $where .= " and sku = '$sku'";
  6327. }
  6328. if ($bs != '') {
  6329. $where .= " and bs = '$bs'";
  6330. }
  6331. if ($number) {
  6332. $where .= " and number = '$number'";
  6333. }
  6334. if ($warehouse) {
  6335. $where .= " and warehouse = '$warehouse'";
  6336. }
  6337. if ($purchase) {
  6338. $where .= " and purchase = '$purchase'";
  6339. }
  6340. if ($orderinfo) {
  6341. $where .= " and orderinfo = '$orderinfo'";
  6342. }
  6343. if ($waybill) {
  6344. $where .= " and waybill = '$waybill'";
  6345. }
  6346. if ($category) {
  6347. $where .= " and features like '%-$category-%'";
  6348. }
  6349. if ($size) {
  6350. $where .= " and features like '%-$size-%'";
  6351. }
  6352. if ($grade) {
  6353. $where .= " and features like '%-$grade-%'";
  6354. }
  6355. if ($color) {
  6356. $where .= " and features like '%-$color-%'";
  6357. }
  6358. if ($lowe) {
  6359. $where .= " and features like '%-$lowe-%'";
  6360. }
  6361. if ($label) {
  6362. $where .= " and label = '$label'";
  6363. }
  6364. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6365. //数据排序
  6366. $order_str = "outk desc";
  6367. if (empty($page)) {
  6368. $start = 0;
  6369. $perpage = 1;
  6370. } else {
  6371. $start = ($page - 1) * $perpage;
  6372. }
  6373. //取得信息列表
  6374. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6375. foreach ($info_list as $key => $value) {
  6376. $warehouse = $this->warehouse->read($value['warehouse']);
  6377. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6378. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6379. if ($value['state'] == 0) {
  6380. $info_list[$key]['state'] = "在库";
  6381. } else if ($value['state'] == 1) {
  6382. $info_list[$key]['state'] = "出库";
  6383. } else if ($value['state'] == 2) {
  6384. $info_list[$key]['state'] = "退库";
  6385. } else if ($value['state'] == 3) {
  6386. $info_list[$key]['state'] = "调拨中";
  6387. } else if ($value['state'] == 4) {
  6388. $info_list[$key]['state'] = "再加工";
  6389. } else if ($value['state'] == 5) {
  6390. $info_list[$key]['state'] = "维修中";
  6391. } else if ($value['state'] == 6) {
  6392. $info_list[$key]['state'] = "盘亏";
  6393. } else if ($value['state'] == 7) {
  6394. $info_list[$key]['state'] = "更换标签";
  6395. } else if ($value['state'] == 8) {
  6396. $info_list[$key]['state'] = "其它";
  6397. } else if ($value['state'] == 9) {
  6398. $info_list[$key]['state'] = "预设";
  6399. } else if ($value['state'] == 10) {
  6400. $info_list[$key]['state'] = "美店零售";
  6401. }
  6402. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6403. }
  6404. $total = $this->$ck->find_count($where);
  6405. $pagenum = ceil($total / $perpage);
  6406. $over = $total - ($start + $perpage);
  6407. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6408. echo json_encode($rows);
  6409. exit;
  6410. }
  6411. if (isset($post['tmsku'])) {
  6412. $time = time();
  6413. $tmsku = $this->input->post('tmsku', true);
  6414. //$post['shop'] = $this->input->post('shop',true);
  6415. $num = $this->input->post('num', true);
  6416. $cktype = $this->input->post('cktype', true);
  6417. $label = $this->whlabellabel->get_label($tmsku);
  6418. if (!$cktype) {
  6419. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6420. }
  6421. if (!isset($label['warehouse'])) {
  6422. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6423. exit;
  6424. }
  6425. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6426. if (stripos($label['features'], '-126-') !== false) {
  6427. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6428. } else {
  6429. $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 = ''");
  6430. }
  6431. $j = 0;
  6432. if (count($ck) >= $num) {
  6433. for ($i = 0; $i < $num; $i++) {
  6434. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6435. {
  6436. $j++;
  6437. }
  6438. }
  6439. if ($j == $num) {
  6440. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6441. exit;
  6442. } else {
  6443. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6444. exit;
  6445. }
  6446. } else {
  6447. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6448. exit;
  6449. }
  6450. }
  6451. if(isset($_SESSION['api']))
  6452. {
  6453. $user = $this->user->get_api($_SESSION['api']);
  6454. if(in_array($user['power'],[1,27])){
  6455. $vip = 1;
  6456. }
  6457. }
  6458. else
  6459. {
  6460. $vip = 0;
  6461. header('Location: /');exit;
  6462. }
  6463. $this->data['vip'] = $vip;
  6464. $this->_Template('whlabel_printck', $this->data);
  6465. }
  6466. public function _printexcel()
  6467. {
  6468. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6469. $config['upload_path'] = '.' . $dir;
  6470. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6471. $config['allowed_types'] = 'xls|xlsx|csv';
  6472. $config['max_size'] = 10240;
  6473. $this->load->library('upload', $config);
  6474. $this->upload->initialize($config);
  6475. if ($this->upload->do_upload('userfile')) {
  6476. $full_path = $dir . $this->upload->data('file_name');
  6477. $fileName = '.' . $full_path;
  6478. if (!file_exists($fileName)) {
  6479. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6480. exit;
  6481. } else {
  6482. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6483. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6484. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6485. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6486. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6487. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6488. ++$column; //如果列数大于26行
  6489. $list = array();
  6490. for ($i = 2; $i <= $row; $i++) // 行数循环
  6491. {
  6492. $data = array();
  6493. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6494. {
  6495. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6496. }
  6497. $list[] = $data;
  6498. }
  6499. }
  6500. $ed = array();
  6501. $i = 0;
  6502. $j = 0;
  6503. $dcdata = array();
  6504. $yc = '';
  6505. $cmf_arr = array_column($list, '1');
  6506. array_multisort($cmf_arr, SORT_ASC, $list);
  6507. foreach ($list as $key => $value) {
  6508. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6509. if ($typeclass) {
  6510. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6511. } else {
  6512. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6513. $i++;
  6514. continue;
  6515. }
  6516. }
  6517. if ($i > 0) {
  6518. $yc = $i . '条异常';
  6519. }
  6520. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6521. exit;
  6522. }
  6523. }
  6524. public function _uck()
  6525. {
  6526. if (isset($_GET['excel'])) {
  6527. $tc = array();
  6528. $typeclass = $this->typeclass->find_all();
  6529. foreach ($typeclass as $v) {
  6530. $tc[$v['id']] = $v['zh'];
  6531. }
  6532. $data = array();
  6533. $t = array();
  6534. $rq = '';
  6535. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6536. $ts = $ts / (24 * 3600);
  6537. for ($i = 0; $i < $ts; $i++) {
  6538. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6539. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6540. }
  6541. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6542. foreach ($info_list as $k => $v) {
  6543. $features = explode('-', trim($v['features'], '-'));
  6544. if (!isset($features[3]) || !isset($features[4])) {
  6545. continue;
  6546. }
  6547. $data[$k][0] = $tc[$features[0]]; //类型
  6548. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6549. $data[$k][2] = $tc[$features[4]]; //曲度
  6550. $data[$k][3] = '';
  6551. if (isset($data[$k][1])) {
  6552. $data[$k][3] .= $data[$k][1];
  6553. }
  6554. if (isset($data[$k][2])) {
  6555. $data[$k][3] .= $data[$k][2];
  6556. }
  6557. if (isset($features[5])) {
  6558. $data[$k][3] .= $tc[$features[5]];
  6559. }
  6560. if (isset($features[2])) {
  6561. $data[$k][3] .= $tc[$features[2]];
  6562. }
  6563. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6564. $data[$k][4] = $v['sku'];
  6565. $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())) . '))'); //月初库存
  6566. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6567. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6568. $ztrq = '';
  6569. $ztsl = '';
  6570. if (count($zt) > 0) {
  6571. foreach ($zt as $vv) {
  6572. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6573. $ztsl .= $vv['num'] . '<br>';
  6574. }
  6575. }
  6576. $data[$k][] = trim($ztsl, '<br>');
  6577. $data[$k][] = trim($ztrq, '<br>');
  6578. $byck = 0;
  6579. foreach ($t as $vv) {
  6580. $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));
  6581. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6582. $byck += $sl;
  6583. }
  6584. $data[$k][] = ($byck > 0) ? $byck : '';
  6585. }
  6586. $title = "详情 " . date("Y-m-d", time());
  6587. $titlename = "<table border=1>
  6588. <tr align='center'>
  6589. <td>类别</td>
  6590. <td>颜色</td>
  6591. <td>曲度</td>
  6592. <td>名称</td>
  6593. <td>SKU</td>
  6594. <td>月初库存</td>
  6595. <td>剩余库存</td>
  6596. <td>在途数量</td>
  6597. <td>预达日期</td>" .
  6598. $rq
  6599. . "<td>本月出库</td></tr>
  6600. </table>";
  6601. $filename = $title . ".xls";
  6602. $tail = "";
  6603. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6604. }
  6605. }
  6606. public function _whlabelexcelzh()
  6607. {
  6608. if (isset($_GET['excel'])) {
  6609. $where = "sku != 'Preset'";
  6610. //数据排序
  6611. $order_str = "id desc";
  6612. if (empty($page)) {
  6613. $start = 0;
  6614. $perpage = 1;
  6615. } else {
  6616. $start = ($page - 1) * $perpage;
  6617. }
  6618. $category = $this->input->get('category', true);
  6619. $warehouse = $this->input->get('warehouse', true);
  6620. $excelid = $this->input->get('sid', true);
  6621. if ($category) {
  6622. $where .= " and features like '%-$category-%'";
  6623. }
  6624. if ($warehouse) {
  6625. $where .= " and warehouse = '$warehouse'";
  6626. }
  6627. $xzid = '';
  6628. if ($excelid) {
  6629. $excelid = explode(',', trim($excelid, ','));
  6630. foreach ($excelid as $key => $value) {
  6631. $xzid .= " id = " . $value . " or";
  6632. }
  6633. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6634. }
  6635. //取得信息列表
  6636. /**
  6637. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6638. $rows = array();$list = array();
  6639. foreach ($info_list as $key=>$value)
  6640. {
  6641. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6642. }
  6643. **/
  6644. $list = array();
  6645. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6646. foreach ($rows as $key => $value) {
  6647. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6648. $zh = '';
  6649. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6650. foreach ($zt as $v) {
  6651. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6652. }
  6653. $zt = array_sum(array_column($zt, 'num'));
  6654. $number = $value['number'];
  6655. $ftime = time() - 15 * 24 * 3600;
  6656. $warehouse = $this->warehouse->read($value['warehouse']);
  6657. $rows[$key]['warehouse'] = $warehouse['title'];
  6658. $rows[$key]['number'] = $c;
  6659. $rows[$key]['features'] = $zh;
  6660. $rows[$key]['hb'] = $c + $zt;
  6661. }
  6662. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6663. $titlename = "<table border=1>
  6664. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6665. <tr align='center'>
  6666. <td>仓库</td>
  6667. <td>SKU</td>
  6668. <td>产品</td>
  6669. <td>库存数量</td>
  6670. <td>在途数量及预达日期</td>
  6671. <td>在途+库存数量</td>
  6672. </tr>
  6673. </table>";
  6674. $filename = $title . ".xls";
  6675. $tail = "";
  6676. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6677. }
  6678. if (isset($_GET['excel'])) {
  6679. $warehouse = $this->input->get('warehouse', true);
  6680. $sku = $this->input->get('sku', true);
  6681. $cz = $this->input->get('cz', true);
  6682. $text = $this->input->post('text', true);
  6683. $xztime = $this->input->get('xztime', true);
  6684. $timetk = $this->input->get('timetk', true);
  6685. $timetj = $this->input->get('timetj', true);
  6686. $timetk = strtotime($timetk);
  6687. $timetj = strtotime($timetj);
  6688. $where = "time = '0' ";
  6689. if ($warehouse) {
  6690. $where .= " and warehouse = '$warehouse'";
  6691. }
  6692. if ($sku) {
  6693. $where .= " and sku = '$sku'";
  6694. }
  6695. if ($text) {
  6696. $where .= " and text like '%$text%'";
  6697. }
  6698. if ($cz != '') {
  6699. $where .= " and cz = '$cz'";
  6700. }
  6701. if ($timetk && $timetj) {
  6702. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6703. }
  6704. //数据排序
  6705. $order_str = $xztime . " desc";
  6706. //取得信息列表
  6707. $zh = array();
  6708. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6709. foreach ($info_list as $v) {
  6710. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6711. $warehouse = $this->warehouse->read($v['warehouse']);
  6712. $v['warehouse'] = $warehouse['title'];
  6713. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6714. $v['stime'] = date('Y-m-d', $v['stime']);
  6715. if (isset($zh[$v['features']])) {
  6716. $zh[$v['features']]['num'] += $v['num'];
  6717. } else {
  6718. $zh[$v['features']] = $v;
  6719. }
  6720. $zh[$v['features']]['features'] = $c;
  6721. }
  6722. $title = "在途数据" . date('Y-m-d', time());
  6723. $titlename = "<table border=1>
  6724. <tr align='center'>
  6725. <td>仓库</td>
  6726. <td>SKU</td>
  6727. <td>名称</td>
  6728. <td>在途数量</td>
  6729. <td>库存数量</td>
  6730. <td>添加在途日期</td>
  6731. <td>预达日期</td>
  6732. <td>备注</td>
  6733. </tr>
  6734. </table>";
  6735. $filename = $title . ".xls";
  6736. $tail = "";
  6737. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6738. }
  6739. }
  6740. public function _fc()
  6741. {
  6742. $vip = 0;
  6743. if (isset($_SESSION['api'])) {
  6744. $user = $this->user->get_api($_SESSION['api']);
  6745. if ($user['vip'] == 1) {
  6746. $vip = 1;
  6747. }
  6748. } else {
  6749. header('Location: /');
  6750. exit;
  6751. }
  6752. $post = $this->input->post(NULL, TRUE);
  6753. if (isset($post['page'])) {
  6754. $page = $this->input->post('page', true);
  6755. $perpage = $this->input->post('perpage', true);
  6756. $category = $this->input->post('category', true);
  6757. $size = $this->input->post('size', true);
  6758. $grade = $this->input->post('grade', true);
  6759. $color = $this->input->post('color', true);
  6760. $lowe = $this->input->post('lowe', true);
  6761. $sku = $this->input->post('sku');
  6762. $title = $this->input->post('title');
  6763. $warehouse = $this->input->post('warehouse', true);
  6764. $usa = $this->input->post('usa', true);
  6765. $purchase = $this->input->post('purchase', true);
  6766. $lacetype = $this->input->post('lacetype', true);
  6767. $haircap = $this->input->post('haircap', true);
  6768. $density = $this->input->post('density', true);
  6769. $details = $this->input->post('details', true);
  6770. $state = $this->input->post('state', true);
  6771. $ktime = $this->input->post('ktime', true);
  6772. $jtime = $this->input->post('jtime', true);
  6773. $ktime = strtotime($ktime);
  6774. $jtime = strtotime($jtime);
  6775. $where = "state = '11'";
  6776. $gj = "";
  6777. $ck = "";
  6778. if ($lacetype) {
  6779. $where .= " and features like '%-$lacetype-%'";
  6780. }
  6781. if ($category) {
  6782. $where .= " and features like '%-$category-%'";
  6783. }
  6784. if ($size) {
  6785. $where .= " and features like '%-$size-%'";
  6786. }
  6787. if ($grade) {
  6788. $where .= " and features like '%-$grade-%'";
  6789. }
  6790. if ($color) {
  6791. $where .= " and features like '%-$color-%'";
  6792. }
  6793. if ($lowe) {
  6794. $where .= " and features like '%-$lowe-%'";
  6795. }
  6796. if ($haircap) {
  6797. $where .= " and features like '%-$haircap-%'";
  6798. }
  6799. if ($density) {
  6800. $where .= " and features like '%-$density-%'";
  6801. }
  6802. if ($usa) {
  6803. if (!$warehouse) {
  6804. $where .= " and (warehouse = '5' or warehouse = '8')";
  6805. }
  6806. }
  6807. if ($warehouse) {
  6808. $where .= " and warehouse = '$warehouse'";
  6809. }
  6810. if ($details) {
  6811. $where .= " and details = '$details'";
  6812. }
  6813. if ($purchase) {
  6814. $where .= " and purchase = '$purchase'";
  6815. }
  6816. if ($state) {
  6817. $where .= " and state = '$state'";
  6818. }
  6819. if ($ktime && $jtime) {
  6820. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6821. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6822. }
  6823. //数据排序
  6824. $order_str = "id desc";
  6825. if (empty($page)) {
  6826. $start = 0;
  6827. $perpage = 1;
  6828. } else {
  6829. $start = ($page - 1) * $perpage;
  6830. }
  6831. if ($sku) {
  6832. $sku = trim($sku, ' ');
  6833. $sku = trim($sku, ' ');
  6834. $where .= " and sku like '%$sku%'";
  6835. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6836. } else if ($title) {
  6837. $title = trim($title, ' ');
  6838. $title = trim($title, ' ');
  6839. $where .= " and title like '%$title%'";
  6840. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6841. } else {
  6842. //$where .= " and time > '$ktime' and time < '$jtime'";
  6843. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6844. }
  6845. //取得信息列表
  6846. $rows = array();
  6847. $list = array();
  6848. foreach ($info_list as $key => $value) {
  6849. $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'] . '"');
  6850. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6851. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6852. $warehouse = $this->warehouse->read($value['warehouse']);
  6853. $info_list[$key]['warehouse'] = $warehouse['title'];
  6854. $info_list[$key]['number'] = $g;
  6855. $info_list[$key]['features'] = $x;
  6856. $info_list[$key]['x'] = $s;
  6857. }
  6858. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6859. $pagenum = ceil($total / $perpage);
  6860. $over = $total - ($start + $perpage);
  6861. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6862. echo json_encode($rows);
  6863. exit;
  6864. }
  6865. $this->data['vip'] = $vip;
  6866. $this->_Template('whlabel_fc', $this->data);
  6867. }
  6868. public function _fcmb()
  6869. {
  6870. $where = "sku != 'Preset'";
  6871. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6872. foreach ($rows as $k => $v) {
  6873. $warehouse = $this->warehouse->read($v['warehouse']);
  6874. $rows[$k]['warehouse'] = $warehouse['title'];
  6875. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6876. $rows[$k]['t'] = '';
  6877. $rows[$k]['n'] = '';
  6878. }
  6879. $title = "封货产品数据导入模板";
  6880. $titlename = "<table border=1>
  6881. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6882. <tr align='center'>
  6883. <td>仓库</td>
  6884. <td>SKU</td>
  6885. <td>产品</td>
  6886. <td>封存产品总数量</td>
  6887. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6888. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6889. </tr>
  6890. </table>";
  6891. $filename = $title . ".xls";
  6892. $tail = "";
  6893. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6894. }
  6895. public function _fcexcel()
  6896. {
  6897. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6898. $config['upload_path'] = '.' . $dir;
  6899. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6900. $config['allowed_types'] = 'xls|xlsx|csv';
  6901. $config['max_size'] = 10240;
  6902. $this->load->library('upload', $config);
  6903. $this->upload->initialize($config);
  6904. if ($this->upload->do_upload('userfile')) {
  6905. $full_path = $dir . $this->upload->data('file_name');
  6906. $fileName = '.' . $full_path;
  6907. if (!file_exists($fileName)) {
  6908. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6909. exit;
  6910. } else {
  6911. libxml_use_internal_errors(true);
  6912. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6913. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6914. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6915. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6916. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6917. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6918. ++$column; //如果列数大于26行
  6919. $list = array();
  6920. for ($i = 2; $i <= $row; $i++) // 行数循环
  6921. {
  6922. $data = array();
  6923. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6924. {
  6925. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6926. }
  6927. $list[] = $data;
  6928. }
  6929. }
  6930. $i = 0;
  6931. $j = 0;
  6932. $ed = array();
  6933. foreach ($list as $key => $value) {
  6934. $time = time();
  6935. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6936. continue;
  6937. }
  6938. $warehouse = $this->warehouse->get_title($value['0']);
  6939. $sku = $value['1'];
  6940. $type = $value['4']; //调整方式0扣减1删除
  6941. $num = $value['5']; //调整数量
  6942. //$text = $value['4'];//扣减说明
  6943. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6944. if (!$d) //如果没有这个SKU
  6945. {
  6946. $ed[] = array($sku . '-库存中不存在此SKU');
  6947. $j++;
  6948. continue;
  6949. }
  6950. if (!isset($warehouse['id'])) {
  6951. $ed[] = array($sku . '-仓库名错误!');
  6952. $j++;
  6953. continue;
  6954. }
  6955. if ($type == 1 || $type == 2) //扣减库存
  6956. {
  6957. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6958. if (count($data) < abs($num)) {
  6959. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6960. $j++;
  6961. continue;
  6962. }
  6963. if ($type == 1) //转入库存
  6964. {
  6965. for ($i = 0; $i < abs($num); $i++) {
  6966. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6967. }
  6968. } else if ($type == 2) //删除
  6969. {
  6970. for ($i = 0; $i < abs($num); $i++) {
  6971. $this->whlabel->remove($data[$i]['id']);
  6972. }
  6973. }
  6974. } else if ($type == 0) //增加库存
  6975. {
  6976. $post['sku'] = $d['sku'];
  6977. $post['shop'] = '';
  6978. $post['warehouse'] = $warehouse['id'];
  6979. $post['purchase'] = $d['purchase'];
  6980. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6981. $post['state'] = 11;
  6982. $post['title'] = $d['title'];
  6983. $post['number'] = $d['number'];
  6984. $post['features'] = $d['features'];
  6985. $post['enter'] = $time;
  6986. $post['time'] = $time; //操作时间
  6987. for ($i = 0; $i < $num; $i++) {
  6988. $post['label'] = time() . rand(100, 999) . $i;
  6989. $this->whlabel->insert($post);
  6990. }
  6991. }
  6992. sleep(1); //防止入库时间一样,需要延迟1秒
  6993. }
  6994. if ($j > 0) {
  6995. $tt = date('Ymd', time());
  6996. $title = '库存导入错误信息-' . $tt;
  6997. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6998. $tail = "\n";
  6999. $filename = $title . ".xls";
  7000. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7001. $dir = '/data/excel/' . $time . '/';
  7002. $file_name = 'error_' . $time . rand(1000, 9999);
  7003. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7004. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7005. fwrite($myfile, $ecl);
  7006. fclose($myfile);
  7007. $error = $dir . $file_name . '.xls';
  7008. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7009. exit;
  7010. } else {
  7011. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7012. exit;
  7013. }
  7014. }
  7015. }
  7016. public function _fcjxc($arg_array)
  7017. {
  7018. if (isset($_GET['excel'])) {
  7019. $category = $this->input->get('category', true);
  7020. $size = $this->input->get('size', true);
  7021. $grade = $this->input->get('grade', true);
  7022. $color = $this->input->get('color', true);
  7023. $lowe = $this->input->get('lowe', true);
  7024. $sku = $this->input->get('sku');
  7025. $title = $this->input->get('title');
  7026. $warehouse = $arg_array[0];
  7027. $usa = $this->input->get('usa', true);
  7028. $purchase = $this->input->get('purchase', true);
  7029. $lacetype = $this->input->get('lacetype', true);
  7030. $haircap = $this->input->get('haircap', true);
  7031. $density = $this->input->get('density', true);
  7032. $title = $this->input->get('title', true);
  7033. $state = $this->input->get('state', true);
  7034. $ktime = $this->input->get('ktime', true);
  7035. $jtime = $this->input->get('jtime', true);
  7036. $where = "state=11";
  7037. $gj = "";
  7038. $ck = "";
  7039. if ($lacetype) {
  7040. $where .= " and features like '%-$lacetype-%'";
  7041. }
  7042. if ($category) {
  7043. $where .= " and features like '%-$category-%'";
  7044. }
  7045. if ($size) {
  7046. $where .= " and features like '%-$size-%'";
  7047. }
  7048. if ($grade) {
  7049. $where .= " and features like '%-$grade-%'";
  7050. }
  7051. if ($color) {
  7052. $where .= " and features like '%-$color-%'";
  7053. }
  7054. if ($lowe) {
  7055. $where .= " and features like '%-$lowe-%'";
  7056. }
  7057. if ($haircap) {
  7058. $where .= " and features like '%-$haircap-%'";
  7059. }
  7060. if ($density) {
  7061. $where .= " and features like '%-$density-%'";
  7062. }
  7063. if ($usa) {
  7064. if (!$warehouse) {
  7065. $where .= " and (warehouse = '5' or warehouse = '8')";
  7066. }
  7067. }
  7068. if ($warehouse) {
  7069. $where .= " and warehouse = '$warehouse'";
  7070. }
  7071. if ($purchase) {
  7072. $where .= " and purchase = '$purchase'";
  7073. }
  7074. if ($state) {
  7075. $where .= " and state = '$state'";
  7076. }
  7077. $order_str = "id desc";
  7078. if ($sku) {
  7079. $sku = trim($sku, ' ');
  7080. $sku = trim($sku, ' ');
  7081. $where .= " and sku like '%$sku%'";
  7082. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7083. } else if ($title) {
  7084. $title = trim($title, ' ');
  7085. $title = trim($title, ' ');
  7086. $where .= " and title like '%$title%'";
  7087. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7088. } else {
  7089. //$where .= " and time > '$ktime' and time < '$jtime'";
  7090. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7091. }
  7092. //取得信息列表
  7093. $rows = array();
  7094. $list = array();
  7095. foreach ($info_list as $key => $value) {
  7096. $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'] . '"');
  7097. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7098. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7099. $rows[$key] = $value;
  7100. $warehouse = $this->warehouse->read($value['warehouse']);
  7101. $rows[$key]['warehouse'] = $warehouse['title'];
  7102. $rows[$key]['features'] = $g;
  7103. $rows[$key]['a'] = $x;
  7104. $rows[$key]['b'] = $s;
  7105. }
  7106. $title = "总统计表";
  7107. $titlename = "<table border=1>
  7108. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7109. <tr align='center'>
  7110. <td>仓库</td>
  7111. <td>SKU</td>
  7112. <td>产品名称</td>
  7113. <td>录入总量</td>
  7114. <td>取出总量</td>
  7115. <td>剩余总量</td>
  7116. </tr>
  7117. </table>";
  7118. $filename = $title . ".xls";
  7119. $tail = "";
  7120. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7121. }
  7122. $vip = 0;
  7123. if (isset($_SESSION['api'])) {
  7124. $user = $this->user->get_api($_SESSION['api']);
  7125. if ($user['vip'] == 1) {
  7126. $vip = 1;
  7127. }
  7128. } else {
  7129. header('Location: /');
  7130. exit;
  7131. }
  7132. $post = $this->input->post(NULL, TRUE);
  7133. if (isset($post['page'])) {
  7134. $page = $this->input->post('page', true);
  7135. $perpage = $this->input->post('perpage', true);
  7136. $category = $this->input->post('category', true);
  7137. $size = $this->input->post('size', true);
  7138. $grade = $this->input->post('grade', true);
  7139. $color = $this->input->post('color', true);
  7140. $lowe = $this->input->post('lowe', true);
  7141. $sku = $this->input->post('sku');
  7142. $title = $this->input->post('title');
  7143. $warehouse = $arg_array[0];
  7144. $usa = $this->input->post('usa', true);
  7145. $purchase = $this->input->post('purchase', true);
  7146. $lacetype = $this->input->post('lacetype', true);
  7147. $haircap = $this->input->post('haircap', true);
  7148. $density = $this->input->post('density', true);
  7149. $title = $this->input->post('title', true);
  7150. $state = $this->input->post('state', true);
  7151. $ktime = $this->input->post('ktime', true);
  7152. $jtime = $this->input->post('jtime', true);
  7153. $ktime = strtotime($ktime);
  7154. $jtime = strtotime($jtime);
  7155. $where = "state=11";
  7156. $gj = "";
  7157. $ck = "";
  7158. if ($lacetype) {
  7159. $where .= " and features like '%-$lacetype-%'";
  7160. }
  7161. if ($category) {
  7162. $where .= " and features like '%-$category-%'";
  7163. }
  7164. if ($size) {
  7165. $where .= " and features like '%-$size-%'";
  7166. }
  7167. if ($grade) {
  7168. $where .= " and features like '%-$grade-%'";
  7169. }
  7170. if ($color) {
  7171. $where .= " and features like '%-$color-%'";
  7172. }
  7173. if ($lowe) {
  7174. $where .= " and features like '%-$lowe-%'";
  7175. }
  7176. if ($haircap) {
  7177. $where .= " and features like '%-$haircap-%'";
  7178. }
  7179. if ($density) {
  7180. $where .= " and features like '%-$density-%'";
  7181. }
  7182. if ($usa) {
  7183. if (!$warehouse) {
  7184. $where .= " and (warehouse = '5' or warehouse = '8')";
  7185. }
  7186. }
  7187. if ($warehouse) {
  7188. $where .= " and warehouse = '$warehouse'";
  7189. }
  7190. if ($purchase) {
  7191. $where .= " and purchase = '$purchase'";
  7192. }
  7193. if ($state) {
  7194. $where .= " and state = '$state'";
  7195. }
  7196. if ($ktime && $jtime) {
  7197. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7198. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7199. }
  7200. //数据排序
  7201. $order_str = "id desc";
  7202. $xs = 0;
  7203. $rows = array();
  7204. $list = array();
  7205. if (empty($page)) {
  7206. $start = 0;
  7207. $perpage = 1;
  7208. } else {
  7209. $start = ($page - 1) * $perpage;
  7210. }
  7211. if ($sku || $title) {
  7212. if ($title) {
  7213. $title = trim($title, ' ');
  7214. $title = trim($title, ' ');
  7215. $where .= " and title like '%$title%'";
  7216. } else {
  7217. $sku = trim($sku, ' ');
  7218. $sku = trim($sku, ' ');
  7219. $where .= " and sku like '%$sku%'";
  7220. }
  7221. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7222. foreach ($info_list as $key => $value) {
  7223. $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'] . '"');
  7224. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7225. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7226. $rows[$key] = $value;
  7227. $warehouse = $this->warehouse->read($value['warehouse']);
  7228. $rows[$key]['warehouse'] = $warehouse['title'];
  7229. $rows[$key]['features'] = $g;
  7230. $rows[$key]['a'] = $x;
  7231. $rows[$key]['b'] = $s;
  7232. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7233. $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天销量
  7234. $yj = $c / ($xl / 30);
  7235. if ($yj < 7) {
  7236. $rows[$key]['y'] = round($yj) . '天销量';
  7237. } else {
  7238. $rows[$key]['y'] = '正常';
  7239. }
  7240. }
  7241. } else {
  7242. //$where .= " and time > '$ktime' and time < '$jtime'";
  7243. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7244. foreach ($info_list as $key => $value) {
  7245. $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'] . '"');
  7246. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7247. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7248. $zs[$key] = $value;
  7249. $warehouse = $this->warehouse->read($value['warehouse']);
  7250. $zs[$key]['warehouse'] = $warehouse['title'];
  7251. $zs[$key]['features'] = $g;
  7252. $zs[$key]['a'] = $x;
  7253. $zs[$key]['b'] = $s;
  7254. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7255. $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天销量
  7256. $yj = $c / ($xl / 30);
  7257. if ($yj < 7) {
  7258. $zs[$key]['y'] = round($yj) . '天销量';
  7259. $rows[$key] = $zs[$key];
  7260. }
  7261. }
  7262. }
  7263. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7264. $pagenum = ceil($total / $perpage);
  7265. $over = $total - ($start + $perpage);
  7266. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7267. echo json_encode($rows);
  7268. exit;
  7269. }
  7270. $this->data['arg_array'] = $arg_array[0];
  7271. $this->_Template('whlabel_fcjxc', $this->data);
  7272. }
  7273. public function _0kcdel()
  7274. {
  7275. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7276. $config['upload_path'] = '.' . $dir;
  7277. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7278. $config['allowed_types'] = 'xls|xlsx|csv';
  7279. $config['max_size'] = 10240;
  7280. $this->load->library('upload', $config);
  7281. $this->upload->initialize($config);
  7282. if ($this->upload->do_upload('userfile')) {
  7283. $full_path = $dir . $this->upload->data('file_name');
  7284. $fileName = '.' . $full_path;
  7285. if (!file_exists($fileName)) {
  7286. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7287. exit;
  7288. } else {
  7289. require_once "./data/excel/PHPExcel/IOFactory.php";
  7290. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7291. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7292. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7293. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7294. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7295. ++$column; //如果列数大于26行
  7296. $list = array();
  7297. for ($i = 2; $i <= $row; $i++) // 行数循环
  7298. {
  7299. $data = array();
  7300. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7301. {
  7302. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7303. }
  7304. $list[] = $data;
  7305. }
  7306. }
  7307. $i = 0;
  7308. $j = 0;
  7309. $ed = array();
  7310. foreach ($list as $key => $value) {
  7311. $time = time();
  7312. if ($value['0'] == "" || $value['1'] == "") {
  7313. continue;
  7314. }
  7315. $warehouse = $this->warehouse->get_title($value['0']);
  7316. $sku = $value['1'];
  7317. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7318. if (!$d) //如果没有这个SKU
  7319. {
  7320. $ed[] = array($sku . '-库存中不存在此SKU');
  7321. $j++;
  7322. continue;
  7323. }
  7324. if (!isset($warehouse['id'])) {
  7325. $ed[] = array($sku . '-仓库名错误!');
  7326. $j++;
  7327. continue;
  7328. }
  7329. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7330. if ($z < 1) {
  7331. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7332. foreach ($z as $v) {
  7333. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7334. if (count($zt) > 0) {
  7335. $ed[] = array($sku . '-有在途库存无法删除!');
  7336. $j++;
  7337. continue;
  7338. }
  7339. $this->whlabel->remove($v['id']);
  7340. }
  7341. } else {
  7342. $ed[] = array($sku . '-非0库存!');
  7343. $j++;
  7344. continue;
  7345. }
  7346. }
  7347. if ($j > 0) {
  7348. $tt = date('Ymd', time());
  7349. $title = '删除0库存错误信息-' . $tt;
  7350. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7351. $tail = "\n";
  7352. $filename = $title . ".xls";
  7353. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7354. $dir = '/data/excel/' . $time . '/';
  7355. $file_name = 'error_' . $time . rand(1000, 9999);
  7356. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7357. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7358. fwrite($myfile, $ecl);
  7359. fclose($myfile);
  7360. $error = $dir . $file_name . '.xls';
  7361. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7362. exit;
  7363. } else {
  7364. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7365. exit;
  7366. }
  7367. }
  7368. }
  7369. public function _gbhtype()
  7370. {
  7371. $post = $this->input->post(NULL, TRUE);
  7372. if (isset($post['s'])) {
  7373. $n = $this->input->post('n');
  7374. $d = $this->input->post('s');
  7375. if (!$d) {
  7376. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7377. exit;
  7378. }
  7379. $d = explode(',', trim($d, ','));
  7380. $t = $this->whlabel_type->read($n);
  7381. //循环删除记录
  7382. foreach ($d as $v) {
  7383. $u = $this->whlabel->read($v);
  7384. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7385. foreach ($data as $val) {
  7386. $this->whlabel->save(array('type' => $n), $val['id']);
  7387. }
  7388. }
  7389. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7390. }
  7391. }
  7392. //出库、退库导出
  7393. public function _dccrtype()
  7394. {
  7395. $classid = $this->classid->sku();
  7396. $pm = $classid;
  7397. $typeclass = array();
  7398. $tc = $this->typeclass->find_all();
  7399. foreach ($tc as $v) {
  7400. $typeclass[$v['id']] = $v;
  7401. }
  7402. $prc = array();
  7403. $purchase = $this->purchase->find_all();
  7404. foreach ($purchase as $k => $v) {
  7405. $prc[$v['id']] = $v['title'];
  7406. }
  7407. if (isset($_GET['sid'])) {
  7408. $wh = array();
  7409. $w = $this->warehouse->find_all('1=1', 'id,title');
  7410. foreach ($w as $v) {
  7411. $wh[$v['id']] = $v['title'];
  7412. }
  7413. $type = $this->input->get('excel', true);
  7414. $category = $this->input->get('category', true);
  7415. $size = $this->input->get('size', true);
  7416. $grade = $this->input->get('grade', true);
  7417. $color = $this->input->get('color', true);
  7418. $lowe = $this->input->get('lowe', true);
  7419. $sku = $this->input->get('sku', true);
  7420. $warehouse = $this->input->get('warehouse', true);
  7421. $lacetype = $this->input->get('lacetype', true);
  7422. $lacecolor = $this->input->get('lacecolor', true);
  7423. $density = $this->input->get('density', true);
  7424. $haircap = $this->input->get('haircap', true);
  7425. $purchase = $this->input->get('purchase', true);
  7426. $title = $this->input->get('title', true);
  7427. $state = $this->input->get('state', true);
  7428. $sid = $this->input->get('sid', true);
  7429. $ktime = $this->input->get('ktime', true);
  7430. $jtime = $this->input->get('jtime', true);
  7431. $ktime = strtotime($ktime);
  7432. $jtime = strtotime($jtime);
  7433. $where = "1=1";
  7434. $gj = "";
  7435. $ck = "";
  7436. if ($category) {
  7437. $where .= " and features like '%-$category-%'";
  7438. }
  7439. if ($size) {
  7440. $where .= " and features like '%-$size-%'";
  7441. }
  7442. if ($grade) {
  7443. $where .= " and features like '%-$grade-%'";
  7444. }
  7445. if ($color) {
  7446. $where .= " and features like '%-$color-%'";
  7447. }
  7448. if ($lowe) {
  7449. $where .= " and features like '%-$lowe-%'";
  7450. }
  7451. if ($warehouse) {
  7452. $where .= " and warehouse = '$warehouse'";
  7453. }
  7454. if ($purchase) {
  7455. $where .= " and purchase = '$purchase'";
  7456. }
  7457. if ($state) {
  7458. $where .= " and state = '$state'";
  7459. }
  7460. if ($lacetype) {
  7461. $where .= " and features like '%-$lacetype-%'";
  7462. }
  7463. if ($lacecolor) {
  7464. $where .= " and features like '%-$lacecolor-%'";
  7465. }
  7466. if ($density) {
  7467. $where .= " and features like '%-$density-%'";
  7468. }
  7469. if ($haircap) {
  7470. $where .= " and features like '%-$haircap-%'";
  7471. }
  7472. if ($title) {
  7473. $title = trim($title, ' ');
  7474. $title = trim($title, ' ');
  7475. $where .= " and title like '%$title%'";
  7476. }
  7477. if ($sku) {
  7478. $sku = trim($sku, ' ');
  7479. $sku = trim($sku, ' ');
  7480. $where .= " and sku like '%$sku%'";
  7481. }
  7482. if ($ktime && $jtime) {
  7483. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7484. }
  7485. $sidwhere = '';
  7486. if ($sid) {
  7487. $sd = "";
  7488. $s = explode(',', trim($sid, ','));
  7489. foreach ($s as $value) {
  7490. $sd .= " id = " . $value . " or";
  7491. }
  7492. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7493. }
  7494. //数据排序
  7495. $order_str = "time desc";
  7496. if (empty($page)) {
  7497. $start = 0;
  7498. $perpage = 1;
  7499. } else {
  7500. $start = ($page - 1) * $perpage;
  7501. }
  7502. $wh = array();
  7503. $w = $this->warehouse->find_all('1=1', 'id,title');
  7504. foreach ($w as $v) {
  7505. $wh[$v['id']] = $v['title'];
  7506. }
  7507. $wt = array();
  7508. $whlabel_type = $this->whlabel_type->find_all();
  7509. foreach ($whlabel_type as $v) {
  7510. $wt[$v['id']] = $v['title'];
  7511. }
  7512. $classid = $this->classid->sku();
  7513. $list = array();
  7514. $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');
  7515. foreach ($rows_r as $key => $value) {
  7516. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7517. $pm = $classid;
  7518. $jm = $classid;
  7519. $rows_r[$key]['enter'] = '入库';
  7520. $rows_r[$key]['time'] = $value['enter'];
  7521. if ($value['rktype'] == 1) {
  7522. $rows_r[$key]['rktype'] = '采购入库';
  7523. } else if ($value['rktype'] == 2) {
  7524. $rows_r[$key]['rktype'] = '盘盈调整';
  7525. } else if ($value['rktype'] == 3) {
  7526. $rows_r[$key]['rktype'] = '其他调整入库';
  7527. } else if ($value['rktype'] == 4) {
  7528. $rows_r[$key]['rktype'] = '其他调整入库';
  7529. } else if ($value['rktype'] == 5) {
  7530. $rows_r[$key]['rktype'] = '退库入库';
  7531. } else if ($value['rktype'] == 6) {
  7532. $rows_r[$key]['rktype'] = '退货可用入库';
  7533. } else if ($value['rktype'] == 7) {
  7534. $rows_r[$key]['rktype'] = '形态转换入库';
  7535. } else {
  7536. $rows_r[$key]['rktype'] = '';
  7537. }
  7538. $features = explode('-', trim($value['features'], '-'));
  7539. foreach ($features as $v) {
  7540. if (isset($typeclass[$v])) {
  7541. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7542. $pm[$typeclass[$v]['classid']] = $zh[0];
  7543. }
  7544. if (isset($typeclass[$v])) {
  7545. if (isset($jm[$typeclass[$v]['classid']])) {
  7546. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7547. }
  7548. }
  7549. }
  7550. $zh = implode(" ", $pm);
  7551. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7552. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7553. $rows_r[$key]['zh'] = $zh;
  7554. $jm = array_filter($jm);
  7555. $rows_r[$key]['features'] = implode("-", $jm);
  7556. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7557. }
  7558. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout,state');
  7559. foreach ($rows_c as $key => $value) {
  7560. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7561. $pm = $classid;
  7562. $jm = $classid;
  7563. $rows_c[$key]['time'] = $value['outk'];
  7564. $rows_c[$key]['outk'] = '出库';
  7565. if ($value['cktype'] == 1) {
  7566. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7567. } else if ($value['cktype'] == 2) {
  7568. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7569. } else if ($value['cktype'] == 3) {
  7570. $rows_c[$key]['cktype'] = '盘亏调整';
  7571. } else if ($value['cktype'] == 4) {
  7572. $rows_c[$key]['cktype'] = '其他调整出库';
  7573. } else if ($value['cktype'] == 5) {
  7574. $rows_c[$key]['cktype'] = '形态转换出库';
  7575. } else {
  7576. $rows_c[$key]['cktype'] = '';
  7577. }
  7578. unset($rows_c[$key]['state']);
  7579. $features = explode('-', trim($value['features'], '-'));
  7580. foreach ($features as $v) {
  7581. if (isset($typeclass[$v])) {
  7582. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7583. $pm[$typeclass[$v]['classid']] = $zh[0];
  7584. }
  7585. if (isset($typeclass[$v])) {
  7586. if (isset($jm[$typeclass[$v]['classid']])) {
  7587. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7588. }
  7589. }
  7590. }
  7591. $zh = implode(" ", $pm);
  7592. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7593. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7594. $rows_c[$key]['zh'] = $zh;
  7595. $jm = array_filter($jm);
  7596. $rows_c[$key]['features'] = implode("-", $jm);
  7597. $rows_c[$key]['number'] = 1;
  7598. }
  7599. $merged = $rows_r;
  7600. foreach ($rows_c as $key => $value) {
  7601. if (isset($merged[$key])) {
  7602. $merged[] = $value;
  7603. } else {
  7604. $merged[$key] = $value;
  7605. }
  7606. }
  7607. usort($merged, function ($a, $b) {
  7608. return $a['time'] - $b['time'];
  7609. });
  7610. foreach ($merged as $key => $value) {
  7611. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7612. }
  7613. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7614. $titlename = "<table border=1>
  7615. <tr align='center'>
  7616. <td>仓库</td>
  7617. <td>SKU</td>
  7618. <td>商品名称</td>
  7619. <td>仓库品名</td>
  7620. <td>料号</td>
  7621. <td>时间</td>
  7622. <td>操作</td>
  7623. <td>类型</td>
  7624. <td>数量</td>
  7625. <td>备注</td>
  7626. </tr>
  7627. </table>";
  7628. $filename = $title . ".xlsx";
  7629. $tail = "";
  7630. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7631. }
  7632. }
  7633. /*************************************处理exceljs导出****************************************************/
  7634. public function _excelrjs(){
  7635. if (isset($_GET['excel'])) {
  7636. $category = $this->input->get('category', true);
  7637. $size = $this->input->get('size', true);
  7638. $grade = $this->input->get('grade', true);
  7639. $color = $this->input->get('color', true);
  7640. $lowe = $this->input->get('lowe', true);
  7641. $sku = $this->input->get('sku', true);
  7642. $warehouse = $this->input->get('warehouse', true);
  7643. $purchase = $this->input->get('purchase', true);
  7644. $ktime = $this->input->get('ktime', true);
  7645. $jtime = $this->input->get('jtime', true);
  7646. $ktime = strtotime($ktime);
  7647. $jtime = strtotime($jtime);
  7648. $where = "1=1";
  7649. $gj = "";
  7650. $ck = "";
  7651. if ($category) {
  7652. $where .= " and features like '%-$category-%'";
  7653. }
  7654. if ($size) {
  7655. $where .= " and features like '%-$size-%'";
  7656. }
  7657. if ($grade) {
  7658. $where .= " and features like '%-$grade-%'";
  7659. }
  7660. if ($color) {
  7661. $where .= " and features like '%-$color-%'";
  7662. }
  7663. if ($lowe) {
  7664. $where .= " and features like '%-$lowe-%'";
  7665. }
  7666. if ($warehouse) {
  7667. $where .= " and warehouse = '$warehouse'";
  7668. }
  7669. if ($purchase) {
  7670. $where .= " and purchase = '$purchase'";
  7671. }
  7672. if ($sku) {
  7673. $where .= " and sku = '$sku'";
  7674. }
  7675. if ($ktime && $jtime) {
  7676. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7677. }
  7678. //数据排序
  7679. $order_str = "id desc";
  7680. if (empty($page)) {
  7681. $start = 0;
  7682. $perpage = 1;
  7683. } else {
  7684. $start = ($page - 1) * $perpage;
  7685. }
  7686. $list = array();
  7687. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7688. foreach ($rows as $value) {
  7689. $ck = $this->warehouse->read($value['warehouse']);
  7690. $warehouse = $ck['title'];
  7691. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7692. $retreatwarehouse = $tkck['title'];
  7693. $gy = $this->purchase->read($value['purchase']);
  7694. $purchase = $gy['title'];
  7695. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7696. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7697. }
  7698. if(empty($list)){
  7699. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7700. }else{
  7701. $final_list = [];
  7702. foreach($list as $v){
  7703. $final_list[] = array_values($v);
  7704. }
  7705. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7706. array_unshift($final_list,[
  7707. "仓库","SKU","商品名称","时间","数量"
  7708. ]);
  7709. array_unshift($final_list,[
  7710. $title,"","","",""
  7711. ]);
  7712. $merges = [
  7713. [
  7714. "s"=>["r"=>0,"c"=>0],
  7715. "e"=>["r"=>0,"c"=>4]
  7716. ]
  7717. ];
  7718. $cols = [
  7719. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7720. ];
  7721. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7722. }
  7723. }
  7724. }
  7725. //出库、退库导出
  7726. public function _excelctjs()
  7727. {
  7728. $classid = $this->classid->sku();
  7729. $pm = $classid;
  7730. $typeclass = array();
  7731. $tc = $this->typeclass->find_all();
  7732. foreach ($tc as $v) {
  7733. $typeclass[$v['id']] = $v;
  7734. }
  7735. $prc = array();
  7736. $purchase = $this->purchase->find_all();
  7737. foreach ($purchase as $k => $v) {
  7738. $prc[$v['id']] = $v['title'];
  7739. }
  7740. if (isset($_GET['excel'])) {
  7741. $wh = array();
  7742. $w = $this->warehouse->find_all('1=1', 'id,title');
  7743. foreach ($w as $v) {
  7744. $wh[$v['id']] = $v['title'];
  7745. }
  7746. $type = $this->input->get('excel', true);
  7747. $category = $this->input->get('category', true);
  7748. $size = $this->input->get('size', true);
  7749. $grade = $this->input->get('grade', true);
  7750. $color = $this->input->get('color', true);
  7751. $lowe = $this->input->get('lowe', true);
  7752. $sku = $this->input->get('sku', true);
  7753. $title = $this->input->get('title', true);
  7754. $warehouse = $this->input->get('warehouse', true);
  7755. $purchase = $this->input->get('purchase', true);
  7756. $lacetype = $this->input->get('lacetype', true);
  7757. $haircap = $this->input->get('haircap', true);
  7758. $lacecolor = $this->input->get('lacecolor', true);
  7759. $density = $this->input->get('density', true);
  7760. $details = $this->input->get('details', true);
  7761. $state = $this->input->get('state', true);
  7762. $shop = $this->input->get('shop', true);
  7763. $hairnumber = $this->input->get('hairnumber', true);
  7764. $type_leixi = $this->input->get('type', true);
  7765. $cpbz = $this->input->get('cpbz', true);
  7766. $sm = $this->input->get('sm', true);
  7767. $sid = $this->input->get('sid', true);
  7768. $ktime = $this->input->get('ktime', true);
  7769. $jtime = $this->input->get('jtime', true);
  7770. $ktime = strtotime($ktime);
  7771. $jtime = strtotime($jtime);
  7772. //$where = " 1=1 ";
  7773. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7774. $where = " sku != '' ";
  7775. $gj = "";
  7776. $ck = "";
  7777. if ($category) {
  7778. $where .= " and features like '%-$category-%'";
  7779. }
  7780. if ($size) {
  7781. $where .= " and features like '%-$size-%'";
  7782. }
  7783. if ($grade) {
  7784. $where .= " and features like '%-$grade-%'";
  7785. }
  7786. if ($color) {
  7787. $where .= " and features like '%-$color-%'";
  7788. }
  7789. if ($lowe) {
  7790. $where .= " and features like '%-$lowe-%'";
  7791. }
  7792. if ($warehouse) {
  7793. $where .= " and warehouse = '$warehouse'";
  7794. }
  7795. if ($purchase) {
  7796. $where .= " and purchase = '$purchase'";
  7797. }
  7798. if ($state) {
  7799. $where .= " and state = '$state'";
  7800. }
  7801. if ($lacetype) {
  7802. $where .= " and features like '%-$lacetype-%'";
  7803. }
  7804. if ($lacecolor) {
  7805. $where .= " and features like '%-$lacecolor-%'";
  7806. }
  7807. if ($density) {
  7808. $where .= " and features like '%-$density-%'";
  7809. }
  7810. if ($haircap) {
  7811. $where .= " and features like '%-$haircap-%'";
  7812. }
  7813. if ($details) {
  7814. $where .= " and details = '$details'";
  7815. }
  7816. if ($shop) {
  7817. $where .= " and shop like '%$shop%'";
  7818. }
  7819. if ($title) {
  7820. $title = trim($title, ' ');
  7821. $title = trim($title, ' ');
  7822. $where .= " and title like '%$title%'";
  7823. }
  7824. if (!empty($hairnumber)) {
  7825. $where .= " and features like '%-128-%' ";
  7826. if ($hairnumber < 0) {
  7827. $class_list = $this->typeclass->find_all('classid = 43');
  7828. foreach ($class_list as $v) {
  7829. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7830. }
  7831. } else {
  7832. $where .= " and features like '%-$hairnumber-%'";
  7833. }
  7834. }
  7835. if ($type_leixi) {
  7836. $where .= " and type = '$type_leixi'";
  7837. }
  7838. if ($cpbz) {
  7839. $where .= " and cpbz like '%$cpbz%' ";
  7840. }
  7841. if ($sm) {
  7842. $where .= " and sm like '%$sm%' ";
  7843. }
  7844. if ($sku) {
  7845. $sku = trim($sku, ' ');
  7846. $sku = trim($sku, ' ');
  7847. $where .= " and sku like '%$sku%'";
  7848. }
  7849. if ($ktime && $jtime) {
  7850. if ($type == 1) {
  7851. $tl = '出库';
  7852. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7853. } else if ($type == 2) {
  7854. $tl = '退库';
  7855. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7856. } else if ($type == 3) {
  7857. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7858. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7859. } else if ($type == 4) {
  7860. $tl = '出库+零售';
  7861. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7862. } else if ($type == 5) {
  7863. $tl = '零售';
  7864. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7865. }
  7866. }
  7867. $sidwhere = '';
  7868. if ($sid) {
  7869. $sd = "";
  7870. $s = explode(',', trim($sid, ','));
  7871. foreach ($s as $value) {
  7872. $sd .= " id = " . $value . " or";
  7873. }
  7874. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7875. }
  7876. //数据排序
  7877. $order_str = "time desc";
  7878. if (empty($page)) {
  7879. $start = 0;
  7880. $perpage = 1;
  7881. } else {
  7882. $start = ($page - 1) * $perpage;
  7883. }
  7884. //取得信息列表
  7885. if ($type != 3 && $type != 5) {
  7886. if ($type == 1 || $type == 4) {
  7887. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7888. foreach ($info_list as $key => $value) {
  7889. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7890. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7891. $warehouse = $this->warehouse->read($value['warehouse']);
  7892. $info_list[$key]['warehouse'] = $warehouse['title'];
  7893. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7894. $features = explode('-', trim($features, '-'));
  7895. $pm = $classid;
  7896. foreach ($features as $k => $v) {
  7897. if ($v != 0) {
  7898. if (!isset($typeclass[$v])) {
  7899. continue;
  7900. }
  7901. if (isset($pm[$typeclass[$v]['classid']])) {
  7902. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7903. $tz = explode('|', $typeclass[$v]['zh']);
  7904. $pm[$typeclass[$v]['classid']] = $tz[0];
  7905. } else {
  7906. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7907. }
  7908. }
  7909. }
  7910. }
  7911. $zh = implode(" ", $pm);
  7912. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7913. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7914. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7915. $info_list[$key]['features'] = $zh;
  7916. }
  7917. $final_list = [];
  7918. foreach($info_list as $k=>$v){
  7919. $number = "";
  7920. if(!empty($v['orderinfo'])){
  7921. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7922. if(!empty($tmp_info['number'])){
  7923. $number = $tmp_info['number'];
  7924. }
  7925. }
  7926. $final_list[] = [
  7927. 'warehouse'=>$v['warehouse'],
  7928. 'purchase'=>$v['purchase'],
  7929. 'sku'=>$v['sku'],
  7930. 'title'=>$v['title'],
  7931. 'features'=>$v['features'],
  7932. 'label'=>$v['label'],
  7933. 'orderinfo'=>$v['orderinfo'],
  7934. 'number'=>$number,
  7935. 'waybill'=>$v['waybill'],
  7936. 'outk'=>$v['outk'],
  7937. ];
  7938. }
  7939. } else {
  7940. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7941. foreach ($info_list as $key => $value) {
  7942. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7943. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7944. $warehouse = $this->warehouse->read($value['warehouse']);
  7945. $info_list[$key]['warehouse'] = $warehouse['title'];
  7946. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7947. $features = explode('-', trim($features, '-'));
  7948. $pm = $classid;
  7949. foreach ($features as $k => $v) {
  7950. if ($v != 0) {
  7951. if (!isset($typeclass[$v])) {
  7952. continue;
  7953. }
  7954. if (isset($pm[$typeclass[$v]['classid']])) {
  7955. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7956. $tz = explode('|', $typeclass[$v]['zh']);
  7957. $pm[$typeclass[$v]['classid']] = $tz[0];
  7958. } else {
  7959. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7960. }
  7961. }
  7962. }
  7963. }
  7964. $zh = implode(" ", $pm);
  7965. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7966. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7967. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7968. $info_list[$key]['features'] = $zh;
  7969. }
  7970. $final_list = [];
  7971. foreach($info_list as $k=>$v){
  7972. $number = "";
  7973. if(!empty($v['orderinfo'])){
  7974. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7975. if(!empty($tmp_info['number'])){
  7976. $number = $tmp_info['number'];
  7977. }
  7978. }
  7979. $final_list[] = [
  7980. 'warehouse'=>$v['warehouse'],
  7981. 'purchase'=>$v['purchase'],
  7982. 'sku'=>$v['sku'],
  7983. 'title'=>$v['title'],
  7984. 'features'=>$v['features'],
  7985. 'label'=>$v['label'],
  7986. 'orderinfo'=>$v['orderinfo'],
  7987. 'number'=>$number,
  7988. 'waybill'=>$v['waybill'],
  7989. 'retreat'=>$v['retreat'],
  7990. ];
  7991. }
  7992. }
  7993. if(empty($final_list)){
  7994. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7995. }else{
  7996. $end_list = [];
  7997. foreach($final_list as $v){
  7998. $end_list[] = array_values($v);
  7999. }
  8000. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8001. array_unshift($end_list,[
  8002. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8003. ]);
  8004. array_unshift($end_list,[
  8005. $title,"","","","","","","","",""
  8006. ]);
  8007. $merges = [
  8008. [
  8009. "s"=>["r"=>0,"c"=>0],
  8010. "e"=>["r"=>0,"c"=>9]
  8011. ]
  8012. ];
  8013. $cols = [
  8014. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8015. ];
  8016. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8017. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8018. ] )));
  8019. }
  8020. } else if ($type == 5) {
  8021. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8022. foreach ($info_list as $key => $value) {
  8023. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8024. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8025. $warehouse = $this->warehouse->read($value['warehouse']);
  8026. $info_list[$key]['warehouse'] = $warehouse['title'];
  8027. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8028. $features = explode('-', trim($features, '-'));
  8029. $pm = $classid;
  8030. foreach ($features as $k => $v) {
  8031. if ($v != 0) {
  8032. if (!isset($typeclass[$v])) {
  8033. continue;
  8034. }
  8035. if (isset($pm[$typeclass[$v]['classid']])) {
  8036. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8037. $tz = explode('|', $typeclass[$v]['zh']);
  8038. $pm[$typeclass[$v]['classid']] = $tz[0];
  8039. } else {
  8040. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8041. }
  8042. }
  8043. }
  8044. }
  8045. $zh = implode(" ", $pm);
  8046. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8047. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8048. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8049. $info_list[$key]['features'] = $zh;
  8050. }
  8051. if(empty($info_list)){
  8052. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8053. }else{
  8054. $final_list = [];
  8055. foreach($info_list as $v){
  8056. $final_list[] = array_values($v);
  8057. }
  8058. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8059. array_unshift($final_list,[
  8060. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8061. ]);
  8062. array_unshift($final_list,[
  8063. $title,"","","","","","",
  8064. ]);
  8065. $merges = [
  8066. [
  8067. "s"=>["r"=>0,"c"=>0],
  8068. "e"=>["r"=>0,"c"=>6]
  8069. ]
  8070. ];
  8071. $cols = [
  8072. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8073. ];
  8074. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8075. }
  8076. } else {
  8077. $wh = array();
  8078. $w = $this->warehouse->find_all('1=1', 'id,title');
  8079. foreach ($w as $v) {
  8080. $wh[$v['id']] = $v['title'];
  8081. }
  8082. $wt = array();
  8083. $whlabel_type = $this->whlabel_type->find_all();
  8084. foreach ($whlabel_type as $v) {
  8085. $wt[$v['id']] = $v['title'];
  8086. }
  8087. $classid = $this->classid->sku();
  8088. $list = array();
  8089. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8090. foreach ($rows as $key => $value) {
  8091. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8092. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8093. $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');
  8094. $details = array();
  8095. $cpid = array();
  8096. $cpbz = array();
  8097. $c = 0;
  8098. $g = 0;
  8099. $x = 0;
  8100. $t = 0;
  8101. $s = 0;
  8102. $q = 0;
  8103. foreach ($sd as $k => $v) {
  8104. if ($v['state'] == 0) {
  8105. $c++;
  8106. }
  8107. if ($v['state'] != 9) {
  8108. $g++;
  8109. }
  8110. if ($v['outk'] > 1) {
  8111. $x++;
  8112. }
  8113. if ($v['retreat'] > 0) {
  8114. $t++;
  8115. }
  8116. if ($v['state'] == 8) {
  8117. $s++;
  8118. }
  8119. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8120. $q++;
  8121. }
  8122. $details[$v['details']] = $v['details'];
  8123. if ($v['cpid'] != 0) {
  8124. $cpid[$v['cpid']] = $v['cpid'];
  8125. }
  8126. if ($v['cpbz'] != '') {
  8127. $cpbz[$v['cpbz']] = $v['cpbz'];
  8128. }
  8129. }
  8130. if (isset($wt[$value['type']])) {
  8131. $rows[$key]['type'] = $wt[$value['type']];
  8132. } else {
  8133. $rows[$key]['type'] = '未设置';
  8134. }
  8135. $rows[$key]['details'] = implode("、", $details);
  8136. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8137. $ftime = time() - 15 * 24 * 3600;
  8138. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8139. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8140. $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);
  8141. $rows[$key]['c'] = $c;
  8142. $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);
  8143. $rows[$key]['t'] = $t;
  8144. $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'] . '"');
  8145. $rows[$key]['z'] = $z;
  8146. // $jm = $classid;
  8147. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8148. $features = explode('-', trim($features, '-'));
  8149. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8150. }
  8151. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8152. $final_list =[];
  8153. foreach($tmp_list as $k=>$v){
  8154. $final_list[] = [
  8155. "warehouse"=>$v['warehouse'],
  8156. "purchase"=>$v['purchase'],
  8157. "details"=>$v['details'],
  8158. "cpid"=>$v['cpid'],
  8159. "sku"=>$v['sku'],
  8160. "title"=>$v['title'],
  8161. "features"=>$v['pm'],
  8162. "cpbz"=>$v['cpbz'],
  8163. "sm"=>$v['sm'],
  8164. "type"=>$v['type'],
  8165. "g"=>$v["g"],
  8166. "c"=>$v["c"],
  8167. "x"=>$v["x"],
  8168. "t"=>$v["t"],
  8169. "z"=>$v["z"],
  8170. "jm"=>$v["jm"],
  8171. "weight"=>$v["weight"],
  8172. "asd"=>$v["asd"],
  8173. ];
  8174. }
  8175. if(empty($final_list)){
  8176. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8177. }else{
  8178. $end_list = [];
  8179. foreach($final_list as $v){
  8180. $end_list[] = array_values($v);
  8181. }
  8182. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8183. array_unshift($end_list,[
  8184. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8185. ]);
  8186. array_unshift($end_list,[
  8187. $title,"","","","","","","","","","","","","","","","","",""
  8188. ]);
  8189. $merges = [
  8190. [
  8191. "s"=>["r"=>0,"c"=>0],
  8192. "e"=>["r"=>0,"c"=>6]
  8193. ]
  8194. ];
  8195. $cols = [
  8196. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8197. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8198. ];
  8199. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8200. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8201. ])));
  8202. }
  8203. }
  8204. }
  8205. }
  8206. public function _exceljxcjs(){
  8207. $classid = $this->classid->sku();
  8208. $pm = $classid;
  8209. $typeclass = array();
  8210. $tc = $this->typeclass->find_all();
  8211. foreach ($tc as $v) {
  8212. $typeclass[$v['id']] = $v;
  8213. }
  8214. $prc = array();
  8215. $purchase = $this->purchase->find_all();
  8216. foreach ($purchase as $k => $v) {
  8217. $prc[$v['id']] = $v['title'];
  8218. }
  8219. if(!isset($_GET['excel'])){
  8220. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8221. }
  8222. $where = "sku != 'Preset'";
  8223. //数据排序
  8224. $order_str = "id desc";
  8225. if (empty($page)) {
  8226. $start = 0;
  8227. $perpage = 1;
  8228. } else {
  8229. $start = ($page - 1) * $perpage;
  8230. }
  8231. $category = $this->input->get('category', true);
  8232. $warehouse = $this->input->get('warehouse', true);
  8233. $excelid = $this->input->get('sid', true);
  8234. if ($category) {
  8235. $where .= " and features like '%-$category-%'";
  8236. }
  8237. if ($warehouse) {
  8238. $where .= " and warehouse = '$warehouse'";
  8239. }
  8240. $xzid = '';
  8241. if ($excelid) {
  8242. $excelid = explode(',', trim($excelid, ','));
  8243. foreach ($excelid as $key => $value) {
  8244. $xzid .= " id = " . $value . " or";
  8245. }
  8246. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8247. }
  8248. $wt = array();
  8249. $whlabel_type = $this->whlabel_type->find_all();
  8250. foreach ($whlabel_type as $v) {
  8251. $wt[$v['id']] = $v['title'];
  8252. }
  8253. $wh = array();
  8254. $w = $this->warehouse->find_all('1=1', 'id,title');
  8255. foreach ($w as $v) {
  8256. $wh[$v['id']] = $v['title'];
  8257. }
  8258. $list = array();
  8259. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8260. foreach ($rows as $key => $value) {
  8261. if (isset($wt[$value['type']])) {
  8262. $rows[$key]['type'] = $wt[$value['type']];
  8263. } else {
  8264. $rows[$key]['type'] = '未设置';
  8265. }
  8266. $bm = '03';
  8267. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8268. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8269. $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');
  8270. $details = array();
  8271. $cpid = array();
  8272. $cpbz = array();
  8273. $c = 0;
  8274. $g = 0;
  8275. $x = 0;
  8276. $t = 0;
  8277. $s = 0;
  8278. $q = 0;
  8279. foreach ($sd as $k => $v) {
  8280. if ($v['state'] == 0) {
  8281. $c++;
  8282. if ($v['cpid'] != 0) {
  8283. $cpid[$v['cpid']] = $v['cpid'];
  8284. }
  8285. if ($v['cpbz'] != '') {
  8286. $cpbz[$v['cpbz']] = $v['cpbz'];
  8287. }
  8288. }
  8289. if ($v['state'] != 9) {
  8290. $g++;
  8291. }
  8292. if ($v['state'] == 1) {
  8293. $x++;
  8294. }
  8295. if ($v['state'] == 2) {
  8296. $t++;
  8297. }
  8298. if ($v['state'] == 8) {
  8299. $s++;
  8300. }
  8301. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8302. $q++;
  8303. }
  8304. $details[$v['details']] = $v['details'];
  8305. }
  8306. $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'] . '"');
  8307. $rows[$key]['details'] = implode("、", $details);
  8308. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8309. $number = $value['number'];
  8310. $ftime = time() - 15 * 24 * 3600;
  8311. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8312. $rows[$key]['number'] = $g;
  8313. $rows[$key]['c'] = $c;
  8314. $rows[$key]['x'] = $x;
  8315. $rows[$key]['t'] = $t;
  8316. $rows[$key]['s'] = $s;
  8317. $rows[$key]['q'] = $q;
  8318. $rows[$key]['z'] = $z;
  8319. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8320. $features = explode('-', trim($features, '-'));
  8321. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8322. }
  8323. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8324. $final_list = [];
  8325. foreach ($list as $k => $v) {
  8326. if (empty($v['sku'])) {
  8327. continue;
  8328. }
  8329. $final_list[] = [
  8330. $v["warehouse"],
  8331. $v["purchase"],
  8332. $v["details"],
  8333. $v["cpid"],
  8334. $v["dbcontent"],
  8335. $v["sku"],
  8336. $v["bm"],
  8337. $v["jm"],
  8338. $v["title"],
  8339. $v["pm"],
  8340. $v["cpbz"],
  8341. $v["sm"],
  8342. $v["type"],
  8343. $v["number"],
  8344. $v["c"],
  8345. $v["x"],
  8346. $v["t"],
  8347. $v["s"],
  8348. $v["q"],
  8349. $v["z"],
  8350. $v['weight'],
  8351. ];
  8352. }
  8353. if(empty($final_list)){
  8354. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8355. }
  8356. $title = "总进销存统计表";
  8357. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8358. $merges = [
  8359. [
  8360. "s"=>["r"=>0,"c"=>0],
  8361. "e"=>["r"=>0,"c"=>21]
  8362. ]
  8363. ];
  8364. $cols = [
  8365. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8366. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8367. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8368. ];
  8369. array_unshift($final_list, $first_row);
  8370. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8371. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8372. }
  8373. public function _summaryjs($arg_array)
  8374. {
  8375. $prc = array();
  8376. $purchase = $this->purchase->find_all();
  8377. foreach ($purchase as $k => $v) {
  8378. $prc[$v['id']] = $v['title'];
  8379. }
  8380. if (isset($_GET['excel'])) {
  8381. $ktime = $this->input->get('ktime', true);
  8382. $jtime = $this->input->get('jtime', true);
  8383. $ktime = strtotime($ktime);
  8384. $jtime = strtotime($jtime);
  8385. $where = "1=1";
  8386. if ($ktime && $jtime) {
  8387. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8388. }
  8389. //数据排序
  8390. $order_str = "time desc";
  8391. if (empty($page)) {
  8392. $start = 0;
  8393. $perpage = 1;
  8394. } else {
  8395. $start = ($page - 1) * $perpage;
  8396. }
  8397. //取得信息列表
  8398. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8399. foreach ($info_list as $key => $value) {
  8400. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8401. $warehouse = $this->warehouse->read($value['warehouse']);
  8402. $info_list[$key]['warehouse'] = $warehouse['title'];
  8403. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8404. $details = array();
  8405. $cpid = array();
  8406. foreach ($x as $k => $v) {
  8407. if ($v['details'] != '') {
  8408. $details[$v['details']] = $v['details'];
  8409. }
  8410. if ($v['cpid'] != 0) {
  8411. $cpid[$v['cpid']] = $v['cpid'];
  8412. }
  8413. }
  8414. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8415. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8416. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8417. $info_list[$key]['s'] = $s;
  8418. $info_list[$key]['x'] = count($x);
  8419. }
  8420. if(empty($info_list)){
  8421. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8422. }
  8423. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8424. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8425. $merges = [
  8426. [
  8427. "s"=>["r"=>0,"c"=>0],
  8428. "e"=>["r"=>0,"c"=>7]
  8429. ]
  8430. ];
  8431. $cols = [
  8432. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8433. ];
  8434. $final_list = [];
  8435. foreach($info_list as $k => $v){
  8436. $final_list[] = array_values($v);
  8437. }
  8438. array_unshift($final_list, $first_row);
  8439. array_unshift($final_list,[
  8440. $title,"","","","","","","","",
  8441. ]);
  8442. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8443. $titlename = "<table border=1>
  8444. <tr align='center'>
  8445. <td>仓库</td>
  8446. <td>供应商</td>
  8447. <td>出库位置</td>
  8448. <td>出库编码</td>
  8449. <td>SKU</td>
  8450. <td>产品名</td>
  8451. <td>总剩余库存</td>
  8452. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8453. </tr>
  8454. </table>";
  8455. $filename = $title . ".xls";
  8456. $tail = "";
  8457. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8458. }
  8459. }
  8460. public function _uckjs()
  8461. {
  8462. if (isset($_GET['excel'])) {
  8463. $tc = array();
  8464. $typeclass = $this->typeclass->find_all();
  8465. foreach ($typeclass as $v) {
  8466. $tc[$v['id']] = $v['zh'];
  8467. }
  8468. $first_row = [
  8469. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8470. ];
  8471. $t = array();
  8472. $rq = '';
  8473. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8474. $ts = $ts / (24 * 3600);
  8475. for ($i = 0; $i < $ts; $i++) {
  8476. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8477. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8478. }
  8479. $day_len = count($t);
  8480. $first_row[] = "本月出库";
  8481. $merges = [
  8482. ];
  8483. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8484. $excel_key = 1;
  8485. $final_list = [];
  8486. foreach ($info_list as $k => $v) {
  8487. $features = explode('-', trim($v['features'], '-'));
  8488. if (!isset($features[3]) || !isset($features[4])) {
  8489. continue;
  8490. }
  8491. $tmp = [];
  8492. $tmp[0] = $tc[$features[0]]; //类型
  8493. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8494. $tmp[2] = $tc[$features[4]]; //曲度
  8495. $tmp[3] = '';
  8496. if (isset($data[$k][1])) {
  8497. $tmp[3] .=$tmp[1];
  8498. }
  8499. if (isset($data[$k][2])) {
  8500. $tmp[3] .= $tmp[2];
  8501. }
  8502. if (isset($features[5])) {
  8503. $tmp[3] .= $tc[$features[5]];
  8504. }
  8505. if (isset($features[2])) {
  8506. $tmp[3] .= $tc[$features[2]];
  8507. }
  8508. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8509. $tmp[4] = $v['sku'];
  8510. $tmp[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())) . '))'); //月初库存
  8511. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8512. $tmp[7] ="";
  8513. $tmp[8] ="";
  8514. $byck = 0;
  8515. foreach ($t as $vv) {
  8516. $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));
  8517. $tmp[] = ($sl > 0) ? $sl : '';
  8518. $byck += $sl;
  8519. }
  8520. $tmp[] = ($byck > 0) ? $byck : '';
  8521. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8522. // $ztrq = '';
  8523. // $ztsl = '';
  8524. // if (count($zt) > 0) {
  8525. // foreach ($zt as $vv) {
  8526. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8527. // $ztsl .= $vv['num'] . '<br>';
  8528. // }
  8529. // }
  8530. if(empty($zt)){
  8531. $final_list[] = $tmp;
  8532. $excel_key = $excel_key + 1;
  8533. }else{
  8534. $len = count($zt);
  8535. if($len == 1){
  8536. $tmp[7] = $zt[0]['num'] ;
  8537. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8538. $final_list[] = $tmp;
  8539. $excel_key = $excel_key + 1;
  8540. }else{
  8541. foreach($zt as $vv){
  8542. $tmp[7] = "";
  8543. $tmp[8] = "";
  8544. $tmp[7] = $vv['num'];
  8545. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8546. $final_list[] = $tmp;
  8547. }
  8548. $merges[] = [
  8549. "s"=>["r"=>$excel_key,"c"=>0],
  8550. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8551. ];
  8552. $merges[] = [
  8553. "s"=>["r"=>$excel_key,"c"=>1],
  8554. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8555. ];
  8556. $merges[] = [
  8557. "s"=>["r"=>$excel_key,"c"=>2],
  8558. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8559. ];
  8560. $merges[] = [
  8561. "s"=>["r"=>$excel_key,"c"=>3],
  8562. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8563. ];
  8564. $merges[] = [
  8565. "s"=>["r"=>$excel_key,"c"=>4],
  8566. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8567. ];
  8568. $merges[] = [
  8569. "s"=>["r"=>$excel_key,"c"=>5],
  8570. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8571. ];
  8572. $merges[] = [
  8573. "s"=>["r"=>$excel_key,"c"=>6],
  8574. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8575. ];
  8576. for($i=1;$i<=$day_len;$i++){
  8577. $merges[] = [
  8578. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8579. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8580. ];
  8581. }
  8582. $merges[] = [
  8583. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8584. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8585. ];
  8586. $excel_key = $excel_key + $len;
  8587. }
  8588. }
  8589. }
  8590. $title = "详情 " . date("Y-m-d", time());
  8591. if(empty($final_list)){
  8592. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8593. }
  8594. $cols = [
  8595. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8596. ];
  8597. array_unshift($final_list, $first_row);
  8598. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8599. }
  8600. }
  8601. public function _whlabelexcelzhjs(){
  8602. if(empty($_GET['excel'])){
  8603. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8604. }
  8605. $where = "sku != 'Preset' and sku != '' ";
  8606. //数据排序
  8607. $order_str = "id desc";
  8608. if (empty($page)) {
  8609. $start = 0;
  8610. $perpage = 1;
  8611. } else {
  8612. $start = ($page - 1) * $perpage;
  8613. }
  8614. $category = $this->input->get('category', true);
  8615. $warehouse = $this->input->get('warehouse', true);
  8616. $excelid = $this->input->get('sid', true);
  8617. if ($category) {
  8618. $where .= " and features like '%-$category-%'";
  8619. }
  8620. if ($warehouse) {
  8621. $where .= " and warehouse = '$warehouse'";
  8622. }
  8623. $xzid = '';
  8624. if ($excelid) {
  8625. $excelid = explode(',', trim($excelid, ','));
  8626. foreach ($excelid as $key => $value) {
  8627. $xzid .= " id = " . $value . " or";
  8628. }
  8629. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8630. }
  8631. $merges = [
  8632. [
  8633. "s"=>["r"=>0,"c"=>0],
  8634. "e"=>["r"=>0,"c"=>6]
  8635. ]
  8636. ];
  8637. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8638. $excel_index = 2;
  8639. $final_list = [];
  8640. foreach ($rows as $key => $value) {
  8641. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8642. $zh = '';
  8643. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8644. // foreach ($zt_list as $v) {
  8645. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8646. // }
  8647. $zt = array_sum(array_column($zt_list, 'num'));
  8648. $number = $value['number'];
  8649. $ftime = time() - 15 * 24 * 3600;
  8650. $warehouse = $this->warehouse->read($value['warehouse']);
  8651. // $rows[$key]['warehouse'] = $warehouse['title'];
  8652. // $rows[$key]['number'] = $c;
  8653. // $rows[$key]['features'] = $zh;
  8654. //$rows[$key]['hb'] = $c + $zt;
  8655. $tmp = [];
  8656. $tmp[0] = $warehouse['title'];
  8657. $tmp[1] = $value['sku'];
  8658. $tmp[2] = $value['title'];
  8659. $tmp[3] = $c;
  8660. $tmp[4] = "";
  8661. $tmp[5] = $c + $zt;
  8662. if(empty($zt_list)){
  8663. $tmp[4] = "";
  8664. $final_list[] = $tmp;
  8665. $excel_index = $excel_index + 1;
  8666. }else{
  8667. if(count($zt_list) == 1){
  8668. $tmp[4] = "";
  8669. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8670. $final_list[] = $tmp;
  8671. $excel_index = $excel_index + 1;
  8672. }else{
  8673. $len = count($zt_list);
  8674. foreach ($zt_list as $v){
  8675. $tmp[4] = "";
  8676. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8677. $final_list[] = $tmp;
  8678. }
  8679. $merges[] = [
  8680. "s"=>["r"=>$excel_index,"c"=>0],
  8681. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8682. ];
  8683. $merges[] = [
  8684. "s"=>["r"=>$excel_index,"c"=>1],
  8685. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8686. ];
  8687. $merges[] = [
  8688. "s"=>["r"=>$excel_index,"c"=>2],
  8689. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8690. ];
  8691. $merges[] = [
  8692. "s"=>["r"=>$excel_index,"c"=>3],
  8693. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8694. ];
  8695. $merges[] = [
  8696. "s"=>["r"=>$excel_index,"c"=>5],
  8697. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8698. ];
  8699. $excel_index = $excel_index + $len;
  8700. }
  8701. }
  8702. }
  8703. $first_row = [
  8704. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8705. ];
  8706. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8707. if(empty($final_list)){
  8708. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8709. }
  8710. $cols = [
  8711. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8712. ];
  8713. array_unshift($final_list, $first_row);
  8714. array_unshift($final_list, [
  8715. $title,"","","","",""
  8716. ]);
  8717. $end_list = [];
  8718. foreach ($final_list as $key => $value) {
  8719. $end_list[] = array_values($value);
  8720. }
  8721. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8722. }
  8723. //出库、退库导出
  8724. public function _dccrtypejs()
  8725. {
  8726. $classid = $this->classid->sku();
  8727. $pm = $classid;
  8728. $typeclass = array();
  8729. $tc = $this->typeclass->find_all();
  8730. foreach ($tc as $v) {
  8731. $typeclass[$v['id']] = $v;
  8732. }
  8733. $prc = array();
  8734. $purchase = $this->purchase->find_all();
  8735. foreach ($purchase as $k => $v) {
  8736. $prc[$v['id']] = $v['title'];
  8737. }
  8738. if (isset($_GET['sid'])) {
  8739. $wh = array();
  8740. $w = $this->warehouse->find_all('1=1', 'id,title');
  8741. foreach ($w as $v) {
  8742. $wh[$v['id']] = $v['title'];
  8743. }
  8744. $type = $this->input->get('excel', true);
  8745. $category = $this->input->get('category', true);
  8746. $size = $this->input->get('size', true);
  8747. $grade = $this->input->get('grade', true);
  8748. $color = $this->input->get('color', true);
  8749. $lowe = $this->input->get('lowe', true);
  8750. $sku = $this->input->get('sku', true);
  8751. $warehouse = $this->input->get('warehouse', true);
  8752. $lacetype = $this->input->get('lacetype', true);
  8753. $lacecolor = $this->input->get('lacecolor', true);
  8754. $density = $this->input->get('density', true);
  8755. $haircap = $this->input->get('haircap', true);
  8756. $purchase = $this->input->get('purchase', true);
  8757. $title = $this->input->get('title', true);
  8758. $state = $this->input->get('state', true);
  8759. $sid = $this->input->get('sid', true);
  8760. $ktime = $this->input->get('ktime', true);
  8761. $jtime = $this->input->get('jtime', true);
  8762. $ktime = strtotime($ktime);
  8763. $jtime = strtotime($jtime);
  8764. $where = "1=1";
  8765. $gj = "";
  8766. $ck = "";
  8767. if ($category) {
  8768. $where .= " and features like '%-$category-%'";
  8769. }
  8770. if ($size) {
  8771. $where .= " and features like '%-$size-%'";
  8772. }
  8773. if ($grade) {
  8774. $where .= " and features like '%-$grade-%'";
  8775. }
  8776. if ($color) {
  8777. $where .= " and features like '%-$color-%'";
  8778. }
  8779. if ($lowe) {
  8780. $where .= " and features like '%-$lowe-%'";
  8781. }
  8782. if ($warehouse) {
  8783. $where .= " and warehouse = '$warehouse'";
  8784. }
  8785. if ($purchase) {
  8786. $where .= " and purchase = '$purchase'";
  8787. }
  8788. if ($state) {
  8789. $where .= " and state = '$state'";
  8790. }
  8791. if ($lacetype) {
  8792. $where .= " and features like '%-$lacetype-%'";
  8793. }
  8794. if ($lacecolor) {
  8795. $where .= " and features like '%-$lacecolor-%'";
  8796. }
  8797. if ($density) {
  8798. $where .= " and features like '%-$density-%'";
  8799. }
  8800. if ($haircap) {
  8801. $where .= " and features like '%-$haircap-%'";
  8802. }
  8803. if ($title) {
  8804. $title = trim($title, ' ');
  8805. $title = trim($title, ' ');
  8806. $where .= " and title like '%$title%'";
  8807. }
  8808. if ($sku) {
  8809. $sku = trim($sku, ' ');
  8810. $sku = trim($sku, ' ');
  8811. $where .= " and sku like '%$sku%'";
  8812. }
  8813. if ($ktime && $jtime) {
  8814. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8815. }
  8816. $sidwhere = '';
  8817. if ($sid) {
  8818. $sd = "";
  8819. $s = explode(',', trim($sid, ','));
  8820. foreach ($s as $value) {
  8821. $sd .= " id = " . $value . " or";
  8822. }
  8823. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8824. }
  8825. //数据排序
  8826. $order_str = "time desc";
  8827. if (empty($page)) {
  8828. $start = 0;
  8829. $perpage = 1;
  8830. } else {
  8831. $start = ($page - 1) * $perpage;
  8832. }
  8833. $wh = array();
  8834. $w = $this->warehouse->find_all('1=1', 'id,title');
  8835. foreach ($w as $v) {
  8836. $wh[$v['id']] = $v['title'];
  8837. }
  8838. $wt = array();
  8839. $whlabel_type = $this->whlabel_type->find_all();
  8840. foreach ($whlabel_type as $v) {
  8841. $wt[$v['id']] = $v['title'];
  8842. }
  8843. $classid = $this->classid->sku();
  8844. $list = array();
  8845. $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');
  8846. foreach ($rows_r as $key => $value) {
  8847. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8848. $pm = $classid;
  8849. $jm = $classid;
  8850. $rows_r[$key]['enter'] = '入库';
  8851. $rows_r[$key]['time'] = $value['enter'];
  8852. if ($value['rktype'] == 1) {
  8853. $rows_r[$key]['rktype'] = '采购入库';
  8854. } else if ($value['rktype'] == 2) {
  8855. $rows_r[$key]['rktype'] = '盘盈调整';
  8856. } else if ($value['rktype'] == 3) {
  8857. $rows_r[$key]['rktype'] = '其他调整入库';
  8858. } else if ($value['rktype'] == 4) {
  8859. $rows_r[$key]['rktype'] = '其他调整入库';
  8860. } else if ($value['rktype'] == 5) {
  8861. $rows_r[$key]['rktype'] = '退库入库';
  8862. } else if ($value['rktype'] == 6) {
  8863. $rows_r[$key]['rktype'] = '退货可用入库';
  8864. } else if ($value['rktype'] == 7) {
  8865. $rows_r[$key]['rktype'] = '形态转换入库';
  8866. } else {
  8867. $rows_r[$key]['rktype'] = '';
  8868. }
  8869. $features = explode('-', trim($value['features'], '-'));
  8870. foreach ($features as $v) {
  8871. if (isset($typeclass[$v])) {
  8872. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8873. $pm[$typeclass[$v]['classid']] = $zh[0];
  8874. }
  8875. if (isset($typeclass[$v])) {
  8876. if (isset($jm[$typeclass[$v]['classid']])) {
  8877. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8878. }
  8879. }
  8880. }
  8881. $zh = implode(" ", $pm);
  8882. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8883. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8884. $rows_r[$key]['zh'] = $zh;
  8885. $jm = array_filter($jm);
  8886. $rows_r[$key]['features'] = implode("-", $jm);
  8887. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8888. }
  8889. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout,state');
  8890. foreach ($rows_c as $key => $value) {
  8891. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8892. $pm = $classid;
  8893. $jm = $classid;
  8894. $rows_c[$key]['time'] = $value['outk'];
  8895. $rows_c[$key]['outk'] = '出库';
  8896. if ($value['cktype'] == 1) {
  8897. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8898. } else if ($value['cktype'] == 2) {
  8899. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8900. } else if ($value['cktype'] == 3) {
  8901. $rows_c[$key]['cktype'] = '盘亏调整';
  8902. } else if ($value['cktype'] == 4) {
  8903. $rows_c[$key]['cktype'] = '其他调整出库';
  8904. } else if ($value['cktype'] == 5) {
  8905. $rows_c[$key]['cktype'] = '形态转换出库';
  8906. } else {
  8907. $rows_c[$key]['cktype'] = '';
  8908. }
  8909. unset($rows_c[$key]['state']);
  8910. $features = explode('-', trim($value['features'], '-'));
  8911. foreach ($features as $v) {
  8912. if (isset($typeclass[$v])) {
  8913. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8914. $pm[$typeclass[$v]['classid']] = $zh[0];
  8915. }
  8916. if (isset($typeclass[$v])) {
  8917. if (isset($jm[$typeclass[$v]['classid']])) {
  8918. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8919. }
  8920. }
  8921. }
  8922. $zh = implode(" ", $pm);
  8923. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8924. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8925. $rows_c[$key]['zh'] = $zh;
  8926. $jm = array_filter($jm);
  8927. $rows_c[$key]['features'] = implode("-", $jm);
  8928. $rows_c[$key]['number'] = 1;
  8929. }
  8930. $merged = $rows_r;
  8931. foreach ($rows_c as $key => $value) {
  8932. if (isset($merged[$key])) {
  8933. $merged[] = $value;
  8934. } else {
  8935. $merged[$key] = $value;
  8936. }
  8937. }
  8938. usort($merged, function ($a, $b) {
  8939. return $a['time'] - $b['time'];
  8940. });
  8941. foreach ($merged as $key => $value) {
  8942. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8943. }
  8944. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8945. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  8946. $cols = [
  8947. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8948. ];
  8949. $final_list= [];
  8950. foreach($merged as $key => $value){
  8951. $final_list[] = array_values($value) ;
  8952. }
  8953. if(empty($merged)){
  8954. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8955. }
  8956. array_unshift($final_list, $first_row);
  8957. $end_list = [];
  8958. foreach ($final_list as $key => $value) {
  8959. $end_list[] = array_values($value);
  8960. }
  8961. $merges = [];
  8962. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8963. }
  8964. }
  8965. public function _errorexceljs()
  8966. {
  8967. $post = $this->input->post(NULL, TRUE);
  8968. if (isset($_GET['page'])) {
  8969. $page = $this->input->get('page', true);
  8970. $perpage = $this->input->get('perpage', true);
  8971. $sku = $this->input->get('sku', true);
  8972. $warehouse = $this->input->get('warehouse', true);
  8973. $ktime = $this->input->get('ktime', true);
  8974. $jtime = $this->input->get('jtime', true);
  8975. $ktime = strtotime($ktime);
  8976. $jtime = strtotime($jtime);
  8977. $where = "sku != 'Preset'";
  8978. $gj = '';
  8979. if ($sku) {
  8980. $where .= " and sku like '%$sku%'";
  8981. } else {
  8982. if ($ktime && $jtime) {
  8983. $gj = " and time > '$ktime' and time < '$jtime'";
  8984. }
  8985. }
  8986. if ($warehouse) {
  8987. $where .= " and warehouse = '$warehouse'";
  8988. }
  8989. //数据排序
  8990. $order_str = "id desc";
  8991. if (empty($page)) {
  8992. $start = 0;
  8993. $perpage = 1;
  8994. } else {
  8995. $start = ($page - 1) * $perpage;
  8996. }
  8997. //取得信息列表
  8998. $rows = array();
  8999. $list = array();
  9000. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9001. foreach ($info_list as $value) {
  9002. $warehouse = $this->warehouse->read($value['warehouse']);
  9003. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9004. $number = $value['number'];
  9005. $ftime = time() - 15 * 24 * 3600;
  9006. if ($c < 1) {
  9007. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9008. }
  9009. }
  9010. $title = "0库存汇总";
  9011. $first_row = ["仓库","SKU","产品","当前库存"];
  9012. $cols = [
  9013. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9014. ];
  9015. $final_list= [];
  9016. foreach($list as $key => $value){
  9017. $final_list[] = array_values($value) ;
  9018. }
  9019. if(empty($final_list)){
  9020. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9021. }
  9022. array_unshift($final_list, $first_row);
  9023. $merges = [];
  9024. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9025. }
  9026. }
  9027. }