Whlabel.php 317 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354
  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. }
  1140. $title = "进销存统计表" . date('Y-m-d', time());
  1141. $titlename = "<table border=1>
  1142. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1143. <tr align='center'>
  1144. <td>仓库</td>
  1145. <td>供应商</td>
  1146. <td>位置</td>
  1147. <td>库存编码</td>
  1148. <td>SKU</td>
  1149. <td>用友编码</td>
  1150. <td>用友料号</td>
  1151. <td>产品英文名</td>
  1152. <td>产品中文名</td>
  1153. <td>备注</td>
  1154. <td>入库总量</td>
  1155. <td>库存数量</td>
  1156. <td>销售数量</td>
  1157. <td>退货数量</td>
  1158. <td>删除数量</td>
  1159. <td>其它操作</td>
  1160. <td>位置数量</td>
  1161. </tr>
  1162. </table>";
  1163. $filename = $title . ".xls";
  1164. $tail = "";
  1165. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1166. }
  1167. }
  1168. public function _type()
  1169. {
  1170. $vip = 0;
  1171. if (isset($_SESSION['api'])) {
  1172. $user = $this->user->get_api($_SESSION['api']);
  1173. $fgshop = "";
  1174. $sid = "";
  1175. $usersp = explode('|', trim($user['shop'], '|'));
  1176. foreach ($usersp as $value) {
  1177. $fgshop .= " shop = " . $value . " or";
  1178. $sid .= " id = " . $value . " or";
  1179. }
  1180. if ($user['vip'] == 1) {
  1181. $vip = 1;
  1182. }
  1183. } else {
  1184. header('Location: /');
  1185. exit;
  1186. }
  1187. $prc = array();
  1188. $purchase = $this->purchase->find_all();
  1189. foreach ($purchase as $k => $v) {
  1190. $prc[$v['id']] = $v['title'];
  1191. }
  1192. $company = array();
  1193. $ct = $this->company->find_all();
  1194. foreach ($ct as $k => $v) {
  1195. $company[$v['id']] = $v['title'];
  1196. }
  1197. $sp = array();
  1198. $s = $this->shop->find_all('1=1', 'id,shopname');
  1199. foreach ($s as $v) {
  1200. $sp[$v['id']] = $v['shopname'];
  1201. }
  1202. $wh = array();
  1203. $w = $this->warehouse->find_all('1=1', 'id,title');
  1204. foreach ($w as $v) {
  1205. $wh[$v['id']] = $v['title'];
  1206. }
  1207. $post = $this->input->post(NULL, TRUE);
  1208. if (isset($post['page'])) {
  1209. $page = $this->input->post('page', true);
  1210. $perpage = $this->input->post('perpage', true);
  1211. $category = $this->input->post('category', true);
  1212. $size = $this->input->post('size', true);
  1213. $grade = $this->input->post('grade', true);
  1214. $color = $this->input->post('color', true);
  1215. $lowe = $this->input->post('lowe', true);
  1216. $sku = $this->input->post('sku');
  1217. $title = $this->input->post('title');
  1218. $warehouse = $this->input->post('warehouse', true);
  1219. $usa = $this->input->post('usa', true);
  1220. $purchase = $this->input->post('purchase', true);
  1221. $lacetype = $this->input->post('lacetype', true);
  1222. $haircap = $this->input->post('haircap', true);
  1223. $density = $this->input->post('density', true);
  1224. $details = $this->input->post('details', true);
  1225. $state = $this->input->post('state', true);
  1226. $shop = $this->input->post('shop', true);
  1227. $lacecolor = $this->input->post('lacecolor', true);
  1228. $hairnumber = $this->input->post('hairnumber', true);
  1229. $type = $this->input->post('type', true);
  1230. $ktime = $this->input->post('ktime', true);
  1231. $jtime = $this->input->post('jtime', true);
  1232. $ktime = strtotime($ktime);
  1233. $jtime = strtotime($jtime);
  1234. $cpbz = $this->input->post('cpbz', true);
  1235. $sm = $this->input->post('sm', true);
  1236. $where = "1=1";
  1237. $gj = "";
  1238. $ck = "";
  1239. if ($usa) {
  1240. if (!$warehouse) {
  1241. $where .= " and (warehouse = '5' or warehouse = '8')";
  1242. }
  1243. }
  1244. if ($warehouse) {
  1245. $where .= " and warehouse = '$warehouse'";
  1246. }
  1247. if ($details) {
  1248. $where .= " and details = '$details'";
  1249. }
  1250. if ($purchase) {
  1251. $where .= " and purchase = '$purchase'";
  1252. }
  1253. if ($state) {
  1254. $where .= " and state = '$state'";
  1255. }
  1256. if ($shop) {
  1257. $where .= " and shop like '%$shop%'";
  1258. }
  1259. if ($type) {
  1260. $where .= " and type = '$type'";
  1261. }
  1262. if ($ktime && $jtime) {
  1263. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1264. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1265. }
  1266. if ($cpbz) {
  1267. $where .= " and cpbz like '%$cpbz%' ";
  1268. }
  1269. if ($sm) {
  1270. $where .= " and sm like '%$sm%' ";
  1271. }
  1272. if ($lacecolor) {
  1273. $where .= " and features like '%-$lacecolor-%'";
  1274. }
  1275. if ($lacetype) {
  1276. $where .= " and features like '%-$lacetype-%'";
  1277. }
  1278. if ($category) {
  1279. $where .= " and features like '%-$category-%'";
  1280. }
  1281. if ($size) {
  1282. $where .= " and features like '%-$size-%'";
  1283. }
  1284. if ($grade) {
  1285. $where .= " and features like '%-$grade-%'";
  1286. }
  1287. if ($color) {
  1288. $where .= " and features like '%-$color-%'";
  1289. }
  1290. if ($lowe) {
  1291. $where .= " and features like '%-$lowe-%'";
  1292. }
  1293. if ($haircap) {
  1294. $where .= " and features like '%-$haircap-%'";
  1295. }
  1296. if ($density) {
  1297. $where .= " and features like '%-$density-%'";
  1298. }
  1299. if (!empty($hairnumber)) {
  1300. $where .= " and features like '%-128-%' ";
  1301. if ($hairnumber < 0) {
  1302. $class_list = $this->typeclass->find_all('classid = 43');
  1303. foreach ($class_list as $v) {
  1304. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1305. }
  1306. } else {
  1307. $where .= " and features like '%-$hairnumber-%'";
  1308. }
  1309. }
  1310. //数据排序
  1311. $order_str = "id desc";
  1312. if (empty($page)) {
  1313. $start = 0;
  1314. $perpage = 1;
  1315. } else {
  1316. $start = ($page - 1) * $perpage;
  1317. }
  1318. $fjnr = '';
  1319. if ($sku) {
  1320. $sku = trim($sku, ' ');
  1321. $sku = trim($sku, ' ');
  1322. $fjnr .= " and sku like '%$sku%'";
  1323. }
  1324. if ($title) {
  1325. $title = trim($title, ' ');
  1326. $title = trim($title, ' ');
  1327. $fjnr .= " and title like '%$title%'";
  1328. }
  1329. $wt = array();
  1330. $whlabel_type = $this->whlabel_type->find_all();
  1331. foreach ($whlabel_type as $v) {
  1332. $wt[$v['id']] = $v['title'];
  1333. }
  1334. //$where .= " and time > '$ktime' and time < '$jtime'";
  1335. $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
  1336. //取得信息列表
  1337. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1338. $rows = array();
  1339. $list = array();
  1340. foreach ($info_list as $key => $value) {
  1341. if (isset($wt[$value['type']])) {
  1342. $info_list[$key]['type'] = $wt[$value['type']];
  1343. } else {
  1344. $info_list[$key]['type'] = '未设置';
  1345. }
  1346. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1347. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1348. $ztdata = '';
  1349. if (count($zt) > 0) {
  1350. foreach ($zt as $vv) {
  1351. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1352. }
  1353. }
  1354. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1355. $cdata = array_filter($qbdata, function ($item) {
  1356. return $item['state'] < 1;
  1357. });
  1358. $c = array_sum(array_column($cdata, 'jnum'));
  1359. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1360. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1361. });
  1362. $g = array_sum(array_column($gdata, 'jnum'));
  1363. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1364. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1365. });
  1366. $x = array_sum(array_column($xdata, 'jnum'));
  1367. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1368. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1369. });
  1370. $t = array_sum(array_column($tdata, 'jnum'));
  1371. // $zdata = array_filter($qbdata, function ($item) {
  1372. // return $item['zd'] != "" && $item['state'] < 1;
  1373. // });
  1374. // $z = array_sum(array_column($zdata, '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. //$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');
  1380. //$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'].'"');
  1381. //$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'].'"');
  1382. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1383. //$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'].'"');
  1384. $details = array();
  1385. $cpid = array();
  1386. $od = array();
  1387. $odid = '';
  1388. $companytitle = '';
  1389. $shop_list = [];
  1390. foreach ($qbdata as $v) {
  1391. if ($v['zd'] != "" && $v['state'] < 1) {
  1392. if (!isset($od[$v['zd']])) {
  1393. $od[$v['zd']] = 1; //所有数据sku
  1394. } else {
  1395. $od[$v['zd']] = $od[$v['zd']] + 1;
  1396. }
  1397. }
  1398. $details[$v['details']] = $v['details'];
  1399. if ($v['state'] < 1) {
  1400. //$details[$v['details']] = $v['details'];
  1401. if ($v['cpid'] != 0) {
  1402. $cpid[$v['cpid']] = $v['cpid'];
  1403. }
  1404. }
  1405. if($v['state'] == 0){
  1406. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1407. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1408. }
  1409. if ($v['shop'] != '') {
  1410. $shop = explode(',', trim($v['shop'], ','));
  1411. foreach ($shop as $vv) {
  1412. if (!in_array($vv, $shop_list)) {
  1413. $shop_list[] = $vv;
  1414. }
  1415. }
  1416. }
  1417. }
  1418. }
  1419. foreach ($od as $k => $vv) {
  1420. $odid .= $k . '数量' . $vv;
  1421. }
  1422. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1423. $info_list[$key]['label'] = $value['sm'];
  1424. $number = $value['number'];
  1425. $ftime = time() - 15 * 24 * 3600;
  1426. $z = $z . '(' . $odid . ')'; //查看订单号
  1427. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1428. $info_list[$key]['features'] = $c;
  1429. $info_list[$key]['number'] = $ztdata;
  1430. $info_list[$key]['sm'] = $g;
  1431. $info_list[$key]['x'] = $x;
  1432. $info_list[$key]['t'] = $t;
  1433. $info_list[$key]['z'] = $z;
  1434. /**
  1435. foreach ($cdata as $k=>$v)
  1436. {
  1437. $details[$v['details']] = $v['details'];
  1438. if($v['cpid'] != 0)
  1439. {
  1440. $cpid[$v['cpid']] = $v['cpid'];
  1441. }
  1442. }
  1443. **/
  1444. $info_list[$key]['shop'] = '';
  1445. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1446. // if ($value['shop'] != '') {
  1447. // $shop = explode(',', trim($value['shop'], ','));
  1448. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1449. // }
  1450. $shop_list = array_unique($shop_list);
  1451. $shop_str = '';
  1452. foreach ($shop_list as $v) {
  1453. if(isset($sp[$v])){
  1454. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1455. }
  1456. }
  1457. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1458. /**
  1459. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1460. if(isset($companytitle[0]))
  1461. {
  1462. foreach ($companytitle as $k=>$v)
  1463. {
  1464. if($v['companytitle'] != '')
  1465. {
  1466. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1467. }
  1468. }
  1469. }
  1470. **/
  1471. }
  1472. $final_all_list = [];
  1473. foreach ($info_list as $k => $v) {
  1474. $final_all_list[] = [
  1475. 'id' => $v['id'],
  1476. "warehouse" => $v["warehouse"],
  1477. "purchase" => $v["purchase"],
  1478. "sku" => $v["sku"],
  1479. "title" => $v["title"] . "<br/>" . $v["pm"],
  1480. "details" => $v["details"],
  1481. "shop" => $v["shop"],
  1482. "cpbz" => $v["cpbz"],
  1483. 'label' => $v['label'],
  1484. "type" => $v["type"],
  1485. "features" => $v["features"],
  1486. "number" => $v["number"],
  1487. "sm" => $v["sm"],
  1488. "x" => $v["x"],
  1489. "t" => $v["t"],
  1490. "z" => $v["z"]
  1491. ];
  1492. }
  1493. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1494. $pagenum = ceil($total / $perpage);
  1495. $over = $total - ($start + $perpage);
  1496. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1497. echo json_encode($rows);
  1498. exit;
  1499. }
  1500. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1501. $this->data['shop'] = $wlshop;
  1502. $this->data['vip'] = $vip;
  1503. $this->_Template('whlabel_type', $this->data);
  1504. }
  1505. //美仓进销存浏览
  1506. public function _usatype()
  1507. {
  1508. if (isset($_SESSION['api'])) {
  1509. $user = $this->user->get_api($_SESSION['api']);
  1510. $usp = $user;
  1511. $fgshop = "";
  1512. $sid = "";
  1513. $wid = "";
  1514. $wtype = "";
  1515. $userwh = explode('|', trim($user['warehouse'], '|'));
  1516. foreach ($userwh as $value) {
  1517. $wid .= " id = " . $value . " or";
  1518. $wtype .= " type = " . $value . " or";
  1519. }
  1520. }
  1521. $prc = array();
  1522. $purchase = $this->purchase->find_all();
  1523. foreach ($purchase as $k => $v) {
  1524. $prc[$v['id']] = $v['title'];
  1525. }
  1526. $post = $this->input->post(NULL, TRUE);
  1527. if (isset($post['page'])) {
  1528. $page = $this->input->post('page', true);
  1529. $perpage = $this->input->post('perpage', true);
  1530. $category = $this->input->post('category', true);
  1531. $size = $this->input->post('size', true);
  1532. $grade = $this->input->post('grade', true);
  1533. $color = $this->input->post('color', true);
  1534. $lowe = $this->input->post('lowe', true);
  1535. $sku = $this->input->post('sku');
  1536. $title = $this->input->post('title');
  1537. $warehouse = $this->input->post('warehouse', true);
  1538. $usa = $this->input->post('usa', true);
  1539. $purchase = $this->input->post('purchase', true);
  1540. $lacetype = $this->input->post('lacetype', true);
  1541. $haircap = $this->input->post('haircap', true);
  1542. $density = $this->input->post('density', true);
  1543. $details = $this->input->post('details', true);
  1544. $state = $this->input->post('state', true);
  1545. $lacecolor = $this->input->post('lacecolor', true);
  1546. $cklx = $this->input->post('cklx', true);
  1547. $ktime = $this->input->post('ktime', true);
  1548. $jtime = $this->input->post('jtime', true);
  1549. $ktime = strtotime($ktime);
  1550. $jtime = strtotime($jtime);
  1551. $where = "1=1";
  1552. $gj = "";
  1553. $ck = "";
  1554. if ($lacetype) {
  1555. $where .= " and features like '%-$lacetype-%'";
  1556. }
  1557. if ($category) {
  1558. $where .= " and features like '%-$category-%'";
  1559. }
  1560. if ($size) {
  1561. $where .= " and features like '%-$size-%'";
  1562. }
  1563. if ($grade) {
  1564. $where .= " and features like '%-$grade-%'";
  1565. }
  1566. if ($color) {
  1567. $where .= " and features like '%-$color-%'";
  1568. }
  1569. if ($lowe) {
  1570. $where .= " and features like '%-$lowe-%'";
  1571. }
  1572. if ($haircap) {
  1573. $where .= " and features like '%-$haircap-%'";
  1574. }
  1575. if ($density) {
  1576. $where .= " and features like '%-$density-%'";
  1577. }
  1578. if ($lacecolor) {
  1579. $where .= " and features like '%-$lacecolor-%'";
  1580. }
  1581. if ($usa) {
  1582. if (!$warehouse) {
  1583. $where .= " and (warehouse = '5' or warehouse = '8')";
  1584. }
  1585. }
  1586. if ($warehouse) {
  1587. $where .= " and warehouse = '$warehouse'";
  1588. }
  1589. if ($details) {
  1590. $where .= " and details = '$details'";
  1591. }
  1592. if ($purchase) {
  1593. $where .= " and purchase = '$purchase'";
  1594. }
  1595. if ($state) {
  1596. $where .= " and state = '$state'";
  1597. }
  1598. $where_add = '';
  1599. if ($cklx) {
  1600. $shop = $this->shop->read($cklx);
  1601. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1602. }
  1603. if ($ktime && $jtime) {
  1604. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1605. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1606. }
  1607. //数据排序
  1608. $order_str = "id desc";
  1609. if (empty($page)) {
  1610. $start = 0;
  1611. $perpage = 1;
  1612. } else {
  1613. $start = ($page - 1) * $perpage;
  1614. }
  1615. if ($sku) {
  1616. $sku = trim($sku, ' ');
  1617. $sku = trim($sku, ' ');
  1618. $where .= " and sku like '%$sku%'";
  1619. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1620. } else if ($title) {
  1621. $title = trim($title, ' ');
  1622. $title = trim($title, ' ');
  1623. $where .= " and title like '%$title%'";
  1624. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1625. } else {
  1626. //$where .= " and time > '$ktime' and time < '$jtime'";
  1627. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1628. }
  1629. //取得信息列表
  1630. $rows = array();
  1631. $list = array();
  1632. foreach ($info_list as $key => $value) {
  1633. $warehouse = $this->warehouse->read($value['warehouse']);
  1634. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1635. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1636. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1637. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1638. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1639. $od = array();
  1640. $odid = '';
  1641. foreach ($z as $v) {
  1642. if (!isset($od[$v['zd']])) {
  1643. $od[$v['zd']] = 1; //所有数据sku
  1644. } else {
  1645. $od[$v['zd']] = $od[$v['zd']] + 1;
  1646. }
  1647. }
  1648. foreach ($od as $k => $vv) {
  1649. $odid .= $k . '数量' . $vv . ' ';
  1650. }
  1651. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1652. $info_list[$key]['features'] = $c;
  1653. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1654. $ztdata = '';
  1655. if (count($zt) > 0) {
  1656. foreach ($zt as $vv) {
  1657. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1658. }
  1659. }
  1660. $info_list[$key]['warehouse'] = $ztdata;
  1661. $info_list[$key]['g'] = $g;
  1662. $info_list[$key]['x'] = $x;
  1663. $info_list[$key]['t'] = $t;
  1664. $info_list[$key]['z'] = $z;
  1665. }
  1666. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1667. $pagenum = ceil($total / $perpage);
  1668. $over = $total - ($start + $perpage);
  1669. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1670. echo json_encode($rows);
  1671. exit;
  1672. }
  1673. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1674. $this->data['warehouse'] = $warehouse;
  1675. $this->_Template('whlabel_typeusa', $this->data);
  1676. }
  1677. //美仓进销存浏览
  1678. public function _usatypeapp()
  1679. {
  1680. $post = $this->input->post(NULL, TRUE);
  1681. if (isset($post['page'])) {
  1682. $page = $this->input->post('page', true);
  1683. $perpage = $this->input->post('perpage', true);
  1684. $sku = $this->input->post('sku', true);
  1685. $warehouse = 5;
  1686. $title = $this->input->post('title', true);
  1687. $state = $this->input->post('state', true);
  1688. $ktime = $this->input->post('ktime', true);
  1689. $jtime = $this->input->post('jtime', true);
  1690. $ktime = strtotime($ktime);
  1691. $jtime = strtotime($jtime);
  1692. $where = "1=1";
  1693. $gj = "";
  1694. $ck = "";
  1695. if ($title) {
  1696. $st = explode(' ', trim($title, ' '));
  1697. foreach ($st as $v) {
  1698. $where .= " and title like '%$v%'";
  1699. }
  1700. }
  1701. if ($warehouse) {
  1702. $where .= " and warehouse = '$warehouse'";
  1703. }
  1704. if ($state) {
  1705. $where .= " and state = '$state'";
  1706. }
  1707. if ($sku) {
  1708. $where .= " and sku like '%$sku%'";
  1709. }
  1710. if ($ktime && $jtime) {
  1711. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1712. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1713. }
  1714. //数据排序
  1715. $order_str = "id desc";
  1716. if (empty($page)) {
  1717. $start = 0;
  1718. $perpage = 1;
  1719. } else {
  1720. $start = ($page - 1) * $perpage;
  1721. }
  1722. //取得信息列表
  1723. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1724. $rows = array();
  1725. $list = array();
  1726. foreach ($info_list as $key => $value) {
  1727. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1728. }
  1729. $rowsdq = array_slice($rows, $start, $perpage);
  1730. foreach ($rowsdq as $value) {
  1731. $warehouse = $this->warehouse->read($value['warehouse']);
  1732. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1733. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1734. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1735. $od = array();
  1736. $odid = '';
  1737. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1738. }
  1739. $total = count($rows);
  1740. $pagenum = ceil($total / $perpage);
  1741. $over = $total - ($start + $perpage);
  1742. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1743. echo json_encode($rows);
  1744. exit;
  1745. }
  1746. $this->_Template('phone/p_usatypeapp', $this->data);
  1747. }
  1748. //入库操作
  1749. public function _enteradd()
  1750. {
  1751. $dt = 0;
  1752. if (isset($_SESSION['api'])) {
  1753. $user = $this->user->get_api($_SESSION['api']);
  1754. $usp = $user;
  1755. $fgshop = "";
  1756. $sid = "";
  1757. $user = explode('|', trim($user['shop'], '|'));
  1758. foreach ($user as $value) {
  1759. $fgshop .= " shop = " . $value . " or";
  1760. $sid .= " id = " . $value . " or";
  1761. }
  1762. }
  1763. $tc = $this->typeclass->find_all();
  1764. $typeclass = array();
  1765. foreach ($tc as $v) {
  1766. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1767. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1768. }
  1769. $post = $this->input->post(NULL, TRUE);
  1770. if (isset($post['sku'])) {
  1771. $list = array();
  1772. $num = "";
  1773. $title = "";
  1774. $features = "";
  1775. $order = $this->input->post('order', true);
  1776. $shop = $this->input->post('shop', true);
  1777. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1778. $sku = $this->input->post('sku', true);
  1779. $post['sm'] = $this->input->post('sm', true);
  1780. $post['warehouse'] = $this->input->post('warehouse', true);
  1781. $post['purchase'] = $this->input->post('purchase', true);
  1782. $post['retreatwarehouse'] = $post['warehouse'];
  1783. $post['state'] = $this->input->post('state', true);
  1784. $post['rktype'] = $this->input->post('rktype', true);
  1785. $post['text'] = $this->input->post('text', true);
  1786. $category = $this->input->post('category', true);
  1787. $list['category'] = $category;
  1788. $list['hairtype'] = $this->input->post('hairtype', true);
  1789. $list['grade'] = $this->input->post('grade', true);
  1790. $size = $this->input->post('size', true);
  1791. $xzsku = $this->input->post('xzsku', true);
  1792. $list['size'] = rtrim($size, ',');
  1793. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1794. $list['extension'] = $this->input->post('extension', true);
  1795. if ($category == 1297) {
  1796. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1797. }
  1798. if ($category == 1702) {
  1799. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1800. $list['syother'] = $this->input->post('syother', true);
  1801. }
  1802. if ($category == 133) {
  1803. $list['fittype'] = $this->input->post('fittype', true);
  1804. $list['acother'] = $this->input->post('acother', true);
  1805. }
  1806. $list['color'] = $this->input->post('color', true);
  1807. $list['lowe'] = $this->input->post('lowe', true);
  1808. if (!$post['purchase']) {
  1809. $post['purchase'] = 1;
  1810. }
  1811. if ($category == 127) {
  1812. $list['type'] = $this->input->post('type', true);
  1813. $list['headroad'] = $this->input->post('headroad', true);
  1814. $list['density'] = $this->input->post('density', true);
  1815. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1816. $list['lacesize'] = $this->input->post('lacesize', true);
  1817. }
  1818. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1819. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1820. }
  1821. if ($category == 128) {
  1822. $list['lacetype'] = $this->input->post('lacetype', true);
  1823. $list['haircap'] = $this->input->post('haircap', true);
  1824. $list['density'] = $this->input->post('density', true);
  1825. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1826. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1827. $list['wigother'] = $this->input->post('wigother', true);
  1828. $list['wigother1'] = $this->input->post('wigother1', true);
  1829. $list['wigother2'] = $this->input->post('wigother2', true);
  1830. }
  1831. if ($category == 129) {
  1832. $list['wide'] = $this->input->post('wide', true);
  1833. }
  1834. if ($category == 131) {
  1835. $list['gifttype'] = $this->input->post('gifttype', true);
  1836. $list['giftother'] = $this->input->post('giftother', true);
  1837. }
  1838. if ($category == 134) {
  1839. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1840. }
  1841. if ($category == 1297) {
  1842. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1843. $list['sywigother'] = $this->input->post('sywigother', true);
  1844. }
  1845. if ($category == 130 || $category == 133 || $category == 1702) {
  1846. $list['items'] = $this->input->post('items', true);
  1847. $list['weight'] = $this->input->post('weight', true);
  1848. }
  1849. if($category == 130){
  1850. $list['jfother'] = $this->input->post('jfother', true);
  1851. }
  1852. if ($category == 1702) {
  1853. $list['syhairther'] = $this->input->post('syhairther', true);
  1854. }
  1855. $classid = $this->classid->sku();
  1856. $scsku = $classid;
  1857. $pm = $classid;
  1858. foreach ($list as $k => $v) {
  1859. if ($v != 0) {
  1860. $num .= $v;
  1861. $features .= $v . '-';
  1862. $post[$k] = $v;
  1863. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1864. if ($k != 'size') {
  1865. $title .= $typeclass[$v]['title'] . " ";
  1866. }
  1867. if (isset($pm[$typeclass[$v]['classid']])) {
  1868. if ($typeclass[$v]['title'] == '9A') {
  1869. $pm[$typeclass[$v]['classid']] = '9A';
  1870. } else if ($typeclass[$v]['title'] == '10A') {
  1871. $pm[$typeclass[$v]['classid']] = '10A';
  1872. } else {
  1873. $clzh = $typeclass[$v]['zh'];
  1874. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1875. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1876. $clzh = $clzh[0];
  1877. }
  1878. $pm[$typeclass[$v]['classid']] = $clzh;
  1879. }
  1880. }
  1881. }
  1882. }
  1883. $zh = implode(" ", $pm);
  1884. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1885. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1886. if ($list['size']) {
  1887. $typeclass = $this->typeclass->read($list['size']);
  1888. $title .= $typeclass['title'];
  1889. }
  1890. $time = time();
  1891. if ($xzsku) {
  1892. $scsku = implode("-", $scsku);
  1893. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1894. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1895. $post['sku'] = trim($scsku, ' ');
  1896. } else {
  1897. $post['sku'] = $sku;
  1898. }
  1899. //$post['sku'] = trim($sku,' ');
  1900. $post['title'] = rtrim($title, ' ');
  1901. $post['number'] = $num;
  1902. $post['features'] = '-' . $features;
  1903. $post['enter'] = $time;
  1904. $post['time'] = $time; //操作时间
  1905. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1906. if ($yza) {
  1907. if ($post['features'] != $yza[0]['features']) {
  1908. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1909. exit;
  1910. }
  1911. }
  1912. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1913. if ($yzb) {
  1914. if ($post['sku'] != $yzb[0]['sku']) {
  1915. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1916. exit;
  1917. }
  1918. }
  1919. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1920. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1921. exit;
  1922. }
  1923. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1924. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1925. exit;
  1926. }
  1927. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1928. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1929. exit;
  1930. }
  1931. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1932. if (isset($yz[0]['type'])) {
  1933. $post['type'] = $yz[0]['type'];
  1934. }
  1935. if ($post['state'] == 9) //如果选择预设库存
  1936. {
  1937. $this->whlabel->insert($post);
  1938. } else {
  1939. /**
  1940. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1941. if($ljg == 1)
  1942. {
  1943. for($i=0;$i<$order;$i++)
  1944. {
  1945. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1946. $this->whlabel->insert($post);
  1947. }
  1948. }
  1949. **/
  1950. //if($post['warehouse'] == '5')
  1951. //{
  1952. //}
  1953. $yydata = $post;
  1954. $yydata['zh'] = $zh;
  1955. /**
  1956. $wl = $this->apiyy->get_cjlp($yydata);
  1957. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1958. {
  1959. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1960. }
  1961. if($wl['Data'][0]['m_isSucess'] != 1)
  1962. {
  1963. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1964. }
  1965. **/
  1966. for ($i = 0; $i < $order; $i++) {
  1967. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1968. $this->whlabel->insert($post);
  1969. }
  1970. }
  1971. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1972. exit;
  1973. }
  1974. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1975. $this->data['wlshop'] = $wlshop;
  1976. $this->_Template('whlabel_enteradd', $this->data);
  1977. }
  1978. //修改产品
  1979. public function _enteredit($arg_array)
  1980. {
  1981. $dt = 0;
  1982. if (isset($_SESSION['api'])) {
  1983. $user = $this->user->get_api($_SESSION['api']);
  1984. $usp = $user;
  1985. $fgshop = "";
  1986. $sid = "";
  1987. $user = explode('|', trim($user['shop'], '|'));
  1988. foreach ($user as $value) {
  1989. $fgshop .= " shop = " . $value . " or";
  1990. $sid .= " id = " . $value . " or";
  1991. }
  1992. }
  1993. $post = $this->input->post(NULL, TRUE);
  1994. if (isset($post['sku'])) {
  1995. $list = array();
  1996. $num = "";
  1997. $title = "";
  1998. $features = "";
  1999. $id = $this->input->post('id', true);
  2000. $order = $this->input->post('order', true);
  2001. $shop = $this->input->post('shop', true);
  2002. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2003. $post['sku'] = $this->input->post('sku', true);
  2004. $post['sm'] = $this->input->post('sm', true);
  2005. $post['warehouse'] = $this->input->post('warehouse', true);
  2006. $post['purchase'] = $this->input->post('purchase', true);
  2007. $post['retreatwarehouse'] = $post['warehouse'];
  2008. $category = $this->input->post('category', true);
  2009. $list['category'] = $category;
  2010. $list['hairtype'] = $this->input->post('hairtype', true);
  2011. $list['grade'] = $this->input->post('grade', true);
  2012. $size = $this->input->post('size', true);
  2013. $list['size'] = rtrim($size, ',');
  2014. $post['rktype'] = $this->input->post('rktype', true);
  2015. $post['text'] = $this->input->post('text', true);
  2016. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2017. $list['extension'] = $this->input->post('extension', true);
  2018. if ($category == 1297) {
  2019. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2020. }
  2021. if ($category == 1702) {
  2022. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2023. $list['syother'] = $this->input->post('syother', true);
  2024. }
  2025. if ($category == 133) {
  2026. $list['fittype'] = $this->input->post('fittype', true);
  2027. $list['acother'] = $this->input->post('acother', true);
  2028. }
  2029. $list['color'] = $this->input->post('color', true);
  2030. $list['lowe'] = $this->input->post('lowe', true);
  2031. if (!$post['purchase']) {
  2032. $post['purchase'] = 1;
  2033. }
  2034. if ($category == 127) {
  2035. $list['type'] = $this->input->post('type', true);
  2036. $list['headroad'] = $this->input->post('headroad', true);
  2037. $list['density'] = $this->input->post('density', true);
  2038. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2039. $list['lacesize'] = $this->input->post('lacesize', true);
  2040. }
  2041. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2042. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2043. }
  2044. if ($category == 128) {
  2045. $list['lacetype'] = $this->input->post('lacetype', true);
  2046. $list['haircap'] = $this->input->post('haircap', true);
  2047. $list['density'] = $this->input->post('density', true);
  2048. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2049. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2050. $list['wigother'] = $this->input->post('wigother', true);
  2051. $list['wigother1'] = $this->input->post('wigother1', true);
  2052. $list['wigother2'] = $this->input->post('wigother2', true);
  2053. }
  2054. if ($category == 129) {
  2055. $list['wide'] = $this->input->post('wide', true);
  2056. }
  2057. if ($category == 131) {
  2058. $list['gifttype'] = $this->input->post('gifttype', true);
  2059. $list['giftother'] = $this->input->post('giftother', true);
  2060. }
  2061. if ($category == 134) {
  2062. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2063. }
  2064. if ($category == 1297) {
  2065. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2066. $list['sywigother'] = $this->input->post('sywigother', true);
  2067. }
  2068. if ($category == 130 || $category == 133 || $category == 1702) {
  2069. $list['items'] = $this->input->post('items', true);
  2070. $list['weight'] = $this->input->post('weight', true);
  2071. }
  2072. if($category == 130){
  2073. $list['jfother'] = $this->input->post('jfother', true);
  2074. }
  2075. if ($category == 1702) {
  2076. $list['syhairther'] = $this->input->post('syhairther', true);
  2077. }
  2078. foreach ($list as $k => $v) {
  2079. if ($v != 0) {
  2080. $num .= $v;
  2081. $features .= $v . '-';
  2082. $typeclass = $this->typeclass->read($v);
  2083. if ($k != 'size') {
  2084. $title .= $typeclass['title'] . " ";
  2085. }
  2086. }
  2087. }
  2088. $typeclass = $this->typeclass->read($list['size']);
  2089. $title .= $typeclass['title'];
  2090. $time = time();
  2091. $post['title'] = rtrim($title, ' ');
  2092. $post['number'] = $num;
  2093. $post['features'] = '-' . $features;
  2094. $post['time'] = $time; //操作时间
  2095. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2096. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2097. exit;
  2098. }
  2099. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2100. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2101. exit;
  2102. }
  2103. $uid = $this->whlabel->read($id);
  2104. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2105. if ($datanum > 0) {
  2106. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2107. exit;
  2108. }
  2109. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2110. {
  2111. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2112. if ($yza) {
  2113. if ($post['features'] != $yza[0]['features']) {
  2114. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2115. exit;
  2116. }
  2117. }
  2118. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2119. if ($yzb) {
  2120. if ($post['sku'] != $yzb[0]['sku']) {
  2121. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2122. exit;
  2123. }
  2124. }
  2125. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2126. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2127. exit;
  2128. }
  2129. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2130. foreach ($data as $v) {
  2131. $post['id'] = $v['id'];
  2132. $this->whlabel->save($post, $v['id']);
  2133. }
  2134. } else {
  2135. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2136. if ($data > 0) {
  2137. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2138. exit;
  2139. } else {
  2140. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2141. foreach ($data as $v) {
  2142. $post['id'] = $v['id'];
  2143. $this->whlabel->save($post, $v['id']);
  2144. }
  2145. }
  2146. }
  2147. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2148. exit;
  2149. }
  2150. $uid = $this->whlabel->read($arg_array[0]);
  2151. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2152. $this->data['enter'] = $uid;
  2153. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2154. $this->data['wlshop'] = $wlshop;
  2155. $this->_Template('whlabel_enteredit', $this->data);
  2156. }
  2157. //入库浏览
  2158. public function _enter()
  2159. {
  2160. $post = $this->input->post(NULL, TRUE);
  2161. if (isset($post['s'])) {
  2162. $id_arr = $this->input->post('s');
  2163. $id_arr = explode(',', $id_arr);
  2164. if (!$id_arr) {
  2165. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2166. exit;
  2167. }
  2168. //循环删除记录
  2169. foreach ($id_arr as $v) {
  2170. $sid = $this->whlabel->read($v);
  2171. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2172. if ($count > 0) {
  2173. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2174. exit;
  2175. }
  2176. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2177. foreach ($info_list as $va) {
  2178. $this->whlabel->remove($va['id']);
  2179. }
  2180. }
  2181. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2182. exit;
  2183. }
  2184. $sp = array();
  2185. $s = $this->shop->find_all('1=1', 'id,shopname');
  2186. foreach ($s as $v) {
  2187. $sp[$v['id']] = $v['shopname'];
  2188. }
  2189. $wh = array();
  2190. $w = $this->warehouse->find_all('1=1', 'id,title');
  2191. foreach ($w as $v) {
  2192. $wh[$v['id']] = $v['title'];
  2193. }
  2194. if (isset($post['page'])) {
  2195. $page = $this->input->post('page', true);
  2196. $perpage = $this->input->post('perpage', true);
  2197. $category = $this->input->post('category', true);
  2198. $size = $this->input->post('size', true);
  2199. $grade = $this->input->post('grade', true);
  2200. $color = $this->input->post('color', true);
  2201. $lowe = $this->input->post('lowe', true);
  2202. $sku = $this->input->post('sku', true);
  2203. $warehouse = $this->input->post('warehouse', true);
  2204. $purchase = $this->input->post('purchase', true);
  2205. $ktime = $this->input->post('ktime', true);
  2206. $jtime = $this->input->post('jtime', true);
  2207. $ktime = strtotime($ktime);
  2208. $jtime = strtotime($jtime);
  2209. $where = "1=1";
  2210. $gj = "";
  2211. $ck = "";
  2212. if ($category) {
  2213. $where .= " and features like '%-$category-%'";
  2214. }
  2215. if ($size) {
  2216. $where .= " and features like '%-$size-%'";
  2217. }
  2218. if ($grade) {
  2219. $where .= " and features like '%-$grade-%'";
  2220. }
  2221. if ($color) {
  2222. $where .= " and features like '%-$color-%'";
  2223. }
  2224. if ($lowe) {
  2225. $where .= " and features like '%-$lowe-%'";
  2226. }
  2227. if ($warehouse) {
  2228. $where .= " and warehouse = '$warehouse'";
  2229. }
  2230. if ($purchase) {
  2231. $where .= " and purchase = '$purchase'";
  2232. }
  2233. if ($sku) {
  2234. $where .= " and sku like '%$sku%'";
  2235. }
  2236. if ($ktime && $jtime) {
  2237. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2238. }
  2239. //数据排序
  2240. $order_str = "enter desc";
  2241. if (empty($page)) {
  2242. $start = 0;
  2243. $perpage = 1;
  2244. } else {
  2245. $start = ($page - 1) * $perpage;
  2246. }
  2247. //取得信息列表
  2248. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2249. foreach ($info_list as $k => $v) {
  2250. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2251. if ($v['shop'] == '') {
  2252. $s = '通用';
  2253. } else {
  2254. $info_list[$k]['shop'] = '';
  2255. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2256. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2257. }
  2258. }
  2259. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2260. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2261. $info_list[$k]['g'] = $g;
  2262. }
  2263. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2264. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2265. $pagenum = ceil($total / $perpage);
  2266. $over = $total - ($start + $perpage);
  2267. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2268. echo json_encode($rows);
  2269. exit;
  2270. }
  2271. $this->_Template('whlabel_enter', $this->data);
  2272. }
  2273. //出库浏览
  2274. public function _out()
  2275. {
  2276. $post = $this->input->post(NULL, TRUE);
  2277. if (isset($post['page'])) {
  2278. $page = $this->input->post('page', true);
  2279. $perpage = $this->input->post('perpage', true);
  2280. $category = $this->input->post('category', true);
  2281. $size = $this->input->post('size', true);
  2282. $grade = $this->input->post('grade', true);
  2283. $color = $this->input->post('color', true);
  2284. $lowe = $this->input->post('lowe', true);
  2285. $sku = $this->input->post('sku', true);
  2286. $warehouse = $this->input->post('warehouse', true);
  2287. $purchase = $this->input->post('purchase', true);
  2288. $state = $this->input->post('state', true);
  2289. $ktime = $this->input->post('ktime', true);
  2290. $jtime = $this->input->post('jtime', true);
  2291. $ktime = strtotime($ktime);
  2292. $jtime = strtotime($jtime);
  2293. $where = "state=3";
  2294. $gj = "";
  2295. $ck = "";
  2296. if ($category) {
  2297. $where .= " and features like '%-$category-%'";
  2298. }
  2299. if ($size) {
  2300. $where .= " and features like '%-$size-%'";
  2301. }
  2302. if ($grade) {
  2303. $where .= " and features like '%-$grade-%'";
  2304. }
  2305. if ($color) {
  2306. $where .= " and features like '%-$color-%'";
  2307. }
  2308. if ($lowe) {
  2309. $where .= " and features like '%-$lowe-%'";
  2310. }
  2311. if ($state) {
  2312. $where .= " and state = '$state'";
  2313. }
  2314. if ($warehouse) {
  2315. $where .= " and warehouse = '$warehouse'";
  2316. }
  2317. if ($purchase) {
  2318. $where .= " and purchase = '$purchase'";
  2319. }
  2320. if ($sku) {
  2321. $where .= " and sku = '$sku'";
  2322. }
  2323. if ($ktime && $jtime) {
  2324. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2325. }
  2326. //数据排序
  2327. $order_str = "id desc";
  2328. if (empty($page)) {
  2329. $start = 0;
  2330. $perpage = 1;
  2331. } else {
  2332. $start = ($page - 1) * $perpage;
  2333. }
  2334. //取得信息列表
  2335. $info_list = $this->whlabel->find_all($where, 'sku');
  2336. $rows = array();
  2337. $list = array();
  2338. foreach ($info_list as $key => $value) {
  2339. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2340. }
  2341. $rows = array_unique($rows); //删除重复记录
  2342. foreach ($rows as $key => $value) {
  2343. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2344. $ck = $this->warehouse->read($data['warehouse']);
  2345. $warehouse = $ck['title'];
  2346. $gy = $this->purchase->read($data['purchase']);
  2347. $purchase = $gy['purchase'];
  2348. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2349. $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);
  2350. }
  2351. $total = count($list);
  2352. $pagenum = ceil($total / $perpage);
  2353. $over = $total - ($start + $perpage);
  2354. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2355. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2356. echo json_encode($rows);
  2357. exit;
  2358. }
  2359. $this->_Template('whlabel_out', $this->data);
  2360. }
  2361. //出库标签浏览
  2362. public function _label()
  2363. {
  2364. $post = $this->input->post(NULL, TRUE);
  2365. if (isset($post['page'])) {
  2366. $page = $this->input->post('page', true);
  2367. $perpage = $this->input->post('perpage', true);
  2368. $sku = $this->input->post('sku', true);
  2369. $warehouse = $this->input->post('warehouse', true);
  2370. $purchase = $this->input->post('purchase', true);
  2371. $orderinfo = $this->input->post('orderinfo', true);
  2372. $waybill = $this->input->post('waybill', true);
  2373. $category = $this->input->post('category', true);
  2374. $size = $this->input->post('size', true);
  2375. $grade = $this->input->post('grade', true);
  2376. $color = $this->input->post('color', true);
  2377. $lowe = $this->input->post('lowe', true);
  2378. $where = "state=1";
  2379. if ($sku) {
  2380. $where .= " and sku = '$sku'";
  2381. }
  2382. if ($warehouse) {
  2383. $where .= " and warehouse = '$warehouse'";
  2384. }
  2385. if ($purchase) {
  2386. $where .= " and purchase = '$purchase'";
  2387. }
  2388. if ($orderinfo) {
  2389. $where .= " and orderinfo = '$orderinfo'";
  2390. }
  2391. if ($waybill) {
  2392. $where .= " and waybill = '$waybill'";
  2393. }
  2394. if ($category) {
  2395. $where .= " and features like '%-$category-%'";
  2396. }
  2397. if ($size) {
  2398. $where .= " and features like '%-$size-%'";
  2399. }
  2400. if ($grade) {
  2401. $where .= " and features like '%-$grade-%'";
  2402. }
  2403. if ($color) {
  2404. $where .= " and features like '%-$color-%'";
  2405. }
  2406. if ($lowe) {
  2407. $where .= " and features like '%-$lowe-%'";
  2408. }
  2409. //数据排序
  2410. $order_str = "outk desc";
  2411. if (empty($page)) {
  2412. $start = 0;
  2413. $perpage = 1;
  2414. } else {
  2415. $start = ($page - 1) * $perpage;
  2416. }
  2417. //取得信息列表
  2418. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2419. foreach ($info_list as $key => $value) {
  2420. $warehouse = $this->warehouse->read($value['warehouse']);
  2421. $info_list[$key]['warehouse'] = $warehouse['title'];
  2422. $purchase = $this->purchase->read($value['purchase']);
  2423. $info_list[$key]['purchase'] = $purchase['title'];
  2424. if ($value['outk'] != 0) {
  2425. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2426. } else {
  2427. $info_list[$key]['outk'] = "";
  2428. }
  2429. if ($value['orderinfo'] == 0) {
  2430. $info_list[$key]['orderinfo'] = "";
  2431. }
  2432. if ($value['waybill'] == 0) {
  2433. $info_list[$key]['waybill'] = "";
  2434. }
  2435. }
  2436. $total = $this->whlabel->find_count($where);
  2437. $pagenum = ceil($total / $perpage);
  2438. $over = $total - ($start + $perpage);
  2439. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2440. echo json_encode($rows);
  2441. exit;
  2442. }
  2443. $this->_Template('whlabel_label', $this->data);
  2444. }
  2445. //独立站出库订单
  2446. public function _outorder()
  2447. {
  2448. if (isset($_SESSION['api'])) {
  2449. $user = $this->user->get_api($_SESSION['api']);
  2450. $usp = $user;
  2451. $fgshop = "";
  2452. $sid = "";
  2453. $user = explode('|', trim($user['shop'], '|'));
  2454. foreach ($user as $value) {
  2455. $fgshop .= " shop = " . $value . " or";
  2456. $sid .= " id = " . $value . " or";
  2457. }
  2458. } else {
  2459. echo "请重新登录";
  2460. }
  2461. $post = $this->input->post(NULL, TRUE);
  2462. if (isset($post['page'])) {
  2463. $page = $this->input->post('page', true);
  2464. $perpage = $this->input->post('perpage', true);
  2465. $warehouse = $this->input->post('warehouse', true);
  2466. $xztime = $this->input->post('xztime', true);
  2467. $timetk = $this->input->post('timetkk', true);
  2468. $timetj = $this->input->post('timetjj', true);
  2469. $shop = $this->input->post('shop', true);
  2470. $source = $this->input->post('source', true);
  2471. $orderinfo = $this->input->post('orderinfo', true);
  2472. $number = $this->input->post('number', true);
  2473. $sfxh = $this->input->post('sfxh', true);
  2474. $express = $this->input->post('express', true);
  2475. $waybill = $this->input->post('waybill', true);
  2476. $library = $this->input->post('library', true);
  2477. $country = $this->input->post('country', true);
  2478. $so = $this->input->post('so', true);
  2479. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2480. $print = $this->input->post('print', true);
  2481. $state = $this->input->post('state', true);
  2482. $orderurl = $this->input->post('orderurl', true);
  2483. $productid = $this->input->post('productid', true);
  2484. $timetk = strtotime($timetk);
  2485. $timetj = strtotime($timetj);
  2486. /**
  2487. $sj = $this->input->post('sj',true);
  2488. if($sj)
  2489. {
  2490. $sj = $this->input->post('sj',true);
  2491. }
  2492. else
  2493. {
  2494. $sj = "fullorder";
  2495. }
  2496. **/
  2497. $sj = "fullorder";
  2498. $where = "1=1";
  2499. if ($warehouse) {
  2500. $where .= " and type = '$warehouse'";
  2501. }
  2502. if ($timetk && $timetj) {
  2503. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2504. }
  2505. if ($orderinfo) {
  2506. $where .= " and orderinfo = '$orderinfo'";
  2507. }
  2508. if ($number) {
  2509. $where .= " and number = '$number'";
  2510. }
  2511. if ($express) {
  2512. $where .= " and express = '$express'";
  2513. }
  2514. if ($waybill) {
  2515. $where .= " and waybill = '$waybill'";
  2516. }
  2517. if ($library) {
  2518. $where .= " and library = '$library'";
  2519. }
  2520. if ($print) {
  2521. $where .= " and print = '$print'";
  2522. }
  2523. if ($libraryconfirm) {
  2524. $where .= " and libraryconfirm = '$libraryconfirm'";
  2525. }
  2526. if ($state) {
  2527. $where .= " and state = '$state'";
  2528. }
  2529. if ($shop) {
  2530. $where .= " and shop = '$shop'";
  2531. }
  2532. if ($country) {
  2533. $where .= " and country = '$country'";
  2534. }
  2535. if ($sfxh != '') {
  2536. $where .= " and sfxh = '$sfxh'";
  2537. }
  2538. if ($so) {
  2539. $where .= " and shipremarks like '%$so%'";
  2540. }
  2541. if ($source) {
  2542. if ($source == '2d') {
  2543. $where .= " and source >= '2'";
  2544. } else {
  2545. $where .= " and source = '$source'";
  2546. }
  2547. }
  2548. if (isset($_SESSION['api'])) {
  2549. foreach ($user as $value) {
  2550. $fgshop .= " shop = " . $value . " or";
  2551. }
  2552. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2553. }
  2554. if ($orderurl) {
  2555. $url = $this->orderurl->read($orderurl);
  2556. $where .= " and link like '%" . $url['url'] . "%'";
  2557. }
  2558. if($productid){
  2559. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2560. }
  2561. //数据排序
  2562. $order_str = "librarytime desc";
  2563. if (empty($page)) {
  2564. $start = 0;
  2565. $perpage = 1;
  2566. } else {
  2567. $start = ($page - 1) * $perpage;
  2568. }
  2569. //取得信息列表
  2570. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2571. //格式化数据
  2572. foreach ($info_list as $key => $value) {
  2573. $shop = $this->shop->read($value['shop']);
  2574. $info_list[$key]['shop'] = $shop['shopname'];
  2575. $express = $this->express->read($value['express']);
  2576. $info_list[$key]['express'] = $express['servicename'];
  2577. $warehouse = $this->warehouse->read($value['type']);
  2578. $info_list[$key]['type'] = $warehouse['title'];
  2579. if ($value['librarytime'] == '0') {
  2580. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2581. } else {
  2582. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2583. }
  2584. }
  2585. $total = $this->$sj->find_count($where);
  2586. $pagenum = ceil($total / $perpage);
  2587. $over = $total - ($start + $perpage);
  2588. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2589. echo json_encode($rows);
  2590. exit;
  2591. }
  2592. $this->data['express'] = $this->express->find_all();
  2593. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2594. $this->data['wlshop'] = $wlshop;
  2595. $user = $this->user->get_api($_SESSION['api']);
  2596. $powerid = $this->power->read($user['power']);
  2597. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2598. $pid = '';
  2599. foreach ($powertext as $v) {
  2600. $pid .= " id = " . $v . " or";
  2601. }
  2602. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2603. $this->data['fullorderexcel'] = $fullorderexcel;
  2604. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2605. $this->data['orderurl'] = $orderurl;
  2606. $this->_Template('whlabel_outorder', $this->data);
  2607. }
  2608. //tt出库
  2609. public function _toutorder()
  2610. {
  2611. $fgshop = "";
  2612. $sid = "";
  2613. if (isset($_SESSION['api'])) {
  2614. $user = $this->user->get_api($_SESSION['api']);
  2615. $usp = $user;
  2616. $user = explode('|', trim($user['shop'], '|'));
  2617. foreach ($user as $value) {
  2618. $fgshop .= " shop = " . $value . " or";
  2619. $sid .= " id = " . $value . " or";
  2620. }
  2621. } else {
  2622. echo "请重新登录";
  2623. die;
  2624. }
  2625. $post = $this->input->post(NULL, TRUE);
  2626. if (isset($post['page'])) {
  2627. $page = $this->input->post('page', true);
  2628. $perpage = $this->input->post('perpage', true);
  2629. $warehouse = $this->input->post('warehouse', true);
  2630. $xztime = $this->input->post('xztime', true);
  2631. $timetk = $this->input->post('timetkk', true);
  2632. $timetj = $this->input->post('timetjj', true);
  2633. $shop = $this->input->post('shop', true);
  2634. $source = $this->input->post('source', true);
  2635. $orderinfo = $this->input->post('orderinfo', true);
  2636. $number = $this->input->post('number', true);
  2637. $sfxh = $this->input->post('sfxh', true);
  2638. $express = $this->input->post('express', true);
  2639. $waybill = $this->input->post('waybill', true);
  2640. $library = $this->input->post('library', true);
  2641. $country = $this->input->post('country', true);
  2642. $so = $this->input->post('so', true);
  2643. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2644. $print = $this->input->post('print', true);
  2645. $state = $this->input->post('state', true);
  2646. $orderurl = $this->input->post('orderurl', true);
  2647. $timetk = strtotime($timetk);
  2648. $timetj = strtotime($timetj);
  2649. /**
  2650. $sj = $this->input->post('sj',true);
  2651. if($sj)
  2652. {
  2653. $sj = $this->input->post('sj',true);
  2654. }
  2655. else
  2656. {
  2657. $sj = "fullorder";
  2658. }
  2659. **/
  2660. $sj = "fullordertt";
  2661. $where = "1=1";
  2662. if ($warehouse) {
  2663. $where .= " and type = '$warehouse'";
  2664. }
  2665. if ($timetk && $timetj) {
  2666. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2667. }
  2668. if ($orderinfo) {
  2669. $where .= " and orderinfo = '$orderinfo'";
  2670. }
  2671. if ($number) {
  2672. $where .= " and number = '$number'";
  2673. }
  2674. if ($express) {
  2675. $where .= " and express = '$express'";
  2676. }
  2677. if ($waybill) {
  2678. $where .= " and waybill = '$waybill'";
  2679. }
  2680. if ($library) {
  2681. $where .= " and library = '$library'";
  2682. }
  2683. if ($print) {
  2684. $where .= " and print = '$print'";
  2685. }
  2686. if ($libraryconfirm) {
  2687. $where .= " and libraryconfirm = '$libraryconfirm'";
  2688. }
  2689. if ($state) {
  2690. $where .= " and state = '$state'";
  2691. }
  2692. if ($shop) {
  2693. $where .= " and shop = '$shop'";
  2694. }
  2695. if ($country) {
  2696. $where .= " and country = '$country'";
  2697. }
  2698. if ($sfxh != '') {
  2699. $where .= " and sfxh = '$sfxh'";
  2700. }
  2701. if ($so) {
  2702. $where .= " and shipremarks like '%$so%'";
  2703. }
  2704. if ($source) {
  2705. if ($source == '2d') {
  2706. $where .= " and source >= '2'";
  2707. } else {
  2708. $where .= " and source = '$source'";
  2709. }
  2710. }
  2711. if (isset($_SESSION['api'])) {
  2712. foreach ($user as $value) {
  2713. $fgshop .= " shop = " . $value . " or";
  2714. }
  2715. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2716. }
  2717. if ($orderurl) {
  2718. $url = $this->orderurl->read($orderurl);
  2719. $where .= " and link like '%" . $url['url'] . "%'";
  2720. }
  2721. //数据排序
  2722. $order_str = "librarytime desc";
  2723. if (empty($page)) {
  2724. $start = 0;
  2725. $perpage = 1;
  2726. } else {
  2727. $start = ($page - 1) * $perpage;
  2728. }
  2729. //取得信息列表
  2730. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2731. //格式化数据
  2732. foreach ($info_list as $key => $value) {
  2733. $shop = $this->shop->read($value['shop']);
  2734. $info_list[$key]['shop'] = $shop['shopname'];
  2735. $express = $this->express->read($value['express']);
  2736. $info_list[$key]['express'] = $express['servicename'];
  2737. $warehouse = $this->warehouse->read($value['type']);
  2738. $info_list[$key]['type'] = $warehouse['title'];
  2739. if ($value['librarytime'] == '0') {
  2740. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2741. } else {
  2742. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2743. }
  2744. }
  2745. $total = $this->$sj->find_count($where);
  2746. $pagenum = ceil($total / $perpage);
  2747. $over = $total - ($start + $perpage);
  2748. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2749. echo json_encode($rows);
  2750. exit;
  2751. }
  2752. $this->data['express'] = $this->express->find_all();
  2753. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2754. $this->data['wlshop'] = $wlshop;
  2755. $user = $this->user->get_api($_SESSION['api']);
  2756. $powerid = $this->power->read($user['power']);
  2757. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2758. $pid = '';
  2759. foreach ($powertext as $v) {
  2760. $pid .= " id = " . $v . " or";
  2761. }
  2762. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2763. $this->data['fullorderexcel'] = $fullorderexcel;
  2764. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2765. $this->data['orderurl'] = $orderurl;
  2766. $this->_Template('whlabel_toutorder', $this->data);
  2767. }
  2768. //tt出库
  2769. public function _aoutorder()
  2770. {
  2771. if (isset($_SESSION['api'])) {
  2772. $user = $this->user->get_api($_SESSION['api']);
  2773. $usp = $user;
  2774. $fgshop = "";
  2775. $sid = "";
  2776. $user = explode('|', trim($user['shop'], '|'));
  2777. foreach ($user as $value) {
  2778. $fgshop .= " shop = " . $value . " or";
  2779. $sid .= " id = " . $value . " or";
  2780. }
  2781. } else {
  2782. echo "请重新登录";
  2783. }
  2784. $post = $this->input->post(NULL, TRUE);
  2785. if (isset($post['page'])) {
  2786. $page = $this->input->post('page', true);
  2787. $perpage = $this->input->post('perpage', true);
  2788. $warehouse = $this->input->post('warehouse', true);
  2789. $xztime = $this->input->post('xztime', true);
  2790. $timetk = $this->input->post('timetkk', true);
  2791. $timetj = $this->input->post('timetjj', true);
  2792. $shop = $this->input->post('shop', true);
  2793. $source = $this->input->post('source', true);
  2794. $orderinfo = $this->input->post('orderinfo', true);
  2795. $number = $this->input->post('number', true);
  2796. $sfxh = $this->input->post('sfxh', true);
  2797. $express = $this->input->post('express', true);
  2798. $waybill = $this->input->post('waybill', true);
  2799. $library = $this->input->post('library', true);
  2800. $country = $this->input->post('country', true);
  2801. $so = $this->input->post('so', true);
  2802. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2803. $print = $this->input->post('print', true);
  2804. $state = $this->input->post('state', true);
  2805. $orderurl = $this->input->post('orderurl', true);
  2806. $timetk = strtotime($timetk);
  2807. $timetj = strtotime($timetj);
  2808. /**
  2809. $sj = $this->input->post('sj',true);
  2810. if($sj)
  2811. {
  2812. $sj = $this->input->post('sj',true);
  2813. }
  2814. else
  2815. {
  2816. $sj = "fullorder";
  2817. }
  2818. **/
  2819. $sj = "fullorderamz";
  2820. $where = "1=1";
  2821. if ($warehouse) {
  2822. $where .= " and type = '$warehouse'";
  2823. }
  2824. if ($timetk && $timetj) {
  2825. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2826. }
  2827. if ($orderinfo) {
  2828. $where .= " and orderinfo = '$orderinfo'";
  2829. }
  2830. if ($number) {
  2831. $where .= " and number = '$number'";
  2832. }
  2833. if ($express) {
  2834. $where .= " and express = '$express'";
  2835. }
  2836. if ($waybill) {
  2837. $where .= " and waybill = '$waybill'";
  2838. }
  2839. if ($library) {
  2840. $where .= " and library = '$library'";
  2841. }
  2842. if ($print) {
  2843. $where .= " and print = '$print'";
  2844. }
  2845. if ($libraryconfirm) {
  2846. $where .= " and libraryconfirm = '$libraryconfirm'";
  2847. }
  2848. if ($state) {
  2849. $where .= " and state = '$state'";
  2850. }
  2851. if ($shop) {
  2852. $where .= " and shop = '$shop'";
  2853. }
  2854. if ($country) {
  2855. $where .= " and country = '$country'";
  2856. }
  2857. if ($sfxh != '') {
  2858. $where .= " and sfxh = '$sfxh'";
  2859. }
  2860. if ($so) {
  2861. $where .= " and shipremarks like '%$so%'";
  2862. }
  2863. if ($source) {
  2864. if ($source == '2d') {
  2865. $where .= " and source >= '2'";
  2866. } else {
  2867. $where .= " and source = '$source'";
  2868. }
  2869. }
  2870. if (isset($_SESSION['api'])) {
  2871. foreach ($user as $value) {
  2872. $fgshop .= " shop = " . $value . " or";
  2873. }
  2874. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2875. }
  2876. if ($orderurl) {
  2877. $url = $this->orderurl->read($orderurl);
  2878. $where .= " and link like '%" . $url['url'] . "%'";
  2879. }
  2880. //数据排序
  2881. $order_str = "librarytime desc";
  2882. if (empty($page)) {
  2883. $start = 0;
  2884. $perpage = 1;
  2885. } else {
  2886. $start = ($page - 1) * $perpage;
  2887. }
  2888. //取得信息列表
  2889. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2890. //格式化数据
  2891. foreach ($info_list as $key => $value) {
  2892. $shop = $this->shop->read($value['shop']);
  2893. $info_list[$key]['shop'] = $shop['shopname'];
  2894. $express = $this->express->read($value['express']);
  2895. $info_list[$key]['express'] = $express['servicename'];
  2896. $warehouse = $this->warehouse->read($value['type']);
  2897. $info_list[$key]['type'] = $warehouse['title'];
  2898. if ($value['librarytime'] == '0') {
  2899. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2900. } else {
  2901. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2902. }
  2903. }
  2904. $total = $this->$sj->find_count($where);
  2905. $pagenum = ceil($total / $perpage);
  2906. $over = $total - ($start + $perpage);
  2907. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2908. echo json_encode($rows);
  2909. exit;
  2910. }
  2911. $this->data['express'] = $this->express->find_all();
  2912. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2913. $this->data['wlshop'] = $wlshop;
  2914. $user = $this->user->get_api($_SESSION['api']);
  2915. $powerid = $this->power->read($user['power']);
  2916. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2917. $pid = '';
  2918. foreach ($powertext as $v) {
  2919. $pid .= " id = " . $v . " or";
  2920. }
  2921. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2922. $this->data['fullorderexcel'] = $fullorderexcel;
  2923. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2924. $this->data['orderurl'] = $orderurl;
  2925. $this->_Template('whlabel_aoutorder', $this->data);
  2926. }
  2927. //速卖通出库订单
  2928. public function _soutorder()
  2929. {
  2930. if (isset($_SESSION['api'])) {
  2931. $user = $this->user->get_api($_SESSION['api']);
  2932. $usp = $user;
  2933. $fgshop = "";
  2934. $sid = "";
  2935. $user = explode('|', trim($user['shop'], '|'));
  2936. foreach ($user as $value) {
  2937. $sid .= " id = " . $value . " or";
  2938. }
  2939. }
  2940. $post = $this->input->post(NULL, TRUE);
  2941. if (isset($post['page'])) {
  2942. $page = $this->input->post('page', true);
  2943. $perpage = $this->input->post('perpage', true);
  2944. $warehouse = $this->input->post('warehouse', true);
  2945. $xztime = $this->input->post('xztime', true);
  2946. $timetk = $this->input->post('timetkk', true);
  2947. $timetj = $this->input->post('timetjj', true);
  2948. $shop = $this->input->post('shop', true);
  2949. $source = $this->input->post('source', true);
  2950. $orderinfo = $this->input->post('orderinfo', true);
  2951. $number = $this->input->post('number', true);
  2952. $express = $this->input->post('express', true);
  2953. $waybill = $this->input->post('waybill', true);
  2954. $library = $this->input->post('library', true);
  2955. $country = $this->input->post('country', true);
  2956. $sfxh = $this->input->post('sfxh', true);
  2957. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2958. $print = $this->input->post('print', true);
  2959. $state = $this->input->post('state', true);
  2960. $so = $this->input->post('so', true);
  2961. $timetk = strtotime($timetk);
  2962. $timetj = strtotime($timetj);
  2963. /**
  2964. $sj = $this->input->post('sj',true);
  2965. if($sj)
  2966. {
  2967. $sj = $this->input->post('sj',true);
  2968. }
  2969. else
  2970. {
  2971. $sj = "fullorder";
  2972. }
  2973. **/
  2974. $sj = "fullordersmt";
  2975. $where = "1=1";
  2976. if ($warehouse) {
  2977. $where .= " and type = '$warehouse'";
  2978. }
  2979. if ($timetk && $timetj) {
  2980. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2981. }
  2982. if ($orderinfo) {
  2983. $where .= " and orderinfo = '$orderinfo'";
  2984. }
  2985. if ($number) {
  2986. $where .= " and number = '$number'";
  2987. }
  2988. if ($express) {
  2989. $where .= " and express = '$express'";
  2990. }
  2991. if ($waybill) {
  2992. $where .= " and waybill = '$waybill'";
  2993. }
  2994. if ($library) {
  2995. $where .= " and library = '$library'";
  2996. }
  2997. if ($print) {
  2998. $where .= " and print = '$print'";
  2999. }
  3000. if ($libraryconfirm) {
  3001. $where .= " and libraryconfirm = '$libraryconfirm'";
  3002. }
  3003. if ($state) {
  3004. $where .= " and state = '$state'";
  3005. }
  3006. if ($shop) {
  3007. $where .= " and shop = '$shop'";
  3008. }
  3009. if ($sfxh != '') {
  3010. $where .= " and sfxh = '$sfxh'";
  3011. }
  3012. if ($so) {
  3013. $where .= " and shipremarks like '%$so%'";
  3014. }
  3015. if ($source) {
  3016. $where .= " and source = '$source'";
  3017. }
  3018. if ($country) {
  3019. $where .= " and country = '$country'";
  3020. } else {
  3021. if (isset($_SESSION['api'])) {
  3022. foreach ($user as $value) {
  3023. $fgshop .= " shop = " . $value . " or";
  3024. }
  3025. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3026. }
  3027. }
  3028. //数据排序
  3029. $order_str = "librarytime desc";
  3030. if (empty($page)) {
  3031. $start = 0;
  3032. $perpage = 1;
  3033. } else {
  3034. $start = ($page - 1) * $perpage;
  3035. }
  3036. //取得信息列表
  3037. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3038. //格式化数据
  3039. foreach ($info_list as $key => $value) {
  3040. $shop = $this->shop->read($value['shop']);
  3041. $info_list[$key]['shop'] = $shop['shopname'];
  3042. $express = $this->express->read($value['express']);
  3043. $info_list[$key]['express'] = $express['servicename'];
  3044. $warehouse = $this->warehouse->read($value['type']);
  3045. $info_list[$key]['type'] = $warehouse['title'];
  3046. if ($value['librarytime'] == '0') {
  3047. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3048. } else {
  3049. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3050. }
  3051. }
  3052. $total = $this->$sj->find_count($where);
  3053. $pagenum = ceil($total / $perpage);
  3054. $over = $total - ($start + $perpage);
  3055. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3056. echo json_encode($rows);
  3057. exit;
  3058. }
  3059. $this->data['express'] = $this->express->find_all();
  3060. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3061. $this->data['wlshop'] = $wlshop;
  3062. $user = $this->user->get_api($_SESSION['api']);
  3063. $powerid = $this->power->read($user['power']);
  3064. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3065. $pid = '';
  3066. foreach ($powertext as $v) {
  3067. $pid .= " id = " . $v . " or";
  3068. }
  3069. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3070. $this->data['fullorderexcel'] = $fullorderexcel;
  3071. $this->_Template('whlabel_soutorder', $this->data);
  3072. }
  3073. //订单退库
  3074. public function _retreat()
  3075. {
  3076. $post = $this->input->post(NULL, TRUE);
  3077. if (isset($post['page'])) {
  3078. $page = $this->input->post('page', true);
  3079. $perpage = $this->input->post('perpage', true);
  3080. $warehouse = $this->input->post('warehouse', true);
  3081. $timetk = $this->input->post('timetk', true);
  3082. $timetj = $this->input->post('timetj', true);
  3083. $shop = $this->input->post('shop', true);
  3084. $source = $this->input->post('source', true);
  3085. $state = $this->input->post('state', true);
  3086. $review = $this->input->post('review', true);
  3087. $state = $this->input->post('state', true);
  3088. $express = $this->input->post('express', true);
  3089. $orderinfo = $this->input->post('orderinfo', true);
  3090. $user = $this->input->post('user', true);
  3091. $name = $this->input->post('name', true);
  3092. $waybill = $this->input->post('waybill', true);
  3093. $timetk = strtotime($timetk);
  3094. $timetj = strtotime($timetj);
  3095. $where = "(state=206 or state=210) and mergeid = 0";
  3096. if ($warehouse) {
  3097. $where .= " and state = '$warehouse'";
  3098. }
  3099. if ($timetk && $timetj) {
  3100. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3101. }
  3102. if ($shop) {
  3103. $where .= " and shop = '$shop'";
  3104. }
  3105. if ($source) {
  3106. $where .= " and source = '$source'";
  3107. }
  3108. if ($state) {
  3109. $where .= " and state = '$state'";
  3110. }
  3111. if ($review) {
  3112. $where .= " and review = '$review'";
  3113. }
  3114. if ($state) {
  3115. $where .= " and state = '$state'";
  3116. }
  3117. if ($express) {
  3118. $where .= " and express = '$express'";
  3119. }
  3120. if ($orderinfo) {
  3121. $where .= " and orderinfo = '$orderinfo'";
  3122. }
  3123. if ($user) {
  3124. $where .= " and user = '$user'";
  3125. }
  3126. if ($name) {
  3127. $where .= " and name = '$name'";
  3128. }
  3129. if ($waybill) {
  3130. $where .= " and waybill = '$waybill'";
  3131. }
  3132. //数据排序
  3133. $order_str = "id desc";
  3134. if (empty($page)) {
  3135. $start = 0;
  3136. $perpage = 1;
  3137. } else {
  3138. $start = ($page - 1) * $perpage;
  3139. }
  3140. //取得信息列表
  3141. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3142. //格式化数据
  3143. foreach ($info_list as $key => $value) {
  3144. $shop = $this->shop->read($value['shop']);
  3145. $info_list[$key]['shop'] = $shop['shopname'];
  3146. $warehouse = $this->warehouse->read($value['warehouse']);
  3147. $info_list[$key]['warehouse'] = $warehouse['title'];
  3148. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3149. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3150. if ($value['waybill'] == 0) {
  3151. $info_list[$key]['waybill'] = "";
  3152. }
  3153. $express = $this->express->read($value['express']);
  3154. $info_list[$key]['express'] = $express['title'];
  3155. $typeclass = $this->typeclass->read($value['state']);
  3156. $info_list[$key]['state'] = $typeclass['title'];
  3157. }
  3158. $total = $this->fullorder->find_count($where);
  3159. $pagenum = ceil($total / $perpage);
  3160. $over = $total - ($start + $perpage);
  3161. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3162. echo json_encode($rows);
  3163. exit;
  3164. }
  3165. $this->data['express'] = $this->express->find_all();
  3166. $this->_Template('whlabel_retreat', $this->data);
  3167. }
  3168. //退库标签浏览
  3169. public function _retreatlk()
  3170. {
  3171. $post = $this->input->post(NULL, TRUE);
  3172. if (isset($post['page'])) {
  3173. $page = $this->input->post('page', true);
  3174. $perpage = $this->input->post('perpage', true);
  3175. $timetk = $this->input->post('timetk', true);
  3176. $timetj = $this->input->post('timetj', true);
  3177. $sku = $this->input->post('sku', true);
  3178. $warehouse = $this->input->post('warehouse', true);
  3179. $purchase = $this->input->post('purchase', true);
  3180. $orderinfo = $this->input->post('orderinfo', true);
  3181. $waybill = $this->input->post('waybill', true);
  3182. $category = $this->input->post('category', true);
  3183. $size = $this->input->post('size', true);
  3184. $grade = $this->input->post('grade', true);
  3185. $color = $this->input->post('color', true);
  3186. $lowe = $this->input->post('lowe', true);
  3187. $state = $this->input->post('state', true);
  3188. $timetk = strtotime($timetk);
  3189. $timetj = strtotime($timetj);
  3190. $where = "state=2";
  3191. if ($timetk && $timetj) {
  3192. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3193. }
  3194. if ($sku) {
  3195. $where .= " and sku = '$sku'";
  3196. }
  3197. if ($warehouse) {
  3198. $where .= " and warehouse = '$warehouse'";
  3199. }
  3200. if ($purchase) {
  3201. $where .= " and purchase = '$purchase'";
  3202. }
  3203. if ($orderinfo) {
  3204. $where .= " and orderinfo = '$orderinfo'";
  3205. }
  3206. if ($waybill) {
  3207. $where .= " and waybill = '$waybill'";
  3208. }
  3209. if ($category) {
  3210. $where .= " and features like '%-$category-%'";
  3211. }
  3212. if ($size) {
  3213. $where .= " and features like '%-$size-%'";
  3214. }
  3215. if ($grade) {
  3216. $where .= " and features like '%-$grade-%'";
  3217. }
  3218. if ($color) {
  3219. $where .= " and features like '%-$color-%'";
  3220. }
  3221. if ($lowe) {
  3222. $where .= " and features like '%-$lowe-%'";
  3223. }
  3224. //数据排序
  3225. $order_str = "time desc";
  3226. if (empty($page)) {
  3227. $start = 0;
  3228. $perpage = 1;
  3229. } else {
  3230. $start = ($page - 1) * $perpage;
  3231. }
  3232. //取得信息列表
  3233. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3234. foreach ($info_list as $key => $value) {
  3235. $warehouse = $this->warehouse->read($value['warehouse']);
  3236. $info_list[$key]['warehouse'] = $warehouse['title'];
  3237. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3238. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3239. $purchase = $this->purchase->read($value['purchase']);
  3240. $info_list[$key]['purchase'] = $purchase['title'];
  3241. if ($value['outk'] != 0) {
  3242. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3243. } else {
  3244. $info_list[$key]['outk'] = "";
  3245. }
  3246. if ($value['retreat'] != 0) {
  3247. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3248. } else {
  3249. $info_list[$key]['retreat'] = "";
  3250. }
  3251. if ($value['orderinfo'] == 0) {
  3252. $info_list[$key]['orderinfo'] = "";
  3253. }
  3254. if ($value['waybill'] == 0) {
  3255. $info_list[$key]['waybill'] = "";
  3256. }
  3257. }
  3258. $total = $this->whlabel->find_count($where);
  3259. $pagenum = ceil($total / $perpage);
  3260. $over = $total - ($start + $perpage);
  3261. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3262. echo json_encode($rows);
  3263. exit;
  3264. }
  3265. $this->_Template('whlabel_retreatlk', $this->data);
  3266. }
  3267. //更换标签及浏览
  3268. public function _change()
  3269. {
  3270. $post = $this->input->post(NULL, TRUE);
  3271. if (isset($post['page'])) {
  3272. $page = $this->input->post('page', true);
  3273. $perpage = $this->input->post('perpage', true);
  3274. $timetk = $this->input->post('timetk', true);
  3275. $timetj = $this->input->post('timetj', true);
  3276. $label = $this->input->post('label', true);
  3277. $oldlabel = $this->input->post('oldlabel', true);
  3278. $timetk = strtotime($timetk);
  3279. $timetj = strtotime($timetj);
  3280. $where = "state=10 ";
  3281. if ($timetk && $timetj) {
  3282. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3283. }
  3284. if ($label) {
  3285. $where .= " and label = '$label'";
  3286. }
  3287. if ($oldlabel) {
  3288. $where .= " and oldlabel = '$oldlabel'";
  3289. }
  3290. //数据排序
  3291. $order_str = "time asc";
  3292. if (empty($page)) {
  3293. $start = 0;
  3294. $perpage = 1;
  3295. } else {
  3296. $start = ($page - 1) * $perpage;
  3297. }
  3298. //取得信息列表
  3299. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3300. foreach ($info_list as $key => $value) {
  3301. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3302. }
  3303. $total = $this->whlabel->find_count($where);
  3304. $pagenum = ceil($total / $perpage);
  3305. $over = $total - ($start + $perpage);
  3306. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3307. echo json_encode($rows);
  3308. exit;
  3309. }
  3310. $this->_Template('whlabel_change', $this->data);
  3311. }
  3312. //产品标签
  3313. public function _cpbqdc()
  3314. {
  3315. if (isset($_GET['excel'])) {
  3316. $where = "1=1";
  3317. //数据排序
  3318. $order_str = "id desc";
  3319. if (empty($page)) {
  3320. $start = 0;
  3321. $perpage = 1;
  3322. } else {
  3323. $start = ($page - 1) * $perpage;
  3324. }
  3325. $warehouse = $this->input->get('warehouse', true);
  3326. $state = $this->input->get('state', true);
  3327. $timetk = $this->input->get('timetkk', true);
  3328. $timetj = $this->input->get('timetjj', true);
  3329. $timetk = strtotime($timetk);
  3330. $timetj = strtotime($timetj);
  3331. if ($warehouse) {
  3332. $where .= " and warehouse = '$warehouse'";
  3333. }
  3334. if ($state || $state == 0) {
  3335. $where .= " and state = '$state'";
  3336. }
  3337. if ($timetk && $timetj) {
  3338. $where .= " and time > '$timetk' and time < '$timetj'";
  3339. }
  3340. //取得信息列表
  3341. $info_list = $this->whlabel->find_all($where, '*');
  3342. $rows = array();
  3343. $list = array();
  3344. foreach ($info_list as $key => $value) {
  3345. $rows[$value['time']] = $value; //所有数据sku
  3346. }
  3347. foreach ($rows as $value) {
  3348. $warehouse = $this->warehouse->read($value['warehouse']);
  3349. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3350. $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);
  3351. }
  3352. $title = "产品标签统计表";
  3353. $titlename = "<table border=1>
  3354. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3355. <tr align='center'>
  3356. <td>仓库</td>
  3357. <td>SKU</td>
  3358. <td>产品</td>
  3359. <td>入库时间</td>
  3360. <td>操作时间</td>
  3361. <td>备注</td>
  3362. <td>数量</td>
  3363. </tr>
  3364. </table>";
  3365. $filename = $title . ".xls";
  3366. $tail = "";
  3367. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3368. }
  3369. }
  3370. //进销存导出
  3371. public function _exceljxc()
  3372. {
  3373. $classid = $this->classid->sku();
  3374. $pm = $classid;
  3375. $typeclass = array();
  3376. $tc = $this->typeclass->find_all();
  3377. foreach ($tc as $v) {
  3378. $typeclass[$v['id']] = $v;
  3379. }
  3380. $prc = array();
  3381. $purchase = $this->purchase->find_all();
  3382. foreach ($purchase as $k => $v) {
  3383. $prc[$v['id']] = $v['title'];
  3384. }
  3385. if (isset($_GET['excel'])) {
  3386. $where = "sku != 'Preset'";
  3387. //数据排序
  3388. $order_str = "id desc";
  3389. if (empty($page)) {
  3390. $start = 0;
  3391. $perpage = 1;
  3392. } else {
  3393. $start = ($page - 1) * $perpage;
  3394. }
  3395. $category = $this->input->get('category', true);
  3396. $warehouse = $this->input->get('warehouse', true);
  3397. $excelid = $this->input->get('sid', true);
  3398. if ($category) {
  3399. $where .= " and features like '%-$category-%'";
  3400. }
  3401. if ($warehouse) {
  3402. $where .= " and warehouse = '$warehouse'";
  3403. }
  3404. $xzid = '';
  3405. if ($excelid) {
  3406. $excelid = explode(',', trim($excelid, ','));
  3407. foreach ($excelid as $key => $value) {
  3408. $xzid .= " id = " . $value . " or";
  3409. }
  3410. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3411. }
  3412. //取得信息列表
  3413. /**
  3414. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3415. $rows = array();$list = array();
  3416. foreach ($info_list as $key=>$value)
  3417. {
  3418. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3419. }
  3420. **/
  3421. $wt = array();
  3422. $whlabel_type = $this->whlabel_type->find_all();
  3423. foreach ($whlabel_type as $v) {
  3424. $wt[$v['id']] = $v['title'];
  3425. }
  3426. $wh = array();
  3427. $w = $this->warehouse->find_all('1=1', 'id,title');
  3428. foreach ($w as $v) {
  3429. $wh[$v['id']] = $v['title'];
  3430. }
  3431. $list = array();
  3432. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3433. foreach ($rows as $key => $value) {
  3434. if (isset($wt[$value['type']])) {
  3435. $rows[$key]['type'] = $wt[$value['type']];
  3436. } else {
  3437. $rows[$key]['type'] = '未设置';
  3438. }
  3439. $bm = '03';
  3440. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3441. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3442. $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');
  3443. $details = array();
  3444. $cpid = array();
  3445. $cpbz = array();
  3446. $c = 0;
  3447. $g = 0;
  3448. $x = 0;
  3449. $t = 0;
  3450. $s = 0;
  3451. $q = 0;
  3452. foreach ($sd as $k => $v) {
  3453. if ($v['state'] == 0) {
  3454. $c++;
  3455. if ($v['cpid'] != 0) {
  3456. $cpid[$v['cpid']] = $v['cpid'];
  3457. }
  3458. if ($v['cpbz'] != '') {
  3459. $cpbz[$v['cpbz']] = $v['cpbz'];
  3460. }
  3461. }
  3462. if ($v['state'] != 9) {
  3463. $g++;
  3464. }
  3465. if ($v['state'] == 1) {
  3466. $x++;
  3467. }
  3468. if ($v['state'] == 2) {
  3469. $t++;
  3470. }
  3471. if ($v['state'] == 8) {
  3472. $s++;
  3473. }
  3474. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3475. $q++;
  3476. }
  3477. $details[$v['details']] = $v['details'];
  3478. }
  3479. $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'] . '"');
  3480. $rows[$key]['details'] = implode("、", $details);
  3481. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3482. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3483. $number = $value['number'];
  3484. $ftime = time() - 15 * 24 * 3600;
  3485. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3486. $rows[$key]['number'] = $g;
  3487. $rows[$key]['c'] = $c;
  3488. $rows[$key]['x'] = $x;
  3489. $rows[$key]['t'] = $t;
  3490. $rows[$key]['s'] = $s;
  3491. $rows[$key]['q'] = $q;
  3492. $rows[$key]['z'] = $z;
  3493. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3494. $features = explode('-', trim($features, '-'));
  3495. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3496. // $pm = $classid;
  3497. // $jm = $classid;
  3498. // foreach($features as $k=>$v)
  3499. // {
  3500. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3501. // {
  3502. // if($typeclass[$v]['bm'] != '')
  3503. // {
  3504. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3505. // }
  3506. // }
  3507. // if($v != 0)
  3508. // {
  3509. // if(!isset($typeclass[$v]))
  3510. // {
  3511. // continue;
  3512. // }
  3513. // if(isset($pm[$typeclass[$v]['classid']]))
  3514. // {
  3515. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3516. // {
  3517. // $tz = explode('|',$typeclass[$v]['zh']);
  3518. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3519. // }
  3520. // else
  3521. // {
  3522. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3523. // }
  3524. // }
  3525. // if(isset($jm[$typeclass[$v]['classid']]))
  3526. // {
  3527. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3528. // }
  3529. // }
  3530. // }
  3531. // $jm = array_filter($jm);
  3532. // $rows[$key]['bs'] = implode("-",$jm);
  3533. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3534. // $zh = implode(" ",$pm);
  3535. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3536. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3537. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3538. // $rows[$key]['features'] = $zh;
  3539. }
  3540. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3541. $final_list = [];
  3542. foreach ($list as $k => $v) {
  3543. if (empty($v['sku'])) {
  3544. continue;
  3545. }
  3546. $final_list[] = [
  3547. "warehouse" => $v["warehouse"],
  3548. "purchase" => $v["purchase"],
  3549. "details" => $v["details"],
  3550. "cpid" => $v["cpid"],
  3551. "dbcontent" => $v["dbcontent"],
  3552. "sku" => $v["sku"],
  3553. "cs" => $v["bm"],
  3554. "bs" => $v["jm"],
  3555. "title" => $v["title"],
  3556. "features" => $v["pm"],
  3557. "cpbz" => $v["cpbz"],
  3558. "sm" => $v["sm"],
  3559. "type" => $v["type"],
  3560. "number" => $v["number"],
  3561. "c" => $v["c"],
  3562. "x" => $v["x"],
  3563. "t" => $v["t"],
  3564. "s" => $v["s"],
  3565. "q" => $v["q"],
  3566. "z" => $v["z"],
  3567. "weight" => $v['weight'],
  3568. ];
  3569. }
  3570. $title = "总进销存统计表";
  3571. $titlename = "<table border=1>
  3572. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3573. <tr align='center'>
  3574. <td>仓库</td>
  3575. <td>供应商</td>
  3576. <td>位置</td>
  3577. <td>库存编码</td>
  3578. <td>类目</td>
  3579. <td>SKU</td>
  3580. <td>用友编码</td>
  3581. <td>用友料号</td>
  3582. <td>商品名称</td>
  3583. <td>商品中文</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>重量(g)</td>
  3595. </tr>
  3596. </table>";
  3597. $filename = $title . ".xls";
  3598. $tail = "";
  3599. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3600. }
  3601. }
  3602. //入库导出
  3603. public function _excelr()
  3604. {
  3605. if (isset($_GET['excel'])) {
  3606. $category = $this->input->get('category', true);
  3607. $size = $this->input->get('size', true);
  3608. $grade = $this->input->get('grade', true);
  3609. $color = $this->input->get('color', true);
  3610. $lowe = $this->input->get('lowe', true);
  3611. $sku = $this->input->get('sku', true);
  3612. $warehouse = $this->input->get('warehouse', true);
  3613. $purchase = $this->input->get('purchase', true);
  3614. $ktime = $this->input->get('ktime', true);
  3615. $jtime = $this->input->get('jtime', true);
  3616. $ktime = strtotime($ktime);
  3617. $jtime = strtotime($jtime);
  3618. $where = "1=1";
  3619. $gj = "";
  3620. $ck = "";
  3621. if ($category) {
  3622. $where .= " and features like '%-$category-%'";
  3623. }
  3624. if ($size) {
  3625. $where .= " and features like '%-$size-%'";
  3626. }
  3627. if ($grade) {
  3628. $where .= " and features like '%-$grade-%'";
  3629. }
  3630. if ($color) {
  3631. $where .= " and features like '%-$color-%'";
  3632. }
  3633. if ($lowe) {
  3634. $where .= " and features like '%-$lowe-%'";
  3635. }
  3636. if ($warehouse) {
  3637. $where .= " and warehouse = '$warehouse'";
  3638. }
  3639. if ($purchase) {
  3640. $where .= " and purchase = '$purchase'";
  3641. }
  3642. if ($sku) {
  3643. $where .= " and sku = '$sku'";
  3644. }
  3645. if ($ktime && $jtime) {
  3646. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3647. }
  3648. //数据排序
  3649. $order_str = "id desc";
  3650. if (empty($page)) {
  3651. $start = 0;
  3652. $perpage = 1;
  3653. } else {
  3654. $start = ($page - 1) * $perpage;
  3655. }
  3656. $list = array();
  3657. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3658. foreach ($rows as $value) {
  3659. $ck = $this->warehouse->read($value['warehouse']);
  3660. $warehouse = $ck['title'];
  3661. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3662. $retreatwarehouse = $tkck['title'];
  3663. $gy = $this->purchase->read($value['purchase']);
  3664. $purchase = $gy['title'];
  3665. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3666. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3667. }
  3668. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3669. $titlename = "<table border=1>
  3670. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3671. <tr align='center'>
  3672. <td>仓库</td>
  3673. <td>SKU</td>
  3674. <td>产品</td>
  3675. <td>时间</td>
  3676. <td>数量</td>
  3677. </tr>
  3678. </table>";
  3679. $filename = $title . ".xls";
  3680. $tail = "";
  3681. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  3682. }
  3683. }
  3684. //出库、退库导出
  3685. public function _excelct()
  3686. {
  3687. $classid = $this->classid->sku();
  3688. $pm = $classid;
  3689. $typeclass = array();
  3690. $tc = $this->typeclass->find_all();
  3691. foreach ($tc as $v) {
  3692. $typeclass[$v['id']] = $v;
  3693. }
  3694. $prc = array();
  3695. $purchase = $this->purchase->find_all();
  3696. foreach ($purchase as $k => $v) {
  3697. $prc[$v['id']] = $v['title'];
  3698. }
  3699. if (isset($_GET['excel'])) {
  3700. $wh = array();
  3701. $w = $this->warehouse->find_all('1=1', 'id,title');
  3702. foreach ($w as $v) {
  3703. $wh[$v['id']] = $v['title'];
  3704. }
  3705. $type = $this->input->get('excel', true);
  3706. $category = $this->input->get('category', true);
  3707. $size = $this->input->get('size', true);
  3708. $grade = $this->input->get('grade', true);
  3709. $color = $this->input->get('color', true);
  3710. $lowe = $this->input->get('lowe', true);
  3711. $sku = $this->input->get('sku', true);
  3712. $title = $this->input->get('title', true);
  3713. $warehouse = $this->input->get('warehouse', true);
  3714. $purchase = $this->input->get('purchase', true);
  3715. $lacetype = $this->input->get('lacetype', true);
  3716. $haircap = $this->input->get('haircap', true);
  3717. $lacecolor = $this->input->get('lacecolor', true);
  3718. $density = $this->input->get('density', true);
  3719. $details = $this->input->get('details', true);
  3720. $state = $this->input->get('state', true);
  3721. $shop = $this->input->get('shop', true);
  3722. $hairnumber = $this->input->get('hairnumber', true);
  3723. $type_leixi = $this->input->get('type', true);
  3724. $cpbz = $this->input->get('cpbz', true);
  3725. $sm = $this->input->get('sm', true);
  3726. $sid = $this->input->get('sid', true);
  3727. $ktime = $this->input->get('ktime', true);
  3728. $jtime = $this->input->get('jtime', true);
  3729. $ktime = strtotime($ktime);
  3730. $jtime = strtotime($jtime);
  3731. //$where = " 1=1 ";
  3732. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3733. $where = " sku != '' ";
  3734. $gj = "";
  3735. $ck = "";
  3736. if ($category) {
  3737. $where .= " and features like '%-$category-%'";
  3738. }
  3739. if ($size) {
  3740. $where .= " and features like '%-$size-%'";
  3741. }
  3742. if ($grade) {
  3743. $where .= " and features like '%-$grade-%'";
  3744. }
  3745. if ($color) {
  3746. $where .= " and features like '%-$color-%'";
  3747. }
  3748. if ($lowe) {
  3749. $where .= " and features like '%-$lowe-%'";
  3750. }
  3751. if ($warehouse) {
  3752. $where .= " and warehouse = '$warehouse'";
  3753. }
  3754. if ($purchase) {
  3755. $where .= " and purchase = '$purchase'";
  3756. }
  3757. if ($state) {
  3758. $where .= " and state = '$state'";
  3759. }
  3760. if ($lacetype) {
  3761. $where .= " and features like '%-$lacetype-%'";
  3762. }
  3763. if ($lacecolor) {
  3764. $where .= " and features like '%-$lacecolor-%'";
  3765. }
  3766. if ($density) {
  3767. $where .= " and features like '%-$density-%'";
  3768. }
  3769. if ($haircap) {
  3770. $where .= " and features like '%-$haircap-%'";
  3771. }
  3772. if ($details) {
  3773. $where .= " and details = '$details'";
  3774. }
  3775. if ($shop) {
  3776. $where .= " and shop like '%$shop%'";
  3777. }
  3778. if ($title) {
  3779. $title = trim($title, ' ');
  3780. $title = trim($title, ' ');
  3781. $where .= " and title like '%$title%'";
  3782. }
  3783. if (!empty($hairnumber)) {
  3784. $where .= " and features like '%-128-%' ";
  3785. if ($hairnumber < 0) {
  3786. $class_list = $this->typeclass->find_all('classid = 43');
  3787. foreach ($class_list as $v) {
  3788. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3789. }
  3790. } else {
  3791. $where .= " and features like '%-$hairnumber-%'";
  3792. }
  3793. }
  3794. if ($type_leixi) {
  3795. $where .= " and type = '$type_leixi'";
  3796. }
  3797. if ($cpbz) {
  3798. $where .= " and cpbz like '%$cpbz%' ";
  3799. }
  3800. if ($sm) {
  3801. $where .= " and sm like '%$sm%' ";
  3802. }
  3803. if ($sku) {
  3804. $sku = trim($sku, ' ');
  3805. $sku = trim($sku, ' ');
  3806. $where .= " and sku like '%$sku%'";
  3807. }
  3808. if ($ktime && $jtime) {
  3809. if ($type == 1) {
  3810. $tl = '出库';
  3811. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3812. } else if ($type == 2) {
  3813. $tl = '退库';
  3814. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3815. } else if ($type == 3) {
  3816. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3817. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3818. } else if ($type == 4) {
  3819. $tl = '出库+零售';
  3820. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3821. } else if ($type == 5) {
  3822. $tl = '零售';
  3823. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3824. }
  3825. }
  3826. $sidwhere = '';
  3827. if ($sid) {
  3828. $sd = "";
  3829. $s = explode(',', trim($sid, ','));
  3830. foreach ($s as $value) {
  3831. $sd .= " id = " . $value . " or";
  3832. }
  3833. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3834. }
  3835. //数据排序
  3836. $order_str = "time desc";
  3837. if (empty($page)) {
  3838. $start = 0;
  3839. $perpage = 1;
  3840. } else {
  3841. $start = ($page - 1) * $perpage;
  3842. }
  3843. //取得信息列表
  3844. if ($type != 3 && $type != 5) {
  3845. if ($type == 1 || $type == 4) {
  3846. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3847. foreach ($info_list as $key => $value) {
  3848. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3849. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3850. $warehouse = $this->warehouse->read($value['warehouse']);
  3851. $info_list[$key]['warehouse'] = $warehouse['title'];
  3852. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3853. $features = explode('-', trim($features, '-'));
  3854. $pm = $classid;
  3855. foreach ($features as $k => $v) {
  3856. if ($v != 0) {
  3857. if (!isset($typeclass[$v])) {
  3858. continue;
  3859. }
  3860. if (isset($pm[$typeclass[$v]['classid']])) {
  3861. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3862. $tz = explode('|', $typeclass[$v]['zh']);
  3863. $pm[$typeclass[$v]['classid']] = $tz[0];
  3864. } else {
  3865. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3866. }
  3867. }
  3868. }
  3869. }
  3870. $zh = implode(" ", $pm);
  3871. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3872. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3873. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3874. $info_list[$key]['features'] = $zh;
  3875. }
  3876. $final_list = [];
  3877. foreach($info_list as $k=>$v){
  3878. $number = "";
  3879. if(!empty($v['orderinfo'])){
  3880. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3881. if(!empty($tmp_info['number'])){
  3882. $number = $tmp_info['number'];
  3883. }
  3884. }
  3885. $final_list[] = [
  3886. 'warehouse'=>$v['warehouse'],
  3887. 'purchase'=>$v['purchase'],
  3888. 'sku'=>$v['sku'],
  3889. 'title'=>$v['title'],
  3890. 'features'=>$v['features'],
  3891. 'label'=>$v['label'],
  3892. 'orderinfo'=>$v['orderinfo'],
  3893. 'number'=>$number,
  3894. 'waybill'=>$v['waybill'],
  3895. 'outk'=>$v['outk'],
  3896. ];
  3897. }
  3898. } else {
  3899. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3900. foreach ($info_list as $key => $value) {
  3901. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3902. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3903. $warehouse = $this->warehouse->read($value['warehouse']);
  3904. $info_list[$key]['warehouse'] = $warehouse['title'];
  3905. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3906. $features = explode('-', trim($features, '-'));
  3907. $pm = $classid;
  3908. foreach ($features as $k => $v) {
  3909. if ($v != 0) {
  3910. if (!isset($typeclass[$v])) {
  3911. continue;
  3912. }
  3913. if (isset($pm[$typeclass[$v]['classid']])) {
  3914. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3915. $tz = explode('|', $typeclass[$v]['zh']);
  3916. $pm[$typeclass[$v]['classid']] = $tz[0];
  3917. } else {
  3918. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3919. }
  3920. }
  3921. }
  3922. }
  3923. $zh = implode(" ", $pm);
  3924. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3925. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3926. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3927. $info_list[$key]['features'] = $zh;
  3928. }
  3929. $final_list = [];
  3930. foreach($info_list as $k=>$v){
  3931. $number = "";
  3932. if(!empty($v['orderinfo'])){
  3933. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3934. if(!empty($tmp_info['number'])){
  3935. $number = $tmp_info['number'];
  3936. }
  3937. }
  3938. $final_list[] = [
  3939. 'warehouse'=>$v['warehouse'],
  3940. 'purchase'=>$v['purchase'],
  3941. 'sku'=>$v['sku'],
  3942. 'title'=>$v['title'],
  3943. 'features'=>$v['features'],
  3944. 'label'=>$v['label'],
  3945. 'orderinfo'=>$v['orderinfo'],
  3946. 'number'=>$number,
  3947. 'waybill'=>$v['waybill'],
  3948. 'retreat'=>$v['retreat'],
  3949. ];
  3950. }
  3951. }
  3952. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3953. $titlename = "<table border=1>
  3954. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3955. <tr align='center'>
  3956. <td>仓库</td>
  3957. <td>供应商</td>
  3958. <td>SKU</td>
  3959. <td>商品名称</td>
  3960. <td>商品中文</td>
  3961. <td>标签</td>
  3962. <td>订单号</td>
  3963. <td>订单编码</td>
  3964. <td>运单号</td>
  3965. <td>" . $tl . "时间(中国时间)</td>
  3966. </tr>
  3967. </table>";
  3968. $filename = $title . ".xls";
  3969. $tail = "";
  3970. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3971. } else if ($type == 5) {
  3972. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3973. foreach ($info_list as $key => $value) {
  3974. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3975. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3976. $warehouse = $this->warehouse->read($value['warehouse']);
  3977. $info_list[$key]['warehouse'] = $warehouse['title'];
  3978. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3979. $features = explode('-', trim($features, '-'));
  3980. $pm = $classid;
  3981. foreach ($features as $k => $v) {
  3982. if ($v != 0) {
  3983. if (!isset($typeclass[$v])) {
  3984. continue;
  3985. }
  3986. if (isset($pm[$typeclass[$v]['classid']])) {
  3987. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3988. $tz = explode('|', $typeclass[$v]['zh']);
  3989. $pm[$typeclass[$v]['classid']] = $tz[0];
  3990. } else {
  3991. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3992. }
  3993. }
  3994. }
  3995. }
  3996. $zh = implode(" ", $pm);
  3997. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3998. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3999. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4000. $info_list[$key]['features'] = $zh;
  4001. }
  4002. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4003. $titlename = "<table border=1>
  4004. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4005. <tr align='center'>
  4006. <td>仓库</td>
  4007. <td>供应商</td>
  4008. <td>SKU</td>
  4009. <td>商品名称</td>
  4010. <td>商品中文</td>
  4011. <td>标签</td>
  4012. <td>" . $tl . "时间(中国时间)</td>
  4013. </tr>
  4014. </table>";
  4015. $filename = $title . ".xls";
  4016. $tail = "";
  4017. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4018. } else {
  4019. /**
  4020. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4021. $rows = array();$list = array();
  4022. foreach ($info_list as $key=>$value)
  4023. {
  4024. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4025. }
  4026. **/
  4027. $wh = array();
  4028. $w = $this->warehouse->find_all('1=1', 'id,title');
  4029. foreach ($w as $v) {
  4030. $wh[$v['id']] = $v['title'];
  4031. }
  4032. $wt = array();
  4033. $whlabel_type = $this->whlabel_type->find_all();
  4034. foreach ($whlabel_type as $v) {
  4035. $wt[$v['id']] = $v['title'];
  4036. }
  4037. $classid = $this->classid->sku();
  4038. $list = array();
  4039. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4040. foreach ($rows as $key => $value) {
  4041. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4042. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4043. $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');
  4044. $details = array();
  4045. $cpid = array();
  4046. $cpbz = array();
  4047. $c = 0;
  4048. $g = 0;
  4049. $x = 0;
  4050. $t = 0;
  4051. $s = 0;
  4052. $q = 0;
  4053. foreach ($sd as $k => $v) {
  4054. if ($v['state'] == 0) {
  4055. $c++;
  4056. }
  4057. if ($v['state'] != 9) {
  4058. $g++;
  4059. }
  4060. if ($v['outk'] > 1) {
  4061. $x++;
  4062. }
  4063. if ($v['retreat'] > 0) {
  4064. $t++;
  4065. }
  4066. if ($v['state'] == 8) {
  4067. $s++;
  4068. }
  4069. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4070. $q++;
  4071. }
  4072. $details[$v['details']] = $v['details'];
  4073. if ($v['cpid'] != 0) {
  4074. $cpid[$v['cpid']] = $v['cpid'];
  4075. }
  4076. if ($v['cpbz'] != '') {
  4077. $cpbz[$v['cpbz']] = $v['cpbz'];
  4078. }
  4079. }
  4080. if (isset($wt[$value['type']])) {
  4081. $rows[$key]['type'] = $wt[$value['type']];
  4082. } else {
  4083. $rows[$key]['type'] = '未设置';
  4084. }
  4085. $rows[$key]['details'] = implode("、", $details);
  4086. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4087. $ftime = time() - 15 * 24 * 3600;
  4088. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4089. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4090. $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);
  4091. $rows[$key]['c'] = $c;
  4092. $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);
  4093. $rows[$key]['t'] = $t;
  4094. $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'] . '"');
  4095. $rows[$key]['z'] = $z;
  4096. // $jm = $classid;
  4097. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4098. $features = explode('-', trim($features, '-'));
  4099. // $pm = $classid;
  4100. // foreach ($features as $k => $v) {
  4101. // if ($v != 0) {
  4102. // if (!isset($typeclass[$v])) {
  4103. // continue;
  4104. // }
  4105. // if (isset($pm[$typeclass[$v]['classid']])) {
  4106. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4107. // $tz = explode('|', $typeclass[$v]['zh']);
  4108. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4109. // } else {
  4110. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4111. // }
  4112. // if (isset($jm[$typeclass[$v]['classid']])) {
  4113. // if ($typeclass[$v]['jm']) {
  4114. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4115. // }
  4116. // }
  4117. // }
  4118. // }
  4119. // }
  4120. // $zh = implode(" ", $pm);
  4121. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4122. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4123. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4124. // $rows[$key]['features'] = $zh;
  4125. // $jm = array_filter($jm); //去除空值
  4126. // $jm = implode("-", $jm);
  4127. // $rows[$key]['jm'] = $jm;
  4128. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4129. }
  4130. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4131. // echo "<pre>";
  4132. // print_r($tmp_list);
  4133. // die;
  4134. $final_list =[];
  4135. foreach($tmp_list as $k=>$v){
  4136. $final_list[] = [
  4137. "warehouse"=>$v['warehouse'],
  4138. "purchase"=>$v['purchase'],
  4139. "details"=>trim($v['details'],'、'),
  4140. "cpid"=>$v['cpid'],
  4141. "sku"=>$v['sku'],
  4142. "title"=>$v['title'],
  4143. "features"=>$v['pm'],
  4144. "cpbz"=>$v['cpbz'],
  4145. "sm"=>$v['sm'],
  4146. "type"=>$v['type'],
  4147. "g"=>$v["g"],
  4148. "c"=>$v["c"],
  4149. "x"=>$v["x"],
  4150. "t"=>$v["t"],
  4151. "z"=>$v["z"],
  4152. "jm"=>$v["jm"],
  4153. "weight"=>$v["weight"],
  4154. "asd"=>$v["asd"],
  4155. ];
  4156. }
  4157. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4158. $titlename = "<table border=1>
  4159. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4160. <tr align='center'>
  4161. <td>仓库</td>
  4162. <td>供应商</td>
  4163. <td>位置</td>
  4164. <td>库存编码</td>
  4165. <td>SKU</td>
  4166. <td>商品名称</td>
  4167. <td>商品中文</td>
  4168. <td>产品备注</td>
  4169. <td>说明</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. </tr>
  4180. </table>";
  4181. $filename = $title . ".xls";
  4182. $tail = "";
  4183. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4184. }
  4185. }
  4186. }
  4187. //出库+入库数据整合
  4188. public function _excelcr()
  4189. {
  4190. if (isset($_GET['excel'])) {
  4191. $type = $this->input->get('excel', true);
  4192. $category = $this->input->get('category', true);
  4193. $size = $this->input->get('size', true);
  4194. $grade = $this->input->get('grade', true);
  4195. $color = $this->input->get('color', true);
  4196. $lowe = $this->input->get('lowe', true);
  4197. $sku = $this->input->get('sku', true);
  4198. $warehouse = $this->input->get('warehouse', true);
  4199. $purchase = $this->input->get('purchase', true);
  4200. $state = $this->input->get('state', true);
  4201. $sid = $this->input->get('sid', true);
  4202. $ktime = $this->input->get('ktime', true);
  4203. $jtime = $this->input->get('jtime', true);
  4204. $ktime = strtotime($ktime);
  4205. $jtime = strtotime($jtime);
  4206. $where = "1=1";
  4207. $gj = "";
  4208. $ck = "";
  4209. if ($category) {
  4210. $where .= " and features like '%-$category-%'";
  4211. }
  4212. if ($size) {
  4213. $where .= " and features like '%-$size-%'";
  4214. }
  4215. if ($grade) {
  4216. $where .= " and features like '%-$grade-%'";
  4217. }
  4218. if ($color) {
  4219. $where .= " and features like '%-$color-%'";
  4220. }
  4221. if ($lowe) {
  4222. $where .= " and features like '%-$lowe-%'";
  4223. }
  4224. if ($warehouse) {
  4225. $where .= " and warehouse = '$warehouse'";
  4226. }
  4227. if ($purchase) {
  4228. $where .= " and purchase = '$purchase'";
  4229. }
  4230. if ($state) {
  4231. $where .= " and state = '$state'";
  4232. }
  4233. if ($sku) {
  4234. $where .= " and sku like '%$sku%'";
  4235. }
  4236. if ($ktime && $jtime) {
  4237. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4238. }
  4239. $sidwhere = '';
  4240. if ($sid) {
  4241. $sd = "";
  4242. $s = explode(',', trim($sid, ','));
  4243. foreach ($s as $value) {
  4244. $sd .= " id = " . $value . " or";
  4245. }
  4246. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4247. }
  4248. //取得信息列表
  4249. $timeread = $ktime;
  4250. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4251. $timelist = array();
  4252. for ($i = 0; $i < $timenum; $i++) {
  4253. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4254. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4255. }
  4256. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4257. //echo "<pre>";
  4258. //print_r($info_list);
  4259. //exit();
  4260. $rows = array();
  4261. $list = array();
  4262. foreach ($info_list as $key => $value) {
  4263. $thistime = $timelist;
  4264. if (isset($rows[strtolower($value['sku'])])) {
  4265. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4266. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4267. }
  4268. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4269. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4270. }
  4271. } else {
  4272. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4273. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4274. }
  4275. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4276. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4277. }
  4278. $rows[strtolower($value['sku'])] = $thistime;
  4279. }
  4280. }
  4281. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4282. <head>
  4283. <!--[if gte mso 9]><xml>
  4284. <x:ExcelWorkbook>
  4285. <x:ExcelWorksheets>
  4286. <x:ExcelWorksheet>
  4287. <x:Name>EXCEL</x:Name>
  4288. <x:WorksheetOptions>
  4289. <x:Print>
  4290. <x:ValidPrinterInfo />
  4291. </x:Print>
  4292. </x:WorksheetOptions>
  4293. </x:ExcelWorksheet>
  4294. </x:ExcelWorksheets>
  4295. </x:ExcelWorkbook>
  4296. </xml>
  4297. <![endif]-->
  4298. </head><body>";
  4299. $str .= "<table border=1><tr><td>SKU</td>";
  4300. foreach ($timelist as $k => $v) {
  4301. $str .= "<td>" . $k . "出库</td>";
  4302. $str .= "<td>" . $k . "入库</td>";
  4303. }
  4304. $str .= "</tr></table>";
  4305. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4306. foreach ($rows as $key => $val) {
  4307. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4308. foreach ($val as $k => $v) {
  4309. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4310. if ($val[$k]['r'] > 0) {
  4311. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4312. } else {
  4313. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4314. }
  4315. }
  4316. $str .= "</tr>";
  4317. }
  4318. $str .= "</table>";
  4319. $str .= "</body></html>";
  4320. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4321. header("Content-type: application/octet-stream");
  4322. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4323. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4324. header("Pragma: no-cache");
  4325. header("Expires: 0");
  4326. exit($str);
  4327. }
  4328. }
  4329. //数量调整模板导出
  4330. public function _presetout()
  4331. {
  4332. if (isset($_GET['excel'])) {
  4333. $where = "sku != 'Preset' and purchase != 0";
  4334. //数据排序
  4335. $order_str = "id desc";
  4336. if (empty($page)) {
  4337. $start = 0;
  4338. $perpage = 1;
  4339. } else {
  4340. $start = ($page - 1) * $perpage;
  4341. }
  4342. //取得信息列表
  4343. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4344. $rows = array();
  4345. $list = array();
  4346. foreach ($info_list as $value) {
  4347. $warehouse = $this->warehouse->read($value['warehouse']);
  4348. $number = $value['number'];
  4349. $ftime = time() - 15 * 24 * 3600;
  4350. $purchase = $this->purchase->read($value['purchase']);
  4351. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4352. }
  4353. $title = "库存模板";
  4354. $titlename = "<table border=1>
  4355. <tr align='center'>
  4356. <td>仓库</td>
  4357. <td>供应商编码</td>
  4358. <td>SKU</td>
  4359. <td>增减数量(正数或负数)</td>
  4360. <td>增减备注</td>
  4361. <td>扣减方式:0减少库存1删除库存</td>
  4362. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4363. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4364. </tr>
  4365. </table>";
  4366. $filename = $title . ".xls";
  4367. $tail = "";
  4368. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4369. }
  4370. }
  4371. //数量调整模板导入
  4372. public function _presetedit()
  4373. {
  4374. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4375. $config['upload_path'] = '.' . $dir;
  4376. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4377. $config['allowed_types'] = 'xls|xlsx|csv';
  4378. $config['max_size'] = 10240;
  4379. $this->load->library('upload', $config);
  4380. $this->upload->initialize($config);
  4381. if ($this->upload->do_upload('userfile')) {
  4382. $full_path = $dir . $this->upload->data('file_name');
  4383. $fileName = '.' . $full_path;
  4384. if (!file_exists($fileName)) {
  4385. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4386. exit;
  4387. } else {
  4388. require_once "./data/excel/PHPExcel/IOFactory.php";
  4389. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4390. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4391. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4392. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4393. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4394. ++$column; //如果列数大于26行
  4395. $list = array();
  4396. for ($i = 2; $i <= $row; $i++) // 行数循环
  4397. {
  4398. $data = array();
  4399. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4400. {
  4401. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4402. }
  4403. $list[] = $data;
  4404. }
  4405. }
  4406. $i = 0;
  4407. $j = 0;
  4408. $ed = array();
  4409. foreach ($list as $key => $value) {
  4410. $time = time();
  4411. if ($value['0'] == "") {
  4412. continue;
  4413. }
  4414. $warehouse = $this->warehouse->get_title($value['0']);
  4415. $purchase = $this->purchase->get_bm($value['1']);
  4416. $sku = $value['2'];
  4417. $num = $value['3']; //调整数量
  4418. $text = $value['4']; //扣减说明
  4419. $type = $value['5']; //调整方式0扣减1删除
  4420. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4421. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4422. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4423. if (!$purchase) //如果没有这个SKU
  4424. {
  4425. $ed[] = array($purchase . '-不存在此供应商编码');
  4426. $j++;
  4427. continue;
  4428. }
  4429. if (!$d) //如果没有这个SKU
  4430. {
  4431. $ed[] = array($sku . '-库存中不存在此SKU');
  4432. $j++;
  4433. continue;
  4434. }
  4435. if (!isset($warehouse['id'])) {
  4436. $ed[] = array($sku . '-仓库名错误!');
  4437. $j++;
  4438. continue;
  4439. }
  4440. if ($type != '0' && $type != '1') {
  4441. $ed[] = array($sku . '-扣减方式填写错误!');
  4442. $j++;
  4443. continue;
  4444. }
  4445. if ($num < 0) //扣减库存
  4446. {
  4447. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4448. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4449. $j++;
  4450. continue;
  4451. }
  4452. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4453. if (count($data) < abs($num)) {
  4454. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4455. $j++;
  4456. continue;
  4457. }
  4458. if ($type == 0) //如果扣减方式为 扣减库存
  4459. {
  4460. for ($i = 0; $i < abs($num); $i++) {
  4461. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4462. }
  4463. } else if ($type == 1) {
  4464. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4465. if (count($zt) > 0) {
  4466. $ed[] = array($sku . '-有在途库存无法删除!');
  4467. $j++;
  4468. continue;
  4469. }
  4470. for ($i = 0; $i < abs($num); $i++) {
  4471. $this->whlabel->remove($data[$i]['id']);
  4472. }
  4473. }
  4474. } else if ($num > 0) //增加库存
  4475. {
  4476. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4477. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4478. $j++;
  4479. continue;
  4480. }
  4481. $post['sku'] = $d['sku'];
  4482. $post['shop'] = $d['shop'];
  4483. $post['warehouse'] = $warehouse['id'];
  4484. $post['purchase'] = $purchase['id'];
  4485. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4486. $post['state'] = 0;
  4487. $post['title'] = $d['title'];
  4488. $post['number'] = $d['number'];
  4489. $post['features'] = $d['features'];
  4490. $post['enter'] = $time;
  4491. $post['time'] = $time; //操作时间
  4492. $post['rktype'] = $rktype;
  4493. for ($i = 0; $i < $num; $i++) {
  4494. $post['label'] = time() . rand(100, 999) . $i;
  4495. $this->whlabel->insert($post);
  4496. }
  4497. }
  4498. sleep(1); //防止入库时间一样,需要延迟1秒
  4499. }
  4500. if ($j > 0) {
  4501. $tt = date('Ymd', time());
  4502. $title = '库存导入错误信息-' . $tt;
  4503. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4504. $tail = "\n";
  4505. $filename = $title . ".xls";
  4506. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4507. $dir = '/data/excel/' . $time . '/';
  4508. $file_name = 'error_' . $time . rand(1000, 9999);
  4509. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4510. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4511. fwrite($myfile, $ecl);
  4512. fclose($myfile);
  4513. $error = $dir . $file_name . '.xls';
  4514. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4515. exit;
  4516. } else {
  4517. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4518. exit;
  4519. }
  4520. }
  4521. }
  4522. public function _presetedittwo(){
  4523. $data = $this->input->post(NULL, TRUE);
  4524. if(empty($list)){
  4525. $raw_data = $this->input->raw_input_stream;
  4526. // 解码 JSON
  4527. $data = json_decode($raw_data, true);
  4528. }
  4529. if(empty($data)){
  4530. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4531. }
  4532. $list = [];
  4533. if(isset($data['list'])){
  4534. $list = $data['list'];
  4535. }
  4536. $i = 0;
  4537. $j = 0;
  4538. $ed = array();
  4539. foreach ($list as $key => $value) {
  4540. $time = time();
  4541. if ($value['0'] == "") {
  4542. continue;
  4543. }
  4544. $warehouse = $this->warehouse->get_title($value['0']);
  4545. $purchase = $this->purchase->get_bm($value['1']);
  4546. $sku = $value['2'];
  4547. $num = $value['3']; //调整数量
  4548. $text = $value['4']; //扣减说明
  4549. $type = $value['5']; //调整方式0扣减1删除
  4550. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4551. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4552. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4553. if (!$purchase) //如果没有这个SKU
  4554. {
  4555. $ed[] = array($value['1'] . '-不存在此供应商编码');
  4556. $j++;
  4557. continue;
  4558. }
  4559. if (!$d) //如果没有这个SKU
  4560. {
  4561. $ed[] = array($sku . '-库存中不存在此SKU');
  4562. $j++;
  4563. continue;
  4564. }
  4565. if (!isset($warehouse['id'])) {
  4566. $ed[] = array($sku . '-仓库名错误!');
  4567. $j++;
  4568. continue;
  4569. }
  4570. if ($type != '0' && $type != '1') {
  4571. $ed[] = array($sku . '-扣减方式填写错误!');
  4572. $j++;
  4573. continue;
  4574. }
  4575. if ($num < 0) //扣减库存
  4576. {
  4577. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4578. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4579. $j++;
  4580. continue;
  4581. }
  4582. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4583. if (count($data) < abs($num)) {
  4584. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4585. $j++;
  4586. continue;
  4587. }
  4588. if ($type == 0) //如果扣减方式为 扣减库存
  4589. {
  4590. for ($i = 0; $i < abs($num); $i++) {
  4591. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4592. }
  4593. } else if ($type == 1) {
  4594. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4595. if (count($zt) > 0) {
  4596. $ed[] = array($sku . '-有在途库存无法删除!');
  4597. $j++;
  4598. continue;
  4599. }
  4600. for ($i = 0; $i < abs($num); $i++) {
  4601. $this->whlabel->remove($data[$i]['id']);
  4602. }
  4603. }
  4604. } else if ($num > 0) //增加库存
  4605. {
  4606. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4607. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4608. $j++;
  4609. continue;
  4610. }
  4611. $post['sku'] = $d['sku'];
  4612. $post['shop'] = $d['shop'];
  4613. $post['warehouse'] = $warehouse['id'];
  4614. $post['purchase'] = $purchase['id'];
  4615. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4616. $post['state'] = 0;
  4617. $post['title'] = $d['title'];
  4618. $post['number'] = $d['number'];
  4619. $post['features'] = $d['features'];
  4620. $post['enter'] = $time;
  4621. $post['time'] = $time; //操作时间
  4622. $post['rktype'] = $rktype;
  4623. $post['sku_master_id'] = $d['sku_master_id'];
  4624. $post['sku_shop_id'] = $d['sku_shop_id'];
  4625. for ($i = 0; $i < $num; $i++) {
  4626. $post['label'] = time() . rand(100, 999) . $i;
  4627. $this->whlabel->insert($post);
  4628. }
  4629. }
  4630. sleep(1); //防止入库时间一样,需要延迟1秒
  4631. }
  4632. if ($j > 0) {
  4633. $tt = date('Ymd', time());
  4634. $title = '库存导入错误信息-' . $tt;
  4635. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4636. $tail = "\n";
  4637. $filename = $title . ".xls";
  4638. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4639. $dir = '/data/excel/' . $time . '/';
  4640. $file_name = 'error_' . $time . rand(1000, 9999);
  4641. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4642. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4643. fwrite($myfile, $ecl);
  4644. fclose($myfile);
  4645. $error = $dir . $file_name . '.xls';
  4646. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4647. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4648. exit;
  4649. } else {
  4650. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4651. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4652. exit;
  4653. }
  4654. }
  4655. //笛卡儿积
  4656. function cp($ps, $sets, $list)
  4657. {
  4658. $result = array();
  4659. $j = 0;
  4660. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4661. if ($i == 0) {
  4662. $result = $sets[$i];
  4663. }
  4664. $tmp = array();
  4665. foreach ($result as $res) {
  4666. foreach ($sets[$i + 1] as $set) {
  4667. $tmp[] = $res . ',' . $set;
  4668. }
  4669. }
  4670. $result = $tmp;
  4671. }
  4672. $this->db->trans_begin();
  4673. foreach ($result as $v) {
  4674. $post = array();
  4675. $title = "";
  4676. $num = "";
  4677. $data = explode(',', $v);
  4678. for ($i = 0; $i < count($list); $i++) {
  4679. $post[$list[$i]] = $data[$i];
  4680. $typeclass = $this->typeclass->read($data[$i]);
  4681. $title = $title . $typeclass['title'] . " ";
  4682. if ($data[$i] != 0) {
  4683. $num .= $data[$i]; //所有数据ID拼接
  4684. }
  4685. }
  4686. foreach ($ps as $kp => $vp) {
  4687. $post[$kp] = $vp;
  4688. }
  4689. $post['number'] = $num;
  4690. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4691. if ($info_list) {
  4692. $j++;
  4693. } else {
  4694. $skunum = $this->whlabel->find_count();
  4695. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4696. $post['title'] = rtrim($title, ' ');
  4697. $this->whlabel->insert($post);
  4698. }
  4699. }
  4700. if ($this->db->trans_status() === FALSE) {
  4701. $this->db->trans_commit();
  4702. return NULL;
  4703. } else {
  4704. $this->db->trans_commit();
  4705. return $j;
  4706. }
  4707. }
  4708. public function _kj($arg_array)
  4709. {
  4710. if (isset($_POST['sku'])) {
  4711. $time = time();
  4712. $sku = $this->input->post('sku', true);
  4713. $warehouse = $this->input->post('warehouse', true);
  4714. $num = $this->input->post('num', true);
  4715. $text = $this->input->post('text', true);
  4716. $purchase = $this->input->post('purchase', true);
  4717. $cktype = $this->input->post('cktype', true);
  4718. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4719. if ($cktype != 1 && $text == '') {
  4720. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4721. exit;
  4722. }
  4723. if ($num > count($order)) {
  4724. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4725. exit;
  4726. } else {
  4727. for ($i = 0; $i < $num; $i++) {
  4728. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4729. }
  4730. }
  4731. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4732. exit;
  4733. }
  4734. $uid = $this->whlabel->read($arg_array[0]);
  4735. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4736. $this->data['data'] = $uid;
  4737. $this->_Template('whlabel_kj', $this->data);
  4738. }
  4739. public function _summary($arg_array)
  4740. {
  4741. $prc = array();
  4742. $purchase = $this->purchase->find_all();
  4743. foreach ($purchase as $k => $v) {
  4744. $prc[$v['id']] = $v['title'];
  4745. }
  4746. if (isset($_GET['excel'])) {
  4747. $ktime = $this->input->get('ktime', true);
  4748. $jtime = $this->input->get('jtime', true);
  4749. $ktime = strtotime($ktime);
  4750. $jtime = strtotime($jtime);
  4751. $where = "1=1";
  4752. if ($ktime && $jtime) {
  4753. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4754. }
  4755. //数据排序
  4756. $order_str = "time desc";
  4757. if (empty($page)) {
  4758. $start = 0;
  4759. $perpage = 1;
  4760. } else {
  4761. $start = ($page - 1) * $perpage;
  4762. }
  4763. //取得信息列表
  4764. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4765. foreach ($info_list as $key => $value) {
  4766. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4767. $warehouse = $this->warehouse->read($value['warehouse']);
  4768. $info_list[$key]['warehouse'] = $warehouse['title'];
  4769. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4770. $details = array();
  4771. $cpid = array();
  4772. foreach ($x as $k => $v) {
  4773. if ($v['details'] != '') {
  4774. $details[$v['details']] = $v['details'];
  4775. }
  4776. if ($v['cpid'] != 0) {
  4777. $cpid[$v['cpid']] = $v['cpid'];
  4778. }
  4779. }
  4780. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4781. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4782. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4783. $info_list[$key]['s'] = $s;
  4784. $info_list[$key]['x'] = count($x);
  4785. }
  4786. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4787. $titlename = "<table border=1>
  4788. <tr align='center'>
  4789. <td>仓库</td>
  4790. <td>供应商</td>
  4791. <td>出库位置</td>
  4792. <td>出库编码</td>
  4793. <td>SKU</td>
  4794. <td>产品名</td>
  4795. <td>总剩余库存</td>
  4796. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4797. </tr>
  4798. </table>";
  4799. $filename = $title . ".xls";
  4800. $tail = "";
  4801. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4802. }
  4803. }
  4804. //usps发货清单
  4805. public function _manifest()
  4806. {
  4807. if (isset($_POST['manifest'])) {
  4808. $wltext = $this->input->post('wltext', true);
  4809. $time = time() - 16 * 3600;
  4810. $ptime = strtotime(date('Y-m-d', $time));
  4811. $waybill = array();
  4812. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4813. foreach ($fullorder as $v) {
  4814. $waybill[$v['waybill']] = $v['waybill'];
  4815. }
  4816. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4817. foreach ($fullordersmt as $v) {
  4818. $waybill[$v['waybill']] = $v['waybill'];
  4819. }
  4820. $wltext = explode(';', $wltext);
  4821. foreach ($wltext as $v) {
  4822. if (isset($waybill[$v])) {
  4823. unset($waybill[$v]);
  4824. }
  4825. }
  4826. $data = $this->usps->get_manifest($waybill);
  4827. if (isset($data['Description'])) {
  4828. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4829. exit;
  4830. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4831. $bctime = date('Ymd', time());
  4832. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4833. echo json_encode(array('msg' => $pdf, 'success' => true));
  4834. exit;
  4835. } else {
  4836. echo json_encode(array('msg' => $data, 'success' => false));
  4837. exit;
  4838. }
  4839. }
  4840. }
  4841. public function _pdf($pdf, $title, $bctime)
  4842. {
  4843. $pdf_path = './data/pdf/' . $bctime . '/';
  4844. $file_base64 = $pdf;
  4845. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4846. $file_base64 = base64_decode($file_base64);
  4847. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4848. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4849. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4850. }
  4851. /**
  4852. *
  4853. *
  4854. *
  4855. 进销存占单异常索引
  4856. *
  4857. *
  4858. *
  4859. **/
  4860. public function _abnormal()
  4861. {
  4862. $post = $this->input->post(NULL, TRUE);
  4863. if (isset($post['page'])) {
  4864. $page = $this->input->post('page', true);
  4865. $perpage = $this->input->post('perpage', true);
  4866. $sku = $this->input->post('sku', true);
  4867. $where = "1=1";
  4868. //数据排序
  4869. $order_str = "id desc";
  4870. if (empty($page)) {
  4871. $start = 0;
  4872. $perpage = 1;
  4873. } else {
  4874. $start = ($page - 1) * $perpage;
  4875. }
  4876. //取得信息列表
  4877. $info_list = $this->whlabel->find_all($where, '*');
  4878. $rows = array();
  4879. $list = array();
  4880. foreach ($info_list as $key => $value) {
  4881. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4882. }
  4883. foreach ($rows as $value) {
  4884. $warehouse = $this->warehouse->read($value['warehouse']);
  4885. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4886. $number = $value['number'];
  4887. $ftime = time() - 15 * 24 * 3600;
  4888. if ($value['shop'] != '') {
  4889. $shop = $value['shop'];
  4890. $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');
  4891. $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');
  4892. $order = array_merge($orderdlz, $ordersmt);
  4893. $od = 0;
  4894. $a = '';
  4895. $orid = '';
  4896. foreach ($order as $v) {
  4897. $or = explode('|', ltrim($v['whlabel'], '|'));
  4898. for ($i = 0; $i < count($or); $i++) {
  4899. $orod = explode('-', $or[$i]);
  4900. if ($orod[0] == $number) {
  4901. $od += $orod[1];
  4902. }
  4903. }
  4904. $orid .= $v['number'] . '-';
  4905. }
  4906. } else {
  4907. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4908. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4909. $order = array_merge($orderdlz, $ordersmt);
  4910. $od = 0;
  4911. $a = '';
  4912. $orid = '';
  4913. $qt = array();
  4914. foreach ($order as $v) {
  4915. $or = explode('|', ltrim($v['whlabel'], '|'));
  4916. for ($i = 0; $i < count($or); $i++) {
  4917. $orod = explode('-', $or[$i]);
  4918. if ($orod[0] == $number) {
  4919. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4920. if ($czzs > 0) {
  4921. if (isset($qt[$v['shop']])) {
  4922. if ($qt[$v['shop']] < $orod[1]) {
  4923. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4924. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4925. } else {
  4926. $qt[$v['shop']] -= $orod[1];
  4927. }
  4928. } else {
  4929. $qt[$v['shop']] = $czzs;
  4930. }
  4931. } else {
  4932. $od += $orod[1];
  4933. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4934. }
  4935. }
  4936. }
  4937. }
  4938. }
  4939. $z = $od . '(' . $orid . ')'; //查看订单号
  4940. //$z = $od;
  4941. if ($od > $c) {
  4942. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4943. }
  4944. }
  4945. $listdata = array_slice($list, $start, $perpage);
  4946. $total = count($list);
  4947. $pagenum = ceil($total / $perpage);
  4948. $over = $total - ($start + $perpage);
  4949. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4950. echo json_encode($rows);
  4951. exit;
  4952. }
  4953. $this->_Template('whlabel_abnormal', $this->data);
  4954. }
  4955. /**
  4956. *
  4957. *
  4958. *
  4959. 进销存占单异常索引
  4960. *
  4961. *
  4962. *
  4963. **/
  4964. public function _error()
  4965. {
  4966. $post = $this->input->post(NULL, TRUE);
  4967. if (isset($post['page'])) {
  4968. $page = $this->input->post('page', true);
  4969. $perpage = $this->input->post('perpage', true);
  4970. $sku = $this->input->post('sku', true);
  4971. $warehouse = $this->input->post('warehouse', true);
  4972. $ktime = $this->input->post('ktime', true);
  4973. $jtime = $this->input->post('jtime', true);
  4974. $ktime = strtotime($ktime);
  4975. $jtime = strtotime($jtime);
  4976. $where = "sku != 'Preset'";
  4977. $gj = '';
  4978. if ($sku) {
  4979. $where .= " and sku like '%$sku%'";
  4980. } else {
  4981. if ($ktime && $jtime) {
  4982. $gj = " and time > '$ktime' and time < '$jtime'";
  4983. }
  4984. }
  4985. if ($warehouse) {
  4986. $where .= " and warehouse = '$warehouse'";
  4987. }
  4988. //数据排序
  4989. $order_str = "id desc";
  4990. if (empty($page)) {
  4991. $start = 0;
  4992. $perpage = 1;
  4993. } else {
  4994. $start = ($page - 1) * $perpage;
  4995. }
  4996. //取得信息列表
  4997. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4998. $rows = array();
  4999. $list = array();
  5000. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5001. // foreach ($info_list as $value)
  5002. // {
  5003. // $warehouse = $this->warehouse->read($value['warehouse']);
  5004. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5005. // $number = $value['number'];$ftime = time()-15*24*3600;
  5006. // if($c < 1)
  5007. // {
  5008. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5009. // }
  5010. // }
  5011. $warehouse_list = $this->warehouse->find_all();
  5012. $warehouse_list = array_column($warehouse_list, null, 'id');
  5013. foreach ($info_list as $value) {
  5014. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5015. 'title' => "",
  5016. ];
  5017. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5018. $number = $value['number'];
  5019. $ftime = time() - 15 * 24 * 3600;
  5020. if ($c < 1) {
  5021. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5022. }
  5023. }
  5024. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5025. // $query = $this->db->query($sql);
  5026. // $info_list = $query->result_array();
  5027. // $sql_two = "select title,id from crowd_warehouse";
  5028. // $query_two = $this->db->query($sql_two);
  5029. // $warehouse_list = $query_two->result_array();
  5030. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5031. // foreach ($info_list as $value)
  5032. // {
  5033. // if(isset($warehouse_arr[$value['warehouse']])){
  5034. // $warehouse = $warehouse_arr[$value['warehouse']];
  5035. // }else{
  5036. // $warehouse = [
  5037. // 'id'=>0,
  5038. // 'title'=>"异常",
  5039. // ];
  5040. // }
  5041. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5042. // $number = $value['number'];$ftime = time()-15*24*3600;
  5043. // if($c < 1)
  5044. // {
  5045. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5046. // }
  5047. // }
  5048. $listdata = array_slice($list, $start, $perpage);
  5049. $total = count($list);
  5050. $pagenum = ceil($total / $perpage);
  5051. $over = $total - ($start + $perpage);
  5052. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5053. echo json_encode($rows);
  5054. exit;
  5055. }
  5056. if (isset($post['s'])) {
  5057. $id_arr = $this->input->post('s');
  5058. $id_arr = explode(',', trim($id_arr, ','));
  5059. if (!$id_arr) {
  5060. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5061. exit;
  5062. }
  5063. //循环删除记录
  5064. foreach ($id_arr as $v) {
  5065. $dd = $this->whlabel->read($v);
  5066. if (!isset($dd['id'])) {
  5067. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5068. exit;
  5069. }
  5070. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5071. if (isset($zt[0])) {
  5072. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5073. exit;
  5074. }
  5075. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5076. foreach ($deldd as $vv) {
  5077. $this->whlabel->remove($vv['id']);
  5078. }
  5079. }
  5080. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5081. exit;
  5082. }
  5083. $this->_Template('whlabel_error', $this->data);
  5084. }
  5085. public function _errorexcel()
  5086. {
  5087. $post = $this->input->post(NULL, TRUE);
  5088. if (isset($_GET['page'])) {
  5089. $page = $this->input->get('page', true);
  5090. $perpage = $this->input->get('perpage', true);
  5091. $sku = $this->input->get('sku', true);
  5092. $warehouse = $this->input->get('warehouse', true);
  5093. $ktime = $this->input->get('ktime', true);
  5094. $jtime = $this->input->get('jtime', true);
  5095. $ktime = strtotime($ktime);
  5096. $jtime = strtotime($jtime);
  5097. $where = "sku != 'Preset'";
  5098. $gj = '';
  5099. if ($sku) {
  5100. $where .= " and sku like '%$sku%'";
  5101. } else {
  5102. if ($ktime && $jtime) {
  5103. $gj = " and time > '$ktime' and time < '$jtime'";
  5104. }
  5105. }
  5106. if ($warehouse) {
  5107. $where .= " and warehouse = '$warehouse'";
  5108. }
  5109. //数据排序
  5110. $order_str = "id desc";
  5111. if (empty($page)) {
  5112. $start = 0;
  5113. $perpage = 1;
  5114. } else {
  5115. $start = ($page - 1) * $perpage;
  5116. }
  5117. //取得信息列表
  5118. $rows = array();
  5119. $list = array();
  5120. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5121. foreach ($info_list as $value) {
  5122. $warehouse = $this->warehouse->read($value['warehouse']);
  5123. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5124. $number = $value['number'];
  5125. $ftime = time() - 15 * 24 * 3600;
  5126. if ($c < 1) {
  5127. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5128. }
  5129. }
  5130. $title = "0库存汇总";
  5131. $titlename = "<table border=1>
  5132. <tr align='center'>
  5133. <td>仓库</td>
  5134. <td>SKU</td>
  5135. <td>产品</td>
  5136. <td>当前库存</td>
  5137. </tr>
  5138. </table>";
  5139. $filename = $title . ".xls";
  5140. $tail = "";
  5141. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5142. }
  5143. }
  5144. /**
  5145. *
  5146. *
  5147. * 占单
  5148. *
  5149. *
  5150. **/
  5151. public function _kcyz()
  5152. {
  5153. $post = $this->input->post(NULL, TRUE);
  5154. if (isset($post['warehouse'])) {
  5155. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5156. exit; //不再使用
  5157. $warehouse = $this->input->post('warehouse', true);
  5158. $whlabel = $this->input->post('whlabel', true);
  5159. $id = $this->input->post('id', true);
  5160. $shop = $this->input->post('shop', true);
  5161. $number = $this->input->post('number', true);
  5162. if (!$whlabel || $whlabel == '|') {
  5163. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5164. exit;
  5165. }
  5166. $pp = explode('|', trim($whlabel, '|'));
  5167. $x = 0;
  5168. $save = array();
  5169. foreach ($pp as $va) {
  5170. $num = explode('-', $va);
  5171. if ($number) {
  5172. $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 = '')"); //通用
  5173. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5174. } else {
  5175. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5176. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5177. }
  5178. $x++;
  5179. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5180. $save[] = $x - 1;
  5181. continue; //提前先加X不然出错,所以要减1
  5182. }
  5183. }
  5184. if (isset($save[0])) {
  5185. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5186. exit;
  5187. } else {
  5188. echo json_encode(array('success' => true));
  5189. exit;
  5190. }
  5191. }
  5192. }
  5193. public function _db()
  5194. {
  5195. $post = $this->input->post(NULL, TRUE);
  5196. if (isset($post['page'])) {
  5197. $page = $this->input->post('page', true);
  5198. $perpage = $this->input->post('perpage', true);
  5199. $sku = $this->input->post('sku', true);
  5200. $number = $this->input->post('number', true);
  5201. $warehouse = $this->input->post('warehouse', true);
  5202. $purchase = $this->input->post('purchase', true);
  5203. $orderinfo = $this->input->post('orderinfo', true);
  5204. $waybill = $this->input->post('waybill', true);
  5205. $category = $this->input->post('category', true);
  5206. $size = $this->input->post('size', true);
  5207. $grade = $this->input->post('grade', true);
  5208. $color = $this->input->post('color', true);
  5209. $lowe = $this->input->post('lowe', true);
  5210. $state = $this->input->post('state', true);
  5211. $label = $this->input->post('label', true);
  5212. $timetk = $this->input->post('timetkk', true);
  5213. $timetj = $this->input->post('timetjj', true);
  5214. $timetk = strtotime($timetk);
  5215. $timetj = strtotime($timetj);
  5216. $where = "dbtime > 0";
  5217. if ($timetk && $timetj) {
  5218. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5219. }
  5220. if ($sku) {
  5221. $where .= " and sku = '$sku'";
  5222. }
  5223. if ($warehouse) {
  5224. $where .= " and warehouse = '$warehouse'";
  5225. if ($warehouse == 12) {
  5226. $w = 'specialstock';
  5227. } else {
  5228. $w = 'whlabel';
  5229. }
  5230. }
  5231. if ($purchase) {
  5232. $where .= " and purchase = '$purchase'";
  5233. }
  5234. if ($category) {
  5235. $where .= " and features like '%-$category-%'";
  5236. }
  5237. if ($size) {
  5238. $where .= " and features like '%-$size-%'";
  5239. }
  5240. if ($grade) {
  5241. $where .= " and features like '%-$grade-%'";
  5242. }
  5243. if ($color) {
  5244. $where .= " and features like '%-$color-%'";
  5245. }
  5246. if ($lowe) {
  5247. $where .= " and features like '%-$lowe-%'";
  5248. }
  5249. if ($state != '') {
  5250. $where .= " and state = '$state'";
  5251. }
  5252. //数据排序
  5253. $order_str = "dbtime desc";
  5254. if (empty($page)) {
  5255. $start = 0;
  5256. $perpage = 1;
  5257. } else {
  5258. $start = ($page - 1) * $perpage;
  5259. }
  5260. //取得信息列表
  5261. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5262. foreach ($info_list as $key => $value) {
  5263. $warehouse = $this->$w->read($value['warehouse']);
  5264. $info_list[$key]['warehouse'] = $warehouse['title'];
  5265. $purchase = $this->purchase->read($value['purchase']);
  5266. $info_list[$key]['purchase'] = $purchase['title'];
  5267. if ($value['enter'] != 0) {
  5268. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5269. } else {
  5270. $info_list[$key]['enter'] = "";
  5271. }
  5272. if ($value['dbtime'] != 0) {
  5273. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5274. } else {
  5275. $info_list[$key]['dbtime'] = "";
  5276. }
  5277. if ($value['state'] == 0) {
  5278. $info_list[$key]['state'] = "在库";
  5279. } else if ($value['state'] == 1) {
  5280. $info_list[$key]['state'] = "出库";
  5281. } else if ($value['state'] == 2) {
  5282. $info_list[$key]['state'] = "退库";
  5283. } else if ($value['state'] == 3) {
  5284. $info_list[$key]['state'] = "调拨中";
  5285. } else if ($value['state'] == 4) {
  5286. $info_list[$key]['state'] = "再加工";
  5287. } else if ($value['state'] == 5) {
  5288. $info_list[$key]['state'] = "维修中";
  5289. } else if ($value['state'] == 6) {
  5290. $info_list[$key]['state'] = "盘亏";
  5291. } else if ($value['state'] == 7) {
  5292. $info_list[$key]['state'] = "更换标签";
  5293. } else if ($value['state'] == 8) {
  5294. $info_list[$key]['state'] = "其它";
  5295. } else if ($value['state'] == 9) {
  5296. $info_list[$key]['state'] = "预设";
  5297. }
  5298. }
  5299. $total = $this->whlabel->find_count($where);
  5300. $pagenum = ceil($total / $perpage);
  5301. $over = $total - ($start + $perpage);
  5302. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5303. echo json_encode($rows);
  5304. exit;
  5305. }
  5306. if (isset($post['outsku'])) {
  5307. $time = time();
  5308. $cz = $this->input->post('cz', true);
  5309. $label = $this->input->post('outsku', true);
  5310. $sl = $this->input->post('sl', true);
  5311. $num = $this->input->post('num', true);
  5312. //$warehouse = $this->input->post('warehouse',true);
  5313. if (!$sl) {
  5314. $sl = 1;
  5315. }
  5316. if (!$warehouse) {
  5317. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5318. exit;
  5319. }
  5320. $dblabel = $this->whlabellabel->get_label($label);
  5321. if ($dblabel) {
  5322. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5323. if (count($data) < 1) {
  5324. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5325. exit;
  5326. }
  5327. if (count($data) < $num) {
  5328. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5329. exit;
  5330. }
  5331. for ($i = 0; $i < $sl; $i++) {
  5332. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5333. }
  5334. echo json_encode(array('success' => true));
  5335. exit;
  5336. } else {
  5337. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5338. exit;
  5339. }
  5340. }
  5341. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5342. $this->_Template('whlabel_db', $this->data);
  5343. }
  5344. public function _dbrk()
  5345. {
  5346. $post = $this->input->post(NULL, TRUE);
  5347. if (isset($post['page'])) {
  5348. $page = $this->input->post('page', true);
  5349. $perpage = $this->input->post('perpage', true);
  5350. $sku = $this->input->post('sku', true);
  5351. $number = $this->input->post('number', true);
  5352. $warehouse = $this->input->post('warehouse', true);
  5353. $purchase = $this->input->post('purchase', true);
  5354. $orderinfo = $this->input->post('orderinfo', true);
  5355. $waybill = $this->input->post('waybill', true);
  5356. $category = $this->input->post('category', true);
  5357. $size = $this->input->post('size', true);
  5358. $grade = $this->input->post('grade', true);
  5359. $color = $this->input->post('color', true);
  5360. $lowe = $this->input->post('lowe', true);
  5361. $state = $this->input->post('state', true);
  5362. $label = $this->input->post('label', true);
  5363. $ctime = $this->input->post('ctime', true);
  5364. $timetk = $this->input->post('timetkk', true);
  5365. $timetj = $this->input->post('timetjj', true);
  5366. $timetk = strtotime($timetk);
  5367. $timetj = strtotime($timetj);
  5368. $where = "dbtime > 0";
  5369. if ($timetk && $timetj) {
  5370. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5371. }
  5372. if ($sku) {
  5373. $where .= " and sku = '$sku'";
  5374. }
  5375. if ($warehouse) {
  5376. $where .= " and warehouse = '$warehouse'";
  5377. }
  5378. if ($purchase) {
  5379. $where .= " and purchase = '$purchase'";
  5380. }
  5381. if ($category) {
  5382. $where .= " and features like '%-$category-%'";
  5383. }
  5384. if ($size) {
  5385. $where .= " and features like '%-$size-%'";
  5386. }
  5387. if ($grade) {
  5388. $where .= " and features like '%-$grade-%'";
  5389. }
  5390. if ($color) {
  5391. $where .= " and features like '%-$color-%'";
  5392. }
  5393. if ($lowe) {
  5394. $where .= " and features like '%-$lowe-%'";
  5395. }
  5396. if ($state != '') {
  5397. $where .= " and state = '$state'";
  5398. }
  5399. //数据排序
  5400. $order_str = "dbtime desc";
  5401. if (empty($page)) {
  5402. $start = 0;
  5403. $perpage = 1;
  5404. } else {
  5405. $start = ($page - 1) * $perpage;
  5406. }
  5407. //取得信息列表
  5408. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5409. foreach ($info_list as $key => $value) {
  5410. $warehouse = $this->warehouse->read($value['warehouse']);
  5411. $info_list[$key]['warehouse'] = $warehouse['title'];
  5412. $purchase = $this->purchase->read($value['purchase']);
  5413. $info_list[$key]['purchase'] = $purchase['title'];
  5414. if ($value['enter'] != 0) {
  5415. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5416. } else {
  5417. $info_list[$key]['enter'] = "";
  5418. }
  5419. if ($value['dbtime'] != 0) {
  5420. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5421. } else {
  5422. $info_list[$key]['dbtime'] = "";
  5423. }
  5424. if ($value['state'] == 0) {
  5425. $info_list[$key]['state'] = "在库";
  5426. } else if ($value['state'] == 1) {
  5427. $info_list[$key]['state'] = "出库";
  5428. } else if ($value['state'] == 2) {
  5429. $info_list[$key]['state'] = "退库";
  5430. } else if ($value['state'] == 3) {
  5431. $info_list[$key]['state'] = "调拨中";
  5432. } else if ($value['state'] == 4) {
  5433. $info_list[$key]['state'] = "再加工";
  5434. } else if ($value['state'] == 5) {
  5435. $info_list[$key]['state'] = "维修中";
  5436. } else if ($value['state'] == 6) {
  5437. $info_list[$key]['state'] = "盘亏";
  5438. } else if ($value['state'] == 7) {
  5439. $info_list[$key]['state'] = "更换标签";
  5440. } else if ($value['state'] == 8) {
  5441. $info_list[$key]['state'] = "其它";
  5442. } else if ($value['state'] == 9) {
  5443. $info_list[$key]['state'] = "预设";
  5444. }
  5445. }
  5446. $total = $this->whlabel->find_count($where);
  5447. $pagenum = ceil($total / $perpage);
  5448. $over = $total - ($start + $perpage);
  5449. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5450. echo json_encode($rows);
  5451. exit;
  5452. }
  5453. if (isset($post['rsku'])) {
  5454. $cz = $this->input->post('cz', true);
  5455. $label = $this->input->post('rsku', true);
  5456. $sl = $this->input->post('sl', true);
  5457. $warehouse = $this->input->post('warehouse', true);
  5458. if (!$sl) {
  5459. $sl = 1;
  5460. }
  5461. if (!$warehouse) {
  5462. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5463. exit;
  5464. }
  5465. $dblabel = $this->whlabellabel->get_label($label);
  5466. if ($dblabel) {
  5467. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5468. if (count($data) < 1) {
  5469. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5470. exit;
  5471. }
  5472. if ($sl > count($data)) {
  5473. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5474. exit;
  5475. }
  5476. $time = time();
  5477. for ($i = 0; $i < $sl; $i++) {
  5478. $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']);
  5479. }
  5480. echo json_encode(array('success' => true));
  5481. exit;
  5482. } else {
  5483. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5484. exit;
  5485. }
  5486. }
  5487. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5488. $this->_Template('whlabel_dbrk', $this->data);
  5489. }
  5490. public function _whlabelczdc()
  5491. {
  5492. if (isset($_GET['excel'])) {
  5493. //数据排序
  5494. $order_str = "id desc";
  5495. if (empty($page)) {
  5496. $start = 0;
  5497. $perpage = 1;
  5498. } else {
  5499. $start = ($page - 1) * $perpage;
  5500. }
  5501. $state = $this->input->get('state', true);
  5502. $sku = $this->input->get('sku', true);
  5503. $ctime = $this->input->get('ctime', true);
  5504. $category = $this->input->get('category', true);
  5505. $size = $this->input->get('size', true);
  5506. $grade = $this->input->get('grade', true);
  5507. $color = $this->input->get('color', true);
  5508. $lowe = $this->input->get('lowe', true);
  5509. $timetk = $this->input->get('timetkk', true);
  5510. $timetj = $this->input->get('timetjj', true);
  5511. $timetk = strtotime($timetk);
  5512. $timetj = strtotime($timetj);
  5513. $where = "dbtime > 0";
  5514. if ($timetk && $timetj) {
  5515. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5516. }
  5517. if ($category) {
  5518. $where .= " and features like '%-$category-%'";
  5519. }
  5520. if ($size) {
  5521. $where .= " and features like '%-$size-%'";
  5522. }
  5523. if ($grade) {
  5524. $where .= " and features like '%-$grade-%'";
  5525. }
  5526. if ($color) {
  5527. $where .= " and features like '%-$color-%'";
  5528. }
  5529. if ($lowe) {
  5530. $where .= " and features like '%-$lowe-%'";
  5531. }
  5532. //取得信息列表
  5533. $info_list = $this->whlabel->find_all($where, '*');
  5534. $rows = array();
  5535. $list = array();
  5536. foreach ($info_list as $key => $value) {
  5537. $rows[$value['sku']] = $value; //所有数据sku
  5538. }
  5539. foreach ($rows as $value) {
  5540. $warehouse = $this->warehouse->read($value['warehouse']);
  5541. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5542. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5543. if ($value['orderinfo'] == 0) {
  5544. $info_list[$key]['orderinfo'] = "";
  5545. }
  5546. if ($value['waybill'] == 0) {
  5547. $info_list[$key]['waybill'] = "";
  5548. }
  5549. if ($value['state'] == 0) {
  5550. $value['state'] = "在库";
  5551. } else if ($value['state'] == 3) {
  5552. $value['state'] = "调拨中";
  5553. }
  5554. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5555. }
  5556. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5557. $titlename = "<table border=1>
  5558. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5559. <tr align='center'>
  5560. <td>SKU</td>
  5561. <td>产品</td>
  5562. <td>调拨数量</td>
  5563. <td>入库数量</td>
  5564. </tr>
  5565. </table>";
  5566. $filename = $title . ".xls";
  5567. $tail = "";
  5568. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5569. }
  5570. }
  5571. public function _print($arg_array)
  5572. {
  5573. if (isset($_SESSION['api'])) {
  5574. $user = $this->user->get_api($_SESSION['api']);
  5575. $usp = $user;
  5576. $fgshop = "";
  5577. $sid = "";
  5578. $wid = "";
  5579. $wtype = "";
  5580. $usersp = explode('|', trim($user['shop'], '|'));
  5581. $userwh = explode('|', trim($user['warehouse'], '|'));
  5582. foreach ($usersp as $value) {
  5583. $fgshop .= " shop = " . $value . " or";
  5584. $sid .= " id = " . $value . " or";
  5585. }
  5586. foreach ($userwh as $value) {
  5587. $wid .= " id = " . $value . " or";
  5588. $wtype .= " type = " . $value . " or";
  5589. }
  5590. }
  5591. $post = $this->input->post(NULL, TRUE);
  5592. if (isset($post['tmsku'])) {
  5593. $tmsku = $this->input->post('tmsku', true);
  5594. if (is_numeric($tmsku)) {
  5595. $yyh = $this->whlabellabel->get_label($tmsku);
  5596. } else {
  5597. $yyh = $this->whlabellabel->get_sku($tmsku);
  5598. if(empty($yyh)){
  5599. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  5600. if($r['code'] == -1 ){
  5601. echo json_encode(array('success' => false));
  5602. exit;
  5603. }else{
  5604. echo json_encode(array('features' => $r['data'], 'success' => true));
  5605. exit;
  5606. }
  5607. }
  5608. }
  5609. if ($yyh) {
  5610. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5611. exit;
  5612. } else {
  5613. echo json_encode(array('success' => false));
  5614. exit;
  5615. }
  5616. }
  5617. $classid = $this->classid->sku();
  5618. $pm = $classid;
  5619. $scsku = $classid;
  5620. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5621. if (isset($post['warehouse'])) {
  5622. if ($post['warehouse']) {
  5623. $list = array();
  5624. $num = "";
  5625. $title = "";
  5626. $features = "";
  5627. $order = 0;
  5628. $post['shop'] = '';
  5629. $brand = $this->input->post('brand', true);
  5630. if ($brand != '0,') {
  5631. $b = $this->brand->read(rtrim($brand, ','));
  5632. if ($b) {
  5633. $post['shop'] = str_replace('|', ',', $b['shop']);
  5634. }
  5635. }
  5636. $post['details'] = $this->input->post('details', true); //打印数量
  5637. $xbqnum = $this->input->post('xbqnum', true);
  5638. $post['purchase'] = $this->input->post('purchase', true);
  5639. $post['warehouse'] = $this->input->post('warehouse', true);
  5640. $post['purchase'] = $this->input->post('purchase', true);
  5641. $post['retreatwarehouse'] = $post['warehouse'];
  5642. $post['cpbz'] = $this->input->post('cpbz', true);
  5643. $post['state'] = 9;
  5644. $category = $this->input->post('category', true);
  5645. $list['category'] = $category;
  5646. $list['hairtype'] = $this->input->post('hairtype', true);
  5647. $list['grade'] = $this->input->post('grade', true);
  5648. $size = $this->input->post('size', true);
  5649. $list['size'] = rtrim($size, ',');
  5650. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5651. $list['extension'] = $this->input->post('extension', true);
  5652. if ($category == 1297) {
  5653. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5654. }
  5655. if ($category == 1702) {
  5656. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5657. $list['syother'] = $this->input->post('syother', true);
  5658. }
  5659. if ($category == 133) {
  5660. $list['fittype'] = $this->input->post('fittype', true);
  5661. $list['acother'] = $this->input->post('acother', true);
  5662. }
  5663. $list['color'] = $this->input->post('color', true);
  5664. $list['lowe'] = $this->input->post('lowe', true);
  5665. if ($category == 127) {
  5666. $list['type'] = $this->input->post('type', true);
  5667. $list['headroad'] = $this->input->post('headroad', true);
  5668. $list['density'] = $this->input->post('density', true);
  5669. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5670. $list['lacesize'] = $this->input->post('lacesize', true);
  5671. }
  5672. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5673. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5674. }
  5675. if ($category == 128) {
  5676. $list['lacetype'] = $this->input->post('lacetype', true);
  5677. $list['haircap'] = $this->input->post('haircap', true);
  5678. $list['density'] = $this->input->post('density', true);
  5679. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5680. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5681. $list['wigother'] = $this->input->post('wigother', true);
  5682. $list['wigother1'] = $this->input->post('wigother1', true);
  5683. $list['wigother2'] = $this->input->post('wigother2', true);
  5684. }
  5685. if ($category == 129) {
  5686. $list['wide'] = $this->input->post('wide', true);
  5687. }
  5688. if ($category == 131) {
  5689. $list['gifttype'] = $this->input->post('gifttype', true);
  5690. $list['giftother'] = $this->input->post('giftother', true);
  5691. }
  5692. if ($category == 134) {
  5693. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5694. }
  5695. if ($category == 1297) {
  5696. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5697. $list['sywigother'] = $this->input->post('sywigother', true);
  5698. }
  5699. if ($category == 130 || $category == 133 || $category == 1702) {
  5700. $list['items'] = $this->input->post('items', true);
  5701. $list['weight'] = $this->input->post('weight', true);
  5702. }
  5703. if ($category == 1702) {
  5704. $list['syhairther'] = $this->input->post('syhairther', true);
  5705. }
  5706. if($category == 130){
  5707. $list['jfother'] = $this->input->post('jfother', true);
  5708. }
  5709. foreach ($list as $k => $v) {
  5710. if ($v != 0) {
  5711. $num .= $v;
  5712. $features .= $v . '-';
  5713. $post[$k] = $v;
  5714. $typeclass = $this->typeclass->read($v);
  5715. if (isset($pm[$typeclass['classid']])) {
  5716. if (stripos($typeclass['zh'], '|') !== false) {
  5717. $exzh = explode('|', $typeclass['zh']);
  5718. $pm[$typeclass['classid']] = $exzh[0];
  5719. } else {
  5720. $pm[$typeclass['classid']] = $typeclass['zh'];
  5721. }
  5722. }
  5723. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5724. if ($k != 'size') {
  5725. $title .= $typeclass['title'] . " ";
  5726. }
  5727. }
  5728. }
  5729. $typeclass = $this->typeclass->read($list['size']);
  5730. $title .= $typeclass['title'];
  5731. $time = time();
  5732. $post['title'] = rtrim($title, ' ');
  5733. $post['number'] = $num;
  5734. $post['features'] = '-' . $features;
  5735. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5736. $featurespp = explode('-', trim($featurespp, '-'));
  5737. if (isset($featurespp[5])) {
  5738. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5739. } else {
  5740. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5741. }
  5742. $post['enter'] = $time;
  5743. $post['time'] = $time; //操作时间
  5744. $scsku = implode("-", $scsku);
  5745. $zh = implode(" ", $pm);
  5746. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5747. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5748. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5749. $post['sku'] = $bqsku;
  5750. $label = time() . rand(0, 9);
  5751. $post['label'] = $label;
  5752. $cpid = $this->whlabellabel->find_count();
  5753. $post['cpid'] = $cpid + 1;
  5754. $cpid = $post['cpid'];
  5755. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5756. //if($whlabelbarcode)
  5757. //{
  5758. //$post['label'] = $whlabelbarcode['label'];
  5759. //if(!$this->whlabellabel->insert($post))
  5760. //{
  5761. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5762. //}
  5763. //}
  5764. //else
  5765. //{
  5766. $this->db->trans_begin();
  5767. $this->whlabellabel->insert($post);
  5768. //$this->whlabelbarcode->insert($post);
  5769. if ($this->db->trans_status() === TRUE) {
  5770. $this->db->trans_commit();
  5771. } else {
  5772. $this->db->trans_rollback();
  5773. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5774. exit;
  5775. }
  5776. //}
  5777. $warehouse_name = "";
  5778. $warehouse = $post['warehouse'];
  5779. if($warehouse == 12){
  5780. $warehouse_name = "特殊库存库";
  5781. }
  5782. // if($warehouse == 13){
  5783. // $warehouse_name = "许昌仓";
  5784. // }
  5785. // if($warehouse == 5){
  5786. // $warehouse_name = "美国店";
  5787. // }
  5788. // if($warehouse == 16){
  5789. // $warehouse_name = "定制头套仓";
  5790. // }
  5791. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5792. if(!empty($warehouse_name)){
  5793. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5794. }
  5795. $purchase = $this->purchase->read($post['purchase']);
  5796. 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));
  5797. exit; //特殊仓目前不需要仓库选项
  5798. }
  5799. }
  5800. if (isset($_SESSION['api'])) {
  5801. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5802. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5803. $this->data['wlshop'] = $wlshop;
  5804. $this->data['warehouse'] = $warehouse;
  5805. }
  5806. $whlabelwz = $this->whlabelwz->find_all();
  5807. $this->data['whlabelwz'] = $whlabelwz;
  5808. $this->_Template('whlabel_print', $this->data);
  5809. }
  5810. public function _usaprint($arg_array)
  5811. {
  5812. if (isset($_SESSION['api'])) {
  5813. $user = $this->user->get_api($_SESSION['api']);
  5814. $usp = $user;
  5815. $fgshop = "";
  5816. $sid = "";
  5817. $wid = "";
  5818. $wtype = "";
  5819. $usersp = explode('|', trim($user['shop'], '|'));
  5820. $userwh = explode('|', trim($user['warehouse'], '|'));
  5821. foreach ($usersp as $value) {
  5822. $fgshop .= " shop = " . $value . " or";
  5823. $sid .= " id = " . $value . " or";
  5824. }
  5825. foreach ($userwh as $value) {
  5826. $wid .= " id = " . $value . " or";
  5827. $wtype .= " type = " . $value . " or";
  5828. }
  5829. }
  5830. $post = $this->input->post(NULL, TRUE);
  5831. if (isset($post['tmsku'])) {
  5832. $tmsku = $this->input->post('tmsku', true);
  5833. if (is_numeric($tmsku)) {
  5834. $yyh = $this->whlabellabel->get_label($tmsku);
  5835. } else {
  5836. $yyh = $this->whlabellabel->get_sku($tmsku);
  5837. }
  5838. if ($yyh) {
  5839. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5840. exit;
  5841. } else {
  5842. echo json_encode(array('success' => false));
  5843. exit;
  5844. }
  5845. }
  5846. $classid = $this->classid->sku();
  5847. $pm = $classid;
  5848. $scsku = $classid;
  5849. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5850. if (isset($post['warehouse'])) {
  5851. if ($post['warehouse']) {
  5852. $list = array();
  5853. $num = "";
  5854. $title = "";
  5855. $features = "";
  5856. $order = 0;
  5857. $post['shop'] = '';
  5858. $brand = $this->input->post('brand', true);
  5859. if ($brand != '0,') {
  5860. $b = $this->brand->read(rtrim($brand, ','));
  5861. if ($b) {
  5862. $post['shop'] = str_replace('|', ',', $b['shop']);
  5863. }
  5864. }
  5865. $post['details'] = $this->input->post('details', true); //打印数量
  5866. $xbqnum = $this->input->post('xbqnum', true);
  5867. $post['purchase'] = $this->input->post('purchase', true);
  5868. $post['warehouse'] = $this->input->post('warehouse', true);
  5869. $post['purchase'] = $this->input->post('purchase', true);
  5870. $post['retreatwarehouse'] = $post['warehouse'];
  5871. $post['cpbz'] = $this->input->post('cpbz', true);
  5872. $post['state'] = 9;
  5873. $category = $this->input->post('category', true);
  5874. $list['category'] = $category;
  5875. $list['hairtype'] = $this->input->post('hairtype', true);
  5876. $list['grade'] = $this->input->post('grade', true);
  5877. $size = $this->input->post('size', true);
  5878. $list['size'] = rtrim($size, ',');
  5879. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5880. $list['extension'] = $this->input->post('extension', true);
  5881. if ($category == 1297) {
  5882. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5883. }
  5884. if ($category == 1702) {
  5885. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5886. $list['syother'] = $this->input->post('syother', true);
  5887. }
  5888. if ($category == 133) {
  5889. $list['fittype'] = $this->input->post('fittype', true);
  5890. $list['acother'] = $this->input->post('acother', true);
  5891. }
  5892. $list['color'] = $this->input->post('color', true);
  5893. $list['lowe'] = $this->input->post('lowe', true);
  5894. if ($category == 127) {
  5895. $list['type'] = $this->input->post('type', true);
  5896. $list['headroad'] = $this->input->post('headroad', true);
  5897. $list['density'] = $this->input->post('density', true);
  5898. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5899. $list['lacesize'] = $this->input->post('lacesize', true);
  5900. }
  5901. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5902. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5903. }
  5904. if ($category == 128) {
  5905. $list['lacetype'] = $this->input->post('lacetype', true);
  5906. $list['haircap'] = $this->input->post('haircap', true);
  5907. $list['density'] = $this->input->post('density', true);
  5908. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5909. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5910. $list['wigother'] = $this->input->post('wigother', true);
  5911. $list['wigother1'] = $this->input->post('wigother1', true);
  5912. $list['wigother2'] = $this->input->post('wigother2', true);
  5913. }
  5914. if ($category == 129) {
  5915. $list['wide'] = $this->input->post('wide', true);
  5916. }
  5917. if ($category == 131) {
  5918. $list['gifttype'] = $this->input->post('gifttype', true);
  5919. $list['giftother'] = $this->input->post('giftother', true);
  5920. }
  5921. if ($category == 134) {
  5922. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5923. }
  5924. if ($category == 1297) {
  5925. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5926. $list['sywigother'] = $this->input->post('sywigother', true);
  5927. }
  5928. if ($category == 130 || $category == 133 || $category == 1702) {
  5929. $list['items'] = $this->input->post('items', true);
  5930. $list['weight'] = $this->input->post('weight', true);
  5931. }
  5932. if ($category == 1702) {
  5933. $list['syhairther'] = $this->input->post('syhairther', true);
  5934. }
  5935. foreach ($list as $k => $v) {
  5936. if ($v != 0) {
  5937. $num .= $v;
  5938. $features .= $v . '-';
  5939. $post[$k] = $v;
  5940. $typeclass = $this->typeclass->read($v);
  5941. if (isset($pm[$typeclass['classid']])) {
  5942. if (stripos($typeclass['zh'], '|') !== false) {
  5943. $exzh = explode('|', $typeclass['zh']);
  5944. $pm[$typeclass['classid']] = $exzh[0];
  5945. } else {
  5946. $pm[$typeclass['classid']] = $typeclass['zh'];
  5947. }
  5948. }
  5949. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5950. if ($k != 'size') {
  5951. $title .= $typeclass['title'] . " ";
  5952. }
  5953. }
  5954. }
  5955. $typeclass = $this->typeclass->read($list['size']);
  5956. $title .= $typeclass['title'];
  5957. $time = time();
  5958. $post['title'] = rtrim($title, ' ');
  5959. $post['number'] = $num;
  5960. $post['features'] = '-' . $features;
  5961. $fp = $this->whlabel->get_features($post['features']);
  5962. if (!$fp) {
  5963. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5964. exit;
  5965. }
  5966. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5967. $featurespp = explode('-', trim($featurespp, '-'));
  5968. if (isset($featurespp[5])) {
  5969. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5970. } else {
  5971. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5972. }
  5973. $post['enter'] = $time;
  5974. $post['time'] = $time; //操作时间
  5975. $scsku = implode("-", $scsku);
  5976. $zh = implode(" ", $pm);
  5977. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5978. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5979. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5980. $post['sku'] = $fp['sku'];
  5981. $post['label'] = $fp['sku'];
  5982. $cpid = $this->whlabellabel->find_count();
  5983. $post['cpid'] = $cpid + 1;
  5984. $cpid = $post['cpid'];
  5985. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5986. //if($whlabelbarcode)
  5987. //{
  5988. //$post['label'] = $whlabelbarcode['label'];
  5989. //if(!$this->whlabellabel->insert($post))
  5990. //{
  5991. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5992. //}
  5993. //}
  5994. //else
  5995. //{
  5996. $this->db->trans_begin();
  5997. $this->whlabellabel->insert($post);
  5998. //$this->whlabelbarcode->insert($post);
  5999. if ($this->db->trans_status() === TRUE) {
  6000. $this->db->trans_commit();
  6001. } else {
  6002. $this->db->trans_rollback();
  6003. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6004. exit;
  6005. }
  6006. //}
  6007. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6008. $purchase = $this->purchase->read($post['purchase']);
  6009. 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));
  6010. exit; //特殊仓目前不需要仓库选项
  6011. }
  6012. }
  6013. if (isset($_SESSION['api'])) {
  6014. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6015. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6016. $this->data['wlshop'] = $wlshop;
  6017. $this->data['warehouse'] = $warehouse;
  6018. }
  6019. $whlabelwz = $this->whlabelwz->find_all();
  6020. $this->data['whlabelwz'] = $whlabelwz;
  6021. $this->_Template('whlabel_usaprint', $this->data);
  6022. }
  6023. public function _printrk($arg_array)
  6024. {
  6025. $prc = array();
  6026. $purchase = $this->purchase->find_all();
  6027. foreach ($purchase as $k => $v) {
  6028. $prc[$v['id']] = $v['title'];
  6029. }
  6030. $post = $this->input->post(NULL, TRUE);
  6031. if (isset($post['page'])) {
  6032. $page = $this->input->post('page', true);
  6033. $perpage = $this->input->post('perpage', true);
  6034. $sku = $this->input->post('sku', true);
  6035. $bs = $this->input->post('bs', true);
  6036. $number = $this->input->post('number', true);
  6037. $warehouse = $this->input->post('warehouse', true);
  6038. $purchase = $this->input->post('purchase', true);
  6039. $orderinfo = $this->input->post('orderinfo', true);
  6040. $waybill = $this->input->post('waybill', true);
  6041. $category = $this->input->post('category', true);
  6042. $size = $this->input->post('size', true);
  6043. $grade = $this->input->post('grade', true);
  6044. $color = $this->input->post('color', true);
  6045. $lowe = $this->input->post('lowe', true);
  6046. $state = $this->input->post('state', true);
  6047. $label = $this->input->post('label', true);
  6048. $timetk = $this->input->post('ktime', true);
  6049. $timetj = $this->input->post('jtime', true);
  6050. $timetk = strtotime($timetk);
  6051. $timetj = strtotime($timetj);
  6052. $where = "1=1 ";
  6053. if ($timetk && $timetj) {
  6054. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6055. }
  6056. if ($sku) {
  6057. $where .= " and sku = '$sku'";
  6058. }
  6059. if ($bs != '') {
  6060. $where .= " and bs = '$bs'";
  6061. }
  6062. if ($number) {
  6063. $where .= " and number = '$number'";
  6064. }
  6065. if ($warehouse) {
  6066. $where .= " and warehouse = '$warehouse'";
  6067. }
  6068. if ($purchase) {
  6069. $where .= " and purchase = '$purchase'";
  6070. }
  6071. if ($orderinfo) {
  6072. $where .= " and orderinfo = '$orderinfo'";
  6073. }
  6074. if ($waybill) {
  6075. $where .= " and waybill = '$waybill'";
  6076. }
  6077. if ($category) {
  6078. $where .= " and features like '%-$category-%'";
  6079. }
  6080. if ($size) {
  6081. $where .= " and features like '%-$size-%'";
  6082. }
  6083. if ($grade) {
  6084. $where .= " and features like '%-$grade-%'";
  6085. }
  6086. if ($color) {
  6087. $where .= " and features like '%-$color-%'";
  6088. }
  6089. if ($lowe) {
  6090. $where .= " and features like '%-$lowe-%'";
  6091. }
  6092. if ($label) {
  6093. $where .= " and label = '$label'";
  6094. }
  6095. if ($state || $state == 0) {
  6096. $where .= " and state = '$state'";
  6097. }
  6098. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6099. //数据排序
  6100. $order_str = "enter desc";
  6101. if (empty($page)) {
  6102. $start = 0;
  6103. $perpage = 1;
  6104. } else {
  6105. $start = ($page - 1) * $perpage;
  6106. }
  6107. //取得信息列表
  6108. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6109. foreach ($info_list as $key => $value) {
  6110. $warehouse = $this->warehouse->read($value['warehouse']);
  6111. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6112. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6113. if ($value['state'] == 0) {
  6114. $info_list[$key]['state'] = "在库";
  6115. } else if ($value['state'] == 1) {
  6116. $info_list[$key]['state'] = "出库";
  6117. } else if ($value['state'] == 2) {
  6118. $info_list[$key]['state'] = "退库";
  6119. } else if ($value['state'] == 3) {
  6120. $info_list[$key]['state'] = "调拨中";
  6121. } else if ($value['state'] == 4) {
  6122. $info_list[$key]['state'] = "再加工";
  6123. } else if ($value['state'] == 5) {
  6124. $info_list[$key]['state'] = "维修中";
  6125. } else if ($value['state'] == 6) {
  6126. $info_list[$key]['state'] = "盘亏";
  6127. } else if ($value['state'] == 7) {
  6128. $info_list[$key]['state'] = "更换标签";
  6129. } else if ($value['state'] == 8) {
  6130. $info_list[$key]['state'] = "其它";
  6131. } else if ($value['state'] == 9) {
  6132. $info_list[$key]['state'] = "预设";
  6133. } else if ($value['state'] == 10) {
  6134. $info_list[$key]['state'] = "美店零售";
  6135. }
  6136. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6137. }
  6138. $total = $this->$ck->find_count($where);
  6139. $pagenum = ceil($total / $perpage);
  6140. $over = $total - ($start + $perpage);
  6141. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6142. echo json_encode($rows);
  6143. exit;
  6144. }
  6145. if (isset($post['tmsku'])) {
  6146. $time = time();
  6147. $tmsku = $this->input->post('tmsku', true);
  6148. //$post['shop'] = $this->input->post('shop',true);
  6149. $num = $this->input->post('num', true);
  6150. $rktype = $this->input->post('rktype', true);
  6151. if ($num > 200) {
  6152. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6153. exit;
  6154. }
  6155. if (!$rktype) {
  6156. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6157. }
  6158. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6159. /**
  6160. $wz = array();
  6161. foreach ($rk as $key=>$value)
  6162. {
  6163. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6164. }
  6165. if(count($wz) > 1)
  6166. {
  6167. $wz = array_values($wz);
  6168. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6169. }
  6170. **/
  6171. if (isset($rk[0]['purchase'])) {
  6172. $rk = $rk[0];
  6173. $j = 0;
  6174. $post['purchase'] = $rk['purchase'];
  6175. $post['warehouse'] = $rk['warehouse'];
  6176. $post['retreatwarehouse'] = $rk['warehouse'];
  6177. $post['sku'] = $rk['sku'];
  6178. $post['number'] = $rk['number'];
  6179. $post['features'] = $rk['features'];
  6180. $post['title'] = $rk['title'];
  6181. $post['enter'] = $time;
  6182. $post['time'] = $time;
  6183. $post['bs'] = 1;
  6184. $post['shop'] = $rk['shop'];
  6185. $post['details'] = $rk['details'];
  6186. $post['cpid'] = $rk['cpid'];
  6187. $post['cpbz'] = $rk['cpbz'];
  6188. $post['rktype'] = $rktype;
  6189. $warehouse = $this->warehouse->read($rk['warehouse']);
  6190. if ($warehouse['bdck'] == '') {
  6191. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6192. exit;
  6193. } else {
  6194. $bdck = $warehouse['bdck'];
  6195. }
  6196. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6197. if (isset($pdwz['details'])) {
  6198. if ($pdwz['details'] != $post['details']) {
  6199. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6200. exit;
  6201. }
  6202. }
  6203. $post['featurespp'] = $rk['featurespp'];
  6204. if ($post['warehouse'] == '5') {
  6205. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6206. if ($yza) {
  6207. if ($post['features'] != $yza[0]['features']) {
  6208. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6209. exit;
  6210. }
  6211. }
  6212. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6213. if ($yzb) {
  6214. if ($post['sku'] != $yzb[0]['sku']) {
  6215. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6216. exit;
  6217. }
  6218. }
  6219. }
  6220. for ($i = 0; $i < $num; $i++) {
  6221. $post['label'] = time() . rand(100, 999) . $i;
  6222. if ($this->$bdck->insert($post)) {
  6223. $j++;
  6224. }
  6225. }
  6226. /**
  6227. if($post['warehouse'] != 12)
  6228. {
  6229. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6230. }
  6231. **/
  6232. $this->whlabelscanlog->insert([
  6233. 'shop'=>$rk['shop'],
  6234. 'type'=>1,
  6235. 'purchase'=>$rk['purchase'],
  6236. 'sku'=>$rk['sku'],
  6237. 'features'=>$rk['features'],
  6238. 'title'=>$rk['title'],
  6239. 'label'=>$rk['label'],
  6240. 'warehouse'=>$rk['warehouse'],
  6241. 'wlid'=>$rk['id'],
  6242. 'num'=>$num,
  6243. 'addtime'=>time()
  6244. ]);
  6245. if ($j == $num) {
  6246. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6247. exit;
  6248. } else {
  6249. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6250. exit;
  6251. }
  6252. } else {
  6253. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6254. exit;
  6255. }
  6256. }
  6257. $this->_Template('whlabel_printrk', $this->data);
  6258. }
  6259. public function _printxzrk($arg_array)
  6260. {
  6261. $post = $this->input->post(NULL, TRUE);
  6262. if (isset($post['wzid'])) {
  6263. $time = time();
  6264. $id = $this->input->post('wzid', true);
  6265. //$post['shop'] = $this->input->post('shop',true);
  6266. $num = 1;
  6267. $rk = $this->whlabellabel->read($id);
  6268. if (isset($rk['purchase'])) {
  6269. $x = 0;
  6270. $post['purchase'] = $rk['purchase'];
  6271. $post['warehouse'] = $rk['warehouse'];
  6272. $post['retreatwarehouse'] = $rk['warehouse'];
  6273. $post['sku'] = $rk['sku'];
  6274. $post['number'] = $rk['number'];
  6275. $post['features'] = $rk['features'];
  6276. $post['title'] = $rk['title'];
  6277. $post['enter'] = $time;
  6278. $post['time'] = $time;
  6279. $post['bs'] = 1;
  6280. $post['shop'] = $rk['shop'];
  6281. $post['details'] = $rk['details'];
  6282. $post['cpid'] = $rk['cpid'];
  6283. $post['cpbz'] = $rk['cpbz'];
  6284. $warehouse = $this->warehouse->read($rk['warehouse']);
  6285. if ($warehouse['bdck'] == '') {
  6286. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6287. exit;
  6288. } else {
  6289. $bdck = $warehouse['bdck'];
  6290. }
  6291. $post['featurespp'] = $rk['featurespp'];
  6292. $this->db->trans_begin();
  6293. for ($i = 0; $i < $num; $i++) {
  6294. $post['label'] = time() . rand(100, 999) . $i;
  6295. $this->$bdck->insert($post);
  6296. }
  6297. /**
  6298. if($post['warehouse'] != 12)
  6299. {
  6300. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6301. }
  6302. **/
  6303. if ($this->db->trans_status() === TRUE) {
  6304. $this->db->trans_commit();
  6305. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6306. exit;
  6307. } else {
  6308. $this->db->trans_rollback();
  6309. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6310. exit;
  6311. }
  6312. } else {
  6313. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6314. exit;
  6315. }
  6316. }
  6317. }
  6318. public function _printck($arg_array)
  6319. {
  6320. $prc = array();
  6321. $purchase = $this->purchase->find_all();
  6322. foreach ($purchase as $k => $v) {
  6323. $prc[$v['id']] = $v['title'];
  6324. }
  6325. $post = $this->input->post(NULL, TRUE);
  6326. if (isset($post['page'])) {
  6327. $page = $this->input->post('page', true);
  6328. $perpage = $this->input->post('perpage', true);
  6329. $sku = $this->input->post('sku', true);
  6330. $bs = $this->input->post('bs', true);
  6331. $number = $this->input->post('number', true);
  6332. $warehouse = $this->input->post('warehouse', true);
  6333. $purchase = $this->input->post('purchase', true);
  6334. $orderinfo = $this->input->post('orderinfo', true);
  6335. $waybill = $this->input->post('waybill', true);
  6336. $category = $this->input->post('category', true);
  6337. $size = $this->input->post('size', true);
  6338. $grade = $this->input->post('grade', true);
  6339. $color = $this->input->post('color', true);
  6340. $lowe = $this->input->post('lowe', true);
  6341. $state = $this->input->post('state', true);
  6342. $label = $this->input->post('label', true);
  6343. $timetk = $this->input->post('ktime', true);
  6344. $timetj = $this->input->post('jtime', true);
  6345. $timetk = strtotime($timetk);
  6346. $timetj = strtotime($timetj);
  6347. $where = "state=1 ";
  6348. if ($timetk && $timetj) {
  6349. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6350. }
  6351. if ($sku) {
  6352. $where .= " and sku = '$sku'";
  6353. }
  6354. if ($bs != '') {
  6355. $where .= " and bs = '$bs'";
  6356. }
  6357. if ($number) {
  6358. $where .= " and number = '$number'";
  6359. }
  6360. if ($warehouse) {
  6361. $where .= " and warehouse = '$warehouse'";
  6362. }
  6363. if ($purchase) {
  6364. $where .= " and purchase = '$purchase'";
  6365. }
  6366. if ($orderinfo) {
  6367. $where .= " and orderinfo = '$orderinfo'";
  6368. }
  6369. if ($waybill) {
  6370. $where .= " and waybill = '$waybill'";
  6371. }
  6372. if ($category) {
  6373. $where .= " and features like '%-$category-%'";
  6374. }
  6375. if ($size) {
  6376. $where .= " and features like '%-$size-%'";
  6377. }
  6378. if ($grade) {
  6379. $where .= " and features like '%-$grade-%'";
  6380. }
  6381. if ($color) {
  6382. $where .= " and features like '%-$color-%'";
  6383. }
  6384. if ($lowe) {
  6385. $where .= " and features like '%-$lowe-%'";
  6386. }
  6387. if ($label) {
  6388. $where .= " and label = '$label'";
  6389. }
  6390. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6391. //数据排序
  6392. $order_str = "outk desc";
  6393. if (empty($page)) {
  6394. $start = 0;
  6395. $perpage = 1;
  6396. } else {
  6397. $start = ($page - 1) * $perpage;
  6398. }
  6399. //取得信息列表
  6400. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6401. foreach ($info_list as $key => $value) {
  6402. $warehouse = $this->warehouse->read($value['warehouse']);
  6403. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6404. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6405. if ($value['state'] == 0) {
  6406. $info_list[$key]['state'] = "在库";
  6407. } else if ($value['state'] == 1) {
  6408. $info_list[$key]['state'] = "出库";
  6409. } else if ($value['state'] == 2) {
  6410. $info_list[$key]['state'] = "退库";
  6411. } else if ($value['state'] == 3) {
  6412. $info_list[$key]['state'] = "调拨中";
  6413. } else if ($value['state'] == 4) {
  6414. $info_list[$key]['state'] = "再加工";
  6415. } else if ($value['state'] == 5) {
  6416. $info_list[$key]['state'] = "维修中";
  6417. } else if ($value['state'] == 6) {
  6418. $info_list[$key]['state'] = "盘亏";
  6419. } else if ($value['state'] == 7) {
  6420. $info_list[$key]['state'] = "更换标签";
  6421. } else if ($value['state'] == 8) {
  6422. $info_list[$key]['state'] = "其它";
  6423. } else if ($value['state'] == 9) {
  6424. $info_list[$key]['state'] = "预设";
  6425. } else if ($value['state'] == 10) {
  6426. $info_list[$key]['state'] = "美店零售";
  6427. }
  6428. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6429. }
  6430. $total = $this->$ck->find_count($where);
  6431. $pagenum = ceil($total / $perpage);
  6432. $over = $total - ($start + $perpage);
  6433. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6434. echo json_encode($rows);
  6435. exit;
  6436. }
  6437. if (isset($post['tmsku'])) {
  6438. $time = time();
  6439. $tmsku = $this->input->post('tmsku', true);
  6440. //$post['shop'] = $this->input->post('shop',true);
  6441. $num = $this->input->post('num', true);
  6442. $cktype = $this->input->post('cktype', true);
  6443. $label = $this->whlabellabel->get_label($tmsku);
  6444. if (!$cktype) {
  6445. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6446. }
  6447. if (!isset($label['warehouse'])) {
  6448. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6449. exit;
  6450. }
  6451. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6452. if (stripos($label['features'], '-126-') !== false) {
  6453. $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 )");
  6454. } else {
  6455. $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 ) ");
  6456. }
  6457. $j = 0;
  6458. if (count($ck) >= $num) {
  6459. for ($i = 0; $i < $num; $i++) {
  6460. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6461. {
  6462. $j++;
  6463. }
  6464. }
  6465. $this->whlabelscanlog->insert([
  6466. 'shop'=>$label['shop'],
  6467. 'type'=>2,
  6468. 'purchase'=>$label['purchase'],
  6469. 'sku'=>$label['sku'],
  6470. 'features'=>$label['features'],
  6471. 'title'=>$label['title'],
  6472. 'label'=>$label['label'],
  6473. 'warehouse'=>$label['warehouse'],
  6474. 'wlid'=>$label['id'],
  6475. 'num'=>$num,
  6476. 'addtime'=>time()
  6477. ]);
  6478. if ($j == $num) {
  6479. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6480. exit;
  6481. } else {
  6482. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6483. exit;
  6484. }
  6485. } else {
  6486. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6487. exit;
  6488. }
  6489. }
  6490. if(isset($_SESSION['api']))
  6491. {
  6492. $user = $this->user->get_api($_SESSION['api']);
  6493. if(in_array($user['power'],[1,27])){
  6494. $vip = 1;
  6495. }
  6496. }
  6497. else
  6498. {
  6499. $vip = 0;
  6500. header('Location: /');exit;
  6501. }
  6502. $this->data['vip'] = $vip;
  6503. $this->_Template('whlabel_printck', $this->data);
  6504. }
  6505. public function _printexcel()
  6506. {
  6507. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6508. $config['upload_path'] = '.' . $dir;
  6509. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6510. $config['allowed_types'] = 'xls|xlsx|csv';
  6511. $config['max_size'] = 10240;
  6512. $this->load->library('upload', $config);
  6513. $this->upload->initialize($config);
  6514. if ($this->upload->do_upload('userfile')) {
  6515. $full_path = $dir . $this->upload->data('file_name');
  6516. $fileName = '.' . $full_path;
  6517. if (!file_exists($fileName)) {
  6518. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6519. exit;
  6520. } else {
  6521. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6522. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6523. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6524. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6525. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6526. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6527. ++$column; //如果列数大于26行
  6528. $list = array();
  6529. for ($i = 2; $i <= $row; $i++) // 行数循环
  6530. {
  6531. $data = array();
  6532. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6533. {
  6534. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6535. }
  6536. $list[] = $data;
  6537. }
  6538. }
  6539. $ed = array();
  6540. $i = 0;
  6541. $j = 0;
  6542. $dcdata = array();
  6543. $yc = '';
  6544. $cmf_arr = array_column($list, '1');
  6545. array_multisort($cmf_arr, SORT_ASC, $list);
  6546. foreach ($list as $key => $value) {
  6547. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6548. if ($typeclass) {
  6549. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6550. } else {
  6551. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6552. $i++;
  6553. continue;
  6554. }
  6555. }
  6556. if ($i > 0) {
  6557. $yc = $i . '条异常';
  6558. }
  6559. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6560. exit;
  6561. }
  6562. }
  6563. public function _uck()
  6564. {
  6565. if (isset($_GET['excel'])) {
  6566. $tc = array();
  6567. $typeclass = $this->typeclass->find_all();
  6568. foreach ($typeclass as $v) {
  6569. $tc[$v['id']] = $v['zh'];
  6570. }
  6571. $data = array();
  6572. $t = array();
  6573. $rq = '';
  6574. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6575. $ts = $ts / (24 * 3600);
  6576. for ($i = 0; $i < $ts; $i++) {
  6577. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6578. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6579. }
  6580. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6581. foreach ($info_list as $k => $v) {
  6582. $features = explode('-', trim($v['features'], '-'));
  6583. if (!isset($features[3]) || !isset($features[4])) {
  6584. continue;
  6585. }
  6586. $data[$k][0] = $tc[$features[0]]; //类型
  6587. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6588. $data[$k][2] = $tc[$features[4]]; //曲度
  6589. $data[$k][3] = '';
  6590. if (isset($data[$k][1])) {
  6591. $data[$k][3] .= $data[$k][1];
  6592. }
  6593. if (isset($data[$k][2])) {
  6594. $data[$k][3] .= $data[$k][2];
  6595. }
  6596. if (isset($features[5])) {
  6597. $data[$k][3] .= $tc[$features[5]];
  6598. }
  6599. if (isset($features[2])) {
  6600. $data[$k][3] .= $tc[$features[2]];
  6601. }
  6602. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6603. $data[$k][4] = $v['sku'];
  6604. $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())) . '))'); //月初库存
  6605. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6606. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6607. $ztrq = '';
  6608. $ztsl = '';
  6609. if (count($zt) > 0) {
  6610. foreach ($zt as $vv) {
  6611. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6612. $ztsl .= $vv['num'] . '<br>';
  6613. }
  6614. }
  6615. $data[$k][] = trim($ztsl, '<br>');
  6616. $data[$k][] = trim($ztrq, '<br>');
  6617. $byck = 0;
  6618. foreach ($t as $vv) {
  6619. $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));
  6620. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6621. $byck += $sl;
  6622. }
  6623. $data[$k][] = ($byck > 0) ? $byck : '';
  6624. }
  6625. $title = "详情 " . date("Y-m-d", time());
  6626. $titlename = "<table border=1>
  6627. <tr align='center'>
  6628. <td>类别</td>
  6629. <td>颜色</td>
  6630. <td>曲度</td>
  6631. <td>名称</td>
  6632. <td>SKU</td>
  6633. <td>月初库存</td>
  6634. <td>剩余库存</td>
  6635. <td>在途数量</td>
  6636. <td>预达日期</td>" .
  6637. $rq
  6638. . "<td>本月出库</td></tr>
  6639. </table>";
  6640. $filename = $title . ".xls";
  6641. $tail = "";
  6642. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  6643. }
  6644. }
  6645. public function _whlabelexcelzh()
  6646. {
  6647. if (isset($_GET['excel'])) {
  6648. $where = "sku != 'Preset'";
  6649. //数据排序
  6650. $order_str = "id desc";
  6651. if (empty($page)) {
  6652. $start = 0;
  6653. $perpage = 1;
  6654. } else {
  6655. $start = ($page - 1) * $perpage;
  6656. }
  6657. $category = $this->input->get('category', true);
  6658. $warehouse = $this->input->get('warehouse', true);
  6659. $excelid = $this->input->get('sid', true);
  6660. if ($category) {
  6661. $where .= " and features like '%-$category-%'";
  6662. }
  6663. if ($warehouse) {
  6664. $where .= " and warehouse = '$warehouse'";
  6665. }
  6666. $xzid = '';
  6667. if ($excelid) {
  6668. $excelid = explode(',', trim($excelid, ','));
  6669. foreach ($excelid as $key => $value) {
  6670. $xzid .= " id = " . $value . " or";
  6671. }
  6672. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6673. }
  6674. //取得信息列表
  6675. /**
  6676. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6677. $rows = array();$list = array();
  6678. foreach ($info_list as $key=>$value)
  6679. {
  6680. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6681. }
  6682. **/
  6683. $list = array();
  6684. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6685. foreach ($rows as $key => $value) {
  6686. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6687. $zh = '';
  6688. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6689. foreach ($zt as $v) {
  6690. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6691. }
  6692. $zt = array_sum(array_column($zt, 'num'));
  6693. $number = $value['number'];
  6694. $ftime = time() - 15 * 24 * 3600;
  6695. $warehouse = $this->warehouse->read($value['warehouse']);
  6696. $rows[$key]['warehouse'] = $warehouse['title'];
  6697. $rows[$key]['number'] = $c;
  6698. $rows[$key]['features'] = $zh;
  6699. $rows[$key]['hb'] = $c + $zt;
  6700. }
  6701. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6702. $titlename = "<table border=1>
  6703. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6704. <tr align='center'>
  6705. <td>仓库</td>
  6706. <td>SKU</td>
  6707. <td>产品</td>
  6708. <td>库存数量</td>
  6709. <td>在途数量及预达日期</td>
  6710. <td>在途+库存数量</td>
  6711. </tr>
  6712. </table>";
  6713. $filename = $title . ".xls";
  6714. $tail = "";
  6715. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6716. }
  6717. if (isset($_GET['excel'])) {
  6718. $warehouse = $this->input->get('warehouse', true);
  6719. $sku = $this->input->get('sku', true);
  6720. $cz = $this->input->get('cz', true);
  6721. $text = $this->input->post('text', true);
  6722. $xztime = $this->input->get('xztime', true);
  6723. $timetk = $this->input->get('timetk', true);
  6724. $timetj = $this->input->get('timetj', true);
  6725. $timetk = strtotime($timetk);
  6726. $timetj = strtotime($timetj);
  6727. $where = "time = '0' ";
  6728. if ($warehouse) {
  6729. $where .= " and warehouse = '$warehouse'";
  6730. }
  6731. if ($sku) {
  6732. $where .= " and sku = '$sku'";
  6733. }
  6734. if ($text) {
  6735. $where .= " and text like '%$text%'";
  6736. }
  6737. if ($cz != '') {
  6738. $where .= " and cz = '$cz'";
  6739. }
  6740. if ($timetk && $timetj) {
  6741. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6742. }
  6743. //数据排序
  6744. $order_str = $xztime . " desc";
  6745. //取得信息列表
  6746. $zh = array();
  6747. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6748. foreach ($info_list as $v) {
  6749. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6750. $warehouse = $this->warehouse->read($v['warehouse']);
  6751. $v['warehouse'] = $warehouse['title'];
  6752. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6753. $v['stime'] = date('Y-m-d', $v['stime']);
  6754. if (isset($zh[$v['features']])) {
  6755. $zh[$v['features']]['num'] += $v['num'];
  6756. } else {
  6757. $zh[$v['features']] = $v;
  6758. }
  6759. $zh[$v['features']]['features'] = $c;
  6760. }
  6761. $title = "在途数据" . date('Y-m-d', time());
  6762. $titlename = "<table border=1>
  6763. <tr align='center'>
  6764. <td>仓库</td>
  6765. <td>SKU</td>
  6766. <td>名称</td>
  6767. <td>在途数量</td>
  6768. <td>库存数量</td>
  6769. <td>添加在途日期</td>
  6770. <td>预达日期</td>
  6771. <td>备注</td>
  6772. </tr>
  6773. </table>";
  6774. $filename = $title . ".xls";
  6775. $tail = "";
  6776. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6777. }
  6778. }
  6779. public function _fc()
  6780. {
  6781. $vip = 0;
  6782. if (isset($_SESSION['api'])) {
  6783. $user = $this->user->get_api($_SESSION['api']);
  6784. if ($user['vip'] == 1) {
  6785. $vip = 1;
  6786. }
  6787. } else {
  6788. header('Location: /');
  6789. exit;
  6790. }
  6791. $post = $this->input->post(NULL, TRUE);
  6792. if (isset($post['page'])) {
  6793. $page = $this->input->post('page', true);
  6794. $perpage = $this->input->post('perpage', true);
  6795. $category = $this->input->post('category', true);
  6796. $size = $this->input->post('size', true);
  6797. $grade = $this->input->post('grade', true);
  6798. $color = $this->input->post('color', true);
  6799. $lowe = $this->input->post('lowe', true);
  6800. $sku = $this->input->post('sku');
  6801. $title = $this->input->post('title');
  6802. $warehouse = $this->input->post('warehouse', true);
  6803. $usa = $this->input->post('usa', true);
  6804. $purchase = $this->input->post('purchase', true);
  6805. $lacetype = $this->input->post('lacetype', true);
  6806. $haircap = $this->input->post('haircap', true);
  6807. $density = $this->input->post('density', true);
  6808. $details = $this->input->post('details', true);
  6809. $state = $this->input->post('state', true);
  6810. $ktime = $this->input->post('ktime', true);
  6811. $jtime = $this->input->post('jtime', true);
  6812. $ktime = strtotime($ktime);
  6813. $jtime = strtotime($jtime);
  6814. $where = "state = '11'";
  6815. $gj = "";
  6816. $ck = "";
  6817. if ($lacetype) {
  6818. $where .= " and features like '%-$lacetype-%'";
  6819. }
  6820. if ($category) {
  6821. $where .= " and features like '%-$category-%'";
  6822. }
  6823. if ($size) {
  6824. $where .= " and features like '%-$size-%'";
  6825. }
  6826. if ($grade) {
  6827. $where .= " and features like '%-$grade-%'";
  6828. }
  6829. if ($color) {
  6830. $where .= " and features like '%-$color-%'";
  6831. }
  6832. if ($lowe) {
  6833. $where .= " and features like '%-$lowe-%'";
  6834. }
  6835. if ($haircap) {
  6836. $where .= " and features like '%-$haircap-%'";
  6837. }
  6838. if ($density) {
  6839. $where .= " and features like '%-$density-%'";
  6840. }
  6841. if ($usa) {
  6842. if (!$warehouse) {
  6843. $where .= " and (warehouse = '5' or warehouse = '8')";
  6844. }
  6845. }
  6846. if ($warehouse) {
  6847. $where .= " and warehouse = '$warehouse'";
  6848. }
  6849. if ($details) {
  6850. $where .= " and details = '$details'";
  6851. }
  6852. if ($purchase) {
  6853. $where .= " and purchase = '$purchase'";
  6854. }
  6855. if ($state) {
  6856. $where .= " and state = '$state'";
  6857. }
  6858. if ($ktime && $jtime) {
  6859. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6860. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6861. }
  6862. //数据排序
  6863. $order_str = "id desc";
  6864. if (empty($page)) {
  6865. $start = 0;
  6866. $perpage = 1;
  6867. } else {
  6868. $start = ($page - 1) * $perpage;
  6869. }
  6870. if ($sku) {
  6871. $sku = trim($sku, ' ');
  6872. $sku = trim($sku, ' ');
  6873. $where .= " and sku like '%$sku%'";
  6874. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6875. } else if ($title) {
  6876. $title = trim($title, ' ');
  6877. $title = trim($title, ' ');
  6878. $where .= " and title like '%$title%'";
  6879. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6880. } else {
  6881. //$where .= " and time > '$ktime' and time < '$jtime'";
  6882. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6883. }
  6884. //取得信息列表
  6885. $rows = array();
  6886. $list = array();
  6887. foreach ($info_list as $key => $value) {
  6888. $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'] . '"');
  6889. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6890. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6891. $warehouse = $this->warehouse->read($value['warehouse']);
  6892. $info_list[$key]['warehouse'] = $warehouse['title'];
  6893. $info_list[$key]['number'] = $g;
  6894. $info_list[$key]['features'] = $x;
  6895. $info_list[$key]['x'] = $s;
  6896. }
  6897. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6898. $pagenum = ceil($total / $perpage);
  6899. $over = $total - ($start + $perpage);
  6900. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6901. echo json_encode($rows);
  6902. exit;
  6903. }
  6904. $this->data['vip'] = $vip;
  6905. $this->_Template('whlabel_fc', $this->data);
  6906. }
  6907. public function _fcmb()
  6908. {
  6909. $where = "sku != 'Preset'";
  6910. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6911. foreach ($rows as $k => $v) {
  6912. $warehouse = $this->warehouse->read($v['warehouse']);
  6913. $rows[$k]['warehouse'] = $warehouse['title'];
  6914. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6915. $rows[$k]['t'] = '';
  6916. $rows[$k]['n'] = '';
  6917. }
  6918. $title = "封货产品数据导入模板";
  6919. $titlename = "<table border=1>
  6920. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6921. <tr align='center'>
  6922. <td>仓库</td>
  6923. <td>SKU</td>
  6924. <td>产品</td>
  6925. <td>封存产品总数量</td>
  6926. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6927. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6928. </tr>
  6929. </table>";
  6930. $filename = $title . ".xls";
  6931. $tail = "";
  6932. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6933. }
  6934. public function _fcexcel()
  6935. {
  6936. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6937. $config['upload_path'] = '.' . $dir;
  6938. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6939. $config['allowed_types'] = 'xls|xlsx|csv';
  6940. $config['max_size'] = 10240;
  6941. $this->load->library('upload', $config);
  6942. $this->upload->initialize($config);
  6943. if ($this->upload->do_upload('userfile')) {
  6944. $full_path = $dir . $this->upload->data('file_name');
  6945. $fileName = '.' . $full_path;
  6946. if (!file_exists($fileName)) {
  6947. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6948. exit;
  6949. } else {
  6950. libxml_use_internal_errors(true);
  6951. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6952. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6953. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6954. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6955. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6956. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6957. ++$column; //如果列数大于26行
  6958. $list = array();
  6959. for ($i = 2; $i <= $row; $i++) // 行数循环
  6960. {
  6961. $data = array();
  6962. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6963. {
  6964. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6965. }
  6966. $list[] = $data;
  6967. }
  6968. }
  6969. $i = 0;
  6970. $j = 0;
  6971. $ed = array();
  6972. foreach ($list as $key => $value) {
  6973. $time = time();
  6974. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6975. continue;
  6976. }
  6977. $warehouse = $this->warehouse->get_title($value['0']);
  6978. $sku = $value['1'];
  6979. $type = $value['4']; //调整方式0扣减1删除
  6980. $num = $value['5']; //调整数量
  6981. //$text = $value['4'];//扣减说明
  6982. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6983. if (!$d) //如果没有这个SKU
  6984. {
  6985. $ed[] = array($sku . '-库存中不存在此SKU');
  6986. $j++;
  6987. continue;
  6988. }
  6989. if (!isset($warehouse['id'])) {
  6990. $ed[] = array($sku . '-仓库名错误!');
  6991. $j++;
  6992. continue;
  6993. }
  6994. if ($type == 1 || $type == 2) //扣减库存
  6995. {
  6996. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6997. if (count($data) < abs($num)) {
  6998. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6999. $j++;
  7000. continue;
  7001. }
  7002. if ($type == 1) //转入库存
  7003. {
  7004. for ($i = 0; $i < abs($num); $i++) {
  7005. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7006. }
  7007. } else if ($type == 2) //删除
  7008. {
  7009. for ($i = 0; $i < abs($num); $i++) {
  7010. $this->whlabel->remove($data[$i]['id']);
  7011. }
  7012. }
  7013. } else if ($type == 0) //增加库存
  7014. {
  7015. $post['sku'] = $d['sku'];
  7016. $post['shop'] = '';
  7017. $post['warehouse'] = $warehouse['id'];
  7018. $post['purchase'] = $d['purchase'];
  7019. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7020. $post['state'] = 11;
  7021. $post['title'] = $d['title'];
  7022. $post['number'] = $d['number'];
  7023. $post['features'] = $d['features'];
  7024. $post['enter'] = $time;
  7025. $post['time'] = $time; //操作时间
  7026. for ($i = 0; $i < $num; $i++) {
  7027. $post['label'] = time() . rand(100, 999) . $i;
  7028. $this->whlabel->insert($post);
  7029. }
  7030. }
  7031. sleep(1); //防止入库时间一样,需要延迟1秒
  7032. }
  7033. if ($j > 0) {
  7034. $tt = date('Ymd', time());
  7035. $title = '库存导入错误信息-' . $tt;
  7036. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7037. $tail = "\n";
  7038. $filename = $title . ".xls";
  7039. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7040. $dir = '/data/excel/' . $time . '/';
  7041. $file_name = 'error_' . $time . rand(1000, 9999);
  7042. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7043. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7044. fwrite($myfile, $ecl);
  7045. fclose($myfile);
  7046. $error = $dir . $file_name . '.xls';
  7047. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7048. exit;
  7049. } else {
  7050. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7051. exit;
  7052. }
  7053. }
  7054. }
  7055. public function _fcjxc($arg_array)
  7056. {
  7057. if (isset($_GET['excel'])) {
  7058. $category = $this->input->get('category', true);
  7059. $size = $this->input->get('size', true);
  7060. $grade = $this->input->get('grade', true);
  7061. $color = $this->input->get('color', true);
  7062. $lowe = $this->input->get('lowe', true);
  7063. $sku = $this->input->get('sku');
  7064. $title = $this->input->get('title');
  7065. $warehouse = $arg_array[0];
  7066. $usa = $this->input->get('usa', true);
  7067. $purchase = $this->input->get('purchase', true);
  7068. $lacetype = $this->input->get('lacetype', true);
  7069. $haircap = $this->input->get('haircap', true);
  7070. $density = $this->input->get('density', true);
  7071. $title = $this->input->get('title', true);
  7072. $state = $this->input->get('state', true);
  7073. $ktime = $this->input->get('ktime', true);
  7074. $jtime = $this->input->get('jtime', true);
  7075. $where = "state=11";
  7076. $gj = "";
  7077. $ck = "";
  7078. if ($lacetype) {
  7079. $where .= " and features like '%-$lacetype-%'";
  7080. }
  7081. if ($category) {
  7082. $where .= " and features like '%-$category-%'";
  7083. }
  7084. if ($size) {
  7085. $where .= " and features like '%-$size-%'";
  7086. }
  7087. if ($grade) {
  7088. $where .= " and features like '%-$grade-%'";
  7089. }
  7090. if ($color) {
  7091. $where .= " and features like '%-$color-%'";
  7092. }
  7093. if ($lowe) {
  7094. $where .= " and features like '%-$lowe-%'";
  7095. }
  7096. if ($haircap) {
  7097. $where .= " and features like '%-$haircap-%'";
  7098. }
  7099. if ($density) {
  7100. $where .= " and features like '%-$density-%'";
  7101. }
  7102. if ($usa) {
  7103. if (!$warehouse) {
  7104. $where .= " and (warehouse = '5' or warehouse = '8')";
  7105. }
  7106. }
  7107. if ($warehouse) {
  7108. $where .= " and warehouse = '$warehouse'";
  7109. }
  7110. if ($purchase) {
  7111. $where .= " and purchase = '$purchase'";
  7112. }
  7113. if ($state) {
  7114. $where .= " and state = '$state'";
  7115. }
  7116. $order_str = "id desc";
  7117. if ($sku) {
  7118. $sku = trim($sku, ' ');
  7119. $sku = trim($sku, ' ');
  7120. $where .= " and sku like '%$sku%'";
  7121. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7122. } else if ($title) {
  7123. $title = trim($title, ' ');
  7124. $title = trim($title, ' ');
  7125. $where .= " and title like '%$title%'";
  7126. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7127. } else {
  7128. //$where .= " and time > '$ktime' and time < '$jtime'";
  7129. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7130. }
  7131. //取得信息列表
  7132. $rows = array();
  7133. $list = array();
  7134. foreach ($info_list as $key => $value) {
  7135. $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'] . '"');
  7136. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7137. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7138. $rows[$key] = $value;
  7139. $warehouse = $this->warehouse->read($value['warehouse']);
  7140. $rows[$key]['warehouse'] = $warehouse['title'];
  7141. $rows[$key]['features'] = $g;
  7142. $rows[$key]['a'] = $x;
  7143. $rows[$key]['b'] = $s;
  7144. }
  7145. $title = "总统计表";
  7146. $titlename = "<table border=1>
  7147. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7148. <tr align='center'>
  7149. <td>仓库</td>
  7150. <td>SKU</td>
  7151. <td>产品名称</td>
  7152. <td>录入总量</td>
  7153. <td>取出总量</td>
  7154. <td>剩余总量</td>
  7155. </tr>
  7156. </table>";
  7157. $filename = $title . ".xls";
  7158. $tail = "";
  7159. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7160. }
  7161. $vip = 0;
  7162. if (isset($_SESSION['api'])) {
  7163. $user = $this->user->get_api($_SESSION['api']);
  7164. if ($user['vip'] == 1) {
  7165. $vip = 1;
  7166. }
  7167. } else {
  7168. header('Location: /');
  7169. exit;
  7170. }
  7171. $post = $this->input->post(NULL, TRUE);
  7172. if (isset($post['page'])) {
  7173. $page = $this->input->post('page', true);
  7174. $perpage = $this->input->post('perpage', true);
  7175. $category = $this->input->post('category', true);
  7176. $size = $this->input->post('size', true);
  7177. $grade = $this->input->post('grade', true);
  7178. $color = $this->input->post('color', true);
  7179. $lowe = $this->input->post('lowe', true);
  7180. $sku = $this->input->post('sku');
  7181. $title = $this->input->post('title');
  7182. $warehouse = $arg_array[0];
  7183. $usa = $this->input->post('usa', true);
  7184. $purchase = $this->input->post('purchase', true);
  7185. $lacetype = $this->input->post('lacetype', true);
  7186. $haircap = $this->input->post('haircap', true);
  7187. $density = $this->input->post('density', true);
  7188. $title = $this->input->post('title', true);
  7189. $state = $this->input->post('state', true);
  7190. $ktime = $this->input->post('ktime', true);
  7191. $jtime = $this->input->post('jtime', true);
  7192. $ktime = strtotime($ktime);
  7193. $jtime = strtotime($jtime);
  7194. $where = "state=11";
  7195. $gj = "";
  7196. $ck = "";
  7197. if ($lacetype) {
  7198. $where .= " and features like '%-$lacetype-%'";
  7199. }
  7200. if ($category) {
  7201. $where .= " and features like '%-$category-%'";
  7202. }
  7203. if ($size) {
  7204. $where .= " and features like '%-$size-%'";
  7205. }
  7206. if ($grade) {
  7207. $where .= " and features like '%-$grade-%'";
  7208. }
  7209. if ($color) {
  7210. $where .= " and features like '%-$color-%'";
  7211. }
  7212. if ($lowe) {
  7213. $where .= " and features like '%-$lowe-%'";
  7214. }
  7215. if ($haircap) {
  7216. $where .= " and features like '%-$haircap-%'";
  7217. }
  7218. if ($density) {
  7219. $where .= " and features like '%-$density-%'";
  7220. }
  7221. if ($usa) {
  7222. if (!$warehouse) {
  7223. $where .= " and (warehouse = '5' or warehouse = '8')";
  7224. }
  7225. }
  7226. if ($warehouse) {
  7227. $where .= " and warehouse = '$warehouse'";
  7228. }
  7229. if ($purchase) {
  7230. $where .= " and purchase = '$purchase'";
  7231. }
  7232. if ($state) {
  7233. $where .= " and state = '$state'";
  7234. }
  7235. if ($ktime && $jtime) {
  7236. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7237. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7238. }
  7239. //数据排序
  7240. $order_str = "id desc";
  7241. $xs = 0;
  7242. $rows = array();
  7243. $list = array();
  7244. if (empty($page)) {
  7245. $start = 0;
  7246. $perpage = 1;
  7247. } else {
  7248. $start = ($page - 1) * $perpage;
  7249. }
  7250. if ($sku || $title) {
  7251. if ($title) {
  7252. $title = trim($title, ' ');
  7253. $title = trim($title, ' ');
  7254. $where .= " and title like '%$title%'";
  7255. } else {
  7256. $sku = trim($sku, ' ');
  7257. $sku = trim($sku, ' ');
  7258. $where .= " and sku like '%$sku%'";
  7259. }
  7260. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7261. foreach ($info_list as $key => $value) {
  7262. $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'] . '"');
  7263. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7264. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7265. $rows[$key] = $value;
  7266. $warehouse = $this->warehouse->read($value['warehouse']);
  7267. $rows[$key]['warehouse'] = $warehouse['title'];
  7268. $rows[$key]['features'] = $g;
  7269. $rows[$key]['a'] = $x;
  7270. $rows[$key]['b'] = $s;
  7271. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7272. $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天销量
  7273. $yj = $c / ($xl / 30);
  7274. if ($yj < 7) {
  7275. $rows[$key]['y'] = round($yj) . '天销量';
  7276. } else {
  7277. $rows[$key]['y'] = '正常';
  7278. }
  7279. }
  7280. } else {
  7281. //$where .= " and time > '$ktime' and time < '$jtime'";
  7282. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7283. foreach ($info_list as $key => $value) {
  7284. $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'] . '"');
  7285. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7286. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7287. $zs[$key] = $value;
  7288. $warehouse = $this->warehouse->read($value['warehouse']);
  7289. $zs[$key]['warehouse'] = $warehouse['title'];
  7290. $zs[$key]['features'] = $g;
  7291. $zs[$key]['a'] = $x;
  7292. $zs[$key]['b'] = $s;
  7293. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7294. $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天销量
  7295. $yj = $c / ($xl / 30);
  7296. if ($yj < 7) {
  7297. $zs[$key]['y'] = round($yj) . '天销量';
  7298. $rows[$key] = $zs[$key];
  7299. }
  7300. }
  7301. }
  7302. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7303. $pagenum = ceil($total / $perpage);
  7304. $over = $total - ($start + $perpage);
  7305. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7306. echo json_encode($rows);
  7307. exit;
  7308. }
  7309. $this->data['arg_array'] = $arg_array[0];
  7310. $this->_Template('whlabel_fcjxc', $this->data);
  7311. }
  7312. public function _0kcdel()
  7313. {
  7314. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7315. $config['upload_path'] = '.' . $dir;
  7316. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7317. $config['allowed_types'] = 'xls|xlsx|csv';
  7318. $config['max_size'] = 10240;
  7319. $this->load->library('upload', $config);
  7320. $this->upload->initialize($config);
  7321. if ($this->upload->do_upload('userfile')) {
  7322. $full_path = $dir . $this->upload->data('file_name');
  7323. $fileName = '.' . $full_path;
  7324. if (!file_exists($fileName)) {
  7325. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7326. exit;
  7327. } else {
  7328. require_once "./data/excel/PHPExcel/IOFactory.php";
  7329. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7330. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7331. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7332. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7333. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7334. ++$column; //如果列数大于26行
  7335. $list = array();
  7336. for ($i = 2; $i <= $row; $i++) // 行数循环
  7337. {
  7338. $data = array();
  7339. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7340. {
  7341. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7342. }
  7343. $list[] = $data;
  7344. }
  7345. }
  7346. $i = 0;
  7347. $j = 0;
  7348. $ed = array();
  7349. foreach ($list as $key => $value) {
  7350. $time = time();
  7351. if ($value['0'] == "" || $value['1'] == "") {
  7352. continue;
  7353. }
  7354. $warehouse = $this->warehouse->get_title($value['0']);
  7355. $sku = $value['1'];
  7356. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7357. if (!$d) //如果没有这个SKU
  7358. {
  7359. $ed[] = array($sku . '-库存中不存在此SKU');
  7360. $j++;
  7361. continue;
  7362. }
  7363. if (!isset($warehouse['id'])) {
  7364. $ed[] = array($sku . '-仓库名错误!');
  7365. $j++;
  7366. continue;
  7367. }
  7368. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7369. if ($z < 1) {
  7370. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7371. foreach ($z as $v) {
  7372. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7373. if (count($zt) > 0) {
  7374. $ed[] = array($sku . '-有在途库存无法删除!');
  7375. $j++;
  7376. continue;
  7377. }
  7378. $this->whlabel->remove($v['id']);
  7379. }
  7380. } else {
  7381. $ed[] = array($sku . '-非0库存!');
  7382. $j++;
  7383. continue;
  7384. }
  7385. }
  7386. if ($j > 0) {
  7387. $tt = date('Ymd', time());
  7388. $title = '删除0库存错误信息-' . $tt;
  7389. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7390. $tail = "\n";
  7391. $filename = $title . ".xls";
  7392. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7393. $dir = '/data/excel/' . $time . '/';
  7394. $file_name = 'error_' . $time . rand(1000, 9999);
  7395. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7396. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7397. fwrite($myfile, $ecl);
  7398. fclose($myfile);
  7399. $error = $dir . $file_name . '.xls';
  7400. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7401. exit;
  7402. } else {
  7403. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7404. exit;
  7405. }
  7406. }
  7407. }
  7408. public function _gbhtype()
  7409. {
  7410. $post = $this->input->post(NULL, TRUE);
  7411. if (isset($post['s'])) {
  7412. $n = $this->input->post('n');
  7413. $d = $this->input->post('s');
  7414. if (!$d) {
  7415. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7416. exit;
  7417. }
  7418. $d = explode(',', trim($d, ','));
  7419. $t = $this->whlabel_type->read($n);
  7420. //循环删除记录
  7421. foreach ($d as $v) {
  7422. $u = $this->whlabel->read($v);
  7423. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7424. foreach ($data as $val) {
  7425. $this->whlabel->save(array('type' => $n), $val['id']);
  7426. }
  7427. }
  7428. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7429. }
  7430. }
  7431. //出库、退库导出
  7432. public function _dccrtype()
  7433. {
  7434. $classid = $this->classid->sku();
  7435. $pm = $classid;
  7436. $typeclass = array();
  7437. $tc = $this->typeclass->find_all();
  7438. foreach ($tc as $v) {
  7439. $typeclass[$v['id']] = $v;
  7440. }
  7441. $prc = array();
  7442. $purchase = $this->purchase->find_all();
  7443. foreach ($purchase as $k => $v) {
  7444. $prc[$v['id']] = $v['title'];
  7445. }
  7446. if (isset($_GET['sid'])) {
  7447. $wh = array();
  7448. $w = $this->warehouse->find_all('1=1', 'id,title');
  7449. foreach ($w as $v) {
  7450. $wh[$v['id']] = $v['title'];
  7451. }
  7452. $type = $this->input->get('excel', true);
  7453. $category = $this->input->get('category', true);
  7454. $size = $this->input->get('size', true);
  7455. $grade = $this->input->get('grade', true);
  7456. $color = $this->input->get('color', true);
  7457. $lowe = $this->input->get('lowe', true);
  7458. $sku = $this->input->get('sku', true);
  7459. $warehouse = $this->input->get('warehouse', true);
  7460. $lacetype = $this->input->get('lacetype', true);
  7461. $lacecolor = $this->input->get('lacecolor', true);
  7462. $density = $this->input->get('density', true);
  7463. $haircap = $this->input->get('haircap', true);
  7464. $purchase = $this->input->get('purchase', true);
  7465. $title = $this->input->get('title', true);
  7466. $state = $this->input->get('state', true);
  7467. $sid = $this->input->get('sid', true);
  7468. $ktime = $this->input->get('ktime', true);
  7469. $jtime = $this->input->get('jtime', true);
  7470. $ktime = strtotime($ktime);
  7471. $jtime = strtotime($jtime);
  7472. $where = "1=1";
  7473. $gj = "";
  7474. $ck = "";
  7475. if ($category) {
  7476. $where .= " and features like '%-$category-%'";
  7477. }
  7478. if ($size) {
  7479. $where .= " and features like '%-$size-%'";
  7480. }
  7481. if ($grade) {
  7482. $where .= " and features like '%-$grade-%'";
  7483. }
  7484. if ($color) {
  7485. $where .= " and features like '%-$color-%'";
  7486. }
  7487. if ($lowe) {
  7488. $where .= " and features like '%-$lowe-%'";
  7489. }
  7490. if ($warehouse) {
  7491. $where .= " and warehouse = '$warehouse'";
  7492. }
  7493. if ($purchase) {
  7494. $where .= " and purchase = '$purchase'";
  7495. }
  7496. if ($state) {
  7497. $where .= " and state = '$state'";
  7498. }
  7499. if ($lacetype) {
  7500. $where .= " and features like '%-$lacetype-%'";
  7501. }
  7502. if ($lacecolor) {
  7503. $where .= " and features like '%-$lacecolor-%'";
  7504. }
  7505. if ($density) {
  7506. $where .= " and features like '%-$density-%'";
  7507. }
  7508. if ($haircap) {
  7509. $where .= " and features like '%-$haircap-%'";
  7510. }
  7511. if ($title) {
  7512. $title = trim($title, ' ');
  7513. $title = trim($title, ' ');
  7514. $where .= " and title like '%$title%'";
  7515. }
  7516. if ($sku) {
  7517. $sku = trim($sku, ' ');
  7518. $sku = trim($sku, ' ');
  7519. $where .= " and sku like '%$sku%'";
  7520. }
  7521. if ($ktime && $jtime) {
  7522. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7523. }
  7524. $sidwhere = '';
  7525. if ($sid) {
  7526. $sd = "";
  7527. $s = explode(',', trim($sid, ','));
  7528. foreach ($s as $value) {
  7529. $sd .= " id = " . $value . " or";
  7530. }
  7531. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7532. }
  7533. //数据排序
  7534. $order_str = "time desc";
  7535. if (empty($page)) {
  7536. $start = 0;
  7537. $perpage = 1;
  7538. } else {
  7539. $start = ($page - 1) * $perpage;
  7540. }
  7541. $wh = array();
  7542. $w = $this->warehouse->find_all('1=1', 'id,title');
  7543. foreach ($w as $v) {
  7544. $wh[$v['id']] = $v['title'];
  7545. }
  7546. $wt = array();
  7547. $whlabel_type = $this->whlabel_type->find_all();
  7548. foreach ($whlabel_type as $v) {
  7549. $wt[$v['id']] = $v['title'];
  7550. }
  7551. $classid = $this->classid->sku();
  7552. $list = array();
  7553. $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');
  7554. foreach ($rows_r as $key => $value) {
  7555. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7556. $pm = $classid;
  7557. $jm = $classid;
  7558. $rows_r[$key]['enter'] = '入库';
  7559. $rows_r[$key]['time'] = $value['enter'];
  7560. if ($value['rktype'] == 1) {
  7561. $rows_r[$key]['rktype'] = '采购入库';
  7562. } else if ($value['rktype'] == 2) {
  7563. $rows_r[$key]['rktype'] = '盘盈调整';
  7564. } else if ($value['rktype'] == 3) {
  7565. $rows_r[$key]['rktype'] = '其他调整入库';
  7566. } else if ($value['rktype'] == 4) {
  7567. $rows_r[$key]['rktype'] = '其他调整入库';
  7568. } else if ($value['rktype'] == 5) {
  7569. $rows_r[$key]['rktype'] = '退库入库';
  7570. } else if ($value['rktype'] == 6) {
  7571. $rows_r[$key]['rktype'] = '退货可用入库';
  7572. } else if ($value['rktype'] == 7) {
  7573. $rows_r[$key]['rktype'] = '形态转换入库';
  7574. } else {
  7575. $rows_r[$key]['rktype'] = '';
  7576. }
  7577. $features = explode('-', trim($value['features'], '-'));
  7578. foreach ($features as $v) {
  7579. if (isset($typeclass[$v])) {
  7580. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7581. $pm[$typeclass[$v]['classid']] = $zh[0];
  7582. }
  7583. if (isset($typeclass[$v])) {
  7584. if (isset($jm[$typeclass[$v]['classid']])) {
  7585. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7586. }
  7587. }
  7588. }
  7589. $zh = implode(" ", $pm);
  7590. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7591. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7592. $rows_r[$key]['zh'] = $zh;
  7593. $jm = array_filter($jm);
  7594. $rows_r[$key]['features'] = implode("-", $jm);
  7595. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7596. }
  7597. $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');
  7598. foreach ($rows_c as $key => $value) {
  7599. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7600. $pm = $classid;
  7601. $jm = $classid;
  7602. $rows_c[$key]['time'] = $value['outk'];
  7603. $rows_c[$key]['outk'] = '出库';
  7604. if ($value['cktype'] == 1) {
  7605. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7606. } else if ($value['cktype'] == 2) {
  7607. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7608. } else if ($value['cktype'] == 3) {
  7609. $rows_c[$key]['cktype'] = '盘亏调整';
  7610. } else if ($value['cktype'] == 4) {
  7611. $rows_c[$key]['cktype'] = '其他调整出库';
  7612. } else if ($value['cktype'] == 5) {
  7613. $rows_c[$key]['cktype'] = '形态转换出库';
  7614. } else {
  7615. $rows_c[$key]['cktype'] = '';
  7616. }
  7617. unset($rows_c[$key]['state']);
  7618. $features = explode('-', trim($value['features'], '-'));
  7619. foreach ($features as $v) {
  7620. if (isset($typeclass[$v])) {
  7621. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7622. $pm[$typeclass[$v]['classid']] = $zh[0];
  7623. }
  7624. if (isset($typeclass[$v])) {
  7625. if (isset($jm[$typeclass[$v]['classid']])) {
  7626. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7627. }
  7628. }
  7629. }
  7630. $zh = implode(" ", $pm);
  7631. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7632. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7633. $rows_c[$key]['zh'] = $zh;
  7634. $jm = array_filter($jm);
  7635. $rows_c[$key]['features'] = implode("-", $jm);
  7636. $rows_c[$key]['number'] = 1;
  7637. }
  7638. $merged = $rows_r;
  7639. foreach ($rows_c as $key => $value) {
  7640. if (isset($merged[$key])) {
  7641. $merged[] = $value;
  7642. } else {
  7643. $merged[$key] = $value;
  7644. }
  7645. }
  7646. usort($merged, function ($a, $b) {
  7647. return $a['time'] - $b['time'];
  7648. });
  7649. foreach ($merged as $key => $value) {
  7650. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7651. }
  7652. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7653. $titlename = "<table border=1>
  7654. <tr align='center'>
  7655. <td>仓库</td>
  7656. <td>SKU</td>
  7657. <td>商品名称</td>
  7658. <td>仓库品名</td>
  7659. <td>料号</td>
  7660. <td>时间</td>
  7661. <td>操作</td>
  7662. <td>类型</td>
  7663. <td>数量</td>
  7664. <td>备注</td>
  7665. </tr>
  7666. </table>";
  7667. $filename = $title . ".xlsx";
  7668. $tail = "";
  7669. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  7670. }
  7671. }
  7672. /*************************************处理exceljs导出****************************************************/
  7673. public function _excelrjs(){
  7674. if (isset($_GET['excel'])) {
  7675. $category = $this->input->get('category', true);
  7676. $size = $this->input->get('size', true);
  7677. $grade = $this->input->get('grade', true);
  7678. $color = $this->input->get('color', true);
  7679. $lowe = $this->input->get('lowe', true);
  7680. $sku = $this->input->get('sku', true);
  7681. $warehouse = $this->input->get('warehouse', true);
  7682. $purchase = $this->input->get('purchase', true);
  7683. $ktime = $this->input->get('ktime', true);
  7684. $jtime = $this->input->get('jtime', true);
  7685. $ktime = strtotime($ktime);
  7686. $jtime = strtotime($jtime);
  7687. $where = "1=1";
  7688. $gj = "";
  7689. $ck = "";
  7690. if ($category) {
  7691. $where .= " and features like '%-$category-%'";
  7692. }
  7693. if ($size) {
  7694. $where .= " and features like '%-$size-%'";
  7695. }
  7696. if ($grade) {
  7697. $where .= " and features like '%-$grade-%'";
  7698. }
  7699. if ($color) {
  7700. $where .= " and features like '%-$color-%'";
  7701. }
  7702. if ($lowe) {
  7703. $where .= " and features like '%-$lowe-%'";
  7704. }
  7705. if ($warehouse) {
  7706. $where .= " and warehouse = '$warehouse'";
  7707. }
  7708. if ($purchase) {
  7709. $where .= " and purchase = '$purchase'";
  7710. }
  7711. if ($sku) {
  7712. $where .= " and sku = '$sku'";
  7713. }
  7714. if ($ktime && $jtime) {
  7715. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7716. }
  7717. //数据排序
  7718. $order_str = "id desc";
  7719. if (empty($page)) {
  7720. $start = 0;
  7721. $perpage = 1;
  7722. } else {
  7723. $start = ($page - 1) * $perpage;
  7724. }
  7725. $list = array();
  7726. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7727. foreach ($rows as $value) {
  7728. $ck = $this->warehouse->read($value['warehouse']);
  7729. $warehouse = $ck['title'];
  7730. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7731. $retreatwarehouse = $tkck['title'];
  7732. $gy = $this->purchase->read($value['purchase']);
  7733. $purchase = $gy['title'];
  7734. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7735. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7736. }
  7737. if(empty($list)){
  7738. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7739. }else{
  7740. $final_list = [];
  7741. foreach($list as $v){
  7742. $final_list[] = array_values($v);
  7743. }
  7744. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7745. array_unshift($final_list,[
  7746. "仓库","SKU","商品名称","时间","数量"
  7747. ]);
  7748. array_unshift($final_list,[
  7749. $title,"","","",""
  7750. ]);
  7751. $merges = [
  7752. [
  7753. "s"=>["r"=>0,"c"=>0],
  7754. "e"=>["r"=>0,"c"=>4]
  7755. ]
  7756. ];
  7757. $cols = [
  7758. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7759. ];
  7760. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7761. }
  7762. }
  7763. }
  7764. //出库、退库导出
  7765. public function _excelctjs()
  7766. {
  7767. $classid = $this->classid->sku();
  7768. $pm = $classid;
  7769. $typeclass = array();
  7770. $tc = $this->typeclass->find_all();
  7771. foreach ($tc as $v) {
  7772. $typeclass[$v['id']] = $v;
  7773. }
  7774. $prc = array();
  7775. $purchase = $this->purchase->find_all();
  7776. foreach ($purchase as $k => $v) {
  7777. $prc[$v['id']] = $v['title'];
  7778. }
  7779. if (isset($_GET['excel'])) {
  7780. $wh = array();
  7781. $w = $this->warehouse->find_all('1=1', 'id,title');
  7782. foreach ($w as $v) {
  7783. $wh[$v['id']] = $v['title'];
  7784. }
  7785. $type = $this->input->get('excel', true);
  7786. $category = $this->input->get('category', true);
  7787. $size = $this->input->get('size', true);
  7788. $grade = $this->input->get('grade', true);
  7789. $color = $this->input->get('color', true);
  7790. $lowe = $this->input->get('lowe', true);
  7791. $sku = $this->input->get('sku', true);
  7792. $title = $this->input->get('title', true);
  7793. $warehouse = $this->input->get('warehouse', true);
  7794. $purchase = $this->input->get('purchase', true);
  7795. $lacetype = $this->input->get('lacetype', true);
  7796. $haircap = $this->input->get('haircap', true);
  7797. $lacecolor = $this->input->get('lacecolor', true);
  7798. $density = $this->input->get('density', true);
  7799. $details = $this->input->get('details', true);
  7800. $state = $this->input->get('state', true);
  7801. $shop = $this->input->get('shop', true);
  7802. $hairnumber = $this->input->get('hairnumber', true);
  7803. $type_leixi = $this->input->get('type', true);
  7804. $cpbz = $this->input->get('cpbz', true);
  7805. $sm = $this->input->get('sm', true);
  7806. $sid = $this->input->get('sid', true);
  7807. $ktime = $this->input->get('ktime', true);
  7808. $jtime = $this->input->get('jtime', true);
  7809. $ktime = strtotime($ktime);
  7810. $jtime = strtotime($jtime);
  7811. //$where = " 1=1 ";
  7812. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7813. $where = " sku != '' ";
  7814. $gj = "";
  7815. $ck = "";
  7816. if ($category) {
  7817. $where .= " and features like '%-$category-%'";
  7818. }
  7819. if ($size) {
  7820. $where .= " and features like '%-$size-%'";
  7821. }
  7822. if ($grade) {
  7823. $where .= " and features like '%-$grade-%'";
  7824. }
  7825. if ($color) {
  7826. $where .= " and features like '%-$color-%'";
  7827. }
  7828. if ($lowe) {
  7829. $where .= " and features like '%-$lowe-%'";
  7830. }
  7831. if ($warehouse) {
  7832. $where .= " and warehouse = '$warehouse'";
  7833. }
  7834. if ($purchase) {
  7835. $where .= " and purchase = '$purchase'";
  7836. }
  7837. if ($state) {
  7838. $where .= " and state = '$state'";
  7839. }
  7840. if ($lacetype) {
  7841. $where .= " and features like '%-$lacetype-%'";
  7842. }
  7843. if ($lacecolor) {
  7844. $where .= " and features like '%-$lacecolor-%'";
  7845. }
  7846. if ($density) {
  7847. $where .= " and features like '%-$density-%'";
  7848. }
  7849. if ($haircap) {
  7850. $where .= " and features like '%-$haircap-%'";
  7851. }
  7852. if ($details) {
  7853. $where .= " and details = '$details'";
  7854. }
  7855. if ($shop) {
  7856. $where .= " and shop like '%$shop%'";
  7857. }
  7858. if ($title) {
  7859. $title = trim($title, ' ');
  7860. $title = trim($title, ' ');
  7861. $where .= " and title like '%$title%'";
  7862. }
  7863. if (!empty($hairnumber)) {
  7864. $where .= " and features like '%-128-%' ";
  7865. if ($hairnumber < 0) {
  7866. $class_list = $this->typeclass->find_all('classid = 43');
  7867. foreach ($class_list as $v) {
  7868. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7869. }
  7870. } else {
  7871. $where .= " and features like '%-$hairnumber-%'";
  7872. }
  7873. }
  7874. if ($type_leixi) {
  7875. $where .= " and type = '$type_leixi'";
  7876. }
  7877. if ($cpbz) {
  7878. $where .= " and cpbz like '%$cpbz%' ";
  7879. }
  7880. if ($sm) {
  7881. $where .= " and sm like '%$sm%' ";
  7882. }
  7883. if ($sku) {
  7884. $sku = trim($sku, ' ');
  7885. $sku = trim($sku, ' ');
  7886. $where .= " and sku like '%$sku%'";
  7887. }
  7888. if ($ktime && $jtime) {
  7889. if ($type == 1) {
  7890. $tl = '出库';
  7891. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7892. } else if ($type == 2) {
  7893. $tl = '退库';
  7894. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7895. } else if ($type == 3) {
  7896. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7897. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7898. } else if ($type == 4) {
  7899. $tl = '出库+零售';
  7900. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7901. } else if ($type == 5) {
  7902. $tl = '零售';
  7903. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7904. }
  7905. }
  7906. $sidwhere = '';
  7907. if ($sid) {
  7908. $sd = "";
  7909. $s = explode(',', trim($sid, ','));
  7910. foreach ($s as $value) {
  7911. $sd .= " id = " . $value . " or";
  7912. }
  7913. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7914. }
  7915. //数据排序
  7916. $order_str = "time desc";
  7917. if (empty($page)) {
  7918. $start = 0;
  7919. $perpage = 1;
  7920. } else {
  7921. $start = ($page - 1) * $perpage;
  7922. }
  7923. //取得信息列表
  7924. if ($type != 3 && $type != 5) {
  7925. if ($type == 1 || $type == 4) {
  7926. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7927. foreach ($info_list as $key => $value) {
  7928. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7929. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7930. $warehouse = $this->warehouse->read($value['warehouse']);
  7931. $info_list[$key]['warehouse'] = $warehouse['title'];
  7932. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7933. $features = explode('-', trim($features, '-'));
  7934. $pm = $classid;
  7935. foreach ($features as $k => $v) {
  7936. if ($v != 0) {
  7937. if (!isset($typeclass[$v])) {
  7938. continue;
  7939. }
  7940. if (isset($pm[$typeclass[$v]['classid']])) {
  7941. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7942. $tz = explode('|', $typeclass[$v]['zh']);
  7943. $pm[$typeclass[$v]['classid']] = $tz[0];
  7944. } else {
  7945. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7946. }
  7947. }
  7948. }
  7949. }
  7950. $zh = implode(" ", $pm);
  7951. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7952. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7953. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7954. $info_list[$key]['features'] = $zh;
  7955. }
  7956. $final_list = [];
  7957. foreach($info_list as $k=>$v){
  7958. $number = "";
  7959. if(!empty($v['orderinfo'])){
  7960. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7961. if(!empty($tmp_info['number'])){
  7962. $number = $tmp_info['number'];
  7963. }
  7964. }
  7965. $final_list[] = [
  7966. 'warehouse'=>$v['warehouse'],
  7967. 'purchase'=>$v['purchase'],
  7968. 'sku'=>$v['sku'],
  7969. 'title'=>$v['title'],
  7970. 'features'=>$v['features'],
  7971. 'label'=>$v['label'],
  7972. 'orderinfo'=>$v['orderinfo'],
  7973. 'number'=>$number,
  7974. 'waybill'=>$v['waybill'],
  7975. 'outk'=>$v['outk'],
  7976. ];
  7977. }
  7978. } else {
  7979. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7980. foreach ($info_list as $key => $value) {
  7981. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7982. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7983. $warehouse = $this->warehouse->read($value['warehouse']);
  7984. $info_list[$key]['warehouse'] = $warehouse['title'];
  7985. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7986. $features = explode('-', trim($features, '-'));
  7987. $pm = $classid;
  7988. foreach ($features as $k => $v) {
  7989. if ($v != 0) {
  7990. if (!isset($typeclass[$v])) {
  7991. continue;
  7992. }
  7993. if (isset($pm[$typeclass[$v]['classid']])) {
  7994. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7995. $tz = explode('|', $typeclass[$v]['zh']);
  7996. $pm[$typeclass[$v]['classid']] = $tz[0];
  7997. } else {
  7998. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7999. }
  8000. }
  8001. }
  8002. }
  8003. $zh = implode(" ", $pm);
  8004. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8005. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8006. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8007. $info_list[$key]['features'] = $zh;
  8008. }
  8009. $final_list = [];
  8010. foreach($info_list as $k=>$v){
  8011. $number = "";
  8012. if(!empty($v['orderinfo'])){
  8013. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8014. if(!empty($tmp_info['number'])){
  8015. $number = $tmp_info['number'];
  8016. }
  8017. }
  8018. $final_list[] = [
  8019. 'warehouse'=>$v['warehouse'],
  8020. 'purchase'=>$v['purchase'],
  8021. 'sku'=>$v['sku'],
  8022. 'title'=>$v['title'],
  8023. 'features'=>$v['features'],
  8024. 'label'=>$v['label'],
  8025. 'orderinfo'=>$v['orderinfo'],
  8026. 'number'=>$number,
  8027. 'waybill'=>$v['waybill'],
  8028. 'retreat'=>$v['retreat'],
  8029. ];
  8030. }
  8031. }
  8032. if(empty($final_list)){
  8033. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8034. }else{
  8035. $end_list = [];
  8036. foreach($final_list as $v){
  8037. $end_list[] = array_values($v);
  8038. }
  8039. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8040. array_unshift($end_list,[
  8041. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8042. ]);
  8043. array_unshift($end_list,[
  8044. $title,"","","","","","","","",""
  8045. ]);
  8046. $merges = [
  8047. [
  8048. "s"=>["r"=>0,"c"=>0],
  8049. "e"=>["r"=>0,"c"=>9]
  8050. ]
  8051. ];
  8052. $cols = [
  8053. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8054. ];
  8055. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8056. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8057. ] )));
  8058. }
  8059. } else if ($type == 5) {
  8060. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8061. foreach ($info_list as $key => $value) {
  8062. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8063. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8064. $warehouse = $this->warehouse->read($value['warehouse']);
  8065. $info_list[$key]['warehouse'] = $warehouse['title'];
  8066. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8067. $features = explode('-', trim($features, '-'));
  8068. $pm = $classid;
  8069. foreach ($features as $k => $v) {
  8070. if ($v != 0) {
  8071. if (!isset($typeclass[$v])) {
  8072. continue;
  8073. }
  8074. if (isset($pm[$typeclass[$v]['classid']])) {
  8075. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8076. $tz = explode('|', $typeclass[$v]['zh']);
  8077. $pm[$typeclass[$v]['classid']] = $tz[0];
  8078. } else {
  8079. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8080. }
  8081. }
  8082. }
  8083. }
  8084. $zh = implode(" ", $pm);
  8085. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8086. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8087. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8088. $info_list[$key]['features'] = $zh;
  8089. }
  8090. if(empty($info_list)){
  8091. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8092. }else{
  8093. $final_list = [];
  8094. foreach($info_list as $v){
  8095. $final_list[] = array_values($v);
  8096. }
  8097. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8098. array_unshift($final_list,[
  8099. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8100. ]);
  8101. array_unshift($final_list,[
  8102. $title,"","","","","","",
  8103. ]);
  8104. $merges = [
  8105. [
  8106. "s"=>["r"=>0,"c"=>0],
  8107. "e"=>["r"=>0,"c"=>6]
  8108. ]
  8109. ];
  8110. $cols = [
  8111. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8112. ];
  8113. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8114. }
  8115. } else {
  8116. $wh = array();
  8117. $w = $this->warehouse->find_all('1=1', 'id,title');
  8118. foreach ($w as $v) {
  8119. $wh[$v['id']] = $v['title'];
  8120. }
  8121. $wt = array();
  8122. $whlabel_type = $this->whlabel_type->find_all();
  8123. foreach ($whlabel_type as $v) {
  8124. $wt[$v['id']] = $v['title'];
  8125. }
  8126. $classid = $this->classid->sku();
  8127. $list = array();
  8128. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8129. foreach ($rows as $key => $value) {
  8130. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8131. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8132. $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');
  8133. $details = array();
  8134. $cpid = array();
  8135. $cpbz = array();
  8136. $c = 0;
  8137. $g = 0;
  8138. $x = 0;
  8139. $t = 0;
  8140. $s = 0;
  8141. $q = 0;
  8142. foreach ($sd as $k => $v) {
  8143. if ($v['state'] == 0) {
  8144. $c++;
  8145. }
  8146. if ($v['state'] != 9) {
  8147. $g++;
  8148. }
  8149. if ($v['outk'] > 1) {
  8150. $x++;
  8151. }
  8152. if ($v['retreat'] > 0) {
  8153. $t++;
  8154. }
  8155. if ($v['state'] == 8) {
  8156. $s++;
  8157. }
  8158. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8159. $q++;
  8160. }
  8161. $details[$v['details']] = $v['details'];
  8162. if ($v['cpid'] != 0) {
  8163. $cpid[$v['cpid']] = $v['cpid'];
  8164. }
  8165. if ($v['cpbz'] != '') {
  8166. $cpbz[$v['cpbz']] = $v['cpbz'];
  8167. }
  8168. }
  8169. if (isset($wt[$value['type']])) {
  8170. $rows[$key]['type'] = $wt[$value['type']];
  8171. } else {
  8172. $rows[$key]['type'] = '未设置';
  8173. }
  8174. $rows[$key]['details'] = implode("、", $details);
  8175. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8176. $ftime = time() - 15 * 24 * 3600;
  8177. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8178. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8179. $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);
  8180. $rows[$key]['c'] = $c;
  8181. $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);
  8182. $rows[$key]['t'] = $t;
  8183. $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'] . '"');
  8184. $rows[$key]['z'] = $z;
  8185. // $jm = $classid;
  8186. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8187. $features = explode('-', trim($features, '-'));
  8188. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8189. }
  8190. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8191. $final_list =[];
  8192. foreach($tmp_list as $k=>$v){
  8193. $final_list[] = [
  8194. "warehouse"=>$v['warehouse'],
  8195. "purchase"=>$v['purchase'],
  8196. "details"=>$v['details'],
  8197. "cpid"=>$v['cpid'],
  8198. "sku"=>$v['sku'],
  8199. "title"=>$v['title'],
  8200. "features"=>$v['pm'],
  8201. "cpbz"=>$v['cpbz'],
  8202. "sm"=>$v['sm'],
  8203. "type"=>$v['type'],
  8204. "g"=>$v["g"],
  8205. "c"=>$v["c"],
  8206. "x"=>$v["x"],
  8207. "t"=>$v["t"],
  8208. "z"=>$v["z"],
  8209. "jm"=>$v["jm"],
  8210. "weight"=>$v["weight"],
  8211. "asd"=>$v["asd"],
  8212. ];
  8213. }
  8214. if(empty($final_list)){
  8215. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8216. }else{
  8217. $end_list = [];
  8218. foreach($final_list as $v){
  8219. $end_list[] = array_values($v);
  8220. }
  8221. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8222. array_unshift($end_list,[
  8223. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8224. ]);
  8225. array_unshift($end_list,[
  8226. $title,"","","","","","","","","","","","","","","","","",""
  8227. ]);
  8228. $merges = [
  8229. [
  8230. "s"=>["r"=>0,"c"=>0],
  8231. "e"=>["r"=>0,"c"=>6]
  8232. ]
  8233. ];
  8234. $cols = [
  8235. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8236. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8237. ];
  8238. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8239. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8240. ])));
  8241. }
  8242. }
  8243. }
  8244. }
  8245. public function _exceljxcjs(){
  8246. $classid = $this->classid->sku();
  8247. $pm = $classid;
  8248. $typeclass = array();
  8249. $tc = $this->typeclass->find_all();
  8250. foreach ($tc as $v) {
  8251. $typeclass[$v['id']] = $v;
  8252. }
  8253. $prc = array();
  8254. $purchase = $this->purchase->find_all();
  8255. foreach ($purchase as $k => $v) {
  8256. $prc[$v['id']] = $v['title'];
  8257. }
  8258. if(!isset($_GET['excel'])){
  8259. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8260. }
  8261. $where = "sku != 'Preset'";
  8262. //数据排序
  8263. $order_str = "id desc";
  8264. if (empty($page)) {
  8265. $start = 0;
  8266. $perpage = 1;
  8267. } else {
  8268. $start = ($page - 1) * $perpage;
  8269. }
  8270. $category = $this->input->get('category', true);
  8271. $warehouse = $this->input->get('warehouse', true);
  8272. $excelid = $this->input->get('sid', true);
  8273. if ($category) {
  8274. $where .= " and features like '%-$category-%'";
  8275. }
  8276. if ($warehouse) {
  8277. $where .= " and warehouse = '$warehouse'";
  8278. }
  8279. $xzid = '';
  8280. if ($excelid) {
  8281. $excelid = explode(',', trim($excelid, ','));
  8282. foreach ($excelid as $key => $value) {
  8283. $xzid .= " id = " . $value . " or";
  8284. }
  8285. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8286. }
  8287. $wt = array();
  8288. $whlabel_type = $this->whlabel_type->find_all();
  8289. foreach ($whlabel_type as $v) {
  8290. $wt[$v['id']] = $v['title'];
  8291. }
  8292. $wh = array();
  8293. $w = $this->warehouse->find_all('1=1', 'id,title');
  8294. foreach ($w as $v) {
  8295. $wh[$v['id']] = $v['title'];
  8296. }
  8297. $list = array();
  8298. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8299. foreach ($rows as $key => $value) {
  8300. if (isset($wt[$value['type']])) {
  8301. $rows[$key]['type'] = $wt[$value['type']];
  8302. } else {
  8303. $rows[$key]['type'] = '未设置';
  8304. }
  8305. $bm = '03';
  8306. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8307. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8308. $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');
  8309. $details = array();
  8310. $cpid = array();
  8311. $cpbz = array();
  8312. $c = 0;
  8313. $g = 0;
  8314. $x = 0;
  8315. $t = 0;
  8316. $s = 0;
  8317. $q = 0;
  8318. foreach ($sd as $k => $v) {
  8319. if ($v['state'] == 0) {
  8320. $c++;
  8321. if ($v['cpid'] != 0) {
  8322. $cpid[$v['cpid']] = $v['cpid'];
  8323. }
  8324. if ($v['cpbz'] != '') {
  8325. $cpbz[$v['cpbz']] = $v['cpbz'];
  8326. }
  8327. }
  8328. if ($v['state'] != 9) {
  8329. $g++;
  8330. }
  8331. if ($v['state'] == 1) {
  8332. $x++;
  8333. }
  8334. if ($v['state'] == 2) {
  8335. $t++;
  8336. }
  8337. if ($v['state'] == 8) {
  8338. $s++;
  8339. }
  8340. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8341. $q++;
  8342. }
  8343. $details[$v['details']] = $v['details'];
  8344. }
  8345. $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'] . '"');
  8346. $rows[$key]['details'] = implode("、", $details);
  8347. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8348. $number = $value['number'];
  8349. $ftime = time() - 15 * 24 * 3600;
  8350. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8351. $rows[$key]['number'] = $g;
  8352. $rows[$key]['c'] = $c;
  8353. $rows[$key]['x'] = $x;
  8354. $rows[$key]['t'] = $t;
  8355. $rows[$key]['s'] = $s;
  8356. $rows[$key]['q'] = $q;
  8357. $rows[$key]['z'] = $z;
  8358. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8359. $features = explode('-', trim($features, '-'));
  8360. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8361. }
  8362. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8363. $final_list = [];
  8364. foreach ($list as $k => $v) {
  8365. if (empty($v['sku'])) {
  8366. continue;
  8367. }
  8368. $final_list[] = [
  8369. $v["warehouse"],
  8370. $v["purchase"],
  8371. $v["details"],
  8372. $v["cpid"],
  8373. $v["dbcontent"],
  8374. $v["sku"],
  8375. $v["bm"],
  8376. $v["jm"],
  8377. $v["title"],
  8378. $v["pm"],
  8379. $v["cpbz"],
  8380. $v["sm"],
  8381. $v["type"],
  8382. $v["number"],
  8383. $v["c"],
  8384. $v["x"],
  8385. $v["t"],
  8386. $v["s"],
  8387. $v["q"],
  8388. $v["z"],
  8389. $v['weight'],
  8390. ];
  8391. }
  8392. if(empty($final_list)){
  8393. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8394. }
  8395. $title = "总进销存统计表";
  8396. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8397. $merges = [
  8398. [
  8399. "s"=>["r"=>0,"c"=>0],
  8400. "e"=>["r"=>0,"c"=>21]
  8401. ]
  8402. ];
  8403. $cols = [
  8404. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8405. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8406. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8407. ];
  8408. array_unshift($final_list, $first_row);
  8409. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8410. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8411. }
  8412. public function _summaryjs($arg_array)
  8413. {
  8414. $prc = array();
  8415. $purchase = $this->purchase->find_all();
  8416. foreach ($purchase as $k => $v) {
  8417. $prc[$v['id']] = $v['title'];
  8418. }
  8419. if (isset($_GET['excel'])) {
  8420. $ktime = $this->input->get('ktime', true);
  8421. $jtime = $this->input->get('jtime', true);
  8422. $ktime = strtotime($ktime);
  8423. $jtime = strtotime($jtime);
  8424. $where = "1=1";
  8425. if ($ktime && $jtime) {
  8426. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8427. }
  8428. //数据排序
  8429. $order_str = "time desc";
  8430. if (empty($page)) {
  8431. $start = 0;
  8432. $perpage = 1;
  8433. } else {
  8434. $start = ($page - 1) * $perpage;
  8435. }
  8436. //取得信息列表
  8437. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8438. foreach ($info_list as $key => $value) {
  8439. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8440. $warehouse = $this->warehouse->read($value['warehouse']);
  8441. $info_list[$key]['warehouse'] = $warehouse['title'];
  8442. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8443. $details = array();
  8444. $cpid = array();
  8445. foreach ($x as $k => $v) {
  8446. if ($v['details'] != '') {
  8447. $details[$v['details']] = $v['details'];
  8448. }
  8449. if ($v['cpid'] != 0) {
  8450. $cpid[$v['cpid']] = $v['cpid'];
  8451. }
  8452. }
  8453. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8454. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8455. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8456. $info_list[$key]['s'] = $s;
  8457. $info_list[$key]['x'] = count($x);
  8458. }
  8459. if(empty($info_list)){
  8460. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8461. }
  8462. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8463. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8464. $merges = [
  8465. [
  8466. "s"=>["r"=>0,"c"=>0],
  8467. "e"=>["r"=>0,"c"=>7]
  8468. ]
  8469. ];
  8470. $cols = [
  8471. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8472. ];
  8473. $final_list = [];
  8474. foreach($info_list as $k => $v){
  8475. $final_list[] = array_values($v);
  8476. }
  8477. array_unshift($final_list, $first_row);
  8478. array_unshift($final_list,[
  8479. $title,"","","","","","","","",
  8480. ]);
  8481. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8482. $titlename = "<table border=1>
  8483. <tr align='center'>
  8484. <td>仓库</td>
  8485. <td>供应商</td>
  8486. <td>出库位置</td>
  8487. <td>出库编码</td>
  8488. <td>SKU</td>
  8489. <td>产品名</td>
  8490. <td>总剩余库存</td>
  8491. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8492. </tr>
  8493. </table>";
  8494. $filename = $title . ".xls";
  8495. $tail = "";
  8496. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8497. }
  8498. }
  8499. public function _uckjs()
  8500. {
  8501. if (isset($_GET['excel'])) {
  8502. $tc = array();
  8503. $typeclass = $this->typeclass->find_all();
  8504. foreach ($typeclass as $v) {
  8505. $tc[$v['id']] = $v['zh'];
  8506. }
  8507. $first_row = [
  8508. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8509. ];
  8510. $t = array();
  8511. $rq = '';
  8512. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8513. $ts = $ts / (24 * 3600);
  8514. for ($i = 0; $i < $ts; $i++) {
  8515. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8516. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8517. }
  8518. $day_len = count($t);
  8519. $first_row[] = "本月出库";
  8520. $merges = [
  8521. ];
  8522. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8523. $excel_key = 1;
  8524. $final_list = [];
  8525. foreach ($info_list as $k => $v) {
  8526. $features = explode('-', trim($v['features'], '-'));
  8527. if (!isset($features[3]) || !isset($features[4])) {
  8528. continue;
  8529. }
  8530. $tmp = [];
  8531. $tmp[0] = $tc[$features[0]]; //类型
  8532. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8533. $tmp[2] = $tc[$features[4]]; //曲度
  8534. $tmp[3] = '';
  8535. if (isset($data[$k][1])) {
  8536. $tmp[3] .=$tmp[1];
  8537. }
  8538. if (isset($data[$k][2])) {
  8539. $tmp[3] .= $tmp[2];
  8540. }
  8541. if (isset($features[5])) {
  8542. $tmp[3] .= $tc[$features[5]];
  8543. }
  8544. if (isset($features[2])) {
  8545. $tmp[3] .= $tc[$features[2]];
  8546. }
  8547. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8548. $tmp[4] = $v['sku'];
  8549. $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())) . '))'); //月初库存
  8550. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8551. $tmp[7] ="";
  8552. $tmp[8] ="";
  8553. $byck = 0;
  8554. foreach ($t as $vv) {
  8555. $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));
  8556. $tmp[] = ($sl > 0) ? $sl : '';
  8557. $byck += $sl;
  8558. }
  8559. $tmp[] = ($byck > 0) ? $byck : '';
  8560. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8561. // $ztrq = '';
  8562. // $ztsl = '';
  8563. // if (count($zt) > 0) {
  8564. // foreach ($zt as $vv) {
  8565. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8566. // $ztsl .= $vv['num'] . '<br>';
  8567. // }
  8568. // }
  8569. if(empty($zt)){
  8570. $final_list[] = $tmp;
  8571. $excel_key = $excel_key + 1;
  8572. }else{
  8573. $len = count($zt);
  8574. if($len == 1){
  8575. $tmp[7] = $zt[0]['num'] ;
  8576. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8577. $final_list[] = $tmp;
  8578. $excel_key = $excel_key + 1;
  8579. }else{
  8580. foreach($zt as $vv){
  8581. $tmp[7] = "";
  8582. $tmp[8] = "";
  8583. $tmp[7] = $vv['num'];
  8584. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8585. $final_list[] = $tmp;
  8586. }
  8587. $merges[] = [
  8588. "s"=>["r"=>$excel_key,"c"=>0],
  8589. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8590. ];
  8591. $merges[] = [
  8592. "s"=>["r"=>$excel_key,"c"=>1],
  8593. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8594. ];
  8595. $merges[] = [
  8596. "s"=>["r"=>$excel_key,"c"=>2],
  8597. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8598. ];
  8599. $merges[] = [
  8600. "s"=>["r"=>$excel_key,"c"=>3],
  8601. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8602. ];
  8603. $merges[] = [
  8604. "s"=>["r"=>$excel_key,"c"=>4],
  8605. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8606. ];
  8607. $merges[] = [
  8608. "s"=>["r"=>$excel_key,"c"=>5],
  8609. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8610. ];
  8611. $merges[] = [
  8612. "s"=>["r"=>$excel_key,"c"=>6],
  8613. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8614. ];
  8615. for($i=1;$i<=$day_len;$i++){
  8616. $merges[] = [
  8617. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8618. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8619. ];
  8620. }
  8621. $merges[] = [
  8622. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8623. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8624. ];
  8625. $excel_key = $excel_key + $len;
  8626. }
  8627. }
  8628. }
  8629. $title = "详情 " . date("Y-m-d", time());
  8630. if(empty($final_list)){
  8631. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8632. }
  8633. $cols = [
  8634. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8635. ];
  8636. array_unshift($final_list, $first_row);
  8637. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8638. }
  8639. }
  8640. public function _whlabelexcelzhjs(){
  8641. if(empty($_GET['excel'])){
  8642. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8643. }
  8644. $where = "sku != 'Preset' and sku != '' ";
  8645. //数据排序
  8646. $order_str = "id desc";
  8647. if (empty($page)) {
  8648. $start = 0;
  8649. $perpage = 1;
  8650. } else {
  8651. $start = ($page - 1) * $perpage;
  8652. }
  8653. $category = $this->input->get('category', true);
  8654. $warehouse = $this->input->get('warehouse', true);
  8655. $excelid = $this->input->get('sid', true);
  8656. if ($category) {
  8657. $where .= " and features like '%-$category-%'";
  8658. }
  8659. if ($warehouse) {
  8660. $where .= " and warehouse = '$warehouse'";
  8661. }
  8662. $xzid = '';
  8663. if ($excelid) {
  8664. $excelid = explode(',', trim($excelid, ','));
  8665. foreach ($excelid as $key => $value) {
  8666. $xzid .= " id = " . $value . " or";
  8667. }
  8668. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8669. }
  8670. $merges = [
  8671. [
  8672. "s"=>["r"=>0,"c"=>0],
  8673. "e"=>["r"=>0,"c"=>6]
  8674. ]
  8675. ];
  8676. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8677. $excel_index = 2;
  8678. $final_list = [];
  8679. foreach ($rows as $key => $value) {
  8680. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8681. $zh = '';
  8682. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8683. // foreach ($zt_list as $v) {
  8684. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8685. // }
  8686. $zt = array_sum(array_column($zt_list, 'num'));
  8687. $number = $value['number'];
  8688. $ftime = time() - 15 * 24 * 3600;
  8689. $warehouse = $this->warehouse->read($value['warehouse']);
  8690. // $rows[$key]['warehouse'] = $warehouse['title'];
  8691. // $rows[$key]['number'] = $c;
  8692. // $rows[$key]['features'] = $zh;
  8693. //$rows[$key]['hb'] = $c + $zt;
  8694. $tmp = [];
  8695. $tmp[0] = $warehouse['title'];
  8696. $tmp[1] = $value['sku'];
  8697. $tmp[2] = $value['title'];
  8698. $tmp[3] = $c;
  8699. $tmp[4] = "";
  8700. $tmp[5] = $c + $zt;
  8701. if(empty($zt_list)){
  8702. $tmp[4] = "";
  8703. $final_list[] = $tmp;
  8704. $excel_index = $excel_index + 1;
  8705. }else{
  8706. if(count($zt_list) == 1){
  8707. $tmp[4] = "";
  8708. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8709. $final_list[] = $tmp;
  8710. $excel_index = $excel_index + 1;
  8711. }else{
  8712. $len = count($zt_list);
  8713. foreach ($zt_list as $v){
  8714. $tmp[4] = "";
  8715. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8716. $final_list[] = $tmp;
  8717. }
  8718. $merges[] = [
  8719. "s"=>["r"=>$excel_index,"c"=>0],
  8720. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8721. ];
  8722. $merges[] = [
  8723. "s"=>["r"=>$excel_index,"c"=>1],
  8724. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8725. ];
  8726. $merges[] = [
  8727. "s"=>["r"=>$excel_index,"c"=>2],
  8728. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8729. ];
  8730. $merges[] = [
  8731. "s"=>["r"=>$excel_index,"c"=>3],
  8732. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8733. ];
  8734. $merges[] = [
  8735. "s"=>["r"=>$excel_index,"c"=>5],
  8736. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8737. ];
  8738. $excel_index = $excel_index + $len;
  8739. }
  8740. }
  8741. }
  8742. $first_row = [
  8743. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8744. ];
  8745. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8746. if(empty($final_list)){
  8747. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8748. }
  8749. $cols = [
  8750. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8751. ];
  8752. array_unshift($final_list, $first_row);
  8753. array_unshift($final_list, [
  8754. $title,"","","","",""
  8755. ]);
  8756. $end_list = [];
  8757. foreach ($final_list as $key => $value) {
  8758. $end_list[] = array_values($value);
  8759. }
  8760. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8761. }
  8762. //出库、退库导出
  8763. public function _dccrtypejs()
  8764. {
  8765. $classid = $this->classid->sku();
  8766. $pm = $classid;
  8767. $typeclass = array();
  8768. $tc = $this->typeclass->find_all();
  8769. foreach ($tc as $v) {
  8770. $typeclass[$v['id']] = $v;
  8771. }
  8772. $prc = array();
  8773. $purchase = $this->purchase->find_all();
  8774. foreach ($purchase as $k => $v) {
  8775. $prc[$v['id']] = $v['title'];
  8776. }
  8777. if (isset($_GET['sid'])) {
  8778. $wh = array();
  8779. $w = $this->warehouse->find_all('1=1', 'id,title');
  8780. foreach ($w as $v) {
  8781. $wh[$v['id']] = $v['title'];
  8782. }
  8783. $type = $this->input->get('excel', true);
  8784. $category = $this->input->get('category', true);
  8785. $size = $this->input->get('size', true);
  8786. $grade = $this->input->get('grade', true);
  8787. $color = $this->input->get('color', true);
  8788. $lowe = $this->input->get('lowe', true);
  8789. $sku = $this->input->get('sku', true);
  8790. $warehouse = $this->input->get('warehouse', true);
  8791. $lacetype = $this->input->get('lacetype', true);
  8792. $lacecolor = $this->input->get('lacecolor', true);
  8793. $density = $this->input->get('density', true);
  8794. $haircap = $this->input->get('haircap', true);
  8795. $purchase = $this->input->get('purchase', true);
  8796. $title = $this->input->get('title', true);
  8797. $state = $this->input->get('state', true);
  8798. $sid = $this->input->get('sid', true);
  8799. $ktime = $this->input->get('ktime', true);
  8800. $jtime = $this->input->get('jtime', true);
  8801. $ktime = strtotime($ktime);
  8802. $jtime = strtotime($jtime);
  8803. $where = "1=1";
  8804. $gj = "";
  8805. $ck = "";
  8806. if ($category) {
  8807. $where .= " and features like '%-$category-%'";
  8808. }
  8809. if ($size) {
  8810. $where .= " and features like '%-$size-%'";
  8811. }
  8812. if ($grade) {
  8813. $where .= " and features like '%-$grade-%'";
  8814. }
  8815. if ($color) {
  8816. $where .= " and features like '%-$color-%'";
  8817. }
  8818. if ($lowe) {
  8819. $where .= " and features like '%-$lowe-%'";
  8820. }
  8821. if ($warehouse) {
  8822. $where .= " and warehouse = '$warehouse'";
  8823. }
  8824. if ($purchase) {
  8825. $where .= " and purchase = '$purchase'";
  8826. }
  8827. if ($state) {
  8828. $where .= " and state = '$state'";
  8829. }
  8830. if ($lacetype) {
  8831. $where .= " and features like '%-$lacetype-%'";
  8832. }
  8833. if ($lacecolor) {
  8834. $where .= " and features like '%-$lacecolor-%'";
  8835. }
  8836. if ($density) {
  8837. $where .= " and features like '%-$density-%'";
  8838. }
  8839. if ($haircap) {
  8840. $where .= " and features like '%-$haircap-%'";
  8841. }
  8842. if ($title) {
  8843. $title = trim($title, ' ');
  8844. $title = trim($title, ' ');
  8845. $where .= " and title like '%$title%'";
  8846. }
  8847. if ($sku) {
  8848. $sku = trim($sku, ' ');
  8849. $sku = trim($sku, ' ');
  8850. $where .= " and sku like '%$sku%'";
  8851. }
  8852. if ($ktime && $jtime) {
  8853. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8854. }
  8855. $sidwhere = '';
  8856. if ($sid) {
  8857. $sd = "";
  8858. $s = explode(',', trim($sid, ','));
  8859. foreach ($s as $value) {
  8860. $sd .= " id = " . $value . " or";
  8861. }
  8862. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8863. }
  8864. //数据排序
  8865. $order_str = "time desc";
  8866. if (empty($page)) {
  8867. $start = 0;
  8868. $perpage = 1;
  8869. } else {
  8870. $start = ($page - 1) * $perpage;
  8871. }
  8872. $wh = array();
  8873. $w = $this->warehouse->find_all('1=1', 'id,title');
  8874. foreach ($w as $v) {
  8875. $wh[$v['id']] = $v['title'];
  8876. }
  8877. $wt = array();
  8878. $whlabel_type = $this->whlabel_type->find_all();
  8879. foreach ($whlabel_type as $v) {
  8880. $wt[$v['id']] = $v['title'];
  8881. }
  8882. $classid = $this->classid->sku();
  8883. $list = array();
  8884. $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');
  8885. foreach ($rows_r as $key => $value) {
  8886. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8887. $pm = $classid;
  8888. $jm = $classid;
  8889. $rows_r[$key]['enter'] = '入库';
  8890. $rows_r[$key]['time'] = $value['enter'];
  8891. if ($value['rktype'] == 1) {
  8892. $rows_r[$key]['rktype'] = '采购入库';
  8893. } else if ($value['rktype'] == 2) {
  8894. $rows_r[$key]['rktype'] = '盘盈调整';
  8895. } else if ($value['rktype'] == 3) {
  8896. $rows_r[$key]['rktype'] = '其他调整入库';
  8897. } else if ($value['rktype'] == 4) {
  8898. $rows_r[$key]['rktype'] = '其他调整入库';
  8899. } else if ($value['rktype'] == 5) {
  8900. $rows_r[$key]['rktype'] = '退库入库';
  8901. } else if ($value['rktype'] == 6) {
  8902. $rows_r[$key]['rktype'] = '退货可用入库';
  8903. } else if ($value['rktype'] == 7) {
  8904. $rows_r[$key]['rktype'] = '形态转换入库';
  8905. } else {
  8906. $rows_r[$key]['rktype'] = '';
  8907. }
  8908. $features = explode('-', trim($value['features'], '-'));
  8909. foreach ($features as $v) {
  8910. if (isset($typeclass[$v])) {
  8911. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8912. $pm[$typeclass[$v]['classid']] = $zh[0];
  8913. }
  8914. if (isset($typeclass[$v])) {
  8915. if (isset($jm[$typeclass[$v]['classid']])) {
  8916. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8917. }
  8918. }
  8919. }
  8920. $zh = implode(" ", $pm);
  8921. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8922. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8923. $rows_r[$key]['zh'] = $zh;
  8924. $jm = array_filter($jm);
  8925. $rows_r[$key]['features'] = implode("-", $jm);
  8926. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8927. }
  8928. $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');
  8929. foreach ($rows_c as $key => $value) {
  8930. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8931. $pm = $classid;
  8932. $jm = $classid;
  8933. $rows_c[$key]['time'] = $value['outk'];
  8934. $rows_c[$key]['outk'] = '出库';
  8935. if ($value['cktype'] == 1) {
  8936. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8937. } else if ($value['cktype'] == 2) {
  8938. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8939. } else if ($value['cktype'] == 3) {
  8940. $rows_c[$key]['cktype'] = '盘亏调整';
  8941. } else if ($value['cktype'] == 4) {
  8942. $rows_c[$key]['cktype'] = '其他调整出库';
  8943. } else if ($value['cktype'] == 5) {
  8944. $rows_c[$key]['cktype'] = '形态转换出库';
  8945. } else {
  8946. $rows_c[$key]['cktype'] = '';
  8947. }
  8948. unset($rows_c[$key]['state']);
  8949. $features = explode('-', trim($value['features'], '-'));
  8950. foreach ($features as $v) {
  8951. if (isset($typeclass[$v])) {
  8952. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8953. $pm[$typeclass[$v]['classid']] = $zh[0];
  8954. }
  8955. if (isset($typeclass[$v])) {
  8956. if (isset($jm[$typeclass[$v]['classid']])) {
  8957. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8958. }
  8959. }
  8960. }
  8961. $zh = implode(" ", $pm);
  8962. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8963. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8964. $rows_c[$key]['zh'] = $zh;
  8965. $jm = array_filter($jm);
  8966. $rows_c[$key]['features'] = implode("-", $jm);
  8967. $rows_c[$key]['number'] = 1;
  8968. }
  8969. $merged = $rows_r;
  8970. foreach ($rows_c as $key => $value) {
  8971. if (isset($merged[$key])) {
  8972. $merged[] = $value;
  8973. } else {
  8974. $merged[$key] = $value;
  8975. }
  8976. }
  8977. usort($merged, function ($a, $b) {
  8978. return $a['time'] - $b['time'];
  8979. });
  8980. foreach ($merged as $key => $value) {
  8981. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8982. }
  8983. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8984. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  8985. $cols = [
  8986. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8987. ];
  8988. $final_list= [];
  8989. foreach($merged as $key => $value){
  8990. $final_list[] = array_values($value) ;
  8991. }
  8992. if(empty($merged)){
  8993. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8994. }
  8995. array_unshift($final_list, $first_row);
  8996. $end_list = [];
  8997. foreach ($final_list as $key => $value) {
  8998. $end_list[] = array_values($value);
  8999. }
  9000. $merges = [];
  9001. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9002. }
  9003. }
  9004. public function _errorexceljs()
  9005. {
  9006. $post = $this->input->post(NULL, TRUE);
  9007. if (isset($_GET['page'])) {
  9008. $page = $this->input->get('page', true);
  9009. $perpage = $this->input->get('perpage', true);
  9010. $sku = $this->input->get('sku', true);
  9011. $warehouse = $this->input->get('warehouse', true);
  9012. $ktime = $this->input->get('ktime', true);
  9013. $jtime = $this->input->get('jtime', true);
  9014. $ktime = strtotime($ktime);
  9015. $jtime = strtotime($jtime);
  9016. $where = "sku != 'Preset'";
  9017. $gj = '';
  9018. if ($sku) {
  9019. $where .= " and sku like '%$sku%'";
  9020. } else {
  9021. if ($ktime && $jtime) {
  9022. $gj = " and time > '$ktime' and time < '$jtime'";
  9023. }
  9024. }
  9025. if ($warehouse) {
  9026. $where .= " and warehouse = '$warehouse'";
  9027. }
  9028. //数据排序
  9029. $order_str = "id desc";
  9030. if (empty($page)) {
  9031. $start = 0;
  9032. $perpage = 1;
  9033. } else {
  9034. $start = ($page - 1) * $perpage;
  9035. }
  9036. //取得信息列表
  9037. $rows = array();
  9038. $list = array();
  9039. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9040. foreach ($info_list as $value) {
  9041. $warehouse = $this->warehouse->read($value['warehouse']);
  9042. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9043. $number = $value['number'];
  9044. $ftime = time() - 15 * 24 * 3600;
  9045. if ($c < 1) {
  9046. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9047. }
  9048. }
  9049. $title = "0库存汇总";
  9050. $first_row = ["仓库","SKU","产品","当前库存"];
  9051. $cols = [
  9052. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9053. ];
  9054. $final_list= [];
  9055. foreach($list as $key => $value){
  9056. $final_list[] = array_values($value) ;
  9057. }
  9058. if(empty($final_list)){
  9059. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9060. }
  9061. array_unshift($final_list, $first_row);
  9062. $merges = [];
  9063. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9064. }
  9065. }
  9066. }