Whlabel.php 317 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351
  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,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. </tr>
  1161. </table>";
  1162. $filename = $title . ".xls";
  1163. $tail = "";
  1164. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1165. }
  1166. }
  1167. public function _type()
  1168. {
  1169. $vip = 0;
  1170. if (isset($_SESSION['api'])) {
  1171. $user = $this->user->get_api($_SESSION['api']);
  1172. $fgshop = "";
  1173. $sid = "";
  1174. $usersp = explode('|', trim($user['shop'], '|'));
  1175. foreach ($usersp as $value) {
  1176. $fgshop .= " shop = " . $value . " or";
  1177. $sid .= " id = " . $value . " or";
  1178. }
  1179. if ($user['vip'] == 1) {
  1180. $vip = 1;
  1181. }
  1182. } else {
  1183. header('Location: /');
  1184. exit;
  1185. }
  1186. $prc = array();
  1187. $purchase = $this->purchase->find_all();
  1188. foreach ($purchase as $k => $v) {
  1189. $prc[$v['id']] = $v['title'];
  1190. }
  1191. $company = array();
  1192. $ct = $this->company->find_all();
  1193. foreach ($ct as $k => $v) {
  1194. $company[$v['id']] = $v['title'];
  1195. }
  1196. $sp = array();
  1197. $s = $this->shop->find_all('1=1', 'id,shopname');
  1198. foreach ($s as $v) {
  1199. $sp[$v['id']] = $v['shopname'];
  1200. }
  1201. $wh = array();
  1202. $w = $this->warehouse->find_all('1=1', 'id,title');
  1203. foreach ($w as $v) {
  1204. $wh[$v['id']] = $v['title'];
  1205. }
  1206. $post = $this->input->post(NULL, TRUE);
  1207. if (isset($post['page'])) {
  1208. $page = $this->input->post('page', true);
  1209. $perpage = $this->input->post('perpage', true);
  1210. $category = $this->input->post('category', true);
  1211. $size = $this->input->post('size', true);
  1212. $grade = $this->input->post('grade', true);
  1213. $color = $this->input->post('color', true);
  1214. $lowe = $this->input->post('lowe', true);
  1215. $sku = $this->input->post('sku');
  1216. $title = $this->input->post('title');
  1217. $warehouse = $this->input->post('warehouse', true);
  1218. $usa = $this->input->post('usa', true);
  1219. $purchase = $this->input->post('purchase', true);
  1220. $lacetype = $this->input->post('lacetype', true);
  1221. $haircap = $this->input->post('haircap', true);
  1222. $density = $this->input->post('density', true);
  1223. $details = $this->input->post('details', true);
  1224. $state = $this->input->post('state', true);
  1225. $shop = $this->input->post('shop', true);
  1226. $lacecolor = $this->input->post('lacecolor', true);
  1227. $hairnumber = $this->input->post('hairnumber', true);
  1228. $type = $this->input->post('type', true);
  1229. $ktime = $this->input->post('ktime', true);
  1230. $jtime = $this->input->post('jtime', true);
  1231. $ktime = strtotime($ktime);
  1232. $jtime = strtotime($jtime);
  1233. $cpbz = $this->input->post('cpbz', true);
  1234. $sm = $this->input->post('sm', true);
  1235. $where = "1=1";
  1236. $gj = "";
  1237. $ck = "";
  1238. if ($usa) {
  1239. if (!$warehouse) {
  1240. $where .= " and (warehouse = '5' or warehouse = '8')";
  1241. }
  1242. }
  1243. if ($warehouse) {
  1244. $where .= " and warehouse = '$warehouse'";
  1245. }
  1246. if ($details) {
  1247. $where .= " and details = '$details'";
  1248. }
  1249. if ($purchase) {
  1250. $where .= " and purchase = '$purchase'";
  1251. }
  1252. if ($state) {
  1253. $where .= " and state = '$state'";
  1254. }
  1255. if ($shop) {
  1256. $where .= " and shop like '%$shop%'";
  1257. }
  1258. if ($type) {
  1259. $where .= " and type = '$type'";
  1260. }
  1261. if ($ktime && $jtime) {
  1262. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1263. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1264. }
  1265. if ($cpbz) {
  1266. $where .= " and cpbz like '%$cpbz%' ";
  1267. }
  1268. if ($sm) {
  1269. $where .= " and sm like '%$sm%' ";
  1270. }
  1271. if ($lacecolor) {
  1272. $where .= " and features like '%-$lacecolor-%'";
  1273. }
  1274. if ($lacetype) {
  1275. $where .= " and features like '%-$lacetype-%'";
  1276. }
  1277. if ($category) {
  1278. $where .= " and features like '%-$category-%'";
  1279. }
  1280. if ($size) {
  1281. $where .= " and features like '%-$size-%'";
  1282. }
  1283. if ($grade) {
  1284. $where .= " and features like '%-$grade-%'";
  1285. }
  1286. if ($color) {
  1287. $where .= " and features like '%-$color-%'";
  1288. }
  1289. if ($lowe) {
  1290. $where .= " and features like '%-$lowe-%'";
  1291. }
  1292. if ($haircap) {
  1293. $where .= " and features like '%-$haircap-%'";
  1294. }
  1295. if ($density) {
  1296. $where .= " and features like '%-$density-%'";
  1297. }
  1298. if (!empty($hairnumber)) {
  1299. $where .= " and features like '%-128-%' ";
  1300. if ($hairnumber < 0) {
  1301. $class_list = $this->typeclass->find_all('classid = 43');
  1302. foreach ($class_list as $v) {
  1303. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1304. }
  1305. } else {
  1306. $where .= " and features like '%-$hairnumber-%'";
  1307. }
  1308. }
  1309. //数据排序
  1310. $order_str = "id desc";
  1311. if (empty($page)) {
  1312. $start = 0;
  1313. $perpage = 1;
  1314. } else {
  1315. $start = ($page - 1) * $perpage;
  1316. }
  1317. $fjnr = '';
  1318. if ($sku) {
  1319. $sku = trim($sku, ' ');
  1320. $sku = trim($sku, ' ');
  1321. $fjnr .= " and sku like '%$sku%'";
  1322. }
  1323. if ($title) {
  1324. $title = trim($title, ' ');
  1325. $title = trim($title, ' ');
  1326. $fjnr .= " and title like '%$title%'";
  1327. }
  1328. $wt = array();
  1329. $whlabel_type = $this->whlabel_type->find_all();
  1330. foreach ($whlabel_type as $v) {
  1331. $wt[$v['id']] = $v['title'];
  1332. }
  1333. //$where .= " and time > '$ktime' and time < '$jtime'";
  1334. $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
  1335. //取得信息列表
  1336. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1337. $rows = array();
  1338. $list = array();
  1339. foreach ($info_list as $key => $value) {
  1340. if (isset($wt[$value['type']])) {
  1341. $info_list[$key]['type'] = $wt[$value['type']];
  1342. } else {
  1343. $info_list[$key]['type'] = '未设置';
  1344. }
  1345. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1346. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1347. $ztdata = '';
  1348. if (count($zt) > 0) {
  1349. foreach ($zt as $vv) {
  1350. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1351. }
  1352. }
  1353. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1354. $cdata = array_filter($qbdata, function ($item) {
  1355. return $item['state'] < 1;
  1356. });
  1357. $c = array_sum(array_column($cdata, 'jnum'));
  1358. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1359. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1360. });
  1361. $g = array_sum(array_column($gdata, 'jnum'));
  1362. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1363. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1364. });
  1365. $x = array_sum(array_column($xdata, 'jnum'));
  1366. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1367. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1368. });
  1369. $t = array_sum(array_column($tdata, 'jnum'));
  1370. // $zdata = array_filter($qbdata, function ($item) {
  1371. // return $item['zd'] != "" && $item['state'] < 1;
  1372. // });
  1373. // $z = array_sum(array_column($zdata, 'jnum'));
  1374. $zdata = array_filter($qbdata, function ($item) {
  1375. return $item['zd'] != "" && $item['state'] < 1;
  1376. });
  1377. $z = array_sum(array_column($zdata, 'jnum'));
  1378. //$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');
  1379. //$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'].'"');
  1380. //$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'].'"');
  1381. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1382. //$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'].'"');
  1383. $details = array();
  1384. $cpid = array();
  1385. $od = array();
  1386. $odid = '';
  1387. $companytitle = '';
  1388. $shop_list = [];
  1389. foreach ($qbdata as $v) {
  1390. if ($v['zd'] != "" && $v['state'] < 1) {
  1391. if (!isset($od[$v['zd']])) {
  1392. $od[$v['zd']] = 1; //所有数据sku
  1393. } else {
  1394. $od[$v['zd']] = $od[$v['zd']] + 1;
  1395. }
  1396. }
  1397. $details[$v['details']] = $v['details'];
  1398. if ($v['state'] < 1) {
  1399. //$details[$v['details']] = $v['details'];
  1400. if ($v['cpid'] != 0) {
  1401. $cpid[$v['cpid']] = $v['cpid'];
  1402. }
  1403. }
  1404. if($v['state'] == 0){
  1405. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1406. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1407. }
  1408. if ($v['shop'] != '') {
  1409. $shop = explode(',', trim($v['shop'], ','));
  1410. foreach ($shop as $vv) {
  1411. if (!in_array($vv, $shop_list)) {
  1412. $shop_list[] = $vv;
  1413. }
  1414. }
  1415. }
  1416. }
  1417. }
  1418. foreach ($od as $k => $vv) {
  1419. $odid .= $k . '数量' . $vv;
  1420. }
  1421. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1422. $info_list[$key]['label'] = $value['sm'];
  1423. $number = $value['number'];
  1424. $ftime = time() - 15 * 24 * 3600;
  1425. $z = $z . '(' . $odid . ')'; //查看订单号
  1426. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1427. $info_list[$key]['features'] = $c;
  1428. $info_list[$key]['number'] = $ztdata;
  1429. $info_list[$key]['sm'] = $g;
  1430. $info_list[$key]['x'] = $x;
  1431. $info_list[$key]['t'] = $t;
  1432. $info_list[$key]['z'] = $z;
  1433. /**
  1434. foreach ($cdata as $k=>$v)
  1435. {
  1436. $details[$v['details']] = $v['details'];
  1437. if($v['cpid'] != 0)
  1438. {
  1439. $cpid[$v['cpid']] = $v['cpid'];
  1440. }
  1441. }
  1442. **/
  1443. $info_list[$key]['shop'] = '';
  1444. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1445. // if ($value['shop'] != '') {
  1446. // $shop = explode(',', trim($value['shop'], ','));
  1447. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1448. // }
  1449. $shop_list = array_unique($shop_list);
  1450. $shop_str = '';
  1451. foreach ($shop_list as $v) {
  1452. if(isset($sp[$v])){
  1453. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1454. }
  1455. }
  1456. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1457. /**
  1458. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1459. if(isset($companytitle[0]))
  1460. {
  1461. foreach ($companytitle as $k=>$v)
  1462. {
  1463. if($v['companytitle'] != '')
  1464. {
  1465. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1466. }
  1467. }
  1468. }
  1469. **/
  1470. }
  1471. $final_all_list = [];
  1472. foreach ($info_list as $k => $v) {
  1473. $final_all_list[] = [
  1474. 'id' => $v['id'],
  1475. "warehouse" => $v["warehouse"],
  1476. "purchase" => $v["purchase"],
  1477. "sku" => $v["sku"],
  1478. "title" => $v["title"] . "<br/>" . $v["pm"],
  1479. "details" => $v["details"],
  1480. "shop" => $v["shop"],
  1481. "cpbz" => $v["cpbz"],
  1482. 'label' => $v['label'],
  1483. "type" => $v["type"],
  1484. "features" => $v["features"],
  1485. "number" => $v["number"],
  1486. "sm" => $v["sm"],
  1487. "x" => $v["x"],
  1488. "t" => $v["t"],
  1489. "z" => $v["z"]
  1490. ];
  1491. }
  1492. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1493. $pagenum = ceil($total / $perpage);
  1494. $over = $total - ($start + $perpage);
  1495. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1496. echo json_encode($rows);
  1497. exit;
  1498. }
  1499. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1500. $this->data['shop'] = $wlshop;
  1501. $this->data['vip'] = $vip;
  1502. $this->_Template('whlabel_type', $this->data);
  1503. }
  1504. //美仓进销存浏览
  1505. public function _usatype()
  1506. {
  1507. if (isset($_SESSION['api'])) {
  1508. $user = $this->user->get_api($_SESSION['api']);
  1509. $usp = $user;
  1510. $fgshop = "";
  1511. $sid = "";
  1512. $wid = "";
  1513. $wtype = "";
  1514. $userwh = explode('|', trim($user['warehouse'], '|'));
  1515. foreach ($userwh as $value) {
  1516. $wid .= " id = " . $value . " or";
  1517. $wtype .= " type = " . $value . " or";
  1518. }
  1519. }
  1520. $prc = array();
  1521. $purchase = $this->purchase->find_all();
  1522. foreach ($purchase as $k => $v) {
  1523. $prc[$v['id']] = $v['title'];
  1524. }
  1525. $post = $this->input->post(NULL, TRUE);
  1526. if (isset($post['page'])) {
  1527. $page = $this->input->post('page', true);
  1528. $perpage = $this->input->post('perpage', true);
  1529. $category = $this->input->post('category', true);
  1530. $size = $this->input->post('size', true);
  1531. $grade = $this->input->post('grade', true);
  1532. $color = $this->input->post('color', true);
  1533. $lowe = $this->input->post('lowe', true);
  1534. $sku = $this->input->post('sku');
  1535. $title = $this->input->post('title');
  1536. $warehouse = $this->input->post('warehouse', true);
  1537. $usa = $this->input->post('usa', true);
  1538. $purchase = $this->input->post('purchase', true);
  1539. $lacetype = $this->input->post('lacetype', true);
  1540. $haircap = $this->input->post('haircap', true);
  1541. $density = $this->input->post('density', true);
  1542. $details = $this->input->post('details', true);
  1543. $state = $this->input->post('state', true);
  1544. $lacecolor = $this->input->post('lacecolor', true);
  1545. $cklx = $this->input->post('cklx', true);
  1546. $ktime = $this->input->post('ktime', true);
  1547. $jtime = $this->input->post('jtime', true);
  1548. $ktime = strtotime($ktime);
  1549. $jtime = strtotime($jtime);
  1550. $where = "1=1";
  1551. $gj = "";
  1552. $ck = "";
  1553. if ($lacetype) {
  1554. $where .= " and features like '%-$lacetype-%'";
  1555. }
  1556. if ($category) {
  1557. $where .= " and features like '%-$category-%'";
  1558. }
  1559. if ($size) {
  1560. $where .= " and features like '%-$size-%'";
  1561. }
  1562. if ($grade) {
  1563. $where .= " and features like '%-$grade-%'";
  1564. }
  1565. if ($color) {
  1566. $where .= " and features like '%-$color-%'";
  1567. }
  1568. if ($lowe) {
  1569. $where .= " and features like '%-$lowe-%'";
  1570. }
  1571. if ($haircap) {
  1572. $where .= " and features like '%-$haircap-%'";
  1573. }
  1574. if ($density) {
  1575. $where .= " and features like '%-$density-%'";
  1576. }
  1577. if ($lacecolor) {
  1578. $where .= " and features like '%-$lacecolor-%'";
  1579. }
  1580. if ($usa) {
  1581. if (!$warehouse) {
  1582. $where .= " and (warehouse = '5' or warehouse = '8')";
  1583. }
  1584. }
  1585. if ($warehouse) {
  1586. $where .= " and warehouse = '$warehouse'";
  1587. }
  1588. if ($details) {
  1589. $where .= " and details = '$details'";
  1590. }
  1591. if ($purchase) {
  1592. $where .= " and purchase = '$purchase'";
  1593. }
  1594. if ($state) {
  1595. $where .= " and state = '$state'";
  1596. }
  1597. $where_add = '';
  1598. if ($cklx) {
  1599. $shop = $this->shop->read($cklx);
  1600. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1601. }
  1602. if ($ktime && $jtime) {
  1603. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1604. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1605. }
  1606. //数据排序
  1607. $order_str = "id desc";
  1608. if (empty($page)) {
  1609. $start = 0;
  1610. $perpage = 1;
  1611. } else {
  1612. $start = ($page - 1) * $perpage;
  1613. }
  1614. if ($sku) {
  1615. $sku = trim($sku, ' ');
  1616. $sku = trim($sku, ' ');
  1617. $where .= " and sku like '%$sku%'";
  1618. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1619. } else if ($title) {
  1620. $title = trim($title, ' ');
  1621. $title = trim($title, ' ');
  1622. $where .= " and title like '%$title%'";
  1623. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1624. } else {
  1625. //$where .= " and time > '$ktime' and time < '$jtime'";
  1626. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1627. }
  1628. //取得信息列表
  1629. $rows = array();
  1630. $list = array();
  1631. foreach ($info_list as $key => $value) {
  1632. $warehouse = $this->warehouse->read($value['warehouse']);
  1633. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1634. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1635. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1636. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1637. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1638. $od = array();
  1639. $odid = '';
  1640. foreach ($z as $v) {
  1641. if (!isset($od[$v['zd']])) {
  1642. $od[$v['zd']] = 1; //所有数据sku
  1643. } else {
  1644. $od[$v['zd']] = $od[$v['zd']] + 1;
  1645. }
  1646. }
  1647. foreach ($od as $k => $vv) {
  1648. $odid .= $k . '数量' . $vv . ' ';
  1649. }
  1650. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1651. $info_list[$key]['features'] = $c;
  1652. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1653. $ztdata = '';
  1654. if (count($zt) > 0) {
  1655. foreach ($zt as $vv) {
  1656. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1657. }
  1658. }
  1659. $info_list[$key]['warehouse'] = $ztdata;
  1660. $info_list[$key]['g'] = $g;
  1661. $info_list[$key]['x'] = $x;
  1662. $info_list[$key]['t'] = $t;
  1663. $info_list[$key]['z'] = $z;
  1664. }
  1665. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1666. $pagenum = ceil($total / $perpage);
  1667. $over = $total - ($start + $perpage);
  1668. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1669. echo json_encode($rows);
  1670. exit;
  1671. }
  1672. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1673. $this->data['warehouse'] = $warehouse;
  1674. $this->_Template('whlabel_typeusa', $this->data);
  1675. }
  1676. //美仓进销存浏览
  1677. public function _usatypeapp()
  1678. {
  1679. $post = $this->input->post(NULL, TRUE);
  1680. if (isset($post['page'])) {
  1681. $page = $this->input->post('page', true);
  1682. $perpage = $this->input->post('perpage', true);
  1683. $sku = $this->input->post('sku', true);
  1684. $warehouse = 5;
  1685. $title = $this->input->post('title', true);
  1686. $state = $this->input->post('state', true);
  1687. $ktime = $this->input->post('ktime', true);
  1688. $jtime = $this->input->post('jtime', true);
  1689. $ktime = strtotime($ktime);
  1690. $jtime = strtotime($jtime);
  1691. $where = "1=1";
  1692. $gj = "";
  1693. $ck = "";
  1694. if ($title) {
  1695. $st = explode(' ', trim($title, ' '));
  1696. foreach ($st as $v) {
  1697. $where .= " and title like '%$v%'";
  1698. }
  1699. }
  1700. if ($warehouse) {
  1701. $where .= " and warehouse = '$warehouse'";
  1702. }
  1703. if ($state) {
  1704. $where .= " and state = '$state'";
  1705. }
  1706. if ($sku) {
  1707. $where .= " and sku like '%$sku%'";
  1708. }
  1709. if ($ktime && $jtime) {
  1710. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1711. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1712. }
  1713. //数据排序
  1714. $order_str = "id desc";
  1715. if (empty($page)) {
  1716. $start = 0;
  1717. $perpage = 1;
  1718. } else {
  1719. $start = ($page - 1) * $perpage;
  1720. }
  1721. //取得信息列表
  1722. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1723. $rows = array();
  1724. $list = array();
  1725. foreach ($info_list as $key => $value) {
  1726. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1727. }
  1728. $rowsdq = array_slice($rows, $start, $perpage);
  1729. foreach ($rowsdq as $value) {
  1730. $warehouse = $this->warehouse->read($value['warehouse']);
  1731. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1732. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1733. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1734. $od = array();
  1735. $odid = '';
  1736. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1737. }
  1738. $total = count($rows);
  1739. $pagenum = ceil($total / $perpage);
  1740. $over = $total - ($start + $perpage);
  1741. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1742. echo json_encode($rows);
  1743. exit;
  1744. }
  1745. $this->_Template('phone/p_usatypeapp', $this->data);
  1746. }
  1747. //入库操作
  1748. public function _enteradd()
  1749. {
  1750. $dt = 0;
  1751. if (isset($_SESSION['api'])) {
  1752. $user = $this->user->get_api($_SESSION['api']);
  1753. $usp = $user;
  1754. $fgshop = "";
  1755. $sid = "";
  1756. $user = explode('|', trim($user['shop'], '|'));
  1757. foreach ($user as $value) {
  1758. $fgshop .= " shop = " . $value . " or";
  1759. $sid .= " id = " . $value . " or";
  1760. }
  1761. }
  1762. $tc = $this->typeclass->find_all();
  1763. $typeclass = array();
  1764. foreach ($tc as $v) {
  1765. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1766. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1767. }
  1768. $post = $this->input->post(NULL, TRUE);
  1769. if (isset($post['sku'])) {
  1770. $list = array();
  1771. $num = "";
  1772. $title = "";
  1773. $features = "";
  1774. $order = $this->input->post('order', true);
  1775. $shop = $this->input->post('shop', true);
  1776. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1777. $sku = $this->input->post('sku', true);
  1778. $post['sm'] = $this->input->post('sm', true);
  1779. $post['warehouse'] = $this->input->post('warehouse', true);
  1780. $post['purchase'] = $this->input->post('purchase', true);
  1781. $post['retreatwarehouse'] = $post['warehouse'];
  1782. $post['state'] = $this->input->post('state', true);
  1783. $post['rktype'] = $this->input->post('rktype', true);
  1784. $post['text'] = $this->input->post('text', true);
  1785. $category = $this->input->post('category', true);
  1786. $list['category'] = $category;
  1787. $list['hairtype'] = $this->input->post('hairtype', true);
  1788. $list['grade'] = $this->input->post('grade', true);
  1789. $size = $this->input->post('size', true);
  1790. $xzsku = $this->input->post('xzsku', true);
  1791. $list['size'] = rtrim($size, ',');
  1792. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1793. $list['extension'] = $this->input->post('extension', true);
  1794. if ($category == 1297) {
  1795. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1796. }
  1797. if ($category == 1702) {
  1798. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1799. $list['syother'] = $this->input->post('syother', true);
  1800. }
  1801. if ($category == 133) {
  1802. $list['fittype'] = $this->input->post('fittype', true);
  1803. $list['acother'] = $this->input->post('acother', true);
  1804. }
  1805. $list['color'] = $this->input->post('color', true);
  1806. $list['lowe'] = $this->input->post('lowe', true);
  1807. if (!$post['purchase']) {
  1808. $post['purchase'] = 1;
  1809. }
  1810. if ($category == 127) {
  1811. $list['type'] = $this->input->post('type', true);
  1812. $list['headroad'] = $this->input->post('headroad', true);
  1813. $list['density'] = $this->input->post('density', true);
  1814. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1815. $list['lacesize'] = $this->input->post('lacesize', true);
  1816. }
  1817. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1818. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1819. }
  1820. if ($category == 128) {
  1821. $list['lacetype'] = $this->input->post('lacetype', true);
  1822. $list['haircap'] = $this->input->post('haircap', true);
  1823. $list['density'] = $this->input->post('density', true);
  1824. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1825. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1826. $list['wigother'] = $this->input->post('wigother', true);
  1827. $list['wigother1'] = $this->input->post('wigother1', true);
  1828. $list['wigother2'] = $this->input->post('wigother2', true);
  1829. }
  1830. if ($category == 129) {
  1831. $list['wide'] = $this->input->post('wide', true);
  1832. }
  1833. if ($category == 131) {
  1834. $list['gifttype'] = $this->input->post('gifttype', true);
  1835. $list['giftother'] = $this->input->post('giftother', true);
  1836. }
  1837. if ($category == 134) {
  1838. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1839. }
  1840. if ($category == 1297) {
  1841. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1842. $list['sywigother'] = $this->input->post('sywigother', true);
  1843. }
  1844. if ($category == 130 || $category == 133 || $category == 1702) {
  1845. $list['items'] = $this->input->post('items', true);
  1846. $list['weight'] = $this->input->post('weight', true);
  1847. }
  1848. if($category == 130){
  1849. $list['jfother'] = $this->input->post('jfother', true);
  1850. }
  1851. if ($category == 1702) {
  1852. $list['syhairther'] = $this->input->post('syhairther', true);
  1853. }
  1854. $classid = $this->classid->sku();
  1855. $scsku = $classid;
  1856. $pm = $classid;
  1857. foreach ($list as $k => $v) {
  1858. if ($v != 0) {
  1859. $num .= $v;
  1860. $features .= $v . '-';
  1861. $post[$k] = $v;
  1862. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1863. if ($k != 'size') {
  1864. $title .= $typeclass[$v]['title'] . " ";
  1865. }
  1866. if (isset($pm[$typeclass[$v]['classid']])) {
  1867. if ($typeclass[$v]['title'] == '9A') {
  1868. $pm[$typeclass[$v]['classid']] = '9A';
  1869. } else if ($typeclass[$v]['title'] == '10A') {
  1870. $pm[$typeclass[$v]['classid']] = '10A';
  1871. } else {
  1872. $clzh = $typeclass[$v]['zh'];
  1873. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1874. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1875. $clzh = $clzh[0];
  1876. }
  1877. $pm[$typeclass[$v]['classid']] = $clzh;
  1878. }
  1879. }
  1880. }
  1881. }
  1882. $zh = implode(" ", $pm);
  1883. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1884. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1885. if ($list['size']) {
  1886. $typeclass = $this->typeclass->read($list['size']);
  1887. $title .= $typeclass['title'];
  1888. }
  1889. $time = time();
  1890. if ($xzsku) {
  1891. $scsku = implode("-", $scsku);
  1892. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1893. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1894. $post['sku'] = trim($scsku, ' ');
  1895. } else {
  1896. $post['sku'] = $sku;
  1897. }
  1898. //$post['sku'] = trim($sku,' ');
  1899. $post['title'] = rtrim($title, ' ');
  1900. $post['number'] = $num;
  1901. $post['features'] = '-' . $features;
  1902. $post['enter'] = $time;
  1903. $post['time'] = $time; //操作时间
  1904. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1905. if ($yza) {
  1906. if ($post['features'] != $yza[0]['features']) {
  1907. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1908. exit;
  1909. }
  1910. }
  1911. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1912. if ($yzb) {
  1913. if ($post['sku'] != $yzb[0]['sku']) {
  1914. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1915. exit;
  1916. }
  1917. }
  1918. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1919. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1920. exit;
  1921. }
  1922. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1923. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1924. exit;
  1925. }
  1926. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1927. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1928. exit;
  1929. }
  1930. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1931. if (isset($yz[0]['type'])) {
  1932. $post['type'] = $yz[0]['type'];
  1933. }
  1934. if ($post['state'] == 9) //如果选择预设库存
  1935. {
  1936. $this->whlabel->insert($post);
  1937. } else {
  1938. /**
  1939. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1940. if($ljg == 1)
  1941. {
  1942. for($i=0;$i<$order;$i++)
  1943. {
  1944. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1945. $this->whlabel->insert($post);
  1946. }
  1947. }
  1948. **/
  1949. //if($post['warehouse'] == '5')
  1950. //{
  1951. //}
  1952. $yydata = $post;
  1953. $yydata['zh'] = $zh;
  1954. /**
  1955. $wl = $this->apiyy->get_cjlp($yydata);
  1956. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1957. {
  1958. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1959. }
  1960. if($wl['Data'][0]['m_isSucess'] != 1)
  1961. {
  1962. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1963. }
  1964. **/
  1965. for ($i = 0; $i < $order; $i++) {
  1966. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1967. $this->whlabel->insert($post);
  1968. }
  1969. }
  1970. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1971. exit;
  1972. }
  1973. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1974. $this->data['wlshop'] = $wlshop;
  1975. $this->_Template('whlabel_enteradd', $this->data);
  1976. }
  1977. //修改产品
  1978. public function _enteredit($arg_array)
  1979. {
  1980. $dt = 0;
  1981. if (isset($_SESSION['api'])) {
  1982. $user = $this->user->get_api($_SESSION['api']);
  1983. $usp = $user;
  1984. $fgshop = "";
  1985. $sid = "";
  1986. $user = explode('|', trim($user['shop'], '|'));
  1987. foreach ($user as $value) {
  1988. $fgshop .= " shop = " . $value . " or";
  1989. $sid .= " id = " . $value . " or";
  1990. }
  1991. }
  1992. $post = $this->input->post(NULL, TRUE);
  1993. if (isset($post['sku'])) {
  1994. $list = array();
  1995. $num = "";
  1996. $title = "";
  1997. $features = "";
  1998. $id = $this->input->post('id', true);
  1999. $order = $this->input->post('order', true);
  2000. $shop = $this->input->post('shop', true);
  2001. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2002. $post['sku'] = $this->input->post('sku', true);
  2003. $post['sm'] = $this->input->post('sm', true);
  2004. $post['warehouse'] = $this->input->post('warehouse', true);
  2005. $post['purchase'] = $this->input->post('purchase', true);
  2006. $post['retreatwarehouse'] = $post['warehouse'];
  2007. $category = $this->input->post('category', true);
  2008. $list['category'] = $category;
  2009. $list['hairtype'] = $this->input->post('hairtype', true);
  2010. $list['grade'] = $this->input->post('grade', true);
  2011. $size = $this->input->post('size', true);
  2012. $list['size'] = rtrim($size, ',');
  2013. $post['rktype'] = $this->input->post('rktype', true);
  2014. $post['text'] = $this->input->post('text', true);
  2015. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2016. $list['extension'] = $this->input->post('extension', true);
  2017. if ($category == 1297) {
  2018. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2019. }
  2020. if ($category == 1702) {
  2021. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2022. $list['syother'] = $this->input->post('syother', true);
  2023. }
  2024. if ($category == 133) {
  2025. $list['fittype'] = $this->input->post('fittype', true);
  2026. $list['acother'] = $this->input->post('acother', true);
  2027. }
  2028. $list['color'] = $this->input->post('color', true);
  2029. $list['lowe'] = $this->input->post('lowe', true);
  2030. if (!$post['purchase']) {
  2031. $post['purchase'] = 1;
  2032. }
  2033. if ($category == 127) {
  2034. $list['type'] = $this->input->post('type', true);
  2035. $list['headroad'] = $this->input->post('headroad', true);
  2036. $list['density'] = $this->input->post('density', true);
  2037. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2038. $list['lacesize'] = $this->input->post('lacesize', true);
  2039. }
  2040. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2041. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2042. }
  2043. if ($category == 128) {
  2044. $list['lacetype'] = $this->input->post('lacetype', true);
  2045. $list['haircap'] = $this->input->post('haircap', true);
  2046. $list['density'] = $this->input->post('density', true);
  2047. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2048. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2049. $list['wigother'] = $this->input->post('wigother', true);
  2050. $list['wigother1'] = $this->input->post('wigother1', true);
  2051. $list['wigother2'] = $this->input->post('wigother2', true);
  2052. }
  2053. if ($category == 129) {
  2054. $list['wide'] = $this->input->post('wide', true);
  2055. }
  2056. if ($category == 131) {
  2057. $list['gifttype'] = $this->input->post('gifttype', true);
  2058. $list['giftother'] = $this->input->post('giftother', true);
  2059. }
  2060. if ($category == 134) {
  2061. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2062. }
  2063. if ($category == 1297) {
  2064. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2065. $list['sywigother'] = $this->input->post('sywigother', true);
  2066. }
  2067. if ($category == 130 || $category == 133 || $category == 1702) {
  2068. $list['items'] = $this->input->post('items', true);
  2069. $list['weight'] = $this->input->post('weight', true);
  2070. }
  2071. if($category == 130){
  2072. $list['jfother'] = $this->input->post('jfother', true);
  2073. }
  2074. if ($category == 1702) {
  2075. $list['syhairther'] = $this->input->post('syhairther', true);
  2076. }
  2077. foreach ($list as $k => $v) {
  2078. if ($v != 0) {
  2079. $num .= $v;
  2080. $features .= $v . '-';
  2081. $typeclass = $this->typeclass->read($v);
  2082. if ($k != 'size') {
  2083. $title .= $typeclass['title'] . " ";
  2084. }
  2085. }
  2086. }
  2087. $typeclass = $this->typeclass->read($list['size']);
  2088. $title .= $typeclass['title'];
  2089. $time = time();
  2090. $post['title'] = rtrim($title, ' ');
  2091. $post['number'] = $num;
  2092. $post['features'] = '-' . $features;
  2093. $post['time'] = $time; //操作时间
  2094. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2095. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2096. exit;
  2097. }
  2098. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2099. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2100. exit;
  2101. }
  2102. $uid = $this->whlabel->read($id);
  2103. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2104. if ($datanum > 0) {
  2105. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2106. exit;
  2107. }
  2108. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2109. {
  2110. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2111. if ($yza) {
  2112. if ($post['features'] != $yza[0]['features']) {
  2113. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2114. exit;
  2115. }
  2116. }
  2117. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2118. if ($yzb) {
  2119. if ($post['sku'] != $yzb[0]['sku']) {
  2120. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2121. exit;
  2122. }
  2123. }
  2124. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2125. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2126. exit;
  2127. }
  2128. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2129. foreach ($data as $v) {
  2130. $post['id'] = $v['id'];
  2131. $this->whlabel->save($post, $v['id']);
  2132. }
  2133. } else {
  2134. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2135. if ($data > 0) {
  2136. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2137. exit;
  2138. } else {
  2139. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2140. foreach ($data as $v) {
  2141. $post['id'] = $v['id'];
  2142. $this->whlabel->save($post, $v['id']);
  2143. }
  2144. }
  2145. }
  2146. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2147. exit;
  2148. }
  2149. $uid = $this->whlabel->read($arg_array[0]);
  2150. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2151. $this->data['enter'] = $uid;
  2152. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2153. $this->data['wlshop'] = $wlshop;
  2154. $this->_Template('whlabel_enteredit', $this->data);
  2155. }
  2156. //入库浏览
  2157. public function _enter()
  2158. {
  2159. $post = $this->input->post(NULL, TRUE);
  2160. if (isset($post['s'])) {
  2161. $id_arr = $this->input->post('s');
  2162. $id_arr = explode(',', $id_arr);
  2163. if (!$id_arr) {
  2164. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2165. exit;
  2166. }
  2167. //循环删除记录
  2168. foreach ($id_arr as $v) {
  2169. $sid = $this->whlabel->read($v);
  2170. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2171. if ($count > 0) {
  2172. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2173. exit;
  2174. }
  2175. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2176. foreach ($info_list as $va) {
  2177. $this->whlabel->remove($va['id']);
  2178. }
  2179. }
  2180. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2181. exit;
  2182. }
  2183. $sp = array();
  2184. $s = $this->shop->find_all('1=1', 'id,shopname');
  2185. foreach ($s as $v) {
  2186. $sp[$v['id']] = $v['shopname'];
  2187. }
  2188. $wh = array();
  2189. $w = $this->warehouse->find_all('1=1', 'id,title');
  2190. foreach ($w as $v) {
  2191. $wh[$v['id']] = $v['title'];
  2192. }
  2193. if (isset($post['page'])) {
  2194. $page = $this->input->post('page', true);
  2195. $perpage = $this->input->post('perpage', true);
  2196. $category = $this->input->post('category', true);
  2197. $size = $this->input->post('size', true);
  2198. $grade = $this->input->post('grade', true);
  2199. $color = $this->input->post('color', true);
  2200. $lowe = $this->input->post('lowe', true);
  2201. $sku = $this->input->post('sku', true);
  2202. $warehouse = $this->input->post('warehouse', true);
  2203. $purchase = $this->input->post('purchase', true);
  2204. $ktime = $this->input->post('ktime', true);
  2205. $jtime = $this->input->post('jtime', true);
  2206. $ktime = strtotime($ktime);
  2207. $jtime = strtotime($jtime);
  2208. $where = "1=1";
  2209. $gj = "";
  2210. $ck = "";
  2211. if ($category) {
  2212. $where .= " and features like '%-$category-%'";
  2213. }
  2214. if ($size) {
  2215. $where .= " and features like '%-$size-%'";
  2216. }
  2217. if ($grade) {
  2218. $where .= " and features like '%-$grade-%'";
  2219. }
  2220. if ($color) {
  2221. $where .= " and features like '%-$color-%'";
  2222. }
  2223. if ($lowe) {
  2224. $where .= " and features like '%-$lowe-%'";
  2225. }
  2226. if ($warehouse) {
  2227. $where .= " and warehouse = '$warehouse'";
  2228. }
  2229. if ($purchase) {
  2230. $where .= " and purchase = '$purchase'";
  2231. }
  2232. if ($sku) {
  2233. $where .= " and sku like '%$sku%'";
  2234. }
  2235. if ($ktime && $jtime) {
  2236. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2237. }
  2238. //数据排序
  2239. $order_str = "enter desc";
  2240. if (empty($page)) {
  2241. $start = 0;
  2242. $perpage = 1;
  2243. } else {
  2244. $start = ($page - 1) * $perpage;
  2245. }
  2246. //取得信息列表
  2247. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2248. foreach ($info_list as $k => $v) {
  2249. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2250. if ($v['shop'] == '') {
  2251. $s = '通用';
  2252. } else {
  2253. $info_list[$k]['shop'] = '';
  2254. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2255. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2256. }
  2257. }
  2258. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2259. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2260. $info_list[$k]['g'] = $g;
  2261. }
  2262. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2263. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2264. $pagenum = ceil($total / $perpage);
  2265. $over = $total - ($start + $perpage);
  2266. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2267. echo json_encode($rows);
  2268. exit;
  2269. }
  2270. $this->_Template('whlabel_enter', $this->data);
  2271. }
  2272. //出库浏览
  2273. public function _out()
  2274. {
  2275. $post = $this->input->post(NULL, TRUE);
  2276. if (isset($post['page'])) {
  2277. $page = $this->input->post('page', true);
  2278. $perpage = $this->input->post('perpage', true);
  2279. $category = $this->input->post('category', true);
  2280. $size = $this->input->post('size', true);
  2281. $grade = $this->input->post('grade', true);
  2282. $color = $this->input->post('color', true);
  2283. $lowe = $this->input->post('lowe', true);
  2284. $sku = $this->input->post('sku', true);
  2285. $warehouse = $this->input->post('warehouse', true);
  2286. $purchase = $this->input->post('purchase', true);
  2287. $state = $this->input->post('state', true);
  2288. $ktime = $this->input->post('ktime', true);
  2289. $jtime = $this->input->post('jtime', true);
  2290. $ktime = strtotime($ktime);
  2291. $jtime = strtotime($jtime);
  2292. $where = "state=3";
  2293. $gj = "";
  2294. $ck = "";
  2295. if ($category) {
  2296. $where .= " and features like '%-$category-%'";
  2297. }
  2298. if ($size) {
  2299. $where .= " and features like '%-$size-%'";
  2300. }
  2301. if ($grade) {
  2302. $where .= " and features like '%-$grade-%'";
  2303. }
  2304. if ($color) {
  2305. $where .= " and features like '%-$color-%'";
  2306. }
  2307. if ($lowe) {
  2308. $where .= " and features like '%-$lowe-%'";
  2309. }
  2310. if ($state) {
  2311. $where .= " and state = '$state'";
  2312. }
  2313. if ($warehouse) {
  2314. $where .= " and warehouse = '$warehouse'";
  2315. }
  2316. if ($purchase) {
  2317. $where .= " and purchase = '$purchase'";
  2318. }
  2319. if ($sku) {
  2320. $where .= " and sku = '$sku'";
  2321. }
  2322. if ($ktime && $jtime) {
  2323. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2324. }
  2325. //数据排序
  2326. $order_str = "id desc";
  2327. if (empty($page)) {
  2328. $start = 0;
  2329. $perpage = 1;
  2330. } else {
  2331. $start = ($page - 1) * $perpage;
  2332. }
  2333. //取得信息列表
  2334. $info_list = $this->whlabel->find_all($where, 'sku');
  2335. $rows = array();
  2336. $list = array();
  2337. foreach ($info_list as $key => $value) {
  2338. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2339. }
  2340. $rows = array_unique($rows); //删除重复记录
  2341. foreach ($rows as $key => $value) {
  2342. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2343. $ck = $this->warehouse->read($data['warehouse']);
  2344. $warehouse = $ck['title'];
  2345. $gy = $this->purchase->read($data['purchase']);
  2346. $purchase = $gy['purchase'];
  2347. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2348. $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);
  2349. }
  2350. $total = count($list);
  2351. $pagenum = ceil($total / $perpage);
  2352. $over = $total - ($start + $perpage);
  2353. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2354. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2355. echo json_encode($rows);
  2356. exit;
  2357. }
  2358. $this->_Template('whlabel_out', $this->data);
  2359. }
  2360. //出库标签浏览
  2361. public function _label()
  2362. {
  2363. $post = $this->input->post(NULL, TRUE);
  2364. if (isset($post['page'])) {
  2365. $page = $this->input->post('page', true);
  2366. $perpage = $this->input->post('perpage', true);
  2367. $sku = $this->input->post('sku', true);
  2368. $warehouse = $this->input->post('warehouse', true);
  2369. $purchase = $this->input->post('purchase', true);
  2370. $orderinfo = $this->input->post('orderinfo', true);
  2371. $waybill = $this->input->post('waybill', true);
  2372. $category = $this->input->post('category', true);
  2373. $size = $this->input->post('size', true);
  2374. $grade = $this->input->post('grade', true);
  2375. $color = $this->input->post('color', true);
  2376. $lowe = $this->input->post('lowe', true);
  2377. $where = "state=1";
  2378. if ($sku) {
  2379. $where .= " and sku = '$sku'";
  2380. }
  2381. if ($warehouse) {
  2382. $where .= " and warehouse = '$warehouse'";
  2383. }
  2384. if ($purchase) {
  2385. $where .= " and purchase = '$purchase'";
  2386. }
  2387. if ($orderinfo) {
  2388. $where .= " and orderinfo = '$orderinfo'";
  2389. }
  2390. if ($waybill) {
  2391. $where .= " and waybill = '$waybill'";
  2392. }
  2393. if ($category) {
  2394. $where .= " and features like '%-$category-%'";
  2395. }
  2396. if ($size) {
  2397. $where .= " and features like '%-$size-%'";
  2398. }
  2399. if ($grade) {
  2400. $where .= " and features like '%-$grade-%'";
  2401. }
  2402. if ($color) {
  2403. $where .= " and features like '%-$color-%'";
  2404. }
  2405. if ($lowe) {
  2406. $where .= " and features like '%-$lowe-%'";
  2407. }
  2408. //数据排序
  2409. $order_str = "outk desc";
  2410. if (empty($page)) {
  2411. $start = 0;
  2412. $perpage = 1;
  2413. } else {
  2414. $start = ($page - 1) * $perpage;
  2415. }
  2416. //取得信息列表
  2417. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2418. foreach ($info_list as $key => $value) {
  2419. $warehouse = $this->warehouse->read($value['warehouse']);
  2420. $info_list[$key]['warehouse'] = $warehouse['title'];
  2421. $purchase = $this->purchase->read($value['purchase']);
  2422. $info_list[$key]['purchase'] = $purchase['title'];
  2423. if ($value['outk'] != 0) {
  2424. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2425. } else {
  2426. $info_list[$key]['outk'] = "";
  2427. }
  2428. if ($value['orderinfo'] == 0) {
  2429. $info_list[$key]['orderinfo'] = "";
  2430. }
  2431. if ($value['waybill'] == 0) {
  2432. $info_list[$key]['waybill'] = "";
  2433. }
  2434. }
  2435. $total = $this->whlabel->find_count($where);
  2436. $pagenum = ceil($total / $perpage);
  2437. $over = $total - ($start + $perpage);
  2438. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2439. echo json_encode($rows);
  2440. exit;
  2441. }
  2442. $this->_Template('whlabel_label', $this->data);
  2443. }
  2444. //独立站出库订单
  2445. public function _outorder()
  2446. {
  2447. if (isset($_SESSION['api'])) {
  2448. $user = $this->user->get_api($_SESSION['api']);
  2449. $usp = $user;
  2450. $fgshop = "";
  2451. $sid = "";
  2452. $user = explode('|', trim($user['shop'], '|'));
  2453. foreach ($user as $value) {
  2454. $fgshop .= " shop = " . $value . " or";
  2455. $sid .= " id = " . $value . " or";
  2456. }
  2457. } else {
  2458. echo "请重新登录";
  2459. }
  2460. $post = $this->input->post(NULL, TRUE);
  2461. if (isset($post['page'])) {
  2462. $page = $this->input->post('page', true);
  2463. $perpage = $this->input->post('perpage', true);
  2464. $warehouse = $this->input->post('warehouse', true);
  2465. $xztime = $this->input->post('xztime', true);
  2466. $timetk = $this->input->post('timetkk', true);
  2467. $timetj = $this->input->post('timetjj', true);
  2468. $shop = $this->input->post('shop', true);
  2469. $source = $this->input->post('source', true);
  2470. $orderinfo = $this->input->post('orderinfo', true);
  2471. $number = $this->input->post('number', true);
  2472. $sfxh = $this->input->post('sfxh', true);
  2473. $express = $this->input->post('express', true);
  2474. $waybill = $this->input->post('waybill', true);
  2475. $library = $this->input->post('library', true);
  2476. $country = $this->input->post('country', true);
  2477. $so = $this->input->post('so', true);
  2478. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2479. $print = $this->input->post('print', true);
  2480. $state = $this->input->post('state', true);
  2481. $orderurl = $this->input->post('orderurl', true);
  2482. $productid = $this->input->post('productid', true);
  2483. $timetk = strtotime($timetk);
  2484. $timetj = strtotime($timetj);
  2485. /**
  2486. $sj = $this->input->post('sj',true);
  2487. if($sj)
  2488. {
  2489. $sj = $this->input->post('sj',true);
  2490. }
  2491. else
  2492. {
  2493. $sj = "fullorder";
  2494. }
  2495. **/
  2496. $sj = "fullorder";
  2497. $where = "1=1";
  2498. if ($warehouse) {
  2499. $where .= " and type = '$warehouse'";
  2500. }
  2501. if ($timetk && $timetj) {
  2502. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2503. }
  2504. if ($orderinfo) {
  2505. $where .= " and orderinfo = '$orderinfo'";
  2506. }
  2507. if ($number) {
  2508. $where .= " and number = '$number'";
  2509. }
  2510. if ($express) {
  2511. $where .= " and express = '$express'";
  2512. }
  2513. if ($waybill) {
  2514. $where .= " and waybill = '$waybill'";
  2515. }
  2516. if ($library) {
  2517. $where .= " and library = '$library'";
  2518. }
  2519. if ($print) {
  2520. $where .= " and print = '$print'";
  2521. }
  2522. if ($libraryconfirm) {
  2523. $where .= " and libraryconfirm = '$libraryconfirm'";
  2524. }
  2525. if ($state) {
  2526. $where .= " and state = '$state'";
  2527. }
  2528. if ($shop) {
  2529. $where .= " and shop = '$shop'";
  2530. }
  2531. if ($country) {
  2532. $where .= " and country = '$country'";
  2533. }
  2534. if ($sfxh != '') {
  2535. $where .= " and sfxh = '$sfxh'";
  2536. }
  2537. if ($so) {
  2538. $where .= " and shipremarks like '%$so%'";
  2539. }
  2540. if ($source) {
  2541. if ($source == '2d') {
  2542. $where .= " and source >= '2'";
  2543. } else {
  2544. $where .= " and source = '$source'";
  2545. }
  2546. }
  2547. if (isset($_SESSION['api'])) {
  2548. foreach ($user as $value) {
  2549. $fgshop .= " shop = " . $value . " or";
  2550. }
  2551. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2552. }
  2553. if ($orderurl) {
  2554. $url = $this->orderurl->read($orderurl);
  2555. $where .= " and link like '%" . $url['url'] . "%'";
  2556. }
  2557. if($productid){
  2558. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2559. }
  2560. //数据排序
  2561. $order_str = "librarytime desc";
  2562. if (empty($page)) {
  2563. $start = 0;
  2564. $perpage = 1;
  2565. } else {
  2566. $start = ($page - 1) * $perpage;
  2567. }
  2568. //取得信息列表
  2569. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2570. //格式化数据
  2571. foreach ($info_list as $key => $value) {
  2572. $shop = $this->shop->read($value['shop']);
  2573. $info_list[$key]['shop'] = $shop['shopname'];
  2574. $express = $this->express->read($value['express']);
  2575. $info_list[$key]['express'] = $express['servicename'];
  2576. $warehouse = $this->warehouse->read($value['type']);
  2577. $info_list[$key]['type'] = $warehouse['title'];
  2578. if ($value['librarytime'] == '0') {
  2579. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2580. } else {
  2581. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2582. }
  2583. }
  2584. $total = $this->$sj->find_count($where);
  2585. $pagenum = ceil($total / $perpage);
  2586. $over = $total - ($start + $perpage);
  2587. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2588. echo json_encode($rows);
  2589. exit;
  2590. }
  2591. $this->data['express'] = $this->express->find_all();
  2592. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2593. $this->data['wlshop'] = $wlshop;
  2594. $user = $this->user->get_api($_SESSION['api']);
  2595. $powerid = $this->power->read($user['power']);
  2596. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2597. $pid = '';
  2598. foreach ($powertext as $v) {
  2599. $pid .= " id = " . $v . " or";
  2600. }
  2601. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2602. $this->data['fullorderexcel'] = $fullorderexcel;
  2603. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2604. $this->data['orderurl'] = $orderurl;
  2605. $this->_Template('whlabel_outorder', $this->data);
  2606. }
  2607. //tt出库
  2608. public function _toutorder()
  2609. {
  2610. $fgshop = "";
  2611. $sid = "";
  2612. if (isset($_SESSION['api'])) {
  2613. $user = $this->user->get_api($_SESSION['api']);
  2614. $usp = $user;
  2615. $user = explode('|', trim($user['shop'], '|'));
  2616. foreach ($user as $value) {
  2617. $fgshop .= " shop = " . $value . " or";
  2618. $sid .= " id = " . $value . " or";
  2619. }
  2620. } else {
  2621. echo "请重新登录";
  2622. die;
  2623. }
  2624. $post = $this->input->post(NULL, TRUE);
  2625. if (isset($post['page'])) {
  2626. $page = $this->input->post('page', true);
  2627. $perpage = $this->input->post('perpage', true);
  2628. $warehouse = $this->input->post('warehouse', true);
  2629. $xztime = $this->input->post('xztime', true);
  2630. $timetk = $this->input->post('timetkk', true);
  2631. $timetj = $this->input->post('timetjj', true);
  2632. $shop = $this->input->post('shop', true);
  2633. $source = $this->input->post('source', true);
  2634. $orderinfo = $this->input->post('orderinfo', true);
  2635. $number = $this->input->post('number', true);
  2636. $sfxh = $this->input->post('sfxh', true);
  2637. $express = $this->input->post('express', true);
  2638. $waybill = $this->input->post('waybill', true);
  2639. $library = $this->input->post('library', true);
  2640. $country = $this->input->post('country', true);
  2641. $so = $this->input->post('so', true);
  2642. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2643. $print = $this->input->post('print', true);
  2644. $state = $this->input->post('state', true);
  2645. $orderurl = $this->input->post('orderurl', true);
  2646. $timetk = strtotime($timetk);
  2647. $timetj = strtotime($timetj);
  2648. /**
  2649. $sj = $this->input->post('sj',true);
  2650. if($sj)
  2651. {
  2652. $sj = $this->input->post('sj',true);
  2653. }
  2654. else
  2655. {
  2656. $sj = "fullorder";
  2657. }
  2658. **/
  2659. $sj = "fullordertt";
  2660. $where = "1=1";
  2661. if ($warehouse) {
  2662. $where .= " and type = '$warehouse'";
  2663. }
  2664. if ($timetk && $timetj) {
  2665. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2666. }
  2667. if ($orderinfo) {
  2668. $where .= " and orderinfo = '$orderinfo'";
  2669. }
  2670. if ($number) {
  2671. $where .= " and number = '$number'";
  2672. }
  2673. if ($express) {
  2674. $where .= " and express = '$express'";
  2675. }
  2676. if ($waybill) {
  2677. $where .= " and waybill = '$waybill'";
  2678. }
  2679. if ($library) {
  2680. $where .= " and library = '$library'";
  2681. }
  2682. if ($print) {
  2683. $where .= " and print = '$print'";
  2684. }
  2685. if ($libraryconfirm) {
  2686. $where .= " and libraryconfirm = '$libraryconfirm'";
  2687. }
  2688. if ($state) {
  2689. $where .= " and state = '$state'";
  2690. }
  2691. if ($shop) {
  2692. $where .= " and shop = '$shop'";
  2693. }
  2694. if ($country) {
  2695. $where .= " and country = '$country'";
  2696. }
  2697. if ($sfxh != '') {
  2698. $where .= " and sfxh = '$sfxh'";
  2699. }
  2700. if ($so) {
  2701. $where .= " and shipremarks like '%$so%'";
  2702. }
  2703. if ($source) {
  2704. if ($source == '2d') {
  2705. $where .= " and source >= '2'";
  2706. } else {
  2707. $where .= " and source = '$source'";
  2708. }
  2709. }
  2710. if (isset($_SESSION['api'])) {
  2711. foreach ($user as $value) {
  2712. $fgshop .= " shop = " . $value . " or";
  2713. }
  2714. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2715. }
  2716. if ($orderurl) {
  2717. $url = $this->orderurl->read($orderurl);
  2718. $where .= " and link like '%" . $url['url'] . "%'";
  2719. }
  2720. //数据排序
  2721. $order_str = "librarytime desc";
  2722. if (empty($page)) {
  2723. $start = 0;
  2724. $perpage = 1;
  2725. } else {
  2726. $start = ($page - 1) * $perpage;
  2727. }
  2728. //取得信息列表
  2729. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2730. //格式化数据
  2731. foreach ($info_list as $key => $value) {
  2732. $shop = $this->shop->read($value['shop']);
  2733. $info_list[$key]['shop'] = $shop['shopname'];
  2734. $express = $this->express->read($value['express']);
  2735. $info_list[$key]['express'] = $express['servicename'];
  2736. $warehouse = $this->warehouse->read($value['type']);
  2737. $info_list[$key]['type'] = $warehouse['title'];
  2738. if ($value['librarytime'] == '0') {
  2739. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2740. } else {
  2741. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2742. }
  2743. }
  2744. $total = $this->$sj->find_count($where);
  2745. $pagenum = ceil($total / $perpage);
  2746. $over = $total - ($start + $perpage);
  2747. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2748. echo json_encode($rows);
  2749. exit;
  2750. }
  2751. $this->data['express'] = $this->express->find_all();
  2752. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2753. $this->data['wlshop'] = $wlshop;
  2754. $user = $this->user->get_api($_SESSION['api']);
  2755. $powerid = $this->power->read($user['power']);
  2756. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2757. $pid = '';
  2758. foreach ($powertext as $v) {
  2759. $pid .= " id = " . $v . " or";
  2760. }
  2761. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2762. $this->data['fullorderexcel'] = $fullorderexcel;
  2763. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2764. $this->data['orderurl'] = $orderurl;
  2765. $this->_Template('whlabel_toutorder', $this->data);
  2766. }
  2767. //tt出库
  2768. public function _aoutorder()
  2769. {
  2770. if (isset($_SESSION['api'])) {
  2771. $user = $this->user->get_api($_SESSION['api']);
  2772. $usp = $user;
  2773. $fgshop = "";
  2774. $sid = "";
  2775. $user = explode('|', trim($user['shop'], '|'));
  2776. foreach ($user as $value) {
  2777. $fgshop .= " shop = " . $value . " or";
  2778. $sid .= " id = " . $value . " or";
  2779. }
  2780. } else {
  2781. echo "请重新登录";
  2782. }
  2783. $post = $this->input->post(NULL, TRUE);
  2784. if (isset($post['page'])) {
  2785. $page = $this->input->post('page', true);
  2786. $perpage = $this->input->post('perpage', true);
  2787. $warehouse = $this->input->post('warehouse', true);
  2788. $xztime = $this->input->post('xztime', true);
  2789. $timetk = $this->input->post('timetkk', true);
  2790. $timetj = $this->input->post('timetjj', true);
  2791. $shop = $this->input->post('shop', true);
  2792. $source = $this->input->post('source', true);
  2793. $orderinfo = $this->input->post('orderinfo', true);
  2794. $number = $this->input->post('number', true);
  2795. $sfxh = $this->input->post('sfxh', true);
  2796. $express = $this->input->post('express', true);
  2797. $waybill = $this->input->post('waybill', true);
  2798. $library = $this->input->post('library', true);
  2799. $country = $this->input->post('country', true);
  2800. $so = $this->input->post('so', true);
  2801. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2802. $print = $this->input->post('print', true);
  2803. $state = $this->input->post('state', true);
  2804. $orderurl = $this->input->post('orderurl', true);
  2805. $timetk = strtotime($timetk);
  2806. $timetj = strtotime($timetj);
  2807. /**
  2808. $sj = $this->input->post('sj',true);
  2809. if($sj)
  2810. {
  2811. $sj = $this->input->post('sj',true);
  2812. }
  2813. else
  2814. {
  2815. $sj = "fullorder";
  2816. }
  2817. **/
  2818. $sj = "fullorderamz";
  2819. $where = "1=1";
  2820. if ($warehouse) {
  2821. $where .= " and type = '$warehouse'";
  2822. }
  2823. if ($timetk && $timetj) {
  2824. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2825. }
  2826. if ($orderinfo) {
  2827. $where .= " and orderinfo = '$orderinfo'";
  2828. }
  2829. if ($number) {
  2830. $where .= " and number = '$number'";
  2831. }
  2832. if ($express) {
  2833. $where .= " and express = '$express'";
  2834. }
  2835. if ($waybill) {
  2836. $where .= " and waybill = '$waybill'";
  2837. }
  2838. if ($library) {
  2839. $where .= " and library = '$library'";
  2840. }
  2841. if ($print) {
  2842. $where .= " and print = '$print'";
  2843. }
  2844. if ($libraryconfirm) {
  2845. $where .= " and libraryconfirm = '$libraryconfirm'";
  2846. }
  2847. if ($state) {
  2848. $where .= " and state = '$state'";
  2849. }
  2850. if ($shop) {
  2851. $where .= " and shop = '$shop'";
  2852. }
  2853. if ($country) {
  2854. $where .= " and country = '$country'";
  2855. }
  2856. if ($sfxh != '') {
  2857. $where .= " and sfxh = '$sfxh'";
  2858. }
  2859. if ($so) {
  2860. $where .= " and shipremarks like '%$so%'";
  2861. }
  2862. if ($source) {
  2863. if ($source == '2d') {
  2864. $where .= " and source >= '2'";
  2865. } else {
  2866. $where .= " and source = '$source'";
  2867. }
  2868. }
  2869. if (isset($_SESSION['api'])) {
  2870. foreach ($user as $value) {
  2871. $fgshop .= " shop = " . $value . " or";
  2872. }
  2873. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2874. }
  2875. if ($orderurl) {
  2876. $url = $this->orderurl->read($orderurl);
  2877. $where .= " and link like '%" . $url['url'] . "%'";
  2878. }
  2879. //数据排序
  2880. $order_str = "librarytime desc";
  2881. if (empty($page)) {
  2882. $start = 0;
  2883. $perpage = 1;
  2884. } else {
  2885. $start = ($page - 1) * $perpage;
  2886. }
  2887. //取得信息列表
  2888. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2889. //格式化数据
  2890. foreach ($info_list as $key => $value) {
  2891. $shop = $this->shop->read($value['shop']);
  2892. $info_list[$key]['shop'] = $shop['shopname'];
  2893. $express = $this->express->read($value['express']);
  2894. $info_list[$key]['express'] = $express['servicename'];
  2895. $warehouse = $this->warehouse->read($value['type']);
  2896. $info_list[$key]['type'] = $warehouse['title'];
  2897. if ($value['librarytime'] == '0') {
  2898. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2899. } else {
  2900. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2901. }
  2902. }
  2903. $total = $this->$sj->find_count($where);
  2904. $pagenum = ceil($total / $perpage);
  2905. $over = $total - ($start + $perpage);
  2906. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2907. echo json_encode($rows);
  2908. exit;
  2909. }
  2910. $this->data['express'] = $this->express->find_all();
  2911. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2912. $this->data['wlshop'] = $wlshop;
  2913. $user = $this->user->get_api($_SESSION['api']);
  2914. $powerid = $this->power->read($user['power']);
  2915. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2916. $pid = '';
  2917. foreach ($powertext as $v) {
  2918. $pid .= " id = " . $v . " or";
  2919. }
  2920. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2921. $this->data['fullorderexcel'] = $fullorderexcel;
  2922. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2923. $this->data['orderurl'] = $orderurl;
  2924. $this->_Template('whlabel_aoutorder', $this->data);
  2925. }
  2926. //速卖通出库订单
  2927. public function _soutorder()
  2928. {
  2929. if (isset($_SESSION['api'])) {
  2930. $user = $this->user->get_api($_SESSION['api']);
  2931. $usp = $user;
  2932. $fgshop = "";
  2933. $sid = "";
  2934. $user = explode('|', trim($user['shop'], '|'));
  2935. foreach ($user as $value) {
  2936. $sid .= " id = " . $value . " or";
  2937. }
  2938. }
  2939. $post = $this->input->post(NULL, TRUE);
  2940. if (isset($post['page'])) {
  2941. $page = $this->input->post('page', true);
  2942. $perpage = $this->input->post('perpage', true);
  2943. $warehouse = $this->input->post('warehouse', true);
  2944. $xztime = $this->input->post('xztime', true);
  2945. $timetk = $this->input->post('timetkk', true);
  2946. $timetj = $this->input->post('timetjj', true);
  2947. $shop = $this->input->post('shop', true);
  2948. $source = $this->input->post('source', true);
  2949. $orderinfo = $this->input->post('orderinfo', true);
  2950. $number = $this->input->post('number', true);
  2951. $express = $this->input->post('express', true);
  2952. $waybill = $this->input->post('waybill', true);
  2953. $library = $this->input->post('library', true);
  2954. $country = $this->input->post('country', true);
  2955. $sfxh = $this->input->post('sfxh', true);
  2956. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2957. $print = $this->input->post('print', true);
  2958. $state = $this->input->post('state', true);
  2959. $so = $this->input->post('so', true);
  2960. $timetk = strtotime($timetk);
  2961. $timetj = strtotime($timetj);
  2962. /**
  2963. $sj = $this->input->post('sj',true);
  2964. if($sj)
  2965. {
  2966. $sj = $this->input->post('sj',true);
  2967. }
  2968. else
  2969. {
  2970. $sj = "fullorder";
  2971. }
  2972. **/
  2973. $sj = "fullordersmt";
  2974. $where = "1=1";
  2975. if ($warehouse) {
  2976. $where .= " and type = '$warehouse'";
  2977. }
  2978. if ($timetk && $timetj) {
  2979. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2980. }
  2981. if ($orderinfo) {
  2982. $where .= " and orderinfo = '$orderinfo'";
  2983. }
  2984. if ($number) {
  2985. $where .= " and number = '$number'";
  2986. }
  2987. if ($express) {
  2988. $where .= " and express = '$express'";
  2989. }
  2990. if ($waybill) {
  2991. $where .= " and waybill = '$waybill'";
  2992. }
  2993. if ($library) {
  2994. $where .= " and library = '$library'";
  2995. }
  2996. if ($print) {
  2997. $where .= " and print = '$print'";
  2998. }
  2999. if ($libraryconfirm) {
  3000. $where .= " and libraryconfirm = '$libraryconfirm'";
  3001. }
  3002. if ($state) {
  3003. $where .= " and state = '$state'";
  3004. }
  3005. if ($shop) {
  3006. $where .= " and shop = '$shop'";
  3007. }
  3008. if ($sfxh != '') {
  3009. $where .= " and sfxh = '$sfxh'";
  3010. }
  3011. if ($so) {
  3012. $where .= " and shipremarks like '%$so%'";
  3013. }
  3014. if ($source) {
  3015. $where .= " and source = '$source'";
  3016. }
  3017. if ($country) {
  3018. $where .= " and country = '$country'";
  3019. } else {
  3020. if (isset($_SESSION['api'])) {
  3021. foreach ($user as $value) {
  3022. $fgshop .= " shop = " . $value . " or";
  3023. }
  3024. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3025. }
  3026. }
  3027. //数据排序
  3028. $order_str = "librarytime desc";
  3029. if (empty($page)) {
  3030. $start = 0;
  3031. $perpage = 1;
  3032. } else {
  3033. $start = ($page - 1) * $perpage;
  3034. }
  3035. //取得信息列表
  3036. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3037. //格式化数据
  3038. foreach ($info_list as $key => $value) {
  3039. $shop = $this->shop->read($value['shop']);
  3040. $info_list[$key]['shop'] = $shop['shopname'];
  3041. $express = $this->express->read($value['express']);
  3042. $info_list[$key]['express'] = $express['servicename'];
  3043. $warehouse = $this->warehouse->read($value['type']);
  3044. $info_list[$key]['type'] = $warehouse['title'];
  3045. if ($value['librarytime'] == '0') {
  3046. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3047. } else {
  3048. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3049. }
  3050. }
  3051. $total = $this->$sj->find_count($where);
  3052. $pagenum = ceil($total / $perpage);
  3053. $over = $total - ($start + $perpage);
  3054. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3055. echo json_encode($rows);
  3056. exit;
  3057. }
  3058. $this->data['express'] = $this->express->find_all();
  3059. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3060. $this->data['wlshop'] = $wlshop;
  3061. $user = $this->user->get_api($_SESSION['api']);
  3062. $powerid = $this->power->read($user['power']);
  3063. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3064. $pid = '';
  3065. foreach ($powertext as $v) {
  3066. $pid .= " id = " . $v . " or";
  3067. }
  3068. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3069. $this->data['fullorderexcel'] = $fullorderexcel;
  3070. $this->_Template('whlabel_soutorder', $this->data);
  3071. }
  3072. //订单退库
  3073. public function _retreat()
  3074. {
  3075. $post = $this->input->post(NULL, TRUE);
  3076. if (isset($post['page'])) {
  3077. $page = $this->input->post('page', true);
  3078. $perpage = $this->input->post('perpage', true);
  3079. $warehouse = $this->input->post('warehouse', true);
  3080. $timetk = $this->input->post('timetk', true);
  3081. $timetj = $this->input->post('timetj', true);
  3082. $shop = $this->input->post('shop', true);
  3083. $source = $this->input->post('source', true);
  3084. $state = $this->input->post('state', true);
  3085. $review = $this->input->post('review', true);
  3086. $state = $this->input->post('state', true);
  3087. $express = $this->input->post('express', true);
  3088. $orderinfo = $this->input->post('orderinfo', true);
  3089. $user = $this->input->post('user', true);
  3090. $name = $this->input->post('name', true);
  3091. $waybill = $this->input->post('waybill', true);
  3092. $timetk = strtotime($timetk);
  3093. $timetj = strtotime($timetj);
  3094. $where = "(state=206 or state=210) and mergeid = 0";
  3095. if ($warehouse) {
  3096. $where .= " and state = '$warehouse'";
  3097. }
  3098. if ($timetk && $timetj) {
  3099. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3100. }
  3101. if ($shop) {
  3102. $where .= " and shop = '$shop'";
  3103. }
  3104. if ($source) {
  3105. $where .= " and source = '$source'";
  3106. }
  3107. if ($state) {
  3108. $where .= " and state = '$state'";
  3109. }
  3110. if ($review) {
  3111. $where .= " and review = '$review'";
  3112. }
  3113. if ($state) {
  3114. $where .= " and state = '$state'";
  3115. }
  3116. if ($express) {
  3117. $where .= " and express = '$express'";
  3118. }
  3119. if ($orderinfo) {
  3120. $where .= " and orderinfo = '$orderinfo'";
  3121. }
  3122. if ($user) {
  3123. $where .= " and user = '$user'";
  3124. }
  3125. if ($name) {
  3126. $where .= " and name = '$name'";
  3127. }
  3128. if ($waybill) {
  3129. $where .= " and waybill = '$waybill'";
  3130. }
  3131. //数据排序
  3132. $order_str = "id desc";
  3133. if (empty($page)) {
  3134. $start = 0;
  3135. $perpage = 1;
  3136. } else {
  3137. $start = ($page - 1) * $perpage;
  3138. }
  3139. //取得信息列表
  3140. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3141. //格式化数据
  3142. foreach ($info_list as $key => $value) {
  3143. $shop = $this->shop->read($value['shop']);
  3144. $info_list[$key]['shop'] = $shop['shopname'];
  3145. $warehouse = $this->warehouse->read($value['warehouse']);
  3146. $info_list[$key]['warehouse'] = $warehouse['title'];
  3147. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3148. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3149. if ($value['waybill'] == 0) {
  3150. $info_list[$key]['waybill'] = "";
  3151. }
  3152. $express = $this->express->read($value['express']);
  3153. $info_list[$key]['express'] = $express['title'];
  3154. $typeclass = $this->typeclass->read($value['state']);
  3155. $info_list[$key]['state'] = $typeclass['title'];
  3156. }
  3157. $total = $this->fullorder->find_count($where);
  3158. $pagenum = ceil($total / $perpage);
  3159. $over = $total - ($start + $perpage);
  3160. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3161. echo json_encode($rows);
  3162. exit;
  3163. }
  3164. $this->data['express'] = $this->express->find_all();
  3165. $this->_Template('whlabel_retreat', $this->data);
  3166. }
  3167. //退库标签浏览
  3168. public function _retreatlk()
  3169. {
  3170. $post = $this->input->post(NULL, TRUE);
  3171. if (isset($post['page'])) {
  3172. $page = $this->input->post('page', true);
  3173. $perpage = $this->input->post('perpage', true);
  3174. $timetk = $this->input->post('timetk', true);
  3175. $timetj = $this->input->post('timetj', true);
  3176. $sku = $this->input->post('sku', true);
  3177. $warehouse = $this->input->post('warehouse', true);
  3178. $purchase = $this->input->post('purchase', true);
  3179. $orderinfo = $this->input->post('orderinfo', true);
  3180. $waybill = $this->input->post('waybill', true);
  3181. $category = $this->input->post('category', true);
  3182. $size = $this->input->post('size', true);
  3183. $grade = $this->input->post('grade', true);
  3184. $color = $this->input->post('color', true);
  3185. $lowe = $this->input->post('lowe', true);
  3186. $state = $this->input->post('state', true);
  3187. $timetk = strtotime($timetk);
  3188. $timetj = strtotime($timetj);
  3189. $where = "state=2";
  3190. if ($timetk && $timetj) {
  3191. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3192. }
  3193. if ($sku) {
  3194. $where .= " and sku = '$sku'";
  3195. }
  3196. if ($warehouse) {
  3197. $where .= " and warehouse = '$warehouse'";
  3198. }
  3199. if ($purchase) {
  3200. $where .= " and purchase = '$purchase'";
  3201. }
  3202. if ($orderinfo) {
  3203. $where .= " and orderinfo = '$orderinfo'";
  3204. }
  3205. if ($waybill) {
  3206. $where .= " and waybill = '$waybill'";
  3207. }
  3208. if ($category) {
  3209. $where .= " and features like '%-$category-%'";
  3210. }
  3211. if ($size) {
  3212. $where .= " and features like '%-$size-%'";
  3213. }
  3214. if ($grade) {
  3215. $where .= " and features like '%-$grade-%'";
  3216. }
  3217. if ($color) {
  3218. $where .= " and features like '%-$color-%'";
  3219. }
  3220. if ($lowe) {
  3221. $where .= " and features like '%-$lowe-%'";
  3222. }
  3223. //数据排序
  3224. $order_str = "time desc";
  3225. if (empty($page)) {
  3226. $start = 0;
  3227. $perpage = 1;
  3228. } else {
  3229. $start = ($page - 1) * $perpage;
  3230. }
  3231. //取得信息列表
  3232. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3233. foreach ($info_list as $key => $value) {
  3234. $warehouse = $this->warehouse->read($value['warehouse']);
  3235. $info_list[$key]['warehouse'] = $warehouse['title'];
  3236. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3237. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3238. $purchase = $this->purchase->read($value['purchase']);
  3239. $info_list[$key]['purchase'] = $purchase['title'];
  3240. if ($value['outk'] != 0) {
  3241. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3242. } else {
  3243. $info_list[$key]['outk'] = "";
  3244. }
  3245. if ($value['retreat'] != 0) {
  3246. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3247. } else {
  3248. $info_list[$key]['retreat'] = "";
  3249. }
  3250. if ($value['orderinfo'] == 0) {
  3251. $info_list[$key]['orderinfo'] = "";
  3252. }
  3253. if ($value['waybill'] == 0) {
  3254. $info_list[$key]['waybill'] = "";
  3255. }
  3256. }
  3257. $total = $this->whlabel->find_count($where);
  3258. $pagenum = ceil($total / $perpage);
  3259. $over = $total - ($start + $perpage);
  3260. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3261. echo json_encode($rows);
  3262. exit;
  3263. }
  3264. $this->_Template('whlabel_retreatlk', $this->data);
  3265. }
  3266. //更换标签及浏览
  3267. public function _change()
  3268. {
  3269. $post = $this->input->post(NULL, TRUE);
  3270. if (isset($post['page'])) {
  3271. $page = $this->input->post('page', true);
  3272. $perpage = $this->input->post('perpage', true);
  3273. $timetk = $this->input->post('timetk', true);
  3274. $timetj = $this->input->post('timetj', true);
  3275. $label = $this->input->post('label', true);
  3276. $oldlabel = $this->input->post('oldlabel', true);
  3277. $timetk = strtotime($timetk);
  3278. $timetj = strtotime($timetj);
  3279. $where = "state=10 ";
  3280. if ($timetk && $timetj) {
  3281. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3282. }
  3283. if ($label) {
  3284. $where .= " and label = '$label'";
  3285. }
  3286. if ($oldlabel) {
  3287. $where .= " and oldlabel = '$oldlabel'";
  3288. }
  3289. //数据排序
  3290. $order_str = "time asc";
  3291. if (empty($page)) {
  3292. $start = 0;
  3293. $perpage = 1;
  3294. } else {
  3295. $start = ($page - 1) * $perpage;
  3296. }
  3297. //取得信息列表
  3298. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3299. foreach ($info_list as $key => $value) {
  3300. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3301. }
  3302. $total = $this->whlabel->find_count($where);
  3303. $pagenum = ceil($total / $perpage);
  3304. $over = $total - ($start + $perpage);
  3305. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3306. echo json_encode($rows);
  3307. exit;
  3308. }
  3309. $this->_Template('whlabel_change', $this->data);
  3310. }
  3311. //产品标签
  3312. public function _cpbqdc()
  3313. {
  3314. if (isset($_GET['excel'])) {
  3315. $where = "1=1";
  3316. //数据排序
  3317. $order_str = "id desc";
  3318. if (empty($page)) {
  3319. $start = 0;
  3320. $perpage = 1;
  3321. } else {
  3322. $start = ($page - 1) * $perpage;
  3323. }
  3324. $warehouse = $this->input->get('warehouse', true);
  3325. $state = $this->input->get('state', true);
  3326. $timetk = $this->input->get('timetkk', true);
  3327. $timetj = $this->input->get('timetjj', true);
  3328. $timetk = strtotime($timetk);
  3329. $timetj = strtotime($timetj);
  3330. if ($warehouse) {
  3331. $where .= " and warehouse = '$warehouse'";
  3332. }
  3333. if ($state || $state == 0) {
  3334. $where .= " and state = '$state'";
  3335. }
  3336. if ($timetk && $timetj) {
  3337. $where .= " and time > '$timetk' and time < '$timetj'";
  3338. }
  3339. //取得信息列表
  3340. $info_list = $this->whlabel->find_all($where, '*');
  3341. $rows = array();
  3342. $list = array();
  3343. foreach ($info_list as $key => $value) {
  3344. $rows[$value['time']] = $value; //所有数据sku
  3345. }
  3346. foreach ($rows as $value) {
  3347. $warehouse = $this->warehouse->read($value['warehouse']);
  3348. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3349. $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);
  3350. }
  3351. $title = "产品标签统计表";
  3352. $titlename = "<table border=1>
  3353. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3354. <tr align='center'>
  3355. <td>仓库</td>
  3356. <td>SKU</td>
  3357. <td>产品</td>
  3358. <td>入库时间</td>
  3359. <td>操作时间</td>
  3360. <td>备注</td>
  3361. <td>数量</td>
  3362. </tr>
  3363. </table>";
  3364. $filename = $title . ".xls";
  3365. $tail = "";
  3366. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3367. }
  3368. }
  3369. //进销存导出
  3370. public function _exceljxc()
  3371. {
  3372. $classid = $this->classid->sku();
  3373. $pm = $classid;
  3374. $typeclass = array();
  3375. $tc = $this->typeclass->find_all();
  3376. foreach ($tc as $v) {
  3377. $typeclass[$v['id']] = $v;
  3378. }
  3379. $prc = array();
  3380. $purchase = $this->purchase->find_all();
  3381. foreach ($purchase as $k => $v) {
  3382. $prc[$v['id']] = $v['title'];
  3383. }
  3384. if (isset($_GET['excel'])) {
  3385. $where = "sku != 'Preset'";
  3386. //数据排序
  3387. $order_str = "id desc";
  3388. if (empty($page)) {
  3389. $start = 0;
  3390. $perpage = 1;
  3391. } else {
  3392. $start = ($page - 1) * $perpage;
  3393. }
  3394. $category = $this->input->get('category', true);
  3395. $warehouse = $this->input->get('warehouse', true);
  3396. $excelid = $this->input->get('sid', true);
  3397. if ($category) {
  3398. $where .= " and features like '%-$category-%'";
  3399. }
  3400. if ($warehouse) {
  3401. $where .= " and warehouse = '$warehouse'";
  3402. }
  3403. $xzid = '';
  3404. if ($excelid) {
  3405. $excelid = explode(',', trim($excelid, ','));
  3406. foreach ($excelid as $key => $value) {
  3407. $xzid .= " id = " . $value . " or";
  3408. }
  3409. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3410. }
  3411. //取得信息列表
  3412. /**
  3413. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3414. $rows = array();$list = array();
  3415. foreach ($info_list as $key=>$value)
  3416. {
  3417. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3418. }
  3419. **/
  3420. $wt = array();
  3421. $whlabel_type = $this->whlabel_type->find_all();
  3422. foreach ($whlabel_type as $v) {
  3423. $wt[$v['id']] = $v['title'];
  3424. }
  3425. $wh = array();
  3426. $w = $this->warehouse->find_all('1=1', 'id,title');
  3427. foreach ($w as $v) {
  3428. $wh[$v['id']] = $v['title'];
  3429. }
  3430. $list = array();
  3431. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3432. foreach ($rows as $key => $value) {
  3433. if (isset($wt[$value['type']])) {
  3434. $rows[$key]['type'] = $wt[$value['type']];
  3435. } else {
  3436. $rows[$key]['type'] = '未设置';
  3437. }
  3438. $bm = '03';
  3439. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3440. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3441. $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');
  3442. $details = array();
  3443. $cpid = array();
  3444. $cpbz = array();
  3445. $c = 0;
  3446. $g = 0;
  3447. $x = 0;
  3448. $t = 0;
  3449. $s = 0;
  3450. $q = 0;
  3451. foreach ($sd as $k => $v) {
  3452. if ($v['state'] == 0) {
  3453. $c++;
  3454. if ($v['cpid'] != 0) {
  3455. $cpid[$v['cpid']] = $v['cpid'];
  3456. }
  3457. if ($v['cpbz'] != '') {
  3458. $cpbz[$v['cpbz']] = $v['cpbz'];
  3459. }
  3460. }
  3461. if ($v['state'] != 9) {
  3462. $g++;
  3463. }
  3464. if ($v['state'] == 1) {
  3465. $x++;
  3466. }
  3467. if ($v['state'] == 2) {
  3468. $t++;
  3469. }
  3470. if ($v['state'] == 8) {
  3471. $s++;
  3472. }
  3473. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3474. $q++;
  3475. }
  3476. $details[$v['details']] = $v['details'];
  3477. }
  3478. $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'] . '"');
  3479. $rows[$key]['details'] = implode("、", $details);
  3480. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3481. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3482. $number = $value['number'];
  3483. $ftime = time() - 15 * 24 * 3600;
  3484. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3485. $rows[$key]['number'] = $g;
  3486. $rows[$key]['c'] = $c;
  3487. $rows[$key]['x'] = $x;
  3488. $rows[$key]['t'] = $t;
  3489. $rows[$key]['s'] = $s;
  3490. $rows[$key]['q'] = $q;
  3491. $rows[$key]['z'] = $z;
  3492. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3493. $features = explode('-', trim($features, '-'));
  3494. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3495. // $pm = $classid;
  3496. // $jm = $classid;
  3497. // foreach($features as $k=>$v)
  3498. // {
  3499. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3500. // {
  3501. // if($typeclass[$v]['bm'] != '')
  3502. // {
  3503. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3504. // }
  3505. // }
  3506. // if($v != 0)
  3507. // {
  3508. // if(!isset($typeclass[$v]))
  3509. // {
  3510. // continue;
  3511. // }
  3512. // if(isset($pm[$typeclass[$v]['classid']]))
  3513. // {
  3514. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3515. // {
  3516. // $tz = explode('|',$typeclass[$v]['zh']);
  3517. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3518. // }
  3519. // else
  3520. // {
  3521. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3522. // }
  3523. // }
  3524. // if(isset($jm[$typeclass[$v]['classid']]))
  3525. // {
  3526. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3527. // }
  3528. // }
  3529. // }
  3530. // $jm = array_filter($jm);
  3531. // $rows[$key]['bs'] = implode("-",$jm);
  3532. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3533. // $zh = implode(" ",$pm);
  3534. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3535. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3536. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3537. // $rows[$key]['features'] = $zh;
  3538. }
  3539. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3540. $final_list = [];
  3541. foreach ($list as $k => $v) {
  3542. if (empty($v['sku'])) {
  3543. continue;
  3544. }
  3545. $final_list[] = [
  3546. "warehouse" => $v["warehouse"],
  3547. "purchase" => $v["purchase"],
  3548. "details" => $v["details"],
  3549. "cpid" => $v["cpid"],
  3550. "dbcontent" => $v["dbcontent"],
  3551. "sku" => $v["sku"],
  3552. "cs" => $v["bm"],
  3553. "bs" => $v["jm"],
  3554. "title" => $v["title"],
  3555. "features" => $v["pm"],
  3556. "cpbz" => $v["cpbz"],
  3557. "sm" => $v["sm"],
  3558. "type" => $v["type"],
  3559. "number" => $v["number"],
  3560. "c" => $v["c"],
  3561. "x" => $v["x"],
  3562. "t" => $v["t"],
  3563. "s" => $v["s"],
  3564. "q" => $v["q"],
  3565. "z" => $v["z"],
  3566. "weight" => $v['weight'],
  3567. ];
  3568. }
  3569. $title = "总进销存统计表";
  3570. $titlename = "<table border=1>
  3571. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3572. <tr align='center'>
  3573. <td>仓库</td>
  3574. <td>供应商</td>
  3575. <td>位置</td>
  3576. <td>库存编码</td>
  3577. <td>类目</td>
  3578. <td>SKU</td>
  3579. <td>用友编码</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>重量(g)</td>
  3594. </tr>
  3595. </table>";
  3596. $filename = $title . ".xls";
  3597. $tail = "";
  3598. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3599. }
  3600. }
  3601. //入库导出
  3602. public function _excelr()
  3603. {
  3604. if (isset($_GET['excel'])) {
  3605. $category = $this->input->get('category', true);
  3606. $size = $this->input->get('size', true);
  3607. $grade = $this->input->get('grade', true);
  3608. $color = $this->input->get('color', true);
  3609. $lowe = $this->input->get('lowe', true);
  3610. $sku = $this->input->get('sku', true);
  3611. $warehouse = $this->input->get('warehouse', true);
  3612. $purchase = $this->input->get('purchase', true);
  3613. $ktime = $this->input->get('ktime', true);
  3614. $jtime = $this->input->get('jtime', true);
  3615. $ktime = strtotime($ktime);
  3616. $jtime = strtotime($jtime);
  3617. $where = "1=1";
  3618. $gj = "";
  3619. $ck = "";
  3620. if ($category) {
  3621. $where .= " and features like '%-$category-%'";
  3622. }
  3623. if ($size) {
  3624. $where .= " and features like '%-$size-%'";
  3625. }
  3626. if ($grade) {
  3627. $where .= " and features like '%-$grade-%'";
  3628. }
  3629. if ($color) {
  3630. $where .= " and features like '%-$color-%'";
  3631. }
  3632. if ($lowe) {
  3633. $where .= " and features like '%-$lowe-%'";
  3634. }
  3635. if ($warehouse) {
  3636. $where .= " and warehouse = '$warehouse'";
  3637. }
  3638. if ($purchase) {
  3639. $where .= " and purchase = '$purchase'";
  3640. }
  3641. if ($sku) {
  3642. $where .= " and sku = '$sku'";
  3643. }
  3644. if ($ktime && $jtime) {
  3645. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3646. }
  3647. //数据排序
  3648. $order_str = "id desc";
  3649. if (empty($page)) {
  3650. $start = 0;
  3651. $perpage = 1;
  3652. } else {
  3653. $start = ($page - 1) * $perpage;
  3654. }
  3655. $list = array();
  3656. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3657. foreach ($rows as $value) {
  3658. $ck = $this->warehouse->read($value['warehouse']);
  3659. $warehouse = $ck['title'];
  3660. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3661. $retreatwarehouse = $tkck['title'];
  3662. $gy = $this->purchase->read($value['purchase']);
  3663. $purchase = $gy['title'];
  3664. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3665. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3666. }
  3667. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3668. $titlename = "<table border=1>
  3669. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3670. <tr align='center'>
  3671. <td>仓库</td>
  3672. <td>SKU</td>
  3673. <td>产品</td>
  3674. <td>时间</td>
  3675. <td>数量</td>
  3676. </tr>
  3677. </table>";
  3678. $filename = $title . ".xls";
  3679. $tail = "";
  3680. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  3681. }
  3682. }
  3683. //出库、退库导出
  3684. public function _excelct()
  3685. {
  3686. $classid = $this->classid->sku();
  3687. $pm = $classid;
  3688. $typeclass = array();
  3689. $tc = $this->typeclass->find_all();
  3690. foreach ($tc as $v) {
  3691. $typeclass[$v['id']] = $v;
  3692. }
  3693. $prc = array();
  3694. $purchase = $this->purchase->find_all();
  3695. foreach ($purchase as $k => $v) {
  3696. $prc[$v['id']] = $v['title'];
  3697. }
  3698. if (isset($_GET['excel'])) {
  3699. $wh = array();
  3700. $w = $this->warehouse->find_all('1=1', 'id,title');
  3701. foreach ($w as $v) {
  3702. $wh[$v['id']] = $v['title'];
  3703. }
  3704. $type = $this->input->get('excel', true);
  3705. $category = $this->input->get('category', true);
  3706. $size = $this->input->get('size', true);
  3707. $grade = $this->input->get('grade', true);
  3708. $color = $this->input->get('color', true);
  3709. $lowe = $this->input->get('lowe', true);
  3710. $sku = $this->input->get('sku', true);
  3711. $title = $this->input->get('title', true);
  3712. $warehouse = $this->input->get('warehouse', true);
  3713. $purchase = $this->input->get('purchase', true);
  3714. $lacetype = $this->input->get('lacetype', true);
  3715. $haircap = $this->input->get('haircap', true);
  3716. $lacecolor = $this->input->get('lacecolor', true);
  3717. $density = $this->input->get('density', true);
  3718. $details = $this->input->get('details', true);
  3719. $state = $this->input->get('state', true);
  3720. $shop = $this->input->get('shop', true);
  3721. $hairnumber = $this->input->get('hairnumber', true);
  3722. $type_leixi = $this->input->get('type', true);
  3723. $cpbz = $this->input->get('cpbz', true);
  3724. $sm = $this->input->get('sm', true);
  3725. $sid = $this->input->get('sid', true);
  3726. $ktime = $this->input->get('ktime', true);
  3727. $jtime = $this->input->get('jtime', true);
  3728. $ktime = strtotime($ktime);
  3729. $jtime = strtotime($jtime);
  3730. //$where = " 1=1 ";
  3731. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3732. $where = " sku != '' ";
  3733. $gj = "";
  3734. $ck = "";
  3735. if ($category) {
  3736. $where .= " and features like '%-$category-%'";
  3737. }
  3738. if ($size) {
  3739. $where .= " and features like '%-$size-%'";
  3740. }
  3741. if ($grade) {
  3742. $where .= " and features like '%-$grade-%'";
  3743. }
  3744. if ($color) {
  3745. $where .= " and features like '%-$color-%'";
  3746. }
  3747. if ($lowe) {
  3748. $where .= " and features like '%-$lowe-%'";
  3749. }
  3750. if ($warehouse) {
  3751. $where .= " and warehouse = '$warehouse'";
  3752. }
  3753. if ($purchase) {
  3754. $where .= " and purchase = '$purchase'";
  3755. }
  3756. if ($state) {
  3757. $where .= " and state = '$state'";
  3758. }
  3759. if ($lacetype) {
  3760. $where .= " and features like '%-$lacetype-%'";
  3761. }
  3762. if ($lacecolor) {
  3763. $where .= " and features like '%-$lacecolor-%'";
  3764. }
  3765. if ($density) {
  3766. $where .= " and features like '%-$density-%'";
  3767. }
  3768. if ($haircap) {
  3769. $where .= " and features like '%-$haircap-%'";
  3770. }
  3771. if ($details) {
  3772. $where .= " and details = '$details'";
  3773. }
  3774. if ($shop) {
  3775. $where .= " and shop like '%$shop%'";
  3776. }
  3777. if ($title) {
  3778. $title = trim($title, ' ');
  3779. $title = trim($title, ' ');
  3780. $where .= " and title like '%$title%'";
  3781. }
  3782. if (!empty($hairnumber)) {
  3783. $where .= " and features like '%-128-%' ";
  3784. if ($hairnumber < 0) {
  3785. $class_list = $this->typeclass->find_all('classid = 43');
  3786. foreach ($class_list as $v) {
  3787. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3788. }
  3789. } else {
  3790. $where .= " and features like '%-$hairnumber-%'";
  3791. }
  3792. }
  3793. if ($type_leixi) {
  3794. $where .= " and type = '$type_leixi'";
  3795. }
  3796. if ($cpbz) {
  3797. $where .= " and cpbz like '%$cpbz%' ";
  3798. }
  3799. if ($sm) {
  3800. $where .= " and sm like '%$sm%' ";
  3801. }
  3802. if ($sku) {
  3803. $sku = trim($sku, ' ');
  3804. $sku = trim($sku, ' ');
  3805. $where .= " and sku like '%$sku%'";
  3806. }
  3807. if ($ktime && $jtime) {
  3808. if ($type == 1) {
  3809. $tl = '出库';
  3810. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3811. } else if ($type == 2) {
  3812. $tl = '退库';
  3813. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3814. } else if ($type == 3) {
  3815. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3816. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3817. } else if ($type == 4) {
  3818. $tl = '出库+零售';
  3819. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3820. } else if ($type == 5) {
  3821. $tl = '零售';
  3822. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3823. }
  3824. }
  3825. $sidwhere = '';
  3826. if ($sid) {
  3827. $sd = "";
  3828. $s = explode(',', trim($sid, ','));
  3829. foreach ($s as $value) {
  3830. $sd .= " id = " . $value . " or";
  3831. }
  3832. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3833. }
  3834. //数据排序
  3835. $order_str = "time desc";
  3836. if (empty($page)) {
  3837. $start = 0;
  3838. $perpage = 1;
  3839. } else {
  3840. $start = ($page - 1) * $perpage;
  3841. }
  3842. //取得信息列表
  3843. if ($type != 3 && $type != 5) {
  3844. if ($type == 1 || $type == 4) {
  3845. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3846. foreach ($info_list as $key => $value) {
  3847. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3848. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3849. $warehouse = $this->warehouse->read($value['warehouse']);
  3850. $info_list[$key]['warehouse'] = $warehouse['title'];
  3851. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3852. $features = explode('-', trim($features, '-'));
  3853. $pm = $classid;
  3854. foreach ($features as $k => $v) {
  3855. if ($v != 0) {
  3856. if (!isset($typeclass[$v])) {
  3857. continue;
  3858. }
  3859. if (isset($pm[$typeclass[$v]['classid']])) {
  3860. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3861. $tz = explode('|', $typeclass[$v]['zh']);
  3862. $pm[$typeclass[$v]['classid']] = $tz[0];
  3863. } else {
  3864. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3865. }
  3866. }
  3867. }
  3868. }
  3869. $zh = implode(" ", $pm);
  3870. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3871. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3872. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3873. $info_list[$key]['features'] = $zh;
  3874. }
  3875. $final_list = [];
  3876. foreach($info_list as $k=>$v){
  3877. $number = "";
  3878. if(!empty($v['orderinfo'])){
  3879. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3880. if(!empty($tmp_info['number'])){
  3881. $number = $tmp_info['number'];
  3882. }
  3883. }
  3884. $final_list[] = [
  3885. 'warehouse'=>$v['warehouse'],
  3886. 'purchase'=>$v['purchase'],
  3887. 'sku'=>$v['sku'],
  3888. 'title'=>$v['title'],
  3889. 'features'=>$v['features'],
  3890. 'label'=>$v['label'],
  3891. 'orderinfo'=>$v['orderinfo'],
  3892. 'number'=>$number,
  3893. 'waybill'=>$v['waybill'],
  3894. 'outk'=>$v['outk'],
  3895. ];
  3896. }
  3897. } else {
  3898. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3899. foreach ($info_list as $key => $value) {
  3900. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3901. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3902. $warehouse = $this->warehouse->read($value['warehouse']);
  3903. $info_list[$key]['warehouse'] = $warehouse['title'];
  3904. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3905. $features = explode('-', trim($features, '-'));
  3906. $pm = $classid;
  3907. foreach ($features as $k => $v) {
  3908. if ($v != 0) {
  3909. if (!isset($typeclass[$v])) {
  3910. continue;
  3911. }
  3912. if (isset($pm[$typeclass[$v]['classid']])) {
  3913. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3914. $tz = explode('|', $typeclass[$v]['zh']);
  3915. $pm[$typeclass[$v]['classid']] = $tz[0];
  3916. } else {
  3917. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3918. }
  3919. }
  3920. }
  3921. }
  3922. $zh = implode(" ", $pm);
  3923. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3924. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3925. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3926. $info_list[$key]['features'] = $zh;
  3927. }
  3928. $final_list = [];
  3929. foreach($info_list as $k=>$v){
  3930. $number = "";
  3931. if(!empty($v['orderinfo'])){
  3932. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3933. if(!empty($tmp_info['number'])){
  3934. $number = $tmp_info['number'];
  3935. }
  3936. }
  3937. $final_list[] = [
  3938. 'warehouse'=>$v['warehouse'],
  3939. 'purchase'=>$v['purchase'],
  3940. 'sku'=>$v['sku'],
  3941. 'title'=>$v['title'],
  3942. 'features'=>$v['features'],
  3943. 'label'=>$v['label'],
  3944. 'orderinfo'=>$v['orderinfo'],
  3945. 'number'=>$number,
  3946. 'waybill'=>$v['waybill'],
  3947. 'retreat'=>$v['retreat'],
  3948. ];
  3949. }
  3950. }
  3951. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3952. $titlename = "<table border=1>
  3953. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3954. <tr align='center'>
  3955. <td>仓库</td>
  3956. <td>供应商</td>
  3957. <td>SKU</td>
  3958. <td>商品名称</td>
  3959. <td>商品中文</td>
  3960. <td>标签</td>
  3961. <td>订单号</td>
  3962. <td>订单编码</td>
  3963. <td>运单号</td>
  3964. <td>" . $tl . "时间(中国时间)</td>
  3965. </tr>
  3966. </table>";
  3967. $filename = $title . ".xls";
  3968. $tail = "";
  3969. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3970. } else if ($type == 5) {
  3971. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3972. foreach ($info_list as $key => $value) {
  3973. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3974. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3975. $warehouse = $this->warehouse->read($value['warehouse']);
  3976. $info_list[$key]['warehouse'] = $warehouse['title'];
  3977. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3978. $features = explode('-', trim($features, '-'));
  3979. $pm = $classid;
  3980. foreach ($features as $k => $v) {
  3981. if ($v != 0) {
  3982. if (!isset($typeclass[$v])) {
  3983. continue;
  3984. }
  3985. if (isset($pm[$typeclass[$v]['classid']])) {
  3986. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3987. $tz = explode('|', $typeclass[$v]['zh']);
  3988. $pm[$typeclass[$v]['classid']] = $tz[0];
  3989. } else {
  3990. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3991. }
  3992. }
  3993. }
  3994. }
  3995. $zh = implode(" ", $pm);
  3996. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3997. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3998. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3999. $info_list[$key]['features'] = $zh;
  4000. }
  4001. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4002. $titlename = "<table border=1>
  4003. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4004. <tr align='center'>
  4005. <td>仓库</td>
  4006. <td>供应商</td>
  4007. <td>SKU</td>
  4008. <td>商品名称</td>
  4009. <td>商品中文</td>
  4010. <td>标签</td>
  4011. <td>" . $tl . "时间(中国时间)</td>
  4012. </tr>
  4013. </table>";
  4014. $filename = $title . ".xls";
  4015. $tail = "";
  4016. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4017. } else {
  4018. /**
  4019. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4020. $rows = array();$list = array();
  4021. foreach ($info_list as $key=>$value)
  4022. {
  4023. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4024. }
  4025. **/
  4026. $wh = array();
  4027. $w = $this->warehouse->find_all('1=1', 'id,title');
  4028. foreach ($w as $v) {
  4029. $wh[$v['id']] = $v['title'];
  4030. }
  4031. $wt = array();
  4032. $whlabel_type = $this->whlabel_type->find_all();
  4033. foreach ($whlabel_type as $v) {
  4034. $wt[$v['id']] = $v['title'];
  4035. }
  4036. $classid = $this->classid->sku();
  4037. $list = array();
  4038. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4039. foreach ($rows as $key => $value) {
  4040. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4041. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4042. $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');
  4043. $details = array();
  4044. $cpid = array();
  4045. $cpbz = array();
  4046. $c = 0;
  4047. $g = 0;
  4048. $x = 0;
  4049. $t = 0;
  4050. $s = 0;
  4051. $q = 0;
  4052. foreach ($sd as $k => $v) {
  4053. if ($v['state'] == 0) {
  4054. $c++;
  4055. }
  4056. if ($v['state'] != 9) {
  4057. $g++;
  4058. }
  4059. if ($v['outk'] > 1) {
  4060. $x++;
  4061. }
  4062. if ($v['retreat'] > 0) {
  4063. $t++;
  4064. }
  4065. if ($v['state'] == 8) {
  4066. $s++;
  4067. }
  4068. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4069. $q++;
  4070. }
  4071. $details[$v['details']] = $v['details'];
  4072. if ($v['cpid'] != 0) {
  4073. $cpid[$v['cpid']] = $v['cpid'];
  4074. }
  4075. if ($v['cpbz'] != '') {
  4076. $cpbz[$v['cpbz']] = $v['cpbz'];
  4077. }
  4078. }
  4079. if (isset($wt[$value['type']])) {
  4080. $rows[$key]['type'] = $wt[$value['type']];
  4081. } else {
  4082. $rows[$key]['type'] = '未设置';
  4083. }
  4084. $rows[$key]['details'] = implode("、", $details);
  4085. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4086. $ftime = time() - 15 * 24 * 3600;
  4087. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4088. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4089. $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);
  4090. $rows[$key]['c'] = $c;
  4091. $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);
  4092. $rows[$key]['t'] = $t;
  4093. $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'] . '"');
  4094. $rows[$key]['z'] = $z;
  4095. // $jm = $classid;
  4096. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4097. $features = explode('-', trim($features, '-'));
  4098. // $pm = $classid;
  4099. // foreach ($features as $k => $v) {
  4100. // if ($v != 0) {
  4101. // if (!isset($typeclass[$v])) {
  4102. // continue;
  4103. // }
  4104. // if (isset($pm[$typeclass[$v]['classid']])) {
  4105. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4106. // $tz = explode('|', $typeclass[$v]['zh']);
  4107. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4108. // } else {
  4109. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4110. // }
  4111. // if (isset($jm[$typeclass[$v]['classid']])) {
  4112. // if ($typeclass[$v]['jm']) {
  4113. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4114. // }
  4115. // }
  4116. // }
  4117. // }
  4118. // }
  4119. // $zh = implode(" ", $pm);
  4120. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4121. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4122. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4123. // $rows[$key]['features'] = $zh;
  4124. // $jm = array_filter($jm); //去除空值
  4125. // $jm = implode("-", $jm);
  4126. // $rows[$key]['jm'] = $jm;
  4127. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4128. }
  4129. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4130. // echo "<pre>";
  4131. // print_r($tmp_list);
  4132. // die;
  4133. $final_list =[];
  4134. foreach($tmp_list as $k=>$v){
  4135. $final_list[] = [
  4136. "warehouse"=>$v['warehouse'],
  4137. "purchase"=>$v['purchase'],
  4138. "details"=>trim($v['details'],'、'),
  4139. "cpid"=>$v['cpid'],
  4140. "sku"=>$v['sku'],
  4141. "title"=>$v['title'],
  4142. "features"=>$v['pm'],
  4143. "cpbz"=>$v['cpbz'],
  4144. "sm"=>$v['sm'],
  4145. "type"=>$v['type'],
  4146. "g"=>$v["g"],
  4147. "c"=>$v["c"],
  4148. "x"=>$v["x"],
  4149. "t"=>$v["t"],
  4150. "z"=>$v["z"],
  4151. "jm"=>$v["jm"],
  4152. "weight"=>$v["weight"],
  4153. "asd"=>$v["asd"],
  4154. ];
  4155. }
  4156. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4157. $titlename = "<table border=1>
  4158. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4159. <tr align='center'>
  4160. <td>仓库</td>
  4161. <td>供应商</td>
  4162. <td>位置</td>
  4163. <td>库存编码</td>
  4164. <td>SKU</td>
  4165. <td>商品名称</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. </tr>
  4179. </table>";
  4180. $filename = $title . ".xls";
  4181. $tail = "";
  4182. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4183. }
  4184. }
  4185. }
  4186. //出库+入库数据整合
  4187. public function _excelcr()
  4188. {
  4189. if (isset($_GET['excel'])) {
  4190. $type = $this->input->get('excel', true);
  4191. $category = $this->input->get('category', true);
  4192. $size = $this->input->get('size', true);
  4193. $grade = $this->input->get('grade', true);
  4194. $color = $this->input->get('color', true);
  4195. $lowe = $this->input->get('lowe', true);
  4196. $sku = $this->input->get('sku', true);
  4197. $warehouse = $this->input->get('warehouse', true);
  4198. $purchase = $this->input->get('purchase', true);
  4199. $state = $this->input->get('state', true);
  4200. $sid = $this->input->get('sid', true);
  4201. $ktime = $this->input->get('ktime', true);
  4202. $jtime = $this->input->get('jtime', true);
  4203. $ktime = strtotime($ktime);
  4204. $jtime = strtotime($jtime);
  4205. $where = "1=1";
  4206. $gj = "";
  4207. $ck = "";
  4208. if ($category) {
  4209. $where .= " and features like '%-$category-%'";
  4210. }
  4211. if ($size) {
  4212. $where .= " and features like '%-$size-%'";
  4213. }
  4214. if ($grade) {
  4215. $where .= " and features like '%-$grade-%'";
  4216. }
  4217. if ($color) {
  4218. $where .= " and features like '%-$color-%'";
  4219. }
  4220. if ($lowe) {
  4221. $where .= " and features like '%-$lowe-%'";
  4222. }
  4223. if ($warehouse) {
  4224. $where .= " and warehouse = '$warehouse'";
  4225. }
  4226. if ($purchase) {
  4227. $where .= " and purchase = '$purchase'";
  4228. }
  4229. if ($state) {
  4230. $where .= " and state = '$state'";
  4231. }
  4232. if ($sku) {
  4233. $where .= " and sku like '%$sku%'";
  4234. }
  4235. if ($ktime && $jtime) {
  4236. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4237. }
  4238. $sidwhere = '';
  4239. if ($sid) {
  4240. $sd = "";
  4241. $s = explode(',', trim($sid, ','));
  4242. foreach ($s as $value) {
  4243. $sd .= " id = " . $value . " or";
  4244. }
  4245. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4246. }
  4247. //取得信息列表
  4248. $timeread = $ktime;
  4249. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4250. $timelist = array();
  4251. for ($i = 0; $i < $timenum; $i++) {
  4252. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4253. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4254. }
  4255. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4256. //echo "<pre>";
  4257. //print_r($info_list);
  4258. //exit();
  4259. $rows = array();
  4260. $list = array();
  4261. foreach ($info_list as $key => $value) {
  4262. $thistime = $timelist;
  4263. if (isset($rows[strtolower($value['sku'])])) {
  4264. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4265. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4266. }
  4267. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4268. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4269. }
  4270. } else {
  4271. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4272. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4273. }
  4274. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4275. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4276. }
  4277. $rows[strtolower($value['sku'])] = $thistime;
  4278. }
  4279. }
  4280. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4281. <head>
  4282. <!--[if gte mso 9]><xml>
  4283. <x:ExcelWorkbook>
  4284. <x:ExcelWorksheets>
  4285. <x:ExcelWorksheet>
  4286. <x:Name>EXCEL</x:Name>
  4287. <x:WorksheetOptions>
  4288. <x:Print>
  4289. <x:ValidPrinterInfo />
  4290. </x:Print>
  4291. </x:WorksheetOptions>
  4292. </x:ExcelWorksheet>
  4293. </x:ExcelWorksheets>
  4294. </x:ExcelWorkbook>
  4295. </xml>
  4296. <![endif]-->
  4297. </head><body>";
  4298. $str .= "<table border=1><tr><td>SKU</td>";
  4299. foreach ($timelist as $k => $v) {
  4300. $str .= "<td>" . $k . "出库</td>";
  4301. $str .= "<td>" . $k . "入库</td>";
  4302. }
  4303. $str .= "</tr></table>";
  4304. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4305. foreach ($rows as $key => $val) {
  4306. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4307. foreach ($val as $k => $v) {
  4308. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4309. if ($val[$k]['r'] > 0) {
  4310. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4311. } else {
  4312. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4313. }
  4314. }
  4315. $str .= "</tr>";
  4316. }
  4317. $str .= "</table>";
  4318. $str .= "</body></html>";
  4319. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4320. header("Content-type: application/octet-stream");
  4321. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4322. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4323. header("Pragma: no-cache");
  4324. header("Expires: 0");
  4325. exit($str);
  4326. }
  4327. }
  4328. //数量调整模板导出
  4329. public function _presetout()
  4330. {
  4331. if (isset($_GET['excel'])) {
  4332. $where = "sku != 'Preset' and purchase != 0";
  4333. //数据排序
  4334. $order_str = "id desc";
  4335. if (empty($page)) {
  4336. $start = 0;
  4337. $perpage = 1;
  4338. } else {
  4339. $start = ($page - 1) * $perpage;
  4340. }
  4341. //取得信息列表
  4342. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4343. $rows = array();
  4344. $list = array();
  4345. foreach ($info_list as $value) {
  4346. $warehouse = $this->warehouse->read($value['warehouse']);
  4347. $number = $value['number'];
  4348. $ftime = time() - 15 * 24 * 3600;
  4349. $purchase = $this->purchase->read($value['purchase']);
  4350. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4351. }
  4352. $title = "库存模板";
  4353. $titlename = "<table border=1>
  4354. <tr align='center'>
  4355. <td>仓库</td>
  4356. <td>供应商编码</td>
  4357. <td>SKU</td>
  4358. <td>增减数量(正数或负数)</td>
  4359. <td>增减备注</td>
  4360. <td>扣减方式:0减少库存1删除库存</td>
  4361. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4362. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4363. </tr>
  4364. </table>";
  4365. $filename = $title . ".xls";
  4366. $tail = "";
  4367. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4368. }
  4369. }
  4370. //数量调整模板导入
  4371. public function _presetedit()
  4372. {
  4373. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4374. $config['upload_path'] = '.' . $dir;
  4375. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4376. $config['allowed_types'] = 'xls|xlsx|csv';
  4377. $config['max_size'] = 10240;
  4378. $this->load->library('upload', $config);
  4379. $this->upload->initialize($config);
  4380. if ($this->upload->do_upload('userfile')) {
  4381. $full_path = $dir . $this->upload->data('file_name');
  4382. $fileName = '.' . $full_path;
  4383. if (!file_exists($fileName)) {
  4384. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4385. exit;
  4386. } else {
  4387. require_once "./data/excel/PHPExcel/IOFactory.php";
  4388. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4389. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4390. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4391. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4392. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4393. ++$column; //如果列数大于26行
  4394. $list = array();
  4395. for ($i = 2; $i <= $row; $i++) // 行数循环
  4396. {
  4397. $data = array();
  4398. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4399. {
  4400. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4401. }
  4402. $list[] = $data;
  4403. }
  4404. }
  4405. $i = 0;
  4406. $j = 0;
  4407. $ed = array();
  4408. foreach ($list as $key => $value) {
  4409. $time = time();
  4410. if ($value['0'] == "") {
  4411. continue;
  4412. }
  4413. $warehouse = $this->warehouse->get_title($value['0']);
  4414. $purchase = $this->purchase->get_bm($value['1']);
  4415. $sku = $value['2'];
  4416. $num = $value['3']; //调整数量
  4417. $text = $value['4']; //扣减说明
  4418. $type = $value['5']; //调整方式0扣减1删除
  4419. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4420. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4421. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4422. if (!$purchase) //如果没有这个SKU
  4423. {
  4424. $ed[] = array($purchase . '-不存在此供应商编码');
  4425. $j++;
  4426. continue;
  4427. }
  4428. if (!$d) //如果没有这个SKU
  4429. {
  4430. $ed[] = array($sku . '-库存中不存在此SKU');
  4431. $j++;
  4432. continue;
  4433. }
  4434. if (!isset($warehouse['id'])) {
  4435. $ed[] = array($sku . '-仓库名错误!');
  4436. $j++;
  4437. continue;
  4438. }
  4439. if ($type != '0' && $type != '1') {
  4440. $ed[] = array($sku . '-扣减方式填写错误!');
  4441. $j++;
  4442. continue;
  4443. }
  4444. if ($num < 0) //扣减库存
  4445. {
  4446. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4447. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4448. $j++;
  4449. continue;
  4450. }
  4451. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4452. if (count($data) < abs($num)) {
  4453. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4454. $j++;
  4455. continue;
  4456. }
  4457. if ($type == 0) //如果扣减方式为 扣减库存
  4458. {
  4459. for ($i = 0; $i < abs($num); $i++) {
  4460. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4461. }
  4462. } else if ($type == 1) {
  4463. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4464. if (count($zt) > 0) {
  4465. $ed[] = array($sku . '-有在途库存无法删除!');
  4466. $j++;
  4467. continue;
  4468. }
  4469. for ($i = 0; $i < abs($num); $i++) {
  4470. $this->whlabel->remove($data[$i]['id']);
  4471. }
  4472. }
  4473. } else if ($num > 0) //增加库存
  4474. {
  4475. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4476. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4477. $j++;
  4478. continue;
  4479. }
  4480. $post['sku'] = $d['sku'];
  4481. $post['shop'] = $d['shop'];
  4482. $post['warehouse'] = $warehouse['id'];
  4483. $post['purchase'] = $purchase['id'];
  4484. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4485. $post['state'] = 0;
  4486. $post['title'] = $d['title'];
  4487. $post['number'] = $d['number'];
  4488. $post['features'] = $d['features'];
  4489. $post['enter'] = $time;
  4490. $post['time'] = $time; //操作时间
  4491. $post['rktype'] = $rktype;
  4492. for ($i = 0; $i < $num; $i++) {
  4493. $post['label'] = time() . rand(100, 999) . $i;
  4494. $this->whlabel->insert($post);
  4495. }
  4496. }
  4497. sleep(1); //防止入库时间一样,需要延迟1秒
  4498. }
  4499. if ($j > 0) {
  4500. $tt = date('Ymd', time());
  4501. $title = '库存导入错误信息-' . $tt;
  4502. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4503. $tail = "\n";
  4504. $filename = $title . ".xls";
  4505. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4506. $dir = '/data/excel/' . $time . '/';
  4507. $file_name = 'error_' . $time . rand(1000, 9999);
  4508. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4509. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4510. fwrite($myfile, $ecl);
  4511. fclose($myfile);
  4512. $error = $dir . $file_name . '.xls';
  4513. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4514. exit;
  4515. } else {
  4516. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4517. exit;
  4518. }
  4519. }
  4520. }
  4521. public function _presetedittwo(){
  4522. $data = $this->input->post(NULL, TRUE);
  4523. if(empty($list)){
  4524. $raw_data = $this->input->raw_input_stream;
  4525. // 解码 JSON
  4526. $data = json_decode($raw_data, true);
  4527. }
  4528. if(empty($data)){
  4529. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4530. }
  4531. $list = [];
  4532. if(isset($data['list'])){
  4533. $list = $data['list'];
  4534. }
  4535. $i = 0;
  4536. $j = 0;
  4537. $ed = array();
  4538. foreach ($list as $key => $value) {
  4539. $time = time();
  4540. if ($value['0'] == "") {
  4541. continue;
  4542. }
  4543. $warehouse = $this->warehouse->get_title($value['0']);
  4544. $purchase = $this->purchase->get_bm($value['1']);
  4545. $sku = $value['2'];
  4546. $num = $value['3']; //调整数量
  4547. $text = $value['4']; //扣减说明
  4548. $type = $value['5']; //调整方式0扣减1删除
  4549. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4550. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4551. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4552. if (!$purchase) //如果没有这个SKU
  4553. {
  4554. $ed[] = array($value['1'] . '-不存在此供应商编码');
  4555. $j++;
  4556. continue;
  4557. }
  4558. if (!$d) //如果没有这个SKU
  4559. {
  4560. $ed[] = array($sku . '-库存中不存在此SKU');
  4561. $j++;
  4562. continue;
  4563. }
  4564. if (!isset($warehouse['id'])) {
  4565. $ed[] = array($sku . '-仓库名错误!');
  4566. $j++;
  4567. continue;
  4568. }
  4569. if ($type != '0' && $type != '1') {
  4570. $ed[] = array($sku . '-扣减方式填写错误!');
  4571. $j++;
  4572. continue;
  4573. }
  4574. if ($num < 0) //扣减库存
  4575. {
  4576. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4577. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4578. $j++;
  4579. continue;
  4580. }
  4581. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4582. if (count($data) < abs($num)) {
  4583. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4584. $j++;
  4585. continue;
  4586. }
  4587. if ($type == 0) //如果扣减方式为 扣减库存
  4588. {
  4589. for ($i = 0; $i < abs($num); $i++) {
  4590. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4591. }
  4592. } else if ($type == 1) {
  4593. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4594. if (count($zt) > 0) {
  4595. $ed[] = array($sku . '-有在途库存无法删除!');
  4596. $j++;
  4597. continue;
  4598. }
  4599. for ($i = 0; $i < abs($num); $i++) {
  4600. $this->whlabel->remove($data[$i]['id']);
  4601. }
  4602. }
  4603. } else if ($num > 0) //增加库存
  4604. {
  4605. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4606. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4607. $j++;
  4608. continue;
  4609. }
  4610. $post['sku'] = $d['sku'];
  4611. $post['shop'] = $d['shop'];
  4612. $post['warehouse'] = $warehouse['id'];
  4613. $post['purchase'] = $purchase['id'];
  4614. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4615. $post['state'] = 0;
  4616. $post['title'] = $d['title'];
  4617. $post['number'] = $d['number'];
  4618. $post['features'] = $d['features'];
  4619. $post['enter'] = $time;
  4620. $post['time'] = $time; //操作时间
  4621. $post['rktype'] = $rktype;
  4622. $post['sku_master_id'] = $d['sku_master_id'];
  4623. $post['sku_shop_id'] = $d['sku_shop_id'];
  4624. for ($i = 0; $i < $num; $i++) {
  4625. $post['label'] = time() . rand(100, 999) . $i;
  4626. $this->whlabel->insert($post);
  4627. }
  4628. }
  4629. sleep(1); //防止入库时间一样,需要延迟1秒
  4630. }
  4631. if ($j > 0) {
  4632. $tt = date('Ymd', time());
  4633. $title = '库存导入错误信息-' . $tt;
  4634. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4635. $tail = "\n";
  4636. $filename = $title . ".xls";
  4637. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4638. $dir = '/data/excel/' . $time . '/';
  4639. $file_name = 'error_' . $time . rand(1000, 9999);
  4640. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4641. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4642. fwrite($myfile, $ecl);
  4643. fclose($myfile);
  4644. $error = $dir . $file_name . '.xls';
  4645. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4646. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4647. exit;
  4648. } else {
  4649. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4650. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4651. exit;
  4652. }
  4653. }
  4654. //笛卡儿积
  4655. function cp($ps, $sets, $list)
  4656. {
  4657. $result = array();
  4658. $j = 0;
  4659. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4660. if ($i == 0) {
  4661. $result = $sets[$i];
  4662. }
  4663. $tmp = array();
  4664. foreach ($result as $res) {
  4665. foreach ($sets[$i + 1] as $set) {
  4666. $tmp[] = $res . ',' . $set;
  4667. }
  4668. }
  4669. $result = $tmp;
  4670. }
  4671. $this->db->trans_begin();
  4672. foreach ($result as $v) {
  4673. $post = array();
  4674. $title = "";
  4675. $num = "";
  4676. $data = explode(',', $v);
  4677. for ($i = 0; $i < count($list); $i++) {
  4678. $post[$list[$i]] = $data[$i];
  4679. $typeclass = $this->typeclass->read($data[$i]);
  4680. $title = $title . $typeclass['title'] . " ";
  4681. if ($data[$i] != 0) {
  4682. $num .= $data[$i]; //所有数据ID拼接
  4683. }
  4684. }
  4685. foreach ($ps as $kp => $vp) {
  4686. $post[$kp] = $vp;
  4687. }
  4688. $post['number'] = $num;
  4689. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4690. if ($info_list) {
  4691. $j++;
  4692. } else {
  4693. $skunum = $this->whlabel->find_count();
  4694. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4695. $post['title'] = rtrim($title, ' ');
  4696. $this->whlabel->insert($post);
  4697. }
  4698. }
  4699. if ($this->db->trans_status() === FALSE) {
  4700. $this->db->trans_commit();
  4701. return NULL;
  4702. } else {
  4703. $this->db->trans_commit();
  4704. return $j;
  4705. }
  4706. }
  4707. public function _kj($arg_array)
  4708. {
  4709. if (isset($_POST['sku'])) {
  4710. $time = time();
  4711. $sku = $this->input->post('sku', true);
  4712. $warehouse = $this->input->post('warehouse', true);
  4713. $num = $this->input->post('num', true);
  4714. $text = $this->input->post('text', true);
  4715. $purchase = $this->input->post('purchase', true);
  4716. $cktype = $this->input->post('cktype', true);
  4717. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4718. if ($cktype != 1 && $text == '') {
  4719. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4720. exit;
  4721. }
  4722. if ($num > count($order)) {
  4723. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4724. exit;
  4725. } else {
  4726. for ($i = 0; $i < $num; $i++) {
  4727. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4728. }
  4729. }
  4730. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4731. exit;
  4732. }
  4733. $uid = $this->whlabel->read($arg_array[0]);
  4734. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4735. $this->data['data'] = $uid;
  4736. $this->_Template('whlabel_kj', $this->data);
  4737. }
  4738. public function _summary($arg_array)
  4739. {
  4740. $prc = array();
  4741. $purchase = $this->purchase->find_all();
  4742. foreach ($purchase as $k => $v) {
  4743. $prc[$v['id']] = $v['title'];
  4744. }
  4745. if (isset($_GET['excel'])) {
  4746. $ktime = $this->input->get('ktime', true);
  4747. $jtime = $this->input->get('jtime', true);
  4748. $ktime = strtotime($ktime);
  4749. $jtime = strtotime($jtime);
  4750. $where = "1=1";
  4751. if ($ktime && $jtime) {
  4752. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4753. }
  4754. //数据排序
  4755. $order_str = "time desc";
  4756. if (empty($page)) {
  4757. $start = 0;
  4758. $perpage = 1;
  4759. } else {
  4760. $start = ($page - 1) * $perpage;
  4761. }
  4762. //取得信息列表
  4763. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4764. foreach ($info_list as $key => $value) {
  4765. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4766. $warehouse = $this->warehouse->read($value['warehouse']);
  4767. $info_list[$key]['warehouse'] = $warehouse['title'];
  4768. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4769. $details = array();
  4770. $cpid = array();
  4771. foreach ($x as $k => $v) {
  4772. if ($v['details'] != '') {
  4773. $details[$v['details']] = $v['details'];
  4774. }
  4775. if ($v['cpid'] != 0) {
  4776. $cpid[$v['cpid']] = $v['cpid'];
  4777. }
  4778. }
  4779. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4780. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4781. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4782. $info_list[$key]['s'] = $s;
  4783. $info_list[$key]['x'] = count($x);
  4784. }
  4785. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4786. $titlename = "<table border=1>
  4787. <tr align='center'>
  4788. <td>仓库</td>
  4789. <td>供应商</td>
  4790. <td>出库位置</td>
  4791. <td>出库编码</td>
  4792. <td>SKU</td>
  4793. <td>产品名</td>
  4794. <td>总剩余库存</td>
  4795. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4796. </tr>
  4797. </table>";
  4798. $filename = $title . ".xls";
  4799. $tail = "";
  4800. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4801. }
  4802. }
  4803. //usps发货清单
  4804. public function _manifest()
  4805. {
  4806. if (isset($_POST['manifest'])) {
  4807. $wltext = $this->input->post('wltext', true);
  4808. $time = time() - 16 * 3600;
  4809. $ptime = strtotime(date('Y-m-d', $time));
  4810. $waybill = array();
  4811. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4812. foreach ($fullorder as $v) {
  4813. $waybill[$v['waybill']] = $v['waybill'];
  4814. }
  4815. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4816. foreach ($fullordersmt as $v) {
  4817. $waybill[$v['waybill']] = $v['waybill'];
  4818. }
  4819. $wltext = explode(';', $wltext);
  4820. foreach ($wltext as $v) {
  4821. if (isset($waybill[$v])) {
  4822. unset($waybill[$v]);
  4823. }
  4824. }
  4825. $data = $this->usps->get_manifest($waybill);
  4826. if (isset($data['Description'])) {
  4827. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4828. exit;
  4829. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4830. $bctime = date('Ymd', time());
  4831. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4832. echo json_encode(array('msg' => $pdf, 'success' => true));
  4833. exit;
  4834. } else {
  4835. echo json_encode(array('msg' => $data, 'success' => false));
  4836. exit;
  4837. }
  4838. }
  4839. }
  4840. public function _pdf($pdf, $title, $bctime)
  4841. {
  4842. $pdf_path = './data/pdf/' . $bctime . '/';
  4843. $file_base64 = $pdf;
  4844. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4845. $file_base64 = base64_decode($file_base64);
  4846. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4847. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4848. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4849. }
  4850. /**
  4851. *
  4852. *
  4853. *
  4854. 进销存占单异常索引
  4855. *
  4856. *
  4857. *
  4858. **/
  4859. public function _abnormal()
  4860. {
  4861. $post = $this->input->post(NULL, TRUE);
  4862. if (isset($post['page'])) {
  4863. $page = $this->input->post('page', true);
  4864. $perpage = $this->input->post('perpage', true);
  4865. $sku = $this->input->post('sku', true);
  4866. $where = "1=1";
  4867. //数据排序
  4868. $order_str = "id desc";
  4869. if (empty($page)) {
  4870. $start = 0;
  4871. $perpage = 1;
  4872. } else {
  4873. $start = ($page - 1) * $perpage;
  4874. }
  4875. //取得信息列表
  4876. $info_list = $this->whlabel->find_all($where, '*');
  4877. $rows = array();
  4878. $list = array();
  4879. foreach ($info_list as $key => $value) {
  4880. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4881. }
  4882. foreach ($rows as $value) {
  4883. $warehouse = $this->warehouse->read($value['warehouse']);
  4884. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4885. $number = $value['number'];
  4886. $ftime = time() - 15 * 24 * 3600;
  4887. if ($value['shop'] != '') {
  4888. $shop = $value['shop'];
  4889. $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');
  4890. $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');
  4891. $order = array_merge($orderdlz, $ordersmt);
  4892. $od = 0;
  4893. $a = '';
  4894. $orid = '';
  4895. foreach ($order as $v) {
  4896. $or = explode('|', ltrim($v['whlabel'], '|'));
  4897. for ($i = 0; $i < count($or); $i++) {
  4898. $orod = explode('-', $or[$i]);
  4899. if ($orod[0] == $number) {
  4900. $od += $orod[1];
  4901. }
  4902. }
  4903. $orid .= $v['number'] . '-';
  4904. }
  4905. } else {
  4906. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4907. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4908. $order = array_merge($orderdlz, $ordersmt);
  4909. $od = 0;
  4910. $a = '';
  4911. $orid = '';
  4912. $qt = array();
  4913. foreach ($order as $v) {
  4914. $or = explode('|', ltrim($v['whlabel'], '|'));
  4915. for ($i = 0; $i < count($or); $i++) {
  4916. $orod = explode('-', $or[$i]);
  4917. if ($orod[0] == $number) {
  4918. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4919. if ($czzs > 0) {
  4920. if (isset($qt[$v['shop']])) {
  4921. if ($qt[$v['shop']] < $orod[1]) {
  4922. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4923. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4924. } else {
  4925. $qt[$v['shop']] -= $orod[1];
  4926. }
  4927. } else {
  4928. $qt[$v['shop']] = $czzs;
  4929. }
  4930. } else {
  4931. $od += $orod[1];
  4932. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4933. }
  4934. }
  4935. }
  4936. }
  4937. }
  4938. $z = $od . '(' . $orid . ')'; //查看订单号
  4939. //$z = $od;
  4940. if ($od > $c) {
  4941. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4942. }
  4943. }
  4944. $listdata = array_slice($list, $start, $perpage);
  4945. $total = count($list);
  4946. $pagenum = ceil($total / $perpage);
  4947. $over = $total - ($start + $perpage);
  4948. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4949. echo json_encode($rows);
  4950. exit;
  4951. }
  4952. $this->_Template('whlabel_abnormal', $this->data);
  4953. }
  4954. /**
  4955. *
  4956. *
  4957. *
  4958. 进销存占单异常索引
  4959. *
  4960. *
  4961. *
  4962. **/
  4963. public function _error()
  4964. {
  4965. $post = $this->input->post(NULL, TRUE);
  4966. if (isset($post['page'])) {
  4967. $page = $this->input->post('page', true);
  4968. $perpage = $this->input->post('perpage', true);
  4969. $sku = $this->input->post('sku', true);
  4970. $warehouse = $this->input->post('warehouse', true);
  4971. $ktime = $this->input->post('ktime', true);
  4972. $jtime = $this->input->post('jtime', true);
  4973. $ktime = strtotime($ktime);
  4974. $jtime = strtotime($jtime);
  4975. $where = "sku != 'Preset'";
  4976. $gj = '';
  4977. if ($sku) {
  4978. $where .= " and sku like '%$sku%'";
  4979. } else {
  4980. if ($ktime && $jtime) {
  4981. $gj = " and time > '$ktime' and time < '$jtime'";
  4982. }
  4983. }
  4984. if ($warehouse) {
  4985. $where .= " and warehouse = '$warehouse'";
  4986. }
  4987. //数据排序
  4988. $order_str = "id desc";
  4989. if (empty($page)) {
  4990. $start = 0;
  4991. $perpage = 1;
  4992. } else {
  4993. $start = ($page - 1) * $perpage;
  4994. }
  4995. //取得信息列表
  4996. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4997. $rows = array();
  4998. $list = array();
  4999. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5000. // foreach ($info_list as $value)
  5001. // {
  5002. // $warehouse = $this->warehouse->read($value['warehouse']);
  5003. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5004. // $number = $value['number'];$ftime = time()-15*24*3600;
  5005. // if($c < 1)
  5006. // {
  5007. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5008. // }
  5009. // }
  5010. $warehouse_list = $this->warehouse->find_all();
  5011. $warehouse_list = array_column($warehouse_list, null, 'id');
  5012. foreach ($info_list as $value) {
  5013. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5014. 'title' => "",
  5015. ];
  5016. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5017. $number = $value['number'];
  5018. $ftime = time() - 15 * 24 * 3600;
  5019. if ($c < 1) {
  5020. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5021. }
  5022. }
  5023. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5024. // $query = $this->db->query($sql);
  5025. // $info_list = $query->result_array();
  5026. // $sql_two = "select title,id from crowd_warehouse";
  5027. // $query_two = $this->db->query($sql_two);
  5028. // $warehouse_list = $query_two->result_array();
  5029. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5030. // foreach ($info_list as $value)
  5031. // {
  5032. // if(isset($warehouse_arr[$value['warehouse']])){
  5033. // $warehouse = $warehouse_arr[$value['warehouse']];
  5034. // }else{
  5035. // $warehouse = [
  5036. // 'id'=>0,
  5037. // 'title'=>"异常",
  5038. // ];
  5039. // }
  5040. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5041. // $number = $value['number'];$ftime = time()-15*24*3600;
  5042. // if($c < 1)
  5043. // {
  5044. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5045. // }
  5046. // }
  5047. $listdata = array_slice($list, $start, $perpage);
  5048. $total = count($list);
  5049. $pagenum = ceil($total / $perpage);
  5050. $over = $total - ($start + $perpage);
  5051. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5052. echo json_encode($rows);
  5053. exit;
  5054. }
  5055. if (isset($post['s'])) {
  5056. $id_arr = $this->input->post('s');
  5057. $id_arr = explode(',', trim($id_arr, ','));
  5058. if (!$id_arr) {
  5059. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5060. exit;
  5061. }
  5062. //循环删除记录
  5063. foreach ($id_arr as $v) {
  5064. $dd = $this->whlabel->read($v);
  5065. if (!isset($dd['id'])) {
  5066. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5067. exit;
  5068. }
  5069. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5070. if (isset($zt[0])) {
  5071. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5072. exit;
  5073. }
  5074. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5075. foreach ($deldd as $vv) {
  5076. $this->whlabel->remove($vv['id']);
  5077. }
  5078. }
  5079. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5080. exit;
  5081. }
  5082. $this->_Template('whlabel_error', $this->data);
  5083. }
  5084. public function _errorexcel()
  5085. {
  5086. $post = $this->input->post(NULL, TRUE);
  5087. if (isset($_GET['page'])) {
  5088. $page = $this->input->get('page', true);
  5089. $perpage = $this->input->get('perpage', true);
  5090. $sku = $this->input->get('sku', true);
  5091. $warehouse = $this->input->get('warehouse', true);
  5092. $ktime = $this->input->get('ktime', true);
  5093. $jtime = $this->input->get('jtime', true);
  5094. $ktime = strtotime($ktime);
  5095. $jtime = strtotime($jtime);
  5096. $where = "sku != 'Preset'";
  5097. $gj = '';
  5098. if ($sku) {
  5099. $where .= " and sku like '%$sku%'";
  5100. } else {
  5101. if ($ktime && $jtime) {
  5102. $gj = " and time > '$ktime' and time < '$jtime'";
  5103. }
  5104. }
  5105. if ($warehouse) {
  5106. $where .= " and warehouse = '$warehouse'";
  5107. }
  5108. //数据排序
  5109. $order_str = "id desc";
  5110. if (empty($page)) {
  5111. $start = 0;
  5112. $perpage = 1;
  5113. } else {
  5114. $start = ($page - 1) * $perpage;
  5115. }
  5116. //取得信息列表
  5117. $rows = array();
  5118. $list = array();
  5119. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5120. foreach ($info_list as $value) {
  5121. $warehouse = $this->warehouse->read($value['warehouse']);
  5122. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5123. $number = $value['number'];
  5124. $ftime = time() - 15 * 24 * 3600;
  5125. if ($c < 1) {
  5126. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5127. }
  5128. }
  5129. $title = "0库存汇总";
  5130. $titlename = "<table border=1>
  5131. <tr align='center'>
  5132. <td>仓库</td>
  5133. <td>SKU</td>
  5134. <td>产品</td>
  5135. <td>当前库存</td>
  5136. </tr>
  5137. </table>";
  5138. $filename = $title . ".xls";
  5139. $tail = "";
  5140. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5141. }
  5142. }
  5143. /**
  5144. *
  5145. *
  5146. * 占单
  5147. *
  5148. *
  5149. **/
  5150. public function _kcyz()
  5151. {
  5152. $post = $this->input->post(NULL, TRUE);
  5153. if (isset($post['warehouse'])) {
  5154. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5155. exit; //不再使用
  5156. $warehouse = $this->input->post('warehouse', true);
  5157. $whlabel = $this->input->post('whlabel', true);
  5158. $id = $this->input->post('id', true);
  5159. $shop = $this->input->post('shop', true);
  5160. $number = $this->input->post('number', true);
  5161. if (!$whlabel || $whlabel == '|') {
  5162. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5163. exit;
  5164. }
  5165. $pp = explode('|', trim($whlabel, '|'));
  5166. $x = 0;
  5167. $save = array();
  5168. foreach ($pp as $va) {
  5169. $num = explode('-', $va);
  5170. if ($number) {
  5171. $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 = '')"); //通用
  5172. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5173. } else {
  5174. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5175. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5176. }
  5177. $x++;
  5178. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5179. $save[] = $x - 1;
  5180. continue; //提前先加X不然出错,所以要减1
  5181. }
  5182. }
  5183. if (isset($save[0])) {
  5184. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5185. exit;
  5186. } else {
  5187. echo json_encode(array('success' => true));
  5188. exit;
  5189. }
  5190. }
  5191. }
  5192. public function _db()
  5193. {
  5194. $post = $this->input->post(NULL, TRUE);
  5195. if (isset($post['page'])) {
  5196. $page = $this->input->post('page', true);
  5197. $perpage = $this->input->post('perpage', true);
  5198. $sku = $this->input->post('sku', true);
  5199. $number = $this->input->post('number', true);
  5200. $warehouse = $this->input->post('warehouse', true);
  5201. $purchase = $this->input->post('purchase', true);
  5202. $orderinfo = $this->input->post('orderinfo', true);
  5203. $waybill = $this->input->post('waybill', true);
  5204. $category = $this->input->post('category', true);
  5205. $size = $this->input->post('size', true);
  5206. $grade = $this->input->post('grade', true);
  5207. $color = $this->input->post('color', true);
  5208. $lowe = $this->input->post('lowe', true);
  5209. $state = $this->input->post('state', true);
  5210. $label = $this->input->post('label', true);
  5211. $timetk = $this->input->post('timetkk', true);
  5212. $timetj = $this->input->post('timetjj', true);
  5213. $timetk = strtotime($timetk);
  5214. $timetj = strtotime($timetj);
  5215. $where = "dbtime > 0";
  5216. if ($timetk && $timetj) {
  5217. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5218. }
  5219. if ($sku) {
  5220. $where .= " and sku = '$sku'";
  5221. }
  5222. if ($warehouse) {
  5223. $where .= " and warehouse = '$warehouse'";
  5224. if ($warehouse == 12) {
  5225. $w = 'specialstock';
  5226. } else {
  5227. $w = 'whlabel';
  5228. }
  5229. }
  5230. if ($purchase) {
  5231. $where .= " and purchase = '$purchase'";
  5232. }
  5233. if ($category) {
  5234. $where .= " and features like '%-$category-%'";
  5235. }
  5236. if ($size) {
  5237. $where .= " and features like '%-$size-%'";
  5238. }
  5239. if ($grade) {
  5240. $where .= " and features like '%-$grade-%'";
  5241. }
  5242. if ($color) {
  5243. $where .= " and features like '%-$color-%'";
  5244. }
  5245. if ($lowe) {
  5246. $where .= " and features like '%-$lowe-%'";
  5247. }
  5248. if ($state != '') {
  5249. $where .= " and state = '$state'";
  5250. }
  5251. //数据排序
  5252. $order_str = "dbtime desc";
  5253. if (empty($page)) {
  5254. $start = 0;
  5255. $perpage = 1;
  5256. } else {
  5257. $start = ($page - 1) * $perpage;
  5258. }
  5259. //取得信息列表
  5260. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5261. foreach ($info_list as $key => $value) {
  5262. $warehouse = $this->$w->read($value['warehouse']);
  5263. $info_list[$key]['warehouse'] = $warehouse['title'];
  5264. $purchase = $this->purchase->read($value['purchase']);
  5265. $info_list[$key]['purchase'] = $purchase['title'];
  5266. if ($value['enter'] != 0) {
  5267. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5268. } else {
  5269. $info_list[$key]['enter'] = "";
  5270. }
  5271. if ($value['dbtime'] != 0) {
  5272. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5273. } else {
  5274. $info_list[$key]['dbtime'] = "";
  5275. }
  5276. if ($value['state'] == 0) {
  5277. $info_list[$key]['state'] = "在库";
  5278. } else if ($value['state'] == 1) {
  5279. $info_list[$key]['state'] = "出库";
  5280. } else if ($value['state'] == 2) {
  5281. $info_list[$key]['state'] = "退库";
  5282. } else if ($value['state'] == 3) {
  5283. $info_list[$key]['state'] = "调拨中";
  5284. } else if ($value['state'] == 4) {
  5285. $info_list[$key]['state'] = "再加工";
  5286. } else if ($value['state'] == 5) {
  5287. $info_list[$key]['state'] = "维修中";
  5288. } else if ($value['state'] == 6) {
  5289. $info_list[$key]['state'] = "盘亏";
  5290. } else if ($value['state'] == 7) {
  5291. $info_list[$key]['state'] = "更换标签";
  5292. } else if ($value['state'] == 8) {
  5293. $info_list[$key]['state'] = "其它";
  5294. } else if ($value['state'] == 9) {
  5295. $info_list[$key]['state'] = "预设";
  5296. }
  5297. }
  5298. $total = $this->whlabel->find_count($where);
  5299. $pagenum = ceil($total / $perpage);
  5300. $over = $total - ($start + $perpage);
  5301. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5302. echo json_encode($rows);
  5303. exit;
  5304. }
  5305. if (isset($post['outsku'])) {
  5306. $time = time();
  5307. $cz = $this->input->post('cz', true);
  5308. $label = $this->input->post('outsku', true);
  5309. $sl = $this->input->post('sl', true);
  5310. $num = $this->input->post('num', true);
  5311. //$warehouse = $this->input->post('warehouse',true);
  5312. if (!$sl) {
  5313. $sl = 1;
  5314. }
  5315. if (!$warehouse) {
  5316. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5317. exit;
  5318. }
  5319. $dblabel = $this->whlabellabel->get_label($label);
  5320. if ($dblabel) {
  5321. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5322. if (count($data) < 1) {
  5323. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5324. exit;
  5325. }
  5326. if (count($data) < $num) {
  5327. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5328. exit;
  5329. }
  5330. for ($i = 0; $i < $sl; $i++) {
  5331. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5332. }
  5333. echo json_encode(array('success' => true));
  5334. exit;
  5335. } else {
  5336. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5337. exit;
  5338. }
  5339. }
  5340. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5341. $this->_Template('whlabel_db', $this->data);
  5342. }
  5343. public function _dbrk()
  5344. {
  5345. $post = $this->input->post(NULL, TRUE);
  5346. if (isset($post['page'])) {
  5347. $page = $this->input->post('page', true);
  5348. $perpage = $this->input->post('perpage', true);
  5349. $sku = $this->input->post('sku', true);
  5350. $number = $this->input->post('number', true);
  5351. $warehouse = $this->input->post('warehouse', true);
  5352. $purchase = $this->input->post('purchase', true);
  5353. $orderinfo = $this->input->post('orderinfo', true);
  5354. $waybill = $this->input->post('waybill', true);
  5355. $category = $this->input->post('category', true);
  5356. $size = $this->input->post('size', true);
  5357. $grade = $this->input->post('grade', true);
  5358. $color = $this->input->post('color', true);
  5359. $lowe = $this->input->post('lowe', true);
  5360. $state = $this->input->post('state', true);
  5361. $label = $this->input->post('label', true);
  5362. $ctime = $this->input->post('ctime', true);
  5363. $timetk = $this->input->post('timetkk', true);
  5364. $timetj = $this->input->post('timetjj', true);
  5365. $timetk = strtotime($timetk);
  5366. $timetj = strtotime($timetj);
  5367. $where = "dbtime > 0";
  5368. if ($timetk && $timetj) {
  5369. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5370. }
  5371. if ($sku) {
  5372. $where .= " and sku = '$sku'";
  5373. }
  5374. if ($warehouse) {
  5375. $where .= " and warehouse = '$warehouse'";
  5376. }
  5377. if ($purchase) {
  5378. $where .= " and purchase = '$purchase'";
  5379. }
  5380. if ($category) {
  5381. $where .= " and features like '%-$category-%'";
  5382. }
  5383. if ($size) {
  5384. $where .= " and features like '%-$size-%'";
  5385. }
  5386. if ($grade) {
  5387. $where .= " and features like '%-$grade-%'";
  5388. }
  5389. if ($color) {
  5390. $where .= " and features like '%-$color-%'";
  5391. }
  5392. if ($lowe) {
  5393. $where .= " and features like '%-$lowe-%'";
  5394. }
  5395. if ($state != '') {
  5396. $where .= " and state = '$state'";
  5397. }
  5398. //数据排序
  5399. $order_str = "dbtime desc";
  5400. if (empty($page)) {
  5401. $start = 0;
  5402. $perpage = 1;
  5403. } else {
  5404. $start = ($page - 1) * $perpage;
  5405. }
  5406. //取得信息列表
  5407. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5408. foreach ($info_list as $key => $value) {
  5409. $warehouse = $this->warehouse->read($value['warehouse']);
  5410. $info_list[$key]['warehouse'] = $warehouse['title'];
  5411. $purchase = $this->purchase->read($value['purchase']);
  5412. $info_list[$key]['purchase'] = $purchase['title'];
  5413. if ($value['enter'] != 0) {
  5414. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5415. } else {
  5416. $info_list[$key]['enter'] = "";
  5417. }
  5418. if ($value['dbtime'] != 0) {
  5419. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5420. } else {
  5421. $info_list[$key]['dbtime'] = "";
  5422. }
  5423. if ($value['state'] == 0) {
  5424. $info_list[$key]['state'] = "在库";
  5425. } else if ($value['state'] == 1) {
  5426. $info_list[$key]['state'] = "出库";
  5427. } else if ($value['state'] == 2) {
  5428. $info_list[$key]['state'] = "退库";
  5429. } else if ($value['state'] == 3) {
  5430. $info_list[$key]['state'] = "调拨中";
  5431. } else if ($value['state'] == 4) {
  5432. $info_list[$key]['state'] = "再加工";
  5433. } else if ($value['state'] == 5) {
  5434. $info_list[$key]['state'] = "维修中";
  5435. } else if ($value['state'] == 6) {
  5436. $info_list[$key]['state'] = "盘亏";
  5437. } else if ($value['state'] == 7) {
  5438. $info_list[$key]['state'] = "更换标签";
  5439. } else if ($value['state'] == 8) {
  5440. $info_list[$key]['state'] = "其它";
  5441. } else if ($value['state'] == 9) {
  5442. $info_list[$key]['state'] = "预设";
  5443. }
  5444. }
  5445. $total = $this->whlabel->find_count($where);
  5446. $pagenum = ceil($total / $perpage);
  5447. $over = $total - ($start + $perpage);
  5448. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5449. echo json_encode($rows);
  5450. exit;
  5451. }
  5452. if (isset($post['rsku'])) {
  5453. $cz = $this->input->post('cz', true);
  5454. $label = $this->input->post('rsku', true);
  5455. $sl = $this->input->post('sl', true);
  5456. $warehouse = $this->input->post('warehouse', true);
  5457. if (!$sl) {
  5458. $sl = 1;
  5459. }
  5460. if (!$warehouse) {
  5461. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5462. exit;
  5463. }
  5464. $dblabel = $this->whlabellabel->get_label($label);
  5465. if ($dblabel) {
  5466. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5467. if (count($data) < 1) {
  5468. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5469. exit;
  5470. }
  5471. if ($sl > count($data)) {
  5472. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5473. exit;
  5474. }
  5475. $time = time();
  5476. for ($i = 0; $i < $sl; $i++) {
  5477. $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']);
  5478. }
  5479. echo json_encode(array('success' => true));
  5480. exit;
  5481. } else {
  5482. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5483. exit;
  5484. }
  5485. }
  5486. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5487. $this->_Template('whlabel_dbrk', $this->data);
  5488. }
  5489. public function _whlabelczdc()
  5490. {
  5491. if (isset($_GET['excel'])) {
  5492. //数据排序
  5493. $order_str = "id desc";
  5494. if (empty($page)) {
  5495. $start = 0;
  5496. $perpage = 1;
  5497. } else {
  5498. $start = ($page - 1) * $perpage;
  5499. }
  5500. $state = $this->input->get('state', true);
  5501. $sku = $this->input->get('sku', true);
  5502. $ctime = $this->input->get('ctime', true);
  5503. $category = $this->input->get('category', true);
  5504. $size = $this->input->get('size', true);
  5505. $grade = $this->input->get('grade', true);
  5506. $color = $this->input->get('color', true);
  5507. $lowe = $this->input->get('lowe', true);
  5508. $timetk = $this->input->get('timetkk', true);
  5509. $timetj = $this->input->get('timetjj', true);
  5510. $timetk = strtotime($timetk);
  5511. $timetj = strtotime($timetj);
  5512. $where = "dbtime > 0";
  5513. if ($timetk && $timetj) {
  5514. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5515. }
  5516. if ($category) {
  5517. $where .= " and features like '%-$category-%'";
  5518. }
  5519. if ($size) {
  5520. $where .= " and features like '%-$size-%'";
  5521. }
  5522. if ($grade) {
  5523. $where .= " and features like '%-$grade-%'";
  5524. }
  5525. if ($color) {
  5526. $where .= " and features like '%-$color-%'";
  5527. }
  5528. if ($lowe) {
  5529. $where .= " and features like '%-$lowe-%'";
  5530. }
  5531. //取得信息列表
  5532. $info_list = $this->whlabel->find_all($where, '*');
  5533. $rows = array();
  5534. $list = array();
  5535. foreach ($info_list as $key => $value) {
  5536. $rows[$value['sku']] = $value; //所有数据sku
  5537. }
  5538. foreach ($rows as $value) {
  5539. $warehouse = $this->warehouse->read($value['warehouse']);
  5540. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5541. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5542. if ($value['orderinfo'] == 0) {
  5543. $info_list[$key]['orderinfo'] = "";
  5544. }
  5545. if ($value['waybill'] == 0) {
  5546. $info_list[$key]['waybill'] = "";
  5547. }
  5548. if ($value['state'] == 0) {
  5549. $value['state'] = "在库";
  5550. } else if ($value['state'] == 3) {
  5551. $value['state'] = "调拨中";
  5552. }
  5553. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5554. }
  5555. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5556. $titlename = "<table border=1>
  5557. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5558. <tr align='center'>
  5559. <td>SKU</td>
  5560. <td>产品</td>
  5561. <td>调拨数量</td>
  5562. <td>入库数量</td>
  5563. </tr>
  5564. </table>";
  5565. $filename = $title . ".xls";
  5566. $tail = "";
  5567. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5568. }
  5569. }
  5570. public function _print($arg_array)
  5571. {
  5572. if (isset($_SESSION['api'])) {
  5573. $user = $this->user->get_api($_SESSION['api']);
  5574. $usp = $user;
  5575. $fgshop = "";
  5576. $sid = "";
  5577. $wid = "";
  5578. $wtype = "";
  5579. $usersp = explode('|', trim($user['shop'], '|'));
  5580. $userwh = explode('|', trim($user['warehouse'], '|'));
  5581. foreach ($usersp as $value) {
  5582. $fgshop .= " shop = " . $value . " or";
  5583. $sid .= " id = " . $value . " or";
  5584. }
  5585. foreach ($userwh as $value) {
  5586. $wid .= " id = " . $value . " or";
  5587. $wtype .= " type = " . $value . " or";
  5588. }
  5589. }
  5590. $post = $this->input->post(NULL, TRUE);
  5591. if (isset($post['tmsku'])) {
  5592. $tmsku = $this->input->post('tmsku', true);
  5593. if (is_numeric($tmsku)) {
  5594. $yyh = $this->whlabellabel->get_label($tmsku);
  5595. } else {
  5596. $yyh = $this->whlabellabel->get_sku($tmsku);
  5597. if(empty($yyh)){
  5598. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  5599. if($r['code'] == -1 ){
  5600. echo json_encode(array('success' => false));
  5601. exit;
  5602. }else{
  5603. echo json_encode(array('features' => $r['data'], 'success' => true));
  5604. exit;
  5605. }
  5606. }
  5607. }
  5608. if ($yyh) {
  5609. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5610. exit;
  5611. } else {
  5612. echo json_encode(array('success' => false));
  5613. exit;
  5614. }
  5615. }
  5616. $classid = $this->classid->sku();
  5617. $pm = $classid;
  5618. $scsku = $classid;
  5619. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5620. if (isset($post['warehouse'])) {
  5621. if ($post['warehouse']) {
  5622. $list = array();
  5623. $num = "";
  5624. $title = "";
  5625. $features = "";
  5626. $order = 0;
  5627. $post['shop'] = '';
  5628. $brand = $this->input->post('brand', true);
  5629. if ($brand != '0,') {
  5630. $b = $this->brand->read(rtrim($brand, ','));
  5631. if ($b) {
  5632. $post['shop'] = str_replace('|', ',', $b['shop']);
  5633. }
  5634. }
  5635. $post['details'] = $this->input->post('details', true); //打印数量
  5636. $xbqnum = $this->input->post('xbqnum', true);
  5637. $post['purchase'] = $this->input->post('purchase', true);
  5638. $post['warehouse'] = $this->input->post('warehouse', true);
  5639. $post['purchase'] = $this->input->post('purchase', true);
  5640. $post['retreatwarehouse'] = $post['warehouse'];
  5641. $post['cpbz'] = $this->input->post('cpbz', true);
  5642. $post['state'] = 9;
  5643. $category = $this->input->post('category', true);
  5644. $list['category'] = $category;
  5645. $list['hairtype'] = $this->input->post('hairtype', true);
  5646. $list['grade'] = $this->input->post('grade', true);
  5647. $size = $this->input->post('size', true);
  5648. $list['size'] = rtrim($size, ',');
  5649. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5650. $list['extension'] = $this->input->post('extension', true);
  5651. if ($category == 1297) {
  5652. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5653. }
  5654. if ($category == 1702) {
  5655. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5656. $list['syother'] = $this->input->post('syother', true);
  5657. }
  5658. if ($category == 133) {
  5659. $list['fittype'] = $this->input->post('fittype', true);
  5660. $list['acother'] = $this->input->post('acother', true);
  5661. }
  5662. $list['color'] = $this->input->post('color', true);
  5663. $list['lowe'] = $this->input->post('lowe', true);
  5664. if ($category == 127) {
  5665. $list['type'] = $this->input->post('type', true);
  5666. $list['headroad'] = $this->input->post('headroad', true);
  5667. $list['density'] = $this->input->post('density', true);
  5668. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5669. $list['lacesize'] = $this->input->post('lacesize', true);
  5670. }
  5671. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5672. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5673. }
  5674. if ($category == 128) {
  5675. $list['lacetype'] = $this->input->post('lacetype', true);
  5676. $list['haircap'] = $this->input->post('haircap', true);
  5677. $list['density'] = $this->input->post('density', true);
  5678. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5679. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5680. $list['wigother'] = $this->input->post('wigother', true);
  5681. $list['wigother1'] = $this->input->post('wigother1', true);
  5682. $list['wigother2'] = $this->input->post('wigother2', true);
  5683. }
  5684. if ($category == 129) {
  5685. $list['wide'] = $this->input->post('wide', true);
  5686. }
  5687. if ($category == 131) {
  5688. $list['gifttype'] = $this->input->post('gifttype', true);
  5689. $list['giftother'] = $this->input->post('giftother', true);
  5690. }
  5691. if ($category == 134) {
  5692. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5693. }
  5694. if ($category == 1297) {
  5695. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5696. $list['sywigother'] = $this->input->post('sywigother', true);
  5697. }
  5698. if ($category == 130 || $category == 133 || $category == 1702) {
  5699. $list['items'] = $this->input->post('items', true);
  5700. $list['weight'] = $this->input->post('weight', true);
  5701. }
  5702. if ($category == 1702) {
  5703. $list['syhairther'] = $this->input->post('syhairther', true);
  5704. }
  5705. if($category == 130){
  5706. $list['jfother'] = $this->input->post('jfother', true);
  5707. }
  5708. foreach ($list as $k => $v) {
  5709. if ($v != 0) {
  5710. $num .= $v;
  5711. $features .= $v . '-';
  5712. $post[$k] = $v;
  5713. $typeclass = $this->typeclass->read($v);
  5714. if (isset($pm[$typeclass['classid']])) {
  5715. if (stripos($typeclass['zh'], '|') !== false) {
  5716. $exzh = explode('|', $typeclass['zh']);
  5717. $pm[$typeclass['classid']] = $exzh[0];
  5718. } else {
  5719. $pm[$typeclass['classid']] = $typeclass['zh'];
  5720. }
  5721. }
  5722. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5723. if ($k != 'size') {
  5724. $title .= $typeclass['title'] . " ";
  5725. }
  5726. }
  5727. }
  5728. $typeclass = $this->typeclass->read($list['size']);
  5729. $title .= $typeclass['title'];
  5730. $time = time();
  5731. $post['title'] = rtrim($title, ' ');
  5732. $post['number'] = $num;
  5733. $post['features'] = '-' . $features;
  5734. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5735. $featurespp = explode('-', trim($featurespp, '-'));
  5736. if (isset($featurespp[5])) {
  5737. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5738. } else {
  5739. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5740. }
  5741. $post['enter'] = $time;
  5742. $post['time'] = $time; //操作时间
  5743. $scsku = implode("-", $scsku);
  5744. $zh = implode(" ", $pm);
  5745. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5746. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5747. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5748. $post['sku'] = $bqsku;
  5749. $label = time() . rand(0, 9);
  5750. $post['label'] = $label;
  5751. $cpid = $this->whlabellabel->find_count();
  5752. $post['cpid'] = $cpid + 1;
  5753. $cpid = $post['cpid'];
  5754. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5755. //if($whlabelbarcode)
  5756. //{
  5757. //$post['label'] = $whlabelbarcode['label'];
  5758. //if(!$this->whlabellabel->insert($post))
  5759. //{
  5760. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5761. //}
  5762. //}
  5763. //else
  5764. //{
  5765. $this->db->trans_begin();
  5766. $this->whlabellabel->insert($post);
  5767. //$this->whlabelbarcode->insert($post);
  5768. if ($this->db->trans_status() === TRUE) {
  5769. $this->db->trans_commit();
  5770. } else {
  5771. $this->db->trans_rollback();
  5772. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5773. exit;
  5774. }
  5775. //}
  5776. $warehouse_name = "";
  5777. $warehouse = $post['warehouse'];
  5778. if($warehouse == 12){
  5779. $warehouse_name = "特殊库存库";
  5780. }
  5781. // if($warehouse == 13){
  5782. // $warehouse_name = "许昌仓";
  5783. // }
  5784. // if($warehouse == 5){
  5785. // $warehouse_name = "美国店";
  5786. // }
  5787. // if($warehouse == 16){
  5788. // $warehouse_name = "定制头套仓";
  5789. // }
  5790. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5791. if(!empty($warehouse_name)){
  5792. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5793. }
  5794. $purchase = $this->purchase->read($post['purchase']);
  5795. 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));
  5796. exit; //特殊仓目前不需要仓库选项
  5797. }
  5798. }
  5799. if (isset($_SESSION['api'])) {
  5800. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5801. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5802. $this->data['wlshop'] = $wlshop;
  5803. $this->data['warehouse'] = $warehouse;
  5804. }
  5805. $whlabelwz = $this->whlabelwz->find_all();
  5806. $this->data['whlabelwz'] = $whlabelwz;
  5807. $this->_Template('whlabel_print', $this->data);
  5808. }
  5809. public function _usaprint($arg_array)
  5810. {
  5811. if (isset($_SESSION['api'])) {
  5812. $user = $this->user->get_api($_SESSION['api']);
  5813. $usp = $user;
  5814. $fgshop = "";
  5815. $sid = "";
  5816. $wid = "";
  5817. $wtype = "";
  5818. $usersp = explode('|', trim($user['shop'], '|'));
  5819. $userwh = explode('|', trim($user['warehouse'], '|'));
  5820. foreach ($usersp as $value) {
  5821. $fgshop .= " shop = " . $value . " or";
  5822. $sid .= " id = " . $value . " or";
  5823. }
  5824. foreach ($userwh as $value) {
  5825. $wid .= " id = " . $value . " or";
  5826. $wtype .= " type = " . $value . " or";
  5827. }
  5828. }
  5829. $post = $this->input->post(NULL, TRUE);
  5830. if (isset($post['tmsku'])) {
  5831. $tmsku = $this->input->post('tmsku', true);
  5832. if (is_numeric($tmsku)) {
  5833. $yyh = $this->whlabellabel->get_label($tmsku);
  5834. } else {
  5835. $yyh = $this->whlabellabel->get_sku($tmsku);
  5836. }
  5837. if ($yyh) {
  5838. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5839. exit;
  5840. } else {
  5841. echo json_encode(array('success' => false));
  5842. exit;
  5843. }
  5844. }
  5845. $classid = $this->classid->sku();
  5846. $pm = $classid;
  5847. $scsku = $classid;
  5848. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5849. if (isset($post['warehouse'])) {
  5850. if ($post['warehouse']) {
  5851. $list = array();
  5852. $num = "";
  5853. $title = "";
  5854. $features = "";
  5855. $order = 0;
  5856. $post['shop'] = '';
  5857. $brand = $this->input->post('brand', true);
  5858. if ($brand != '0,') {
  5859. $b = $this->brand->read(rtrim($brand, ','));
  5860. if ($b) {
  5861. $post['shop'] = str_replace('|', ',', $b['shop']);
  5862. }
  5863. }
  5864. $post['details'] = $this->input->post('details', true); //打印数量
  5865. $xbqnum = $this->input->post('xbqnum', true);
  5866. $post['purchase'] = $this->input->post('purchase', true);
  5867. $post['warehouse'] = $this->input->post('warehouse', true);
  5868. $post['purchase'] = $this->input->post('purchase', true);
  5869. $post['retreatwarehouse'] = $post['warehouse'];
  5870. $post['cpbz'] = $this->input->post('cpbz', true);
  5871. $post['state'] = 9;
  5872. $category = $this->input->post('category', true);
  5873. $list['category'] = $category;
  5874. $list['hairtype'] = $this->input->post('hairtype', true);
  5875. $list['grade'] = $this->input->post('grade', true);
  5876. $size = $this->input->post('size', true);
  5877. $list['size'] = rtrim($size, ',');
  5878. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5879. $list['extension'] = $this->input->post('extension', true);
  5880. if ($category == 1297) {
  5881. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5882. }
  5883. if ($category == 1702) {
  5884. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5885. $list['syother'] = $this->input->post('syother', true);
  5886. }
  5887. if ($category == 133) {
  5888. $list['fittype'] = $this->input->post('fittype', true);
  5889. $list['acother'] = $this->input->post('acother', true);
  5890. }
  5891. $list['color'] = $this->input->post('color', true);
  5892. $list['lowe'] = $this->input->post('lowe', true);
  5893. if ($category == 127) {
  5894. $list['type'] = $this->input->post('type', true);
  5895. $list['headroad'] = $this->input->post('headroad', true);
  5896. $list['density'] = $this->input->post('density', true);
  5897. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5898. $list['lacesize'] = $this->input->post('lacesize', true);
  5899. }
  5900. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5901. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5902. }
  5903. if ($category == 128) {
  5904. $list['lacetype'] = $this->input->post('lacetype', true);
  5905. $list['haircap'] = $this->input->post('haircap', true);
  5906. $list['density'] = $this->input->post('density', true);
  5907. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5908. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5909. $list['wigother'] = $this->input->post('wigother', true);
  5910. $list['wigother1'] = $this->input->post('wigother1', true);
  5911. $list['wigother2'] = $this->input->post('wigother2', true);
  5912. }
  5913. if ($category == 129) {
  5914. $list['wide'] = $this->input->post('wide', true);
  5915. }
  5916. if ($category == 131) {
  5917. $list['gifttype'] = $this->input->post('gifttype', true);
  5918. $list['giftother'] = $this->input->post('giftother', true);
  5919. }
  5920. if ($category == 134) {
  5921. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5922. }
  5923. if ($category == 1297) {
  5924. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5925. $list['sywigother'] = $this->input->post('sywigother', true);
  5926. }
  5927. if ($category == 130 || $category == 133 || $category == 1702) {
  5928. $list['items'] = $this->input->post('items', true);
  5929. $list['weight'] = $this->input->post('weight', true);
  5930. }
  5931. if ($category == 1702) {
  5932. $list['syhairther'] = $this->input->post('syhairther', true);
  5933. }
  5934. foreach ($list as $k => $v) {
  5935. if ($v != 0) {
  5936. $num .= $v;
  5937. $features .= $v . '-';
  5938. $post[$k] = $v;
  5939. $typeclass = $this->typeclass->read($v);
  5940. if (isset($pm[$typeclass['classid']])) {
  5941. if (stripos($typeclass['zh'], '|') !== false) {
  5942. $exzh = explode('|', $typeclass['zh']);
  5943. $pm[$typeclass['classid']] = $exzh[0];
  5944. } else {
  5945. $pm[$typeclass['classid']] = $typeclass['zh'];
  5946. }
  5947. }
  5948. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5949. if ($k != 'size') {
  5950. $title .= $typeclass['title'] . " ";
  5951. }
  5952. }
  5953. }
  5954. $typeclass = $this->typeclass->read($list['size']);
  5955. $title .= $typeclass['title'];
  5956. $time = time();
  5957. $post['title'] = rtrim($title, ' ');
  5958. $post['number'] = $num;
  5959. $post['features'] = '-' . $features;
  5960. $fp = $this->whlabel->get_features($post['features']);
  5961. if (!$fp) {
  5962. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5963. exit;
  5964. }
  5965. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5966. $featurespp = explode('-', trim($featurespp, '-'));
  5967. if (isset($featurespp[5])) {
  5968. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5969. } else {
  5970. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5971. }
  5972. $post['enter'] = $time;
  5973. $post['time'] = $time; //操作时间
  5974. $scsku = implode("-", $scsku);
  5975. $zh = implode(" ", $pm);
  5976. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5977. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5978. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5979. $post['sku'] = $fp['sku'];
  5980. $post['label'] = $fp['sku'];
  5981. $cpid = $this->whlabellabel->find_count();
  5982. $post['cpid'] = $cpid + 1;
  5983. $cpid = $post['cpid'];
  5984. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5985. //if($whlabelbarcode)
  5986. //{
  5987. //$post['label'] = $whlabelbarcode['label'];
  5988. //if(!$this->whlabellabel->insert($post))
  5989. //{
  5990. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5991. //}
  5992. //}
  5993. //else
  5994. //{
  5995. $this->db->trans_begin();
  5996. $this->whlabellabel->insert($post);
  5997. //$this->whlabelbarcode->insert($post);
  5998. if ($this->db->trans_status() === TRUE) {
  5999. $this->db->trans_commit();
  6000. } else {
  6001. $this->db->trans_rollback();
  6002. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6003. exit;
  6004. }
  6005. //}
  6006. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6007. $purchase = $this->purchase->read($post['purchase']);
  6008. 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));
  6009. exit; //特殊仓目前不需要仓库选项
  6010. }
  6011. }
  6012. if (isset($_SESSION['api'])) {
  6013. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6014. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6015. $this->data['wlshop'] = $wlshop;
  6016. $this->data['warehouse'] = $warehouse;
  6017. }
  6018. $whlabelwz = $this->whlabelwz->find_all();
  6019. $this->data['whlabelwz'] = $whlabelwz;
  6020. $this->_Template('whlabel_usaprint', $this->data);
  6021. }
  6022. public function _printrk($arg_array)
  6023. {
  6024. $prc = array();
  6025. $purchase = $this->purchase->find_all();
  6026. foreach ($purchase as $k => $v) {
  6027. $prc[$v['id']] = $v['title'];
  6028. }
  6029. $post = $this->input->post(NULL, TRUE);
  6030. if (isset($post['page'])) {
  6031. $page = $this->input->post('page', true);
  6032. $perpage = $this->input->post('perpage', true);
  6033. $sku = $this->input->post('sku', true);
  6034. $bs = $this->input->post('bs', true);
  6035. $number = $this->input->post('number', true);
  6036. $warehouse = $this->input->post('warehouse', true);
  6037. $purchase = $this->input->post('purchase', true);
  6038. $orderinfo = $this->input->post('orderinfo', true);
  6039. $waybill = $this->input->post('waybill', true);
  6040. $category = $this->input->post('category', true);
  6041. $size = $this->input->post('size', true);
  6042. $grade = $this->input->post('grade', true);
  6043. $color = $this->input->post('color', true);
  6044. $lowe = $this->input->post('lowe', true);
  6045. $state = $this->input->post('state', true);
  6046. $label = $this->input->post('label', true);
  6047. $timetk = $this->input->post('ktime', true);
  6048. $timetj = $this->input->post('jtime', true);
  6049. $timetk = strtotime($timetk);
  6050. $timetj = strtotime($timetj);
  6051. $where = "1=1 ";
  6052. if ($timetk && $timetj) {
  6053. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6054. }
  6055. if ($sku) {
  6056. $where .= " and sku = '$sku'";
  6057. }
  6058. if ($bs != '') {
  6059. $where .= " and bs = '$bs'";
  6060. }
  6061. if ($number) {
  6062. $where .= " and number = '$number'";
  6063. }
  6064. if ($warehouse) {
  6065. $where .= " and warehouse = '$warehouse'";
  6066. }
  6067. if ($purchase) {
  6068. $where .= " and purchase = '$purchase'";
  6069. }
  6070. if ($orderinfo) {
  6071. $where .= " and orderinfo = '$orderinfo'";
  6072. }
  6073. if ($waybill) {
  6074. $where .= " and waybill = '$waybill'";
  6075. }
  6076. if ($category) {
  6077. $where .= " and features like '%-$category-%'";
  6078. }
  6079. if ($size) {
  6080. $where .= " and features like '%-$size-%'";
  6081. }
  6082. if ($grade) {
  6083. $where .= " and features like '%-$grade-%'";
  6084. }
  6085. if ($color) {
  6086. $where .= " and features like '%-$color-%'";
  6087. }
  6088. if ($lowe) {
  6089. $where .= " and features like '%-$lowe-%'";
  6090. }
  6091. if ($label) {
  6092. $where .= " and label = '$label'";
  6093. }
  6094. if ($state || $state == 0) {
  6095. $where .= " and state = '$state'";
  6096. }
  6097. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6098. //数据排序
  6099. $order_str = "enter desc";
  6100. if (empty($page)) {
  6101. $start = 0;
  6102. $perpage = 1;
  6103. } else {
  6104. $start = ($page - 1) * $perpage;
  6105. }
  6106. //取得信息列表
  6107. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6108. foreach ($info_list as $key => $value) {
  6109. $warehouse = $this->warehouse->read($value['warehouse']);
  6110. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6111. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6112. if ($value['state'] == 0) {
  6113. $info_list[$key]['state'] = "在库";
  6114. } else if ($value['state'] == 1) {
  6115. $info_list[$key]['state'] = "出库";
  6116. } else if ($value['state'] == 2) {
  6117. $info_list[$key]['state'] = "退库";
  6118. } else if ($value['state'] == 3) {
  6119. $info_list[$key]['state'] = "调拨中";
  6120. } else if ($value['state'] == 4) {
  6121. $info_list[$key]['state'] = "再加工";
  6122. } else if ($value['state'] == 5) {
  6123. $info_list[$key]['state'] = "维修中";
  6124. } else if ($value['state'] == 6) {
  6125. $info_list[$key]['state'] = "盘亏";
  6126. } else if ($value['state'] == 7) {
  6127. $info_list[$key]['state'] = "更换标签";
  6128. } else if ($value['state'] == 8) {
  6129. $info_list[$key]['state'] = "其它";
  6130. } else if ($value['state'] == 9) {
  6131. $info_list[$key]['state'] = "预设";
  6132. } else if ($value['state'] == 10) {
  6133. $info_list[$key]['state'] = "美店零售";
  6134. }
  6135. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6136. }
  6137. $total = $this->$ck->find_count($where);
  6138. $pagenum = ceil($total / $perpage);
  6139. $over = $total - ($start + $perpage);
  6140. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6141. echo json_encode($rows);
  6142. exit;
  6143. }
  6144. if (isset($post['tmsku'])) {
  6145. $time = time();
  6146. $tmsku = $this->input->post('tmsku', true);
  6147. //$post['shop'] = $this->input->post('shop',true);
  6148. $num = $this->input->post('num', true);
  6149. $rktype = $this->input->post('rktype', true);
  6150. if ($num > 200) {
  6151. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6152. exit;
  6153. }
  6154. if (!$rktype) {
  6155. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6156. }
  6157. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6158. /**
  6159. $wz = array();
  6160. foreach ($rk as $key=>$value)
  6161. {
  6162. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6163. }
  6164. if(count($wz) > 1)
  6165. {
  6166. $wz = array_values($wz);
  6167. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6168. }
  6169. **/
  6170. if (isset($rk[0]['purchase'])) {
  6171. $rk = $rk[0];
  6172. $j = 0;
  6173. $post['purchase'] = $rk['purchase'];
  6174. $post['warehouse'] = $rk['warehouse'];
  6175. $post['retreatwarehouse'] = $rk['warehouse'];
  6176. $post['sku'] = $rk['sku'];
  6177. $post['number'] = $rk['number'];
  6178. $post['features'] = $rk['features'];
  6179. $post['title'] = $rk['title'];
  6180. $post['enter'] = $time;
  6181. $post['time'] = $time;
  6182. $post['bs'] = 1;
  6183. $post['shop'] = $rk['shop'];
  6184. $post['details'] = $rk['details'];
  6185. $post['cpid'] = $rk['cpid'];
  6186. $post['cpbz'] = $rk['cpbz'];
  6187. $post['rktype'] = $rktype;
  6188. $warehouse = $this->warehouse->read($rk['warehouse']);
  6189. if ($warehouse['bdck'] == '') {
  6190. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6191. exit;
  6192. } else {
  6193. $bdck = $warehouse['bdck'];
  6194. }
  6195. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6196. if (isset($pdwz['details'])) {
  6197. if ($pdwz['details'] != $post['details']) {
  6198. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6199. exit;
  6200. }
  6201. }
  6202. $post['featurespp'] = $rk['featurespp'];
  6203. if ($post['warehouse'] == '5') {
  6204. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6205. if ($yza) {
  6206. if ($post['features'] != $yza[0]['features']) {
  6207. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6208. exit;
  6209. }
  6210. }
  6211. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6212. if ($yzb) {
  6213. if ($post['sku'] != $yzb[0]['sku']) {
  6214. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6215. exit;
  6216. }
  6217. }
  6218. }
  6219. for ($i = 0; $i < $num; $i++) {
  6220. $post['label'] = time() . rand(100, 999) . $i;
  6221. if ($this->$bdck->insert($post)) {
  6222. $j++;
  6223. }
  6224. }
  6225. /**
  6226. if($post['warehouse'] != 12)
  6227. {
  6228. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6229. }
  6230. **/
  6231. $this->whlabelscanlog->insert([
  6232. 'shop'=>$rk['shop'],
  6233. 'type'=>1,
  6234. 'purchase'=>$rk['purchase'],
  6235. 'sku'=>$rk['sku'],
  6236. 'features'=>$rk['features'],
  6237. 'title'=>$rk['title'],
  6238. 'label'=>$rk['label'],
  6239. 'warehouse'=>$rk['warehouse'],
  6240. 'wlid'=>$rk['id'],
  6241. 'num'=>$num,
  6242. 'addtime'=>time()
  6243. ]);
  6244. if ($j == $num) {
  6245. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6246. exit;
  6247. } else {
  6248. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6249. exit;
  6250. }
  6251. } else {
  6252. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6253. exit;
  6254. }
  6255. }
  6256. $this->_Template('whlabel_printrk', $this->data);
  6257. }
  6258. public function _printxzrk($arg_array)
  6259. {
  6260. $post = $this->input->post(NULL, TRUE);
  6261. if (isset($post['wzid'])) {
  6262. $time = time();
  6263. $id = $this->input->post('wzid', true);
  6264. //$post['shop'] = $this->input->post('shop',true);
  6265. $num = 1;
  6266. $rk = $this->whlabellabel->read($id);
  6267. if (isset($rk['purchase'])) {
  6268. $x = 0;
  6269. $post['purchase'] = $rk['purchase'];
  6270. $post['warehouse'] = $rk['warehouse'];
  6271. $post['retreatwarehouse'] = $rk['warehouse'];
  6272. $post['sku'] = $rk['sku'];
  6273. $post['number'] = $rk['number'];
  6274. $post['features'] = $rk['features'];
  6275. $post['title'] = $rk['title'];
  6276. $post['enter'] = $time;
  6277. $post['time'] = $time;
  6278. $post['bs'] = 1;
  6279. $post['shop'] = $rk['shop'];
  6280. $post['details'] = $rk['details'];
  6281. $post['cpid'] = $rk['cpid'];
  6282. $post['cpbz'] = $rk['cpbz'];
  6283. $warehouse = $this->warehouse->read($rk['warehouse']);
  6284. if ($warehouse['bdck'] == '') {
  6285. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6286. exit;
  6287. } else {
  6288. $bdck = $warehouse['bdck'];
  6289. }
  6290. $post['featurespp'] = $rk['featurespp'];
  6291. $this->db->trans_begin();
  6292. for ($i = 0; $i < $num; $i++) {
  6293. $post['label'] = time() . rand(100, 999) . $i;
  6294. $this->$bdck->insert($post);
  6295. }
  6296. /**
  6297. if($post['warehouse'] != 12)
  6298. {
  6299. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6300. }
  6301. **/
  6302. if ($this->db->trans_status() === TRUE) {
  6303. $this->db->trans_commit();
  6304. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6305. exit;
  6306. } else {
  6307. $this->db->trans_rollback();
  6308. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6309. exit;
  6310. }
  6311. } else {
  6312. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6313. exit;
  6314. }
  6315. }
  6316. }
  6317. public function _printck($arg_array)
  6318. {
  6319. $prc = array();
  6320. $purchase = $this->purchase->find_all();
  6321. foreach ($purchase as $k => $v) {
  6322. $prc[$v['id']] = $v['title'];
  6323. }
  6324. $post = $this->input->post(NULL, TRUE);
  6325. if (isset($post['page'])) {
  6326. $page = $this->input->post('page', true);
  6327. $perpage = $this->input->post('perpage', true);
  6328. $sku = $this->input->post('sku', true);
  6329. $bs = $this->input->post('bs', true);
  6330. $number = $this->input->post('number', true);
  6331. $warehouse = $this->input->post('warehouse', true);
  6332. $purchase = $this->input->post('purchase', true);
  6333. $orderinfo = $this->input->post('orderinfo', true);
  6334. $waybill = $this->input->post('waybill', true);
  6335. $category = $this->input->post('category', true);
  6336. $size = $this->input->post('size', true);
  6337. $grade = $this->input->post('grade', true);
  6338. $color = $this->input->post('color', true);
  6339. $lowe = $this->input->post('lowe', true);
  6340. $state = $this->input->post('state', true);
  6341. $label = $this->input->post('label', true);
  6342. $timetk = $this->input->post('ktime', true);
  6343. $timetj = $this->input->post('jtime', true);
  6344. $timetk = strtotime($timetk);
  6345. $timetj = strtotime($timetj);
  6346. $where = "state=1 ";
  6347. if ($timetk && $timetj) {
  6348. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6349. }
  6350. if ($sku) {
  6351. $where .= " and sku = '$sku'";
  6352. }
  6353. if ($bs != '') {
  6354. $where .= " and bs = '$bs'";
  6355. }
  6356. if ($number) {
  6357. $where .= " and number = '$number'";
  6358. }
  6359. if ($warehouse) {
  6360. $where .= " and warehouse = '$warehouse'";
  6361. }
  6362. if ($purchase) {
  6363. $where .= " and purchase = '$purchase'";
  6364. }
  6365. if ($orderinfo) {
  6366. $where .= " and orderinfo = '$orderinfo'";
  6367. }
  6368. if ($waybill) {
  6369. $where .= " and waybill = '$waybill'";
  6370. }
  6371. if ($category) {
  6372. $where .= " and features like '%-$category-%'";
  6373. }
  6374. if ($size) {
  6375. $where .= " and features like '%-$size-%'";
  6376. }
  6377. if ($grade) {
  6378. $where .= " and features like '%-$grade-%'";
  6379. }
  6380. if ($color) {
  6381. $where .= " and features like '%-$color-%'";
  6382. }
  6383. if ($lowe) {
  6384. $where .= " and features like '%-$lowe-%'";
  6385. }
  6386. if ($label) {
  6387. $where .= " and label = '$label'";
  6388. }
  6389. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6390. //数据排序
  6391. $order_str = "outk desc";
  6392. if (empty($page)) {
  6393. $start = 0;
  6394. $perpage = 1;
  6395. } else {
  6396. $start = ($page - 1) * $perpage;
  6397. }
  6398. //取得信息列表
  6399. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6400. foreach ($info_list as $key => $value) {
  6401. $warehouse = $this->warehouse->read($value['warehouse']);
  6402. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6403. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6404. if ($value['state'] == 0) {
  6405. $info_list[$key]['state'] = "在库";
  6406. } else if ($value['state'] == 1) {
  6407. $info_list[$key]['state'] = "出库";
  6408. } else if ($value['state'] == 2) {
  6409. $info_list[$key]['state'] = "退库";
  6410. } else if ($value['state'] == 3) {
  6411. $info_list[$key]['state'] = "调拨中";
  6412. } else if ($value['state'] == 4) {
  6413. $info_list[$key]['state'] = "再加工";
  6414. } else if ($value['state'] == 5) {
  6415. $info_list[$key]['state'] = "维修中";
  6416. } else if ($value['state'] == 6) {
  6417. $info_list[$key]['state'] = "盘亏";
  6418. } else if ($value['state'] == 7) {
  6419. $info_list[$key]['state'] = "更换标签";
  6420. } else if ($value['state'] == 8) {
  6421. $info_list[$key]['state'] = "其它";
  6422. } else if ($value['state'] == 9) {
  6423. $info_list[$key]['state'] = "预设";
  6424. } else if ($value['state'] == 10) {
  6425. $info_list[$key]['state'] = "美店零售";
  6426. }
  6427. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6428. }
  6429. $total = $this->$ck->find_count($where);
  6430. $pagenum = ceil($total / $perpage);
  6431. $over = $total - ($start + $perpage);
  6432. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6433. echo json_encode($rows);
  6434. exit;
  6435. }
  6436. if (isset($post['tmsku'])) {
  6437. $time = time();
  6438. $tmsku = $this->input->post('tmsku', true);
  6439. //$post['shop'] = $this->input->post('shop',true);
  6440. $num = $this->input->post('num', true);
  6441. $cktype = $this->input->post('cktype', true);
  6442. $label = $this->whlabellabel->get_label($tmsku);
  6443. if (!$cktype) {
  6444. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6445. }
  6446. if (!isset($label['warehouse'])) {
  6447. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6448. exit;
  6449. }
  6450. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6451. if (stripos($label['features'], '-126-') !== false) {
  6452. $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 )");
  6453. } else {
  6454. $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 ) ");
  6455. }
  6456. $j = 0;
  6457. if (count($ck) >= $num) {
  6458. for ($i = 0; $i < $num; $i++) {
  6459. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6460. {
  6461. $j++;
  6462. }
  6463. }
  6464. $this->whlabelscanlog->insert([
  6465. 'shop'=>$label['shop'],
  6466. 'type'=>2,
  6467. 'purchase'=>$label['purchase'],
  6468. 'sku'=>$label['sku'],
  6469. 'features'=>$label['features'],
  6470. 'title'=>$label['title'],
  6471. 'label'=>$label['label'],
  6472. 'warehouse'=>$label['warehouse'],
  6473. 'wlid'=>$label['id'],
  6474. 'num'=>$num,
  6475. 'addtime'=>time()
  6476. ]);
  6477. if ($j == $num) {
  6478. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6479. exit;
  6480. } else {
  6481. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6482. exit;
  6483. }
  6484. } else {
  6485. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6486. exit;
  6487. }
  6488. }
  6489. if(isset($_SESSION['api']))
  6490. {
  6491. $user = $this->user->get_api($_SESSION['api']);
  6492. if(in_array($user['power'],[1,27])){
  6493. $vip = 1;
  6494. }
  6495. }
  6496. else
  6497. {
  6498. $vip = 0;
  6499. header('Location: /');exit;
  6500. }
  6501. $this->data['vip'] = $vip;
  6502. $this->_Template('whlabel_printck', $this->data);
  6503. }
  6504. public function _printexcel()
  6505. {
  6506. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6507. $config['upload_path'] = '.' . $dir;
  6508. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6509. $config['allowed_types'] = 'xls|xlsx|csv';
  6510. $config['max_size'] = 10240;
  6511. $this->load->library('upload', $config);
  6512. $this->upload->initialize($config);
  6513. if ($this->upload->do_upload('userfile')) {
  6514. $full_path = $dir . $this->upload->data('file_name');
  6515. $fileName = '.' . $full_path;
  6516. if (!file_exists($fileName)) {
  6517. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6518. exit;
  6519. } else {
  6520. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6521. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6522. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6523. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6524. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6525. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6526. ++$column; //如果列数大于26行
  6527. $list = array();
  6528. for ($i = 2; $i <= $row; $i++) // 行数循环
  6529. {
  6530. $data = array();
  6531. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6532. {
  6533. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6534. }
  6535. $list[] = $data;
  6536. }
  6537. }
  6538. $ed = array();
  6539. $i = 0;
  6540. $j = 0;
  6541. $dcdata = array();
  6542. $yc = '';
  6543. $cmf_arr = array_column($list, '1');
  6544. array_multisort($cmf_arr, SORT_ASC, $list);
  6545. foreach ($list as $key => $value) {
  6546. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6547. if ($typeclass) {
  6548. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6549. } else {
  6550. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6551. $i++;
  6552. continue;
  6553. }
  6554. }
  6555. if ($i > 0) {
  6556. $yc = $i . '条异常';
  6557. }
  6558. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6559. exit;
  6560. }
  6561. }
  6562. public function _uck()
  6563. {
  6564. if (isset($_GET['excel'])) {
  6565. $tc = array();
  6566. $typeclass = $this->typeclass->find_all();
  6567. foreach ($typeclass as $v) {
  6568. $tc[$v['id']] = $v['zh'];
  6569. }
  6570. $data = array();
  6571. $t = array();
  6572. $rq = '';
  6573. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6574. $ts = $ts / (24 * 3600);
  6575. for ($i = 0; $i < $ts; $i++) {
  6576. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6577. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6578. }
  6579. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6580. foreach ($info_list as $k => $v) {
  6581. $features = explode('-', trim($v['features'], '-'));
  6582. if (!isset($features[3]) || !isset($features[4])) {
  6583. continue;
  6584. }
  6585. $data[$k][0] = $tc[$features[0]]; //类型
  6586. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6587. $data[$k][2] = $tc[$features[4]]; //曲度
  6588. $data[$k][3] = '';
  6589. if (isset($data[$k][1])) {
  6590. $data[$k][3] .= $data[$k][1];
  6591. }
  6592. if (isset($data[$k][2])) {
  6593. $data[$k][3] .= $data[$k][2];
  6594. }
  6595. if (isset($features[5])) {
  6596. $data[$k][3] .= $tc[$features[5]];
  6597. }
  6598. if (isset($features[2])) {
  6599. $data[$k][3] .= $tc[$features[2]];
  6600. }
  6601. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6602. $data[$k][4] = $v['sku'];
  6603. $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())) . '))'); //月初库存
  6604. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6605. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6606. $ztrq = '';
  6607. $ztsl = '';
  6608. if (count($zt) > 0) {
  6609. foreach ($zt as $vv) {
  6610. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6611. $ztsl .= $vv['num'] . '<br>';
  6612. }
  6613. }
  6614. $data[$k][] = trim($ztsl, '<br>');
  6615. $data[$k][] = trim($ztrq, '<br>');
  6616. $byck = 0;
  6617. foreach ($t as $vv) {
  6618. $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));
  6619. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6620. $byck += $sl;
  6621. }
  6622. $data[$k][] = ($byck > 0) ? $byck : '';
  6623. }
  6624. $title = "详情 " . date("Y-m-d", time());
  6625. $titlename = "<table border=1>
  6626. <tr align='center'>
  6627. <td>类别</td>
  6628. <td>颜色</td>
  6629. <td>曲度</td>
  6630. <td>名称</td>
  6631. <td>SKU</td>
  6632. <td>月初库存</td>
  6633. <td>剩余库存</td>
  6634. <td>在途数量</td>
  6635. <td>预达日期</td>" .
  6636. $rq
  6637. . "<td>本月出库</td></tr>
  6638. </table>";
  6639. $filename = $title . ".xls";
  6640. $tail = "";
  6641. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6642. }
  6643. }
  6644. public function _whlabelexcelzh()
  6645. {
  6646. if (isset($_GET['excel'])) {
  6647. $where = "sku != 'Preset'";
  6648. //数据排序
  6649. $order_str = "id desc";
  6650. if (empty($page)) {
  6651. $start = 0;
  6652. $perpage = 1;
  6653. } else {
  6654. $start = ($page - 1) * $perpage;
  6655. }
  6656. $category = $this->input->get('category', true);
  6657. $warehouse = $this->input->get('warehouse', true);
  6658. $excelid = $this->input->get('sid', true);
  6659. if ($category) {
  6660. $where .= " and features like '%-$category-%'";
  6661. }
  6662. if ($warehouse) {
  6663. $where .= " and warehouse = '$warehouse'";
  6664. }
  6665. $xzid = '';
  6666. if ($excelid) {
  6667. $excelid = explode(',', trim($excelid, ','));
  6668. foreach ($excelid as $key => $value) {
  6669. $xzid .= " id = " . $value . " or";
  6670. }
  6671. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6672. }
  6673. //取得信息列表
  6674. /**
  6675. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6676. $rows = array();$list = array();
  6677. foreach ($info_list as $key=>$value)
  6678. {
  6679. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6680. }
  6681. **/
  6682. $list = array();
  6683. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6684. foreach ($rows as $key => $value) {
  6685. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6686. $zh = '';
  6687. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6688. foreach ($zt as $v) {
  6689. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6690. }
  6691. $zt = array_sum(array_column($zt, 'num'));
  6692. $number = $value['number'];
  6693. $ftime = time() - 15 * 24 * 3600;
  6694. $warehouse = $this->warehouse->read($value['warehouse']);
  6695. $rows[$key]['warehouse'] = $warehouse['title'];
  6696. $rows[$key]['number'] = $c;
  6697. $rows[$key]['features'] = $zh;
  6698. $rows[$key]['hb'] = $c + $zt;
  6699. }
  6700. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6701. $titlename = "<table border=1>
  6702. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6703. <tr align='center'>
  6704. <td>仓库</td>
  6705. <td>SKU</td>
  6706. <td>产品</td>
  6707. <td>库存数量</td>
  6708. <td>在途数量及预达日期</td>
  6709. <td>在途+库存数量</td>
  6710. </tr>
  6711. </table>";
  6712. $filename = $title . ".xls";
  6713. $tail = "";
  6714. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6715. }
  6716. if (isset($_GET['excel'])) {
  6717. $warehouse = $this->input->get('warehouse', true);
  6718. $sku = $this->input->get('sku', true);
  6719. $cz = $this->input->get('cz', true);
  6720. $text = $this->input->post('text', true);
  6721. $xztime = $this->input->get('xztime', true);
  6722. $timetk = $this->input->get('timetk', true);
  6723. $timetj = $this->input->get('timetj', true);
  6724. $timetk = strtotime($timetk);
  6725. $timetj = strtotime($timetj);
  6726. $where = "time = '0' ";
  6727. if ($warehouse) {
  6728. $where .= " and warehouse = '$warehouse'";
  6729. }
  6730. if ($sku) {
  6731. $where .= " and sku = '$sku'";
  6732. }
  6733. if ($text) {
  6734. $where .= " and text like '%$text%'";
  6735. }
  6736. if ($cz != '') {
  6737. $where .= " and cz = '$cz'";
  6738. }
  6739. if ($timetk && $timetj) {
  6740. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6741. }
  6742. //数据排序
  6743. $order_str = $xztime . " desc";
  6744. //取得信息列表
  6745. $zh = array();
  6746. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6747. foreach ($info_list as $v) {
  6748. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6749. $warehouse = $this->warehouse->read($v['warehouse']);
  6750. $v['warehouse'] = $warehouse['title'];
  6751. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6752. $v['stime'] = date('Y-m-d', $v['stime']);
  6753. if (isset($zh[$v['features']])) {
  6754. $zh[$v['features']]['num'] += $v['num'];
  6755. } else {
  6756. $zh[$v['features']] = $v;
  6757. }
  6758. $zh[$v['features']]['features'] = $c;
  6759. }
  6760. $title = "在途数据" . date('Y-m-d', time());
  6761. $titlename = "<table border=1>
  6762. <tr align='center'>
  6763. <td>仓库</td>
  6764. <td>SKU</td>
  6765. <td>名称</td>
  6766. <td>在途数量</td>
  6767. <td>库存数量</td>
  6768. <td>添加在途日期</td>
  6769. <td>预达日期</td>
  6770. <td>备注</td>
  6771. </tr>
  6772. </table>";
  6773. $filename = $title . ".xls";
  6774. $tail = "";
  6775. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6776. }
  6777. }
  6778. public function _fc()
  6779. {
  6780. $vip = 0;
  6781. if (isset($_SESSION['api'])) {
  6782. $user = $this->user->get_api($_SESSION['api']);
  6783. if ($user['vip'] == 1) {
  6784. $vip = 1;
  6785. }
  6786. } else {
  6787. header('Location: /');
  6788. exit;
  6789. }
  6790. $post = $this->input->post(NULL, TRUE);
  6791. if (isset($post['page'])) {
  6792. $page = $this->input->post('page', true);
  6793. $perpage = $this->input->post('perpage', true);
  6794. $category = $this->input->post('category', true);
  6795. $size = $this->input->post('size', true);
  6796. $grade = $this->input->post('grade', true);
  6797. $color = $this->input->post('color', true);
  6798. $lowe = $this->input->post('lowe', true);
  6799. $sku = $this->input->post('sku');
  6800. $title = $this->input->post('title');
  6801. $warehouse = $this->input->post('warehouse', true);
  6802. $usa = $this->input->post('usa', true);
  6803. $purchase = $this->input->post('purchase', true);
  6804. $lacetype = $this->input->post('lacetype', true);
  6805. $haircap = $this->input->post('haircap', true);
  6806. $density = $this->input->post('density', true);
  6807. $details = $this->input->post('details', true);
  6808. $state = $this->input->post('state', true);
  6809. $ktime = $this->input->post('ktime', true);
  6810. $jtime = $this->input->post('jtime', true);
  6811. $ktime = strtotime($ktime);
  6812. $jtime = strtotime($jtime);
  6813. $where = "state = '11'";
  6814. $gj = "";
  6815. $ck = "";
  6816. if ($lacetype) {
  6817. $where .= " and features like '%-$lacetype-%'";
  6818. }
  6819. if ($category) {
  6820. $where .= " and features like '%-$category-%'";
  6821. }
  6822. if ($size) {
  6823. $where .= " and features like '%-$size-%'";
  6824. }
  6825. if ($grade) {
  6826. $where .= " and features like '%-$grade-%'";
  6827. }
  6828. if ($color) {
  6829. $where .= " and features like '%-$color-%'";
  6830. }
  6831. if ($lowe) {
  6832. $where .= " and features like '%-$lowe-%'";
  6833. }
  6834. if ($haircap) {
  6835. $where .= " and features like '%-$haircap-%'";
  6836. }
  6837. if ($density) {
  6838. $where .= " and features like '%-$density-%'";
  6839. }
  6840. if ($usa) {
  6841. if (!$warehouse) {
  6842. $where .= " and (warehouse = '5' or warehouse = '8')";
  6843. }
  6844. }
  6845. if ($warehouse) {
  6846. $where .= " and warehouse = '$warehouse'";
  6847. }
  6848. if ($details) {
  6849. $where .= " and details = '$details'";
  6850. }
  6851. if ($purchase) {
  6852. $where .= " and purchase = '$purchase'";
  6853. }
  6854. if ($state) {
  6855. $where .= " and state = '$state'";
  6856. }
  6857. if ($ktime && $jtime) {
  6858. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6859. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6860. }
  6861. //数据排序
  6862. $order_str = "id desc";
  6863. if (empty($page)) {
  6864. $start = 0;
  6865. $perpage = 1;
  6866. } else {
  6867. $start = ($page - 1) * $perpage;
  6868. }
  6869. if ($sku) {
  6870. $sku = trim($sku, ' ');
  6871. $sku = trim($sku, ' ');
  6872. $where .= " and sku like '%$sku%'";
  6873. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6874. } else if ($title) {
  6875. $title = trim($title, ' ');
  6876. $title = trim($title, ' ');
  6877. $where .= " and title like '%$title%'";
  6878. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6879. } else {
  6880. //$where .= " and time > '$ktime' and time < '$jtime'";
  6881. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6882. }
  6883. //取得信息列表
  6884. $rows = array();
  6885. $list = array();
  6886. foreach ($info_list as $key => $value) {
  6887. $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'] . '"');
  6888. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6889. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6890. $warehouse = $this->warehouse->read($value['warehouse']);
  6891. $info_list[$key]['warehouse'] = $warehouse['title'];
  6892. $info_list[$key]['number'] = $g;
  6893. $info_list[$key]['features'] = $x;
  6894. $info_list[$key]['x'] = $s;
  6895. }
  6896. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6897. $pagenum = ceil($total / $perpage);
  6898. $over = $total - ($start + $perpage);
  6899. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6900. echo json_encode($rows);
  6901. exit;
  6902. }
  6903. $this->data['vip'] = $vip;
  6904. $this->_Template('whlabel_fc', $this->data);
  6905. }
  6906. public function _fcmb()
  6907. {
  6908. $where = "sku != 'Preset'";
  6909. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6910. foreach ($rows as $k => $v) {
  6911. $warehouse = $this->warehouse->read($v['warehouse']);
  6912. $rows[$k]['warehouse'] = $warehouse['title'];
  6913. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6914. $rows[$k]['t'] = '';
  6915. $rows[$k]['n'] = '';
  6916. }
  6917. $title = "封货产品数据导入模板";
  6918. $titlename = "<table border=1>
  6919. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6920. <tr align='center'>
  6921. <td>仓库</td>
  6922. <td>SKU</td>
  6923. <td>产品</td>
  6924. <td>封存产品总数量</td>
  6925. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6926. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6927. </tr>
  6928. </table>";
  6929. $filename = $title . ".xls";
  6930. $tail = "";
  6931. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6932. }
  6933. public function _fcexcel()
  6934. {
  6935. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6936. $config['upload_path'] = '.' . $dir;
  6937. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6938. $config['allowed_types'] = 'xls|xlsx|csv';
  6939. $config['max_size'] = 10240;
  6940. $this->load->library('upload', $config);
  6941. $this->upload->initialize($config);
  6942. if ($this->upload->do_upload('userfile')) {
  6943. $full_path = $dir . $this->upload->data('file_name');
  6944. $fileName = '.' . $full_path;
  6945. if (!file_exists($fileName)) {
  6946. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6947. exit;
  6948. } else {
  6949. libxml_use_internal_errors(true);
  6950. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6951. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6952. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6953. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6954. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6955. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6956. ++$column; //如果列数大于26行
  6957. $list = array();
  6958. for ($i = 2; $i <= $row; $i++) // 行数循环
  6959. {
  6960. $data = array();
  6961. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6962. {
  6963. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6964. }
  6965. $list[] = $data;
  6966. }
  6967. }
  6968. $i = 0;
  6969. $j = 0;
  6970. $ed = array();
  6971. foreach ($list as $key => $value) {
  6972. $time = time();
  6973. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6974. continue;
  6975. }
  6976. $warehouse = $this->warehouse->get_title($value['0']);
  6977. $sku = $value['1'];
  6978. $type = $value['4']; //调整方式0扣减1删除
  6979. $num = $value['5']; //调整数量
  6980. //$text = $value['4'];//扣减说明
  6981. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6982. if (!$d) //如果没有这个SKU
  6983. {
  6984. $ed[] = array($sku . '-库存中不存在此SKU');
  6985. $j++;
  6986. continue;
  6987. }
  6988. if (!isset($warehouse['id'])) {
  6989. $ed[] = array($sku . '-仓库名错误!');
  6990. $j++;
  6991. continue;
  6992. }
  6993. if ($type == 1 || $type == 2) //扣减库存
  6994. {
  6995. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6996. if (count($data) < abs($num)) {
  6997. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6998. $j++;
  6999. continue;
  7000. }
  7001. if ($type == 1) //转入库存
  7002. {
  7003. for ($i = 0; $i < abs($num); $i++) {
  7004. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7005. }
  7006. } else if ($type == 2) //删除
  7007. {
  7008. for ($i = 0; $i < abs($num); $i++) {
  7009. $this->whlabel->remove($data[$i]['id']);
  7010. }
  7011. }
  7012. } else if ($type == 0) //增加库存
  7013. {
  7014. $post['sku'] = $d['sku'];
  7015. $post['shop'] = '';
  7016. $post['warehouse'] = $warehouse['id'];
  7017. $post['purchase'] = $d['purchase'];
  7018. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7019. $post['state'] = 11;
  7020. $post['title'] = $d['title'];
  7021. $post['number'] = $d['number'];
  7022. $post['features'] = $d['features'];
  7023. $post['enter'] = $time;
  7024. $post['time'] = $time; //操作时间
  7025. for ($i = 0; $i < $num; $i++) {
  7026. $post['label'] = time() . rand(100, 999) . $i;
  7027. $this->whlabel->insert($post);
  7028. }
  7029. }
  7030. sleep(1); //防止入库时间一样,需要延迟1秒
  7031. }
  7032. if ($j > 0) {
  7033. $tt = date('Ymd', time());
  7034. $title = '库存导入错误信息-' . $tt;
  7035. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7036. $tail = "\n";
  7037. $filename = $title . ".xls";
  7038. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7039. $dir = '/data/excel/' . $time . '/';
  7040. $file_name = 'error_' . $time . rand(1000, 9999);
  7041. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7042. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7043. fwrite($myfile, $ecl);
  7044. fclose($myfile);
  7045. $error = $dir . $file_name . '.xls';
  7046. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7047. exit;
  7048. } else {
  7049. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7050. exit;
  7051. }
  7052. }
  7053. }
  7054. public function _fcjxc($arg_array)
  7055. {
  7056. if (isset($_GET['excel'])) {
  7057. $category = $this->input->get('category', true);
  7058. $size = $this->input->get('size', true);
  7059. $grade = $this->input->get('grade', true);
  7060. $color = $this->input->get('color', true);
  7061. $lowe = $this->input->get('lowe', true);
  7062. $sku = $this->input->get('sku');
  7063. $title = $this->input->get('title');
  7064. $warehouse = $arg_array[0];
  7065. $usa = $this->input->get('usa', true);
  7066. $purchase = $this->input->get('purchase', true);
  7067. $lacetype = $this->input->get('lacetype', true);
  7068. $haircap = $this->input->get('haircap', true);
  7069. $density = $this->input->get('density', true);
  7070. $title = $this->input->get('title', true);
  7071. $state = $this->input->get('state', true);
  7072. $ktime = $this->input->get('ktime', true);
  7073. $jtime = $this->input->get('jtime', true);
  7074. $where = "state=11";
  7075. $gj = "";
  7076. $ck = "";
  7077. if ($lacetype) {
  7078. $where .= " and features like '%-$lacetype-%'";
  7079. }
  7080. if ($category) {
  7081. $where .= " and features like '%-$category-%'";
  7082. }
  7083. if ($size) {
  7084. $where .= " and features like '%-$size-%'";
  7085. }
  7086. if ($grade) {
  7087. $where .= " and features like '%-$grade-%'";
  7088. }
  7089. if ($color) {
  7090. $where .= " and features like '%-$color-%'";
  7091. }
  7092. if ($lowe) {
  7093. $where .= " and features like '%-$lowe-%'";
  7094. }
  7095. if ($haircap) {
  7096. $where .= " and features like '%-$haircap-%'";
  7097. }
  7098. if ($density) {
  7099. $where .= " and features like '%-$density-%'";
  7100. }
  7101. if ($usa) {
  7102. if (!$warehouse) {
  7103. $where .= " and (warehouse = '5' or warehouse = '8')";
  7104. }
  7105. }
  7106. if ($warehouse) {
  7107. $where .= " and warehouse = '$warehouse'";
  7108. }
  7109. if ($purchase) {
  7110. $where .= " and purchase = '$purchase'";
  7111. }
  7112. if ($state) {
  7113. $where .= " and state = '$state'";
  7114. }
  7115. $order_str = "id desc";
  7116. if ($sku) {
  7117. $sku = trim($sku, ' ');
  7118. $sku = trim($sku, ' ');
  7119. $where .= " and sku like '%$sku%'";
  7120. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7121. } else if ($title) {
  7122. $title = trim($title, ' ');
  7123. $title = trim($title, ' ');
  7124. $where .= " and title like '%$title%'";
  7125. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7126. } else {
  7127. //$where .= " and time > '$ktime' and time < '$jtime'";
  7128. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7129. }
  7130. //取得信息列表
  7131. $rows = array();
  7132. $list = array();
  7133. foreach ($info_list as $key => $value) {
  7134. $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'] . '"');
  7135. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7136. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7137. $rows[$key] = $value;
  7138. $warehouse = $this->warehouse->read($value['warehouse']);
  7139. $rows[$key]['warehouse'] = $warehouse['title'];
  7140. $rows[$key]['features'] = $g;
  7141. $rows[$key]['a'] = $x;
  7142. $rows[$key]['b'] = $s;
  7143. }
  7144. $title = "总统计表";
  7145. $titlename = "<table border=1>
  7146. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7147. <tr align='center'>
  7148. <td>仓库</td>
  7149. <td>SKU</td>
  7150. <td>产品名称</td>
  7151. <td>录入总量</td>
  7152. <td>取出总量</td>
  7153. <td>剩余总量</td>
  7154. </tr>
  7155. </table>";
  7156. $filename = $title . ".xls";
  7157. $tail = "";
  7158. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7159. }
  7160. $vip = 0;
  7161. if (isset($_SESSION['api'])) {
  7162. $user = $this->user->get_api($_SESSION['api']);
  7163. if ($user['vip'] == 1) {
  7164. $vip = 1;
  7165. }
  7166. } else {
  7167. header('Location: /');
  7168. exit;
  7169. }
  7170. $post = $this->input->post(NULL, TRUE);
  7171. if (isset($post['page'])) {
  7172. $page = $this->input->post('page', true);
  7173. $perpage = $this->input->post('perpage', true);
  7174. $category = $this->input->post('category', true);
  7175. $size = $this->input->post('size', true);
  7176. $grade = $this->input->post('grade', true);
  7177. $color = $this->input->post('color', true);
  7178. $lowe = $this->input->post('lowe', true);
  7179. $sku = $this->input->post('sku');
  7180. $title = $this->input->post('title');
  7181. $warehouse = $arg_array[0];
  7182. $usa = $this->input->post('usa', true);
  7183. $purchase = $this->input->post('purchase', true);
  7184. $lacetype = $this->input->post('lacetype', true);
  7185. $haircap = $this->input->post('haircap', true);
  7186. $density = $this->input->post('density', true);
  7187. $title = $this->input->post('title', true);
  7188. $state = $this->input->post('state', true);
  7189. $ktime = $this->input->post('ktime', true);
  7190. $jtime = $this->input->post('jtime', true);
  7191. $ktime = strtotime($ktime);
  7192. $jtime = strtotime($jtime);
  7193. $where = "state=11";
  7194. $gj = "";
  7195. $ck = "";
  7196. if ($lacetype) {
  7197. $where .= " and features like '%-$lacetype-%'";
  7198. }
  7199. if ($category) {
  7200. $where .= " and features like '%-$category-%'";
  7201. }
  7202. if ($size) {
  7203. $where .= " and features like '%-$size-%'";
  7204. }
  7205. if ($grade) {
  7206. $where .= " and features like '%-$grade-%'";
  7207. }
  7208. if ($color) {
  7209. $where .= " and features like '%-$color-%'";
  7210. }
  7211. if ($lowe) {
  7212. $where .= " and features like '%-$lowe-%'";
  7213. }
  7214. if ($haircap) {
  7215. $where .= " and features like '%-$haircap-%'";
  7216. }
  7217. if ($density) {
  7218. $where .= " and features like '%-$density-%'";
  7219. }
  7220. if ($usa) {
  7221. if (!$warehouse) {
  7222. $where .= " and (warehouse = '5' or warehouse = '8')";
  7223. }
  7224. }
  7225. if ($warehouse) {
  7226. $where .= " and warehouse = '$warehouse'";
  7227. }
  7228. if ($purchase) {
  7229. $where .= " and purchase = '$purchase'";
  7230. }
  7231. if ($state) {
  7232. $where .= " and state = '$state'";
  7233. }
  7234. if ($ktime && $jtime) {
  7235. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7236. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7237. }
  7238. //数据排序
  7239. $order_str = "id desc";
  7240. $xs = 0;
  7241. $rows = array();
  7242. $list = array();
  7243. if (empty($page)) {
  7244. $start = 0;
  7245. $perpage = 1;
  7246. } else {
  7247. $start = ($page - 1) * $perpage;
  7248. }
  7249. if ($sku || $title) {
  7250. if ($title) {
  7251. $title = trim($title, ' ');
  7252. $title = trim($title, ' ');
  7253. $where .= " and title like '%$title%'";
  7254. } else {
  7255. $sku = trim($sku, ' ');
  7256. $sku = trim($sku, ' ');
  7257. $where .= " and sku like '%$sku%'";
  7258. }
  7259. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7260. foreach ($info_list as $key => $value) {
  7261. $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'] . '"');
  7262. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7263. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7264. $rows[$key] = $value;
  7265. $warehouse = $this->warehouse->read($value['warehouse']);
  7266. $rows[$key]['warehouse'] = $warehouse['title'];
  7267. $rows[$key]['features'] = $g;
  7268. $rows[$key]['a'] = $x;
  7269. $rows[$key]['b'] = $s;
  7270. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7271. $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天销量
  7272. $yj = $c / ($xl / 30);
  7273. if ($yj < 7) {
  7274. $rows[$key]['y'] = round($yj) . '天销量';
  7275. } else {
  7276. $rows[$key]['y'] = '正常';
  7277. }
  7278. }
  7279. } else {
  7280. //$where .= " and time > '$ktime' and time < '$jtime'";
  7281. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7282. foreach ($info_list as $key => $value) {
  7283. $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'] . '"');
  7284. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7285. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7286. $zs[$key] = $value;
  7287. $warehouse = $this->warehouse->read($value['warehouse']);
  7288. $zs[$key]['warehouse'] = $warehouse['title'];
  7289. $zs[$key]['features'] = $g;
  7290. $zs[$key]['a'] = $x;
  7291. $zs[$key]['b'] = $s;
  7292. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7293. $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天销量
  7294. $yj = $c / ($xl / 30);
  7295. if ($yj < 7) {
  7296. $zs[$key]['y'] = round($yj) . '天销量';
  7297. $rows[$key] = $zs[$key];
  7298. }
  7299. }
  7300. }
  7301. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7302. $pagenum = ceil($total / $perpage);
  7303. $over = $total - ($start + $perpage);
  7304. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7305. echo json_encode($rows);
  7306. exit;
  7307. }
  7308. $this->data['arg_array'] = $arg_array[0];
  7309. $this->_Template('whlabel_fcjxc', $this->data);
  7310. }
  7311. public function _0kcdel()
  7312. {
  7313. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7314. $config['upload_path'] = '.' . $dir;
  7315. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7316. $config['allowed_types'] = 'xls|xlsx|csv';
  7317. $config['max_size'] = 10240;
  7318. $this->load->library('upload', $config);
  7319. $this->upload->initialize($config);
  7320. if ($this->upload->do_upload('userfile')) {
  7321. $full_path = $dir . $this->upload->data('file_name');
  7322. $fileName = '.' . $full_path;
  7323. if (!file_exists($fileName)) {
  7324. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7325. exit;
  7326. } else {
  7327. require_once "./data/excel/PHPExcel/IOFactory.php";
  7328. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7329. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7330. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7331. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7332. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7333. ++$column; //如果列数大于26行
  7334. $list = array();
  7335. for ($i = 2; $i <= $row; $i++) // 行数循环
  7336. {
  7337. $data = array();
  7338. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7339. {
  7340. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7341. }
  7342. $list[] = $data;
  7343. }
  7344. }
  7345. $i = 0;
  7346. $j = 0;
  7347. $ed = array();
  7348. foreach ($list as $key => $value) {
  7349. $time = time();
  7350. if ($value['0'] == "" || $value['1'] == "") {
  7351. continue;
  7352. }
  7353. $warehouse = $this->warehouse->get_title($value['0']);
  7354. $sku = $value['1'];
  7355. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7356. if (!$d) //如果没有这个SKU
  7357. {
  7358. $ed[] = array($sku . '-库存中不存在此SKU');
  7359. $j++;
  7360. continue;
  7361. }
  7362. if (!isset($warehouse['id'])) {
  7363. $ed[] = array($sku . '-仓库名错误!');
  7364. $j++;
  7365. continue;
  7366. }
  7367. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7368. if ($z < 1) {
  7369. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7370. foreach ($z as $v) {
  7371. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7372. if (count($zt) > 0) {
  7373. $ed[] = array($sku . '-有在途库存无法删除!');
  7374. $j++;
  7375. continue;
  7376. }
  7377. $this->whlabel->remove($v['id']);
  7378. }
  7379. } else {
  7380. $ed[] = array($sku . '-非0库存!');
  7381. $j++;
  7382. continue;
  7383. }
  7384. }
  7385. if ($j > 0) {
  7386. $tt = date('Ymd', time());
  7387. $title = '删除0库存错误信息-' . $tt;
  7388. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7389. $tail = "\n";
  7390. $filename = $title . ".xls";
  7391. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7392. $dir = '/data/excel/' . $time . '/';
  7393. $file_name = 'error_' . $time . rand(1000, 9999);
  7394. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7395. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7396. fwrite($myfile, $ecl);
  7397. fclose($myfile);
  7398. $error = $dir . $file_name . '.xls';
  7399. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7400. exit;
  7401. } else {
  7402. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7403. exit;
  7404. }
  7405. }
  7406. }
  7407. public function _gbhtype()
  7408. {
  7409. $post = $this->input->post(NULL, TRUE);
  7410. if (isset($post['s'])) {
  7411. $n = $this->input->post('n');
  7412. $d = $this->input->post('s');
  7413. if (!$d) {
  7414. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7415. exit;
  7416. }
  7417. $d = explode(',', trim($d, ','));
  7418. $t = $this->whlabel_type->read($n);
  7419. //循环删除记录
  7420. foreach ($d as $v) {
  7421. $u = $this->whlabel->read($v);
  7422. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7423. foreach ($data as $val) {
  7424. $this->whlabel->save(array('type' => $n), $val['id']);
  7425. }
  7426. }
  7427. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7428. }
  7429. }
  7430. //出库、退库导出
  7431. public function _dccrtype()
  7432. {
  7433. $classid = $this->classid->sku();
  7434. $pm = $classid;
  7435. $typeclass = array();
  7436. $tc = $this->typeclass->find_all();
  7437. foreach ($tc as $v) {
  7438. $typeclass[$v['id']] = $v;
  7439. }
  7440. $prc = array();
  7441. $purchase = $this->purchase->find_all();
  7442. foreach ($purchase as $k => $v) {
  7443. $prc[$v['id']] = $v['title'];
  7444. }
  7445. if (isset($_GET['sid'])) {
  7446. $wh = array();
  7447. $w = $this->warehouse->find_all('1=1', 'id,title');
  7448. foreach ($w as $v) {
  7449. $wh[$v['id']] = $v['title'];
  7450. }
  7451. $type = $this->input->get('excel', true);
  7452. $category = $this->input->get('category', true);
  7453. $size = $this->input->get('size', true);
  7454. $grade = $this->input->get('grade', true);
  7455. $color = $this->input->get('color', true);
  7456. $lowe = $this->input->get('lowe', true);
  7457. $sku = $this->input->get('sku', true);
  7458. $warehouse = $this->input->get('warehouse', true);
  7459. $lacetype = $this->input->get('lacetype', true);
  7460. $lacecolor = $this->input->get('lacecolor', true);
  7461. $density = $this->input->get('density', true);
  7462. $haircap = $this->input->get('haircap', true);
  7463. $purchase = $this->input->get('purchase', true);
  7464. $title = $this->input->get('title', true);
  7465. $state = $this->input->get('state', true);
  7466. $sid = $this->input->get('sid', true);
  7467. $ktime = $this->input->get('ktime', true);
  7468. $jtime = $this->input->get('jtime', true);
  7469. $ktime = strtotime($ktime);
  7470. $jtime = strtotime($jtime);
  7471. $where = "1=1";
  7472. $gj = "";
  7473. $ck = "";
  7474. if ($category) {
  7475. $where .= " and features like '%-$category-%'";
  7476. }
  7477. if ($size) {
  7478. $where .= " and features like '%-$size-%'";
  7479. }
  7480. if ($grade) {
  7481. $where .= " and features like '%-$grade-%'";
  7482. }
  7483. if ($color) {
  7484. $where .= " and features like '%-$color-%'";
  7485. }
  7486. if ($lowe) {
  7487. $where .= " and features like '%-$lowe-%'";
  7488. }
  7489. if ($warehouse) {
  7490. $where .= " and warehouse = '$warehouse'";
  7491. }
  7492. if ($purchase) {
  7493. $where .= " and purchase = '$purchase'";
  7494. }
  7495. if ($state) {
  7496. $where .= " and state = '$state'";
  7497. }
  7498. if ($lacetype) {
  7499. $where .= " and features like '%-$lacetype-%'";
  7500. }
  7501. if ($lacecolor) {
  7502. $where .= " and features like '%-$lacecolor-%'";
  7503. }
  7504. if ($density) {
  7505. $where .= " and features like '%-$density-%'";
  7506. }
  7507. if ($haircap) {
  7508. $where .= " and features like '%-$haircap-%'";
  7509. }
  7510. if ($title) {
  7511. $title = trim($title, ' ');
  7512. $title = trim($title, ' ');
  7513. $where .= " and title like '%$title%'";
  7514. }
  7515. if ($sku) {
  7516. $sku = trim($sku, ' ');
  7517. $sku = trim($sku, ' ');
  7518. $where .= " and sku like '%$sku%'";
  7519. }
  7520. if ($ktime && $jtime) {
  7521. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7522. }
  7523. $sidwhere = '';
  7524. if ($sid) {
  7525. $sd = "";
  7526. $s = explode(',', trim($sid, ','));
  7527. foreach ($s as $value) {
  7528. $sd .= " id = " . $value . " or";
  7529. }
  7530. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7531. }
  7532. //数据排序
  7533. $order_str = "time desc";
  7534. if (empty($page)) {
  7535. $start = 0;
  7536. $perpage = 1;
  7537. } else {
  7538. $start = ($page - 1) * $perpage;
  7539. }
  7540. $wh = array();
  7541. $w = $this->warehouse->find_all('1=1', 'id,title');
  7542. foreach ($w as $v) {
  7543. $wh[$v['id']] = $v['title'];
  7544. }
  7545. $wt = array();
  7546. $whlabel_type = $this->whlabel_type->find_all();
  7547. foreach ($whlabel_type as $v) {
  7548. $wt[$v['id']] = $v['title'];
  7549. }
  7550. $classid = $this->classid->sku();
  7551. $list = array();
  7552. $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');
  7553. foreach ($rows_r as $key => $value) {
  7554. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7555. $pm = $classid;
  7556. $jm = $classid;
  7557. $rows_r[$key]['enter'] = '入库';
  7558. $rows_r[$key]['time'] = $value['enter'];
  7559. if ($value['rktype'] == 1) {
  7560. $rows_r[$key]['rktype'] = '采购入库';
  7561. } else if ($value['rktype'] == 2) {
  7562. $rows_r[$key]['rktype'] = '盘盈调整';
  7563. } else if ($value['rktype'] == 3) {
  7564. $rows_r[$key]['rktype'] = '其他调整入库';
  7565. } else if ($value['rktype'] == 4) {
  7566. $rows_r[$key]['rktype'] = '其他调整入库';
  7567. } else if ($value['rktype'] == 5) {
  7568. $rows_r[$key]['rktype'] = '退库入库';
  7569. } else if ($value['rktype'] == 6) {
  7570. $rows_r[$key]['rktype'] = '退货可用入库';
  7571. } else if ($value['rktype'] == 7) {
  7572. $rows_r[$key]['rktype'] = '形态转换入库';
  7573. } else {
  7574. $rows_r[$key]['rktype'] = '';
  7575. }
  7576. $features = explode('-', trim($value['features'], '-'));
  7577. foreach ($features as $v) {
  7578. if (isset($typeclass[$v])) {
  7579. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7580. $pm[$typeclass[$v]['classid']] = $zh[0];
  7581. }
  7582. if (isset($typeclass[$v])) {
  7583. if (isset($jm[$typeclass[$v]['classid']])) {
  7584. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7585. }
  7586. }
  7587. }
  7588. $zh = implode(" ", $pm);
  7589. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7590. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7591. $rows_r[$key]['zh'] = $zh;
  7592. $jm = array_filter($jm);
  7593. $rows_r[$key]['features'] = implode("-", $jm);
  7594. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7595. }
  7596. $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');
  7597. foreach ($rows_c as $key => $value) {
  7598. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7599. $pm = $classid;
  7600. $jm = $classid;
  7601. $rows_c[$key]['time'] = $value['outk'];
  7602. $rows_c[$key]['outk'] = '出库';
  7603. if ($value['cktype'] == 1) {
  7604. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7605. } else if ($value['cktype'] == 2) {
  7606. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7607. } else if ($value['cktype'] == 3) {
  7608. $rows_c[$key]['cktype'] = '盘亏调整';
  7609. } else if ($value['cktype'] == 4) {
  7610. $rows_c[$key]['cktype'] = '其他调整出库';
  7611. } else if ($value['cktype'] == 5) {
  7612. $rows_c[$key]['cktype'] = '形态转换出库';
  7613. } else {
  7614. $rows_c[$key]['cktype'] = '';
  7615. }
  7616. unset($rows_c[$key]['state']);
  7617. $features = explode('-', trim($value['features'], '-'));
  7618. foreach ($features as $v) {
  7619. if (isset($typeclass[$v])) {
  7620. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7621. $pm[$typeclass[$v]['classid']] = $zh[0];
  7622. }
  7623. if (isset($typeclass[$v])) {
  7624. if (isset($jm[$typeclass[$v]['classid']])) {
  7625. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7626. }
  7627. }
  7628. }
  7629. $zh = implode(" ", $pm);
  7630. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7631. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7632. $rows_c[$key]['zh'] = $zh;
  7633. $jm = array_filter($jm);
  7634. $rows_c[$key]['features'] = implode("-", $jm);
  7635. $rows_c[$key]['number'] = 1;
  7636. }
  7637. $merged = $rows_r;
  7638. foreach ($rows_c as $key => $value) {
  7639. if (isset($merged[$key])) {
  7640. $merged[] = $value;
  7641. } else {
  7642. $merged[$key] = $value;
  7643. }
  7644. }
  7645. usort($merged, function ($a, $b) {
  7646. return $a['time'] - $b['time'];
  7647. });
  7648. foreach ($merged as $key => $value) {
  7649. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7650. }
  7651. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7652. $titlename = "<table border=1>
  7653. <tr align='center'>
  7654. <td>仓库</td>
  7655. <td>SKU</td>
  7656. <td>商品名称</td>
  7657. <td>仓库品名</td>
  7658. <td>料号</td>
  7659. <td>时间</td>
  7660. <td>操作</td>
  7661. <td>类型</td>
  7662. <td>数量</td>
  7663. <td>备注</td>
  7664. </tr>
  7665. </table>";
  7666. $filename = $title . ".xlsx";
  7667. $tail = "";
  7668. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7669. }
  7670. }
  7671. /*************************************处理exceljs导出****************************************************/
  7672. public function _excelrjs(){
  7673. if (isset($_GET['excel'])) {
  7674. $category = $this->input->get('category', true);
  7675. $size = $this->input->get('size', true);
  7676. $grade = $this->input->get('grade', true);
  7677. $color = $this->input->get('color', true);
  7678. $lowe = $this->input->get('lowe', true);
  7679. $sku = $this->input->get('sku', true);
  7680. $warehouse = $this->input->get('warehouse', true);
  7681. $purchase = $this->input->get('purchase', true);
  7682. $ktime = $this->input->get('ktime', true);
  7683. $jtime = $this->input->get('jtime', true);
  7684. $ktime = strtotime($ktime);
  7685. $jtime = strtotime($jtime);
  7686. $where = "1=1";
  7687. $gj = "";
  7688. $ck = "";
  7689. if ($category) {
  7690. $where .= " and features like '%-$category-%'";
  7691. }
  7692. if ($size) {
  7693. $where .= " and features like '%-$size-%'";
  7694. }
  7695. if ($grade) {
  7696. $where .= " and features like '%-$grade-%'";
  7697. }
  7698. if ($color) {
  7699. $where .= " and features like '%-$color-%'";
  7700. }
  7701. if ($lowe) {
  7702. $where .= " and features like '%-$lowe-%'";
  7703. }
  7704. if ($warehouse) {
  7705. $where .= " and warehouse = '$warehouse'";
  7706. }
  7707. if ($purchase) {
  7708. $where .= " and purchase = '$purchase'";
  7709. }
  7710. if ($sku) {
  7711. $where .= " and sku = '$sku'";
  7712. }
  7713. if ($ktime && $jtime) {
  7714. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7715. }
  7716. //数据排序
  7717. $order_str = "id desc";
  7718. if (empty($page)) {
  7719. $start = 0;
  7720. $perpage = 1;
  7721. } else {
  7722. $start = ($page - 1) * $perpage;
  7723. }
  7724. $list = array();
  7725. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7726. foreach ($rows as $value) {
  7727. $ck = $this->warehouse->read($value['warehouse']);
  7728. $warehouse = $ck['title'];
  7729. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7730. $retreatwarehouse = $tkck['title'];
  7731. $gy = $this->purchase->read($value['purchase']);
  7732. $purchase = $gy['title'];
  7733. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7734. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7735. }
  7736. if(empty($list)){
  7737. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7738. }else{
  7739. $final_list = [];
  7740. foreach($list as $v){
  7741. $final_list[] = array_values($v);
  7742. }
  7743. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7744. array_unshift($final_list,[
  7745. "仓库","SKU","商品名称","时间","数量"
  7746. ]);
  7747. array_unshift($final_list,[
  7748. $title,"","","",""
  7749. ]);
  7750. $merges = [
  7751. [
  7752. "s"=>["r"=>0,"c"=>0],
  7753. "e"=>["r"=>0,"c"=>4]
  7754. ]
  7755. ];
  7756. $cols = [
  7757. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7758. ];
  7759. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7760. }
  7761. }
  7762. }
  7763. //出库、退库导出
  7764. public function _excelctjs()
  7765. {
  7766. $classid = $this->classid->sku();
  7767. $pm = $classid;
  7768. $typeclass = array();
  7769. $tc = $this->typeclass->find_all();
  7770. foreach ($tc as $v) {
  7771. $typeclass[$v['id']] = $v;
  7772. }
  7773. $prc = array();
  7774. $purchase = $this->purchase->find_all();
  7775. foreach ($purchase as $k => $v) {
  7776. $prc[$v['id']] = $v['title'];
  7777. }
  7778. if (isset($_GET['excel'])) {
  7779. $wh = array();
  7780. $w = $this->warehouse->find_all('1=1', 'id,title');
  7781. foreach ($w as $v) {
  7782. $wh[$v['id']] = $v['title'];
  7783. }
  7784. $type = $this->input->get('excel', true);
  7785. $category = $this->input->get('category', true);
  7786. $size = $this->input->get('size', true);
  7787. $grade = $this->input->get('grade', true);
  7788. $color = $this->input->get('color', true);
  7789. $lowe = $this->input->get('lowe', true);
  7790. $sku = $this->input->get('sku', true);
  7791. $title = $this->input->get('title', true);
  7792. $warehouse = $this->input->get('warehouse', true);
  7793. $purchase = $this->input->get('purchase', true);
  7794. $lacetype = $this->input->get('lacetype', true);
  7795. $haircap = $this->input->get('haircap', true);
  7796. $lacecolor = $this->input->get('lacecolor', true);
  7797. $density = $this->input->get('density', true);
  7798. $details = $this->input->get('details', true);
  7799. $state = $this->input->get('state', true);
  7800. $shop = $this->input->get('shop', true);
  7801. $hairnumber = $this->input->get('hairnumber', true);
  7802. $type_leixi = $this->input->get('type', true);
  7803. $cpbz = $this->input->get('cpbz', true);
  7804. $sm = $this->input->get('sm', true);
  7805. $sid = $this->input->get('sid', true);
  7806. $ktime = $this->input->get('ktime', true);
  7807. $jtime = $this->input->get('jtime', true);
  7808. $ktime = strtotime($ktime);
  7809. $jtime = strtotime($jtime);
  7810. //$where = " 1=1 ";
  7811. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7812. $where = " sku != '' ";
  7813. $gj = "";
  7814. $ck = "";
  7815. if ($category) {
  7816. $where .= " and features like '%-$category-%'";
  7817. }
  7818. if ($size) {
  7819. $where .= " and features like '%-$size-%'";
  7820. }
  7821. if ($grade) {
  7822. $where .= " and features like '%-$grade-%'";
  7823. }
  7824. if ($color) {
  7825. $where .= " and features like '%-$color-%'";
  7826. }
  7827. if ($lowe) {
  7828. $where .= " and features like '%-$lowe-%'";
  7829. }
  7830. if ($warehouse) {
  7831. $where .= " and warehouse = '$warehouse'";
  7832. }
  7833. if ($purchase) {
  7834. $where .= " and purchase = '$purchase'";
  7835. }
  7836. if ($state) {
  7837. $where .= " and state = '$state'";
  7838. }
  7839. if ($lacetype) {
  7840. $where .= " and features like '%-$lacetype-%'";
  7841. }
  7842. if ($lacecolor) {
  7843. $where .= " and features like '%-$lacecolor-%'";
  7844. }
  7845. if ($density) {
  7846. $where .= " and features like '%-$density-%'";
  7847. }
  7848. if ($haircap) {
  7849. $where .= " and features like '%-$haircap-%'";
  7850. }
  7851. if ($details) {
  7852. $where .= " and details = '$details'";
  7853. }
  7854. if ($shop) {
  7855. $where .= " and shop like '%$shop%'";
  7856. }
  7857. if ($title) {
  7858. $title = trim($title, ' ');
  7859. $title = trim($title, ' ');
  7860. $where .= " and title like '%$title%'";
  7861. }
  7862. if (!empty($hairnumber)) {
  7863. $where .= " and features like '%-128-%' ";
  7864. if ($hairnumber < 0) {
  7865. $class_list = $this->typeclass->find_all('classid = 43');
  7866. foreach ($class_list as $v) {
  7867. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7868. }
  7869. } else {
  7870. $where .= " and features like '%-$hairnumber-%'";
  7871. }
  7872. }
  7873. if ($type_leixi) {
  7874. $where .= " and type = '$type_leixi'";
  7875. }
  7876. if ($cpbz) {
  7877. $where .= " and cpbz like '%$cpbz%' ";
  7878. }
  7879. if ($sm) {
  7880. $where .= " and sm like '%$sm%' ";
  7881. }
  7882. if ($sku) {
  7883. $sku = trim($sku, ' ');
  7884. $sku = trim($sku, ' ');
  7885. $where .= " and sku like '%$sku%'";
  7886. }
  7887. if ($ktime && $jtime) {
  7888. if ($type == 1) {
  7889. $tl = '出库';
  7890. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7891. } else if ($type == 2) {
  7892. $tl = '退库';
  7893. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7894. } else if ($type == 3) {
  7895. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7896. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7897. } else if ($type == 4) {
  7898. $tl = '出库+零售';
  7899. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7900. } else if ($type == 5) {
  7901. $tl = '零售';
  7902. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7903. }
  7904. }
  7905. $sidwhere = '';
  7906. if ($sid) {
  7907. $sd = "";
  7908. $s = explode(',', trim($sid, ','));
  7909. foreach ($s as $value) {
  7910. $sd .= " id = " . $value . " or";
  7911. }
  7912. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7913. }
  7914. //数据排序
  7915. $order_str = "time desc";
  7916. if (empty($page)) {
  7917. $start = 0;
  7918. $perpage = 1;
  7919. } else {
  7920. $start = ($page - 1) * $perpage;
  7921. }
  7922. //取得信息列表
  7923. if ($type != 3 && $type != 5) {
  7924. if ($type == 1 || $type == 4) {
  7925. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7926. foreach ($info_list as $key => $value) {
  7927. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7928. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7929. $warehouse = $this->warehouse->read($value['warehouse']);
  7930. $info_list[$key]['warehouse'] = $warehouse['title'];
  7931. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7932. $features = explode('-', trim($features, '-'));
  7933. $pm = $classid;
  7934. foreach ($features as $k => $v) {
  7935. if ($v != 0) {
  7936. if (!isset($typeclass[$v])) {
  7937. continue;
  7938. }
  7939. if (isset($pm[$typeclass[$v]['classid']])) {
  7940. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7941. $tz = explode('|', $typeclass[$v]['zh']);
  7942. $pm[$typeclass[$v]['classid']] = $tz[0];
  7943. } else {
  7944. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7945. }
  7946. }
  7947. }
  7948. }
  7949. $zh = implode(" ", $pm);
  7950. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7951. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7952. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7953. $info_list[$key]['features'] = $zh;
  7954. }
  7955. $final_list = [];
  7956. foreach($info_list as $k=>$v){
  7957. $number = "";
  7958. if(!empty($v['orderinfo'])){
  7959. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7960. if(!empty($tmp_info['number'])){
  7961. $number = $tmp_info['number'];
  7962. }
  7963. }
  7964. $final_list[] = [
  7965. 'warehouse'=>$v['warehouse'],
  7966. 'purchase'=>$v['purchase'],
  7967. 'sku'=>$v['sku'],
  7968. 'title'=>$v['title'],
  7969. 'features'=>$v['features'],
  7970. 'label'=>$v['label'],
  7971. 'orderinfo'=>$v['orderinfo'],
  7972. 'number'=>$number,
  7973. 'waybill'=>$v['waybill'],
  7974. 'outk'=>$v['outk'],
  7975. ];
  7976. }
  7977. } else {
  7978. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7979. foreach ($info_list as $key => $value) {
  7980. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7981. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  7982. $warehouse = $this->warehouse->read($value['warehouse']);
  7983. $info_list[$key]['warehouse'] = $warehouse['title'];
  7984. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7985. $features = explode('-', trim($features, '-'));
  7986. $pm = $classid;
  7987. foreach ($features as $k => $v) {
  7988. if ($v != 0) {
  7989. if (!isset($typeclass[$v])) {
  7990. continue;
  7991. }
  7992. if (isset($pm[$typeclass[$v]['classid']])) {
  7993. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7994. $tz = explode('|', $typeclass[$v]['zh']);
  7995. $pm[$typeclass[$v]['classid']] = $tz[0];
  7996. } else {
  7997. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7998. }
  7999. }
  8000. }
  8001. }
  8002. $zh = implode(" ", $pm);
  8003. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8004. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8005. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8006. $info_list[$key]['features'] = $zh;
  8007. }
  8008. $final_list = [];
  8009. foreach($info_list as $k=>$v){
  8010. $number = "";
  8011. if(!empty($v['orderinfo'])){
  8012. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8013. if(!empty($tmp_info['number'])){
  8014. $number = $tmp_info['number'];
  8015. }
  8016. }
  8017. $final_list[] = [
  8018. 'warehouse'=>$v['warehouse'],
  8019. 'purchase'=>$v['purchase'],
  8020. 'sku'=>$v['sku'],
  8021. 'title'=>$v['title'],
  8022. 'features'=>$v['features'],
  8023. 'label'=>$v['label'],
  8024. 'orderinfo'=>$v['orderinfo'],
  8025. 'number'=>$number,
  8026. 'waybill'=>$v['waybill'],
  8027. 'retreat'=>$v['retreat'],
  8028. ];
  8029. }
  8030. }
  8031. if(empty($final_list)){
  8032. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8033. }else{
  8034. $end_list = [];
  8035. foreach($final_list as $v){
  8036. $end_list[] = array_values($v);
  8037. }
  8038. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8039. array_unshift($end_list,[
  8040. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8041. ]);
  8042. array_unshift($end_list,[
  8043. $title,"","","","","","","","",""
  8044. ]);
  8045. $merges = [
  8046. [
  8047. "s"=>["r"=>0,"c"=>0],
  8048. "e"=>["r"=>0,"c"=>9]
  8049. ]
  8050. ];
  8051. $cols = [
  8052. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8053. ];
  8054. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8055. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8056. ] )));
  8057. }
  8058. } else if ($type == 5) {
  8059. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8060. foreach ($info_list as $key => $value) {
  8061. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8062. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8063. $warehouse = $this->warehouse->read($value['warehouse']);
  8064. $info_list[$key]['warehouse'] = $warehouse['title'];
  8065. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8066. $features = explode('-', trim($features, '-'));
  8067. $pm = $classid;
  8068. foreach ($features as $k => $v) {
  8069. if ($v != 0) {
  8070. if (!isset($typeclass[$v])) {
  8071. continue;
  8072. }
  8073. if (isset($pm[$typeclass[$v]['classid']])) {
  8074. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8075. $tz = explode('|', $typeclass[$v]['zh']);
  8076. $pm[$typeclass[$v]['classid']] = $tz[0];
  8077. } else {
  8078. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8079. }
  8080. }
  8081. }
  8082. }
  8083. $zh = implode(" ", $pm);
  8084. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8085. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8086. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8087. $info_list[$key]['features'] = $zh;
  8088. }
  8089. if(empty($info_list)){
  8090. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8091. }else{
  8092. $final_list = [];
  8093. foreach($info_list as $v){
  8094. $final_list[] = array_values($v);
  8095. }
  8096. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8097. array_unshift($final_list,[
  8098. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8099. ]);
  8100. array_unshift($final_list,[
  8101. $title,"","","","","","",
  8102. ]);
  8103. $merges = [
  8104. [
  8105. "s"=>["r"=>0,"c"=>0],
  8106. "e"=>["r"=>0,"c"=>6]
  8107. ]
  8108. ];
  8109. $cols = [
  8110. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8111. ];
  8112. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8113. }
  8114. } else {
  8115. $wh = array();
  8116. $w = $this->warehouse->find_all('1=1', 'id,title');
  8117. foreach ($w as $v) {
  8118. $wh[$v['id']] = $v['title'];
  8119. }
  8120. $wt = array();
  8121. $whlabel_type = $this->whlabel_type->find_all();
  8122. foreach ($whlabel_type as $v) {
  8123. $wt[$v['id']] = $v['title'];
  8124. }
  8125. $classid = $this->classid->sku();
  8126. $list = array();
  8127. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8128. foreach ($rows as $key => $value) {
  8129. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8130. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8131. $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');
  8132. $details = array();
  8133. $cpid = array();
  8134. $cpbz = array();
  8135. $c = 0;
  8136. $g = 0;
  8137. $x = 0;
  8138. $t = 0;
  8139. $s = 0;
  8140. $q = 0;
  8141. foreach ($sd as $k => $v) {
  8142. if ($v['state'] == 0) {
  8143. $c++;
  8144. }
  8145. if ($v['state'] != 9) {
  8146. $g++;
  8147. }
  8148. if ($v['outk'] > 1) {
  8149. $x++;
  8150. }
  8151. if ($v['retreat'] > 0) {
  8152. $t++;
  8153. }
  8154. if ($v['state'] == 8) {
  8155. $s++;
  8156. }
  8157. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8158. $q++;
  8159. }
  8160. $details[$v['details']] = $v['details'];
  8161. if ($v['cpid'] != 0) {
  8162. $cpid[$v['cpid']] = $v['cpid'];
  8163. }
  8164. if ($v['cpbz'] != '') {
  8165. $cpbz[$v['cpbz']] = $v['cpbz'];
  8166. }
  8167. }
  8168. if (isset($wt[$value['type']])) {
  8169. $rows[$key]['type'] = $wt[$value['type']];
  8170. } else {
  8171. $rows[$key]['type'] = '未设置';
  8172. }
  8173. $rows[$key]['details'] = implode("、", $details);
  8174. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8175. $ftime = time() - 15 * 24 * 3600;
  8176. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8177. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8178. $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);
  8179. $rows[$key]['c'] = $c;
  8180. $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);
  8181. $rows[$key]['t'] = $t;
  8182. $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'] . '"');
  8183. $rows[$key]['z'] = $z;
  8184. // $jm = $classid;
  8185. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8186. $features = explode('-', trim($features, '-'));
  8187. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8188. }
  8189. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8190. $final_list =[];
  8191. foreach($tmp_list as $k=>$v){
  8192. $final_list[] = [
  8193. "warehouse"=>$v['warehouse'],
  8194. "purchase"=>$v['purchase'],
  8195. "details"=>$v['details'],
  8196. "cpid"=>$v['cpid'],
  8197. "sku"=>$v['sku'],
  8198. "title"=>$v['title'],
  8199. "features"=>$v['pm'],
  8200. "cpbz"=>$v['cpbz'],
  8201. "sm"=>$v['sm'],
  8202. "type"=>$v['type'],
  8203. "g"=>$v["g"],
  8204. "c"=>$v["c"],
  8205. "x"=>$v["x"],
  8206. "t"=>$v["t"],
  8207. "z"=>$v["z"],
  8208. "jm"=>$v["jm"],
  8209. "weight"=>$v["weight"],
  8210. "asd"=>$v["asd"],
  8211. ];
  8212. }
  8213. if(empty($final_list)){
  8214. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8215. }else{
  8216. $end_list = [];
  8217. foreach($final_list as $v){
  8218. $end_list[] = array_values($v);
  8219. }
  8220. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8221. array_unshift($end_list,[
  8222. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8223. ]);
  8224. array_unshift($end_list,[
  8225. $title,"","","","","","","","","","","","","","","","","",""
  8226. ]);
  8227. $merges = [
  8228. [
  8229. "s"=>["r"=>0,"c"=>0],
  8230. "e"=>["r"=>0,"c"=>6]
  8231. ]
  8232. ];
  8233. $cols = [
  8234. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8235. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8236. ];
  8237. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8238. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8239. ])));
  8240. }
  8241. }
  8242. }
  8243. }
  8244. public function _exceljxcjs(){
  8245. $classid = $this->classid->sku();
  8246. $pm = $classid;
  8247. $typeclass = array();
  8248. $tc = $this->typeclass->find_all();
  8249. foreach ($tc as $v) {
  8250. $typeclass[$v['id']] = $v;
  8251. }
  8252. $prc = array();
  8253. $purchase = $this->purchase->find_all();
  8254. foreach ($purchase as $k => $v) {
  8255. $prc[$v['id']] = $v['title'];
  8256. }
  8257. if(!isset($_GET['excel'])){
  8258. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8259. }
  8260. $where = "sku != 'Preset'";
  8261. //数据排序
  8262. $order_str = "id desc";
  8263. if (empty($page)) {
  8264. $start = 0;
  8265. $perpage = 1;
  8266. } else {
  8267. $start = ($page - 1) * $perpage;
  8268. }
  8269. $category = $this->input->get('category', true);
  8270. $warehouse = $this->input->get('warehouse', true);
  8271. $excelid = $this->input->get('sid', true);
  8272. if ($category) {
  8273. $where .= " and features like '%-$category-%'";
  8274. }
  8275. if ($warehouse) {
  8276. $where .= " and warehouse = '$warehouse'";
  8277. }
  8278. $xzid = '';
  8279. if ($excelid) {
  8280. $excelid = explode(',', trim($excelid, ','));
  8281. foreach ($excelid as $key => $value) {
  8282. $xzid .= " id = " . $value . " or";
  8283. }
  8284. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8285. }
  8286. $wt = array();
  8287. $whlabel_type = $this->whlabel_type->find_all();
  8288. foreach ($whlabel_type as $v) {
  8289. $wt[$v['id']] = $v['title'];
  8290. }
  8291. $wh = array();
  8292. $w = $this->warehouse->find_all('1=1', 'id,title');
  8293. foreach ($w as $v) {
  8294. $wh[$v['id']] = $v['title'];
  8295. }
  8296. $list = array();
  8297. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8298. foreach ($rows as $key => $value) {
  8299. if (isset($wt[$value['type']])) {
  8300. $rows[$key]['type'] = $wt[$value['type']];
  8301. } else {
  8302. $rows[$key]['type'] = '未设置';
  8303. }
  8304. $bm = '03';
  8305. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8306. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8307. $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');
  8308. $details = array();
  8309. $cpid = array();
  8310. $cpbz = array();
  8311. $c = 0;
  8312. $g = 0;
  8313. $x = 0;
  8314. $t = 0;
  8315. $s = 0;
  8316. $q = 0;
  8317. foreach ($sd as $k => $v) {
  8318. if ($v['state'] == 0) {
  8319. $c++;
  8320. if ($v['cpid'] != 0) {
  8321. $cpid[$v['cpid']] = $v['cpid'];
  8322. }
  8323. if ($v['cpbz'] != '') {
  8324. $cpbz[$v['cpbz']] = $v['cpbz'];
  8325. }
  8326. }
  8327. if ($v['state'] != 9) {
  8328. $g++;
  8329. }
  8330. if ($v['state'] == 1) {
  8331. $x++;
  8332. }
  8333. if ($v['state'] == 2) {
  8334. $t++;
  8335. }
  8336. if ($v['state'] == 8) {
  8337. $s++;
  8338. }
  8339. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8340. $q++;
  8341. }
  8342. $details[$v['details']] = $v['details'];
  8343. }
  8344. $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'] . '"');
  8345. $rows[$key]['details'] = implode("、", $details);
  8346. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8347. $number = $value['number'];
  8348. $ftime = time() - 15 * 24 * 3600;
  8349. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8350. $rows[$key]['number'] = $g;
  8351. $rows[$key]['c'] = $c;
  8352. $rows[$key]['x'] = $x;
  8353. $rows[$key]['t'] = $t;
  8354. $rows[$key]['s'] = $s;
  8355. $rows[$key]['q'] = $q;
  8356. $rows[$key]['z'] = $z;
  8357. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8358. $features = explode('-', trim($features, '-'));
  8359. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8360. }
  8361. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8362. $final_list = [];
  8363. foreach ($list as $k => $v) {
  8364. if (empty($v['sku'])) {
  8365. continue;
  8366. }
  8367. $final_list[] = [
  8368. $v["warehouse"],
  8369. $v["purchase"],
  8370. $v["details"],
  8371. $v["cpid"],
  8372. $v["dbcontent"],
  8373. $v["sku"],
  8374. $v["bm"],
  8375. $v["jm"],
  8376. $v["title"],
  8377. $v["pm"],
  8378. $v["cpbz"],
  8379. $v["sm"],
  8380. $v["type"],
  8381. $v["number"],
  8382. $v["c"],
  8383. $v["x"],
  8384. $v["t"],
  8385. $v["s"],
  8386. $v["q"],
  8387. $v["z"],
  8388. $v['weight'],
  8389. ];
  8390. }
  8391. if(empty($final_list)){
  8392. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8393. }
  8394. $title = "总进销存统计表";
  8395. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8396. $merges = [
  8397. [
  8398. "s"=>["r"=>0,"c"=>0],
  8399. "e"=>["r"=>0,"c"=>21]
  8400. ]
  8401. ];
  8402. $cols = [
  8403. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8404. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8405. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8406. ];
  8407. array_unshift($final_list, $first_row);
  8408. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8409. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8410. }
  8411. public function _summaryjs($arg_array)
  8412. {
  8413. $prc = array();
  8414. $purchase = $this->purchase->find_all();
  8415. foreach ($purchase as $k => $v) {
  8416. $prc[$v['id']] = $v['title'];
  8417. }
  8418. if (isset($_GET['excel'])) {
  8419. $ktime = $this->input->get('ktime', true);
  8420. $jtime = $this->input->get('jtime', true);
  8421. $ktime = strtotime($ktime);
  8422. $jtime = strtotime($jtime);
  8423. $where = "1=1";
  8424. if ($ktime && $jtime) {
  8425. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8426. }
  8427. //数据排序
  8428. $order_str = "time desc";
  8429. if (empty($page)) {
  8430. $start = 0;
  8431. $perpage = 1;
  8432. } else {
  8433. $start = ($page - 1) * $perpage;
  8434. }
  8435. //取得信息列表
  8436. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8437. foreach ($info_list as $key => $value) {
  8438. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8439. $warehouse = $this->warehouse->read($value['warehouse']);
  8440. $info_list[$key]['warehouse'] = $warehouse['title'];
  8441. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8442. $details = array();
  8443. $cpid = array();
  8444. foreach ($x as $k => $v) {
  8445. if ($v['details'] != '') {
  8446. $details[$v['details']] = $v['details'];
  8447. }
  8448. if ($v['cpid'] != 0) {
  8449. $cpid[$v['cpid']] = $v['cpid'];
  8450. }
  8451. }
  8452. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8453. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8454. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8455. $info_list[$key]['s'] = $s;
  8456. $info_list[$key]['x'] = count($x);
  8457. }
  8458. if(empty($info_list)){
  8459. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8460. }
  8461. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8462. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8463. $merges = [
  8464. [
  8465. "s"=>["r"=>0,"c"=>0],
  8466. "e"=>["r"=>0,"c"=>7]
  8467. ]
  8468. ];
  8469. $cols = [
  8470. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8471. ];
  8472. $final_list = [];
  8473. foreach($info_list as $k => $v){
  8474. $final_list[] = array_values($v);
  8475. }
  8476. array_unshift($final_list, $first_row);
  8477. array_unshift($final_list,[
  8478. $title,"","","","","","","","",
  8479. ]);
  8480. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8481. $titlename = "<table border=1>
  8482. <tr align='center'>
  8483. <td>仓库</td>
  8484. <td>供应商</td>
  8485. <td>出库位置</td>
  8486. <td>出库编码</td>
  8487. <td>SKU</td>
  8488. <td>产品名</td>
  8489. <td>总剩余库存</td>
  8490. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8491. </tr>
  8492. </table>";
  8493. $filename = $title . ".xls";
  8494. $tail = "";
  8495. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8496. }
  8497. }
  8498. public function _uckjs()
  8499. {
  8500. if (isset($_GET['excel'])) {
  8501. $tc = array();
  8502. $typeclass = $this->typeclass->find_all();
  8503. foreach ($typeclass as $v) {
  8504. $tc[$v['id']] = $v['zh'];
  8505. }
  8506. $first_row = [
  8507. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8508. ];
  8509. $t = array();
  8510. $rq = '';
  8511. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8512. $ts = $ts / (24 * 3600);
  8513. for ($i = 0; $i < $ts; $i++) {
  8514. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8515. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8516. }
  8517. $day_len = count($t);
  8518. $first_row[] = "本月出库";
  8519. $merges = [
  8520. ];
  8521. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8522. $excel_key = 1;
  8523. $final_list = [];
  8524. foreach ($info_list as $k => $v) {
  8525. $features = explode('-', trim($v['features'], '-'));
  8526. if (!isset($features[3]) || !isset($features[4])) {
  8527. continue;
  8528. }
  8529. $tmp = [];
  8530. $tmp[0] = $tc[$features[0]]; //类型
  8531. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8532. $tmp[2] = $tc[$features[4]]; //曲度
  8533. $tmp[3] = '';
  8534. if (isset($data[$k][1])) {
  8535. $tmp[3] .=$tmp[1];
  8536. }
  8537. if (isset($data[$k][2])) {
  8538. $tmp[3] .= $tmp[2];
  8539. }
  8540. if (isset($features[5])) {
  8541. $tmp[3] .= $tc[$features[5]];
  8542. }
  8543. if (isset($features[2])) {
  8544. $tmp[3] .= $tc[$features[2]];
  8545. }
  8546. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8547. $tmp[4] = $v['sku'];
  8548. $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())) . '))'); //月初库存
  8549. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8550. $tmp[7] ="";
  8551. $tmp[8] ="";
  8552. $byck = 0;
  8553. foreach ($t as $vv) {
  8554. $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));
  8555. $tmp[] = ($sl > 0) ? $sl : '';
  8556. $byck += $sl;
  8557. }
  8558. $tmp[] = ($byck > 0) ? $byck : '';
  8559. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8560. // $ztrq = '';
  8561. // $ztsl = '';
  8562. // if (count($zt) > 0) {
  8563. // foreach ($zt as $vv) {
  8564. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8565. // $ztsl .= $vv['num'] . '<br>';
  8566. // }
  8567. // }
  8568. if(empty($zt)){
  8569. $final_list[] = $tmp;
  8570. $excel_key = $excel_key + 1;
  8571. }else{
  8572. $len = count($zt);
  8573. if($len == 1){
  8574. $tmp[7] = $zt[0]['num'] ;
  8575. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8576. $final_list[] = $tmp;
  8577. $excel_key = $excel_key + 1;
  8578. }else{
  8579. foreach($zt as $vv){
  8580. $tmp[7] = "";
  8581. $tmp[8] = "";
  8582. $tmp[7] = $vv['num'];
  8583. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8584. $final_list[] = $tmp;
  8585. }
  8586. $merges[] = [
  8587. "s"=>["r"=>$excel_key,"c"=>0],
  8588. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8589. ];
  8590. $merges[] = [
  8591. "s"=>["r"=>$excel_key,"c"=>1],
  8592. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8593. ];
  8594. $merges[] = [
  8595. "s"=>["r"=>$excel_key,"c"=>2],
  8596. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8597. ];
  8598. $merges[] = [
  8599. "s"=>["r"=>$excel_key,"c"=>3],
  8600. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8601. ];
  8602. $merges[] = [
  8603. "s"=>["r"=>$excel_key,"c"=>4],
  8604. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8605. ];
  8606. $merges[] = [
  8607. "s"=>["r"=>$excel_key,"c"=>5],
  8608. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8609. ];
  8610. $merges[] = [
  8611. "s"=>["r"=>$excel_key,"c"=>6],
  8612. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8613. ];
  8614. for($i=1;$i<=$day_len;$i++){
  8615. $merges[] = [
  8616. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8617. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8618. ];
  8619. }
  8620. $merges[] = [
  8621. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8622. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8623. ];
  8624. $excel_key = $excel_key + $len;
  8625. }
  8626. }
  8627. }
  8628. $title = "详情 " . date("Y-m-d", time());
  8629. if(empty($final_list)){
  8630. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8631. }
  8632. $cols = [
  8633. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8634. ];
  8635. array_unshift($final_list, $first_row);
  8636. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8637. }
  8638. }
  8639. public function _whlabelexcelzhjs(){
  8640. if(empty($_GET['excel'])){
  8641. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8642. }
  8643. $where = "sku != 'Preset' and sku != '' ";
  8644. //数据排序
  8645. $order_str = "id desc";
  8646. if (empty($page)) {
  8647. $start = 0;
  8648. $perpage = 1;
  8649. } else {
  8650. $start = ($page - 1) * $perpage;
  8651. }
  8652. $category = $this->input->get('category', true);
  8653. $warehouse = $this->input->get('warehouse', true);
  8654. $excelid = $this->input->get('sid', true);
  8655. if ($category) {
  8656. $where .= " and features like '%-$category-%'";
  8657. }
  8658. if ($warehouse) {
  8659. $where .= " and warehouse = '$warehouse'";
  8660. }
  8661. $xzid = '';
  8662. if ($excelid) {
  8663. $excelid = explode(',', trim($excelid, ','));
  8664. foreach ($excelid as $key => $value) {
  8665. $xzid .= " id = " . $value . " or";
  8666. }
  8667. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8668. }
  8669. $merges = [
  8670. [
  8671. "s"=>["r"=>0,"c"=>0],
  8672. "e"=>["r"=>0,"c"=>6]
  8673. ]
  8674. ];
  8675. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8676. $excel_index = 2;
  8677. $final_list = [];
  8678. foreach ($rows as $key => $value) {
  8679. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8680. $zh = '';
  8681. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8682. // foreach ($zt_list as $v) {
  8683. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8684. // }
  8685. $zt = array_sum(array_column($zt_list, 'num'));
  8686. $number = $value['number'];
  8687. $ftime = time() - 15 * 24 * 3600;
  8688. $warehouse = $this->warehouse->read($value['warehouse']);
  8689. // $rows[$key]['warehouse'] = $warehouse['title'];
  8690. // $rows[$key]['number'] = $c;
  8691. // $rows[$key]['features'] = $zh;
  8692. //$rows[$key]['hb'] = $c + $zt;
  8693. $tmp = [];
  8694. $tmp[0] = $warehouse['title'];
  8695. $tmp[1] = $value['sku'];
  8696. $tmp[2] = $value['title'];
  8697. $tmp[3] = $c;
  8698. $tmp[4] = "";
  8699. $tmp[5] = $c + $zt;
  8700. if(empty($zt_list)){
  8701. $tmp[4] = "";
  8702. $final_list[] = $tmp;
  8703. $excel_index = $excel_index + 1;
  8704. }else{
  8705. if(count($zt_list) == 1){
  8706. $tmp[4] = "";
  8707. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8708. $final_list[] = $tmp;
  8709. $excel_index = $excel_index + 1;
  8710. }else{
  8711. $len = count($zt_list);
  8712. foreach ($zt_list as $v){
  8713. $tmp[4] = "";
  8714. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8715. $final_list[] = $tmp;
  8716. }
  8717. $merges[] = [
  8718. "s"=>["r"=>$excel_index,"c"=>0],
  8719. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8720. ];
  8721. $merges[] = [
  8722. "s"=>["r"=>$excel_index,"c"=>1],
  8723. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8724. ];
  8725. $merges[] = [
  8726. "s"=>["r"=>$excel_index,"c"=>2],
  8727. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8728. ];
  8729. $merges[] = [
  8730. "s"=>["r"=>$excel_index,"c"=>3],
  8731. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8732. ];
  8733. $merges[] = [
  8734. "s"=>["r"=>$excel_index,"c"=>5],
  8735. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8736. ];
  8737. $excel_index = $excel_index + $len;
  8738. }
  8739. }
  8740. }
  8741. $first_row = [
  8742. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8743. ];
  8744. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8745. if(empty($final_list)){
  8746. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8747. }
  8748. $cols = [
  8749. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8750. ];
  8751. array_unshift($final_list, $first_row);
  8752. array_unshift($final_list, [
  8753. $title,"","","","",""
  8754. ]);
  8755. $end_list = [];
  8756. foreach ($final_list as $key => $value) {
  8757. $end_list[] = array_values($value);
  8758. }
  8759. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8760. }
  8761. //出库、退库导出
  8762. public function _dccrtypejs()
  8763. {
  8764. $classid = $this->classid->sku();
  8765. $pm = $classid;
  8766. $typeclass = array();
  8767. $tc = $this->typeclass->find_all();
  8768. foreach ($tc as $v) {
  8769. $typeclass[$v['id']] = $v;
  8770. }
  8771. $prc = array();
  8772. $purchase = $this->purchase->find_all();
  8773. foreach ($purchase as $k => $v) {
  8774. $prc[$v['id']] = $v['title'];
  8775. }
  8776. if (isset($_GET['sid'])) {
  8777. $wh = array();
  8778. $w = $this->warehouse->find_all('1=1', 'id,title');
  8779. foreach ($w as $v) {
  8780. $wh[$v['id']] = $v['title'];
  8781. }
  8782. $type = $this->input->get('excel', true);
  8783. $category = $this->input->get('category', true);
  8784. $size = $this->input->get('size', true);
  8785. $grade = $this->input->get('grade', true);
  8786. $color = $this->input->get('color', true);
  8787. $lowe = $this->input->get('lowe', true);
  8788. $sku = $this->input->get('sku', true);
  8789. $warehouse = $this->input->get('warehouse', true);
  8790. $lacetype = $this->input->get('lacetype', true);
  8791. $lacecolor = $this->input->get('lacecolor', true);
  8792. $density = $this->input->get('density', true);
  8793. $haircap = $this->input->get('haircap', true);
  8794. $purchase = $this->input->get('purchase', true);
  8795. $title = $this->input->get('title', true);
  8796. $state = $this->input->get('state', true);
  8797. $sid = $this->input->get('sid', true);
  8798. $ktime = $this->input->get('ktime', true);
  8799. $jtime = $this->input->get('jtime', true);
  8800. $ktime = strtotime($ktime);
  8801. $jtime = strtotime($jtime);
  8802. $where = "1=1";
  8803. $gj = "";
  8804. $ck = "";
  8805. if ($category) {
  8806. $where .= " and features like '%-$category-%'";
  8807. }
  8808. if ($size) {
  8809. $where .= " and features like '%-$size-%'";
  8810. }
  8811. if ($grade) {
  8812. $where .= " and features like '%-$grade-%'";
  8813. }
  8814. if ($color) {
  8815. $where .= " and features like '%-$color-%'";
  8816. }
  8817. if ($lowe) {
  8818. $where .= " and features like '%-$lowe-%'";
  8819. }
  8820. if ($warehouse) {
  8821. $where .= " and warehouse = '$warehouse'";
  8822. }
  8823. if ($purchase) {
  8824. $where .= " and purchase = '$purchase'";
  8825. }
  8826. if ($state) {
  8827. $where .= " and state = '$state'";
  8828. }
  8829. if ($lacetype) {
  8830. $where .= " and features like '%-$lacetype-%'";
  8831. }
  8832. if ($lacecolor) {
  8833. $where .= " and features like '%-$lacecolor-%'";
  8834. }
  8835. if ($density) {
  8836. $where .= " and features like '%-$density-%'";
  8837. }
  8838. if ($haircap) {
  8839. $where .= " and features like '%-$haircap-%'";
  8840. }
  8841. if ($title) {
  8842. $title = trim($title, ' ');
  8843. $title = trim($title, ' ');
  8844. $where .= " and title like '%$title%'";
  8845. }
  8846. if ($sku) {
  8847. $sku = trim($sku, ' ');
  8848. $sku = trim($sku, ' ');
  8849. $where .= " and sku like '%$sku%'";
  8850. }
  8851. if ($ktime && $jtime) {
  8852. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8853. }
  8854. $sidwhere = '';
  8855. if ($sid) {
  8856. $sd = "";
  8857. $s = explode(',', trim($sid, ','));
  8858. foreach ($s as $value) {
  8859. $sd .= " id = " . $value . " or";
  8860. }
  8861. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8862. }
  8863. //数据排序
  8864. $order_str = "time desc";
  8865. if (empty($page)) {
  8866. $start = 0;
  8867. $perpage = 1;
  8868. } else {
  8869. $start = ($page - 1) * $perpage;
  8870. }
  8871. $wh = array();
  8872. $w = $this->warehouse->find_all('1=1', 'id,title');
  8873. foreach ($w as $v) {
  8874. $wh[$v['id']] = $v['title'];
  8875. }
  8876. $wt = array();
  8877. $whlabel_type = $this->whlabel_type->find_all();
  8878. foreach ($whlabel_type as $v) {
  8879. $wt[$v['id']] = $v['title'];
  8880. }
  8881. $classid = $this->classid->sku();
  8882. $list = array();
  8883. $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');
  8884. foreach ($rows_r as $key => $value) {
  8885. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8886. $pm = $classid;
  8887. $jm = $classid;
  8888. $rows_r[$key]['enter'] = '入库';
  8889. $rows_r[$key]['time'] = $value['enter'];
  8890. if ($value['rktype'] == 1) {
  8891. $rows_r[$key]['rktype'] = '采购入库';
  8892. } else if ($value['rktype'] == 2) {
  8893. $rows_r[$key]['rktype'] = '盘盈调整';
  8894. } else if ($value['rktype'] == 3) {
  8895. $rows_r[$key]['rktype'] = '其他调整入库';
  8896. } else if ($value['rktype'] == 4) {
  8897. $rows_r[$key]['rktype'] = '其他调整入库';
  8898. } else if ($value['rktype'] == 5) {
  8899. $rows_r[$key]['rktype'] = '退库入库';
  8900. } else if ($value['rktype'] == 6) {
  8901. $rows_r[$key]['rktype'] = '退货可用入库';
  8902. } else if ($value['rktype'] == 7) {
  8903. $rows_r[$key]['rktype'] = '形态转换入库';
  8904. } else {
  8905. $rows_r[$key]['rktype'] = '';
  8906. }
  8907. $features = explode('-', trim($value['features'], '-'));
  8908. foreach ($features as $v) {
  8909. if (isset($typeclass[$v])) {
  8910. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8911. $pm[$typeclass[$v]['classid']] = $zh[0];
  8912. }
  8913. if (isset($typeclass[$v])) {
  8914. if (isset($jm[$typeclass[$v]['classid']])) {
  8915. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8916. }
  8917. }
  8918. }
  8919. $zh = implode(" ", $pm);
  8920. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8921. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8922. $rows_r[$key]['zh'] = $zh;
  8923. $jm = array_filter($jm);
  8924. $rows_r[$key]['features'] = implode("-", $jm);
  8925. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8926. }
  8927. $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');
  8928. foreach ($rows_c as $key => $value) {
  8929. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8930. $pm = $classid;
  8931. $jm = $classid;
  8932. $rows_c[$key]['time'] = $value['outk'];
  8933. $rows_c[$key]['outk'] = '出库';
  8934. if ($value['cktype'] == 1) {
  8935. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8936. } else if ($value['cktype'] == 2) {
  8937. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8938. } else if ($value['cktype'] == 3) {
  8939. $rows_c[$key]['cktype'] = '盘亏调整';
  8940. } else if ($value['cktype'] == 4) {
  8941. $rows_c[$key]['cktype'] = '其他调整出库';
  8942. } else if ($value['cktype'] == 5) {
  8943. $rows_c[$key]['cktype'] = '形态转换出库';
  8944. } else {
  8945. $rows_c[$key]['cktype'] = '';
  8946. }
  8947. unset($rows_c[$key]['state']);
  8948. $features = explode('-', trim($value['features'], '-'));
  8949. foreach ($features as $v) {
  8950. if (isset($typeclass[$v])) {
  8951. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8952. $pm[$typeclass[$v]['classid']] = $zh[0];
  8953. }
  8954. if (isset($typeclass[$v])) {
  8955. if (isset($jm[$typeclass[$v]['classid']])) {
  8956. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8957. }
  8958. }
  8959. }
  8960. $zh = implode(" ", $pm);
  8961. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8962. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8963. $rows_c[$key]['zh'] = $zh;
  8964. $jm = array_filter($jm);
  8965. $rows_c[$key]['features'] = implode("-", $jm);
  8966. $rows_c[$key]['number'] = 1;
  8967. }
  8968. $merged = $rows_r;
  8969. foreach ($rows_c as $key => $value) {
  8970. if (isset($merged[$key])) {
  8971. $merged[] = $value;
  8972. } else {
  8973. $merged[$key] = $value;
  8974. }
  8975. }
  8976. usort($merged, function ($a, $b) {
  8977. return $a['time'] - $b['time'];
  8978. });
  8979. foreach ($merged as $key => $value) {
  8980. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8981. }
  8982. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8983. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  8984. $cols = [
  8985. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8986. ];
  8987. $final_list= [];
  8988. foreach($merged as $key => $value){
  8989. $final_list[] = array_values($value) ;
  8990. }
  8991. if(empty($merged)){
  8992. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8993. }
  8994. array_unshift($final_list, $first_row);
  8995. $end_list = [];
  8996. foreach ($final_list as $key => $value) {
  8997. $end_list[] = array_values($value);
  8998. }
  8999. $merges = [];
  9000. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9001. }
  9002. }
  9003. public function _errorexceljs()
  9004. {
  9005. $post = $this->input->post(NULL, TRUE);
  9006. if (isset($_GET['page'])) {
  9007. $page = $this->input->get('page', true);
  9008. $perpage = $this->input->get('perpage', true);
  9009. $sku = $this->input->get('sku', true);
  9010. $warehouse = $this->input->get('warehouse', true);
  9011. $ktime = $this->input->get('ktime', true);
  9012. $jtime = $this->input->get('jtime', true);
  9013. $ktime = strtotime($ktime);
  9014. $jtime = strtotime($jtime);
  9015. $where = "sku != 'Preset'";
  9016. $gj = '';
  9017. if ($sku) {
  9018. $where .= " and sku like '%$sku%'";
  9019. } else {
  9020. if ($ktime && $jtime) {
  9021. $gj = " and time > '$ktime' and time < '$jtime'";
  9022. }
  9023. }
  9024. if ($warehouse) {
  9025. $where .= " and warehouse = '$warehouse'";
  9026. }
  9027. //数据排序
  9028. $order_str = "id desc";
  9029. if (empty($page)) {
  9030. $start = 0;
  9031. $perpage = 1;
  9032. } else {
  9033. $start = ($page - 1) * $perpage;
  9034. }
  9035. //取得信息列表
  9036. $rows = array();
  9037. $list = array();
  9038. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9039. foreach ($info_list as $value) {
  9040. $warehouse = $this->warehouse->read($value['warehouse']);
  9041. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9042. $number = $value['number'];
  9043. $ftime = time() - 15 * 24 * 3600;
  9044. if ($c < 1) {
  9045. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9046. }
  9047. }
  9048. $title = "0库存汇总";
  9049. $first_row = ["仓库","SKU","产品","当前库存"];
  9050. $cols = [
  9051. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9052. ];
  9053. $final_list= [];
  9054. foreach($list as $key => $value){
  9055. $final_list[] = array_values($value) ;
  9056. }
  9057. if(empty($final_list)){
  9058. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9059. }
  9060. array_unshift($final_list, $first_row);
  9061. $merges = [];
  9062. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9063. }
  9064. }
  9065. }