Whlabel.php 264 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698
  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. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg, $arg_array)
  48. {
  49. if ($arg == 'existence') //在库标签
  50. {
  51. $this->_existence();
  52. } else if ($arg == 'cpbqdc') //在库标签
  53. {
  54. $this->_cpbqdc();
  55. } else if ($arg == 'type') //进销存浏览
  56. {
  57. $this->_type();
  58. } else if ($arg == 'typedy') //进销存浏览店员页面
  59. {
  60. $this->_typedy($arg_array);
  61. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  62. {
  63. $this->_typedy_ck($arg_array);
  64. } else if ($arg == 'typeck') {
  65. $this->_typeck($arg_array);
  66. } else if ($arg == 'whlabeckdc') {
  67. $this->_whlabeckdc($arg_array);
  68. } else if ($arg == 'usatype') //美仓进销存浏览
  69. {
  70. $this->_usatype();
  71. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  72. {
  73. $this->_usatypeapp();
  74. } else if ($arg == 'enteradd') //入库操作
  75. {
  76. $this->_enteradd();
  77. } else if ($arg == 'enteredit') //修改
  78. {
  79. $this->_enteredit($arg_array);
  80. } else if ($arg == 'enter') //入库浏览
  81. {
  82. $this->_enter();
  83. } else if ($arg == 'out') //出库浏览
  84. {
  85. $this->_out();
  86. } else if ($arg == 'label') //出库标签浏览
  87. {
  88. $this->_label();
  89. } else if ($arg == 'outorder') //独立站出库订单
  90. {
  91. $this->_outorder();
  92. } else if ($arg == 'soutorder') //速卖通出库订单
  93. {
  94. $this->_soutorder();
  95. } else if ($arg == 'toutorder') //TT出库订单
  96. {
  97. $this->_toutorder();
  98. }else if ($arg == 'aoutorder') //amz出库订单
  99. {
  100. $this->_aoutorder();
  101. } else if ($arg == 'retreat') //退库订单
  102. {
  103. $this->_retreat();
  104. } else if ($arg == 'retreatlk') //退库订单
  105. {
  106. $this->_retreatlk();
  107. } else if ($arg == 'change') //更换标签
  108. {
  109. $this->_change();
  110. } else if ($arg == 'del') //删除
  111. {
  112. $this->_del();
  113. } else if ($arg == 'exceljxc') //进销存信息导出
  114. {
  115. $this->_exceljxc();
  116. } else if ($arg == 'excelr') //入库信息导出
  117. {
  118. $this->_excelr();
  119. } else if ($arg == 'excelct') //出库、退库信息导出
  120. {
  121. $this->_excelct();
  122. } else if ($arg == 'dccrtype') //根据出入库类型导出
  123. {
  124. $this->_dccrtype();
  125. } else if ($arg == 'excelcr') //出库、退库信息导出
  126. {
  127. $this->_excelcr();
  128. } else if ($arg == 'kcyz') //库存验证
  129. {
  130. $this->_kcyz();
  131. } else if ($arg == 'kj') //库存扣减
  132. {
  133. $this->_kj($arg_array);
  134. } else if ($arg == 'presetout') //预设库存导入
  135. {
  136. $this->_presetout($arg_array);
  137. } else if ($arg == 'presetedit') //预设库存导入
  138. {
  139. $this->_presetedit($arg_array);
  140. } else if ($arg == 'summary') //汇总导出
  141. {
  142. $this->_summary($arg_array);
  143. } else if ($arg == 'manifest') //usps发货清单
  144. {
  145. $this->_manifest();
  146. } else if ($arg == 'abnormal') //占单异常
  147. {
  148. $this->_abnormal();
  149. } else if ($arg == 'error') //0库存SKU
  150. {
  151. $this->_error();
  152. } else if ($arg == 'errorexcel') //0库存SKU导出
  153. {
  154. $this->_errorexcel();
  155. } else if ($arg == 'db') {
  156. $this->_db();
  157. } else if ($arg == 'dbrk') {
  158. $this->_dbrk();
  159. } else if ($arg == 'whlabelczdc') {
  160. $this->_whlabelczdc();
  161. } else if ($arg == 'print') {
  162. $this->_print($arg_array);
  163. } else if ($arg == 'usaprint') {
  164. $this->_usaprint($arg_array);
  165. } else if ($arg == 'printck') {
  166. $this->_printck($arg_array);
  167. } else if ($arg == 'printrk') {
  168. $this->_printrk($arg_array);
  169. } else if ($arg == 'printxzrk') {
  170. $this->_printxzrk($arg_array);
  171. } else if ($arg == 'printexcel') {
  172. $this->_printexcel($arg_array);
  173. } else if ($arg == 'uck') {
  174. $this->_uck();
  175. } else if ($arg == 'whlabelexcelzh') {
  176. $this->_whlabelexcelzh();
  177. } else if ($arg == 'fc') {
  178. $this->_fc();
  179. } else if ($arg == 'fcmb') {
  180. $this->_fcmb();
  181. } else if ($arg == 'fcexcel') {
  182. $this->_fcexcel();
  183. } else if ($arg == 'fcjxc') {
  184. $this->_fcjxc($arg_array);
  185. } else if ($arg == '0kcdel') {
  186. $this->_0kcdel(); //导表删除0库存
  187. } else if ($arg == 'gbhtype') {
  188. $this->_gbhtype(); //更改备货状态
  189. } else if($arg == 'excelrjs'){
  190. $this->_excelrjs();
  191. }else if($arg == "w_t_cs"){
  192. $this->_w_t_cs(); //首页
  193. }else {
  194. $this->_index();
  195. }
  196. }
  197. public function _w_t_cs(){
  198. $vip = 0;
  199. if (isset($_SESSION['api'])) {
  200. $user = $this->user->get_api($_SESSION['api']);
  201. $fgshop = "";
  202. $sid = "";
  203. $usersp = explode('|', trim($user['shop'], '|'));
  204. foreach ($usersp as $value) {
  205. $fgshop .= " shop = " . $value . " or";
  206. $sid .= " id = " . $value . " or";
  207. }
  208. if ($user['vip'] == 1) {
  209. $vip = 1;
  210. }
  211. } else {
  212. header('Location: /');
  213. exit;
  214. }
  215. $prc = array();
  216. $purchase = $this->purchase->find_all();
  217. foreach ($purchase as $k => $v) {
  218. $prc[$v['id']] = $v['title'];
  219. }
  220. $company = array();
  221. $ct = $this->company->find_all();
  222. foreach ($ct as $k => $v) {
  223. $company[$v['id']] = $v['title'];
  224. }
  225. $sp = array();
  226. $s = $this->shop->find_all('1=1', 'id,shopname');
  227. foreach ($s as $v) {
  228. $sp[$v['id']] = $v['shopname'];
  229. }
  230. $wh = array();
  231. $w = $this->warehouse->find_all('1=1', 'id,title');
  232. foreach ($w as $v) {
  233. $wh[$v['id']] = $v['title'];
  234. }
  235. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  236. $this->data['shop'] = $wlshop;
  237. $this->data['vip'] = $vip;
  238. $this->_Template('whlabel_typejs', $this->data);
  239. }
  240. //管理
  241. public function _index()
  242. {
  243. $post = $this->input->post(NULL, TRUE);
  244. if (isset($post['page'])) {
  245. $page = $this->input->post('page', true);
  246. $perpage = $this->input->post('perpage', true);
  247. $sku = $this->input->post('sku', true);
  248. $number = $this->input->post('number', true);
  249. $warehouse = $this->input->post('warehouse', true);
  250. $purchase = $this->input->post('purchase', true);
  251. $orderinfo = $this->input->post('orderinfo', true);
  252. $waybill = $this->input->post('waybill', true);
  253. $category = $this->input->post('category', true);
  254. $size = $this->input->post('size', true);
  255. $grade = $this->input->post('grade', true);
  256. $color = $this->input->post('color', true);
  257. $lowe = $this->input->post('lowe', true);
  258. $state = $this->input->post('state', true);
  259. $label = $this->input->post('label', true);
  260. $timetk = $this->input->post('timetkk', true);
  261. $timetj = $this->input->post('timetjj', true);
  262. $timetk = strtotime($timetk);
  263. $timetj = strtotime($timetj);
  264. $where = "1=1 ";
  265. if ($timetk && $timetj) {
  266. $where .= " and time > '$timetk' and time < '$timetj'";
  267. }
  268. if ($sku) {
  269. $where .= " and sku = '$sku'";
  270. }
  271. if ($number) {
  272. $where .= " and number = '$number'";
  273. }
  274. if ($warehouse) {
  275. $where .= " and warehouse = '$warehouse'";
  276. }
  277. if ($purchase) {
  278. $where .= " and purchase = '$purchase'";
  279. }
  280. if ($orderinfo) {
  281. $where .= " and orderinfo = '$orderinfo'";
  282. }
  283. if ($waybill) {
  284. $where .= " and waybill = '$waybill'";
  285. }
  286. if ($category) {
  287. $where .= " and features like '%-$category-%'";
  288. }
  289. if ($size) {
  290. $where .= " and features like '%-$size-%'";
  291. }
  292. if ($grade) {
  293. $where .= " and features like '%-$grade-%'";
  294. }
  295. if ($color) {
  296. $where .= " and features like '%-$color-%'";
  297. }
  298. if ($lowe) {
  299. $where .= " and features like '%-$lowe-%'";
  300. }
  301. if ($label) {
  302. $where .= " and label = '$label'";
  303. }
  304. if ($state != '') {
  305. $where .= " and state = '$state'";
  306. }
  307. //数据排序
  308. $order_str = "time desc";
  309. if (empty($page)) {
  310. $start = 0;
  311. $perpage = 1;
  312. } else {
  313. $start = ($page - 1) * $perpage;
  314. }
  315. //取得信息列表
  316. $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);
  317. foreach ($info_list as $key => $value) {
  318. $warehouse = $this->warehouse->read($value['warehouse']);
  319. $info_list[$key]['warehouse'] = $warehouse['title'];
  320. $purchase = $this->purchase->read($value['purchase']);
  321. $info_list[$key]['purchase'] = $purchase['title'];
  322. if ($value['enter'] != 0) {
  323. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  324. } else {
  325. $info_list[$key]['enter'] = "";
  326. }
  327. if ($value['outk'] != 0) {
  328. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  329. } else {
  330. $info_list[$key]['outk'] = "";
  331. }
  332. if ($value['printing'] != 0) {
  333. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  334. } else {
  335. $info_list[$key]['printing'] = "";
  336. }
  337. if ($value['orderinfo'] == 0) {
  338. $info_list[$key]['orderinfo'] = "";
  339. }
  340. if ($value['waybill'] == 0) {
  341. $info_list[$key]['waybill'] = "";
  342. }
  343. if ($value['state'] == 0) {
  344. $info_list[$key]['state'] = "在库";
  345. } else if ($value['state'] == 1) {
  346. $info_list[$key]['state'] = "出库";
  347. } else if ($value['state'] == 2) {
  348. $info_list[$key]['state'] = "退库";
  349. } else if ($value['state'] == 3) {
  350. $info_list[$key]['state'] = "调拨中";
  351. } else if ($value['state'] == 4) {
  352. $info_list[$key]['state'] = "再加工";
  353. } else if ($value['state'] == 5) {
  354. $info_list[$key]['state'] = "维修中";
  355. } else if ($value['state'] == 6) {
  356. $info_list[$key]['state'] = "盘亏";
  357. } else if ($value['state'] == 7) {
  358. $info_list[$key]['state'] = "更换标签";
  359. } else if ($value['state'] == 8) {
  360. $info_list[$key]['state'] = "其它";
  361. } else if ($value['state'] == 9) {
  362. $info_list[$key]['state'] = "预设";
  363. } else if ($value['state'] == 10) {
  364. $info_list[$key]['state'] = "美店零售";
  365. }
  366. if ($value['text'] == "") {
  367. $info_list[$key]['text'] = "";
  368. }
  369. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  370. }
  371. $total = $this->whlabel->find_count($where);
  372. $pagenum = ceil($total / $perpage);
  373. $over = $total - ($start + $perpage);
  374. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  375. echo json_encode($rows);
  376. exit;
  377. }
  378. if (isset($post['outsku'])) {
  379. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  380. $cz = $this->input->post('cz', true);
  381. if ($cz == '1') {
  382. $sku = $this->input->post('outsku', true);
  383. if ($sku) {
  384. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  385. if (count($data) < 1) {
  386. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  387. exit;
  388. }
  389. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  390. echo json_encode(array('success' => true));
  391. exit;
  392. }
  393. } else {
  394. echo json_encode(array('msg' => '此方法禁用!', 'success' => false));
  395. exit;
  396. $sku = $this->input->post('outsku', true);
  397. if ($sku) {
  398. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  399. if (count($data) < 1) {
  400. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  401. exit;
  402. }
  403. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  404. echo json_encode(array('success' => true));
  405. exit;
  406. }
  407. }
  408. }
  409. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  410. $this->_Template('whlabel', $this->data);
  411. }
  412. //在库标签
  413. public function _existence()
  414. {
  415. $post = $this->input->post(NULL, TRUE);
  416. if (isset($post['s'])) {
  417. $id_arr = $this->input->post('s');
  418. $id_arr = explode(',', $id_arr);
  419. if (!$id_arr) {
  420. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  421. exit;
  422. }
  423. //循环删除记录
  424. foreach ($id_arr as $v) {
  425. $sid = $this->whlabel->read($v);
  426. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  427. if ($count > 0) {
  428. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  429. exit;
  430. }
  431. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  432. if (count($zt) > 0) {
  433. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  434. exit;
  435. }
  436. $this->whlabel->remove($v);
  437. }
  438. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  439. exit;
  440. }
  441. if (isset($post['page'])) {
  442. $page = $this->input->post('page', true);
  443. $perpage = $this->input->post('perpage', true);
  444. $warehouse = $this->input->post('warehouse', true);
  445. $label = $this->input->post('label', true);
  446. $where = "1=1 and state = 0";
  447. if ($warehouse) {
  448. $where .= " and warehouse = '$warehouse'";
  449. }
  450. if ($label) {
  451. $where .= " and label = '$label'";
  452. }
  453. //数据排序
  454. $order_str = "time asc";
  455. if (empty($page)) {
  456. $start = 0;
  457. $perpage = 1;
  458. } else {
  459. $start = ($page - 1) * $perpage;
  460. }
  461. //取得信息列表
  462. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  463. foreach ($info_list as $key => $value) {
  464. if ($value['enter'] != 0) {
  465. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  466. } else {
  467. $info_list[$key]['enter'] = "";
  468. }
  469. if ($value['printing'] != 0) {
  470. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  471. } else {
  472. $info_list[$key]['printing'] = "";
  473. }
  474. }
  475. $total = $this->whlabel->find_count($where);
  476. $pagenum = ceil($total / $perpage);
  477. $over = $total - ($start + $perpage);
  478. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  479. echo json_encode($rows);
  480. exit;
  481. }
  482. $this->_Template('whlabel_existence', $this->data);
  483. }
  484. //进销存浏览
  485. public function _typedy($arg_array)
  486. {
  487. $prc = array();
  488. $purchase = $this->purchase->find_all();
  489. foreach ($purchase as $k => $v) {
  490. $prc[$v['id']] = $v['title'];
  491. }
  492. $post = $this->input->post(NULL, TRUE);
  493. if (isset($post['page'])) {
  494. $page = $this->input->post('page', true);
  495. $perpage = $this->input->post('perpage', true);
  496. $category = $this->input->post('category', true);
  497. $size = $this->input->post('size', true);
  498. $grade = $this->input->post('grade', true);
  499. $color = $this->input->post('color', true);
  500. $lowe = $this->input->post('lowe', true);
  501. $sku = $this->input->post('sku');
  502. $title = $this->input->post('title');
  503. $warehouse = $this->input->post('warehouse', true);
  504. $usa = $this->input->post('usa', true);
  505. $purchase = $this->input->post('purchase', true);
  506. $lacetype = $this->input->post('lacetype', true);
  507. $haircap = $this->input->post('haircap', true);
  508. $density = $this->input->post('density', true);
  509. $details = $this->input->post('details', true);
  510. $state = $this->input->post('state', true);
  511. $lacecolor = $this->input->post('lacecolor', true);
  512. $hairnumber = $this->input->post('hairnumber', true);
  513. $cklx = $this->input->post('cklx', true);
  514. $ktime = $this->input->post('ktime', true);
  515. $jtime = $this->input->post('jtime', true);
  516. $sm = $this->input->post('sm', true);
  517. $cpbz = $this->input->post('cpbz', true);
  518. $type = $this->input->post('type', true);
  519. $ktime = strtotime($ktime);
  520. $jtime = strtotime($jtime);
  521. $where = "1=1";
  522. $gj = "";
  523. $ck = "";
  524. if ($usa) {
  525. if (!$warehouse) {
  526. $where .= " and (warehouse = '5' or warehouse = '8')";
  527. }
  528. }
  529. if ($warehouse) {
  530. $where .= " and warehouse = '$warehouse'";
  531. }
  532. if ($details) {
  533. $where .= " and details = '$details'";
  534. }
  535. if ($purchase) {
  536. $where .= " and purchase = '$purchase'";
  537. }
  538. if (isset($state)) {
  539. if($state >-1){
  540. $where .= " and state = '$state'";
  541. }
  542. }
  543. if ($lacetype) {
  544. $where .= " and features like '%-$lacetype-%'";
  545. }
  546. if ($category) {
  547. $where .= " and features like '%-$category-%'";
  548. }
  549. if ($size) {
  550. $where .= " and features like '%-$size-%'";
  551. }
  552. if ($grade) {
  553. $where .= " and features like '%-$grade-%'";
  554. }
  555. if ($color) {
  556. $where .= " and features like '%-$color-%'";
  557. }
  558. if ($lowe) {
  559. $where .= " and features like '%-$lowe-%'";
  560. }
  561. if ($haircap) {
  562. $where .= " and features like '%-$haircap-%'";
  563. }
  564. if ($density) {
  565. $where .= " and features like '%-$density-%'";
  566. }
  567. if ($lacecolor) {
  568. $where .= " and features like '%-$lacecolor-%'";
  569. }
  570. if($sm){
  571. $where .= " and sm like '%".$sm."%'";
  572. }
  573. if($cpbz){
  574. $where .= " and cpbz like '%".$cpbz."%'";
  575. }
  576. if($type){
  577. $where .= " and type = ".$type."";
  578. }
  579. if (!empty($hairnumber)) {
  580. $where .= " and features like '%-128-%' ";
  581. if ($hairnumber < 0) {
  582. $class_list = $this->typeclass->find_all('classid = 43');
  583. foreach ($class_list as $v) {
  584. $where .= " and features not like '%-" . $v['id'] . "-%'";
  585. }
  586. } else {
  587. $where .= " and features like '%-$hairnumber-%'";
  588. }
  589. }
  590. $where_add = '';
  591. if ($cklx) {
  592. $shop = $this->shop->read($cklx);
  593. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  594. }
  595. if ($ktime && $jtime) {
  596. $gj = " and enter > '$ktime' and enter < '$jtime'";
  597. $ck = " and outk > '$ktime' and outk < '$jtime'";
  598. }
  599. //数据排序
  600. $order_str = "id desc";
  601. if (empty($page)) {
  602. $start = 0;
  603. $perpage = 1;
  604. } else {
  605. $start = ($page - 1) * $perpage;
  606. }
  607. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  608. if ($sku) {
  609. $sku = trim($sku, ' ');
  610. $sku = trim($sku, ' ');
  611. $where .= " and sku like '%$sku%'";
  612. $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);
  613. } else if ($title) {
  614. $title = trim($title, ' ');
  615. $title = trim($title, ' ');
  616. $where .= " and title like '%$title%'";
  617. $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);
  618. } else {
  619. //$where .= " and time > '$ktime' and time < '$jtime'";
  620. $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);
  621. }
  622. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  623. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  624. foreach ($info_list as $k => $v) {
  625. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  626. unset($info_list[$k]['pm']);
  627. unset($info_list[$k]['jm']);
  628. unset($info_list[$k]['bm']);
  629. }
  630. //取得信息列表
  631. $rows = array();
  632. $list = array();
  633. foreach ($info_list as $key => $value) {
  634. $warehouse = $this->warehouse->read($value['warehouse']);
  635. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  636. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  637. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  638. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  639. $info_list[$key]['label'] = $value['sm'];
  640. $number = $value['number'];
  641. $ftime = time() - 15 * 24 * 3600;
  642. $info_list[$key]['warehouse'] = $warehouse['title'];
  643. $info_list[$key]['features'] = count($c);
  644. $z = count($z); //查看订单号
  645. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  646. $ztdata = '';
  647. if (count($zt) > 0) {
  648. foreach ($zt as $vv) {
  649. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  650. }
  651. }
  652. $info_list[$key]['number'] = $ztdata;
  653. $info_list[$key]['sm'] = $z;
  654. $details = array();
  655. $cpid = array();
  656. foreach ($c as $k => $v) {
  657. $details[$v['details']] = $v['details'];
  658. if ($v['cpid'] != 0) {
  659. $cpid[$v['cpid']] = $v['cpid'];
  660. }
  661. }
  662. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  663. if ($value['shop'] != '') {
  664. $shop = explode(',', trim($value['shop'], ','));
  665. $shop = $this->shop->read($shop[0]);
  666. $info_list[$key]['shop'] = $shop['shopname'];
  667. }
  668. }
  669. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  670. $pagenum = ceil($total / $perpage);
  671. $over = $total - ($start + $perpage);
  672. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  673. echo json_encode($rows);
  674. exit;
  675. }
  676. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  677. $this->_Template('whlabel_typedy', $this->data);
  678. }
  679. //进销存浏览
  680. public function _typedy_ck($arg_array)
  681. {
  682. $prc = array();
  683. $purchase = $this->purchase->find_all();
  684. foreach ($purchase as $k => $v) {
  685. $prc[$v['id']] = $v['title'];
  686. }
  687. $post = $this->input->post(NULL, TRUE);
  688. if (isset($post['page'])) {
  689. $page = $this->input->post('page', true);
  690. $perpage = $this->input->post('perpage', true);
  691. $category = $this->input->post('category', true);
  692. $size = $this->input->post('size', true);
  693. $grade = $this->input->post('grade', true);
  694. $color = $this->input->post('color', true);
  695. $lowe = $this->input->post('lowe', true);
  696. $sku = $this->input->post('sku');
  697. $title = $this->input->post('title');
  698. $warehouse = $this->input->post('warehouse', true);
  699. $usa = $this->input->post('usa', true);
  700. $purchase = $this->input->post('purchase', true);
  701. $lacetype = $this->input->post('lacetype', true);
  702. $haircap = $this->input->post('haircap', true);
  703. $density = $this->input->post('density', true);
  704. $details = $this->input->post('details', true);
  705. $state = $this->input->post('state', true);
  706. $lacecolor = $this->input->post('lacecolor', true);
  707. $cklx = $this->input->post('cklx', true);
  708. $ktime = $this->input->post('ktime', true);
  709. $jtime = $this->input->post('jtime', true);
  710. $ktime = strtotime($ktime);
  711. $jtime = strtotime($jtime);
  712. $where = "1=1";
  713. $gj = "";
  714. $ck = "";
  715. if ($lacetype) {
  716. $where .= " and features like '%-$lacetype-%'";
  717. }
  718. if ($category) {
  719. $where .= " and features like '%-$category-%'";
  720. }
  721. if ($size) {
  722. $where .= " and features like '%-$size-%'";
  723. }
  724. if ($grade) {
  725. $where .= " and features like '%-$grade-%'";
  726. }
  727. if ($color) {
  728. $where .= " and features like '%-$color-%'";
  729. }
  730. if ($lowe) {
  731. $where .= " and features like '%-$lowe-%'";
  732. }
  733. if ($haircap) {
  734. $where .= " and features like '%-$haircap-%'";
  735. }
  736. if ($density) {
  737. $where .= " and features like '%-$density-%'";
  738. }
  739. if ($lacecolor) {
  740. $where .= " and features like '%-$lacecolor-%'";
  741. }
  742. if ($usa) {
  743. if (!$warehouse) {
  744. $where .= " and (warehouse = '5' or warehouse = '8')";
  745. }
  746. }
  747. if ($warehouse) {
  748. $where .= " and warehouse = '$warehouse'";
  749. }
  750. if ($details) {
  751. $where .= " and details = '$details'";
  752. }
  753. if ($purchase) {
  754. $where .= " and purchase = '$purchase'";
  755. }
  756. if ($state) {
  757. $where .= " and state = '$state'";
  758. }
  759. $where_add = '';
  760. if ($cklx) {
  761. $shop = $this->shop->read($cklx);
  762. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  763. }
  764. if ($ktime && $jtime) {
  765. $gj = " and enter > '$ktime' and enter < '$jtime'";
  766. $ck = " and outk > '$ktime' and outk < '$jtime'";
  767. }
  768. //数据排序
  769. $order_str = "id desc";
  770. if (empty($page)) {
  771. $start = 0;
  772. $perpage = 1;
  773. } else {
  774. $start = ($page - 1) * $perpage;
  775. }
  776. if ($sku) {
  777. $sku = trim($sku, ' ');
  778. $sku = trim($sku, ' ');
  779. $where .= " and sku like '%$sku%'";
  780. $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);
  781. } else if ($title) {
  782. $title = trim($title, ' ');
  783. $title = trim($title, ' ');
  784. $where .= " and title like '%$title%'";
  785. $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);
  786. } else {
  787. //$where .= " and time > '$ktime' and time < '$jtime'";
  788. $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);
  789. }
  790. //取得信息列表
  791. $rows = array();
  792. $list = array();
  793. foreach ($info_list as $key => $value) {
  794. $warehouse = $this->warehouse->read($value['warehouse']);
  795. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  796. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  797. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  798. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  799. $ftime = time() - 15 * 24 * 3600;
  800. $info_list[$key]['warehouse'] = $warehouse['title'];
  801. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  802. //$z = count($z);//查看订单号
  803. //$info_list[$key]['zd'] = $z;
  804. $details = array();
  805. $cpid = array();
  806. foreach ($c as $k => $v) {
  807. $details[$v['details']] = $v['details'];
  808. if ($v['cpid'] != 0) {
  809. $cpid[$v['cpid']] = $v['cpid'];
  810. }
  811. }
  812. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  813. if ($value['shop'] != '') {
  814. $shop = explode(',', trim($value['shop'], ','));
  815. $shop = $this->shop->read($shop[0]);
  816. $info_list[$key]['shop'] = $shop['shopname'];
  817. }
  818. }
  819. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  820. $pagenum = ceil($total / $perpage);
  821. $over = $total - ($start + $perpage);
  822. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  823. echo json_encode($rows);
  824. exit;
  825. }
  826. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  827. $this->_Template('whlabel_typedy_ck', $this->data);
  828. }
  829. public function _typeck($arg_array)
  830. {
  831. $prc = array();
  832. $purchase = $this->purchase->find_all();
  833. foreach ($purchase as $k => $v) {
  834. $prc[$v['id']] = $v['title'];
  835. }
  836. $post = $this->input->post(NULL, TRUE);
  837. if (isset($post['page'])) {
  838. $page = $this->input->post('page', true);
  839. $perpage = $this->input->post('perpage', true);
  840. $category = $this->input->post('category', true);
  841. $size = $this->input->post('size', true);
  842. $grade = $this->input->post('grade', true);
  843. $color = $this->input->post('color', true);
  844. $lacecolor = $this->input->post('lacecolor', true);
  845. $lowe = $this->input->post('lowe', true);
  846. $sku = $this->input->post('sku');
  847. $title = $this->input->post('title');
  848. $warehouse = 13;
  849. $usa = $this->input->post('usa', true);
  850. $purchase = $this->input->post('purchase', true);
  851. $lacetype = $this->input->post('lacetype', true);
  852. $haircap = $this->input->post('haircap', true);
  853. $density = $this->input->post('density', true);
  854. $details = $this->input->post('details', true);
  855. $state = $this->input->post('state', true);
  856. $ktime = $this->input->post('ktime', true);
  857. $jtime = $this->input->post('jtime', true);
  858. $ktime = strtotime($ktime);
  859. $jtime = strtotime($jtime);
  860. $where = "1=1";
  861. $gj = "";
  862. $ck = "";
  863. if ($lacetype) {
  864. $where .= " and features like '%-$lacetype-%'";
  865. }
  866. if ($category) {
  867. $where .= " and features like '%-$category-%'";
  868. }
  869. if ($size) {
  870. $where .= " and features like '%-$size-%'";
  871. }
  872. if ($grade) {
  873. $where .= " and features like '%-$grade-%'";
  874. }
  875. if ($color) {
  876. $where .= " and features like '%-$color-%'";
  877. }
  878. if ($lacecolor) {
  879. $where .= " and features like '%-$lacecolor-%'";
  880. }
  881. if ($lowe) {
  882. $where .= " and features like '%-$lowe-%'";
  883. }
  884. if ($haircap) {
  885. $where .= " and features like '%-$haircap-%'";
  886. }
  887. if ($density) {
  888. $where .= " and features like '%-$density-%'";
  889. }
  890. if ($warehouse) {
  891. $where .= " and warehouse = '$warehouse'";
  892. }
  893. if ($details) {
  894. $where .= " and details = '$details'";
  895. }
  896. if ($purchase) {
  897. $where .= " and purchase = '$purchase'";
  898. }
  899. if ($state) {
  900. $where .= " and state = '$state'";
  901. }
  902. if ($ktime && $jtime) {
  903. $gj = " and enter > '$ktime' and enter < '$jtime'";
  904. $ck = " and outk > '$ktime' and outk < '$jtime'";
  905. }
  906. //数据排序
  907. $order_str = "id desc";
  908. if (empty($page)) {
  909. $start = 0;
  910. $perpage = 1;
  911. } else {
  912. $start = ($page - 1) * $perpage;
  913. }
  914. if ($sku) {
  915. $sku = trim($sku, ' ');
  916. $sku = trim($sku, ' ');
  917. $where .= " and sku like '%$sku%'";
  918. } else if ($title) {
  919. $title = trim($title, ' ');
  920. $title = trim($title, ' ');
  921. $where .= " and title like '%$title%'";
  922. }
  923. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  924. //取得信息列表
  925. $t = array();
  926. $typeclass = $this->typeclass->find_all();
  927. foreach ($typeclass as $v) {
  928. $t[$v['id']] = $v;
  929. }
  930. $rows = array();
  931. $list = array();
  932. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  933. foreach ($info_list as $key => $value) {
  934. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  935. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  936. $warehouse = $this->warehouse->read($value['warehouse']);
  937. $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');
  938. $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'] . '"');
  939. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  940. $number = $value['number'];
  941. $ftime = time() - 15 * 24 * 3600;
  942. $z = count($z); //查看订单号
  943. $info_list[$key]['warehouse'] = $warehouse['title'];
  944. $info_list[$key]['features'] = count($c);
  945. $info_list[$key]['number'] = $z;
  946. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  947. $details = array();
  948. $cpid = array();
  949. foreach ($c as $k => $v) {
  950. $details[$v['details']] = $v['details'];
  951. if ($v['cpid'] != 0) {
  952. $cpid[$v['cpid']] = $v['cpid'];
  953. }
  954. }
  955. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  956. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  957. unset($info_list[$key]['pm']);
  958. unset($info_list[$key]['jm']);
  959. unset($info_list[$key]['bm']);
  960. }
  961. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  962. $pagenum = ceil($total / $perpage);
  963. $over = $total - ($start + $perpage);
  964. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  965. echo json_encode($rows);
  966. exit;
  967. }
  968. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  969. $this->_Template('whlabel_typeck', $this->data);
  970. }
  971. //进销存导出
  972. public function _whlabeckdc()
  973. {
  974. $prc = array();
  975. $purchase = $this->purchase->find_all();
  976. foreach ($purchase as $k => $v) {
  977. $prc[$v['id']] = $v['title'];
  978. }
  979. if (isset($_GET['excel'])) {
  980. $where = "sku != 'Preset'";
  981. //数据排序
  982. $order_str = "id desc";
  983. if (empty($page)) {
  984. $start = 0;
  985. $perpage = 1;
  986. } else {
  987. $start = ($page - 1) * $perpage;
  988. }
  989. $category = $this->input->get('category', true);
  990. $color = $this->input->get('color', true);
  991. $lowe = $this->input->get('lowe', true);
  992. $lacetype = $this->input->get('lacetype', true);
  993. $size = $this->input->get('size', true);
  994. $density = $this->input->get('density', true);
  995. $haircap = $this->input->get('haircap', true);
  996. $sku = $this->input->get('sku', true);
  997. $details = $this->input->get('details', true);
  998. $warehouse = 13;
  999. $excelid = $this->input->get('sid', true);
  1000. if ($category) {
  1001. $where .= " and features like '%-$category-%'";
  1002. }
  1003. if ($color) {
  1004. $where .= " and features like '%-$color-%'";
  1005. }
  1006. if ($lowe) {
  1007. $where .= " and features like '%-$lowe-%'";
  1008. }
  1009. if ($lacetype) {
  1010. $where .= " and features like '%-$lacetype-%'";
  1011. }
  1012. if ($size) {
  1013. $where .= " and features like '%-$size-%'";
  1014. }
  1015. if ($density) {
  1016. $where .= " and features like '%-$density-%'";
  1017. }
  1018. if ($haircap) {
  1019. $where .= " and features like '%-$haircap-%'";
  1020. }
  1021. if ($warehouse) {
  1022. $where .= " and warehouse = '$warehouse'";
  1023. }
  1024. if ($sku) {
  1025. $where .= " and sku like '%$sku%'";
  1026. }
  1027. if ($details) {
  1028. $where .= " and details = '$details'";
  1029. }
  1030. $xzid = '';
  1031. if ($excelid) {
  1032. $excelid = explode(',', trim($excelid, ','));
  1033. foreach ($excelid as $key => $value) {
  1034. $xzid .= " id = " . $value . " or";
  1035. }
  1036. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1037. }
  1038. //取得信息列表
  1039. /**
  1040. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1041. $rows = array();$list = array();
  1042. foreach ($info_list as $key=>$value)
  1043. {
  1044. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1045. }
  1046. **/
  1047. $wh = array();
  1048. $w = $this->warehouse->find_all('1=1', 'id,title');
  1049. foreach ($w as $v) {
  1050. $wh[$v['id']] = $v['title'];
  1051. }
  1052. $tc = array();
  1053. $tcdata = array();
  1054. $list = array();
  1055. $classid = $this->classid->sku();
  1056. $tcall = $this->typeclass->find_all();
  1057. $typeclass = array();
  1058. foreach ($tcall as $v)
  1059. {
  1060. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1061. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1062. }
  1063. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  1064. foreach ($rows as $key => $value) {
  1065. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1066. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1067. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1068. $rows[$key]['cpbz'] = $u9_info['bm'];
  1069. $rows[$key]['cs'] = $u9_info['jm'];
  1070. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1071. $details = array();
  1072. $cpid = array();
  1073. $cpbz = array();
  1074. $c = 0;
  1075. $g = 0;
  1076. $x = 0;
  1077. $t = 0;
  1078. $s = 0;
  1079. $q = 0;
  1080. foreach ($sd as $k => $v) {
  1081. if ($v['state'] == 0) {
  1082. $c++;
  1083. }
  1084. if ($v['state'] != 9) {
  1085. $g++;
  1086. }
  1087. if ($v['state'] == 1) {
  1088. $x++;
  1089. }
  1090. if ($v['state'] == 2) {
  1091. $t++;
  1092. }
  1093. if ($v['state'] == 8) {
  1094. $s++;
  1095. }
  1096. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1097. $q++;
  1098. }
  1099. $details[$v['details']] = $v['details'];
  1100. if ($v['cpid'] != 0) {
  1101. $cpid[$v['cpid']] = $v['cpid'];
  1102. }
  1103. if ($v['cpbz'] != '') {
  1104. $cpbz[$v['cpbz']] = $v['cpbz'];
  1105. }
  1106. }
  1107. $rows[$key]['details'] = implode("、", $details);
  1108. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1109. $number = $value['number'];
  1110. $ftime = time() - 15 * 24 * 3600;
  1111. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1112. $rows[$key]['number'] = $g;
  1113. $rows[$key]['features'] = $c;
  1114. $rows[$key]['x'] = $x;
  1115. $rows[$key]['t'] = $t;
  1116. $rows[$key]['s'] = $s;
  1117. $rows[$key]['q'] = $q;
  1118. $rows[$key]['wzsl'] = count($details);
  1119. }
  1120. $title = "进销存统计表" . date('Y-m-d', time());
  1121. $titlename = "<table border=1>
  1122. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1123. <tr align='center'>
  1124. <td>仓库</td>
  1125. <td>供应商</td>
  1126. <td>位置</td>
  1127. <td>库存编码</td>
  1128. <td>SKU</td>
  1129. <td>用友编码</td>
  1130. <td>用友料号</td>
  1131. <td>产品英文名</td>
  1132. <td>产品中文名</td>
  1133. <td>入库总量</td>
  1134. <td>库存数量</td>
  1135. <td>销售数量</td>
  1136. <td>退货数量</td>
  1137. <td>删除数量</td>
  1138. <td>其它操作</td>
  1139. <td>位置数量</td>
  1140. </tr>
  1141. </table>";
  1142. $filename = $title . ".xls";
  1143. $tail = "";
  1144. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1145. }
  1146. }
  1147. public function _type()
  1148. {
  1149. $vip = 0;
  1150. if (isset($_SESSION['api'])) {
  1151. $user = $this->user->get_api($_SESSION['api']);
  1152. $fgshop = "";
  1153. $sid = "";
  1154. $usersp = explode('|', trim($user['shop'], '|'));
  1155. foreach ($usersp as $value) {
  1156. $fgshop .= " shop = " . $value . " or";
  1157. $sid .= " id = " . $value . " or";
  1158. }
  1159. if ($user['vip'] == 1) {
  1160. $vip = 1;
  1161. }
  1162. } else {
  1163. header('Location: /');
  1164. exit;
  1165. }
  1166. $prc = array();
  1167. $purchase = $this->purchase->find_all();
  1168. foreach ($purchase as $k => $v) {
  1169. $prc[$v['id']] = $v['title'];
  1170. }
  1171. $company = array();
  1172. $ct = $this->company->find_all();
  1173. foreach ($ct as $k => $v) {
  1174. $company[$v['id']] = $v['title'];
  1175. }
  1176. $sp = array();
  1177. $s = $this->shop->find_all('1=1', 'id,shopname');
  1178. foreach ($s as $v) {
  1179. $sp[$v['id']] = $v['shopname'];
  1180. }
  1181. $wh = array();
  1182. $w = $this->warehouse->find_all('1=1', 'id,title');
  1183. foreach ($w as $v) {
  1184. $wh[$v['id']] = $v['title'];
  1185. }
  1186. $post = $this->input->post(NULL, TRUE);
  1187. if (isset($post['page'])) {
  1188. $page = $this->input->post('page', true);
  1189. $perpage = $this->input->post('perpage', true);
  1190. $category = $this->input->post('category', true);
  1191. $size = $this->input->post('size', true);
  1192. $grade = $this->input->post('grade', true);
  1193. $color = $this->input->post('color', true);
  1194. $lowe = $this->input->post('lowe', true);
  1195. $sku = $this->input->post('sku');
  1196. $title = $this->input->post('title');
  1197. $warehouse = $this->input->post('warehouse', true);
  1198. $usa = $this->input->post('usa', true);
  1199. $purchase = $this->input->post('purchase', true);
  1200. $lacetype = $this->input->post('lacetype', true);
  1201. $haircap = $this->input->post('haircap', true);
  1202. $density = $this->input->post('density', true);
  1203. $details = $this->input->post('details', true);
  1204. $state = $this->input->post('state', true);
  1205. $shop = $this->input->post('shop', true);
  1206. $lacecolor = $this->input->post('lacecolor', true);
  1207. $hairnumber = $this->input->post('hairnumber', true);
  1208. $type = $this->input->post('type', true);
  1209. $ktime = $this->input->post('ktime', true);
  1210. $jtime = $this->input->post('jtime', true);
  1211. $ktime = strtotime($ktime);
  1212. $jtime = strtotime($jtime);
  1213. $cpbz = $this->input->post('cpbz', true);
  1214. $sm = $this->input->post('sm', true);
  1215. $where = "1=1";
  1216. $gj = "";
  1217. $ck = "";
  1218. if ($usa) {
  1219. if (!$warehouse) {
  1220. $where .= " and (warehouse = '5' or warehouse = '8')";
  1221. }
  1222. }
  1223. if ($warehouse) {
  1224. $where .= " and warehouse = '$warehouse'";
  1225. }
  1226. if ($details) {
  1227. $where .= " and details = '$details'";
  1228. }
  1229. if ($purchase) {
  1230. $where .= " and purchase = '$purchase'";
  1231. }
  1232. if ($state) {
  1233. $where .= " and state = '$state'";
  1234. }
  1235. if ($shop) {
  1236. $where .= " and shop like '%$shop%'";
  1237. }
  1238. if ($type) {
  1239. $where .= " and type = '$type'";
  1240. }
  1241. if ($ktime && $jtime) {
  1242. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1243. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1244. }
  1245. if ($cpbz) {
  1246. $where .= " and cpbz like '%$cpbz%' ";
  1247. }
  1248. if ($sm) {
  1249. $where .= " and sm like '%$sm%' ";
  1250. }
  1251. if ($lacecolor) {
  1252. $where .= " and features like '%-$lacecolor-%'";
  1253. }
  1254. if ($lacetype) {
  1255. $where .= " and features like '%-$lacetype-%'";
  1256. }
  1257. if ($category) {
  1258. $where .= " and features like '%-$category-%'";
  1259. }
  1260. if ($size) {
  1261. $where .= " and features like '%-$size-%'";
  1262. }
  1263. if ($grade) {
  1264. $where .= " and features like '%-$grade-%'";
  1265. }
  1266. if ($color) {
  1267. $where .= " and features like '%-$color-%'";
  1268. }
  1269. if ($lowe) {
  1270. $where .= " and features like '%-$lowe-%'";
  1271. }
  1272. if ($haircap) {
  1273. $where .= " and features like '%-$haircap-%'";
  1274. }
  1275. if ($density) {
  1276. $where .= " and features like '%-$density-%'";
  1277. }
  1278. if (!empty($hairnumber)) {
  1279. $where .= " and features like '%-128-%' ";
  1280. if ($hairnumber < 0) {
  1281. $class_list = $this->typeclass->find_all('classid = 43');
  1282. foreach ($class_list as $v) {
  1283. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1284. }
  1285. } else {
  1286. $where .= " and features like '%-$hairnumber-%'";
  1287. }
  1288. }
  1289. //数据排序
  1290. $order_str = "id desc";
  1291. if (empty($page)) {
  1292. $start = 0;
  1293. $perpage = 1;
  1294. } else {
  1295. $start = ($page - 1) * $perpage;
  1296. }
  1297. $fjnr = '';
  1298. if ($sku) {
  1299. $sku = trim($sku, ' ');
  1300. $sku = trim($sku, ' ');
  1301. $fjnr .= " and sku like '%$sku%'";
  1302. }
  1303. if ($title) {
  1304. $title = trim($title, ' ');
  1305. $title = trim($title, ' ');
  1306. $fjnr .= " and title like '%$title%'";
  1307. }
  1308. $wt = array();
  1309. $whlabel_type = $this->whlabel_type->find_all();
  1310. foreach ($whlabel_type as $v) {
  1311. $wt[$v['id']] = $v['title'];
  1312. }
  1313. //$where .= " and time > '$ktime' and time < '$jtime'";
  1314. $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
  1315. //取得信息列表
  1316. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1317. $rows = array();
  1318. $list = array();
  1319. foreach ($info_list as $key => $value) {
  1320. if (isset($wt[$value['type']])) {
  1321. $info_list[$key]['type'] = $wt[$value['type']];
  1322. } else {
  1323. $info_list[$key]['type'] = '未设置';
  1324. }
  1325. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1326. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1327. $ztdata = '';
  1328. if (count($zt) > 0) {
  1329. foreach ($zt as $vv) {
  1330. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1331. }
  1332. }
  1333. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1334. $cdata = array_filter($qbdata, function ($item) {
  1335. return $item['state'] < 1;
  1336. });
  1337. $c = array_sum(array_column($cdata, 'jnum'));
  1338. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1339. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1340. });
  1341. $g = array_sum(array_column($gdata, 'jnum'));
  1342. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1343. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1344. });
  1345. $x = array_sum(array_column($xdata, 'jnum'));
  1346. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1347. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1348. });
  1349. $t = array_sum(array_column($tdata, 'jnum'));
  1350. // $zdata = array_filter($qbdata, function ($item) {
  1351. // return $item['zd'] != "" && $item['state'] < 1;
  1352. // });
  1353. // $z = array_sum(array_column($zdata, 'jnum'));
  1354. $zdata = array_filter($qbdata, function ($item) {
  1355. return $item['zd'] != "" && $item['state'] < 1;
  1356. });
  1357. $z = array_sum(array_column($zdata, 'jnum'));
  1358. //$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');
  1359. //$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'].'"');
  1360. //$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'].'"');
  1361. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1362. //$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'].'"');
  1363. $details = array();
  1364. $cpid = array();
  1365. $od = array();
  1366. $odid = '';
  1367. $companytitle = '';
  1368. $shop_list = [];
  1369. foreach ($qbdata as $v) {
  1370. if ($v['zd'] != "" && $v['state'] < 1) {
  1371. if (!isset($od[$v['zd']])) {
  1372. $od[$v['zd']] = 1; //所有数据sku
  1373. } else {
  1374. $od[$v['zd']] = $od[$v['zd']] + 1;
  1375. }
  1376. }
  1377. if ($v['state'] < 1) {
  1378. $details[$v['details']] = $v['details'];
  1379. if ($v['cpid'] != 0) {
  1380. $cpid[$v['cpid']] = $v['cpid'];
  1381. }
  1382. }
  1383. if($v['state'] == 0){
  1384. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1385. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1386. }
  1387. if ($v['shop'] != '') {
  1388. $shop = explode(',', trim($v['shop'], ','));
  1389. foreach ($shop as $vv) {
  1390. if (!in_array($vv, $shop_list)) {
  1391. $shop_list[] = $vv;
  1392. }
  1393. }
  1394. }
  1395. }
  1396. }
  1397. foreach ($od as $k => $vv) {
  1398. $odid .= $k . '数量' . $vv;
  1399. }
  1400. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1401. $info_list[$key]['label'] = $value['sm'];
  1402. $number = $value['number'];
  1403. $ftime = time() - 15 * 24 * 3600;
  1404. $z = $z . '(' . $odid . ')'; //查看订单号
  1405. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1406. $info_list[$key]['features'] = $c;
  1407. $info_list[$key]['number'] = $ztdata;
  1408. $info_list[$key]['sm'] = $g;
  1409. $info_list[$key]['x'] = $x;
  1410. $info_list[$key]['t'] = $t;
  1411. $info_list[$key]['z'] = $z;
  1412. /**
  1413. foreach ($cdata as $k=>$v)
  1414. {
  1415. $details[$v['details']] = $v['details'];
  1416. if($v['cpid'] != 0)
  1417. {
  1418. $cpid[$v['cpid']] = $v['cpid'];
  1419. }
  1420. }
  1421. **/
  1422. $info_list[$key]['shop'] = '';
  1423. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1424. // if ($value['shop'] != '') {
  1425. // $shop = explode(',', trim($value['shop'], ','));
  1426. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1427. // }
  1428. $shop_list = array_unique($shop_list);
  1429. $shop_str = '';
  1430. foreach ($shop_list as $v) {
  1431. if(isset($sp[$v])){
  1432. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1433. }
  1434. }
  1435. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1436. /**
  1437. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1438. if(isset($companytitle[0]))
  1439. {
  1440. foreach ($companytitle as $k=>$v)
  1441. {
  1442. if($v['companytitle'] != '')
  1443. {
  1444. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1445. }
  1446. }
  1447. }
  1448. **/
  1449. }
  1450. $final_all_list = [];
  1451. foreach ($info_list as $k => $v) {
  1452. $final_all_list[] = [
  1453. 'id' => $v['id'],
  1454. "warehouse" => $v["warehouse"],
  1455. "purchase" => $v["purchase"],
  1456. "sku" => $v["sku"],
  1457. "title" => $v["title"] . "<br/>" . $v["pm"],
  1458. "details" => $v["details"],
  1459. "shop" => $v["shop"],
  1460. "cpbz" => $v["cpbz"],
  1461. 'label' => $v['label'],
  1462. "type" => $v["type"],
  1463. "features" => $v["features"],
  1464. "number" => $v["number"],
  1465. "sm" => $v["sm"],
  1466. "x" => $v["x"],
  1467. "t" => $v["t"],
  1468. "z" => $v["z"]
  1469. ];
  1470. }
  1471. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1472. $pagenum = ceil($total / $perpage);
  1473. $over = $total - ($start + $perpage);
  1474. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1475. echo json_encode($rows);
  1476. exit;
  1477. }
  1478. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1479. $this->data['shop'] = $wlshop;
  1480. $this->data['vip'] = $vip;
  1481. $this->_Template('whlabel_type', $this->data);
  1482. }
  1483. //美仓进销存浏览
  1484. public function _usatype()
  1485. {
  1486. if (isset($_SESSION['api'])) {
  1487. $user = $this->user->get_api($_SESSION['api']);
  1488. $usp = $user;
  1489. $fgshop = "";
  1490. $sid = "";
  1491. $wid = "";
  1492. $wtype = "";
  1493. $userwh = explode('|', trim($user['warehouse'], '|'));
  1494. foreach ($userwh as $value) {
  1495. $wid .= " id = " . $value . " or";
  1496. $wtype .= " type = " . $value . " or";
  1497. }
  1498. }
  1499. $prc = array();
  1500. $purchase = $this->purchase->find_all();
  1501. foreach ($purchase as $k => $v) {
  1502. $prc[$v['id']] = $v['title'];
  1503. }
  1504. $post = $this->input->post(NULL, TRUE);
  1505. if (isset($post['page'])) {
  1506. $page = $this->input->post('page', true);
  1507. $perpage = $this->input->post('perpage', true);
  1508. $category = $this->input->post('category', true);
  1509. $size = $this->input->post('size', true);
  1510. $grade = $this->input->post('grade', true);
  1511. $color = $this->input->post('color', true);
  1512. $lowe = $this->input->post('lowe', true);
  1513. $sku = $this->input->post('sku');
  1514. $title = $this->input->post('title');
  1515. $warehouse = $this->input->post('warehouse', true);
  1516. $usa = $this->input->post('usa', true);
  1517. $purchase = $this->input->post('purchase', true);
  1518. $lacetype = $this->input->post('lacetype', true);
  1519. $haircap = $this->input->post('haircap', true);
  1520. $density = $this->input->post('density', true);
  1521. $details = $this->input->post('details', true);
  1522. $state = $this->input->post('state', true);
  1523. $lacecolor = $this->input->post('lacecolor', true);
  1524. $cklx = $this->input->post('cklx', true);
  1525. $ktime = $this->input->post('ktime', true);
  1526. $jtime = $this->input->post('jtime', true);
  1527. $ktime = strtotime($ktime);
  1528. $jtime = strtotime($jtime);
  1529. $where = "1=1";
  1530. $gj = "";
  1531. $ck = "";
  1532. if ($lacetype) {
  1533. $where .= " and features like '%-$lacetype-%'";
  1534. }
  1535. if ($category) {
  1536. $where .= " and features like '%-$category-%'";
  1537. }
  1538. if ($size) {
  1539. $where .= " and features like '%-$size-%'";
  1540. }
  1541. if ($grade) {
  1542. $where .= " and features like '%-$grade-%'";
  1543. }
  1544. if ($color) {
  1545. $where .= " and features like '%-$color-%'";
  1546. }
  1547. if ($lowe) {
  1548. $where .= " and features like '%-$lowe-%'";
  1549. }
  1550. if ($haircap) {
  1551. $where .= " and features like '%-$haircap-%'";
  1552. }
  1553. if ($density) {
  1554. $where .= " and features like '%-$density-%'";
  1555. }
  1556. if ($lacecolor) {
  1557. $where .= " and features like '%-$lacecolor-%'";
  1558. }
  1559. if ($usa) {
  1560. if (!$warehouse) {
  1561. $where .= " and (warehouse = '5' or warehouse = '8')";
  1562. }
  1563. }
  1564. if ($warehouse) {
  1565. $where .= " and warehouse = '$warehouse'";
  1566. }
  1567. if ($details) {
  1568. $where .= " and details = '$details'";
  1569. }
  1570. if ($purchase) {
  1571. $where .= " and purchase = '$purchase'";
  1572. }
  1573. if ($state) {
  1574. $where .= " and state = '$state'";
  1575. }
  1576. $where_add = '';
  1577. if ($cklx) {
  1578. $shop = $this->shop->read($cklx);
  1579. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1580. }
  1581. if ($ktime && $jtime) {
  1582. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1583. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1584. }
  1585. //数据排序
  1586. $order_str = "id desc";
  1587. if (empty($page)) {
  1588. $start = 0;
  1589. $perpage = 1;
  1590. } else {
  1591. $start = ($page - 1) * $perpage;
  1592. }
  1593. if ($sku) {
  1594. $sku = trim($sku, ' ');
  1595. $sku = trim($sku, ' ');
  1596. $where .= " and sku like '%$sku%'";
  1597. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1598. } else if ($title) {
  1599. $title = trim($title, ' ');
  1600. $title = trim($title, ' ');
  1601. $where .= " and title like '%$title%'";
  1602. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1603. } else {
  1604. //$where .= " and time > '$ktime' and time < '$jtime'";
  1605. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1606. }
  1607. //取得信息列表
  1608. $rows = array();
  1609. $list = array();
  1610. foreach ($info_list as $key => $value) {
  1611. $warehouse = $this->warehouse->read($value['warehouse']);
  1612. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1613. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1614. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1615. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1616. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1617. $od = array();
  1618. $odid = '';
  1619. foreach ($z as $v) {
  1620. if (!isset($od[$v['zd']])) {
  1621. $od[$v['zd']] = 1; //所有数据sku
  1622. } else {
  1623. $od[$v['zd']] = $od[$v['zd']] + 1;
  1624. }
  1625. }
  1626. foreach ($od as $k => $vv) {
  1627. $odid .= $k . '数量' . $vv . ' ';
  1628. }
  1629. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1630. $info_list[$key]['features'] = $c;
  1631. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1632. $ztdata = '';
  1633. if (count($zt) > 0) {
  1634. foreach ($zt as $vv) {
  1635. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1636. }
  1637. }
  1638. $info_list[$key]['warehouse'] = $ztdata;
  1639. $info_list[$key]['g'] = $g;
  1640. $info_list[$key]['x'] = $x;
  1641. $info_list[$key]['t'] = $t;
  1642. $info_list[$key]['z'] = $z;
  1643. }
  1644. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1645. $pagenum = ceil($total / $perpage);
  1646. $over = $total - ($start + $perpage);
  1647. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1648. echo json_encode($rows);
  1649. exit;
  1650. }
  1651. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1652. $this->data['warehouse'] = $warehouse;
  1653. $this->_Template('whlabel_typeusa', $this->data);
  1654. }
  1655. //美仓进销存浏览
  1656. public function _usatypeapp()
  1657. {
  1658. $post = $this->input->post(NULL, TRUE);
  1659. if (isset($post['page'])) {
  1660. $page = $this->input->post('page', true);
  1661. $perpage = $this->input->post('perpage', true);
  1662. $sku = $this->input->post('sku', true);
  1663. $warehouse = 5;
  1664. $title = $this->input->post('title', true);
  1665. $state = $this->input->post('state', true);
  1666. $ktime = $this->input->post('ktime', true);
  1667. $jtime = $this->input->post('jtime', true);
  1668. $ktime = strtotime($ktime);
  1669. $jtime = strtotime($jtime);
  1670. $where = "1=1";
  1671. $gj = "";
  1672. $ck = "";
  1673. if ($title) {
  1674. $st = explode(' ', trim($title, ' '));
  1675. foreach ($st as $v) {
  1676. $where .= " and title like '%$v%'";
  1677. }
  1678. }
  1679. if ($warehouse) {
  1680. $where .= " and warehouse = '$warehouse'";
  1681. }
  1682. if ($state) {
  1683. $where .= " and state = '$state'";
  1684. }
  1685. if ($sku) {
  1686. $where .= " and sku like '%$sku%'";
  1687. }
  1688. if ($ktime && $jtime) {
  1689. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1690. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1691. }
  1692. //数据排序
  1693. $order_str = "id desc";
  1694. if (empty($page)) {
  1695. $start = 0;
  1696. $perpage = 1;
  1697. } else {
  1698. $start = ($page - 1) * $perpage;
  1699. }
  1700. //取得信息列表
  1701. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1702. $rows = array();
  1703. $list = array();
  1704. foreach ($info_list as $key => $value) {
  1705. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1706. }
  1707. $rowsdq = array_slice($rows, $start, $perpage);
  1708. foreach ($rowsdq as $value) {
  1709. $warehouse = $this->warehouse->read($value['warehouse']);
  1710. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1711. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1712. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1713. $od = array();
  1714. $odid = '';
  1715. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1716. }
  1717. $total = count($rows);
  1718. $pagenum = ceil($total / $perpage);
  1719. $over = $total - ($start + $perpage);
  1720. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1721. echo json_encode($rows);
  1722. exit;
  1723. }
  1724. $this->_Template('phone/p_usatypeapp', $this->data);
  1725. }
  1726. //入库操作
  1727. public function _enteradd()
  1728. {
  1729. $dt = 0;
  1730. if (isset($_SESSION['api'])) {
  1731. $user = $this->user->get_api($_SESSION['api']);
  1732. $usp = $user;
  1733. $fgshop = "";
  1734. $sid = "";
  1735. $user = explode('|', trim($user['shop'], '|'));
  1736. foreach ($user as $value) {
  1737. $fgshop .= " shop = " . $value . " or";
  1738. $sid .= " id = " . $value . " or";
  1739. }
  1740. }
  1741. $tc = $this->typeclass->find_all();
  1742. $typeclass = array();
  1743. foreach ($tc as $v) {
  1744. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1745. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1746. }
  1747. $post = $this->input->post(NULL, TRUE);
  1748. if (isset($post['sku'])) {
  1749. $list = array();
  1750. $num = "";
  1751. $title = "";
  1752. $features = "";
  1753. $order = $this->input->post('order', true);
  1754. $shop = $this->input->post('shop', true);
  1755. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1756. $sku = $this->input->post('sku', true);
  1757. $post['sm'] = $this->input->post('sm', true);
  1758. $post['warehouse'] = $this->input->post('warehouse', true);
  1759. $post['purchase'] = $this->input->post('purchase', true);
  1760. $post['retreatwarehouse'] = $post['warehouse'];
  1761. $post['state'] = $this->input->post('state', true);
  1762. $post['rktype'] = $this->input->post('rktype', true);
  1763. $post['text'] = $this->input->post('text', true);
  1764. $category = $this->input->post('category', true);
  1765. $list['category'] = $category;
  1766. $list['hairtype'] = $this->input->post('hairtype', true);
  1767. $list['grade'] = $this->input->post('grade', true);
  1768. $size = $this->input->post('size', true);
  1769. $xzsku = $this->input->post('xzsku', true);
  1770. $list['size'] = rtrim($size, ',');
  1771. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1772. $list['extension'] = $this->input->post('extension', true);
  1773. if ($category == 1297) {
  1774. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1775. }
  1776. if ($category == 1702) {
  1777. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1778. $list['syother'] = $this->input->post('syother', true);
  1779. }
  1780. if ($category == 133) {
  1781. $list['fittype'] = $this->input->post('fittype', true);
  1782. $list['acother'] = $this->input->post('acother', true);
  1783. }
  1784. $list['color'] = $this->input->post('color', true);
  1785. $list['lowe'] = $this->input->post('lowe', true);
  1786. if (!$post['purchase']) {
  1787. $post['purchase'] = 1;
  1788. }
  1789. if ($category == 127) {
  1790. $list['type'] = $this->input->post('type', true);
  1791. $list['headroad'] = $this->input->post('headroad', true);
  1792. $list['density'] = $this->input->post('density', true);
  1793. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1794. $list['lacesize'] = $this->input->post('lacesize', true);
  1795. }
  1796. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1797. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1798. }
  1799. if ($category == 128) {
  1800. $list['lacetype'] = $this->input->post('lacetype', true);
  1801. $list['haircap'] = $this->input->post('haircap', true);
  1802. $list['density'] = $this->input->post('density', true);
  1803. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1804. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1805. $list['wigother'] = $this->input->post('wigother', true);
  1806. $list['wigother1'] = $this->input->post('wigother1', true);
  1807. $list['wigother2'] = $this->input->post('wigother2', true);
  1808. }
  1809. if ($category == 129) {
  1810. $list['wide'] = $this->input->post('wide', true);
  1811. }
  1812. if ($category == 131) {
  1813. $list['gifttype'] = $this->input->post('gifttype', true);
  1814. $list['giftother'] = $this->input->post('giftother', true);
  1815. }
  1816. if ($category == 134) {
  1817. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1818. }
  1819. if ($category == 1297) {
  1820. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1821. $list['sywigother'] = $this->input->post('sywigother', true);
  1822. }
  1823. if ($category == 130 || $category == 133 || $category == 1702) {
  1824. $list['items'] = $this->input->post('items', true);
  1825. $list['weight'] = $this->input->post('weight', true);
  1826. }
  1827. if ($category == 1702) {
  1828. $list['syhairther'] = $this->input->post('syhairther', true);
  1829. }
  1830. $classid = $this->classid->sku();
  1831. $scsku = $classid;
  1832. $pm = $classid;
  1833. foreach ($list as $k => $v) {
  1834. if ($v != 0) {
  1835. $num .= $v;
  1836. $features .= $v . '-';
  1837. $post[$k] = $v;
  1838. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1839. if ($k != 'size') {
  1840. $title .= $typeclass[$v]['title'] . " ";
  1841. }
  1842. if (isset($pm[$typeclass[$v]['classid']])) {
  1843. if ($typeclass[$v]['title'] == '9A') {
  1844. $pm[$typeclass[$v]['classid']] = '9A';
  1845. } else if ($typeclass[$v]['title'] == '10A') {
  1846. $pm[$typeclass[$v]['classid']] = '10A';
  1847. } else {
  1848. $clzh = $typeclass[$v]['zh'];
  1849. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1850. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1851. $clzh = $clzh[0];
  1852. }
  1853. $pm[$typeclass[$v]['classid']] = $clzh;
  1854. }
  1855. }
  1856. }
  1857. }
  1858. $zh = implode(" ", $pm);
  1859. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1860. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1861. if ($list['size']) {
  1862. $typeclass = $this->typeclass->read($list['size']);
  1863. $title .= $typeclass['title'];
  1864. }
  1865. $time = time();
  1866. if ($xzsku) {
  1867. $scsku = implode("-", $scsku);
  1868. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1869. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1870. $post['sku'] = trim($scsku, ' ');
  1871. } else {
  1872. $post['sku'] = $sku;
  1873. }
  1874. //$post['sku'] = trim($sku,' ');
  1875. $post['title'] = rtrim($title, ' ');
  1876. $post['number'] = $num;
  1877. $post['features'] = '-' . $features;
  1878. $post['enter'] = $time;
  1879. $post['time'] = $time; //操作时间
  1880. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1881. if ($yza) {
  1882. if ($post['features'] != $yza[0]['features']) {
  1883. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1884. exit;
  1885. }
  1886. }
  1887. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1888. if ($yzb) {
  1889. if ($post['sku'] != $yzb[0]['sku']) {
  1890. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1891. exit;
  1892. }
  1893. }
  1894. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1895. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1896. exit;
  1897. }
  1898. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1899. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1900. exit;
  1901. }
  1902. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1903. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1904. exit;
  1905. }
  1906. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1907. if (isset($yz[0]['type'])) {
  1908. $post['type'] = $yz[0]['type'];
  1909. }
  1910. if ($post['state'] == 9) //如果选择预设库存
  1911. {
  1912. $this->whlabel->insert($post);
  1913. } else {
  1914. /**
  1915. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1916. if($ljg == 1)
  1917. {
  1918. for($i=0;$i<$order;$i++)
  1919. {
  1920. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1921. $this->whlabel->insert($post);
  1922. }
  1923. }
  1924. **/
  1925. //if($post['warehouse'] == '5')
  1926. //{
  1927. //}
  1928. $yydata = $post;
  1929. $yydata['zh'] = $zh;
  1930. /**
  1931. $wl = $this->apiyy->get_cjlp($yydata);
  1932. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1933. {
  1934. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1935. }
  1936. if($wl['Data'][0]['m_isSucess'] != 1)
  1937. {
  1938. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1939. }
  1940. **/
  1941. for ($i = 0; $i < $order; $i++) {
  1942. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1943. $this->whlabel->insert($post);
  1944. }
  1945. }
  1946. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1947. exit;
  1948. }
  1949. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1950. $this->data['wlshop'] = $wlshop;
  1951. $this->_Template('whlabel_enteradd', $this->data);
  1952. }
  1953. //修改产品
  1954. public function _enteredit($arg_array)
  1955. {
  1956. $dt = 0;
  1957. if (isset($_SESSION['api'])) {
  1958. $user = $this->user->get_api($_SESSION['api']);
  1959. $usp = $user;
  1960. $fgshop = "";
  1961. $sid = "";
  1962. $user = explode('|', trim($user['shop'], '|'));
  1963. foreach ($user as $value) {
  1964. $fgshop .= " shop = " . $value . " or";
  1965. $sid .= " id = " . $value . " or";
  1966. }
  1967. }
  1968. $post = $this->input->post(NULL, TRUE);
  1969. if (isset($post['sku'])) {
  1970. $list = array();
  1971. $num = "";
  1972. $title = "";
  1973. $features = "";
  1974. $id = $this->input->post('id', true);
  1975. $order = $this->input->post('order', true);
  1976. $shop = $this->input->post('shop', true);
  1977. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1978. $post['sku'] = $this->input->post('sku', true);
  1979. $post['sm'] = $this->input->post('sm', true);
  1980. $post['warehouse'] = $this->input->post('warehouse', true);
  1981. $post['purchase'] = $this->input->post('purchase', true);
  1982. $post['retreatwarehouse'] = $post['warehouse'];
  1983. $category = $this->input->post('category', true);
  1984. $list['category'] = $category;
  1985. $list['hairtype'] = $this->input->post('hairtype', true);
  1986. $list['grade'] = $this->input->post('grade', true);
  1987. $size = $this->input->post('size', true);
  1988. $list['size'] = rtrim($size, ',');
  1989. $post['rktype'] = $this->input->post('rktype', true);
  1990. $post['text'] = $this->input->post('text', true);
  1991. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1992. $list['extension'] = $this->input->post('extension', true);
  1993. if ($category == 1297) {
  1994. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1995. }
  1996. if ($category == 1702) {
  1997. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1998. $list['syother'] = $this->input->post('syother', true);
  1999. }
  2000. if ($category == 133) {
  2001. $list['fittype'] = $this->input->post('fittype', true);
  2002. $list['acother'] = $this->input->post('acother', true);
  2003. }
  2004. $list['color'] = $this->input->post('color', true);
  2005. $list['lowe'] = $this->input->post('lowe', true);
  2006. if (!$post['purchase']) {
  2007. $post['purchase'] = 1;
  2008. }
  2009. if ($category == 127) {
  2010. $list['type'] = $this->input->post('type', true);
  2011. $list['headroad'] = $this->input->post('headroad', true);
  2012. $list['density'] = $this->input->post('density', true);
  2013. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2014. $list['lacesize'] = $this->input->post('lacesize', true);
  2015. }
  2016. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2017. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2018. }
  2019. if ($category == 128) {
  2020. $list['lacetype'] = $this->input->post('lacetype', true);
  2021. $list['haircap'] = $this->input->post('haircap', true);
  2022. $list['density'] = $this->input->post('density', true);
  2023. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2024. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2025. $list['wigother'] = $this->input->post('wigother', true);
  2026. $list['wigother1'] = $this->input->post('wigother1', true);
  2027. $list['wigother2'] = $this->input->post('wigother2', true);
  2028. }
  2029. if ($category == 129) {
  2030. $list['wide'] = $this->input->post('wide', true);
  2031. }
  2032. if ($category == 131) {
  2033. $list['gifttype'] = $this->input->post('gifttype', true);
  2034. $list['giftother'] = $this->input->post('giftother', true);
  2035. }
  2036. if ($category == 134) {
  2037. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2038. }
  2039. if ($category == 1297) {
  2040. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2041. $list['sywigother'] = $this->input->post('sywigother', true);
  2042. }
  2043. if ($category == 130 || $category == 133 || $category == 1702) {
  2044. $list['items'] = $this->input->post('items', true);
  2045. $list['weight'] = $this->input->post('weight', true);
  2046. }
  2047. if ($category == 1702) {
  2048. $list['syhairther'] = $this->input->post('syhairther', true);
  2049. }
  2050. foreach ($list as $k => $v) {
  2051. if ($v != 0) {
  2052. $num .= $v;
  2053. $features .= $v . '-';
  2054. $typeclass = $this->typeclass->read($v);
  2055. if ($k != 'size') {
  2056. $title .= $typeclass['title'] . " ";
  2057. }
  2058. }
  2059. }
  2060. $typeclass = $this->typeclass->read($list['size']);
  2061. $title .= $typeclass['title'];
  2062. $time = time();
  2063. $post['title'] = rtrim($title, ' ');
  2064. $post['number'] = $num;
  2065. $post['features'] = '-' . $features;
  2066. $post['time'] = $time; //操作时间
  2067. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2068. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2069. exit;
  2070. }
  2071. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2072. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2073. exit;
  2074. }
  2075. $uid = $this->whlabel->read($id);
  2076. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2077. if ($datanum > 0) {
  2078. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2079. exit;
  2080. }
  2081. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2082. {
  2083. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2084. if ($yza) {
  2085. if ($post['features'] != $yza[0]['features']) {
  2086. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2087. exit;
  2088. }
  2089. }
  2090. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2091. if ($yzb) {
  2092. if ($post['sku'] != $yzb[0]['sku']) {
  2093. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2094. exit;
  2095. }
  2096. }
  2097. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2098. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2099. exit;
  2100. }
  2101. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2102. foreach ($data as $v) {
  2103. $post['id'] = $v['id'];
  2104. $this->whlabel->save($post, $v['id']);
  2105. }
  2106. } else {
  2107. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2108. if ($data > 0) {
  2109. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2110. exit;
  2111. } else {
  2112. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2113. foreach ($data as $v) {
  2114. $post['id'] = $v['id'];
  2115. $this->whlabel->save($post, $v['id']);
  2116. }
  2117. }
  2118. }
  2119. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2120. exit;
  2121. }
  2122. $uid = $this->whlabel->read($arg_array[0]);
  2123. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2124. $this->data['enter'] = $uid;
  2125. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2126. $this->data['wlshop'] = $wlshop;
  2127. $this->_Template('whlabel_enteredit', $this->data);
  2128. }
  2129. //入库浏览
  2130. public function _enter()
  2131. {
  2132. $post = $this->input->post(NULL, TRUE);
  2133. if (isset($post['s'])) {
  2134. $id_arr = $this->input->post('s');
  2135. $id_arr = explode(',', $id_arr);
  2136. if (!$id_arr) {
  2137. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2138. exit;
  2139. }
  2140. //循环删除记录
  2141. foreach ($id_arr as $v) {
  2142. $sid = $this->whlabel->read($v);
  2143. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2144. if ($count > 0) {
  2145. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2146. exit;
  2147. }
  2148. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2149. foreach ($info_list as $va) {
  2150. $this->whlabel->remove($va['id']);
  2151. }
  2152. }
  2153. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2154. exit;
  2155. }
  2156. $sp = array();
  2157. $s = $this->shop->find_all('1=1', 'id,shopname');
  2158. foreach ($s as $v) {
  2159. $sp[$v['id']] = $v['shopname'];
  2160. }
  2161. $wh = array();
  2162. $w = $this->warehouse->find_all('1=1', 'id,title');
  2163. foreach ($w as $v) {
  2164. $wh[$v['id']] = $v['title'];
  2165. }
  2166. if (isset($post['page'])) {
  2167. $page = $this->input->post('page', true);
  2168. $perpage = $this->input->post('perpage', true);
  2169. $category = $this->input->post('category', true);
  2170. $size = $this->input->post('size', true);
  2171. $grade = $this->input->post('grade', true);
  2172. $color = $this->input->post('color', true);
  2173. $lowe = $this->input->post('lowe', true);
  2174. $sku = $this->input->post('sku', true);
  2175. $warehouse = $this->input->post('warehouse', true);
  2176. $purchase = $this->input->post('purchase', true);
  2177. $ktime = $this->input->post('ktime', true);
  2178. $jtime = $this->input->post('jtime', true);
  2179. $ktime = strtotime($ktime);
  2180. $jtime = strtotime($jtime);
  2181. $where = "1=1";
  2182. $gj = "";
  2183. $ck = "";
  2184. if ($category) {
  2185. $where .= " and features like '%-$category-%'";
  2186. }
  2187. if ($size) {
  2188. $where .= " and features like '%-$size-%'";
  2189. }
  2190. if ($grade) {
  2191. $where .= " and features like '%-$grade-%'";
  2192. }
  2193. if ($color) {
  2194. $where .= " and features like '%-$color-%'";
  2195. }
  2196. if ($lowe) {
  2197. $where .= " and features like '%-$lowe-%'";
  2198. }
  2199. if ($warehouse) {
  2200. $where .= " and warehouse = '$warehouse'";
  2201. }
  2202. if ($purchase) {
  2203. $where .= " and purchase = '$purchase'";
  2204. }
  2205. if ($sku) {
  2206. $where .= " and sku like '%$sku%'";
  2207. }
  2208. if ($ktime && $jtime) {
  2209. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2210. }
  2211. //数据排序
  2212. $order_str = "enter desc";
  2213. if (empty($page)) {
  2214. $start = 0;
  2215. $perpage = 1;
  2216. } else {
  2217. $start = ($page - 1) * $perpage;
  2218. }
  2219. //取得信息列表
  2220. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2221. foreach ($info_list as $k => $v) {
  2222. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2223. if ($v['shop'] == '') {
  2224. $s = '通用';
  2225. } else {
  2226. $info_list[$k]['shop'] = '';
  2227. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2228. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2229. }
  2230. }
  2231. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2232. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2233. $info_list[$k]['g'] = $g;
  2234. }
  2235. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2236. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2237. $pagenum = ceil($total / $perpage);
  2238. $over = $total - ($start + $perpage);
  2239. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2240. echo json_encode($rows);
  2241. exit;
  2242. }
  2243. $this->_Template('whlabel_enter', $this->data);
  2244. }
  2245. //出库浏览
  2246. public function _out()
  2247. {
  2248. $post = $this->input->post(NULL, TRUE);
  2249. if (isset($post['page'])) {
  2250. $page = $this->input->post('page', true);
  2251. $perpage = $this->input->post('perpage', true);
  2252. $category = $this->input->post('category', true);
  2253. $size = $this->input->post('size', true);
  2254. $grade = $this->input->post('grade', true);
  2255. $color = $this->input->post('color', true);
  2256. $lowe = $this->input->post('lowe', true);
  2257. $sku = $this->input->post('sku', true);
  2258. $warehouse = $this->input->post('warehouse', true);
  2259. $purchase = $this->input->post('purchase', true);
  2260. $state = $this->input->post('state', true);
  2261. $ktime = $this->input->post('ktime', true);
  2262. $jtime = $this->input->post('jtime', true);
  2263. $ktime = strtotime($ktime);
  2264. $jtime = strtotime($jtime);
  2265. $where = "state=3";
  2266. $gj = "";
  2267. $ck = "";
  2268. if ($category) {
  2269. $where .= " and features like '%-$category-%'";
  2270. }
  2271. if ($size) {
  2272. $where .= " and features like '%-$size-%'";
  2273. }
  2274. if ($grade) {
  2275. $where .= " and features like '%-$grade-%'";
  2276. }
  2277. if ($color) {
  2278. $where .= " and features like '%-$color-%'";
  2279. }
  2280. if ($lowe) {
  2281. $where .= " and features like '%-$lowe-%'";
  2282. }
  2283. if ($state) {
  2284. $where .= " and state = '$state'";
  2285. }
  2286. if ($warehouse) {
  2287. $where .= " and warehouse = '$warehouse'";
  2288. }
  2289. if ($purchase) {
  2290. $where .= " and purchase = '$purchase'";
  2291. }
  2292. if ($sku) {
  2293. $where .= " and sku = '$sku'";
  2294. }
  2295. if ($ktime && $jtime) {
  2296. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2297. }
  2298. //数据排序
  2299. $order_str = "id desc";
  2300. if (empty($page)) {
  2301. $start = 0;
  2302. $perpage = 1;
  2303. } else {
  2304. $start = ($page - 1) * $perpage;
  2305. }
  2306. //取得信息列表
  2307. $info_list = $this->whlabel->find_all($where, 'sku');
  2308. $rows = array();
  2309. $list = array();
  2310. foreach ($info_list as $key => $value) {
  2311. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2312. }
  2313. $rows = array_unique($rows); //删除重复记录
  2314. foreach ($rows as $key => $value) {
  2315. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2316. $ck = $this->warehouse->read($data['warehouse']);
  2317. $warehouse = $ck['title'];
  2318. $gy = $this->purchase->read($data['purchase']);
  2319. $purchase = $gy['purchase'];
  2320. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2321. $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);
  2322. }
  2323. $total = count($list);
  2324. $pagenum = ceil($total / $perpage);
  2325. $over = $total - ($start + $perpage);
  2326. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2327. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2328. echo json_encode($rows);
  2329. exit;
  2330. }
  2331. $this->_Template('whlabel_out', $this->data);
  2332. }
  2333. //出库标签浏览
  2334. public function _label()
  2335. {
  2336. $post = $this->input->post(NULL, TRUE);
  2337. if (isset($post['page'])) {
  2338. $page = $this->input->post('page', true);
  2339. $perpage = $this->input->post('perpage', true);
  2340. $sku = $this->input->post('sku', true);
  2341. $warehouse = $this->input->post('warehouse', true);
  2342. $purchase = $this->input->post('purchase', true);
  2343. $orderinfo = $this->input->post('orderinfo', true);
  2344. $waybill = $this->input->post('waybill', true);
  2345. $category = $this->input->post('category', true);
  2346. $size = $this->input->post('size', true);
  2347. $grade = $this->input->post('grade', true);
  2348. $color = $this->input->post('color', true);
  2349. $lowe = $this->input->post('lowe', true);
  2350. $where = "state=1";
  2351. if ($sku) {
  2352. $where .= " and sku = '$sku'";
  2353. }
  2354. if ($warehouse) {
  2355. $where .= " and warehouse = '$warehouse'";
  2356. }
  2357. if ($purchase) {
  2358. $where .= " and purchase = '$purchase'";
  2359. }
  2360. if ($orderinfo) {
  2361. $where .= " and orderinfo = '$orderinfo'";
  2362. }
  2363. if ($waybill) {
  2364. $where .= " and waybill = '$waybill'";
  2365. }
  2366. if ($category) {
  2367. $where .= " and features like '%-$category-%'";
  2368. }
  2369. if ($size) {
  2370. $where .= " and features like '%-$size-%'";
  2371. }
  2372. if ($grade) {
  2373. $where .= " and features like '%-$grade-%'";
  2374. }
  2375. if ($color) {
  2376. $where .= " and features like '%-$color-%'";
  2377. }
  2378. if ($lowe) {
  2379. $where .= " and features like '%-$lowe-%'";
  2380. }
  2381. //数据排序
  2382. $order_str = "outk desc";
  2383. if (empty($page)) {
  2384. $start = 0;
  2385. $perpage = 1;
  2386. } else {
  2387. $start = ($page - 1) * $perpage;
  2388. }
  2389. //取得信息列表
  2390. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2391. foreach ($info_list as $key => $value) {
  2392. $warehouse = $this->warehouse->read($value['warehouse']);
  2393. $info_list[$key]['warehouse'] = $warehouse['title'];
  2394. $purchase = $this->purchase->read($value['purchase']);
  2395. $info_list[$key]['purchase'] = $purchase['title'];
  2396. if ($value['outk'] != 0) {
  2397. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2398. } else {
  2399. $info_list[$key]['outk'] = "";
  2400. }
  2401. if ($value['orderinfo'] == 0) {
  2402. $info_list[$key]['orderinfo'] = "";
  2403. }
  2404. if ($value['waybill'] == 0) {
  2405. $info_list[$key]['waybill'] = "";
  2406. }
  2407. }
  2408. $total = $this->whlabel->find_count($where);
  2409. $pagenum = ceil($total / $perpage);
  2410. $over = $total - ($start + $perpage);
  2411. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2412. echo json_encode($rows);
  2413. exit;
  2414. }
  2415. $this->_Template('whlabel_label', $this->data);
  2416. }
  2417. //独立站出库订单
  2418. public function _outorder()
  2419. {
  2420. if (isset($_SESSION['api'])) {
  2421. $user = $this->user->get_api($_SESSION['api']);
  2422. $usp = $user;
  2423. $fgshop = "";
  2424. $sid = "";
  2425. $user = explode('|', trim($user['shop'], '|'));
  2426. foreach ($user as $value) {
  2427. $fgshop .= " shop = " . $value . " or";
  2428. $sid .= " id = " . $value . " or";
  2429. }
  2430. } else {
  2431. echo "请重新登录";
  2432. }
  2433. $post = $this->input->post(NULL, TRUE);
  2434. if (isset($post['page'])) {
  2435. $page = $this->input->post('page', true);
  2436. $perpage = $this->input->post('perpage', true);
  2437. $warehouse = $this->input->post('warehouse', true);
  2438. $xztime = $this->input->post('xztime', true);
  2439. $timetk = $this->input->post('timetkk', true);
  2440. $timetj = $this->input->post('timetjj', true);
  2441. $shop = $this->input->post('shop', true);
  2442. $source = $this->input->post('source', true);
  2443. $orderinfo = $this->input->post('orderinfo', true);
  2444. $number = $this->input->post('number', true);
  2445. $sfxh = $this->input->post('sfxh', true);
  2446. $express = $this->input->post('express', true);
  2447. $waybill = $this->input->post('waybill', true);
  2448. $library = $this->input->post('library', true);
  2449. $country = $this->input->post('country', true);
  2450. $so = $this->input->post('so', true);
  2451. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2452. $print = $this->input->post('print', true);
  2453. $state = $this->input->post('state', true);
  2454. $orderurl = $this->input->post('orderurl', true);
  2455. $productid = $this->input->post('productid', true);
  2456. $timetk = strtotime($timetk);
  2457. $timetj = strtotime($timetj);
  2458. /**
  2459. $sj = $this->input->post('sj',true);
  2460. if($sj)
  2461. {
  2462. $sj = $this->input->post('sj',true);
  2463. }
  2464. else
  2465. {
  2466. $sj = "fullorder";
  2467. }
  2468. **/
  2469. $sj = "fullorder";
  2470. $where = "1=1";
  2471. if ($warehouse) {
  2472. $where .= " and type = '$warehouse'";
  2473. }
  2474. if ($timetk && $timetj) {
  2475. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2476. }
  2477. if ($orderinfo) {
  2478. $where .= " and orderinfo = '$orderinfo'";
  2479. }
  2480. if ($number) {
  2481. $where .= " and number = '$number'";
  2482. }
  2483. if ($express) {
  2484. $where .= " and express = '$express'";
  2485. }
  2486. if ($waybill) {
  2487. $where .= " and waybill = '$waybill'";
  2488. }
  2489. if ($library) {
  2490. $where .= " and library = '$library'";
  2491. }
  2492. if ($print) {
  2493. $where .= " and print = '$print'";
  2494. }
  2495. if ($libraryconfirm) {
  2496. $where .= " and libraryconfirm = '$libraryconfirm'";
  2497. }
  2498. if ($state) {
  2499. $where .= " and state = '$state'";
  2500. }
  2501. if ($shop) {
  2502. $where .= " and shop = '$shop'";
  2503. }
  2504. if ($country) {
  2505. $where .= " and country = '$country'";
  2506. }
  2507. if ($sfxh != '') {
  2508. $where .= " and sfxh = '$sfxh'";
  2509. }
  2510. if ($so) {
  2511. $where .= " and shipremarks like '%$so%'";
  2512. }
  2513. if ($source) {
  2514. if ($source == '2d') {
  2515. $where .= " and source >= '2'";
  2516. } else {
  2517. $where .= " and source = '$source'";
  2518. }
  2519. }
  2520. if (isset($_SESSION['api'])) {
  2521. foreach ($user as $value) {
  2522. $fgshop .= " shop = " . $value . " or";
  2523. }
  2524. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2525. }
  2526. if ($orderurl) {
  2527. $url = $this->orderurl->read($orderurl);
  2528. $where .= " and link like '%" . $url['url'] . "%'";
  2529. }
  2530. if($productid){
  2531. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2532. }
  2533. //数据排序
  2534. $order_str = "librarytime desc";
  2535. if (empty($page)) {
  2536. $start = 0;
  2537. $perpage = 1;
  2538. } else {
  2539. $start = ($page - 1) * $perpage;
  2540. }
  2541. //取得信息列表
  2542. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2543. //格式化数据
  2544. foreach ($info_list as $key => $value) {
  2545. $shop = $this->shop->read($value['shop']);
  2546. $info_list[$key]['shop'] = $shop['shopname'];
  2547. $express = $this->express->read($value['express']);
  2548. $info_list[$key]['express'] = $express['servicename'];
  2549. $warehouse = $this->warehouse->read($value['type']);
  2550. $info_list[$key]['type'] = $warehouse['title'];
  2551. if ($value['librarytime'] == '0') {
  2552. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2553. } else {
  2554. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2555. }
  2556. }
  2557. $total = $this->$sj->find_count($where);
  2558. $pagenum = ceil($total / $perpage);
  2559. $over = $total - ($start + $perpage);
  2560. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2561. echo json_encode($rows);
  2562. exit;
  2563. }
  2564. $this->data['express'] = $this->express->find_all();
  2565. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2566. $this->data['wlshop'] = $wlshop;
  2567. $user = $this->user->get_api($_SESSION['api']);
  2568. $powerid = $this->power->read($user['power']);
  2569. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2570. $pid = '';
  2571. foreach ($powertext as $v) {
  2572. $pid .= " id = " . $v . " or";
  2573. }
  2574. $fullorderexcel = $this->fullorderexcel->find_all("1=1"); //导出模板
  2575. $this->data['fullorderexcel'] = $fullorderexcel;
  2576. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2577. $this->data['orderurl'] = $orderurl;
  2578. $this->_Template('whlabel_outorder', $this->data);
  2579. }
  2580. //tt出库
  2581. public function _toutorder()
  2582. {
  2583. $fgshop = "";
  2584. $sid = "";
  2585. if (isset($_SESSION['api'])) {
  2586. $user = $this->user->get_api($_SESSION['api']);
  2587. $usp = $user;
  2588. $user = explode('|', trim($user['shop'], '|'));
  2589. foreach ($user as $value) {
  2590. $fgshop .= " shop = " . $value . " or";
  2591. $sid .= " id = " . $value . " or";
  2592. }
  2593. } else {
  2594. echo "请重新登录";
  2595. die;
  2596. }
  2597. $post = $this->input->post(NULL, TRUE);
  2598. if (isset($post['page'])) {
  2599. $page = $this->input->post('page', true);
  2600. $perpage = $this->input->post('perpage', true);
  2601. $warehouse = $this->input->post('warehouse', true);
  2602. $xztime = $this->input->post('xztime', true);
  2603. $timetk = $this->input->post('timetkk', true);
  2604. $timetj = $this->input->post('timetjj', true);
  2605. $shop = $this->input->post('shop', true);
  2606. $source = $this->input->post('source', true);
  2607. $orderinfo = $this->input->post('orderinfo', true);
  2608. $number = $this->input->post('number', true);
  2609. $sfxh = $this->input->post('sfxh', true);
  2610. $express = $this->input->post('express', true);
  2611. $waybill = $this->input->post('waybill', true);
  2612. $library = $this->input->post('library', true);
  2613. $country = $this->input->post('country', true);
  2614. $so = $this->input->post('so', true);
  2615. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2616. $print = $this->input->post('print', true);
  2617. $state = $this->input->post('state', true);
  2618. $orderurl = $this->input->post('orderurl', true);
  2619. $timetk = strtotime($timetk);
  2620. $timetj = strtotime($timetj);
  2621. /**
  2622. $sj = $this->input->post('sj',true);
  2623. if($sj)
  2624. {
  2625. $sj = $this->input->post('sj',true);
  2626. }
  2627. else
  2628. {
  2629. $sj = "fullorder";
  2630. }
  2631. **/
  2632. $sj = "fullordertt";
  2633. $where = "1=1";
  2634. if ($warehouse) {
  2635. $where .= " and type = '$warehouse'";
  2636. }
  2637. if ($timetk && $timetj) {
  2638. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2639. }
  2640. if ($orderinfo) {
  2641. $where .= " and orderinfo = '$orderinfo'";
  2642. }
  2643. if ($number) {
  2644. $where .= " and number = '$number'";
  2645. }
  2646. if ($express) {
  2647. $where .= " and express = '$express'";
  2648. }
  2649. if ($waybill) {
  2650. $where .= " and waybill = '$waybill'";
  2651. }
  2652. if ($library) {
  2653. $where .= " and library = '$library'";
  2654. }
  2655. if ($print) {
  2656. $where .= " and print = '$print'";
  2657. }
  2658. if ($libraryconfirm) {
  2659. $where .= " and libraryconfirm = '$libraryconfirm'";
  2660. }
  2661. if ($state) {
  2662. $where .= " and state = '$state'";
  2663. }
  2664. if ($shop) {
  2665. $where .= " and shop = '$shop'";
  2666. }
  2667. if ($country) {
  2668. $where .= " and country = '$country'";
  2669. }
  2670. if ($sfxh != '') {
  2671. $where .= " and sfxh = '$sfxh'";
  2672. }
  2673. if ($so) {
  2674. $where .= " and shipremarks like '%$so%'";
  2675. }
  2676. if ($source) {
  2677. if ($source == '2d') {
  2678. $where .= " and source >= '2'";
  2679. } else {
  2680. $where .= " and source = '$source'";
  2681. }
  2682. }
  2683. if (isset($_SESSION['api'])) {
  2684. foreach ($user as $value) {
  2685. $fgshop .= " shop = " . $value . " or";
  2686. }
  2687. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2688. }
  2689. if ($orderurl) {
  2690. $url = $this->orderurl->read($orderurl);
  2691. $where .= " and link like '%" . $url['url'] . "%'";
  2692. }
  2693. //数据排序
  2694. $order_str = "librarytime desc";
  2695. if (empty($page)) {
  2696. $start = 0;
  2697. $perpage = 1;
  2698. } else {
  2699. $start = ($page - 1) * $perpage;
  2700. }
  2701. //取得信息列表
  2702. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2703. //格式化数据
  2704. foreach ($info_list as $key => $value) {
  2705. $shop = $this->shop->read($value['shop']);
  2706. $info_list[$key]['shop'] = $shop['shopname'];
  2707. $express = $this->express->read($value['express']);
  2708. $info_list[$key]['express'] = $express['servicename'];
  2709. $warehouse = $this->warehouse->read($value['type']);
  2710. $info_list[$key]['type'] = $warehouse['title'];
  2711. if ($value['librarytime'] == '0') {
  2712. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2713. } else {
  2714. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2715. }
  2716. }
  2717. $total = $this->$sj->find_count($where);
  2718. $pagenum = ceil($total / $perpage);
  2719. $over = $total - ($start + $perpage);
  2720. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2721. echo json_encode($rows);
  2722. exit;
  2723. }
  2724. $this->data['express'] = $this->express->find_all();
  2725. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2726. $this->data['wlshop'] = $wlshop;
  2727. $user = $this->user->get_api($_SESSION['api']);
  2728. $powerid = $this->power->read($user['power']);
  2729. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2730. $pid = '';
  2731. foreach ($powertext as $v) {
  2732. $pid .= " id = " . $v . " or";
  2733. }
  2734. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2735. $this->data['fullorderexcel'] = $fullorderexcel;
  2736. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2737. $this->data['orderurl'] = $orderurl;
  2738. $this->_Template('whlabel_toutorder', $this->data);
  2739. }
  2740. //tt出库
  2741. public function _aoutorder()
  2742. {
  2743. if (isset($_SESSION['api'])) {
  2744. $user = $this->user->get_api($_SESSION['api']);
  2745. $usp = $user;
  2746. $fgshop = "";
  2747. $sid = "";
  2748. $user = explode('|', trim($user['shop'], '|'));
  2749. foreach ($user as $value) {
  2750. $fgshop .= " shop = " . $value . " or";
  2751. $sid .= " id = " . $value . " or";
  2752. }
  2753. } else {
  2754. echo "请重新登录";
  2755. }
  2756. $post = $this->input->post(NULL, TRUE);
  2757. if (isset($post['page'])) {
  2758. $page = $this->input->post('page', true);
  2759. $perpage = $this->input->post('perpage', true);
  2760. $warehouse = $this->input->post('warehouse', true);
  2761. $xztime = $this->input->post('xztime', true);
  2762. $timetk = $this->input->post('timetkk', true);
  2763. $timetj = $this->input->post('timetjj', true);
  2764. $shop = $this->input->post('shop', true);
  2765. $source = $this->input->post('source', true);
  2766. $orderinfo = $this->input->post('orderinfo', true);
  2767. $number = $this->input->post('number', true);
  2768. $sfxh = $this->input->post('sfxh', true);
  2769. $express = $this->input->post('express', true);
  2770. $waybill = $this->input->post('waybill', true);
  2771. $library = $this->input->post('library', true);
  2772. $country = $this->input->post('country', true);
  2773. $so = $this->input->post('so', true);
  2774. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2775. $print = $this->input->post('print', true);
  2776. $state = $this->input->post('state', true);
  2777. $orderurl = $this->input->post('orderurl', true);
  2778. $timetk = strtotime($timetk);
  2779. $timetj = strtotime($timetj);
  2780. /**
  2781. $sj = $this->input->post('sj',true);
  2782. if($sj)
  2783. {
  2784. $sj = $this->input->post('sj',true);
  2785. }
  2786. else
  2787. {
  2788. $sj = "fullorder";
  2789. }
  2790. **/
  2791. $sj = "fullorderamz";
  2792. $where = "1=1";
  2793. if ($warehouse) {
  2794. $where .= " and type = '$warehouse'";
  2795. }
  2796. if ($timetk && $timetj) {
  2797. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2798. }
  2799. if ($orderinfo) {
  2800. $where .= " and orderinfo = '$orderinfo'";
  2801. }
  2802. if ($number) {
  2803. $where .= " and number = '$number'";
  2804. }
  2805. if ($express) {
  2806. $where .= " and express = '$express'";
  2807. }
  2808. if ($waybill) {
  2809. $where .= " and waybill = '$waybill'";
  2810. }
  2811. if ($library) {
  2812. $where .= " and library = '$library'";
  2813. }
  2814. if ($print) {
  2815. $where .= " and print = '$print'";
  2816. }
  2817. if ($libraryconfirm) {
  2818. $where .= " and libraryconfirm = '$libraryconfirm'";
  2819. }
  2820. if ($state) {
  2821. $where .= " and state = '$state'";
  2822. }
  2823. if ($shop) {
  2824. $where .= " and shop = '$shop'";
  2825. }
  2826. if ($country) {
  2827. $where .= " and country = '$country'";
  2828. }
  2829. if ($sfxh != '') {
  2830. $where .= " and sfxh = '$sfxh'";
  2831. }
  2832. if ($so) {
  2833. $where .= " and shipremarks like '%$so%'";
  2834. }
  2835. if ($source) {
  2836. if ($source == '2d') {
  2837. $where .= " and source >= '2'";
  2838. } else {
  2839. $where .= " and source = '$source'";
  2840. }
  2841. }
  2842. if (isset($_SESSION['api'])) {
  2843. foreach ($user as $value) {
  2844. $fgshop .= " shop = " . $value . " or";
  2845. }
  2846. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2847. }
  2848. if ($orderurl) {
  2849. $url = $this->orderurl->read($orderurl);
  2850. $where .= " and link like '%" . $url['url'] . "%'";
  2851. }
  2852. //数据排序
  2853. $order_str = "librarytime desc";
  2854. if (empty($page)) {
  2855. $start = 0;
  2856. $perpage = 1;
  2857. } else {
  2858. $start = ($page - 1) * $perpage;
  2859. }
  2860. //取得信息列表
  2861. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2862. //格式化数据
  2863. foreach ($info_list as $key => $value) {
  2864. $shop = $this->shop->read($value['shop']);
  2865. $info_list[$key]['shop'] = $shop['shopname'];
  2866. $express = $this->express->read($value['express']);
  2867. $info_list[$key]['express'] = $express['servicename'];
  2868. $warehouse = $this->warehouse->read($value['type']);
  2869. $info_list[$key]['type'] = $warehouse['title'];
  2870. if ($value['librarytime'] == '0') {
  2871. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2872. } else {
  2873. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2874. }
  2875. }
  2876. $total = $this->$sj->find_count($where);
  2877. $pagenum = ceil($total / $perpage);
  2878. $over = $total - ($start + $perpage);
  2879. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2880. echo json_encode($rows);
  2881. exit;
  2882. }
  2883. $this->data['express'] = $this->express->find_all();
  2884. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2885. $this->data['wlshop'] = $wlshop;
  2886. $user = $this->user->get_api($_SESSION['api']);
  2887. $powerid = $this->power->read($user['power']);
  2888. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2889. $pid = '';
  2890. foreach ($powertext as $v) {
  2891. $pid .= " id = " . $v . " or";
  2892. }
  2893. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2894. $this->data['fullorderexcel'] = $fullorderexcel;
  2895. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2896. $this->data['orderurl'] = $orderurl;
  2897. $this->_Template('whlabel_aoutorder', $this->data);
  2898. }
  2899. //速卖通出库订单
  2900. public function _soutorder()
  2901. {
  2902. if (isset($_SESSION['api'])) {
  2903. $user = $this->user->get_api($_SESSION['api']);
  2904. $usp = $user;
  2905. $fgshop = "";
  2906. $sid = "";
  2907. $user = explode('|', trim($user['shop'], '|'));
  2908. foreach ($user as $value) {
  2909. $sid .= " id = " . $value . " or";
  2910. }
  2911. }
  2912. $post = $this->input->post(NULL, TRUE);
  2913. if (isset($post['page'])) {
  2914. $page = $this->input->post('page', true);
  2915. $perpage = $this->input->post('perpage', true);
  2916. $warehouse = $this->input->post('warehouse', true);
  2917. $xztime = $this->input->post('xztime', true);
  2918. $timetk = $this->input->post('timetkk', true);
  2919. $timetj = $this->input->post('timetjj', true);
  2920. $shop = $this->input->post('shop', true);
  2921. $source = $this->input->post('source', true);
  2922. $orderinfo = $this->input->post('orderinfo', true);
  2923. $number = $this->input->post('number', true);
  2924. $express = $this->input->post('express', true);
  2925. $waybill = $this->input->post('waybill', true);
  2926. $library = $this->input->post('library', true);
  2927. $country = $this->input->post('country', true);
  2928. $sfxh = $this->input->post('sfxh', true);
  2929. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2930. $print = $this->input->post('print', true);
  2931. $state = $this->input->post('state', true);
  2932. $so = $this->input->post('so', true);
  2933. $timetk = strtotime($timetk);
  2934. $timetj = strtotime($timetj);
  2935. /**
  2936. $sj = $this->input->post('sj',true);
  2937. if($sj)
  2938. {
  2939. $sj = $this->input->post('sj',true);
  2940. }
  2941. else
  2942. {
  2943. $sj = "fullorder";
  2944. }
  2945. **/
  2946. $sj = "fullordersmt";
  2947. $where = "1=1";
  2948. if ($warehouse) {
  2949. $where .= " and type = '$warehouse'";
  2950. }
  2951. if ($timetk && $timetj) {
  2952. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2953. }
  2954. if ($orderinfo) {
  2955. $where .= " and orderinfo = '$orderinfo'";
  2956. }
  2957. if ($number) {
  2958. $where .= " and number = '$number'";
  2959. }
  2960. if ($express) {
  2961. $where .= " and express = '$express'";
  2962. }
  2963. if ($waybill) {
  2964. $where .= " and waybill = '$waybill'";
  2965. }
  2966. if ($library) {
  2967. $where .= " and library = '$library'";
  2968. }
  2969. if ($print) {
  2970. $where .= " and print = '$print'";
  2971. }
  2972. if ($libraryconfirm) {
  2973. $where .= " and libraryconfirm = '$libraryconfirm'";
  2974. }
  2975. if ($state) {
  2976. $where .= " and state = '$state'";
  2977. }
  2978. if ($shop) {
  2979. $where .= " and shop = '$shop'";
  2980. }
  2981. if ($sfxh != '') {
  2982. $where .= " and sfxh = '$sfxh'";
  2983. }
  2984. if ($so) {
  2985. $where .= " and shipremarks like '%$so%'";
  2986. }
  2987. if ($source) {
  2988. $where .= " and source = '$source'";
  2989. }
  2990. if ($country) {
  2991. $where .= " and country = '$country'";
  2992. } else {
  2993. if (isset($_SESSION['api'])) {
  2994. foreach ($user as $value) {
  2995. $fgshop .= " shop = " . $value . " or";
  2996. }
  2997. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2998. }
  2999. }
  3000. //数据排序
  3001. $order_str = "librarytime desc";
  3002. if (empty($page)) {
  3003. $start = 0;
  3004. $perpage = 1;
  3005. } else {
  3006. $start = ($page - 1) * $perpage;
  3007. }
  3008. //取得信息列表
  3009. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3010. //格式化数据
  3011. foreach ($info_list as $key => $value) {
  3012. $shop = $this->shop->read($value['shop']);
  3013. $info_list[$key]['shop'] = $shop['shopname'];
  3014. $express = $this->express->read($value['express']);
  3015. $info_list[$key]['express'] = $express['servicename'];
  3016. $warehouse = $this->warehouse->read($value['type']);
  3017. $info_list[$key]['type'] = $warehouse['title'];
  3018. if ($value['librarytime'] == '0') {
  3019. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3020. } else {
  3021. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3022. }
  3023. }
  3024. $total = $this->$sj->find_count($where);
  3025. $pagenum = ceil($total / $perpage);
  3026. $over = $total - ($start + $perpage);
  3027. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3028. echo json_encode($rows);
  3029. exit;
  3030. }
  3031. $this->data['express'] = $this->express->find_all();
  3032. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3033. $this->data['wlshop'] = $wlshop;
  3034. $user = $this->user->get_api($_SESSION['api']);
  3035. $powerid = $this->power->read($user['power']);
  3036. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3037. $pid = '';
  3038. foreach ($powertext as $v) {
  3039. $pid .= " id = " . $v . " or";
  3040. }
  3041. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3042. $this->data['fullorderexcel'] = $fullorderexcel;
  3043. $this->_Template('whlabel_soutorder', $this->data);
  3044. }
  3045. //订单退库
  3046. public function _retreat()
  3047. {
  3048. $post = $this->input->post(NULL, TRUE);
  3049. if (isset($post['page'])) {
  3050. $page = $this->input->post('page', true);
  3051. $perpage = $this->input->post('perpage', true);
  3052. $warehouse = $this->input->post('warehouse', true);
  3053. $timetk = $this->input->post('timetk', true);
  3054. $timetj = $this->input->post('timetj', true);
  3055. $shop = $this->input->post('shop', true);
  3056. $source = $this->input->post('source', true);
  3057. $state = $this->input->post('state', true);
  3058. $review = $this->input->post('review', true);
  3059. $state = $this->input->post('state', true);
  3060. $express = $this->input->post('express', true);
  3061. $orderinfo = $this->input->post('orderinfo', true);
  3062. $user = $this->input->post('user', true);
  3063. $name = $this->input->post('name', true);
  3064. $waybill = $this->input->post('waybill', true);
  3065. $timetk = strtotime($timetk);
  3066. $timetj = strtotime($timetj);
  3067. $where = "(state=206 or state=210) and mergeid = 0";
  3068. if ($warehouse) {
  3069. $where .= " and state = '$warehouse'";
  3070. }
  3071. if ($timetk && $timetj) {
  3072. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3073. }
  3074. if ($shop) {
  3075. $where .= " and shop = '$shop'";
  3076. }
  3077. if ($source) {
  3078. $where .= " and source = '$source'";
  3079. }
  3080. if ($state) {
  3081. $where .= " and state = '$state'";
  3082. }
  3083. if ($review) {
  3084. $where .= " and review = '$review'";
  3085. }
  3086. if ($state) {
  3087. $where .= " and state = '$state'";
  3088. }
  3089. if ($express) {
  3090. $where .= " and express = '$express'";
  3091. }
  3092. if ($orderinfo) {
  3093. $where .= " and orderinfo = '$orderinfo'";
  3094. }
  3095. if ($user) {
  3096. $where .= " and user = '$user'";
  3097. }
  3098. if ($name) {
  3099. $where .= " and name = '$name'";
  3100. }
  3101. if ($waybill) {
  3102. $where .= " and waybill = '$waybill'";
  3103. }
  3104. //数据排序
  3105. $order_str = "id desc";
  3106. if (empty($page)) {
  3107. $start = 0;
  3108. $perpage = 1;
  3109. } else {
  3110. $start = ($page - 1) * $perpage;
  3111. }
  3112. //取得信息列表
  3113. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3114. //格式化数据
  3115. foreach ($info_list as $key => $value) {
  3116. $shop = $this->shop->read($value['shop']);
  3117. $info_list[$key]['shop'] = $shop['shopname'];
  3118. $warehouse = $this->warehouse->read($value['warehouse']);
  3119. $info_list[$key]['warehouse'] = $warehouse['title'];
  3120. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3121. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3122. if ($value['waybill'] == 0) {
  3123. $info_list[$key]['waybill'] = "";
  3124. }
  3125. $express = $this->express->read($value['express']);
  3126. $info_list[$key]['express'] = $express['title'];
  3127. $typeclass = $this->typeclass->read($value['state']);
  3128. $info_list[$key]['state'] = $typeclass['title'];
  3129. }
  3130. $total = $this->fullorder->find_count($where);
  3131. $pagenum = ceil($total / $perpage);
  3132. $over = $total - ($start + $perpage);
  3133. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3134. echo json_encode($rows);
  3135. exit;
  3136. }
  3137. $this->data['express'] = $this->express->find_all();
  3138. $this->_Template('whlabel_retreat', $this->data);
  3139. }
  3140. //退库标签浏览
  3141. public function _retreatlk()
  3142. {
  3143. $post = $this->input->post(NULL, TRUE);
  3144. if (isset($post['page'])) {
  3145. $page = $this->input->post('page', true);
  3146. $perpage = $this->input->post('perpage', true);
  3147. $timetk = $this->input->post('timetk', true);
  3148. $timetj = $this->input->post('timetj', true);
  3149. $sku = $this->input->post('sku', true);
  3150. $warehouse = $this->input->post('warehouse', true);
  3151. $purchase = $this->input->post('purchase', true);
  3152. $orderinfo = $this->input->post('orderinfo', true);
  3153. $waybill = $this->input->post('waybill', true);
  3154. $category = $this->input->post('category', true);
  3155. $size = $this->input->post('size', true);
  3156. $grade = $this->input->post('grade', true);
  3157. $color = $this->input->post('color', true);
  3158. $lowe = $this->input->post('lowe', true);
  3159. $state = $this->input->post('state', true);
  3160. $timetk = strtotime($timetk);
  3161. $timetj = strtotime($timetj);
  3162. $where = "state=2";
  3163. if ($timetk && $timetj) {
  3164. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3165. }
  3166. if ($sku) {
  3167. $where .= " and sku = '$sku'";
  3168. }
  3169. if ($warehouse) {
  3170. $where .= " and warehouse = '$warehouse'";
  3171. }
  3172. if ($purchase) {
  3173. $where .= " and purchase = '$purchase'";
  3174. }
  3175. if ($orderinfo) {
  3176. $where .= " and orderinfo = '$orderinfo'";
  3177. }
  3178. if ($waybill) {
  3179. $where .= " and waybill = '$waybill'";
  3180. }
  3181. if ($category) {
  3182. $where .= " and features like '%-$category-%'";
  3183. }
  3184. if ($size) {
  3185. $where .= " and features like '%-$size-%'";
  3186. }
  3187. if ($grade) {
  3188. $where .= " and features like '%-$grade-%'";
  3189. }
  3190. if ($color) {
  3191. $where .= " and features like '%-$color-%'";
  3192. }
  3193. if ($lowe) {
  3194. $where .= " and features like '%-$lowe-%'";
  3195. }
  3196. //数据排序
  3197. $order_str = "time desc";
  3198. if (empty($page)) {
  3199. $start = 0;
  3200. $perpage = 1;
  3201. } else {
  3202. $start = ($page - 1) * $perpage;
  3203. }
  3204. //取得信息列表
  3205. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3206. foreach ($info_list as $key => $value) {
  3207. $warehouse = $this->warehouse->read($value['warehouse']);
  3208. $info_list[$key]['warehouse'] = $warehouse['title'];
  3209. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3210. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3211. $purchase = $this->purchase->read($value['purchase']);
  3212. $info_list[$key]['purchase'] = $purchase['title'];
  3213. if ($value['outk'] != 0) {
  3214. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3215. } else {
  3216. $info_list[$key]['outk'] = "";
  3217. }
  3218. if ($value['retreat'] != 0) {
  3219. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3220. } else {
  3221. $info_list[$key]['retreat'] = "";
  3222. }
  3223. if ($value['orderinfo'] == 0) {
  3224. $info_list[$key]['orderinfo'] = "";
  3225. }
  3226. if ($value['waybill'] == 0) {
  3227. $info_list[$key]['waybill'] = "";
  3228. }
  3229. }
  3230. $total = $this->whlabel->find_count($where);
  3231. $pagenum = ceil($total / $perpage);
  3232. $over = $total - ($start + $perpage);
  3233. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3234. echo json_encode($rows);
  3235. exit;
  3236. }
  3237. $this->_Template('whlabel_retreatlk', $this->data);
  3238. }
  3239. //更换标签及浏览
  3240. public function _change()
  3241. {
  3242. $post = $this->input->post(NULL, TRUE);
  3243. if (isset($post['page'])) {
  3244. $page = $this->input->post('page', true);
  3245. $perpage = $this->input->post('perpage', true);
  3246. $timetk = $this->input->post('timetk', true);
  3247. $timetj = $this->input->post('timetj', true);
  3248. $label = $this->input->post('label', true);
  3249. $oldlabel = $this->input->post('oldlabel', true);
  3250. $timetk = strtotime($timetk);
  3251. $timetj = strtotime($timetj);
  3252. $where = "state=10 ";
  3253. if ($timetk && $timetj) {
  3254. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3255. }
  3256. if ($label) {
  3257. $where .= " and label = '$label'";
  3258. }
  3259. if ($oldlabel) {
  3260. $where .= " and oldlabel = '$oldlabel'";
  3261. }
  3262. //数据排序
  3263. $order_str = "time asc";
  3264. if (empty($page)) {
  3265. $start = 0;
  3266. $perpage = 1;
  3267. } else {
  3268. $start = ($page - 1) * $perpage;
  3269. }
  3270. //取得信息列表
  3271. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3272. foreach ($info_list as $key => $value) {
  3273. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3274. }
  3275. $total = $this->whlabel->find_count($where);
  3276. $pagenum = ceil($total / $perpage);
  3277. $over = $total - ($start + $perpage);
  3278. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3279. echo json_encode($rows);
  3280. exit;
  3281. }
  3282. $this->_Template('whlabel_change', $this->data);
  3283. }
  3284. //产品标签
  3285. public function _cpbqdc()
  3286. {
  3287. if (isset($_GET['excel'])) {
  3288. $where = "1=1";
  3289. //数据排序
  3290. $order_str = "id desc";
  3291. if (empty($page)) {
  3292. $start = 0;
  3293. $perpage = 1;
  3294. } else {
  3295. $start = ($page - 1) * $perpage;
  3296. }
  3297. $warehouse = $this->input->get('warehouse', true);
  3298. $state = $this->input->get('state', true);
  3299. $timetk = $this->input->get('timetkk', true);
  3300. $timetj = $this->input->get('timetjj', true);
  3301. $timetk = strtotime($timetk);
  3302. $timetj = strtotime($timetj);
  3303. if ($warehouse) {
  3304. $where .= " and warehouse = '$warehouse'";
  3305. }
  3306. if ($state || $state == 0) {
  3307. $where .= " and state = '$state'";
  3308. }
  3309. if ($timetk && $timetj) {
  3310. $where .= " and time > '$timetk' and time < '$timetj'";
  3311. }
  3312. //取得信息列表
  3313. $info_list = $this->whlabel->find_all($where, '*');
  3314. $rows = array();
  3315. $list = array();
  3316. foreach ($info_list as $key => $value) {
  3317. $rows[$value['time']] = $value; //所有数据sku
  3318. }
  3319. foreach ($rows as $value) {
  3320. $warehouse = $this->warehouse->read($value['warehouse']);
  3321. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3322. $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);
  3323. }
  3324. $title = "产品标签统计表";
  3325. $titlename = "<table border=1>
  3326. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3327. <tr align='center'>
  3328. <td>仓库</td>
  3329. <td>SKU</td>
  3330. <td>产品</td>
  3331. <td>入库时间</td>
  3332. <td>操作时间</td>
  3333. <td>备注</td>
  3334. <td>数量</td>
  3335. </tr>
  3336. </table>";
  3337. $filename = $title . ".xls";
  3338. $tail = "";
  3339. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3340. }
  3341. }
  3342. //进销存导出
  3343. public function _exceljxc()
  3344. {
  3345. $classid = $this->classid->sku();
  3346. $pm = $classid;
  3347. $typeclass = array();
  3348. $tc = $this->typeclass->find_all();
  3349. foreach ($tc as $v) {
  3350. $typeclass[$v['id']] = $v;
  3351. }
  3352. $prc = array();
  3353. $purchase = $this->purchase->find_all();
  3354. foreach ($purchase as $k => $v) {
  3355. $prc[$v['id']] = $v['title'];
  3356. }
  3357. if (isset($_GET['excel'])) {
  3358. $where = "sku != 'Preset'";
  3359. //数据排序
  3360. $order_str = "id desc";
  3361. if (empty($page)) {
  3362. $start = 0;
  3363. $perpage = 1;
  3364. } else {
  3365. $start = ($page - 1) * $perpage;
  3366. }
  3367. $category = $this->input->get('category', true);
  3368. $warehouse = $this->input->get('warehouse', true);
  3369. $excelid = $this->input->get('sid', true);
  3370. if ($category) {
  3371. $where .= " and features like '%-$category-%'";
  3372. }
  3373. if ($warehouse) {
  3374. $where .= " and warehouse = '$warehouse'";
  3375. }
  3376. $xzid = '';
  3377. if ($excelid) {
  3378. $excelid = explode(',', trim($excelid, ','));
  3379. foreach ($excelid as $key => $value) {
  3380. $xzid .= " id = " . $value . " or";
  3381. }
  3382. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3383. }
  3384. //取得信息列表
  3385. /**
  3386. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3387. $rows = array();$list = array();
  3388. foreach ($info_list as $key=>$value)
  3389. {
  3390. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3391. }
  3392. **/
  3393. $wt = array();
  3394. $whlabel_type = $this->whlabel_type->find_all();
  3395. foreach ($whlabel_type as $v) {
  3396. $wt[$v['id']] = $v['title'];
  3397. }
  3398. $wh = array();
  3399. $w = $this->warehouse->find_all('1=1', 'id,title');
  3400. foreach ($w as $v) {
  3401. $wh[$v['id']] = $v['title'];
  3402. }
  3403. $list = array();
  3404. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3405. foreach ($rows as $key => $value) {
  3406. if (isset($wt[$value['type']])) {
  3407. $rows[$key]['type'] = $wt[$value['type']];
  3408. } else {
  3409. $rows[$key]['type'] = '未设置';
  3410. }
  3411. $bm = '03';
  3412. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3413. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3414. $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');
  3415. $details = array();
  3416. $cpid = array();
  3417. $cpbz = array();
  3418. $c = 0;
  3419. $g = 0;
  3420. $x = 0;
  3421. $t = 0;
  3422. $s = 0;
  3423. $q = 0;
  3424. foreach ($sd as $k => $v) {
  3425. if ($v['state'] == 0) {
  3426. $c++;
  3427. if ($v['cpid'] != 0) {
  3428. $cpid[$v['cpid']] = $v['cpid'];
  3429. }
  3430. if ($v['cpbz'] != '') {
  3431. $cpbz[$v['cpbz']] = $v['cpbz'];
  3432. }
  3433. }
  3434. if ($v['state'] != 9) {
  3435. $g++;
  3436. }
  3437. if ($v['state'] == 1) {
  3438. $x++;
  3439. }
  3440. if ($v['state'] == 2) {
  3441. $t++;
  3442. }
  3443. if ($v['state'] == 8) {
  3444. $s++;
  3445. }
  3446. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3447. $q++;
  3448. }
  3449. $details[$v['details']] = $v['details'];
  3450. }
  3451. $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'] . '"');
  3452. $rows[$key]['details'] = implode("、", $details);
  3453. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3454. $number = $value['number'];
  3455. $ftime = time() - 15 * 24 * 3600;
  3456. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3457. $rows[$key]['number'] = $g;
  3458. $rows[$key]['c'] = $c;
  3459. $rows[$key]['x'] = $x;
  3460. $rows[$key]['t'] = $t;
  3461. $rows[$key]['s'] = $s;
  3462. $rows[$key]['q'] = $q;
  3463. $rows[$key]['z'] = $z;
  3464. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3465. $features = explode('-', trim($features, '-'));
  3466. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3467. // $pm = $classid;
  3468. // $jm = $classid;
  3469. // foreach($features as $k=>$v)
  3470. // {
  3471. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3472. // {
  3473. // if($typeclass[$v]['bm'] != '')
  3474. // {
  3475. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3476. // }
  3477. // }
  3478. // if($v != 0)
  3479. // {
  3480. // if(!isset($typeclass[$v]))
  3481. // {
  3482. // continue;
  3483. // }
  3484. // if(isset($pm[$typeclass[$v]['classid']]))
  3485. // {
  3486. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3487. // {
  3488. // $tz = explode('|',$typeclass[$v]['zh']);
  3489. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3490. // }
  3491. // else
  3492. // {
  3493. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3494. // }
  3495. // }
  3496. // if(isset($jm[$typeclass[$v]['classid']]))
  3497. // {
  3498. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3499. // }
  3500. // }
  3501. // }
  3502. // $jm = array_filter($jm);
  3503. // $rows[$key]['bs'] = implode("-",$jm);
  3504. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3505. // $zh = implode(" ",$pm);
  3506. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3507. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3508. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3509. // $rows[$key]['features'] = $zh;
  3510. }
  3511. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3512. $final_list = [];
  3513. foreach ($list as $k => $v) {
  3514. if (empty($v['sku'])) {
  3515. continue;
  3516. }
  3517. $final_list[] = [
  3518. "warehouse" => $v["warehouse"],
  3519. "purchase" => $v["purchase"],
  3520. "details" => $v["details"],
  3521. "cpid" => $v["cpid"],
  3522. "dbcontent" => $v["dbcontent"],
  3523. "sku" => $v["sku"],
  3524. "cs" => $v["bm"],
  3525. "bs" => $v["jm"],
  3526. "title" => $v["title"],
  3527. "features" => $v["pm"],
  3528. "cpbz" => $v["cpbz"],
  3529. "sm" => $v["sm"],
  3530. "type" => $v["type"],
  3531. "number" => $v["number"],
  3532. "c" => $v["c"],
  3533. "x" => $v["x"],
  3534. "t" => $v["t"],
  3535. "s" => $v["s"],
  3536. "q" => $v["q"],
  3537. "z" => $v["z"],
  3538. "weight" => $v['weight'],
  3539. ];
  3540. }
  3541. $title = "总进销存统计表";
  3542. $titlename = "<table border=1>
  3543. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3544. <tr align='center'>
  3545. <td>仓库</td>
  3546. <td>供应商</td>
  3547. <td>位置</td>
  3548. <td>库存编码</td>
  3549. <td>类目</td>
  3550. <td>SKU</td>
  3551. <td>用友编码</td>
  3552. <td>用友料号</td>
  3553. <td>商品名称</td>
  3554. <td>商品中文</td>
  3555. <td>产品备注</td>
  3556. <td>说明</td>
  3557. <td>类型</td>
  3558. <td>入库总量</td>
  3559. <td>库存数量</td>
  3560. <td>销售数量</td>
  3561. <td>退货数量</td>
  3562. <td>删除数量</td>
  3563. <td>其它操作</td>
  3564. <td>占单数量</td>
  3565. <td>重量(g)</td>
  3566. </tr>
  3567. </table>";
  3568. $filename = $title . ".xls";
  3569. $tail = "";
  3570. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3571. }
  3572. }
  3573. //入库导出
  3574. public function _excelr()
  3575. {
  3576. if (isset($_GET['excel'])) {
  3577. $category = $this->input->get('category', true);
  3578. $size = $this->input->get('size', true);
  3579. $grade = $this->input->get('grade', true);
  3580. $color = $this->input->get('color', true);
  3581. $lowe = $this->input->get('lowe', true);
  3582. $sku = $this->input->get('sku', true);
  3583. $warehouse = $this->input->get('warehouse', true);
  3584. $purchase = $this->input->get('purchase', true);
  3585. $ktime = $this->input->get('ktime', true);
  3586. $jtime = $this->input->get('jtime', true);
  3587. $ktime = strtotime($ktime);
  3588. $jtime = strtotime($jtime);
  3589. $where = "1=1";
  3590. $gj = "";
  3591. $ck = "";
  3592. if ($category) {
  3593. $where .= " and features like '%-$category-%'";
  3594. }
  3595. if ($size) {
  3596. $where .= " and features like '%-$size-%'";
  3597. }
  3598. if ($grade) {
  3599. $where .= " and features like '%-$grade-%'";
  3600. }
  3601. if ($color) {
  3602. $where .= " and features like '%-$color-%'";
  3603. }
  3604. if ($lowe) {
  3605. $where .= " and features like '%-$lowe-%'";
  3606. }
  3607. if ($warehouse) {
  3608. $where .= " and warehouse = '$warehouse'";
  3609. }
  3610. if ($purchase) {
  3611. $where .= " and purchase = '$purchase'";
  3612. }
  3613. if ($sku) {
  3614. $where .= " and sku = '$sku'";
  3615. }
  3616. if ($ktime && $jtime) {
  3617. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3618. }
  3619. //数据排序
  3620. $order_str = "id desc";
  3621. if (empty($page)) {
  3622. $start = 0;
  3623. $perpage = 1;
  3624. } else {
  3625. $start = ($page - 1) * $perpage;
  3626. }
  3627. $list = array();
  3628. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3629. foreach ($rows as $value) {
  3630. $ck = $this->warehouse->read($value['warehouse']);
  3631. $warehouse = $ck['title'];
  3632. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3633. $retreatwarehouse = $tkck['title'];
  3634. $gy = $this->purchase->read($value['purchase']);
  3635. $purchase = $gy['title'];
  3636. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3637. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3638. }
  3639. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3640. $titlename = "<table border=1>
  3641. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3642. <tr align='center'>
  3643. <td>仓库</td>
  3644. <td>SKU</td>
  3645. <td>产品</td>
  3646. <td>时间</td>
  3647. <td>数量</td>
  3648. </tr>
  3649. </table>";
  3650. $filename = $title . ".xls";
  3651. $tail = "";
  3652. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3653. }
  3654. }
  3655. //出库、退库导出
  3656. public function _excelct()
  3657. {
  3658. $classid = $this->classid->sku();
  3659. $pm = $classid;
  3660. $typeclass = array();
  3661. $tc = $this->typeclass->find_all();
  3662. foreach ($tc as $v) {
  3663. $typeclass[$v['id']] = $v;
  3664. }
  3665. $prc = array();
  3666. $purchase = $this->purchase->find_all();
  3667. foreach ($purchase as $k => $v) {
  3668. $prc[$v['id']] = $v['title'];
  3669. }
  3670. if (isset($_GET['excel'])) {
  3671. $wh = array();
  3672. $w = $this->warehouse->find_all('1=1', 'id,title');
  3673. foreach ($w as $v) {
  3674. $wh[$v['id']] = $v['title'];
  3675. }
  3676. $type = $this->input->get('excel', true);
  3677. $category = $this->input->get('category', true);
  3678. $size = $this->input->get('size', true);
  3679. $grade = $this->input->get('grade', true);
  3680. $color = $this->input->get('color', true);
  3681. $lowe = $this->input->get('lowe', true);
  3682. $sku = $this->input->get('sku', true);
  3683. $warehouse = $this->input->get('warehouse', true);
  3684. $lacetype = $this->input->get('lacetype', true);
  3685. $lacecolor = $this->input->get('lacecolor', true);
  3686. $density = $this->input->get('density', true);
  3687. $haircap = $this->input->get('haircap', true);
  3688. $purchase = $this->input->get('purchase', true);
  3689. $title = $this->input->get('title', true);
  3690. $state = $this->input->get('state', true);
  3691. $sid = $this->input->get('sid', true);
  3692. $ktime = $this->input->get('ktime', true);
  3693. $jtime = $this->input->get('jtime', true);
  3694. $ktime = strtotime($ktime);
  3695. $jtime = strtotime($jtime);
  3696. //$where = " 1=1 ";
  3697. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  3698. $where = " sku != '' ";
  3699. $gj = "";
  3700. $ck = "";
  3701. if ($category) {
  3702. $where .= " and features like '%-$category-%'";
  3703. }
  3704. if ($size) {
  3705. $where .= " and features like '%-$size-%'";
  3706. }
  3707. if ($grade) {
  3708. $where .= " and features like '%-$grade-%'";
  3709. }
  3710. if ($color) {
  3711. $where .= " and features like '%-$color-%'";
  3712. }
  3713. if ($lowe) {
  3714. $where .= " and features like '%-$lowe-%'";
  3715. }
  3716. if ($warehouse) {
  3717. $where .= " and warehouse = '$warehouse'";
  3718. }
  3719. if ($purchase) {
  3720. $where .= " and purchase = '$purchase'";
  3721. }
  3722. if ($state) {
  3723. $where .= " and state = '$state'";
  3724. }
  3725. if ($lacetype) {
  3726. $where .= " and features like '%-$lacetype-%'";
  3727. }
  3728. if ($lacecolor) {
  3729. $where .= " and features like '%-$lacecolor-%'";
  3730. }
  3731. if ($density) {
  3732. $where .= " and features like '%-$density-%'";
  3733. }
  3734. if ($haircap) {
  3735. $where .= " and features like '%-$haircap-%'";
  3736. }
  3737. if ($title) {
  3738. $title = trim($title, ' ');
  3739. $title = trim($title, ' ');
  3740. $where .= " and title like '%$title%'";
  3741. }
  3742. if ($sku) {
  3743. $sku = trim($sku, ' ');
  3744. $sku = trim($sku, ' ');
  3745. $where .= " and sku like '%$sku%'";
  3746. }
  3747. if ($ktime && $jtime) {
  3748. if ($type == 1) {
  3749. $tl = '出库';
  3750. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3751. } else if ($type == 2) {
  3752. $tl = '退库';
  3753. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3754. } else if ($type == 3) {
  3755. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3756. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3757. } else if ($type == 4) {
  3758. $tl = '出库+零售';
  3759. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3760. } else if ($type == 5) {
  3761. $tl = '零售';
  3762. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3763. }
  3764. }
  3765. $sidwhere = '';
  3766. if ($sid) {
  3767. $sd = "";
  3768. $s = explode(',', trim($sid, ','));
  3769. foreach ($s as $value) {
  3770. $sd .= " id = " . $value . " or";
  3771. }
  3772. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3773. }
  3774. //数据排序
  3775. $order_str = "time desc";
  3776. if (empty($page)) {
  3777. $start = 0;
  3778. $perpage = 1;
  3779. } else {
  3780. $start = ($page - 1) * $perpage;
  3781. }
  3782. //取得信息列表
  3783. if ($type != 3 && $type != 5) {
  3784. if ($type == 1 || $type == 4) {
  3785. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3786. foreach ($info_list as $key => $value) {
  3787. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3788. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3789. $warehouse = $this->warehouse->read($value['warehouse']);
  3790. $info_list[$key]['warehouse'] = $warehouse['title'];
  3791. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3792. $features = explode('-', trim($features, '-'));
  3793. $pm = $classid;
  3794. foreach ($features as $k => $v) {
  3795. if ($v != 0) {
  3796. if (!isset($typeclass[$v])) {
  3797. continue;
  3798. }
  3799. if (isset($pm[$typeclass[$v]['classid']])) {
  3800. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3801. $tz = explode('|', $typeclass[$v]['zh']);
  3802. $pm[$typeclass[$v]['classid']] = $tz[0];
  3803. } else {
  3804. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3805. }
  3806. }
  3807. }
  3808. }
  3809. $zh = implode(" ", $pm);
  3810. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3811. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3812. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3813. $info_list[$key]['features'] = $zh;
  3814. }
  3815. $final_list = [];
  3816. foreach($info_list as $k=>$v){
  3817. $number = "";
  3818. if(!empty($v['orderinfo'])){
  3819. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3820. if(!empty($tmp_info['number'])){
  3821. $number = $tmp_info['number'];
  3822. }
  3823. }
  3824. $final_list[] = [
  3825. 'warehouse'=>$v['warehouse'],
  3826. 'purchase'=>$v['purchase'],
  3827. 'sku'=>$v['sku'],
  3828. 'title'=>$v['title'],
  3829. 'features'=>$v['features'],
  3830. 'label'=>$v['label'],
  3831. 'orderinfo'=>$v['orderinfo'],
  3832. 'number'=>$number,
  3833. 'waybill'=>$v['waybill'],
  3834. 'outk'=>$v['outk'],
  3835. ];
  3836. }
  3837. } else {
  3838. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3839. foreach ($info_list as $key => $value) {
  3840. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3841. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3842. $warehouse = $this->warehouse->read($value['warehouse']);
  3843. $info_list[$key]['warehouse'] = $warehouse['title'];
  3844. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3845. $features = explode('-', trim($features, '-'));
  3846. $pm = $classid;
  3847. foreach ($features as $k => $v) {
  3848. if ($v != 0) {
  3849. if (!isset($typeclass[$v])) {
  3850. continue;
  3851. }
  3852. if (isset($pm[$typeclass[$v]['classid']])) {
  3853. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3854. $tz = explode('|', $typeclass[$v]['zh']);
  3855. $pm[$typeclass[$v]['classid']] = $tz[0];
  3856. } else {
  3857. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3858. }
  3859. }
  3860. }
  3861. }
  3862. $zh = implode(" ", $pm);
  3863. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3864. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3865. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3866. $info_list[$key]['features'] = $zh;
  3867. }
  3868. $final_list = [];
  3869. foreach($info_list as $k=>$v){
  3870. $number = "";
  3871. if(!empty($v['orderinfo'])){
  3872. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3873. if(!empty($tmp_info['number'])){
  3874. $number = $tmp_info['number'];
  3875. }
  3876. }
  3877. $final_list[] = [
  3878. 'warehouse'=>$v['warehouse'],
  3879. 'purchase'=>$v['purchase'],
  3880. 'sku'=>$v['sku'],
  3881. 'title'=>$v['title'],
  3882. 'features'=>$v['features'],
  3883. 'label'=>$v['label'],
  3884. 'orderinfo'=>$v['orderinfo'],
  3885. 'number'=>$number,
  3886. 'waybill'=>$v['waybill'],
  3887. 'retreat'=>$v['retreat'],
  3888. ];
  3889. }
  3890. }
  3891. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3892. $titlename = "<table border=1>
  3893. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3894. <tr align='center'>
  3895. <td>仓库</td>
  3896. <td>供应商</td>
  3897. <td>SKU</td>
  3898. <td>商品名称</td>
  3899. <td>商品中文</td>
  3900. <td>标签</td>
  3901. <td>订单号</td>
  3902. <td>订单编码</td>
  3903. <td>运单号</td>
  3904. <td>" . $tl . "时间(中国时间)</td>
  3905. </tr>
  3906. </table>";
  3907. $filename = $title . ".xls";
  3908. $tail = "";
  3909. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3910. } else if ($type == 5) {
  3911. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3912. foreach ($info_list as $key => $value) {
  3913. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3914. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3915. $warehouse = $this->warehouse->read($value['warehouse']);
  3916. $info_list[$key]['warehouse'] = $warehouse['title'];
  3917. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3918. $features = explode('-', trim($features, '-'));
  3919. $pm = $classid;
  3920. foreach ($features as $k => $v) {
  3921. if ($v != 0) {
  3922. if (!isset($typeclass[$v])) {
  3923. continue;
  3924. }
  3925. if (isset($pm[$typeclass[$v]['classid']])) {
  3926. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3927. $tz = explode('|', $typeclass[$v]['zh']);
  3928. $pm[$typeclass[$v]['classid']] = $tz[0];
  3929. } else {
  3930. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3931. }
  3932. }
  3933. }
  3934. }
  3935. $zh = implode(" ", $pm);
  3936. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3937. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3938. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3939. $info_list[$key]['features'] = $zh;
  3940. }
  3941. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3942. $titlename = "<table border=1>
  3943. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3944. <tr align='center'>
  3945. <td>仓库</td>
  3946. <td>供应商</td>
  3947. <td>SKU</td>
  3948. <td>商品名称</td>
  3949. <td>商品中文</td>
  3950. <td>标签</td>
  3951. <td>" . $tl . "时间(中国时间)</td>
  3952. </tr>
  3953. </table>";
  3954. $filename = $title . ".xls";
  3955. $tail = "";
  3956. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3957. } else {
  3958. /**
  3959. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3960. $rows = array();$list = array();
  3961. foreach ($info_list as $key=>$value)
  3962. {
  3963. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3964. }
  3965. **/
  3966. $wh = array();
  3967. $w = $this->warehouse->find_all('1=1', 'id,title');
  3968. foreach ($w as $v) {
  3969. $wh[$v['id']] = $v['title'];
  3970. }
  3971. $wt = array();
  3972. $whlabel_type = $this->whlabel_type->find_all();
  3973. foreach ($whlabel_type as $v) {
  3974. $wt[$v['id']] = $v['title'];
  3975. }
  3976. $classid = $this->classid->sku();
  3977. $list = array();
  3978. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3979. foreach ($rows as $key => $value) {
  3980. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3981. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3982. $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');
  3983. $details = array();
  3984. $cpid = array();
  3985. $cpbz = array();
  3986. $c = 0;
  3987. $g = 0;
  3988. $x = 0;
  3989. $t = 0;
  3990. $s = 0;
  3991. $q = 0;
  3992. foreach ($sd as $k => $v) {
  3993. if ($v['state'] == 0) {
  3994. $c++;
  3995. }
  3996. if ($v['state'] != 9) {
  3997. $g++;
  3998. }
  3999. if ($v['outk'] > 1) {
  4000. $x++;
  4001. }
  4002. if ($v['retreat'] > 0) {
  4003. $t++;
  4004. }
  4005. if ($v['state'] == 8) {
  4006. $s++;
  4007. }
  4008. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4009. $q++;
  4010. }
  4011. $details[$v['details']] = $v['details'];
  4012. if ($v['cpid'] != 0) {
  4013. $cpid[$v['cpid']] = $v['cpid'];
  4014. }
  4015. if ($v['cpbz'] != '') {
  4016. $cpbz[$v['cpbz']] = $v['cpbz'];
  4017. }
  4018. }
  4019. if (isset($wt[$value['type']])) {
  4020. $rows[$key]['type'] = $wt[$value['type']];
  4021. } else {
  4022. $rows[$key]['type'] = '未设置';
  4023. }
  4024. $rows[$key]['details'] = implode("、", $details);
  4025. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4026. $ftime = time() - 15 * 24 * 3600;
  4027. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4028. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4029. $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);
  4030. $rows[$key]['c'] = $c;
  4031. $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);
  4032. $rows[$key]['t'] = $t;
  4033. $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'] . '"');
  4034. $rows[$key]['z'] = $z;
  4035. // $jm = $classid;
  4036. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4037. $features = explode('-', trim($features, '-'));
  4038. // $pm = $classid;
  4039. // foreach ($features as $k => $v) {
  4040. // if ($v != 0) {
  4041. // if (!isset($typeclass[$v])) {
  4042. // continue;
  4043. // }
  4044. // if (isset($pm[$typeclass[$v]['classid']])) {
  4045. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4046. // $tz = explode('|', $typeclass[$v]['zh']);
  4047. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4048. // } else {
  4049. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4050. // }
  4051. // if (isset($jm[$typeclass[$v]['classid']])) {
  4052. // if ($typeclass[$v]['jm']) {
  4053. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4054. // }
  4055. // }
  4056. // }
  4057. // }
  4058. // }
  4059. // $zh = implode(" ", $pm);
  4060. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4061. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4062. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4063. // $rows[$key]['features'] = $zh;
  4064. // $jm = array_filter($jm); //去除空值
  4065. // $jm = implode("-", $jm);
  4066. // $rows[$key]['jm'] = $jm;
  4067. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4068. }
  4069. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4070. // echo "<pre>";
  4071. // print_r($tmp_list);
  4072. // die;
  4073. $final_list =[];
  4074. foreach($tmp_list as $k=>$v){
  4075. $final_list[] = [
  4076. "warehouse"=>$v['warehouse'],
  4077. "purchase"=>$v['purchase'],
  4078. "details"=>$v['details'],
  4079. "cpid"=>$v['cpid'],
  4080. "sku"=>$v['sku'],
  4081. "title"=>$v['title'],
  4082. "features"=>$v['pm'],
  4083. "cpbz"=>$v['cpbz'],
  4084. "sm"=>$v['sm'],
  4085. "type"=>$v['type'],
  4086. "g"=>$v["g"],
  4087. "c"=>$v["c"],
  4088. "x"=>$v["x"],
  4089. "t"=>$v["t"],
  4090. "z"=>$v["z"],
  4091. "jm"=>$v["jm"],
  4092. "weight"=>$v["weight"],
  4093. "asd"=>$v["asd"],
  4094. ];
  4095. }
  4096. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4097. $titlename = "<table border=1>
  4098. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4099. <tr align='center'>
  4100. <td>仓库</td>
  4101. <td>供应商</td>
  4102. <td>位置</td>
  4103. <td>库存编码</td>
  4104. <td>SKU</td>
  4105. <td>商品名称</td>
  4106. <td>商品中文</td>
  4107. <td>产品备注</td>
  4108. <td>说明</td>
  4109. <td>类型</td>
  4110. <td>入库总量</td>
  4111. <td>库存数量</td>
  4112. <td>销售数量</td>
  4113. <td>退货数量</td>
  4114. <td>占单数量</td>
  4115. <td>料号</td>
  4116. <td>重量</td>
  4117. <td>类目</td>
  4118. </tr>
  4119. </table>";
  4120. $filename = $title . ".xls";
  4121. $tail = "";
  4122. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4123. }
  4124. }
  4125. }
  4126. //出库+入库数据整合
  4127. public function _excelcr()
  4128. {
  4129. if (isset($_GET['excel'])) {
  4130. $type = $this->input->get('excel', true);
  4131. $category = $this->input->get('category', true);
  4132. $size = $this->input->get('size', true);
  4133. $grade = $this->input->get('grade', true);
  4134. $color = $this->input->get('color', true);
  4135. $lowe = $this->input->get('lowe', true);
  4136. $sku = $this->input->get('sku', true);
  4137. $warehouse = $this->input->get('warehouse', true);
  4138. $purchase = $this->input->get('purchase', true);
  4139. $state = $this->input->get('state', true);
  4140. $sid = $this->input->get('sid', true);
  4141. $ktime = $this->input->get('ktime', true);
  4142. $jtime = $this->input->get('jtime', true);
  4143. $ktime = strtotime($ktime);
  4144. $jtime = strtotime($jtime);
  4145. $where = "1=1";
  4146. $gj = "";
  4147. $ck = "";
  4148. if ($category) {
  4149. $where .= " and features like '%-$category-%'";
  4150. }
  4151. if ($size) {
  4152. $where .= " and features like '%-$size-%'";
  4153. }
  4154. if ($grade) {
  4155. $where .= " and features like '%-$grade-%'";
  4156. }
  4157. if ($color) {
  4158. $where .= " and features like '%-$color-%'";
  4159. }
  4160. if ($lowe) {
  4161. $where .= " and features like '%-$lowe-%'";
  4162. }
  4163. if ($warehouse) {
  4164. $where .= " and warehouse = '$warehouse'";
  4165. }
  4166. if ($purchase) {
  4167. $where .= " and purchase = '$purchase'";
  4168. }
  4169. if ($state) {
  4170. $where .= " and state = '$state'";
  4171. }
  4172. if ($sku) {
  4173. $where .= " and sku like '%$sku%'";
  4174. }
  4175. if ($ktime && $jtime) {
  4176. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4177. }
  4178. $sidwhere = '';
  4179. if ($sid) {
  4180. $sd = "";
  4181. $s = explode(',', trim($sid, ','));
  4182. foreach ($s as $value) {
  4183. $sd .= " id = " . $value . " or";
  4184. }
  4185. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4186. }
  4187. //取得信息列表
  4188. $timeread = $ktime;
  4189. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4190. $timelist = array();
  4191. for ($i = 0; $i < $timenum; $i++) {
  4192. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4193. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4194. }
  4195. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4196. //echo "<pre>";
  4197. //print_r($info_list);
  4198. //exit();
  4199. $rows = array();
  4200. $list = array();
  4201. foreach ($info_list as $key => $value) {
  4202. $thistime = $timelist;
  4203. if (isset($rows[strtolower($value['sku'])])) {
  4204. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4205. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4206. }
  4207. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4208. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4209. }
  4210. } else {
  4211. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4212. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4213. }
  4214. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4215. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4216. }
  4217. $rows[strtolower($value['sku'])] = $thistime;
  4218. }
  4219. }
  4220. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4221. <head>
  4222. <!--[if gte mso 9]><xml>
  4223. <x:ExcelWorkbook>
  4224. <x:ExcelWorksheets>
  4225. <x:ExcelWorksheet>
  4226. <x:Name>EXCEL</x:Name>
  4227. <x:WorksheetOptions>
  4228. <x:Print>
  4229. <x:ValidPrinterInfo />
  4230. </x:Print>
  4231. </x:WorksheetOptions>
  4232. </x:ExcelWorksheet>
  4233. </x:ExcelWorksheets>
  4234. </x:ExcelWorkbook>
  4235. </xml>
  4236. <![endif]-->
  4237. </head><body>";
  4238. $str .= "<table border=1><tr><td>SKU</td>";
  4239. foreach ($timelist as $k => $v) {
  4240. $str .= "<td>" . $k . "出库</td>";
  4241. $str .= "<td>" . $k . "入库</td>";
  4242. }
  4243. $str .= "</tr></table>";
  4244. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4245. foreach ($rows as $key => $val) {
  4246. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4247. foreach ($val as $k => $v) {
  4248. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4249. if ($val[$k]['r'] > 0) {
  4250. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4251. } else {
  4252. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4253. }
  4254. }
  4255. $str .= "</tr>";
  4256. }
  4257. $str .= "</table>";
  4258. $str .= "</body></html>";
  4259. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4260. header("Content-type: application/octet-stream");
  4261. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4262. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4263. header("Pragma: no-cache");
  4264. header("Expires: 0");
  4265. exit($str);
  4266. }
  4267. }
  4268. //数量调整模板导出
  4269. public function _presetout()
  4270. {
  4271. if (isset($_GET['excel'])) {
  4272. $where = "sku != 'Preset' and purchase != 0";
  4273. //数据排序
  4274. $order_str = "id desc";
  4275. if (empty($page)) {
  4276. $start = 0;
  4277. $perpage = 1;
  4278. } else {
  4279. $start = ($page - 1) * $perpage;
  4280. }
  4281. //取得信息列表
  4282. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4283. $rows = array();
  4284. $list = array();
  4285. foreach ($info_list as $value) {
  4286. $warehouse = $this->warehouse->read($value['warehouse']);
  4287. $number = $value['number'];
  4288. $ftime = time() - 15 * 24 * 3600;
  4289. $purchase = $this->purchase->read($value['purchase']);
  4290. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4291. }
  4292. $title = "库存模板";
  4293. $titlename = "<table border=1>
  4294. <tr align='center'>
  4295. <td>仓库</td>
  4296. <td>供应商编码</td>
  4297. <td>SKU</td>
  4298. <td>增减数量(正数或负数)</td>
  4299. <td>增减备注</td>
  4300. <td>扣减方式:0减少库存1删除库存</td>
  4301. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4302. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4303. </tr>
  4304. </table>";
  4305. $filename = $title . ".xls";
  4306. $tail = "";
  4307. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4308. }
  4309. }
  4310. //数量调整模板导入
  4311. public function _presetedit()
  4312. {
  4313. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4314. $config['upload_path'] = '.' . $dir;
  4315. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4316. $config['allowed_types'] = 'xls|xlsx|csv';
  4317. $config['max_size'] = 10240;
  4318. $this->load->library('upload', $config);
  4319. $this->upload->initialize($config);
  4320. if ($this->upload->do_upload('userfile')) {
  4321. $full_path = $dir . $this->upload->data('file_name');
  4322. $fileName = '.' . $full_path;
  4323. if (!file_exists($fileName)) {
  4324. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4325. exit;
  4326. } else {
  4327. require_once "./data/excel/PHPExcel/IOFactory.php";
  4328. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4329. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4330. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4331. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4332. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4333. ++$column; //如果列数大于26行
  4334. $list = array();
  4335. for ($i = 2; $i <= $row; $i++) // 行数循环
  4336. {
  4337. $data = array();
  4338. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4339. {
  4340. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4341. }
  4342. $list[] = $data;
  4343. }
  4344. }
  4345. $i = 0;
  4346. $j = 0;
  4347. $ed = array();
  4348. foreach ($list as $key => $value) {
  4349. $time = time();
  4350. if ($value['0'] == "") {
  4351. continue;
  4352. }
  4353. $warehouse = $this->warehouse->get_title($value['0']);
  4354. $purchase = $this->purchase->get_bm($value['1']);
  4355. $sku = $value['2'];
  4356. $num = $value['3']; //调整数量
  4357. $text = $value['4']; //扣减说明
  4358. $type = $value['5']; //调整方式0扣减1删除
  4359. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4360. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4361. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4362. if (!$purchase) //如果没有这个SKU
  4363. {
  4364. $ed[] = array($purchase . '-不存在此供应商编码');
  4365. $j++;
  4366. continue;
  4367. }
  4368. if (!$d) //如果没有这个SKU
  4369. {
  4370. $ed[] = array($sku . '-库存中不存在此SKU');
  4371. $j++;
  4372. continue;
  4373. }
  4374. if (!isset($warehouse['id'])) {
  4375. $ed[] = array($sku . '-仓库名错误!');
  4376. $j++;
  4377. continue;
  4378. }
  4379. if ($type != '0' && $type != '1') {
  4380. $ed[] = array($sku . '-扣减方式填写错误!');
  4381. $j++;
  4382. continue;
  4383. }
  4384. if ($num < 0) //扣减库存
  4385. {
  4386. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4387. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4388. $j++;
  4389. continue;
  4390. }
  4391. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4392. if (count($data) < abs($num)) {
  4393. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4394. $j++;
  4395. continue;
  4396. }
  4397. if ($type == 0) //如果扣减方式为 扣减库存
  4398. {
  4399. for ($i = 0; $i < abs($num); $i++) {
  4400. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4401. }
  4402. } else if ($type == 1) {
  4403. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4404. if (count($zt) > 0) {
  4405. $ed[] = array($sku . '-有在途库存无法删除!');
  4406. $j++;
  4407. continue;
  4408. }
  4409. for ($i = 0; $i < abs($num); $i++) {
  4410. $this->whlabel->remove($data[$i]['id']);
  4411. }
  4412. }
  4413. } else if ($num > 0) //增加库存
  4414. {
  4415. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4416. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4417. $j++;
  4418. continue;
  4419. }
  4420. $post['sku'] = $d['sku'];
  4421. $post['shop'] = $d['shop'];
  4422. $post['warehouse'] = $warehouse['id'];
  4423. $post['purchase'] = $purchase['id'];
  4424. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4425. $post['state'] = 0;
  4426. $post['title'] = $d['title'];
  4427. $post['number'] = $d['number'];
  4428. $post['features'] = $d['features'];
  4429. $post['enter'] = $time;
  4430. $post['time'] = $time; //操作时间
  4431. $post['rktype'] = $rktype;
  4432. for ($i = 0; $i < $num; $i++) {
  4433. $post['label'] = time() . rand(100, 999) . $i;
  4434. $this->whlabel->insert($post);
  4435. }
  4436. }
  4437. sleep(1); //防止入库时间一样,需要延迟1秒
  4438. }
  4439. if ($j > 0) {
  4440. $tt = date('Ymd', time());
  4441. $title = '库存导入错误信息-' . $tt;
  4442. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4443. $tail = "\n";
  4444. $filename = $title . ".xls";
  4445. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4446. $dir = '/data/excel/' . $time . '/';
  4447. $file_name = 'error_' . $time . rand(1000, 9999);
  4448. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4449. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4450. fwrite($myfile, $ecl);
  4451. fclose($myfile);
  4452. $error = $dir . $file_name . '.xls';
  4453. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4454. exit;
  4455. } else {
  4456. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4457. exit;
  4458. }
  4459. }
  4460. }
  4461. //笛卡儿积
  4462. function cp($ps, $sets, $list)
  4463. {
  4464. $result = array();
  4465. $j = 0;
  4466. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4467. if ($i == 0) {
  4468. $result = $sets[$i];
  4469. }
  4470. $tmp = array();
  4471. foreach ($result as $res) {
  4472. foreach ($sets[$i + 1] as $set) {
  4473. $tmp[] = $res . ',' . $set;
  4474. }
  4475. }
  4476. $result = $tmp;
  4477. }
  4478. $this->db->trans_begin();
  4479. foreach ($result as $v) {
  4480. $post = array();
  4481. $title = "";
  4482. $num = "";
  4483. $data = explode(',', $v);
  4484. for ($i = 0; $i < count($list); $i++) {
  4485. $post[$list[$i]] = $data[$i];
  4486. $typeclass = $this->typeclass->read($data[$i]);
  4487. $title = $title . $typeclass['title'] . " ";
  4488. if ($data[$i] != 0) {
  4489. $num .= $data[$i]; //所有数据ID拼接
  4490. }
  4491. }
  4492. foreach ($ps as $kp => $vp) {
  4493. $post[$kp] = $vp;
  4494. }
  4495. $post['number'] = $num;
  4496. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4497. if ($info_list) {
  4498. $j++;
  4499. } else {
  4500. $skunum = $this->whlabel->find_count();
  4501. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4502. $post['title'] = rtrim($title, ' ');
  4503. $this->whlabel->insert($post);
  4504. }
  4505. }
  4506. if ($this->db->trans_status() === FALSE) {
  4507. $this->db->trans_commit();
  4508. return NULL;
  4509. } else {
  4510. $this->db->trans_commit();
  4511. return $j;
  4512. }
  4513. }
  4514. public function _kj($arg_array)
  4515. {
  4516. if (isset($_POST['sku'])) {
  4517. $time = time();
  4518. $sku = $this->input->post('sku', true);
  4519. $warehouse = $this->input->post('warehouse', true);
  4520. $num = $this->input->post('num', true);
  4521. $text = $this->input->post('text', true);
  4522. $purchase = $this->input->post('purchase', true);
  4523. $cktype = $this->input->post('cktype', true);
  4524. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4525. if ($cktype != 1 && $text == '') {
  4526. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4527. exit;
  4528. }
  4529. if ($num > count($order)) {
  4530. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4531. exit;
  4532. } else {
  4533. for ($i = 0; $i < $num; $i++) {
  4534. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4535. }
  4536. }
  4537. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4538. exit;
  4539. }
  4540. $uid = $this->whlabel->read($arg_array[0]);
  4541. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4542. $this->data['data'] = $uid;
  4543. $this->_Template('whlabel_kj', $this->data);
  4544. }
  4545. public function _summary($arg_array)
  4546. {
  4547. $prc = array();
  4548. $purchase = $this->purchase->find_all();
  4549. foreach ($purchase as $k => $v) {
  4550. $prc[$v['id']] = $v['title'];
  4551. }
  4552. if (isset($_GET['excel'])) {
  4553. $ktime = $this->input->get('ktime', true);
  4554. $jtime = $this->input->get('jtime', true);
  4555. $ktime = strtotime($ktime);
  4556. $jtime = strtotime($jtime);
  4557. $where = "1=1";
  4558. if ($ktime && $jtime) {
  4559. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4560. }
  4561. //数据排序
  4562. $order_str = "time desc";
  4563. if (empty($page)) {
  4564. $start = 0;
  4565. $perpage = 1;
  4566. } else {
  4567. $start = ($page - 1) * $perpage;
  4568. }
  4569. //取得信息列表
  4570. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4571. foreach ($info_list as $key => $value) {
  4572. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4573. $warehouse = $this->warehouse->read($value['warehouse']);
  4574. $info_list[$key]['warehouse'] = $warehouse['title'];
  4575. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4576. $details = array();
  4577. $cpid = array();
  4578. foreach ($x as $k => $v) {
  4579. if ($v['details'] != '') {
  4580. $details[$v['details']] = $v['details'];
  4581. }
  4582. if ($v['cpid'] != 0) {
  4583. $cpid[$v['cpid']] = $v['cpid'];
  4584. }
  4585. }
  4586. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4587. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4588. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4589. $info_list[$key]['s'] = $s;
  4590. $info_list[$key]['x'] = count($x);
  4591. }
  4592. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4593. $titlename = "<table border=1>
  4594. <tr align='center'>
  4595. <td>仓库</td>
  4596. <td>供应商</td>
  4597. <td>出库位置</td>
  4598. <td>出库编码</td>
  4599. <td>SKU</td>
  4600. <td>产品名</td>
  4601. <td>总剩余库存</td>
  4602. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4603. </tr>
  4604. </table>";
  4605. $filename = $title . ".xls";
  4606. $tail = "";
  4607. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4608. }
  4609. }
  4610. //usps发货清单
  4611. public function _manifest()
  4612. {
  4613. if (isset($_POST['manifest'])) {
  4614. $wltext = $this->input->post('wltext', true);
  4615. $time = time() - 16 * 3600;
  4616. $ptime = strtotime(date('Y-m-d', $time));
  4617. $waybill = array();
  4618. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4619. foreach ($fullorder as $v) {
  4620. $waybill[$v['waybill']] = $v['waybill'];
  4621. }
  4622. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4623. foreach ($fullordersmt as $v) {
  4624. $waybill[$v['waybill']] = $v['waybill'];
  4625. }
  4626. $wltext = explode(';', $wltext);
  4627. foreach ($wltext as $v) {
  4628. if (isset($waybill[$v])) {
  4629. unset($waybill[$v]);
  4630. }
  4631. }
  4632. $data = $this->usps->get_manifest($waybill);
  4633. if (isset($data['Description'])) {
  4634. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4635. exit;
  4636. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4637. $bctime = date('Ymd', time());
  4638. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4639. echo json_encode(array('msg' => $pdf, 'success' => true));
  4640. exit;
  4641. } else {
  4642. echo json_encode(array('msg' => $data, 'success' => false));
  4643. exit;
  4644. }
  4645. }
  4646. }
  4647. public function _pdf($pdf, $title, $bctime)
  4648. {
  4649. $pdf_path = './data/pdf/' . $bctime . '/';
  4650. $file_base64 = $pdf;
  4651. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4652. $file_base64 = base64_decode($file_base64);
  4653. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4654. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4655. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4656. }
  4657. /**
  4658. *
  4659. *
  4660. *
  4661. 进销存占单异常索引
  4662. *
  4663. *
  4664. *
  4665. **/
  4666. public function _abnormal()
  4667. {
  4668. $post = $this->input->post(NULL, TRUE);
  4669. if (isset($post['page'])) {
  4670. $page = $this->input->post('page', true);
  4671. $perpage = $this->input->post('perpage', true);
  4672. $sku = $this->input->post('sku', true);
  4673. $where = "1=1";
  4674. //数据排序
  4675. $order_str = "id desc";
  4676. if (empty($page)) {
  4677. $start = 0;
  4678. $perpage = 1;
  4679. } else {
  4680. $start = ($page - 1) * $perpage;
  4681. }
  4682. //取得信息列表
  4683. $info_list = $this->whlabel->find_all($where, '*');
  4684. $rows = array();
  4685. $list = array();
  4686. foreach ($info_list as $key => $value) {
  4687. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4688. }
  4689. foreach ($rows as $value) {
  4690. $warehouse = $this->warehouse->read($value['warehouse']);
  4691. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4692. $number = $value['number'];
  4693. $ftime = time() - 15 * 24 * 3600;
  4694. if ($value['shop'] != '') {
  4695. $shop = $value['shop'];
  4696. $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');
  4697. $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');
  4698. $order = array_merge($orderdlz, $ordersmt);
  4699. $od = 0;
  4700. $a = '';
  4701. $orid = '';
  4702. foreach ($order as $v) {
  4703. $or = explode('|', ltrim($v['whlabel'], '|'));
  4704. for ($i = 0; $i < count($or); $i++) {
  4705. $orod = explode('-', $or[$i]);
  4706. if ($orod[0] == $number) {
  4707. $od += $orod[1];
  4708. }
  4709. }
  4710. $orid .= $v['number'] . '-';
  4711. }
  4712. } else {
  4713. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4714. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4715. $order = array_merge($orderdlz, $ordersmt);
  4716. $od = 0;
  4717. $a = '';
  4718. $orid = '';
  4719. $qt = array();
  4720. foreach ($order as $v) {
  4721. $or = explode('|', ltrim($v['whlabel'], '|'));
  4722. for ($i = 0; $i < count($or); $i++) {
  4723. $orod = explode('-', $or[$i]);
  4724. if ($orod[0] == $number) {
  4725. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4726. if ($czzs > 0) {
  4727. if (isset($qt[$v['shop']])) {
  4728. if ($qt[$v['shop']] < $orod[1]) {
  4729. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4730. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4731. } else {
  4732. $qt[$v['shop']] -= $orod[1];
  4733. }
  4734. } else {
  4735. $qt[$v['shop']] = $czzs;
  4736. }
  4737. } else {
  4738. $od += $orod[1];
  4739. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4740. }
  4741. }
  4742. }
  4743. }
  4744. }
  4745. $z = $od . '(' . $orid . ')'; //查看订单号
  4746. //$z = $od;
  4747. if ($od > $c) {
  4748. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4749. }
  4750. }
  4751. $listdata = array_slice($list, $start, $perpage);
  4752. $total = count($list);
  4753. $pagenum = ceil($total / $perpage);
  4754. $over = $total - ($start + $perpage);
  4755. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4756. echo json_encode($rows);
  4757. exit;
  4758. }
  4759. $this->_Template('whlabel_abnormal', $this->data);
  4760. }
  4761. /**
  4762. *
  4763. *
  4764. *
  4765. 进销存占单异常索引
  4766. *
  4767. *
  4768. *
  4769. **/
  4770. public function _error()
  4771. {
  4772. $post = $this->input->post(NULL, TRUE);
  4773. if (isset($post['page'])) {
  4774. $page = $this->input->post('page', true);
  4775. $perpage = $this->input->post('perpage', true);
  4776. $sku = $this->input->post('sku', true);
  4777. $warehouse = $this->input->post('warehouse', true);
  4778. $ktime = $this->input->post('ktime', true);
  4779. $jtime = $this->input->post('jtime', true);
  4780. $ktime = strtotime($ktime);
  4781. $jtime = strtotime($jtime);
  4782. $where = "sku != 'Preset'";
  4783. $gj = '';
  4784. if ($sku) {
  4785. $where .= " and sku like '%$sku%'";
  4786. } else {
  4787. if ($ktime && $jtime) {
  4788. $gj = " and time > '$ktime' and time < '$jtime'";
  4789. }
  4790. }
  4791. if ($warehouse) {
  4792. $where .= " and warehouse = '$warehouse'";
  4793. }
  4794. //数据排序
  4795. $order_str = "id desc";
  4796. if (empty($page)) {
  4797. $start = 0;
  4798. $perpage = 1;
  4799. } else {
  4800. $start = ($page - 1) * $perpage;
  4801. }
  4802. //取得信息列表
  4803. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4804. $rows = array();
  4805. $list = array();
  4806. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4807. // foreach ($info_list as $value)
  4808. // {
  4809. // $warehouse = $this->warehouse->read($value['warehouse']);
  4810. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4811. // $number = $value['number'];$ftime = time()-15*24*3600;
  4812. // if($c < 1)
  4813. // {
  4814. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4815. // }
  4816. // }
  4817. $warehouse_list = $this->warehouse->find_all();
  4818. $warehouse_list = array_column($warehouse_list, null, 'id');
  4819. foreach ($info_list as $value) {
  4820. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4821. 'title' => "",
  4822. ];
  4823. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4824. $number = $value['number'];
  4825. $ftime = time() - 15 * 24 * 3600;
  4826. if ($c < 1) {
  4827. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4828. }
  4829. }
  4830. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4831. // $query = $this->db->query($sql);
  4832. // $info_list = $query->result_array();
  4833. // $sql_two = "select title,id from crowd_warehouse";
  4834. // $query_two = $this->db->query($sql_two);
  4835. // $warehouse_list = $query_two->result_array();
  4836. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4837. // foreach ($info_list as $value)
  4838. // {
  4839. // if(isset($warehouse_arr[$value['warehouse']])){
  4840. // $warehouse = $warehouse_arr[$value['warehouse']];
  4841. // }else{
  4842. // $warehouse = [
  4843. // 'id'=>0,
  4844. // 'title'=>"异常",
  4845. // ];
  4846. // }
  4847. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4848. // $number = $value['number'];$ftime = time()-15*24*3600;
  4849. // if($c < 1)
  4850. // {
  4851. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4852. // }
  4853. // }
  4854. $listdata = array_slice($list, $start, $perpage);
  4855. $total = count($list);
  4856. $pagenum = ceil($total / $perpage);
  4857. $over = $total - ($start + $perpage);
  4858. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4859. echo json_encode($rows);
  4860. exit;
  4861. }
  4862. if (isset($post['s'])) {
  4863. $id_arr = $this->input->post('s');
  4864. $id_arr = explode(',', trim($id_arr, ','));
  4865. if (!$id_arr) {
  4866. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4867. exit;
  4868. }
  4869. //循环删除记录
  4870. foreach ($id_arr as $v) {
  4871. $dd = $this->whlabel->read($v);
  4872. if (!isset($dd['id'])) {
  4873. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4874. exit;
  4875. }
  4876. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4877. if (isset($zt[0])) {
  4878. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4879. exit;
  4880. }
  4881. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4882. foreach ($deldd as $vv) {
  4883. $this->whlabel->remove($vv['id']);
  4884. }
  4885. }
  4886. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4887. exit;
  4888. }
  4889. $this->_Template('whlabel_error', $this->data);
  4890. }
  4891. public function _errorexcel()
  4892. {
  4893. $post = $this->input->post(NULL, TRUE);
  4894. if (isset($_GET['page'])) {
  4895. $page = $this->input->get('page', true);
  4896. $perpage = $this->input->get('perpage', true);
  4897. $sku = $this->input->get('sku', true);
  4898. $warehouse = $this->input->get('warehouse', true);
  4899. $ktime = $this->input->get('ktime', true);
  4900. $jtime = $this->input->get('jtime', true);
  4901. $ktime = strtotime($ktime);
  4902. $jtime = strtotime($jtime);
  4903. $where = "sku != 'Preset'";
  4904. $gj = '';
  4905. if ($sku) {
  4906. $where .= " and sku like '%$sku%'";
  4907. } else {
  4908. if ($ktime && $jtime) {
  4909. $gj = " and time > '$ktime' and time < '$jtime'";
  4910. }
  4911. }
  4912. if ($warehouse) {
  4913. $where .= " and warehouse = '$warehouse'";
  4914. }
  4915. //数据排序
  4916. $order_str = "id desc";
  4917. if (empty($page)) {
  4918. $start = 0;
  4919. $perpage = 1;
  4920. } else {
  4921. $start = ($page - 1) * $perpage;
  4922. }
  4923. //取得信息列表
  4924. $rows = array();
  4925. $list = array();
  4926. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4927. foreach ($info_list as $value) {
  4928. $warehouse = $this->warehouse->read($value['warehouse']);
  4929. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4930. $number = $value['number'];
  4931. $ftime = time() - 15 * 24 * 3600;
  4932. if ($c < 1) {
  4933. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4934. }
  4935. }
  4936. $title = "0库存汇总";
  4937. $titlename = "<table border=1>
  4938. <tr align='center'>
  4939. <td>仓库</td>
  4940. <td>SKU</td>
  4941. <td>产品</td>
  4942. <td>当前库存</td>
  4943. </tr>
  4944. </table>";
  4945. $filename = $title . ".xls";
  4946. $tail = "";
  4947. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4948. }
  4949. }
  4950. /**
  4951. *
  4952. *
  4953. * 占单
  4954. *
  4955. *
  4956. **/
  4957. public function _kcyz()
  4958. {
  4959. $post = $this->input->post(NULL, TRUE);
  4960. if (isset($post['warehouse'])) {
  4961. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4962. exit; //不再使用
  4963. $warehouse = $this->input->post('warehouse', true);
  4964. $whlabel = $this->input->post('whlabel', true);
  4965. $id = $this->input->post('id', true);
  4966. $shop = $this->input->post('shop', true);
  4967. $number = $this->input->post('number', true);
  4968. if (!$whlabel || $whlabel == '|') {
  4969. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4970. exit;
  4971. }
  4972. $pp = explode('|', trim($whlabel, '|'));
  4973. $x = 0;
  4974. $save = array();
  4975. foreach ($pp as $va) {
  4976. $num = explode('-', $va);
  4977. if ($number) {
  4978. $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 = '')"); //通用
  4979. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4980. } else {
  4981. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4982. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4983. }
  4984. $x++;
  4985. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4986. $save[] = $x - 1;
  4987. continue; //提前先加X不然出错,所以要减1
  4988. }
  4989. }
  4990. if (isset($save[0])) {
  4991. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4992. exit;
  4993. } else {
  4994. echo json_encode(array('success' => true));
  4995. exit;
  4996. }
  4997. }
  4998. }
  4999. public function _db()
  5000. {
  5001. $post = $this->input->post(NULL, TRUE);
  5002. if (isset($post['page'])) {
  5003. $page = $this->input->post('page', true);
  5004. $perpage = $this->input->post('perpage', true);
  5005. $sku = $this->input->post('sku', true);
  5006. $number = $this->input->post('number', true);
  5007. $warehouse = $this->input->post('warehouse', true);
  5008. $purchase = $this->input->post('purchase', true);
  5009. $orderinfo = $this->input->post('orderinfo', true);
  5010. $waybill = $this->input->post('waybill', true);
  5011. $category = $this->input->post('category', true);
  5012. $size = $this->input->post('size', true);
  5013. $grade = $this->input->post('grade', true);
  5014. $color = $this->input->post('color', true);
  5015. $lowe = $this->input->post('lowe', true);
  5016. $state = $this->input->post('state', true);
  5017. $label = $this->input->post('label', true);
  5018. $timetk = $this->input->post('timetkk', true);
  5019. $timetj = $this->input->post('timetjj', true);
  5020. $timetk = strtotime($timetk);
  5021. $timetj = strtotime($timetj);
  5022. $where = "dbtime > 0";
  5023. if ($timetk && $timetj) {
  5024. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5025. }
  5026. if ($sku) {
  5027. $where .= " and sku = '$sku'";
  5028. }
  5029. if ($warehouse) {
  5030. $where .= " and warehouse = '$warehouse'";
  5031. if ($warehouse == 12) {
  5032. $w = 'specialstock';
  5033. } else {
  5034. $w = 'whlabel';
  5035. }
  5036. }
  5037. if ($purchase) {
  5038. $where .= " and purchase = '$purchase'";
  5039. }
  5040. if ($category) {
  5041. $where .= " and features like '%-$category-%'";
  5042. }
  5043. if ($size) {
  5044. $where .= " and features like '%-$size-%'";
  5045. }
  5046. if ($grade) {
  5047. $where .= " and features like '%-$grade-%'";
  5048. }
  5049. if ($color) {
  5050. $where .= " and features like '%-$color-%'";
  5051. }
  5052. if ($lowe) {
  5053. $where .= " and features like '%-$lowe-%'";
  5054. }
  5055. if ($state != '') {
  5056. $where .= " and state = '$state'";
  5057. }
  5058. //数据排序
  5059. $order_str = "dbtime desc";
  5060. if (empty($page)) {
  5061. $start = 0;
  5062. $perpage = 1;
  5063. } else {
  5064. $start = ($page - 1) * $perpage;
  5065. }
  5066. //取得信息列表
  5067. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5068. foreach ($info_list as $key => $value) {
  5069. $warehouse = $this->$w->read($value['warehouse']);
  5070. $info_list[$key]['warehouse'] = $warehouse['title'];
  5071. $purchase = $this->purchase->read($value['purchase']);
  5072. $info_list[$key]['purchase'] = $purchase['title'];
  5073. if ($value['enter'] != 0) {
  5074. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5075. } else {
  5076. $info_list[$key]['enter'] = "";
  5077. }
  5078. if ($value['dbtime'] != 0) {
  5079. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5080. } else {
  5081. $info_list[$key]['dbtime'] = "";
  5082. }
  5083. if ($value['state'] == 0) {
  5084. $info_list[$key]['state'] = "在库";
  5085. } else if ($value['state'] == 1) {
  5086. $info_list[$key]['state'] = "出库";
  5087. } else if ($value['state'] == 2) {
  5088. $info_list[$key]['state'] = "退库";
  5089. } else if ($value['state'] == 3) {
  5090. $info_list[$key]['state'] = "调拨中";
  5091. } else if ($value['state'] == 4) {
  5092. $info_list[$key]['state'] = "再加工";
  5093. } else if ($value['state'] == 5) {
  5094. $info_list[$key]['state'] = "维修中";
  5095. } else if ($value['state'] == 6) {
  5096. $info_list[$key]['state'] = "盘亏";
  5097. } else if ($value['state'] == 7) {
  5098. $info_list[$key]['state'] = "更换标签";
  5099. } else if ($value['state'] == 8) {
  5100. $info_list[$key]['state'] = "其它";
  5101. } else if ($value['state'] == 9) {
  5102. $info_list[$key]['state'] = "预设";
  5103. }
  5104. }
  5105. $total = $this->whlabel->find_count($where);
  5106. $pagenum = ceil($total / $perpage);
  5107. $over = $total - ($start + $perpage);
  5108. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5109. echo json_encode($rows);
  5110. exit;
  5111. }
  5112. if (isset($post['outsku'])) {
  5113. $time = time();
  5114. $cz = $this->input->post('cz', true);
  5115. $label = $this->input->post('outsku', true);
  5116. $sl = $this->input->post('sl', true);
  5117. $num = $this->input->post('num', true);
  5118. //$warehouse = $this->input->post('warehouse',true);
  5119. if (!$sl) {
  5120. $sl = 1;
  5121. }
  5122. if (!$warehouse) {
  5123. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5124. exit;
  5125. }
  5126. $dblabel = $this->whlabellabel->get_label($label);
  5127. if ($dblabel) {
  5128. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5129. if (count($data) < 1) {
  5130. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5131. exit;
  5132. }
  5133. if (count($data) < $num) {
  5134. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5135. exit;
  5136. }
  5137. for ($i = 0; $i < $sl; $i++) {
  5138. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5139. }
  5140. echo json_encode(array('success' => true));
  5141. exit;
  5142. } else {
  5143. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5144. exit;
  5145. }
  5146. }
  5147. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5148. $this->_Template('whlabel_db', $this->data);
  5149. }
  5150. public function _dbrk()
  5151. {
  5152. $post = $this->input->post(NULL, TRUE);
  5153. if (isset($post['page'])) {
  5154. $page = $this->input->post('page', true);
  5155. $perpage = $this->input->post('perpage', true);
  5156. $sku = $this->input->post('sku', true);
  5157. $number = $this->input->post('number', true);
  5158. $warehouse = $this->input->post('warehouse', true);
  5159. $purchase = $this->input->post('purchase', true);
  5160. $orderinfo = $this->input->post('orderinfo', true);
  5161. $waybill = $this->input->post('waybill', true);
  5162. $category = $this->input->post('category', true);
  5163. $size = $this->input->post('size', true);
  5164. $grade = $this->input->post('grade', true);
  5165. $color = $this->input->post('color', true);
  5166. $lowe = $this->input->post('lowe', true);
  5167. $state = $this->input->post('state', true);
  5168. $label = $this->input->post('label', true);
  5169. $ctime = $this->input->post('ctime', true);
  5170. $timetk = $this->input->post('timetkk', true);
  5171. $timetj = $this->input->post('timetjj', true);
  5172. $timetk = strtotime($timetk);
  5173. $timetj = strtotime($timetj);
  5174. $where = "dbtime > 0";
  5175. if ($timetk && $timetj) {
  5176. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5177. }
  5178. if ($sku) {
  5179. $where .= " and sku = '$sku'";
  5180. }
  5181. if ($warehouse) {
  5182. $where .= " and warehouse = '$warehouse'";
  5183. }
  5184. if ($purchase) {
  5185. $where .= " and purchase = '$purchase'";
  5186. }
  5187. if ($category) {
  5188. $where .= " and features like '%-$category-%'";
  5189. }
  5190. if ($size) {
  5191. $where .= " and features like '%-$size-%'";
  5192. }
  5193. if ($grade) {
  5194. $where .= " and features like '%-$grade-%'";
  5195. }
  5196. if ($color) {
  5197. $where .= " and features like '%-$color-%'";
  5198. }
  5199. if ($lowe) {
  5200. $where .= " and features like '%-$lowe-%'";
  5201. }
  5202. if ($state != '') {
  5203. $where .= " and state = '$state'";
  5204. }
  5205. //数据排序
  5206. $order_str = "dbtime desc";
  5207. if (empty($page)) {
  5208. $start = 0;
  5209. $perpage = 1;
  5210. } else {
  5211. $start = ($page - 1) * $perpage;
  5212. }
  5213. //取得信息列表
  5214. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5215. foreach ($info_list as $key => $value) {
  5216. $warehouse = $this->warehouse->read($value['warehouse']);
  5217. $info_list[$key]['warehouse'] = $warehouse['title'];
  5218. $purchase = $this->purchase->read($value['purchase']);
  5219. $info_list[$key]['purchase'] = $purchase['title'];
  5220. if ($value['enter'] != 0) {
  5221. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5222. } else {
  5223. $info_list[$key]['enter'] = "";
  5224. }
  5225. if ($value['dbtime'] != 0) {
  5226. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5227. } else {
  5228. $info_list[$key]['dbtime'] = "";
  5229. }
  5230. if ($value['state'] == 0) {
  5231. $info_list[$key]['state'] = "在库";
  5232. } else if ($value['state'] == 1) {
  5233. $info_list[$key]['state'] = "出库";
  5234. } else if ($value['state'] == 2) {
  5235. $info_list[$key]['state'] = "退库";
  5236. } else if ($value['state'] == 3) {
  5237. $info_list[$key]['state'] = "调拨中";
  5238. } else if ($value['state'] == 4) {
  5239. $info_list[$key]['state'] = "再加工";
  5240. } else if ($value['state'] == 5) {
  5241. $info_list[$key]['state'] = "维修中";
  5242. } else if ($value['state'] == 6) {
  5243. $info_list[$key]['state'] = "盘亏";
  5244. } else if ($value['state'] == 7) {
  5245. $info_list[$key]['state'] = "更换标签";
  5246. } else if ($value['state'] == 8) {
  5247. $info_list[$key]['state'] = "其它";
  5248. } else if ($value['state'] == 9) {
  5249. $info_list[$key]['state'] = "预设";
  5250. }
  5251. }
  5252. $total = $this->whlabel->find_count($where);
  5253. $pagenum = ceil($total / $perpage);
  5254. $over = $total - ($start + $perpage);
  5255. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5256. echo json_encode($rows);
  5257. exit;
  5258. }
  5259. if (isset($post['rsku'])) {
  5260. $cz = $this->input->post('cz', true);
  5261. $label = $this->input->post('rsku', true);
  5262. $sl = $this->input->post('sl', true);
  5263. $warehouse = $this->input->post('warehouse', true);
  5264. if (!$sl) {
  5265. $sl = 1;
  5266. }
  5267. if (!$warehouse) {
  5268. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5269. exit;
  5270. }
  5271. $dblabel = $this->whlabellabel->get_label($label);
  5272. if ($dblabel) {
  5273. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5274. if (count($data) < 1) {
  5275. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5276. exit;
  5277. }
  5278. if ($sl > count($data)) {
  5279. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5280. exit;
  5281. }
  5282. $time = time();
  5283. for ($i = 0; $i < $sl; $i++) {
  5284. $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']);
  5285. }
  5286. echo json_encode(array('success' => true));
  5287. exit;
  5288. } else {
  5289. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5290. exit;
  5291. }
  5292. }
  5293. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5294. $this->_Template('whlabel_dbrk', $this->data);
  5295. }
  5296. public function _whlabelczdc()
  5297. {
  5298. if (isset($_GET['excel'])) {
  5299. //数据排序
  5300. $order_str = "id desc";
  5301. if (empty($page)) {
  5302. $start = 0;
  5303. $perpage = 1;
  5304. } else {
  5305. $start = ($page - 1) * $perpage;
  5306. }
  5307. $state = $this->input->get('state', true);
  5308. $sku = $this->input->get('sku', true);
  5309. $ctime = $this->input->get('ctime', true);
  5310. $category = $this->input->get('category', true);
  5311. $size = $this->input->get('size', true);
  5312. $grade = $this->input->get('grade', true);
  5313. $color = $this->input->get('color', true);
  5314. $lowe = $this->input->get('lowe', true);
  5315. $timetk = $this->input->get('timetkk', true);
  5316. $timetj = $this->input->get('timetjj', true);
  5317. $timetk = strtotime($timetk);
  5318. $timetj = strtotime($timetj);
  5319. $where = "dbtime > 0";
  5320. if ($timetk && $timetj) {
  5321. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5322. }
  5323. if ($category) {
  5324. $where .= " and features like '%-$category-%'";
  5325. }
  5326. if ($size) {
  5327. $where .= " and features like '%-$size-%'";
  5328. }
  5329. if ($grade) {
  5330. $where .= " and features like '%-$grade-%'";
  5331. }
  5332. if ($color) {
  5333. $where .= " and features like '%-$color-%'";
  5334. }
  5335. if ($lowe) {
  5336. $where .= " and features like '%-$lowe-%'";
  5337. }
  5338. //取得信息列表
  5339. $info_list = $this->whlabel->find_all($where, '*');
  5340. $rows = array();
  5341. $list = array();
  5342. foreach ($info_list as $key => $value) {
  5343. $rows[$value['sku']] = $value; //所有数据sku
  5344. }
  5345. foreach ($rows as $value) {
  5346. $warehouse = $this->warehouse->read($value['warehouse']);
  5347. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5348. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5349. if ($value['orderinfo'] == 0) {
  5350. $info_list[$key]['orderinfo'] = "";
  5351. }
  5352. if ($value['waybill'] == 0) {
  5353. $info_list[$key]['waybill'] = "";
  5354. }
  5355. if ($value['state'] == 0) {
  5356. $value['state'] = "在库";
  5357. } else if ($value['state'] == 3) {
  5358. $value['state'] = "调拨中";
  5359. }
  5360. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5361. }
  5362. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5363. $titlename = "<table border=1>
  5364. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5365. <tr align='center'>
  5366. <td>SKU</td>
  5367. <td>产品</td>
  5368. <td>调拨数量</td>
  5369. <td>入库数量</td>
  5370. </tr>
  5371. </table>";
  5372. $filename = $title . ".xls";
  5373. $tail = "";
  5374. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5375. }
  5376. }
  5377. public function _print($arg_array)
  5378. {
  5379. if (isset($_SESSION['api'])) {
  5380. $user = $this->user->get_api($_SESSION['api']);
  5381. $usp = $user;
  5382. $fgshop = "";
  5383. $sid = "";
  5384. $wid = "";
  5385. $wtype = "";
  5386. $usersp = explode('|', trim($user['shop'], '|'));
  5387. $userwh = explode('|', trim($user['warehouse'], '|'));
  5388. foreach ($usersp as $value) {
  5389. $fgshop .= " shop = " . $value . " or";
  5390. $sid .= " id = " . $value . " or";
  5391. }
  5392. foreach ($userwh as $value) {
  5393. $wid .= " id = " . $value . " or";
  5394. $wtype .= " type = " . $value . " or";
  5395. }
  5396. }
  5397. $post = $this->input->post(NULL, TRUE);
  5398. if (isset($post['tmsku'])) {
  5399. $tmsku = $this->input->post('tmsku', true);
  5400. if (is_numeric($tmsku)) {
  5401. $yyh = $this->whlabellabel->get_label($tmsku);
  5402. } else {
  5403. $yyh = $this->whlabellabel->get_sku($tmsku);
  5404. }
  5405. if ($yyh) {
  5406. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5407. exit;
  5408. } else {
  5409. echo json_encode(array('success' => false));
  5410. exit;
  5411. }
  5412. }
  5413. $classid = $this->classid->sku();
  5414. $pm = $classid;
  5415. $scsku = $classid;
  5416. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5417. if (isset($post['warehouse'])) {
  5418. if ($post['warehouse']) {
  5419. $list = array();
  5420. $num = "";
  5421. $title = "";
  5422. $features = "";
  5423. $order = 0;
  5424. $post['shop'] = '';
  5425. $brand = $this->input->post('brand', true);
  5426. if ($brand != '0,') {
  5427. $b = $this->brand->read(rtrim($brand, ','));
  5428. if ($b) {
  5429. $post['shop'] = str_replace('|', ',', $b['shop']);
  5430. }
  5431. }
  5432. $post['details'] = $this->input->post('details', true); //打印数量
  5433. $xbqnum = $this->input->post('xbqnum', true);
  5434. $post['purchase'] = $this->input->post('purchase', true);
  5435. $post['warehouse'] = $this->input->post('warehouse', true);
  5436. $post['purchase'] = $this->input->post('purchase', true);
  5437. $post['retreatwarehouse'] = $post['warehouse'];
  5438. $post['cpbz'] = $this->input->post('cpbz', true);
  5439. $post['state'] = 9;
  5440. $category = $this->input->post('category', true);
  5441. $list['category'] = $category;
  5442. $list['hairtype'] = $this->input->post('hairtype', true);
  5443. $list['grade'] = $this->input->post('grade', true);
  5444. $size = $this->input->post('size', true);
  5445. $list['size'] = rtrim($size, ',');
  5446. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5447. $list['extension'] = $this->input->post('extension', true);
  5448. if ($category == 1297) {
  5449. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5450. }
  5451. if ($category == 1702) {
  5452. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5453. $list['syother'] = $this->input->post('syother', true);
  5454. }
  5455. if ($category == 133) {
  5456. $list['fittype'] = $this->input->post('fittype', true);
  5457. $list['acother'] = $this->input->post('acother', true);
  5458. }
  5459. $list['color'] = $this->input->post('color', true);
  5460. $list['lowe'] = $this->input->post('lowe', true);
  5461. if ($category == 127) {
  5462. $list['type'] = $this->input->post('type', true);
  5463. $list['headroad'] = $this->input->post('headroad', true);
  5464. $list['density'] = $this->input->post('density', true);
  5465. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5466. $list['lacesize'] = $this->input->post('lacesize', true);
  5467. }
  5468. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5469. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5470. }
  5471. if ($category == 128) {
  5472. $list['lacetype'] = $this->input->post('lacetype', true);
  5473. $list['haircap'] = $this->input->post('haircap', true);
  5474. $list['density'] = $this->input->post('density', true);
  5475. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5476. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5477. $list['wigother'] = $this->input->post('wigother', true);
  5478. $list['wigother1'] = $this->input->post('wigother1', true);
  5479. $list['wigother2'] = $this->input->post('wigother2', true);
  5480. }
  5481. if ($category == 129) {
  5482. $list['wide'] = $this->input->post('wide', true);
  5483. }
  5484. if ($category == 131) {
  5485. $list['gifttype'] = $this->input->post('gifttype', true);
  5486. $list['giftother'] = $this->input->post('giftother', true);
  5487. }
  5488. if ($category == 134) {
  5489. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5490. }
  5491. if ($category == 1297) {
  5492. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5493. $list['sywigother'] = $this->input->post('sywigother', true);
  5494. }
  5495. if ($category == 130 || $category == 133 || $category == 1702) {
  5496. $list['items'] = $this->input->post('items', true);
  5497. $list['weight'] = $this->input->post('weight', true);
  5498. }
  5499. if ($category == 1702) {
  5500. $list['syhairther'] = $this->input->post('syhairther', true);
  5501. }
  5502. foreach ($list as $k => $v) {
  5503. if ($v != 0) {
  5504. $num .= $v;
  5505. $features .= $v . '-';
  5506. $post[$k] = $v;
  5507. $typeclass = $this->typeclass->read($v);
  5508. if (isset($pm[$typeclass['classid']])) {
  5509. if (stripos($typeclass['zh'], '|') !== false) {
  5510. $exzh = explode('|', $typeclass['zh']);
  5511. $pm[$typeclass['classid']] = $exzh[0];
  5512. } else {
  5513. $pm[$typeclass['classid']] = $typeclass['zh'];
  5514. }
  5515. }
  5516. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5517. if ($k != 'size') {
  5518. $title .= $typeclass['title'] . " ";
  5519. }
  5520. }
  5521. }
  5522. $typeclass = $this->typeclass->read($list['size']);
  5523. $title .= $typeclass['title'];
  5524. $time = time();
  5525. $post['title'] = rtrim($title, ' ');
  5526. $post['number'] = $num;
  5527. $post['features'] = '-' . $features;
  5528. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5529. $featurespp = explode('-', trim($featurespp, '-'));
  5530. if (isset($featurespp[5])) {
  5531. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5532. } else {
  5533. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5534. }
  5535. $post['enter'] = $time;
  5536. $post['time'] = $time; //操作时间
  5537. $scsku = implode("-", $scsku);
  5538. $zh = implode(" ", $pm);
  5539. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5540. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5541. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5542. $post['sku'] = $bqsku;
  5543. $label = time() . rand(0, 9);
  5544. $post['label'] = $label;
  5545. $cpid = $this->whlabellabel->find_count();
  5546. $post['cpid'] = $cpid + 1;
  5547. $cpid = $post['cpid'];
  5548. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5549. //if($whlabelbarcode)
  5550. //{
  5551. //$post['label'] = $whlabelbarcode['label'];
  5552. //if(!$this->whlabellabel->insert($post))
  5553. //{
  5554. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5555. //}
  5556. //}
  5557. //else
  5558. //{
  5559. $this->db->trans_begin();
  5560. $this->whlabellabel->insert($post);
  5561. //$this->whlabelbarcode->insert($post);
  5562. if ($this->db->trans_status() === TRUE) {
  5563. $this->db->trans_commit();
  5564. } else {
  5565. $this->db->trans_rollback();
  5566. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5567. exit;
  5568. }
  5569. //}
  5570. $warehouse_name = "";
  5571. $warehouse = $post['warehouse'];
  5572. if($warehouse == 12){
  5573. $warehouse_name = "特殊库存库";
  5574. }
  5575. // if($warehouse == 13){
  5576. // $warehouse_name = "许昌仓";
  5577. // }
  5578. // if($warehouse == 5){
  5579. // $warehouse_name = "美国店";
  5580. // }
  5581. // if($warehouse == 16){
  5582. // $warehouse_name = "定制头套仓";
  5583. // }
  5584. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5585. if(!empty($warehouse_name)){
  5586. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5587. }
  5588. $purchase = $this->purchase->read($post['purchase']);
  5589. 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));
  5590. exit; //特殊仓目前不需要仓库选项
  5591. }
  5592. }
  5593. if (isset($_SESSION['api'])) {
  5594. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5595. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5596. $this->data['wlshop'] = $wlshop;
  5597. $this->data['warehouse'] = $warehouse;
  5598. }
  5599. $whlabelwz = $this->whlabelwz->find_all();
  5600. $this->data['whlabelwz'] = $whlabelwz;
  5601. $this->_Template('whlabel_print', $this->data);
  5602. }
  5603. public function _usaprint($arg_array)
  5604. {
  5605. if (isset($_SESSION['api'])) {
  5606. $user = $this->user->get_api($_SESSION['api']);
  5607. $usp = $user;
  5608. $fgshop = "";
  5609. $sid = "";
  5610. $wid = "";
  5611. $wtype = "";
  5612. $usersp = explode('|', trim($user['shop'], '|'));
  5613. $userwh = explode('|', trim($user['warehouse'], '|'));
  5614. foreach ($usersp as $value) {
  5615. $fgshop .= " shop = " . $value . " or";
  5616. $sid .= " id = " . $value . " or";
  5617. }
  5618. foreach ($userwh as $value) {
  5619. $wid .= " id = " . $value . " or";
  5620. $wtype .= " type = " . $value . " or";
  5621. }
  5622. }
  5623. $post = $this->input->post(NULL, TRUE);
  5624. if (isset($post['tmsku'])) {
  5625. $tmsku = $this->input->post('tmsku', true);
  5626. if (is_numeric($tmsku)) {
  5627. $yyh = $this->whlabellabel->get_label($tmsku);
  5628. } else {
  5629. $yyh = $this->whlabellabel->get_sku($tmsku);
  5630. }
  5631. if ($yyh) {
  5632. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5633. exit;
  5634. } else {
  5635. echo json_encode(array('success' => false));
  5636. exit;
  5637. }
  5638. }
  5639. $classid = $this->classid->sku();
  5640. $pm = $classid;
  5641. $scsku = $classid;
  5642. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5643. if (isset($post['warehouse'])) {
  5644. if ($post['warehouse']) {
  5645. $list = array();
  5646. $num = "";
  5647. $title = "";
  5648. $features = "";
  5649. $order = 0;
  5650. $post['shop'] = '';
  5651. $brand = $this->input->post('brand', true);
  5652. if ($brand != '0,') {
  5653. $b = $this->brand->read(rtrim($brand, ','));
  5654. if ($b) {
  5655. $post['shop'] = str_replace('|', ',', $b['shop']);
  5656. }
  5657. }
  5658. $post['details'] = $this->input->post('details', true); //打印数量
  5659. $xbqnum = $this->input->post('xbqnum', true);
  5660. $post['purchase'] = $this->input->post('purchase', true);
  5661. $post['warehouse'] = $this->input->post('warehouse', true);
  5662. $post['purchase'] = $this->input->post('purchase', true);
  5663. $post['retreatwarehouse'] = $post['warehouse'];
  5664. $post['cpbz'] = $this->input->post('cpbz', true);
  5665. $post['state'] = 9;
  5666. $category = $this->input->post('category', true);
  5667. $list['category'] = $category;
  5668. $list['hairtype'] = $this->input->post('hairtype', true);
  5669. $list['grade'] = $this->input->post('grade', true);
  5670. $size = $this->input->post('size', true);
  5671. $list['size'] = rtrim($size, ',');
  5672. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5673. $list['extension'] = $this->input->post('extension', true);
  5674. if ($category == 1297) {
  5675. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5676. }
  5677. if ($category == 1702) {
  5678. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5679. $list['syother'] = $this->input->post('syother', true);
  5680. }
  5681. if ($category == 133) {
  5682. $list['fittype'] = $this->input->post('fittype', true);
  5683. $list['acother'] = $this->input->post('acother', true);
  5684. }
  5685. $list['color'] = $this->input->post('color', true);
  5686. $list['lowe'] = $this->input->post('lowe', true);
  5687. if ($category == 127) {
  5688. $list['type'] = $this->input->post('type', true);
  5689. $list['headroad'] = $this->input->post('headroad', true);
  5690. $list['density'] = $this->input->post('density', true);
  5691. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5692. $list['lacesize'] = $this->input->post('lacesize', true);
  5693. }
  5694. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5695. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5696. }
  5697. if ($category == 128) {
  5698. $list['lacetype'] = $this->input->post('lacetype', true);
  5699. $list['haircap'] = $this->input->post('haircap', true);
  5700. $list['density'] = $this->input->post('density', true);
  5701. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5702. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5703. $list['wigother'] = $this->input->post('wigother', true);
  5704. $list['wigother1'] = $this->input->post('wigother1', true);
  5705. $list['wigother2'] = $this->input->post('wigother2', true);
  5706. }
  5707. if ($category == 129) {
  5708. $list['wide'] = $this->input->post('wide', true);
  5709. }
  5710. if ($category == 131) {
  5711. $list['gifttype'] = $this->input->post('gifttype', true);
  5712. $list['giftother'] = $this->input->post('giftother', true);
  5713. }
  5714. if ($category == 134) {
  5715. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5716. }
  5717. if ($category == 1297) {
  5718. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5719. $list['sywigother'] = $this->input->post('sywigother', true);
  5720. }
  5721. if ($category == 130 || $category == 133 || $category == 1702) {
  5722. $list['items'] = $this->input->post('items', true);
  5723. $list['weight'] = $this->input->post('weight', true);
  5724. }
  5725. if ($category == 1702) {
  5726. $list['syhairther'] = $this->input->post('syhairther', true);
  5727. }
  5728. foreach ($list as $k => $v) {
  5729. if ($v != 0) {
  5730. $num .= $v;
  5731. $features .= $v . '-';
  5732. $post[$k] = $v;
  5733. $typeclass = $this->typeclass->read($v);
  5734. if (isset($pm[$typeclass['classid']])) {
  5735. if (stripos($typeclass['zh'], '|') !== false) {
  5736. $exzh = explode('|', $typeclass['zh']);
  5737. $pm[$typeclass['classid']] = $exzh[0];
  5738. } else {
  5739. $pm[$typeclass['classid']] = $typeclass['zh'];
  5740. }
  5741. }
  5742. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5743. if ($k != 'size') {
  5744. $title .= $typeclass['title'] . " ";
  5745. }
  5746. }
  5747. }
  5748. $typeclass = $this->typeclass->read($list['size']);
  5749. $title .= $typeclass['title'];
  5750. $time = time();
  5751. $post['title'] = rtrim($title, ' ');
  5752. $post['number'] = $num;
  5753. $post['features'] = '-' . $features;
  5754. $fp = $this->whlabel->get_features($post['features']);
  5755. if (!$fp) {
  5756. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5757. exit;
  5758. }
  5759. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5760. $featurespp = explode('-', trim($featurespp, '-'));
  5761. if (isset($featurespp[5])) {
  5762. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5763. } else {
  5764. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5765. }
  5766. $post['enter'] = $time;
  5767. $post['time'] = $time; //操作时间
  5768. $scsku = implode("-", $scsku);
  5769. $zh = implode(" ", $pm);
  5770. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5771. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5772. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5773. $post['sku'] = $fp['sku'];
  5774. $post['label'] = $fp['sku'];
  5775. $cpid = $this->whlabellabel->find_count();
  5776. $post['cpid'] = $cpid + 1;
  5777. $cpid = $post['cpid'];
  5778. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5779. //if($whlabelbarcode)
  5780. //{
  5781. //$post['label'] = $whlabelbarcode['label'];
  5782. //if(!$this->whlabellabel->insert($post))
  5783. //{
  5784. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5785. //}
  5786. //}
  5787. //else
  5788. //{
  5789. $this->db->trans_begin();
  5790. $this->whlabellabel->insert($post);
  5791. //$this->whlabelbarcode->insert($post);
  5792. if ($this->db->trans_status() === TRUE) {
  5793. $this->db->trans_commit();
  5794. } else {
  5795. $this->db->trans_rollback();
  5796. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5797. exit;
  5798. }
  5799. //}
  5800. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5801. $purchase = $this->purchase->read($post['purchase']);
  5802. 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));
  5803. exit; //特殊仓目前不需要仓库选项
  5804. }
  5805. }
  5806. if (isset($_SESSION['api'])) {
  5807. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5808. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5809. $this->data['wlshop'] = $wlshop;
  5810. $this->data['warehouse'] = $warehouse;
  5811. }
  5812. $whlabelwz = $this->whlabelwz->find_all();
  5813. $this->data['whlabelwz'] = $whlabelwz;
  5814. $this->_Template('whlabel_usaprint', $this->data);
  5815. }
  5816. public function _printrk($arg_array)
  5817. {
  5818. $prc = array();
  5819. $purchase = $this->purchase->find_all();
  5820. foreach ($purchase as $k => $v) {
  5821. $prc[$v['id']] = $v['title'];
  5822. }
  5823. $post = $this->input->post(NULL, TRUE);
  5824. if (isset($post['page'])) {
  5825. $page = $this->input->post('page', true);
  5826. $perpage = $this->input->post('perpage', true);
  5827. $sku = $this->input->post('sku', true);
  5828. $bs = $this->input->post('bs', true);
  5829. $number = $this->input->post('number', true);
  5830. $warehouse = $this->input->post('warehouse', true);
  5831. $purchase = $this->input->post('purchase', true);
  5832. $orderinfo = $this->input->post('orderinfo', true);
  5833. $waybill = $this->input->post('waybill', true);
  5834. $category = $this->input->post('category', true);
  5835. $size = $this->input->post('size', true);
  5836. $grade = $this->input->post('grade', true);
  5837. $color = $this->input->post('color', true);
  5838. $lowe = $this->input->post('lowe', true);
  5839. $state = $this->input->post('state', true);
  5840. $label = $this->input->post('label', true);
  5841. $timetk = $this->input->post('ktime', true);
  5842. $timetj = $this->input->post('jtime', true);
  5843. $timetk = strtotime($timetk);
  5844. $timetj = strtotime($timetj);
  5845. $where = "1=1 ";
  5846. if ($timetk && $timetj) {
  5847. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5848. }
  5849. if ($sku) {
  5850. $where .= " and sku = '$sku'";
  5851. }
  5852. if ($bs != '') {
  5853. $where .= " and bs = '$bs'";
  5854. }
  5855. if ($number) {
  5856. $where .= " and number = '$number'";
  5857. }
  5858. if ($warehouse) {
  5859. $where .= " and warehouse = '$warehouse'";
  5860. }
  5861. if ($purchase) {
  5862. $where .= " and purchase = '$purchase'";
  5863. }
  5864. if ($orderinfo) {
  5865. $where .= " and orderinfo = '$orderinfo'";
  5866. }
  5867. if ($waybill) {
  5868. $where .= " and waybill = '$waybill'";
  5869. }
  5870. if ($category) {
  5871. $where .= " and features like '%-$category-%'";
  5872. }
  5873. if ($size) {
  5874. $where .= " and features like '%-$size-%'";
  5875. }
  5876. if ($grade) {
  5877. $where .= " and features like '%-$grade-%'";
  5878. }
  5879. if ($color) {
  5880. $where .= " and features like '%-$color-%'";
  5881. }
  5882. if ($lowe) {
  5883. $where .= " and features like '%-$lowe-%'";
  5884. }
  5885. if ($label) {
  5886. $where .= " and label = '$label'";
  5887. }
  5888. if ($state || $state == 0) {
  5889. $where .= " and state = '$state'";
  5890. }
  5891. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5892. //数据排序
  5893. $order_str = "enter desc";
  5894. if (empty($page)) {
  5895. $start = 0;
  5896. $perpage = 1;
  5897. } else {
  5898. $start = ($page - 1) * $perpage;
  5899. }
  5900. //取得信息列表
  5901. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5902. foreach ($info_list as $key => $value) {
  5903. $warehouse = $this->warehouse->read($value['warehouse']);
  5904. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5905. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5906. if ($value['state'] == 0) {
  5907. $info_list[$key]['state'] = "在库";
  5908. } else if ($value['state'] == 1) {
  5909. $info_list[$key]['state'] = "出库";
  5910. } else if ($value['state'] == 2) {
  5911. $info_list[$key]['state'] = "退库";
  5912. } else if ($value['state'] == 3) {
  5913. $info_list[$key]['state'] = "调拨中";
  5914. } else if ($value['state'] == 4) {
  5915. $info_list[$key]['state'] = "再加工";
  5916. } else if ($value['state'] == 5) {
  5917. $info_list[$key]['state'] = "维修中";
  5918. } else if ($value['state'] == 6) {
  5919. $info_list[$key]['state'] = "盘亏";
  5920. } else if ($value['state'] == 7) {
  5921. $info_list[$key]['state'] = "更换标签";
  5922. } else if ($value['state'] == 8) {
  5923. $info_list[$key]['state'] = "其它";
  5924. } else if ($value['state'] == 9) {
  5925. $info_list[$key]['state'] = "预设";
  5926. } else if ($value['state'] == 10) {
  5927. $info_list[$key]['state'] = "美店零售";
  5928. }
  5929. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5930. }
  5931. $total = $this->$ck->find_count($where);
  5932. $pagenum = ceil($total / $perpage);
  5933. $over = $total - ($start + $perpage);
  5934. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5935. echo json_encode($rows);
  5936. exit;
  5937. }
  5938. if (isset($post['tmsku'])) {
  5939. $time = time();
  5940. $tmsku = $this->input->post('tmsku', true);
  5941. //$post['shop'] = $this->input->post('shop',true);
  5942. $num = $this->input->post('num', true);
  5943. $rktype = $this->input->post('rktype', true);
  5944. if ($num > 200) {
  5945. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5946. exit;
  5947. }
  5948. if (!$rktype) {
  5949. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5950. }
  5951. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5952. /**
  5953. $wz = array();
  5954. foreach ($rk as $key=>$value)
  5955. {
  5956. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5957. }
  5958. if(count($wz) > 1)
  5959. {
  5960. $wz = array_values($wz);
  5961. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5962. }
  5963. **/
  5964. if (isset($rk[0]['purchase'])) {
  5965. $rk = $rk[0];
  5966. $j = 0;
  5967. $post['purchase'] = $rk['purchase'];
  5968. $post['warehouse'] = $rk['warehouse'];
  5969. $post['retreatwarehouse'] = $rk['warehouse'];
  5970. $post['sku'] = $rk['sku'];
  5971. $post['number'] = $rk['number'];
  5972. $post['features'] = $rk['features'];
  5973. $post['title'] = $rk['title'];
  5974. $post['enter'] = $time;
  5975. $post['time'] = $time;
  5976. $post['bs'] = 1;
  5977. $post['shop'] = $rk['shop'];
  5978. $post['details'] = $rk['details'];
  5979. $post['cpid'] = $rk['cpid'];
  5980. $post['cpbz'] = $rk['cpbz'];
  5981. //$post['rktype'] = $rktype;
  5982. $warehouse = $this->warehouse->read($rk['warehouse']);
  5983. if ($warehouse['bdck'] == '') {
  5984. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5985. exit;
  5986. } else {
  5987. $bdck = $warehouse['bdck'];
  5988. }
  5989. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5990. if (isset($pdwz['details'])) {
  5991. if ($pdwz['details'] != $post['details']) {
  5992. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5993. exit;
  5994. }
  5995. }
  5996. $post['featurespp'] = $rk['featurespp'];
  5997. if ($post['warehouse'] == '5') {
  5998. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5999. if ($yza) {
  6000. if ($post['features'] != $yza[0]['features']) {
  6001. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6002. exit;
  6003. }
  6004. }
  6005. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6006. if ($yzb) {
  6007. if ($post['sku'] != $yzb[0]['sku']) {
  6008. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6009. exit;
  6010. }
  6011. }
  6012. }
  6013. for ($i = 0; $i < $num; $i++) {
  6014. $post['label'] = time() . rand(100, 999) . $i;
  6015. if ($this->$bdck->insert($post)) {
  6016. $j++;
  6017. }
  6018. }
  6019. /**
  6020. if($post['warehouse'] != 12)
  6021. {
  6022. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6023. }
  6024. **/
  6025. if ($j == $num) {
  6026. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6027. exit;
  6028. } else {
  6029. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6030. exit;
  6031. }
  6032. } else {
  6033. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6034. exit;
  6035. }
  6036. }
  6037. $this->_Template('whlabel_printrk', $this->data);
  6038. }
  6039. public function _printxzrk($arg_array)
  6040. {
  6041. $post = $this->input->post(NULL, TRUE);
  6042. if (isset($post['wzid'])) {
  6043. $time = time();
  6044. $id = $this->input->post('wzid', true);
  6045. //$post['shop'] = $this->input->post('shop',true);
  6046. $num = 1;
  6047. $rk = $this->whlabellabel->read($id);
  6048. if (isset($rk['purchase'])) {
  6049. $x = 0;
  6050. $post['purchase'] = $rk['purchase'];
  6051. $post['warehouse'] = $rk['warehouse'];
  6052. $post['retreatwarehouse'] = $rk['warehouse'];
  6053. $post['sku'] = $rk['sku'];
  6054. $post['number'] = $rk['number'];
  6055. $post['features'] = $rk['features'];
  6056. $post['title'] = $rk['title'];
  6057. $post['enter'] = $time;
  6058. $post['time'] = $time;
  6059. $post['bs'] = 1;
  6060. $post['shop'] = $rk['shop'];
  6061. $post['details'] = $rk['details'];
  6062. $post['cpid'] = $rk['cpid'];
  6063. $post['cpbz'] = $rk['cpbz'];
  6064. $warehouse = $this->warehouse->read($rk['warehouse']);
  6065. if ($warehouse['bdck'] == '') {
  6066. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6067. exit;
  6068. } else {
  6069. $bdck = $warehouse['bdck'];
  6070. }
  6071. $post['featurespp'] = $rk['featurespp'];
  6072. $this->db->trans_begin();
  6073. for ($i = 0; $i < $num; $i++) {
  6074. $post['label'] = time() . rand(100, 999) . $i;
  6075. $this->$bdck->insert($post);
  6076. }
  6077. /**
  6078. if($post['warehouse'] != 12)
  6079. {
  6080. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6081. }
  6082. **/
  6083. if ($this->db->trans_status() === TRUE) {
  6084. $this->db->trans_commit();
  6085. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6086. exit;
  6087. } else {
  6088. $this->db->trans_rollback();
  6089. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6090. exit;
  6091. }
  6092. } else {
  6093. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6094. exit;
  6095. }
  6096. }
  6097. }
  6098. public function _printck($arg_array)
  6099. {
  6100. $prc = array();
  6101. $purchase = $this->purchase->find_all();
  6102. foreach ($purchase as $k => $v) {
  6103. $prc[$v['id']] = $v['title'];
  6104. }
  6105. $post = $this->input->post(NULL, TRUE);
  6106. if (isset($post['page'])) {
  6107. $page = $this->input->post('page', true);
  6108. $perpage = $this->input->post('perpage', true);
  6109. $sku = $this->input->post('sku', true);
  6110. $bs = $this->input->post('bs', true);
  6111. $number = $this->input->post('number', true);
  6112. $warehouse = $this->input->post('warehouse', true);
  6113. $purchase = $this->input->post('purchase', true);
  6114. $orderinfo = $this->input->post('orderinfo', true);
  6115. $waybill = $this->input->post('waybill', true);
  6116. $category = $this->input->post('category', true);
  6117. $size = $this->input->post('size', true);
  6118. $grade = $this->input->post('grade', true);
  6119. $color = $this->input->post('color', true);
  6120. $lowe = $this->input->post('lowe', true);
  6121. $state = $this->input->post('state', true);
  6122. $label = $this->input->post('label', true);
  6123. $timetk = $this->input->post('ktime', true);
  6124. $timetj = $this->input->post('jtime', true);
  6125. $timetk = strtotime($timetk);
  6126. $timetj = strtotime($timetj);
  6127. $where = "state=1 ";
  6128. if ($timetk && $timetj) {
  6129. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6130. }
  6131. if ($sku) {
  6132. $where .= " and sku = '$sku'";
  6133. }
  6134. if ($bs != '') {
  6135. $where .= " and bs = '$bs'";
  6136. }
  6137. if ($number) {
  6138. $where .= " and number = '$number'";
  6139. }
  6140. if ($warehouse) {
  6141. $where .= " and warehouse = '$warehouse'";
  6142. }
  6143. if ($purchase) {
  6144. $where .= " and purchase = '$purchase'";
  6145. }
  6146. if ($orderinfo) {
  6147. $where .= " and orderinfo = '$orderinfo'";
  6148. }
  6149. if ($waybill) {
  6150. $where .= " and waybill = '$waybill'";
  6151. }
  6152. if ($category) {
  6153. $where .= " and features like '%-$category-%'";
  6154. }
  6155. if ($size) {
  6156. $where .= " and features like '%-$size-%'";
  6157. }
  6158. if ($grade) {
  6159. $where .= " and features like '%-$grade-%'";
  6160. }
  6161. if ($color) {
  6162. $where .= " and features like '%-$color-%'";
  6163. }
  6164. if ($lowe) {
  6165. $where .= " and features like '%-$lowe-%'";
  6166. }
  6167. if ($label) {
  6168. $where .= " and label = '$label'";
  6169. }
  6170. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6171. //数据排序
  6172. $order_str = "outk desc";
  6173. if (empty($page)) {
  6174. $start = 0;
  6175. $perpage = 1;
  6176. } else {
  6177. $start = ($page - 1) * $perpage;
  6178. }
  6179. //取得信息列表
  6180. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6181. foreach ($info_list as $key => $value) {
  6182. $warehouse = $this->warehouse->read($value['warehouse']);
  6183. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6184. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6185. if ($value['state'] == 0) {
  6186. $info_list[$key]['state'] = "在库";
  6187. } else if ($value['state'] == 1) {
  6188. $info_list[$key]['state'] = "出库";
  6189. } else if ($value['state'] == 2) {
  6190. $info_list[$key]['state'] = "退库";
  6191. } else if ($value['state'] == 3) {
  6192. $info_list[$key]['state'] = "调拨中";
  6193. } else if ($value['state'] == 4) {
  6194. $info_list[$key]['state'] = "再加工";
  6195. } else if ($value['state'] == 5) {
  6196. $info_list[$key]['state'] = "维修中";
  6197. } else if ($value['state'] == 6) {
  6198. $info_list[$key]['state'] = "盘亏";
  6199. } else if ($value['state'] == 7) {
  6200. $info_list[$key]['state'] = "更换标签";
  6201. } else if ($value['state'] == 8) {
  6202. $info_list[$key]['state'] = "其它";
  6203. } else if ($value['state'] == 9) {
  6204. $info_list[$key]['state'] = "预设";
  6205. } else if ($value['state'] == 10) {
  6206. $info_list[$key]['state'] = "美店零售";
  6207. }
  6208. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6209. }
  6210. $total = $this->$ck->find_count($where);
  6211. $pagenum = ceil($total / $perpage);
  6212. $over = $total - ($start + $perpage);
  6213. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6214. echo json_encode($rows);
  6215. exit;
  6216. }
  6217. if (isset($post['tmsku'])) {
  6218. $time = time();
  6219. $tmsku = $this->input->post('tmsku', true);
  6220. //$post['shop'] = $this->input->post('shop',true);
  6221. $num = $this->input->post('num', true);
  6222. $cktype = $this->input->post('cktype', true);
  6223. $label = $this->whlabellabel->get_label($tmsku);
  6224. if (!$cktype) {
  6225. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6226. }
  6227. if (!isset($label['warehouse'])) {
  6228. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6229. exit;
  6230. }
  6231. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6232. if (stripos($label['features'], '-126-') !== false) {
  6233. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6234. } else {
  6235. $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 = ''");
  6236. }
  6237. $j = 0;
  6238. if (count($ck) >= $num) {
  6239. for ($i = 0; $i < $num; $i++) {
  6240. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6241. {
  6242. $j++;
  6243. }
  6244. }
  6245. if ($j == $num) {
  6246. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6247. exit;
  6248. } else {
  6249. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6250. exit;
  6251. }
  6252. } else {
  6253. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6254. exit;
  6255. }
  6256. }
  6257. if(isset($_SESSION['api']))
  6258. {
  6259. $user = $this->user->get_api($_SESSION['api']);
  6260. if(in_array($user['power'],[1,27])){
  6261. $vip = 1;
  6262. }
  6263. }
  6264. else
  6265. {
  6266. $vip = 0;
  6267. header('Location: /');exit;
  6268. }
  6269. $this->data['vip'] = $vip;
  6270. $this->_Template('whlabel_printck', $this->data);
  6271. }
  6272. public function _printexcel()
  6273. {
  6274. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6275. $config['upload_path'] = '.' . $dir;
  6276. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6277. $config['allowed_types'] = 'xls|xlsx|csv';
  6278. $config['max_size'] = 10240;
  6279. $this->load->library('upload', $config);
  6280. $this->upload->initialize($config);
  6281. if ($this->upload->do_upload('userfile')) {
  6282. $full_path = $dir . $this->upload->data('file_name');
  6283. $fileName = '.' . $full_path;
  6284. if (!file_exists($fileName)) {
  6285. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6286. exit;
  6287. } else {
  6288. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6289. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6290. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6291. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6292. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6293. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6294. ++$column; //如果列数大于26行
  6295. $list = array();
  6296. for ($i = 2; $i <= $row; $i++) // 行数循环
  6297. {
  6298. $data = array();
  6299. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6300. {
  6301. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6302. }
  6303. $list[] = $data;
  6304. }
  6305. }
  6306. $ed = array();
  6307. $i = 0;
  6308. $j = 0;
  6309. $dcdata = array();
  6310. $yc = '';
  6311. $cmf_arr = array_column($list, '1');
  6312. array_multisort($cmf_arr, SORT_ASC, $list);
  6313. foreach ($list as $key => $value) {
  6314. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6315. if ($typeclass) {
  6316. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6317. } else {
  6318. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6319. $i++;
  6320. continue;
  6321. }
  6322. }
  6323. if ($i > 0) {
  6324. $yc = $i . '条异常';
  6325. }
  6326. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6327. exit;
  6328. }
  6329. }
  6330. public function _uck()
  6331. {
  6332. if (isset($_GET['excel'])) {
  6333. $tc = array();
  6334. $typeclass = $this->typeclass->find_all();
  6335. foreach ($typeclass as $v) {
  6336. $tc[$v['id']] = $v['zh'];
  6337. }
  6338. $data = array();
  6339. $t = array();
  6340. $rq = '';
  6341. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6342. $ts = $ts / (24 * 3600);
  6343. for ($i = 0; $i < $ts; $i++) {
  6344. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6345. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6346. }
  6347. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6348. foreach ($info_list as $k => $v) {
  6349. $features = explode('-', trim($v['features'], '-'));
  6350. if (!isset($features[3]) || !isset($features[4])) {
  6351. continue;
  6352. }
  6353. $data[$k][0] = $tc[$features[0]]; //类型
  6354. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6355. $data[$k][2] = $tc[$features[4]]; //曲度
  6356. $data[$k][3] = '';
  6357. if (isset($data[$k][1])) {
  6358. $data[$k][3] .= $data[$k][1];
  6359. }
  6360. if (isset($data[$k][2])) {
  6361. $data[$k][3] .= $data[$k][2];
  6362. }
  6363. if (isset($features[5])) {
  6364. $data[$k][3] .= $tc[$features[5]];
  6365. }
  6366. if (isset($features[2])) {
  6367. $data[$k][3] .= $tc[$features[2]];
  6368. }
  6369. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6370. $data[$k][4] = $v['sku'];
  6371. $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())) . '))'); //月初库存
  6372. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6373. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6374. $ztrq = '';
  6375. $ztsl = '';
  6376. if (count($zt) > 0) {
  6377. foreach ($zt as $vv) {
  6378. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6379. $ztsl .= $vv['num'] . '<br>';
  6380. }
  6381. }
  6382. $data[$k][] = trim($ztsl, '<br>');
  6383. $data[$k][] = trim($ztrq, '<br>');
  6384. $byck = 0;
  6385. foreach ($t as $vv) {
  6386. $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));
  6387. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6388. $byck += $sl;
  6389. }
  6390. $data[$k][] = ($byck > 0) ? $byck : '';
  6391. }
  6392. $title = "详情 " . date("Y-m-d", time());
  6393. $titlename = "<table border=1>
  6394. <tr align='center'>
  6395. <td>类别</td>
  6396. <td>颜色</td>
  6397. <td>曲度</td>
  6398. <td>名称</td>
  6399. <td>SKU</td>
  6400. <td>月初库存</td>
  6401. <td>剩余库存</td>
  6402. <td>在途数量</td>
  6403. <td>预达日期</td>" .
  6404. $rq
  6405. . "<td>本月出库</td></tr>
  6406. </table>";
  6407. $filename = $title . ".xls";
  6408. $tail = "";
  6409. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6410. }
  6411. }
  6412. public function _whlabelexcelzh()
  6413. {
  6414. if (isset($_GET['excel'])) {
  6415. $where = "sku != 'Preset'";
  6416. //数据排序
  6417. $order_str = "id desc";
  6418. if (empty($page)) {
  6419. $start = 0;
  6420. $perpage = 1;
  6421. } else {
  6422. $start = ($page - 1) * $perpage;
  6423. }
  6424. $category = $this->input->get('category', true);
  6425. $warehouse = $this->input->get('warehouse', true);
  6426. $excelid = $this->input->get('sid', true);
  6427. if ($category) {
  6428. $where .= " and features like '%-$category-%'";
  6429. }
  6430. if ($warehouse) {
  6431. $where .= " and warehouse = '$warehouse'";
  6432. }
  6433. $xzid = '';
  6434. if ($excelid) {
  6435. $excelid = explode(',', trim($excelid, ','));
  6436. foreach ($excelid as $key => $value) {
  6437. $xzid .= " id = " . $value . " or";
  6438. }
  6439. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6440. }
  6441. //取得信息列表
  6442. /**
  6443. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6444. $rows = array();$list = array();
  6445. foreach ($info_list as $key=>$value)
  6446. {
  6447. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6448. }
  6449. **/
  6450. $list = array();
  6451. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6452. foreach ($rows as $key => $value) {
  6453. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6454. $zh = '';
  6455. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6456. foreach ($zt as $v) {
  6457. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6458. }
  6459. $zt = array_sum(array_column($zt, 'num'));
  6460. $number = $value['number'];
  6461. $ftime = time() - 15 * 24 * 3600;
  6462. $warehouse = $this->warehouse->read($value['warehouse']);
  6463. $rows[$key]['warehouse'] = $warehouse['title'];
  6464. $rows[$key]['number'] = $c;
  6465. $rows[$key]['features'] = $zh;
  6466. $rows[$key]['hb'] = $c + $zt;
  6467. }
  6468. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6469. $titlename = "<table border=1>
  6470. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6471. <tr align='center'>
  6472. <td>仓库</td>
  6473. <td>SKU</td>
  6474. <td>产品</td>
  6475. <td>库存数量</td>
  6476. <td>在途数量及预达日期</td>
  6477. <td>在途+库存数量</td>
  6478. </tr>
  6479. </table>";
  6480. $filename = $title . ".xls";
  6481. $tail = "";
  6482. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6483. }
  6484. if (isset($_GET['excel'])) {
  6485. $warehouse = $this->input->get('warehouse', true);
  6486. $sku = $this->input->get('sku', true);
  6487. $cz = $this->input->get('cz', true);
  6488. $text = $this->input->post('text', true);
  6489. $xztime = $this->input->get('xztime', true);
  6490. $timetk = $this->input->get('timetk', true);
  6491. $timetj = $this->input->get('timetj', true);
  6492. $timetk = strtotime($timetk);
  6493. $timetj = strtotime($timetj);
  6494. $where = "time = '0' ";
  6495. if ($warehouse) {
  6496. $where .= " and warehouse = '$warehouse'";
  6497. }
  6498. if ($sku) {
  6499. $where .= " and sku = '$sku'";
  6500. }
  6501. if ($text) {
  6502. $where .= " and text like '%$text%'";
  6503. }
  6504. if ($cz != '') {
  6505. $where .= " and cz = '$cz'";
  6506. }
  6507. if ($timetk && $timetj) {
  6508. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6509. }
  6510. //数据排序
  6511. $order_str = $xztime . " desc";
  6512. //取得信息列表
  6513. $zh = array();
  6514. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6515. foreach ($info_list as $v) {
  6516. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6517. $warehouse = $this->warehouse->read($v['warehouse']);
  6518. $v['warehouse'] = $warehouse['title'];
  6519. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6520. $v['stime'] = date('Y-m-d', $v['stime']);
  6521. if (isset($zh[$v['features']])) {
  6522. $zh[$v['features']]['num'] += $v['num'];
  6523. } else {
  6524. $zh[$v['features']] = $v;
  6525. }
  6526. $zh[$v['features']]['features'] = $c;
  6527. }
  6528. $title = "在途数据" . date('Y-m-d', time());
  6529. $titlename = "<table border=1>
  6530. <tr align='center'>
  6531. <td>仓库</td>
  6532. <td>SKU</td>
  6533. <td>名称</td>
  6534. <td>在途数量</td>
  6535. <td>库存数量</td>
  6536. <td>添加在途日期</td>
  6537. <td>预达日期</td>
  6538. <td>备注</td>
  6539. </tr>
  6540. </table>";
  6541. $filename = $title . ".xls";
  6542. $tail = "";
  6543. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6544. }
  6545. }
  6546. public function _fc()
  6547. {
  6548. $vip = 0;
  6549. if (isset($_SESSION['api'])) {
  6550. $user = $this->user->get_api($_SESSION['api']);
  6551. if ($user['vip'] == 1) {
  6552. $vip = 1;
  6553. }
  6554. } else {
  6555. header('Location: /');
  6556. exit;
  6557. }
  6558. $post = $this->input->post(NULL, TRUE);
  6559. if (isset($post['page'])) {
  6560. $page = $this->input->post('page', true);
  6561. $perpage = $this->input->post('perpage', true);
  6562. $category = $this->input->post('category', true);
  6563. $size = $this->input->post('size', true);
  6564. $grade = $this->input->post('grade', true);
  6565. $color = $this->input->post('color', true);
  6566. $lowe = $this->input->post('lowe', true);
  6567. $sku = $this->input->post('sku');
  6568. $title = $this->input->post('title');
  6569. $warehouse = $this->input->post('warehouse', true);
  6570. $usa = $this->input->post('usa', true);
  6571. $purchase = $this->input->post('purchase', true);
  6572. $lacetype = $this->input->post('lacetype', true);
  6573. $haircap = $this->input->post('haircap', true);
  6574. $density = $this->input->post('density', true);
  6575. $details = $this->input->post('details', true);
  6576. $state = $this->input->post('state', true);
  6577. $ktime = $this->input->post('ktime', true);
  6578. $jtime = $this->input->post('jtime', true);
  6579. $ktime = strtotime($ktime);
  6580. $jtime = strtotime($jtime);
  6581. $where = "state = '11'";
  6582. $gj = "";
  6583. $ck = "";
  6584. if ($lacetype) {
  6585. $where .= " and features like '%-$lacetype-%'";
  6586. }
  6587. if ($category) {
  6588. $where .= " and features like '%-$category-%'";
  6589. }
  6590. if ($size) {
  6591. $where .= " and features like '%-$size-%'";
  6592. }
  6593. if ($grade) {
  6594. $where .= " and features like '%-$grade-%'";
  6595. }
  6596. if ($color) {
  6597. $where .= " and features like '%-$color-%'";
  6598. }
  6599. if ($lowe) {
  6600. $where .= " and features like '%-$lowe-%'";
  6601. }
  6602. if ($haircap) {
  6603. $where .= " and features like '%-$haircap-%'";
  6604. }
  6605. if ($density) {
  6606. $where .= " and features like '%-$density-%'";
  6607. }
  6608. if ($usa) {
  6609. if (!$warehouse) {
  6610. $where .= " and (warehouse = '5' or warehouse = '8')";
  6611. }
  6612. }
  6613. if ($warehouse) {
  6614. $where .= " and warehouse = '$warehouse'";
  6615. }
  6616. if ($details) {
  6617. $where .= " and details = '$details'";
  6618. }
  6619. if ($purchase) {
  6620. $where .= " and purchase = '$purchase'";
  6621. }
  6622. if ($state) {
  6623. $where .= " and state = '$state'";
  6624. }
  6625. if ($ktime && $jtime) {
  6626. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6627. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6628. }
  6629. //数据排序
  6630. $order_str = "id desc";
  6631. if (empty($page)) {
  6632. $start = 0;
  6633. $perpage = 1;
  6634. } else {
  6635. $start = ($page - 1) * $perpage;
  6636. }
  6637. if ($sku) {
  6638. $sku = trim($sku, ' ');
  6639. $sku = trim($sku, ' ');
  6640. $where .= " and sku like '%$sku%'";
  6641. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6642. } else if ($title) {
  6643. $title = trim($title, ' ');
  6644. $title = trim($title, ' ');
  6645. $where .= " and title like '%$title%'";
  6646. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6647. } else {
  6648. //$where .= " and time > '$ktime' and time < '$jtime'";
  6649. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6650. }
  6651. //取得信息列表
  6652. $rows = array();
  6653. $list = array();
  6654. foreach ($info_list as $key => $value) {
  6655. $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'] . '"');
  6656. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6657. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6658. $warehouse = $this->warehouse->read($value['warehouse']);
  6659. $info_list[$key]['warehouse'] = $warehouse['title'];
  6660. $info_list[$key]['number'] = $g;
  6661. $info_list[$key]['features'] = $x;
  6662. $info_list[$key]['x'] = $s;
  6663. }
  6664. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6665. $pagenum = ceil($total / $perpage);
  6666. $over = $total - ($start + $perpage);
  6667. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6668. echo json_encode($rows);
  6669. exit;
  6670. }
  6671. $this->data['vip'] = $vip;
  6672. $this->_Template('whlabel_fc', $this->data);
  6673. }
  6674. public function _fcmb()
  6675. {
  6676. $where = "sku != 'Preset'";
  6677. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6678. foreach ($rows as $k => $v) {
  6679. $warehouse = $this->warehouse->read($v['warehouse']);
  6680. $rows[$k]['warehouse'] = $warehouse['title'];
  6681. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6682. $rows[$k]['t'] = '';
  6683. $rows[$k]['n'] = '';
  6684. }
  6685. $title = "封货产品数据导入模板";
  6686. $titlename = "<table border=1>
  6687. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6688. <tr align='center'>
  6689. <td>仓库</td>
  6690. <td>SKU</td>
  6691. <td>产品</td>
  6692. <td>封存产品总数量</td>
  6693. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6694. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6695. </tr>
  6696. </table>";
  6697. $filename = $title . ".xls";
  6698. $tail = "";
  6699. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6700. }
  6701. public function _fcexcel()
  6702. {
  6703. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6704. $config['upload_path'] = '.' . $dir;
  6705. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6706. $config['allowed_types'] = 'xls|xlsx|csv';
  6707. $config['max_size'] = 10240;
  6708. $this->load->library('upload', $config);
  6709. $this->upload->initialize($config);
  6710. if ($this->upload->do_upload('userfile')) {
  6711. $full_path = $dir . $this->upload->data('file_name');
  6712. $fileName = '.' . $full_path;
  6713. if (!file_exists($fileName)) {
  6714. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6715. exit;
  6716. } else {
  6717. libxml_use_internal_errors(true);
  6718. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6719. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6720. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6721. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6722. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6723. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6724. ++$column; //如果列数大于26行
  6725. $list = array();
  6726. for ($i = 2; $i <= $row; $i++) // 行数循环
  6727. {
  6728. $data = array();
  6729. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6730. {
  6731. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6732. }
  6733. $list[] = $data;
  6734. }
  6735. }
  6736. $i = 0;
  6737. $j = 0;
  6738. $ed = array();
  6739. foreach ($list as $key => $value) {
  6740. $time = time();
  6741. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6742. continue;
  6743. }
  6744. $warehouse = $this->warehouse->get_title($value['0']);
  6745. $sku = $value['1'];
  6746. $type = $value['4']; //调整方式0扣减1删除
  6747. $num = $value['5']; //调整数量
  6748. //$text = $value['4'];//扣减说明
  6749. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6750. if (!$d) //如果没有这个SKU
  6751. {
  6752. $ed[] = array($sku . '-库存中不存在此SKU');
  6753. $j++;
  6754. continue;
  6755. }
  6756. if (!isset($warehouse['id'])) {
  6757. $ed[] = array($sku . '-仓库名错误!');
  6758. $j++;
  6759. continue;
  6760. }
  6761. if ($type == 1 || $type == 2) //扣减库存
  6762. {
  6763. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6764. if (count($data) < abs($num)) {
  6765. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6766. $j++;
  6767. continue;
  6768. }
  6769. if ($type == 1) //转入库存
  6770. {
  6771. for ($i = 0; $i < abs($num); $i++) {
  6772. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6773. }
  6774. } else if ($type == 2) //删除
  6775. {
  6776. for ($i = 0; $i < abs($num); $i++) {
  6777. $this->whlabel->remove($data[$i]['id']);
  6778. }
  6779. }
  6780. } else if ($type == 0) //增加库存
  6781. {
  6782. $post['sku'] = $d['sku'];
  6783. $post['shop'] = '';
  6784. $post['warehouse'] = $warehouse['id'];
  6785. $post['purchase'] = $d['purchase'];
  6786. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6787. $post['state'] = 11;
  6788. $post['title'] = $d['title'];
  6789. $post['number'] = $d['number'];
  6790. $post['features'] = $d['features'];
  6791. $post['enter'] = $time;
  6792. $post['time'] = $time; //操作时间
  6793. for ($i = 0; $i < $num; $i++) {
  6794. $post['label'] = time() . rand(100, 999) . $i;
  6795. $this->whlabel->insert($post);
  6796. }
  6797. }
  6798. sleep(1); //防止入库时间一样,需要延迟1秒
  6799. }
  6800. if ($j > 0) {
  6801. $tt = date('Ymd', time());
  6802. $title = '库存导入错误信息-' . $tt;
  6803. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6804. $tail = "\n";
  6805. $filename = $title . ".xls";
  6806. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6807. $dir = '/data/excel/' . $time . '/';
  6808. $file_name = 'error_' . $time . rand(1000, 9999);
  6809. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6810. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6811. fwrite($myfile, $ecl);
  6812. fclose($myfile);
  6813. $error = $dir . $file_name . '.xls';
  6814. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6815. exit;
  6816. } else {
  6817. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6818. exit;
  6819. }
  6820. }
  6821. }
  6822. public function _fcjxc($arg_array)
  6823. {
  6824. if (isset($_GET['excel'])) {
  6825. $category = $this->input->get('category', true);
  6826. $size = $this->input->get('size', true);
  6827. $grade = $this->input->get('grade', true);
  6828. $color = $this->input->get('color', true);
  6829. $lowe = $this->input->get('lowe', true);
  6830. $sku = $this->input->get('sku');
  6831. $title = $this->input->get('title');
  6832. $warehouse = $arg_array[0];
  6833. $usa = $this->input->get('usa', true);
  6834. $purchase = $this->input->get('purchase', true);
  6835. $lacetype = $this->input->get('lacetype', true);
  6836. $haircap = $this->input->get('haircap', true);
  6837. $density = $this->input->get('density', true);
  6838. $title = $this->input->get('title', true);
  6839. $state = $this->input->get('state', true);
  6840. $ktime = $this->input->get('ktime', true);
  6841. $jtime = $this->input->get('jtime', true);
  6842. $where = "state=11";
  6843. $gj = "";
  6844. $ck = "";
  6845. if ($lacetype) {
  6846. $where .= " and features like '%-$lacetype-%'";
  6847. }
  6848. if ($category) {
  6849. $where .= " and features like '%-$category-%'";
  6850. }
  6851. if ($size) {
  6852. $where .= " and features like '%-$size-%'";
  6853. }
  6854. if ($grade) {
  6855. $where .= " and features like '%-$grade-%'";
  6856. }
  6857. if ($color) {
  6858. $where .= " and features like '%-$color-%'";
  6859. }
  6860. if ($lowe) {
  6861. $where .= " and features like '%-$lowe-%'";
  6862. }
  6863. if ($haircap) {
  6864. $where .= " and features like '%-$haircap-%'";
  6865. }
  6866. if ($density) {
  6867. $where .= " and features like '%-$density-%'";
  6868. }
  6869. if ($usa) {
  6870. if (!$warehouse) {
  6871. $where .= " and (warehouse = '5' or warehouse = '8')";
  6872. }
  6873. }
  6874. if ($warehouse) {
  6875. $where .= " and warehouse = '$warehouse'";
  6876. }
  6877. if ($purchase) {
  6878. $where .= " and purchase = '$purchase'";
  6879. }
  6880. if ($state) {
  6881. $where .= " and state = '$state'";
  6882. }
  6883. $order_str = "id desc";
  6884. if ($sku) {
  6885. $sku = trim($sku, ' ');
  6886. $sku = trim($sku, ' ');
  6887. $where .= " and sku like '%$sku%'";
  6888. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6889. } else if ($title) {
  6890. $title = trim($title, ' ');
  6891. $title = trim($title, ' ');
  6892. $where .= " and title like '%$title%'";
  6893. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6894. } else {
  6895. //$where .= " and time > '$ktime' and time < '$jtime'";
  6896. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6897. }
  6898. //取得信息列表
  6899. $rows = array();
  6900. $list = array();
  6901. foreach ($info_list as $key => $value) {
  6902. $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'] . '"');
  6903. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6904. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6905. $rows[$key] = $value;
  6906. $warehouse = $this->warehouse->read($value['warehouse']);
  6907. $rows[$key]['warehouse'] = $warehouse['title'];
  6908. $rows[$key]['features'] = $g;
  6909. $rows[$key]['a'] = $x;
  6910. $rows[$key]['b'] = $s;
  6911. }
  6912. $title = "总统计表";
  6913. $titlename = "<table border=1>
  6914. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6915. <tr align='center'>
  6916. <td>仓库</td>
  6917. <td>SKU</td>
  6918. <td>产品名称</td>
  6919. <td>录入总量</td>
  6920. <td>取出总量</td>
  6921. <td>剩余总量</td>
  6922. </tr>
  6923. </table>";
  6924. $filename = $title . ".xls";
  6925. $tail = "";
  6926. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6927. }
  6928. $vip = 0;
  6929. if (isset($_SESSION['api'])) {
  6930. $user = $this->user->get_api($_SESSION['api']);
  6931. if ($user['vip'] == 1) {
  6932. $vip = 1;
  6933. }
  6934. } else {
  6935. header('Location: /');
  6936. exit;
  6937. }
  6938. $post = $this->input->post(NULL, TRUE);
  6939. if (isset($post['page'])) {
  6940. $page = $this->input->post('page', true);
  6941. $perpage = $this->input->post('perpage', true);
  6942. $category = $this->input->post('category', true);
  6943. $size = $this->input->post('size', true);
  6944. $grade = $this->input->post('grade', true);
  6945. $color = $this->input->post('color', true);
  6946. $lowe = $this->input->post('lowe', true);
  6947. $sku = $this->input->post('sku');
  6948. $title = $this->input->post('title');
  6949. $warehouse = $arg_array[0];
  6950. $usa = $this->input->post('usa', true);
  6951. $purchase = $this->input->post('purchase', true);
  6952. $lacetype = $this->input->post('lacetype', true);
  6953. $haircap = $this->input->post('haircap', true);
  6954. $density = $this->input->post('density', true);
  6955. $title = $this->input->post('title', true);
  6956. $state = $this->input->post('state', true);
  6957. $ktime = $this->input->post('ktime', true);
  6958. $jtime = $this->input->post('jtime', true);
  6959. $ktime = strtotime($ktime);
  6960. $jtime = strtotime($jtime);
  6961. $where = "state=11";
  6962. $gj = "";
  6963. $ck = "";
  6964. if ($lacetype) {
  6965. $where .= " and features like '%-$lacetype-%'";
  6966. }
  6967. if ($category) {
  6968. $where .= " and features like '%-$category-%'";
  6969. }
  6970. if ($size) {
  6971. $where .= " and features like '%-$size-%'";
  6972. }
  6973. if ($grade) {
  6974. $where .= " and features like '%-$grade-%'";
  6975. }
  6976. if ($color) {
  6977. $where .= " and features like '%-$color-%'";
  6978. }
  6979. if ($lowe) {
  6980. $where .= " and features like '%-$lowe-%'";
  6981. }
  6982. if ($haircap) {
  6983. $where .= " and features like '%-$haircap-%'";
  6984. }
  6985. if ($density) {
  6986. $where .= " and features like '%-$density-%'";
  6987. }
  6988. if ($usa) {
  6989. if (!$warehouse) {
  6990. $where .= " and (warehouse = '5' or warehouse = '8')";
  6991. }
  6992. }
  6993. if ($warehouse) {
  6994. $where .= " and warehouse = '$warehouse'";
  6995. }
  6996. if ($purchase) {
  6997. $where .= " and purchase = '$purchase'";
  6998. }
  6999. if ($state) {
  7000. $where .= " and state = '$state'";
  7001. }
  7002. if ($ktime && $jtime) {
  7003. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7004. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7005. }
  7006. //数据排序
  7007. $order_str = "id desc";
  7008. $xs = 0;
  7009. $rows = array();
  7010. $list = array();
  7011. if (empty($page)) {
  7012. $start = 0;
  7013. $perpage = 1;
  7014. } else {
  7015. $start = ($page - 1) * $perpage;
  7016. }
  7017. if ($sku || $title) {
  7018. if ($title) {
  7019. $title = trim($title, ' ');
  7020. $title = trim($title, ' ');
  7021. $where .= " and title like '%$title%'";
  7022. } else {
  7023. $sku = trim($sku, ' ');
  7024. $sku = trim($sku, ' ');
  7025. $where .= " and sku like '%$sku%'";
  7026. }
  7027. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7028. foreach ($info_list as $key => $value) {
  7029. $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'] . '"');
  7030. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7031. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7032. $rows[$key] = $value;
  7033. $warehouse = $this->warehouse->read($value['warehouse']);
  7034. $rows[$key]['warehouse'] = $warehouse['title'];
  7035. $rows[$key]['features'] = $g;
  7036. $rows[$key]['a'] = $x;
  7037. $rows[$key]['b'] = $s;
  7038. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7039. $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天销量
  7040. $yj = $c / ($xl / 30);
  7041. if ($yj < 7) {
  7042. $rows[$key]['y'] = round($yj) . '天销量';
  7043. } else {
  7044. $rows[$key]['y'] = '正常';
  7045. }
  7046. }
  7047. } else {
  7048. //$where .= " and time > '$ktime' and time < '$jtime'";
  7049. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7050. foreach ($info_list as $key => $value) {
  7051. $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'] . '"');
  7052. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7053. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7054. $zs[$key] = $value;
  7055. $warehouse = $this->warehouse->read($value['warehouse']);
  7056. $zs[$key]['warehouse'] = $warehouse['title'];
  7057. $zs[$key]['features'] = $g;
  7058. $zs[$key]['a'] = $x;
  7059. $zs[$key]['b'] = $s;
  7060. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7061. $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天销量
  7062. $yj = $c / ($xl / 30);
  7063. if ($yj < 7) {
  7064. $zs[$key]['y'] = round($yj) . '天销量';
  7065. $rows[$key] = $zs[$key];
  7066. }
  7067. }
  7068. }
  7069. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7070. $pagenum = ceil($total / $perpage);
  7071. $over = $total - ($start + $perpage);
  7072. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7073. echo json_encode($rows);
  7074. exit;
  7075. }
  7076. $this->data['arg_array'] = $arg_array[0];
  7077. $this->_Template('whlabel_fcjxc', $this->data);
  7078. }
  7079. public function _0kcdel()
  7080. {
  7081. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7082. $config['upload_path'] = '.' . $dir;
  7083. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7084. $config['allowed_types'] = 'xls|xlsx|csv';
  7085. $config['max_size'] = 10240;
  7086. $this->load->library('upload', $config);
  7087. $this->upload->initialize($config);
  7088. if ($this->upload->do_upload('userfile')) {
  7089. $full_path = $dir . $this->upload->data('file_name');
  7090. $fileName = '.' . $full_path;
  7091. if (!file_exists($fileName)) {
  7092. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7093. exit;
  7094. } else {
  7095. require_once "./data/excel/PHPExcel/IOFactory.php";
  7096. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7097. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7098. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7099. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7100. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7101. ++$column; //如果列数大于26行
  7102. $list = array();
  7103. for ($i = 2; $i <= $row; $i++) // 行数循环
  7104. {
  7105. $data = array();
  7106. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7107. {
  7108. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7109. }
  7110. $list[] = $data;
  7111. }
  7112. }
  7113. $i = 0;
  7114. $j = 0;
  7115. $ed = array();
  7116. foreach ($list as $key => $value) {
  7117. $time = time();
  7118. if ($value['0'] == "" || $value['1'] == "") {
  7119. continue;
  7120. }
  7121. $warehouse = $this->warehouse->get_title($value['0']);
  7122. $sku = $value['1'];
  7123. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7124. if (!$d) //如果没有这个SKU
  7125. {
  7126. $ed[] = array($sku . '-库存中不存在此SKU');
  7127. $j++;
  7128. continue;
  7129. }
  7130. if (!isset($warehouse['id'])) {
  7131. $ed[] = array($sku . '-仓库名错误!');
  7132. $j++;
  7133. continue;
  7134. }
  7135. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7136. if ($z < 1) {
  7137. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7138. foreach ($z as $v) {
  7139. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7140. if (count($zt) > 0) {
  7141. $ed[] = array($sku . '-有在途库存无法删除!');
  7142. $j++;
  7143. continue;
  7144. }
  7145. $this->whlabel->remove($v['id']);
  7146. }
  7147. } else {
  7148. $ed[] = array($sku . '-非0库存!');
  7149. $j++;
  7150. continue;
  7151. }
  7152. }
  7153. if ($j > 0) {
  7154. $tt = date('Ymd', time());
  7155. $title = '删除0库存错误信息-' . $tt;
  7156. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7157. $tail = "\n";
  7158. $filename = $title . ".xls";
  7159. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7160. $dir = '/data/excel/' . $time . '/';
  7161. $file_name = 'error_' . $time . rand(1000, 9999);
  7162. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7163. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7164. fwrite($myfile, $ecl);
  7165. fclose($myfile);
  7166. $error = $dir . $file_name . '.xls';
  7167. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7168. exit;
  7169. } else {
  7170. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7171. exit;
  7172. }
  7173. }
  7174. }
  7175. public function _gbhtype()
  7176. {
  7177. $post = $this->input->post(NULL, TRUE);
  7178. if (isset($post['s'])) {
  7179. $n = $this->input->post('n');
  7180. $d = $this->input->post('s');
  7181. if (!$d) {
  7182. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7183. exit;
  7184. }
  7185. $d = explode(',', trim($d, ','));
  7186. $t = $this->whlabel_type->read($n);
  7187. //循环删除记录
  7188. foreach ($d as $v) {
  7189. $u = $this->whlabel->read($v);
  7190. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7191. foreach ($data as $val) {
  7192. $this->whlabel->save(array('type' => $n), $val['id']);
  7193. }
  7194. }
  7195. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7196. }
  7197. }
  7198. //出库、退库导出
  7199. public function _dccrtype()
  7200. {
  7201. $classid = $this->classid->sku();
  7202. $pm = $classid;
  7203. $typeclass = array();
  7204. $tc = $this->typeclass->find_all();
  7205. foreach ($tc as $v) {
  7206. $typeclass[$v['id']] = $v;
  7207. }
  7208. $prc = array();
  7209. $purchase = $this->purchase->find_all();
  7210. foreach ($purchase as $k => $v) {
  7211. $prc[$v['id']] = $v['title'];
  7212. }
  7213. if (isset($_GET['sid'])) {
  7214. $wh = array();
  7215. $w = $this->warehouse->find_all('1=1', 'id,title');
  7216. foreach ($w as $v) {
  7217. $wh[$v['id']] = $v['title'];
  7218. }
  7219. $type = $this->input->get('excel', true);
  7220. $category = $this->input->get('category', true);
  7221. $size = $this->input->get('size', true);
  7222. $grade = $this->input->get('grade', true);
  7223. $color = $this->input->get('color', true);
  7224. $lowe = $this->input->get('lowe', true);
  7225. $sku = $this->input->get('sku', true);
  7226. $warehouse = $this->input->get('warehouse', true);
  7227. $lacetype = $this->input->get('lacetype', true);
  7228. $lacecolor = $this->input->get('lacecolor', true);
  7229. $density = $this->input->get('density', true);
  7230. $haircap = $this->input->get('haircap', true);
  7231. $purchase = $this->input->get('purchase', true);
  7232. $title = $this->input->get('title', true);
  7233. $state = $this->input->get('state', true);
  7234. $sid = $this->input->get('sid', true);
  7235. $ktime = $this->input->get('ktime', true);
  7236. $jtime = $this->input->get('jtime', true);
  7237. $ktime = strtotime($ktime);
  7238. $jtime = strtotime($jtime);
  7239. $where = "1=1";
  7240. $gj = "";
  7241. $ck = "";
  7242. if ($category) {
  7243. $where .= " and features like '%-$category-%'";
  7244. }
  7245. if ($size) {
  7246. $where .= " and features like '%-$size-%'";
  7247. }
  7248. if ($grade) {
  7249. $where .= " and features like '%-$grade-%'";
  7250. }
  7251. if ($color) {
  7252. $where .= " and features like '%-$color-%'";
  7253. }
  7254. if ($lowe) {
  7255. $where .= " and features like '%-$lowe-%'";
  7256. }
  7257. if ($warehouse) {
  7258. $where .= " and warehouse = '$warehouse'";
  7259. }
  7260. if ($purchase) {
  7261. $where .= " and purchase = '$purchase'";
  7262. }
  7263. if ($state) {
  7264. $where .= " and state = '$state'";
  7265. }
  7266. if ($lacetype) {
  7267. $where .= " and features like '%-$lacetype-%'";
  7268. }
  7269. if ($lacecolor) {
  7270. $where .= " and features like '%-$lacecolor-%'";
  7271. }
  7272. if ($density) {
  7273. $where .= " and features like '%-$density-%'";
  7274. }
  7275. if ($haircap) {
  7276. $where .= " and features like '%-$haircap-%'";
  7277. }
  7278. if ($title) {
  7279. $title = trim($title, ' ');
  7280. $title = trim($title, ' ');
  7281. $where .= " and title like '%$title%'";
  7282. }
  7283. if ($sku) {
  7284. $sku = trim($sku, ' ');
  7285. $sku = trim($sku, ' ');
  7286. $where .= " and sku like '%$sku%'";
  7287. }
  7288. if ($ktime && $jtime) {
  7289. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7290. }
  7291. $sidwhere = '';
  7292. if ($sid) {
  7293. $sd = "";
  7294. $s = explode(',', trim($sid, ','));
  7295. foreach ($s as $value) {
  7296. $sd .= " id = " . $value . " or";
  7297. }
  7298. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7299. }
  7300. //数据排序
  7301. $order_str = "time desc";
  7302. if (empty($page)) {
  7303. $start = 0;
  7304. $perpage = 1;
  7305. } else {
  7306. $start = ($page - 1) * $perpage;
  7307. }
  7308. $wh = array();
  7309. $w = $this->warehouse->find_all('1=1', 'id,title');
  7310. foreach ($w as $v) {
  7311. $wh[$v['id']] = $v['title'];
  7312. }
  7313. $wt = array();
  7314. $whlabel_type = $this->whlabel_type->find_all();
  7315. foreach ($whlabel_type as $v) {
  7316. $wt[$v['id']] = $v['title'];
  7317. }
  7318. $classid = $this->classid->sku();
  7319. $list = array();
  7320. $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');
  7321. foreach ($rows_r as $key => $value) {
  7322. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7323. $pm = $classid;
  7324. $jm = $classid;
  7325. $rows_r[$key]['enter'] = '入库';
  7326. $rows_r[$key]['time'] = $value['enter'];
  7327. if ($value['rktype'] == 1) {
  7328. $rows_r[$key]['rktype'] = '采购入库';
  7329. } else if ($value['rktype'] == 2) {
  7330. $rows_r[$key]['rktype'] = '盘盈调整';
  7331. } else if ($value['rktype'] == 3) {
  7332. $rows_r[$key]['rktype'] = '其他调整入库';
  7333. } else if ($value['rktype'] == 4) {
  7334. $rows_r[$key]['rktype'] = '其他调整入库';
  7335. } else if ($value['rktype'] == 5) {
  7336. $rows_r[$key]['rktype'] = '退库入库';
  7337. } else if ($value['rktype'] == 6) {
  7338. $rows_r[$key]['rktype'] = '退货可用入库';
  7339. } else if ($value['rktype'] == 7) {
  7340. $rows_r[$key]['rktype'] = '形态转换入库';
  7341. } else {
  7342. $rows_r[$key]['rktype'] = '';
  7343. }
  7344. $features = explode('-', trim($value['features'], '-'));
  7345. foreach ($features as $v) {
  7346. if (isset($typeclass[$v])) {
  7347. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7348. $pm[$typeclass[$v]['classid']] = $zh[0];
  7349. }
  7350. if (isset($typeclass[$v])) {
  7351. if (isset($jm[$typeclass[$v]['classid']])) {
  7352. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7353. }
  7354. }
  7355. }
  7356. $zh = implode(" ", $pm);
  7357. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7358. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7359. $rows_r[$key]['zh'] = $zh;
  7360. $jm = array_filter($jm);
  7361. $rows_r[$key]['features'] = implode("-", $jm);
  7362. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7363. }
  7364. $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');
  7365. foreach ($rows_c as $key => $value) {
  7366. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7367. $pm = $classid;
  7368. $jm = $classid;
  7369. $rows_c[$key]['time'] = $value['outk'];
  7370. $rows_c[$key]['outk'] = '出库';
  7371. if ($value['cktype'] == 1) {
  7372. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  7373. } else if ($value['cktype'] == 2) {
  7374. $rows_c[$key]['cktype'] = '美国销售调货出库';
  7375. } else if ($value['cktype'] == 3) {
  7376. $rows_c[$key]['cktype'] = '盘亏调整';
  7377. } else if ($value['cktype'] == 4) {
  7378. $rows_c[$key]['cktype'] = '其他调整出库';
  7379. } else if ($value['cktype'] == 5) {
  7380. $rows_c[$key]['cktype'] = '形态转换出库';
  7381. } else {
  7382. $rows_c[$key]['cktype'] = '';
  7383. }
  7384. unset($rows_c[$key]['state']);
  7385. $features = explode('-', trim($value['features'], '-'));
  7386. foreach ($features as $v) {
  7387. if (isset($typeclass[$v])) {
  7388. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7389. $pm[$typeclass[$v]['classid']] = $zh[0];
  7390. }
  7391. if (isset($typeclass[$v])) {
  7392. if (isset($jm[$typeclass[$v]['classid']])) {
  7393. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7394. }
  7395. }
  7396. }
  7397. $zh = implode(" ", $pm);
  7398. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7399. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7400. $rows_c[$key]['zh'] = $zh;
  7401. $jm = array_filter($jm);
  7402. $rows_c[$key]['features'] = implode("-", $jm);
  7403. $rows_c[$key]['number'] = 1;
  7404. }
  7405. $merged = $rows_r;
  7406. foreach ($rows_c as $key => $value) {
  7407. if (isset($merged[$key])) {
  7408. $merged[] = $value;
  7409. } else {
  7410. $merged[$key] = $value;
  7411. }
  7412. }
  7413. usort($merged, function ($a, $b) {
  7414. return $a['time'] - $b['time'];
  7415. });
  7416. foreach ($merged as $key => $value) {
  7417. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7418. }
  7419. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7420. $titlename = "<table border=1>
  7421. <tr align='center'>
  7422. <td>仓库</td>
  7423. <td>SKU</td>
  7424. <td>商品名称</td>
  7425. <td>仓库品名</td>
  7426. <td>料号</td>
  7427. <td>时间</td>
  7428. <td>操作</td>
  7429. <td>类型</td>
  7430. <td>数量</td>
  7431. <td>备注</td>
  7432. </tr>
  7433. </table>";
  7434. $filename = $title . ".xlsx";
  7435. $tail = "";
  7436. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7437. }
  7438. }
  7439. /*************************************处理exceljs导出****************************************************/
  7440. public function _excelrjs(){
  7441. if (isset($_GET['excel'])) {
  7442. $category = $this->input->get('category', true);
  7443. $size = $this->input->get('size', true);
  7444. $grade = $this->input->get('grade', true);
  7445. $color = $this->input->get('color', true);
  7446. $lowe = $this->input->get('lowe', true);
  7447. $sku = $this->input->get('sku', true);
  7448. $warehouse = $this->input->get('warehouse', true);
  7449. $purchase = $this->input->get('purchase', true);
  7450. $ktime = $this->input->get('ktime', true);
  7451. $jtime = $this->input->get('jtime', true);
  7452. $ktime = strtotime($ktime);
  7453. $jtime = strtotime($jtime);
  7454. $where = "1=1";
  7455. $gj = "";
  7456. $ck = "";
  7457. if ($category) {
  7458. $where .= " and features like '%-$category-%'";
  7459. }
  7460. if ($size) {
  7461. $where .= " and features like '%-$size-%'";
  7462. }
  7463. if ($grade) {
  7464. $where .= " and features like '%-$grade-%'";
  7465. }
  7466. if ($color) {
  7467. $where .= " and features like '%-$color-%'";
  7468. }
  7469. if ($lowe) {
  7470. $where .= " and features like '%-$lowe-%'";
  7471. }
  7472. if ($warehouse) {
  7473. $where .= " and warehouse = '$warehouse'";
  7474. }
  7475. if ($purchase) {
  7476. $where .= " and purchase = '$purchase'";
  7477. }
  7478. if ($sku) {
  7479. $where .= " and sku = '$sku'";
  7480. }
  7481. if ($ktime && $jtime) {
  7482. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  7483. }
  7484. //数据排序
  7485. $order_str = "id desc";
  7486. if (empty($page)) {
  7487. $start = 0;
  7488. $perpage = 1;
  7489. } else {
  7490. $start = ($page - 1) * $perpage;
  7491. }
  7492. $list = array();
  7493. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  7494. foreach ($rows as $value) {
  7495. $ck = $this->warehouse->read($value['warehouse']);
  7496. $warehouse = $ck['title'];
  7497. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  7498. $retreatwarehouse = $tkck['title'];
  7499. $gy = $this->purchase->read($value['purchase']);
  7500. $purchase = $gy['title'];
  7501. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  7502. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  7503. }
  7504. // $list = [
  7505. // [
  7506. // 'warehouse'=>"许昌仓",
  7507. // 'sku'=>"123456",
  7508. // 'title'=>"商品名称",
  7509. // 'time'=>"2021-01-01 12:00:00",
  7510. // 'number'=>"121-111121"
  7511. // ],
  7512. // [
  7513. // 'warehouse'=>"美仓",
  7514. // 'sku'=>"353456",
  7515. // 'title'=>"商品名称1",
  7516. // 'time'=>"2021-01-01 12:01:00",
  7517. // 'number'=>"121-1333121"
  7518. // ],
  7519. // ];
  7520. if(empty($list)){
  7521. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  7522. }else{
  7523. $final_list = [];
  7524. foreach($list as $v){
  7525. $final_list[] = array_values($v);
  7526. }
  7527. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  7528. array_unshift($final_list,[
  7529. "仓库","SKU","商品名称","时间","数量"
  7530. ]);
  7531. array_unshift($final_list,[
  7532. $title,"","","",""
  7533. ]);
  7534. exit(json_encode(array('code' => 1,'msg'=>"获取成功", 'data' => $final_list,'title'=>$title)));
  7535. }
  7536. }
  7537. }
  7538. }