Whlabel.php 317 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  46. $this->load->_model("Model_whlabelscanlog","whlabelscanlog");
  47. $this->load->_model("Model_excel","excelxh");
  48. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg, $arg_array)
  51. {
  52. if ($arg == 'existence') //在库标签
  53. {
  54. $this->_existence();
  55. } else if ($arg == 'cpbqdc') //在库标签
  56. {
  57. $this->_cpbqdc();
  58. } else if ($arg == 'type') //进销存浏览
  59. {
  60. $this->_type();
  61. } else if ($arg == 'typedy') //进销存浏览店员页面
  62. {
  63. $this->_typedy($arg_array);
  64. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  65. {
  66. $this->_typedy_ck($arg_array);
  67. } else if ($arg == 'typeck') {
  68. $this->_typeck($arg_array);
  69. } else if ($arg == 'whlabeckdc') {
  70. $this->_whlabeckdc($arg_array);
  71. } else if ($arg == 'usatype') //美仓进销存浏览
  72. {
  73. $this->_usatype();
  74. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  75. {
  76. $this->_usatypeapp();
  77. } else if ($arg == 'enteradd') //入库操作
  78. {
  79. $this->_enteradd();
  80. } else if ($arg == 'enteredit') //修改
  81. {
  82. $this->_enteredit($arg_array);
  83. } else if ($arg == 'enter') //入库浏览
  84. {
  85. $this->_enter();
  86. } else if ($arg == 'out') //出库浏览
  87. {
  88. $this->_out();
  89. } else if ($arg == 'label') //出库标签浏览
  90. {
  91. $this->_label();
  92. } else if ($arg == 'outorder') //独立站出库订单
  93. {
  94. $this->_outorder();
  95. } else if ($arg == 'soutorder') //速卖通出库订单
  96. {
  97. $this->_soutorder();
  98. } else if ($arg == 'toutorder') //TT出库订单
  99. {
  100. $this->_toutorder();
  101. }else if ($arg == 'aoutorder') //amz出库订单
  102. {
  103. $this->_aoutorder();
  104. } else if ($arg == 'retreat') //退库订单
  105. {
  106. $this->_retreat();
  107. } else if ($arg == 'retreatlk') //退库订单
  108. {
  109. $this->_retreatlk();
  110. } else if ($arg == 'change') //更换标签
  111. {
  112. $this->_change();
  113. } else if ($arg == 'del') //删除
  114. {
  115. $this->_del();
  116. } else if ($arg == 'exceljxc') //进销存信息导出
  117. {
  118. $this->_exceljxc();
  119. } else if ($arg == 'excelr') //入库信息导出
  120. {
  121. $this->_excelr();
  122. } else if ($arg == 'excelct') //出库、退库信息导出
  123. {
  124. $this->_excelct();
  125. } else if ($arg == 'dccrtype') //根据出入库类型导出
  126. {
  127. $this->_dccrtype();
  128. } else if ($arg == 'excelcr') //出库、退库信息导出
  129. {
  130. $this->_excelcr();
  131. } else if ($arg == 'kcyz') //库存验证
  132. {
  133. $this->_kcyz();
  134. } else if ($arg == 'kj') //库存扣减
  135. {
  136. $this->_kj($arg_array);
  137. } else if ($arg == 'presetout') //预设库存导入
  138. {
  139. $this->_presetout($arg_array);
  140. } else if ($arg == 'presetedit') //预设库存导入
  141. {
  142. $this->_presetedit($arg_array);
  143. }else if ($arg == 'presetedittwo') //预设库存导入
  144. {
  145. $this->_presetedittwo($arg_array);
  146. } else if ($arg == 'summary') //汇总导出
  147. {
  148. $this->_summary($arg_array);
  149. } else if ($arg == 'manifest') //usps发货清单
  150. {
  151. $this->_manifest();
  152. } else if ($arg == 'abnormal') //占单异常
  153. {
  154. $this->_abnormal();
  155. } else if ($arg == 'error') //0库存SKU
  156. {
  157. $this->_error();
  158. } else if ($arg == 'errorexcel') //0库存SKU导出
  159. {
  160. $this->_errorexcel();
  161. } else if ($arg == 'db') {
  162. $this->_db();
  163. } else if ($arg == 'dbrk') {
  164. $this->_dbrk();
  165. } else if ($arg == 'whlabelczdc') {
  166. $this->_whlabelczdc();
  167. } else if ($arg == 'print') {
  168. $this->_print($arg_array);
  169. } else if ($arg == 'usaprint') {
  170. $this->_usaprint($arg_array);
  171. } else if ($arg == 'printck') {
  172. $this->_printck($arg_array);
  173. } else if ($arg == 'printrk') {
  174. $this->_printrk($arg_array);
  175. } else if ($arg == 'printxzrk') {
  176. $this->_printxzrk($arg_array);
  177. } else if ($arg == 'printexcel') {
  178. $this->_printexcel($arg_array);
  179. } else if ($arg == 'uck') {
  180. $this->_uck();
  181. } else if ($arg == 'whlabelexcelzh') {
  182. $this->_whlabelexcelzh();
  183. } else if ($arg == 'fc') {
  184. $this->_fc();
  185. } else if ($arg == 'fcmb') {
  186. $this->_fcmb();
  187. } else if ($arg == 'fcexcel') {
  188. $this->_fcexcel();
  189. } else if ($arg == 'fcjxc') {
  190. $this->_fcjxc($arg_array);
  191. } else if ($arg == '0kcdel') {
  192. $this->_0kcdel(); //导表删除0库存
  193. } else if ($arg == 'gbhtype') {
  194. $this->_gbhtype(); //更改备货状态
  195. } else if($arg == 'excelrjs'){
  196. $this->_excelrjs();
  197. } else if($arg == 'excelctjs'){
  198. $this->_excelctjs();
  199. }else if ($arg == 'exceljxcjs') //进销存信息导出
  200. {
  201. $this->_exceljxcjs();
  202. } else if ($arg == 'summaryjs') //汇总导出
  203. {
  204. $this->_summaryjs($arg_array);
  205. }else if($arg == 'uckjs'){
  206. $this->_uckjs();
  207. }else if ($arg == 'whlabelexcelzhjs') {
  208. $this->_whlabelexcelzhjs();
  209. }else if($arg == 'dccrtypejs'){
  210. $this->_dccrtypejs();
  211. }else if($arg == 'errorexceljs'){
  212. $this->_errorexceljs();
  213. }else if($arg == "w_t_cs"){
  214. $this->_w_t_cs(); //首页
  215. }else {
  216. $this->_index();
  217. }
  218. }
  219. public function _w_t_cs(){
  220. $vip = 0;
  221. if (isset($_SESSION['api'])) {
  222. $user = $this->user->get_api($_SESSION['api']);
  223. $fgshop = "";
  224. $sid = "";
  225. $usersp = explode('|', trim($user['shop'], '|'));
  226. foreach ($usersp as $value) {
  227. $fgshop .= " shop = " . $value . " or";
  228. $sid .= " id = " . $value . " or";
  229. }
  230. if ($user['vip'] == 1) {
  231. $vip = 1;
  232. }
  233. } else {
  234. header('Location: /');
  235. exit;
  236. }
  237. $prc = array();
  238. $purchase = $this->purchase->find_all();
  239. foreach ($purchase as $k => $v) {
  240. $prc[$v['id']] = $v['title'];
  241. }
  242. $company = array();
  243. $ct = $this->company->find_all();
  244. foreach ($ct as $k => $v) {
  245. $company[$v['id']] = $v['title'];
  246. }
  247. $sp = array();
  248. $s = $this->shop->find_all('1=1', 'id,shopname');
  249. foreach ($s as $v) {
  250. $sp[$v['id']] = $v['shopname'];
  251. }
  252. $wh = array();
  253. $w = $this->warehouse->find_all('1=1', 'id,title');
  254. foreach ($w as $v) {
  255. $wh[$v['id']] = $v['title'];
  256. }
  257. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  258. $this->data['shop'] = $wlshop;
  259. $this->data['vip'] = $vip;
  260. $this->_Template('whlabel_typejs', $this->data);
  261. }
  262. //管理
  263. public function _index()
  264. {
  265. $post = $this->input->post(NULL, TRUE);
  266. if (isset($post['page'])) {
  267. $page = $this->input->post('page', true);
  268. $perpage = $this->input->post('perpage', true);
  269. $sku = $this->input->post('sku', true);
  270. $number = $this->input->post('number', true);
  271. $warehouse = $this->input->post('warehouse', true);
  272. $purchase = $this->input->post('purchase', true);
  273. $orderinfo = $this->input->post('orderinfo', true);
  274. $waybill = $this->input->post('waybill', true);
  275. $category = $this->input->post('category', true);
  276. $size = $this->input->post('size', true);
  277. $grade = $this->input->post('grade', true);
  278. $color = $this->input->post('color', true);
  279. $lowe = $this->input->post('lowe', true);
  280. $state = $this->input->post('state', true);
  281. $label = $this->input->post('label', true);
  282. $timetk = $this->input->post('timetkk', true);
  283. $timetj = $this->input->post('timetjj', true);
  284. $timetk = strtotime($timetk);
  285. $timetj = strtotime($timetj);
  286. $where = "1=1 ";
  287. if ($timetk && $timetj) {
  288. $where .= " and time > '$timetk' and time < '$timetj'";
  289. }
  290. if ($sku) {
  291. $where .= " and sku = '$sku'";
  292. }
  293. if ($number) {
  294. $where .= " and number = '$number'";
  295. }
  296. if ($warehouse) {
  297. $where .= " and warehouse = '$warehouse'";
  298. }
  299. if ($purchase) {
  300. $where .= " and purchase = '$purchase'";
  301. }
  302. if ($orderinfo) {
  303. $where .= " and orderinfo = '$orderinfo'";
  304. }
  305. if ($waybill) {
  306. $where .= " and waybill = '$waybill'";
  307. }
  308. if ($category) {
  309. $where .= " and features like '%-$category-%'";
  310. }
  311. if ($size) {
  312. $where .= " and features like '%-$size-%'";
  313. }
  314. if ($grade) {
  315. $where .= " and features like '%-$grade-%'";
  316. }
  317. if ($color) {
  318. $where .= " and features like '%-$color-%'";
  319. }
  320. if ($lowe) {
  321. $where .= " and features like '%-$lowe-%'";
  322. }
  323. if ($label) {
  324. $where .= " and label = '$label'";
  325. }
  326. if ($state != '') {
  327. $where .= " and state = '$state'";
  328. }
  329. //数据排序
  330. $order_str = "time desc";
  331. if (empty($page)) {
  332. $start = 0;
  333. $perpage = 1;
  334. } else {
  335. $start = ($page - 1) * $perpage;
  336. }
  337. //取得信息列表
  338. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  339. foreach ($info_list as $key => $value) {
  340. $warehouse = $this->warehouse->read($value['warehouse']);
  341. $info_list[$key]['warehouse'] = $warehouse['title'];
  342. $purchase = $this->purchase->read($value['purchase']);
  343. $info_list[$key]['purchase'] = $purchase['title'];
  344. if ($value['enter'] != 0) {
  345. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  346. } else {
  347. $info_list[$key]['enter'] = "";
  348. }
  349. if ($value['outk'] != 0) {
  350. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  351. } else {
  352. $info_list[$key]['outk'] = "";
  353. }
  354. if ($value['printing'] != 0) {
  355. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  356. } else {
  357. $info_list[$key]['printing'] = "";
  358. }
  359. if ($value['orderinfo'] == 0) {
  360. $info_list[$key]['orderinfo'] = "";
  361. }
  362. if ($value['waybill'] == 0) {
  363. $info_list[$key]['waybill'] = "";
  364. }
  365. if ($value['state'] == 0) {
  366. $info_list[$key]['state'] = "在库";
  367. } else if ($value['state'] == 1) {
  368. $info_list[$key]['state'] = "出库";
  369. } else if ($value['state'] == 2) {
  370. $info_list[$key]['state'] = "退库";
  371. } else if ($value['state'] == 3) {
  372. $info_list[$key]['state'] = "调拨中";
  373. } else if ($value['state'] == 4) {
  374. $info_list[$key]['state'] = "再加工";
  375. } else if ($value['state'] == 5) {
  376. $info_list[$key]['state'] = "维修中";
  377. } else if ($value['state'] == 6) {
  378. $info_list[$key]['state'] = "盘亏";
  379. } else if ($value['state'] == 7) {
  380. $info_list[$key]['state'] = "更换标签";
  381. } else if ($value['state'] == 8) {
  382. $info_list[$key]['state'] = "其它";
  383. } else if ($value['state'] == 9) {
  384. $info_list[$key]['state'] = "预设";
  385. } else if ($value['state'] == 10) {
  386. $info_list[$key]['state'] = "美店零售";
  387. }
  388. if ($value['text'] == "") {
  389. $info_list[$key]['text'] = "";
  390. }
  391. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  392. }
  393. $total = $this->whlabel->find_count($where);
  394. $pagenum = ceil($total / $perpage);
  395. $over = $total - ($start + $perpage);
  396. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  397. echo json_encode($rows);
  398. exit;
  399. }
  400. if (isset($post['outsku'])) {
  401. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  402. $cz = $this->input->post('cz', true);
  403. if ($cz == '1') {
  404. $sku = $this->input->post('outsku', true);
  405. if ($sku) {
  406. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  407. if (count($data) < 1) {
  408. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  409. exit;
  410. }
  411. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  412. echo json_encode(array('success' => true));
  413. exit;
  414. }
  415. } else {
  416. $sku = $this->input->post('outsku', true);
  417. if ($sku) {
  418. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  419. if (count($data) < 1) {
  420. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  421. exit;
  422. }
  423. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  424. echo json_encode(array('success' => true));
  425. exit;
  426. }
  427. }
  428. }
  429. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  430. $this->_Template('whlabel', $this->data);
  431. }
  432. //在库标签
  433. public function _existence()
  434. {
  435. $post = $this->input->post(NULL, TRUE);
  436. if (isset($post['s'])) {
  437. $id_arr = $this->input->post('s');
  438. $id_arr = explode(',', $id_arr);
  439. if (!$id_arr) {
  440. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  441. exit;
  442. }
  443. //循环删除记录
  444. foreach ($id_arr as $v) {
  445. $sid = $this->whlabel->read($v);
  446. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  447. if ($count > 0) {
  448. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  449. exit;
  450. }
  451. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  452. if (count($zt) > 0) {
  453. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  454. exit;
  455. }
  456. $this->whlabel->remove($v);
  457. }
  458. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  459. exit;
  460. }
  461. if (isset($post['page'])) {
  462. $page = $this->input->post('page', true);
  463. $perpage = $this->input->post('perpage', true);
  464. $warehouse = $this->input->post('warehouse', true);
  465. $label = $this->input->post('label', true);
  466. $where = "1=1 and state = 0";
  467. if ($warehouse) {
  468. $where .= " and warehouse = '$warehouse'";
  469. }
  470. if ($label) {
  471. $where .= " and label = '$label'";
  472. }
  473. //数据排序
  474. $order_str = "time asc";
  475. if (empty($page)) {
  476. $start = 0;
  477. $perpage = 1;
  478. } else {
  479. $start = ($page - 1) * $perpage;
  480. }
  481. //取得信息列表
  482. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  483. foreach ($info_list as $key => $value) {
  484. if ($value['enter'] != 0) {
  485. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  486. } else {
  487. $info_list[$key]['enter'] = "";
  488. }
  489. if ($value['printing'] != 0) {
  490. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  491. } else {
  492. $info_list[$key]['printing'] = "";
  493. }
  494. }
  495. $total = $this->whlabel->find_count($where);
  496. $pagenum = ceil($total / $perpage);
  497. $over = $total - ($start + $perpage);
  498. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  499. echo json_encode($rows);
  500. exit;
  501. }
  502. $this->_Template('whlabel_existence', $this->data);
  503. }
  504. //进销存浏览
  505. public function _typedy($arg_array)
  506. {
  507. $prc = array();
  508. $purchase = $this->purchase->find_all();
  509. foreach ($purchase as $k => $v) {
  510. $prc[$v['id']] = $v['title'];
  511. }
  512. $post = $this->input->post(NULL, TRUE);
  513. if (isset($post['page'])) {
  514. $page = $this->input->post('page', true);
  515. $perpage = $this->input->post('perpage', true);
  516. $category = $this->input->post('category', true);
  517. $size = $this->input->post('size', true);
  518. $grade = $this->input->post('grade', true);
  519. $color = $this->input->post('color', true);
  520. $lowe = $this->input->post('lowe', true);
  521. $sku = $this->input->post('sku');
  522. $title = $this->input->post('title');
  523. $warehouse = $this->input->post('warehouse', true);
  524. $usa = $this->input->post('usa', true);
  525. $purchase = $this->input->post('purchase', true);
  526. $lacetype = $this->input->post('lacetype', true);
  527. $haircap = $this->input->post('haircap', true);
  528. $density = $this->input->post('density', true);
  529. $details = $this->input->post('details', true);
  530. $state = $this->input->post('state', true);
  531. $lacecolor = $this->input->post('lacecolor', true);
  532. $hairnumber = $this->input->post('hairnumber', true);
  533. $cklx = $this->input->post('cklx', true);
  534. $ktime = $this->input->post('ktime', true);
  535. $jtime = $this->input->post('jtime', true);
  536. $sm = $this->input->post('sm', true);
  537. $cpbz = $this->input->post('cpbz', true);
  538. $type = $this->input->post('type', true);
  539. $ktime = strtotime($ktime);
  540. $jtime = strtotime($jtime);
  541. $where = "1=1";
  542. $gj = "";
  543. $ck = "";
  544. if ($usa) {
  545. if (!$warehouse) {
  546. $where .= " and (warehouse = '5' or warehouse = '8')";
  547. }
  548. }
  549. if ($warehouse) {
  550. $where .= " and warehouse = '$warehouse'";
  551. }
  552. if ($details) {
  553. $where .= " and details = '$details'";
  554. }
  555. if ($purchase) {
  556. $where .= " and purchase = '$purchase'";
  557. }
  558. if (isset($state)) {
  559. if($state >-1){
  560. $where .= " and state = '$state'";
  561. }
  562. }
  563. if ($lacetype) {
  564. $where .= " and features like '%-$lacetype-%'";
  565. }
  566. if ($category) {
  567. $where .= " and features like '%-$category-%'";
  568. }
  569. if ($size) {
  570. $where .= " and features like '%-$size-%'";
  571. }
  572. if ($grade) {
  573. $where .= " and features like '%-$grade-%'";
  574. }
  575. if ($color) {
  576. $where .= " and features like '%-$color-%'";
  577. }
  578. if ($lowe) {
  579. $where .= " and features like '%-$lowe-%'";
  580. }
  581. if ($haircap) {
  582. $where .= " and features like '%-$haircap-%'";
  583. }
  584. if ($density) {
  585. $where .= " and features like '%-$density-%'";
  586. }
  587. if ($lacecolor) {
  588. $where .= " and features like '%-$lacecolor-%'";
  589. }
  590. if($sm){
  591. $where .= " and sm like '%".$sm."%'";
  592. }
  593. if($cpbz){
  594. $where .= " and cpbz like '%".$cpbz."%'";
  595. }
  596. if($type){
  597. $where .= " and type = ".$type."";
  598. }
  599. if (!empty($hairnumber)) {
  600. $where .= " and features like '%-128-%' ";
  601. if ($hairnumber < 0) {
  602. $class_list = $this->typeclass->find_all('classid = 43');
  603. foreach ($class_list as $v) {
  604. $where .= " and features not like '%-" . $v['id'] . "-%'";
  605. }
  606. } else {
  607. $where .= " and features like '%-$hairnumber-%'";
  608. }
  609. }
  610. $where_add = '';
  611. if ($cklx) {
  612. $shop = $this->shop->read($cklx);
  613. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  614. }
  615. if ($ktime && $jtime) {
  616. $gj = " and enter > '$ktime' and enter < '$jtime'";
  617. $ck = " and outk > '$ktime' and outk < '$jtime'";
  618. }
  619. //数据排序
  620. $order_str = "id desc";
  621. if (empty($page)) {
  622. $start = 0;
  623. $perpage = 1;
  624. } else {
  625. $start = ($page - 1) * $perpage;
  626. }
  627. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  628. if ($sku) {
  629. $sku = trim($sku, ' ');
  630. $sku = trim($sku, ' ');
  631. $where .= " and sku like '%$sku%'";
  632. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  633. } else if ($title) {
  634. $title = trim($title, ' ');
  635. $title = trim($title, ' ');
  636. $where .= " and title like '%$title%'";
  637. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  638. } else {
  639. //$where .= " and time > '$ktime' and time < '$jtime'";
  640. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  641. }
  642. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  643. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  644. foreach ($info_list as $k => $v) {
  645. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  646. unset($info_list[$k]['pm']);
  647. unset($info_list[$k]['jm']);
  648. unset($info_list[$k]['bm']);
  649. }
  650. //取得信息列表
  651. $rows = array();
  652. $list = array();
  653. foreach ($info_list as $key => $value) {
  654. $warehouse = $this->warehouse->read($value['warehouse']);
  655. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  656. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  657. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  658. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  659. $info_list[$key]['label'] = $value['sm'];
  660. $number = $value['number'];
  661. $ftime = time() - 15 * 24 * 3600;
  662. $info_list[$key]['warehouse'] = $warehouse['title'];
  663. $info_list[$key]['features'] = count($c);
  664. $z = count($z); //查看订单号
  665. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  666. $ztdata = '';
  667. if (count($zt) > 0) {
  668. foreach ($zt as $vv) {
  669. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  670. }
  671. }
  672. $info_list[$key]['number'] = $ztdata;
  673. $info_list[$key]['sm'] = $z;
  674. $details = array();
  675. $cpid = array();
  676. foreach ($c as $k => $v) {
  677. $details[$v['details']] = $v['details'];
  678. if ($v['cpid'] != 0) {
  679. $cpid[$v['cpid']] = $v['cpid'];
  680. }
  681. }
  682. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  683. if ($value['shop'] != '') {
  684. $shop = explode(',', trim($value['shop'], ','));
  685. $shop = $this->shop->read($shop[0]);
  686. $info_list[$key]['shop'] = $shop['shopname'];
  687. }
  688. }
  689. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  690. $pagenum = ceil($total / $perpage);
  691. $over = $total - ($start + $perpage);
  692. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  693. echo json_encode($rows);
  694. exit;
  695. }
  696. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  697. $this->_Template('whlabel_typedy', $this->data);
  698. }
  699. //进销存浏览
  700. public function _typedy_ck($arg_array)
  701. {
  702. $prc = array();
  703. $purchase = $this->purchase->find_all();
  704. foreach ($purchase as $k => $v) {
  705. $prc[$v['id']] = $v['title'];
  706. }
  707. $post = $this->input->post(NULL, TRUE);
  708. if (isset($post['page'])) {
  709. $page = $this->input->post('page', true);
  710. $perpage = $this->input->post('perpage', true);
  711. $category = $this->input->post('category', true);
  712. $size = $this->input->post('size', true);
  713. $grade = $this->input->post('grade', true);
  714. $color = $this->input->post('color', true);
  715. $lowe = $this->input->post('lowe', true);
  716. $sku = $this->input->post('sku');
  717. $title = $this->input->post('title');
  718. $warehouse = $this->input->post('warehouse', true);
  719. $usa = $this->input->post('usa', true);
  720. $purchase = $this->input->post('purchase', true);
  721. $lacetype = $this->input->post('lacetype', true);
  722. $haircap = $this->input->post('haircap', true);
  723. $density = $this->input->post('density', true);
  724. $details = $this->input->post('details', true);
  725. $state = $this->input->post('state', true);
  726. $lacecolor = $this->input->post('lacecolor', true);
  727. $cklx = $this->input->post('cklx', true);
  728. $ktime = $this->input->post('ktime', true);
  729. $jtime = $this->input->post('jtime', true);
  730. $ktime = strtotime($ktime);
  731. $jtime = strtotime($jtime);
  732. $where = "1=1";
  733. $gj = "";
  734. $ck = "";
  735. if ($lacetype) {
  736. $where .= " and features like '%-$lacetype-%'";
  737. }
  738. if ($category) {
  739. $where .= " and features like '%-$category-%'";
  740. }
  741. if ($size) {
  742. $where .= " and features like '%-$size-%'";
  743. }
  744. if ($grade) {
  745. $where .= " and features like '%-$grade-%'";
  746. }
  747. if ($color) {
  748. $where .= " and features like '%-$color-%'";
  749. }
  750. if ($lowe) {
  751. $where .= " and features like '%-$lowe-%'";
  752. }
  753. if ($haircap) {
  754. $where .= " and features like '%-$haircap-%'";
  755. }
  756. if ($density) {
  757. $where .= " and features like '%-$density-%'";
  758. }
  759. if ($lacecolor) {
  760. $where .= " and features like '%-$lacecolor-%'";
  761. }
  762. if ($usa) {
  763. if (!$warehouse) {
  764. $where .= " and (warehouse = '5' or warehouse = '8')";
  765. }
  766. }
  767. if ($warehouse) {
  768. $where .= " and warehouse = '$warehouse'";
  769. }
  770. if ($details) {
  771. $where .= " and details = '$details'";
  772. }
  773. if ($purchase) {
  774. $where .= " and purchase = '$purchase'";
  775. }
  776. if ($state) {
  777. $where .= " and state = '$state'";
  778. }
  779. $where_add = '';
  780. if ($cklx) {
  781. $shop = $this->shop->read($cklx);
  782. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  783. }
  784. if ($ktime && $jtime) {
  785. $gj = " and enter > '$ktime' and enter < '$jtime'";
  786. $ck = " and outk > '$ktime' and outk < '$jtime'";
  787. }
  788. //数据排序
  789. $order_str = "id desc";
  790. if (empty($page)) {
  791. $start = 0;
  792. $perpage = 1;
  793. } else {
  794. $start = ($page - 1) * $perpage;
  795. }
  796. if ($sku) {
  797. $sku = trim($sku, ' ');
  798. $sku = trim($sku, ' ');
  799. $where .= " and sku like '%$sku%'";
  800. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  801. } else if ($title) {
  802. $title = trim($title, ' ');
  803. $title = trim($title, ' ');
  804. $where .= " and title like '%$title%'";
  805. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  806. } else {
  807. //$where .= " and time > '$ktime' and time < '$jtime'";
  808. $info_list = $this->whlabel->find_pc($where . $where_add . ' and zd != ""', 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,zd,COUNT(CASE WHEN zd != "" and state = 0 THEN 1 ELSE NULL END) AS zd', 'zd desc', $start, $perpage);
  809. }
  810. //取得信息列表
  811. $rows = array();
  812. $list = array();
  813. foreach ($info_list as $key => $value) {
  814. $warehouse = $this->warehouse->read($value['warehouse']);
  815. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  816. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  817. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  818. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  819. $ftime = time() - 15 * 24 * 3600;
  820. $info_list[$key]['warehouse'] = $warehouse['title'];
  821. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  822. //$z = count($z);//查看订单号
  823. //$info_list[$key]['zd'] = $z;
  824. $details = array();
  825. $cpid = array();
  826. foreach ($c as $k => $v) {
  827. $details[$v['details']] = $v['details'];
  828. if ($v['cpid'] != 0) {
  829. $cpid[$v['cpid']] = $v['cpid'];
  830. }
  831. }
  832. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  833. if ($value['shop'] != '') {
  834. $shop = explode(',', trim($value['shop'], ','));
  835. $shop = $this->shop->read($shop[0]);
  836. $info_list[$key]['shop'] = $shop['shopname'];
  837. }
  838. }
  839. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  840. $pagenum = ceil($total / $perpage);
  841. $over = $total - ($start + $perpage);
  842. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  843. echo json_encode($rows);
  844. exit;
  845. }
  846. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  847. $this->_Template('whlabel_typedy_ck', $this->data);
  848. }
  849. public function _typeck($arg_array)
  850. {
  851. $prc = array();
  852. $purchase = $this->purchase->find_all();
  853. foreach ($purchase as $k => $v) {
  854. $prc[$v['id']] = $v['title'];
  855. }
  856. $post = $this->input->post(NULL, TRUE);
  857. if (isset($post['page'])) {
  858. $page = $this->input->post('page', true);
  859. $perpage = $this->input->post('perpage', true);
  860. $category = $this->input->post('category', true);
  861. $size = $this->input->post('size', true);
  862. $grade = $this->input->post('grade', true);
  863. $color = $this->input->post('color', true);
  864. $lacecolor = $this->input->post('lacecolor', true);
  865. $lowe = $this->input->post('lowe', true);
  866. $sku = $this->input->post('sku');
  867. $title = $this->input->post('title');
  868. $warehouse = 13;
  869. $usa = $this->input->post('usa', true);
  870. $purchase = $this->input->post('purchase', true);
  871. $lacetype = $this->input->post('lacetype', true);
  872. $haircap = $this->input->post('haircap', true);
  873. $density = $this->input->post('density', true);
  874. $details = $this->input->post('details', true);
  875. $state = $this->input->post('state', true);
  876. $ktime = $this->input->post('ktime', true);
  877. $jtime = $this->input->post('jtime', true);
  878. $ktime = strtotime($ktime);
  879. $jtime = strtotime($jtime);
  880. $where = "1=1";
  881. $gj = "";
  882. $ck = "";
  883. if ($lacetype) {
  884. $where .= " and features like '%-$lacetype-%'";
  885. }
  886. if ($category) {
  887. $where .= " and features like '%-$category-%'";
  888. }
  889. if ($size) {
  890. $where .= " and features like '%-$size-%'";
  891. }
  892. if ($grade) {
  893. $where .= " and features like '%-$grade-%'";
  894. }
  895. if ($color) {
  896. $where .= " and features like '%-$color-%'";
  897. }
  898. if ($lacecolor) {
  899. $where .= " and features like '%-$lacecolor-%'";
  900. }
  901. if ($lowe) {
  902. $where .= " and features like '%-$lowe-%'";
  903. }
  904. if ($haircap) {
  905. $where .= " and features like '%-$haircap-%'";
  906. }
  907. if ($density) {
  908. $where .= " and features like '%-$density-%'";
  909. }
  910. if ($warehouse) {
  911. $where .= " and warehouse = '$warehouse'";
  912. }
  913. if ($details) {
  914. $where .= " and details = '$details'";
  915. }
  916. if ($purchase) {
  917. $where .= " and purchase = '$purchase'";
  918. }
  919. if ($state) {
  920. $where .= " and state = '$state'";
  921. }
  922. if ($ktime && $jtime) {
  923. $gj = " and enter > '$ktime' and enter < '$jtime'";
  924. $ck = " and outk > '$ktime' and outk < '$jtime'";
  925. }
  926. //数据排序
  927. $order_str = "id desc";
  928. if (empty($page)) {
  929. $start = 0;
  930. $perpage = 1;
  931. } else {
  932. $start = ($page - 1) * $perpage;
  933. }
  934. if ($sku) {
  935. $sku = trim($sku, ' ');
  936. $sku = trim($sku, ' ');
  937. $where .= " and sku like '%$sku%'";
  938. } else if ($title) {
  939. $title = trim($title, ' ');
  940. $title = trim($title, ' ');
  941. $where .= " and title like '%$title%'";
  942. }
  943. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  944. //取得信息列表
  945. $t = array();
  946. $typeclass = $this->typeclass->find_all();
  947. foreach ($typeclass as $v) {
  948. $t[$v['id']] = $v;
  949. }
  950. $rows = array();
  951. $list = array();
  952. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  953. foreach ($info_list as $key => $value) {
  954. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  955. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  956. $warehouse = $this->warehouse->read($value['warehouse']);
  957. $c = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  958. $z = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  959. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  960. $number = $value['number'];
  961. $ftime = time() - 15 * 24 * 3600;
  962. $z = count($z); //查看订单号
  963. $info_list[$key]['warehouse'] = $warehouse['title'];
  964. $info_list[$key]['features'] = count($c);
  965. $info_list[$key]['number'] = $z;
  966. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  967. $details = array();
  968. $cpid = array();
  969. foreach ($c as $k => $v) {
  970. $details[$v['details']] = $v['details'];
  971. if ($v['cpid'] != 0) {
  972. $cpid[$v['cpid']] = $v['cpid'];
  973. }
  974. }
  975. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  976. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  977. unset($info_list[$key]['pm']);
  978. unset($info_list[$key]['jm']);
  979. unset($info_list[$key]['bm']);
  980. }
  981. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  982. $pagenum = ceil($total / $perpage);
  983. $over = $total - ($start + $perpage);
  984. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  985. echo json_encode($rows);
  986. exit;
  987. }
  988. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  989. $this->_Template('whlabel_typeck', $this->data);
  990. }
  991. //进销存导出
  992. public function _whlabeckdc()
  993. {
  994. $prc = array();
  995. $purchase = $this->purchase->find_all();
  996. foreach ($purchase as $k => $v) {
  997. $prc[$v['id']] = $v['title'];
  998. }
  999. if (isset($_GET['excel'])) {
  1000. $where = "sku != 'Preset'";
  1001. //数据排序
  1002. $order_str = "id desc";
  1003. if (empty($page)) {
  1004. $start = 0;
  1005. $perpage = 1;
  1006. } else {
  1007. $start = ($page - 1) * $perpage;
  1008. }
  1009. $category = $this->input->get('category', true);
  1010. $color = $this->input->get('color', true);
  1011. $lowe = $this->input->get('lowe', true);
  1012. $lacetype = $this->input->get('lacetype', true);
  1013. $size = $this->input->get('size', true);
  1014. $density = $this->input->get('density', true);
  1015. $haircap = $this->input->get('haircap', true);
  1016. $sku = $this->input->get('sku', true);
  1017. $details = $this->input->get('details', true);
  1018. $warehouse = 13;
  1019. $excelid = $this->input->get('sid', true);
  1020. if ($category) {
  1021. $where .= " and features like '%-$category-%'";
  1022. }
  1023. if ($color) {
  1024. $where .= " and features like '%-$color-%'";
  1025. }
  1026. if ($lowe) {
  1027. $where .= " and features like '%-$lowe-%'";
  1028. }
  1029. if ($lacetype) {
  1030. $where .= " and features like '%-$lacetype-%'";
  1031. }
  1032. if ($size) {
  1033. $where .= " and features like '%-$size-%'";
  1034. }
  1035. if ($density) {
  1036. $where .= " and features like '%-$density-%'";
  1037. }
  1038. if ($haircap) {
  1039. $where .= " and features like '%-$haircap-%'";
  1040. }
  1041. if ($warehouse) {
  1042. $where .= " and warehouse = '$warehouse'";
  1043. }
  1044. if ($sku) {
  1045. $where .= " and sku like '%$sku%'";
  1046. }
  1047. if ($details) {
  1048. $where .= " and details = '$details'";
  1049. }
  1050. $xzid = '';
  1051. if ($excelid) {
  1052. $excelid = explode(',', trim($excelid, ','));
  1053. foreach ($excelid as $key => $value) {
  1054. $xzid .= " id = " . $value . " or";
  1055. }
  1056. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1057. }
  1058. //取得信息列表
  1059. /**
  1060. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1061. $rows = array();$list = array();
  1062. foreach ($info_list as $key=>$value)
  1063. {
  1064. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1065. }
  1066. **/
  1067. $wh = array();
  1068. $w = $this->warehouse->find_all('1=1', 'id,title');
  1069. foreach ($w as $v) {
  1070. $wh[$v['id']] = $v['title'];
  1071. }
  1072. $tc = array();
  1073. $tcdata = array();
  1074. $list = array();
  1075. $classid = $this->classid->sku();
  1076. $tcall = $this->typeclass->find_all();
  1077. $typeclass = array();
  1078. foreach ($tcall as $v)
  1079. {
  1080. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1081. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1082. }
  1083. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', "warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,GROUP_CONCAT(NULLIF(cpbz, '') ORDER BY cpbz ASC SEPARATOR ', ') AS cpbzs,number,features ");
  1084. foreach ($rows as $key => $value) {
  1085. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1086. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1087. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1088. $rows[$key]['cpbz'] = $u9_info['bm'];
  1089. $rows[$key]['cs'] = $u9_info['jm'];
  1090. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1091. $details = array();
  1092. $details_num = [];
  1093. $cpid = array();
  1094. $cpbz = array();
  1095. $c = 0;
  1096. $g = 0;
  1097. $x = 0;
  1098. $t = 0;
  1099. $s = 0;
  1100. $q = 0;
  1101. foreach ($sd as $k => $v) {
  1102. if ($v['state'] == 0) {
  1103. $c++;
  1104. }
  1105. if ($v['state'] != 9) {
  1106. $g++;
  1107. }
  1108. if ($v['state'] == 1) {
  1109. $x++;
  1110. }
  1111. if ($v['state'] == 2) {
  1112. $t++;
  1113. }
  1114. if ($v['state'] == 8) {
  1115. $s++;
  1116. }
  1117. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1118. $q++;
  1119. }
  1120. if(isset($details_num[$v['details']])){
  1121. $details_num[$v['details']] = $details_num[$v['details']] + 1;
  1122. }else{
  1123. $details_num[$v['details']] = 1;
  1124. }
  1125. $details[$v['details']] = $v['details'];
  1126. if ($v['cpid'] != 0) {
  1127. $cpid[$v['cpid']] = $v['cpid'];
  1128. }
  1129. if ($v['cpbz'] != '') {
  1130. $cpbz[$v['cpbz']] = $v['cpbz'];
  1131. }
  1132. }
  1133. $rows[$key]['details'] = implode("、", $details);
  1134. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1135. $number = $value['number'];
  1136. $ftime = time() - 15 * 24 * 3600;
  1137. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1138. $rows[$key]['number'] = $g;
  1139. $rows[$key]['features'] = $c;
  1140. $rows[$key]['x'] = $x;
  1141. $rows[$key]['t'] = $t;
  1142. $rows[$key]['s'] = $s;
  1143. $rows[$key]['q'] = $q;
  1144. $rows[$key]['wzsl'] = count($details);
  1145. $wzlpsl_str= "";
  1146. foreach($details_num as $kk => $vv){
  1147. $wzlpsl_str .= $kk . ":" . $vv . " <br/>";
  1148. }
  1149. $rows[$key]['wzlpsl'] = trim($wzlpsl_str,"<br/>");
  1150. //cpbzs
  1151. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1152. $unique_arr = array_unique($tmp_cpbzs);
  1153. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1154. }
  1155. $title = "进销存统计表" . date('Y-m-d', time());
  1156. $titlename = "<table border=1>
  1157. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1158. <tr align='center'>
  1159. <td>仓库</td>
  1160. <td>供应商</td>
  1161. <td>位置</td>
  1162. <td>库存编码</td>
  1163. <td>SKU</td>
  1164. <td>用友编码</td>
  1165. <td>用友料号</td>
  1166. <td>产品英文名</td>
  1167. <td>产品中文名</td>
  1168. <td>备注</td>
  1169. <td>入库总量</td>
  1170. <td>库存数量</td>
  1171. <td>销售数量</td>
  1172. <td>退货数量</td>
  1173. <td>删除数量</td>
  1174. <td>其它操作</td>
  1175. <td>位置数量</td>
  1176. <td>位置货物数量</td>
  1177. </tr>
  1178. </table>";
  1179. $filename = $title . ".xls";
  1180. $tail = "";
  1181. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1182. }
  1183. }
  1184. public function _type()
  1185. {
  1186. $vip = 0;
  1187. if (isset($_SESSION['api'])) {
  1188. $user = $this->user->get_api($_SESSION['api']);
  1189. $fgshop = "";
  1190. $sid = "";
  1191. $usersp = explode('|', trim($user['shop'], '|'));
  1192. foreach ($usersp as $value) {
  1193. $fgshop .= " shop = " . $value . " or";
  1194. $sid .= " id = " . $value . " or";
  1195. }
  1196. if ($user['vip'] == 1) {
  1197. $vip = 1;
  1198. }
  1199. } else {
  1200. header('Location: /');
  1201. exit;
  1202. }
  1203. $prc = array();
  1204. $purchase = $this->purchase->find_all();
  1205. foreach ($purchase as $k => $v) {
  1206. $prc[$v['id']] = $v['title'];
  1207. }
  1208. $company = array();
  1209. $ct = $this->company->find_all();
  1210. foreach ($ct as $k => $v) {
  1211. $company[$v['id']] = $v['title'];
  1212. }
  1213. $sp = array();
  1214. $s = $this->shop->find_all('1=1', 'id,shopname');
  1215. foreach ($s as $v) {
  1216. $sp[$v['id']] = $v['shopname'];
  1217. }
  1218. $wh = array();
  1219. $w = $this->warehouse->find_all('1=1', 'id,title');
  1220. foreach ($w as $v) {
  1221. $wh[$v['id']] = $v['title'];
  1222. }
  1223. $post = $this->input->post(NULL, TRUE);
  1224. if (isset($post['page'])) {
  1225. $page = $this->input->post('page', true);
  1226. $perpage = $this->input->post('perpage', true);
  1227. $category = $this->input->post('category', true);
  1228. $size = $this->input->post('size', true);
  1229. $grade = $this->input->post('grade', true);
  1230. $color = $this->input->post('color', true);
  1231. $lowe = $this->input->post('lowe', true);
  1232. $sku = $this->input->post('sku');
  1233. $title = $this->input->post('title');
  1234. $warehouse = $this->input->post('warehouse', true);
  1235. $usa = $this->input->post('usa', true);
  1236. $purchase = $this->input->post('purchase', true);
  1237. $lacetype = $this->input->post('lacetype', true);
  1238. $haircap = $this->input->post('haircap', true);
  1239. $density = $this->input->post('density', true);
  1240. $details = $this->input->post('details', true);
  1241. $state = $this->input->post('state', true);
  1242. $shop = $this->input->post('shop', true);
  1243. $lacecolor = $this->input->post('lacecolor', true);
  1244. $hairnumber = $this->input->post('hairnumber', true);
  1245. $type = $this->input->post('type', true);
  1246. $ktime = $this->input->post('ktime', true);
  1247. $jtime = $this->input->post('jtime', true);
  1248. $ktime = strtotime($ktime);
  1249. $jtime = strtotime($jtime);
  1250. $cpbz = $this->input->post('cpbz', true);
  1251. $sm = $this->input->post('sm', true);
  1252. $where = "1=1";
  1253. $gj = "";
  1254. $ck = "";
  1255. if ($usa) {
  1256. if (!$warehouse) {
  1257. $where .= " and (warehouse = '5' or warehouse = '8')";
  1258. }
  1259. }
  1260. if ($warehouse) {
  1261. $where .= " and warehouse = '$warehouse'";
  1262. }
  1263. if ($details) {
  1264. $where .= " and details = '$details'";
  1265. }
  1266. if ($purchase) {
  1267. $where .= " and purchase = '$purchase'";
  1268. }
  1269. if ($state) {
  1270. $where .= " and state = '$state'";
  1271. }
  1272. if ($shop) {
  1273. $where .= " and shop like '%$shop%'";
  1274. }
  1275. if ($type) {
  1276. $where .= " and type = '$type'";
  1277. }
  1278. if ($ktime && $jtime) {
  1279. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1280. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1281. }
  1282. if ($cpbz) {
  1283. $where .= " and cpbz like '%$cpbz%' ";
  1284. }
  1285. if ($sm) {
  1286. $where .= " and sm like '%$sm%' ";
  1287. }
  1288. if ($lacecolor) {
  1289. $where .= " and features like '%-$lacecolor-%'";
  1290. }
  1291. if ($lacetype) {
  1292. $where .= " and features like '%-$lacetype-%'";
  1293. }
  1294. if ($category) {
  1295. $where .= " and features like '%-$category-%'";
  1296. }
  1297. if ($size) {
  1298. $where .= " and features like '%-$size-%'";
  1299. }
  1300. if ($grade) {
  1301. $where .= " and features like '%-$grade-%'";
  1302. }
  1303. if ($color) {
  1304. $where .= " and features like '%-$color-%'";
  1305. }
  1306. if ($lowe) {
  1307. $where .= " and features like '%-$lowe-%'";
  1308. }
  1309. if ($haircap) {
  1310. $where .= " and features like '%-$haircap-%'";
  1311. }
  1312. if ($density) {
  1313. $where .= " and features like '%-$density-%'";
  1314. }
  1315. if (!empty($hairnumber)) {
  1316. $where .= " and features like '%-128-%' ";
  1317. if ($hairnumber < 0) {
  1318. $class_list = $this->typeclass->find_all('classid = 43');
  1319. foreach ($class_list as $v) {
  1320. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1321. }
  1322. } else {
  1323. $where .= " and features like '%-$hairnumber-%'";
  1324. }
  1325. }
  1326. //数据排序
  1327. $order_str = "id desc";
  1328. if (empty($page)) {
  1329. $start = 0;
  1330. $perpage = 1;
  1331. } else {
  1332. $start = ($page - 1) * $perpage;
  1333. }
  1334. $fjnr = '';
  1335. if ($sku) {
  1336. $sku = trim($sku, ' ');
  1337. $sku = trim($sku, ' ');
  1338. $fjnr .= " and sku like '%$sku%'";
  1339. }
  1340. if ($title) {
  1341. $title = trim($title, ' ');
  1342. $title = trim($title, ' ');
  1343. $fjnr .= " and title like '%$title%'";
  1344. }
  1345. $wt = array();
  1346. $whlabel_type = $this->whlabel_type->find_all();
  1347. foreach ($whlabel_type as $v) {
  1348. $wt[$v['id']] = $v['title'];
  1349. }
  1350. //$where .= " and time > '$ktime' and time < '$jtime'";
  1351. $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
  1352. //取得信息列表
  1353. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1354. $rows = array();
  1355. $list = array();
  1356. foreach ($info_list as $key => $value) {
  1357. if (isset($wt[$value['type']])) {
  1358. $info_list[$key]['type'] = $wt[$value['type']];
  1359. } else {
  1360. $info_list[$key]['type'] = '未设置';
  1361. }
  1362. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1363. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1364. $ztdata = '';
  1365. if (count($zt) > 0) {
  1366. foreach ($zt as $vv) {
  1367. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1368. }
  1369. }
  1370. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1371. $cdata = array_filter($qbdata, function ($item) {
  1372. return $item['state'] < 1;
  1373. });
  1374. $c = array_sum(array_column($cdata, 'jnum'));
  1375. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1376. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1377. });
  1378. $g = array_sum(array_column($gdata, 'jnum'));
  1379. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1380. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1381. });
  1382. $x = array_sum(array_column($xdata, 'jnum'));
  1383. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1384. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1385. });
  1386. $t = array_sum(array_column($tdata, 'jnum'));
  1387. // $zdata = array_filter($qbdata, function ($item) {
  1388. // return $item['zd'] != "" && $item['state'] < 1;
  1389. // });
  1390. // $z = array_sum(array_column($zdata, 'jnum'));
  1391. $zdata = array_filter($qbdata, function ($item) {
  1392. return $item['zd'] != "" && $item['state'] < 1;
  1393. });
  1394. $z = array_sum(array_column($zdata, 'jnum'));
  1395. //$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');
  1396. //$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'].'"');
  1397. //$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'].'"');
  1398. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1399. //$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'].'"');
  1400. $details = array();
  1401. $cpid = array();
  1402. $od = array();
  1403. $odid = '';
  1404. $companytitle = '';
  1405. $shop_list = [];
  1406. foreach ($qbdata as $v) {
  1407. if ($v['zd'] != "" && $v['state'] < 1) {
  1408. if (!isset($od[$v['zd']])) {
  1409. $od[$v['zd']] = 1; //所有数据sku
  1410. } else {
  1411. $od[$v['zd']] = $od[$v['zd']] + 1;
  1412. }
  1413. }
  1414. $details[$v['details']] = $v['details'];
  1415. if ($v['state'] < 1) {
  1416. //$details[$v['details']] = $v['details'];
  1417. if ($v['cpid'] != 0) {
  1418. $cpid[$v['cpid']] = $v['cpid'];
  1419. }
  1420. }
  1421. if($v['state'] == 0){
  1422. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1423. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1424. }
  1425. if ($v['shop'] != '') {
  1426. $shop = explode(',', trim($v['shop'], ','));
  1427. foreach ($shop as $vv) {
  1428. if (!in_array($vv, $shop_list)) {
  1429. $shop_list[] = $vv;
  1430. }
  1431. }
  1432. }
  1433. }
  1434. }
  1435. foreach ($od as $k => $vv) {
  1436. $odid .= $k . '数量' . $vv;
  1437. }
  1438. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1439. $info_list[$key]['label'] = $value['sm'];
  1440. $number = $value['number'];
  1441. $ftime = time() - 15 * 24 * 3600;
  1442. $z = $z . '(' . $odid . ')'; //查看订单号
  1443. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1444. $info_list[$key]['features'] = $c;
  1445. $info_list[$key]['number'] = $ztdata;
  1446. $info_list[$key]['sm'] = $g;
  1447. $info_list[$key]['x'] = $x;
  1448. $info_list[$key]['t'] = $t;
  1449. $info_list[$key]['z'] = $z;
  1450. /**
  1451. foreach ($cdata as $k=>$v)
  1452. {
  1453. $details[$v['details']] = $v['details'];
  1454. if($v['cpid'] != 0)
  1455. {
  1456. $cpid[$v['cpid']] = $v['cpid'];
  1457. }
  1458. }
  1459. **/
  1460. $info_list[$key]['shop'] = '';
  1461. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1462. // if ($value['shop'] != '') {
  1463. // $shop = explode(',', trim($value['shop'], ','));
  1464. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1465. // }
  1466. $shop_list = array_unique($shop_list);
  1467. $shop_str = '';
  1468. foreach ($shop_list as $v) {
  1469. if(isset($sp[$v])){
  1470. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1471. }
  1472. }
  1473. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1474. /**
  1475. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1476. if(isset($companytitle[0]))
  1477. {
  1478. foreach ($companytitle as $k=>$v)
  1479. {
  1480. if($v['companytitle'] != '')
  1481. {
  1482. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1483. }
  1484. }
  1485. }
  1486. **/
  1487. }
  1488. $final_all_list = [];
  1489. foreach ($info_list as $k => $v) {
  1490. $final_all_list[] = [
  1491. 'id' => $v['id'],
  1492. "warehouse" => $v["warehouse"],
  1493. "purchase" => $v["purchase"],
  1494. "sku" => $v["sku"],
  1495. "title" => $v["title"] . "<br/>" . $v["pm"],
  1496. "details" => $v["details"],
  1497. "shop" => $v["shop"],
  1498. "cpbz" => $v["cpbz"],
  1499. 'label' => $v['label'],
  1500. "type" => $v["type"],
  1501. "features" => $v["features"],
  1502. "number" => $v["number"],
  1503. "sm" => $v["sm"],
  1504. "x" => $v["x"],
  1505. "t" => $v["t"],
  1506. "z" => $v["z"]
  1507. ];
  1508. }
  1509. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1510. $pagenum = ceil($total / $perpage);
  1511. $over = $total - ($start + $perpage);
  1512. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1513. echo json_encode($rows);
  1514. exit;
  1515. }
  1516. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1517. $this->data['shop'] = $wlshop;
  1518. $this->data['vip'] = $vip;
  1519. $this->_Template('whlabel_type', $this->data);
  1520. }
  1521. //美仓进销存浏览
  1522. public function _usatype()
  1523. {
  1524. if (isset($_SESSION['api'])) {
  1525. $user = $this->user->get_api($_SESSION['api']);
  1526. $usp = $user;
  1527. $fgshop = "";
  1528. $sid = "";
  1529. $wid = "";
  1530. $wtype = "";
  1531. $userwh = explode('|', trim($user['warehouse'], '|'));
  1532. foreach ($userwh as $value) {
  1533. $wid .= " id = " . $value . " or";
  1534. $wtype .= " type = " . $value . " or";
  1535. }
  1536. }
  1537. $prc = array();
  1538. $purchase = $this->purchase->find_all();
  1539. foreach ($purchase as $k => $v) {
  1540. $prc[$v['id']] = $v['title'];
  1541. }
  1542. $post = $this->input->post(NULL, TRUE);
  1543. if (isset($post['page'])) {
  1544. $page = $this->input->post('page', true);
  1545. $perpage = $this->input->post('perpage', true);
  1546. $category = $this->input->post('category', true);
  1547. $size = $this->input->post('size', true);
  1548. $grade = $this->input->post('grade', true);
  1549. $color = $this->input->post('color', true);
  1550. $lowe = $this->input->post('lowe', true);
  1551. $sku = $this->input->post('sku');
  1552. $title = $this->input->post('title');
  1553. $warehouse = $this->input->post('warehouse', true);
  1554. $usa = $this->input->post('usa', true);
  1555. $purchase = $this->input->post('purchase', true);
  1556. $lacetype = $this->input->post('lacetype', true);
  1557. $haircap = $this->input->post('haircap', true);
  1558. $density = $this->input->post('density', true);
  1559. $details = $this->input->post('details', true);
  1560. $state = $this->input->post('state', true);
  1561. $lacecolor = $this->input->post('lacecolor', true);
  1562. $cklx = $this->input->post('cklx', true);
  1563. $ktime = $this->input->post('ktime', true);
  1564. $jtime = $this->input->post('jtime', true);
  1565. $ktime = strtotime($ktime);
  1566. $jtime = strtotime($jtime);
  1567. $where = "1=1";
  1568. $gj = "";
  1569. $ck = "";
  1570. if ($lacetype) {
  1571. $where .= " and features like '%-$lacetype-%'";
  1572. }
  1573. if ($category) {
  1574. $where .= " and features like '%-$category-%'";
  1575. }
  1576. if ($size) {
  1577. $where .= " and features like '%-$size-%'";
  1578. }
  1579. if ($grade) {
  1580. $where .= " and features like '%-$grade-%'";
  1581. }
  1582. if ($color) {
  1583. $where .= " and features like '%-$color-%'";
  1584. }
  1585. if ($lowe) {
  1586. $where .= " and features like '%-$lowe-%'";
  1587. }
  1588. if ($haircap) {
  1589. $where .= " and features like '%-$haircap-%'";
  1590. }
  1591. if ($density) {
  1592. $where .= " and features like '%-$density-%'";
  1593. }
  1594. if ($lacecolor) {
  1595. $where .= " and features like '%-$lacecolor-%'";
  1596. }
  1597. if ($usa) {
  1598. if (!$warehouse) {
  1599. $where .= " and (warehouse = '5' or warehouse = '8')";
  1600. }
  1601. }
  1602. if ($warehouse) {
  1603. $where .= " and warehouse = '$warehouse'";
  1604. }
  1605. if ($details) {
  1606. $where .= " and details = '$details'";
  1607. }
  1608. if ($purchase) {
  1609. $where .= " and purchase = '$purchase'";
  1610. }
  1611. if ($state) {
  1612. $where .= " and state = '$state'";
  1613. }
  1614. $where_add = '';
  1615. if ($cklx) {
  1616. $shop = $this->shop->read($cklx);
  1617. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1618. }
  1619. if ($ktime && $jtime) {
  1620. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1621. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1622. }
  1623. //数据排序
  1624. $order_str = "id desc";
  1625. if (empty($page)) {
  1626. $start = 0;
  1627. $perpage = 1;
  1628. } else {
  1629. $start = ($page - 1) * $perpage;
  1630. }
  1631. if ($sku) {
  1632. $sku = trim($sku, ' ');
  1633. $sku = trim($sku, ' ');
  1634. $where .= " and sku like '%$sku%'";
  1635. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1636. } else if ($title) {
  1637. $title = trim($title, ' ');
  1638. $title = trim($title, ' ');
  1639. $where .= " and title like '%$title%'";
  1640. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1641. } else {
  1642. //$where .= " and time > '$ktime' and time < '$jtime'";
  1643. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1644. }
  1645. //取得信息列表
  1646. $rows = array();
  1647. $list = array();
  1648. foreach ($info_list as $key => $value) {
  1649. $warehouse = $this->warehouse->read($value['warehouse']);
  1650. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1651. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1652. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1653. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1654. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1655. $od = array();
  1656. $odid = '';
  1657. foreach ($z as $v) {
  1658. if (!isset($od[$v['zd']])) {
  1659. $od[$v['zd']] = 1; //所有数据sku
  1660. } else {
  1661. $od[$v['zd']] = $od[$v['zd']] + 1;
  1662. }
  1663. }
  1664. foreach ($od as $k => $vv) {
  1665. $odid .= $k . '数量' . $vv . ' ';
  1666. }
  1667. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1668. $info_list[$key]['features'] = $c;
  1669. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1670. $ztdata = '';
  1671. if (count($zt) > 0) {
  1672. foreach ($zt as $vv) {
  1673. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1674. }
  1675. }
  1676. $info_list[$key]['warehouse'] = $ztdata;
  1677. $info_list[$key]['g'] = $g;
  1678. $info_list[$key]['x'] = $x;
  1679. $info_list[$key]['t'] = $t;
  1680. $info_list[$key]['z'] = $z;
  1681. }
  1682. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1683. $pagenum = ceil($total / $perpage);
  1684. $over = $total - ($start + $perpage);
  1685. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1686. echo json_encode($rows);
  1687. exit;
  1688. }
  1689. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1690. $this->data['warehouse'] = $warehouse;
  1691. $this->_Template('whlabel_typeusa', $this->data);
  1692. }
  1693. //美仓进销存浏览
  1694. public function _usatypeapp()
  1695. {
  1696. $post = $this->input->post(NULL, TRUE);
  1697. if (isset($post['page'])) {
  1698. $page = $this->input->post('page', true);
  1699. $perpage = $this->input->post('perpage', true);
  1700. $sku = $this->input->post('sku', true);
  1701. $warehouse = 5;
  1702. $title = $this->input->post('title', true);
  1703. $state = $this->input->post('state', true);
  1704. $ktime = $this->input->post('ktime', true);
  1705. $jtime = $this->input->post('jtime', true);
  1706. $ktime = strtotime($ktime);
  1707. $jtime = strtotime($jtime);
  1708. $where = "1=1";
  1709. $gj = "";
  1710. $ck = "";
  1711. if ($title) {
  1712. $st = explode(' ', trim($title, ' '));
  1713. foreach ($st as $v) {
  1714. $where .= " and title like '%$v%'";
  1715. }
  1716. }
  1717. if ($warehouse) {
  1718. $where .= " and warehouse = '$warehouse'";
  1719. }
  1720. if ($state) {
  1721. $where .= " and state = '$state'";
  1722. }
  1723. if ($sku) {
  1724. $where .= " and sku like '%$sku%'";
  1725. }
  1726. if ($ktime && $jtime) {
  1727. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1728. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1729. }
  1730. //数据排序
  1731. $order_str = "id desc";
  1732. if (empty($page)) {
  1733. $start = 0;
  1734. $perpage = 1;
  1735. } else {
  1736. $start = ($page - 1) * $perpage;
  1737. }
  1738. //取得信息列表
  1739. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1740. $rows = array();
  1741. $list = array();
  1742. foreach ($info_list as $key => $value) {
  1743. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1744. }
  1745. $rowsdq = array_slice($rows, $start, $perpage);
  1746. foreach ($rowsdq as $value) {
  1747. $warehouse = $this->warehouse->read($value['warehouse']);
  1748. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1749. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1750. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1751. $od = array();
  1752. $odid = '';
  1753. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1754. }
  1755. $total = count($rows);
  1756. $pagenum = ceil($total / $perpage);
  1757. $over = $total - ($start + $perpage);
  1758. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1759. echo json_encode($rows);
  1760. exit;
  1761. }
  1762. $this->_Template('phone/p_usatypeapp', $this->data);
  1763. }
  1764. //入库操作
  1765. public function _enteradd()
  1766. {
  1767. $dt = 0;
  1768. if (isset($_SESSION['api'])) {
  1769. $user = $this->user->get_api($_SESSION['api']);
  1770. $usp = $user;
  1771. $fgshop = "";
  1772. $sid = "";
  1773. $user = explode('|', trim($user['shop'], '|'));
  1774. foreach ($user as $value) {
  1775. $fgshop .= " shop = " . $value . " or";
  1776. $sid .= " id = " . $value . " or";
  1777. }
  1778. }
  1779. $tc = $this->typeclass->find_all();
  1780. $typeclass = array();
  1781. foreach ($tc as $v) {
  1782. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1783. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1784. }
  1785. $post = $this->input->post(NULL, TRUE);
  1786. if (isset($post['sku'])) {
  1787. $list = array();
  1788. $num = "";
  1789. $title = "";
  1790. $features = "";
  1791. $order = $this->input->post('order', true);
  1792. $shop = $this->input->post('shop', true);
  1793. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1794. $sku = $this->input->post('sku', true);
  1795. $post['sm'] = $this->input->post('sm', true);
  1796. $post['warehouse'] = $this->input->post('warehouse', true);
  1797. $post['purchase'] = $this->input->post('purchase', true);
  1798. $post['retreatwarehouse'] = $post['warehouse'];
  1799. $post['state'] = $this->input->post('state', true);
  1800. $post['rktype'] = $this->input->post('rktype', true);
  1801. $post['text'] = $this->input->post('text', true);
  1802. $category = $this->input->post('category', true);
  1803. $list['category'] = $category;
  1804. $list['hairtype'] = $this->input->post('hairtype', true);
  1805. $list['grade'] = $this->input->post('grade', true);
  1806. $size = $this->input->post('size', true);
  1807. $xzsku = $this->input->post('xzsku', true);
  1808. $list['size'] = rtrim($size, ',');
  1809. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1810. $list['extension'] = $this->input->post('extension', true);
  1811. if ($category == 1297) {
  1812. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1813. }
  1814. if ($category == 1702) {
  1815. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1816. $list['syother'] = $this->input->post('syother', true);
  1817. }
  1818. if ($category == 133) {
  1819. $list['fittype'] = $this->input->post('fittype', true);
  1820. $list['acother'] = $this->input->post('acother', true);
  1821. }
  1822. $list['color'] = $this->input->post('color', true);
  1823. $list['lowe'] = $this->input->post('lowe', true);
  1824. if (!$post['purchase']) {
  1825. $post['purchase'] = 1;
  1826. }
  1827. if ($category == 127) {
  1828. $list['type'] = $this->input->post('type', true);
  1829. $list['headroad'] = $this->input->post('headroad', true);
  1830. $list['density'] = $this->input->post('density', true);
  1831. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1832. $list['lacesize'] = $this->input->post('lacesize', true);
  1833. }
  1834. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1835. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1836. }
  1837. if ($category == 128) {
  1838. $list['lacetype'] = $this->input->post('lacetype', true);
  1839. $list['haircap'] = $this->input->post('haircap', true);
  1840. $list['density'] = $this->input->post('density', true);
  1841. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1842. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1843. $list['wigother'] = $this->input->post('wigother', true);
  1844. $list['wigother1'] = $this->input->post('wigother1', true);
  1845. $list['wigother2'] = $this->input->post('wigother2', true);
  1846. }
  1847. if ($category == 129) {
  1848. $list['wide'] = $this->input->post('wide', true);
  1849. }
  1850. if ($category == 131) {
  1851. $list['gifttype'] = $this->input->post('gifttype', true);
  1852. $list['giftother'] = $this->input->post('giftother', true);
  1853. }
  1854. if ($category == 134) {
  1855. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1856. }
  1857. if ($category == 1297) {
  1858. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1859. $list['sywigother'] = $this->input->post('sywigother', true);
  1860. }
  1861. if ($category == 130 || $category == 133 || $category == 1702) {
  1862. $list['items'] = $this->input->post('items', true);
  1863. $list['weight'] = $this->input->post('weight', true);
  1864. }
  1865. if($category == 130){
  1866. $list['jfother'] = $this->input->post('jfother', true);
  1867. }
  1868. if ($category == 1702) {
  1869. $list['syhairther'] = $this->input->post('syhairther', true);
  1870. }
  1871. $classid = $this->classid->sku();
  1872. $scsku = $classid;
  1873. $pm = $classid;
  1874. foreach ($list as $k => $v) {
  1875. if ($v != 0) {
  1876. $num .= $v;
  1877. $features .= $v . '-';
  1878. $post[$k] = $v;
  1879. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1880. if ($k != 'size') {
  1881. $title .= $typeclass[$v]['title'] . " ";
  1882. }
  1883. if (isset($pm[$typeclass[$v]['classid']])) {
  1884. if ($typeclass[$v]['title'] == '9A') {
  1885. $pm[$typeclass[$v]['classid']] = '9A';
  1886. } else if ($typeclass[$v]['title'] == '10A') {
  1887. $pm[$typeclass[$v]['classid']] = '10A';
  1888. } else {
  1889. $clzh = $typeclass[$v]['zh'];
  1890. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1891. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1892. $clzh = $clzh[0];
  1893. }
  1894. $pm[$typeclass[$v]['classid']] = $clzh;
  1895. }
  1896. }
  1897. }
  1898. }
  1899. $zh = implode(" ", $pm);
  1900. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1901. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1902. if ($list['size']) {
  1903. $typeclass = $this->typeclass->read($list['size']);
  1904. $title .= $typeclass['title'];
  1905. }
  1906. $time = time();
  1907. if ($xzsku) {
  1908. $scsku = implode("-", $scsku);
  1909. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1910. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1911. $post['sku'] = trim($scsku, ' ');
  1912. } else {
  1913. $post['sku'] = $sku;
  1914. }
  1915. //$post['sku'] = trim($sku,' ');
  1916. $post['title'] = rtrim($title, ' ');
  1917. $post['number'] = $num;
  1918. $post['features'] = '-' . $features;
  1919. $post['enter'] = $time;
  1920. $post['time'] = $time; //操作时间
  1921. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1922. if ($yza) {
  1923. if ($post['features'] != $yza[0]['features']) {
  1924. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1925. exit;
  1926. }
  1927. }
  1928. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1929. if ($yzb) {
  1930. if ($post['sku'] != $yzb[0]['sku']) {
  1931. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1932. exit;
  1933. }
  1934. }
  1935. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1936. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1937. exit;
  1938. }
  1939. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1940. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1941. exit;
  1942. }
  1943. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1944. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1945. exit;
  1946. }
  1947. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1948. if (isset($yz[0]['type'])) {
  1949. $post['type'] = $yz[0]['type'];
  1950. }
  1951. if ($post['state'] == 9) //如果选择预设库存
  1952. {
  1953. $this->whlabel->insert($post);
  1954. } else {
  1955. /**
  1956. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1957. if($ljg == 1)
  1958. {
  1959. for($i=0;$i<$order;$i++)
  1960. {
  1961. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1962. $this->whlabel->insert($post);
  1963. }
  1964. }
  1965. **/
  1966. //if($post['warehouse'] == '5')
  1967. //{
  1968. //}
  1969. $yydata = $post;
  1970. $yydata['zh'] = $zh;
  1971. /**
  1972. $wl = $this->apiyy->get_cjlp($yydata);
  1973. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1974. {
  1975. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1976. }
  1977. if($wl['Data'][0]['m_isSucess'] != 1)
  1978. {
  1979. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1980. }
  1981. **/
  1982. for ($i = 0; $i < $order; $i++) {
  1983. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1984. $this->whlabel->insert($post);
  1985. }
  1986. }
  1987. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1988. exit;
  1989. }
  1990. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1991. $this->data['wlshop'] = $wlshop;
  1992. $this->_Template('whlabel_enteradd', $this->data);
  1993. }
  1994. //修改产品
  1995. public function _enteredit($arg_array)
  1996. {
  1997. $dt = 0;
  1998. if (isset($_SESSION['api'])) {
  1999. $user = $this->user->get_api($_SESSION['api']);
  2000. $usp = $user;
  2001. $fgshop = "";
  2002. $sid = "";
  2003. $user = explode('|', trim($user['shop'], '|'));
  2004. foreach ($user as $value) {
  2005. $fgshop .= " shop = " . $value . " or";
  2006. $sid .= " id = " . $value . " or";
  2007. }
  2008. }
  2009. $post = $this->input->post(NULL, TRUE);
  2010. if (isset($post['sku'])) {
  2011. $list = array();
  2012. $num = "";
  2013. $title = "";
  2014. $features = "";
  2015. $id = $this->input->post('id', true);
  2016. $order = $this->input->post('order', true);
  2017. $shop = $this->input->post('shop', true);
  2018. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2019. $post['sku'] = $this->input->post('sku', true);
  2020. $post['sm'] = $this->input->post('sm', true);
  2021. $post['warehouse'] = $this->input->post('warehouse', true);
  2022. $post['purchase'] = $this->input->post('purchase', true);
  2023. $post['retreatwarehouse'] = $post['warehouse'];
  2024. $category = $this->input->post('category', true);
  2025. $list['category'] = $category;
  2026. $list['hairtype'] = $this->input->post('hairtype', true);
  2027. $list['grade'] = $this->input->post('grade', true);
  2028. $size = $this->input->post('size', true);
  2029. $list['size'] = rtrim($size, ',');
  2030. $post['rktype'] = $this->input->post('rktype', true);
  2031. $post['text'] = $this->input->post('text', true);
  2032. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2033. $list['extension'] = $this->input->post('extension', true);
  2034. if ($category == 1297) {
  2035. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2036. }
  2037. if ($category == 1702) {
  2038. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2039. $list['syother'] = $this->input->post('syother', true);
  2040. }
  2041. if ($category == 133) {
  2042. $list['fittype'] = $this->input->post('fittype', true);
  2043. $list['acother'] = $this->input->post('acother', true);
  2044. }
  2045. $list['color'] = $this->input->post('color', true);
  2046. $list['lowe'] = $this->input->post('lowe', true);
  2047. if (!$post['purchase']) {
  2048. $post['purchase'] = 1;
  2049. }
  2050. if ($category == 127) {
  2051. $list['type'] = $this->input->post('type', true);
  2052. $list['headroad'] = $this->input->post('headroad', true);
  2053. $list['density'] = $this->input->post('density', true);
  2054. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2055. $list['lacesize'] = $this->input->post('lacesize', true);
  2056. }
  2057. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2058. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2059. }
  2060. if ($category == 128) {
  2061. $list['lacetype'] = $this->input->post('lacetype', true);
  2062. $list['haircap'] = $this->input->post('haircap', true);
  2063. $list['density'] = $this->input->post('density', true);
  2064. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2065. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2066. $list['wigother'] = $this->input->post('wigother', true);
  2067. $list['wigother1'] = $this->input->post('wigother1', true);
  2068. $list['wigother2'] = $this->input->post('wigother2', true);
  2069. }
  2070. if ($category == 129) {
  2071. $list['wide'] = $this->input->post('wide', true);
  2072. }
  2073. if ($category == 131) {
  2074. $list['gifttype'] = $this->input->post('gifttype', true);
  2075. $list['giftother'] = $this->input->post('giftother', true);
  2076. }
  2077. if ($category == 134) {
  2078. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2079. }
  2080. if ($category == 1297) {
  2081. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2082. $list['sywigother'] = $this->input->post('sywigother', true);
  2083. }
  2084. if ($category == 130 || $category == 133 || $category == 1702) {
  2085. $list['items'] = $this->input->post('items', true);
  2086. $list['weight'] = $this->input->post('weight', true);
  2087. }
  2088. if($category == 130){
  2089. $list['jfother'] = $this->input->post('jfother', true);
  2090. }
  2091. if ($category == 1702) {
  2092. $list['syhairther'] = $this->input->post('syhairther', true);
  2093. }
  2094. foreach ($list as $k => $v) {
  2095. if ($v != 0) {
  2096. $num .= $v;
  2097. $features .= $v . '-';
  2098. $typeclass = $this->typeclass->read($v);
  2099. if ($k != 'size') {
  2100. $title .= $typeclass['title'] . " ";
  2101. }
  2102. }
  2103. }
  2104. $typeclass = $this->typeclass->read($list['size']);
  2105. $title .= $typeclass['title'];
  2106. $time = time();
  2107. $post['title'] = rtrim($title, ' ');
  2108. $post['number'] = $num;
  2109. $post['features'] = '-' . $features;
  2110. $post['time'] = $time; //操作时间
  2111. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2112. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2113. exit;
  2114. }
  2115. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2116. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2117. exit;
  2118. }
  2119. $uid = $this->whlabel->read($id);
  2120. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2121. if ($datanum > 0) {
  2122. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2123. exit;
  2124. }
  2125. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2126. {
  2127. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2128. if ($yza) {
  2129. if ($post['features'] != $yza[0]['features']) {
  2130. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2131. exit;
  2132. }
  2133. }
  2134. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2135. if ($yzb) {
  2136. if ($post['sku'] != $yzb[0]['sku']) {
  2137. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2138. exit;
  2139. }
  2140. }
  2141. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2142. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2143. exit;
  2144. }
  2145. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2146. foreach ($data as $v) {
  2147. $post['id'] = $v['id'];
  2148. $this->whlabel->save($post, $v['id']);
  2149. }
  2150. } else {
  2151. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2152. if ($data > 0) {
  2153. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2154. exit;
  2155. } else {
  2156. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2157. foreach ($data as $v) {
  2158. $post['id'] = $v['id'];
  2159. $this->whlabel->save($post, $v['id']);
  2160. }
  2161. }
  2162. }
  2163. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2164. exit;
  2165. }
  2166. $uid = $this->whlabel->read($arg_array[0]);
  2167. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2168. $this->data['enter'] = $uid;
  2169. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2170. $this->data['wlshop'] = $wlshop;
  2171. $this->_Template('whlabel_enteredit', $this->data);
  2172. }
  2173. //入库浏览
  2174. public function _enter()
  2175. {
  2176. $post = $this->input->post(NULL, TRUE);
  2177. if (isset($post['s'])) {
  2178. $id_arr = $this->input->post('s');
  2179. $id_arr = explode(',', $id_arr);
  2180. if (!$id_arr) {
  2181. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2182. exit;
  2183. }
  2184. //循环删除记录
  2185. foreach ($id_arr as $v) {
  2186. $sid = $this->whlabel->read($v);
  2187. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2188. if ($count > 0) {
  2189. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2190. exit;
  2191. }
  2192. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2193. foreach ($info_list as $va) {
  2194. $this->whlabel->remove($va['id']);
  2195. }
  2196. }
  2197. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2198. exit;
  2199. }
  2200. $sp = array();
  2201. $s = $this->shop->find_all('1=1', 'id,shopname');
  2202. foreach ($s as $v) {
  2203. $sp[$v['id']] = $v['shopname'];
  2204. }
  2205. $wh = array();
  2206. $w = $this->warehouse->find_all('1=1', 'id,title');
  2207. foreach ($w as $v) {
  2208. $wh[$v['id']] = $v['title'];
  2209. }
  2210. if (isset($post['page'])) {
  2211. $page = $this->input->post('page', true);
  2212. $perpage = $this->input->post('perpage', true);
  2213. $category = $this->input->post('category', true);
  2214. $size = $this->input->post('size', true);
  2215. $grade = $this->input->post('grade', true);
  2216. $color = $this->input->post('color', true);
  2217. $lowe = $this->input->post('lowe', true);
  2218. $sku = $this->input->post('sku', true);
  2219. $warehouse = $this->input->post('warehouse', true);
  2220. $purchase = $this->input->post('purchase', true);
  2221. $ktime = $this->input->post('ktime', true);
  2222. $jtime = $this->input->post('jtime', true);
  2223. $ktime = strtotime($ktime);
  2224. $jtime = strtotime($jtime);
  2225. $where = "1=1";
  2226. $gj = "";
  2227. $ck = "";
  2228. if ($category) {
  2229. $where .= " and features like '%-$category-%'";
  2230. }
  2231. if ($size) {
  2232. $where .= " and features like '%-$size-%'";
  2233. }
  2234. if ($grade) {
  2235. $where .= " and features like '%-$grade-%'";
  2236. }
  2237. if ($color) {
  2238. $where .= " and features like '%-$color-%'";
  2239. }
  2240. if ($lowe) {
  2241. $where .= " and features like '%-$lowe-%'";
  2242. }
  2243. if ($warehouse) {
  2244. $where .= " and warehouse = '$warehouse'";
  2245. }
  2246. if ($purchase) {
  2247. $where .= " and purchase = '$purchase'";
  2248. }
  2249. if ($sku) {
  2250. $where .= " and sku like '%$sku%'";
  2251. }
  2252. if ($ktime && $jtime) {
  2253. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2254. }
  2255. //数据排序
  2256. $order_str = "enter desc";
  2257. if (empty($page)) {
  2258. $start = 0;
  2259. $perpage = 1;
  2260. } else {
  2261. $start = ($page - 1) * $perpage;
  2262. }
  2263. //取得信息列表
  2264. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2265. foreach ($info_list as $k => $v) {
  2266. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2267. if ($v['shop'] == '') {
  2268. $s = '通用';
  2269. } else {
  2270. $info_list[$k]['shop'] = '';
  2271. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2272. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2273. }
  2274. }
  2275. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2276. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2277. $info_list[$k]['g'] = $g;
  2278. }
  2279. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2280. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2281. $pagenum = ceil($total / $perpage);
  2282. $over = $total - ($start + $perpage);
  2283. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2284. echo json_encode($rows);
  2285. exit;
  2286. }
  2287. $this->_Template('whlabel_enter', $this->data);
  2288. }
  2289. //出库浏览
  2290. public function _out()
  2291. {
  2292. $post = $this->input->post(NULL, TRUE);
  2293. if (isset($post['page'])) {
  2294. $page = $this->input->post('page', true);
  2295. $perpage = $this->input->post('perpage', true);
  2296. $category = $this->input->post('category', true);
  2297. $size = $this->input->post('size', true);
  2298. $grade = $this->input->post('grade', true);
  2299. $color = $this->input->post('color', true);
  2300. $lowe = $this->input->post('lowe', true);
  2301. $sku = $this->input->post('sku', true);
  2302. $warehouse = $this->input->post('warehouse', true);
  2303. $purchase = $this->input->post('purchase', true);
  2304. $state = $this->input->post('state', true);
  2305. $ktime = $this->input->post('ktime', true);
  2306. $jtime = $this->input->post('jtime', true);
  2307. $ktime = strtotime($ktime);
  2308. $jtime = strtotime($jtime);
  2309. $where = "state=3";
  2310. $gj = "";
  2311. $ck = "";
  2312. if ($category) {
  2313. $where .= " and features like '%-$category-%'";
  2314. }
  2315. if ($size) {
  2316. $where .= " and features like '%-$size-%'";
  2317. }
  2318. if ($grade) {
  2319. $where .= " and features like '%-$grade-%'";
  2320. }
  2321. if ($color) {
  2322. $where .= " and features like '%-$color-%'";
  2323. }
  2324. if ($lowe) {
  2325. $where .= " and features like '%-$lowe-%'";
  2326. }
  2327. if ($state) {
  2328. $where .= " and state = '$state'";
  2329. }
  2330. if ($warehouse) {
  2331. $where .= " and warehouse = '$warehouse'";
  2332. }
  2333. if ($purchase) {
  2334. $where .= " and purchase = '$purchase'";
  2335. }
  2336. if ($sku) {
  2337. $where .= " and sku = '$sku'";
  2338. }
  2339. if ($ktime && $jtime) {
  2340. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2341. }
  2342. //数据排序
  2343. $order_str = "id desc";
  2344. if (empty($page)) {
  2345. $start = 0;
  2346. $perpage = 1;
  2347. } else {
  2348. $start = ($page - 1) * $perpage;
  2349. }
  2350. //取得信息列表
  2351. $info_list = $this->whlabel->find_all($where, 'sku');
  2352. $rows = array();
  2353. $list = array();
  2354. foreach ($info_list as $key => $value) {
  2355. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2356. }
  2357. $rows = array_unique($rows); //删除重复记录
  2358. foreach ($rows as $key => $value) {
  2359. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2360. $ck = $this->warehouse->read($data['warehouse']);
  2361. $warehouse = $ck['title'];
  2362. $gy = $this->purchase->read($data['purchase']);
  2363. $purchase = $gy['purchase'];
  2364. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2365. $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);
  2366. }
  2367. $total = count($list);
  2368. $pagenum = ceil($total / $perpage);
  2369. $over = $total - ($start + $perpage);
  2370. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2371. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2372. echo json_encode($rows);
  2373. exit;
  2374. }
  2375. $this->_Template('whlabel_out', $this->data);
  2376. }
  2377. //出库标签浏览
  2378. public function _label()
  2379. {
  2380. $post = $this->input->post(NULL, TRUE);
  2381. if (isset($post['page'])) {
  2382. $page = $this->input->post('page', true);
  2383. $perpage = $this->input->post('perpage', true);
  2384. $sku = $this->input->post('sku', true);
  2385. $warehouse = $this->input->post('warehouse', true);
  2386. $purchase = $this->input->post('purchase', true);
  2387. $orderinfo = $this->input->post('orderinfo', true);
  2388. $waybill = $this->input->post('waybill', true);
  2389. $category = $this->input->post('category', true);
  2390. $size = $this->input->post('size', true);
  2391. $grade = $this->input->post('grade', true);
  2392. $color = $this->input->post('color', true);
  2393. $lowe = $this->input->post('lowe', true);
  2394. $where = "state=1";
  2395. if ($sku) {
  2396. $where .= " and sku = '$sku'";
  2397. }
  2398. if ($warehouse) {
  2399. $where .= " and warehouse = '$warehouse'";
  2400. }
  2401. if ($purchase) {
  2402. $where .= " and purchase = '$purchase'";
  2403. }
  2404. if ($orderinfo) {
  2405. $where .= " and orderinfo = '$orderinfo'";
  2406. }
  2407. if ($waybill) {
  2408. $where .= " and waybill = '$waybill'";
  2409. }
  2410. if ($category) {
  2411. $where .= " and features like '%-$category-%'";
  2412. }
  2413. if ($size) {
  2414. $where .= " and features like '%-$size-%'";
  2415. }
  2416. if ($grade) {
  2417. $where .= " and features like '%-$grade-%'";
  2418. }
  2419. if ($color) {
  2420. $where .= " and features like '%-$color-%'";
  2421. }
  2422. if ($lowe) {
  2423. $where .= " and features like '%-$lowe-%'";
  2424. }
  2425. //数据排序
  2426. $order_str = "outk desc";
  2427. if (empty($page)) {
  2428. $start = 0;
  2429. $perpage = 1;
  2430. } else {
  2431. $start = ($page - 1) * $perpage;
  2432. }
  2433. //取得信息列表
  2434. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2435. foreach ($info_list as $key => $value) {
  2436. $warehouse = $this->warehouse->read($value['warehouse']);
  2437. $info_list[$key]['warehouse'] = $warehouse['title'];
  2438. $purchase = $this->purchase->read($value['purchase']);
  2439. $info_list[$key]['purchase'] = $purchase['title'];
  2440. if ($value['outk'] != 0) {
  2441. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2442. } else {
  2443. $info_list[$key]['outk'] = "";
  2444. }
  2445. if ($value['orderinfo'] == 0) {
  2446. $info_list[$key]['orderinfo'] = "";
  2447. }
  2448. if ($value['waybill'] == 0) {
  2449. $info_list[$key]['waybill'] = "";
  2450. }
  2451. }
  2452. $total = $this->whlabel->find_count($where);
  2453. $pagenum = ceil($total / $perpage);
  2454. $over = $total - ($start + $perpage);
  2455. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2456. echo json_encode($rows);
  2457. exit;
  2458. }
  2459. $this->_Template('whlabel_label', $this->data);
  2460. }
  2461. //独立站出库订单
  2462. public function _outorder()
  2463. {
  2464. if (isset($_SESSION['api'])) {
  2465. $user = $this->user->get_api($_SESSION['api']);
  2466. $usp = $user;
  2467. $fgshop = "";
  2468. $sid = "";
  2469. $user = explode('|', trim($user['shop'], '|'));
  2470. foreach ($user as $value) {
  2471. $fgshop .= " shop = " . $value . " or";
  2472. $sid .= " id = " . $value . " or";
  2473. }
  2474. } else {
  2475. echo "请重新登录";
  2476. }
  2477. $post = $this->input->post(NULL, TRUE);
  2478. if (isset($post['page'])) {
  2479. $page = $this->input->post('page', true);
  2480. $perpage = $this->input->post('perpage', true);
  2481. $warehouse = $this->input->post('warehouse', true);
  2482. $xztime = $this->input->post('xztime', true);
  2483. $timetk = $this->input->post('timetkk', true);
  2484. $timetj = $this->input->post('timetjj', true);
  2485. $shop = $this->input->post('shop', true);
  2486. $source = $this->input->post('source', true);
  2487. $orderinfo = $this->input->post('orderinfo', true);
  2488. $number = $this->input->post('number', true);
  2489. $sfxh = $this->input->post('sfxh', true);
  2490. $express = $this->input->post('express', true);
  2491. $waybill = $this->input->post('waybill', true);
  2492. $library = $this->input->post('library', true);
  2493. $country = $this->input->post('country', true);
  2494. $so = $this->input->post('so', true);
  2495. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2496. $print = $this->input->post('print', true);
  2497. $state = $this->input->post('state', true);
  2498. $orderurl = $this->input->post('orderurl', true);
  2499. $productid = $this->input->post('productid', true);
  2500. $timetk = strtotime($timetk);
  2501. $timetj = strtotime($timetj);
  2502. /**
  2503. $sj = $this->input->post('sj',true);
  2504. if($sj)
  2505. {
  2506. $sj = $this->input->post('sj',true);
  2507. }
  2508. else
  2509. {
  2510. $sj = "fullorder";
  2511. }
  2512. **/
  2513. $sj = "fullorder";
  2514. $where = "1=1";
  2515. if ($warehouse) {
  2516. $where .= " and type = '$warehouse'";
  2517. }
  2518. if ($timetk && $timetj) {
  2519. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2520. }
  2521. if ($orderinfo) {
  2522. $where .= " and orderinfo = '$orderinfo'";
  2523. }
  2524. if ($number) {
  2525. $where .= " and number = '$number'";
  2526. }
  2527. if ($express) {
  2528. $where .= " and express = '$express'";
  2529. }
  2530. if ($waybill) {
  2531. $where .= " and waybill = '$waybill'";
  2532. }
  2533. if ($library) {
  2534. $where .= " and library = '$library'";
  2535. }
  2536. if ($print) {
  2537. $where .= " and print = '$print'";
  2538. }
  2539. if ($libraryconfirm) {
  2540. $where .= " and libraryconfirm = '$libraryconfirm'";
  2541. }
  2542. if ($state) {
  2543. $where .= " and state = '$state'";
  2544. }
  2545. if ($shop) {
  2546. $where .= " and shop = '$shop'";
  2547. }
  2548. if ($country) {
  2549. $where .= " and country = '$country'";
  2550. }
  2551. if ($sfxh != '') {
  2552. $where .= " and sfxh = '$sfxh'";
  2553. }
  2554. if ($so) {
  2555. $where .= " and shipremarks like '%$so%'";
  2556. }
  2557. if ($source) {
  2558. if ($source == '2d') {
  2559. $where .= " and source >= '2'";
  2560. } else {
  2561. $where .= " and source = '$source'";
  2562. }
  2563. }
  2564. if (isset($_SESSION['api'])) {
  2565. foreach ($user as $value) {
  2566. $fgshop .= " shop = " . $value . " or";
  2567. }
  2568. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2569. }
  2570. if ($orderurl) {
  2571. $url = $this->orderurl->read($orderurl);
  2572. $where .= " and link like '%" . $url['url'] . "%'";
  2573. }
  2574. if($productid){
  2575. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2576. }
  2577. //数据排序
  2578. $order_str = "librarytime desc";
  2579. if (empty($page)) {
  2580. $start = 0;
  2581. $perpage = 1;
  2582. } else {
  2583. $start = ($page - 1) * $perpage;
  2584. }
  2585. //取得信息列表
  2586. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2587. //格式化数据
  2588. foreach ($info_list as $key => $value) {
  2589. $shop = $this->shop->read($value['shop']);
  2590. $info_list[$key]['shop'] = $shop['shopname'];
  2591. $express = $this->express->read($value['express']);
  2592. $info_list[$key]['express'] = $express['servicename'];
  2593. $warehouse = $this->warehouse->read($value['type']);
  2594. $info_list[$key]['type'] = $warehouse['title'];
  2595. if ($value['librarytime'] == '0') {
  2596. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2597. } else {
  2598. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2599. }
  2600. }
  2601. $total = $this->$sj->find_count($where);
  2602. $pagenum = ceil($total / $perpage);
  2603. $over = $total - ($start + $perpage);
  2604. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2605. echo json_encode($rows);
  2606. exit;
  2607. }
  2608. $this->data['express'] = $this->express->find_all();
  2609. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2610. $this->data['wlshop'] = $wlshop;
  2611. $user = $this->user->get_api($_SESSION['api']);
  2612. $powerid = $this->power->read($user['power']);
  2613. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2614. $pid = '';
  2615. foreach ($powertext as $v) {
  2616. $pid .= " id = " . $v . " or";
  2617. }
  2618. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2619. $this->data['fullorderexcel'] = $fullorderexcel;
  2620. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2621. $this->data['orderurl'] = $orderurl;
  2622. $this->_Template('whlabel_outorder', $this->data);
  2623. }
  2624. //tt出库
  2625. public function _toutorder()
  2626. {
  2627. $fgshop = "";
  2628. $sid = "";
  2629. if (isset($_SESSION['api'])) {
  2630. $user = $this->user->get_api($_SESSION['api']);
  2631. $usp = $user;
  2632. $user = explode('|', trim($user['shop'], '|'));
  2633. foreach ($user as $value) {
  2634. $fgshop .= " shop = " . $value . " or";
  2635. $sid .= " id = " . $value . " or";
  2636. }
  2637. } else {
  2638. echo "请重新登录";
  2639. die;
  2640. }
  2641. $post = $this->input->post(NULL, TRUE);
  2642. if (isset($post['page'])) {
  2643. $page = $this->input->post('page', true);
  2644. $perpage = $this->input->post('perpage', true);
  2645. $warehouse = $this->input->post('warehouse', true);
  2646. $xztime = $this->input->post('xztime', true);
  2647. $timetk = $this->input->post('timetkk', true);
  2648. $timetj = $this->input->post('timetjj', true);
  2649. $shop = $this->input->post('shop', true);
  2650. $source = $this->input->post('source', true);
  2651. $orderinfo = $this->input->post('orderinfo', true);
  2652. $number = $this->input->post('number', true);
  2653. $sfxh = $this->input->post('sfxh', true);
  2654. $express = $this->input->post('express', true);
  2655. $waybill = $this->input->post('waybill', true);
  2656. $library = $this->input->post('library', true);
  2657. $country = $this->input->post('country', true);
  2658. $so = $this->input->post('so', true);
  2659. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2660. $print = $this->input->post('print', true);
  2661. $state = $this->input->post('state', true);
  2662. $orderurl = $this->input->post('orderurl', true);
  2663. $timetk = strtotime($timetk);
  2664. $timetj = strtotime($timetj);
  2665. /**
  2666. $sj = $this->input->post('sj',true);
  2667. if($sj)
  2668. {
  2669. $sj = $this->input->post('sj',true);
  2670. }
  2671. else
  2672. {
  2673. $sj = "fullorder";
  2674. }
  2675. **/
  2676. $sj = "fullordertt";
  2677. $where = "1=1";
  2678. if ($warehouse) {
  2679. $where .= " and type = '$warehouse'";
  2680. }
  2681. if ($timetk && $timetj) {
  2682. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2683. }
  2684. if ($orderinfo) {
  2685. $where .= " and orderinfo = '$orderinfo'";
  2686. }
  2687. if ($number) {
  2688. $where .= " and number = '$number'";
  2689. }
  2690. if ($express) {
  2691. $where .= " and express = '$express'";
  2692. }
  2693. if ($waybill) {
  2694. $where .= " and waybill = '$waybill'";
  2695. }
  2696. if ($library) {
  2697. $where .= " and library = '$library'";
  2698. }
  2699. if ($print) {
  2700. $where .= " and print = '$print'";
  2701. }
  2702. if ($libraryconfirm) {
  2703. $where .= " and libraryconfirm = '$libraryconfirm'";
  2704. }
  2705. if ($state) {
  2706. $where .= " and state = '$state'";
  2707. }
  2708. if ($shop) {
  2709. $where .= " and shop = '$shop'";
  2710. }
  2711. if ($country) {
  2712. $where .= " and country = '$country'";
  2713. }
  2714. if ($sfxh != '') {
  2715. $where .= " and sfxh = '$sfxh'";
  2716. }
  2717. if ($so) {
  2718. $where .= " and shipremarks like '%$so%'";
  2719. }
  2720. if ($source) {
  2721. if ($source == '2d') {
  2722. $where .= " and source >= '2'";
  2723. } else {
  2724. $where .= " and source = '$source'";
  2725. }
  2726. }
  2727. if (isset($_SESSION['api'])) {
  2728. foreach ($user as $value) {
  2729. $fgshop .= " shop = " . $value . " or";
  2730. }
  2731. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2732. }
  2733. if ($orderurl) {
  2734. $url = $this->orderurl->read($orderurl);
  2735. $where .= " and link like '%" . $url['url'] . "%'";
  2736. }
  2737. //数据排序
  2738. $order_str = "librarytime desc";
  2739. if (empty($page)) {
  2740. $start = 0;
  2741. $perpage = 1;
  2742. } else {
  2743. $start = ($page - 1) * $perpage;
  2744. }
  2745. //取得信息列表
  2746. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2747. //格式化数据
  2748. foreach ($info_list as $key => $value) {
  2749. $shop = $this->shop->read($value['shop']);
  2750. $info_list[$key]['shop'] = $shop['shopname'];
  2751. $express = $this->express->read($value['express']);
  2752. $info_list[$key]['express'] = $express['servicename'];
  2753. $warehouse = $this->warehouse->read($value['type']);
  2754. $info_list[$key]['type'] = $warehouse['title'];
  2755. if ($value['librarytime'] == '0') {
  2756. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2757. } else {
  2758. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2759. }
  2760. }
  2761. $total = $this->$sj->find_count($where);
  2762. $pagenum = ceil($total / $perpage);
  2763. $over = $total - ($start + $perpage);
  2764. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2765. echo json_encode($rows);
  2766. exit;
  2767. }
  2768. $this->data['express'] = $this->express->find_all();
  2769. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2770. $this->data['wlshop'] = $wlshop;
  2771. $user = $this->user->get_api($_SESSION['api']);
  2772. $powerid = $this->power->read($user['power']);
  2773. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2774. $pid = '';
  2775. foreach ($powertext as $v) {
  2776. $pid .= " id = " . $v . " or";
  2777. }
  2778. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2779. $this->data['fullorderexcel'] = $fullorderexcel;
  2780. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2781. $this->data['orderurl'] = $orderurl;
  2782. $this->_Template('whlabel_toutorder', $this->data);
  2783. }
  2784. //tt出库
  2785. public function _aoutorder()
  2786. {
  2787. if (isset($_SESSION['api'])) {
  2788. $user = $this->user->get_api($_SESSION['api']);
  2789. $usp = $user;
  2790. $fgshop = "";
  2791. $sid = "";
  2792. $user = explode('|', trim($user['shop'], '|'));
  2793. foreach ($user as $value) {
  2794. $fgshop .= " shop = " . $value . " or";
  2795. $sid .= " id = " . $value . " or";
  2796. }
  2797. } else {
  2798. echo "请重新登录";
  2799. }
  2800. $post = $this->input->post(NULL, TRUE);
  2801. if (isset($post['page'])) {
  2802. $page = $this->input->post('page', true);
  2803. $perpage = $this->input->post('perpage', true);
  2804. $warehouse = $this->input->post('warehouse', true);
  2805. $xztime = $this->input->post('xztime', true);
  2806. $timetk = $this->input->post('timetkk', true);
  2807. $timetj = $this->input->post('timetjj', true);
  2808. $shop = $this->input->post('shop', true);
  2809. $source = $this->input->post('source', true);
  2810. $orderinfo = $this->input->post('orderinfo', true);
  2811. $number = $this->input->post('number', true);
  2812. $sfxh = $this->input->post('sfxh', true);
  2813. $express = $this->input->post('express', true);
  2814. $waybill = $this->input->post('waybill', true);
  2815. $library = $this->input->post('library', true);
  2816. $country = $this->input->post('country', true);
  2817. $so = $this->input->post('so', true);
  2818. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2819. $print = $this->input->post('print', true);
  2820. $state = $this->input->post('state', true);
  2821. $orderurl = $this->input->post('orderurl', true);
  2822. $timetk = strtotime($timetk);
  2823. $timetj = strtotime($timetj);
  2824. /**
  2825. $sj = $this->input->post('sj',true);
  2826. if($sj)
  2827. {
  2828. $sj = $this->input->post('sj',true);
  2829. }
  2830. else
  2831. {
  2832. $sj = "fullorder";
  2833. }
  2834. **/
  2835. $sj = "fullorderamz";
  2836. $where = "1=1";
  2837. if ($warehouse) {
  2838. $where .= " and type = '$warehouse'";
  2839. }
  2840. if ($timetk && $timetj) {
  2841. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2842. }
  2843. if ($orderinfo) {
  2844. $where .= " and orderinfo = '$orderinfo'";
  2845. }
  2846. if ($number) {
  2847. $where .= " and number = '$number'";
  2848. }
  2849. if ($express) {
  2850. $where .= " and express = '$express'";
  2851. }
  2852. if ($waybill) {
  2853. $where .= " and waybill = '$waybill'";
  2854. }
  2855. if ($library) {
  2856. $where .= " and library = '$library'";
  2857. }
  2858. if ($print) {
  2859. $where .= " and print = '$print'";
  2860. }
  2861. if ($libraryconfirm) {
  2862. $where .= " and libraryconfirm = '$libraryconfirm'";
  2863. }
  2864. if ($state) {
  2865. $where .= " and state = '$state'";
  2866. }
  2867. if ($shop) {
  2868. $where .= " and shop = '$shop'";
  2869. }
  2870. if ($country) {
  2871. $where .= " and country = '$country'";
  2872. }
  2873. if ($sfxh != '') {
  2874. $where .= " and sfxh = '$sfxh'";
  2875. }
  2876. if ($so) {
  2877. $where .= " and shipremarks like '%$so%'";
  2878. }
  2879. if ($source) {
  2880. if ($source == '2d') {
  2881. $where .= " and source >= '2'";
  2882. } else {
  2883. $where .= " and source = '$source'";
  2884. }
  2885. }
  2886. if (isset($_SESSION['api'])) {
  2887. foreach ($user as $value) {
  2888. $fgshop .= " shop = " . $value . " or";
  2889. }
  2890. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2891. }
  2892. if ($orderurl) {
  2893. $url = $this->orderurl->read($orderurl);
  2894. $where .= " and link like '%" . $url['url'] . "%'";
  2895. }
  2896. //数据排序
  2897. $order_str = "librarytime desc";
  2898. if (empty($page)) {
  2899. $start = 0;
  2900. $perpage = 1;
  2901. } else {
  2902. $start = ($page - 1) * $perpage;
  2903. }
  2904. //取得信息列表
  2905. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2906. //格式化数据
  2907. foreach ($info_list as $key => $value) {
  2908. $shop = $this->shop->read($value['shop']);
  2909. $info_list[$key]['shop'] = $shop['shopname'];
  2910. $express = $this->express->read($value['express']);
  2911. $info_list[$key]['express'] = $express['servicename'];
  2912. $warehouse = $this->warehouse->read($value['type']);
  2913. $info_list[$key]['type'] = $warehouse['title'];
  2914. if ($value['librarytime'] == '0') {
  2915. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2916. } else {
  2917. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2918. }
  2919. }
  2920. $total = $this->$sj->find_count($where);
  2921. $pagenum = ceil($total / $perpage);
  2922. $over = $total - ($start + $perpage);
  2923. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2924. echo json_encode($rows);
  2925. exit;
  2926. }
  2927. $this->data['express'] = $this->express->find_all();
  2928. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2929. $this->data['wlshop'] = $wlshop;
  2930. $user = $this->user->get_api($_SESSION['api']);
  2931. $powerid = $this->power->read($user['power']);
  2932. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2933. $pid = '';
  2934. foreach ($powertext as $v) {
  2935. $pid .= " id = " . $v . " or";
  2936. }
  2937. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2938. $this->data['fullorderexcel'] = $fullorderexcel;
  2939. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2940. $this->data['orderurl'] = $orderurl;
  2941. $this->_Template('whlabel_aoutorder', $this->data);
  2942. }
  2943. //速卖通出库订单
  2944. public function _soutorder()
  2945. {
  2946. if (isset($_SESSION['api'])) {
  2947. $user = $this->user->get_api($_SESSION['api']);
  2948. $usp = $user;
  2949. $fgshop = "";
  2950. $sid = "";
  2951. $user = explode('|', trim($user['shop'], '|'));
  2952. foreach ($user as $value) {
  2953. $sid .= " id = " . $value . " or";
  2954. }
  2955. }
  2956. $post = $this->input->post(NULL, TRUE);
  2957. if (isset($post['page'])) {
  2958. $page = $this->input->post('page', true);
  2959. $perpage = $this->input->post('perpage', true);
  2960. $warehouse = $this->input->post('warehouse', true);
  2961. $xztime = $this->input->post('xztime', true);
  2962. $timetk = $this->input->post('timetkk', true);
  2963. $timetj = $this->input->post('timetjj', true);
  2964. $shop = $this->input->post('shop', true);
  2965. $source = $this->input->post('source', true);
  2966. $orderinfo = $this->input->post('orderinfo', true);
  2967. $number = $this->input->post('number', true);
  2968. $express = $this->input->post('express', true);
  2969. $waybill = $this->input->post('waybill', true);
  2970. $library = $this->input->post('library', true);
  2971. $country = $this->input->post('country', true);
  2972. $sfxh = $this->input->post('sfxh', true);
  2973. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2974. $print = $this->input->post('print', true);
  2975. $state = $this->input->post('state', true);
  2976. $so = $this->input->post('so', true);
  2977. $timetk = strtotime($timetk);
  2978. $timetj = strtotime($timetj);
  2979. /**
  2980. $sj = $this->input->post('sj',true);
  2981. if($sj)
  2982. {
  2983. $sj = $this->input->post('sj',true);
  2984. }
  2985. else
  2986. {
  2987. $sj = "fullorder";
  2988. }
  2989. **/
  2990. $sj = "fullordersmt";
  2991. $where = "1=1";
  2992. if ($warehouse) {
  2993. $where .= " and type = '$warehouse'";
  2994. }
  2995. if ($timetk && $timetj) {
  2996. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2997. }
  2998. if ($orderinfo) {
  2999. $where .= " and orderinfo = '$orderinfo'";
  3000. }
  3001. if ($number) {
  3002. $where .= " and number = '$number'";
  3003. }
  3004. if ($express) {
  3005. $where .= " and express = '$express'";
  3006. }
  3007. if ($waybill) {
  3008. $where .= " and waybill = '$waybill'";
  3009. }
  3010. if ($library) {
  3011. $where .= " and library = '$library'";
  3012. }
  3013. if ($print) {
  3014. $where .= " and print = '$print'";
  3015. }
  3016. if ($libraryconfirm) {
  3017. $where .= " and libraryconfirm = '$libraryconfirm'";
  3018. }
  3019. if ($state) {
  3020. $where .= " and state = '$state'";
  3021. }
  3022. if ($shop) {
  3023. $where .= " and shop = '$shop'";
  3024. }
  3025. if ($sfxh != '') {
  3026. $where .= " and sfxh = '$sfxh'";
  3027. }
  3028. if ($so) {
  3029. $where .= " and shipremarks like '%$so%'";
  3030. }
  3031. if ($source) {
  3032. $where .= " and source = '$source'";
  3033. }
  3034. if ($country) {
  3035. $where .= " and country = '$country'";
  3036. } else {
  3037. if (isset($_SESSION['api'])) {
  3038. foreach ($user as $value) {
  3039. $fgshop .= " shop = " . $value . " or";
  3040. }
  3041. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3042. }
  3043. }
  3044. //数据排序
  3045. $order_str = "librarytime desc";
  3046. if (empty($page)) {
  3047. $start = 0;
  3048. $perpage = 1;
  3049. } else {
  3050. $start = ($page - 1) * $perpage;
  3051. }
  3052. //取得信息列表
  3053. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3054. //格式化数据
  3055. foreach ($info_list as $key => $value) {
  3056. $shop = $this->shop->read($value['shop']);
  3057. $info_list[$key]['shop'] = $shop['shopname'];
  3058. $express = $this->express->read($value['express']);
  3059. $info_list[$key]['express'] = $express['servicename'];
  3060. $warehouse = $this->warehouse->read($value['type']);
  3061. $info_list[$key]['type'] = $warehouse['title'];
  3062. if ($value['librarytime'] == '0') {
  3063. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3064. } else {
  3065. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3066. }
  3067. }
  3068. $total = $this->$sj->find_count($where);
  3069. $pagenum = ceil($total / $perpage);
  3070. $over = $total - ($start + $perpage);
  3071. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3072. echo json_encode($rows);
  3073. exit;
  3074. }
  3075. $this->data['express'] = $this->express->find_all();
  3076. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3077. $this->data['wlshop'] = $wlshop;
  3078. $user = $this->user->get_api($_SESSION['api']);
  3079. $powerid = $this->power->read($user['power']);
  3080. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3081. $pid = '';
  3082. foreach ($powertext as $v) {
  3083. $pid .= " id = " . $v . " or";
  3084. }
  3085. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3086. $this->data['fullorderexcel'] = $fullorderexcel;
  3087. $this->_Template('whlabel_soutorder', $this->data);
  3088. }
  3089. //订单退库
  3090. public function _retreat()
  3091. {
  3092. $post = $this->input->post(NULL, TRUE);
  3093. if (isset($post['page'])) {
  3094. $page = $this->input->post('page', true);
  3095. $perpage = $this->input->post('perpage', true);
  3096. $warehouse = $this->input->post('warehouse', true);
  3097. $timetk = $this->input->post('timetk', true);
  3098. $timetj = $this->input->post('timetj', true);
  3099. $shop = $this->input->post('shop', true);
  3100. $source = $this->input->post('source', true);
  3101. $state = $this->input->post('state', true);
  3102. $review = $this->input->post('review', true);
  3103. $state = $this->input->post('state', true);
  3104. $express = $this->input->post('express', true);
  3105. $orderinfo = $this->input->post('orderinfo', true);
  3106. $user = $this->input->post('user', true);
  3107. $name = $this->input->post('name', true);
  3108. $waybill = $this->input->post('waybill', true);
  3109. $timetk = strtotime($timetk);
  3110. $timetj = strtotime($timetj);
  3111. $where = "(state=206 or state=210) and mergeid = 0";
  3112. if ($warehouse) {
  3113. $where .= " and state = '$warehouse'";
  3114. }
  3115. if ($timetk && $timetj) {
  3116. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3117. }
  3118. if ($shop) {
  3119. $where .= " and shop = '$shop'";
  3120. }
  3121. if ($source) {
  3122. $where .= " and source = '$source'";
  3123. }
  3124. if ($state) {
  3125. $where .= " and state = '$state'";
  3126. }
  3127. if ($review) {
  3128. $where .= " and review = '$review'";
  3129. }
  3130. if ($state) {
  3131. $where .= " and state = '$state'";
  3132. }
  3133. if ($express) {
  3134. $where .= " and express = '$express'";
  3135. }
  3136. if ($orderinfo) {
  3137. $where .= " and orderinfo = '$orderinfo'";
  3138. }
  3139. if ($user) {
  3140. $where .= " and user = '$user'";
  3141. }
  3142. if ($name) {
  3143. $where .= " and name = '$name'";
  3144. }
  3145. if ($waybill) {
  3146. $where .= " and waybill = '$waybill'";
  3147. }
  3148. //数据排序
  3149. $order_str = "id desc";
  3150. if (empty($page)) {
  3151. $start = 0;
  3152. $perpage = 1;
  3153. } else {
  3154. $start = ($page - 1) * $perpage;
  3155. }
  3156. //取得信息列表
  3157. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3158. //格式化数据
  3159. foreach ($info_list as $key => $value) {
  3160. $shop = $this->shop->read($value['shop']);
  3161. $info_list[$key]['shop'] = $shop['shopname'];
  3162. $warehouse = $this->warehouse->read($value['warehouse']);
  3163. $info_list[$key]['warehouse'] = $warehouse['title'];
  3164. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3165. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3166. if ($value['waybill'] == 0) {
  3167. $info_list[$key]['waybill'] = "";
  3168. }
  3169. $express = $this->express->read($value['express']);
  3170. $info_list[$key]['express'] = $express['title'];
  3171. $typeclass = $this->typeclass->read($value['state']);
  3172. $info_list[$key]['state'] = $typeclass['title'];
  3173. }
  3174. $total = $this->fullorder->find_count($where);
  3175. $pagenum = ceil($total / $perpage);
  3176. $over = $total - ($start + $perpage);
  3177. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3178. echo json_encode($rows);
  3179. exit;
  3180. }
  3181. $this->data['express'] = $this->express->find_all();
  3182. $this->_Template('whlabel_retreat', $this->data);
  3183. }
  3184. //退库标签浏览
  3185. public function _retreatlk()
  3186. {
  3187. $post = $this->input->post(NULL, TRUE);
  3188. if (isset($post['page'])) {
  3189. $page = $this->input->post('page', true);
  3190. $perpage = $this->input->post('perpage', true);
  3191. $timetk = $this->input->post('timetk', true);
  3192. $timetj = $this->input->post('timetj', true);
  3193. $sku = $this->input->post('sku', true);
  3194. $warehouse = $this->input->post('warehouse', true);
  3195. $purchase = $this->input->post('purchase', true);
  3196. $orderinfo = $this->input->post('orderinfo', true);
  3197. $waybill = $this->input->post('waybill', true);
  3198. $category = $this->input->post('category', true);
  3199. $size = $this->input->post('size', true);
  3200. $grade = $this->input->post('grade', true);
  3201. $color = $this->input->post('color', true);
  3202. $lowe = $this->input->post('lowe', true);
  3203. $state = $this->input->post('state', true);
  3204. $timetk = strtotime($timetk);
  3205. $timetj = strtotime($timetj);
  3206. $where = "state=2";
  3207. if ($timetk && $timetj) {
  3208. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3209. }
  3210. if ($sku) {
  3211. $where .= " and sku = '$sku'";
  3212. }
  3213. if ($warehouse) {
  3214. $where .= " and warehouse = '$warehouse'";
  3215. }
  3216. if ($purchase) {
  3217. $where .= " and purchase = '$purchase'";
  3218. }
  3219. if ($orderinfo) {
  3220. $where .= " and orderinfo = '$orderinfo'";
  3221. }
  3222. if ($waybill) {
  3223. $where .= " and waybill = '$waybill'";
  3224. }
  3225. if ($category) {
  3226. $where .= " and features like '%-$category-%'";
  3227. }
  3228. if ($size) {
  3229. $where .= " and features like '%-$size-%'";
  3230. }
  3231. if ($grade) {
  3232. $where .= " and features like '%-$grade-%'";
  3233. }
  3234. if ($color) {
  3235. $where .= " and features like '%-$color-%'";
  3236. }
  3237. if ($lowe) {
  3238. $where .= " and features like '%-$lowe-%'";
  3239. }
  3240. //数据排序
  3241. $order_str = "time desc";
  3242. if (empty($page)) {
  3243. $start = 0;
  3244. $perpage = 1;
  3245. } else {
  3246. $start = ($page - 1) * $perpage;
  3247. }
  3248. //取得信息列表
  3249. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3250. foreach ($info_list as $key => $value) {
  3251. $warehouse = $this->warehouse->read($value['warehouse']);
  3252. $info_list[$key]['warehouse'] = $warehouse['title'];
  3253. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3254. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3255. $purchase = $this->purchase->read($value['purchase']);
  3256. $info_list[$key]['purchase'] = $purchase['title'];
  3257. if ($value['outk'] != 0) {
  3258. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3259. } else {
  3260. $info_list[$key]['outk'] = "";
  3261. }
  3262. if ($value['retreat'] != 0) {
  3263. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3264. } else {
  3265. $info_list[$key]['retreat'] = "";
  3266. }
  3267. if ($value['orderinfo'] == 0) {
  3268. $info_list[$key]['orderinfo'] = "";
  3269. }
  3270. if ($value['waybill'] == 0) {
  3271. $info_list[$key]['waybill'] = "";
  3272. }
  3273. }
  3274. $total = $this->whlabel->find_count($where);
  3275. $pagenum = ceil($total / $perpage);
  3276. $over = $total - ($start + $perpage);
  3277. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3278. echo json_encode($rows);
  3279. exit;
  3280. }
  3281. $this->_Template('whlabel_retreatlk', $this->data);
  3282. }
  3283. //更换标签及浏览
  3284. public function _change()
  3285. {
  3286. $post = $this->input->post(NULL, TRUE);
  3287. if (isset($post['page'])) {
  3288. $page = $this->input->post('page', true);
  3289. $perpage = $this->input->post('perpage', true);
  3290. $timetk = $this->input->post('timetk', true);
  3291. $timetj = $this->input->post('timetj', true);
  3292. $label = $this->input->post('label', true);
  3293. $oldlabel = $this->input->post('oldlabel', true);
  3294. $timetk = strtotime($timetk);
  3295. $timetj = strtotime($timetj);
  3296. $where = "state=10 ";
  3297. if ($timetk && $timetj) {
  3298. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3299. }
  3300. if ($label) {
  3301. $where .= " and label = '$label'";
  3302. }
  3303. if ($oldlabel) {
  3304. $where .= " and oldlabel = '$oldlabel'";
  3305. }
  3306. //数据排序
  3307. $order_str = "time asc";
  3308. if (empty($page)) {
  3309. $start = 0;
  3310. $perpage = 1;
  3311. } else {
  3312. $start = ($page - 1) * $perpage;
  3313. }
  3314. //取得信息列表
  3315. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3316. foreach ($info_list as $key => $value) {
  3317. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3318. }
  3319. $total = $this->whlabel->find_count($where);
  3320. $pagenum = ceil($total / $perpage);
  3321. $over = $total - ($start + $perpage);
  3322. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3323. echo json_encode($rows);
  3324. exit;
  3325. }
  3326. $this->_Template('whlabel_change', $this->data);
  3327. }
  3328. //产品标签
  3329. public function _cpbqdc()
  3330. {
  3331. if (isset($_GET['excel'])) {
  3332. $where = "1=1";
  3333. //数据排序
  3334. $order_str = "id desc";
  3335. if (empty($page)) {
  3336. $start = 0;
  3337. $perpage = 1;
  3338. } else {
  3339. $start = ($page - 1) * $perpage;
  3340. }
  3341. $warehouse = $this->input->get('warehouse', true);
  3342. $state = $this->input->get('state', true);
  3343. $timetk = $this->input->get('timetkk', true);
  3344. $timetj = $this->input->get('timetjj', true);
  3345. $timetk = strtotime($timetk);
  3346. $timetj = strtotime($timetj);
  3347. if ($warehouse) {
  3348. $where .= " and warehouse = '$warehouse'";
  3349. }
  3350. if ($state || $state == 0) {
  3351. $where .= " and state = '$state'";
  3352. }
  3353. if ($timetk && $timetj) {
  3354. $where .= " and time > '$timetk' and time < '$timetj'";
  3355. }
  3356. //取得信息列表
  3357. $info_list = $this->whlabel->find_all($where, '*');
  3358. $rows = array();
  3359. $list = array();
  3360. foreach ($info_list as $key => $value) {
  3361. $rows[$value['time']] = $value; //所有数据sku
  3362. }
  3363. foreach ($rows as $value) {
  3364. $warehouse = $this->warehouse->read($value['warehouse']);
  3365. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3366. $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);
  3367. }
  3368. $title = "产品标签统计表";
  3369. $titlename = "<table border=1>
  3370. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3371. <tr align='center'>
  3372. <td>仓库</td>
  3373. <td>SKU</td>
  3374. <td>产品</td>
  3375. <td>入库时间</td>
  3376. <td>操作时间</td>
  3377. <td>备注</td>
  3378. <td>数量</td>
  3379. </tr>
  3380. </table>";
  3381. $filename = $title . ".xls";
  3382. $tail = "";
  3383. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3384. }
  3385. }
  3386. //进销存导出
  3387. public function _exceljxc()
  3388. {
  3389. $classid = $this->classid->sku();
  3390. $pm = $classid;
  3391. $typeclass = array();
  3392. $tc = $this->typeclass->find_all();
  3393. foreach ($tc as $v) {
  3394. $typeclass[$v['id']] = $v;
  3395. }
  3396. $prc = array();
  3397. $purchase = $this->purchase->find_all();
  3398. foreach ($purchase as $k => $v) {
  3399. $prc[$v['id']] = $v['title'];
  3400. }
  3401. if (isset($_GET['excel'])) {
  3402. $where = "sku != 'Preset'";
  3403. //数据排序
  3404. $order_str = "id desc";
  3405. if (empty($page)) {
  3406. $start = 0;
  3407. $perpage = 1;
  3408. } else {
  3409. $start = ($page - 1) * $perpage;
  3410. }
  3411. $category = $this->input->get('category', true);
  3412. $warehouse = $this->input->get('warehouse', true);
  3413. $excelid = $this->input->get('sid', true);
  3414. if ($category) {
  3415. $where .= " and features like '%-$category-%'";
  3416. }
  3417. if ($warehouse) {
  3418. $where .= " and warehouse = '$warehouse'";
  3419. }
  3420. $xzid = '';
  3421. if ($excelid) {
  3422. $excelid = explode(',', trim($excelid, ','));
  3423. foreach ($excelid as $key => $value) {
  3424. $xzid .= " id = " . $value . " or";
  3425. }
  3426. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3427. }
  3428. //取得信息列表
  3429. /**
  3430. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3431. $rows = array();$list = array();
  3432. foreach ($info_list as $key=>$value)
  3433. {
  3434. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3435. }
  3436. **/
  3437. $wt = array();
  3438. $whlabel_type = $this->whlabel_type->find_all();
  3439. foreach ($whlabel_type as $v) {
  3440. $wt[$v['id']] = $v['title'];
  3441. }
  3442. $wh = array();
  3443. $w = $this->warehouse->find_all('1=1', 'id,title');
  3444. foreach ($w as $v) {
  3445. $wh[$v['id']] = $v['title'];
  3446. }
  3447. $list = array();
  3448. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3449. foreach ($rows as $key => $value) {
  3450. if (isset($wt[$value['type']])) {
  3451. $rows[$key]['type'] = $wt[$value['type']];
  3452. } else {
  3453. $rows[$key]['type'] = '未设置';
  3454. }
  3455. $bm = '03';
  3456. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3457. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3458. $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');
  3459. $details = array();
  3460. $cpid = array();
  3461. $cpbz = array();
  3462. $c = 0;
  3463. $g = 0;
  3464. $x = 0;
  3465. $t = 0;
  3466. $s = 0;
  3467. $q = 0;
  3468. foreach ($sd as $k => $v) {
  3469. if ($v['state'] == 0) {
  3470. $c++;
  3471. if ($v['cpid'] != 0) {
  3472. $cpid[$v['cpid']] = $v['cpid'];
  3473. }
  3474. if ($v['cpbz'] != '') {
  3475. $cpbz[$v['cpbz']] = $v['cpbz'];
  3476. }
  3477. }
  3478. if ($v['state'] != 9) {
  3479. $g++;
  3480. }
  3481. if ($v['state'] == 1) {
  3482. $x++;
  3483. }
  3484. if ($v['state'] == 2) {
  3485. $t++;
  3486. }
  3487. if ($v['state'] == 8) {
  3488. $s++;
  3489. }
  3490. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3491. $q++;
  3492. }
  3493. $details[$v['details']] = $v['details'];
  3494. }
  3495. $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'] . '"');
  3496. $rows[$key]['details'] = implode("、", $details);
  3497. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3498. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3499. $number = $value['number'];
  3500. $ftime = time() - 15 * 24 * 3600;
  3501. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3502. $rows[$key]['number'] = $g;
  3503. $rows[$key]['c'] = $c;
  3504. $rows[$key]['x'] = $x;
  3505. $rows[$key]['t'] = $t;
  3506. $rows[$key]['s'] = $s;
  3507. $rows[$key]['q'] = $q;
  3508. $rows[$key]['z'] = $z;
  3509. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3510. $features = explode('-', trim($features, '-'));
  3511. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3512. // $pm = $classid;
  3513. // $jm = $classid;
  3514. // foreach($features as $k=>$v)
  3515. // {
  3516. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3517. // {
  3518. // if($typeclass[$v]['bm'] != '')
  3519. // {
  3520. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3521. // }
  3522. // }
  3523. // if($v != 0)
  3524. // {
  3525. // if(!isset($typeclass[$v]))
  3526. // {
  3527. // continue;
  3528. // }
  3529. // if(isset($pm[$typeclass[$v]['classid']]))
  3530. // {
  3531. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3532. // {
  3533. // $tz = explode('|',$typeclass[$v]['zh']);
  3534. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3535. // }
  3536. // else
  3537. // {
  3538. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3539. // }
  3540. // }
  3541. // if(isset($jm[$typeclass[$v]['classid']]))
  3542. // {
  3543. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3544. // }
  3545. // }
  3546. // }
  3547. // $jm = array_filter($jm);
  3548. // $rows[$key]['bs'] = implode("-",$jm);
  3549. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3550. // $zh = implode(" ",$pm);
  3551. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3552. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3553. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3554. // $rows[$key]['features'] = $zh;
  3555. }
  3556. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3557. $final_list = [];
  3558. foreach ($list as $k => $v) {
  3559. if (empty($v['sku'])) {
  3560. continue;
  3561. }
  3562. $final_list[] = [
  3563. "warehouse" => $v["warehouse"],
  3564. "purchase" => $v["purchase"],
  3565. "details" => $v["details"],
  3566. "cpid" => $v["cpid"],
  3567. "dbcontent" => $v["dbcontent"],
  3568. "sku" => $v["sku"],
  3569. "cs" => $v["bm"],
  3570. "bs" => $v["jm"],
  3571. "title" => $v["title"],
  3572. "features" => $v["pm"],
  3573. "cpbz" => $v["cpbz"],
  3574. "sm" => $v["sm"],
  3575. "type" => $v["type"],
  3576. "number" => $v["number"],
  3577. "c" => $v["c"],
  3578. "x" => $v["x"],
  3579. "t" => $v["t"],
  3580. "s" => $v["s"],
  3581. "q" => $v["q"],
  3582. "z" => $v["z"],
  3583. "weight" => $v['weight'],
  3584. ];
  3585. }
  3586. $title = "总进销存统计表";
  3587. $titlename = "<table border=1>
  3588. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3589. <tr align='center'>
  3590. <td>仓库</td>
  3591. <td>供应商</td>
  3592. <td>位置</td>
  3593. <td>库存编码</td>
  3594. <td>类目</td>
  3595. <td>SKU</td>
  3596. <td>用友编码</td>
  3597. <td>用友料号</td>
  3598. <td>商品名称</td>
  3599. <td>商品中文</td>
  3600. <td>产品备注</td>
  3601. <td>库位负责人</td>
  3602. <td>类型</td>
  3603. <td>入库总量</td>
  3604. <td>库存数量</td>
  3605. <td>销售数量</td>
  3606. <td>退货数量</td>
  3607. <td>删除数量</td>
  3608. <td>其它操作</td>
  3609. <td>占单数量</td>
  3610. <td>重量(g)</td>
  3611. </tr>
  3612. </table>";
  3613. $filename = $title . ".xls";
  3614. $tail = "";
  3615. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3616. }
  3617. }
  3618. //入库导出
  3619. public function _excelr()
  3620. {
  3621. if (isset($_GET['excel'])) {
  3622. $category = $this->input->get('category', true);
  3623. $size = $this->input->get('size', true);
  3624. $grade = $this->input->get('grade', true);
  3625. $color = $this->input->get('color', true);
  3626. $lowe = $this->input->get('lowe', true);
  3627. $sku = $this->input->get('sku', true);
  3628. $warehouse = $this->input->get('warehouse', true);
  3629. $purchase = $this->input->get('purchase', true);
  3630. $ktime = $this->input->get('ktime', true);
  3631. $jtime = $this->input->get('jtime', true);
  3632. $ktime = strtotime($ktime);
  3633. $jtime = strtotime($jtime);
  3634. $where = "1=1";
  3635. $gj = "";
  3636. $ck = "";
  3637. if ($category) {
  3638. $where .= " and features like '%-$category-%'";
  3639. }
  3640. if ($size) {
  3641. $where .= " and features like '%-$size-%'";
  3642. }
  3643. if ($grade) {
  3644. $where .= " and features like '%-$grade-%'";
  3645. }
  3646. if ($color) {
  3647. $where .= " and features like '%-$color-%'";
  3648. }
  3649. if ($lowe) {
  3650. $where .= " and features like '%-$lowe-%'";
  3651. }
  3652. if ($warehouse) {
  3653. $where .= " and warehouse = '$warehouse'";
  3654. }
  3655. if ($purchase) {
  3656. $where .= " and purchase = '$purchase'";
  3657. }
  3658. if ($sku) {
  3659. $where .= " and sku = '$sku'";
  3660. }
  3661. if ($ktime && $jtime) {
  3662. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3663. }
  3664. //数据排序
  3665. $order_str = "id desc";
  3666. if (empty($page)) {
  3667. $start = 0;
  3668. $perpage = 1;
  3669. } else {
  3670. $start = ($page - 1) * $perpage;
  3671. }
  3672. $list = array();
  3673. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3674. foreach ($rows as $value) {
  3675. $ck = $this->warehouse->read($value['warehouse']);
  3676. $warehouse = $ck['title'];
  3677. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3678. $retreatwarehouse = $tkck['title'];
  3679. $gy = $this->purchase->read($value['purchase']);
  3680. $purchase = $gy['title'];
  3681. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3682. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3683. }
  3684. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3685. $titlename = "<table border=1>
  3686. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3687. <tr align='center'>
  3688. <td>仓库</td>
  3689. <td>SKU</td>
  3690. <td>产品</td>
  3691. <td>时间</td>
  3692. <td>数量</td>
  3693. </tr>
  3694. </table>";
  3695. $filename = $title . ".xls";
  3696. $tail = "";
  3697. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  3698. }
  3699. }
  3700. //出库、退库导出
  3701. public function _excelct()
  3702. {
  3703. $classid = $this->classid->sku();
  3704. $pm = $classid;
  3705. $typeclass = array();
  3706. $tc = $this->typeclass->find_all();
  3707. foreach ($tc as $v) {
  3708. $typeclass[$v['id']] = $v;
  3709. }
  3710. $prc = array();
  3711. $purchase = $this->purchase->find_all();
  3712. foreach ($purchase as $k => $v) {
  3713. $prc[$v['id']] = $v['title'];
  3714. }
  3715. if (isset($_GET['excel'])) {
  3716. $wh = array();
  3717. $w = $this->warehouse->find_all('1=1', 'id,title');
  3718. foreach ($w as $v) {
  3719. $wh[$v['id']] = $v['title'];
  3720. }
  3721. $type = $this->input->get('excel', true);
  3722. $category = $this->input->get('category', true);
  3723. $size = $this->input->get('size', true);
  3724. $grade = $this->input->get('grade', true);
  3725. $color = $this->input->get('color', true);
  3726. $lowe = $this->input->get('lowe', true);
  3727. $sku = $this->input->get('sku', true);
  3728. $title = $this->input->get('title', true);
  3729. $warehouse = $this->input->get('warehouse', true);
  3730. $purchase = $this->input->get('purchase', true);
  3731. $lacetype = $this->input->get('lacetype', true);
  3732. $haircap = $this->input->get('haircap', true);
  3733. $lacecolor = $this->input->get('lacecolor', true);
  3734. $density = $this->input->get('density', true);
  3735. $details = $this->input->get('details', true);
  3736. $state = $this->input->get('state', true);
  3737. $shop = $this->input->get('shop', true);
  3738. $hairnumber = $this->input->get('hairnumber', true);
  3739. $type_leixi = $this->input->get('type', true);
  3740. $cpbz = $this->input->get('cpbz', true);
  3741. $sm = $this->input->get('sm', true);
  3742. $sid = $this->input->get('sid', true);
  3743. $ktime = $this->input->get('ktime', true);
  3744. $jtime = $this->input->get('jtime', true);
  3745. $ktime = strtotime($ktime);
  3746. $jtime = strtotime($jtime);
  3747. //$where = " 1=1 ";
  3748. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3749. $where = " sku != '' ";
  3750. $gj = "";
  3751. $ck = "";
  3752. if ($category) {
  3753. $where .= " and features like '%-$category-%'";
  3754. }
  3755. if ($size) {
  3756. $where .= " and features like '%-$size-%'";
  3757. }
  3758. if ($grade) {
  3759. $where .= " and features like '%-$grade-%'";
  3760. }
  3761. if ($color) {
  3762. $where .= " and features like '%-$color-%'";
  3763. }
  3764. if ($lowe) {
  3765. $where .= " and features like '%-$lowe-%'";
  3766. }
  3767. if ($warehouse) {
  3768. $where .= " and warehouse = '$warehouse'";
  3769. }
  3770. if ($purchase) {
  3771. $where .= " and purchase = '$purchase'";
  3772. }
  3773. if ($state) {
  3774. $where .= " and state = '$state'";
  3775. }
  3776. if ($lacetype) {
  3777. $where .= " and features like '%-$lacetype-%'";
  3778. }
  3779. if ($lacecolor) {
  3780. $where .= " and features like '%-$lacecolor-%'";
  3781. }
  3782. if ($density) {
  3783. $where .= " and features like '%-$density-%'";
  3784. }
  3785. if ($haircap) {
  3786. $where .= " and features like '%-$haircap-%'";
  3787. }
  3788. if ($details) {
  3789. $where .= " and details = '$details'";
  3790. }
  3791. if ($shop) {
  3792. $where .= " and shop like '%$shop%'";
  3793. }
  3794. if ($title) {
  3795. $title = trim($title, ' ');
  3796. $title = trim($title, ' ');
  3797. $where .= " and title like '%$title%'";
  3798. }
  3799. if (!empty($hairnumber)) {
  3800. $where .= " and features like '%-128-%' ";
  3801. if ($hairnumber < 0) {
  3802. $class_list = $this->typeclass->find_all('classid = 43');
  3803. foreach ($class_list as $v) {
  3804. $where .= " and features not like '%-" . $v['id'] . "-%'";
  3805. }
  3806. } else {
  3807. $where .= " and features like '%-$hairnumber-%'";
  3808. }
  3809. }
  3810. if ($type_leixi) {
  3811. $where .= " and type = '$type_leixi'";
  3812. }
  3813. if ($cpbz) {
  3814. $where .= " and cpbz like '%$cpbz%' ";
  3815. }
  3816. if ($sm) {
  3817. $where .= " and sm like '%$sm%' ";
  3818. }
  3819. if ($sku) {
  3820. $sku = trim($sku, ' ');
  3821. $sku = trim($sku, ' ');
  3822. $where .= " and sku like '%$sku%'";
  3823. }
  3824. if ($ktime && $jtime) {
  3825. if ($type == 1) {
  3826. $tl = '出库';
  3827. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3828. } else if ($type == 2) {
  3829. $tl = '退库';
  3830. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3831. } else if ($type == 3) {
  3832. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3833. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3834. } else if ($type == 4) {
  3835. $tl = '出库+零售';
  3836. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3837. } else if ($type == 5) {
  3838. $tl = '零售';
  3839. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3840. }
  3841. }
  3842. $sidwhere = '';
  3843. if ($sid) {
  3844. $sd = "";
  3845. $s = explode(',', trim($sid, ','));
  3846. foreach ($s as $value) {
  3847. $sd .= " id = " . $value . " or";
  3848. }
  3849. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3850. }
  3851. //数据排序
  3852. $order_str = "time desc";
  3853. if (empty($page)) {
  3854. $start = 0;
  3855. $perpage = 1;
  3856. } else {
  3857. $start = ($page - 1) * $perpage;
  3858. }
  3859. //取得信息列表
  3860. if ($type != 3 && $type != 5) {
  3861. if ($type == 1 || $type == 4) {
  3862. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3863. foreach ($info_list as $key => $value) {
  3864. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3865. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3866. $warehouse = $this->warehouse->read($value['warehouse']);
  3867. $info_list[$key]['warehouse'] = $warehouse['title'];
  3868. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3869. $features = explode('-', trim($features, '-'));
  3870. $pm = $classid;
  3871. foreach ($features as $k => $v) {
  3872. if ($v != 0) {
  3873. if (!isset($typeclass[$v])) {
  3874. continue;
  3875. }
  3876. if (isset($pm[$typeclass[$v]['classid']])) {
  3877. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3878. $tz = explode('|', $typeclass[$v]['zh']);
  3879. $pm[$typeclass[$v]['classid']] = $tz[0];
  3880. } else {
  3881. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3882. }
  3883. }
  3884. }
  3885. }
  3886. $zh = implode(" ", $pm);
  3887. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3888. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3889. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3890. $info_list[$key]['features'] = $zh;
  3891. }
  3892. $final_list = [];
  3893. foreach($info_list as $k=>$v){
  3894. $number = "";
  3895. if(!empty($v['orderinfo'])){
  3896. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3897. if(!empty($tmp_info['number'])){
  3898. $number = $tmp_info['number'];
  3899. }
  3900. }
  3901. $final_list[] = [
  3902. 'warehouse'=>$v['warehouse'],
  3903. 'purchase'=>$v['purchase'],
  3904. 'sku'=>$v['sku'],
  3905. 'title'=>$v['title'],
  3906. 'features'=>$v['features'],
  3907. 'label'=>$v['label'],
  3908. 'orderinfo'=>$v['orderinfo'],
  3909. 'number'=>$number,
  3910. 'waybill'=>$v['waybill'],
  3911. 'outk'=>$v['outk'],
  3912. ];
  3913. }
  3914. } else {
  3915. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3916. foreach ($info_list as $key => $value) {
  3917. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3918. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3919. $warehouse = $this->warehouse->read($value['warehouse']);
  3920. $info_list[$key]['warehouse'] = $warehouse['title'];
  3921. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3922. $features = explode('-', trim($features, '-'));
  3923. $pm = $classid;
  3924. foreach ($features as $k => $v) {
  3925. if ($v != 0) {
  3926. if (!isset($typeclass[$v])) {
  3927. continue;
  3928. }
  3929. if (isset($pm[$typeclass[$v]['classid']])) {
  3930. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3931. $tz = explode('|', $typeclass[$v]['zh']);
  3932. $pm[$typeclass[$v]['classid']] = $tz[0];
  3933. } else {
  3934. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3935. }
  3936. }
  3937. }
  3938. }
  3939. $zh = implode(" ", $pm);
  3940. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3941. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3942. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3943. $info_list[$key]['features'] = $zh;
  3944. }
  3945. $final_list = [];
  3946. foreach($info_list as $k=>$v){
  3947. $number = "";
  3948. if(!empty($v['orderinfo'])){
  3949. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3950. if(!empty($tmp_info['number'])){
  3951. $number = $tmp_info['number'];
  3952. }
  3953. }
  3954. $final_list[] = [
  3955. 'warehouse'=>$v['warehouse'],
  3956. 'purchase'=>$v['purchase'],
  3957. 'sku'=>$v['sku'],
  3958. 'title'=>$v['title'],
  3959. 'features'=>$v['features'],
  3960. 'label'=>$v['label'],
  3961. 'orderinfo'=>$v['orderinfo'],
  3962. 'number'=>$number,
  3963. 'waybill'=>$v['waybill'],
  3964. 'retreat'=>$v['retreat'],
  3965. ];
  3966. }
  3967. }
  3968. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3969. $titlename = "<table border=1>
  3970. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3971. <tr align='center'>
  3972. <td>仓库</td>
  3973. <td>供应商</td>
  3974. <td>SKU</td>
  3975. <td>商品名称</td>
  3976. <td>商品中文</td>
  3977. <td>标签</td>
  3978. <td>订单号</td>
  3979. <td>订单编码</td>
  3980. <td>运单号</td>
  3981. <td>" . $tl . "时间(中国时间)</td>
  3982. </tr>
  3983. </table>";
  3984. $filename = $title . ".xls";
  3985. $tail = "";
  3986. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3987. } else if ($type == 5) {
  3988. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3989. foreach ($info_list as $key => $value) {
  3990. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3991. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3992. $warehouse = $this->warehouse->read($value['warehouse']);
  3993. $info_list[$key]['warehouse'] = $warehouse['title'];
  3994. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3995. $features = explode('-', trim($features, '-'));
  3996. $pm = $classid;
  3997. foreach ($features as $k => $v) {
  3998. if ($v != 0) {
  3999. if (!isset($typeclass[$v])) {
  4000. continue;
  4001. }
  4002. if (isset($pm[$typeclass[$v]['classid']])) {
  4003. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4004. $tz = explode('|', $typeclass[$v]['zh']);
  4005. $pm[$typeclass[$v]['classid']] = $tz[0];
  4006. } else {
  4007. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4008. }
  4009. }
  4010. }
  4011. }
  4012. $zh = implode(" ", $pm);
  4013. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4014. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4015. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4016. $info_list[$key]['features'] = $zh;
  4017. }
  4018. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4019. $titlename = "<table border=1>
  4020. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4021. <tr align='center'>
  4022. <td>仓库</td>
  4023. <td>供应商</td>
  4024. <td>SKU</td>
  4025. <td>商品名称</td>
  4026. <td>商品中文</td>
  4027. <td>标签</td>
  4028. <td>" . $tl . "时间(中国时间)</td>
  4029. </tr>
  4030. </table>";
  4031. $filename = $title . ".xls";
  4032. $tail = "";
  4033. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4034. } else {
  4035. /**
  4036. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4037. $rows = array();$list = array();
  4038. foreach ($info_list as $key=>$value)
  4039. {
  4040. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4041. }
  4042. **/
  4043. $wh = array();
  4044. $w = $this->warehouse->find_all('1=1', 'id,title');
  4045. foreach ($w as $v) {
  4046. $wh[$v['id']] = $v['title'];
  4047. }
  4048. $wt = array();
  4049. $whlabel_type = $this->whlabel_type->find_all();
  4050. foreach ($whlabel_type as $v) {
  4051. $wt[$v['id']] = $v['title'];
  4052. }
  4053. $classid = $this->classid->sku();
  4054. $list = array();
  4055. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4056. foreach ($rows as $key => $value) {
  4057. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4058. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4059. $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');
  4060. $details = array();
  4061. $cpid = array();
  4062. $cpbz = array();
  4063. $c = 0;
  4064. $g = 0;
  4065. $x = 0;
  4066. $t = 0;
  4067. $s = 0;
  4068. $q = 0;
  4069. foreach ($sd as $k => $v) {
  4070. if ($v['state'] == 0) {
  4071. $c++;
  4072. }
  4073. if ($v['state'] != 9) {
  4074. $g++;
  4075. }
  4076. if ($v['outk'] > 1) {
  4077. $x++;
  4078. }
  4079. if ($v['retreat'] > 0) {
  4080. $t++;
  4081. }
  4082. if ($v['state'] == 8) {
  4083. $s++;
  4084. }
  4085. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4086. $q++;
  4087. }
  4088. $details[$v['details']] = $v['details'];
  4089. if ($v['cpid'] != 0) {
  4090. $cpid[$v['cpid']] = $v['cpid'];
  4091. }
  4092. if ($v['cpbz'] != '') {
  4093. $cpbz[$v['cpbz']] = $v['cpbz'];
  4094. }
  4095. }
  4096. if (isset($wt[$value['type']])) {
  4097. $rows[$key]['type'] = $wt[$value['type']];
  4098. } else {
  4099. $rows[$key]['type'] = '未设置';
  4100. }
  4101. $rows[$key]['details'] = implode("、", $details);
  4102. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4103. $ftime = time() - 15 * 24 * 3600;
  4104. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4105. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4106. $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);
  4107. $rows[$key]['c'] = $c;
  4108. $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);
  4109. $rows[$key]['t'] = $t;
  4110. $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'] . '"');
  4111. $rows[$key]['z'] = $z;
  4112. // $jm = $classid;
  4113. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4114. $features = explode('-', trim($features, '-'));
  4115. // $pm = $classid;
  4116. // foreach ($features as $k => $v) {
  4117. // if ($v != 0) {
  4118. // if (!isset($typeclass[$v])) {
  4119. // continue;
  4120. // }
  4121. // if (isset($pm[$typeclass[$v]['classid']])) {
  4122. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4123. // $tz = explode('|', $typeclass[$v]['zh']);
  4124. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4125. // } else {
  4126. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4127. // }
  4128. // if (isset($jm[$typeclass[$v]['classid']])) {
  4129. // if ($typeclass[$v]['jm']) {
  4130. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4131. // }
  4132. // }
  4133. // }
  4134. // }
  4135. // }
  4136. // $zh = implode(" ", $pm);
  4137. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4138. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4139. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4140. // $rows[$key]['features'] = $zh;
  4141. // $jm = array_filter($jm); //去除空值
  4142. // $jm = implode("-", $jm);
  4143. // $rows[$key]['jm'] = $jm;
  4144. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4145. }
  4146. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4147. // echo "<pre>";
  4148. // print_r($tmp_list);
  4149. // die;
  4150. $final_list =[];
  4151. foreach($tmp_list as $k=>$v){
  4152. $final_list[] = [
  4153. "warehouse"=>$v['warehouse'],
  4154. "purchase"=>$v['purchase'],
  4155. "details"=>trim($v['details'],'、'),
  4156. "cpid"=>$v['cpid'],
  4157. "sku"=>$v['sku'],
  4158. "title"=>$v['title'],
  4159. "features"=>$v['pm'],
  4160. "cpbz"=>$v['cpbz'],
  4161. "sm"=>$v['sm'],
  4162. "type"=>$v['type'],
  4163. "g"=>$v["g"],
  4164. "c"=>$v["c"],
  4165. "x"=>$v["x"],
  4166. "t"=>$v["t"],
  4167. "z"=>$v["z"],
  4168. "jm"=>$v["jm"],
  4169. "weight"=>$v["weight"],
  4170. "asd"=>$v["asd"],
  4171. ];
  4172. }
  4173. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4174. $titlename = "<table border=1>
  4175. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4176. <tr align='center'>
  4177. <td>仓库</td>
  4178. <td>供应商</td>
  4179. <td>位置</td>
  4180. <td>库存编码</td>
  4181. <td>SKU</td>
  4182. <td>商品名称</td>
  4183. <td>商品中文</td>
  4184. <td>产品备注</td>
  4185. <td>说明</td>
  4186. <td>类型</td>
  4187. <td>入库总量</td>
  4188. <td>库存数量</td>
  4189. <td>销售数量</td>
  4190. <td>退货数量</td>
  4191. <td>占单数量</td>
  4192. <td>料号</td>
  4193. <td>重量</td>
  4194. <td>类目</td>
  4195. </tr>
  4196. </table>";
  4197. $filename = $title . ".xls";
  4198. $tail = "";
  4199. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4200. }
  4201. }
  4202. }
  4203. //出库+入库数据整合
  4204. public function _excelcr()
  4205. {
  4206. if (isset($_GET['excel'])) {
  4207. $type = $this->input->get('excel', true);
  4208. $category = $this->input->get('category', true);
  4209. $size = $this->input->get('size', true);
  4210. $grade = $this->input->get('grade', true);
  4211. $color = $this->input->get('color', true);
  4212. $lowe = $this->input->get('lowe', true);
  4213. $sku = $this->input->get('sku', true);
  4214. $warehouse = $this->input->get('warehouse', true);
  4215. $purchase = $this->input->get('purchase', true);
  4216. $state = $this->input->get('state', true);
  4217. $sid = $this->input->get('sid', true);
  4218. $ktime = $this->input->get('ktime', true);
  4219. $jtime = $this->input->get('jtime', true);
  4220. $ktime = strtotime($ktime);
  4221. $jtime = strtotime($jtime);
  4222. $where = "1=1";
  4223. $gj = "";
  4224. $ck = "";
  4225. if ($category) {
  4226. $where .= " and features like '%-$category-%'";
  4227. }
  4228. if ($size) {
  4229. $where .= " and features like '%-$size-%'";
  4230. }
  4231. if ($grade) {
  4232. $where .= " and features like '%-$grade-%'";
  4233. }
  4234. if ($color) {
  4235. $where .= " and features like '%-$color-%'";
  4236. }
  4237. if ($lowe) {
  4238. $where .= " and features like '%-$lowe-%'";
  4239. }
  4240. if ($warehouse) {
  4241. $where .= " and warehouse = '$warehouse'";
  4242. }
  4243. if ($purchase) {
  4244. $where .= " and purchase = '$purchase'";
  4245. }
  4246. if ($state) {
  4247. $where .= " and state = '$state'";
  4248. }
  4249. if ($sku) {
  4250. $where .= " and sku like '%$sku%'";
  4251. }
  4252. if ($ktime && $jtime) {
  4253. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4254. }
  4255. $sidwhere = '';
  4256. if ($sid) {
  4257. $sd = "";
  4258. $s = explode(',', trim($sid, ','));
  4259. foreach ($s as $value) {
  4260. $sd .= " id = " . $value . " or";
  4261. }
  4262. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4263. }
  4264. //取得信息列表
  4265. $timeread = $ktime;
  4266. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4267. $timelist = array();
  4268. for ($i = 0; $i < $timenum; $i++) {
  4269. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4270. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4271. }
  4272. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4273. //echo "<pre>";
  4274. //print_r($info_list);
  4275. //exit();
  4276. $rows = array();
  4277. $list = array();
  4278. foreach ($info_list as $key => $value) {
  4279. $thistime = $timelist;
  4280. if (isset($rows[strtolower($value['sku'])])) {
  4281. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4282. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4283. }
  4284. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4285. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4286. }
  4287. } else {
  4288. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4289. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4290. }
  4291. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4292. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4293. }
  4294. $rows[strtolower($value['sku'])] = $thistime;
  4295. }
  4296. }
  4297. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4298. <head>
  4299. <!--[if gte mso 9]><xml>
  4300. <x:ExcelWorkbook>
  4301. <x:ExcelWorksheets>
  4302. <x:ExcelWorksheet>
  4303. <x:Name>EXCEL</x:Name>
  4304. <x:WorksheetOptions>
  4305. <x:Print>
  4306. <x:ValidPrinterInfo />
  4307. </x:Print>
  4308. </x:WorksheetOptions>
  4309. </x:ExcelWorksheet>
  4310. </x:ExcelWorksheets>
  4311. </x:ExcelWorkbook>
  4312. </xml>
  4313. <![endif]-->
  4314. </head><body>";
  4315. $str .= "<table border=1><tr><td>SKU</td>";
  4316. foreach ($timelist as $k => $v) {
  4317. $str .= "<td>" . $k . "出库</td>";
  4318. $str .= "<td>" . $k . "入库</td>";
  4319. }
  4320. $str .= "</tr></table>";
  4321. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4322. foreach ($rows as $key => $val) {
  4323. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4324. foreach ($val as $k => $v) {
  4325. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4326. if ($val[$k]['r'] > 0) {
  4327. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4328. } else {
  4329. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4330. }
  4331. }
  4332. $str .= "</tr>";
  4333. }
  4334. $str .= "</table>";
  4335. $str .= "</body></html>";
  4336. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4337. header("Content-type: application/octet-stream");
  4338. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4339. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4340. header("Pragma: no-cache");
  4341. header("Expires: 0");
  4342. exit($str);
  4343. }
  4344. }
  4345. //数量调整模板导出
  4346. public function _presetout()
  4347. {
  4348. if (isset($_GET['excel'])) {
  4349. $where = "sku != 'Preset' and purchase != 0";
  4350. //数据排序
  4351. $order_str = "id desc";
  4352. if (empty($page)) {
  4353. $start = 0;
  4354. $perpage = 1;
  4355. } else {
  4356. $start = ($page - 1) * $perpage;
  4357. }
  4358. //取得信息列表
  4359. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4360. $rows = array();
  4361. $list = array();
  4362. foreach ($info_list as $value) {
  4363. $warehouse = $this->warehouse->read($value['warehouse']);
  4364. $number = $value['number'];
  4365. $ftime = time() - 15 * 24 * 3600;
  4366. $purchase = $this->purchase->read($value['purchase']);
  4367. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4368. }
  4369. $title = "库存模板";
  4370. $titlename = "<table border=1>
  4371. <tr align='center'>
  4372. <td>仓库</td>
  4373. <td>供应商编码</td>
  4374. <td>SKU</td>
  4375. <td>增减数量(正数或负数)</td>
  4376. <td>增减备注</td>
  4377. <td>扣减方式:0减少库存1删除库存</td>
  4378. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4379. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4380. </tr>
  4381. </table>";
  4382. $filename = $title . ".xls";
  4383. $tail = "";
  4384. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4385. }
  4386. }
  4387. //数量调整模板导入
  4388. public function _presetedit()
  4389. {
  4390. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4391. $config['upload_path'] = '.' . $dir;
  4392. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4393. $config['allowed_types'] = 'xls|xlsx|csv';
  4394. $config['max_size'] = 10240;
  4395. $this->load->library('upload', $config);
  4396. $this->upload->initialize($config);
  4397. if ($this->upload->do_upload('userfile')) {
  4398. $full_path = $dir . $this->upload->data('file_name');
  4399. $fileName = '.' . $full_path;
  4400. if (!file_exists($fileName)) {
  4401. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4402. exit;
  4403. } else {
  4404. require_once "./data/excel/PHPExcel/IOFactory.php";
  4405. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4406. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4407. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4408. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4409. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4410. ++$column; //如果列数大于26行
  4411. $list = array();
  4412. for ($i = 2; $i <= $row; $i++) // 行数循环
  4413. {
  4414. $data = array();
  4415. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4416. {
  4417. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4418. }
  4419. $list[] = $data;
  4420. }
  4421. }
  4422. $i = 0;
  4423. $j = 0;
  4424. $ed = array();
  4425. foreach ($list as $key => $value) {
  4426. $time = time();
  4427. if ($value['0'] == "") {
  4428. continue;
  4429. }
  4430. $warehouse = $this->warehouse->get_title($value['0']);
  4431. $purchase = $this->purchase->get_bm($value['1']);
  4432. $sku = $value['2'];
  4433. $num = $value['3']; //调整数量
  4434. $text = $value['4']; //扣减说明
  4435. $type = $value['5']; //调整方式0扣减1删除
  4436. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4437. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4438. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4439. if (!$purchase) //如果没有这个SKU
  4440. {
  4441. $ed[] = array($purchase . '-不存在此供应商编码');
  4442. $j++;
  4443. continue;
  4444. }
  4445. if (!$d) //如果没有这个SKU
  4446. {
  4447. $ed[] = array($sku . '-库存中不存在此SKU');
  4448. $j++;
  4449. continue;
  4450. }
  4451. if (!isset($warehouse['id'])) {
  4452. $ed[] = array($sku . '-仓库名错误!');
  4453. $j++;
  4454. continue;
  4455. }
  4456. if ($type != '0' && $type != '1') {
  4457. $ed[] = array($sku . '-扣减方式填写错误!');
  4458. $j++;
  4459. continue;
  4460. }
  4461. if ($num < 0) //扣减库存
  4462. {
  4463. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4464. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4465. $j++;
  4466. continue;
  4467. }
  4468. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4469. if (count($data) < abs($num)) {
  4470. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4471. $j++;
  4472. continue;
  4473. }
  4474. if ($type == 0) //如果扣减方式为 扣减库存
  4475. {
  4476. for ($i = 0; $i < abs($num); $i++) {
  4477. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4478. }
  4479. } else if ($type == 1) {
  4480. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4481. if (count($zt) > 0) {
  4482. $ed[] = array($sku . '-有在途库存无法删除!');
  4483. $j++;
  4484. continue;
  4485. }
  4486. for ($i = 0; $i < abs($num); $i++) {
  4487. $this->whlabel->remove($data[$i]['id']);
  4488. }
  4489. }
  4490. } else if ($num > 0) //增加库存
  4491. {
  4492. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4493. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4494. $j++;
  4495. continue;
  4496. }
  4497. $post['sku'] = $d['sku'];
  4498. $post['shop'] = $d['shop'];
  4499. $post['warehouse'] = $warehouse['id'];
  4500. $post['purchase'] = $purchase['id'];
  4501. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4502. $post['state'] = 0;
  4503. $post['title'] = $d['title'];
  4504. $post['number'] = $d['number'];
  4505. $post['features'] = $d['features'];
  4506. $post['enter'] = $time;
  4507. $post['time'] = $time; //操作时间
  4508. $post['rktype'] = $rktype;
  4509. for ($i = 0; $i < $num; $i++) {
  4510. $post['label'] = time() . rand(100, 999) . $i;
  4511. $this->whlabel->insert($post);
  4512. }
  4513. }
  4514. sleep(1); //防止入库时间一样,需要延迟1秒
  4515. }
  4516. if ($j > 0) {
  4517. $tt = date('Ymd', time());
  4518. $title = '库存导入错误信息-' . $tt;
  4519. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4520. $tail = "\n";
  4521. $filename = $title . ".xls";
  4522. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4523. $dir = '/data/excel/' . $time . '/';
  4524. $file_name = 'error_' . $time . rand(1000, 9999);
  4525. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4526. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4527. fwrite($myfile, $ecl);
  4528. fclose($myfile);
  4529. $error = $dir . $file_name . '.xls';
  4530. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4531. exit;
  4532. } else {
  4533. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4534. exit;
  4535. }
  4536. }
  4537. }
  4538. public function _presetedittwo(){
  4539. $data = $this->input->post(NULL, TRUE);
  4540. if(empty($list)){
  4541. $raw_data = $this->input->raw_input_stream;
  4542. // 解码 JSON
  4543. $data = json_decode($raw_data, true);
  4544. }
  4545. if(empty($data)){
  4546. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4547. }
  4548. $list = [];
  4549. if(isset($data['list'])){
  4550. $list = $data['list'];
  4551. }
  4552. $i = 0;
  4553. $j = 0;
  4554. $ed = array();
  4555. foreach ($list as $key => $value) {
  4556. $time = time();
  4557. if ($value['0'] == "") {
  4558. continue;
  4559. }
  4560. $warehouse = $this->warehouse->get_title($value['0']);
  4561. $purchase = $this->purchase->get_bm($value['1']);
  4562. $sku = $value['2'];
  4563. $num = $value['3']; //调整数量
  4564. $text = $value['4']; //扣减说明
  4565. $type = $value['5']; //调整方式0扣减1删除
  4566. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4567. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4568. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4569. if (!$purchase) //如果没有这个SKU
  4570. {
  4571. $ed[] = array($value['1'] . '-不存在此供应商编码');
  4572. $j++;
  4573. continue;
  4574. }
  4575. if (!$d) //如果没有这个SKU
  4576. {
  4577. $ed[] = array($sku . '-库存中不存在此SKU');
  4578. $j++;
  4579. continue;
  4580. }
  4581. if (!isset($warehouse['id'])) {
  4582. $ed[] = array($sku . '-仓库名错误!');
  4583. $j++;
  4584. continue;
  4585. }
  4586. if ($type != '0' && $type != '1') {
  4587. $ed[] = array($sku . '-扣减方式填写错误!');
  4588. $j++;
  4589. continue;
  4590. }
  4591. if ($num < 0) //扣减库存
  4592. {
  4593. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4594. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4595. $j++;
  4596. continue;
  4597. }
  4598. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4599. if (count($data) < abs($num)) {
  4600. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4601. $j++;
  4602. continue;
  4603. }
  4604. if ($type == 0) //如果扣减方式为 扣减库存
  4605. {
  4606. for ($i = 0; $i < abs($num); $i++) {
  4607. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4608. }
  4609. } else if ($type == 1) {
  4610. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4611. if (count($zt) > 0) {
  4612. $ed[] = array($sku . '-有在途库存无法删除!');
  4613. $j++;
  4614. continue;
  4615. }
  4616. for ($i = 0; $i < abs($num); $i++) {
  4617. $this->whlabel->remove($data[$i]['id']);
  4618. }
  4619. }
  4620. } else if ($num > 0) //增加库存
  4621. {
  4622. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4623. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4624. $j++;
  4625. continue;
  4626. }
  4627. $post['sku'] = $d['sku'];
  4628. $post['shop'] = $d['shop'];
  4629. $post['warehouse'] = $warehouse['id'];
  4630. $post['purchase'] = $purchase['id'];
  4631. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4632. $post['state'] = 0;
  4633. $post['title'] = $d['title'];
  4634. $post['number'] = $d['number'];
  4635. $post['features'] = $d['features'];
  4636. $post['enter'] = $time;
  4637. $post['time'] = $time; //操作时间
  4638. $post['rktype'] = $rktype;
  4639. $post['sku_master_id'] = $d['sku_master_id'];
  4640. $post['sku_shop_id'] = $d['sku_shop_id'];
  4641. for ($i = 0; $i < $num; $i++) {
  4642. $post['label'] = time() . rand(100, 999) . $i;
  4643. $this->whlabel->insert($post);
  4644. }
  4645. }
  4646. sleep(1); //防止入库时间一样,需要延迟1秒
  4647. }
  4648. if ($j > 0) {
  4649. $tt = date('Ymd', time());
  4650. $title = '库存导入错误信息-' . $tt;
  4651. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4652. $tail = "\n";
  4653. $filename = $title . ".xls";
  4654. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4655. $dir = '/data/excel/' . $time . '/';
  4656. $file_name = 'error_' . $time . rand(1000, 9999);
  4657. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4658. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4659. fwrite($myfile, $ecl);
  4660. fclose($myfile);
  4661. $error = $dir . $file_name . '.xls';
  4662. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  4663. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4664. exit;
  4665. } else {
  4666. $this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  4667. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4668. exit;
  4669. }
  4670. }
  4671. //笛卡儿积
  4672. function cp($ps, $sets, $list)
  4673. {
  4674. $result = array();
  4675. $j = 0;
  4676. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4677. if ($i == 0) {
  4678. $result = $sets[$i];
  4679. }
  4680. $tmp = array();
  4681. foreach ($result as $res) {
  4682. foreach ($sets[$i + 1] as $set) {
  4683. $tmp[] = $res . ',' . $set;
  4684. }
  4685. }
  4686. $result = $tmp;
  4687. }
  4688. $this->db->trans_begin();
  4689. foreach ($result as $v) {
  4690. $post = array();
  4691. $title = "";
  4692. $num = "";
  4693. $data = explode(',', $v);
  4694. for ($i = 0; $i < count($list); $i++) {
  4695. $post[$list[$i]] = $data[$i];
  4696. $typeclass = $this->typeclass->read($data[$i]);
  4697. $title = $title . $typeclass['title'] . " ";
  4698. if ($data[$i] != 0) {
  4699. $num .= $data[$i]; //所有数据ID拼接
  4700. }
  4701. }
  4702. foreach ($ps as $kp => $vp) {
  4703. $post[$kp] = $vp;
  4704. }
  4705. $post['number'] = $num;
  4706. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4707. if ($info_list) {
  4708. $j++;
  4709. } else {
  4710. $skunum = $this->whlabel->find_count();
  4711. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4712. $post['title'] = rtrim($title, ' ');
  4713. $this->whlabel->insert($post);
  4714. }
  4715. }
  4716. if ($this->db->trans_status() === FALSE) {
  4717. $this->db->trans_commit();
  4718. return NULL;
  4719. } else {
  4720. $this->db->trans_commit();
  4721. return $j;
  4722. }
  4723. }
  4724. public function _kj($arg_array)
  4725. {
  4726. if (isset($_POST['sku'])) {
  4727. $time = time();
  4728. $sku = $this->input->post('sku', true);
  4729. $warehouse = $this->input->post('warehouse', true);
  4730. $num = $this->input->post('num', true);
  4731. $text = $this->input->post('text', true);
  4732. $purchase = $this->input->post('purchase', true);
  4733. $cktype = $this->input->post('cktype', true);
  4734. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4735. if ($cktype != 1 && $text == '') {
  4736. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4737. exit;
  4738. }
  4739. if ($num > count($order)) {
  4740. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4741. exit;
  4742. } else {
  4743. for ($i = 0; $i < $num; $i++) {
  4744. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4745. }
  4746. }
  4747. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4748. exit;
  4749. }
  4750. $uid = $this->whlabel->read($arg_array[0]);
  4751. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4752. $this->data['data'] = $uid;
  4753. $this->_Template('whlabel_kj', $this->data);
  4754. }
  4755. public function _summary($arg_array)
  4756. {
  4757. $prc = array();
  4758. $purchase = $this->purchase->find_all();
  4759. foreach ($purchase as $k => $v) {
  4760. $prc[$v['id']] = $v['title'];
  4761. }
  4762. if (isset($_GET['excel'])) {
  4763. $ktime = $this->input->get('ktime', true);
  4764. $jtime = $this->input->get('jtime', true);
  4765. $ktime = strtotime($ktime);
  4766. $jtime = strtotime($jtime);
  4767. $where = "1=1";
  4768. if ($ktime && $jtime) {
  4769. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4770. }
  4771. //数据排序
  4772. $order_str = "time desc";
  4773. if (empty($page)) {
  4774. $start = 0;
  4775. $perpage = 1;
  4776. } else {
  4777. $start = ($page - 1) * $perpage;
  4778. }
  4779. //取得信息列表
  4780. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4781. foreach ($info_list as $key => $value) {
  4782. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4783. $warehouse = $this->warehouse->read($value['warehouse']);
  4784. $info_list[$key]['warehouse'] = $warehouse['title'];
  4785. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4786. $details = array();
  4787. $cpid = array();
  4788. foreach ($x as $k => $v) {
  4789. if ($v['details'] != '') {
  4790. $details[$v['details']] = $v['details'];
  4791. }
  4792. if ($v['cpid'] != 0) {
  4793. $cpid[$v['cpid']] = $v['cpid'];
  4794. }
  4795. }
  4796. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4797. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4798. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4799. $info_list[$key]['s'] = $s;
  4800. $info_list[$key]['x'] = count($x);
  4801. }
  4802. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4803. $titlename = "<table border=1>
  4804. <tr align='center'>
  4805. <td>仓库</td>
  4806. <td>供应商</td>
  4807. <td>出库位置</td>
  4808. <td>出库编码</td>
  4809. <td>SKU</td>
  4810. <td>产品名</td>
  4811. <td>总剩余库存</td>
  4812. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4813. </tr>
  4814. </table>";
  4815. $filename = $title . ".xls";
  4816. $tail = "";
  4817. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4818. }
  4819. }
  4820. //usps发货清单
  4821. public function _manifest()
  4822. {
  4823. if (isset($_POST['manifest'])) {
  4824. $wltext = $this->input->post('wltext', true);
  4825. $time = time() - 16 * 3600;
  4826. $ptime = strtotime(date('Y-m-d', $time));
  4827. $waybill = array();
  4828. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4829. foreach ($fullorder as $v) {
  4830. $waybill[$v['waybill']] = $v['waybill'];
  4831. }
  4832. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4833. foreach ($fullordersmt as $v) {
  4834. $waybill[$v['waybill']] = $v['waybill'];
  4835. }
  4836. $wltext = explode(';', $wltext);
  4837. foreach ($wltext as $v) {
  4838. if (isset($waybill[$v])) {
  4839. unset($waybill[$v]);
  4840. }
  4841. }
  4842. $data = $this->usps->get_manifest($waybill);
  4843. if (isset($data['Description'])) {
  4844. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4845. exit;
  4846. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4847. $bctime = date('Ymd', time());
  4848. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4849. echo json_encode(array('msg' => $pdf, 'success' => true));
  4850. exit;
  4851. } else {
  4852. echo json_encode(array('msg' => $data, 'success' => false));
  4853. exit;
  4854. }
  4855. }
  4856. }
  4857. public function _pdf($pdf, $title, $bctime)
  4858. {
  4859. $pdf_path = './data/pdf/' . $bctime . '/';
  4860. $file_base64 = $pdf;
  4861. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4862. $file_base64 = base64_decode($file_base64);
  4863. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4864. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4865. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4866. }
  4867. /**
  4868. *
  4869. *
  4870. *
  4871. 进销存占单异常索引
  4872. *
  4873. *
  4874. *
  4875. **/
  4876. public function _abnormal()
  4877. {
  4878. $post = $this->input->post(NULL, TRUE);
  4879. if (isset($post['page'])) {
  4880. $page = $this->input->post('page', true);
  4881. $perpage = $this->input->post('perpage', true);
  4882. $sku = $this->input->post('sku', true);
  4883. $where = "1=1";
  4884. //数据排序
  4885. $order_str = "id desc";
  4886. if (empty($page)) {
  4887. $start = 0;
  4888. $perpage = 1;
  4889. } else {
  4890. $start = ($page - 1) * $perpage;
  4891. }
  4892. //取得信息列表
  4893. $info_list = $this->whlabel->find_all($where, '*');
  4894. $rows = array();
  4895. $list = array();
  4896. foreach ($info_list as $key => $value) {
  4897. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4898. }
  4899. foreach ($rows as $value) {
  4900. $warehouse = $this->warehouse->read($value['warehouse']);
  4901. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4902. $number = $value['number'];
  4903. $ftime = time() - 15 * 24 * 3600;
  4904. if ($value['shop'] != '') {
  4905. $shop = $value['shop'];
  4906. $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');
  4907. $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');
  4908. $order = array_merge($orderdlz, $ordersmt);
  4909. $od = 0;
  4910. $a = '';
  4911. $orid = '';
  4912. foreach ($order as $v) {
  4913. $or = explode('|', ltrim($v['whlabel'], '|'));
  4914. for ($i = 0; $i < count($or); $i++) {
  4915. $orod = explode('-', $or[$i]);
  4916. if ($orod[0] == $number) {
  4917. $od += $orod[1];
  4918. }
  4919. }
  4920. $orid .= $v['number'] . '-';
  4921. }
  4922. } else {
  4923. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4924. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4925. $order = array_merge($orderdlz, $ordersmt);
  4926. $od = 0;
  4927. $a = '';
  4928. $orid = '';
  4929. $qt = array();
  4930. foreach ($order as $v) {
  4931. $or = explode('|', ltrim($v['whlabel'], '|'));
  4932. for ($i = 0; $i < count($or); $i++) {
  4933. $orod = explode('-', $or[$i]);
  4934. if ($orod[0] == $number) {
  4935. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4936. if ($czzs > 0) {
  4937. if (isset($qt[$v['shop']])) {
  4938. if ($qt[$v['shop']] < $orod[1]) {
  4939. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4940. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4941. } else {
  4942. $qt[$v['shop']] -= $orod[1];
  4943. }
  4944. } else {
  4945. $qt[$v['shop']] = $czzs;
  4946. }
  4947. } else {
  4948. $od += $orod[1];
  4949. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4950. }
  4951. }
  4952. }
  4953. }
  4954. }
  4955. $z = $od . '(' . $orid . ')'; //查看订单号
  4956. //$z = $od;
  4957. if ($od > $c) {
  4958. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4959. }
  4960. }
  4961. $listdata = array_slice($list, $start, $perpage);
  4962. $total = count($list);
  4963. $pagenum = ceil($total / $perpage);
  4964. $over = $total - ($start + $perpage);
  4965. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4966. echo json_encode($rows);
  4967. exit;
  4968. }
  4969. $this->_Template('whlabel_abnormal', $this->data);
  4970. }
  4971. /**
  4972. *
  4973. *
  4974. *
  4975. 进销存占单异常索引
  4976. *
  4977. *
  4978. *
  4979. **/
  4980. public function _error()
  4981. {
  4982. $post = $this->input->post(NULL, TRUE);
  4983. if (isset($post['page'])) {
  4984. $page = $this->input->post('page', true);
  4985. $perpage = $this->input->post('perpage', true);
  4986. $sku = $this->input->post('sku', true);
  4987. $warehouse = $this->input->post('warehouse', true);
  4988. $ktime = $this->input->post('ktime', true);
  4989. $jtime = $this->input->post('jtime', true);
  4990. $ktime = strtotime($ktime);
  4991. $jtime = strtotime($jtime);
  4992. $where = "sku != 'Preset'";
  4993. $gj = '';
  4994. if ($sku) {
  4995. $where .= " and sku like '%$sku%'";
  4996. } else {
  4997. if ($ktime && $jtime) {
  4998. $gj = " and time > '$ktime' and time < '$jtime'";
  4999. }
  5000. }
  5001. if ($warehouse) {
  5002. $where .= " and warehouse = '$warehouse'";
  5003. }
  5004. //数据排序
  5005. $order_str = "id desc";
  5006. if (empty($page)) {
  5007. $start = 0;
  5008. $perpage = 1;
  5009. } else {
  5010. $start = ($page - 1) * $perpage;
  5011. }
  5012. //取得信息列表
  5013. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5014. $rows = array();
  5015. $list = array();
  5016. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5017. // foreach ($info_list as $value)
  5018. // {
  5019. // $warehouse = $this->warehouse->read($value['warehouse']);
  5020. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5021. // $number = $value['number'];$ftime = time()-15*24*3600;
  5022. // if($c < 1)
  5023. // {
  5024. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5025. // }
  5026. // }
  5027. $warehouse_list = $this->warehouse->find_all();
  5028. $warehouse_list = array_column($warehouse_list, null, 'id');
  5029. foreach ($info_list as $value) {
  5030. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5031. 'title' => "",
  5032. ];
  5033. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5034. $number = $value['number'];
  5035. $ftime = time() - 15 * 24 * 3600;
  5036. if ($c < 1) {
  5037. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5038. }
  5039. }
  5040. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5041. // $query = $this->db->query($sql);
  5042. // $info_list = $query->result_array();
  5043. // $sql_two = "select title,id from crowd_warehouse";
  5044. // $query_two = $this->db->query($sql_two);
  5045. // $warehouse_list = $query_two->result_array();
  5046. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5047. // foreach ($info_list as $value)
  5048. // {
  5049. // if(isset($warehouse_arr[$value['warehouse']])){
  5050. // $warehouse = $warehouse_arr[$value['warehouse']];
  5051. // }else{
  5052. // $warehouse = [
  5053. // 'id'=>0,
  5054. // 'title'=>"异常",
  5055. // ];
  5056. // }
  5057. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5058. // $number = $value['number'];$ftime = time()-15*24*3600;
  5059. // if($c < 1)
  5060. // {
  5061. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5062. // }
  5063. // }
  5064. $listdata = array_slice($list, $start, $perpage);
  5065. $total = count($list);
  5066. $pagenum = ceil($total / $perpage);
  5067. $over = $total - ($start + $perpage);
  5068. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5069. echo json_encode($rows);
  5070. exit;
  5071. }
  5072. if (isset($post['s'])) {
  5073. $id_arr = $this->input->post('s');
  5074. $id_arr = explode(',', trim($id_arr, ','));
  5075. if (!$id_arr) {
  5076. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5077. exit;
  5078. }
  5079. //循环删除记录
  5080. foreach ($id_arr as $v) {
  5081. $dd = $this->whlabel->read($v);
  5082. if (!isset($dd['id'])) {
  5083. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5084. exit;
  5085. }
  5086. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5087. if (isset($zt[0])) {
  5088. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5089. exit;
  5090. }
  5091. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5092. foreach ($deldd as $vv) {
  5093. $this->whlabel->remove($vv['id']);
  5094. }
  5095. }
  5096. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5097. exit;
  5098. }
  5099. $this->_Template('whlabel_error', $this->data);
  5100. }
  5101. public function _errorexcel()
  5102. {
  5103. $post = $this->input->post(NULL, TRUE);
  5104. if (isset($_GET['page'])) {
  5105. $page = $this->input->get('page', true);
  5106. $perpage = $this->input->get('perpage', true);
  5107. $sku = $this->input->get('sku', true);
  5108. $warehouse = $this->input->get('warehouse', true);
  5109. $ktime = $this->input->get('ktime', true);
  5110. $jtime = $this->input->get('jtime', true);
  5111. $ktime = strtotime($ktime);
  5112. $jtime = strtotime($jtime);
  5113. $where = "sku != 'Preset'";
  5114. $gj = '';
  5115. if ($sku) {
  5116. $where .= " and sku like '%$sku%'";
  5117. } else {
  5118. if ($ktime && $jtime) {
  5119. $gj = " and time > '$ktime' and time < '$jtime'";
  5120. }
  5121. }
  5122. if ($warehouse) {
  5123. $where .= " and warehouse = '$warehouse'";
  5124. }
  5125. //数据排序
  5126. $order_str = "id desc";
  5127. if (empty($page)) {
  5128. $start = 0;
  5129. $perpage = 1;
  5130. } else {
  5131. $start = ($page - 1) * $perpage;
  5132. }
  5133. //取得信息列表
  5134. $rows = array();
  5135. $list = array();
  5136. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5137. foreach ($info_list as $value) {
  5138. $warehouse = $this->warehouse->read($value['warehouse']);
  5139. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5140. $number = $value['number'];
  5141. $ftime = time() - 15 * 24 * 3600;
  5142. if ($c < 1) {
  5143. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5144. }
  5145. }
  5146. $title = "0库存汇总";
  5147. $titlename = "<table border=1>
  5148. <tr align='center'>
  5149. <td>仓库</td>
  5150. <td>SKU</td>
  5151. <td>产品</td>
  5152. <td>当前库存</td>
  5153. </tr>
  5154. </table>";
  5155. $filename = $title . ".xls";
  5156. $tail = "";
  5157. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5158. }
  5159. }
  5160. /**
  5161. *
  5162. *
  5163. * 占单
  5164. *
  5165. *
  5166. **/
  5167. public function _kcyz()
  5168. {
  5169. $post = $this->input->post(NULL, TRUE);
  5170. if (isset($post['warehouse'])) {
  5171. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5172. exit; //不再使用
  5173. $warehouse = $this->input->post('warehouse', true);
  5174. $whlabel = $this->input->post('whlabel', true);
  5175. $id = $this->input->post('id', true);
  5176. $shop = $this->input->post('shop', true);
  5177. $number = $this->input->post('number', true);
  5178. if (!$whlabel || $whlabel == '|') {
  5179. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5180. exit;
  5181. }
  5182. $pp = explode('|', trim($whlabel, '|'));
  5183. $x = 0;
  5184. $save = array();
  5185. foreach ($pp as $va) {
  5186. $num = explode('-', $va);
  5187. if ($number) {
  5188. $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 = '')"); //通用
  5189. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5190. } else {
  5191. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5192. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5193. }
  5194. $x++;
  5195. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5196. $save[] = $x - 1;
  5197. continue; //提前先加X不然出错,所以要减1
  5198. }
  5199. }
  5200. if (isset($save[0])) {
  5201. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5202. exit;
  5203. } else {
  5204. echo json_encode(array('success' => true));
  5205. exit;
  5206. }
  5207. }
  5208. }
  5209. public function _db()
  5210. {
  5211. $post = $this->input->post(NULL, TRUE);
  5212. if (isset($post['page'])) {
  5213. $page = $this->input->post('page', true);
  5214. $perpage = $this->input->post('perpage', true);
  5215. $sku = $this->input->post('sku', true);
  5216. $number = $this->input->post('number', true);
  5217. $warehouse = $this->input->post('warehouse', true);
  5218. $purchase = $this->input->post('purchase', true);
  5219. $orderinfo = $this->input->post('orderinfo', true);
  5220. $waybill = $this->input->post('waybill', true);
  5221. $category = $this->input->post('category', true);
  5222. $size = $this->input->post('size', true);
  5223. $grade = $this->input->post('grade', true);
  5224. $color = $this->input->post('color', true);
  5225. $lowe = $this->input->post('lowe', true);
  5226. $state = $this->input->post('state', true);
  5227. $label = $this->input->post('label', true);
  5228. $timetk = $this->input->post('timetkk', true);
  5229. $timetj = $this->input->post('timetjj', true);
  5230. $timetk = strtotime($timetk);
  5231. $timetj = strtotime($timetj);
  5232. $where = "dbtime > 0";
  5233. if ($timetk && $timetj) {
  5234. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5235. }
  5236. if ($sku) {
  5237. $where .= " and sku = '$sku'";
  5238. }
  5239. if ($warehouse) {
  5240. $where .= " and warehouse = '$warehouse'";
  5241. if ($warehouse == 12) {
  5242. $w = 'specialstock';
  5243. } else {
  5244. $w = 'whlabel';
  5245. }
  5246. }
  5247. if ($purchase) {
  5248. $where .= " and purchase = '$purchase'";
  5249. }
  5250. if ($category) {
  5251. $where .= " and features like '%-$category-%'";
  5252. }
  5253. if ($size) {
  5254. $where .= " and features like '%-$size-%'";
  5255. }
  5256. if ($grade) {
  5257. $where .= " and features like '%-$grade-%'";
  5258. }
  5259. if ($color) {
  5260. $where .= " and features like '%-$color-%'";
  5261. }
  5262. if ($lowe) {
  5263. $where .= " and features like '%-$lowe-%'";
  5264. }
  5265. if ($state != '') {
  5266. $where .= " and state = '$state'";
  5267. }
  5268. //数据排序
  5269. $order_str = "dbtime desc";
  5270. if (empty($page)) {
  5271. $start = 0;
  5272. $perpage = 1;
  5273. } else {
  5274. $start = ($page - 1) * $perpage;
  5275. }
  5276. //取得信息列表
  5277. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5278. foreach ($info_list as $key => $value) {
  5279. $warehouse = $this->$w->read($value['warehouse']);
  5280. $info_list[$key]['warehouse'] = $warehouse['title'];
  5281. $purchase = $this->purchase->read($value['purchase']);
  5282. $info_list[$key]['purchase'] = $purchase['title'];
  5283. if ($value['enter'] != 0) {
  5284. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5285. } else {
  5286. $info_list[$key]['enter'] = "";
  5287. }
  5288. if ($value['dbtime'] != 0) {
  5289. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5290. } else {
  5291. $info_list[$key]['dbtime'] = "";
  5292. }
  5293. if ($value['state'] == 0) {
  5294. $info_list[$key]['state'] = "在库";
  5295. } else if ($value['state'] == 1) {
  5296. $info_list[$key]['state'] = "出库";
  5297. } else if ($value['state'] == 2) {
  5298. $info_list[$key]['state'] = "退库";
  5299. } else if ($value['state'] == 3) {
  5300. $info_list[$key]['state'] = "调拨中";
  5301. } else if ($value['state'] == 4) {
  5302. $info_list[$key]['state'] = "再加工";
  5303. } else if ($value['state'] == 5) {
  5304. $info_list[$key]['state'] = "维修中";
  5305. } else if ($value['state'] == 6) {
  5306. $info_list[$key]['state'] = "盘亏";
  5307. } else if ($value['state'] == 7) {
  5308. $info_list[$key]['state'] = "更换标签";
  5309. } else if ($value['state'] == 8) {
  5310. $info_list[$key]['state'] = "其它";
  5311. } else if ($value['state'] == 9) {
  5312. $info_list[$key]['state'] = "预设";
  5313. }
  5314. }
  5315. $total = $this->whlabel->find_count($where);
  5316. $pagenum = ceil($total / $perpage);
  5317. $over = $total - ($start + $perpage);
  5318. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5319. echo json_encode($rows);
  5320. exit;
  5321. }
  5322. if (isset($post['outsku'])) {
  5323. $time = time();
  5324. $cz = $this->input->post('cz', true);
  5325. $label = $this->input->post('outsku', true);
  5326. $sl = $this->input->post('sl', true);
  5327. $num = $this->input->post('num', true);
  5328. //$warehouse = $this->input->post('warehouse',true);
  5329. if (!$sl) {
  5330. $sl = 1;
  5331. }
  5332. if (!$warehouse) {
  5333. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5334. exit;
  5335. }
  5336. $dblabel = $this->whlabellabel->get_label($label);
  5337. if ($dblabel) {
  5338. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5339. if (count($data) < 1) {
  5340. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5341. exit;
  5342. }
  5343. if (count($data) < $num) {
  5344. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5345. exit;
  5346. }
  5347. for ($i = 0; $i < $sl; $i++) {
  5348. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5349. }
  5350. echo json_encode(array('success' => true));
  5351. exit;
  5352. } else {
  5353. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5354. exit;
  5355. }
  5356. }
  5357. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5358. $this->_Template('whlabel_db', $this->data);
  5359. }
  5360. public function _dbrk()
  5361. {
  5362. $post = $this->input->post(NULL, TRUE);
  5363. if (isset($post['page'])) {
  5364. $page = $this->input->post('page', true);
  5365. $perpage = $this->input->post('perpage', true);
  5366. $sku = $this->input->post('sku', true);
  5367. $number = $this->input->post('number', true);
  5368. $warehouse = $this->input->post('warehouse', true);
  5369. $purchase = $this->input->post('purchase', true);
  5370. $orderinfo = $this->input->post('orderinfo', true);
  5371. $waybill = $this->input->post('waybill', true);
  5372. $category = $this->input->post('category', true);
  5373. $size = $this->input->post('size', true);
  5374. $grade = $this->input->post('grade', true);
  5375. $color = $this->input->post('color', true);
  5376. $lowe = $this->input->post('lowe', true);
  5377. $state = $this->input->post('state', true);
  5378. $label = $this->input->post('label', true);
  5379. $ctime = $this->input->post('ctime', true);
  5380. $timetk = $this->input->post('timetkk', true);
  5381. $timetj = $this->input->post('timetjj', true);
  5382. $timetk = strtotime($timetk);
  5383. $timetj = strtotime($timetj);
  5384. $where = "dbtime > 0";
  5385. if ($timetk && $timetj) {
  5386. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5387. }
  5388. if ($sku) {
  5389. $where .= " and sku = '$sku'";
  5390. }
  5391. if ($warehouse) {
  5392. $where .= " and warehouse = '$warehouse'";
  5393. }
  5394. if ($purchase) {
  5395. $where .= " and purchase = '$purchase'";
  5396. }
  5397. if ($category) {
  5398. $where .= " and features like '%-$category-%'";
  5399. }
  5400. if ($size) {
  5401. $where .= " and features like '%-$size-%'";
  5402. }
  5403. if ($grade) {
  5404. $where .= " and features like '%-$grade-%'";
  5405. }
  5406. if ($color) {
  5407. $where .= " and features like '%-$color-%'";
  5408. }
  5409. if ($lowe) {
  5410. $where .= " and features like '%-$lowe-%'";
  5411. }
  5412. if ($state != '') {
  5413. $where .= " and state = '$state'";
  5414. }
  5415. //数据排序
  5416. $order_str = "dbtime desc";
  5417. if (empty($page)) {
  5418. $start = 0;
  5419. $perpage = 1;
  5420. } else {
  5421. $start = ($page - 1) * $perpage;
  5422. }
  5423. //取得信息列表
  5424. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5425. foreach ($info_list as $key => $value) {
  5426. $warehouse = $this->warehouse->read($value['warehouse']);
  5427. $info_list[$key]['warehouse'] = $warehouse['title'];
  5428. $purchase = $this->purchase->read($value['purchase']);
  5429. $info_list[$key]['purchase'] = $purchase['title'];
  5430. if ($value['enter'] != 0) {
  5431. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5432. } else {
  5433. $info_list[$key]['enter'] = "";
  5434. }
  5435. if ($value['dbtime'] != 0) {
  5436. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5437. } else {
  5438. $info_list[$key]['dbtime'] = "";
  5439. }
  5440. if ($value['state'] == 0) {
  5441. $info_list[$key]['state'] = "在库";
  5442. } else if ($value['state'] == 1) {
  5443. $info_list[$key]['state'] = "出库";
  5444. } else if ($value['state'] == 2) {
  5445. $info_list[$key]['state'] = "退库";
  5446. } else if ($value['state'] == 3) {
  5447. $info_list[$key]['state'] = "调拨中";
  5448. } else if ($value['state'] == 4) {
  5449. $info_list[$key]['state'] = "再加工";
  5450. } else if ($value['state'] == 5) {
  5451. $info_list[$key]['state'] = "维修中";
  5452. } else if ($value['state'] == 6) {
  5453. $info_list[$key]['state'] = "盘亏";
  5454. } else if ($value['state'] == 7) {
  5455. $info_list[$key]['state'] = "更换标签";
  5456. } else if ($value['state'] == 8) {
  5457. $info_list[$key]['state'] = "其它";
  5458. } else if ($value['state'] == 9) {
  5459. $info_list[$key]['state'] = "预设";
  5460. }
  5461. }
  5462. $total = $this->whlabel->find_count($where);
  5463. $pagenum = ceil($total / $perpage);
  5464. $over = $total - ($start + $perpage);
  5465. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5466. echo json_encode($rows);
  5467. exit;
  5468. }
  5469. if (isset($post['rsku'])) {
  5470. $cz = $this->input->post('cz', true);
  5471. $label = $this->input->post('rsku', true);
  5472. $sl = $this->input->post('sl', true);
  5473. $warehouse = $this->input->post('warehouse', true);
  5474. if (!$sl) {
  5475. $sl = 1;
  5476. }
  5477. if (!$warehouse) {
  5478. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5479. exit;
  5480. }
  5481. $dblabel = $this->whlabellabel->get_label($label);
  5482. if ($dblabel) {
  5483. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5484. if (count($data) < 1) {
  5485. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5486. exit;
  5487. }
  5488. if ($sl > count($data)) {
  5489. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5490. exit;
  5491. }
  5492. $time = time();
  5493. for ($i = 0; $i < $sl; $i++) {
  5494. $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']);
  5495. }
  5496. echo json_encode(array('success' => true));
  5497. exit;
  5498. } else {
  5499. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5500. exit;
  5501. }
  5502. }
  5503. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5504. $this->_Template('whlabel_dbrk', $this->data);
  5505. }
  5506. public function _whlabelczdc()
  5507. {
  5508. if (isset($_GET['excel'])) {
  5509. //数据排序
  5510. $order_str = "id desc";
  5511. if (empty($page)) {
  5512. $start = 0;
  5513. $perpage = 1;
  5514. } else {
  5515. $start = ($page - 1) * $perpage;
  5516. }
  5517. $state = $this->input->get('state', true);
  5518. $sku = $this->input->get('sku', true);
  5519. $ctime = $this->input->get('ctime', true);
  5520. $category = $this->input->get('category', true);
  5521. $size = $this->input->get('size', true);
  5522. $grade = $this->input->get('grade', true);
  5523. $color = $this->input->get('color', true);
  5524. $lowe = $this->input->get('lowe', true);
  5525. $timetk = $this->input->get('timetkk', true);
  5526. $timetj = $this->input->get('timetjj', true);
  5527. $timetk = strtotime($timetk);
  5528. $timetj = strtotime($timetj);
  5529. $where = "dbtime > 0";
  5530. if ($timetk && $timetj) {
  5531. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5532. }
  5533. if ($category) {
  5534. $where .= " and features like '%-$category-%'";
  5535. }
  5536. if ($size) {
  5537. $where .= " and features like '%-$size-%'";
  5538. }
  5539. if ($grade) {
  5540. $where .= " and features like '%-$grade-%'";
  5541. }
  5542. if ($color) {
  5543. $where .= " and features like '%-$color-%'";
  5544. }
  5545. if ($lowe) {
  5546. $where .= " and features like '%-$lowe-%'";
  5547. }
  5548. //取得信息列表
  5549. $info_list = $this->whlabel->find_all($where, '*');
  5550. $rows = array();
  5551. $list = array();
  5552. foreach ($info_list as $key => $value) {
  5553. $rows[$value['sku']] = $value; //所有数据sku
  5554. }
  5555. foreach ($rows as $value) {
  5556. $warehouse = $this->warehouse->read($value['warehouse']);
  5557. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5558. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5559. if ($value['orderinfo'] == 0) {
  5560. $info_list[$key]['orderinfo'] = "";
  5561. }
  5562. if ($value['waybill'] == 0) {
  5563. $info_list[$key]['waybill'] = "";
  5564. }
  5565. if ($value['state'] == 0) {
  5566. $value['state'] = "在库";
  5567. } else if ($value['state'] == 3) {
  5568. $value['state'] = "调拨中";
  5569. }
  5570. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5571. }
  5572. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5573. $titlename = "<table border=1>
  5574. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5575. <tr align='center'>
  5576. <td>SKU</td>
  5577. <td>产品</td>
  5578. <td>调拨数量</td>
  5579. <td>入库数量</td>
  5580. </tr>
  5581. </table>";
  5582. $filename = $title . ".xls";
  5583. $tail = "";
  5584. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5585. }
  5586. }
  5587. public function _print($arg_array)
  5588. {
  5589. if (isset($_SESSION['api'])) {
  5590. $user = $this->user->get_api($_SESSION['api']);
  5591. $usp = $user;
  5592. $fgshop = "";
  5593. $sid = "";
  5594. $wid = "";
  5595. $wtype = "";
  5596. $usersp = explode('|', trim($user['shop'], '|'));
  5597. $userwh = explode('|', trim($user['warehouse'], '|'));
  5598. foreach ($usersp as $value) {
  5599. $fgshop .= " shop = " . $value . " or";
  5600. $sid .= " id = " . $value . " or";
  5601. }
  5602. foreach ($userwh as $value) {
  5603. $wid .= " id = " . $value . " or";
  5604. $wtype .= " type = " . $value . " or";
  5605. }
  5606. }
  5607. $post = $this->input->post(NULL, TRUE);
  5608. if (isset($post['tmsku'])) {
  5609. $tmsku = $this->input->post('tmsku', true);
  5610. if (is_numeric($tmsku)) {
  5611. $yyh = $this->whlabellabel->get_label($tmsku);
  5612. } else {
  5613. $yyh = $this->whlabellabel->get_sku($tmsku);
  5614. if(empty($yyh)){
  5615. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  5616. if($r['code'] == -1 ){
  5617. echo json_encode(array('success' => false));
  5618. exit;
  5619. }else{
  5620. echo json_encode(array('features' => $r['data'], 'success' => true));
  5621. exit;
  5622. }
  5623. }
  5624. }
  5625. if ($yyh) {
  5626. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5627. exit;
  5628. } else {
  5629. echo json_encode(array('success' => false));
  5630. exit;
  5631. }
  5632. }
  5633. $classid = $this->classid->sku();
  5634. $pm = $classid;
  5635. $scsku = $classid;
  5636. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5637. if (isset($post['warehouse'])) {
  5638. if ($post['warehouse']) {
  5639. $list = array();
  5640. $num = "";
  5641. $title = "";
  5642. $features = "";
  5643. $order = 0;
  5644. $post['shop'] = '';
  5645. $brand = $this->input->post('brand', true);
  5646. if ($brand != '0,') {
  5647. $b = $this->brand->read(rtrim($brand, ','));
  5648. if ($b) {
  5649. $post['shop'] = str_replace('|', ',', $b['shop']);
  5650. }
  5651. }
  5652. $post['details'] = $this->input->post('details', true); //打印数量
  5653. $xbqnum = $this->input->post('xbqnum', true);
  5654. $post['purchase'] = $this->input->post('purchase', true);
  5655. $post['warehouse'] = $this->input->post('warehouse', true);
  5656. $post['purchase'] = $this->input->post('purchase', true);
  5657. $post['retreatwarehouse'] = $post['warehouse'];
  5658. $post['cpbz'] = $this->input->post('cpbz', true);
  5659. $post['state'] = 9;
  5660. $category = $this->input->post('category', true);
  5661. $list['category'] = $category;
  5662. $list['hairtype'] = $this->input->post('hairtype', true);
  5663. $list['grade'] = $this->input->post('grade', true);
  5664. $size = $this->input->post('size', true);
  5665. $list['size'] = rtrim($size, ',');
  5666. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5667. $list['extension'] = $this->input->post('extension', true);
  5668. if ($category == 1297) {
  5669. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5670. }
  5671. if ($category == 1702) {
  5672. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5673. $list['syother'] = $this->input->post('syother', true);
  5674. }
  5675. if ($category == 133) {
  5676. $list['fittype'] = $this->input->post('fittype', true);
  5677. $list['acother'] = $this->input->post('acother', true);
  5678. }
  5679. $list['color'] = $this->input->post('color', true);
  5680. $list['lowe'] = $this->input->post('lowe', true);
  5681. if ($category == 127) {
  5682. $list['type'] = $this->input->post('type', true);
  5683. $list['headroad'] = $this->input->post('headroad', true);
  5684. $list['density'] = $this->input->post('density', true);
  5685. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5686. $list['lacesize'] = $this->input->post('lacesize', true);
  5687. }
  5688. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5689. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5690. }
  5691. if ($category == 128) {
  5692. $list['lacetype'] = $this->input->post('lacetype', true);
  5693. $list['haircap'] = $this->input->post('haircap', true);
  5694. $list['density'] = $this->input->post('density', true);
  5695. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5696. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5697. $list['wigother'] = $this->input->post('wigother', true);
  5698. $list['wigother1'] = $this->input->post('wigother1', true);
  5699. $list['wigother2'] = $this->input->post('wigother2', true);
  5700. }
  5701. if ($category == 129) {
  5702. $list['wide'] = $this->input->post('wide', true);
  5703. }
  5704. if ($category == 131) {
  5705. $list['gifttype'] = $this->input->post('gifttype', true);
  5706. $list['giftother'] = $this->input->post('giftother', true);
  5707. }
  5708. if ($category == 134) {
  5709. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5710. }
  5711. if ($category == 1297) {
  5712. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5713. $list['sywigother'] = $this->input->post('sywigother', true);
  5714. }
  5715. if ($category == 130 || $category == 133 || $category == 1702) {
  5716. $list['items'] = $this->input->post('items', true);
  5717. $list['weight'] = $this->input->post('weight', true);
  5718. }
  5719. if ($category == 1702) {
  5720. $list['syhairther'] = $this->input->post('syhairther', true);
  5721. }
  5722. if($category == 130){
  5723. $list['jfother'] = $this->input->post('jfother', true);
  5724. }
  5725. foreach ($list as $k => $v) {
  5726. if ($v != 0) {
  5727. $num .= $v;
  5728. $features .= $v . '-';
  5729. $post[$k] = $v;
  5730. $typeclass = $this->typeclass->read($v);
  5731. if (isset($pm[$typeclass['classid']])) {
  5732. if (stripos($typeclass['zh'], '|') !== false) {
  5733. $exzh = explode('|', $typeclass['zh']);
  5734. $pm[$typeclass['classid']] = $exzh[0];
  5735. } else {
  5736. $pm[$typeclass['classid']] = $typeclass['zh'];
  5737. }
  5738. }
  5739. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5740. if ($k != 'size') {
  5741. $title .= $typeclass['title'] . " ";
  5742. }
  5743. }
  5744. }
  5745. $typeclass = $this->typeclass->read($list['size']);
  5746. $title .= $typeclass['title'];
  5747. $time = time();
  5748. $post['title'] = rtrim($title, ' ');
  5749. $post['number'] = $num;
  5750. $post['features'] = '-' . $features;
  5751. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5752. $featurespp = explode('-', trim($featurespp, '-'));
  5753. if (isset($featurespp[5])) {
  5754. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5755. } else {
  5756. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5757. }
  5758. $post['enter'] = $time;
  5759. $post['time'] = $time; //操作时间
  5760. $scsku = implode("-", $scsku);
  5761. $zh = implode(" ", $pm);
  5762. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5763. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5764. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5765. $post['sku'] = $bqsku;
  5766. $label = time() . rand(0, 9);
  5767. $post['label'] = $label;
  5768. $cpid = $this->whlabellabel->find_count();
  5769. $post['cpid'] = $cpid + 1;
  5770. $cpid = $post['cpid'];
  5771. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5772. //if($whlabelbarcode)
  5773. //{
  5774. //$post['label'] = $whlabelbarcode['label'];
  5775. //if(!$this->whlabellabel->insert($post))
  5776. //{
  5777. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5778. //}
  5779. //}
  5780. //else
  5781. //{
  5782. $this->db->trans_begin();
  5783. $this->whlabellabel->insert($post);
  5784. //$this->whlabelbarcode->insert($post);
  5785. if ($this->db->trans_status() === TRUE) {
  5786. $this->db->trans_commit();
  5787. } else {
  5788. $this->db->trans_rollback();
  5789. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5790. exit;
  5791. }
  5792. //}
  5793. $warehouse_name = "";
  5794. $warehouse = $post['warehouse'];
  5795. if($warehouse == 12){
  5796. $warehouse_name = "特殊库存库";
  5797. }
  5798. // if($warehouse == 13){
  5799. // $warehouse_name = "许昌仓";
  5800. // }
  5801. // if($warehouse == 5){
  5802. // $warehouse_name = "美国店";
  5803. // }
  5804. // if($warehouse == 16){
  5805. // $warehouse_name = "定制头套仓";
  5806. // }
  5807. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5808. if(!empty($warehouse_name)){
  5809. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5810. }
  5811. $purchase = $this->purchase->read($post['purchase']);
  5812. 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));
  5813. exit; //特殊仓目前不需要仓库选项
  5814. }
  5815. }
  5816. if (isset($_SESSION['api'])) {
  5817. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5818. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5819. $this->data['wlshop'] = $wlshop;
  5820. $this->data['warehouse'] = $warehouse;
  5821. }
  5822. $whlabelwz = $this->whlabelwz->find_all();
  5823. $this->data['whlabelwz'] = $whlabelwz;
  5824. $this->_Template('whlabel_print', $this->data);
  5825. }
  5826. public function _usaprint($arg_array)
  5827. {
  5828. if (isset($_SESSION['api'])) {
  5829. $user = $this->user->get_api($_SESSION['api']);
  5830. $usp = $user;
  5831. $fgshop = "";
  5832. $sid = "";
  5833. $wid = "";
  5834. $wtype = "";
  5835. $usersp = explode('|', trim($user['shop'], '|'));
  5836. $userwh = explode('|', trim($user['warehouse'], '|'));
  5837. foreach ($usersp as $value) {
  5838. $fgshop .= " shop = " . $value . " or";
  5839. $sid .= " id = " . $value . " or";
  5840. }
  5841. foreach ($userwh as $value) {
  5842. $wid .= " id = " . $value . " or";
  5843. $wtype .= " type = " . $value . " or";
  5844. }
  5845. }
  5846. $post = $this->input->post(NULL, TRUE);
  5847. if (isset($post['tmsku'])) {
  5848. $tmsku = $this->input->post('tmsku', true);
  5849. if (is_numeric($tmsku)) {
  5850. $yyh = $this->whlabellabel->get_label($tmsku);
  5851. } else {
  5852. $yyh = $this->whlabellabel->get_sku($tmsku);
  5853. }
  5854. if ($yyh) {
  5855. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5856. exit;
  5857. } else {
  5858. echo json_encode(array('success' => false));
  5859. exit;
  5860. }
  5861. }
  5862. $classid = $this->classid->sku();
  5863. $pm = $classid;
  5864. $scsku = $classid;
  5865. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5866. if (isset($post['warehouse'])) {
  5867. if ($post['warehouse']) {
  5868. $list = array();
  5869. $num = "";
  5870. $title = "";
  5871. $features = "";
  5872. $order = 0;
  5873. $post['shop'] = '';
  5874. $brand = $this->input->post('brand', true);
  5875. if ($brand != '0,') {
  5876. $b = $this->brand->read(rtrim($brand, ','));
  5877. if ($b) {
  5878. $post['shop'] = str_replace('|', ',', $b['shop']);
  5879. }
  5880. }
  5881. $post['details'] = $this->input->post('details', true); //打印数量
  5882. $xbqnum = $this->input->post('xbqnum', true);
  5883. $post['purchase'] = $this->input->post('purchase', true);
  5884. $post['warehouse'] = $this->input->post('warehouse', true);
  5885. $post['purchase'] = $this->input->post('purchase', true);
  5886. $post['retreatwarehouse'] = $post['warehouse'];
  5887. $post['cpbz'] = $this->input->post('cpbz', true);
  5888. $post['state'] = 9;
  5889. $category = $this->input->post('category', true);
  5890. $list['category'] = $category;
  5891. $list['hairtype'] = $this->input->post('hairtype', true);
  5892. $list['grade'] = $this->input->post('grade', true);
  5893. $size = $this->input->post('size', true);
  5894. $list['size'] = rtrim($size, ',');
  5895. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5896. $list['extension'] = $this->input->post('extension', true);
  5897. if ($category == 1297) {
  5898. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5899. }
  5900. if ($category == 1702) {
  5901. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5902. $list['syother'] = $this->input->post('syother', true);
  5903. }
  5904. if ($category == 133) {
  5905. $list['fittype'] = $this->input->post('fittype', true);
  5906. $list['acother'] = $this->input->post('acother', true);
  5907. }
  5908. $list['color'] = $this->input->post('color', true);
  5909. $list['lowe'] = $this->input->post('lowe', true);
  5910. if ($category == 127) {
  5911. $list['type'] = $this->input->post('type', true);
  5912. $list['headroad'] = $this->input->post('headroad', true);
  5913. $list['density'] = $this->input->post('density', true);
  5914. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5915. $list['lacesize'] = $this->input->post('lacesize', true);
  5916. }
  5917. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5918. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5919. }
  5920. if ($category == 128) {
  5921. $list['lacetype'] = $this->input->post('lacetype', true);
  5922. $list['haircap'] = $this->input->post('haircap', true);
  5923. $list['density'] = $this->input->post('density', true);
  5924. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5925. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5926. $list['wigother'] = $this->input->post('wigother', true);
  5927. $list['wigother1'] = $this->input->post('wigother1', true);
  5928. $list['wigother2'] = $this->input->post('wigother2', true);
  5929. }
  5930. if ($category == 129) {
  5931. $list['wide'] = $this->input->post('wide', true);
  5932. }
  5933. if ($category == 131) {
  5934. $list['gifttype'] = $this->input->post('gifttype', true);
  5935. $list['giftother'] = $this->input->post('giftother', true);
  5936. }
  5937. if ($category == 134) {
  5938. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5939. }
  5940. if ($category == 1297) {
  5941. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5942. $list['sywigother'] = $this->input->post('sywigother', true);
  5943. }
  5944. if ($category == 130 || $category == 133 || $category == 1702) {
  5945. $list['items'] = $this->input->post('items', true);
  5946. $list['weight'] = $this->input->post('weight', true);
  5947. }
  5948. if ($category == 1702) {
  5949. $list['syhairther'] = $this->input->post('syhairther', true);
  5950. }
  5951. foreach ($list as $k => $v) {
  5952. if ($v != 0) {
  5953. $num .= $v;
  5954. $features .= $v . '-';
  5955. $post[$k] = $v;
  5956. $typeclass = $this->typeclass->read($v);
  5957. if (isset($pm[$typeclass['classid']])) {
  5958. if (stripos($typeclass['zh'], '|') !== false) {
  5959. $exzh = explode('|', $typeclass['zh']);
  5960. $pm[$typeclass['classid']] = $exzh[0];
  5961. } else {
  5962. $pm[$typeclass['classid']] = $typeclass['zh'];
  5963. }
  5964. }
  5965. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5966. if ($k != 'size') {
  5967. $title .= $typeclass['title'] . " ";
  5968. }
  5969. }
  5970. }
  5971. $typeclass = $this->typeclass->read($list['size']);
  5972. $title .= $typeclass['title'];
  5973. $time = time();
  5974. $post['title'] = rtrim($title, ' ');
  5975. $post['number'] = $num;
  5976. $post['features'] = '-' . $features;
  5977. $fp = $this->whlabel->get_features($post['features']);
  5978. if (!$fp) {
  5979. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5980. exit;
  5981. }
  5982. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5983. $featurespp = explode('-', trim($featurespp, '-'));
  5984. if (isset($featurespp[5])) {
  5985. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5986. } else {
  5987. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5988. }
  5989. $post['enter'] = $time;
  5990. $post['time'] = $time; //操作时间
  5991. $scsku = implode("-", $scsku);
  5992. $zh = implode(" ", $pm);
  5993. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5994. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5995. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5996. $post['sku'] = $fp['sku'];
  5997. $post['label'] = $fp['sku'];
  5998. $cpid = $this->whlabellabel->find_count();
  5999. $post['cpid'] = $cpid + 1;
  6000. $cpid = $post['cpid'];
  6001. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6002. //if($whlabelbarcode)
  6003. //{
  6004. //$post['label'] = $whlabelbarcode['label'];
  6005. //if(!$this->whlabellabel->insert($post))
  6006. //{
  6007. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6008. //}
  6009. //}
  6010. //else
  6011. //{
  6012. $this->db->trans_begin();
  6013. $this->whlabellabel->insert($post);
  6014. //$this->whlabelbarcode->insert($post);
  6015. if ($this->db->trans_status() === TRUE) {
  6016. $this->db->trans_commit();
  6017. } else {
  6018. $this->db->trans_rollback();
  6019. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6020. exit;
  6021. }
  6022. //}
  6023. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6024. $purchase = $this->purchase->read($post['purchase']);
  6025. 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));
  6026. exit; //特殊仓目前不需要仓库选项
  6027. }
  6028. }
  6029. if (isset($_SESSION['api'])) {
  6030. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6031. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6032. $this->data['wlshop'] = $wlshop;
  6033. $this->data['warehouse'] = $warehouse;
  6034. }
  6035. $whlabelwz = $this->whlabelwz->find_all();
  6036. $this->data['whlabelwz'] = $whlabelwz;
  6037. $this->_Template('whlabel_usaprint', $this->data);
  6038. }
  6039. public function _printrk($arg_array)
  6040. {
  6041. $prc = array();
  6042. $purchase = $this->purchase->find_all();
  6043. foreach ($purchase as $k => $v) {
  6044. $prc[$v['id']] = $v['title'];
  6045. }
  6046. $post = $this->input->post(NULL, TRUE);
  6047. if (isset($post['page'])) {
  6048. $page = $this->input->post('page', true);
  6049. $perpage = $this->input->post('perpage', true);
  6050. $sku = $this->input->post('sku', true);
  6051. $bs = $this->input->post('bs', true);
  6052. $number = $this->input->post('number', true);
  6053. $warehouse = $this->input->post('warehouse', true);
  6054. $purchase = $this->input->post('purchase', true);
  6055. $orderinfo = $this->input->post('orderinfo', true);
  6056. $waybill = $this->input->post('waybill', true);
  6057. $category = $this->input->post('category', true);
  6058. $size = $this->input->post('size', true);
  6059. $grade = $this->input->post('grade', true);
  6060. $color = $this->input->post('color', true);
  6061. $lowe = $this->input->post('lowe', true);
  6062. $state = $this->input->post('state', true);
  6063. $label = $this->input->post('label', true);
  6064. $timetk = $this->input->post('ktime', true);
  6065. $timetj = $this->input->post('jtime', true);
  6066. $timetk = strtotime($timetk);
  6067. $timetj = strtotime($timetj);
  6068. $where = "1=1 ";
  6069. if ($timetk && $timetj) {
  6070. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6071. }
  6072. if ($sku) {
  6073. $where .= " and sku = '$sku'";
  6074. }
  6075. if ($bs != '') {
  6076. $where .= " and bs = '$bs'";
  6077. }
  6078. if ($number) {
  6079. $where .= " and number = '$number'";
  6080. }
  6081. if ($warehouse) {
  6082. $where .= " and warehouse = '$warehouse'";
  6083. }
  6084. if ($purchase) {
  6085. $where .= " and purchase = '$purchase'";
  6086. }
  6087. if ($orderinfo) {
  6088. $where .= " and orderinfo = '$orderinfo'";
  6089. }
  6090. if ($waybill) {
  6091. $where .= " and waybill = '$waybill'";
  6092. }
  6093. if ($category) {
  6094. $where .= " and features like '%-$category-%'";
  6095. }
  6096. if ($size) {
  6097. $where .= " and features like '%-$size-%'";
  6098. }
  6099. if ($grade) {
  6100. $where .= " and features like '%-$grade-%'";
  6101. }
  6102. if ($color) {
  6103. $where .= " and features like '%-$color-%'";
  6104. }
  6105. if ($lowe) {
  6106. $where .= " and features like '%-$lowe-%'";
  6107. }
  6108. if ($label) {
  6109. $where .= " and label = '$label'";
  6110. }
  6111. if ($state || $state == 0) {
  6112. $where .= " and state = '$state'";
  6113. }
  6114. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6115. //数据排序
  6116. $order_str = "enter desc";
  6117. if (empty($page)) {
  6118. $start = 0;
  6119. $perpage = 1;
  6120. } else {
  6121. $start = ($page - 1) * $perpage;
  6122. }
  6123. //取得信息列表
  6124. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6125. foreach ($info_list as $key => $value) {
  6126. $warehouse = $this->warehouse->read($value['warehouse']);
  6127. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6128. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6129. if ($value['state'] == 0) {
  6130. $info_list[$key]['state'] = "在库";
  6131. } else if ($value['state'] == 1) {
  6132. $info_list[$key]['state'] = "出库";
  6133. } else if ($value['state'] == 2) {
  6134. $info_list[$key]['state'] = "退库";
  6135. } else if ($value['state'] == 3) {
  6136. $info_list[$key]['state'] = "调拨中";
  6137. } else if ($value['state'] == 4) {
  6138. $info_list[$key]['state'] = "再加工";
  6139. } else if ($value['state'] == 5) {
  6140. $info_list[$key]['state'] = "维修中";
  6141. } else if ($value['state'] == 6) {
  6142. $info_list[$key]['state'] = "盘亏";
  6143. } else if ($value['state'] == 7) {
  6144. $info_list[$key]['state'] = "更换标签";
  6145. } else if ($value['state'] == 8) {
  6146. $info_list[$key]['state'] = "其它";
  6147. } else if ($value['state'] == 9) {
  6148. $info_list[$key]['state'] = "预设";
  6149. } else if ($value['state'] == 10) {
  6150. $info_list[$key]['state'] = "美店零售";
  6151. }
  6152. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6153. }
  6154. $total = $this->$ck->find_count($where);
  6155. $pagenum = ceil($total / $perpage);
  6156. $over = $total - ($start + $perpage);
  6157. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6158. echo json_encode($rows);
  6159. exit;
  6160. }
  6161. if (isset($post['tmsku'])) {
  6162. $time = time();
  6163. $tmsku = $this->input->post('tmsku', true);
  6164. //$post['shop'] = $this->input->post('shop',true);
  6165. $num = $this->input->post('num', true);
  6166. $rktype = $this->input->post('rktype', true);
  6167. if ($num > 200) {
  6168. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6169. exit;
  6170. }
  6171. if (!$rktype) {
  6172. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6173. }
  6174. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6175. /**
  6176. $wz = array();
  6177. foreach ($rk as $key=>$value)
  6178. {
  6179. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6180. }
  6181. if(count($wz) > 1)
  6182. {
  6183. $wz = array_values($wz);
  6184. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6185. }
  6186. **/
  6187. if (isset($rk[0]['purchase'])) {
  6188. $rk = $rk[0];
  6189. $j = 0;
  6190. $post['purchase'] = $rk['purchase'];
  6191. $post['warehouse'] = $rk['warehouse'];
  6192. $post['retreatwarehouse'] = $rk['warehouse'];
  6193. $post['sku'] = $rk['sku'];
  6194. $post['number'] = $rk['number'];
  6195. $post['features'] = $rk['features'];
  6196. $post['title'] = $rk['title'];
  6197. $post['enter'] = $time;
  6198. $post['time'] = $time;
  6199. $post['bs'] = 1;
  6200. $post['shop'] = $rk['shop'];
  6201. $post['details'] = $rk['details'];
  6202. $post['cpid'] = $rk['cpid'];
  6203. $post['cpbz'] = $rk['cpbz'];
  6204. $post['rktype'] = $rktype;
  6205. $warehouse = $this->warehouse->read($rk['warehouse']);
  6206. if ($warehouse['bdck'] == '') {
  6207. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6208. exit;
  6209. } else {
  6210. $bdck = $warehouse['bdck'];
  6211. }
  6212. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6213. if (isset($pdwz['details'])) {
  6214. if ($pdwz['details'] != $post['details']) {
  6215. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6216. }else{
  6217. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6218. exit;
  6219. }
  6220. }
  6221. }
  6222. $post['featurespp'] = $rk['featurespp'];
  6223. if ($post['warehouse'] == '5') {
  6224. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6225. if ($yza) {
  6226. if ($post['features'] != $yza[0]['features']) {
  6227. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6228. exit;
  6229. }
  6230. }
  6231. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6232. if ($yzb) {
  6233. if ($post['sku'] != $yzb[0]['sku']) {
  6234. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6235. exit;
  6236. }
  6237. }
  6238. }
  6239. for ($i = 0; $i < $num; $i++) {
  6240. $post['label'] = time() . rand(100, 999) . $i;
  6241. if ($this->$bdck->insert($post)) {
  6242. $j++;
  6243. }
  6244. }
  6245. /**
  6246. if($post['warehouse'] != 12)
  6247. {
  6248. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6249. }
  6250. **/
  6251. $this->whlabelscanlog->insert([
  6252. 'shop'=>$rk['shop'],
  6253. 'type'=>1,
  6254. 'purchase'=>$rk['purchase'],
  6255. 'sku'=>$rk['sku'],
  6256. 'features'=>$rk['features'],
  6257. 'title'=>$rk['title'],
  6258. 'label'=>$rk['label'],
  6259. 'warehouse'=>$rk['warehouse'],
  6260. 'wlid'=>$rk['id'],
  6261. 'num'=>$num,
  6262. 'addtime'=>time()
  6263. ]);
  6264. if ($j == $num) {
  6265. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6266. exit;
  6267. } else {
  6268. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6269. exit;
  6270. }
  6271. } else {
  6272. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6273. exit;
  6274. }
  6275. }
  6276. $this->_Template('whlabel_printrk', $this->data);
  6277. }
  6278. public function _printxzrk($arg_array)
  6279. {
  6280. $post = $this->input->post(NULL, TRUE);
  6281. if (isset($post['wzid'])) {
  6282. $time = time();
  6283. $id = $this->input->post('wzid', true);
  6284. //$post['shop'] = $this->input->post('shop',true);
  6285. $num = 1;
  6286. $rk = $this->whlabellabel->read($id);
  6287. if (isset($rk['purchase'])) {
  6288. $x = 0;
  6289. $post['purchase'] = $rk['purchase'];
  6290. $post['warehouse'] = $rk['warehouse'];
  6291. $post['retreatwarehouse'] = $rk['warehouse'];
  6292. $post['sku'] = $rk['sku'];
  6293. $post['number'] = $rk['number'];
  6294. $post['features'] = $rk['features'];
  6295. $post['title'] = $rk['title'];
  6296. $post['enter'] = $time;
  6297. $post['time'] = $time;
  6298. $post['bs'] = 1;
  6299. $post['shop'] = $rk['shop'];
  6300. $post['details'] = $rk['details'];
  6301. $post['cpid'] = $rk['cpid'];
  6302. $post['cpbz'] = $rk['cpbz'];
  6303. $warehouse = $this->warehouse->read($rk['warehouse']);
  6304. if ($warehouse['bdck'] == '') {
  6305. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6306. exit;
  6307. } else {
  6308. $bdck = $warehouse['bdck'];
  6309. }
  6310. $post['featurespp'] = $rk['featurespp'];
  6311. $this->db->trans_begin();
  6312. for ($i = 0; $i < $num; $i++) {
  6313. $post['label'] = time() . rand(100, 999) . $i;
  6314. $this->$bdck->insert($post);
  6315. }
  6316. /**
  6317. if($post['warehouse'] != 12)
  6318. {
  6319. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6320. }
  6321. **/
  6322. if ($this->db->trans_status() === TRUE) {
  6323. $this->db->trans_commit();
  6324. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6325. exit;
  6326. } else {
  6327. $this->db->trans_rollback();
  6328. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6329. exit;
  6330. }
  6331. } else {
  6332. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6333. exit;
  6334. }
  6335. }
  6336. }
  6337. public function _printck($arg_array)
  6338. {
  6339. $prc = array();
  6340. $purchase = $this->purchase->find_all();
  6341. foreach ($purchase as $k => $v) {
  6342. $prc[$v['id']] = $v['title'];
  6343. }
  6344. $post = $this->input->post(NULL, TRUE);
  6345. if (isset($post['page'])) {
  6346. $page = $this->input->post('page', true);
  6347. $perpage = $this->input->post('perpage', true);
  6348. $sku = $this->input->post('sku', true);
  6349. $bs = $this->input->post('bs', true);
  6350. $number = $this->input->post('number', true);
  6351. $warehouse = $this->input->post('warehouse', true);
  6352. $purchase = $this->input->post('purchase', true);
  6353. $orderinfo = $this->input->post('orderinfo', true);
  6354. $waybill = $this->input->post('waybill', true);
  6355. $category = $this->input->post('category', true);
  6356. $size = $this->input->post('size', true);
  6357. $grade = $this->input->post('grade', true);
  6358. $color = $this->input->post('color', true);
  6359. $lowe = $this->input->post('lowe', true);
  6360. $state = $this->input->post('state', true);
  6361. $label = $this->input->post('label', true);
  6362. $timetk = $this->input->post('ktime', true);
  6363. $timetj = $this->input->post('jtime', true);
  6364. $timetk = strtotime($timetk);
  6365. $timetj = strtotime($timetj);
  6366. $where = "state=1 ";
  6367. if ($timetk && $timetj) {
  6368. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6369. }
  6370. if ($sku) {
  6371. $where .= " and sku = '$sku'";
  6372. }
  6373. if ($bs != '') {
  6374. $where .= " and bs = '$bs'";
  6375. }
  6376. if ($number) {
  6377. $where .= " and number = '$number'";
  6378. }
  6379. if ($warehouse) {
  6380. $where .= " and warehouse = '$warehouse'";
  6381. }
  6382. if ($purchase) {
  6383. $where .= " and purchase = '$purchase'";
  6384. }
  6385. if ($orderinfo) {
  6386. $where .= " and orderinfo = '$orderinfo'";
  6387. }
  6388. if ($waybill) {
  6389. $where .= " and waybill = '$waybill'";
  6390. }
  6391. if ($category) {
  6392. $where .= " and features like '%-$category-%'";
  6393. }
  6394. if ($size) {
  6395. $where .= " and features like '%-$size-%'";
  6396. }
  6397. if ($grade) {
  6398. $where .= " and features like '%-$grade-%'";
  6399. }
  6400. if ($color) {
  6401. $where .= " and features like '%-$color-%'";
  6402. }
  6403. if ($lowe) {
  6404. $where .= " and features like '%-$lowe-%'";
  6405. }
  6406. if ($label) {
  6407. $where .= " and label = '$label'";
  6408. }
  6409. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6410. //数据排序
  6411. $order_str = "outk desc";
  6412. if (empty($page)) {
  6413. $start = 0;
  6414. $perpage = 1;
  6415. } else {
  6416. $start = ($page - 1) * $perpage;
  6417. }
  6418. //取得信息列表
  6419. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6420. foreach ($info_list as $key => $value) {
  6421. $warehouse = $this->warehouse->read($value['warehouse']);
  6422. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6423. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6424. if ($value['state'] == 0) {
  6425. $info_list[$key]['state'] = "在库";
  6426. } else if ($value['state'] == 1) {
  6427. $info_list[$key]['state'] = "出库";
  6428. } else if ($value['state'] == 2) {
  6429. $info_list[$key]['state'] = "退库";
  6430. } else if ($value['state'] == 3) {
  6431. $info_list[$key]['state'] = "调拨中";
  6432. } else if ($value['state'] == 4) {
  6433. $info_list[$key]['state'] = "再加工";
  6434. } else if ($value['state'] == 5) {
  6435. $info_list[$key]['state'] = "维修中";
  6436. } else if ($value['state'] == 6) {
  6437. $info_list[$key]['state'] = "盘亏";
  6438. } else if ($value['state'] == 7) {
  6439. $info_list[$key]['state'] = "更换标签";
  6440. } else if ($value['state'] == 8) {
  6441. $info_list[$key]['state'] = "其它";
  6442. } else if ($value['state'] == 9) {
  6443. $info_list[$key]['state'] = "预设";
  6444. } else if ($value['state'] == 10) {
  6445. $info_list[$key]['state'] = "美店零售";
  6446. }
  6447. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6448. }
  6449. $total = $this->$ck->find_count($where);
  6450. $pagenum = ceil($total / $perpage);
  6451. $over = $total - ($start + $perpage);
  6452. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6453. echo json_encode($rows);
  6454. exit;
  6455. }
  6456. if (isset($post['tmsku'])) {
  6457. $time = time();
  6458. $tmsku = $this->input->post('tmsku', true);
  6459. //$post['shop'] = $this->input->post('shop',true);
  6460. $num = $this->input->post('num', true);
  6461. $cktype = $this->input->post('cktype', true);
  6462. $label = $this->whlabellabel->get_label($tmsku);
  6463. if (!$cktype) {
  6464. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6465. }
  6466. if (!isset($label['warehouse'])) {
  6467. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6468. exit;
  6469. }
  6470. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6471. if (stripos($label['features'], '-126-') !== false) {
  6472. $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 )");
  6473. } else {
  6474. $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 ) ");
  6475. }
  6476. $j = 0;
  6477. if (count($ck) >= $num) {
  6478. for ($i = 0; $i < $num; $i++) {
  6479. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6480. {
  6481. $j++;
  6482. }
  6483. }
  6484. $this->whlabelscanlog->insert([
  6485. 'shop'=>$label['shop'],
  6486. 'type'=>2,
  6487. 'purchase'=>$label['purchase'],
  6488. 'sku'=>$label['sku'],
  6489. 'features'=>$label['features'],
  6490. 'title'=>$label['title'],
  6491. 'label'=>$label['label'],
  6492. 'warehouse'=>$label['warehouse'],
  6493. 'wlid'=>$label['id'],
  6494. 'num'=>$num,
  6495. 'addtime'=>time()
  6496. ]);
  6497. if ($j == $num) {
  6498. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6499. exit;
  6500. } else {
  6501. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6502. exit;
  6503. }
  6504. } else {
  6505. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6506. exit;
  6507. }
  6508. }
  6509. if(isset($_SESSION['api']))
  6510. {
  6511. $user = $this->user->get_api($_SESSION['api']);
  6512. if(in_array($user['power'],[1,27])){
  6513. $vip = 1;
  6514. }
  6515. }
  6516. else
  6517. {
  6518. $vip = 0;
  6519. header('Location: /');exit;
  6520. }
  6521. $this->data['vip'] = $vip;
  6522. $this->_Template('whlabel_printck', $this->data);
  6523. }
  6524. public function _printexcel()
  6525. {
  6526. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6527. $config['upload_path'] = '.' . $dir;
  6528. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6529. $config['allowed_types'] = 'xls|xlsx|csv';
  6530. $config['max_size'] = 10240;
  6531. $this->load->library('upload', $config);
  6532. $this->upload->initialize($config);
  6533. if ($this->upload->do_upload('userfile')) {
  6534. $full_path = $dir . $this->upload->data('file_name');
  6535. $fileName = '.' . $full_path;
  6536. if (!file_exists($fileName)) {
  6537. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6538. exit;
  6539. } else {
  6540. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6541. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6542. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6543. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6544. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6545. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6546. ++$column; //如果列数大于26行
  6547. $list = array();
  6548. for ($i = 2; $i <= $row; $i++) // 行数循环
  6549. {
  6550. $data = array();
  6551. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6552. {
  6553. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6554. }
  6555. $list[] = $data;
  6556. }
  6557. }
  6558. $ed = array();
  6559. $i = 0;
  6560. $j = 0;
  6561. $dcdata = array();
  6562. $yc = '';
  6563. $cmf_arr = array_column($list, '1');
  6564. array_multisort($cmf_arr, SORT_ASC, $list);
  6565. foreach ($list as $key => $value) {
  6566. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6567. if ($typeclass) {
  6568. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6569. } else {
  6570. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6571. $i++;
  6572. continue;
  6573. }
  6574. }
  6575. if ($i > 0) {
  6576. $yc = $i . '条异常';
  6577. }
  6578. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6579. exit;
  6580. }
  6581. }
  6582. public function _uck()
  6583. {
  6584. if (isset($_GET['excel'])) {
  6585. $tc = array();
  6586. $typeclass = $this->typeclass->find_all();
  6587. foreach ($typeclass as $v) {
  6588. $tc[$v['id']] = $v['zh'];
  6589. }
  6590. $data = array();
  6591. $t = array();
  6592. $rq = '';
  6593. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6594. $ts = $ts / (24 * 3600);
  6595. for ($i = 0; $i < $ts; $i++) {
  6596. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6597. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6598. }
  6599. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6600. foreach ($info_list as $k => $v) {
  6601. $features = explode('-', trim($v['features'], '-'));
  6602. if (!isset($features[3]) || !isset($features[4])) {
  6603. continue;
  6604. }
  6605. $data[$k][0] = $tc[$features[0]]; //类型
  6606. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6607. $data[$k][2] = $tc[$features[4]]; //曲度
  6608. $data[$k][3] = '';
  6609. if (isset($data[$k][1])) {
  6610. $data[$k][3] .= $data[$k][1];
  6611. }
  6612. if (isset($data[$k][2])) {
  6613. $data[$k][3] .= $data[$k][2];
  6614. }
  6615. if (isset($features[5])) {
  6616. $data[$k][3] .= $tc[$features[5]];
  6617. }
  6618. if (isset($features[2])) {
  6619. $data[$k][3] .= $tc[$features[2]];
  6620. }
  6621. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6622. $data[$k][4] = $v['sku'];
  6623. $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())) . '))'); //月初库存
  6624. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6625. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6626. $ztrq = '';
  6627. $ztsl = '';
  6628. if (count($zt) > 0) {
  6629. foreach ($zt as $vv) {
  6630. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6631. $ztsl .= $vv['num'] . '<br>';
  6632. }
  6633. }
  6634. $data[$k][] = trim($ztsl, '<br>');
  6635. $data[$k][] = trim($ztrq, '<br>');
  6636. $byck = 0;
  6637. foreach ($t as $vv) {
  6638. $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));
  6639. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6640. $byck += $sl;
  6641. }
  6642. $data[$k][] = ($byck > 0) ? $byck : '';
  6643. }
  6644. $title = "详情 " . date("Y-m-d", time());
  6645. $titlename = "<table border=1>
  6646. <tr align='center'>
  6647. <td>类别</td>
  6648. <td>颜色</td>
  6649. <td>曲度</td>
  6650. <td>名称</td>
  6651. <td>SKU</td>
  6652. <td>月初库存</td>
  6653. <td>剩余库存</td>
  6654. <td>在途数量</td>
  6655. <td>预达日期</td>" .
  6656. $rq
  6657. . "<td>本月出库</td></tr>
  6658. </table>";
  6659. $filename = $title . ".xls";
  6660. $tail = "";
  6661. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  6662. }
  6663. }
  6664. public function _whlabelexcelzh()
  6665. {
  6666. if (isset($_GET['excel'])) {
  6667. $where = "sku != 'Preset'";
  6668. //数据排序
  6669. $order_str = "id desc";
  6670. if (empty($page)) {
  6671. $start = 0;
  6672. $perpage = 1;
  6673. } else {
  6674. $start = ($page - 1) * $perpage;
  6675. }
  6676. $category = $this->input->get('category', true);
  6677. $warehouse = $this->input->get('warehouse', true);
  6678. $excelid = $this->input->get('sid', true);
  6679. if ($category) {
  6680. $where .= " and features like '%-$category-%'";
  6681. }
  6682. if ($warehouse) {
  6683. $where .= " and warehouse = '$warehouse'";
  6684. }
  6685. $xzid = '';
  6686. if ($excelid) {
  6687. $excelid = explode(',', trim($excelid, ','));
  6688. foreach ($excelid as $key => $value) {
  6689. $xzid .= " id = " . $value . " or";
  6690. }
  6691. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6692. }
  6693. //取得信息列表
  6694. /**
  6695. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6696. $rows = array();$list = array();
  6697. foreach ($info_list as $key=>$value)
  6698. {
  6699. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6700. }
  6701. **/
  6702. $list = array();
  6703. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6704. foreach ($rows as $key => $value) {
  6705. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6706. $zh = '';
  6707. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6708. foreach ($zt as $v) {
  6709. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6710. }
  6711. $zt = array_sum(array_column($zt, 'num'));
  6712. $number = $value['number'];
  6713. $ftime = time() - 15 * 24 * 3600;
  6714. $warehouse = $this->warehouse->read($value['warehouse']);
  6715. $rows[$key]['warehouse'] = $warehouse['title'];
  6716. $rows[$key]['number'] = $c;
  6717. $rows[$key]['features'] = $zh;
  6718. $rows[$key]['hb'] = $c + $zt;
  6719. }
  6720. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6721. $titlename = "<table border=1>
  6722. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6723. <tr align='center'>
  6724. <td>仓库</td>
  6725. <td>SKU</td>
  6726. <td>产品</td>
  6727. <td>库存数量</td>
  6728. <td>在途数量及预达日期</td>
  6729. <td>在途+库存数量</td>
  6730. </tr>
  6731. </table>";
  6732. $filename = $title . ".xls";
  6733. $tail = "";
  6734. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6735. }
  6736. if (isset($_GET['excel'])) {
  6737. $warehouse = $this->input->get('warehouse', true);
  6738. $sku = $this->input->get('sku', true);
  6739. $cz = $this->input->get('cz', true);
  6740. $text = $this->input->post('text', true);
  6741. $xztime = $this->input->get('xztime', true);
  6742. $timetk = $this->input->get('timetk', true);
  6743. $timetj = $this->input->get('timetj', true);
  6744. $timetk = strtotime($timetk);
  6745. $timetj = strtotime($timetj);
  6746. $where = "time = '0' ";
  6747. if ($warehouse) {
  6748. $where .= " and warehouse = '$warehouse'";
  6749. }
  6750. if ($sku) {
  6751. $where .= " and sku = '$sku'";
  6752. }
  6753. if ($text) {
  6754. $where .= " and text like '%$text%'";
  6755. }
  6756. if ($cz != '') {
  6757. $where .= " and cz = '$cz'";
  6758. }
  6759. if ($timetk && $timetj) {
  6760. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6761. }
  6762. //数据排序
  6763. $order_str = $xztime . " desc";
  6764. //取得信息列表
  6765. $zh = array();
  6766. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6767. foreach ($info_list as $v) {
  6768. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6769. $warehouse = $this->warehouse->read($v['warehouse']);
  6770. $v['warehouse'] = $warehouse['title'];
  6771. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6772. $v['stime'] = date('Y-m-d', $v['stime']);
  6773. if (isset($zh[$v['features']])) {
  6774. $zh[$v['features']]['num'] += $v['num'];
  6775. } else {
  6776. $zh[$v['features']] = $v;
  6777. }
  6778. $zh[$v['features']]['features'] = $c;
  6779. }
  6780. $title = "在途数据" . date('Y-m-d', time());
  6781. $titlename = "<table border=1>
  6782. <tr align='center'>
  6783. <td>仓库</td>
  6784. <td>SKU</td>
  6785. <td>名称</td>
  6786. <td>在途数量</td>
  6787. <td>库存数量</td>
  6788. <td>添加在途日期</td>
  6789. <td>预达日期</td>
  6790. <td>备注</td>
  6791. </tr>
  6792. </table>";
  6793. $filename = $title . ".xls";
  6794. $tail = "";
  6795. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6796. }
  6797. }
  6798. public function _fc()
  6799. {
  6800. $vip = 0;
  6801. if (isset($_SESSION['api'])) {
  6802. $user = $this->user->get_api($_SESSION['api']);
  6803. if ($user['vip'] == 1) {
  6804. $vip = 1;
  6805. }
  6806. } else {
  6807. header('Location: /');
  6808. exit;
  6809. }
  6810. $post = $this->input->post(NULL, TRUE);
  6811. if (isset($post['page'])) {
  6812. $page = $this->input->post('page', true);
  6813. $perpage = $this->input->post('perpage', true);
  6814. $category = $this->input->post('category', true);
  6815. $size = $this->input->post('size', true);
  6816. $grade = $this->input->post('grade', true);
  6817. $color = $this->input->post('color', true);
  6818. $lowe = $this->input->post('lowe', true);
  6819. $sku = $this->input->post('sku');
  6820. $title = $this->input->post('title');
  6821. $warehouse = $this->input->post('warehouse', true);
  6822. $usa = $this->input->post('usa', true);
  6823. $purchase = $this->input->post('purchase', true);
  6824. $lacetype = $this->input->post('lacetype', true);
  6825. $haircap = $this->input->post('haircap', true);
  6826. $density = $this->input->post('density', true);
  6827. $details = $this->input->post('details', true);
  6828. $state = $this->input->post('state', true);
  6829. $ktime = $this->input->post('ktime', true);
  6830. $jtime = $this->input->post('jtime', true);
  6831. $ktime = strtotime($ktime);
  6832. $jtime = strtotime($jtime);
  6833. $where = "state = '11'";
  6834. $gj = "";
  6835. $ck = "";
  6836. if ($lacetype) {
  6837. $where .= " and features like '%-$lacetype-%'";
  6838. }
  6839. if ($category) {
  6840. $where .= " and features like '%-$category-%'";
  6841. }
  6842. if ($size) {
  6843. $where .= " and features like '%-$size-%'";
  6844. }
  6845. if ($grade) {
  6846. $where .= " and features like '%-$grade-%'";
  6847. }
  6848. if ($color) {
  6849. $where .= " and features like '%-$color-%'";
  6850. }
  6851. if ($lowe) {
  6852. $where .= " and features like '%-$lowe-%'";
  6853. }
  6854. if ($haircap) {
  6855. $where .= " and features like '%-$haircap-%'";
  6856. }
  6857. if ($density) {
  6858. $where .= " and features like '%-$density-%'";
  6859. }
  6860. if ($usa) {
  6861. if (!$warehouse) {
  6862. $where .= " and (warehouse = '5' or warehouse = '8')";
  6863. }
  6864. }
  6865. if ($warehouse) {
  6866. $where .= " and warehouse = '$warehouse'";
  6867. }
  6868. if ($details) {
  6869. $where .= " and details = '$details'";
  6870. }
  6871. if ($purchase) {
  6872. $where .= " and purchase = '$purchase'";
  6873. }
  6874. if ($state) {
  6875. $where .= " and state = '$state'";
  6876. }
  6877. if ($ktime && $jtime) {
  6878. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6879. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6880. }
  6881. //数据排序
  6882. $order_str = "id desc";
  6883. if (empty($page)) {
  6884. $start = 0;
  6885. $perpage = 1;
  6886. } else {
  6887. $start = ($page - 1) * $perpage;
  6888. }
  6889. if ($sku) {
  6890. $sku = trim($sku, ' ');
  6891. $sku = trim($sku, ' ');
  6892. $where .= " and sku like '%$sku%'";
  6893. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6894. } else if ($title) {
  6895. $title = trim($title, ' ');
  6896. $title = trim($title, ' ');
  6897. $where .= " and title like '%$title%'";
  6898. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6899. } else {
  6900. //$where .= " and time > '$ktime' and time < '$jtime'";
  6901. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6902. }
  6903. //取得信息列表
  6904. $rows = array();
  6905. $list = array();
  6906. foreach ($info_list as $key => $value) {
  6907. $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'] . '"');
  6908. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6909. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6910. $warehouse = $this->warehouse->read($value['warehouse']);
  6911. $info_list[$key]['warehouse'] = $warehouse['title'];
  6912. $info_list[$key]['number'] = $g;
  6913. $info_list[$key]['features'] = $x;
  6914. $info_list[$key]['x'] = $s;
  6915. }
  6916. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6917. $pagenum = ceil($total / $perpage);
  6918. $over = $total - ($start + $perpage);
  6919. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6920. echo json_encode($rows);
  6921. exit;
  6922. }
  6923. $this->data['vip'] = $vip;
  6924. $this->_Template('whlabel_fc', $this->data);
  6925. }
  6926. public function _fcmb()
  6927. {
  6928. $where = "sku != 'Preset'";
  6929. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6930. foreach ($rows as $k => $v) {
  6931. $warehouse = $this->warehouse->read($v['warehouse']);
  6932. $rows[$k]['warehouse'] = $warehouse['title'];
  6933. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6934. $rows[$k]['t'] = '';
  6935. $rows[$k]['n'] = '';
  6936. }
  6937. $title = "封货产品数据导入模板";
  6938. $titlename = "<table border=1>
  6939. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6940. <tr align='center'>
  6941. <td>仓库</td>
  6942. <td>SKU</td>
  6943. <td>产品</td>
  6944. <td>封存产品总数量</td>
  6945. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6946. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6947. </tr>
  6948. </table>";
  6949. $filename = $title . ".xls";
  6950. $tail = "";
  6951. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6952. }
  6953. public function _fcexcel()
  6954. {
  6955. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6956. $config['upload_path'] = '.' . $dir;
  6957. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6958. $config['allowed_types'] = 'xls|xlsx|csv';
  6959. $config['max_size'] = 10240;
  6960. $this->load->library('upload', $config);
  6961. $this->upload->initialize($config);
  6962. if ($this->upload->do_upload('userfile')) {
  6963. $full_path = $dir . $this->upload->data('file_name');
  6964. $fileName = '.' . $full_path;
  6965. if (!file_exists($fileName)) {
  6966. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6967. exit;
  6968. } else {
  6969. libxml_use_internal_errors(true);
  6970. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6971. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6972. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6973. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6974. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6975. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6976. ++$column; //如果列数大于26行
  6977. $list = array();
  6978. for ($i = 2; $i <= $row; $i++) // 行数循环
  6979. {
  6980. $data = array();
  6981. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6982. {
  6983. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6984. }
  6985. $list[] = $data;
  6986. }
  6987. }
  6988. $i = 0;
  6989. $j = 0;
  6990. $ed = array();
  6991. foreach ($list as $key => $value) {
  6992. $time = time();
  6993. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6994. continue;
  6995. }
  6996. $warehouse = $this->warehouse->get_title($value['0']);
  6997. $sku = $value['1'];
  6998. $type = $value['4']; //调整方式0扣减1删除
  6999. $num = $value['5']; //调整数量
  7000. //$text = $value['4'];//扣减说明
  7001. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7002. if (!$d) //如果没有这个SKU
  7003. {
  7004. $ed[] = array($sku . '-库存中不存在此SKU');
  7005. $j++;
  7006. continue;
  7007. }
  7008. if (!isset($warehouse['id'])) {
  7009. $ed[] = array($sku . '-仓库名错误!');
  7010. $j++;
  7011. continue;
  7012. }
  7013. if ($type == 1 || $type == 2) //扣减库存
  7014. {
  7015. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7016. if (count($data) < abs($num)) {
  7017. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7018. $j++;
  7019. continue;
  7020. }
  7021. if ($type == 1) //转入库存
  7022. {
  7023. for ($i = 0; $i < abs($num); $i++) {
  7024. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7025. }
  7026. } else if ($type == 2) //删除
  7027. {
  7028. for ($i = 0; $i < abs($num); $i++) {
  7029. $this->whlabel->remove($data[$i]['id']);
  7030. }
  7031. }
  7032. } else if ($type == 0) //增加库存
  7033. {
  7034. $post['sku'] = $d['sku'];
  7035. $post['shop'] = '';
  7036. $post['warehouse'] = $warehouse['id'];
  7037. $post['purchase'] = $d['purchase'];
  7038. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7039. $post['state'] = 11;
  7040. $post['title'] = $d['title'];
  7041. $post['number'] = $d['number'];
  7042. $post['features'] = $d['features'];
  7043. $post['enter'] = $time;
  7044. $post['time'] = $time; //操作时间
  7045. for ($i = 0; $i < $num; $i++) {
  7046. $post['label'] = time() . rand(100, 999) . $i;
  7047. $this->whlabel->insert($post);
  7048. }
  7049. }
  7050. sleep(1); //防止入库时间一样,需要延迟1秒
  7051. }
  7052. if ($j > 0) {
  7053. $tt = date('Ymd', time());
  7054. $title = '库存导入错误信息-' . $tt;
  7055. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7056. $tail = "\n";
  7057. $filename = $title . ".xls";
  7058. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7059. $dir = '/data/excel/' . $time . '/';
  7060. $file_name = 'error_' . $time . rand(1000, 9999);
  7061. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7062. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7063. fwrite($myfile, $ecl);
  7064. fclose($myfile);
  7065. $error = $dir . $file_name . '.xls';
  7066. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7067. exit;
  7068. } else {
  7069. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7070. exit;
  7071. }
  7072. }
  7073. }
  7074. public function _fcjxc($arg_array)
  7075. {
  7076. if (isset($_GET['excel'])) {
  7077. $category = $this->input->get('category', true);
  7078. $size = $this->input->get('size', true);
  7079. $grade = $this->input->get('grade', true);
  7080. $color = $this->input->get('color', true);
  7081. $lowe = $this->input->get('lowe', true);
  7082. $sku = $this->input->get('sku');
  7083. $title = $this->input->get('title');
  7084. $warehouse = $arg_array[0];
  7085. $usa = $this->input->get('usa', true);
  7086. $purchase = $this->input->get('purchase', true);
  7087. $lacetype = $this->input->get('lacetype', true);
  7088. $haircap = $this->input->get('haircap', true);
  7089. $density = $this->input->get('density', true);
  7090. $title = $this->input->get('title', true);
  7091. $state = $this->input->get('state', true);
  7092. $ktime = $this->input->get('ktime', true);
  7093. $jtime = $this->input->get('jtime', true);
  7094. $where = "state=11";
  7095. $gj = "";
  7096. $ck = "";
  7097. if ($lacetype) {
  7098. $where .= " and features like '%-$lacetype-%'";
  7099. }
  7100. if ($category) {
  7101. $where .= " and features like '%-$category-%'";
  7102. }
  7103. if ($size) {
  7104. $where .= " and features like '%-$size-%'";
  7105. }
  7106. if ($grade) {
  7107. $where .= " and features like '%-$grade-%'";
  7108. }
  7109. if ($color) {
  7110. $where .= " and features like '%-$color-%'";
  7111. }
  7112. if ($lowe) {
  7113. $where .= " and features like '%-$lowe-%'";
  7114. }
  7115. if ($haircap) {
  7116. $where .= " and features like '%-$haircap-%'";
  7117. }
  7118. if ($density) {
  7119. $where .= " and features like '%-$density-%'";
  7120. }
  7121. if ($usa) {
  7122. if (!$warehouse) {
  7123. $where .= " and (warehouse = '5' or warehouse = '8')";
  7124. }
  7125. }
  7126. if ($warehouse) {
  7127. $where .= " and warehouse = '$warehouse'";
  7128. }
  7129. if ($purchase) {
  7130. $where .= " and purchase = '$purchase'";
  7131. }
  7132. if ($state) {
  7133. $where .= " and state = '$state'";
  7134. }
  7135. $order_str = "id desc";
  7136. if ($sku) {
  7137. $sku = trim($sku, ' ');
  7138. $sku = trim($sku, ' ');
  7139. $where .= " and sku like '%$sku%'";
  7140. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7141. } else if ($title) {
  7142. $title = trim($title, ' ');
  7143. $title = trim($title, ' ');
  7144. $where .= " and title like '%$title%'";
  7145. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7146. } else {
  7147. //$where .= " and time > '$ktime' and time < '$jtime'";
  7148. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7149. }
  7150. //取得信息列表
  7151. $rows = array();
  7152. $list = array();
  7153. foreach ($info_list as $key => $value) {
  7154. $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'] . '"');
  7155. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7156. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7157. $rows[$key] = $value;
  7158. $warehouse = $this->warehouse->read($value['warehouse']);
  7159. $rows[$key]['warehouse'] = $warehouse['title'];
  7160. $rows[$key]['features'] = $g;
  7161. $rows[$key]['a'] = $x;
  7162. $rows[$key]['b'] = $s;
  7163. }
  7164. $title = "总统计表";
  7165. $titlename = "<table border=1>
  7166. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7167. <tr align='center'>
  7168. <td>仓库</td>
  7169. <td>SKU</td>
  7170. <td>产品名称</td>
  7171. <td>录入总量</td>
  7172. <td>取出总量</td>
  7173. <td>剩余总量</td>
  7174. </tr>
  7175. </table>";
  7176. $filename = $title . ".xls";
  7177. $tail = "";
  7178. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7179. }
  7180. $vip = 0;
  7181. if (isset($_SESSION['api'])) {
  7182. $user = $this->user->get_api($_SESSION['api']);
  7183. if ($user['vip'] == 1) {
  7184. $vip = 1;
  7185. }
  7186. } else {
  7187. header('Location: /');
  7188. exit;
  7189. }
  7190. $post = $this->input->post(NULL, TRUE);
  7191. if (isset($post['page'])) {
  7192. $page = $this->input->post('page', true);
  7193. $perpage = $this->input->post('perpage', true);
  7194. $category = $this->input->post('category', true);
  7195. $size = $this->input->post('size', true);
  7196. $grade = $this->input->post('grade', true);
  7197. $color = $this->input->post('color', true);
  7198. $lowe = $this->input->post('lowe', true);
  7199. $sku = $this->input->post('sku');
  7200. $title = $this->input->post('title');
  7201. $warehouse = $arg_array[0];
  7202. $usa = $this->input->post('usa', true);
  7203. $purchase = $this->input->post('purchase', true);
  7204. $lacetype = $this->input->post('lacetype', true);
  7205. $haircap = $this->input->post('haircap', true);
  7206. $density = $this->input->post('density', true);
  7207. $title = $this->input->post('title', true);
  7208. $state = $this->input->post('state', true);
  7209. $ktime = $this->input->post('ktime', true);
  7210. $jtime = $this->input->post('jtime', true);
  7211. $ktime = strtotime($ktime);
  7212. $jtime = strtotime($jtime);
  7213. $where = "state=11";
  7214. $gj = "";
  7215. $ck = "";
  7216. if ($lacetype) {
  7217. $where .= " and features like '%-$lacetype-%'";
  7218. }
  7219. if ($category) {
  7220. $where .= " and features like '%-$category-%'";
  7221. }
  7222. if ($size) {
  7223. $where .= " and features like '%-$size-%'";
  7224. }
  7225. if ($grade) {
  7226. $where .= " and features like '%-$grade-%'";
  7227. }
  7228. if ($color) {
  7229. $where .= " and features like '%-$color-%'";
  7230. }
  7231. if ($lowe) {
  7232. $where .= " and features like '%-$lowe-%'";
  7233. }
  7234. if ($haircap) {
  7235. $where .= " and features like '%-$haircap-%'";
  7236. }
  7237. if ($density) {
  7238. $where .= " and features like '%-$density-%'";
  7239. }
  7240. if ($usa) {
  7241. if (!$warehouse) {
  7242. $where .= " and (warehouse = '5' or warehouse = '8')";
  7243. }
  7244. }
  7245. if ($warehouse) {
  7246. $where .= " and warehouse = '$warehouse'";
  7247. }
  7248. if ($purchase) {
  7249. $where .= " and purchase = '$purchase'";
  7250. }
  7251. if ($state) {
  7252. $where .= " and state = '$state'";
  7253. }
  7254. if ($ktime && $jtime) {
  7255. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7256. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7257. }
  7258. //数据排序
  7259. $order_str = "id desc";
  7260. $xs = 0;
  7261. $rows = array();
  7262. $list = array();
  7263. if (empty($page)) {
  7264. $start = 0;
  7265. $perpage = 1;
  7266. } else {
  7267. $start = ($page - 1) * $perpage;
  7268. }
  7269. if ($sku || $title) {
  7270. if ($title) {
  7271. $title = trim($title, ' ');
  7272. $title = trim($title, ' ');
  7273. $where .= " and title like '%$title%'";
  7274. } else {
  7275. $sku = trim($sku, ' ');
  7276. $sku = trim($sku, ' ');
  7277. $where .= " and sku like '%$sku%'";
  7278. }
  7279. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7280. foreach ($info_list as $key => $value) {
  7281. $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'] . '"');
  7282. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7283. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7284. $rows[$key] = $value;
  7285. $warehouse = $this->warehouse->read($value['warehouse']);
  7286. $rows[$key]['warehouse'] = $warehouse['title'];
  7287. $rows[$key]['features'] = $g;
  7288. $rows[$key]['a'] = $x;
  7289. $rows[$key]['b'] = $s;
  7290. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7291. $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天销量
  7292. $yj = $c / ($xl / 30);
  7293. if ($yj < 7) {
  7294. $rows[$key]['y'] = round($yj) . '天销量';
  7295. } else {
  7296. $rows[$key]['y'] = '正常';
  7297. }
  7298. }
  7299. } else {
  7300. //$where .= " and time > '$ktime' and time < '$jtime'";
  7301. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7302. foreach ($info_list as $key => $value) {
  7303. $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'] . '"');
  7304. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7305. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7306. $zs[$key] = $value;
  7307. $warehouse = $this->warehouse->read($value['warehouse']);
  7308. $zs[$key]['warehouse'] = $warehouse['title'];
  7309. $zs[$key]['features'] = $g;
  7310. $zs[$key]['a'] = $x;
  7311. $zs[$key]['b'] = $s;
  7312. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7313. $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天销量
  7314. $yj = $c / ($xl / 30);
  7315. if ($yj < 7) {
  7316. $zs[$key]['y'] = round($yj) . '天销量';
  7317. $rows[$key] = $zs[$key];
  7318. }
  7319. }
  7320. }
  7321. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7322. $pagenum = ceil($total / $perpage);
  7323. $over = $total - ($start + $perpage);
  7324. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7325. echo json_encode($rows);
  7326. exit;
  7327. }
  7328. $this->data['arg_array'] = $arg_array[0];
  7329. $this->_Template('whlabel_fcjxc', $this->data);
  7330. }
  7331. public function _0kcdel()
  7332. {
  7333. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7334. $config['upload_path'] = '.' . $dir;
  7335. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7336. $config['allowed_types'] = 'xls|xlsx|csv';
  7337. $config['max_size'] = 10240;
  7338. $this->load->library('upload', $config);
  7339. $this->upload->initialize($config);
  7340. if ($this->upload->do_upload('userfile')) {
  7341. $full_path = $dir . $this->upload->data('file_name');
  7342. $fileName = '.' . $full_path;
  7343. if (!file_exists($fileName)) {
  7344. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7345. exit;
  7346. } else {
  7347. require_once "./data/excel/PHPExcel/IOFactory.php";
  7348. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7349. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7350. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7351. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7352. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7353. ++$column; //如果列数大于26行
  7354. $list = array();
  7355. for ($i = 2; $i <= $row; $i++) // 行数循环
  7356. {
  7357. $data = array();
  7358. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7359. {
  7360. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7361. }
  7362. $list[] = $data;
  7363. }
  7364. }
  7365. $i = 0;
  7366. $j = 0;
  7367. $ed = array();
  7368. foreach ($list as $key => $value) {
  7369. $time = time();
  7370. if ($value['0'] == "" || $value['1'] == "") {
  7371. continue;
  7372. }
  7373. $warehouse = $this->warehouse->get_title($value['0']);
  7374. $sku = $value['1'];
  7375. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7376. if (!$d) //如果没有这个SKU
  7377. {
  7378. $ed[] = array($sku . '-库存中不存在此SKU');
  7379. $j++;
  7380. continue;
  7381. }
  7382. if (!isset($warehouse['id'])) {
  7383. $ed[] = array($sku . '-仓库名错误!');
  7384. $j++;
  7385. continue;
  7386. }
  7387. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7388. if ($z < 1) {
  7389. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7390. foreach ($z as $v) {
  7391. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7392. if (count($zt) > 0) {
  7393. $ed[] = array($sku . '-有在途库存无法删除!');
  7394. $j++;
  7395. continue;
  7396. }
  7397. $this->whlabel->remove($v['id']);
  7398. }
  7399. } else {
  7400. $ed[] = array($sku . '-非0库存!');
  7401. $j++;
  7402. continue;
  7403. }
  7404. }
  7405. if ($j > 0) {
  7406. $tt = date('Ymd', time());
  7407. $title = '删除0库存错误信息-' . $tt;
  7408. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7409. $tail = "\n";
  7410. $filename = $title . ".xls";
  7411. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7412. $dir = '/data/excel/' . $time . '/';
  7413. $file_name = 'error_' . $time . rand(1000, 9999);
  7414. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7415. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7416. fwrite($myfile, $ecl);
  7417. fclose($myfile);
  7418. $error = $dir . $file_name . '.xls';
  7419. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7420. exit;
  7421. } else {
  7422. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7423. exit;
  7424. }
  7425. }
  7426. }
  7427. public function _gbhtype()
  7428. {
  7429. $post = $this->input->post(NULL, TRUE);
  7430. if (isset($post['s'])) {
  7431. $n = $this->input->post('n');
  7432. $d = $this->input->post('s');
  7433. if (!$d) {
  7434. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7435. exit;
  7436. }
  7437. $d = explode(',', trim($d, ','));
  7438. $t = $this->whlabel_type->read($n);
  7439. //循环删除记录
  7440. foreach ($d as $v) {
  7441. $u = $this->whlabel->read($v);
  7442. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7443. foreach ($data as $val) {
  7444. $this->whlabel->save(array('type' => $n), $val['id']);
  7445. }
  7446. }
  7447. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7448. }
  7449. }
  7450. //出库、退库导出
  7451. public function _dccrtype()
  7452. {
  7453. $classid = $this->classid->sku();
  7454. $pm = $classid;
  7455. $typeclass = array();
  7456. $tc = $this->typeclass->find_all();
  7457. foreach ($tc as $v) {
  7458. $typeclass[$v['id']] = $v;
  7459. }
  7460. $prc = array();
  7461. $purchase = $this->purchase->find_all();
  7462. foreach ($purchase as $k => $v) {
  7463. $prc[$v['id']] = $v['title'];
  7464. }
  7465. if (isset($_GET['sid'])) {
  7466. $wh = array();
  7467. $w = $this->warehouse->find_all('1=1', 'id,title');
  7468. foreach ($w as $v) {
  7469. $wh[$v['id']] = $v['title'];
  7470. }
  7471. $type = $this->input->get('excel', true);
  7472. $category = $this->input->get('category', true);
  7473. $size = $this->input->get('size', true);
  7474. $grade = $this->input->get('grade', true);
  7475. $color = $this->input->get('color', true);
  7476. $lowe = $this->input->get('lowe', true);
  7477. $sku = $this->input->get('sku', true);
  7478. $warehouse = $this->input->get('warehouse', true);
  7479. $lacetype = $this->input->get('lacetype', true);
  7480. $lacecolor = $this->input->get('lacecolor', true);
  7481. $density = $this->input->get('density', true);
  7482. $haircap = $this->input->get('haircap', true);
  7483. $purchase = $this->input->get('purchase', true);
  7484. $title = $this->input->get('title', true);
  7485. $state = $this->input->get('state', true);
  7486. $sid = $this->input->get('sid', true);
  7487. $ktime = $this->input->get('ktime', true);
  7488. $jtime = $this->input->get('jtime', true);
  7489. $ktime = strtotime($ktime);
  7490. $jtime = strtotime($jtime);
  7491. $where = "1=1";
  7492. $gj = "";
  7493. $ck = "";
  7494. if ($category) {
  7495. $where .= " and features like '%-$category-%'";
  7496. }
  7497. if ($size) {
  7498. $where .= " and features like '%-$size-%'";
  7499. }
  7500. if ($grade) {
  7501. $where .= " and features like '%-$grade-%'";
  7502. }
  7503. if ($color) {
  7504. $where .= " and features like '%-$color-%'";
  7505. }
  7506. if ($lowe) {
  7507. $where .= " and features like '%-$lowe-%'";
  7508. }
  7509. if ($warehouse) {
  7510. $where .= " and warehouse = '$warehouse'";
  7511. }
  7512. if ($purchase) {
  7513. $where .= " and purchase = '$purchase'";
  7514. }
  7515. if ($state) {
  7516. $where .= " and state = '$state'";
  7517. }
  7518. if ($lacetype) {
  7519. $where .= " and features like '%-$lacetype-%'";
  7520. }
  7521. if ($lacecolor) {
  7522. $where .= " and features like '%-$lacecolor-%'";
  7523. }
  7524. if ($density) {
  7525. $where .= " and features like '%-$density-%'";
  7526. }
  7527. if ($haircap) {
  7528. $where .= " and features like '%-$haircap-%'";
  7529. }
  7530. if ($title) {
  7531. $title = trim($title, ' ');
  7532. $title = trim($title, ' ');
  7533. $where .= " and title like '%$title%'";
  7534. }
  7535. if ($sku) {
  7536. $sku = trim($sku, ' ');
  7537. $sku = trim($sku, ' ');
  7538. $where .= " and sku like '%$sku%'";
  7539. }
  7540. if ($ktime && $jtime) {
  7541. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7542. }
  7543. $sidwhere = '';
  7544. if ($sid) {
  7545. $sd = "";
  7546. $s = explode(',', trim($sid, ','));
  7547. foreach ($s as $value) {
  7548. $sd .= " id = " . $value . " or";
  7549. }
  7550. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7551. }
  7552. //数据排序
  7553. $order_str = "time desc";
  7554. if (empty($page)) {
  7555. $start = 0;
  7556. $perpage = 1;
  7557. } else {
  7558. $start = ($page - 1) * $perpage;
  7559. }
  7560. $wh = array();
  7561. $w = $this->warehouse->find_all('1=1', 'id,title');
  7562. foreach ($w as $v) {
  7563. $wh[$v['id']] = $v['title'];
  7564. }
  7565. $wt = array();
  7566. $whlabel_type = $this->whlabel_type->find_all();
  7567. foreach ($whlabel_type as $v) {
  7568. $wt[$v['id']] = $v['title'];
  7569. }
  7570. $classid = $this->classid->sku();
  7571. $list = array();
  7572. $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');
  7573. foreach ($rows_r as $key => $value) {
  7574. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7575. $pm = $classid;
  7576. $jm = $classid;
  7577. $rows_r[$key]['enter'] = '入库';
  7578. $rows_r[$key]['time'] = $value['enter'];
  7579. if ($value['rktype'] == 1) {
  7580. $rows_r[$key]['rktype'] = '采购入库';
  7581. } else if ($value['rktype'] == 2) {
  7582. $rows_r[$key]['rktype'] = '盘盈调整';
  7583. } else if ($value['rktype'] == 3) {
  7584. $rows_r[$key]['rktype'] = '其他调整入库';
  7585. } else if ($value['rktype'] == 4) {
  7586. $rows_r[$key]['rktype'] = '其他调整入库';
  7587. } else if ($value['rktype'] == 5) {
  7588. $rows_r[$key]['rktype'] = '退库入库';
  7589. } else if ($value['rktype'] == 6) {
  7590. $rows_r[$key]['rktype'] = '退货可用入库';
  7591. } else if ($value['rktype'] == 7) {
  7592. $rows_r[$key]['rktype'] = '形态转换入库';
  7593. } else {
  7594. $rows_r[$key]['rktype'] = '';
  7595. }
  7596. $features = explode('-', trim($value['features'], '-'));
  7597. foreach ($features as $v) {
  7598. if (isset($typeclass[$v])) {
  7599. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7600. $pm[$typeclass[$v]['classid']] = $zh[0];
  7601. }
  7602. if (isset($typeclass[$v])) {
  7603. if (isset($jm[$typeclass[$v]['classid']])) {
  7604. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7605. }
  7606. }
  7607. }
  7608. $zh = implode(" ", $pm);
  7609. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7610. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7611. $rows_r[$key]['zh'] = $zh;
  7612. $jm = array_filter($jm);
  7613. $rows_r[$key]['features'] = implode("-", $jm);
  7614. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7615. }
  7616. $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');
  7617. foreach ($rows_c as $key => $value) {
  7618. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7619. $pm = $classid;
  7620. $jm = $classid;
  7621. $rows_c[$key]['time'] = $value['outk'];
  7622. $rows_c[$key]['outk'] = '出库';
  7623. if ($value['cktype'] == 1) {
  7624. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7625. } else if ($value['cktype'] == 2) {
  7626. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7627. } else if ($value['cktype'] == 3) {
  7628. $rows_c[$key]['cktype'] = '盘亏调整';
  7629. } else if ($value['cktype'] == 4) {
  7630. $rows_c[$key]['cktype'] = '其他调整出库';
  7631. } else if ($value['cktype'] == 5) {
  7632. $rows_c[$key]['cktype'] = '形态转换出库';
  7633. } else {
  7634. $rows_c[$key]['cktype'] = '';
  7635. }
  7636. unset($rows_c[$key]['state']);
  7637. $features = explode('-', trim($value['features'], '-'));
  7638. foreach ($features as $v) {
  7639. if (isset($typeclass[$v])) {
  7640. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7641. $pm[$typeclass[$v]['classid']] = $zh[0];
  7642. }
  7643. if (isset($typeclass[$v])) {
  7644. if (isset($jm[$typeclass[$v]['classid']])) {
  7645. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7646. }
  7647. }
  7648. }
  7649. $zh = implode(" ", $pm);
  7650. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7651. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7652. $rows_c[$key]['zh'] = $zh;
  7653. $jm = array_filter($jm);
  7654. $rows_c[$key]['features'] = implode("-", $jm);
  7655. $rows_c[$key]['number'] = 1;
  7656. }
  7657. $merged = $rows_r;
  7658. foreach ($rows_c as $key => $value) {
  7659. if (isset($merged[$key])) {
  7660. $merged[] = $value;
  7661. } else {
  7662. $merged[$key] = $value;
  7663. }
  7664. }
  7665. usort($merged, function ($a, $b) {
  7666. return $a['time'] - $b['time'];
  7667. });
  7668. foreach ($merged as $key => $value) {
  7669. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7670. }
  7671. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7672. $titlename = "<table border=1>
  7673. <tr align='center'>
  7674. <td>仓库</td>
  7675. <td>SKU</td>
  7676. <td>商品名称</td>
  7677. <td>仓库品名</td>
  7678. <td>料号</td>
  7679. <td>时间</td>
  7680. <td>操作</td>
  7681. <td>类型</td>
  7682. <td>数量</td>
  7683. <td>备注</td>
  7684. </tr>
  7685. </table>";
  7686. $filename = $title . ".xlsx";
  7687. $tail = "";
  7688. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  7689. }
  7690. }
  7691. /*************************************处理exceljs导出****************************************************/
  7692. public function _excelrjs(){
  7693. if (isset($_GET['excel'])) {
  7694. $category = $this->input->get('category', true);
  7695. $size = $this->input->get('size', true);
  7696. $grade = $this->input->get('grade', true);
  7697. $color = $this->input->get('color', true);
  7698. $lowe = $this->input->get('lowe', true);
  7699. $sku = $this->input->get('sku', true);
  7700. $warehouse = $this->input->get('warehouse', true);
  7701. $purchase = $this->input->get('purchase', true);
  7702. $ktime = $this->input->get('ktime', true);
  7703. $jtime = $this->input->get('jtime', true);
  7704. $ktime = strtotime($ktime);
  7705. $jtime = strtotime($jtime);
  7706. $where = "1=1";
  7707. $gj = "";
  7708. $ck = "";
  7709. if ($category) {
  7710. $where .= " and features like '%-$category-%'";
  7711. }
  7712. if ($size) {
  7713. $where .= " and features like '%-$size-%'";
  7714. }
  7715. if ($grade) {
  7716. $where .= " and features like '%-$grade-%'";
  7717. }
  7718. if ($color) {
  7719. $where .= " and features like '%-$color-%'";
  7720. }
  7721. if ($lowe) {
  7722. $where .= " and features like '%-$lowe-%'";
  7723. }
  7724. if ($warehouse) {
  7725. $where .= " and warehouse = '$warehouse'";
  7726. }
  7727. if ($purchase) {
  7728. $where .= " and purchase = '$purchase'";
  7729. }
  7730. if ($sku) {
  7731. $where .= " and sku = '$sku'";
  7732. }
  7733. if ($ktime && $jtime) {
  7734. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7735. }
  7736. //数据排序
  7737. $order_str = "id desc";
  7738. if (empty($page)) {
  7739. $start = 0;
  7740. $perpage = 1;
  7741. } else {
  7742. $start = ($page - 1) * $perpage;
  7743. }
  7744. $list = array();
  7745. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7746. foreach ($rows as $value) {
  7747. $ck = $this->warehouse->read($value['warehouse']);
  7748. $warehouse = $ck['title'];
  7749. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7750. $retreatwarehouse = $tkck['title'];
  7751. $gy = $this->purchase->read($value['purchase']);
  7752. $purchase = $gy['title'];
  7753. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7754. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7755. }
  7756. if(empty($list)){
  7757. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7758. }else{
  7759. $final_list = [];
  7760. foreach($list as $v){
  7761. $final_list[] = array_values($v);
  7762. }
  7763. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7764. array_unshift($final_list,[
  7765. "仓库","SKU","商品名称","时间","数量"
  7766. ]);
  7767. array_unshift($final_list,[
  7768. $title,"","","",""
  7769. ]);
  7770. $merges = [
  7771. [
  7772. "s"=>["r"=>0,"c"=>0],
  7773. "e"=>["r"=>0,"c"=>4]
  7774. ]
  7775. ];
  7776. $cols = [
  7777. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  7778. ];
  7779. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  7780. }
  7781. }
  7782. }
  7783. //出库、退库导出
  7784. public function _excelctjs()
  7785. {
  7786. $classid = $this->classid->sku();
  7787. $pm = $classid;
  7788. $typeclass = array();
  7789. $tc = $this->typeclass->find_all();
  7790. foreach ($tc as $v) {
  7791. $typeclass[$v['id']] = $v;
  7792. }
  7793. $prc = array();
  7794. $purchase = $this->purchase->find_all();
  7795. foreach ($purchase as $k => $v) {
  7796. $prc[$v['id']] = $v['title'];
  7797. }
  7798. if (isset($_GET['excel'])) {
  7799. $wh = array();
  7800. $w = $this->warehouse->find_all('1=1', 'id,title');
  7801. foreach ($w as $v) {
  7802. $wh[$v['id']] = $v['title'];
  7803. }
  7804. $type = $this->input->get('excel', true);
  7805. $category = $this->input->get('category', true);
  7806. $size = $this->input->get('size', true);
  7807. $grade = $this->input->get('grade', true);
  7808. $color = $this->input->get('color', true);
  7809. $lowe = $this->input->get('lowe', true);
  7810. $sku = $this->input->get('sku', true);
  7811. $title = $this->input->get('title', true);
  7812. $warehouse = $this->input->get('warehouse', true);
  7813. $purchase = $this->input->get('purchase', true);
  7814. $lacetype = $this->input->get('lacetype', true);
  7815. $haircap = $this->input->get('haircap', true);
  7816. $lacecolor = $this->input->get('lacecolor', true);
  7817. $density = $this->input->get('density', true);
  7818. $details = $this->input->get('details', true);
  7819. $state = $this->input->get('state', true);
  7820. $shop = $this->input->get('shop', true);
  7821. $hairnumber = $this->input->get('hairnumber', true);
  7822. $type_leixi = $this->input->get('type', true);
  7823. $cpbz = $this->input->get('cpbz', true);
  7824. $sm = $this->input->get('sm', true);
  7825. $sid = $this->input->get('sid', true);
  7826. $ktime = $this->input->get('ktime', true);
  7827. $jtime = $this->input->get('jtime', true);
  7828. $ktime = strtotime($ktime);
  7829. $jtime = strtotime($jtime);
  7830. //$where = " 1=1 ";
  7831. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  7832. $where = " sku != '' ";
  7833. $gj = "";
  7834. $ck = "";
  7835. if ($category) {
  7836. $where .= " and features like '%-$category-%'";
  7837. }
  7838. if ($size) {
  7839. $where .= " and features like '%-$size-%'";
  7840. }
  7841. if ($grade) {
  7842. $where .= " and features like '%-$grade-%'";
  7843. }
  7844. if ($color) {
  7845. $where .= " and features like '%-$color-%'";
  7846. }
  7847. if ($lowe) {
  7848. $where .= " and features like '%-$lowe-%'";
  7849. }
  7850. if ($warehouse) {
  7851. $where .= " and warehouse = '$warehouse'";
  7852. }
  7853. if ($purchase) {
  7854. $where .= " and purchase = '$purchase'";
  7855. }
  7856. if ($state) {
  7857. $where .= " and state = '$state'";
  7858. }
  7859. if ($lacetype) {
  7860. $where .= " and features like '%-$lacetype-%'";
  7861. }
  7862. if ($lacecolor) {
  7863. $where .= " and features like '%-$lacecolor-%'";
  7864. }
  7865. if ($density) {
  7866. $where .= " and features like '%-$density-%'";
  7867. }
  7868. if ($haircap) {
  7869. $where .= " and features like '%-$haircap-%'";
  7870. }
  7871. if ($details) {
  7872. $where .= " and details = '$details'";
  7873. }
  7874. if ($shop) {
  7875. $where .= " and shop like '%$shop%'";
  7876. }
  7877. if ($title) {
  7878. $title = trim($title, ' ');
  7879. $title = trim($title, ' ');
  7880. $where .= " and title like '%$title%'";
  7881. }
  7882. if (!empty($hairnumber)) {
  7883. $where .= " and features like '%-128-%' ";
  7884. if ($hairnumber < 0) {
  7885. $class_list = $this->typeclass->find_all('classid = 43');
  7886. foreach ($class_list as $v) {
  7887. $where .= " and features not like '%-" . $v['id'] . "-%'";
  7888. }
  7889. } else {
  7890. $where .= " and features like '%-$hairnumber-%'";
  7891. }
  7892. }
  7893. if ($type_leixi) {
  7894. $where .= " and type = '$type_leixi'";
  7895. }
  7896. if ($cpbz) {
  7897. $where .= " and cpbz like '%$cpbz%' ";
  7898. }
  7899. if ($sm) {
  7900. $where .= " and sm like '%$sm%' ";
  7901. }
  7902. if ($sku) {
  7903. $sku = trim($sku, ' ');
  7904. $sku = trim($sku, ' ');
  7905. $where .= " and sku like '%$sku%'";
  7906. }
  7907. if ($ktime && $jtime) {
  7908. if ($type == 1) {
  7909. $tl = '出库';
  7910. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  7911. } else if ($type == 2) {
  7912. $tl = '退库';
  7913. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  7914. } else if ($type == 3) {
  7915. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7916. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7917. } else if ($type == 4) {
  7918. $tl = '出库+零售';
  7919. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  7920. } else if ($type == 5) {
  7921. $tl = '零售';
  7922. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  7923. }
  7924. }
  7925. $sidwhere = '';
  7926. if ($sid) {
  7927. $sd = "";
  7928. $s = explode(',', trim($sid, ','));
  7929. foreach ($s as $value) {
  7930. $sd .= " id = " . $value . " or";
  7931. }
  7932. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7933. }
  7934. //数据排序
  7935. $order_str = "time desc";
  7936. if (empty($page)) {
  7937. $start = 0;
  7938. $perpage = 1;
  7939. } else {
  7940. $start = ($page - 1) * $perpage;
  7941. }
  7942. //取得信息列表
  7943. if ($type != 3 && $type != 5) {
  7944. if ($type == 1 || $type == 4) {
  7945. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  7946. foreach ($info_list as $key => $value) {
  7947. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  7948. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  7949. $warehouse = $this->warehouse->read($value['warehouse']);
  7950. $info_list[$key]['warehouse'] = $warehouse['title'];
  7951. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  7952. $features = explode('-', trim($features, '-'));
  7953. $pm = $classid;
  7954. foreach ($features as $k => $v) {
  7955. if ($v != 0) {
  7956. if (!isset($typeclass[$v])) {
  7957. continue;
  7958. }
  7959. if (isset($pm[$typeclass[$v]['classid']])) {
  7960. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  7961. $tz = explode('|', $typeclass[$v]['zh']);
  7962. $pm[$typeclass[$v]['classid']] = $tz[0];
  7963. } else {
  7964. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  7965. }
  7966. }
  7967. }
  7968. }
  7969. $zh = implode(" ", $pm);
  7970. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  7971. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7972. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  7973. $info_list[$key]['features'] = $zh;
  7974. }
  7975. $final_list = [];
  7976. foreach($info_list as $k=>$v){
  7977. $number = "";
  7978. if(!empty($v['orderinfo'])){
  7979. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  7980. if(!empty($tmp_info['number'])){
  7981. $number = $tmp_info['number'];
  7982. }
  7983. }
  7984. $final_list[] = [
  7985. 'warehouse'=>$v['warehouse'],
  7986. 'purchase'=>$v['purchase'],
  7987. 'sku'=>$v['sku'],
  7988. 'title'=>$v['title'],
  7989. 'features'=>$v['features'],
  7990. 'label'=>$v['label'],
  7991. 'orderinfo'=>$v['orderinfo'],
  7992. 'number'=>$number,
  7993. 'waybill'=>$v['waybill'],
  7994. 'outk'=>$v['outk'],
  7995. ];
  7996. }
  7997. } else {
  7998. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  7999. foreach ($info_list as $key => $value) {
  8000. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8001. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8002. $warehouse = $this->warehouse->read($value['warehouse']);
  8003. $info_list[$key]['warehouse'] = $warehouse['title'];
  8004. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8005. $features = explode('-', trim($features, '-'));
  8006. $pm = $classid;
  8007. foreach ($features as $k => $v) {
  8008. if ($v != 0) {
  8009. if (!isset($typeclass[$v])) {
  8010. continue;
  8011. }
  8012. if (isset($pm[$typeclass[$v]['classid']])) {
  8013. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8014. $tz = explode('|', $typeclass[$v]['zh']);
  8015. $pm[$typeclass[$v]['classid']] = $tz[0];
  8016. } else {
  8017. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8018. }
  8019. }
  8020. }
  8021. }
  8022. $zh = implode(" ", $pm);
  8023. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8024. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8025. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8026. $info_list[$key]['features'] = $zh;
  8027. }
  8028. $final_list = [];
  8029. foreach($info_list as $k=>$v){
  8030. $number = "";
  8031. if(!empty($v['orderinfo'])){
  8032. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8033. if(!empty($tmp_info['number'])){
  8034. $number = $tmp_info['number'];
  8035. }
  8036. }
  8037. $final_list[] = [
  8038. 'warehouse'=>$v['warehouse'],
  8039. 'purchase'=>$v['purchase'],
  8040. 'sku'=>$v['sku'],
  8041. 'title'=>$v['title'],
  8042. 'features'=>$v['features'],
  8043. 'label'=>$v['label'],
  8044. 'orderinfo'=>$v['orderinfo'],
  8045. 'number'=>$number,
  8046. 'waybill'=>$v['waybill'],
  8047. 'retreat'=>$v['retreat'],
  8048. ];
  8049. }
  8050. }
  8051. if(empty($final_list)){
  8052. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8053. }else{
  8054. $end_list = [];
  8055. foreach($final_list as $v){
  8056. $end_list[] = array_values($v);
  8057. }
  8058. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8059. array_unshift($end_list,[
  8060. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8061. ]);
  8062. array_unshift($end_list,[
  8063. $title,"","","","","","","","",""
  8064. ]);
  8065. $merges = [
  8066. [
  8067. "s"=>["r"=>0,"c"=>0],
  8068. "e"=>["r"=>0,"c"=>9]
  8069. ]
  8070. ];
  8071. $cols = [
  8072. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8073. ];
  8074. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8075. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8076. ] )));
  8077. }
  8078. } else if ($type == 5) {
  8079. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8080. foreach ($info_list as $key => $value) {
  8081. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8082. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8083. $warehouse = $this->warehouse->read($value['warehouse']);
  8084. $info_list[$key]['warehouse'] = $warehouse['title'];
  8085. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8086. $features = explode('-', trim($features, '-'));
  8087. $pm = $classid;
  8088. foreach ($features as $k => $v) {
  8089. if ($v != 0) {
  8090. if (!isset($typeclass[$v])) {
  8091. continue;
  8092. }
  8093. if (isset($pm[$typeclass[$v]['classid']])) {
  8094. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8095. $tz = explode('|', $typeclass[$v]['zh']);
  8096. $pm[$typeclass[$v]['classid']] = $tz[0];
  8097. } else {
  8098. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8099. }
  8100. }
  8101. }
  8102. }
  8103. $zh = implode(" ", $pm);
  8104. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8105. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8106. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8107. $info_list[$key]['features'] = $zh;
  8108. }
  8109. if(empty($info_list)){
  8110. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8111. }else{
  8112. $final_list = [];
  8113. foreach($info_list as $v){
  8114. $final_list[] = array_values($v);
  8115. }
  8116. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8117. array_unshift($final_list,[
  8118. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8119. ]);
  8120. array_unshift($final_list,[
  8121. $title,"","","","","","",
  8122. ]);
  8123. $merges = [
  8124. [
  8125. "s"=>["r"=>0,"c"=>0],
  8126. "e"=>["r"=>0,"c"=>6]
  8127. ]
  8128. ];
  8129. $cols = [
  8130. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8131. ];
  8132. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8133. }
  8134. } else {
  8135. $wh = array();
  8136. $w = $this->warehouse->find_all('1=1', 'id,title');
  8137. foreach ($w as $v) {
  8138. $wh[$v['id']] = $v['title'];
  8139. }
  8140. $wt = array();
  8141. $whlabel_type = $this->whlabel_type->find_all();
  8142. foreach ($whlabel_type as $v) {
  8143. $wt[$v['id']] = $v['title'];
  8144. }
  8145. $classid = $this->classid->sku();
  8146. $list = array();
  8147. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8148. foreach ($rows as $key => $value) {
  8149. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8150. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8151. $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');
  8152. $details = array();
  8153. $cpid = array();
  8154. $cpbz = array();
  8155. $c = 0;
  8156. $g = 0;
  8157. $x = 0;
  8158. $t = 0;
  8159. $s = 0;
  8160. $q = 0;
  8161. foreach ($sd as $k => $v) {
  8162. if ($v['state'] == 0) {
  8163. $c++;
  8164. }
  8165. if ($v['state'] != 9) {
  8166. $g++;
  8167. }
  8168. if ($v['outk'] > 1) {
  8169. $x++;
  8170. }
  8171. if ($v['retreat'] > 0) {
  8172. $t++;
  8173. }
  8174. if ($v['state'] == 8) {
  8175. $s++;
  8176. }
  8177. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8178. $q++;
  8179. }
  8180. $details[$v['details']] = $v['details'];
  8181. if ($v['cpid'] != 0) {
  8182. $cpid[$v['cpid']] = $v['cpid'];
  8183. }
  8184. if ($v['cpbz'] != '') {
  8185. $cpbz[$v['cpbz']] = $v['cpbz'];
  8186. }
  8187. }
  8188. if (isset($wt[$value['type']])) {
  8189. $rows[$key]['type'] = $wt[$value['type']];
  8190. } else {
  8191. $rows[$key]['type'] = '未设置';
  8192. }
  8193. $rows[$key]['details'] = implode("、", $details);
  8194. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8195. $ftime = time() - 15 * 24 * 3600;
  8196. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8197. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8198. $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);
  8199. $rows[$key]['c'] = $c;
  8200. $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);
  8201. $rows[$key]['t'] = $t;
  8202. $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'] . '"');
  8203. $rows[$key]['z'] = $z;
  8204. // $jm = $classid;
  8205. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8206. $features = explode('-', trim($features, '-'));
  8207. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8208. }
  8209. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8210. $final_list =[];
  8211. foreach($tmp_list as $k=>$v){
  8212. $final_list[] = [
  8213. "warehouse"=>$v['warehouse'],
  8214. "purchase"=>$v['purchase'],
  8215. "details"=>$v['details'],
  8216. "cpid"=>$v['cpid'],
  8217. "sku"=>$v['sku'],
  8218. "title"=>$v['title'],
  8219. "features"=>$v['pm'],
  8220. "cpbz"=>$v['cpbz'],
  8221. "sm"=>$v['sm'],
  8222. "type"=>$v['type'],
  8223. "g"=>$v["g"],
  8224. "c"=>$v["c"],
  8225. "x"=>$v["x"],
  8226. "t"=>$v["t"],
  8227. "z"=>$v["z"],
  8228. "jm"=>$v["jm"],
  8229. "weight"=>$v["weight"],
  8230. "asd"=>$v["asd"],
  8231. ];
  8232. }
  8233. if(empty($final_list)){
  8234. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8235. }else{
  8236. $end_list = [];
  8237. foreach($final_list as $v){
  8238. $end_list[] = array_values($v);
  8239. }
  8240. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8241. array_unshift($end_list,[
  8242. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8243. ]);
  8244. array_unshift($end_list,[
  8245. $title,"","","","","","","","","","","","","","","","","",""
  8246. ]);
  8247. $merges = [
  8248. [
  8249. "s"=>["r"=>0,"c"=>0],
  8250. "e"=>["r"=>0,"c"=>6]
  8251. ]
  8252. ];
  8253. $cols = [
  8254. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8255. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8256. ];
  8257. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8258. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8259. ])));
  8260. }
  8261. }
  8262. }
  8263. }
  8264. public function _exceljxcjs(){
  8265. $classid = $this->classid->sku();
  8266. $pm = $classid;
  8267. $typeclass = array();
  8268. $tc = $this->typeclass->find_all();
  8269. foreach ($tc as $v) {
  8270. $typeclass[$v['id']] = $v;
  8271. }
  8272. $prc = array();
  8273. $purchase = $this->purchase->find_all();
  8274. foreach ($purchase as $k => $v) {
  8275. $prc[$v['id']] = $v['title'];
  8276. }
  8277. if(!isset($_GET['excel'])){
  8278. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8279. }
  8280. $where = "sku != 'Preset'";
  8281. //数据排序
  8282. $order_str = "id desc";
  8283. if (empty($page)) {
  8284. $start = 0;
  8285. $perpage = 1;
  8286. } else {
  8287. $start = ($page - 1) * $perpage;
  8288. }
  8289. $category = $this->input->get('category', true);
  8290. $warehouse = $this->input->get('warehouse', true);
  8291. $excelid = $this->input->get('sid', true);
  8292. if ($category) {
  8293. $where .= " and features like '%-$category-%'";
  8294. }
  8295. if ($warehouse) {
  8296. $where .= " and warehouse = '$warehouse'";
  8297. }
  8298. $xzid = '';
  8299. if ($excelid) {
  8300. $excelid = explode(',', trim($excelid, ','));
  8301. foreach ($excelid as $key => $value) {
  8302. $xzid .= " id = " . $value . " or";
  8303. }
  8304. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8305. }
  8306. $wt = array();
  8307. $whlabel_type = $this->whlabel_type->find_all();
  8308. foreach ($whlabel_type as $v) {
  8309. $wt[$v['id']] = $v['title'];
  8310. }
  8311. $wh = array();
  8312. $w = $this->warehouse->find_all('1=1', 'id,title');
  8313. foreach ($w as $v) {
  8314. $wh[$v['id']] = $v['title'];
  8315. }
  8316. $list = array();
  8317. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8318. foreach ($rows as $key => $value) {
  8319. if (isset($wt[$value['type']])) {
  8320. $rows[$key]['type'] = $wt[$value['type']];
  8321. } else {
  8322. $rows[$key]['type'] = '未设置';
  8323. }
  8324. $bm = '03';
  8325. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8326. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8327. $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');
  8328. $details = array();
  8329. $cpid = array();
  8330. $cpbz = array();
  8331. $c = 0;
  8332. $g = 0;
  8333. $x = 0;
  8334. $t = 0;
  8335. $s = 0;
  8336. $q = 0;
  8337. foreach ($sd as $k => $v) {
  8338. if ($v['state'] == 0) {
  8339. $c++;
  8340. if ($v['cpid'] != 0) {
  8341. $cpid[$v['cpid']] = $v['cpid'];
  8342. }
  8343. if ($v['cpbz'] != '') {
  8344. $cpbz[$v['cpbz']] = $v['cpbz'];
  8345. }
  8346. }
  8347. if ($v['state'] != 9) {
  8348. $g++;
  8349. }
  8350. if ($v['state'] == 1) {
  8351. $x++;
  8352. }
  8353. if ($v['state'] == 2) {
  8354. $t++;
  8355. }
  8356. if ($v['state'] == 8) {
  8357. $s++;
  8358. }
  8359. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8360. $q++;
  8361. }
  8362. $details[$v['details']] = $v['details'];
  8363. }
  8364. $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'] . '"');
  8365. $rows[$key]['details'] = implode("、", $details);
  8366. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8367. $number = $value['number'];
  8368. $ftime = time() - 15 * 24 * 3600;
  8369. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8370. $rows[$key]['number'] = $g;
  8371. $rows[$key]['c'] = $c;
  8372. $rows[$key]['x'] = $x;
  8373. $rows[$key]['t'] = $t;
  8374. $rows[$key]['s'] = $s;
  8375. $rows[$key]['q'] = $q;
  8376. $rows[$key]['z'] = $z;
  8377. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8378. $features = explode('-', trim($features, '-'));
  8379. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8380. }
  8381. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8382. $final_list = [];
  8383. foreach ($list as $k => $v) {
  8384. if (empty($v['sku'])) {
  8385. continue;
  8386. }
  8387. $final_list[] = [
  8388. $v["warehouse"],
  8389. $v["purchase"],
  8390. $v["details"],
  8391. $v["cpid"],
  8392. $v["dbcontent"],
  8393. $v["sku"],
  8394. $v["bm"],
  8395. $v["jm"],
  8396. $v["title"],
  8397. $v["pm"],
  8398. $v["cpbz"],
  8399. $v["sm"],
  8400. $v["type"],
  8401. $v["number"],
  8402. $v["c"],
  8403. $v["x"],
  8404. $v["t"],
  8405. $v["s"],
  8406. $v["q"],
  8407. $v["z"],
  8408. $v['weight'],
  8409. ];
  8410. }
  8411. if(empty($final_list)){
  8412. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8413. }
  8414. $title = "总进销存统计表";
  8415. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8416. $merges = [
  8417. [
  8418. "s"=>["r"=>0,"c"=>0],
  8419. "e"=>["r"=>0,"c"=>21]
  8420. ]
  8421. ];
  8422. $cols = [
  8423. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8424. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8425. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8426. ];
  8427. array_unshift($final_list, $first_row);
  8428. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8429. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8430. }
  8431. public function _summaryjs($arg_array)
  8432. {
  8433. $prc = array();
  8434. $purchase = $this->purchase->find_all();
  8435. foreach ($purchase as $k => $v) {
  8436. $prc[$v['id']] = $v['title'];
  8437. }
  8438. if (isset($_GET['excel'])) {
  8439. $ktime = $this->input->get('ktime', true);
  8440. $jtime = $this->input->get('jtime', true);
  8441. $ktime = strtotime($ktime);
  8442. $jtime = strtotime($jtime);
  8443. $where = "1=1";
  8444. if ($ktime && $jtime) {
  8445. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8446. }
  8447. //数据排序
  8448. $order_str = "time desc";
  8449. if (empty($page)) {
  8450. $start = 0;
  8451. $perpage = 1;
  8452. } else {
  8453. $start = ($page - 1) * $perpage;
  8454. }
  8455. //取得信息列表
  8456. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  8457. foreach ($info_list as $key => $value) {
  8458. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8459. $warehouse = $this->warehouse->read($value['warehouse']);
  8460. $info_list[$key]['warehouse'] = $warehouse['title'];
  8461. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  8462. $details = array();
  8463. $cpid = array();
  8464. foreach ($x as $k => $v) {
  8465. if ($v['details'] != '') {
  8466. $details[$v['details']] = $v['details'];
  8467. }
  8468. if ($v['cpid'] != 0) {
  8469. $cpid[$v['cpid']] = $v['cpid'];
  8470. }
  8471. }
  8472. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  8473. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8474. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  8475. $info_list[$key]['s'] = $s;
  8476. $info_list[$key]['x'] = count($x);
  8477. }
  8478. if(empty($info_list)){
  8479. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8480. }
  8481. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  8482. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  8483. $merges = [
  8484. [
  8485. "s"=>["r"=>0,"c"=>0],
  8486. "e"=>["r"=>0,"c"=>7]
  8487. ]
  8488. ];
  8489. $cols = [
  8490. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  8491. ];
  8492. $final_list = [];
  8493. foreach($info_list as $k => $v){
  8494. $final_list[] = array_values($v);
  8495. }
  8496. array_unshift($final_list, $first_row);
  8497. array_unshift($final_list,[
  8498. $title,"","","","","","","","",
  8499. ]);
  8500. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8501. $titlename = "<table border=1>
  8502. <tr align='center'>
  8503. <td>仓库</td>
  8504. <td>供应商</td>
  8505. <td>出库位置</td>
  8506. <td>出库编码</td>
  8507. <td>SKU</td>
  8508. <td>产品名</td>
  8509. <td>总剩余库存</td>
  8510. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  8511. </tr>
  8512. </table>";
  8513. $filename = $title . ".xls";
  8514. $tail = "";
  8515. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  8516. }
  8517. }
  8518. public function _uckjs()
  8519. {
  8520. if (isset($_GET['excel'])) {
  8521. $tc = array();
  8522. $typeclass = $this->typeclass->find_all();
  8523. foreach ($typeclass as $v) {
  8524. $tc[$v['id']] = $v['zh'];
  8525. }
  8526. $first_row = [
  8527. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  8528. ];
  8529. $t = array();
  8530. $rq = '';
  8531. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  8532. $ts = $ts / (24 * 3600);
  8533. for ($i = 0; $i < $ts; $i++) {
  8534. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8535. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  8536. }
  8537. $day_len = count($t);
  8538. $first_row[] = "本月出库";
  8539. $merges = [
  8540. ];
  8541. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  8542. $excel_key = 1;
  8543. $final_list = [];
  8544. foreach ($info_list as $k => $v) {
  8545. $features = explode('-', trim($v['features'], '-'));
  8546. if (!isset($features[3]) || !isset($features[4])) {
  8547. continue;
  8548. }
  8549. $tmp = [];
  8550. $tmp[0] = $tc[$features[0]]; //类型
  8551. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  8552. $tmp[2] = $tc[$features[4]]; //曲度
  8553. $tmp[3] = '';
  8554. if (isset($data[$k][1])) {
  8555. $tmp[3] .=$tmp[1];
  8556. }
  8557. if (isset($data[$k][2])) {
  8558. $tmp[3] .= $tmp[2];
  8559. }
  8560. if (isset($features[5])) {
  8561. $tmp[3] .= $tc[$features[5]];
  8562. }
  8563. if (isset($features[2])) {
  8564. $tmp[3] .= $tc[$features[2]];
  8565. }
  8566. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  8567. $tmp[4] = $v['sku'];
  8568. $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())) . '))'); //月初库存
  8569. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  8570. $tmp[7] ="";
  8571. $tmp[8] ="";
  8572. $byck = 0;
  8573. foreach ($t as $vv) {
  8574. $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));
  8575. $tmp[] = ($sl > 0) ? $sl : '';
  8576. $byck += $sl;
  8577. }
  8578. $tmp[] = ($byck > 0) ? $byck : '';
  8579. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  8580. // $ztrq = '';
  8581. // $ztsl = '';
  8582. // if (count($zt) > 0) {
  8583. // foreach ($zt as $vv) {
  8584. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  8585. // $ztsl .= $vv['num'] . '<br>';
  8586. // }
  8587. // }
  8588. if(empty($zt)){
  8589. $final_list[] = $tmp;
  8590. $excel_key = $excel_key + 1;
  8591. }else{
  8592. $len = count($zt);
  8593. if($len == 1){
  8594. $tmp[7] = $zt[0]['num'] ;
  8595. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  8596. $final_list[] = $tmp;
  8597. $excel_key = $excel_key + 1;
  8598. }else{
  8599. foreach($zt as $vv){
  8600. $tmp[7] = "";
  8601. $tmp[8] = "";
  8602. $tmp[7] = $vv['num'];
  8603. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  8604. $final_list[] = $tmp;
  8605. }
  8606. $merges[] = [
  8607. "s"=>["r"=>$excel_key,"c"=>0],
  8608. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  8609. ];
  8610. $merges[] = [
  8611. "s"=>["r"=>$excel_key,"c"=>1],
  8612. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  8613. ];
  8614. $merges[] = [
  8615. "s"=>["r"=>$excel_key,"c"=>2],
  8616. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  8617. ];
  8618. $merges[] = [
  8619. "s"=>["r"=>$excel_key,"c"=>3],
  8620. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  8621. ];
  8622. $merges[] = [
  8623. "s"=>["r"=>$excel_key,"c"=>4],
  8624. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  8625. ];
  8626. $merges[] = [
  8627. "s"=>["r"=>$excel_key,"c"=>5],
  8628. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  8629. ];
  8630. $merges[] = [
  8631. "s"=>["r"=>$excel_key,"c"=>6],
  8632. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  8633. ];
  8634. for($i=1;$i<=$day_len;$i++){
  8635. $merges[] = [
  8636. "s"=>["r"=>$excel_key,"c"=>8+$i],
  8637. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  8638. ];
  8639. }
  8640. $merges[] = [
  8641. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  8642. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  8643. ];
  8644. $excel_key = $excel_key + $len;
  8645. }
  8646. }
  8647. }
  8648. $title = "详情 " . date("Y-m-d", time());
  8649. if(empty($final_list)){
  8650. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8651. }
  8652. $cols = [
  8653. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  8654. ];
  8655. array_unshift($final_list, $first_row);
  8656. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8657. }
  8658. }
  8659. public function _whlabelexcelzhjs(){
  8660. if(empty($_GET['excel'])){
  8661. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8662. }
  8663. $where = "sku != 'Preset' and sku != '' ";
  8664. //数据排序
  8665. $order_str = "id desc";
  8666. if (empty($page)) {
  8667. $start = 0;
  8668. $perpage = 1;
  8669. } else {
  8670. $start = ($page - 1) * $perpage;
  8671. }
  8672. $category = $this->input->get('category', true);
  8673. $warehouse = $this->input->get('warehouse', true);
  8674. $excelid = $this->input->get('sid', true);
  8675. if ($category) {
  8676. $where .= " and features like '%-$category-%'";
  8677. }
  8678. if ($warehouse) {
  8679. $where .= " and warehouse = '$warehouse'";
  8680. }
  8681. $xzid = '';
  8682. if ($excelid) {
  8683. $excelid = explode(',', trim($excelid, ','));
  8684. foreach ($excelid as $key => $value) {
  8685. $xzid .= " id = " . $value . " or";
  8686. }
  8687. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8688. }
  8689. $merges = [
  8690. [
  8691. "s"=>["r"=>0,"c"=>0],
  8692. "e"=>["r"=>0,"c"=>6]
  8693. ]
  8694. ];
  8695. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  8696. $excel_index = 2;
  8697. $final_list = [];
  8698. foreach ($rows as $key => $value) {
  8699. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  8700. $zh = '';
  8701. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  8702. // foreach ($zt_list as $v) {
  8703. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  8704. // }
  8705. $zt = array_sum(array_column($zt_list, 'num'));
  8706. $number = $value['number'];
  8707. $ftime = time() - 15 * 24 * 3600;
  8708. $warehouse = $this->warehouse->read($value['warehouse']);
  8709. // $rows[$key]['warehouse'] = $warehouse['title'];
  8710. // $rows[$key]['number'] = $c;
  8711. // $rows[$key]['features'] = $zh;
  8712. //$rows[$key]['hb'] = $c + $zt;
  8713. $tmp = [];
  8714. $tmp[0] = $warehouse['title'];
  8715. $tmp[1] = $value['sku'];
  8716. $tmp[2] = $value['title'];
  8717. $tmp[3] = $c;
  8718. $tmp[4] = "";
  8719. $tmp[5] = $c + $zt;
  8720. if(empty($zt_list)){
  8721. $tmp[4] = "";
  8722. $final_list[] = $tmp;
  8723. $excel_index = $excel_index + 1;
  8724. }else{
  8725. if(count($zt_list) == 1){
  8726. $tmp[4] = "";
  8727. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  8728. $final_list[] = $tmp;
  8729. $excel_index = $excel_index + 1;
  8730. }else{
  8731. $len = count($zt_list);
  8732. foreach ($zt_list as $v){
  8733. $tmp[4] = "";
  8734. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  8735. $final_list[] = $tmp;
  8736. }
  8737. $merges[] = [
  8738. "s"=>["r"=>$excel_index,"c"=>0],
  8739. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  8740. ];
  8741. $merges[] = [
  8742. "s"=>["r"=>$excel_index,"c"=>1],
  8743. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  8744. ];
  8745. $merges[] = [
  8746. "s"=>["r"=>$excel_index,"c"=>2],
  8747. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  8748. ];
  8749. $merges[] = [
  8750. "s"=>["r"=>$excel_index,"c"=>3],
  8751. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  8752. ];
  8753. $merges[] = [
  8754. "s"=>["r"=>$excel_index,"c"=>5],
  8755. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  8756. ];
  8757. $excel_index = $excel_index + $len;
  8758. }
  8759. }
  8760. }
  8761. $first_row = [
  8762. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  8763. ];
  8764. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  8765. if(empty($final_list)){
  8766. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8767. }
  8768. $cols = [
  8769. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  8770. ];
  8771. array_unshift($final_list, $first_row);
  8772. array_unshift($final_list, [
  8773. $title,"","","","",""
  8774. ]);
  8775. $end_list = [];
  8776. foreach ($final_list as $key => $value) {
  8777. $end_list[] = array_values($value);
  8778. }
  8779. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  8780. }
  8781. //出库、退库导出
  8782. public function _dccrtypejs()
  8783. {
  8784. $classid = $this->classid->sku();
  8785. $pm = $classid;
  8786. $typeclass = array();
  8787. $tc = $this->typeclass->find_all();
  8788. foreach ($tc as $v) {
  8789. $typeclass[$v['id']] = $v;
  8790. }
  8791. $prc = array();
  8792. $purchase = $this->purchase->find_all();
  8793. foreach ($purchase as $k => $v) {
  8794. $prc[$v['id']] = $v['title'];
  8795. }
  8796. if (isset($_GET['sid'])) {
  8797. $wh = array();
  8798. $w = $this->warehouse->find_all('1=1', 'id,title');
  8799. foreach ($w as $v) {
  8800. $wh[$v['id']] = $v['title'];
  8801. }
  8802. $type = $this->input->get('excel', true);
  8803. $category = $this->input->get('category', true);
  8804. $size = $this->input->get('size', true);
  8805. $grade = $this->input->get('grade', true);
  8806. $color = $this->input->get('color', true);
  8807. $lowe = $this->input->get('lowe', true);
  8808. $sku = $this->input->get('sku', true);
  8809. $warehouse = $this->input->get('warehouse', true);
  8810. $lacetype = $this->input->get('lacetype', true);
  8811. $lacecolor = $this->input->get('lacecolor', true);
  8812. $density = $this->input->get('density', true);
  8813. $haircap = $this->input->get('haircap', true);
  8814. $purchase = $this->input->get('purchase', true);
  8815. $title = $this->input->get('title', true);
  8816. $state = $this->input->get('state', true);
  8817. $sid = $this->input->get('sid', true);
  8818. $ktime = $this->input->get('ktime', true);
  8819. $jtime = $this->input->get('jtime', true);
  8820. $ktime = strtotime($ktime);
  8821. $jtime = strtotime($jtime);
  8822. $where = "1=1";
  8823. $gj = "";
  8824. $ck = "";
  8825. if ($category) {
  8826. $where .= " and features like '%-$category-%'";
  8827. }
  8828. if ($size) {
  8829. $where .= " and features like '%-$size-%'";
  8830. }
  8831. if ($grade) {
  8832. $where .= " and features like '%-$grade-%'";
  8833. }
  8834. if ($color) {
  8835. $where .= " and features like '%-$color-%'";
  8836. }
  8837. if ($lowe) {
  8838. $where .= " and features like '%-$lowe-%'";
  8839. }
  8840. if ($warehouse) {
  8841. $where .= " and warehouse = '$warehouse'";
  8842. }
  8843. if ($purchase) {
  8844. $where .= " and purchase = '$purchase'";
  8845. }
  8846. if ($state) {
  8847. $where .= " and state = '$state'";
  8848. }
  8849. if ($lacetype) {
  8850. $where .= " and features like '%-$lacetype-%'";
  8851. }
  8852. if ($lacecolor) {
  8853. $where .= " and features like '%-$lacecolor-%'";
  8854. }
  8855. if ($density) {
  8856. $where .= " and features like '%-$density-%'";
  8857. }
  8858. if ($haircap) {
  8859. $where .= " and features like '%-$haircap-%'";
  8860. }
  8861. if ($title) {
  8862. $title = trim($title, ' ');
  8863. $title = trim($title, ' ');
  8864. $where .= " and title like '%$title%'";
  8865. }
  8866. if ($sku) {
  8867. $sku = trim($sku, ' ');
  8868. $sku = trim($sku, ' ');
  8869. $where .= " and sku like '%$sku%'";
  8870. }
  8871. if ($ktime && $jtime) {
  8872. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8873. }
  8874. $sidwhere = '';
  8875. if ($sid) {
  8876. $sd = "";
  8877. $s = explode(',', trim($sid, ','));
  8878. foreach ($s as $value) {
  8879. $sd .= " id = " . $value . " or";
  8880. }
  8881. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8882. }
  8883. //数据排序
  8884. $order_str = "time desc";
  8885. if (empty($page)) {
  8886. $start = 0;
  8887. $perpage = 1;
  8888. } else {
  8889. $start = ($page - 1) * $perpage;
  8890. }
  8891. $wh = array();
  8892. $w = $this->warehouse->find_all('1=1', 'id,title');
  8893. foreach ($w as $v) {
  8894. $wh[$v['id']] = $v['title'];
  8895. }
  8896. $wt = array();
  8897. $whlabel_type = $this->whlabel_type->find_all();
  8898. foreach ($whlabel_type as $v) {
  8899. $wt[$v['id']] = $v['title'];
  8900. }
  8901. $classid = $this->classid->sku();
  8902. $list = array();
  8903. $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');
  8904. foreach ($rows_r as $key => $value) {
  8905. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8906. $pm = $classid;
  8907. $jm = $classid;
  8908. $rows_r[$key]['enter'] = '入库';
  8909. $rows_r[$key]['time'] = $value['enter'];
  8910. if ($value['rktype'] == 1) {
  8911. $rows_r[$key]['rktype'] = '采购入库';
  8912. } else if ($value['rktype'] == 2) {
  8913. $rows_r[$key]['rktype'] = '盘盈调整';
  8914. } else if ($value['rktype'] == 3) {
  8915. $rows_r[$key]['rktype'] = '其他调整入库';
  8916. } else if ($value['rktype'] == 4) {
  8917. $rows_r[$key]['rktype'] = '其他调整入库';
  8918. } else if ($value['rktype'] == 5) {
  8919. $rows_r[$key]['rktype'] = '退库入库';
  8920. } else if ($value['rktype'] == 6) {
  8921. $rows_r[$key]['rktype'] = '退货可用入库';
  8922. } else if ($value['rktype'] == 7) {
  8923. $rows_r[$key]['rktype'] = '形态转换入库';
  8924. } else {
  8925. $rows_r[$key]['rktype'] = '';
  8926. }
  8927. $features = explode('-', trim($value['features'], '-'));
  8928. foreach ($features as $v) {
  8929. if (isset($typeclass[$v])) {
  8930. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8931. $pm[$typeclass[$v]['classid']] = $zh[0];
  8932. }
  8933. if (isset($typeclass[$v])) {
  8934. if (isset($jm[$typeclass[$v]['classid']])) {
  8935. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8936. }
  8937. }
  8938. }
  8939. $zh = implode(" ", $pm);
  8940. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8941. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8942. $rows_r[$key]['zh'] = $zh;
  8943. $jm = array_filter($jm);
  8944. $rows_r[$key]['features'] = implode("-", $jm);
  8945. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8946. }
  8947. $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');
  8948. foreach ($rows_c as $key => $value) {
  8949. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8950. $pm = $classid;
  8951. $jm = $classid;
  8952. $rows_c[$key]['time'] = $value['outk'];
  8953. $rows_c[$key]['outk'] = '出库';
  8954. if ($value['cktype'] == 1) {
  8955. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8956. } else if ($value['cktype'] == 2) {
  8957. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8958. } else if ($value['cktype'] == 3) {
  8959. $rows_c[$key]['cktype'] = '盘亏调整';
  8960. } else if ($value['cktype'] == 4) {
  8961. $rows_c[$key]['cktype'] = '其他调整出库';
  8962. } else if ($value['cktype'] == 5) {
  8963. $rows_c[$key]['cktype'] = '形态转换出库';
  8964. } else {
  8965. $rows_c[$key]['cktype'] = '';
  8966. }
  8967. unset($rows_c[$key]['state']);
  8968. $features = explode('-', trim($value['features'], '-'));
  8969. foreach ($features as $v) {
  8970. if (isset($typeclass[$v])) {
  8971. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8972. $pm[$typeclass[$v]['classid']] = $zh[0];
  8973. }
  8974. if (isset($typeclass[$v])) {
  8975. if (isset($jm[$typeclass[$v]['classid']])) {
  8976. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8977. }
  8978. }
  8979. }
  8980. $zh = implode(" ", $pm);
  8981. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8982. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8983. $rows_c[$key]['zh'] = $zh;
  8984. $jm = array_filter($jm);
  8985. $rows_c[$key]['features'] = implode("-", $jm);
  8986. $rows_c[$key]['number'] = 1;
  8987. }
  8988. $merged = $rows_r;
  8989. foreach ($rows_c as $key => $value) {
  8990. if (isset($merged[$key])) {
  8991. $merged[] = $value;
  8992. } else {
  8993. $merged[$key] = $value;
  8994. }
  8995. }
  8996. usort($merged, function ($a, $b) {
  8997. return $a['time'] - $b['time'];
  8998. });
  8999. foreach ($merged as $key => $value) {
  9000. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9001. }
  9002. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9003. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9004. $cols = [
  9005. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9006. ];
  9007. $final_list= [];
  9008. foreach($merged as $key => $value){
  9009. $final_list[] = array_values($value) ;
  9010. }
  9011. if(empty($merged)){
  9012. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9013. }
  9014. array_unshift($final_list, $first_row);
  9015. $end_list = [];
  9016. foreach ($final_list as $key => $value) {
  9017. $end_list[] = array_values($value);
  9018. }
  9019. $merges = [];
  9020. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9021. }
  9022. }
  9023. public function _errorexceljs()
  9024. {
  9025. $post = $this->input->post(NULL, TRUE);
  9026. if (isset($_GET['page'])) {
  9027. $page = $this->input->get('page', true);
  9028. $perpage = $this->input->get('perpage', true);
  9029. $sku = $this->input->get('sku', true);
  9030. $warehouse = $this->input->get('warehouse', true);
  9031. $ktime = $this->input->get('ktime', true);
  9032. $jtime = $this->input->get('jtime', true);
  9033. $ktime = strtotime($ktime);
  9034. $jtime = strtotime($jtime);
  9035. $where = "sku != 'Preset'";
  9036. $gj = '';
  9037. if ($sku) {
  9038. $where .= " and sku like '%$sku%'";
  9039. } else {
  9040. if ($ktime && $jtime) {
  9041. $gj = " and time > '$ktime' and time < '$jtime'";
  9042. }
  9043. }
  9044. if ($warehouse) {
  9045. $where .= " and warehouse = '$warehouse'";
  9046. }
  9047. //数据排序
  9048. $order_str = "id desc";
  9049. if (empty($page)) {
  9050. $start = 0;
  9051. $perpage = 1;
  9052. } else {
  9053. $start = ($page - 1) * $perpage;
  9054. }
  9055. //取得信息列表
  9056. $rows = array();
  9057. $list = array();
  9058. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9059. foreach ($info_list as $value) {
  9060. $warehouse = $this->warehouse->read($value['warehouse']);
  9061. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9062. $number = $value['number'];
  9063. $ftime = time() - 15 * 24 * 3600;
  9064. if ($c < 1) {
  9065. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9066. }
  9067. }
  9068. $title = "0库存汇总";
  9069. $first_row = ["仓库","SKU","产品","当前库存"];
  9070. $cols = [
  9071. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9072. ];
  9073. $final_list= [];
  9074. foreach($list as $key => $value){
  9075. $final_list[] = array_values($value) ;
  9076. }
  9077. if(empty($final_list)){
  9078. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9079. }
  9080. array_unshift($final_list, $first_row);
  9081. $merges = [];
  9082. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9083. }
  9084. }
  9085. }