Whlabel.php 317 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363
  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. $this->load->_model("Model_whlabelscanlog","whlabelscanlog");
  47. $this->load->_model("Model_excel","excelxh");
  48. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg, $arg_array)
  51. {
  52. if ($arg == 'existence') //在库标签
  53. {
  54. $this->_existence();
  55. } else if ($arg == 'cpbqdc') //在库标签
  56. {
  57. $this->_cpbqdc();
  58. } else if ($arg == 'type') //进销存浏览
  59. {
  60. $this->_type();
  61. } else if ($arg == 'typedy') //进销存浏览店员页面
  62. {
  63. $this->_typedy($arg_array);
  64. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  65. {
  66. $this->_typedy_ck($arg_array);
  67. } else if ($arg == 'typeck') {
  68. $this->_typeck($arg_array);
  69. } else if ($arg == 'whlabeckdc') {
  70. $this->_whlabeckdc($arg_array);
  71. } else if ($arg == 'usatype') //美仓进销存浏览
  72. {
  73. $this->_usatype();
  74. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  75. {
  76. $this->_usatypeapp();
  77. } else if ($arg == 'enteradd') //入库操作
  78. {
  79. $this->_enteradd();
  80. } else if ($arg == 'enteredit') //修改
  81. {
  82. $this->_enteredit($arg_array);
  83. } else if ($arg == 'enter') //入库浏览
  84. {
  85. $this->_enter();
  86. } else if ($arg == 'out') //出库浏览
  87. {
  88. $this->_out();
  89. } else if ($arg == 'label') //出库标签浏览
  90. {
  91. $this->_label();
  92. } else if ($arg == 'outorder') //独立站出库订单
  93. {
  94. $this->_outorder();
  95. } else if ($arg == 'soutorder') //速卖通出库订单
  96. {
  97. $this->_soutorder();
  98. } else if ($arg == 'toutorder') //TT出库订单
  99. {
  100. $this->_toutorder();
  101. }else if ($arg == 'aoutorder') //amz出库订单
  102. {
  103. $this->_aoutorder();
  104. } else if ($arg == 'retreat') //退库订单
  105. {
  106. $this->_retreat();
  107. } else if ($arg == 'retreatlk') //退库订单
  108. {
  109. $this->_retreatlk();
  110. } else if ($arg == 'change') //更换标签
  111. {
  112. $this->_change();
  113. } else if ($arg == 'del') //删除
  114. {
  115. $this->_del();
  116. } else if ($arg == 'exceljxc') //进销存信息导出
  117. {
  118. $this->_exceljxc();
  119. } else if ($arg == 'excelr') //入库信息导出
  120. {
  121. $this->_excelr();
  122. } else if ($arg == 'excelct') //出库、退库信息导出
  123. {
  124. $this->_excelct();
  125. } else if ($arg == 'dccrtype') //根据出入库类型导出
  126. {
  127. $this->_dccrtype();
  128. } else if ($arg == 'excelcr') //出库、退库信息导出
  129. {
  130. $this->_excelcr();
  131. } else if ($arg == 'kcyz') //库存验证
  132. {
  133. $this->_kcyz();
  134. } else if ($arg == 'kj') //库存扣减
  135. {
  136. $this->_kj($arg_array);
  137. } else if ($arg == 'presetout') //预设库存导入
  138. {
  139. $this->_presetout($arg_array);
  140. } else if ($arg == 'presetedit') //预设库存导入
  141. {
  142. $this->_presetedit($arg_array);
  143. }else if ($arg == 'presetedittwo') //预设库存导入
  144. {
  145. $this->_presetedittwo($arg_array);
  146. } else if ($arg == 'summary') //汇总导出
  147. {
  148. $this->_summary($arg_array);
  149. } else if ($arg == 'manifest') //usps发货清单
  150. {
  151. $this->_manifest();
  152. } else if ($arg == 'abnormal') //占单异常
  153. {
  154. $this->_abnormal();
  155. } else if ($arg == 'error') //0库存SKU
  156. {
  157. $this->_error();
  158. } else if ($arg == 'errorexcel') //0库存SKU导出
  159. {
  160. $this->_errorexcel();
  161. } else if ($arg == 'db') {
  162. $this->_db();
  163. } else if ($arg == 'dbrk') {
  164. $this->_dbrk();
  165. } else if ($arg == 'whlabelczdc') {
  166. $this->_whlabelczdc();
  167. } else if ($arg == 'print') {
  168. $this->_print($arg_array);
  169. } else if ($arg == 'usaprint') {
  170. $this->_usaprint($arg_array);
  171. } else if ($arg == 'printck') {
  172. $this->_printck($arg_array);
  173. } else if ($arg == 'printrk') {
  174. $this->_printrk($arg_array);
  175. } else if ($arg == 'printxzrk') {
  176. $this->_printxzrk($arg_array);
  177. } else if ($arg == 'printexcel') {
  178. $this->_printexcel($arg_array);
  179. } else if ($arg == 'uck') {
  180. $this->_uck();
  181. } else if ($arg == 'whlabelexcelzh') {
  182. $this->_whlabelexcelzh();
  183. } else if ($arg == 'fc') {
  184. $this->_fc();
  185. } else if ($arg == 'fcmb') {
  186. $this->_fcmb();
  187. } else if ($arg == 'fcexcel') {
  188. $this->_fcexcel();
  189. } else if ($arg == 'fcjxc') {
  190. $this->_fcjxc($arg_array);
  191. } else if ($arg == '0kcdel') {
  192. $this->_0kcdel(); //导表删除0库存
  193. } else if ($arg == 'gbhtype') {
  194. $this->_gbhtype(); //更改备货状态
  195. } else if($arg == 'excelrjs'){
  196. $this->_excelrjs();
  197. } else if($arg == 'excelctjs'){
  198. $this->_excelctjs();
  199. }else if ($arg == 'exceljxcjs') //进销存信息导出
  200. {
  201. $this->_exceljxcjs();
  202. } else if ($arg == 'summaryjs') //汇总导出
  203. {
  204. $this->_summaryjs($arg_array);
  205. }else if($arg == 'uckjs'){
  206. $this->_uckjs();
  207. }else if ($arg == 'whlabelexcelzhjs') {
  208. $this->_whlabelexcelzhjs();
  209. }else if($arg == 'dccrtypejs'){
  210. $this->_dccrtypejs();
  211. }else if($arg == 'errorexceljs'){
  212. $this->_errorexceljs();
  213. }else if($arg == "w_t_cs"){
  214. $this->_w_t_cs(); //首页
  215. }else {
  216. $this->_index();
  217. }
  218. }
  219. public function _w_t_cs(){
  220. $vip = 0;
  221. if (isset($_SESSION['api'])) {
  222. $user = $this->user->get_api($_SESSION['api']);
  223. $fgshop = "";
  224. $sid = "";
  225. $usersp = explode('|', trim($user['shop'], '|'));
  226. foreach ($usersp as $value) {
  227. $fgshop .= " shop = " . $value . " or";
  228. $sid .= " id = " . $value . " or";
  229. }
  230. if ($user['vip'] == 1) {
  231. $vip = 1;
  232. }
  233. } else {
  234. header('Location: /');
  235. exit;
  236. }
  237. $prc = array();
  238. $purchase = $this->purchase->find_all();
  239. foreach ($purchase as $k => $v) {
  240. $prc[$v['id']] = $v['title'];
  241. }
  242. $company = array();
  243. $ct = $this->company->find_all();
  244. foreach ($ct as $k => $v) {
  245. $company[$v['id']] = $v['title'];
  246. }
  247. $sp = array();
  248. $s = $this->shop->find_all('1=1', 'id,shopname');
  249. foreach ($s as $v) {
  250. $sp[$v['id']] = $v['shopname'];
  251. }
  252. $wh = array();
  253. $w = $this->warehouse->find_all('1=1', 'id,title');
  254. foreach ($w as $v) {
  255. $wh[$v['id']] = $v['title'];
  256. }
  257. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  258. $this->data['shop'] = $wlshop;
  259. $this->data['vip'] = $vip;
  260. $this->_Template('whlabel_typejs', $this->data);
  261. }
  262. //管理
  263. public function _index()
  264. {
  265. $post = $this->input->post(NULL, TRUE);
  266. if (isset($post['page'])) {
  267. $page = $this->input->post('page', true);
  268. $perpage = $this->input->post('perpage', true);
  269. $sku = $this->input->post('sku', true);
  270. $number = $this->input->post('number', true);
  271. $warehouse = $this->input->post('warehouse', true);
  272. $purchase = $this->input->post('purchase', true);
  273. $orderinfo = $this->input->post('orderinfo', true);
  274. $waybill = $this->input->post('waybill', true);
  275. $category = $this->input->post('category', true);
  276. $size = $this->input->post('size', true);
  277. $grade = $this->input->post('grade', true);
  278. $color = $this->input->post('color', true);
  279. $lowe = $this->input->post('lowe', true);
  280. $state = $this->input->post('state', true);
  281. $label = $this->input->post('label', true);
  282. $timetk = $this->input->post('timetkk', true);
  283. $timetj = $this->input->post('timetjj', true);
  284. $timetk = strtotime($timetk);
  285. $timetj = strtotime($timetj);
  286. $where = "1=1 ";
  287. if ($timetk && $timetj) {
  288. $where .= " and time > '$timetk' and time < '$timetj'";
  289. }
  290. if ($sku) {
  291. $where .= " and sku = '$sku'";
  292. }
  293. if ($number) {
  294. $where .= " and number = '$number'";
  295. }
  296. if ($warehouse) {
  297. $where .= " and warehouse = '$warehouse'";
  298. }
  299. if ($purchase) {
  300. $where .= " and purchase = '$purchase'";
  301. }
  302. if ($orderinfo) {
  303. $where .= " and orderinfo = '$orderinfo'";
  304. }
  305. if ($waybill) {
  306. $where .= " and waybill = '$waybill'";
  307. }
  308. if ($category) {
  309. $where .= " and features like '%-$category-%'";
  310. }
  311. if ($size) {
  312. $where .= " and features like '%-$size-%'";
  313. }
  314. if ($grade) {
  315. $where .= " and features like '%-$grade-%'";
  316. }
  317. if ($color) {
  318. $where .= " and features like '%-$color-%'";
  319. }
  320. if ($lowe) {
  321. $where .= " and features like '%-$lowe-%'";
  322. }
  323. if ($label) {
  324. $where .= " and label = '$label'";
  325. }
  326. if ($state != '') {
  327. $where .= " and state = '$state'";
  328. }
  329. //数据排序
  330. $order_str = "time desc";
  331. if (empty($page)) {
  332. $start = 0;
  333. $perpage = 1;
  334. } else {
  335. $start = ($page - 1) * $perpage;
  336. }
  337. //取得信息列表
  338. $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);
  339. foreach ($info_list as $key => $value) {
  340. $warehouse = $this->warehouse->read($value['warehouse']);
  341. $info_list[$key]['warehouse'] = $warehouse['title'];
  342. $purchase = $this->purchase->read($value['purchase']);
  343. $info_list[$key]['purchase'] = $purchase['title'];
  344. if ($value['enter'] != 0) {
  345. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  346. } else {
  347. $info_list[$key]['enter'] = "";
  348. }
  349. if ($value['outk'] != 0) {
  350. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  351. } else {
  352. $info_list[$key]['outk'] = "";
  353. }
  354. if ($value['printing'] != 0) {
  355. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  356. } else {
  357. $info_list[$key]['printing'] = "";
  358. }
  359. if ($value['orderinfo'] == 0) {
  360. $info_list[$key]['orderinfo'] = "";
  361. }
  362. if ($value['waybill'] == 0) {
  363. $info_list[$key]['waybill'] = "";
  364. }
  365. if ($value['state'] == 0) {
  366. $info_list[$key]['state'] = "在库";
  367. } else if ($value['state'] == 1) {
  368. $info_list[$key]['state'] = "出库";
  369. } else if ($value['state'] == 2) {
  370. $info_list[$key]['state'] = "退库";
  371. } else if ($value['state'] == 3) {
  372. $info_list[$key]['state'] = "调拨中";
  373. } else if ($value['state'] == 4) {
  374. $info_list[$key]['state'] = "再加工";
  375. } else if ($value['state'] == 5) {
  376. $info_list[$key]['state'] = "维修中";
  377. } else if ($value['state'] == 6) {
  378. $info_list[$key]['state'] = "盘亏";
  379. } else if ($value['state'] == 7) {
  380. $info_list[$key]['state'] = "更换标签";
  381. } else if ($value['state'] == 8) {
  382. $info_list[$key]['state'] = "其它";
  383. } else if ($value['state'] == 9) {
  384. $info_list[$key]['state'] = "预设";
  385. } else if ($value['state'] == 10) {
  386. $info_list[$key]['state'] = "美店零售";
  387. }
  388. if ($value['text'] == "") {
  389. $info_list[$key]['text'] = "";
  390. }
  391. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  392. }
  393. $total = $this->whlabel->find_count($where);
  394. $pagenum = ceil($total / $perpage);
  395. $over = $total - ($start + $perpage);
  396. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  397. echo json_encode($rows);
  398. exit;
  399. }
  400. if (isset($post['outsku'])) {
  401. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  402. $cz = $this->input->post('cz', true);
  403. if ($cz == '1') {
  404. $sku = $this->input->post('outsku', true);
  405. if ($sku) {
  406. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  407. if (count($data) < 1) {
  408. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  409. exit;
  410. }
  411. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  412. echo json_encode(array('success' => true));
  413. exit;
  414. }
  415. } else {
  416. $sku = $this->input->post('outsku', true);
  417. if ($sku) {
  418. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  419. if (count($data) < 1) {
  420. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  421. exit;
  422. }
  423. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  424. echo json_encode(array('success' => true));
  425. exit;
  426. }
  427. }
  428. }
  429. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  430. $this->_Template('whlabel', $this->data);
  431. }
  432. //在库标签
  433. public function _existence()
  434. {
  435. $post = $this->input->post(NULL, TRUE);
  436. if (isset($post['s'])) {
  437. $id_arr = $this->input->post('s');
  438. $id_arr = explode(',', $id_arr);
  439. if (!$id_arr) {
  440. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  441. exit;
  442. }
  443. //循环删除记录
  444. foreach ($id_arr as $v) {
  445. $sid = $this->whlabel->read($v);
  446. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  447. if ($count > 0) {
  448. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  449. exit;
  450. }
  451. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  452. if (count($zt) > 0) {
  453. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  454. exit;
  455. }
  456. $this->whlabel->remove($v);
  457. }
  458. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  459. exit;
  460. }
  461. if (isset($post['page'])) {
  462. $page = $this->input->post('page', true);
  463. $perpage = $this->input->post('perpage', true);
  464. $warehouse = $this->input->post('warehouse', true);
  465. $label = $this->input->post('label', true);
  466. $where = "1=1 and state = 0";
  467. if ($warehouse) {
  468. $where .= " and warehouse = '$warehouse'";
  469. }
  470. if ($label) {
  471. $where .= " and label = '$label'";
  472. }
  473. //数据排序
  474. $order_str = "time asc";
  475. if (empty($page)) {
  476. $start = 0;
  477. $perpage = 1;
  478. } else {
  479. $start = ($page - 1) * $perpage;
  480. }
  481. //取得信息列表
  482. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  483. foreach ($info_list as $key => $value) {
  484. if ($value['enter'] != 0) {
  485. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  486. } else {
  487. $info_list[$key]['enter'] = "";
  488. }
  489. if ($value['printing'] != 0) {
  490. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  491. } else {
  492. $info_list[$key]['printing'] = "";
  493. }
  494. }
  495. $total = $this->whlabel->find_count($where);
  496. $pagenum = ceil($total / $perpage);
  497. $over = $total - ($start + $perpage);
  498. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  499. echo json_encode($rows);
  500. exit;
  501. }
  502. $this->_Template('whlabel_existence', $this->data);
  503. }
  504. //进销存浏览
  505. public function _typedy($arg_array)
  506. {
  507. $prc = array();
  508. $purchase = $this->purchase->find_all();
  509. foreach ($purchase as $k => $v) {
  510. $prc[$v['id']] = $v['title'];
  511. }
  512. $post = $this->input->post(NULL, TRUE);
  513. if (isset($post['page'])) {
  514. $page = $this->input->post('page', true);
  515. $perpage = $this->input->post('perpage', true);
  516. $category = $this->input->post('category', true);
  517. $size = $this->input->post('size', true);
  518. $grade = $this->input->post('grade', true);
  519. $color = $this->input->post('color', true);
  520. $lowe = $this->input->post('lowe', true);
  521. $sku = $this->input->post('sku');
  522. $title = $this->input->post('title');
  523. $warehouse = $this->input->post('warehouse', true);
  524. $usa = $this->input->post('usa', true);
  525. $purchase = $this->input->post('purchase', true);
  526. $lacetype = $this->input->post('lacetype', true);
  527. $haircap = $this->input->post('haircap', true);
  528. $density = $this->input->post('density', true);
  529. $details = $this->input->post('details', true);
  530. $state = $this->input->post('state', true);
  531. $lacecolor = $this->input->post('lacecolor', true);
  532. $hairnumber = $this->input->post('hairnumber', true);
  533. $cklx = $this->input->post('cklx', true);
  534. $ktime = $this->input->post('ktime', true);
  535. $jtime = $this->input->post('jtime', true);
  536. $sm = $this->input->post('sm', true);
  537. $cpbz = $this->input->post('cpbz', true);
  538. $type = $this->input->post('type', true);
  539. $ktime = strtotime($ktime);
  540. $jtime = strtotime($jtime);
  541. $where = "1=1";
  542. $gj = "";
  543. $ck = "";
  544. if ($usa) {
  545. if (!$warehouse) {
  546. $where .= " and (warehouse = '5' or warehouse = '8')";
  547. }
  548. }
  549. if ($warehouse) {
  550. $where .= " and warehouse = '$warehouse'";
  551. }
  552. if ($details) {
  553. $where .= " and details = '$details'";
  554. }
  555. if ($purchase) {
  556. $where .= " and purchase = '$purchase'";
  557. }
  558. if (isset($state)) {
  559. if($state >-1){
  560. $where .= " and state = '$state'";
  561. }
  562. }
  563. if ($lacetype) {
  564. $where .= " and features like '%-$lacetype-%'";
  565. }
  566. if ($category) {
  567. $where .= " and features like '%-$category-%'";
  568. }
  569. if ($size) {
  570. $where .= " and features like '%-$size-%'";
  571. }
  572. if ($grade) {
  573. $where .= " and features like '%-$grade-%'";
  574. }
  575. if ($color) {
  576. $where .= " and features like '%-$color-%'";
  577. }
  578. if ($lowe) {
  579. $where .= " and features like '%-$lowe-%'";
  580. }
  581. if ($haircap) {
  582. $where .= " and features like '%-$haircap-%'";
  583. }
  584. if ($density) {
  585. $where .= " and features like '%-$density-%'";
  586. }
  587. if ($lacecolor) {
  588. $where .= " and features like '%-$lacecolor-%'";
  589. }
  590. if($sm){
  591. $where .= " and sm like '%".$sm."%'";
  592. }
  593. if($cpbz){
  594. $where .= " and cpbz like '%".$cpbz."%'";
  595. }
  596. if($type){
  597. $where .= " and type = ".$type."";
  598. }
  599. if (!empty($hairnumber)) {
  600. $where .= " and features like '%-128-%' ";
  601. if ($hairnumber < 0) {
  602. $class_list = $this->typeclass->find_all('classid = 43');
  603. foreach ($class_list as $v) {
  604. $where .= " and features not like '%-" . $v['id'] . "-%'";
  605. }
  606. } else {
  607. $where .= " and features like '%-$hairnumber-%'";
  608. }
  609. }
  610. $where_add = '';
  611. if ($cklx) {
  612. $shop = $this->shop->read($cklx);
  613. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  614. }
  615. if ($ktime && $jtime) {
  616. $gj = " and enter > '$ktime' and enter < '$jtime'";
  617. $ck = " and outk > '$ktime' and outk < '$jtime'";
  618. }
  619. //数据排序
  620. $order_str = "id desc";
  621. if (empty($page)) {
  622. $start = 0;
  623. $perpage = 1;
  624. } else {
  625. $start = ($page - 1) * $perpage;
  626. }
  627. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  628. if ($sku) {
  629. $sku = trim($sku, ' ');
  630. $sku = trim($sku, ' ');
  631. $where .= " and sku like '%$sku%'";
  632. $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);
  633. } else if ($title) {
  634. $title = trim($title, ' ');
  635. $title = trim($title, ' ');
  636. $where .= " and title like '%$title%'";
  637. $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);
  638. } else {
  639. //$where .= " and time > '$ktime' and time < '$jtime'";
  640. $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);
  641. }
  642. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  643. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  644. foreach ($info_list as $k => $v) {
  645. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  646. unset($info_list[$k]['pm']);
  647. unset($info_list[$k]['jm']);
  648. unset($info_list[$k]['bm']);
  649. }
  650. //取得信息列表
  651. $rows = array();
  652. $list = array();
  653. foreach ($info_list as $key => $value) {
  654. $warehouse = $this->warehouse->read($value['warehouse']);
  655. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  656. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  657. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  658. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  659. $info_list[$key]['label'] = $value['sm'];
  660. $number = $value['number'];
  661. $ftime = time() - 15 * 24 * 3600;
  662. $info_list[$key]['warehouse'] = $warehouse['title'];
  663. $info_list[$key]['features'] = count($c);
  664. $z = count($z); //查看订单号
  665. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  666. $ztdata = '';
  667. if (count($zt) > 0) {
  668. foreach ($zt as $vv) {
  669. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  670. }
  671. }
  672. $info_list[$key]['number'] = $ztdata;
  673. $info_list[$key]['sm'] = $z;
  674. $details = array();
  675. $cpid = array();
  676. foreach ($c as $k => $v) {
  677. $details[$v['details']] = $v['details'];
  678. if ($v['cpid'] != 0) {
  679. $cpid[$v['cpid']] = $v['cpid'];
  680. }
  681. }
  682. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  683. if ($value['shop'] != '') {
  684. $shop = explode(',', trim($value['shop'], ','));
  685. $shop = $this->shop->read($shop[0]);
  686. $info_list[$key]['shop'] = $shop['shopname'];
  687. }
  688. }
  689. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  690. $pagenum = ceil($total / $perpage);
  691. $over = $total - ($start + $perpage);
  692. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  693. echo json_encode($rows);
  694. exit;
  695. }
  696. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  697. $this->_Template('whlabel_typedy', $this->data);
  698. }
  699. //进销存浏览
  700. public function _typedy_ck($arg_array)
  701. {
  702. $prc = array();
  703. $purchase = $this->purchase->find_all();
  704. foreach ($purchase as $k => $v) {
  705. $prc[$v['id']] = $v['title'];
  706. }
  707. $post = $this->input->post(NULL, TRUE);
  708. if (isset($post['page'])) {
  709. $page = $this->input->post('page', true);
  710. $perpage = $this->input->post('perpage', true);
  711. $category = $this->input->post('category', true);
  712. $size = $this->input->post('size', true);
  713. $grade = $this->input->post('grade', true);
  714. $color = $this->input->post('color', true);
  715. $lowe = $this->input->post('lowe', true);
  716. $sku = $this->input->post('sku');
  717. $title = $this->input->post('title');
  718. $warehouse = $this->input->post('warehouse', true);
  719. $usa = $this->input->post('usa', true);
  720. $purchase = $this->input->post('purchase', true);
  721. $lacetype = $this->input->post('lacetype', true);
  722. $haircap = $this->input->post('haircap', true);
  723. $density = $this->input->post('density', true);
  724. $details = $this->input->post('details', true);
  725. $state = $this->input->post('state', true);
  726. $lacecolor = $this->input->post('lacecolor', true);
  727. $cklx = $this->input->post('cklx', true);
  728. $ktime = $this->input->post('ktime', true);
  729. $jtime = $this->input->post('jtime', true);
  730. $ktime = strtotime($ktime);
  731. $jtime = strtotime($jtime);
  732. $where = "1=1";
  733. $gj = "";
  734. $ck = "";
  735. if ($lacetype) {
  736. $where .= " and features like '%-$lacetype-%'";
  737. }
  738. if ($category) {
  739. $where .= " and features like '%-$category-%'";
  740. }
  741. if ($size) {
  742. $where .= " and features like '%-$size-%'";
  743. }
  744. if ($grade) {
  745. $where .= " and features like '%-$grade-%'";
  746. }
  747. if ($color) {
  748. $where .= " and features like '%-$color-%'";
  749. }
  750. if ($lowe) {
  751. $where .= " and features like '%-$lowe-%'";
  752. }
  753. if ($haircap) {
  754. $where .= " and features like '%-$haircap-%'";
  755. }
  756. if ($density) {
  757. $where .= " and features like '%-$density-%'";
  758. }
  759. if ($lacecolor) {
  760. $where .= " and features like '%-$lacecolor-%'";
  761. }
  762. if ($usa) {
  763. if (!$warehouse) {
  764. $where .= " and (warehouse = '5' or warehouse = '8')";
  765. }
  766. }
  767. if ($warehouse) {
  768. $where .= " and warehouse = '$warehouse'";
  769. }
  770. if ($details) {
  771. $where .= " and details = '$details'";
  772. }
  773. if ($purchase) {
  774. $where .= " and purchase = '$purchase'";
  775. }
  776. if ($state) {
  777. $where .= " and state = '$state'";
  778. }
  779. $where_add = '';
  780. if ($cklx) {
  781. $shop = $this->shop->read($cklx);
  782. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  783. }
  784. if ($ktime && $jtime) {
  785. $gj = " and enter > '$ktime' and enter < '$jtime'";
  786. $ck = " and outk > '$ktime' and outk < '$jtime'";
  787. }
  788. //数据排序
  789. $order_str = "id desc";
  790. if (empty($page)) {
  791. $start = 0;
  792. $perpage = 1;
  793. } else {
  794. $start = ($page - 1) * $perpage;
  795. }
  796. if ($sku) {
  797. $sku = trim($sku, ' ');
  798. $sku = trim($sku, ' ');
  799. $where .= " and sku like '%$sku%'";
  800. $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);
  801. } else if ($title) {
  802. $title = trim($title, ' ');
  803. $title = trim($title, ' ');
  804. $where .= " and title like '%$title%'";
  805. $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);
  806. } else {
  807. //$where .= " and time > '$ktime' and time < '$jtime'";
  808. $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);
  809. }
  810. //取得信息列表
  811. $rows = array();
  812. $list = array();
  813. foreach ($info_list as $key => $value) {
  814. $warehouse = $this->warehouse->read($value['warehouse']);
  815. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  816. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  817. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  818. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  819. $ftime = time() - 15 * 24 * 3600;
  820. $info_list[$key]['warehouse'] = $warehouse['title'];
  821. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  822. //$z = count($z);//查看订单号
  823. //$info_list[$key]['zd'] = $z;
  824. $details = array();
  825. $cpid = array();
  826. foreach ($c as $k => $v) {
  827. $details[$v['details']] = $v['details'];
  828. if ($v['cpid'] != 0) {
  829. $cpid[$v['cpid']] = $v['cpid'];
  830. }
  831. }
  832. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  833. if ($value['shop'] != '') {
  834. $shop = explode(',', trim($value['shop'], ','));
  835. $shop = $this->shop->read($shop[0]);
  836. $info_list[$key]['shop'] = $shop['shopname'];
  837. }
  838. }
  839. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  840. $pagenum = ceil($total / $perpage);
  841. $over = $total - ($start + $perpage);
  842. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  843. echo json_encode($rows);
  844. exit;
  845. }
  846. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  847. $this->_Template('whlabel_typedy_ck', $this->data);
  848. }
  849. public function _typeck($arg_array)
  850. {
  851. $prc = array();
  852. $purchase = $this->purchase->find_all();
  853. foreach ($purchase as $k => $v) {
  854. $prc[$v['id']] = $v['title'];
  855. }
  856. $post = $this->input->post(NULL, TRUE);
  857. if (isset($post['page'])) {
  858. $page = $this->input->post('page', true);
  859. $perpage = $this->input->post('perpage', true);
  860. $category = $this->input->post('category', true);
  861. $size = $this->input->post('size', true);
  862. $grade = $this->input->post('grade', true);
  863. $color = $this->input->post('color', true);
  864. $lacecolor = $this->input->post('lacecolor', true);
  865. $lowe = $this->input->post('lowe', true);
  866. $sku = $this->input->post('sku');
  867. $title = $this->input->post('title');
  868. $warehouse = 13;
  869. $usa = $this->input->post('usa', true);
  870. $purchase = $this->input->post('purchase', true);
  871. $lacetype = $this->input->post('lacetype', true);
  872. $haircap = $this->input->post('haircap', true);
  873. $density = $this->input->post('density', true);
  874. $details = $this->input->post('details', true);
  875. $state = $this->input->post('state', true);
  876. $ktime = $this->input->post('ktime', true);
  877. $jtime = $this->input->post('jtime', true);
  878. $ktime = strtotime($ktime);
  879. $jtime = strtotime($jtime);
  880. $where = "1=1";
  881. $gj = "";
  882. $ck = "";
  883. if ($lacetype) {
  884. $where .= " and features like '%-$lacetype-%'";
  885. }
  886. if ($category) {
  887. $where .= " and features like '%-$category-%'";
  888. }
  889. if ($size) {
  890. $where .= " and features like '%-$size-%'";
  891. }
  892. if ($grade) {
  893. $where .= " and features like '%-$grade-%'";
  894. }
  895. if ($color) {
  896. $where .= " and features like '%-$color-%'";
  897. }
  898. if ($lacecolor) {
  899. $where .= " and features like '%-$lacecolor-%'";
  900. }
  901. if ($lowe) {
  902. $where .= " and features like '%-$lowe-%'";
  903. }
  904. if ($haircap) {
  905. $where .= " and features like '%-$haircap-%'";
  906. }
  907. if ($density) {
  908. $where .= " and features like '%-$density-%'";
  909. }
  910. if ($warehouse) {
  911. $where .= " and warehouse = '$warehouse'";
  912. }
  913. if ($details) {
  914. $where .= " and details = '$details'";
  915. }
  916. if ($purchase) {
  917. $where .= " and purchase = '$purchase'";
  918. }
  919. if ($state) {
  920. $where .= " and state = '$state'";
  921. }
  922. if ($ktime && $jtime) {
  923. $gj = " and enter > '$ktime' and enter < '$jtime'";
  924. $ck = " and outk > '$ktime' and outk < '$jtime'";
  925. }
  926. //数据排序
  927. $order_str = "id desc";
  928. if (empty($page)) {
  929. $start = 0;
  930. $perpage = 1;
  931. } else {
  932. $start = ($page - 1) * $perpage;
  933. }
  934. if ($sku) {
  935. $sku = trim($sku, ' ');
  936. $sku = trim($sku, ' ');
  937. $where .= " and sku like '%$sku%'";
  938. } else if ($title) {
  939. $title = trim($title, ' ');
  940. $title = trim($title, ' ');
  941. $where .= " and title like '%$title%'";
  942. }
  943. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  944. //取得信息列表
  945. $t = array();
  946. $typeclass = $this->typeclass->find_all();
  947. foreach ($typeclass as $v) {
  948. $t[$v['id']] = $v;
  949. }
  950. $rows = array();
  951. $list = array();
  952. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  953. foreach ($info_list as $key => $value) {
  954. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  955. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  956. $warehouse = $this->warehouse->read($value['warehouse']);
  957. $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');
  958. $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'] . '"');
  959. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  960. $number = $value['number'];
  961. $ftime = time() - 15 * 24 * 3600;
  962. $z = count($z); //查看订单号
  963. $info_list[$key]['warehouse'] = $warehouse['title'];
  964. $info_list[$key]['features'] = count($c);
  965. $info_list[$key]['number'] = $z;
  966. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  967. $details = array();
  968. $cpid = array();
  969. foreach ($c as $k => $v) {
  970. $details[$v['details']] = $v['details'];
  971. if ($v['cpid'] != 0) {
  972. $cpid[$v['cpid']] = $v['cpid'];
  973. }
  974. }
  975. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  976. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  977. unset($info_list[$key]['pm']);
  978. unset($info_list[$key]['jm']);
  979. unset($info_list[$key]['bm']);
  980. }
  981. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  982. $pagenum = ceil($total / $perpage);
  983. $over = $total - ($start + $perpage);
  984. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  985. echo json_encode($rows);
  986. exit;
  987. }
  988. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  989. $this->_Template('whlabel_typeck', $this->data);
  990. }
  991. //进销存导出
  992. public function _whlabeckdc()
  993. {
  994. $prc = array();
  995. $purchase = $this->purchase->find_all();
  996. foreach ($purchase as $k => $v) {
  997. $prc[$v['id']] = $v['title'];
  998. }
  999. if (isset($_GET['excel'])) {
  1000. $where = "sku != 'Preset'";
  1001. //数据排序
  1002. $order_str = "id desc";
  1003. if (empty($page)) {
  1004. $start = 0;
  1005. $perpage = 1;
  1006. } else {
  1007. $start = ($page - 1) * $perpage;
  1008. }
  1009. $category = $this->input->get('category', true);
  1010. $color = $this->input->get('color', true);
  1011. $lowe = $this->input->get('lowe', true);
  1012. $lacetype = $this->input->get('lacetype', true);
  1013. $size = $this->input->get('size', true);
  1014. $density = $this->input->get('density', true);
  1015. $haircap = $this->input->get('haircap', true);
  1016. $sku = $this->input->get('sku', true);
  1017. $details = $this->input->get('details', true);
  1018. $warehouse = 13;
  1019. $excelid = $this->input->get('sid', true);
  1020. if ($category) {
  1021. $where .= " and features like '%-$category-%'";
  1022. }
  1023. if ($color) {
  1024. $where .= " and features like '%-$color-%'";
  1025. }
  1026. if ($lowe) {
  1027. $where .= " and features like '%-$lowe-%'";
  1028. }
  1029. if ($lacetype) {
  1030. $where .= " and features like '%-$lacetype-%'";
  1031. }
  1032. if ($size) {
  1033. $where .= " and features like '%-$size-%'";
  1034. }
  1035. if ($density) {
  1036. $where .= " and features like '%-$density-%'";
  1037. }
  1038. if ($haircap) {
  1039. $where .= " and features like '%-$haircap-%'";
  1040. }
  1041. if ($warehouse) {
  1042. $where .= " and warehouse = '$warehouse'";
  1043. }
  1044. if ($sku) {
  1045. $where .= " and sku like '%$sku%'";
  1046. }
  1047. if ($details) {
  1048. $where .= " and details = '$details'";
  1049. }
  1050. $xzid = '';
  1051. if ($excelid) {
  1052. $excelid = explode(',', trim($excelid, ','));
  1053. foreach ($excelid as $key => $value) {
  1054. $xzid .= " id = " . $value . " or";
  1055. }
  1056. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1057. }
  1058. //取得信息列表
  1059. /**
  1060. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1061. $rows = array();$list = array();
  1062. foreach ($info_list as $key=>$value)
  1063. {
  1064. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1065. }
  1066. **/
  1067. $wh = array();
  1068. $w = $this->warehouse->find_all('1=1', 'id,title');
  1069. foreach ($w as $v) {
  1070. $wh[$v['id']] = $v['title'];
  1071. }
  1072. $tc = array();
  1073. $tcdata = array();
  1074. $list = array();
  1075. $classid = $this->classid->sku();
  1076. $tcall = $this->typeclass->find_all();
  1077. $typeclass = array();
  1078. foreach ($tcall as $v)
  1079. {
  1080. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1081. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1082. }
  1083. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', "warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,GROUP_CONCAT(NULLIF(cpbz, '') ORDER BY cpbz ASC SEPARATOR ', ') AS cpbzs,number,features ");
  1084. foreach ($rows as $key => $value) {
  1085. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1086. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1087. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1088. $rows[$key]['cpbz'] = $u9_info['bm'];
  1089. $rows[$key]['cs'] = $u9_info['jm'];
  1090. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1091. $details = array();
  1092. $cpid = array();
  1093. $cpbz = array();
  1094. $c = 0;
  1095. $g = 0;
  1096. $x = 0;
  1097. $t = 0;
  1098. $s = 0;
  1099. $q = 0;
  1100. foreach ($sd as $k => $v) {
  1101. if ($v['state'] == 0) {
  1102. $c++;
  1103. }
  1104. if ($v['state'] != 9) {
  1105. $g++;
  1106. }
  1107. if ($v['state'] == 1) {
  1108. $x++;
  1109. }
  1110. if ($v['state'] == 2) {
  1111. $t++;
  1112. }
  1113. if ($v['state'] == 8) {
  1114. $s++;
  1115. }
  1116. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1117. $q++;
  1118. }
  1119. $details[$v['details']] = $v['details'];
  1120. if ($v['cpid'] != 0) {
  1121. $cpid[$v['cpid']] = $v['cpid'];
  1122. }
  1123. if ($v['cpbz'] != '') {
  1124. $cpbz[$v['cpbz']] = $v['cpbz'];
  1125. }
  1126. }
  1127. $rows[$key]['details'] = implode("、", $details);
  1128. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1129. $number = $value['number'];
  1130. $ftime = time() - 15 * 24 * 3600;
  1131. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1132. $rows[$key]['number'] = $g;
  1133. $rows[$key]['features'] = $c;
  1134. $rows[$key]['x'] = $x;
  1135. $rows[$key]['t'] = $t;
  1136. $rows[$key]['s'] = $s;
  1137. $rows[$key]['q'] = $q;
  1138. $rows[$key]['wzsl'] = count($details);
  1139. //cpbzs
  1140. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1141. $unique_arr = array_unique($tmp_cpbzs);
  1142. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1143. }
  1144. $title = "进销存统计表" . date('Y-m-d', time());
  1145. $titlename = "<table border=1>
  1146. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1147. <tr align='center'>
  1148. <td>仓库</td>
  1149. <td>供应商</td>
  1150. <td>位置</td>
  1151. <td>库存编码</td>
  1152. <td>SKU</td>
  1153. <td>用友编码</td>
  1154. <td>用友料号</td>
  1155. <td>产品英文名</td>
  1156. <td>产品中文名</td>
  1157. <td>备注</td>
  1158. <td>入库总量</td>
  1159. <td>库存数量</td>
  1160. <td>销售数量</td>
  1161. <td>退货数量</td>
  1162. <td>删除数量</td>
  1163. <td>其它操作</td>
  1164. <td>位置数量</td>
  1165. </tr>
  1166. </table>";
  1167. $filename = $title . ".xls";
  1168. $tail = "";
  1169. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1170. }
  1171. }
  1172. public function _type()
  1173. {
  1174. $vip = 0;
  1175. if (isset($_SESSION['api'])) {
  1176. $user = $this->user->get_api($_SESSION['api']);
  1177. $fgshop = "";
  1178. $sid = "";
  1179. $usersp = explode('|', trim($user['shop'], '|'));
  1180. foreach ($usersp as $value) {
  1181. $fgshop .= " shop = " . $value . " or";
  1182. $sid .= " id = " . $value . " or";
  1183. }
  1184. if ($user['vip'] == 1) {
  1185. $vip = 1;
  1186. }
  1187. } else {
  1188. header('Location: /');
  1189. exit;
  1190. }
  1191. $prc = array();
  1192. $purchase = $this->purchase->find_all();
  1193. foreach ($purchase as $k => $v) {
  1194. $prc[$v['id']] = $v['title'];
  1195. }
  1196. $company = array();
  1197. $ct = $this->company->find_all();
  1198. foreach ($ct as $k => $v) {
  1199. $company[$v['id']] = $v['title'];
  1200. }
  1201. $sp = array();
  1202. $s = $this->shop->find_all('1=1', 'id,shopname');
  1203. foreach ($s as $v) {
  1204. $sp[$v['id']] = $v['shopname'];
  1205. }
  1206. $wh = array();
  1207. $w = $this->warehouse->find_all('1=1', 'id,title');
  1208. foreach ($w as $v) {
  1209. $wh[$v['id']] = $v['title'];
  1210. }
  1211. $post = $this->input->post(NULL, TRUE);
  1212. if (isset($post['page'])) {
  1213. $page = $this->input->post('page', true);
  1214. $perpage = $this->input->post('perpage', true);
  1215. $category = $this->input->post('category', true);
  1216. $size = $this->input->post('size', true);
  1217. $grade = $this->input->post('grade', true);
  1218. $color = $this->input->post('color', true);
  1219. $lowe = $this->input->post('lowe', true);
  1220. $sku = $this->input->post('sku');
  1221. $title = $this->input->post('title');
  1222. $warehouse = $this->input->post('warehouse', true);
  1223. $usa = $this->input->post('usa', true);
  1224. $purchase = $this->input->post('purchase', true);
  1225. $lacetype = $this->input->post('lacetype', true);
  1226. $haircap = $this->input->post('haircap', true);
  1227. $density = $this->input->post('density', true);
  1228. $details = $this->input->post('details', true);
  1229. $state = $this->input->post('state', true);
  1230. $shop = $this->input->post('shop', true);
  1231. $lacecolor = $this->input->post('lacecolor', true);
  1232. $hairnumber = $this->input->post('hairnumber', true);
  1233. $type = $this->input->post('type', true);
  1234. $ktime = $this->input->post('ktime', true);
  1235. $jtime = $this->input->post('jtime', true);
  1236. $ktime = strtotime($ktime);
  1237. $jtime = strtotime($jtime);
  1238. $cpbz = $this->input->post('cpbz', true);
  1239. $sm = $this->input->post('sm', true);
  1240. $where = "1=1";
  1241. $gj = "";
  1242. $ck = "";
  1243. if ($usa) {
  1244. if (!$warehouse) {
  1245. $where .= " and (warehouse = '5' or warehouse = '8')";
  1246. }
  1247. }
  1248. if ($warehouse) {
  1249. $where .= " and warehouse = '$warehouse'";
  1250. }
  1251. if ($details) {
  1252. $where .= " and details = '$details'";
  1253. }
  1254. if ($purchase) {
  1255. $where .= " and purchase = '$purchase'";
  1256. }
  1257. if ($state) {
  1258. $where .= " and state = '$state'";
  1259. }
  1260. if ($shop) {
  1261. $where .= " and shop like '%$shop%'";
  1262. }
  1263. if ($type) {
  1264. $where .= " and type = '$type'";
  1265. }
  1266. if ($ktime && $jtime) {
  1267. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1268. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1269. }
  1270. if ($cpbz) {
  1271. $where .= " and cpbz like '%$cpbz%' ";
  1272. }
  1273. if ($sm) {
  1274. $where .= " and sm like '%$sm%' ";
  1275. }
  1276. if ($lacecolor) {
  1277. $where .= " and features like '%-$lacecolor-%'";
  1278. }
  1279. if ($lacetype) {
  1280. $where .= " and features like '%-$lacetype-%'";
  1281. }
  1282. if ($category) {
  1283. $where .= " and features like '%-$category-%'";
  1284. }
  1285. if ($size) {
  1286. $where .= " and features like '%-$size-%'";
  1287. }
  1288. if ($grade) {
  1289. $where .= " and features like '%-$grade-%'";
  1290. }
  1291. if ($color) {
  1292. $where .= " and features like '%-$color-%'";
  1293. }
  1294. if ($lowe) {
  1295. $where .= " and features like '%-$lowe-%'";
  1296. }
  1297. if ($haircap) {
  1298. $where .= " and features like '%-$haircap-%'";
  1299. }
  1300. if ($density) {
  1301. $where .= " and features like '%-$density-%'";
  1302. }
  1303. if (!empty($hairnumber)) {
  1304. $where .= " and features like '%-128-%' ";
  1305. if ($hairnumber < 0) {
  1306. $class_list = $this->typeclass->find_all('classid = 43');
  1307. foreach ($class_list as $v) {
  1308. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1309. }
  1310. } else {
  1311. $where .= " and features like '%-$hairnumber-%'";
  1312. }
  1313. }
  1314. //数据排序
  1315. $order_str = "id desc";
  1316. if (empty($page)) {
  1317. $start = 0;
  1318. $perpage = 1;
  1319. } else {
  1320. $start = ($page - 1) * $perpage;
  1321. }
  1322. $fjnr = '';
  1323. if ($sku) {
  1324. $sku = trim($sku, ' ');
  1325. $sku = trim($sku, ' ');
  1326. $fjnr .= " and sku like '%$sku%'";
  1327. }
  1328. if ($title) {
  1329. $title = trim($title, ' ');
  1330. $title = trim($title, ' ');
  1331. $fjnr .= " and title like '%$title%'";
  1332. }
  1333. $wt = array();
  1334. $whlabel_type = $this->whlabel_type->find_all();
  1335. foreach ($whlabel_type as $v) {
  1336. $wt[$v['id']] = $v['title'];
  1337. }
  1338. //$where .= " and time > '$ktime' and time < '$jtime'";
  1339. $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
  1340. //取得信息列表
  1341. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1342. $rows = array();
  1343. $list = array();
  1344. foreach ($info_list as $key => $value) {
  1345. if (isset($wt[$value['type']])) {
  1346. $info_list[$key]['type'] = $wt[$value['type']];
  1347. } else {
  1348. $info_list[$key]['type'] = '未设置';
  1349. }
  1350. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1351. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1352. $ztdata = '';
  1353. if (count($zt) > 0) {
  1354. foreach ($zt as $vv) {
  1355. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1356. }
  1357. }
  1358. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1359. $cdata = array_filter($qbdata, function ($item) {
  1360. return $item['state'] < 1;
  1361. });
  1362. $c = array_sum(array_column($cdata, 'jnum'));
  1363. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1364. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1365. });
  1366. $g = array_sum(array_column($gdata, 'jnum'));
  1367. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1368. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1369. });
  1370. $x = array_sum(array_column($xdata, 'jnum'));
  1371. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1372. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1373. });
  1374. $t = array_sum(array_column($tdata, 'jnum'));
  1375. // $zdata = array_filter($qbdata, function ($item) {
  1376. // return $item['zd'] != "" && $item['state'] < 1;
  1377. // });
  1378. // $z = array_sum(array_column($zdata, 'jnum'));
  1379. $zdata = array_filter($qbdata, function ($item) {
  1380. return $item['zd'] != "" && $item['state'] < 1;
  1381. });
  1382. $z = array_sum(array_column($zdata, 'jnum'));
  1383. //$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');
  1384. //$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'].'"');
  1385. //$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'].'"');
  1386. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1387. //$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'].'"');
  1388. $details = array();
  1389. $cpid = array();
  1390. $od = array();
  1391. $odid = '';
  1392. $companytitle = '';
  1393. $shop_list = [];
  1394. foreach ($qbdata as $v) {
  1395. if ($v['zd'] != "" && $v['state'] < 1) {
  1396. if (!isset($od[$v['zd']])) {
  1397. $od[$v['zd']] = 1; //所有数据sku
  1398. } else {
  1399. $od[$v['zd']] = $od[$v['zd']] + 1;
  1400. }
  1401. }
  1402. $details[$v['details']] = $v['details'];
  1403. if ($v['state'] < 1) {
  1404. //$details[$v['details']] = $v['details'];
  1405. if ($v['cpid'] != 0) {
  1406. $cpid[$v['cpid']] = $v['cpid'];
  1407. }
  1408. }
  1409. if($v['state'] == 0){
  1410. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1411. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1412. }
  1413. if ($v['shop'] != '') {
  1414. $shop = explode(',', trim($v['shop'], ','));
  1415. foreach ($shop as $vv) {
  1416. if (!in_array($vv, $shop_list)) {
  1417. $shop_list[] = $vv;
  1418. }
  1419. }
  1420. }
  1421. }
  1422. }
  1423. foreach ($od as $k => $vv) {
  1424. $odid .= $k . '数量' . $vv;
  1425. }
  1426. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1427. $info_list[$key]['label'] = $value['sm'];
  1428. $number = $value['number'];
  1429. $ftime = time() - 15 * 24 * 3600;
  1430. $z = $z . '(' . $odid . ')'; //查看订单号
  1431. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1432. $info_list[$key]['features'] = $c;
  1433. $info_list[$key]['number'] = $ztdata;
  1434. $info_list[$key]['sm'] = $g;
  1435. $info_list[$key]['x'] = $x;
  1436. $info_list[$key]['t'] = $t;
  1437. $info_list[$key]['z'] = $z;
  1438. /**
  1439. foreach ($cdata as $k=>$v)
  1440. {
  1441. $details[$v['details']] = $v['details'];
  1442. if($v['cpid'] != 0)
  1443. {
  1444. $cpid[$v['cpid']] = $v['cpid'];
  1445. }
  1446. }
  1447. **/
  1448. $info_list[$key]['shop'] = '';
  1449. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1450. // if ($value['shop'] != '') {
  1451. // $shop = explode(',', trim($value['shop'], ','));
  1452. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1453. // }
  1454. $shop_list = array_unique($shop_list);
  1455. $shop_str = '';
  1456. foreach ($shop_list as $v) {
  1457. if(isset($sp[$v])){
  1458. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1459. }
  1460. }
  1461. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1462. /**
  1463. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1464. if(isset($companytitle[0]))
  1465. {
  1466. foreach ($companytitle as $k=>$v)
  1467. {
  1468. if($v['companytitle'] != '')
  1469. {
  1470. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1471. }
  1472. }
  1473. }
  1474. **/
  1475. }
  1476. $final_all_list = [];
  1477. foreach ($info_list as $k => $v) {
  1478. $final_all_list[] = [
  1479. 'id' => $v['id'],
  1480. "warehouse" => $v["warehouse"],
  1481. "purchase" => $v["purchase"],
  1482. "sku" => $v["sku"],
  1483. "title" => $v["title"] . "<br/>" . $v["pm"],
  1484. "details" => $v["details"],
  1485. "shop" => $v["shop"],
  1486. "cpbz" => $v["cpbz"],
  1487. 'label' => $v['label'],
  1488. "type" => $v["type"],
  1489. "features" => $v["features"],
  1490. "number" => $v["number"],
  1491. "sm" => $v["sm"],
  1492. "x" => $v["x"],
  1493. "t" => $v["t"],
  1494. "z" => $v["z"]
  1495. ];
  1496. }
  1497. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1498. $pagenum = ceil($total / $perpage);
  1499. $over = $total - ($start + $perpage);
  1500. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1501. echo json_encode($rows);
  1502. exit;
  1503. }
  1504. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1505. $this->data['shop'] = $wlshop;
  1506. $this->data['vip'] = $vip;
  1507. $this->_Template('whlabel_type', $this->data);
  1508. }
  1509. //美仓进销存浏览
  1510. public function _usatype()
  1511. {
  1512. if (isset($_SESSION['api'])) {
  1513. $user = $this->user->get_api($_SESSION['api']);
  1514. $usp = $user;
  1515. $fgshop = "";
  1516. $sid = "";
  1517. $wid = "";
  1518. $wtype = "";
  1519. $userwh = explode('|', trim($user['warehouse'], '|'));
  1520. foreach ($userwh as $value) {
  1521. $wid .= " id = " . $value . " or";
  1522. $wtype .= " type = " . $value . " or";
  1523. }
  1524. }
  1525. $prc = array();
  1526. $purchase = $this->purchase->find_all();
  1527. foreach ($purchase as $k => $v) {
  1528. $prc[$v['id']] = $v['title'];
  1529. }
  1530. $post = $this->input->post(NULL, TRUE);
  1531. if (isset($post['page'])) {
  1532. $page = $this->input->post('page', true);
  1533. $perpage = $this->input->post('perpage', true);
  1534. $category = $this->input->post('category', true);
  1535. $size = $this->input->post('size', true);
  1536. $grade = $this->input->post('grade', true);
  1537. $color = $this->input->post('color', true);
  1538. $lowe = $this->input->post('lowe', true);
  1539. $sku = $this->input->post('sku');
  1540. $title = $this->input->post('title');
  1541. $warehouse = $this->input->post('warehouse', true);
  1542. $usa = $this->input->post('usa', true);
  1543. $purchase = $this->input->post('purchase', true);
  1544. $lacetype = $this->input->post('lacetype', true);
  1545. $haircap = $this->input->post('haircap', true);
  1546. $density = $this->input->post('density', true);
  1547. $details = $this->input->post('details', true);
  1548. $state = $this->input->post('state', true);
  1549. $lacecolor = $this->input->post('lacecolor', true);
  1550. $cklx = $this->input->post('cklx', true);
  1551. $ktime = $this->input->post('ktime', true);
  1552. $jtime = $this->input->post('jtime', true);
  1553. $ktime = strtotime($ktime);
  1554. $jtime = strtotime($jtime);
  1555. $where = "1=1";
  1556. $gj = "";
  1557. $ck = "";
  1558. if ($lacetype) {
  1559. $where .= " and features like '%-$lacetype-%'";
  1560. }
  1561. if ($category) {
  1562. $where .= " and features like '%-$category-%'";
  1563. }
  1564. if ($size) {
  1565. $where .= " and features like '%-$size-%'";
  1566. }
  1567. if ($grade) {
  1568. $where .= " and features like '%-$grade-%'";
  1569. }
  1570. if ($color) {
  1571. $where .= " and features like '%-$color-%'";
  1572. }
  1573. if ($lowe) {
  1574. $where .= " and features like '%-$lowe-%'";
  1575. }
  1576. if ($haircap) {
  1577. $where .= " and features like '%-$haircap-%'";
  1578. }
  1579. if ($density) {
  1580. $where .= " and features like '%-$density-%'";
  1581. }
  1582. if ($lacecolor) {
  1583. $where .= " and features like '%-$lacecolor-%'";
  1584. }
  1585. if ($usa) {
  1586. if (!$warehouse) {
  1587. $where .= " and (warehouse = '5' or warehouse = '8')";
  1588. }
  1589. }
  1590. if ($warehouse) {
  1591. $where .= " and warehouse = '$warehouse'";
  1592. }
  1593. if ($details) {
  1594. $where .= " and details = '$details'";
  1595. }
  1596. if ($purchase) {
  1597. $where .= " and purchase = '$purchase'";
  1598. }
  1599. if ($state) {
  1600. $where .= " and state = '$state'";
  1601. }
  1602. $where_add = '';
  1603. if ($cklx) {
  1604. $shop = $this->shop->read($cklx);
  1605. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1606. }
  1607. if ($ktime && $jtime) {
  1608. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1609. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1610. }
  1611. //数据排序
  1612. $order_str = "id desc";
  1613. if (empty($page)) {
  1614. $start = 0;
  1615. $perpage = 1;
  1616. } else {
  1617. $start = ($page - 1) * $perpage;
  1618. }
  1619. if ($sku) {
  1620. $sku = trim($sku, ' ');
  1621. $sku = trim($sku, ' ');
  1622. $where .= " and sku like '%$sku%'";
  1623. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1624. } else if ($title) {
  1625. $title = trim($title, ' ');
  1626. $title = trim($title, ' ');
  1627. $where .= " and title like '%$title%'";
  1628. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1629. } else {
  1630. //$where .= " and time > '$ktime' and time < '$jtime'";
  1631. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1632. }
  1633. //取得信息列表
  1634. $rows = array();
  1635. $list = array();
  1636. foreach ($info_list as $key => $value) {
  1637. $warehouse = $this->warehouse->read($value['warehouse']);
  1638. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1639. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1640. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1641. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1642. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1643. $od = array();
  1644. $odid = '';
  1645. foreach ($z as $v) {
  1646. if (!isset($od[$v['zd']])) {
  1647. $od[$v['zd']] = 1; //所有数据sku
  1648. } else {
  1649. $od[$v['zd']] = $od[$v['zd']] + 1;
  1650. }
  1651. }
  1652. foreach ($od as $k => $vv) {
  1653. $odid .= $k . '数量' . $vv . ' ';
  1654. }
  1655. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1656. $info_list[$key]['features'] = $c;
  1657. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1658. $ztdata = '';
  1659. if (count($zt) > 0) {
  1660. foreach ($zt as $vv) {
  1661. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1662. }
  1663. }
  1664. $info_list[$key]['warehouse'] = $ztdata;
  1665. $info_list[$key]['g'] = $g;
  1666. $info_list[$key]['x'] = $x;
  1667. $info_list[$key]['t'] = $t;
  1668. $info_list[$key]['z'] = $z;
  1669. }
  1670. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1671. $pagenum = ceil($total / $perpage);
  1672. $over = $total - ($start + $perpage);
  1673. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1674. echo json_encode($rows);
  1675. exit;
  1676. }
  1677. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1678. $this->data['warehouse'] = $warehouse;
  1679. $this->_Template('whlabel_typeusa', $this->data);
  1680. }
  1681. //美仓进销存浏览
  1682. public function _usatypeapp()
  1683. {
  1684. $post = $this->input->post(NULL, TRUE);
  1685. if (isset($post['page'])) {
  1686. $page = $this->input->post('page', true);
  1687. $perpage = $this->input->post('perpage', true);
  1688. $sku = $this->input->post('sku', true);
  1689. $warehouse = 5;
  1690. $title = $this->input->post('title', true);
  1691. $state = $this->input->post('state', true);
  1692. $ktime = $this->input->post('ktime', true);
  1693. $jtime = $this->input->post('jtime', true);
  1694. $ktime = strtotime($ktime);
  1695. $jtime = strtotime($jtime);
  1696. $where = "1=1";
  1697. $gj = "";
  1698. $ck = "";
  1699. if ($title) {
  1700. $st = explode(' ', trim($title, ' '));
  1701. foreach ($st as $v) {
  1702. $where .= " and title like '%$v%'";
  1703. }
  1704. }
  1705. if ($warehouse) {
  1706. $where .= " and warehouse = '$warehouse'";
  1707. }
  1708. if ($state) {
  1709. $where .= " and state = '$state'";
  1710. }
  1711. if ($sku) {
  1712. $where .= " and sku like '%$sku%'";
  1713. }
  1714. if ($ktime && $jtime) {
  1715. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1716. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1717. }
  1718. //数据排序
  1719. $order_str = "id desc";
  1720. if (empty($page)) {
  1721. $start = 0;
  1722. $perpage = 1;
  1723. } else {
  1724. $start = ($page - 1) * $perpage;
  1725. }
  1726. //取得信息列表
  1727. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1728. $rows = array();
  1729. $list = array();
  1730. foreach ($info_list as $key => $value) {
  1731. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1732. }
  1733. $rowsdq = array_slice($rows, $start, $perpage);
  1734. foreach ($rowsdq as $value) {
  1735. $warehouse = $this->warehouse->read($value['warehouse']);
  1736. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1737. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1738. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1739. $od = array();
  1740. $odid = '';
  1741. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1742. }
  1743. $total = count($rows);
  1744. $pagenum = ceil($total / $perpage);
  1745. $over = $total - ($start + $perpage);
  1746. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1747. echo json_encode($rows);
  1748. exit;
  1749. }
  1750. $this->_Template('phone/p_usatypeapp', $this->data);
  1751. }
  1752. //入库操作
  1753. public function _enteradd()
  1754. {
  1755. $dt = 0;
  1756. if (isset($_SESSION['api'])) {
  1757. $user = $this->user->get_api($_SESSION['api']);
  1758. $usp = $user;
  1759. $fgshop = "";
  1760. $sid = "";
  1761. $user = explode('|', trim($user['shop'], '|'));
  1762. foreach ($user as $value) {
  1763. $fgshop .= " shop = " . $value . " or";
  1764. $sid .= " id = " . $value . " or";
  1765. }
  1766. }
  1767. $tc = $this->typeclass->find_all();
  1768. $typeclass = array();
  1769. foreach ($tc as $v) {
  1770. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1771. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1772. }
  1773. $post = $this->input->post(NULL, TRUE);
  1774. if (isset($post['sku'])) {
  1775. $list = array();
  1776. $num = "";
  1777. $title = "";
  1778. $features = "";
  1779. $order = $this->input->post('order', true);
  1780. $shop = $this->input->post('shop', true);
  1781. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1782. $sku = $this->input->post('sku', true);
  1783. $post['sm'] = $this->input->post('sm', true);
  1784. $post['warehouse'] = $this->input->post('warehouse', true);
  1785. $post['purchase'] = $this->input->post('purchase', true);
  1786. $post['retreatwarehouse'] = $post['warehouse'];
  1787. $post['state'] = $this->input->post('state', true);
  1788. $post['rktype'] = $this->input->post('rktype', true);
  1789. $post['text'] = $this->input->post('text', true);
  1790. $category = $this->input->post('category', true);
  1791. $list['category'] = $category;
  1792. $list['hairtype'] = $this->input->post('hairtype', true);
  1793. $list['grade'] = $this->input->post('grade', true);
  1794. $size = $this->input->post('size', true);
  1795. $xzsku = $this->input->post('xzsku', true);
  1796. $list['size'] = rtrim($size, ',');
  1797. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1798. $list['extension'] = $this->input->post('extension', true);
  1799. if ($category == 1297) {
  1800. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1801. }
  1802. if ($category == 1702) {
  1803. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1804. $list['syother'] = $this->input->post('syother', true);
  1805. }
  1806. if ($category == 133) {
  1807. $list['fittype'] = $this->input->post('fittype', true);
  1808. $list['acother'] = $this->input->post('acother', true);
  1809. }
  1810. $list['color'] = $this->input->post('color', true);
  1811. $list['lowe'] = $this->input->post('lowe', true);
  1812. if (!$post['purchase']) {
  1813. $post['purchase'] = 1;
  1814. }
  1815. if ($category == 127) {
  1816. $list['type'] = $this->input->post('type', true);
  1817. $list['headroad'] = $this->input->post('headroad', true);
  1818. $list['density'] = $this->input->post('density', true);
  1819. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1820. $list['lacesize'] = $this->input->post('lacesize', true);
  1821. }
  1822. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1823. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1824. }
  1825. if ($category == 128) {
  1826. $list['lacetype'] = $this->input->post('lacetype', true);
  1827. $list['haircap'] = $this->input->post('haircap', true);
  1828. $list['density'] = $this->input->post('density', true);
  1829. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1830. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1831. $list['wigother'] = $this->input->post('wigother', true);
  1832. $list['wigother1'] = $this->input->post('wigother1', true);
  1833. $list['wigother2'] = $this->input->post('wigother2', true);
  1834. }
  1835. if ($category == 129) {
  1836. $list['wide'] = $this->input->post('wide', true);
  1837. }
  1838. if ($category == 131) {
  1839. $list['gifttype'] = $this->input->post('gifttype', true);
  1840. $list['giftother'] = $this->input->post('giftother', true);
  1841. }
  1842. if ($category == 134) {
  1843. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1844. }
  1845. if ($category == 1297) {
  1846. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1847. $list['sywigother'] = $this->input->post('sywigother', true);
  1848. }
  1849. if ($category == 130 || $category == 133 || $category == 1702) {
  1850. $list['items'] = $this->input->post('items', true);
  1851. $list['weight'] = $this->input->post('weight', true);
  1852. }
  1853. if($category == 130){
  1854. $list['jfother'] = $this->input->post('jfother', true);
  1855. }
  1856. if ($category == 1702) {
  1857. $list['syhairther'] = $this->input->post('syhairther', true);
  1858. }
  1859. $classid = $this->classid->sku();
  1860. $scsku = $classid;
  1861. $pm = $classid;
  1862. foreach ($list as $k => $v) {
  1863. if ($v != 0) {
  1864. $num .= $v;
  1865. $features .= $v . '-';
  1866. $post[$k] = $v;
  1867. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1868. if ($k != 'size') {
  1869. $title .= $typeclass[$v]['title'] . " ";
  1870. }
  1871. if (isset($pm[$typeclass[$v]['classid']])) {
  1872. if ($typeclass[$v]['title'] == '9A') {
  1873. $pm[$typeclass[$v]['classid']] = '9A';
  1874. } else if ($typeclass[$v]['title'] == '10A') {
  1875. $pm[$typeclass[$v]['classid']] = '10A';
  1876. } else {
  1877. $clzh = $typeclass[$v]['zh'];
  1878. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1879. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1880. $clzh = $clzh[0];
  1881. }
  1882. $pm[$typeclass[$v]['classid']] = $clzh;
  1883. }
  1884. }
  1885. }
  1886. }
  1887. $zh = implode(" ", $pm);
  1888. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1889. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1890. if ($list['size']) {
  1891. $typeclass = $this->typeclass->read($list['size']);
  1892. $title .= $typeclass['title'];
  1893. }
  1894. $time = time();
  1895. if ($xzsku) {
  1896. $scsku = implode("-", $scsku);
  1897. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1898. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1899. $post['sku'] = trim($scsku, ' ');
  1900. } else {
  1901. $post['sku'] = $sku;
  1902. }
  1903. //$post['sku'] = trim($sku,' ');
  1904. $post['title'] = rtrim($title, ' ');
  1905. $post['number'] = $num;
  1906. $post['features'] = '-' . $features;
  1907. $post['enter'] = $time;
  1908. $post['time'] = $time; //操作时间
  1909. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1910. if ($yza) {
  1911. if ($post['features'] != $yza[0]['features']) {
  1912. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1913. exit;
  1914. }
  1915. }
  1916. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1917. if ($yzb) {
  1918. if ($post['sku'] != $yzb[0]['sku']) {
  1919. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1920. exit;
  1921. }
  1922. }
  1923. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1924. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1925. exit;
  1926. }
  1927. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1928. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1929. exit;
  1930. }
  1931. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1932. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1933. exit;
  1934. }
  1935. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1936. if (isset($yz[0]['type'])) {
  1937. $post['type'] = $yz[0]['type'];
  1938. }
  1939. if ($post['state'] == 9) //如果选择预设库存
  1940. {
  1941. $this->whlabel->insert($post);
  1942. } else {
  1943. /**
  1944. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1945. if($ljg == 1)
  1946. {
  1947. for($i=0;$i<$order;$i++)
  1948. {
  1949. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1950. $this->whlabel->insert($post);
  1951. }
  1952. }
  1953. **/
  1954. //if($post['warehouse'] == '5')
  1955. //{
  1956. //}
  1957. $yydata = $post;
  1958. $yydata['zh'] = $zh;
  1959. /**
  1960. $wl = $this->apiyy->get_cjlp($yydata);
  1961. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1962. {
  1963. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1964. }
  1965. if($wl['Data'][0]['m_isSucess'] != 1)
  1966. {
  1967. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1968. }
  1969. **/
  1970. for ($i = 0; $i < $order; $i++) {
  1971. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1972. $this->whlabel->insert($post);
  1973. }
  1974. }
  1975. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1976. exit;
  1977. }
  1978. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1979. $this->data['wlshop'] = $wlshop;
  1980. $this->_Template('whlabel_enteradd', $this->data);
  1981. }
  1982. //修改产品
  1983. public function _enteredit($arg_array)
  1984. {
  1985. $dt = 0;
  1986. if (isset($_SESSION['api'])) {
  1987. $user = $this->user->get_api($_SESSION['api']);
  1988. $usp = $user;
  1989. $fgshop = "";
  1990. $sid = "";
  1991. $user = explode('|', trim($user['shop'], '|'));
  1992. foreach ($user as $value) {
  1993. $fgshop .= " shop = " . $value . " or";
  1994. $sid .= " id = " . $value . " or";
  1995. }
  1996. }
  1997. $post = $this->input->post(NULL, TRUE);
  1998. if (isset($post['sku'])) {
  1999. $list = array();
  2000. $num = "";
  2001. $title = "";
  2002. $features = "";
  2003. $id = $this->input->post('id', true);
  2004. $order = $this->input->post('order', true);
  2005. $shop = $this->input->post('shop', true);
  2006. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2007. $post['sku'] = $this->input->post('sku', true);
  2008. $post['sm'] = $this->input->post('sm', true);
  2009. $post['warehouse'] = $this->input->post('warehouse', true);
  2010. $post['purchase'] = $this->input->post('purchase', true);
  2011. $post['retreatwarehouse'] = $post['warehouse'];
  2012. $category = $this->input->post('category', true);
  2013. $list['category'] = $category;
  2014. $list['hairtype'] = $this->input->post('hairtype', true);
  2015. $list['grade'] = $this->input->post('grade', true);
  2016. $size = $this->input->post('size', true);
  2017. $list['size'] = rtrim($size, ',');
  2018. $post['rktype'] = $this->input->post('rktype', true);
  2019. $post['text'] = $this->input->post('text', true);
  2020. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2021. $list['extension'] = $this->input->post('extension', true);
  2022. if ($category == 1297) {
  2023. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2024. }
  2025. if ($category == 1702) {
  2026. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2027. $list['syother'] = $this->input->post('syother', true);
  2028. }
  2029. if ($category == 133) {
  2030. $list['fittype'] = $this->input->post('fittype', true);
  2031. $list['acother'] = $this->input->post('acother', true);
  2032. }
  2033. $list['color'] = $this->input->post('color', true);
  2034. $list['lowe'] = $this->input->post('lowe', true);
  2035. if (!$post['purchase']) {
  2036. $post['purchase'] = 1;
  2037. }
  2038. if ($category == 127) {
  2039. $list['type'] = $this->input->post('type', true);
  2040. $list['headroad'] = $this->input->post('headroad', true);
  2041. $list['density'] = $this->input->post('density', true);
  2042. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2043. $list['lacesize'] = $this->input->post('lacesize', true);
  2044. }
  2045. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2046. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2047. }
  2048. if ($category == 128) {
  2049. $list['lacetype'] = $this->input->post('lacetype', true);
  2050. $list['haircap'] = $this->input->post('haircap', true);
  2051. $list['density'] = $this->input->post('density', true);
  2052. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2053. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2054. $list['wigother'] = $this->input->post('wigother', true);
  2055. $list['wigother1'] = $this->input->post('wigother1', true);
  2056. $list['wigother2'] = $this->input->post('wigother2', true);
  2057. }
  2058. if ($category == 129) {
  2059. $list['wide'] = $this->input->post('wide', true);
  2060. }
  2061. if ($category == 131) {
  2062. $list['gifttype'] = $this->input->post('gifttype', true);
  2063. $list['giftother'] = $this->input->post('giftother', true);
  2064. }
  2065. if ($category == 134) {
  2066. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2067. }
  2068. if ($category == 1297) {
  2069. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2070. $list['sywigother'] = $this->input->post('sywigother', true);
  2071. }
  2072. if ($category == 130 || $category == 133 || $category == 1702) {
  2073. $list['items'] = $this->input->post('items', true);
  2074. $list['weight'] = $this->input->post('weight', true);
  2075. }
  2076. if($category == 130){
  2077. $list['jfother'] = $this->input->post('jfother', true);
  2078. }
  2079. if ($category == 1702) {
  2080. $list['syhairther'] = $this->input->post('syhairther', true);
  2081. }
  2082. foreach ($list as $k => $v) {
  2083. if ($v != 0) {
  2084. $num .= $v;
  2085. $features .= $v . '-';
  2086. $typeclass = $this->typeclass->read($v);
  2087. if ($k != 'size') {
  2088. $title .= $typeclass['title'] . " ";
  2089. }
  2090. }
  2091. }
  2092. $typeclass = $this->typeclass->read($list['size']);
  2093. $title .= $typeclass['title'];
  2094. $time = time();
  2095. $post['title'] = rtrim($title, ' ');
  2096. $post['number'] = $num;
  2097. $post['features'] = '-' . $features;
  2098. $post['time'] = $time; //操作时间
  2099. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2100. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2101. exit;
  2102. }
  2103. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2104. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2105. exit;
  2106. }
  2107. $uid = $this->whlabel->read($id);
  2108. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2109. if ($datanum > 0) {
  2110. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2111. exit;
  2112. }
  2113. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2114. {
  2115. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2116. if ($yza) {
  2117. if ($post['features'] != $yza[0]['features']) {
  2118. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2119. exit;
  2120. }
  2121. }
  2122. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2123. if ($yzb) {
  2124. if ($post['sku'] != $yzb[0]['sku']) {
  2125. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2126. exit;
  2127. }
  2128. }
  2129. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2130. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2131. exit;
  2132. }
  2133. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2134. foreach ($data as $v) {
  2135. $post['id'] = $v['id'];
  2136. $this->whlabel->save($post, $v['id']);
  2137. }
  2138. } else {
  2139. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2140. if ($data > 0) {
  2141. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2142. exit;
  2143. } else {
  2144. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2145. foreach ($data as $v) {
  2146. $post['id'] = $v['id'];
  2147. $this->whlabel->save($post, $v['id']);
  2148. }
  2149. }
  2150. }
  2151. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2152. exit;
  2153. }
  2154. $uid = $this->whlabel->read($arg_array[0]);
  2155. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2156. $this->data['enter'] = $uid;
  2157. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2158. $this->data['wlshop'] = $wlshop;
  2159. $this->_Template('whlabel_enteredit', $this->data);
  2160. }
  2161. //入库浏览
  2162. public function _enter()
  2163. {
  2164. $post = $this->input->post(NULL, TRUE);
  2165. if (isset($post['s'])) {
  2166. $id_arr = $this->input->post('s');
  2167. $id_arr = explode(',', $id_arr);
  2168. if (!$id_arr) {
  2169. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2170. exit;
  2171. }
  2172. //循环删除记录
  2173. foreach ($id_arr as $v) {
  2174. $sid = $this->whlabel->read($v);
  2175. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2176. if ($count > 0) {
  2177. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2178. exit;
  2179. }
  2180. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2181. foreach ($info_list as $va) {
  2182. $this->whlabel->remove($va['id']);
  2183. }
  2184. }
  2185. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2186. exit;
  2187. }
  2188. $sp = array();
  2189. $s = $this->shop->find_all('1=1', 'id,shopname');
  2190. foreach ($s as $v) {
  2191. $sp[$v['id']] = $v['shopname'];
  2192. }
  2193. $wh = array();
  2194. $w = $this->warehouse->find_all('1=1', 'id,title');
  2195. foreach ($w as $v) {
  2196. $wh[$v['id']] = $v['title'];
  2197. }
  2198. if (isset($post['page'])) {
  2199. $page = $this->input->post('page', true);
  2200. $perpage = $this->input->post('perpage', true);
  2201. $category = $this->input->post('category', true);
  2202. $size = $this->input->post('size', true);
  2203. $grade = $this->input->post('grade', true);
  2204. $color = $this->input->post('color', true);
  2205. $lowe = $this->input->post('lowe', true);
  2206. $sku = $this->input->post('sku', true);
  2207. $warehouse = $this->input->post('warehouse', true);
  2208. $purchase = $this->input->post('purchase', true);
  2209. $ktime = $this->input->post('ktime', true);
  2210. $jtime = $this->input->post('jtime', true);
  2211. $ktime = strtotime($ktime);
  2212. $jtime = strtotime($jtime);
  2213. $where = "1=1";
  2214. $gj = "";
  2215. $ck = "";
  2216. if ($category) {
  2217. $where .= " and features like '%-$category-%'";
  2218. }
  2219. if ($size) {
  2220. $where .= " and features like '%-$size-%'";
  2221. }
  2222. if ($grade) {
  2223. $where .= " and features like '%-$grade-%'";
  2224. }
  2225. if ($color) {
  2226. $where .= " and features like '%-$color-%'";
  2227. }
  2228. if ($lowe) {
  2229. $where .= " and features like '%-$lowe-%'";
  2230. }
  2231. if ($warehouse) {
  2232. $where .= " and warehouse = '$warehouse'";
  2233. }
  2234. if ($purchase) {
  2235. $where .= " and purchase = '$purchase'";
  2236. }
  2237. if ($sku) {
  2238. $where .= " and sku like '%$sku%'";
  2239. }
  2240. if ($ktime && $jtime) {
  2241. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2242. }
  2243. //数据排序
  2244. $order_str = "enter desc";
  2245. if (empty($page)) {
  2246. $start = 0;
  2247. $perpage = 1;
  2248. } else {
  2249. $start = ($page - 1) * $perpage;
  2250. }
  2251. //取得信息列表
  2252. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2253. foreach ($info_list as $k => $v) {
  2254. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2255. if ($v['shop'] == '') {
  2256. $s = '通用';
  2257. } else {
  2258. $info_list[$k]['shop'] = '';
  2259. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2260. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2261. }
  2262. }
  2263. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2264. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2265. $info_list[$k]['g'] = $g;
  2266. }
  2267. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2268. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2269. $pagenum = ceil($total / $perpage);
  2270. $over = $total - ($start + $perpage);
  2271. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2272. echo json_encode($rows);
  2273. exit;
  2274. }
  2275. $this->_Template('whlabel_enter', $this->data);
  2276. }
  2277. //出库浏览
  2278. public function _out()
  2279. {
  2280. $post = $this->input->post(NULL, TRUE);
  2281. if (isset($post['page'])) {
  2282. $page = $this->input->post('page', true);
  2283. $perpage = $this->input->post('perpage', true);
  2284. $category = $this->input->post('category', true);
  2285. $size = $this->input->post('size', true);
  2286. $grade = $this->input->post('grade', true);
  2287. $color = $this->input->post('color', true);
  2288. $lowe = $this->input->post('lowe', true);
  2289. $sku = $this->input->post('sku', true);
  2290. $warehouse = $this->input->post('warehouse', true);
  2291. $purchase = $this->input->post('purchase', true);
  2292. $state = $this->input->post('state', true);
  2293. $ktime = $this->input->post('ktime', true);
  2294. $jtime = $this->input->post('jtime', true);
  2295. $ktime = strtotime($ktime);
  2296. $jtime = strtotime($jtime);
  2297. $where = "state=3";
  2298. $gj = "";
  2299. $ck = "";
  2300. if ($category) {
  2301. $where .= " and features like '%-$category-%'";
  2302. }
  2303. if ($size) {
  2304. $where .= " and features like '%-$size-%'";
  2305. }
  2306. if ($grade) {
  2307. $where .= " and features like '%-$grade-%'";
  2308. }
  2309. if ($color) {
  2310. $where .= " and features like '%-$color-%'";
  2311. }
  2312. if ($lowe) {
  2313. $where .= " and features like '%-$lowe-%'";
  2314. }
  2315. if ($state) {
  2316. $where .= " and state = '$state'";
  2317. }
  2318. if ($warehouse) {
  2319. $where .= " and warehouse = '$warehouse'";
  2320. }
  2321. if ($purchase) {
  2322. $where .= " and purchase = '$purchase'";
  2323. }
  2324. if ($sku) {
  2325. $where .= " and sku = '$sku'";
  2326. }
  2327. if ($ktime && $jtime) {
  2328. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2329. }
  2330. //数据排序
  2331. $order_str = "id desc";
  2332. if (empty($page)) {
  2333. $start = 0;
  2334. $perpage = 1;
  2335. } else {
  2336. $start = ($page - 1) * $perpage;
  2337. }
  2338. //取得信息列表
  2339. $info_list = $this->whlabel->find_all($where, 'sku');
  2340. $rows = array();
  2341. $list = array();
  2342. foreach ($info_list as $key => $value) {
  2343. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2344. }
  2345. $rows = array_unique($rows); //删除重复记录
  2346. foreach ($rows as $key => $value) {
  2347. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2348. $ck = $this->warehouse->read($data['warehouse']);
  2349. $warehouse = $ck['title'];
  2350. $gy = $this->purchase->read($data['purchase']);
  2351. $purchase = $gy['purchase'];
  2352. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2353. $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);
  2354. }
  2355. $total = count($list);
  2356. $pagenum = ceil($total / $perpage);
  2357. $over = $total - ($start + $perpage);
  2358. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2359. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2360. echo json_encode($rows);
  2361. exit;
  2362. }
  2363. $this->_Template('whlabel_out', $this->data);
  2364. }
  2365. //出库标签浏览
  2366. public function _label()
  2367. {
  2368. $post = $this->input->post(NULL, TRUE);
  2369. if (isset($post['page'])) {
  2370. $page = $this->input->post('page', true);
  2371. $perpage = $this->input->post('perpage', true);
  2372. $sku = $this->input->post('sku', true);
  2373. $warehouse = $this->input->post('warehouse', true);
  2374. $purchase = $this->input->post('purchase', true);
  2375. $orderinfo = $this->input->post('orderinfo', true);
  2376. $waybill = $this->input->post('waybill', true);
  2377. $category = $this->input->post('category', true);
  2378. $size = $this->input->post('size', true);
  2379. $grade = $this->input->post('grade', true);
  2380. $color = $this->input->post('color', true);
  2381. $lowe = $this->input->post('lowe', true);
  2382. $where = "state=1";
  2383. if ($sku) {
  2384. $where .= " and sku = '$sku'";
  2385. }
  2386. if ($warehouse) {
  2387. $where .= " and warehouse = '$warehouse'";
  2388. }
  2389. if ($purchase) {
  2390. $where .= " and purchase = '$purchase'";
  2391. }
  2392. if ($orderinfo) {
  2393. $where .= " and orderinfo = '$orderinfo'";
  2394. }
  2395. if ($waybill) {
  2396. $where .= " and waybill = '$waybill'";
  2397. }
  2398. if ($category) {
  2399. $where .= " and features like '%-$category-%'";
  2400. }
  2401. if ($size) {
  2402. $where .= " and features like '%-$size-%'";
  2403. }
  2404. if ($grade) {
  2405. $where .= " and features like '%-$grade-%'";
  2406. }
  2407. if ($color) {
  2408. $where .= " and features like '%-$color-%'";
  2409. }
  2410. if ($lowe) {
  2411. $where .= " and features like '%-$lowe-%'";
  2412. }
  2413. //数据排序
  2414. $order_str = "outk desc";
  2415. if (empty($page)) {
  2416. $start = 0;
  2417. $perpage = 1;
  2418. } else {
  2419. $start = ($page - 1) * $perpage;
  2420. }
  2421. //取得信息列表
  2422. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2423. foreach ($info_list as $key => $value) {
  2424. $warehouse = $this->warehouse->read($value['warehouse']);
  2425. $info_list[$key]['warehouse'] = $warehouse['title'];
  2426. $purchase = $this->purchase->read($value['purchase']);
  2427. $info_list[$key]['purchase'] = $purchase['title'];
  2428. if ($value['outk'] != 0) {
  2429. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2430. } else {
  2431. $info_list[$key]['outk'] = "";
  2432. }
  2433. if ($value['orderinfo'] == 0) {
  2434. $info_list[$key]['orderinfo'] = "";
  2435. }
  2436. if ($value['waybill'] == 0) {
  2437. $info_list[$key]['waybill'] = "";
  2438. }
  2439. }
  2440. $total = $this->whlabel->find_count($where);
  2441. $pagenum = ceil($total / $perpage);
  2442. $over = $total - ($start + $perpage);
  2443. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2444. echo json_encode($rows);
  2445. exit;
  2446. }
  2447. $this->_Template('whlabel_label', $this->data);
  2448. }
  2449. //独立站出库订单
  2450. public function _outorder()
  2451. {
  2452. if (isset($_SESSION['api'])) {
  2453. $user = $this->user->get_api($_SESSION['api']);
  2454. $usp = $user;
  2455. $fgshop = "";
  2456. $sid = "";
  2457. $user = explode('|', trim($user['shop'], '|'));
  2458. foreach ($user as $value) {
  2459. $fgshop .= " shop = " . $value . " or";
  2460. $sid .= " id = " . $value . " or";
  2461. }
  2462. } else {
  2463. echo "请重新登录";
  2464. }
  2465. $post = $this->input->post(NULL, TRUE);
  2466. if (isset($post['page'])) {
  2467. $page = $this->input->post('page', true);
  2468. $perpage = $this->input->post('perpage', true);
  2469. $warehouse = $this->input->post('warehouse', true);
  2470. $xztime = $this->input->post('xztime', true);
  2471. $timetk = $this->input->post('timetkk', true);
  2472. $timetj = $this->input->post('timetjj', true);
  2473. $shop = $this->input->post('shop', true);
  2474. $source = $this->input->post('source', true);
  2475. $orderinfo = $this->input->post('orderinfo', true);
  2476. $number = $this->input->post('number', true);
  2477. $sfxh = $this->input->post('sfxh', true);
  2478. $express = $this->input->post('express', true);
  2479. $waybill = $this->input->post('waybill', true);
  2480. $library = $this->input->post('library', true);
  2481. $country = $this->input->post('country', true);
  2482. $so = $this->input->post('so', true);
  2483. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2484. $print = $this->input->post('print', true);
  2485. $state = $this->input->post('state', true);
  2486. $orderurl = $this->input->post('orderurl', true);
  2487. $productid = $this->input->post('productid', true);
  2488. $timetk = strtotime($timetk);
  2489. $timetj = strtotime($timetj);
  2490. /**
  2491. $sj = $this->input->post('sj',true);
  2492. if($sj)
  2493. {
  2494. $sj = $this->input->post('sj',true);
  2495. }
  2496. else
  2497. {
  2498. $sj = "fullorder";
  2499. }
  2500. **/
  2501. $sj = "fullorder";
  2502. $where = "1=1";
  2503. if ($warehouse) {
  2504. $where .= " and type = '$warehouse'";
  2505. }
  2506. if ($timetk && $timetj) {
  2507. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2508. }
  2509. if ($orderinfo) {
  2510. $where .= " and orderinfo = '$orderinfo'";
  2511. }
  2512. if ($number) {
  2513. $where .= " and number = '$number'";
  2514. }
  2515. if ($express) {
  2516. $where .= " and express = '$express'";
  2517. }
  2518. if ($waybill) {
  2519. $where .= " and waybill = '$waybill'";
  2520. }
  2521. if ($library) {
  2522. $where .= " and library = '$library'";
  2523. }
  2524. if ($print) {
  2525. $where .= " and print = '$print'";
  2526. }
  2527. if ($libraryconfirm) {
  2528. $where .= " and libraryconfirm = '$libraryconfirm'";
  2529. }
  2530. if ($state) {
  2531. $where .= " and state = '$state'";
  2532. }
  2533. if ($shop) {
  2534. $where .= " and shop = '$shop'";
  2535. }
  2536. if ($country) {
  2537. $where .= " and country = '$country'";
  2538. }
  2539. if ($sfxh != '') {
  2540. $where .= " and sfxh = '$sfxh'";
  2541. }
  2542. if ($so) {
  2543. $where .= " and shipremarks like '%$so%'";
  2544. }
  2545. if ($source) {
  2546. if ($source == '2d') {
  2547. $where .= " and source >= '2'";
  2548. } else {
  2549. $where .= " and source = '$source'";
  2550. }
  2551. }
  2552. if (isset($_SESSION['api'])) {
  2553. foreach ($user as $value) {
  2554. $fgshop .= " shop = " . $value . " or";
  2555. }
  2556. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2557. }
  2558. if ($orderurl) {
  2559. $url = $this->orderurl->read($orderurl);
  2560. $where .= " and link like '%" . $url['url'] . "%'";
  2561. }
  2562. if($productid){
  2563. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2564. }
  2565. //数据排序
  2566. $order_str = "librarytime desc";
  2567. if (empty($page)) {
  2568. $start = 0;
  2569. $perpage = 1;
  2570. } else {
  2571. $start = ($page - 1) * $perpage;
  2572. }
  2573. //取得信息列表
  2574. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2575. //格式化数据
  2576. foreach ($info_list as $key => $value) {
  2577. $shop = $this->shop->read($value['shop']);
  2578. $info_list[$key]['shop'] = $shop['shopname'];
  2579. $express = $this->express->read($value['express']);
  2580. $info_list[$key]['express'] = $express['servicename'];
  2581. $warehouse = $this->warehouse->read($value['type']);
  2582. $info_list[$key]['type'] = $warehouse['title'];
  2583. if ($value['librarytime'] == '0') {
  2584. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2585. } else {
  2586. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2587. }
  2588. }
  2589. $total = $this->$sj->find_count($where);
  2590. $pagenum = ceil($total / $perpage);
  2591. $over = $total - ($start + $perpage);
  2592. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2593. echo json_encode($rows);
  2594. exit;
  2595. }
  2596. $this->data['express'] = $this->express->find_all();
  2597. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2598. $this->data['wlshop'] = $wlshop;
  2599. $user = $this->user->get_api($_SESSION['api']);
  2600. $powerid = $this->power->read($user['power']);
  2601. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2602. $pid = '';
  2603. foreach ($powertext as $v) {
  2604. $pid .= " id = " . $v . " or";
  2605. }
  2606. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2607. $this->data['fullorderexcel'] = $fullorderexcel;
  2608. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2609. $this->data['orderurl'] = $orderurl;
  2610. $this->_Template('whlabel_outorder', $this->data);
  2611. }
  2612. //tt出库
  2613. public function _toutorder()
  2614. {
  2615. $fgshop = "";
  2616. $sid = "";
  2617. if (isset($_SESSION['api'])) {
  2618. $user = $this->user->get_api($_SESSION['api']);
  2619. $usp = $user;
  2620. $user = explode('|', trim($user['shop'], '|'));
  2621. foreach ($user as $value) {
  2622. $fgshop .= " shop = " . $value . " or";
  2623. $sid .= " id = " . $value . " or";
  2624. }
  2625. } else {
  2626. echo "请重新登录";
  2627. die;
  2628. }
  2629. $post = $this->input->post(NULL, TRUE);
  2630. if (isset($post['page'])) {
  2631. $page = $this->input->post('page', true);
  2632. $perpage = $this->input->post('perpage', true);
  2633. $warehouse = $this->input->post('warehouse', true);
  2634. $xztime = $this->input->post('xztime', true);
  2635. $timetk = $this->input->post('timetkk', true);
  2636. $timetj = $this->input->post('timetjj', true);
  2637. $shop = $this->input->post('shop', true);
  2638. $source = $this->input->post('source', true);
  2639. $orderinfo = $this->input->post('orderinfo', true);
  2640. $number = $this->input->post('number', true);
  2641. $sfxh = $this->input->post('sfxh', true);
  2642. $express = $this->input->post('express', true);
  2643. $waybill = $this->input->post('waybill', true);
  2644. $library = $this->input->post('library', true);
  2645. $country = $this->input->post('country', true);
  2646. $so = $this->input->post('so', true);
  2647. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2648. $print = $this->input->post('print', true);
  2649. $state = $this->input->post('state', true);
  2650. $orderurl = $this->input->post('orderurl', true);
  2651. $timetk = strtotime($timetk);
  2652. $timetj = strtotime($timetj);
  2653. /**
  2654. $sj = $this->input->post('sj',true);
  2655. if($sj)
  2656. {
  2657. $sj = $this->input->post('sj',true);
  2658. }
  2659. else
  2660. {
  2661. $sj = "fullorder";
  2662. }
  2663. **/
  2664. $sj = "fullordertt";
  2665. $where = "1=1";
  2666. if ($warehouse) {
  2667. $where .= " and type = '$warehouse'";
  2668. }
  2669. if ($timetk && $timetj) {
  2670. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2671. }
  2672. if ($orderinfo) {
  2673. $where .= " and orderinfo = '$orderinfo'";
  2674. }
  2675. if ($number) {
  2676. $where .= " and number = '$number'";
  2677. }
  2678. if ($express) {
  2679. $where .= " and express = '$express'";
  2680. }
  2681. if ($waybill) {
  2682. $where .= " and waybill = '$waybill'";
  2683. }
  2684. if ($library) {
  2685. $where .= " and library = '$library'";
  2686. }
  2687. if ($print) {
  2688. $where .= " and print = '$print'";
  2689. }
  2690. if ($libraryconfirm) {
  2691. $where .= " and libraryconfirm = '$libraryconfirm'";
  2692. }
  2693. if ($state) {
  2694. $where .= " and state = '$state'";
  2695. }
  2696. if ($shop) {
  2697. $where .= " and shop = '$shop'";
  2698. }
  2699. if ($country) {
  2700. $where .= " and country = '$country'";
  2701. }
  2702. if ($sfxh != '') {
  2703. $where .= " and sfxh = '$sfxh'";
  2704. }
  2705. if ($so) {
  2706. $where .= " and shipremarks like '%$so%'";
  2707. }
  2708. if ($source) {
  2709. if ($source == '2d') {
  2710. $where .= " and source >= '2'";
  2711. } else {
  2712. $where .= " and source = '$source'";
  2713. }
  2714. }
  2715. if (isset($_SESSION['api'])) {
  2716. foreach ($user as $value) {
  2717. $fgshop .= " shop = " . $value . " or";
  2718. }
  2719. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2720. }
  2721. if ($orderurl) {
  2722. $url = $this->orderurl->read($orderurl);
  2723. $where .= " and link like '%" . $url['url'] . "%'";
  2724. }
  2725. //数据排序
  2726. $order_str = "librarytime desc";
  2727. if (empty($page)) {
  2728. $start = 0;
  2729. $perpage = 1;
  2730. } else {
  2731. $start = ($page - 1) * $perpage;
  2732. }
  2733. //取得信息列表
  2734. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2735. //格式化数据
  2736. foreach ($info_list as $key => $value) {
  2737. $shop = $this->shop->read($value['shop']);
  2738. $info_list[$key]['shop'] = $shop['shopname'];
  2739. $express = $this->express->read($value['express']);
  2740. $info_list[$key]['express'] = $express['servicename'];
  2741. $warehouse = $this->warehouse->read($value['type']);
  2742. $info_list[$key]['type'] = $warehouse['title'];
  2743. if ($value['librarytime'] == '0') {
  2744. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2745. } else {
  2746. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2747. }
  2748. }
  2749. $total = $this->$sj->find_count($where);
  2750. $pagenum = ceil($total / $perpage);
  2751. $over = $total - ($start + $perpage);
  2752. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2753. echo json_encode($rows);
  2754. exit;
  2755. }
  2756. $this->data['express'] = $this->express->find_all();
  2757. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2758. $this->data['wlshop'] = $wlshop;
  2759. $user = $this->user->get_api($_SESSION['api']);
  2760. $powerid = $this->power->read($user['power']);
  2761. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2762. $pid = '';
  2763. foreach ($powertext as $v) {
  2764. $pid .= " id = " . $v . " or";
  2765. }
  2766. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2767. $this->data['fullorderexcel'] = $fullorderexcel;
  2768. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2769. $this->data['orderurl'] = $orderurl;
  2770. $this->_Template('whlabel_toutorder', $this->data);
  2771. }
  2772. //tt出库
  2773. public function _aoutorder()
  2774. {
  2775. if (isset($_SESSION['api'])) {
  2776. $user = $this->user->get_api($_SESSION['api']);
  2777. $usp = $user;
  2778. $fgshop = "";
  2779. $sid = "";
  2780. $user = explode('|', trim($user['shop'], '|'));
  2781. foreach ($user as $value) {
  2782. $fgshop .= " shop = " . $value . " or";
  2783. $sid .= " id = " . $value . " or";
  2784. }
  2785. } else {
  2786. echo "请重新登录";
  2787. }
  2788. $post = $this->input->post(NULL, TRUE);
  2789. if (isset($post['page'])) {
  2790. $page = $this->input->post('page', true);
  2791. $perpage = $this->input->post('perpage', true);
  2792. $warehouse = $this->input->post('warehouse', true);
  2793. $xztime = $this->input->post('xztime', true);
  2794. $timetk = $this->input->post('timetkk', true);
  2795. $timetj = $this->input->post('timetjj', true);
  2796. $shop = $this->input->post('shop', true);
  2797. $source = $this->input->post('source', true);
  2798. $orderinfo = $this->input->post('orderinfo', true);
  2799. $number = $this->input->post('number', true);
  2800. $sfxh = $this->input->post('sfxh', true);
  2801. $express = $this->input->post('express', true);
  2802. $waybill = $this->input->post('waybill', true);
  2803. $library = $this->input->post('library', true);
  2804. $country = $this->input->post('country', true);
  2805. $so = $this->input->post('so', true);
  2806. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2807. $print = $this->input->post('print', true);
  2808. $state = $this->input->post('state', true);
  2809. $orderurl = $this->input->post('orderurl', true);
  2810. $timetk = strtotime($timetk);
  2811. $timetj = strtotime($timetj);
  2812. /**
  2813. $sj = $this->input->post('sj',true);
  2814. if($sj)
  2815. {
  2816. $sj = $this->input->post('sj',true);
  2817. }
  2818. else
  2819. {
  2820. $sj = "fullorder";
  2821. }
  2822. **/
  2823. $sj = "fullorderamz";
  2824. $where = "1=1";
  2825. if ($warehouse) {
  2826. $where .= " and type = '$warehouse'";
  2827. }
  2828. if ($timetk && $timetj) {
  2829. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2830. }
  2831. if ($orderinfo) {
  2832. $where .= " and orderinfo = '$orderinfo'";
  2833. }
  2834. if ($number) {
  2835. $where .= " and number = '$number'";
  2836. }
  2837. if ($express) {
  2838. $where .= " and express = '$express'";
  2839. }
  2840. if ($waybill) {
  2841. $where .= " and waybill = '$waybill'";
  2842. }
  2843. if ($library) {
  2844. $where .= " and library = '$library'";
  2845. }
  2846. if ($print) {
  2847. $where .= " and print = '$print'";
  2848. }
  2849. if ($libraryconfirm) {
  2850. $where .= " and libraryconfirm = '$libraryconfirm'";
  2851. }
  2852. if ($state) {
  2853. $where .= " and state = '$state'";
  2854. }
  2855. if ($shop) {
  2856. $where .= " and shop = '$shop'";
  2857. }
  2858. if ($country) {
  2859. $where .= " and country = '$country'";
  2860. }
  2861. if ($sfxh != '') {
  2862. $where .= " and sfxh = '$sfxh'";
  2863. }
  2864. if ($so) {
  2865. $where .= " and shipremarks like '%$so%'";
  2866. }
  2867. if ($source) {
  2868. if ($source == '2d') {
  2869. $where .= " and source >= '2'";
  2870. } else {
  2871. $where .= " and source = '$source'";
  2872. }
  2873. }
  2874. if (isset($_SESSION['api'])) {
  2875. foreach ($user as $value) {
  2876. $fgshop .= " shop = " . $value . " or";
  2877. }
  2878. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2879. }
  2880. if ($orderurl) {
  2881. $url = $this->orderurl->read($orderurl);
  2882. $where .= " and link like '%" . $url['url'] . "%'";
  2883. }
  2884. //数据排序
  2885. $order_str = "librarytime desc";
  2886. if (empty($page)) {
  2887. $start = 0;
  2888. $perpage = 1;
  2889. } else {
  2890. $start = ($page - 1) * $perpage;
  2891. }
  2892. //取得信息列表
  2893. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2894. //格式化数据
  2895. foreach ($info_list as $key => $value) {
  2896. $shop = $this->shop->read($value['shop']);
  2897. $info_list[$key]['shop'] = $shop['shopname'];
  2898. $express = $this->express->read($value['express']);
  2899. $info_list[$key]['express'] = $express['servicename'];
  2900. $warehouse = $this->warehouse->read($value['type']);
  2901. $info_list[$key]['type'] = $warehouse['title'];
  2902. if ($value['librarytime'] == '0') {
  2903. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2904. } else {
  2905. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2906. }
  2907. }
  2908. $total = $this->$sj->find_count($where);
  2909. $pagenum = ceil($total / $perpage);
  2910. $over = $total - ($start + $perpage);
  2911. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2912. echo json_encode($rows);
  2913. exit;
  2914. }
  2915. $this->data['express'] = $this->express->find_all();
  2916. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2917. $this->data['wlshop'] = $wlshop;
  2918. $user = $this->user->get_api($_SESSION['api']);
  2919. $powerid = $this->power->read($user['power']);
  2920. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2921. $pid = '';
  2922. foreach ($powertext as $v) {
  2923. $pid .= " id = " . $v . " or";
  2924. }
  2925. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2926. $this->data['fullorderexcel'] = $fullorderexcel;
  2927. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2928. $this->data['orderurl'] = $orderurl;
  2929. $this->_Template('whlabel_aoutorder', $this->data);
  2930. }
  2931. //速卖通出库订单
  2932. public function _soutorder()
  2933. {
  2934. if (isset($_SESSION['api'])) {
  2935. $user = $this->user->get_api($_SESSION['api']);
  2936. $usp = $user;
  2937. $fgshop = "";
  2938. $sid = "";
  2939. $user = explode('|', trim($user['shop'], '|'));
  2940. foreach ($user as $value) {
  2941. $sid .= " id = " . $value . " or";
  2942. }
  2943. }
  2944. $post = $this->input->post(NULL, TRUE);
  2945. if (isset($post['page'])) {
  2946. $page = $this->input->post('page', true);
  2947. $perpage = $this->input->post('perpage', true);
  2948. $warehouse = $this->input->post('warehouse', true);
  2949. $xztime = $this->input->post('xztime', true);
  2950. $timetk = $this->input->post('timetkk', true);
  2951. $timetj = $this->input->post('timetjj', true);
  2952. $shop = $this->input->post('shop', true);
  2953. $source = $this->input->post('source', true);
  2954. $orderinfo = $this->input->post('orderinfo', true);
  2955. $number = $this->input->post('number', true);
  2956. $express = $this->input->post('express', true);
  2957. $waybill = $this->input->post('waybill', true);
  2958. $library = $this->input->post('library', true);
  2959. $country = $this->input->post('country', true);
  2960. $sfxh = $this->input->post('sfxh', true);
  2961. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2962. $print = $this->input->post('print', true);
  2963. $state = $this->input->post('state', true);
  2964. $so = $this->input->post('so', true);
  2965. $timetk = strtotime($timetk);
  2966. $timetj = strtotime($timetj);
  2967. /**
  2968. $sj = $this->input->post('sj',true);
  2969. if($sj)
  2970. {
  2971. $sj = $this->input->post('sj',true);
  2972. }
  2973. else
  2974. {
  2975. $sj = "fullorder";
  2976. }
  2977. **/
  2978. $sj = "fullordersmt";
  2979. $where = "1=1";
  2980. if ($warehouse) {
  2981. $where .= " and type = '$warehouse'";
  2982. }
  2983. if ($timetk && $timetj) {
  2984. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2985. }
  2986. if ($orderinfo) {
  2987. $where .= " and orderinfo = '$orderinfo'";
  2988. }
  2989. if ($number) {
  2990. $where .= " and number = '$number'";
  2991. }
  2992. if ($express) {
  2993. $where .= " and express = '$express'";
  2994. }
  2995. if ($waybill) {
  2996. $where .= " and waybill = '$waybill'";
  2997. }
  2998. if ($library) {
  2999. $where .= " and library = '$library'";
  3000. }
  3001. if ($print) {
  3002. $where .= " and print = '$print'";
  3003. }
  3004. if ($libraryconfirm) {
  3005. $where .= " and libraryconfirm = '$libraryconfirm'";
  3006. }
  3007. if ($state) {
  3008. $where .= " and state = '$state'";
  3009. }
  3010. if ($shop) {
  3011. $where .= " and shop = '$shop'";
  3012. }
  3013. if ($sfxh != '') {
  3014. $where .= " and sfxh = '$sfxh'";
  3015. }
  3016. if ($so) {
  3017. $where .= " and shipremarks like '%$so%'";
  3018. }
  3019. if ($source) {
  3020. $where .= " and source = '$source'";
  3021. }
  3022. if ($country) {
  3023. $where .= " and country = '$country'";
  3024. } else {
  3025. if (isset($_SESSION['api'])) {
  3026. foreach ($user as $value) {
  3027. $fgshop .= " shop = " . $value . " or";
  3028. }
  3029. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3030. }
  3031. }
  3032. //数据排序
  3033. $order_str = "librarytime desc";
  3034. if (empty($page)) {
  3035. $start = 0;
  3036. $perpage = 1;
  3037. } else {
  3038. $start = ($page - 1) * $perpage;
  3039. }
  3040. //取得信息列表
  3041. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3042. //格式化数据
  3043. foreach ($info_list as $key => $value) {
  3044. $shop = $this->shop->read($value['shop']);
  3045. $info_list[$key]['shop'] = $shop['shopname'];
  3046. $express = $this->express->read($value['express']);
  3047. $info_list[$key]['express'] = $express['servicename'];
  3048. $warehouse = $this->warehouse->read($value['type']);
  3049. $info_list[$key]['type'] = $warehouse['title'];
  3050. if ($value['librarytime'] == '0') {
  3051. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3052. } else {
  3053. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3054. }
  3055. }
  3056. $total = $this->$sj->find_count($where);
  3057. $pagenum = ceil($total / $perpage);
  3058. $over = $total - ($start + $perpage);
  3059. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3060. echo json_encode($rows);
  3061. exit;
  3062. }
  3063. $this->data['express'] = $this->express->find_all();
  3064. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3065. $this->data['wlshop'] = $wlshop;
  3066. $user = $this->user->get_api($_SESSION['api']);
  3067. $powerid = $this->power->read($user['power']);
  3068. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3069. $pid = '';
  3070. foreach ($powertext as $v) {
  3071. $pid .= " id = " . $v . " or";
  3072. }
  3073. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3074. $this->data['fullorderexcel'] = $fullorderexcel;
  3075. $this->_Template('whlabel_soutorder', $this->data);
  3076. }
  3077. //订单退库
  3078. public function _retreat()
  3079. {
  3080. $post = $this->input->post(NULL, TRUE);
  3081. if (isset($post['page'])) {
  3082. $page = $this->input->post('page', true);
  3083. $perpage = $this->input->post('perpage', true);
  3084. $warehouse = $this->input->post('warehouse', true);
  3085. $timetk = $this->input->post('timetk', true);
  3086. $timetj = $this->input->post('timetj', true);
  3087. $shop = $this->input->post('shop', true);
  3088. $source = $this->input->post('source', true);
  3089. $state = $this->input->post('state', true);
  3090. $review = $this->input->post('review', true);
  3091. $state = $this->input->post('state', true);
  3092. $express = $this->input->post('express', true);
  3093. $orderinfo = $this->input->post('orderinfo', true);
  3094. $user = $this->input->post('user', true);
  3095. $name = $this->input->post('name', true);
  3096. $waybill = $this->input->post('waybill', true);
  3097. $timetk = strtotime($timetk);
  3098. $timetj = strtotime($timetj);
  3099. $where = "(state=206 or state=210) and mergeid = 0";
  3100. if ($warehouse) {
  3101. $where .= " and state = '$warehouse'";
  3102. }
  3103. if ($timetk && $timetj) {
  3104. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3105. }
  3106. if ($shop) {
  3107. $where .= " and shop = '$shop'";
  3108. }
  3109. if ($source) {
  3110. $where .= " and source = '$source'";
  3111. }
  3112. if ($state) {
  3113. $where .= " and state = '$state'";
  3114. }
  3115. if ($review) {
  3116. $where .= " and review = '$review'";
  3117. }
  3118. if ($state) {
  3119. $where .= " and state = '$state'";
  3120. }
  3121. if ($express) {
  3122. $where .= " and express = '$express'";
  3123. }
  3124. if ($orderinfo) {
  3125. $where .= " and orderinfo = '$orderinfo'";
  3126. }
  3127. if ($user) {
  3128. $where .= " and user = '$user'";
  3129. }
  3130. if ($name) {
  3131. $where .= " and name = '$name'";
  3132. }
  3133. if ($waybill) {
  3134. $where .= " and waybill = '$waybill'";
  3135. }
  3136. //数据排序
  3137. $order_str = "id desc";
  3138. if (empty($page)) {
  3139. $start = 0;
  3140. $perpage = 1;
  3141. } else {
  3142. $start = ($page - 1) * $perpage;
  3143. }
  3144. //取得信息列表
  3145. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3146. //格式化数据
  3147. foreach ($info_list as $key => $value) {
  3148. $shop = $this->shop->read($value['shop']);
  3149. $info_list[$key]['shop'] = $shop['shopname'];
  3150. $warehouse = $this->warehouse->read($value['warehouse']);
  3151. $info_list[$key]['warehouse'] = $warehouse['title'];
  3152. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3153. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3154. if ($value['waybill'] == 0) {
  3155. $info_list[$key]['waybill'] = "";
  3156. }
  3157. $express = $this->express->read($value['express']);
  3158. $info_list[$key]['express'] = $express['title'];
  3159. $typeclass = $this->typeclass->read($value['state']);
  3160. $info_list[$key]['state'] = $typeclass['title'];
  3161. }
  3162. $total = $this->fullorder->find_count($where);
  3163. $pagenum = ceil($total / $perpage);
  3164. $over = $total - ($start + $perpage);
  3165. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3166. echo json_encode($rows);
  3167. exit;
  3168. }
  3169. $this->data['express'] = $this->express->find_all();
  3170. $this->_Template('whlabel_retreat', $this->data);
  3171. }
  3172. //退库标签浏览
  3173. public function _retreatlk()
  3174. {
  3175. $post = $this->input->post(NULL, TRUE);
  3176. if (isset($post['page'])) {
  3177. $page = $this->input->post('page', true);
  3178. $perpage = $this->input->post('perpage', true);
  3179. $timetk = $this->input->post('timetk', true);
  3180. $timetj = $this->input->post('timetj', true);
  3181. $sku = $this->input->post('sku', true);
  3182. $warehouse = $this->input->post('warehouse', true);
  3183. $purchase = $this->input->post('purchase', true);
  3184. $orderinfo = $this->input->post('orderinfo', true);
  3185. $waybill = $this->input->post('waybill', true);
  3186. $category = $this->input->post('category', true);
  3187. $size = $this->input->post('size', true);
  3188. $grade = $this->input->post('grade', true);
  3189. $color = $this->input->post('color', true);
  3190. $lowe = $this->input->post('lowe', true);
  3191. $state = $this->input->post('state', true);
  3192. $timetk = strtotime($timetk);
  3193. $timetj = strtotime($timetj);
  3194. $where = "state=2";
  3195. if ($timetk && $timetj) {
  3196. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3197. }
  3198. if ($sku) {
  3199. $where .= " and sku = '$sku'";
  3200. }
  3201. if ($warehouse) {
  3202. $where .= " and warehouse = '$warehouse'";
  3203. }
  3204. if ($purchase) {
  3205. $where .= " and purchase = '$purchase'";
  3206. }
  3207. if ($orderinfo) {
  3208. $where .= " and orderinfo = '$orderinfo'";
  3209. }
  3210. if ($waybill) {
  3211. $where .= " and waybill = '$waybill'";
  3212. }
  3213. if ($category) {
  3214. $where .= " and features like '%-$category-%'";
  3215. }
  3216. if ($size) {
  3217. $where .= " and features like '%-$size-%'";
  3218. }
  3219. if ($grade) {
  3220. $where .= " and features like '%-$grade-%'";
  3221. }
  3222. if ($color) {
  3223. $where .= " and features like '%-$color-%'";
  3224. }
  3225. if ($lowe) {
  3226. $where .= " and features like '%-$lowe-%'";
  3227. }
  3228. //数据排序
  3229. $order_str = "time desc";
  3230. if (empty($page)) {
  3231. $start = 0;
  3232. $perpage = 1;
  3233. } else {
  3234. $start = ($page - 1) * $perpage;
  3235. }
  3236. //取得信息列表
  3237. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3238. foreach ($info_list as $key => $value) {
  3239. $warehouse = $this->warehouse->read($value['warehouse']);
  3240. $info_list[$key]['warehouse'] = $warehouse['title'];
  3241. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3242. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3243. $purchase = $this->purchase->read($value['purchase']);
  3244. $info_list[$key]['purchase'] = $purchase['title'];
  3245. if ($value['outk'] != 0) {
  3246. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3247. } else {
  3248. $info_list[$key]['outk'] = "";
  3249. }
  3250. if ($value['retreat'] != 0) {
  3251. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3252. } else {
  3253. $info_list[$key]['retreat'] = "";
  3254. }
  3255. if ($value['orderinfo'] == 0) {
  3256. $info_list[$key]['orderinfo'] = "";
  3257. }
  3258. if ($value['waybill'] == 0) {
  3259. $info_list[$key]['waybill'] = "";
  3260. }
  3261. }
  3262. $total = $this->whlabel->find_count($where);
  3263. $pagenum = ceil($total / $perpage);
  3264. $over = $total - ($start + $perpage);
  3265. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3266. echo json_encode($rows);
  3267. exit;
  3268. }
  3269. $this->_Template('whlabel_retreatlk', $this->data);
  3270. }
  3271. //更换标签及浏览
  3272. public function _change()
  3273. {
  3274. $post = $this->input->post(NULL, TRUE);
  3275. if (isset($post['page'])) {
  3276. $page = $this->input->post('page', true);
  3277. $perpage = $this->input->post('perpage', true);
  3278. $timetk = $this->input->post('timetk', true);
  3279. $timetj = $this->input->post('timetj', true);
  3280. $label = $this->input->post('label', true);
  3281. $oldlabel = $this->input->post('oldlabel', true);
  3282. $timetk = strtotime($timetk);
  3283. $timetj = strtotime($timetj);
  3284. $where = "state=10 ";
  3285. if ($timetk && $timetj) {
  3286. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3287. }
  3288. if ($label) {
  3289. $where .= " and label = '$label'";
  3290. }
  3291. if ($oldlabel) {
  3292. $where .= " and oldlabel = '$oldlabel'";
  3293. }
  3294. //数据排序
  3295. $order_str = "time asc";
  3296. if (empty($page)) {
  3297. $start = 0;
  3298. $perpage = 1;
  3299. } else {
  3300. $start = ($page - 1) * $perpage;
  3301. }
  3302. //取得信息列表
  3303. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3304. foreach ($info_list as $key => $value) {
  3305. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3306. }
  3307. $total = $this->whlabel->find_count($where);
  3308. $pagenum = ceil($total / $perpage);
  3309. $over = $total - ($start + $perpage);
  3310. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3311. echo json_encode($rows);
  3312. exit;
  3313. }
  3314. $this->_Template('whlabel_change', $this->data);
  3315. }
  3316. //产品标签
  3317. public function _cpbqdc()
  3318. {
  3319. if (isset($_GET['excel'])) {
  3320. $where = "1=1";
  3321. //数据排序
  3322. $order_str = "id desc";
  3323. if (empty($page)) {
  3324. $start = 0;
  3325. $perpage = 1;
  3326. } else {
  3327. $start = ($page - 1) * $perpage;
  3328. }
  3329. $warehouse = $this->input->get('warehouse', true);
  3330. $state = $this->input->get('state', true);
  3331. $timetk = $this->input->get('timetkk', true);
  3332. $timetj = $this->input->get('timetjj', true);
  3333. $timetk = strtotime($timetk);
  3334. $timetj = strtotime($timetj);
  3335. if ($warehouse) {
  3336. $where .= " and warehouse = '$warehouse'";
  3337. }
  3338. if ($state || $state == 0) {
  3339. $where .= " and state = '$state'";
  3340. }
  3341. if ($timetk && $timetj) {
  3342. $where .= " and time > '$timetk' and time < '$timetj'";
  3343. }
  3344. //取得信息列表
  3345. $info_list = $this->whlabel->find_all($where, '*');
  3346. $rows = array();
  3347. $list = array();
  3348. foreach ($info_list as $key => $value) {
  3349. $rows[$value['time']] = $value; //所有数据sku
  3350. }
  3351. foreach ($rows as $value) {
  3352. $warehouse = $this->warehouse->read($value['warehouse']);
  3353. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3354. $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);
  3355. }
  3356. $title = "产品标签统计表";
  3357. $titlename = "<table border=1>
  3358. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3359. <tr align='center'>
  3360. <td>仓库</td>
  3361. <td>SKU</td>
  3362. <td>产品</td>
  3363. <td>入库时间</td>
  3364. <td>操作时间</td>
  3365. <td>备注</td>
  3366. <td>数量</td>
  3367. </tr>
  3368. </table>";
  3369. $filename = $title . ".xls";
  3370. $tail = "";
  3371. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3372. }
  3373. }
  3374. //进销存导出
  3375. public function _exceljxc()
  3376. {
  3377. $classid = $this->classid->sku();
  3378. $pm = $classid;
  3379. $typeclass = array();
  3380. $tc = $this->typeclass->find_all();
  3381. foreach ($tc as $v) {
  3382. $typeclass[$v['id']] = $v;
  3383. }
  3384. $prc = array();
  3385. $purchase = $this->purchase->find_all();
  3386. foreach ($purchase as $k => $v) {
  3387. $prc[$v['id']] = $v['title'];
  3388. }
  3389. if (isset($_GET['excel'])) {
  3390. $where = "sku != 'Preset'";
  3391. //数据排序
  3392. $order_str = "id desc";
  3393. if (empty($page)) {
  3394. $start = 0;
  3395. $perpage = 1;
  3396. } else {
  3397. $start = ($page - 1) * $perpage;
  3398. }
  3399. $category = $this->input->get('category', true);
  3400. $warehouse = $this->input->get('warehouse', true);
  3401. $excelid = $this->input->get('sid', true);
  3402. if ($category) {
  3403. $where .= " and features like '%-$category-%'";
  3404. }
  3405. if ($warehouse) {
  3406. $where .= " and warehouse = '$warehouse'";
  3407. }
  3408. $xzid = '';
  3409. if ($excelid) {
  3410. $excelid = explode(',', trim($excelid, ','));
  3411. foreach ($excelid as $key => $value) {
  3412. $xzid .= " id = " . $value . " or";
  3413. }
  3414. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3415. }
  3416. //取得信息列表
  3417. /**
  3418. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3419. $rows = array();$list = array();
  3420. foreach ($info_list as $key=>$value)
  3421. {
  3422. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3423. }
  3424. **/
  3425. $wt = array();
  3426. $whlabel_type = $this->whlabel_type->find_all();
  3427. foreach ($whlabel_type as $v) {
  3428. $wt[$v['id']] = $v['title'];
  3429. }
  3430. $wh = array();
  3431. $w = $this->warehouse->find_all('1=1', 'id,title');
  3432. foreach ($w as $v) {
  3433. $wh[$v['id']] = $v['title'];
  3434. }
  3435. $list = array();
  3436. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3437. foreach ($rows as $key => $value) {
  3438. if (isset($wt[$value['type']])) {
  3439. $rows[$key]['type'] = $wt[$value['type']];
  3440. } else {
  3441. $rows[$key]['type'] = '未设置';
  3442. }
  3443. $bm = '03';
  3444. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3445. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3446. $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');
  3447. $details = array();
  3448. $cpid = array();
  3449. $cpbz = array();
  3450. $c = 0;
  3451. $g = 0;
  3452. $x = 0;
  3453. $t = 0;
  3454. $s = 0;
  3455. $q = 0;
  3456. foreach ($sd as $k => $v) {
  3457. if ($v['state'] == 0) {
  3458. $c++;
  3459. if ($v['cpid'] != 0) {
  3460. $cpid[$v['cpid']] = $v['cpid'];
  3461. }
  3462. if ($v['cpbz'] != '') {
  3463. $cpbz[$v['cpbz']] = $v['cpbz'];
  3464. }
  3465. }
  3466. if ($v['state'] != 9) {
  3467. $g++;
  3468. }
  3469. if ($v['state'] == 1) {
  3470. $x++;
  3471. }
  3472. if ($v['state'] == 2) {
  3473. $t++;
  3474. }
  3475. if ($v['state'] == 8) {
  3476. $s++;
  3477. }
  3478. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3479. $q++;
  3480. }
  3481. $details[$v['details']] = $v['details'];
  3482. }
  3483. $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'] . '"');
  3484. $rows[$key]['details'] = implode("、", $details);
  3485. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3486. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3487. $number = $value['number'];
  3488. $ftime = time() - 15 * 24 * 3600;
  3489. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3490. $rows[$key]['number'] = $g;
  3491. $rows[$key]['c'] = $c;
  3492. $rows[$key]['x'] = $x;
  3493. $rows[$key]['t'] = $t;
  3494. $rows[$key]['s'] = $s;
  3495. $rows[$key]['q'] = $q;
  3496. $rows[$key]['z'] = $z;
  3497. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3498. $features = explode('-', trim($features, '-'));
  3499. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3500. // $pm = $classid;
  3501. // $jm = $classid;
  3502. // foreach($features as $k=>$v)
  3503. // {
  3504. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3505. // {
  3506. // if($typeclass[$v]['bm'] != '')
  3507. // {
  3508. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3509. // }
  3510. // }
  3511. // if($v != 0)
  3512. // {
  3513. // if(!isset($typeclass[$v]))
  3514. // {
  3515. // continue;
  3516. // }
  3517. // if(isset($pm[$typeclass[$v]['classid']]))
  3518. // {
  3519. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3520. // {
  3521. // $tz = explode('|',$typeclass[$v]['zh']);
  3522. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3523. // }
  3524. // else
  3525. // {
  3526. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3527. // }
  3528. // }
  3529. // if(isset($jm[$typeclass[$v]['classid']]))
  3530. // {
  3531. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3532. // }
  3533. // }
  3534. // }
  3535. // $jm = array_filter($jm);
  3536. // $rows[$key]['bs'] = implode("-",$jm);
  3537. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3538. // $zh = implode(" ",$pm);
  3539. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3540. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3541. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3542. // $rows[$key]['features'] = $zh;
  3543. }
  3544. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3545. $final_list = [];
  3546. foreach ($list as $k => $v) {
  3547. if (empty($v['sku'])) {
  3548. continue;
  3549. }
  3550. $final_list[] = [
  3551. "warehouse" => $v["warehouse"],
  3552. "purchase" => $v["purchase"],
  3553. "details" => $v["details"],
  3554. "cpid" => $v["cpid"],
  3555. "dbcontent" => $v["dbcontent"],
  3556. "sku" => $v["sku"],
  3557. "cs" => $v["bm"],
  3558. "bs" => $v["jm"],
  3559. "title" => $v["title"],
  3560. "features" => $v["pm"],
  3561. "cpbz" => $v["cpbz"],
  3562. "sm" => $v["sm"],
  3563. "type" => $v["type"],
  3564. "number" => $v["number"],
  3565. "c" => $v["c"],
  3566. "x" => $v["x"],
  3567. "t" => $v["t"],
  3568. "s" => $v["s"],
  3569. "q" => $v["q"],
  3570. "z" => $v["z"],
  3571. "weight" => $v['weight'],
  3572. ];
  3573. }
  3574. $title = "总进销存统计表";
  3575. $titlename = "<table border=1>
  3576. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3577. <tr align='center'>
  3578. <td>仓库</td>
  3579. <td>供应商</td>
  3580. <td>位置</td>
  3581. <td>库存编码</td>
  3582. <td>类目</td>
  3583. <td>SKU</td>
  3584. <td>用友编码</td>
  3585. <td>用友料号</td>
  3586. <td>商品名称</td>
  3587. <td>商品中文</td>
  3588. <td>产品备注</td>
  3589. <td>库位负责人</td>
  3590. <td>类型</td>
  3591. <td>入库总量</td>
  3592. <td>库存数量</td>
  3593. <td>销售数量</td>
  3594. <td>退货数量</td>
  3595. <td>删除数量</td>
  3596. <td>其它操作</td>
  3597. <td>占单数量</td>
  3598. <td>重量(g)</td>
  3599. </tr>
  3600. </table>";
  3601. $filename = $title . ".xls";
  3602. $tail = "";
  3603. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3604. }
  3605. }
  3606. //入库导出
  3607. public function _excelr()
  3608. {
  3609. if (isset($_GET['excel'])) {
  3610. $category = $this->input->get('category', true);
  3611. $size = $this->input->get('size', true);
  3612. $grade = $this->input->get('grade', true);
  3613. $color = $this->input->get('color', true);
  3614. $lowe = $this->input->get('lowe', true);
  3615. $sku = $this->input->get('sku', true);
  3616. $warehouse = $this->input->get('warehouse', true);
  3617. $purchase = $this->input->get('purchase', true);
  3618. $ktime = $this->input->get('ktime', true);
  3619. $jtime = $this->input->get('jtime', true);
  3620. $ktime = strtotime($ktime);
  3621. $jtime = strtotime($jtime);
  3622. $where = "1=1";
  3623. $gj = "";
  3624. $ck = "";
  3625. if ($category) {
  3626. $where .= " and features like '%-$category-%'";
  3627. }
  3628. if ($size) {
  3629. $where .= " and features like '%-$size-%'";
  3630. }
  3631. if ($grade) {
  3632. $where .= " and features like '%-$grade-%'";
  3633. }
  3634. if ($color) {
  3635. $where .= " and features like '%-$color-%'";
  3636. }
  3637. if ($lowe) {
  3638. $where .= " and features like '%-$lowe-%'";
  3639. }
  3640. if ($warehouse) {
  3641. $where .= " and warehouse = '$warehouse'";
  3642. }
  3643. if ($purchase) {
  3644. $where .= " and purchase = '$purchase'";
  3645. }
  3646. if ($sku) {
  3647. $where .= " and sku = '$sku'";
  3648. }
  3649. if ($ktime && $jtime) {
  3650. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3651. }
  3652. //数据排序
  3653. $order_str = "id desc";
  3654. if (empty($page)) {
  3655. $start = 0;
  3656. $perpage = 1;
  3657. } else {
  3658. $start = ($page - 1) * $perpage;
  3659. }
  3660. $list = array();
  3661. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3662. foreach ($rows as $value) {
  3663. $ck = $this->warehouse->read($value['warehouse']);
  3664. $warehouse = $ck['title'];
  3665. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3666. $retreatwarehouse = $tkck['title'];
  3667. $gy = $this->purchase->read($value['purchase']);
  3668. $purchase = $gy['title'];
  3669. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3670. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3671. }
  3672. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3673. $titlename = "<table border=1>
  3674. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3675. <tr align='center'>
  3676. <td>仓库</td>
  3677. <td>SKU</td>
  3678. <td>产品</td>
  3679. <td>时间</td>
  3680. <td>数量</td>
  3681. </tr>
  3682. </table>";
  3683. $filename = $title . ".xls";
  3684. $tail = "";
  3685. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  3686. }
  3687. }
  3688. //出库、退库导出
  3689. public function _excelct()
  3690. {
  3691. $classid = $this->classid->sku();
  3692. $pm = $classid;
  3693. $typeclass = array();
  3694. $tc = $this->typeclass->find_all();
  3695. foreach ($tc as $v) {
  3696. $typeclass[$v['id']] = $v;
  3697. }
  3698. $prc = array();
  3699. $purchase = $this->purchase->find_all();
  3700. foreach ($purchase as $k => $v) {
  3701. $prc[$v['id']] = $v['title'];
  3702. }
  3703. if (isset($_GET['excel'])) {
  3704. $wh = array();
  3705. $w = $this->warehouse->find_all('1=1', 'id,title');
  3706. foreach ($w as $v) {
  3707. $wh[$v['id']] = $v['title'];
  3708. }
  3709. $type = $this->input->get('excel', true);
  3710. $category = $this->input->get('category', true);
  3711. $size = $this->input->get('size', true);
  3712. $grade = $this->input->get('grade', true);
  3713. $color = $this->input->get('color', true);
  3714. $lowe = $this->input->get('lowe', true);
  3715. $sku = $this->input->get('sku', true);
  3716. $title = $this->input->get('title', true);
  3717. $warehouse = $this->input->get('warehouse', true);
  3718. $purchase = $this->input->get('purchase', true);
  3719. $lacetype = $this->input->get('lacetype', true);
  3720. $haircap = $this->input->get('haircap', true);
  3721. $lacecolor = $this->input->get('lacecolor', true);
  3722. $density = $this->input->get('density', true);
  3723. $details = $this->input->get('details', true);
  3724. $state = $this->input->get('state', true);
  3725. $shop = $this->input->get('shop', true);
  3726. $hairnumber = $this->input->get('hairnumber', true);
  3727. $type_leixi = $this->input->get('type', true);
  3728. $cpbz = $this->input->get('cpbz', true);
  3729. $sm = $this->input->get('sm', true);
  3730. $sid = $this->input->get('sid', true);
  3731. $ktime = $this->input->get('ktime', true);
  3732. $jtime = $this->input->get('jtime', true);
  3733. $ktime = strtotime($ktime);
  3734. $jtime = strtotime($jtime);
  3735. //$where = " 1=1 ";
  3736. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3737. $where = " sku != '' ";
  3738. $gj = "";
  3739. $ck = "";
  3740. if ($category) {
  3741. $where .= " and features like '%-$category-%'";
  3742. }
  3743. if ($size) {
  3744. $where .= " and features like '%-$size-%'";
  3745. }
  3746. if ($grade) {
  3747. $where .= " and features like '%-$grade-%'";
  3748. }
  3749. if ($color) {
  3750. $where .= " and features like '%-$color-%'";
  3751. }
  3752. if ($lowe) {
  3753. $where .= " and features like '%-$lowe-%'";
  3754. }
  3755. if ($warehouse) {
  3756. $where .= " and warehouse = '$warehouse'";
  3757. }
  3758. if ($purchase) {
  3759. $where .= " and purchase = '$purchase'";
  3760. }
  3761. if ($state) {
  3762. $where .= " and state = '$state'";
  3763. }
  3764. if ($lacetype) {
  3765. $where .= " and features like '%-$lacetype-%'";
  3766. }
  3767. if ($lacecolor) {
  3768. $where .= " and features like '%-$lacecolor-%'";
  3769. }
  3770. if ($density) {
  3771. $where .= " and features like '%-$density-%'";
  3772. }
  3773. if ($haircap) {
  3774. $where .= " and features like '%-$haircap-%'";
  3775. }
  3776. if ($details) {
  3777. $where .= " and details = '$details'";
  3778. }
  3779. if ($shop) {
  3780. $where .= " and shop like '%$shop%'";
  3781. }
  3782. if ($title) {
  3783. $title = trim($title, ' ');
  3784. $title = trim($title, ' ');
  3785. $where .= " and title like '%$title%'";
  3786. }
  3787. if (!empty($hairnumber)) {
  3788. $where .= " and features like '%-128-%' ";
  3789. if ($hairnumber < 0) {
  3790. $class_list = $this->typeclass->find_all('classid = 43');
  3791. foreach ($class_list as $v) {
  3792. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3793. }
  3794. } else {
  3795. $where .= " and features like '%-$hairnumber-%'";
  3796. }
  3797. }
  3798. if ($type_leixi) {
  3799. $where .= " and type = '$type_leixi'";
  3800. }
  3801. if ($cpbz) {
  3802. $where .= " and cpbz like '%$cpbz%' ";
  3803. }
  3804. if ($sm) {
  3805. $where .= " and sm like '%$sm%' ";
  3806. }
  3807. if ($sku) {
  3808. $sku = trim($sku, ' ');
  3809. $sku = trim($sku, ' ');
  3810. $where .= " and sku like '%$sku%'";
  3811. }
  3812. if ($ktime && $jtime) {
  3813. if ($type == 1) {
  3814. $tl = '出库';
  3815. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3816. } else if ($type == 2) {
  3817. $tl = '退库';
  3818. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3819. } else if ($type == 3) {
  3820. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3821. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3822. } else if ($type == 4) {
  3823. $tl = '出库+零售';
  3824. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3825. } else if ($type == 5) {
  3826. $tl = '零售';
  3827. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3828. }
  3829. }
  3830. $sidwhere = '';
  3831. if ($sid) {
  3832. $sd = "";
  3833. $s = explode(',', trim($sid, ','));
  3834. foreach ($s as $value) {
  3835. $sd .= " id = " . $value . " or";
  3836. }
  3837. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3838. }
  3839. //数据排序
  3840. $order_str = "time desc";
  3841. if (empty($page)) {
  3842. $start = 0;
  3843. $perpage = 1;
  3844. } else {
  3845. $start = ($page - 1) * $perpage;
  3846. }
  3847. //取得信息列表
  3848. if ($type != 3 && $type != 5) {
  3849. if ($type == 1 || $type == 4) {
  3850. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3851. foreach ($info_list as $key => $value) {
  3852. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3853. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3854. $warehouse = $this->warehouse->read($value['warehouse']);
  3855. $info_list[$key]['warehouse'] = $warehouse['title'];
  3856. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3857. $features = explode('-', trim($features, '-'));
  3858. $pm = $classid;
  3859. foreach ($features as $k => $v) {
  3860. if ($v != 0) {
  3861. if (!isset($typeclass[$v])) {
  3862. continue;
  3863. }
  3864. if (isset($pm[$typeclass[$v]['classid']])) {
  3865. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3866. $tz = explode('|', $typeclass[$v]['zh']);
  3867. $pm[$typeclass[$v]['classid']] = $tz[0];
  3868. } else {
  3869. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3870. }
  3871. }
  3872. }
  3873. }
  3874. $zh = implode(" ", $pm);
  3875. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3876. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3877. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3878. $info_list[$key]['features'] = $zh;
  3879. }
  3880. $final_list = [];
  3881. foreach($info_list as $k=>$v){
  3882. $number = "";
  3883. if(!empty($v['orderinfo'])){
  3884. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3885. if(!empty($tmp_info['number'])){
  3886. $number = $tmp_info['number'];
  3887. }
  3888. }
  3889. $final_list[] = [
  3890. 'warehouse'=>$v['warehouse'],
  3891. 'purchase'=>$v['purchase'],
  3892. 'sku'=>$v['sku'],
  3893. 'title'=>$v['title'],
  3894. 'features'=>$v['features'],
  3895. 'label'=>$v['label'],
  3896. 'orderinfo'=>$v['orderinfo'],
  3897. 'number'=>$number,
  3898. 'waybill'=>$v['waybill'],
  3899. 'outk'=>$v['outk'],
  3900. ];
  3901. }
  3902. } else {
  3903. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3904. foreach ($info_list as $key => $value) {
  3905. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3906. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3907. $warehouse = $this->warehouse->read($value['warehouse']);
  3908. $info_list[$key]['warehouse'] = $warehouse['title'];
  3909. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3910. $features = explode('-', trim($features, '-'));
  3911. $pm = $classid;
  3912. foreach ($features as $k => $v) {
  3913. if ($v != 0) {
  3914. if (!isset($typeclass[$v])) {
  3915. continue;
  3916. }
  3917. if (isset($pm[$typeclass[$v]['classid']])) {
  3918. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3919. $tz = explode('|', $typeclass[$v]['zh']);
  3920. $pm[$typeclass[$v]['classid']] = $tz[0];
  3921. } else {
  3922. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3923. }
  3924. }
  3925. }
  3926. }
  3927. $zh = implode(" ", $pm);
  3928. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3929. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3930. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3931. $info_list[$key]['features'] = $zh;
  3932. }
  3933. $final_list = [];
  3934. foreach($info_list as $k=>$v){
  3935. $number = "";
  3936. if(!empty($v['orderinfo'])){
  3937. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3938. if(!empty($tmp_info['number'])){
  3939. $number = $tmp_info['number'];
  3940. }
  3941. }
  3942. $final_list[] = [
  3943. 'warehouse'=>$v['warehouse'],
  3944. 'purchase'=>$v['purchase'],
  3945. 'sku'=>$v['sku'],
  3946. 'title'=>$v['title'],
  3947. 'features'=>$v['features'],
  3948. 'label'=>$v['label'],
  3949. 'orderinfo'=>$v['orderinfo'],
  3950. 'number'=>$number,
  3951. 'waybill'=>$v['waybill'],
  3952. 'retreat'=>$v['retreat'],
  3953. ];
  3954. }
  3955. }
  3956. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3957. $titlename = "<table border=1>
  3958. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3959. <tr align='center'>
  3960. <td>仓库</td>
  3961. <td>供应商</td>
  3962. <td>SKU</td>
  3963. <td>商品名称</td>
  3964. <td>商品中文</td>
  3965. <td>标签</td>
  3966. <td>订单号</td>
  3967. <td>订单编码</td>
  3968. <td>运单号</td>
  3969. <td>" . $tl . "时间(中国时间)</td>
  3970. </tr>
  3971. </table>";
  3972. $filename = $title . ".xls";
  3973. $tail = "";
  3974. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3975. } else if ($type == 5) {
  3976. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3977. foreach ($info_list as $key => $value) {
  3978. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3979. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3980. $warehouse = $this->warehouse->read($value['warehouse']);
  3981. $info_list[$key]['warehouse'] = $warehouse['title'];
  3982. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3983. $features = explode('-', trim($features, '-'));
  3984. $pm = $classid;
  3985. foreach ($features as $k => $v) {
  3986. if ($v != 0) {
  3987. if (!isset($typeclass[$v])) {
  3988. continue;
  3989. }
  3990. if (isset($pm[$typeclass[$v]['classid']])) {
  3991. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3992. $tz = explode('|', $typeclass[$v]['zh']);
  3993. $pm[$typeclass[$v]['classid']] = $tz[0];
  3994. } else {
  3995. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3996. }
  3997. }
  3998. }
  3999. }
  4000. $zh = implode(" ", $pm);
  4001. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4002. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4003. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4004. $info_list[$key]['features'] = $zh;
  4005. }
  4006. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4007. $titlename = "<table border=1>
  4008. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4009. <tr align='center'>
  4010. <td>仓库</td>
  4011. <td>供应商</td>
  4012. <td>SKU</td>
  4013. <td>商品名称</td>
  4014. <td>商品中文</td>
  4015. <td>标签</td>
  4016. <td>" . $tl . "时间(中国时间)</td>
  4017. </tr>
  4018. </table>";
  4019. $filename = $title . ".xls";
  4020. $tail = "";
  4021. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4022. } else {
  4023. /**
  4024. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4025. $rows = array();$list = array();
  4026. foreach ($info_list as $key=>$value)
  4027. {
  4028. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4029. }
  4030. **/
  4031. $wh = array();
  4032. $w = $this->warehouse->find_all('1=1', 'id,title');
  4033. foreach ($w as $v) {
  4034. $wh[$v['id']] = $v['title'];
  4035. }
  4036. $wt = array();
  4037. $whlabel_type = $this->whlabel_type->find_all();
  4038. foreach ($whlabel_type as $v) {
  4039. $wt[$v['id']] = $v['title'];
  4040. }
  4041. $classid = $this->classid->sku();
  4042. $list = array();
  4043. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4044. foreach ($rows as $key => $value) {
  4045. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4046. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4047. $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');
  4048. $details = array();
  4049. $cpid = array();
  4050. $cpbz = array();
  4051. $c = 0;
  4052. $g = 0;
  4053. $x = 0;
  4054. $t = 0;
  4055. $s = 0;
  4056. $q = 0;
  4057. foreach ($sd as $k => $v) {
  4058. if ($v['state'] == 0) {
  4059. $c++;
  4060. }
  4061. if ($v['state'] != 9) {
  4062. $g++;
  4063. }
  4064. if ($v['outk'] > 1) {
  4065. $x++;
  4066. }
  4067. if ($v['retreat'] > 0) {
  4068. $t++;
  4069. }
  4070. if ($v['state'] == 8) {
  4071. $s++;
  4072. }
  4073. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4074. $q++;
  4075. }
  4076. $details[$v['details']] = $v['details'];
  4077. if ($v['cpid'] != 0) {
  4078. $cpid[$v['cpid']] = $v['cpid'];
  4079. }
  4080. if ($v['cpbz'] != '') {
  4081. $cpbz[$v['cpbz']] = $v['cpbz'];
  4082. }
  4083. }
  4084. if (isset($wt[$value['type']])) {
  4085. $rows[$key]['type'] = $wt[$value['type']];
  4086. } else {
  4087. $rows[$key]['type'] = '未设置';
  4088. }
  4089. $rows[$key]['details'] = implode("、", $details);
  4090. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4091. $ftime = time() - 15 * 24 * 3600;
  4092. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4093. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4094. $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);
  4095. $rows[$key]['c'] = $c;
  4096. $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);
  4097. $rows[$key]['t'] = $t;
  4098. $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'] . '"');
  4099. $rows[$key]['z'] = $z;
  4100. // $jm = $classid;
  4101. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4102. $features = explode('-', trim($features, '-'));
  4103. // $pm = $classid;
  4104. // foreach ($features as $k => $v) {
  4105. // if ($v != 0) {
  4106. // if (!isset($typeclass[$v])) {
  4107. // continue;
  4108. // }
  4109. // if (isset($pm[$typeclass[$v]['classid']])) {
  4110. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4111. // $tz = explode('|', $typeclass[$v]['zh']);
  4112. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4113. // } else {
  4114. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4115. // }
  4116. // if (isset($jm[$typeclass[$v]['classid']])) {
  4117. // if ($typeclass[$v]['jm']) {
  4118. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4119. // }
  4120. // }
  4121. // }
  4122. // }
  4123. // }
  4124. // $zh = implode(" ", $pm);
  4125. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4126. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4127. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4128. // $rows[$key]['features'] = $zh;
  4129. // $jm = array_filter($jm); //去除空值
  4130. // $jm = implode("-", $jm);
  4131. // $rows[$key]['jm'] = $jm;
  4132. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4133. }
  4134. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4135. // echo "<pre>";
  4136. // print_r($tmp_list);
  4137. // die;
  4138. $final_list =[];
  4139. foreach($tmp_list as $k=>$v){
  4140. $final_list[] = [
  4141. "warehouse"=>$v['warehouse'],
  4142. "purchase"=>$v['purchase'],
  4143. "details"=>trim($v['details'],'、'),
  4144. "cpid"=>$v['cpid'],
  4145. "sku"=>$v['sku'],
  4146. "title"=>$v['title'],
  4147. "features"=>$v['pm'],
  4148. "cpbz"=>$v['cpbz'],
  4149. "sm"=>$v['sm'],
  4150. "type"=>$v['type'],
  4151. "g"=>$v["g"],
  4152. "c"=>$v["c"],
  4153. "x"=>$v["x"],
  4154. "t"=>$v["t"],
  4155. "z"=>$v["z"],
  4156. "jm"=>$v["jm"],
  4157. "weight"=>$v["weight"],
  4158. "asd"=>$v["asd"],
  4159. ];
  4160. }
  4161. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4162. $titlename = "<table border=1>
  4163. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4164. <tr align='center'>
  4165. <td>仓库</td>
  4166. <td>供应商</td>
  4167. <td>位置</td>
  4168. <td>库存编码</td>
  4169. <td>SKU</td>
  4170. <td>商品名称</td>
  4171. <td>商品中文</td>
  4172. <td>产品备注</td>
  4173. <td>说明</td>
  4174. <td>类型</td>
  4175. <td>入库总量</td>
  4176. <td>库存数量</td>
  4177. <td>销售数量</td>
  4178. <td>退货数量</td>
  4179. <td>占单数量</td>
  4180. <td>料号</td>
  4181. <td>重量</td>
  4182. <td>类目</td>
  4183. </tr>
  4184. </table>";
  4185. $filename = $title . ".xls";
  4186. $tail = "";
  4187. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4188. }
  4189. }
  4190. }
  4191. //出库+入库数据整合
  4192. public function _excelcr()
  4193. {
  4194. if (isset($_GET['excel'])) {
  4195. $type = $this->input->get('excel', true);
  4196. $category = $this->input->get('category', true);
  4197. $size = $this->input->get('size', true);
  4198. $grade = $this->input->get('grade', true);
  4199. $color = $this->input->get('color', true);
  4200. $lowe = $this->input->get('lowe', true);
  4201. $sku = $this->input->get('sku', true);
  4202. $warehouse = $this->input->get('warehouse', true);
  4203. $purchase = $this->input->get('purchase', true);
  4204. $state = $this->input->get('state', true);
  4205. $sid = $this->input->get('sid', true);
  4206. $ktime = $this->input->get('ktime', true);
  4207. $jtime = $this->input->get('jtime', true);
  4208. $ktime = strtotime($ktime);
  4209. $jtime = strtotime($jtime);
  4210. $where = "1=1";
  4211. $gj = "";
  4212. $ck = "";
  4213. if ($category) {
  4214. $where .= " and features like '%-$category-%'";
  4215. }
  4216. if ($size) {
  4217. $where .= " and features like '%-$size-%'";
  4218. }
  4219. if ($grade) {
  4220. $where .= " and features like '%-$grade-%'";
  4221. }
  4222. if ($color) {
  4223. $where .= " and features like '%-$color-%'";
  4224. }
  4225. if ($lowe) {
  4226. $where .= " and features like '%-$lowe-%'";
  4227. }
  4228. if ($warehouse) {
  4229. $where .= " and warehouse = '$warehouse'";
  4230. }
  4231. if ($purchase) {
  4232. $where .= " and purchase = '$purchase'";
  4233. }
  4234. if ($state) {
  4235. $where .= " and state = '$state'";
  4236. }
  4237. if ($sku) {
  4238. $where .= " and sku like '%$sku%'";
  4239. }
  4240. if ($ktime && $jtime) {
  4241. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4242. }
  4243. $sidwhere = '';
  4244. if ($sid) {
  4245. $sd = "";
  4246. $s = explode(',', trim($sid, ','));
  4247. foreach ($s as $value) {
  4248. $sd .= " id = " . $value . " or";
  4249. }
  4250. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4251. }
  4252. //取得信息列表
  4253. $timeread = $ktime;
  4254. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4255. $timelist = array();
  4256. for ($i = 0; $i < $timenum; $i++) {
  4257. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4258. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4259. }
  4260. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4261. //echo "<pre>";
  4262. //print_r($info_list);
  4263. //exit();
  4264. $rows = array();
  4265. $list = array();
  4266. foreach ($info_list as $key => $value) {
  4267. $thistime = $timelist;
  4268. if (isset($rows[strtolower($value['sku'])])) {
  4269. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4270. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4271. }
  4272. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4273. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4274. }
  4275. } else {
  4276. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4277. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4278. }
  4279. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4280. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4281. }
  4282. $rows[strtolower($value['sku'])] = $thistime;
  4283. }
  4284. }
  4285. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4286. <head>
  4287. <!--[if gte mso 9]><xml>
  4288. <x:ExcelWorkbook>
  4289. <x:ExcelWorksheets>
  4290. <x:ExcelWorksheet>
  4291. <x:Name>EXCEL</x:Name>
  4292. <x:WorksheetOptions>
  4293. <x:Print>
  4294. <x:ValidPrinterInfo />
  4295. </x:Print>
  4296. </x:WorksheetOptions>
  4297. </x:ExcelWorksheet>
  4298. </x:ExcelWorksheets>
  4299. </x:ExcelWorkbook>
  4300. </xml>
  4301. <![endif]-->
  4302. </head><body>";
  4303. $str .= "<table border=1><tr><td>SKU</td>";
  4304. foreach ($timelist as $k => $v) {
  4305. $str .= "<td>" . $k . "出库</td>";
  4306. $str .= "<td>" . $k . "入库</td>";
  4307. }
  4308. $str .= "</tr></table>";
  4309. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4310. foreach ($rows as $key => $val) {
  4311. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4312. foreach ($val as $k => $v) {
  4313. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4314. if ($val[$k]['r'] > 0) {
  4315. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4316. } else {
  4317. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4318. }
  4319. }
  4320. $str .= "</tr>";
  4321. }
  4322. $str .= "</table>";
  4323. $str .= "</body></html>";
  4324. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4325. header("Content-type: application/octet-stream");
  4326. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4327. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4328. header("Pragma: no-cache");
  4329. header("Expires: 0");
  4330. exit($str);
  4331. }
  4332. }
  4333. //数量调整模板导出
  4334. public function _presetout()
  4335. {
  4336. if (isset($_GET['excel'])) {
  4337. $where = "sku != 'Preset' and purchase != 0";
  4338. //数据排序
  4339. $order_str = "id desc";
  4340. if (empty($page)) {
  4341. $start = 0;
  4342. $perpage = 1;
  4343. } else {
  4344. $start = ($page - 1) * $perpage;
  4345. }
  4346. //取得信息列表
  4347. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4348. $rows = array();
  4349. $list = array();
  4350. foreach ($info_list as $value) {
  4351. $warehouse = $this->warehouse->read($value['warehouse']);
  4352. $number = $value['number'];
  4353. $ftime = time() - 15 * 24 * 3600;
  4354. $purchase = $this->purchase->read($value['purchase']);
  4355. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4356. }
  4357. $title = "库存模板";
  4358. $titlename = "<table border=1>
  4359. <tr align='center'>
  4360. <td>仓库</td>
  4361. <td>供应商编码</td>
  4362. <td>SKU</td>
  4363. <td>增减数量(正数或负数)</td>
  4364. <td>增减备注</td>
  4365. <td>扣减方式:0减少库存1删除库存</td>
  4366. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4367. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4368. </tr>
  4369. </table>";
  4370. $filename = $title . ".xls";
  4371. $tail = "";
  4372. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4373. }
  4374. }
  4375. //数量调整模板导入
  4376. public function _presetedit()
  4377. {
  4378. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4379. $config['upload_path'] = '.' . $dir;
  4380. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4381. $config['allowed_types'] = 'xls|xlsx|csv';
  4382. $config['max_size'] = 10240;
  4383. $this->load->library('upload', $config);
  4384. $this->upload->initialize($config);
  4385. if ($this->upload->do_upload('userfile')) {
  4386. $full_path = $dir . $this->upload->data('file_name');
  4387. $fileName = '.' . $full_path;
  4388. if (!file_exists($fileName)) {
  4389. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4390. exit;
  4391. } else {
  4392. require_once "./data/excel/PHPExcel/IOFactory.php";
  4393. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4394. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4395. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4396. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4397. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4398. ++$column; //如果列数大于26行
  4399. $list = array();
  4400. for ($i = 2; $i <= $row; $i++) // 行数循环
  4401. {
  4402. $data = array();
  4403. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4404. {
  4405. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4406. }
  4407. $list[] = $data;
  4408. }
  4409. }
  4410. $i = 0;
  4411. $j = 0;
  4412. $ed = array();
  4413. foreach ($list as $key => $value) {
  4414. $time = time();
  4415. if ($value['0'] == "") {
  4416. continue;
  4417. }
  4418. $warehouse = $this->warehouse->get_title($value['0']);
  4419. $purchase = $this->purchase->get_bm($value['1']);
  4420. $sku = $value['2'];
  4421. $num = $value['3']; //调整数量
  4422. $text = $value['4']; //扣减说明
  4423. $type = $value['5']; //调整方式0扣减1删除
  4424. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4425. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4426. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4427. if (!$purchase) //如果没有这个SKU
  4428. {
  4429. $ed[] = array($purchase . '-不存在此供应商编码');
  4430. $j++;
  4431. continue;
  4432. }
  4433. if (!$d) //如果没有这个SKU
  4434. {
  4435. $ed[] = array($sku . '-库存中不存在此SKU');
  4436. $j++;
  4437. continue;
  4438. }
  4439. if (!isset($warehouse['id'])) {
  4440. $ed[] = array($sku . '-仓库名错误!');
  4441. $j++;
  4442. continue;
  4443. }
  4444. if ($type != '0' && $type != '1') {
  4445. $ed[] = array($sku . '-扣减方式填写错误!');
  4446. $j++;
  4447. continue;
  4448. }
  4449. if ($num < 0) //扣减库存
  4450. {
  4451. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4452. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4453. $j++;
  4454. continue;
  4455. }
  4456. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4457. if (count($data) < abs($num)) {
  4458. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4459. $j++;
  4460. continue;
  4461. }
  4462. if ($type == 0) //如果扣减方式为 扣减库存
  4463. {
  4464. for ($i = 0; $i < abs($num); $i++) {
  4465. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4466. }
  4467. } else if ($type == 1) {
  4468. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4469. if (count($zt) > 0) {
  4470. $ed[] = array($sku . '-有在途库存无法删除!');
  4471. $j++;
  4472. continue;
  4473. }
  4474. for ($i = 0; $i < abs($num); $i++) {
  4475. $this->whlabel->remove($data[$i]['id']);
  4476. }
  4477. }
  4478. } else if ($num > 0) //增加库存
  4479. {
  4480. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4481. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4482. $j++;
  4483. continue;
  4484. }
  4485. $post['sku'] = $d['sku'];
  4486. $post['shop'] = $d['shop'];
  4487. $post['warehouse'] = $warehouse['id'];
  4488. $post['purchase'] = $purchase['id'];
  4489. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4490. $post['state'] = 0;
  4491. $post['title'] = $d['title'];
  4492. $post['number'] = $d['number'];
  4493. $post['features'] = $d['features'];
  4494. $post['enter'] = $time;
  4495. $post['time'] = $time; //操作时间
  4496. $post['rktype'] = $rktype;
  4497. for ($i = 0; $i < $num; $i++) {
  4498. $post['label'] = time() . rand(100, 999) . $i;
  4499. $this->whlabel->insert($post);
  4500. }
  4501. }
  4502. sleep(1); //防止入库时间一样,需要延迟1秒
  4503. }
  4504. if ($j > 0) {
  4505. $tt = date('Ymd', time());
  4506. $title = '库存导入错误信息-' . $tt;
  4507. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4508. $tail = "\n";
  4509. $filename = $title . ".xls";
  4510. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4511. $dir = '/data/excel/' . $time . '/';
  4512. $file_name = 'error_' . $time . rand(1000, 9999);
  4513. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4514. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4515. fwrite($myfile, $ecl);
  4516. fclose($myfile);
  4517. $error = $dir . $file_name . '.xls';
  4518. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4519. exit;
  4520. } else {
  4521. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4522. exit;
  4523. }
  4524. }
  4525. }
  4526. public function _presetedittwo(){
  4527. $data = $this->input->post(NULL, TRUE);
  4528. if(empty($list)){
  4529. $raw_data = $this->input->raw_input_stream;
  4530. // 解码 JSON
  4531. $data = json_decode($raw_data, true);
  4532. }
  4533. if(empty($data)){
  4534. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4535. }
  4536. $list = [];
  4537. if(isset($data['list'])){
  4538. $list = $data['list'];
  4539. }
  4540. $i = 0;
  4541. $j = 0;
  4542. $ed = array();
  4543. foreach ($list as $key => $value) {
  4544. $time = time();
  4545. if ($value['0'] == "") {
  4546. continue;
  4547. }
  4548. $warehouse = $this->warehouse->get_title($value['0']);
  4549. $purchase = $this->purchase->get_bm($value['1']);
  4550. $sku = $value['2'];
  4551. $num = $value['3']; //调整数量
  4552. $text = $value['4']; //扣减说明
  4553. $type = $value['5']; //调整方式0扣减1删除
  4554. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4555. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4556. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4557. if (!$purchase) //如果没有这个SKU
  4558. {
  4559. $ed[] = array($value['1'] . '-不存在此供应商编码');
  4560. $j++;
  4561. continue;
  4562. }
  4563. if (!$d) //如果没有这个SKU
  4564. {
  4565. $ed[] = array($sku . '-库存中不存在此SKU');
  4566. $j++;
  4567. continue;
  4568. }
  4569. if (!isset($warehouse['id'])) {
  4570. $ed[] = array($sku . '-仓库名错误!');
  4571. $j++;
  4572. continue;
  4573. }
  4574. if ($type != '0' && $type != '1') {
  4575. $ed[] = array($sku . '-扣减方式填写错误!');
  4576. $j++;
  4577. continue;
  4578. }
  4579. if ($num < 0) //扣减库存
  4580. {
  4581. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4582. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4583. $j++;
  4584. continue;
  4585. }
  4586. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4587. if (count($data) < abs($num)) {
  4588. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4589. $j++;
  4590. continue;
  4591. }
  4592. if ($type == 0) //如果扣减方式为 扣减库存
  4593. {
  4594. for ($i = 0; $i < abs($num); $i++) {
  4595. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4596. }
  4597. } else if ($type == 1) {
  4598. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4599. if (count($zt) > 0) {
  4600. $ed[] = array($sku . '-有在途库存无法删除!');
  4601. $j++;
  4602. continue;
  4603. }
  4604. for ($i = 0; $i < abs($num); $i++) {
  4605. $this->whlabel->remove($data[$i]['id']);
  4606. }
  4607. }
  4608. } else if ($num > 0) //增加库存
  4609. {
  4610. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4611. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4612. $j++;
  4613. continue;
  4614. }
  4615. $post['sku'] = $d['sku'];
  4616. $post['shop'] = $d['shop'];
  4617. $post['warehouse'] = $warehouse['id'];
  4618. $post['purchase'] = $purchase['id'];
  4619. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4620. $post['state'] = 0;
  4621. $post['title'] = $d['title'];
  4622. $post['number'] = $d['number'];
  4623. $post['features'] = $d['features'];
  4624. $post['enter'] = $time;
  4625. $post['time'] = $time; //操作时间
  4626. $post['rktype'] = $rktype;
  4627. $post['sku_master_id'] = $d['sku_master_id'];
  4628. $post['sku_shop_id'] = $d['sku_shop_id'];
  4629. for ($i = 0; $i < $num; $i++) {
  4630. $post['label'] = time() . rand(100, 999) . $i;
  4631. $this->whlabel->insert($post);
  4632. }
  4633. }
  4634. sleep(1); //防止入库时间一样,需要延迟1秒
  4635. }
  4636. if ($j > 0) {
  4637. $tt = date('Ymd', time());
  4638. $title = '库存导入错误信息-' . $tt;
  4639. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4640. $tail = "\n";
  4641. $filename = $title . ".xls";
  4642. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4643. $dir = '/data/excel/' . $time . '/';
  4644. $file_name = 'error_' . $time . rand(1000, 9999);
  4645. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4646. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4647. fwrite($myfile, $ecl);
  4648. fclose($myfile);
  4649. $error = $dir . $file_name . '.xls';
  4650. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4651. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4652. exit;
  4653. } else {
  4654. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4655. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4656. exit;
  4657. }
  4658. }
  4659. //笛卡儿积
  4660. function cp($ps, $sets, $list)
  4661. {
  4662. $result = array();
  4663. $j = 0;
  4664. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4665. if ($i == 0) {
  4666. $result = $sets[$i];
  4667. }
  4668. $tmp = array();
  4669. foreach ($result as $res) {
  4670. foreach ($sets[$i + 1] as $set) {
  4671. $tmp[] = $res . ',' . $set;
  4672. }
  4673. }
  4674. $result = $tmp;
  4675. }
  4676. $this->db->trans_begin();
  4677. foreach ($result as $v) {
  4678. $post = array();
  4679. $title = "";
  4680. $num = "";
  4681. $data = explode(',', $v);
  4682. for ($i = 0; $i < count($list); $i++) {
  4683. $post[$list[$i]] = $data[$i];
  4684. $typeclass = $this->typeclass->read($data[$i]);
  4685. $title = $title . $typeclass['title'] . " ";
  4686. if ($data[$i] != 0) {
  4687. $num .= $data[$i]; //所有数据ID拼接
  4688. }
  4689. }
  4690. foreach ($ps as $kp => $vp) {
  4691. $post[$kp] = $vp;
  4692. }
  4693. $post['number'] = $num;
  4694. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4695. if ($info_list) {
  4696. $j++;
  4697. } else {
  4698. $skunum = $this->whlabel->find_count();
  4699. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4700. $post['title'] = rtrim($title, ' ');
  4701. $this->whlabel->insert($post);
  4702. }
  4703. }
  4704. if ($this->db->trans_status() === FALSE) {
  4705. $this->db->trans_commit();
  4706. return NULL;
  4707. } else {
  4708. $this->db->trans_commit();
  4709. return $j;
  4710. }
  4711. }
  4712. public function _kj($arg_array)
  4713. {
  4714. if (isset($_POST['sku'])) {
  4715. $time = time();
  4716. $sku = $this->input->post('sku', true);
  4717. $warehouse = $this->input->post('warehouse', true);
  4718. $num = $this->input->post('num', true);
  4719. $text = $this->input->post('text', true);
  4720. $purchase = $this->input->post('purchase', true);
  4721. $cktype = $this->input->post('cktype', true);
  4722. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4723. if ($cktype != 1 && $text == '') {
  4724. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4725. exit;
  4726. }
  4727. if ($num > count($order)) {
  4728. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4729. exit;
  4730. } else {
  4731. for ($i = 0; $i < $num; $i++) {
  4732. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4733. }
  4734. }
  4735. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4736. exit;
  4737. }
  4738. $uid = $this->whlabel->read($arg_array[0]);
  4739. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4740. $this->data['data'] = $uid;
  4741. $this->_Template('whlabel_kj', $this->data);
  4742. }
  4743. public function _summary($arg_array)
  4744. {
  4745. $prc = array();
  4746. $purchase = $this->purchase->find_all();
  4747. foreach ($purchase as $k => $v) {
  4748. $prc[$v['id']] = $v['title'];
  4749. }
  4750. if (isset($_GET['excel'])) {
  4751. $ktime = $this->input->get('ktime', true);
  4752. $jtime = $this->input->get('jtime', true);
  4753. $ktime = strtotime($ktime);
  4754. $jtime = strtotime($jtime);
  4755. $where = "1=1";
  4756. if ($ktime && $jtime) {
  4757. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4758. }
  4759. //数据排序
  4760. $order_str = "time desc";
  4761. if (empty($page)) {
  4762. $start = 0;
  4763. $perpage = 1;
  4764. } else {
  4765. $start = ($page - 1) * $perpage;
  4766. }
  4767. //取得信息列表
  4768. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4769. foreach ($info_list as $key => $value) {
  4770. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4771. $warehouse = $this->warehouse->read($value['warehouse']);
  4772. $info_list[$key]['warehouse'] = $warehouse['title'];
  4773. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4774. $details = array();
  4775. $cpid = array();
  4776. foreach ($x as $k => $v) {
  4777. if ($v['details'] != '') {
  4778. $details[$v['details']] = $v['details'];
  4779. }
  4780. if ($v['cpid'] != 0) {
  4781. $cpid[$v['cpid']] = $v['cpid'];
  4782. }
  4783. }
  4784. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4785. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4786. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4787. $info_list[$key]['s'] = $s;
  4788. $info_list[$key]['x'] = count($x);
  4789. }
  4790. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4791. $titlename = "<table border=1>
  4792. <tr align='center'>
  4793. <td>仓库</td>
  4794. <td>供应商</td>
  4795. <td>出库位置</td>
  4796. <td>出库编码</td>
  4797. <td>SKU</td>
  4798. <td>产品名</td>
  4799. <td>总剩余库存</td>
  4800. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4801. </tr>
  4802. </table>";
  4803. $filename = $title . ".xls";
  4804. $tail = "";
  4805. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4806. }
  4807. }
  4808. //usps发货清单
  4809. public function _manifest()
  4810. {
  4811. if (isset($_POST['manifest'])) {
  4812. $wltext = $this->input->post('wltext', true);
  4813. $time = time() - 16 * 3600;
  4814. $ptime = strtotime(date('Y-m-d', $time));
  4815. $waybill = array();
  4816. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4817. foreach ($fullorder as $v) {
  4818. $waybill[$v['waybill']] = $v['waybill'];
  4819. }
  4820. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4821. foreach ($fullordersmt as $v) {
  4822. $waybill[$v['waybill']] = $v['waybill'];
  4823. }
  4824. $wltext = explode(';', $wltext);
  4825. foreach ($wltext as $v) {
  4826. if (isset($waybill[$v])) {
  4827. unset($waybill[$v]);
  4828. }
  4829. }
  4830. $data = $this->usps->get_manifest($waybill);
  4831. if (isset($data['Description'])) {
  4832. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4833. exit;
  4834. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4835. $bctime = date('Ymd', time());
  4836. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4837. echo json_encode(array('msg' => $pdf, 'success' => true));
  4838. exit;
  4839. } else {
  4840. echo json_encode(array('msg' => $data, 'success' => false));
  4841. exit;
  4842. }
  4843. }
  4844. }
  4845. public function _pdf($pdf, $title, $bctime)
  4846. {
  4847. $pdf_path = './data/pdf/' . $bctime . '/';
  4848. $file_base64 = $pdf;
  4849. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4850. $file_base64 = base64_decode($file_base64);
  4851. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4852. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4853. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4854. }
  4855. /**
  4856. *
  4857. *
  4858. *
  4859. 进销存占单异常索引
  4860. *
  4861. *
  4862. *
  4863. **/
  4864. public function _abnormal()
  4865. {
  4866. $post = $this->input->post(NULL, TRUE);
  4867. if (isset($post['page'])) {
  4868. $page = $this->input->post('page', true);
  4869. $perpage = $this->input->post('perpage', true);
  4870. $sku = $this->input->post('sku', true);
  4871. $where = "1=1";
  4872. //数据排序
  4873. $order_str = "id desc";
  4874. if (empty($page)) {
  4875. $start = 0;
  4876. $perpage = 1;
  4877. } else {
  4878. $start = ($page - 1) * $perpage;
  4879. }
  4880. //取得信息列表
  4881. $info_list = $this->whlabel->find_all($where, '*');
  4882. $rows = array();
  4883. $list = array();
  4884. foreach ($info_list as $key => $value) {
  4885. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4886. }
  4887. foreach ($rows as $value) {
  4888. $warehouse = $this->warehouse->read($value['warehouse']);
  4889. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4890. $number = $value['number'];
  4891. $ftime = time() - 15 * 24 * 3600;
  4892. if ($value['shop'] != '') {
  4893. $shop = $value['shop'];
  4894. $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');
  4895. $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');
  4896. $order = array_merge($orderdlz, $ordersmt);
  4897. $od = 0;
  4898. $a = '';
  4899. $orid = '';
  4900. foreach ($order as $v) {
  4901. $or = explode('|', ltrim($v['whlabel'], '|'));
  4902. for ($i = 0; $i < count($or); $i++) {
  4903. $orod = explode('-', $or[$i]);
  4904. if ($orod[0] == $number) {
  4905. $od += $orod[1];
  4906. }
  4907. }
  4908. $orid .= $v['number'] . '-';
  4909. }
  4910. } else {
  4911. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4912. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4913. $order = array_merge($orderdlz, $ordersmt);
  4914. $od = 0;
  4915. $a = '';
  4916. $orid = '';
  4917. $qt = array();
  4918. foreach ($order as $v) {
  4919. $or = explode('|', ltrim($v['whlabel'], '|'));
  4920. for ($i = 0; $i < count($or); $i++) {
  4921. $orod = explode('-', $or[$i]);
  4922. if ($orod[0] == $number) {
  4923. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4924. if ($czzs > 0) {
  4925. if (isset($qt[$v['shop']])) {
  4926. if ($qt[$v['shop']] < $orod[1]) {
  4927. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4928. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4929. } else {
  4930. $qt[$v['shop']] -= $orod[1];
  4931. }
  4932. } else {
  4933. $qt[$v['shop']] = $czzs;
  4934. }
  4935. } else {
  4936. $od += $orod[1];
  4937. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4938. }
  4939. }
  4940. }
  4941. }
  4942. }
  4943. $z = $od . '(' . $orid . ')'; //查看订单号
  4944. //$z = $od;
  4945. if ($od > $c) {
  4946. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4947. }
  4948. }
  4949. $listdata = array_slice($list, $start, $perpage);
  4950. $total = count($list);
  4951. $pagenum = ceil($total / $perpage);
  4952. $over = $total - ($start + $perpage);
  4953. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4954. echo json_encode($rows);
  4955. exit;
  4956. }
  4957. $this->_Template('whlabel_abnormal', $this->data);
  4958. }
  4959. /**
  4960. *
  4961. *
  4962. *
  4963. 进销存占单异常索引
  4964. *
  4965. *
  4966. *
  4967. **/
  4968. public function _error()
  4969. {
  4970. $post = $this->input->post(NULL, TRUE);
  4971. if (isset($post['page'])) {
  4972. $page = $this->input->post('page', true);
  4973. $perpage = $this->input->post('perpage', true);
  4974. $sku = $this->input->post('sku', true);
  4975. $warehouse = $this->input->post('warehouse', true);
  4976. $ktime = $this->input->post('ktime', true);
  4977. $jtime = $this->input->post('jtime', true);
  4978. $ktime = strtotime($ktime);
  4979. $jtime = strtotime($jtime);
  4980. $where = "sku != 'Preset'";
  4981. $gj = '';
  4982. if ($sku) {
  4983. $where .= " and sku like '%$sku%'";
  4984. } else {
  4985. if ($ktime && $jtime) {
  4986. $gj = " and time > '$ktime' and time < '$jtime'";
  4987. }
  4988. }
  4989. if ($warehouse) {
  4990. $where .= " and warehouse = '$warehouse'";
  4991. }
  4992. //数据排序
  4993. $order_str = "id desc";
  4994. if (empty($page)) {
  4995. $start = 0;
  4996. $perpage = 1;
  4997. } else {
  4998. $start = ($page - 1) * $perpage;
  4999. }
  5000. //取得信息列表
  5001. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5002. $rows = array();
  5003. $list = array();
  5004. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5005. // foreach ($info_list as $value)
  5006. // {
  5007. // $warehouse = $this->warehouse->read($value['warehouse']);
  5008. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5009. // $number = $value['number'];$ftime = time()-15*24*3600;
  5010. // if($c < 1)
  5011. // {
  5012. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5013. // }
  5014. // }
  5015. $warehouse_list = $this->warehouse->find_all();
  5016. $warehouse_list = array_column($warehouse_list, null, 'id');
  5017. foreach ($info_list as $value) {
  5018. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5019. 'title' => "",
  5020. ];
  5021. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5022. $number = $value['number'];
  5023. $ftime = time() - 15 * 24 * 3600;
  5024. if ($c < 1) {
  5025. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5026. }
  5027. }
  5028. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5029. // $query = $this->db->query($sql);
  5030. // $info_list = $query->result_array();
  5031. // $sql_two = "select title,id from crowd_warehouse";
  5032. // $query_two = $this->db->query($sql_two);
  5033. // $warehouse_list = $query_two->result_array();
  5034. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5035. // foreach ($info_list as $value)
  5036. // {
  5037. // if(isset($warehouse_arr[$value['warehouse']])){
  5038. // $warehouse = $warehouse_arr[$value['warehouse']];
  5039. // }else{
  5040. // $warehouse = [
  5041. // 'id'=>0,
  5042. // 'title'=>"异常",
  5043. // ];
  5044. // }
  5045. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5046. // $number = $value['number'];$ftime = time()-15*24*3600;
  5047. // if($c < 1)
  5048. // {
  5049. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5050. // }
  5051. // }
  5052. $listdata = array_slice($list, $start, $perpage);
  5053. $total = count($list);
  5054. $pagenum = ceil($total / $perpage);
  5055. $over = $total - ($start + $perpage);
  5056. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5057. echo json_encode($rows);
  5058. exit;
  5059. }
  5060. if (isset($post['s'])) {
  5061. $id_arr = $this->input->post('s');
  5062. $id_arr = explode(',', trim($id_arr, ','));
  5063. if (!$id_arr) {
  5064. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5065. exit;
  5066. }
  5067. //循环删除记录
  5068. foreach ($id_arr as $v) {
  5069. $dd = $this->whlabel->read($v);
  5070. if (!isset($dd['id'])) {
  5071. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5072. exit;
  5073. }
  5074. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5075. if (isset($zt[0])) {
  5076. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5077. exit;
  5078. }
  5079. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5080. foreach ($deldd as $vv) {
  5081. $this->whlabel->remove($vv['id']);
  5082. }
  5083. }
  5084. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5085. exit;
  5086. }
  5087. $this->_Template('whlabel_error', $this->data);
  5088. }
  5089. public function _errorexcel()
  5090. {
  5091. $post = $this->input->post(NULL, TRUE);
  5092. if (isset($_GET['page'])) {
  5093. $page = $this->input->get('page', true);
  5094. $perpage = $this->input->get('perpage', true);
  5095. $sku = $this->input->get('sku', true);
  5096. $warehouse = $this->input->get('warehouse', true);
  5097. $ktime = $this->input->get('ktime', true);
  5098. $jtime = $this->input->get('jtime', true);
  5099. $ktime = strtotime($ktime);
  5100. $jtime = strtotime($jtime);
  5101. $where = "sku != 'Preset'";
  5102. $gj = '';
  5103. if ($sku) {
  5104. $where .= " and sku like '%$sku%'";
  5105. } else {
  5106. if ($ktime && $jtime) {
  5107. $gj = " and time > '$ktime' and time < '$jtime'";
  5108. }
  5109. }
  5110. if ($warehouse) {
  5111. $where .= " and warehouse = '$warehouse'";
  5112. }
  5113. //数据排序
  5114. $order_str = "id desc";
  5115. if (empty($page)) {
  5116. $start = 0;
  5117. $perpage = 1;
  5118. } else {
  5119. $start = ($page - 1) * $perpage;
  5120. }
  5121. //取得信息列表
  5122. $rows = array();
  5123. $list = array();
  5124. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5125. foreach ($info_list as $value) {
  5126. $warehouse = $this->warehouse->read($value['warehouse']);
  5127. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5128. $number = $value['number'];
  5129. $ftime = time() - 15 * 24 * 3600;
  5130. if ($c < 1) {
  5131. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5132. }
  5133. }
  5134. $title = "0库存汇总";
  5135. $titlename = "<table border=1>
  5136. <tr align='center'>
  5137. <td>仓库</td>
  5138. <td>SKU</td>
  5139. <td>产品</td>
  5140. <td>当前库存</td>
  5141. </tr>
  5142. </table>";
  5143. $filename = $title . ".xls";
  5144. $tail = "";
  5145. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5146. }
  5147. }
  5148. /**
  5149. *
  5150. *
  5151. * 占单
  5152. *
  5153. *
  5154. **/
  5155. public function _kcyz()
  5156. {
  5157. $post = $this->input->post(NULL, TRUE);
  5158. if (isset($post['warehouse'])) {
  5159. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5160. exit; //不再使用
  5161. $warehouse = $this->input->post('warehouse', true);
  5162. $whlabel = $this->input->post('whlabel', true);
  5163. $id = $this->input->post('id', true);
  5164. $shop = $this->input->post('shop', true);
  5165. $number = $this->input->post('number', true);
  5166. if (!$whlabel || $whlabel == '|') {
  5167. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5168. exit;
  5169. }
  5170. $pp = explode('|', trim($whlabel, '|'));
  5171. $x = 0;
  5172. $save = array();
  5173. foreach ($pp as $va) {
  5174. $num = explode('-', $va);
  5175. if ($number) {
  5176. $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 = '')"); //通用
  5177. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5178. } else {
  5179. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5180. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5181. }
  5182. $x++;
  5183. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5184. $save[] = $x - 1;
  5185. continue; //提前先加X不然出错,所以要减1
  5186. }
  5187. }
  5188. if (isset($save[0])) {
  5189. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5190. exit;
  5191. } else {
  5192. echo json_encode(array('success' => true));
  5193. exit;
  5194. }
  5195. }
  5196. }
  5197. public function _db()
  5198. {
  5199. $post = $this->input->post(NULL, TRUE);
  5200. if (isset($post['page'])) {
  5201. $page = $this->input->post('page', true);
  5202. $perpage = $this->input->post('perpage', true);
  5203. $sku = $this->input->post('sku', true);
  5204. $number = $this->input->post('number', true);
  5205. $warehouse = $this->input->post('warehouse', true);
  5206. $purchase = $this->input->post('purchase', true);
  5207. $orderinfo = $this->input->post('orderinfo', true);
  5208. $waybill = $this->input->post('waybill', true);
  5209. $category = $this->input->post('category', true);
  5210. $size = $this->input->post('size', true);
  5211. $grade = $this->input->post('grade', true);
  5212. $color = $this->input->post('color', true);
  5213. $lowe = $this->input->post('lowe', true);
  5214. $state = $this->input->post('state', true);
  5215. $label = $this->input->post('label', true);
  5216. $timetk = $this->input->post('timetkk', true);
  5217. $timetj = $this->input->post('timetjj', true);
  5218. $timetk = strtotime($timetk);
  5219. $timetj = strtotime($timetj);
  5220. $where = "dbtime > 0";
  5221. if ($timetk && $timetj) {
  5222. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5223. }
  5224. if ($sku) {
  5225. $where .= " and sku = '$sku'";
  5226. }
  5227. if ($warehouse) {
  5228. $where .= " and warehouse = '$warehouse'";
  5229. if ($warehouse == 12) {
  5230. $w = 'specialstock';
  5231. } else {
  5232. $w = 'whlabel';
  5233. }
  5234. }
  5235. if ($purchase) {
  5236. $where .= " and purchase = '$purchase'";
  5237. }
  5238. if ($category) {
  5239. $where .= " and features like '%-$category-%'";
  5240. }
  5241. if ($size) {
  5242. $where .= " and features like '%-$size-%'";
  5243. }
  5244. if ($grade) {
  5245. $where .= " and features like '%-$grade-%'";
  5246. }
  5247. if ($color) {
  5248. $where .= " and features like '%-$color-%'";
  5249. }
  5250. if ($lowe) {
  5251. $where .= " and features like '%-$lowe-%'";
  5252. }
  5253. if ($state != '') {
  5254. $where .= " and state = '$state'";
  5255. }
  5256. //数据排序
  5257. $order_str = "dbtime desc";
  5258. if (empty($page)) {
  5259. $start = 0;
  5260. $perpage = 1;
  5261. } else {
  5262. $start = ($page - 1) * $perpage;
  5263. }
  5264. //取得信息列表
  5265. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5266. foreach ($info_list as $key => $value) {
  5267. $warehouse = $this->$w->read($value['warehouse']);
  5268. $info_list[$key]['warehouse'] = $warehouse['title'];
  5269. $purchase = $this->purchase->read($value['purchase']);
  5270. $info_list[$key]['purchase'] = $purchase['title'];
  5271. if ($value['enter'] != 0) {
  5272. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5273. } else {
  5274. $info_list[$key]['enter'] = "";
  5275. }
  5276. if ($value['dbtime'] != 0) {
  5277. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5278. } else {
  5279. $info_list[$key]['dbtime'] = "";
  5280. }
  5281. if ($value['state'] == 0) {
  5282. $info_list[$key]['state'] = "在库";
  5283. } else if ($value['state'] == 1) {
  5284. $info_list[$key]['state'] = "出库";
  5285. } else if ($value['state'] == 2) {
  5286. $info_list[$key]['state'] = "退库";
  5287. } else if ($value['state'] == 3) {
  5288. $info_list[$key]['state'] = "调拨中";
  5289. } else if ($value['state'] == 4) {
  5290. $info_list[$key]['state'] = "再加工";
  5291. } else if ($value['state'] == 5) {
  5292. $info_list[$key]['state'] = "维修中";
  5293. } else if ($value['state'] == 6) {
  5294. $info_list[$key]['state'] = "盘亏";
  5295. } else if ($value['state'] == 7) {
  5296. $info_list[$key]['state'] = "更换标签";
  5297. } else if ($value['state'] == 8) {
  5298. $info_list[$key]['state'] = "其它";
  5299. } else if ($value['state'] == 9) {
  5300. $info_list[$key]['state'] = "预设";
  5301. }
  5302. }
  5303. $total = $this->whlabel->find_count($where);
  5304. $pagenum = ceil($total / $perpage);
  5305. $over = $total - ($start + $perpage);
  5306. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5307. echo json_encode($rows);
  5308. exit;
  5309. }
  5310. if (isset($post['outsku'])) {
  5311. $time = time();
  5312. $cz = $this->input->post('cz', true);
  5313. $label = $this->input->post('outsku', true);
  5314. $sl = $this->input->post('sl', true);
  5315. $num = $this->input->post('num', true);
  5316. //$warehouse = $this->input->post('warehouse',true);
  5317. if (!$sl) {
  5318. $sl = 1;
  5319. }
  5320. if (!$warehouse) {
  5321. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5322. exit;
  5323. }
  5324. $dblabel = $this->whlabellabel->get_label($label);
  5325. if ($dblabel) {
  5326. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5327. if (count($data) < 1) {
  5328. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5329. exit;
  5330. }
  5331. if (count($data) < $num) {
  5332. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5333. exit;
  5334. }
  5335. for ($i = 0; $i < $sl; $i++) {
  5336. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5337. }
  5338. echo json_encode(array('success' => true));
  5339. exit;
  5340. } else {
  5341. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5342. exit;
  5343. }
  5344. }
  5345. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5346. $this->_Template('whlabel_db', $this->data);
  5347. }
  5348. public function _dbrk()
  5349. {
  5350. $post = $this->input->post(NULL, TRUE);
  5351. if (isset($post['page'])) {
  5352. $page = $this->input->post('page', true);
  5353. $perpage = $this->input->post('perpage', true);
  5354. $sku = $this->input->post('sku', true);
  5355. $number = $this->input->post('number', true);
  5356. $warehouse = $this->input->post('warehouse', true);
  5357. $purchase = $this->input->post('purchase', true);
  5358. $orderinfo = $this->input->post('orderinfo', true);
  5359. $waybill = $this->input->post('waybill', true);
  5360. $category = $this->input->post('category', true);
  5361. $size = $this->input->post('size', true);
  5362. $grade = $this->input->post('grade', true);
  5363. $color = $this->input->post('color', true);
  5364. $lowe = $this->input->post('lowe', true);
  5365. $state = $this->input->post('state', true);
  5366. $label = $this->input->post('label', true);
  5367. $ctime = $this->input->post('ctime', true);
  5368. $timetk = $this->input->post('timetkk', true);
  5369. $timetj = $this->input->post('timetjj', true);
  5370. $timetk = strtotime($timetk);
  5371. $timetj = strtotime($timetj);
  5372. $where = "dbtime > 0";
  5373. if ($timetk && $timetj) {
  5374. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5375. }
  5376. if ($sku) {
  5377. $where .= " and sku = '$sku'";
  5378. }
  5379. if ($warehouse) {
  5380. $where .= " and warehouse = '$warehouse'";
  5381. }
  5382. if ($purchase) {
  5383. $where .= " and purchase = '$purchase'";
  5384. }
  5385. if ($category) {
  5386. $where .= " and features like '%-$category-%'";
  5387. }
  5388. if ($size) {
  5389. $where .= " and features like '%-$size-%'";
  5390. }
  5391. if ($grade) {
  5392. $where .= " and features like '%-$grade-%'";
  5393. }
  5394. if ($color) {
  5395. $where .= " and features like '%-$color-%'";
  5396. }
  5397. if ($lowe) {
  5398. $where .= " and features like '%-$lowe-%'";
  5399. }
  5400. if ($state != '') {
  5401. $where .= " and state = '$state'";
  5402. }
  5403. //数据排序
  5404. $order_str = "dbtime desc";
  5405. if (empty($page)) {
  5406. $start = 0;
  5407. $perpage = 1;
  5408. } else {
  5409. $start = ($page - 1) * $perpage;
  5410. }
  5411. //取得信息列表
  5412. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5413. foreach ($info_list as $key => $value) {
  5414. $warehouse = $this->warehouse->read($value['warehouse']);
  5415. $info_list[$key]['warehouse'] = $warehouse['title'];
  5416. $purchase = $this->purchase->read($value['purchase']);
  5417. $info_list[$key]['purchase'] = $purchase['title'];
  5418. if ($value['enter'] != 0) {
  5419. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5420. } else {
  5421. $info_list[$key]['enter'] = "";
  5422. }
  5423. if ($value['dbtime'] != 0) {
  5424. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5425. } else {
  5426. $info_list[$key]['dbtime'] = "";
  5427. }
  5428. if ($value['state'] == 0) {
  5429. $info_list[$key]['state'] = "在库";
  5430. } else if ($value['state'] == 1) {
  5431. $info_list[$key]['state'] = "出库";
  5432. } else if ($value['state'] == 2) {
  5433. $info_list[$key]['state'] = "退库";
  5434. } else if ($value['state'] == 3) {
  5435. $info_list[$key]['state'] = "调拨中";
  5436. } else if ($value['state'] == 4) {
  5437. $info_list[$key]['state'] = "再加工";
  5438. } else if ($value['state'] == 5) {
  5439. $info_list[$key]['state'] = "维修中";
  5440. } else if ($value['state'] == 6) {
  5441. $info_list[$key]['state'] = "盘亏";
  5442. } else if ($value['state'] == 7) {
  5443. $info_list[$key]['state'] = "更换标签";
  5444. } else if ($value['state'] == 8) {
  5445. $info_list[$key]['state'] = "其它";
  5446. } else if ($value['state'] == 9) {
  5447. $info_list[$key]['state'] = "预设";
  5448. }
  5449. }
  5450. $total = $this->whlabel->find_count($where);
  5451. $pagenum = ceil($total / $perpage);
  5452. $over = $total - ($start + $perpage);
  5453. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5454. echo json_encode($rows);
  5455. exit;
  5456. }
  5457. if (isset($post['rsku'])) {
  5458. $cz = $this->input->post('cz', true);
  5459. $label = $this->input->post('rsku', true);
  5460. $sl = $this->input->post('sl', true);
  5461. $warehouse = $this->input->post('warehouse', true);
  5462. if (!$sl) {
  5463. $sl = 1;
  5464. }
  5465. if (!$warehouse) {
  5466. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5467. exit;
  5468. }
  5469. $dblabel = $this->whlabellabel->get_label($label);
  5470. if ($dblabel) {
  5471. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5472. if (count($data) < 1) {
  5473. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5474. exit;
  5475. }
  5476. if ($sl > count($data)) {
  5477. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5478. exit;
  5479. }
  5480. $time = time();
  5481. for ($i = 0; $i < $sl; $i++) {
  5482. $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']);
  5483. }
  5484. echo json_encode(array('success' => true));
  5485. exit;
  5486. } else {
  5487. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5488. exit;
  5489. }
  5490. }
  5491. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5492. $this->_Template('whlabel_dbrk', $this->data);
  5493. }
  5494. public function _whlabelczdc()
  5495. {
  5496. if (isset($_GET['excel'])) {
  5497. //数据排序
  5498. $order_str = "id desc";
  5499. if (empty($page)) {
  5500. $start = 0;
  5501. $perpage = 1;
  5502. } else {
  5503. $start = ($page - 1) * $perpage;
  5504. }
  5505. $state = $this->input->get('state', true);
  5506. $sku = $this->input->get('sku', true);
  5507. $ctime = $this->input->get('ctime', true);
  5508. $category = $this->input->get('category', true);
  5509. $size = $this->input->get('size', true);
  5510. $grade = $this->input->get('grade', true);
  5511. $color = $this->input->get('color', true);
  5512. $lowe = $this->input->get('lowe', true);
  5513. $timetk = $this->input->get('timetkk', true);
  5514. $timetj = $this->input->get('timetjj', true);
  5515. $timetk = strtotime($timetk);
  5516. $timetj = strtotime($timetj);
  5517. $where = "dbtime > 0";
  5518. if ($timetk && $timetj) {
  5519. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5520. }
  5521. if ($category) {
  5522. $where .= " and features like '%-$category-%'";
  5523. }
  5524. if ($size) {
  5525. $where .= " and features like '%-$size-%'";
  5526. }
  5527. if ($grade) {
  5528. $where .= " and features like '%-$grade-%'";
  5529. }
  5530. if ($color) {
  5531. $where .= " and features like '%-$color-%'";
  5532. }
  5533. if ($lowe) {
  5534. $where .= " and features like '%-$lowe-%'";
  5535. }
  5536. //取得信息列表
  5537. $info_list = $this->whlabel->find_all($where, '*');
  5538. $rows = array();
  5539. $list = array();
  5540. foreach ($info_list as $key => $value) {
  5541. $rows[$value['sku']] = $value; //所有数据sku
  5542. }
  5543. foreach ($rows as $value) {
  5544. $warehouse = $this->warehouse->read($value['warehouse']);
  5545. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5546. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5547. if ($value['orderinfo'] == 0) {
  5548. $info_list[$key]['orderinfo'] = "";
  5549. }
  5550. if ($value['waybill'] == 0) {
  5551. $info_list[$key]['waybill'] = "";
  5552. }
  5553. if ($value['state'] == 0) {
  5554. $value['state'] = "在库";
  5555. } else if ($value['state'] == 3) {
  5556. $value['state'] = "调拨中";
  5557. }
  5558. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5559. }
  5560. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5561. $titlename = "<table border=1>
  5562. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5563. <tr align='center'>
  5564. <td>SKU</td>
  5565. <td>产品</td>
  5566. <td>调拨数量</td>
  5567. <td>入库数量</td>
  5568. </tr>
  5569. </table>";
  5570. $filename = $title . ".xls";
  5571. $tail = "";
  5572. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5573. }
  5574. }
  5575. public function _print($arg_array)
  5576. {
  5577. if (isset($_SESSION['api'])) {
  5578. $user = $this->user->get_api($_SESSION['api']);
  5579. $usp = $user;
  5580. $fgshop = "";
  5581. $sid = "";
  5582. $wid = "";
  5583. $wtype = "";
  5584. $usersp = explode('|', trim($user['shop'], '|'));
  5585. $userwh = explode('|', trim($user['warehouse'], '|'));
  5586. foreach ($usersp as $value) {
  5587. $fgshop .= " shop = " . $value . " or";
  5588. $sid .= " id = " . $value . " or";
  5589. }
  5590. foreach ($userwh as $value) {
  5591. $wid .= " id = " . $value . " or";
  5592. $wtype .= " type = " . $value . " or";
  5593. }
  5594. }
  5595. $post = $this->input->post(NULL, TRUE);
  5596. if (isset($post['tmsku'])) {
  5597. $tmsku = $this->input->post('tmsku', true);
  5598. if (is_numeric($tmsku)) {
  5599. $yyh = $this->whlabellabel->get_label($tmsku);
  5600. } else {
  5601. $yyh = $this->whlabellabel->get_sku($tmsku);
  5602. if(empty($yyh)){
  5603. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  5604. if($r['code'] == -1 ){
  5605. echo json_encode(array('success' => false));
  5606. exit;
  5607. }else{
  5608. echo json_encode(array('features' => $r['data'], 'success' => true));
  5609. exit;
  5610. }
  5611. }
  5612. }
  5613. if ($yyh) {
  5614. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5615. exit;
  5616. } else {
  5617. echo json_encode(array('success' => false));
  5618. exit;
  5619. }
  5620. }
  5621. $classid = $this->classid->sku();
  5622. $pm = $classid;
  5623. $scsku = $classid;
  5624. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5625. if (isset($post['warehouse'])) {
  5626. if ($post['warehouse']) {
  5627. $list = array();
  5628. $num = "";
  5629. $title = "";
  5630. $features = "";
  5631. $order = 0;
  5632. $post['shop'] = '';
  5633. $brand = $this->input->post('brand', true);
  5634. if ($brand != '0,') {
  5635. $b = $this->brand->read(rtrim($brand, ','));
  5636. if ($b) {
  5637. $post['shop'] = str_replace('|', ',', $b['shop']);
  5638. }
  5639. }
  5640. $post['details'] = $this->input->post('details', true); //打印数量
  5641. $xbqnum = $this->input->post('xbqnum', true);
  5642. $post['purchase'] = $this->input->post('purchase', true);
  5643. $post['warehouse'] = $this->input->post('warehouse', true);
  5644. $post['purchase'] = $this->input->post('purchase', true);
  5645. $post['retreatwarehouse'] = $post['warehouse'];
  5646. $post['cpbz'] = $this->input->post('cpbz', true);
  5647. $post['state'] = 9;
  5648. $category = $this->input->post('category', true);
  5649. $list['category'] = $category;
  5650. $list['hairtype'] = $this->input->post('hairtype', true);
  5651. $list['grade'] = $this->input->post('grade', true);
  5652. $size = $this->input->post('size', true);
  5653. $list['size'] = rtrim($size, ',');
  5654. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5655. $list['extension'] = $this->input->post('extension', true);
  5656. if ($category == 1297) {
  5657. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5658. }
  5659. if ($category == 1702) {
  5660. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5661. $list['syother'] = $this->input->post('syother', true);
  5662. }
  5663. if ($category == 133) {
  5664. $list['fittype'] = $this->input->post('fittype', true);
  5665. $list['acother'] = $this->input->post('acother', true);
  5666. }
  5667. $list['color'] = $this->input->post('color', true);
  5668. $list['lowe'] = $this->input->post('lowe', true);
  5669. if ($category == 127) {
  5670. $list['type'] = $this->input->post('type', true);
  5671. $list['headroad'] = $this->input->post('headroad', true);
  5672. $list['density'] = $this->input->post('density', true);
  5673. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5674. $list['lacesize'] = $this->input->post('lacesize', true);
  5675. }
  5676. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5677. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5678. }
  5679. if ($category == 128) {
  5680. $list['lacetype'] = $this->input->post('lacetype', true);
  5681. $list['haircap'] = $this->input->post('haircap', true);
  5682. $list['density'] = $this->input->post('density', true);
  5683. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5684. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5685. $list['wigother'] = $this->input->post('wigother', true);
  5686. $list['wigother1'] = $this->input->post('wigother1', true);
  5687. $list['wigother2'] = $this->input->post('wigother2', true);
  5688. }
  5689. if ($category == 129) {
  5690. $list['wide'] = $this->input->post('wide', true);
  5691. }
  5692. if ($category == 131) {
  5693. $list['gifttype'] = $this->input->post('gifttype', true);
  5694. $list['giftother'] = $this->input->post('giftother', true);
  5695. }
  5696. if ($category == 134) {
  5697. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5698. }
  5699. if ($category == 1297) {
  5700. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5701. $list['sywigother'] = $this->input->post('sywigother', true);
  5702. }
  5703. if ($category == 130 || $category == 133 || $category == 1702) {
  5704. $list['items'] = $this->input->post('items', true);
  5705. $list['weight'] = $this->input->post('weight', true);
  5706. }
  5707. if ($category == 1702) {
  5708. $list['syhairther'] = $this->input->post('syhairther', true);
  5709. }
  5710. if($category == 130){
  5711. $list['jfother'] = $this->input->post('jfother', true);
  5712. }
  5713. foreach ($list as $k => $v) {
  5714. if ($v != 0) {
  5715. $num .= $v;
  5716. $features .= $v . '-';
  5717. $post[$k] = $v;
  5718. $typeclass = $this->typeclass->read($v);
  5719. if (isset($pm[$typeclass['classid']])) {
  5720. if (stripos($typeclass['zh'], '|') !== false) {
  5721. $exzh = explode('|', $typeclass['zh']);
  5722. $pm[$typeclass['classid']] = $exzh[0];
  5723. } else {
  5724. $pm[$typeclass['classid']] = $typeclass['zh'];
  5725. }
  5726. }
  5727. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5728. if ($k != 'size') {
  5729. $title .= $typeclass['title'] . " ";
  5730. }
  5731. }
  5732. }
  5733. $typeclass = $this->typeclass->read($list['size']);
  5734. $title .= $typeclass['title'];
  5735. $time = time();
  5736. $post['title'] = rtrim($title, ' ');
  5737. $post['number'] = $num;
  5738. $post['features'] = '-' . $features;
  5739. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5740. $featurespp = explode('-', trim($featurespp, '-'));
  5741. if (isset($featurespp[5])) {
  5742. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5743. } else {
  5744. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5745. }
  5746. $post['enter'] = $time;
  5747. $post['time'] = $time; //操作时间
  5748. $scsku = implode("-", $scsku);
  5749. $zh = implode(" ", $pm);
  5750. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5751. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5752. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5753. $post['sku'] = $bqsku;
  5754. $label = time() . rand(0, 9);
  5755. $post['label'] = $label;
  5756. $cpid = $this->whlabellabel->find_count();
  5757. $post['cpid'] = $cpid + 1;
  5758. $cpid = $post['cpid'];
  5759. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5760. //if($whlabelbarcode)
  5761. //{
  5762. //$post['label'] = $whlabelbarcode['label'];
  5763. //if(!$this->whlabellabel->insert($post))
  5764. //{
  5765. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5766. //}
  5767. //}
  5768. //else
  5769. //{
  5770. $this->db->trans_begin();
  5771. $this->whlabellabel->insert($post);
  5772. //$this->whlabelbarcode->insert($post);
  5773. if ($this->db->trans_status() === TRUE) {
  5774. $this->db->trans_commit();
  5775. } else {
  5776. $this->db->trans_rollback();
  5777. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5778. exit;
  5779. }
  5780. //}
  5781. $warehouse_name = "";
  5782. $warehouse = $post['warehouse'];
  5783. if($warehouse == 12){
  5784. $warehouse_name = "特殊库存库";
  5785. }
  5786. // if($warehouse == 13){
  5787. // $warehouse_name = "许昌仓";
  5788. // }
  5789. // if($warehouse == 5){
  5790. // $warehouse_name = "美国店";
  5791. // }
  5792. // if($warehouse == 16){
  5793. // $warehouse_name = "定制头套仓";
  5794. // }
  5795. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5796. if(!empty($warehouse_name)){
  5797. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5798. }
  5799. $purchase = $this->purchase->read($post['purchase']);
  5800. 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));
  5801. exit; //特殊仓目前不需要仓库选项
  5802. }
  5803. }
  5804. if (isset($_SESSION['api'])) {
  5805. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5806. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5807. $this->data['wlshop'] = $wlshop;
  5808. $this->data['warehouse'] = $warehouse;
  5809. }
  5810. $whlabelwz = $this->whlabelwz->find_all();
  5811. $this->data['whlabelwz'] = $whlabelwz;
  5812. $this->_Template('whlabel_print', $this->data);
  5813. }
  5814. public function _usaprint($arg_array)
  5815. {
  5816. if (isset($_SESSION['api'])) {
  5817. $user = $this->user->get_api($_SESSION['api']);
  5818. $usp = $user;
  5819. $fgshop = "";
  5820. $sid = "";
  5821. $wid = "";
  5822. $wtype = "";
  5823. $usersp = explode('|', trim($user['shop'], '|'));
  5824. $userwh = explode('|', trim($user['warehouse'], '|'));
  5825. foreach ($usersp as $value) {
  5826. $fgshop .= " shop = " . $value . " or";
  5827. $sid .= " id = " . $value . " or";
  5828. }
  5829. foreach ($userwh as $value) {
  5830. $wid .= " id = " . $value . " or";
  5831. $wtype .= " type = " . $value . " or";
  5832. }
  5833. }
  5834. $post = $this->input->post(NULL, TRUE);
  5835. if (isset($post['tmsku'])) {
  5836. $tmsku = $this->input->post('tmsku', true);
  5837. if (is_numeric($tmsku)) {
  5838. $yyh = $this->whlabellabel->get_label($tmsku);
  5839. } else {
  5840. $yyh = $this->whlabellabel->get_sku($tmsku);
  5841. }
  5842. if ($yyh) {
  5843. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5844. exit;
  5845. } else {
  5846. echo json_encode(array('success' => false));
  5847. exit;
  5848. }
  5849. }
  5850. $classid = $this->classid->sku();
  5851. $pm = $classid;
  5852. $scsku = $classid;
  5853. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5854. if (isset($post['warehouse'])) {
  5855. if ($post['warehouse']) {
  5856. $list = array();
  5857. $num = "";
  5858. $title = "";
  5859. $features = "";
  5860. $order = 0;
  5861. $post['shop'] = '';
  5862. $brand = $this->input->post('brand', true);
  5863. if ($brand != '0,') {
  5864. $b = $this->brand->read(rtrim($brand, ','));
  5865. if ($b) {
  5866. $post['shop'] = str_replace('|', ',', $b['shop']);
  5867. }
  5868. }
  5869. $post['details'] = $this->input->post('details', true); //打印数量
  5870. $xbqnum = $this->input->post('xbqnum', true);
  5871. $post['purchase'] = $this->input->post('purchase', true);
  5872. $post['warehouse'] = $this->input->post('warehouse', true);
  5873. $post['purchase'] = $this->input->post('purchase', true);
  5874. $post['retreatwarehouse'] = $post['warehouse'];
  5875. $post['cpbz'] = $this->input->post('cpbz', true);
  5876. $post['state'] = 9;
  5877. $category = $this->input->post('category', true);
  5878. $list['category'] = $category;
  5879. $list['hairtype'] = $this->input->post('hairtype', true);
  5880. $list['grade'] = $this->input->post('grade', true);
  5881. $size = $this->input->post('size', true);
  5882. $list['size'] = rtrim($size, ',');
  5883. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5884. $list['extension'] = $this->input->post('extension', true);
  5885. if ($category == 1297) {
  5886. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5887. }
  5888. if ($category == 1702) {
  5889. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5890. $list['syother'] = $this->input->post('syother', true);
  5891. }
  5892. if ($category == 133) {
  5893. $list['fittype'] = $this->input->post('fittype', true);
  5894. $list['acother'] = $this->input->post('acother', true);
  5895. }
  5896. $list['color'] = $this->input->post('color', true);
  5897. $list['lowe'] = $this->input->post('lowe', true);
  5898. if ($category == 127) {
  5899. $list['type'] = $this->input->post('type', true);
  5900. $list['headroad'] = $this->input->post('headroad', true);
  5901. $list['density'] = $this->input->post('density', true);
  5902. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5903. $list['lacesize'] = $this->input->post('lacesize', true);
  5904. }
  5905. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5906. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5907. }
  5908. if ($category == 128) {
  5909. $list['lacetype'] = $this->input->post('lacetype', true);
  5910. $list['haircap'] = $this->input->post('haircap', true);
  5911. $list['density'] = $this->input->post('density', true);
  5912. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5913. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5914. $list['wigother'] = $this->input->post('wigother', true);
  5915. $list['wigother1'] = $this->input->post('wigother1', true);
  5916. $list['wigother2'] = $this->input->post('wigother2', true);
  5917. }
  5918. if ($category == 129) {
  5919. $list['wide'] = $this->input->post('wide', true);
  5920. }
  5921. if ($category == 131) {
  5922. $list['gifttype'] = $this->input->post('gifttype', true);
  5923. $list['giftother'] = $this->input->post('giftother', true);
  5924. }
  5925. if ($category == 134) {
  5926. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5927. }
  5928. if ($category == 1297) {
  5929. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5930. $list['sywigother'] = $this->input->post('sywigother', true);
  5931. }
  5932. if ($category == 130 || $category == 133 || $category == 1702) {
  5933. $list['items'] = $this->input->post('items', true);
  5934. $list['weight'] = $this->input->post('weight', true);
  5935. }
  5936. if ($category == 1702) {
  5937. $list['syhairther'] = $this->input->post('syhairther', true);
  5938. }
  5939. foreach ($list as $k => $v) {
  5940. if ($v != 0) {
  5941. $num .= $v;
  5942. $features .= $v . '-';
  5943. $post[$k] = $v;
  5944. $typeclass = $this->typeclass->read($v);
  5945. if (isset($pm[$typeclass['classid']])) {
  5946. if (stripos($typeclass['zh'], '|') !== false) {
  5947. $exzh = explode('|', $typeclass['zh']);
  5948. $pm[$typeclass['classid']] = $exzh[0];
  5949. } else {
  5950. $pm[$typeclass['classid']] = $typeclass['zh'];
  5951. }
  5952. }
  5953. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5954. if ($k != 'size') {
  5955. $title .= $typeclass['title'] . " ";
  5956. }
  5957. }
  5958. }
  5959. $typeclass = $this->typeclass->read($list['size']);
  5960. $title .= $typeclass['title'];
  5961. $time = time();
  5962. $post['title'] = rtrim($title, ' ');
  5963. $post['number'] = $num;
  5964. $post['features'] = '-' . $features;
  5965. $fp = $this->whlabel->get_features($post['features']);
  5966. if (!$fp) {
  5967. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5968. exit;
  5969. }
  5970. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5971. $featurespp = explode('-', trim($featurespp, '-'));
  5972. if (isset($featurespp[5])) {
  5973. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5974. } else {
  5975. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5976. }
  5977. $post['enter'] = $time;
  5978. $post['time'] = $time; //操作时间
  5979. $scsku = implode("-", $scsku);
  5980. $zh = implode(" ", $pm);
  5981. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5982. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5983. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5984. $post['sku'] = $fp['sku'];
  5985. $post['label'] = $fp['sku'];
  5986. $cpid = $this->whlabellabel->find_count();
  5987. $post['cpid'] = $cpid + 1;
  5988. $cpid = $post['cpid'];
  5989. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5990. //if($whlabelbarcode)
  5991. //{
  5992. //$post['label'] = $whlabelbarcode['label'];
  5993. //if(!$this->whlabellabel->insert($post))
  5994. //{
  5995. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5996. //}
  5997. //}
  5998. //else
  5999. //{
  6000. $this->db->trans_begin();
  6001. $this->whlabellabel->insert($post);
  6002. //$this->whlabelbarcode->insert($post);
  6003. if ($this->db->trans_status() === TRUE) {
  6004. $this->db->trans_commit();
  6005. } else {
  6006. $this->db->trans_rollback();
  6007. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6008. exit;
  6009. }
  6010. //}
  6011. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6012. $purchase = $this->purchase->read($post['purchase']);
  6013. 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));
  6014. exit; //特殊仓目前不需要仓库选项
  6015. }
  6016. }
  6017. if (isset($_SESSION['api'])) {
  6018. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6019. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6020. $this->data['wlshop'] = $wlshop;
  6021. $this->data['warehouse'] = $warehouse;
  6022. }
  6023. $whlabelwz = $this->whlabelwz->find_all();
  6024. $this->data['whlabelwz'] = $whlabelwz;
  6025. $this->_Template('whlabel_usaprint', $this->data);
  6026. }
  6027. public function _printrk($arg_array)
  6028. {
  6029. $prc = array();
  6030. $purchase = $this->purchase->find_all();
  6031. foreach ($purchase as $k => $v) {
  6032. $prc[$v['id']] = $v['title'];
  6033. }
  6034. $post = $this->input->post(NULL, TRUE);
  6035. if (isset($post['page'])) {
  6036. $page = $this->input->post('page', true);
  6037. $perpage = $this->input->post('perpage', true);
  6038. $sku = $this->input->post('sku', true);
  6039. $bs = $this->input->post('bs', true);
  6040. $number = $this->input->post('number', true);
  6041. $warehouse = $this->input->post('warehouse', true);
  6042. $purchase = $this->input->post('purchase', true);
  6043. $orderinfo = $this->input->post('orderinfo', true);
  6044. $waybill = $this->input->post('waybill', true);
  6045. $category = $this->input->post('category', true);
  6046. $size = $this->input->post('size', true);
  6047. $grade = $this->input->post('grade', true);
  6048. $color = $this->input->post('color', true);
  6049. $lowe = $this->input->post('lowe', true);
  6050. $state = $this->input->post('state', true);
  6051. $label = $this->input->post('label', true);
  6052. $timetk = $this->input->post('ktime', true);
  6053. $timetj = $this->input->post('jtime', true);
  6054. $timetk = strtotime($timetk);
  6055. $timetj = strtotime($timetj);
  6056. $where = "1=1 ";
  6057. if ($timetk && $timetj) {
  6058. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6059. }
  6060. if ($sku) {
  6061. $where .= " and sku = '$sku'";
  6062. }
  6063. if ($bs != '') {
  6064. $where .= " and bs = '$bs'";
  6065. }
  6066. if ($number) {
  6067. $where .= " and number = '$number'";
  6068. }
  6069. if ($warehouse) {
  6070. $where .= " and warehouse = '$warehouse'";
  6071. }
  6072. if ($purchase) {
  6073. $where .= " and purchase = '$purchase'";
  6074. }
  6075. if ($orderinfo) {
  6076. $where .= " and orderinfo = '$orderinfo'";
  6077. }
  6078. if ($waybill) {
  6079. $where .= " and waybill = '$waybill'";
  6080. }
  6081. if ($category) {
  6082. $where .= " and features like '%-$category-%'";
  6083. }
  6084. if ($size) {
  6085. $where .= " and features like '%-$size-%'";
  6086. }
  6087. if ($grade) {
  6088. $where .= " and features like '%-$grade-%'";
  6089. }
  6090. if ($color) {
  6091. $where .= " and features like '%-$color-%'";
  6092. }
  6093. if ($lowe) {
  6094. $where .= " and features like '%-$lowe-%'";
  6095. }
  6096. if ($label) {
  6097. $where .= " and label = '$label'";
  6098. }
  6099. if ($state || $state == 0) {
  6100. $where .= " and state = '$state'";
  6101. }
  6102. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6103. //数据排序
  6104. $order_str = "enter desc";
  6105. if (empty($page)) {
  6106. $start = 0;
  6107. $perpage = 1;
  6108. } else {
  6109. $start = ($page - 1) * $perpage;
  6110. }
  6111. //取得信息列表
  6112. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6113. foreach ($info_list as $key => $value) {
  6114. $warehouse = $this->warehouse->read($value['warehouse']);
  6115. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6116. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6117. if ($value['state'] == 0) {
  6118. $info_list[$key]['state'] = "在库";
  6119. } else if ($value['state'] == 1) {
  6120. $info_list[$key]['state'] = "出库";
  6121. } else if ($value['state'] == 2) {
  6122. $info_list[$key]['state'] = "退库";
  6123. } else if ($value['state'] == 3) {
  6124. $info_list[$key]['state'] = "调拨中";
  6125. } else if ($value['state'] == 4) {
  6126. $info_list[$key]['state'] = "再加工";
  6127. } else if ($value['state'] == 5) {
  6128. $info_list[$key]['state'] = "维修中";
  6129. } else if ($value['state'] == 6) {
  6130. $info_list[$key]['state'] = "盘亏";
  6131. } else if ($value['state'] == 7) {
  6132. $info_list[$key]['state'] = "更换标签";
  6133. } else if ($value['state'] == 8) {
  6134. $info_list[$key]['state'] = "其它";
  6135. } else if ($value['state'] == 9) {
  6136. $info_list[$key]['state'] = "预设";
  6137. } else if ($value['state'] == 10) {
  6138. $info_list[$key]['state'] = "美店零售";
  6139. }
  6140. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6141. }
  6142. $total = $this->$ck->find_count($where);
  6143. $pagenum = ceil($total / $perpage);
  6144. $over = $total - ($start + $perpage);
  6145. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6146. echo json_encode($rows);
  6147. exit;
  6148. }
  6149. if (isset($post['tmsku'])) {
  6150. $time = time();
  6151. $tmsku = $this->input->post('tmsku', true);
  6152. //$post['shop'] = $this->input->post('shop',true);
  6153. $num = $this->input->post('num', true);
  6154. $rktype = $this->input->post('rktype', true);
  6155. if ($num > 200) {
  6156. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6157. exit;
  6158. }
  6159. if (!$rktype) {
  6160. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6161. }
  6162. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6163. /**
  6164. $wz = array();
  6165. foreach ($rk as $key=>$value)
  6166. {
  6167. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6168. }
  6169. if(count($wz) > 1)
  6170. {
  6171. $wz = array_values($wz);
  6172. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6173. }
  6174. **/
  6175. if (isset($rk[0]['purchase'])) {
  6176. $rk = $rk[0];
  6177. $j = 0;
  6178. $post['purchase'] = $rk['purchase'];
  6179. $post['warehouse'] = $rk['warehouse'];
  6180. $post['retreatwarehouse'] = $rk['warehouse'];
  6181. $post['sku'] = $rk['sku'];
  6182. $post['number'] = $rk['number'];
  6183. $post['features'] = $rk['features'];
  6184. $post['title'] = $rk['title'];
  6185. $post['enter'] = $time;
  6186. $post['time'] = $time;
  6187. $post['bs'] = 1;
  6188. $post['shop'] = $rk['shop'];
  6189. $post['details'] = $rk['details'];
  6190. $post['cpid'] = $rk['cpid'];
  6191. $post['cpbz'] = $rk['cpbz'];
  6192. $post['rktype'] = $rktype;
  6193. $warehouse = $this->warehouse->read($rk['warehouse']);
  6194. if ($warehouse['bdck'] == '') {
  6195. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6196. exit;
  6197. } else {
  6198. $bdck = $warehouse['bdck'];
  6199. }
  6200. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6201. if (isset($pdwz['details'])) {
  6202. if ($pdwz['details'] != $post['details']) {
  6203. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6204. }else{
  6205. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6206. exit;
  6207. }
  6208. }
  6209. }
  6210. $post['featurespp'] = $rk['featurespp'];
  6211. if ($post['warehouse'] == '5') {
  6212. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6213. if ($yza) {
  6214. if ($post['features'] != $yza[0]['features']) {
  6215. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6216. exit;
  6217. }
  6218. }
  6219. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6220. if ($yzb) {
  6221. if ($post['sku'] != $yzb[0]['sku']) {
  6222. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6223. exit;
  6224. }
  6225. }
  6226. }
  6227. for ($i = 0; $i < $num; $i++) {
  6228. $post['label'] = time() . rand(100, 999) . $i;
  6229. if ($this->$bdck->insert($post)) {
  6230. $j++;
  6231. }
  6232. }
  6233. /**
  6234. if($post['warehouse'] != 12)
  6235. {
  6236. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6237. }
  6238. **/
  6239. $this->whlabelscanlog->insert([
  6240. 'shop'=>$rk['shop'],
  6241. 'type'=>1,
  6242. 'purchase'=>$rk['purchase'],
  6243. 'sku'=>$rk['sku'],
  6244. 'features'=>$rk['features'],
  6245. 'title'=>$rk['title'],
  6246. 'label'=>$rk['label'],
  6247. 'warehouse'=>$rk['warehouse'],
  6248. 'wlid'=>$rk['id'],
  6249. 'num'=>$num,
  6250. 'addtime'=>time()
  6251. ]);
  6252. if ($j == $num) {
  6253. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6254. exit;
  6255. } else {
  6256. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6257. exit;
  6258. }
  6259. } else {
  6260. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6261. exit;
  6262. }
  6263. }
  6264. $this->_Template('whlabel_printrk', $this->data);
  6265. }
  6266. public function _printxzrk($arg_array)
  6267. {
  6268. $post = $this->input->post(NULL, TRUE);
  6269. if (isset($post['wzid'])) {
  6270. $time = time();
  6271. $id = $this->input->post('wzid', true);
  6272. //$post['shop'] = $this->input->post('shop',true);
  6273. $num = 1;
  6274. $rk = $this->whlabellabel->read($id);
  6275. if (isset($rk['purchase'])) {
  6276. $x = 0;
  6277. $post['purchase'] = $rk['purchase'];
  6278. $post['warehouse'] = $rk['warehouse'];
  6279. $post['retreatwarehouse'] = $rk['warehouse'];
  6280. $post['sku'] = $rk['sku'];
  6281. $post['number'] = $rk['number'];
  6282. $post['features'] = $rk['features'];
  6283. $post['title'] = $rk['title'];
  6284. $post['enter'] = $time;
  6285. $post['time'] = $time;
  6286. $post['bs'] = 1;
  6287. $post['shop'] = $rk['shop'];
  6288. $post['details'] = $rk['details'];
  6289. $post['cpid'] = $rk['cpid'];
  6290. $post['cpbz'] = $rk['cpbz'];
  6291. $warehouse = $this->warehouse->read($rk['warehouse']);
  6292. if ($warehouse['bdck'] == '') {
  6293. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6294. exit;
  6295. } else {
  6296. $bdck = $warehouse['bdck'];
  6297. }
  6298. $post['featurespp'] = $rk['featurespp'];
  6299. $this->db->trans_begin();
  6300. for ($i = 0; $i < $num; $i++) {
  6301. $post['label'] = time() . rand(100, 999) . $i;
  6302. $this->$bdck->insert($post);
  6303. }
  6304. /**
  6305. if($post['warehouse'] != 12)
  6306. {
  6307. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6308. }
  6309. **/
  6310. if ($this->db->trans_status() === TRUE) {
  6311. $this->db->trans_commit();
  6312. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6313. exit;
  6314. } else {
  6315. $this->db->trans_rollback();
  6316. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6317. exit;
  6318. }
  6319. } else {
  6320. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6321. exit;
  6322. }
  6323. }
  6324. }
  6325. public function _printck($arg_array)
  6326. {
  6327. $prc = array();
  6328. $purchase = $this->purchase->find_all();
  6329. foreach ($purchase as $k => $v) {
  6330. $prc[$v['id']] = $v['title'];
  6331. }
  6332. $post = $this->input->post(NULL, TRUE);
  6333. if (isset($post['page'])) {
  6334. $page = $this->input->post('page', true);
  6335. $perpage = $this->input->post('perpage', true);
  6336. $sku = $this->input->post('sku', true);
  6337. $bs = $this->input->post('bs', true);
  6338. $number = $this->input->post('number', true);
  6339. $warehouse = $this->input->post('warehouse', true);
  6340. $purchase = $this->input->post('purchase', true);
  6341. $orderinfo = $this->input->post('orderinfo', true);
  6342. $waybill = $this->input->post('waybill', true);
  6343. $category = $this->input->post('category', true);
  6344. $size = $this->input->post('size', true);
  6345. $grade = $this->input->post('grade', true);
  6346. $color = $this->input->post('color', true);
  6347. $lowe = $this->input->post('lowe', true);
  6348. $state = $this->input->post('state', true);
  6349. $label = $this->input->post('label', true);
  6350. $timetk = $this->input->post('ktime', true);
  6351. $timetj = $this->input->post('jtime', true);
  6352. $timetk = strtotime($timetk);
  6353. $timetj = strtotime($timetj);
  6354. $where = "state=1 ";
  6355. if ($timetk && $timetj) {
  6356. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6357. }
  6358. if ($sku) {
  6359. $where .= " and sku = '$sku'";
  6360. }
  6361. if ($bs != '') {
  6362. $where .= " and bs = '$bs'";
  6363. }
  6364. if ($number) {
  6365. $where .= " and number = '$number'";
  6366. }
  6367. if ($warehouse) {
  6368. $where .= " and warehouse = '$warehouse'";
  6369. }
  6370. if ($purchase) {
  6371. $where .= " and purchase = '$purchase'";
  6372. }
  6373. if ($orderinfo) {
  6374. $where .= " and orderinfo = '$orderinfo'";
  6375. }
  6376. if ($waybill) {
  6377. $where .= " and waybill = '$waybill'";
  6378. }
  6379. if ($category) {
  6380. $where .= " and features like '%-$category-%'";
  6381. }
  6382. if ($size) {
  6383. $where .= " and features like '%-$size-%'";
  6384. }
  6385. if ($grade) {
  6386. $where .= " and features like '%-$grade-%'";
  6387. }
  6388. if ($color) {
  6389. $where .= " and features like '%-$color-%'";
  6390. }
  6391. if ($lowe) {
  6392. $where .= " and features like '%-$lowe-%'";
  6393. }
  6394. if ($label) {
  6395. $where .= " and label = '$label'";
  6396. }
  6397. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6398. //数据排序
  6399. $order_str = "outk desc";
  6400. if (empty($page)) {
  6401. $start = 0;
  6402. $perpage = 1;
  6403. } else {
  6404. $start = ($page - 1) * $perpage;
  6405. }
  6406. //取得信息列表
  6407. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6408. foreach ($info_list as $key => $value) {
  6409. $warehouse = $this->warehouse->read($value['warehouse']);
  6410. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6411. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6412. if ($value['state'] == 0) {
  6413. $info_list[$key]['state'] = "在库";
  6414. } else if ($value['state'] == 1) {
  6415. $info_list[$key]['state'] = "出库";
  6416. } else if ($value['state'] == 2) {
  6417. $info_list[$key]['state'] = "退库";
  6418. } else if ($value['state'] == 3) {
  6419. $info_list[$key]['state'] = "调拨中";
  6420. } else if ($value['state'] == 4) {
  6421. $info_list[$key]['state'] = "再加工";
  6422. } else if ($value['state'] == 5) {
  6423. $info_list[$key]['state'] = "维修中";
  6424. } else if ($value['state'] == 6) {
  6425. $info_list[$key]['state'] = "盘亏";
  6426. } else if ($value['state'] == 7) {
  6427. $info_list[$key]['state'] = "更换标签";
  6428. } else if ($value['state'] == 8) {
  6429. $info_list[$key]['state'] = "其它";
  6430. } else if ($value['state'] == 9) {
  6431. $info_list[$key]['state'] = "预设";
  6432. } else if ($value['state'] == 10) {
  6433. $info_list[$key]['state'] = "美店零售";
  6434. }
  6435. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6436. }
  6437. $total = $this->$ck->find_count($where);
  6438. $pagenum = ceil($total / $perpage);
  6439. $over = $total - ($start + $perpage);
  6440. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6441. echo json_encode($rows);
  6442. exit;
  6443. }
  6444. if (isset($post['tmsku'])) {
  6445. $time = time();
  6446. $tmsku = $this->input->post('tmsku', true);
  6447. //$post['shop'] = $this->input->post('shop',true);
  6448. $num = $this->input->post('num', true);
  6449. $cktype = $this->input->post('cktype', true);
  6450. $label = $this->whlabellabel->get_label($tmsku);
  6451. if (!$cktype) {
  6452. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6453. }
  6454. if (!isset($label['warehouse'])) {
  6455. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6456. exit;
  6457. }
  6458. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6459. if (stripos($label['features'], '-126-') !== false) {
  6460. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and ( zd = '' or zd is null )");
  6461. } else {
  6462. $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 = '' or zd is null ) ");
  6463. }
  6464. $j = 0;
  6465. if (count($ck) >= $num) {
  6466. for ($i = 0; $i < $num; $i++) {
  6467. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6468. {
  6469. $j++;
  6470. }
  6471. }
  6472. $this->whlabelscanlog->insert([
  6473. 'shop'=>$label['shop'],
  6474. 'type'=>2,
  6475. 'purchase'=>$label['purchase'],
  6476. 'sku'=>$label['sku'],
  6477. 'features'=>$label['features'],
  6478. 'title'=>$label['title'],
  6479. 'label'=>$label['label'],
  6480. 'warehouse'=>$label['warehouse'],
  6481. 'wlid'=>$label['id'],
  6482. 'num'=>$num,
  6483. 'addtime'=>time()
  6484. ]);
  6485. if ($j == $num) {
  6486. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6487. exit;
  6488. } else {
  6489. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6490. exit;
  6491. }
  6492. } else {
  6493. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6494. exit;
  6495. }
  6496. }
  6497. if(isset($_SESSION['api']))
  6498. {
  6499. $user = $this->user->get_api($_SESSION['api']);
  6500. if(in_array($user['power'],[1,27])){
  6501. $vip = 1;
  6502. }
  6503. }
  6504. else
  6505. {
  6506. $vip = 0;
  6507. header('Location: /');exit;
  6508. }
  6509. $this->data['vip'] = $vip;
  6510. $this->_Template('whlabel_printck', $this->data);
  6511. }
  6512. public function _printexcel()
  6513. {
  6514. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6515. $config['upload_path'] = '.' . $dir;
  6516. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6517. $config['allowed_types'] = 'xls|xlsx|csv';
  6518. $config['max_size'] = 10240;
  6519. $this->load->library('upload', $config);
  6520. $this->upload->initialize($config);
  6521. if ($this->upload->do_upload('userfile')) {
  6522. $full_path = $dir . $this->upload->data('file_name');
  6523. $fileName = '.' . $full_path;
  6524. if (!file_exists($fileName)) {
  6525. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6526. exit;
  6527. } else {
  6528. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6529. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6530. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6531. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6532. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6533. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6534. ++$column; //如果列数大于26行
  6535. $list = array();
  6536. for ($i = 2; $i <= $row; $i++) // 行数循环
  6537. {
  6538. $data = array();
  6539. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6540. {
  6541. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6542. }
  6543. $list[] = $data;
  6544. }
  6545. }
  6546. $ed = array();
  6547. $i = 0;
  6548. $j = 0;
  6549. $dcdata = array();
  6550. $yc = '';
  6551. $cmf_arr = array_column($list, '1');
  6552. array_multisort($cmf_arr, SORT_ASC, $list);
  6553. foreach ($list as $key => $value) {
  6554. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6555. if ($typeclass) {
  6556. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6557. } else {
  6558. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6559. $i++;
  6560. continue;
  6561. }
  6562. }
  6563. if ($i > 0) {
  6564. $yc = $i . '条异常';
  6565. }
  6566. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6567. exit;
  6568. }
  6569. }
  6570. public function _uck()
  6571. {
  6572. if (isset($_GET['excel'])) {
  6573. $tc = array();
  6574. $typeclass = $this->typeclass->find_all();
  6575. foreach ($typeclass as $v) {
  6576. $tc[$v['id']] = $v['zh'];
  6577. }
  6578. $data = array();
  6579. $t = array();
  6580. $rq = '';
  6581. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6582. $ts = $ts / (24 * 3600);
  6583. for ($i = 0; $i < $ts; $i++) {
  6584. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6585. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6586. }
  6587. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6588. foreach ($info_list as $k => $v) {
  6589. $features = explode('-', trim($v['features'], '-'));
  6590. if (!isset($features[3]) || !isset($features[4])) {
  6591. continue;
  6592. }
  6593. $data[$k][0] = $tc[$features[0]]; //类型
  6594. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6595. $data[$k][2] = $tc[$features[4]]; //曲度
  6596. $data[$k][3] = '';
  6597. if (isset($data[$k][1])) {
  6598. $data[$k][3] .= $data[$k][1];
  6599. }
  6600. if (isset($data[$k][2])) {
  6601. $data[$k][3] .= $data[$k][2];
  6602. }
  6603. if (isset($features[5])) {
  6604. $data[$k][3] .= $tc[$features[5]];
  6605. }
  6606. if (isset($features[2])) {
  6607. $data[$k][3] .= $tc[$features[2]];
  6608. }
  6609. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6610. $data[$k][4] = $v['sku'];
  6611. $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())) . '))'); //月初库存
  6612. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6613. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6614. $ztrq = '';
  6615. $ztsl = '';
  6616. if (count($zt) > 0) {
  6617. foreach ($zt as $vv) {
  6618. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6619. $ztsl .= $vv['num'] . '<br>';
  6620. }
  6621. }
  6622. $data[$k][] = trim($ztsl, '<br>');
  6623. $data[$k][] = trim($ztrq, '<br>');
  6624. $byck = 0;
  6625. foreach ($t as $vv) {
  6626. $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));
  6627. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6628. $byck += $sl;
  6629. }
  6630. $data[$k][] = ($byck > 0) ? $byck : '';
  6631. }
  6632. $title = "详情 " . date("Y-m-d", time());
  6633. $titlename = "<table border=1>
  6634. <tr align='center'>
  6635. <td>类别</td>
  6636. <td>颜色</td>
  6637. <td>曲度</td>
  6638. <td>名称</td>
  6639. <td>SKU</td>
  6640. <td>月初库存</td>
  6641. <td>剩余库存</td>
  6642. <td>在途数量</td>
  6643. <td>预达日期</td>" .
  6644. $rq
  6645. . "<td>本月出库</td></tr>
  6646. </table>";
  6647. $filename = $title . ".xls";
  6648. $tail = "";
  6649. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  6650. }
  6651. }
  6652. public function _whlabelexcelzh()
  6653. {
  6654. if (isset($_GET['excel'])) {
  6655. $where = "sku != 'Preset'";
  6656. //数据排序
  6657. $order_str = "id desc";
  6658. if (empty($page)) {
  6659. $start = 0;
  6660. $perpage = 1;
  6661. } else {
  6662. $start = ($page - 1) * $perpage;
  6663. }
  6664. $category = $this->input->get('category', true);
  6665. $warehouse = $this->input->get('warehouse', true);
  6666. $excelid = $this->input->get('sid', true);
  6667. if ($category) {
  6668. $where .= " and features like '%-$category-%'";
  6669. }
  6670. if ($warehouse) {
  6671. $where .= " and warehouse = '$warehouse'";
  6672. }
  6673. $xzid = '';
  6674. if ($excelid) {
  6675. $excelid = explode(',', trim($excelid, ','));
  6676. foreach ($excelid as $key => $value) {
  6677. $xzid .= " id = " . $value . " or";
  6678. }
  6679. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6680. }
  6681. //取得信息列表
  6682. /**
  6683. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6684. $rows = array();$list = array();
  6685. foreach ($info_list as $key=>$value)
  6686. {
  6687. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6688. }
  6689. **/
  6690. $list = array();
  6691. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6692. foreach ($rows as $key => $value) {
  6693. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6694. $zh = '';
  6695. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6696. foreach ($zt as $v) {
  6697. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6698. }
  6699. $zt = array_sum(array_column($zt, 'num'));
  6700. $number = $value['number'];
  6701. $ftime = time() - 15 * 24 * 3600;
  6702. $warehouse = $this->warehouse->read($value['warehouse']);
  6703. $rows[$key]['warehouse'] = $warehouse['title'];
  6704. $rows[$key]['number'] = $c;
  6705. $rows[$key]['features'] = $zh;
  6706. $rows[$key]['hb'] = $c + $zt;
  6707. }
  6708. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6709. $titlename = "<table border=1>
  6710. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6711. <tr align='center'>
  6712. <td>仓库</td>
  6713. <td>SKU</td>
  6714. <td>产品</td>
  6715. <td>库存数量</td>
  6716. <td>在途数量及预达日期</td>
  6717. <td>在途+库存数量</td>
  6718. </tr>
  6719. </table>";
  6720. $filename = $title . ".xls";
  6721. $tail = "";
  6722. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6723. }
  6724. if (isset($_GET['excel'])) {
  6725. $warehouse = $this->input->get('warehouse', true);
  6726. $sku = $this->input->get('sku', true);
  6727. $cz = $this->input->get('cz', true);
  6728. $text = $this->input->post('text', true);
  6729. $xztime = $this->input->get('xztime', true);
  6730. $timetk = $this->input->get('timetk', true);
  6731. $timetj = $this->input->get('timetj', true);
  6732. $timetk = strtotime($timetk);
  6733. $timetj = strtotime($timetj);
  6734. $where = "time = '0' ";
  6735. if ($warehouse) {
  6736. $where .= " and warehouse = '$warehouse'";
  6737. }
  6738. if ($sku) {
  6739. $where .= " and sku = '$sku'";
  6740. }
  6741. if ($text) {
  6742. $where .= " and text like '%$text%'";
  6743. }
  6744. if ($cz != '') {
  6745. $where .= " and cz = '$cz'";
  6746. }
  6747. if ($timetk && $timetj) {
  6748. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6749. }
  6750. //数据排序
  6751. $order_str = $xztime . " desc";
  6752. //取得信息列表
  6753. $zh = array();
  6754. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6755. foreach ($info_list as $v) {
  6756. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6757. $warehouse = $this->warehouse->read($v['warehouse']);
  6758. $v['warehouse'] = $warehouse['title'];
  6759. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6760. $v['stime'] = date('Y-m-d', $v['stime']);
  6761. if (isset($zh[$v['features']])) {
  6762. $zh[$v['features']]['num'] += $v['num'];
  6763. } else {
  6764. $zh[$v['features']] = $v;
  6765. }
  6766. $zh[$v['features']]['features'] = $c;
  6767. }
  6768. $title = "在途数据" . date('Y-m-d', time());
  6769. $titlename = "<table border=1>
  6770. <tr align='center'>
  6771. <td>仓库</td>
  6772. <td>SKU</td>
  6773. <td>名称</td>
  6774. <td>在途数量</td>
  6775. <td>库存数量</td>
  6776. <td>添加在途日期</td>
  6777. <td>预达日期</td>
  6778. <td>备注</td>
  6779. </tr>
  6780. </table>";
  6781. $filename = $title . ".xls";
  6782. $tail = "";
  6783. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6784. }
  6785. }
  6786. public function _fc()
  6787. {
  6788. $vip = 0;
  6789. if (isset($_SESSION['api'])) {
  6790. $user = $this->user->get_api($_SESSION['api']);
  6791. if ($user['vip'] == 1) {
  6792. $vip = 1;
  6793. }
  6794. } else {
  6795. header('Location: /');
  6796. exit;
  6797. }
  6798. $post = $this->input->post(NULL, TRUE);
  6799. if (isset($post['page'])) {
  6800. $page = $this->input->post('page', true);
  6801. $perpage = $this->input->post('perpage', true);
  6802. $category = $this->input->post('category', true);
  6803. $size = $this->input->post('size', true);
  6804. $grade = $this->input->post('grade', true);
  6805. $color = $this->input->post('color', true);
  6806. $lowe = $this->input->post('lowe', true);
  6807. $sku = $this->input->post('sku');
  6808. $title = $this->input->post('title');
  6809. $warehouse = $this->input->post('warehouse', true);
  6810. $usa = $this->input->post('usa', true);
  6811. $purchase = $this->input->post('purchase', true);
  6812. $lacetype = $this->input->post('lacetype', true);
  6813. $haircap = $this->input->post('haircap', true);
  6814. $density = $this->input->post('density', true);
  6815. $details = $this->input->post('details', true);
  6816. $state = $this->input->post('state', true);
  6817. $ktime = $this->input->post('ktime', true);
  6818. $jtime = $this->input->post('jtime', true);
  6819. $ktime = strtotime($ktime);
  6820. $jtime = strtotime($jtime);
  6821. $where = "state = '11'";
  6822. $gj = "";
  6823. $ck = "";
  6824. if ($lacetype) {
  6825. $where .= " and features like '%-$lacetype-%'";
  6826. }
  6827. if ($category) {
  6828. $where .= " and features like '%-$category-%'";
  6829. }
  6830. if ($size) {
  6831. $where .= " and features like '%-$size-%'";
  6832. }
  6833. if ($grade) {
  6834. $where .= " and features like '%-$grade-%'";
  6835. }
  6836. if ($color) {
  6837. $where .= " and features like '%-$color-%'";
  6838. }
  6839. if ($lowe) {
  6840. $where .= " and features like '%-$lowe-%'";
  6841. }
  6842. if ($haircap) {
  6843. $where .= " and features like '%-$haircap-%'";
  6844. }
  6845. if ($density) {
  6846. $where .= " and features like '%-$density-%'";
  6847. }
  6848. if ($usa) {
  6849. if (!$warehouse) {
  6850. $where .= " and (warehouse = '5' or warehouse = '8')";
  6851. }
  6852. }
  6853. if ($warehouse) {
  6854. $where .= " and warehouse = '$warehouse'";
  6855. }
  6856. if ($details) {
  6857. $where .= " and details = '$details'";
  6858. }
  6859. if ($purchase) {
  6860. $where .= " and purchase = '$purchase'";
  6861. }
  6862. if ($state) {
  6863. $where .= " and state = '$state'";
  6864. }
  6865. if ($ktime && $jtime) {
  6866. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6867. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6868. }
  6869. //数据排序
  6870. $order_str = "id desc";
  6871. if (empty($page)) {
  6872. $start = 0;
  6873. $perpage = 1;
  6874. } else {
  6875. $start = ($page - 1) * $perpage;
  6876. }
  6877. if ($sku) {
  6878. $sku = trim($sku, ' ');
  6879. $sku = trim($sku, ' ');
  6880. $where .= " and sku like '%$sku%'";
  6881. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6882. } else if ($title) {
  6883. $title = trim($title, ' ');
  6884. $title = trim($title, ' ');
  6885. $where .= " and title like '%$title%'";
  6886. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6887. } else {
  6888. //$where .= " and time > '$ktime' and time < '$jtime'";
  6889. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6890. }
  6891. //取得信息列表
  6892. $rows = array();
  6893. $list = array();
  6894. foreach ($info_list as $key => $value) {
  6895. $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'] . '"');
  6896. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6897. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6898. $warehouse = $this->warehouse->read($value['warehouse']);
  6899. $info_list[$key]['warehouse'] = $warehouse['title'];
  6900. $info_list[$key]['number'] = $g;
  6901. $info_list[$key]['features'] = $x;
  6902. $info_list[$key]['x'] = $s;
  6903. }
  6904. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6905. $pagenum = ceil($total / $perpage);
  6906. $over = $total - ($start + $perpage);
  6907. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6908. echo json_encode($rows);
  6909. exit;
  6910. }
  6911. $this->data['vip'] = $vip;
  6912. $this->_Template('whlabel_fc', $this->data);
  6913. }
  6914. public function _fcmb()
  6915. {
  6916. $where = "sku != 'Preset'";
  6917. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6918. foreach ($rows as $k => $v) {
  6919. $warehouse = $this->warehouse->read($v['warehouse']);
  6920. $rows[$k]['warehouse'] = $warehouse['title'];
  6921. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6922. $rows[$k]['t'] = '';
  6923. $rows[$k]['n'] = '';
  6924. }
  6925. $title = "封货产品数据导入模板";
  6926. $titlename = "<table border=1>
  6927. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6928. <tr align='center'>
  6929. <td>仓库</td>
  6930. <td>SKU</td>
  6931. <td>产品</td>
  6932. <td>封存产品总数量</td>
  6933. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6934. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6935. </tr>
  6936. </table>";
  6937. $filename = $title . ".xls";
  6938. $tail = "";
  6939. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6940. }
  6941. public function _fcexcel()
  6942. {
  6943. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6944. $config['upload_path'] = '.' . $dir;
  6945. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6946. $config['allowed_types'] = 'xls|xlsx|csv';
  6947. $config['max_size'] = 10240;
  6948. $this->load->library('upload', $config);
  6949. $this->upload->initialize($config);
  6950. if ($this->upload->do_upload('userfile')) {
  6951. $full_path = $dir . $this->upload->data('file_name');
  6952. $fileName = '.' . $full_path;
  6953. if (!file_exists($fileName)) {
  6954. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6955. exit;
  6956. } else {
  6957. libxml_use_internal_errors(true);
  6958. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6959. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6960. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6961. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6962. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6963. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6964. ++$column; //如果列数大于26行
  6965. $list = array();
  6966. for ($i = 2; $i <= $row; $i++) // 行数循环
  6967. {
  6968. $data = array();
  6969. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6970. {
  6971. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6972. }
  6973. $list[] = $data;
  6974. }
  6975. }
  6976. $i = 0;
  6977. $j = 0;
  6978. $ed = array();
  6979. foreach ($list as $key => $value) {
  6980. $time = time();
  6981. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6982. continue;
  6983. }
  6984. $warehouse = $this->warehouse->get_title($value['0']);
  6985. $sku = $value['1'];
  6986. $type = $value['4']; //调整方式0扣减1删除
  6987. $num = $value['5']; //调整数量
  6988. //$text = $value['4'];//扣减说明
  6989. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6990. if (!$d) //如果没有这个SKU
  6991. {
  6992. $ed[] = array($sku . '-库存中不存在此SKU');
  6993. $j++;
  6994. continue;
  6995. }
  6996. if (!isset($warehouse['id'])) {
  6997. $ed[] = array($sku . '-仓库名错误!');
  6998. $j++;
  6999. continue;
  7000. }
  7001. if ($type == 1 || $type == 2) //扣减库存
  7002. {
  7003. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7004. if (count($data) < abs($num)) {
  7005. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7006. $j++;
  7007. continue;
  7008. }
  7009. if ($type == 1) //转入库存
  7010. {
  7011. for ($i = 0; $i < abs($num); $i++) {
  7012. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7013. }
  7014. } else if ($type == 2) //删除
  7015. {
  7016. for ($i = 0; $i < abs($num); $i++) {
  7017. $this->whlabel->remove($data[$i]['id']);
  7018. }
  7019. }
  7020. } else if ($type == 0) //增加库存
  7021. {
  7022. $post['sku'] = $d['sku'];
  7023. $post['shop'] = '';
  7024. $post['warehouse'] = $warehouse['id'];
  7025. $post['purchase'] = $d['purchase'];
  7026. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7027. $post['state'] = 11;
  7028. $post['title'] = $d['title'];
  7029. $post['number'] = $d['number'];
  7030. $post['features'] = $d['features'];
  7031. $post['enter'] = $time;
  7032. $post['time'] = $time; //操作时间
  7033. for ($i = 0; $i < $num; $i++) {
  7034. $post['label'] = time() . rand(100, 999) . $i;
  7035. $this->whlabel->insert($post);
  7036. }
  7037. }
  7038. sleep(1); //防止入库时间一样,需要延迟1秒
  7039. }
  7040. if ($j > 0) {
  7041. $tt = date('Ymd', time());
  7042. $title = '库存导入错误信息-' . $tt;
  7043. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7044. $tail = "\n";
  7045. $filename = $title . ".xls";
  7046. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7047. $dir = '/data/excel/' . $time . '/';
  7048. $file_name = 'error_' . $time . rand(1000, 9999);
  7049. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7050. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7051. fwrite($myfile, $ecl);
  7052. fclose($myfile);
  7053. $error = $dir . $file_name . '.xls';
  7054. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7055. exit;
  7056. } else {
  7057. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7058. exit;
  7059. }
  7060. }
  7061. }
  7062. public function _fcjxc($arg_array)
  7063. {
  7064. if (isset($_GET['excel'])) {
  7065. $category = $this->input->get('category', true);
  7066. $size = $this->input->get('size', true);
  7067. $grade = $this->input->get('grade', true);
  7068. $color = $this->input->get('color', true);
  7069. $lowe = $this->input->get('lowe', true);
  7070. $sku = $this->input->get('sku');
  7071. $title = $this->input->get('title');
  7072. $warehouse = $arg_array[0];
  7073. $usa = $this->input->get('usa', true);
  7074. $purchase = $this->input->get('purchase', true);
  7075. $lacetype = $this->input->get('lacetype', true);
  7076. $haircap = $this->input->get('haircap', true);
  7077. $density = $this->input->get('density', true);
  7078. $title = $this->input->get('title', true);
  7079. $state = $this->input->get('state', true);
  7080. $ktime = $this->input->get('ktime', true);
  7081. $jtime = $this->input->get('jtime', true);
  7082. $where = "state=11";
  7083. $gj = "";
  7084. $ck = "";
  7085. if ($lacetype) {
  7086. $where .= " and features like '%-$lacetype-%'";
  7087. }
  7088. if ($category) {
  7089. $where .= " and features like '%-$category-%'";
  7090. }
  7091. if ($size) {
  7092. $where .= " and features like '%-$size-%'";
  7093. }
  7094. if ($grade) {
  7095. $where .= " and features like '%-$grade-%'";
  7096. }
  7097. if ($color) {
  7098. $where .= " and features like '%-$color-%'";
  7099. }
  7100. if ($lowe) {
  7101. $where .= " and features like '%-$lowe-%'";
  7102. }
  7103. if ($haircap) {
  7104. $where .= " and features like '%-$haircap-%'";
  7105. }
  7106. if ($density) {
  7107. $where .= " and features like '%-$density-%'";
  7108. }
  7109. if ($usa) {
  7110. if (!$warehouse) {
  7111. $where .= " and (warehouse = '5' or warehouse = '8')";
  7112. }
  7113. }
  7114. if ($warehouse) {
  7115. $where .= " and warehouse = '$warehouse'";
  7116. }
  7117. if ($purchase) {
  7118. $where .= " and purchase = '$purchase'";
  7119. }
  7120. if ($state) {
  7121. $where .= " and state = '$state'";
  7122. }
  7123. $order_str = "id desc";
  7124. if ($sku) {
  7125. $sku = trim($sku, ' ');
  7126. $sku = trim($sku, ' ');
  7127. $where .= " and sku like '%$sku%'";
  7128. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7129. } else if ($title) {
  7130. $title = trim($title, ' ');
  7131. $title = trim($title, ' ');
  7132. $where .= " and title like '%$title%'";
  7133. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7134. } else {
  7135. //$where .= " and time > '$ktime' and time < '$jtime'";
  7136. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7137. }
  7138. //取得信息列表
  7139. $rows = array();
  7140. $list = array();
  7141. foreach ($info_list as $key => $value) {
  7142. $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'] . '"');
  7143. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7144. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7145. $rows[$key] = $value;
  7146. $warehouse = $this->warehouse->read($value['warehouse']);
  7147. $rows[$key]['warehouse'] = $warehouse['title'];
  7148. $rows[$key]['features'] = $g;
  7149. $rows[$key]['a'] = $x;
  7150. $rows[$key]['b'] = $s;
  7151. }
  7152. $title = "总统计表";
  7153. $titlename = "<table border=1>
  7154. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7155. <tr align='center'>
  7156. <td>仓库</td>
  7157. <td>SKU</td>
  7158. <td>产品名称</td>
  7159. <td>录入总量</td>
  7160. <td>取出总量</td>
  7161. <td>剩余总量</td>
  7162. </tr>
  7163. </table>";
  7164. $filename = $title . ".xls";
  7165. $tail = "";
  7166. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7167. }
  7168. $vip = 0;
  7169. if (isset($_SESSION['api'])) {
  7170. $user = $this->user->get_api($_SESSION['api']);
  7171. if ($user['vip'] == 1) {
  7172. $vip = 1;
  7173. }
  7174. } else {
  7175. header('Location: /');
  7176. exit;
  7177. }
  7178. $post = $this->input->post(NULL, TRUE);
  7179. if (isset($post['page'])) {
  7180. $page = $this->input->post('page', true);
  7181. $perpage = $this->input->post('perpage', true);
  7182. $category = $this->input->post('category', true);
  7183. $size = $this->input->post('size', true);
  7184. $grade = $this->input->post('grade', true);
  7185. $color = $this->input->post('color', true);
  7186. $lowe = $this->input->post('lowe', true);
  7187. $sku = $this->input->post('sku');
  7188. $title = $this->input->post('title');
  7189. $warehouse = $arg_array[0];
  7190. $usa = $this->input->post('usa', true);
  7191. $purchase = $this->input->post('purchase', true);
  7192. $lacetype = $this->input->post('lacetype', true);
  7193. $haircap = $this->input->post('haircap', true);
  7194. $density = $this->input->post('density', true);
  7195. $title = $this->input->post('title', true);
  7196. $state = $this->input->post('state', true);
  7197. $ktime = $this->input->post('ktime', true);
  7198. $jtime = $this->input->post('jtime', true);
  7199. $ktime = strtotime($ktime);
  7200. $jtime = strtotime($jtime);
  7201. $where = "state=11";
  7202. $gj = "";
  7203. $ck = "";
  7204. if ($lacetype) {
  7205. $where .= " and features like '%-$lacetype-%'";
  7206. }
  7207. if ($category) {
  7208. $where .= " and features like '%-$category-%'";
  7209. }
  7210. if ($size) {
  7211. $where .= " and features like '%-$size-%'";
  7212. }
  7213. if ($grade) {
  7214. $where .= " and features like '%-$grade-%'";
  7215. }
  7216. if ($color) {
  7217. $where .= " and features like '%-$color-%'";
  7218. }
  7219. if ($lowe) {
  7220. $where .= " and features like '%-$lowe-%'";
  7221. }
  7222. if ($haircap) {
  7223. $where .= " and features like '%-$haircap-%'";
  7224. }
  7225. if ($density) {
  7226. $where .= " and features like '%-$density-%'";
  7227. }
  7228. if ($usa) {
  7229. if (!$warehouse) {
  7230. $where .= " and (warehouse = '5' or warehouse = '8')";
  7231. }
  7232. }
  7233. if ($warehouse) {
  7234. $where .= " and warehouse = '$warehouse'";
  7235. }
  7236. if ($purchase) {
  7237. $where .= " and purchase = '$purchase'";
  7238. }
  7239. if ($state) {
  7240. $where .= " and state = '$state'";
  7241. }
  7242. if ($ktime && $jtime) {
  7243. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7244. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7245. }
  7246. //数据排序
  7247. $order_str = "id desc";
  7248. $xs = 0;
  7249. $rows = array();
  7250. $list = array();
  7251. if (empty($page)) {
  7252. $start = 0;
  7253. $perpage = 1;
  7254. } else {
  7255. $start = ($page - 1) * $perpage;
  7256. }
  7257. if ($sku || $title) {
  7258. if ($title) {
  7259. $title = trim($title, ' ');
  7260. $title = trim($title, ' ');
  7261. $where .= " and title like '%$title%'";
  7262. } else {
  7263. $sku = trim($sku, ' ');
  7264. $sku = trim($sku, ' ');
  7265. $where .= " and sku like '%$sku%'";
  7266. }
  7267. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7268. foreach ($info_list as $key => $value) {
  7269. $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'] . '"');
  7270. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7271. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7272. $rows[$key] = $value;
  7273. $warehouse = $this->warehouse->read($value['warehouse']);
  7274. $rows[$key]['warehouse'] = $warehouse['title'];
  7275. $rows[$key]['features'] = $g;
  7276. $rows[$key]['a'] = $x;
  7277. $rows[$key]['b'] = $s;
  7278. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7279. $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天销量
  7280. $yj = $c / ($xl / 30);
  7281. if ($yj < 7) {
  7282. $rows[$key]['y'] = round($yj) . '天销量';
  7283. } else {
  7284. $rows[$key]['y'] = '正常';
  7285. }
  7286. }
  7287. } else {
  7288. //$where .= " and time > '$ktime' and time < '$jtime'";
  7289. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7290. foreach ($info_list as $key => $value) {
  7291. $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'] . '"');
  7292. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7293. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7294. $zs[$key] = $value;
  7295. $warehouse = $this->warehouse->read($value['warehouse']);
  7296. $zs[$key]['warehouse'] = $warehouse['title'];
  7297. $zs[$key]['features'] = $g;
  7298. $zs[$key]['a'] = $x;
  7299. $zs[$key]['b'] = $s;
  7300. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7301. $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天销量
  7302. $yj = $c / ($xl / 30);
  7303. if ($yj < 7) {
  7304. $zs[$key]['y'] = round($yj) . '天销量';
  7305. $rows[$key] = $zs[$key];
  7306. }
  7307. }
  7308. }
  7309. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7310. $pagenum = ceil($total / $perpage);
  7311. $over = $total - ($start + $perpage);
  7312. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7313. echo json_encode($rows);
  7314. exit;
  7315. }
  7316. $this->data['arg_array'] = $arg_array[0];
  7317. $this->_Template('whlabel_fcjxc', $this->data);
  7318. }
  7319. public function _0kcdel()
  7320. {
  7321. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7322. $config['upload_path'] = '.' . $dir;
  7323. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7324. $config['allowed_types'] = 'xls|xlsx|csv';
  7325. $config['max_size'] = 10240;
  7326. $this->load->library('upload', $config);
  7327. $this->upload->initialize($config);
  7328. if ($this->upload->do_upload('userfile')) {
  7329. $full_path = $dir . $this->upload->data('file_name');
  7330. $fileName = '.' . $full_path;
  7331. if (!file_exists($fileName)) {
  7332. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7333. exit;
  7334. } else {
  7335. require_once "./data/excel/PHPExcel/IOFactory.php";
  7336. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7337. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7338. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7339. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7340. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7341. ++$column; //如果列数大于26行
  7342. $list = array();
  7343. for ($i = 2; $i <= $row; $i++) // 行数循环
  7344. {
  7345. $data = array();
  7346. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7347. {
  7348. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7349. }
  7350. $list[] = $data;
  7351. }
  7352. }
  7353. $i = 0;
  7354. $j = 0;
  7355. $ed = array();
  7356. foreach ($list as $key => $value) {
  7357. $time = time();
  7358. if ($value['0'] == "" || $value['1'] == "") {
  7359. continue;
  7360. }
  7361. $warehouse = $this->warehouse->get_title($value['0']);
  7362. $sku = $value['1'];
  7363. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7364. if (!$d) //如果没有这个SKU
  7365. {
  7366. $ed[] = array($sku . '-库存中不存在此SKU');
  7367. $j++;
  7368. continue;
  7369. }
  7370. if (!isset($warehouse['id'])) {
  7371. $ed[] = array($sku . '-仓库名错误!');
  7372. $j++;
  7373. continue;
  7374. }
  7375. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7376. if ($z < 1) {
  7377. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7378. foreach ($z as $v) {
  7379. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7380. if (count($zt) > 0) {
  7381. $ed[] = array($sku . '-有在途库存无法删除!');
  7382. $j++;
  7383. continue;
  7384. }
  7385. $this->whlabel->remove($v['id']);
  7386. }
  7387. } else {
  7388. $ed[] = array($sku . '-非0库存!');
  7389. $j++;
  7390. continue;
  7391. }
  7392. }
  7393. if ($j > 0) {
  7394. $tt = date('Ymd', time());
  7395. $title = '删除0库存错误信息-' . $tt;
  7396. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7397. $tail = "\n";
  7398. $filename = $title . ".xls";
  7399. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7400. $dir = '/data/excel/' . $time . '/';
  7401. $file_name = 'error_' . $time . rand(1000, 9999);
  7402. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7403. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7404. fwrite($myfile, $ecl);
  7405. fclose($myfile);
  7406. $error = $dir . $file_name . '.xls';
  7407. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7408. exit;
  7409. } else {
  7410. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7411. exit;
  7412. }
  7413. }
  7414. }
  7415. public function _gbhtype()
  7416. {
  7417. $post = $this->input->post(NULL, TRUE);
  7418. if (isset($post['s'])) {
  7419. $n = $this->input->post('n');
  7420. $d = $this->input->post('s');
  7421. if (!$d) {
  7422. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7423. exit;
  7424. }
  7425. $d = explode(',', trim($d, ','));
  7426. $t = $this->whlabel_type->read($n);
  7427. //循环删除记录
  7428. foreach ($d as $v) {
  7429. $u = $this->whlabel->read($v);
  7430. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7431. foreach ($data as $val) {
  7432. $this->whlabel->save(array('type' => $n), $val['id']);
  7433. }
  7434. }
  7435. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7436. }
  7437. }
  7438. //出库、退库导出
  7439. public function _dccrtype()
  7440. {
  7441. $classid = $this->classid->sku();
  7442. $pm = $classid;
  7443. $typeclass = array();
  7444. $tc = $this->typeclass->find_all();
  7445. foreach ($tc as $v) {
  7446. $typeclass[$v['id']] = $v;
  7447. }
  7448. $prc = array();
  7449. $purchase = $this->purchase->find_all();
  7450. foreach ($purchase as $k => $v) {
  7451. $prc[$v['id']] = $v['title'];
  7452. }
  7453. if (isset($_GET['sid'])) {
  7454. $wh = array();
  7455. $w = $this->warehouse->find_all('1=1', 'id,title');
  7456. foreach ($w as $v) {
  7457. $wh[$v['id']] = $v['title'];
  7458. }
  7459. $type = $this->input->get('excel', true);
  7460. $category = $this->input->get('category', true);
  7461. $size = $this->input->get('size', true);
  7462. $grade = $this->input->get('grade', true);
  7463. $color = $this->input->get('color', true);
  7464. $lowe = $this->input->get('lowe', true);
  7465. $sku = $this->input->get('sku', true);
  7466. $warehouse = $this->input->get('warehouse', true);
  7467. $lacetype = $this->input->get('lacetype', true);
  7468. $lacecolor = $this->input->get('lacecolor', true);
  7469. $density = $this->input->get('density', true);
  7470. $haircap = $this->input->get('haircap', true);
  7471. $purchase = $this->input->get('purchase', true);
  7472. $title = $this->input->get('title', true);
  7473. $state = $this->input->get('state', true);
  7474. $sid = $this->input->get('sid', true);
  7475. $ktime = $this->input->get('ktime', true);
  7476. $jtime = $this->input->get('jtime', true);
  7477. $ktime = strtotime($ktime);
  7478. $jtime = strtotime($jtime);
  7479. $where = "1=1";
  7480. $gj = "";
  7481. $ck = "";
  7482. if ($category) {
  7483. $where .= " and features like '%-$category-%'";
  7484. }
  7485. if ($size) {
  7486. $where .= " and features like '%-$size-%'";
  7487. }
  7488. if ($grade) {
  7489. $where .= " and features like '%-$grade-%'";
  7490. }
  7491. if ($color) {
  7492. $where .= " and features like '%-$color-%'";
  7493. }
  7494. if ($lowe) {
  7495. $where .= " and features like '%-$lowe-%'";
  7496. }
  7497. if ($warehouse) {
  7498. $where .= " and warehouse = '$warehouse'";
  7499. }
  7500. if ($purchase) {
  7501. $where .= " and purchase = '$purchase'";
  7502. }
  7503. if ($state) {
  7504. $where .= " and state = '$state'";
  7505. }
  7506. if ($lacetype) {
  7507. $where .= " and features like '%-$lacetype-%'";
  7508. }
  7509. if ($lacecolor) {
  7510. $where .= " and features like '%-$lacecolor-%'";
  7511. }
  7512. if ($density) {
  7513. $where .= " and features like '%-$density-%'";
  7514. }
  7515. if ($haircap) {
  7516. $where .= " and features like '%-$haircap-%'";
  7517. }
  7518. if ($title) {
  7519. $title = trim($title, ' ');
  7520. $title = trim($title, ' ');
  7521. $where .= " and title like '%$title%'";
  7522. }
  7523. if ($sku) {
  7524. $sku = trim($sku, ' ');
  7525. $sku = trim($sku, ' ');
  7526. $where .= " and sku like '%$sku%'";
  7527. }
  7528. if ($ktime && $jtime) {
  7529. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7530. }
  7531. $sidwhere = '';
  7532. if ($sid) {
  7533. $sd = "";
  7534. $s = explode(',', trim($sid, ','));
  7535. foreach ($s as $value) {
  7536. $sd .= " id = " . $value . " or";
  7537. }
  7538. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7539. }
  7540. //数据排序
  7541. $order_str = "time desc";
  7542. if (empty($page)) {
  7543. $start = 0;
  7544. $perpage = 1;
  7545. } else {
  7546. $start = ($page - 1) * $perpage;
  7547. }
  7548. $wh = array();
  7549. $w = $this->warehouse->find_all('1=1', 'id,title');
  7550. foreach ($w as $v) {
  7551. $wh[$v['id']] = $v['title'];
  7552. }
  7553. $wt = array();
  7554. $whlabel_type = $this->whlabel_type->find_all();
  7555. foreach ($whlabel_type as $v) {
  7556. $wt[$v['id']] = $v['title'];
  7557. }
  7558. $classid = $this->classid->sku();
  7559. $list = array();
  7560. $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');
  7561. foreach ($rows_r as $key => $value) {
  7562. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7563. $pm = $classid;
  7564. $jm = $classid;
  7565. $rows_r[$key]['enter'] = '入库';
  7566. $rows_r[$key]['time'] = $value['enter'];
  7567. if ($value['rktype'] == 1) {
  7568. $rows_r[$key]['rktype'] = '采购入库';
  7569. } else if ($value['rktype'] == 2) {
  7570. $rows_r[$key]['rktype'] = '盘盈调整';
  7571. } else if ($value['rktype'] == 3) {
  7572. $rows_r[$key]['rktype'] = '其他调整入库';
  7573. } else if ($value['rktype'] == 4) {
  7574. $rows_r[$key]['rktype'] = '其他调整入库';
  7575. } else if ($value['rktype'] == 5) {
  7576. $rows_r[$key]['rktype'] = '退库入库';
  7577. } else if ($value['rktype'] == 6) {
  7578. $rows_r[$key]['rktype'] = '退货可用入库';
  7579. } else if ($value['rktype'] == 7) {
  7580. $rows_r[$key]['rktype'] = '形态转换入库';
  7581. } else {
  7582. $rows_r[$key]['rktype'] = '';
  7583. }
  7584. $features = explode('-', trim($value['features'], '-'));
  7585. foreach ($features as $v) {
  7586. if (isset($typeclass[$v])) {
  7587. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7588. $pm[$typeclass[$v]['classid']] = $zh[0];
  7589. }
  7590. if (isset($typeclass[$v])) {
  7591. if (isset($jm[$typeclass[$v]['classid']])) {
  7592. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7593. }
  7594. }
  7595. }
  7596. $zh = implode(" ", $pm);
  7597. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7598. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7599. $rows_r[$key]['zh'] = $zh;
  7600. $jm = array_filter($jm);
  7601. $rows_r[$key]['features'] = implode("-", $jm);
  7602. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7603. }
  7604. $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');
  7605. foreach ($rows_c as $key => $value) {
  7606. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7607. $pm = $classid;
  7608. $jm = $classid;
  7609. $rows_c[$key]['time'] = $value['outk'];
  7610. $rows_c[$key]['outk'] = '出库';
  7611. if ($value['cktype'] == 1) {
  7612. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7613. } else if ($value['cktype'] == 2) {
  7614. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7615. } else if ($value['cktype'] == 3) {
  7616. $rows_c[$key]['cktype'] = '盘亏调整';
  7617. } else if ($value['cktype'] == 4) {
  7618. $rows_c[$key]['cktype'] = '其他调整出库';
  7619. } else if ($value['cktype'] == 5) {
  7620. $rows_c[$key]['cktype'] = '形态转换出库';
  7621. } else {
  7622. $rows_c[$key]['cktype'] = '';
  7623. }
  7624. unset($rows_c[$key]['state']);
  7625. $features = explode('-', trim($value['features'], '-'));
  7626. foreach ($features as $v) {
  7627. if (isset($typeclass[$v])) {
  7628. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7629. $pm[$typeclass[$v]['classid']] = $zh[0];
  7630. }
  7631. if (isset($typeclass[$v])) {
  7632. if (isset($jm[$typeclass[$v]['classid']])) {
  7633. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7634. }
  7635. }
  7636. }
  7637. $zh = implode(" ", $pm);
  7638. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7639. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7640. $rows_c[$key]['zh'] = $zh;
  7641. $jm = array_filter($jm);
  7642. $rows_c[$key]['features'] = implode("-", $jm);
  7643. $rows_c[$key]['number'] = 1;
  7644. }
  7645. $merged = $rows_r;
  7646. foreach ($rows_c as $key => $value) {
  7647. if (isset($merged[$key])) {
  7648. $merged[] = $value;
  7649. } else {
  7650. $merged[$key] = $value;
  7651. }
  7652. }
  7653. usort($merged, function ($a, $b) {
  7654. return $a['time'] - $b['time'];
  7655. });
  7656. foreach ($merged as $key => $value) {
  7657. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7658. }
  7659. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7660. $titlename = "<table border=1>
  7661. <tr align='center'>
  7662. <td>仓库</td>
  7663. <td>SKU</td>
  7664. <td>商品名称</td>
  7665. <td>仓库品名</td>
  7666. <td>料号</td>
  7667. <td>时间</td>
  7668. <td>操作</td>
  7669. <td>类型</td>
  7670. <td>数量</td>
  7671. <td>备注</td>
  7672. </tr>
  7673. </table>";
  7674. $filename = $title . ".xlsx";
  7675. $tail = "";
  7676. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  7677. }
  7678. }
  7679. /*************************************处理exceljs导出****************************************************/
  7680. public function _excelrjs(){
  7681. if (isset($_GET['excel'])) {
  7682. $category = $this->input->get('category', true);
  7683. $size = $this->input->get('size', true);
  7684. $grade = $this->input->get('grade', true);
  7685. $color = $this->input->get('color', true);
  7686. $lowe = $this->input->get('lowe', true);
  7687. $sku = $this->input->get('sku', true);
  7688. $warehouse = $this->input->get('warehouse', true);
  7689. $purchase = $this->input->get('purchase', true);
  7690. $ktime = $this->input->get('ktime', true);
  7691. $jtime = $this->input->get('jtime', true);
  7692. $ktime = strtotime($ktime);
  7693. $jtime = strtotime($jtime);
  7694. $where = "1=1";
  7695. $gj = "";
  7696. $ck = "";
  7697. if ($category) {
  7698. $where .= " and features like '%-$category-%'";
  7699. }
  7700. if ($size) {
  7701. $where .= " and features like '%-$size-%'";
  7702. }
  7703. if ($grade) {
  7704. $where .= " and features like '%-$grade-%'";
  7705. }
  7706. if ($color) {
  7707. $where .= " and features like '%-$color-%'";
  7708. }
  7709. if ($lowe) {
  7710. $where .= " and features like '%-$lowe-%'";
  7711. }
  7712. if ($warehouse) {
  7713. $where .= " and warehouse = '$warehouse'";
  7714. }
  7715. if ($purchase) {
  7716. $where .= " and purchase = '$purchase'";
  7717. }
  7718. if ($sku) {
  7719. $where .= " and sku = '$sku'";
  7720. }
  7721. if ($ktime && $jtime) {
  7722. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7723. }
  7724. //数据排序
  7725. $order_str = "id desc";
  7726. if (empty($page)) {
  7727. $start = 0;
  7728. $perpage = 1;
  7729. } else {
  7730. $start = ($page - 1) * $perpage;
  7731. }
  7732. $list = array();
  7733. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7734. foreach ($rows as $value) {
  7735. $ck = $this->warehouse->read($value['warehouse']);
  7736. $warehouse = $ck['title'];
  7737. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7738. $retreatwarehouse = $tkck['title'];
  7739. $gy = $this->purchase->read($value['purchase']);
  7740. $purchase = $gy['title'];
  7741. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7742. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7743. }
  7744. if(empty($list)){
  7745. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7746. }else{
  7747. $final_list = [];
  7748. foreach($list as $v){
  7749. $final_list[] = array_values($v);
  7750. }
  7751. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7752. array_unshift($final_list,[
  7753. "仓库","SKU","商品名称","时间","数量"
  7754. ]);
  7755. array_unshift($final_list,[
  7756. $title,"","","",""
  7757. ]);
  7758. $merges = [
  7759. [
  7760. "s"=>["r"=>0,"c"=>0],
  7761. "e"=>["r"=>0,"c"=>4]
  7762. ]
  7763. ];
  7764. $cols = [
  7765. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7766. ];
  7767. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7768. }
  7769. }
  7770. }
  7771. //出库、退库导出
  7772. public function _excelctjs()
  7773. {
  7774. $classid = $this->classid->sku();
  7775. $pm = $classid;
  7776. $typeclass = array();
  7777. $tc = $this->typeclass->find_all();
  7778. foreach ($tc as $v) {
  7779. $typeclass[$v['id']] = $v;
  7780. }
  7781. $prc = array();
  7782. $purchase = $this->purchase->find_all();
  7783. foreach ($purchase as $k => $v) {
  7784. $prc[$v['id']] = $v['title'];
  7785. }
  7786. if (isset($_GET['excel'])) {
  7787. $wh = array();
  7788. $w = $this->warehouse->find_all('1=1', 'id,title');
  7789. foreach ($w as $v) {
  7790. $wh[$v['id']] = $v['title'];
  7791. }
  7792. $type = $this->input->get('excel', true);
  7793. $category = $this->input->get('category', true);
  7794. $size = $this->input->get('size', true);
  7795. $grade = $this->input->get('grade', true);
  7796. $color = $this->input->get('color', true);
  7797. $lowe = $this->input->get('lowe', true);
  7798. $sku = $this->input->get('sku', true);
  7799. $title = $this->input->get('title', true);
  7800. $warehouse = $this->input->get('warehouse', true);
  7801. $purchase = $this->input->get('purchase', true);
  7802. $lacetype = $this->input->get('lacetype', true);
  7803. $haircap = $this->input->get('haircap', true);
  7804. $lacecolor = $this->input->get('lacecolor', true);
  7805. $density = $this->input->get('density', true);
  7806. $details = $this->input->get('details', true);
  7807. $state = $this->input->get('state', true);
  7808. $shop = $this->input->get('shop', true);
  7809. $hairnumber = $this->input->get('hairnumber', true);
  7810. $type_leixi = $this->input->get('type', true);
  7811. $cpbz = $this->input->get('cpbz', true);
  7812. $sm = $this->input->get('sm', true);
  7813. $sid = $this->input->get('sid', true);
  7814. $ktime = $this->input->get('ktime', true);
  7815. $jtime = $this->input->get('jtime', true);
  7816. $ktime = strtotime($ktime);
  7817. $jtime = strtotime($jtime);
  7818. //$where = " 1=1 ";
  7819. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7820. $where = " sku != '' ";
  7821. $gj = "";
  7822. $ck = "";
  7823. if ($category) {
  7824. $where .= " and features like '%-$category-%'";
  7825. }
  7826. if ($size) {
  7827. $where .= " and features like '%-$size-%'";
  7828. }
  7829. if ($grade) {
  7830. $where .= " and features like '%-$grade-%'";
  7831. }
  7832. if ($color) {
  7833. $where .= " and features like '%-$color-%'";
  7834. }
  7835. if ($lowe) {
  7836. $where .= " and features like '%-$lowe-%'";
  7837. }
  7838. if ($warehouse) {
  7839. $where .= " and warehouse = '$warehouse'";
  7840. }
  7841. if ($purchase) {
  7842. $where .= " and purchase = '$purchase'";
  7843. }
  7844. if ($state) {
  7845. $where .= " and state = '$state'";
  7846. }
  7847. if ($lacetype) {
  7848. $where .= " and features like '%-$lacetype-%'";
  7849. }
  7850. if ($lacecolor) {
  7851. $where .= " and features like '%-$lacecolor-%'";
  7852. }
  7853. if ($density) {
  7854. $where .= " and features like '%-$density-%'";
  7855. }
  7856. if ($haircap) {
  7857. $where .= " and features like '%-$haircap-%'";
  7858. }
  7859. if ($details) {
  7860. $where .= " and details = '$details'";
  7861. }
  7862. if ($shop) {
  7863. $where .= " and shop like '%$shop%'";
  7864. }
  7865. if ($title) {
  7866. $title = trim($title, ' ');
  7867. $title = trim($title, ' ');
  7868. $where .= " and title like '%$title%'";
  7869. }
  7870. if (!empty($hairnumber)) {
  7871. $where .= " and features like '%-128-%' ";
  7872. if ($hairnumber < 0) {
  7873. $class_list = $this->typeclass->find_all('classid = 43');
  7874. foreach ($class_list as $v) {
  7875. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7876. }
  7877. } else {
  7878. $where .= " and features like '%-$hairnumber-%'";
  7879. }
  7880. }
  7881. if ($type_leixi) {
  7882. $where .= " and type = '$type_leixi'";
  7883. }
  7884. if ($cpbz) {
  7885. $where .= " and cpbz like '%$cpbz%' ";
  7886. }
  7887. if ($sm) {
  7888. $where .= " and sm like '%$sm%' ";
  7889. }
  7890. if ($sku) {
  7891. $sku = trim($sku, ' ');
  7892. $sku = trim($sku, ' ');
  7893. $where .= " and sku like '%$sku%'";
  7894. }
  7895. if ($ktime && $jtime) {
  7896. if ($type == 1) {
  7897. $tl = '出库';
  7898. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7899. } else if ($type == 2) {
  7900. $tl = '退库';
  7901. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7902. } else if ($type == 3) {
  7903. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7904. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7905. } else if ($type == 4) {
  7906. $tl = '出库+零售';
  7907. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7908. } else if ($type == 5) {
  7909. $tl = '零售';
  7910. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7911. }
  7912. }
  7913. $sidwhere = '';
  7914. if ($sid) {
  7915. $sd = "";
  7916. $s = explode(',', trim($sid, ','));
  7917. foreach ($s as $value) {
  7918. $sd .= " id = " . $value . " or";
  7919. }
  7920. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7921. }
  7922. //数据排序
  7923. $order_str = "time desc";
  7924. if (empty($page)) {
  7925. $start = 0;
  7926. $perpage = 1;
  7927. } else {
  7928. $start = ($page - 1) * $perpage;
  7929. }
  7930. //取得信息列表
  7931. if ($type != 3 && $type != 5) {
  7932. if ($type == 1 || $type == 4) {
  7933. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7934. foreach ($info_list as $key => $value) {
  7935. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7936. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7937. $warehouse = $this->warehouse->read($value['warehouse']);
  7938. $info_list[$key]['warehouse'] = $warehouse['title'];
  7939. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7940. $features = explode('-', trim($features, '-'));
  7941. $pm = $classid;
  7942. foreach ($features as $k => $v) {
  7943. if ($v != 0) {
  7944. if (!isset($typeclass[$v])) {
  7945. continue;
  7946. }
  7947. if (isset($pm[$typeclass[$v]['classid']])) {
  7948. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7949. $tz = explode('|', $typeclass[$v]['zh']);
  7950. $pm[$typeclass[$v]['classid']] = $tz[0];
  7951. } else {
  7952. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7953. }
  7954. }
  7955. }
  7956. }
  7957. $zh = implode(" ", $pm);
  7958. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7959. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7960. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7961. $info_list[$key]['features'] = $zh;
  7962. }
  7963. $final_list = [];
  7964. foreach($info_list as $k=>$v){
  7965. $number = "";
  7966. if(!empty($v['orderinfo'])){
  7967. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7968. if(!empty($tmp_info['number'])){
  7969. $number = $tmp_info['number'];
  7970. }
  7971. }
  7972. $final_list[] = [
  7973. 'warehouse'=>$v['warehouse'],
  7974. 'purchase'=>$v['purchase'],
  7975. 'sku'=>$v['sku'],
  7976. 'title'=>$v['title'],
  7977. 'features'=>$v['features'],
  7978. 'label'=>$v['label'],
  7979. 'orderinfo'=>$v['orderinfo'],
  7980. 'number'=>$number,
  7981. 'waybill'=>$v['waybill'],
  7982. 'outk'=>$v['outk'],
  7983. ];
  7984. }
  7985. } else {
  7986. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7987. foreach ($info_list as $key => $value) {
  7988. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7989. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7990. $warehouse = $this->warehouse->read($value['warehouse']);
  7991. $info_list[$key]['warehouse'] = $warehouse['title'];
  7992. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7993. $features = explode('-', trim($features, '-'));
  7994. $pm = $classid;
  7995. foreach ($features as $k => $v) {
  7996. if ($v != 0) {
  7997. if (!isset($typeclass[$v])) {
  7998. continue;
  7999. }
  8000. if (isset($pm[$typeclass[$v]['classid']])) {
  8001. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8002. $tz = explode('|', $typeclass[$v]['zh']);
  8003. $pm[$typeclass[$v]['classid']] = $tz[0];
  8004. } else {
  8005. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8006. }
  8007. }
  8008. }
  8009. }
  8010. $zh = implode(" ", $pm);
  8011. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8012. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8013. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8014. $info_list[$key]['features'] = $zh;
  8015. }
  8016. $final_list = [];
  8017. foreach($info_list as $k=>$v){
  8018. $number = "";
  8019. if(!empty($v['orderinfo'])){
  8020. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8021. if(!empty($tmp_info['number'])){
  8022. $number = $tmp_info['number'];
  8023. }
  8024. }
  8025. $final_list[] = [
  8026. 'warehouse'=>$v['warehouse'],
  8027. 'purchase'=>$v['purchase'],
  8028. 'sku'=>$v['sku'],
  8029. 'title'=>$v['title'],
  8030. 'features'=>$v['features'],
  8031. 'label'=>$v['label'],
  8032. 'orderinfo'=>$v['orderinfo'],
  8033. 'number'=>$number,
  8034. 'waybill'=>$v['waybill'],
  8035. 'retreat'=>$v['retreat'],
  8036. ];
  8037. }
  8038. }
  8039. if(empty($final_list)){
  8040. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8041. }else{
  8042. $end_list = [];
  8043. foreach($final_list as $v){
  8044. $end_list[] = array_values($v);
  8045. }
  8046. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8047. array_unshift($end_list,[
  8048. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8049. ]);
  8050. array_unshift($end_list,[
  8051. $title,"","","","","","","","",""
  8052. ]);
  8053. $merges = [
  8054. [
  8055. "s"=>["r"=>0,"c"=>0],
  8056. "e"=>["r"=>0,"c"=>9]
  8057. ]
  8058. ];
  8059. $cols = [
  8060. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8061. ];
  8062. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8063. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8064. ] )));
  8065. }
  8066. } else if ($type == 5) {
  8067. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8068. foreach ($info_list as $key => $value) {
  8069. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8070. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8071. $warehouse = $this->warehouse->read($value['warehouse']);
  8072. $info_list[$key]['warehouse'] = $warehouse['title'];
  8073. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8074. $features = explode('-', trim($features, '-'));
  8075. $pm = $classid;
  8076. foreach ($features as $k => $v) {
  8077. if ($v != 0) {
  8078. if (!isset($typeclass[$v])) {
  8079. continue;
  8080. }
  8081. if (isset($pm[$typeclass[$v]['classid']])) {
  8082. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8083. $tz = explode('|', $typeclass[$v]['zh']);
  8084. $pm[$typeclass[$v]['classid']] = $tz[0];
  8085. } else {
  8086. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8087. }
  8088. }
  8089. }
  8090. }
  8091. $zh = implode(" ", $pm);
  8092. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8093. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8094. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8095. $info_list[$key]['features'] = $zh;
  8096. }
  8097. if(empty($info_list)){
  8098. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8099. }else{
  8100. $final_list = [];
  8101. foreach($info_list as $v){
  8102. $final_list[] = array_values($v);
  8103. }
  8104. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8105. array_unshift($final_list,[
  8106. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8107. ]);
  8108. array_unshift($final_list,[
  8109. $title,"","","","","","",
  8110. ]);
  8111. $merges = [
  8112. [
  8113. "s"=>["r"=>0,"c"=>0],
  8114. "e"=>["r"=>0,"c"=>6]
  8115. ]
  8116. ];
  8117. $cols = [
  8118. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8119. ];
  8120. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8121. }
  8122. } else {
  8123. $wh = array();
  8124. $w = $this->warehouse->find_all('1=1', 'id,title');
  8125. foreach ($w as $v) {
  8126. $wh[$v['id']] = $v['title'];
  8127. }
  8128. $wt = array();
  8129. $whlabel_type = $this->whlabel_type->find_all();
  8130. foreach ($whlabel_type as $v) {
  8131. $wt[$v['id']] = $v['title'];
  8132. }
  8133. $classid = $this->classid->sku();
  8134. $list = array();
  8135. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8136. foreach ($rows as $key => $value) {
  8137. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8138. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8139. $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');
  8140. $details = array();
  8141. $cpid = array();
  8142. $cpbz = array();
  8143. $c = 0;
  8144. $g = 0;
  8145. $x = 0;
  8146. $t = 0;
  8147. $s = 0;
  8148. $q = 0;
  8149. foreach ($sd as $k => $v) {
  8150. if ($v['state'] == 0) {
  8151. $c++;
  8152. }
  8153. if ($v['state'] != 9) {
  8154. $g++;
  8155. }
  8156. if ($v['outk'] > 1) {
  8157. $x++;
  8158. }
  8159. if ($v['retreat'] > 0) {
  8160. $t++;
  8161. }
  8162. if ($v['state'] == 8) {
  8163. $s++;
  8164. }
  8165. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8166. $q++;
  8167. }
  8168. $details[$v['details']] = $v['details'];
  8169. if ($v['cpid'] != 0) {
  8170. $cpid[$v['cpid']] = $v['cpid'];
  8171. }
  8172. if ($v['cpbz'] != '') {
  8173. $cpbz[$v['cpbz']] = $v['cpbz'];
  8174. }
  8175. }
  8176. if (isset($wt[$value['type']])) {
  8177. $rows[$key]['type'] = $wt[$value['type']];
  8178. } else {
  8179. $rows[$key]['type'] = '未设置';
  8180. }
  8181. $rows[$key]['details'] = implode("、", $details);
  8182. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8183. $ftime = time() - 15 * 24 * 3600;
  8184. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8185. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8186. $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);
  8187. $rows[$key]['c'] = $c;
  8188. $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);
  8189. $rows[$key]['t'] = $t;
  8190. $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'] . '"');
  8191. $rows[$key]['z'] = $z;
  8192. // $jm = $classid;
  8193. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8194. $features = explode('-', trim($features, '-'));
  8195. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8196. }
  8197. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8198. $final_list =[];
  8199. foreach($tmp_list as $k=>$v){
  8200. $final_list[] = [
  8201. "warehouse"=>$v['warehouse'],
  8202. "purchase"=>$v['purchase'],
  8203. "details"=>$v['details'],
  8204. "cpid"=>$v['cpid'],
  8205. "sku"=>$v['sku'],
  8206. "title"=>$v['title'],
  8207. "features"=>$v['pm'],
  8208. "cpbz"=>$v['cpbz'],
  8209. "sm"=>$v['sm'],
  8210. "type"=>$v['type'],
  8211. "g"=>$v["g"],
  8212. "c"=>$v["c"],
  8213. "x"=>$v["x"],
  8214. "t"=>$v["t"],
  8215. "z"=>$v["z"],
  8216. "jm"=>$v["jm"],
  8217. "weight"=>$v["weight"],
  8218. "asd"=>$v["asd"],
  8219. ];
  8220. }
  8221. if(empty($final_list)){
  8222. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8223. }else{
  8224. $end_list = [];
  8225. foreach($final_list as $v){
  8226. $end_list[] = array_values($v);
  8227. }
  8228. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8229. array_unshift($end_list,[
  8230. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8231. ]);
  8232. array_unshift($end_list,[
  8233. $title,"","","","","","","","","","","","","","","","","",""
  8234. ]);
  8235. $merges = [
  8236. [
  8237. "s"=>["r"=>0,"c"=>0],
  8238. "e"=>["r"=>0,"c"=>6]
  8239. ]
  8240. ];
  8241. $cols = [
  8242. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8243. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8244. ];
  8245. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8246. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8247. ])));
  8248. }
  8249. }
  8250. }
  8251. }
  8252. public function _exceljxcjs(){
  8253. $classid = $this->classid->sku();
  8254. $pm = $classid;
  8255. $typeclass = array();
  8256. $tc = $this->typeclass->find_all();
  8257. foreach ($tc as $v) {
  8258. $typeclass[$v['id']] = $v;
  8259. }
  8260. $prc = array();
  8261. $purchase = $this->purchase->find_all();
  8262. foreach ($purchase as $k => $v) {
  8263. $prc[$v['id']] = $v['title'];
  8264. }
  8265. if(!isset($_GET['excel'])){
  8266. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8267. }
  8268. $where = "sku != 'Preset'";
  8269. //数据排序
  8270. $order_str = "id desc";
  8271. if (empty($page)) {
  8272. $start = 0;
  8273. $perpage = 1;
  8274. } else {
  8275. $start = ($page - 1) * $perpage;
  8276. }
  8277. $category = $this->input->get('category', true);
  8278. $warehouse = $this->input->get('warehouse', true);
  8279. $excelid = $this->input->get('sid', true);
  8280. if ($category) {
  8281. $where .= " and features like '%-$category-%'";
  8282. }
  8283. if ($warehouse) {
  8284. $where .= " and warehouse = '$warehouse'";
  8285. }
  8286. $xzid = '';
  8287. if ($excelid) {
  8288. $excelid = explode(',', trim($excelid, ','));
  8289. foreach ($excelid as $key => $value) {
  8290. $xzid .= " id = " . $value . " or";
  8291. }
  8292. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8293. }
  8294. $wt = array();
  8295. $whlabel_type = $this->whlabel_type->find_all();
  8296. foreach ($whlabel_type as $v) {
  8297. $wt[$v['id']] = $v['title'];
  8298. }
  8299. $wh = array();
  8300. $w = $this->warehouse->find_all('1=1', 'id,title');
  8301. foreach ($w as $v) {
  8302. $wh[$v['id']] = $v['title'];
  8303. }
  8304. $list = array();
  8305. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8306. foreach ($rows as $key => $value) {
  8307. if (isset($wt[$value['type']])) {
  8308. $rows[$key]['type'] = $wt[$value['type']];
  8309. } else {
  8310. $rows[$key]['type'] = '未设置';
  8311. }
  8312. $bm = '03';
  8313. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8314. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8315. $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');
  8316. $details = array();
  8317. $cpid = array();
  8318. $cpbz = array();
  8319. $c = 0;
  8320. $g = 0;
  8321. $x = 0;
  8322. $t = 0;
  8323. $s = 0;
  8324. $q = 0;
  8325. foreach ($sd as $k => $v) {
  8326. if ($v['state'] == 0) {
  8327. $c++;
  8328. if ($v['cpid'] != 0) {
  8329. $cpid[$v['cpid']] = $v['cpid'];
  8330. }
  8331. if ($v['cpbz'] != '') {
  8332. $cpbz[$v['cpbz']] = $v['cpbz'];
  8333. }
  8334. }
  8335. if ($v['state'] != 9) {
  8336. $g++;
  8337. }
  8338. if ($v['state'] == 1) {
  8339. $x++;
  8340. }
  8341. if ($v['state'] == 2) {
  8342. $t++;
  8343. }
  8344. if ($v['state'] == 8) {
  8345. $s++;
  8346. }
  8347. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8348. $q++;
  8349. }
  8350. $details[$v['details']] = $v['details'];
  8351. }
  8352. $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'] . '"');
  8353. $rows[$key]['details'] = implode("、", $details);
  8354. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8355. $number = $value['number'];
  8356. $ftime = time() - 15 * 24 * 3600;
  8357. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8358. $rows[$key]['number'] = $g;
  8359. $rows[$key]['c'] = $c;
  8360. $rows[$key]['x'] = $x;
  8361. $rows[$key]['t'] = $t;
  8362. $rows[$key]['s'] = $s;
  8363. $rows[$key]['q'] = $q;
  8364. $rows[$key]['z'] = $z;
  8365. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8366. $features = explode('-', trim($features, '-'));
  8367. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8368. }
  8369. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8370. $final_list = [];
  8371. foreach ($list as $k => $v) {
  8372. if (empty($v['sku'])) {
  8373. continue;
  8374. }
  8375. $final_list[] = [
  8376. $v["warehouse"],
  8377. $v["purchase"],
  8378. $v["details"],
  8379. $v["cpid"],
  8380. $v["dbcontent"],
  8381. $v["sku"],
  8382. $v["bm"],
  8383. $v["jm"],
  8384. $v["title"],
  8385. $v["pm"],
  8386. $v["cpbz"],
  8387. $v["sm"],
  8388. $v["type"],
  8389. $v["number"],
  8390. $v["c"],
  8391. $v["x"],
  8392. $v["t"],
  8393. $v["s"],
  8394. $v["q"],
  8395. $v["z"],
  8396. $v['weight'],
  8397. ];
  8398. }
  8399. if(empty($final_list)){
  8400. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8401. }
  8402. $title = "总进销存统计表";
  8403. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8404. $merges = [
  8405. [
  8406. "s"=>["r"=>0,"c"=>0],
  8407. "e"=>["r"=>0,"c"=>21]
  8408. ]
  8409. ];
  8410. $cols = [
  8411. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8412. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8413. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8414. ];
  8415. array_unshift($final_list, $first_row);
  8416. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8417. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8418. }
  8419. public function _summaryjs($arg_array)
  8420. {
  8421. $prc = array();
  8422. $purchase = $this->purchase->find_all();
  8423. foreach ($purchase as $k => $v) {
  8424. $prc[$v['id']] = $v['title'];
  8425. }
  8426. if (isset($_GET['excel'])) {
  8427. $ktime = $this->input->get('ktime', true);
  8428. $jtime = $this->input->get('jtime', true);
  8429. $ktime = strtotime($ktime);
  8430. $jtime = strtotime($jtime);
  8431. $where = "1=1";
  8432. if ($ktime && $jtime) {
  8433. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8434. }
  8435. //数据排序
  8436. $order_str = "time desc";
  8437. if (empty($page)) {
  8438. $start = 0;
  8439. $perpage = 1;
  8440. } else {
  8441. $start = ($page - 1) * $perpage;
  8442. }
  8443. //取得信息列表
  8444. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8445. foreach ($info_list as $key => $value) {
  8446. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8447. $warehouse = $this->warehouse->read($value['warehouse']);
  8448. $info_list[$key]['warehouse'] = $warehouse['title'];
  8449. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8450. $details = array();
  8451. $cpid = array();
  8452. foreach ($x as $k => $v) {
  8453. if ($v['details'] != '') {
  8454. $details[$v['details']] = $v['details'];
  8455. }
  8456. if ($v['cpid'] != 0) {
  8457. $cpid[$v['cpid']] = $v['cpid'];
  8458. }
  8459. }
  8460. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8461. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8462. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8463. $info_list[$key]['s'] = $s;
  8464. $info_list[$key]['x'] = count($x);
  8465. }
  8466. if(empty($info_list)){
  8467. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8468. }
  8469. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8470. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8471. $merges = [
  8472. [
  8473. "s"=>["r"=>0,"c"=>0],
  8474. "e"=>["r"=>0,"c"=>7]
  8475. ]
  8476. ];
  8477. $cols = [
  8478. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8479. ];
  8480. $final_list = [];
  8481. foreach($info_list as $k => $v){
  8482. $final_list[] = array_values($v);
  8483. }
  8484. array_unshift($final_list, $first_row);
  8485. array_unshift($final_list,[
  8486. $title,"","","","","","","","",
  8487. ]);
  8488. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8489. $titlename = "<table border=1>
  8490. <tr align='center'>
  8491. <td>仓库</td>
  8492. <td>供应商</td>
  8493. <td>出库位置</td>
  8494. <td>出库编码</td>
  8495. <td>SKU</td>
  8496. <td>产品名</td>
  8497. <td>总剩余库存</td>
  8498. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8499. </tr>
  8500. </table>";
  8501. $filename = $title . ".xls";
  8502. $tail = "";
  8503. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8504. }
  8505. }
  8506. public function _uckjs()
  8507. {
  8508. if (isset($_GET['excel'])) {
  8509. $tc = array();
  8510. $typeclass = $this->typeclass->find_all();
  8511. foreach ($typeclass as $v) {
  8512. $tc[$v['id']] = $v['zh'];
  8513. }
  8514. $first_row = [
  8515. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8516. ];
  8517. $t = array();
  8518. $rq = '';
  8519. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8520. $ts = $ts / (24 * 3600);
  8521. for ($i = 0; $i < $ts; $i++) {
  8522. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8523. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8524. }
  8525. $day_len = count($t);
  8526. $first_row[] = "本月出库";
  8527. $merges = [
  8528. ];
  8529. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8530. $excel_key = 1;
  8531. $final_list = [];
  8532. foreach ($info_list as $k => $v) {
  8533. $features = explode('-', trim($v['features'], '-'));
  8534. if (!isset($features[3]) || !isset($features[4])) {
  8535. continue;
  8536. }
  8537. $tmp = [];
  8538. $tmp[0] = $tc[$features[0]]; //类型
  8539. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8540. $tmp[2] = $tc[$features[4]]; //曲度
  8541. $tmp[3] = '';
  8542. if (isset($data[$k][1])) {
  8543. $tmp[3] .=$tmp[1];
  8544. }
  8545. if (isset($data[$k][2])) {
  8546. $tmp[3] .= $tmp[2];
  8547. }
  8548. if (isset($features[5])) {
  8549. $tmp[3] .= $tc[$features[5]];
  8550. }
  8551. if (isset($features[2])) {
  8552. $tmp[3] .= $tc[$features[2]];
  8553. }
  8554. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8555. $tmp[4] = $v['sku'];
  8556. $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())) . '))'); //月初库存
  8557. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8558. $tmp[7] ="";
  8559. $tmp[8] ="";
  8560. $byck = 0;
  8561. foreach ($t as $vv) {
  8562. $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));
  8563. $tmp[] = ($sl > 0) ? $sl : '';
  8564. $byck += $sl;
  8565. }
  8566. $tmp[] = ($byck > 0) ? $byck : '';
  8567. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8568. // $ztrq = '';
  8569. // $ztsl = '';
  8570. // if (count($zt) > 0) {
  8571. // foreach ($zt as $vv) {
  8572. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8573. // $ztsl .= $vv['num'] . '<br>';
  8574. // }
  8575. // }
  8576. if(empty($zt)){
  8577. $final_list[] = $tmp;
  8578. $excel_key = $excel_key + 1;
  8579. }else{
  8580. $len = count($zt);
  8581. if($len == 1){
  8582. $tmp[7] = $zt[0]['num'] ;
  8583. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8584. $final_list[] = $tmp;
  8585. $excel_key = $excel_key + 1;
  8586. }else{
  8587. foreach($zt as $vv){
  8588. $tmp[7] = "";
  8589. $tmp[8] = "";
  8590. $tmp[7] = $vv['num'];
  8591. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8592. $final_list[] = $tmp;
  8593. }
  8594. $merges[] = [
  8595. "s"=>["r"=>$excel_key,"c"=>0],
  8596. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8597. ];
  8598. $merges[] = [
  8599. "s"=>["r"=>$excel_key,"c"=>1],
  8600. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8601. ];
  8602. $merges[] = [
  8603. "s"=>["r"=>$excel_key,"c"=>2],
  8604. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8605. ];
  8606. $merges[] = [
  8607. "s"=>["r"=>$excel_key,"c"=>3],
  8608. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8609. ];
  8610. $merges[] = [
  8611. "s"=>["r"=>$excel_key,"c"=>4],
  8612. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8613. ];
  8614. $merges[] = [
  8615. "s"=>["r"=>$excel_key,"c"=>5],
  8616. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8617. ];
  8618. $merges[] = [
  8619. "s"=>["r"=>$excel_key,"c"=>6],
  8620. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8621. ];
  8622. for($i=1;$i<=$day_len;$i++){
  8623. $merges[] = [
  8624. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8625. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8626. ];
  8627. }
  8628. $merges[] = [
  8629. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8630. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8631. ];
  8632. $excel_key = $excel_key + $len;
  8633. }
  8634. }
  8635. }
  8636. $title = "详情 " . date("Y-m-d", time());
  8637. if(empty($final_list)){
  8638. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8639. }
  8640. $cols = [
  8641. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8642. ];
  8643. array_unshift($final_list, $first_row);
  8644. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8645. }
  8646. }
  8647. public function _whlabelexcelzhjs(){
  8648. if(empty($_GET['excel'])){
  8649. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8650. }
  8651. $where = "sku != 'Preset' and sku != '' ";
  8652. //数据排序
  8653. $order_str = "id desc";
  8654. if (empty($page)) {
  8655. $start = 0;
  8656. $perpage = 1;
  8657. } else {
  8658. $start = ($page - 1) * $perpage;
  8659. }
  8660. $category = $this->input->get('category', true);
  8661. $warehouse = $this->input->get('warehouse', true);
  8662. $excelid = $this->input->get('sid', true);
  8663. if ($category) {
  8664. $where .= " and features like '%-$category-%'";
  8665. }
  8666. if ($warehouse) {
  8667. $where .= " and warehouse = '$warehouse'";
  8668. }
  8669. $xzid = '';
  8670. if ($excelid) {
  8671. $excelid = explode(',', trim($excelid, ','));
  8672. foreach ($excelid as $key => $value) {
  8673. $xzid .= " id = " . $value . " or";
  8674. }
  8675. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8676. }
  8677. $merges = [
  8678. [
  8679. "s"=>["r"=>0,"c"=>0],
  8680. "e"=>["r"=>0,"c"=>6]
  8681. ]
  8682. ];
  8683. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8684. $excel_index = 2;
  8685. $final_list = [];
  8686. foreach ($rows as $key => $value) {
  8687. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8688. $zh = '';
  8689. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8690. // foreach ($zt_list as $v) {
  8691. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8692. // }
  8693. $zt = array_sum(array_column($zt_list, 'num'));
  8694. $number = $value['number'];
  8695. $ftime = time() - 15 * 24 * 3600;
  8696. $warehouse = $this->warehouse->read($value['warehouse']);
  8697. // $rows[$key]['warehouse'] = $warehouse['title'];
  8698. // $rows[$key]['number'] = $c;
  8699. // $rows[$key]['features'] = $zh;
  8700. //$rows[$key]['hb'] = $c + $zt;
  8701. $tmp = [];
  8702. $tmp[0] = $warehouse['title'];
  8703. $tmp[1] = $value['sku'];
  8704. $tmp[2] = $value['title'];
  8705. $tmp[3] = $c;
  8706. $tmp[4] = "";
  8707. $tmp[5] = $c + $zt;
  8708. if(empty($zt_list)){
  8709. $tmp[4] = "";
  8710. $final_list[] = $tmp;
  8711. $excel_index = $excel_index + 1;
  8712. }else{
  8713. if(count($zt_list) == 1){
  8714. $tmp[4] = "";
  8715. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8716. $final_list[] = $tmp;
  8717. $excel_index = $excel_index + 1;
  8718. }else{
  8719. $len = count($zt_list);
  8720. foreach ($zt_list as $v){
  8721. $tmp[4] = "";
  8722. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8723. $final_list[] = $tmp;
  8724. }
  8725. $merges[] = [
  8726. "s"=>["r"=>$excel_index,"c"=>0],
  8727. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8728. ];
  8729. $merges[] = [
  8730. "s"=>["r"=>$excel_index,"c"=>1],
  8731. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8732. ];
  8733. $merges[] = [
  8734. "s"=>["r"=>$excel_index,"c"=>2],
  8735. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8736. ];
  8737. $merges[] = [
  8738. "s"=>["r"=>$excel_index,"c"=>3],
  8739. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8740. ];
  8741. $merges[] = [
  8742. "s"=>["r"=>$excel_index,"c"=>5],
  8743. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8744. ];
  8745. $excel_index = $excel_index + $len;
  8746. }
  8747. }
  8748. }
  8749. $first_row = [
  8750. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8751. ];
  8752. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8753. if(empty($final_list)){
  8754. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8755. }
  8756. $cols = [
  8757. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8758. ];
  8759. array_unshift($final_list, $first_row);
  8760. array_unshift($final_list, [
  8761. $title,"","","","",""
  8762. ]);
  8763. $end_list = [];
  8764. foreach ($final_list as $key => $value) {
  8765. $end_list[] = array_values($value);
  8766. }
  8767. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8768. }
  8769. //出库、退库导出
  8770. public function _dccrtypejs()
  8771. {
  8772. $classid = $this->classid->sku();
  8773. $pm = $classid;
  8774. $typeclass = array();
  8775. $tc = $this->typeclass->find_all();
  8776. foreach ($tc as $v) {
  8777. $typeclass[$v['id']] = $v;
  8778. }
  8779. $prc = array();
  8780. $purchase = $this->purchase->find_all();
  8781. foreach ($purchase as $k => $v) {
  8782. $prc[$v['id']] = $v['title'];
  8783. }
  8784. if (isset($_GET['sid'])) {
  8785. $wh = array();
  8786. $w = $this->warehouse->find_all('1=1', 'id,title');
  8787. foreach ($w as $v) {
  8788. $wh[$v['id']] = $v['title'];
  8789. }
  8790. $type = $this->input->get('excel', true);
  8791. $category = $this->input->get('category', true);
  8792. $size = $this->input->get('size', true);
  8793. $grade = $this->input->get('grade', true);
  8794. $color = $this->input->get('color', true);
  8795. $lowe = $this->input->get('lowe', true);
  8796. $sku = $this->input->get('sku', true);
  8797. $warehouse = $this->input->get('warehouse', true);
  8798. $lacetype = $this->input->get('lacetype', true);
  8799. $lacecolor = $this->input->get('lacecolor', true);
  8800. $density = $this->input->get('density', true);
  8801. $haircap = $this->input->get('haircap', true);
  8802. $purchase = $this->input->get('purchase', true);
  8803. $title = $this->input->get('title', true);
  8804. $state = $this->input->get('state', true);
  8805. $sid = $this->input->get('sid', true);
  8806. $ktime = $this->input->get('ktime', true);
  8807. $jtime = $this->input->get('jtime', true);
  8808. $ktime = strtotime($ktime);
  8809. $jtime = strtotime($jtime);
  8810. $where = "1=1";
  8811. $gj = "";
  8812. $ck = "";
  8813. if ($category) {
  8814. $where .= " and features like '%-$category-%'";
  8815. }
  8816. if ($size) {
  8817. $where .= " and features like '%-$size-%'";
  8818. }
  8819. if ($grade) {
  8820. $where .= " and features like '%-$grade-%'";
  8821. }
  8822. if ($color) {
  8823. $where .= " and features like '%-$color-%'";
  8824. }
  8825. if ($lowe) {
  8826. $where .= " and features like '%-$lowe-%'";
  8827. }
  8828. if ($warehouse) {
  8829. $where .= " and warehouse = '$warehouse'";
  8830. }
  8831. if ($purchase) {
  8832. $where .= " and purchase = '$purchase'";
  8833. }
  8834. if ($state) {
  8835. $where .= " and state = '$state'";
  8836. }
  8837. if ($lacetype) {
  8838. $where .= " and features like '%-$lacetype-%'";
  8839. }
  8840. if ($lacecolor) {
  8841. $where .= " and features like '%-$lacecolor-%'";
  8842. }
  8843. if ($density) {
  8844. $where .= " and features like '%-$density-%'";
  8845. }
  8846. if ($haircap) {
  8847. $where .= " and features like '%-$haircap-%'";
  8848. }
  8849. if ($title) {
  8850. $title = trim($title, ' ');
  8851. $title = trim($title, ' ');
  8852. $where .= " and title like '%$title%'";
  8853. }
  8854. if ($sku) {
  8855. $sku = trim($sku, ' ');
  8856. $sku = trim($sku, ' ');
  8857. $where .= " and sku like '%$sku%'";
  8858. }
  8859. if ($ktime && $jtime) {
  8860. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8861. }
  8862. $sidwhere = '';
  8863. if ($sid) {
  8864. $sd = "";
  8865. $s = explode(',', trim($sid, ','));
  8866. foreach ($s as $value) {
  8867. $sd .= " id = " . $value . " or";
  8868. }
  8869. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8870. }
  8871. //数据排序
  8872. $order_str = "time desc";
  8873. if (empty($page)) {
  8874. $start = 0;
  8875. $perpage = 1;
  8876. } else {
  8877. $start = ($page - 1) * $perpage;
  8878. }
  8879. $wh = array();
  8880. $w = $this->warehouse->find_all('1=1', 'id,title');
  8881. foreach ($w as $v) {
  8882. $wh[$v['id']] = $v['title'];
  8883. }
  8884. $wt = array();
  8885. $whlabel_type = $this->whlabel_type->find_all();
  8886. foreach ($whlabel_type as $v) {
  8887. $wt[$v['id']] = $v['title'];
  8888. }
  8889. $classid = $this->classid->sku();
  8890. $list = array();
  8891. $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');
  8892. foreach ($rows_r as $key => $value) {
  8893. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8894. $pm = $classid;
  8895. $jm = $classid;
  8896. $rows_r[$key]['enter'] = '入库';
  8897. $rows_r[$key]['time'] = $value['enter'];
  8898. if ($value['rktype'] == 1) {
  8899. $rows_r[$key]['rktype'] = '采购入库';
  8900. } else if ($value['rktype'] == 2) {
  8901. $rows_r[$key]['rktype'] = '盘盈调整';
  8902. } else if ($value['rktype'] == 3) {
  8903. $rows_r[$key]['rktype'] = '其他调整入库';
  8904. } else if ($value['rktype'] == 4) {
  8905. $rows_r[$key]['rktype'] = '其他调整入库';
  8906. } else if ($value['rktype'] == 5) {
  8907. $rows_r[$key]['rktype'] = '退库入库';
  8908. } else if ($value['rktype'] == 6) {
  8909. $rows_r[$key]['rktype'] = '退货可用入库';
  8910. } else if ($value['rktype'] == 7) {
  8911. $rows_r[$key]['rktype'] = '形态转换入库';
  8912. } else {
  8913. $rows_r[$key]['rktype'] = '';
  8914. }
  8915. $features = explode('-', trim($value['features'], '-'));
  8916. foreach ($features as $v) {
  8917. if (isset($typeclass[$v])) {
  8918. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8919. $pm[$typeclass[$v]['classid']] = $zh[0];
  8920. }
  8921. if (isset($typeclass[$v])) {
  8922. if (isset($jm[$typeclass[$v]['classid']])) {
  8923. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8924. }
  8925. }
  8926. }
  8927. $zh = implode(" ", $pm);
  8928. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8929. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8930. $rows_r[$key]['zh'] = $zh;
  8931. $jm = array_filter($jm);
  8932. $rows_r[$key]['features'] = implode("-", $jm);
  8933. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8934. }
  8935. $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');
  8936. foreach ($rows_c as $key => $value) {
  8937. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8938. $pm = $classid;
  8939. $jm = $classid;
  8940. $rows_c[$key]['time'] = $value['outk'];
  8941. $rows_c[$key]['outk'] = '出库';
  8942. if ($value['cktype'] == 1) {
  8943. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8944. } else if ($value['cktype'] == 2) {
  8945. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8946. } else if ($value['cktype'] == 3) {
  8947. $rows_c[$key]['cktype'] = '盘亏调整';
  8948. } else if ($value['cktype'] == 4) {
  8949. $rows_c[$key]['cktype'] = '其他调整出库';
  8950. } else if ($value['cktype'] == 5) {
  8951. $rows_c[$key]['cktype'] = '形态转换出库';
  8952. } else {
  8953. $rows_c[$key]['cktype'] = '';
  8954. }
  8955. unset($rows_c[$key]['state']);
  8956. $features = explode('-', trim($value['features'], '-'));
  8957. foreach ($features as $v) {
  8958. if (isset($typeclass[$v])) {
  8959. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8960. $pm[$typeclass[$v]['classid']] = $zh[0];
  8961. }
  8962. if (isset($typeclass[$v])) {
  8963. if (isset($jm[$typeclass[$v]['classid']])) {
  8964. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8965. }
  8966. }
  8967. }
  8968. $zh = implode(" ", $pm);
  8969. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8970. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8971. $rows_c[$key]['zh'] = $zh;
  8972. $jm = array_filter($jm);
  8973. $rows_c[$key]['features'] = implode("-", $jm);
  8974. $rows_c[$key]['number'] = 1;
  8975. }
  8976. $merged = $rows_r;
  8977. foreach ($rows_c as $key => $value) {
  8978. if (isset($merged[$key])) {
  8979. $merged[] = $value;
  8980. } else {
  8981. $merged[$key] = $value;
  8982. }
  8983. }
  8984. usort($merged, function ($a, $b) {
  8985. return $a['time'] - $b['time'];
  8986. });
  8987. foreach ($merged as $key => $value) {
  8988. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8989. }
  8990. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8991. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  8992. $cols = [
  8993. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8994. ];
  8995. $final_list= [];
  8996. foreach($merged as $key => $value){
  8997. $final_list[] = array_values($value) ;
  8998. }
  8999. if(empty($merged)){
  9000. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9001. }
  9002. array_unshift($final_list, $first_row);
  9003. $end_list = [];
  9004. foreach ($final_list as $key => $value) {
  9005. $end_list[] = array_values($value);
  9006. }
  9007. $merges = [];
  9008. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9009. }
  9010. }
  9011. public function _errorexceljs()
  9012. {
  9013. $post = $this->input->post(NULL, TRUE);
  9014. if (isset($_GET['page'])) {
  9015. $page = $this->input->get('page', true);
  9016. $perpage = $this->input->get('perpage', true);
  9017. $sku = $this->input->get('sku', true);
  9018. $warehouse = $this->input->get('warehouse', true);
  9019. $ktime = $this->input->get('ktime', true);
  9020. $jtime = $this->input->get('jtime', true);
  9021. $ktime = strtotime($ktime);
  9022. $jtime = strtotime($jtime);
  9023. $where = "sku != 'Preset'";
  9024. $gj = '';
  9025. if ($sku) {
  9026. $where .= " and sku like '%$sku%'";
  9027. } else {
  9028. if ($ktime && $jtime) {
  9029. $gj = " and time > '$ktime' and time < '$jtime'";
  9030. }
  9031. }
  9032. if ($warehouse) {
  9033. $where .= " and warehouse = '$warehouse'";
  9034. }
  9035. //数据排序
  9036. $order_str = "id desc";
  9037. if (empty($page)) {
  9038. $start = 0;
  9039. $perpage = 1;
  9040. } else {
  9041. $start = ($page - 1) * $perpage;
  9042. }
  9043. //取得信息列表
  9044. $rows = array();
  9045. $list = array();
  9046. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9047. foreach ($info_list as $value) {
  9048. $warehouse = $this->warehouse->read($value['warehouse']);
  9049. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9050. $number = $value['number'];
  9051. $ftime = time() - 15 * 24 * 3600;
  9052. if ($c < 1) {
  9053. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9054. }
  9055. }
  9056. $title = "0库存汇总";
  9057. $first_row = ["仓库","SKU","产品","当前库存"];
  9058. $cols = [
  9059. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9060. ];
  9061. $final_list= [];
  9062. foreach($list as $key => $value){
  9063. $final_list[] = array_values($value) ;
  9064. }
  9065. if(empty($final_list)){
  9066. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9067. }
  9068. array_unshift($final_list, $first_row);
  9069. $merges = [];
  9070. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9071. }
  9072. }
  9073. }