Whlabel.php 258 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491
  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. }
  45. //定义方法的调用规则 获取URI第二段值
  46. public function _remap($arg, $arg_array)
  47. {
  48. if ($arg == 'existence') //在库标签
  49. {
  50. $this->_existence();
  51. } else if ($arg == 'cpbqdc') //在库标签
  52. {
  53. $this->_cpbqdc();
  54. } else if ($arg == 'type') //进销存浏览
  55. {
  56. $this->_type();
  57. } else if ($arg == 'typedy') //进销存浏览店员页面
  58. {
  59. $this->_typedy($arg_array);
  60. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  61. {
  62. $this->_typedy_ck($arg_array);
  63. } else if ($arg == 'typeck') {
  64. $this->_typeck($arg_array);
  65. } else if ($arg == 'whlabeckdc') {
  66. $this->_whlabeckdc($arg_array);
  67. } else if ($arg == 'usatype') //美仓进销存浏览
  68. {
  69. $this->_usatype();
  70. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  71. {
  72. $this->_usatypeapp();
  73. } else if ($arg == 'enteradd') //入库操作
  74. {
  75. $this->_enteradd();
  76. } else if ($arg == 'enteredit') //修改
  77. {
  78. $this->_enteredit($arg_array);
  79. } else if ($arg == 'enter') //入库浏览
  80. {
  81. $this->_enter();
  82. } else if ($arg == 'out') //出库浏览
  83. {
  84. $this->_out();
  85. } else if ($arg == 'label') //出库标签浏览
  86. {
  87. $this->_label();
  88. } else if ($arg == 'outorder') //独立站出库订单
  89. {
  90. $this->_outorder();
  91. } else if ($arg == 'soutorder') //速卖通出库订单
  92. {
  93. $this->_soutorder();
  94. } else if ($arg == 'toutorder') //TT出库订单
  95. {
  96. $this->_toutorder();
  97. }else if ($arg == 'aoutorder') //amz出库订单
  98. {
  99. $this->_aoutorder();
  100. } else if ($arg == 'retreat') //退库订单
  101. {
  102. $this->_retreat();
  103. } else if ($arg == 'retreatlk') //退库订单
  104. {
  105. $this->_retreatlk();
  106. } else if ($arg == 'change') //更换标签
  107. {
  108. $this->_change();
  109. } else if ($arg == 'del') //删除
  110. {
  111. $this->_del();
  112. } else if ($arg == 'exceljxc') //进销存信息导出
  113. {
  114. $this->_exceljxc();
  115. } else if ($arg == 'excelr') //入库信息导出
  116. {
  117. $this->_excelr();
  118. } else if ($arg == 'excelct') //出库、退库信息导出
  119. {
  120. $this->_excelct();
  121. } else if ($arg == 'dccrtype') //根据出入库类型导出
  122. {
  123. $this->_dccrtype();
  124. } else if ($arg == 'excelcr') //出库、退库信息导出
  125. {
  126. $this->_excelcr();
  127. } else if ($arg == 'kcyz') //库存验证
  128. {
  129. $this->_kcyz();
  130. } else if ($arg == 'kj') //库存扣减
  131. {
  132. $this->_kj($arg_array);
  133. } else if ($arg == 'presetout') //预设库存导入
  134. {
  135. $this->_presetout($arg_array);
  136. } else if ($arg == 'presetedit') //预设库存导入
  137. {
  138. $this->_presetedit($arg_array);
  139. } else if ($arg == 'summary') //汇总导出
  140. {
  141. $this->_summary($arg_array);
  142. } else if ($arg == 'manifest') //usps发货清单
  143. {
  144. $this->_manifest();
  145. } else if ($arg == 'abnormal') //占单异常
  146. {
  147. $this->_abnormal();
  148. } else if ($arg == 'error') //0库存SKU
  149. {
  150. $this->_error();
  151. } else if ($arg == 'errorexcel') //0库存SKU导出
  152. {
  153. $this->_errorexcel();
  154. } else if ($arg == 'db') {
  155. $this->_db();
  156. } else if ($arg == 'dbrk') {
  157. $this->_dbrk();
  158. } else if ($arg == 'whlabelczdc') {
  159. $this->_whlabelczdc();
  160. } else if ($arg == 'print') {
  161. $this->_print($arg_array);
  162. } else if ($arg == 'usaprint') {
  163. $this->_usaprint($arg_array);
  164. } else if ($arg == 'printck') {
  165. $this->_printck($arg_array);
  166. } else if ($arg == 'printrk') {
  167. $this->_printrk($arg_array);
  168. } else if ($arg == 'printxzrk') {
  169. $this->_printxzrk($arg_array);
  170. } else if ($arg == 'printexcel') {
  171. $this->_printexcel($arg_array);
  172. } else if ($arg == 'uck') {
  173. $this->_uck();
  174. } else if ($arg == 'whlabelexcelzh') {
  175. $this->_whlabelexcelzh();
  176. } else if ($arg == 'fc') {
  177. $this->_fc();
  178. } else if ($arg == 'fcmb') {
  179. $this->_fcmb();
  180. } else if ($arg == 'fcexcel') {
  181. $this->_fcexcel();
  182. } else if ($arg == 'fcjxc') {
  183. $this->_fcjxc($arg_array);
  184. } else if ($arg == '0kcdel') {
  185. $this->_0kcdel(); //导表删除0库存
  186. } else if ($arg == 'gbhtype') {
  187. $this->_gbhtype(); //更改备货状态
  188. } else {
  189. $this->_index();
  190. }
  191. }
  192. //管理
  193. public function _index()
  194. {
  195. $post = $this->input->post(NULL, TRUE);
  196. if (isset($post['page'])) {
  197. $page = $this->input->post('page', true);
  198. $perpage = $this->input->post('perpage', true);
  199. $sku = $this->input->post('sku', true);
  200. $number = $this->input->post('number', true);
  201. $warehouse = $this->input->post('warehouse', true);
  202. $purchase = $this->input->post('purchase', true);
  203. $orderinfo = $this->input->post('orderinfo', true);
  204. $waybill = $this->input->post('waybill', true);
  205. $category = $this->input->post('category', true);
  206. $size = $this->input->post('size', true);
  207. $grade = $this->input->post('grade', true);
  208. $color = $this->input->post('color', true);
  209. $lowe = $this->input->post('lowe', true);
  210. $state = $this->input->post('state', true);
  211. $label = $this->input->post('label', true);
  212. $timetk = $this->input->post('timetkk', true);
  213. $timetj = $this->input->post('timetjj', true);
  214. $timetk = strtotime($timetk);
  215. $timetj = strtotime($timetj);
  216. $where = "1=1 ";
  217. if ($timetk && $timetj) {
  218. $where .= " and time > '$timetk' and time < '$timetj'";
  219. }
  220. if ($sku) {
  221. $where .= " and sku = '$sku'";
  222. }
  223. if ($number) {
  224. $where .= " and number = '$number'";
  225. }
  226. if ($warehouse) {
  227. $where .= " and warehouse = '$warehouse'";
  228. }
  229. if ($purchase) {
  230. $where .= " and purchase = '$purchase'";
  231. }
  232. if ($orderinfo) {
  233. $where .= " and orderinfo = '$orderinfo'";
  234. }
  235. if ($waybill) {
  236. $where .= " and waybill = '$waybill'";
  237. }
  238. if ($category) {
  239. $where .= " and features like '%-$category-%'";
  240. }
  241. if ($size) {
  242. $where .= " and features like '%-$size-%'";
  243. }
  244. if ($grade) {
  245. $where .= " and features like '%-$grade-%'";
  246. }
  247. if ($color) {
  248. $where .= " and features like '%-$color-%'";
  249. }
  250. if ($lowe) {
  251. $where .= " and features like '%-$lowe-%'";
  252. }
  253. if ($label) {
  254. $where .= " and label = '$label'";
  255. }
  256. if ($state != '') {
  257. $where .= " and state = '$state'";
  258. }
  259. //数据排序
  260. $order_str = "time desc";
  261. if (empty($page)) {
  262. $start = 0;
  263. $perpage = 1;
  264. } else {
  265. $start = ($page - 1) * $perpage;
  266. }
  267. //取得信息列表
  268. $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);
  269. foreach ($info_list as $key => $value) {
  270. $warehouse = $this->warehouse->read($value['warehouse']);
  271. $info_list[$key]['warehouse'] = $warehouse['title'];
  272. $purchase = $this->purchase->read($value['purchase']);
  273. $info_list[$key]['purchase'] = $purchase['title'];
  274. if ($value['enter'] != 0) {
  275. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  276. } else {
  277. $info_list[$key]['enter'] = "";
  278. }
  279. if ($value['outk'] != 0) {
  280. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  281. } else {
  282. $info_list[$key]['outk'] = "";
  283. }
  284. if ($value['printing'] != 0) {
  285. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  286. } else {
  287. $info_list[$key]['printing'] = "";
  288. }
  289. if ($value['orderinfo'] == 0) {
  290. $info_list[$key]['orderinfo'] = "";
  291. }
  292. if ($value['waybill'] == 0) {
  293. $info_list[$key]['waybill'] = "";
  294. }
  295. if ($value['state'] == 0) {
  296. $info_list[$key]['state'] = "在库";
  297. } else if ($value['state'] == 1) {
  298. $info_list[$key]['state'] = "出库";
  299. } else if ($value['state'] == 2) {
  300. $info_list[$key]['state'] = "退库";
  301. } else if ($value['state'] == 3) {
  302. $info_list[$key]['state'] = "调拨中";
  303. } else if ($value['state'] == 4) {
  304. $info_list[$key]['state'] = "再加工";
  305. } else if ($value['state'] == 5) {
  306. $info_list[$key]['state'] = "维修中";
  307. } else if ($value['state'] == 6) {
  308. $info_list[$key]['state'] = "盘亏";
  309. } else if ($value['state'] == 7) {
  310. $info_list[$key]['state'] = "更换标签";
  311. } else if ($value['state'] == 8) {
  312. $info_list[$key]['state'] = "其它";
  313. } else if ($value['state'] == 9) {
  314. $info_list[$key]['state'] = "预设";
  315. } else if ($value['state'] == 10) {
  316. $info_list[$key]['state'] = "美店零售";
  317. }
  318. if ($value['text'] == "") {
  319. $info_list[$key]['text'] = "";
  320. }
  321. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  322. }
  323. $total = $this->whlabel->find_count($where);
  324. $pagenum = ceil($total / $perpage);
  325. $over = $total - ($start + $perpage);
  326. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  327. echo json_encode($rows);
  328. exit;
  329. }
  330. if (isset($post['outsku'])) {
  331. $cz = $this->input->post('cz', true);
  332. if ($cz == '1') {
  333. $sku = $this->input->post('outsku', true);
  334. if ($sku) {
  335. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  336. if (count($data) < 1) {
  337. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  338. exit;
  339. }
  340. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 1), $data[0]['id']);
  341. echo json_encode(array('success' => true));
  342. exit;
  343. }
  344. } else {
  345. $sku = $this->input->post('outsku', true);
  346. if ($sku) {
  347. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  348. if (count($data) < 1) {
  349. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  350. exit;
  351. }
  352. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  353. echo json_encode(array('success' => true));
  354. exit;
  355. }
  356. }
  357. }
  358. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  359. $this->_Template('whlabel', $this->data);
  360. }
  361. //在库标签
  362. public function _existence()
  363. {
  364. $post = $this->input->post(NULL, TRUE);
  365. if (isset($post['s'])) {
  366. $id_arr = $this->input->post('s');
  367. $id_arr = explode(',', $id_arr);
  368. if (!$id_arr) {
  369. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  370. exit;
  371. }
  372. //循环删除记录
  373. foreach ($id_arr as $v) {
  374. $sid = $this->whlabel->read($v);
  375. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  376. if ($count > 0) {
  377. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  378. exit;
  379. }
  380. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  381. if (count($zt) > 0) {
  382. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  383. exit;
  384. }
  385. $this->whlabel->remove($v);
  386. }
  387. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  388. exit;
  389. }
  390. if (isset($post['page'])) {
  391. $page = $this->input->post('page', true);
  392. $perpage = $this->input->post('perpage', true);
  393. $warehouse = $this->input->post('warehouse', true);
  394. $label = $this->input->post('label', true);
  395. $where = "1=1 and state = 0";
  396. if ($warehouse) {
  397. $where .= " and warehouse = '$warehouse'";
  398. }
  399. if ($label) {
  400. $where .= " and label = '$label'";
  401. }
  402. //数据排序
  403. $order_str = "time asc";
  404. if (empty($page)) {
  405. $start = 0;
  406. $perpage = 1;
  407. } else {
  408. $start = ($page - 1) * $perpage;
  409. }
  410. //取得信息列表
  411. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  412. foreach ($info_list as $key => $value) {
  413. if ($value['enter'] != 0) {
  414. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  415. } else {
  416. $info_list[$key]['enter'] = "";
  417. }
  418. if ($value['printing'] != 0) {
  419. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  420. } else {
  421. $info_list[$key]['printing'] = "";
  422. }
  423. }
  424. $total = $this->whlabel->find_count($where);
  425. $pagenum = ceil($total / $perpage);
  426. $over = $total - ($start + $perpage);
  427. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  428. echo json_encode($rows);
  429. exit;
  430. }
  431. $this->_Template('whlabel_existence', $this->data);
  432. }
  433. //进销存浏览
  434. public function _typedy($arg_array)
  435. {
  436. $prc = array();
  437. $purchase = $this->purchase->find_all();
  438. foreach ($purchase as $k => $v) {
  439. $prc[$v['id']] = $v['title'];
  440. }
  441. $post = $this->input->post(NULL, TRUE);
  442. if (isset($post['page'])) {
  443. $page = $this->input->post('page', true);
  444. $perpage = $this->input->post('perpage', true);
  445. $category = $this->input->post('category', true);
  446. $size = $this->input->post('size', true);
  447. $grade = $this->input->post('grade', true);
  448. $color = $this->input->post('color', true);
  449. $lowe = $this->input->post('lowe', true);
  450. $sku = $this->input->post('sku');
  451. $title = $this->input->post('title');
  452. $warehouse = $this->input->post('warehouse', true);
  453. $usa = $this->input->post('usa', true);
  454. $purchase = $this->input->post('purchase', true);
  455. $lacetype = $this->input->post('lacetype', true);
  456. $haircap = $this->input->post('haircap', true);
  457. $density = $this->input->post('density', true);
  458. $details = $this->input->post('details', true);
  459. $state = $this->input->post('state', true);
  460. $lacecolor = $this->input->post('lacecolor', true);
  461. $hairnumber = $this->input->post('hairnumber', true);
  462. $cklx = $this->input->post('cklx', true);
  463. $ktime = $this->input->post('ktime', true);
  464. $jtime = $this->input->post('jtime', true);
  465. $ktime = strtotime($ktime);
  466. $jtime = strtotime($jtime);
  467. $where = "1=1";
  468. $gj = "";
  469. $ck = "";
  470. if ($usa) {
  471. if (!$warehouse) {
  472. $where .= " and (warehouse = '5' or warehouse = '8')";
  473. }
  474. }
  475. if ($warehouse) {
  476. $where .= " and warehouse = '$warehouse'";
  477. }
  478. if ($details) {
  479. $where .= " and details = '$details'";
  480. }
  481. if ($purchase) {
  482. $where .= " and purchase = '$purchase'";
  483. }
  484. if ($state) {
  485. $where .= " and state = '$state'";
  486. }
  487. if ($lacetype) {
  488. $where .= " and features like '%-$lacetype-%'";
  489. }
  490. if ($category) {
  491. $where .= " and features like '%-$category-%'";
  492. }
  493. if ($size) {
  494. $where .= " and features like '%-$size-%'";
  495. }
  496. if ($grade) {
  497. $where .= " and features like '%-$grade-%'";
  498. }
  499. if ($color) {
  500. $where .= " and features like '%-$color-%'";
  501. }
  502. if ($lowe) {
  503. $where .= " and features like '%-$lowe-%'";
  504. }
  505. if ($haircap) {
  506. $where .= " and features like '%-$haircap-%'";
  507. }
  508. if ($density) {
  509. $where .= " and features like '%-$density-%'";
  510. }
  511. if ($lacecolor) {
  512. $where .= " and features like '%-$lacecolor-%'";
  513. }
  514. if (!empty($hairnumber)) {
  515. $where .= " and features like '%-128-%' ";
  516. if ($hairnumber < 0) {
  517. $class_list = $this->typeclass->find_all('classid = 43');
  518. foreach ($class_list as $v) {
  519. $where .= " and features not like '%-" . $v['id'] . "-%'";
  520. }
  521. } else {
  522. $where .= " and features like '%-$hairnumber-%'";
  523. }
  524. }
  525. $where_add = '';
  526. if ($cklx) {
  527. $shop = $this->shop->read($cklx);
  528. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  529. }
  530. if ($ktime && $jtime) {
  531. $gj = " and enter > '$ktime' and enter < '$jtime'";
  532. $ck = " and outk > '$ktime' and outk < '$jtime'";
  533. }
  534. //数据排序
  535. $order_str = "id desc";
  536. if (empty($page)) {
  537. $start = 0;
  538. $perpage = 1;
  539. } else {
  540. $start = ($page - 1) * $perpage;
  541. }
  542. if ($sku) {
  543. $sku = trim($sku, ' ');
  544. $sku = trim($sku, ' ');
  545. $where .= " and sku like '%$sku%'";
  546. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  547. } else if ($title) {
  548. $title = trim($title, ' ');
  549. $title = trim($title, ' ');
  550. $where .= " and title like '%$title%'";
  551. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  552. } else {
  553. //$where .= " and time > '$ktime' and time < '$jtime'";
  554. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number,sm', $order_str, $start, $perpage);
  555. }
  556. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  557. foreach ($info_list as $k => $v) {
  558. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  559. unset($info_list[$k]['pm']);
  560. unset($info_list[$k]['jm']);
  561. unset($info_list[$k]['bm']);
  562. }
  563. //取得信息列表
  564. $rows = array();
  565. $list = array();
  566. foreach ($info_list as $key => $value) {
  567. $warehouse = $this->warehouse->read($value['warehouse']);
  568. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  569. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  570. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  571. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  572. $number = $value['number'];
  573. $ftime = time() - 15 * 24 * 3600;
  574. $info_list[$key]['warehouse'] = $warehouse['title'];
  575. $info_list[$key]['features'] = count($c);
  576. $z = count($z); //查看订单号
  577. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  578. $ztdata = '';
  579. if (count($zt) > 0) {
  580. foreach ($zt as $vv) {
  581. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  582. }
  583. }
  584. $info_list[$key]['number'] = $ztdata;
  585. $info_list[$key]['sm'] = $z;
  586. $details = array();
  587. $cpid = array();
  588. foreach ($c as $k => $v) {
  589. $details[$v['details']] = $v['details'];
  590. if ($v['cpid'] != 0) {
  591. $cpid[$v['cpid']] = $v['cpid'];
  592. }
  593. }
  594. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  595. if ($value['shop'] != '') {
  596. $shop = explode(',', trim($value['shop'], ','));
  597. $shop = $this->shop->read($shop[0]);
  598. $info_list[$key]['shop'] = $shop['shopname'];
  599. }
  600. }
  601. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  602. $pagenum = ceil($total / $perpage);
  603. $over = $total - ($start + $perpage);
  604. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  605. echo json_encode($rows);
  606. exit;
  607. }
  608. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  609. $this->_Template('whlabel_typedy', $this->data);
  610. }
  611. //进销存浏览
  612. public function _typedy_ck($arg_array)
  613. {
  614. $prc = array();
  615. $purchase = $this->purchase->find_all();
  616. foreach ($purchase as $k => $v) {
  617. $prc[$v['id']] = $v['title'];
  618. }
  619. $post = $this->input->post(NULL, TRUE);
  620. if (isset($post['page'])) {
  621. $page = $this->input->post('page', true);
  622. $perpage = $this->input->post('perpage', true);
  623. $category = $this->input->post('category', true);
  624. $size = $this->input->post('size', true);
  625. $grade = $this->input->post('grade', true);
  626. $color = $this->input->post('color', true);
  627. $lowe = $this->input->post('lowe', true);
  628. $sku = $this->input->post('sku');
  629. $title = $this->input->post('title');
  630. $warehouse = $this->input->post('warehouse', true);
  631. $usa = $this->input->post('usa', true);
  632. $purchase = $this->input->post('purchase', true);
  633. $lacetype = $this->input->post('lacetype', true);
  634. $haircap = $this->input->post('haircap', true);
  635. $density = $this->input->post('density', true);
  636. $details = $this->input->post('details', true);
  637. $state = $this->input->post('state', true);
  638. $lacecolor = $this->input->post('lacecolor', true);
  639. $cklx = $this->input->post('cklx', true);
  640. $ktime = $this->input->post('ktime', true);
  641. $jtime = $this->input->post('jtime', true);
  642. $ktime = strtotime($ktime);
  643. $jtime = strtotime($jtime);
  644. $where = "1=1";
  645. $gj = "";
  646. $ck = "";
  647. if ($lacetype) {
  648. $where .= " and features like '%-$lacetype-%'";
  649. }
  650. if ($category) {
  651. $where .= " and features like '%-$category-%'";
  652. }
  653. if ($size) {
  654. $where .= " and features like '%-$size-%'";
  655. }
  656. if ($grade) {
  657. $where .= " and features like '%-$grade-%'";
  658. }
  659. if ($color) {
  660. $where .= " and features like '%-$color-%'";
  661. }
  662. if ($lowe) {
  663. $where .= " and features like '%-$lowe-%'";
  664. }
  665. if ($haircap) {
  666. $where .= " and features like '%-$haircap-%'";
  667. }
  668. if ($density) {
  669. $where .= " and features like '%-$density-%'";
  670. }
  671. if ($lacecolor) {
  672. $where .= " and features like '%-$lacecolor-%'";
  673. }
  674. if ($usa) {
  675. if (!$warehouse) {
  676. $where .= " and (warehouse = '5' or warehouse = '8')";
  677. }
  678. }
  679. if ($warehouse) {
  680. $where .= " and warehouse = '$warehouse'";
  681. }
  682. if ($details) {
  683. $where .= " and details = '$details'";
  684. }
  685. if ($purchase) {
  686. $where .= " and purchase = '$purchase'";
  687. }
  688. if ($state) {
  689. $where .= " and state = '$state'";
  690. }
  691. $where_add = '';
  692. if ($cklx) {
  693. $shop = $this->shop->read($cklx);
  694. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  695. }
  696. if ($ktime && $jtime) {
  697. $gj = " and enter > '$ktime' and enter < '$jtime'";
  698. $ck = " and outk > '$ktime' and outk < '$jtime'";
  699. }
  700. //数据排序
  701. $order_str = "id desc";
  702. if (empty($page)) {
  703. $start = 0;
  704. $perpage = 1;
  705. } else {
  706. $start = ($page - 1) * $perpage;
  707. }
  708. if ($sku) {
  709. $sku = trim($sku, ' ');
  710. $sku = trim($sku, ' ');
  711. $where .= " and sku like '%$sku%'";
  712. $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);
  713. } else if ($title) {
  714. $title = trim($title, ' ');
  715. $title = trim($title, ' ');
  716. $where .= " and title like '%$title%'";
  717. $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);
  718. } else {
  719. //$where .= " and time > '$ktime' and time < '$jtime'";
  720. $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);
  721. }
  722. //取得信息列表
  723. $rows = array();
  724. $list = array();
  725. foreach ($info_list as $key => $value) {
  726. $warehouse = $this->warehouse->read($value['warehouse']);
  727. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  728. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  729. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  730. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  731. $ftime = time() - 15 * 24 * 3600;
  732. $info_list[$key]['warehouse'] = $warehouse['title'];
  733. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  734. //$z = count($z);//查看订单号
  735. //$info_list[$key]['zd'] = $z;
  736. $details = array();
  737. $cpid = array();
  738. foreach ($c as $k => $v) {
  739. $details[$v['details']] = $v['details'];
  740. if ($v['cpid'] != 0) {
  741. $cpid[$v['cpid']] = $v['cpid'];
  742. }
  743. }
  744. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  745. if ($value['shop'] != '') {
  746. $shop = explode(',', trim($value['shop'], ','));
  747. $shop = $this->shop->read($shop[0]);
  748. $info_list[$key]['shop'] = $shop['shopname'];
  749. }
  750. }
  751. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  752. $pagenum = ceil($total / $perpage);
  753. $over = $total - ($start + $perpage);
  754. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  755. echo json_encode($rows);
  756. exit;
  757. }
  758. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  759. $this->_Template('whlabel_typedy_ck', $this->data);
  760. }
  761. public function _typeck($arg_array)
  762. {
  763. $prc = array();
  764. $purchase = $this->purchase->find_all();
  765. foreach ($purchase as $k => $v) {
  766. $prc[$v['id']] = $v['title'];
  767. }
  768. $post = $this->input->post(NULL, TRUE);
  769. if (isset($post['page'])) {
  770. $page = $this->input->post('page', true);
  771. $perpage = $this->input->post('perpage', true);
  772. $category = $this->input->post('category', true);
  773. $size = $this->input->post('size', true);
  774. $grade = $this->input->post('grade', true);
  775. $color = $this->input->post('color', true);
  776. $lacecolor = $this->input->post('lacecolor', true);
  777. $lowe = $this->input->post('lowe', true);
  778. $sku = $this->input->post('sku');
  779. $title = $this->input->post('title');
  780. $warehouse = 13;
  781. $usa = $this->input->post('usa', true);
  782. $purchase = $this->input->post('purchase', true);
  783. $lacetype = $this->input->post('lacetype', true);
  784. $haircap = $this->input->post('haircap', true);
  785. $density = $this->input->post('density', true);
  786. $details = $this->input->post('details', true);
  787. $state = $this->input->post('state', true);
  788. $ktime = $this->input->post('ktime', true);
  789. $jtime = $this->input->post('jtime', true);
  790. $ktime = strtotime($ktime);
  791. $jtime = strtotime($jtime);
  792. $where = "1=1";
  793. $gj = "";
  794. $ck = "";
  795. if ($lacetype) {
  796. $where .= " and features like '%-$lacetype-%'";
  797. }
  798. if ($category) {
  799. $where .= " and features like '%-$category-%'";
  800. }
  801. if ($size) {
  802. $where .= " and features like '%-$size-%'";
  803. }
  804. if ($grade) {
  805. $where .= " and features like '%-$grade-%'";
  806. }
  807. if ($color) {
  808. $where .= " and features like '%-$color-%'";
  809. }
  810. if ($lacecolor) {
  811. $where .= " and features like '%-$lacecolor-%'";
  812. }
  813. if ($lowe) {
  814. $where .= " and features like '%-$lowe-%'";
  815. }
  816. if ($haircap) {
  817. $where .= " and features like '%-$haircap-%'";
  818. }
  819. if ($density) {
  820. $where .= " and features like '%-$density-%'";
  821. }
  822. if ($warehouse) {
  823. $where .= " and warehouse = '$warehouse'";
  824. }
  825. if ($details) {
  826. $where .= " and details = '$details'";
  827. }
  828. if ($purchase) {
  829. $where .= " and purchase = '$purchase'";
  830. }
  831. if ($state) {
  832. $where .= " and state = '$state'";
  833. }
  834. if ($ktime && $jtime) {
  835. $gj = " and enter > '$ktime' and enter < '$jtime'";
  836. $ck = " and outk > '$ktime' and outk < '$jtime'";
  837. }
  838. //数据排序
  839. $order_str = "id desc";
  840. if (empty($page)) {
  841. $start = 0;
  842. $perpage = 1;
  843. } else {
  844. $start = ($page - 1) * $perpage;
  845. }
  846. if ($sku) {
  847. $sku = trim($sku, ' ');
  848. $sku = trim($sku, ' ');
  849. $where .= " and sku like '%$sku%'";
  850. } else if ($title) {
  851. $title = trim($title, ' ');
  852. $title = trim($title, ' ');
  853. $where .= " and title like '%$title%'";
  854. }
  855. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  856. //取得信息列表
  857. $t = array();
  858. $typeclass = $this->typeclass->find_all();
  859. foreach ($typeclass as $v) {
  860. $t[$v['id']] = $v;
  861. }
  862. $rows = array();
  863. $list = array();
  864. foreach ($info_list as $key => $value) {
  865. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  866. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  867. $warehouse = $this->warehouse->read($value['warehouse']);
  868. $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');
  869. $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'] . '"');
  870. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  871. $number = $value['number'];
  872. $ftime = time() - 15 * 24 * 3600;
  873. $z = count($z); //查看订单号
  874. $info_list[$key]['warehouse'] = $warehouse['title'];
  875. $info_list[$key]['features'] = count($c);
  876. $info_list[$key]['number'] = $z;
  877. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  878. $details = array();
  879. $cpid = array();
  880. foreach ($c as $k => $v) {
  881. $details[$v['details']] = $v['details'];
  882. if ($v['cpid'] != 0) {
  883. $cpid[$v['cpid']] = $v['cpid'];
  884. }
  885. }
  886. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  887. $classid = $this->classid->sku();
  888. $pm = $classid;
  889. $features = explode('-', trim($value['features'], '-'));
  890. foreach ($features as $v) {
  891. $zh = explode('|', trim($t[$v]['zh'], '|'));
  892. $pm[$t[$v]['classid']] = $zh[0];
  893. }
  894. $zh = implode(" ", $pm);
  895. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  896. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  897. $info_list[$key]['sm'] = $zh;
  898. }
  899. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  900. $pagenum = ceil($total / $perpage);
  901. $over = $total - ($start + $perpage);
  902. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  903. echo json_encode($rows);
  904. exit;
  905. }
  906. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  907. $this->_Template('whlabel_typeck', $this->data);
  908. }
  909. //进销存导出
  910. public function _whlabeckdc()
  911. {
  912. $prc = array();
  913. $purchase = $this->purchase->find_all();
  914. foreach ($purchase as $k => $v) {
  915. $prc[$v['id']] = $v['title'];
  916. }
  917. if (isset($_GET['excel'])) {
  918. $where = "sku != 'Preset'";
  919. //数据排序
  920. $order_str = "id desc";
  921. if (empty($page)) {
  922. $start = 0;
  923. $perpage = 1;
  924. } else {
  925. $start = ($page - 1) * $perpage;
  926. }
  927. $category = $this->input->get('category', true);
  928. $color = $this->input->get('color', true);
  929. $lowe = $this->input->get('lowe', true);
  930. $lacetype = $this->input->get('lacetype', true);
  931. $size = $this->input->get('size', true);
  932. $density = $this->input->get('density', true);
  933. $haircap = $this->input->get('haircap', true);
  934. $sku = $this->input->get('sku', true);
  935. $details = $this->input->get('details', true);
  936. $warehouse = 13;
  937. $excelid = $this->input->get('sid', true);
  938. if ($category) {
  939. $where .= " and features like '%-$category-%'";
  940. }
  941. if ($color) {
  942. $where .= " and features like '%-$color-%'";
  943. }
  944. if ($lowe) {
  945. $where .= " and features like '%-$lowe-%'";
  946. }
  947. if ($lacetype) {
  948. $where .= " and features like '%-$lacetype-%'";
  949. }
  950. if ($size) {
  951. $where .= " and features like '%-$size-%'";
  952. }
  953. if ($density) {
  954. $where .= " and features like '%-$density-%'";
  955. }
  956. if ($haircap) {
  957. $where .= " and features like '%-$haircap-%'";
  958. }
  959. if ($warehouse) {
  960. $where .= " and warehouse = '$warehouse'";
  961. }
  962. if ($sku) {
  963. $where .= " and sku like '%$sku%'";
  964. }
  965. if ($details) {
  966. $where .= " and details = '$details'";
  967. }
  968. $xzid = '';
  969. if ($excelid) {
  970. $excelid = explode(',', trim($excelid, ','));
  971. foreach ($excelid as $key => $value) {
  972. $xzid .= " id = " . $value . " or";
  973. }
  974. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  975. }
  976. //取得信息列表
  977. /**
  978. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  979. $rows = array();$list = array();
  980. foreach ($info_list as $key=>$value)
  981. {
  982. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  983. }
  984. **/
  985. $wh = array();
  986. $w = $this->warehouse->find_all('1=1', 'id,title');
  987. foreach ($w as $v) {
  988. $wh[$v['id']] = $v['title'];
  989. }
  990. $tc = array();
  991. $tcdata = array();
  992. $typeclass = $this->typeclass->find_all();
  993. foreach ($typeclass as $v) {
  994. $tc[$v['id']] = $v;
  995. }
  996. $list = array();
  997. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  998. foreach ($rows as $key => $value) {
  999. $bm = '03';
  1000. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  1001. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1002. $classid = $this->classid->sku();
  1003. $pm = $classid;
  1004. $jm = $classid;
  1005. $features = explode('-', trim($value['features'], '-'));
  1006. foreach ($features as $v) {
  1007. if (isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']])) {
  1008. if ($tc[$v]['bm'] != '') {
  1009. $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
  1010. }
  1011. }
  1012. if (isset($tc[$v])) {
  1013. $zh = explode('|', trim($tc[$v]['zh'], '|'));
  1014. $pm[$tc[$v]['classid']] = $zh[0];
  1015. }
  1016. if (isset($tc[$v])) {
  1017. if (isset($jm[$tc[$v]['classid']])) {
  1018. $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
  1019. }
  1020. }
  1021. }
  1022. $zh = implode(" ", $pm);
  1023. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  1024. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1025. $rows[$key]['dbcontent'] = $zh;
  1026. $rows[$key]['cpbz'] = $bm . implode("", $bmpx);
  1027. $jm = array_filter($jm);
  1028. $rows[$key]['cs'] = implode("-", $jm);
  1029. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1030. $details = array();
  1031. $cpid = array();
  1032. $cpbz = array();
  1033. $c = 0;
  1034. $g = 0;
  1035. $x = 0;
  1036. $t = 0;
  1037. $s = 0;
  1038. $q = 0;
  1039. foreach ($sd as $k => $v) {
  1040. if ($v['state'] == 0) {
  1041. $c++;
  1042. }
  1043. if ($v['state'] != 9) {
  1044. $g++;
  1045. }
  1046. if ($v['state'] == 1) {
  1047. $x++;
  1048. }
  1049. if ($v['state'] == 2) {
  1050. $t++;
  1051. }
  1052. if ($v['state'] == 8) {
  1053. $s++;
  1054. }
  1055. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1056. $q++;
  1057. }
  1058. $details[$v['details']] = $v['details'];
  1059. if ($v['cpid'] != 0) {
  1060. $cpid[$v['cpid']] = $v['cpid'];
  1061. }
  1062. if ($v['cpbz'] != '') {
  1063. $cpbz[$v['cpbz']] = $v['cpbz'];
  1064. }
  1065. }
  1066. $rows[$key]['details'] = implode("、", $details);
  1067. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1068. $number = $value['number'];
  1069. $ftime = time() - 15 * 24 * 3600;
  1070. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1071. $rows[$key]['number'] = $g;
  1072. $rows[$key]['features'] = $c;
  1073. $rows[$key]['x'] = $x;
  1074. $rows[$key]['t'] = $t;
  1075. $rows[$key]['s'] = $s;
  1076. $rows[$key]['q'] = $q;
  1077. $rows[$key]['wzsl'] = count($details);
  1078. }
  1079. $title = "进销存统计表" . date('Y-m-d', time());
  1080. $titlename = "<table border=1>
  1081. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1082. <tr align='center'>
  1083. <td>仓库</td>
  1084. <td>供应商</td>
  1085. <td>位置</td>
  1086. <td>库存编码</td>
  1087. <td>SKU</td>
  1088. <td>用友编码</td>
  1089. <td>用友料号</td>
  1090. <td>产品英文名</td>
  1091. <td>产品中文名</td>
  1092. <td>入库总量</td>
  1093. <td>库存数量</td>
  1094. <td>销售数量</td>
  1095. <td>退货数量</td>
  1096. <td>删除数量</td>
  1097. <td>其它操作</td>
  1098. <td>位置数量</td>
  1099. </tr>
  1100. </table>";
  1101. $filename = $title . ".xls";
  1102. $tail = "";
  1103. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1104. }
  1105. }
  1106. public function _type()
  1107. {
  1108. $vip = 0;
  1109. if (isset($_SESSION['api'])) {
  1110. $user = $this->user->get_api($_SESSION['api']);
  1111. $fgshop = "";
  1112. $sid = "";
  1113. $usersp = explode('|', trim($user['shop'], '|'));
  1114. foreach ($usersp as $value) {
  1115. $fgshop .= " shop = " . $value . " or";
  1116. $sid .= " id = " . $value . " or";
  1117. }
  1118. if ($user['vip'] == 1) {
  1119. $vip = 1;
  1120. }
  1121. } else {
  1122. header('Location: /');
  1123. exit;
  1124. }
  1125. $prc = array();
  1126. $purchase = $this->purchase->find_all();
  1127. foreach ($purchase as $k => $v) {
  1128. $prc[$v['id']] = $v['title'];
  1129. }
  1130. $company = array();
  1131. $ct = $this->company->find_all();
  1132. foreach ($ct as $k => $v) {
  1133. $company[$v['id']] = $v['title'];
  1134. }
  1135. $sp = array();
  1136. $s = $this->shop->find_all('1=1', 'id,shopname');
  1137. foreach ($s as $v) {
  1138. $sp[$v['id']] = $v['shopname'];
  1139. }
  1140. $wh = array();
  1141. $w = $this->warehouse->find_all('1=1', 'id,title');
  1142. foreach ($w as $v) {
  1143. $wh[$v['id']] = $v['title'];
  1144. }
  1145. $post = $this->input->post(NULL, TRUE);
  1146. if (isset($post['page'])) {
  1147. $page = $this->input->post('page', true);
  1148. $perpage = $this->input->post('perpage', true);
  1149. $category = $this->input->post('category', true);
  1150. $size = $this->input->post('size', true);
  1151. $grade = $this->input->post('grade', true);
  1152. $color = $this->input->post('color', true);
  1153. $lowe = $this->input->post('lowe', true);
  1154. $sku = $this->input->post('sku');
  1155. $title = $this->input->post('title');
  1156. $warehouse = $this->input->post('warehouse', true);
  1157. $usa = $this->input->post('usa', true);
  1158. $purchase = $this->input->post('purchase', true);
  1159. $lacetype = $this->input->post('lacetype', true);
  1160. $haircap = $this->input->post('haircap', true);
  1161. $density = $this->input->post('density', true);
  1162. $details = $this->input->post('details', true);
  1163. $state = $this->input->post('state', true);
  1164. $shop = $this->input->post('shop', true);
  1165. $lacecolor = $this->input->post('lacecolor', true);
  1166. $hairnumber = $this->input->post('hairnumber', true);
  1167. $type = $this->input->post('type', true);
  1168. $ktime = $this->input->post('ktime', true);
  1169. $jtime = $this->input->post('jtime', true);
  1170. $ktime = strtotime($ktime);
  1171. $jtime = strtotime($jtime);
  1172. $cpbz = $this->input->post('cpbz', true);
  1173. $where = "1=1";
  1174. $gj = "";
  1175. $ck = "";
  1176. if ($usa) {
  1177. if (!$warehouse) {
  1178. $where .= " and (warehouse = '5' or warehouse = '8')";
  1179. }
  1180. }
  1181. if ($warehouse) {
  1182. $where .= " and warehouse = '$warehouse'";
  1183. }
  1184. if ($details) {
  1185. $where .= " and details = '$details'";
  1186. }
  1187. if ($purchase) {
  1188. $where .= " and purchase = '$purchase'";
  1189. }
  1190. if ($state) {
  1191. $where .= " and state = '$state'";
  1192. }
  1193. if ($shop) {
  1194. $where .= " and shop like '%$shop%'";
  1195. }
  1196. if ($type) {
  1197. $where .= " and type = '$type'";
  1198. }
  1199. if ($ktime && $jtime) {
  1200. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1201. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1202. }
  1203. if ($cpbz) {
  1204. $where .= " and cpbz like '%$cpbz%' ";
  1205. }
  1206. if ($lacecolor) {
  1207. $where .= " and features like '%-$lacecolor-%'";
  1208. }
  1209. if ($lacetype) {
  1210. $where .= " and features like '%-$lacetype-%'";
  1211. }
  1212. if ($category) {
  1213. $where .= " and features like '%-$category-%'";
  1214. }
  1215. if ($size) {
  1216. $where .= " and features like '%-$size-%'";
  1217. }
  1218. if ($grade) {
  1219. $where .= " and features like '%-$grade-%'";
  1220. }
  1221. if ($color) {
  1222. $where .= " and features like '%-$color-%'";
  1223. }
  1224. if ($lowe) {
  1225. $where .= " and features like '%-$lowe-%'";
  1226. }
  1227. if ($haircap) {
  1228. $where .= " and features like '%-$haircap-%'";
  1229. }
  1230. if ($density) {
  1231. $where .= " and features like '%-$density-%'";
  1232. }
  1233. if (!empty($hairnumber)) {
  1234. $where .= " and features like '%-128-%' ";
  1235. if ($hairnumber < 0) {
  1236. $class_list = $this->typeclass->find_all('classid = 43');
  1237. foreach ($class_list as $v) {
  1238. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1239. }
  1240. } else {
  1241. $where .= " and features like '%-$hairnumber-%'";
  1242. }
  1243. }
  1244. //数据排序
  1245. $order_str = "id desc";
  1246. if (empty($page)) {
  1247. $start = 0;
  1248. $perpage = 1;
  1249. } else {
  1250. $start = ($page - 1) * $perpage;
  1251. }
  1252. $fjnr = '';
  1253. if ($sku) {
  1254. $sku = trim($sku, ' ');
  1255. $sku = trim($sku, ' ');
  1256. $fjnr .= " and sku like '%$sku%'";
  1257. }
  1258. if ($title) {
  1259. $title = trim($title, ' ');
  1260. $title = trim($title, ' ');
  1261. $fjnr .= " and title like '%$title%'";
  1262. }
  1263. $wt = array();
  1264. $whlabel_type = $this->whlabel_type->find_all();
  1265. foreach ($whlabel_type as $v) {
  1266. $wt[$v['id']] = $v['title'];
  1267. }
  1268. //$where .= " and time > '$ktime' and time < '$jtime'";
  1269. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1270. //取得信息列表
  1271. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1272. $rows = array();
  1273. $list = array();
  1274. foreach ($info_list as $key => $value) {
  1275. if (isset($wt[$value['type']])) {
  1276. $info_list[$key]['type'] = $wt[$value['type']];
  1277. } else {
  1278. $info_list[$key]['type'] = '未设置';
  1279. }
  1280. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1281. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1282. $ztdata = '';
  1283. if (count($zt) > 0) {
  1284. foreach ($zt as $vv) {
  1285. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1286. }
  1287. }
  1288. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1289. $cdata = array_filter($qbdata, function ($item) {
  1290. return $item['state'] < 1;
  1291. });
  1292. $c = array_sum(array_column($cdata, 'jnum'));
  1293. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1294. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1295. });
  1296. $g = array_sum(array_column($gdata, 'jnum'));
  1297. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1298. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1299. });
  1300. $x = array_sum(array_column($xdata, 'jnum'));
  1301. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1302. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1303. });
  1304. $t = array_sum(array_column($tdata, 'jnum'));
  1305. $zdata = array_filter($qbdata, function ($item) {
  1306. return $item['zd'] != "" && $item['state'] < 1;
  1307. });
  1308. $z = array_sum(array_column($zdata, 'jnum'));
  1309. $zdata = array_filter($qbdata, function ($item) {
  1310. return $item['zd'] != "" && $item['state'] < 1;
  1311. });
  1312. $z = array_sum(array_column($zdata, 'jnum'));
  1313. //$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');
  1314. //$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'].'"');
  1315. //$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'].'"');
  1316. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1317. //$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'].'"');
  1318. $details = array();
  1319. $cpid = array();
  1320. $od = array();
  1321. $odid = '';
  1322. $companytitle = '';
  1323. foreach ($qbdata as $v) {
  1324. if ($v['zd'] != "" && $v['state'] < 1) {
  1325. if (!isset($od[$v['zd']])) {
  1326. $od[$v['zd']] = 1; //所有数据sku
  1327. } else {
  1328. $od[$v['zd']] = $od[$v['zd']] + 1;
  1329. }
  1330. }
  1331. if ($v['state'] < 1) {
  1332. $details[$v['details']] = $v['details'];
  1333. if ($v['cpid'] != 0) {
  1334. $cpid[$v['cpid']] = $v['cpid'];
  1335. }
  1336. }
  1337. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1338. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1339. }
  1340. }
  1341. foreach ($od as $k => $vv) {
  1342. $odid .= $k . '数量' . $vv;
  1343. }
  1344. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  1345. $number = $value['number'];
  1346. $ftime = time() - 15 * 24 * 3600;
  1347. $z = $z . '(' . $odid . ')'; //查看订单号
  1348. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1349. $info_list[$key]['features'] = $c;
  1350. $info_list[$key]['number'] = $ztdata;
  1351. $info_list[$key]['sm'] = $g;
  1352. $info_list[$key]['x'] = $x;
  1353. $info_list[$key]['t'] = $t;
  1354. $info_list[$key]['z'] = $z;
  1355. /**
  1356. foreach ($cdata as $k=>$v)
  1357. {
  1358. $details[$v['details']] = $v['details'];
  1359. if($v['cpid'] != 0)
  1360. {
  1361. $cpid[$v['cpid']] = $v['cpid'];
  1362. }
  1363. }
  1364. **/
  1365. $info_list[$key]['shop'] = '';
  1366. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1367. if ($value['shop'] != '') {
  1368. $shop = explode(',', trim($value['shop'], ','));
  1369. $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1370. }
  1371. $info_list[$key]['shop'] .= $companytitle;
  1372. /**
  1373. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1374. if(isset($companytitle[0]))
  1375. {
  1376. foreach ($companytitle as $k=>$v)
  1377. {
  1378. if($v['companytitle'] != '')
  1379. {
  1380. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1381. }
  1382. }
  1383. }
  1384. **/
  1385. }
  1386. $final_all_list = [];
  1387. foreach ($info_list as $k => $v) {
  1388. $final_all_list[] = [
  1389. 'id' => $v['id'],
  1390. "warehouse" => $v["warehouse"],
  1391. "purchase" => $v["purchase"],
  1392. "sku" => $v["sku"],
  1393. "title" => $v["title"] . "<br/>" . $v["pm"],
  1394. "details" => $v["details"],
  1395. "shop" => $v["shop"],
  1396. "cpbz" => $v["cpbz"],
  1397. "type" => $v["type"],
  1398. "features" => $v["features"],
  1399. "number" => $v["number"],
  1400. "sm" => $v["sm"],
  1401. "x" => $v["x"],
  1402. "t" => $v["t"],
  1403. "z" => $v["z"]
  1404. ];
  1405. }
  1406. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1407. $pagenum = ceil($total / $perpage);
  1408. $over = $total - ($start + $perpage);
  1409. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1410. echo json_encode($rows);
  1411. exit;
  1412. }
  1413. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1414. $this->data['shop'] = $wlshop;
  1415. $this->data['vip'] = $vip;
  1416. $this->_Template('whlabel_type', $this->data);
  1417. }
  1418. //美仓进销存浏览
  1419. public function _usatype()
  1420. {
  1421. if (isset($_SESSION['api'])) {
  1422. $user = $this->user->get_api($_SESSION['api']);
  1423. $usp = $user;
  1424. $fgshop = "";
  1425. $sid = "";
  1426. $wid = "";
  1427. $wtype = "";
  1428. $userwh = explode('|', trim($user['warehouse'], '|'));
  1429. foreach ($userwh as $value) {
  1430. $wid .= " id = " . $value . " or";
  1431. $wtype .= " type = " . $value . " or";
  1432. }
  1433. }
  1434. $prc = array();
  1435. $purchase = $this->purchase->find_all();
  1436. foreach ($purchase as $k => $v) {
  1437. $prc[$v['id']] = $v['title'];
  1438. }
  1439. $post = $this->input->post(NULL, TRUE);
  1440. if (isset($post['page'])) {
  1441. $page = $this->input->post('page', true);
  1442. $perpage = $this->input->post('perpage', true);
  1443. $category = $this->input->post('category', true);
  1444. $size = $this->input->post('size', true);
  1445. $grade = $this->input->post('grade', true);
  1446. $color = $this->input->post('color', true);
  1447. $lowe = $this->input->post('lowe', true);
  1448. $sku = $this->input->post('sku');
  1449. $title = $this->input->post('title');
  1450. $warehouse = $this->input->post('warehouse', true);
  1451. $usa = $this->input->post('usa', true);
  1452. $purchase = $this->input->post('purchase', true);
  1453. $lacetype = $this->input->post('lacetype', true);
  1454. $haircap = $this->input->post('haircap', true);
  1455. $density = $this->input->post('density', true);
  1456. $details = $this->input->post('details', true);
  1457. $state = $this->input->post('state', true);
  1458. $lacecolor = $this->input->post('lacecolor', true);
  1459. $cklx = $this->input->post('cklx', true);
  1460. $ktime = $this->input->post('ktime', true);
  1461. $jtime = $this->input->post('jtime', true);
  1462. $ktime = strtotime($ktime);
  1463. $jtime = strtotime($jtime);
  1464. $where = "1=1";
  1465. $gj = "";
  1466. $ck = "";
  1467. if ($lacetype) {
  1468. $where .= " and features like '%-$lacetype-%'";
  1469. }
  1470. if ($category) {
  1471. $where .= " and features like '%-$category-%'";
  1472. }
  1473. if ($size) {
  1474. $where .= " and features like '%-$size-%'";
  1475. }
  1476. if ($grade) {
  1477. $where .= " and features like '%-$grade-%'";
  1478. }
  1479. if ($color) {
  1480. $where .= " and features like '%-$color-%'";
  1481. }
  1482. if ($lowe) {
  1483. $where .= " and features like '%-$lowe-%'";
  1484. }
  1485. if ($haircap) {
  1486. $where .= " and features like '%-$haircap-%'";
  1487. }
  1488. if ($density) {
  1489. $where .= " and features like '%-$density-%'";
  1490. }
  1491. if ($lacecolor) {
  1492. $where .= " and features like '%-$lacecolor-%'";
  1493. }
  1494. if ($usa) {
  1495. if (!$warehouse) {
  1496. $where .= " and (warehouse = '5' or warehouse = '8')";
  1497. }
  1498. }
  1499. if ($warehouse) {
  1500. $where .= " and warehouse = '$warehouse'";
  1501. }
  1502. if ($details) {
  1503. $where .= " and details = '$details'";
  1504. }
  1505. if ($purchase) {
  1506. $where .= " and purchase = '$purchase'";
  1507. }
  1508. if ($state) {
  1509. $where .= " and state = '$state'";
  1510. }
  1511. $where_add = '';
  1512. if ($cklx) {
  1513. $shop = $this->shop->read($cklx);
  1514. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1515. }
  1516. if ($ktime && $jtime) {
  1517. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1518. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1519. }
  1520. //数据排序
  1521. $order_str = "id desc";
  1522. if (empty($page)) {
  1523. $start = 0;
  1524. $perpage = 1;
  1525. } else {
  1526. $start = ($page - 1) * $perpage;
  1527. }
  1528. if ($sku) {
  1529. $sku = trim($sku, ' ');
  1530. $sku = trim($sku, ' ');
  1531. $where .= " and sku like '%$sku%'";
  1532. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1533. } else if ($title) {
  1534. $title = trim($title, ' ');
  1535. $title = trim($title, ' ');
  1536. $where .= " and title like '%$title%'";
  1537. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1538. } else {
  1539. //$where .= " and time > '$ktime' and time < '$jtime'";
  1540. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1541. }
  1542. //取得信息列表
  1543. $rows = array();
  1544. $list = array();
  1545. foreach ($info_list as $key => $value) {
  1546. $warehouse = $this->warehouse->read($value['warehouse']);
  1547. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1548. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1549. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1550. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1551. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1552. $od = array();
  1553. $odid = '';
  1554. foreach ($z as $v) {
  1555. if (!isset($od[$v['zd']])) {
  1556. $od[$v['zd']] = 1; //所有数据sku
  1557. } else {
  1558. $od[$v['zd']] = $od[$v['zd']] + 1;
  1559. }
  1560. }
  1561. foreach ($od as $k => $vv) {
  1562. $odid .= $k . '数量' . $vv . ' ';
  1563. }
  1564. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1565. $info_list[$key]['features'] = $c;
  1566. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1567. $ztdata = '';
  1568. if (count($zt) > 0) {
  1569. foreach ($zt as $vv) {
  1570. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1571. }
  1572. }
  1573. $info_list[$key]['warehouse'] = $ztdata;
  1574. $info_list[$key]['g'] = $g;
  1575. $info_list[$key]['x'] = $x;
  1576. $info_list[$key]['t'] = $t;
  1577. $info_list[$key]['z'] = $z;
  1578. }
  1579. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1580. $pagenum = ceil($total / $perpage);
  1581. $over = $total - ($start + $perpage);
  1582. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1583. echo json_encode($rows);
  1584. exit;
  1585. }
  1586. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1587. $this->data['warehouse'] = $warehouse;
  1588. $this->_Template('whlabel_typeusa', $this->data);
  1589. }
  1590. //美仓进销存浏览
  1591. public function _usatypeapp()
  1592. {
  1593. $post = $this->input->post(NULL, TRUE);
  1594. if (isset($post['page'])) {
  1595. $page = $this->input->post('page', true);
  1596. $perpage = $this->input->post('perpage', true);
  1597. $sku = $this->input->post('sku', true);
  1598. $warehouse = 5;
  1599. $title = $this->input->post('title', true);
  1600. $state = $this->input->post('state', true);
  1601. $ktime = $this->input->post('ktime', true);
  1602. $jtime = $this->input->post('jtime', true);
  1603. $ktime = strtotime($ktime);
  1604. $jtime = strtotime($jtime);
  1605. $where = "1=1";
  1606. $gj = "";
  1607. $ck = "";
  1608. if ($title) {
  1609. $st = explode(' ', trim($title, ' '));
  1610. foreach ($st as $v) {
  1611. $where .= " and title like '%$v%'";
  1612. }
  1613. }
  1614. if ($warehouse) {
  1615. $where .= " and warehouse = '$warehouse'";
  1616. }
  1617. if ($state) {
  1618. $where .= " and state = '$state'";
  1619. }
  1620. if ($sku) {
  1621. $where .= " and sku like '%$sku%'";
  1622. }
  1623. if ($ktime && $jtime) {
  1624. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1625. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1626. }
  1627. //数据排序
  1628. $order_str = "id desc";
  1629. if (empty($page)) {
  1630. $start = 0;
  1631. $perpage = 1;
  1632. } else {
  1633. $start = ($page - 1) * $perpage;
  1634. }
  1635. //取得信息列表
  1636. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1637. $rows = array();
  1638. $list = array();
  1639. foreach ($info_list as $key => $value) {
  1640. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1641. }
  1642. $rowsdq = array_slice($rows, $start, $perpage);
  1643. foreach ($rowsdq as $value) {
  1644. $warehouse = $this->warehouse->read($value['warehouse']);
  1645. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1646. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1647. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1648. $od = array();
  1649. $odid = '';
  1650. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1651. }
  1652. $total = count($rows);
  1653. $pagenum = ceil($total / $perpage);
  1654. $over = $total - ($start + $perpage);
  1655. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1656. echo json_encode($rows);
  1657. exit;
  1658. }
  1659. $this->_Template('phone/p_usatypeapp', $this->data);
  1660. }
  1661. //入库操作
  1662. public function _enteradd()
  1663. {
  1664. $dt = 0;
  1665. if (isset($_SESSION['api'])) {
  1666. $user = $this->user->get_api($_SESSION['api']);
  1667. $usp = $user;
  1668. $fgshop = "";
  1669. $sid = "";
  1670. $user = explode('|', trim($user['shop'], '|'));
  1671. foreach ($user as $value) {
  1672. $fgshop .= " shop = " . $value . " or";
  1673. $sid .= " id = " . $value . " or";
  1674. }
  1675. }
  1676. $tc = $this->typeclass->find_all();
  1677. $typeclass = array();
  1678. foreach ($tc as $v) {
  1679. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1680. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1681. }
  1682. $post = $this->input->post(NULL, TRUE);
  1683. if (isset($post['sku'])) {
  1684. $list = array();
  1685. $num = "";
  1686. $title = "";
  1687. $features = "";
  1688. $order = $this->input->post('order', true);
  1689. $shop = $this->input->post('shop', true);
  1690. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1691. $sku = $this->input->post('sku', true);
  1692. $post['sm'] = $this->input->post('sm', true);
  1693. $post['warehouse'] = $this->input->post('warehouse', true);
  1694. $post['purchase'] = $this->input->post('purchase', true);
  1695. $post['retreatwarehouse'] = $post['warehouse'];
  1696. $post['state'] = $this->input->post('state', true);
  1697. $post['rktype'] = $this->input->post('rktype', true);
  1698. $post['text'] = $this->input->post('text', true);
  1699. $category = $this->input->post('category', true);
  1700. $list['category'] = $category;
  1701. $list['hairtype'] = $this->input->post('hairtype', true);
  1702. $list['grade'] = $this->input->post('grade', true);
  1703. $size = $this->input->post('size', true);
  1704. $xzsku = $this->input->post('xzsku', true);
  1705. $list['size'] = rtrim($size, ',');
  1706. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1707. $list['extension'] = $this->input->post('extension', true);
  1708. if ($category == 1297) {
  1709. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1710. }
  1711. if ($category == 1702) {
  1712. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1713. $list['syother'] = $this->input->post('syother', true);
  1714. }
  1715. if ($category == 133) {
  1716. $list['fittype'] = $this->input->post('fittype', true);
  1717. $list['acother'] = $this->input->post('acother', true);
  1718. }
  1719. $list['color'] = $this->input->post('color', true);
  1720. $list['lowe'] = $this->input->post('lowe', true);
  1721. if (!$post['purchase']) {
  1722. $post['purchase'] = 1;
  1723. }
  1724. if ($category == 127) {
  1725. $list['type'] = $this->input->post('type', true);
  1726. $list['headroad'] = $this->input->post('headroad', true);
  1727. $list['density'] = $this->input->post('density', true);
  1728. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1729. $list['lacesize'] = $this->input->post('lacesize', true);
  1730. }
  1731. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1732. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1733. }
  1734. if ($category == 128) {
  1735. $list['lacetype'] = $this->input->post('lacetype', true);
  1736. $list['haircap'] = $this->input->post('haircap', true);
  1737. $list['density'] = $this->input->post('density', true);
  1738. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1739. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1740. $list['wigother'] = $this->input->post('wigother', true);
  1741. $list['wigother1'] = $this->input->post('wigother1', true);
  1742. $list['wigother2'] = $this->input->post('wigother2', true);
  1743. }
  1744. if ($category == 129) {
  1745. $list['wide'] = $this->input->post('wide', true);
  1746. }
  1747. if ($category == 131) {
  1748. $list['gifttype'] = $this->input->post('gifttype', true);
  1749. $list['giftother'] = $this->input->post('giftother', true);
  1750. }
  1751. if ($category == 134) {
  1752. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1753. }
  1754. if ($category == 1297) {
  1755. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1756. $list['sywigother'] = $this->input->post('sywigother', true);
  1757. }
  1758. if ($category == 130 || $category == 133 || $category == 1702) {
  1759. $list['items'] = $this->input->post('items', true);
  1760. $list['weight'] = $this->input->post('weight', true);
  1761. }
  1762. if ($category == 1702) {
  1763. $list['syhairther'] = $this->input->post('syhairther', true);
  1764. }
  1765. $classid = $this->classid->sku();
  1766. $scsku = $classid;
  1767. $pm = $classid;
  1768. foreach ($list as $k => $v) {
  1769. if ($v != 0) {
  1770. $num .= $v;
  1771. $features .= $v . '-';
  1772. $post[$k] = $v;
  1773. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1774. if ($k != 'size') {
  1775. $title .= $typeclass[$v]['title'] . " ";
  1776. }
  1777. if (isset($pm[$typeclass[$v]['classid']])) {
  1778. if ($typeclass[$v]['title'] == '9A') {
  1779. $pm[$typeclass[$v]['classid']] = '9A';
  1780. } else if ($typeclass[$v]['title'] == '10A') {
  1781. $pm[$typeclass[$v]['classid']] = '10A';
  1782. } else {
  1783. $clzh = $typeclass[$v]['zh'];
  1784. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1785. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1786. $clzh = $clzh[0];
  1787. }
  1788. $pm[$typeclass[$v]['classid']] = $clzh;
  1789. }
  1790. }
  1791. }
  1792. }
  1793. $zh = implode(" ", $pm);
  1794. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1795. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1796. if ($list['size']) {
  1797. $typeclass = $this->typeclass->read($list['size']);
  1798. $title .= $typeclass['title'];
  1799. }
  1800. $time = time();
  1801. if ($xzsku) {
  1802. $scsku = implode("-", $scsku);
  1803. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1804. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1805. $post['sku'] = trim($scsku, ' ');
  1806. } else {
  1807. $post['sku'] = $sku;
  1808. }
  1809. //$post['sku'] = trim($sku,' ');
  1810. $post['title'] = rtrim($title, ' ');
  1811. $post['number'] = $num;
  1812. $post['features'] = '-' . $features;
  1813. $post['enter'] = $time;
  1814. $post['time'] = $time; //操作时间
  1815. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1816. if ($yza) {
  1817. if ($post['features'] != $yza[0]['features']) {
  1818. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1819. exit;
  1820. }
  1821. }
  1822. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1823. if ($yzb) {
  1824. if ($post['sku'] != $yzb[0]['sku']) {
  1825. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1826. exit;
  1827. }
  1828. }
  1829. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1830. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1831. exit;
  1832. }
  1833. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1834. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1835. exit;
  1836. }
  1837. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1838. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1839. exit;
  1840. }
  1841. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1842. if (isset($yz[0]['type'])) {
  1843. $post['type'] = $yz[0]['type'];
  1844. }
  1845. if ($post['state'] == 9) //如果选择预设库存
  1846. {
  1847. $this->whlabel->insert($post);
  1848. } else {
  1849. /**
  1850. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1851. if($ljg == 1)
  1852. {
  1853. for($i=0;$i<$order;$i++)
  1854. {
  1855. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1856. $this->whlabel->insert($post);
  1857. }
  1858. }
  1859. **/
  1860. //if($post['warehouse'] == '5')
  1861. //{
  1862. //}
  1863. $yydata = $post;
  1864. $yydata['zh'] = $zh;
  1865. /**
  1866. $wl = $this->apiyy->get_cjlp($yydata);
  1867. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1868. {
  1869. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1870. }
  1871. if($wl['Data'][0]['m_isSucess'] != 1)
  1872. {
  1873. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1874. }
  1875. **/
  1876. for ($i = 0; $i < $order; $i++) {
  1877. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1878. $this->whlabel->insert($post);
  1879. }
  1880. }
  1881. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1882. exit;
  1883. }
  1884. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1885. $this->data['wlshop'] = $wlshop;
  1886. $this->_Template('whlabel_enteradd', $this->data);
  1887. }
  1888. //修改产品
  1889. public function _enteredit($arg_array)
  1890. {
  1891. $dt = 0;
  1892. if (isset($_SESSION['api'])) {
  1893. $user = $this->user->get_api($_SESSION['api']);
  1894. $usp = $user;
  1895. $fgshop = "";
  1896. $sid = "";
  1897. $user = explode('|', trim($user['shop'], '|'));
  1898. foreach ($user as $value) {
  1899. $fgshop .= " shop = " . $value . " or";
  1900. $sid .= " id = " . $value . " or";
  1901. }
  1902. }
  1903. $post = $this->input->post(NULL, TRUE);
  1904. if (isset($post['sku'])) {
  1905. $list = array();
  1906. $num = "";
  1907. $title = "";
  1908. $features = "";
  1909. $id = $this->input->post('id', true);
  1910. $order = $this->input->post('order', true);
  1911. $shop = $this->input->post('shop', true);
  1912. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1913. $post['sku'] = $this->input->post('sku', true);
  1914. $post['sm'] = $this->input->post('sm', true);
  1915. $post['warehouse'] = $this->input->post('warehouse', true);
  1916. $post['purchase'] = $this->input->post('purchase', true);
  1917. $post['retreatwarehouse'] = $post['warehouse'];
  1918. $category = $this->input->post('category', true);
  1919. $list['category'] = $category;
  1920. $list['hairtype'] = $this->input->post('hairtype', true);
  1921. $list['grade'] = $this->input->post('grade', true);
  1922. $size = $this->input->post('size', true);
  1923. $list['size'] = rtrim($size, ',');
  1924. $post['rktype'] = $this->input->post('rktype', true);
  1925. $post['text'] = $this->input->post('text', true);
  1926. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1927. $list['extension'] = $this->input->post('extension', true);
  1928. if ($category == 1297) {
  1929. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1930. }
  1931. if ($category == 1702) {
  1932. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1933. $list['syother'] = $this->input->post('syother', true);
  1934. }
  1935. if ($category == 133) {
  1936. $list['fittype'] = $this->input->post('fittype', true);
  1937. $list['acother'] = $this->input->post('acother', true);
  1938. }
  1939. $list['color'] = $this->input->post('color', true);
  1940. $list['lowe'] = $this->input->post('lowe', true);
  1941. if (!$post['purchase']) {
  1942. $post['purchase'] = 1;
  1943. }
  1944. if ($category == 127) {
  1945. $list['type'] = $this->input->post('type', true);
  1946. $list['headroad'] = $this->input->post('headroad', true);
  1947. $list['density'] = $this->input->post('density', true);
  1948. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1949. $list['lacesize'] = $this->input->post('lacesize', true);
  1950. }
  1951. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1952. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1953. }
  1954. if ($category == 128) {
  1955. $list['lacetype'] = $this->input->post('lacetype', true);
  1956. $list['haircap'] = $this->input->post('haircap', true);
  1957. $list['density'] = $this->input->post('density', true);
  1958. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1959. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1960. $list['wigother'] = $this->input->post('wigother', true);
  1961. $list['wigother1'] = $this->input->post('wigother2', true);
  1962. $list['wigother2'] = $this->input->post('wigother2', true);
  1963. }
  1964. if ($category == 129) {
  1965. $list['wide'] = $this->input->post('wide', true);
  1966. }
  1967. if ($category == 131) {
  1968. $list['gifttype'] = $this->input->post('gifttype', true);
  1969. $list['giftother'] = $this->input->post('giftother', true);
  1970. }
  1971. if ($category == 134) {
  1972. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1973. }
  1974. if ($category == 1297) {
  1975. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1976. $list['sywigother'] = $this->input->post('sywigother', true);
  1977. }
  1978. if ($category == 130 || $category == 133 || $category == 1702) {
  1979. $list['items'] = $this->input->post('items', true);
  1980. $list['weight'] = $this->input->post('weight', true);
  1981. }
  1982. if ($category == 1702) {
  1983. $list['syhairther'] = $this->input->post('syhairther', true);
  1984. }
  1985. foreach ($list as $k => $v) {
  1986. if ($v != 0) {
  1987. $num .= $v;
  1988. $features .= $v . '-';
  1989. $typeclass = $this->typeclass->read($v);
  1990. if ($k != 'size') {
  1991. $title .= $typeclass['title'] . " ";
  1992. }
  1993. }
  1994. }
  1995. $typeclass = $this->typeclass->read($list['size']);
  1996. $title .= $typeclass['title'];
  1997. $time = time();
  1998. $post['title'] = rtrim($title, ' ');
  1999. $post['number'] = $num;
  2000. $post['features'] = '-' . $features;
  2001. $post['time'] = $time; //操作时间
  2002. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2003. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2004. exit;
  2005. }
  2006. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2007. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2008. exit;
  2009. }
  2010. $uid = $this->whlabel->read($id);
  2011. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2012. if ($datanum > 0) {
  2013. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2014. exit;
  2015. }
  2016. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2017. {
  2018. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2019. if ($yza) {
  2020. if ($post['features'] != $yza[0]['features']) {
  2021. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2022. exit;
  2023. }
  2024. }
  2025. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2026. if ($yzb) {
  2027. if ($post['sku'] != $yzb[0]['sku']) {
  2028. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2029. exit;
  2030. }
  2031. }
  2032. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2033. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2034. exit;
  2035. }
  2036. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2037. foreach ($data as $v) {
  2038. $post['id'] = $v['id'];
  2039. $this->whlabel->save($post, $v['id']);
  2040. }
  2041. } else {
  2042. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2043. if ($data > 0) {
  2044. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2045. exit;
  2046. } else {
  2047. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2048. foreach ($data as $v) {
  2049. $post['id'] = $v['id'];
  2050. $this->whlabel->save($post, $v['id']);
  2051. }
  2052. }
  2053. }
  2054. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2055. exit;
  2056. }
  2057. $uid = $this->whlabel->read($arg_array[0]);
  2058. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2059. $this->data['enter'] = $uid;
  2060. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2061. $this->data['wlshop'] = $wlshop;
  2062. $this->_Template('whlabel_enteredit', $this->data);
  2063. }
  2064. //入库浏览
  2065. public function _enter()
  2066. {
  2067. $post = $this->input->post(NULL, TRUE);
  2068. if (isset($post['s'])) {
  2069. $id_arr = $this->input->post('s');
  2070. $id_arr = explode(',', $id_arr);
  2071. if (!$id_arr) {
  2072. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2073. exit;
  2074. }
  2075. //循环删除记录
  2076. foreach ($id_arr as $v) {
  2077. $sid = $this->whlabel->read($v);
  2078. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2079. if ($count > 0) {
  2080. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2081. exit;
  2082. }
  2083. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2084. foreach ($info_list as $va) {
  2085. $this->whlabel->remove($va['id']);
  2086. }
  2087. }
  2088. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2089. exit;
  2090. }
  2091. $sp = array();
  2092. $s = $this->shop->find_all('1=1', 'id,shopname');
  2093. foreach ($s as $v) {
  2094. $sp[$v['id']] = $v['shopname'];
  2095. }
  2096. $wh = array();
  2097. $w = $this->warehouse->find_all('1=1', 'id,title');
  2098. foreach ($w as $v) {
  2099. $wh[$v['id']] = $v['title'];
  2100. }
  2101. if (isset($post['page'])) {
  2102. $page = $this->input->post('page', true);
  2103. $perpage = $this->input->post('perpage', true);
  2104. $category = $this->input->post('category', true);
  2105. $size = $this->input->post('size', true);
  2106. $grade = $this->input->post('grade', true);
  2107. $color = $this->input->post('color', true);
  2108. $lowe = $this->input->post('lowe', true);
  2109. $sku = $this->input->post('sku', true);
  2110. $warehouse = $this->input->post('warehouse', true);
  2111. $purchase = $this->input->post('purchase', true);
  2112. $ktime = $this->input->post('ktime', true);
  2113. $jtime = $this->input->post('jtime', true);
  2114. $ktime = strtotime($ktime);
  2115. $jtime = strtotime($jtime);
  2116. $where = "1=1";
  2117. $gj = "";
  2118. $ck = "";
  2119. if ($category) {
  2120. $where .= " and features like '%-$category-%'";
  2121. }
  2122. if ($size) {
  2123. $where .= " and features like '%-$size-%'";
  2124. }
  2125. if ($grade) {
  2126. $where .= " and features like '%-$grade-%'";
  2127. }
  2128. if ($color) {
  2129. $where .= " and features like '%-$color-%'";
  2130. }
  2131. if ($lowe) {
  2132. $where .= " and features like '%-$lowe-%'";
  2133. }
  2134. if ($warehouse) {
  2135. $where .= " and warehouse = '$warehouse'";
  2136. }
  2137. if ($purchase) {
  2138. $where .= " and purchase = '$purchase'";
  2139. }
  2140. if ($sku) {
  2141. $where .= " and sku like '%$sku%'";
  2142. }
  2143. if ($ktime && $jtime) {
  2144. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2145. }
  2146. //数据排序
  2147. $order_str = "enter desc";
  2148. if (empty($page)) {
  2149. $start = 0;
  2150. $perpage = 1;
  2151. } else {
  2152. $start = ($page - 1) * $perpage;
  2153. }
  2154. //取得信息列表
  2155. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2156. foreach ($info_list as $k => $v) {
  2157. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2158. if ($v['shop'] == '') {
  2159. $s = '通用';
  2160. } else {
  2161. $info_list[$k]['shop'] = '';
  2162. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2163. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2164. }
  2165. }
  2166. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2167. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2168. $info_list[$k]['g'] = $g;
  2169. }
  2170. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2171. $pagenum = ceil($total / $perpage);
  2172. $over = $total - ($start + $perpage);
  2173. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2174. echo json_encode($rows);
  2175. exit;
  2176. }
  2177. $this->_Template('whlabel_enter', $this->data);
  2178. }
  2179. //出库浏览
  2180. public function _out()
  2181. {
  2182. $post = $this->input->post(NULL, TRUE);
  2183. if (isset($post['page'])) {
  2184. $page = $this->input->post('page', true);
  2185. $perpage = $this->input->post('perpage', true);
  2186. $category = $this->input->post('category', true);
  2187. $size = $this->input->post('size', true);
  2188. $grade = $this->input->post('grade', true);
  2189. $color = $this->input->post('color', true);
  2190. $lowe = $this->input->post('lowe', true);
  2191. $sku = $this->input->post('sku', true);
  2192. $warehouse = $this->input->post('warehouse', true);
  2193. $purchase = $this->input->post('purchase', true);
  2194. $state = $this->input->post('state', true);
  2195. $ktime = $this->input->post('ktime', true);
  2196. $jtime = $this->input->post('jtime', true);
  2197. $ktime = strtotime($ktime);
  2198. $jtime = strtotime($jtime);
  2199. $where = "state=3";
  2200. $gj = "";
  2201. $ck = "";
  2202. if ($category) {
  2203. $where .= " and features like '%-$category-%'";
  2204. }
  2205. if ($size) {
  2206. $where .= " and features like '%-$size-%'";
  2207. }
  2208. if ($grade) {
  2209. $where .= " and features like '%-$grade-%'";
  2210. }
  2211. if ($color) {
  2212. $where .= " and features like '%-$color-%'";
  2213. }
  2214. if ($lowe) {
  2215. $where .= " and features like '%-$lowe-%'";
  2216. }
  2217. if ($state) {
  2218. $where .= " and state = '$state'";
  2219. }
  2220. if ($warehouse) {
  2221. $where .= " and warehouse = '$warehouse'";
  2222. }
  2223. if ($purchase) {
  2224. $where .= " and purchase = '$purchase'";
  2225. }
  2226. if ($sku) {
  2227. $where .= " and sku = '$sku'";
  2228. }
  2229. if ($ktime && $jtime) {
  2230. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2231. }
  2232. //数据排序
  2233. $order_str = "id desc";
  2234. if (empty($page)) {
  2235. $start = 0;
  2236. $perpage = 1;
  2237. } else {
  2238. $start = ($page - 1) * $perpage;
  2239. }
  2240. //取得信息列表
  2241. $info_list = $this->whlabel->find_all($where, 'sku');
  2242. $rows = array();
  2243. $list = array();
  2244. foreach ($info_list as $key => $value) {
  2245. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2246. }
  2247. $rows = array_unique($rows); //删除重复记录
  2248. foreach ($rows as $key => $value) {
  2249. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2250. $ck = $this->warehouse->read($data['warehouse']);
  2251. $warehouse = $ck['title'];
  2252. $gy = $this->purchase->read($data['purchase']);
  2253. $purchase = $gy['purchase'];
  2254. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2255. $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);
  2256. }
  2257. $total = count($list);
  2258. $pagenum = ceil($total / $perpage);
  2259. $over = $total - ($start + $perpage);
  2260. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2261. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2262. echo json_encode($rows);
  2263. exit;
  2264. }
  2265. $this->_Template('whlabel_out', $this->data);
  2266. }
  2267. //出库标签浏览
  2268. public function _label()
  2269. {
  2270. $post = $this->input->post(NULL, TRUE);
  2271. if (isset($post['page'])) {
  2272. $page = $this->input->post('page', true);
  2273. $perpage = $this->input->post('perpage', true);
  2274. $sku = $this->input->post('sku', true);
  2275. $warehouse = $this->input->post('warehouse', true);
  2276. $purchase = $this->input->post('purchase', true);
  2277. $orderinfo = $this->input->post('orderinfo', true);
  2278. $waybill = $this->input->post('waybill', true);
  2279. $category = $this->input->post('category', true);
  2280. $size = $this->input->post('size', true);
  2281. $grade = $this->input->post('grade', true);
  2282. $color = $this->input->post('color', true);
  2283. $lowe = $this->input->post('lowe', true);
  2284. $where = "state=1";
  2285. if ($sku) {
  2286. $where .= " and sku = '$sku'";
  2287. }
  2288. if ($warehouse) {
  2289. $where .= " and warehouse = '$warehouse'";
  2290. }
  2291. if ($purchase) {
  2292. $where .= " and purchase = '$purchase'";
  2293. }
  2294. if ($orderinfo) {
  2295. $where .= " and orderinfo = '$orderinfo'";
  2296. }
  2297. if ($waybill) {
  2298. $where .= " and waybill = '$waybill'";
  2299. }
  2300. if ($category) {
  2301. $where .= " and features like '%-$category-%'";
  2302. }
  2303. if ($size) {
  2304. $where .= " and features like '%-$size-%'";
  2305. }
  2306. if ($grade) {
  2307. $where .= " and features like '%-$grade-%'";
  2308. }
  2309. if ($color) {
  2310. $where .= " and features like '%-$color-%'";
  2311. }
  2312. if ($lowe) {
  2313. $where .= " and features like '%-$lowe-%'";
  2314. }
  2315. //数据排序
  2316. $order_str = "outk desc";
  2317. if (empty($page)) {
  2318. $start = 0;
  2319. $perpage = 1;
  2320. } else {
  2321. $start = ($page - 1) * $perpage;
  2322. }
  2323. //取得信息列表
  2324. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2325. foreach ($info_list as $key => $value) {
  2326. $warehouse = $this->warehouse->read($value['warehouse']);
  2327. $info_list[$key]['warehouse'] = $warehouse['title'];
  2328. $purchase = $this->purchase->read($value['purchase']);
  2329. $info_list[$key]['purchase'] = $purchase['title'];
  2330. if ($value['outk'] != 0) {
  2331. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2332. } else {
  2333. $info_list[$key]['outk'] = "";
  2334. }
  2335. if ($value['orderinfo'] == 0) {
  2336. $info_list[$key]['orderinfo'] = "";
  2337. }
  2338. if ($value['waybill'] == 0) {
  2339. $info_list[$key]['waybill'] = "";
  2340. }
  2341. }
  2342. $total = $this->whlabel->find_count($where);
  2343. $pagenum = ceil($total / $perpage);
  2344. $over = $total - ($start + $perpage);
  2345. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2346. echo json_encode($rows);
  2347. exit;
  2348. }
  2349. $this->_Template('whlabel_label', $this->data);
  2350. }
  2351. //独立站出库订单
  2352. public function _outorder()
  2353. {
  2354. if (isset($_SESSION['api'])) {
  2355. $user = $this->user->get_api($_SESSION['api']);
  2356. $usp = $user;
  2357. $fgshop = "";
  2358. $sid = "";
  2359. $user = explode('|', trim($user['shop'], '|'));
  2360. foreach ($user as $value) {
  2361. $fgshop .= " shop = " . $value . " or";
  2362. $sid .= " id = " . $value . " or";
  2363. }
  2364. } else {
  2365. echo "请重新登录";
  2366. }
  2367. $post = $this->input->post(NULL, TRUE);
  2368. if (isset($post['page'])) {
  2369. $page = $this->input->post('page', true);
  2370. $perpage = $this->input->post('perpage', true);
  2371. $warehouse = $this->input->post('warehouse', true);
  2372. $xztime = $this->input->post('xztime', true);
  2373. $timetk = $this->input->post('timetkk', true);
  2374. $timetj = $this->input->post('timetjj', true);
  2375. $shop = $this->input->post('shop', true);
  2376. $source = $this->input->post('source', true);
  2377. $orderinfo = $this->input->post('orderinfo', true);
  2378. $number = $this->input->post('number', true);
  2379. $sfxh = $this->input->post('sfxh', true);
  2380. $express = $this->input->post('express', true);
  2381. $waybill = $this->input->post('waybill', true);
  2382. $library = $this->input->post('library', true);
  2383. $country = $this->input->post('country', true);
  2384. $so = $this->input->post('so', true);
  2385. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2386. $print = $this->input->post('print', true);
  2387. $state = $this->input->post('state', true);
  2388. $orderurl = $this->input->post('orderurl', true);
  2389. $timetk = strtotime($timetk);
  2390. $timetj = strtotime($timetj);
  2391. /**
  2392. $sj = $this->input->post('sj',true);
  2393. if($sj)
  2394. {
  2395. $sj = $this->input->post('sj',true);
  2396. }
  2397. else
  2398. {
  2399. $sj = "fullorder";
  2400. }
  2401. **/
  2402. $sj = "fullorder";
  2403. $where = "1=1";
  2404. if ($warehouse) {
  2405. $where .= " and type = '$warehouse'";
  2406. }
  2407. if ($timetk && $timetj) {
  2408. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2409. }
  2410. if ($orderinfo) {
  2411. $where .= " and orderinfo = '$orderinfo'";
  2412. }
  2413. if ($number) {
  2414. $where .= " and number = '$number'";
  2415. }
  2416. if ($express) {
  2417. $where .= " and express = '$express'";
  2418. }
  2419. if ($waybill) {
  2420. $where .= " and waybill = '$waybill'";
  2421. }
  2422. if ($library) {
  2423. $where .= " and library = '$library'";
  2424. }
  2425. if ($print) {
  2426. $where .= " and print = '$print'";
  2427. }
  2428. if ($libraryconfirm) {
  2429. $where .= " and libraryconfirm = '$libraryconfirm'";
  2430. }
  2431. if ($state) {
  2432. $where .= " and state = '$state'";
  2433. }
  2434. if ($shop) {
  2435. $where .= " and shop = '$shop'";
  2436. }
  2437. if ($country) {
  2438. $where .= " and country = '$country'";
  2439. }
  2440. if ($sfxh != '') {
  2441. $where .= " and sfxh = '$sfxh'";
  2442. }
  2443. if ($so) {
  2444. $where .= " and shipremarks like '%$so%'";
  2445. }
  2446. if ($source) {
  2447. if ($source == '2d') {
  2448. $where .= " and source >= '2'";
  2449. } else {
  2450. $where .= " and source = '$source'";
  2451. }
  2452. }
  2453. if (isset($_SESSION['api'])) {
  2454. foreach ($user as $value) {
  2455. $fgshop .= " shop = " . $value . " or";
  2456. }
  2457. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2458. }
  2459. if ($orderurl) {
  2460. $url = $this->orderurl->read($orderurl);
  2461. $where .= " and link like '%" . $url['url'] . "%'";
  2462. }
  2463. //数据排序
  2464. $order_str = "librarytime desc";
  2465. if (empty($page)) {
  2466. $start = 0;
  2467. $perpage = 1;
  2468. } else {
  2469. $start = ($page - 1) * $perpage;
  2470. }
  2471. //取得信息列表
  2472. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2473. //格式化数据
  2474. foreach ($info_list as $key => $value) {
  2475. $shop = $this->shop->read($value['shop']);
  2476. $info_list[$key]['shop'] = $shop['shopname'];
  2477. $express = $this->express->read($value['express']);
  2478. $info_list[$key]['express'] = $express['servicename'];
  2479. $warehouse = $this->warehouse->read($value['type']);
  2480. $info_list[$key]['type'] = $warehouse['title'];
  2481. if ($value['librarytime'] == '0') {
  2482. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2483. } else {
  2484. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2485. }
  2486. }
  2487. $total = $this->$sj->find_count($where);
  2488. $pagenum = ceil($total / $perpage);
  2489. $over = $total - ($start + $perpage);
  2490. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2491. echo json_encode($rows);
  2492. exit;
  2493. }
  2494. $this->data['express'] = $this->express->find_all();
  2495. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2496. $this->data['wlshop'] = $wlshop;
  2497. $user = $this->user->get_api($_SESSION['api']);
  2498. $powerid = $this->power->read($user['power']);
  2499. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2500. $pid = '';
  2501. foreach ($powertext as $v) {
  2502. $pid .= " id = " . $v . " or";
  2503. }
  2504. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2505. $this->data['fullorderexcel'] = $fullorderexcel;
  2506. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2507. $this->data['orderurl'] = $orderurl;
  2508. $this->_Template('whlabel_outorder', $this->data);
  2509. }
  2510. //tt出库
  2511. public function _toutorder()
  2512. {
  2513. if (isset($_SESSION['api'])) {
  2514. $user = $this->user->get_api($_SESSION['api']);
  2515. $usp = $user;
  2516. $fgshop = "";
  2517. $sid = "";
  2518. $user = explode('|', trim($user['shop'], '|'));
  2519. foreach ($user as $value) {
  2520. $fgshop .= " shop = " . $value . " or";
  2521. $sid .= " id = " . $value . " or";
  2522. }
  2523. } else {
  2524. echo "请重新登录";
  2525. }
  2526. $post = $this->input->post(NULL, TRUE);
  2527. if (isset($post['page'])) {
  2528. $page = $this->input->post('page', true);
  2529. $perpage = $this->input->post('perpage', true);
  2530. $warehouse = $this->input->post('warehouse', true);
  2531. $xztime = $this->input->post('xztime', true);
  2532. $timetk = $this->input->post('timetkk', true);
  2533. $timetj = $this->input->post('timetjj', true);
  2534. $shop = $this->input->post('shop', true);
  2535. $source = $this->input->post('source', true);
  2536. $orderinfo = $this->input->post('orderinfo', true);
  2537. $number = $this->input->post('number', true);
  2538. $sfxh = $this->input->post('sfxh', true);
  2539. $express = $this->input->post('express', true);
  2540. $waybill = $this->input->post('waybill', true);
  2541. $library = $this->input->post('library', true);
  2542. $country = $this->input->post('country', true);
  2543. $so = $this->input->post('so', true);
  2544. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2545. $print = $this->input->post('print', true);
  2546. $state = $this->input->post('state', true);
  2547. $orderurl = $this->input->post('orderurl', true);
  2548. $timetk = strtotime($timetk);
  2549. $timetj = strtotime($timetj);
  2550. /**
  2551. $sj = $this->input->post('sj',true);
  2552. if($sj)
  2553. {
  2554. $sj = $this->input->post('sj',true);
  2555. }
  2556. else
  2557. {
  2558. $sj = "fullorder";
  2559. }
  2560. **/
  2561. $sj = "fullordertt";
  2562. $where = "1=1";
  2563. if ($warehouse) {
  2564. $where .= " and type = '$warehouse'";
  2565. }
  2566. if ($timetk && $timetj) {
  2567. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2568. }
  2569. if ($orderinfo) {
  2570. $where .= " and orderinfo = '$orderinfo'";
  2571. }
  2572. if ($number) {
  2573. $where .= " and number = '$number'";
  2574. }
  2575. if ($express) {
  2576. $where .= " and express = '$express'";
  2577. }
  2578. if ($waybill) {
  2579. $where .= " and waybill = '$waybill'";
  2580. }
  2581. if ($library) {
  2582. $where .= " and library = '$library'";
  2583. }
  2584. if ($print) {
  2585. $where .= " and print = '$print'";
  2586. }
  2587. if ($libraryconfirm) {
  2588. $where .= " and libraryconfirm = '$libraryconfirm'";
  2589. }
  2590. if ($state) {
  2591. $where .= " and state = '$state'";
  2592. }
  2593. if ($shop) {
  2594. $where .= " and shop = '$shop'";
  2595. }
  2596. if ($country) {
  2597. $where .= " and country = '$country'";
  2598. }
  2599. if ($sfxh != '') {
  2600. $where .= " and sfxh = '$sfxh'";
  2601. }
  2602. if ($so) {
  2603. $where .= " and shipremarks like '%$so%'";
  2604. }
  2605. if ($source) {
  2606. if ($source == '2d') {
  2607. $where .= " and source >= '2'";
  2608. } else {
  2609. $where .= " and source = '$source'";
  2610. }
  2611. }
  2612. if (isset($_SESSION['api'])) {
  2613. foreach ($user as $value) {
  2614. $fgshop .= " shop = " . $value . " or";
  2615. }
  2616. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2617. }
  2618. if ($orderurl) {
  2619. $url = $this->orderurl->read($orderurl);
  2620. $where .= " and link like '%" . $url['url'] . "%'";
  2621. }
  2622. //数据排序
  2623. $order_str = "librarytime desc";
  2624. if (empty($page)) {
  2625. $start = 0;
  2626. $perpage = 1;
  2627. } else {
  2628. $start = ($page - 1) * $perpage;
  2629. }
  2630. //取得信息列表
  2631. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2632. //格式化数据
  2633. foreach ($info_list as $key => $value) {
  2634. $shop = $this->shop->read($value['shop']);
  2635. $info_list[$key]['shop'] = $shop['shopname'];
  2636. $express = $this->express->read($value['express']);
  2637. $info_list[$key]['express'] = $express['servicename'];
  2638. $warehouse = $this->warehouse->read($value['type']);
  2639. $info_list[$key]['type'] = $warehouse['title'];
  2640. if ($value['librarytime'] == '0') {
  2641. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2642. } else {
  2643. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2644. }
  2645. }
  2646. $total = $this->$sj->find_count($where);
  2647. $pagenum = ceil($total / $perpage);
  2648. $over = $total - ($start + $perpage);
  2649. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2650. echo json_encode($rows);
  2651. exit;
  2652. }
  2653. $this->data['express'] = $this->express->find_all();
  2654. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2655. $this->data['wlshop'] = $wlshop;
  2656. $user = $this->user->get_api($_SESSION['api']);
  2657. $powerid = $this->power->read($user['power']);
  2658. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2659. $pid = '';
  2660. foreach ($powertext as $v) {
  2661. $pid .= " id = " . $v . " or";
  2662. }
  2663. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2664. $this->data['fullorderexcel'] = $fullorderexcel;
  2665. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2666. $this->data['orderurl'] = $orderurl;
  2667. $this->_Template('whlabel_toutorder', $this->data);
  2668. }
  2669. //tt出库
  2670. public function _aoutorder()
  2671. {
  2672. if (isset($_SESSION['api'])) {
  2673. $user = $this->user->get_api($_SESSION['api']);
  2674. $usp = $user;
  2675. $fgshop = "";
  2676. $sid = "";
  2677. $user = explode('|', trim($user['shop'], '|'));
  2678. foreach ($user as $value) {
  2679. $fgshop .= " shop = " . $value . " or";
  2680. $sid .= " id = " . $value . " or";
  2681. }
  2682. } else {
  2683. echo "请重新登录";
  2684. }
  2685. $post = $this->input->post(NULL, TRUE);
  2686. if (isset($post['page'])) {
  2687. $page = $this->input->post('page', true);
  2688. $perpage = $this->input->post('perpage', true);
  2689. $warehouse = $this->input->post('warehouse', true);
  2690. $xztime = $this->input->post('xztime', true);
  2691. $timetk = $this->input->post('timetkk', true);
  2692. $timetj = $this->input->post('timetjj', true);
  2693. $shop = $this->input->post('shop', true);
  2694. $source = $this->input->post('source', true);
  2695. $orderinfo = $this->input->post('orderinfo', true);
  2696. $number = $this->input->post('number', true);
  2697. $sfxh = $this->input->post('sfxh', true);
  2698. $express = $this->input->post('express', true);
  2699. $waybill = $this->input->post('waybill', true);
  2700. $library = $this->input->post('library', true);
  2701. $country = $this->input->post('country', true);
  2702. $so = $this->input->post('so', true);
  2703. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2704. $print = $this->input->post('print', true);
  2705. $state = $this->input->post('state', true);
  2706. $orderurl = $this->input->post('orderurl', true);
  2707. $timetk = strtotime($timetk);
  2708. $timetj = strtotime($timetj);
  2709. /**
  2710. $sj = $this->input->post('sj',true);
  2711. if($sj)
  2712. {
  2713. $sj = $this->input->post('sj',true);
  2714. }
  2715. else
  2716. {
  2717. $sj = "fullorder";
  2718. }
  2719. **/
  2720. $sj = "fullorderamz";
  2721. $where = "1=1";
  2722. if ($warehouse) {
  2723. $where .= " and type = '$warehouse'";
  2724. }
  2725. if ($timetk && $timetj) {
  2726. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2727. }
  2728. if ($orderinfo) {
  2729. $where .= " and orderinfo = '$orderinfo'";
  2730. }
  2731. if ($number) {
  2732. $where .= " and number = '$number'";
  2733. }
  2734. if ($express) {
  2735. $where .= " and express = '$express'";
  2736. }
  2737. if ($waybill) {
  2738. $where .= " and waybill = '$waybill'";
  2739. }
  2740. if ($library) {
  2741. $where .= " and library = '$library'";
  2742. }
  2743. if ($print) {
  2744. $where .= " and print = '$print'";
  2745. }
  2746. if ($libraryconfirm) {
  2747. $where .= " and libraryconfirm = '$libraryconfirm'";
  2748. }
  2749. if ($state) {
  2750. $where .= " and state = '$state'";
  2751. }
  2752. if ($shop) {
  2753. $where .= " and shop = '$shop'";
  2754. }
  2755. if ($country) {
  2756. $where .= " and country = '$country'";
  2757. }
  2758. if ($sfxh != '') {
  2759. $where .= " and sfxh = '$sfxh'";
  2760. }
  2761. if ($so) {
  2762. $where .= " and shipremarks like '%$so%'";
  2763. }
  2764. if ($source) {
  2765. if ($source == '2d') {
  2766. $where .= " and source >= '2'";
  2767. } else {
  2768. $where .= " and source = '$source'";
  2769. }
  2770. }
  2771. if (isset($_SESSION['api'])) {
  2772. foreach ($user as $value) {
  2773. $fgshop .= " shop = " . $value . " or";
  2774. }
  2775. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2776. }
  2777. if ($orderurl) {
  2778. $url = $this->orderurl->read($orderurl);
  2779. $where .= " and link like '%" . $url['url'] . "%'";
  2780. }
  2781. //数据排序
  2782. $order_str = "librarytime desc";
  2783. if (empty($page)) {
  2784. $start = 0;
  2785. $perpage = 1;
  2786. } else {
  2787. $start = ($page - 1) * $perpage;
  2788. }
  2789. //取得信息列表
  2790. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2791. //格式化数据
  2792. foreach ($info_list as $key => $value) {
  2793. $shop = $this->shop->read($value['shop']);
  2794. $info_list[$key]['shop'] = $shop['shopname'];
  2795. $express = $this->express->read($value['express']);
  2796. $info_list[$key]['express'] = $express['servicename'];
  2797. $warehouse = $this->warehouse->read($value['type']);
  2798. $info_list[$key]['type'] = $warehouse['title'];
  2799. if ($value['librarytime'] == '0') {
  2800. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2801. } else {
  2802. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2803. }
  2804. }
  2805. $total = $this->$sj->find_count($where);
  2806. $pagenum = ceil($total / $perpage);
  2807. $over = $total - ($start + $perpage);
  2808. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2809. echo json_encode($rows);
  2810. exit;
  2811. }
  2812. $this->data['express'] = $this->express->find_all();
  2813. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2814. $this->data['wlshop'] = $wlshop;
  2815. $user = $this->user->get_api($_SESSION['api']);
  2816. $powerid = $this->power->read($user['power']);
  2817. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2818. $pid = '';
  2819. foreach ($powertext as $v) {
  2820. $pid .= " id = " . $v . " or";
  2821. }
  2822. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2823. $this->data['fullorderexcel'] = $fullorderexcel;
  2824. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2825. $this->data['orderurl'] = $orderurl;
  2826. $this->_Template('whlabel_aoutorder', $this->data);
  2827. }
  2828. //速卖通出库订单
  2829. public function _soutorder()
  2830. {
  2831. if (isset($_SESSION['api'])) {
  2832. $user = $this->user->get_api($_SESSION['api']);
  2833. $usp = $user;
  2834. $fgshop = "";
  2835. $sid = "";
  2836. $user = explode('|', trim($user['shop'], '|'));
  2837. foreach ($user as $value) {
  2838. $sid .= " id = " . $value . " or";
  2839. }
  2840. }
  2841. $post = $this->input->post(NULL, TRUE);
  2842. if (isset($post['page'])) {
  2843. $page = $this->input->post('page', true);
  2844. $perpage = $this->input->post('perpage', true);
  2845. $warehouse = $this->input->post('warehouse', true);
  2846. $xztime = $this->input->post('xztime', true);
  2847. $timetk = $this->input->post('timetkk', true);
  2848. $timetj = $this->input->post('timetjj', true);
  2849. $shop = $this->input->post('shop', true);
  2850. $source = $this->input->post('source', true);
  2851. $orderinfo = $this->input->post('orderinfo', true);
  2852. $number = $this->input->post('number', true);
  2853. $express = $this->input->post('express', true);
  2854. $waybill = $this->input->post('waybill', true);
  2855. $library = $this->input->post('library', true);
  2856. $country = $this->input->post('country', true);
  2857. $sfxh = $this->input->post('sfxh', true);
  2858. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2859. $print = $this->input->post('print', true);
  2860. $state = $this->input->post('state', true);
  2861. $so = $this->input->post('so', true);
  2862. $timetk = strtotime($timetk);
  2863. $timetj = strtotime($timetj);
  2864. /**
  2865. $sj = $this->input->post('sj',true);
  2866. if($sj)
  2867. {
  2868. $sj = $this->input->post('sj',true);
  2869. }
  2870. else
  2871. {
  2872. $sj = "fullorder";
  2873. }
  2874. **/
  2875. $sj = "fullordersmt";
  2876. $where = "1=1";
  2877. if ($warehouse) {
  2878. $where .= " and type = '$warehouse'";
  2879. }
  2880. if ($timetk && $timetj) {
  2881. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2882. }
  2883. if ($orderinfo) {
  2884. $where .= " and orderinfo = '$orderinfo'";
  2885. }
  2886. if ($number) {
  2887. $where .= " and number = '$number'";
  2888. }
  2889. if ($express) {
  2890. $where .= " and express = '$express'";
  2891. }
  2892. if ($waybill) {
  2893. $where .= " and waybill = '$waybill'";
  2894. }
  2895. if ($library) {
  2896. $where .= " and library = '$library'";
  2897. }
  2898. if ($print) {
  2899. $where .= " and print = '$print'";
  2900. }
  2901. if ($libraryconfirm) {
  2902. $where .= " and libraryconfirm = '$libraryconfirm'";
  2903. }
  2904. if ($state) {
  2905. $where .= " and state = '$state'";
  2906. }
  2907. if ($shop) {
  2908. $where .= " and shop = '$shop'";
  2909. }
  2910. if ($sfxh != '') {
  2911. $where .= " and sfxh = '$sfxh'";
  2912. }
  2913. if ($so) {
  2914. $where .= " and shipremarks like '%$so%'";
  2915. }
  2916. if ($source) {
  2917. $where .= " and source = '$source'";
  2918. }
  2919. if ($country) {
  2920. $where .= " and country = '$country'";
  2921. } else {
  2922. if (isset($_SESSION['api'])) {
  2923. foreach ($user as $value) {
  2924. $fgshop .= " shop = " . $value . " or";
  2925. }
  2926. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2927. }
  2928. }
  2929. //数据排序
  2930. $order_str = "librarytime desc";
  2931. if (empty($page)) {
  2932. $start = 0;
  2933. $perpage = 1;
  2934. } else {
  2935. $start = ($page - 1) * $perpage;
  2936. }
  2937. //取得信息列表
  2938. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2939. //格式化数据
  2940. foreach ($info_list as $key => $value) {
  2941. $shop = $this->shop->read($value['shop']);
  2942. $info_list[$key]['shop'] = $shop['shopname'];
  2943. $express = $this->express->read($value['express']);
  2944. $info_list[$key]['express'] = $express['servicename'];
  2945. $warehouse = $this->warehouse->read($value['type']);
  2946. $info_list[$key]['type'] = $warehouse['title'];
  2947. if ($value['librarytime'] == '0') {
  2948. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2949. } else {
  2950. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2951. }
  2952. }
  2953. $total = $this->$sj->find_count($where);
  2954. $pagenum = ceil($total / $perpage);
  2955. $over = $total - ($start + $perpage);
  2956. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2957. echo json_encode($rows);
  2958. exit;
  2959. }
  2960. $this->data['express'] = $this->express->find_all();
  2961. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2962. $this->data['wlshop'] = $wlshop;
  2963. $user = $this->user->get_api($_SESSION['api']);
  2964. $powerid = $this->power->read($user['power']);
  2965. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2966. $pid = '';
  2967. foreach ($powertext as $v) {
  2968. $pid .= " id = " . $v . " or";
  2969. }
  2970. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2971. $this->data['fullorderexcel'] = $fullorderexcel;
  2972. $this->_Template('whlabel_soutorder', $this->data);
  2973. }
  2974. //订单退库
  2975. public function _retreat()
  2976. {
  2977. $post = $this->input->post(NULL, TRUE);
  2978. if (isset($post['page'])) {
  2979. $page = $this->input->post('page', true);
  2980. $perpage = $this->input->post('perpage', true);
  2981. $warehouse = $this->input->post('warehouse', true);
  2982. $timetk = $this->input->post('timetk', true);
  2983. $timetj = $this->input->post('timetj', true);
  2984. $shop = $this->input->post('shop', true);
  2985. $source = $this->input->post('source', true);
  2986. $state = $this->input->post('state', true);
  2987. $review = $this->input->post('review', true);
  2988. $state = $this->input->post('state', true);
  2989. $express = $this->input->post('express', true);
  2990. $orderinfo = $this->input->post('orderinfo', true);
  2991. $user = $this->input->post('user', true);
  2992. $name = $this->input->post('name', true);
  2993. $waybill = $this->input->post('waybill', true);
  2994. $timetk = strtotime($timetk);
  2995. $timetj = strtotime($timetj);
  2996. $where = "(state=206 or state=210) and mergeid = 0";
  2997. if ($warehouse) {
  2998. $where .= " and state = '$warehouse'";
  2999. }
  3000. if ($timetk && $timetj) {
  3001. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3002. }
  3003. if ($shop) {
  3004. $where .= " and shop = '$shop'";
  3005. }
  3006. if ($source) {
  3007. $where .= " and source = '$source'";
  3008. }
  3009. if ($state) {
  3010. $where .= " and state = '$state'";
  3011. }
  3012. if ($review) {
  3013. $where .= " and review = '$review'";
  3014. }
  3015. if ($state) {
  3016. $where .= " and state = '$state'";
  3017. }
  3018. if ($express) {
  3019. $where .= " and express = '$express'";
  3020. }
  3021. if ($orderinfo) {
  3022. $where .= " and orderinfo = '$orderinfo'";
  3023. }
  3024. if ($user) {
  3025. $where .= " and user = '$user'";
  3026. }
  3027. if ($name) {
  3028. $where .= " and name = '$name'";
  3029. }
  3030. if ($waybill) {
  3031. $where .= " and waybill = '$waybill'";
  3032. }
  3033. //数据排序
  3034. $order_str = "id desc";
  3035. if (empty($page)) {
  3036. $start = 0;
  3037. $perpage = 1;
  3038. } else {
  3039. $start = ($page - 1) * $perpage;
  3040. }
  3041. //取得信息列表
  3042. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3043. //格式化数据
  3044. foreach ($info_list as $key => $value) {
  3045. $shop = $this->shop->read($value['shop']);
  3046. $info_list[$key]['shop'] = $shop['shopname'];
  3047. $warehouse = $this->warehouse->read($value['warehouse']);
  3048. $info_list[$key]['warehouse'] = $warehouse['title'];
  3049. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3050. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3051. if ($value['waybill'] == 0) {
  3052. $info_list[$key]['waybill'] = "";
  3053. }
  3054. $express = $this->express->read($value['express']);
  3055. $info_list[$key]['express'] = $express['title'];
  3056. $typeclass = $this->typeclass->read($value['state']);
  3057. $info_list[$key]['state'] = $typeclass['title'];
  3058. }
  3059. $total = $this->fullorder->find_count($where);
  3060. $pagenum = ceil($total / $perpage);
  3061. $over = $total - ($start + $perpage);
  3062. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3063. echo json_encode($rows);
  3064. exit;
  3065. }
  3066. $this->data['express'] = $this->express->find_all();
  3067. $this->_Template('whlabel_retreat', $this->data);
  3068. }
  3069. //退库标签浏览
  3070. public function _retreatlk()
  3071. {
  3072. $post = $this->input->post(NULL, TRUE);
  3073. if (isset($post['page'])) {
  3074. $page = $this->input->post('page', true);
  3075. $perpage = $this->input->post('perpage', true);
  3076. $timetk = $this->input->post('timetk', true);
  3077. $timetj = $this->input->post('timetj', true);
  3078. $sku = $this->input->post('sku', true);
  3079. $warehouse = $this->input->post('warehouse', true);
  3080. $purchase = $this->input->post('purchase', true);
  3081. $orderinfo = $this->input->post('orderinfo', true);
  3082. $waybill = $this->input->post('waybill', true);
  3083. $category = $this->input->post('category', true);
  3084. $size = $this->input->post('size', true);
  3085. $grade = $this->input->post('grade', true);
  3086. $color = $this->input->post('color', true);
  3087. $lowe = $this->input->post('lowe', true);
  3088. $state = $this->input->post('state', true);
  3089. $timetk = strtotime($timetk);
  3090. $timetj = strtotime($timetj);
  3091. $where = "state=2";
  3092. if ($timetk && $timetj) {
  3093. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3094. }
  3095. if ($sku) {
  3096. $where .= " and sku = '$sku'";
  3097. }
  3098. if ($warehouse) {
  3099. $where .= " and warehouse = '$warehouse'";
  3100. }
  3101. if ($purchase) {
  3102. $where .= " and purchase = '$purchase'";
  3103. }
  3104. if ($orderinfo) {
  3105. $where .= " and orderinfo = '$orderinfo'";
  3106. }
  3107. if ($waybill) {
  3108. $where .= " and waybill = '$waybill'";
  3109. }
  3110. if ($category) {
  3111. $where .= " and features like '%-$category-%'";
  3112. }
  3113. if ($size) {
  3114. $where .= " and features like '%-$size-%'";
  3115. }
  3116. if ($grade) {
  3117. $where .= " and features like '%-$grade-%'";
  3118. }
  3119. if ($color) {
  3120. $where .= " and features like '%-$color-%'";
  3121. }
  3122. if ($lowe) {
  3123. $where .= " and features like '%-$lowe-%'";
  3124. }
  3125. //数据排序
  3126. $order_str = "time desc";
  3127. if (empty($page)) {
  3128. $start = 0;
  3129. $perpage = 1;
  3130. } else {
  3131. $start = ($page - 1) * $perpage;
  3132. }
  3133. //取得信息列表
  3134. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3135. foreach ($info_list as $key => $value) {
  3136. $warehouse = $this->warehouse->read($value['warehouse']);
  3137. $info_list[$key]['warehouse'] = $warehouse['title'];
  3138. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3139. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3140. $purchase = $this->purchase->read($value['purchase']);
  3141. $info_list[$key]['purchase'] = $purchase['title'];
  3142. if ($value['outk'] != 0) {
  3143. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3144. } else {
  3145. $info_list[$key]['outk'] = "";
  3146. }
  3147. if ($value['retreat'] != 0) {
  3148. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3149. } else {
  3150. $info_list[$key]['retreat'] = "";
  3151. }
  3152. if ($value['orderinfo'] == 0) {
  3153. $info_list[$key]['orderinfo'] = "";
  3154. }
  3155. if ($value['waybill'] == 0) {
  3156. $info_list[$key]['waybill'] = "";
  3157. }
  3158. }
  3159. $total = $this->whlabel->find_count($where);
  3160. $pagenum = ceil($total / $perpage);
  3161. $over = $total - ($start + $perpage);
  3162. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3163. echo json_encode($rows);
  3164. exit;
  3165. }
  3166. $this->_Template('whlabel_retreatlk', $this->data);
  3167. }
  3168. //更换标签及浏览
  3169. public function _change()
  3170. {
  3171. $post = $this->input->post(NULL, TRUE);
  3172. if (isset($post['page'])) {
  3173. $page = $this->input->post('page', true);
  3174. $perpage = $this->input->post('perpage', true);
  3175. $timetk = $this->input->post('timetk', true);
  3176. $timetj = $this->input->post('timetj', true);
  3177. $label = $this->input->post('label', true);
  3178. $oldlabel = $this->input->post('oldlabel', true);
  3179. $timetk = strtotime($timetk);
  3180. $timetj = strtotime($timetj);
  3181. $where = "state=10 ";
  3182. if ($timetk && $timetj) {
  3183. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3184. }
  3185. if ($label) {
  3186. $where .= " and label = '$label'";
  3187. }
  3188. if ($oldlabel) {
  3189. $where .= " and oldlabel = '$oldlabel'";
  3190. }
  3191. //数据排序
  3192. $order_str = "time asc";
  3193. if (empty($page)) {
  3194. $start = 0;
  3195. $perpage = 1;
  3196. } else {
  3197. $start = ($page - 1) * $perpage;
  3198. }
  3199. //取得信息列表
  3200. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3201. foreach ($info_list as $key => $value) {
  3202. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3203. }
  3204. $total = $this->whlabel->find_count($where);
  3205. $pagenum = ceil($total / $perpage);
  3206. $over = $total - ($start + $perpage);
  3207. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3208. echo json_encode($rows);
  3209. exit;
  3210. }
  3211. $this->_Template('whlabel_change', $this->data);
  3212. }
  3213. //产品标签
  3214. public function _cpbqdc()
  3215. {
  3216. if (isset($_GET['excel'])) {
  3217. $where = "1=1";
  3218. //数据排序
  3219. $order_str = "id desc";
  3220. if (empty($page)) {
  3221. $start = 0;
  3222. $perpage = 1;
  3223. } else {
  3224. $start = ($page - 1) * $perpage;
  3225. }
  3226. $warehouse = $this->input->get('warehouse', true);
  3227. $state = $this->input->get('state', true);
  3228. $timetk = $this->input->get('timetkk', true);
  3229. $timetj = $this->input->get('timetjj', true);
  3230. $timetk = strtotime($timetk);
  3231. $timetj = strtotime($timetj);
  3232. if ($warehouse) {
  3233. $where .= " and warehouse = '$warehouse'";
  3234. }
  3235. if ($state || $state == 0) {
  3236. $where .= " and state = '$state'";
  3237. }
  3238. if ($timetk && $timetj) {
  3239. $where .= " and time > '$timetk' and time < '$timetj'";
  3240. }
  3241. //取得信息列表
  3242. $info_list = $this->whlabel->find_all($where, '*');
  3243. $rows = array();
  3244. $list = array();
  3245. foreach ($info_list as $key => $value) {
  3246. $rows[$value['time']] = $value; //所有数据sku
  3247. }
  3248. foreach ($rows as $value) {
  3249. $warehouse = $this->warehouse->read($value['warehouse']);
  3250. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3251. $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);
  3252. }
  3253. $title = "产品标签统计表";
  3254. $titlename = "<table border=1>
  3255. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3256. <tr align='center'>
  3257. <td>仓库</td>
  3258. <td>SKU</td>
  3259. <td>产品</td>
  3260. <td>入库时间</td>
  3261. <td>操作时间</td>
  3262. <td>备注</td>
  3263. <td>数量</td>
  3264. </tr>
  3265. </table>";
  3266. $filename = $title . ".xls";
  3267. $tail = "";
  3268. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3269. }
  3270. }
  3271. //进销存导出
  3272. public function _exceljxc()
  3273. {
  3274. $classid = $this->classid->sku();
  3275. $pm = $classid;
  3276. $typeclass = array();
  3277. $tc = $this->typeclass->find_all();
  3278. foreach ($tc as $v) {
  3279. $typeclass[$v['id']] = $v;
  3280. }
  3281. $prc = array();
  3282. $purchase = $this->purchase->find_all();
  3283. foreach ($purchase as $k => $v) {
  3284. $prc[$v['id']] = $v['title'];
  3285. }
  3286. if (isset($_GET['excel'])) {
  3287. $where = "sku != 'Preset'";
  3288. //数据排序
  3289. $order_str = "id desc";
  3290. if (empty($page)) {
  3291. $start = 0;
  3292. $perpage = 1;
  3293. } else {
  3294. $start = ($page - 1) * $perpage;
  3295. }
  3296. $category = $this->input->get('category', true);
  3297. $warehouse = $this->input->get('warehouse', true);
  3298. $excelid = $this->input->get('sid', true);
  3299. if ($category) {
  3300. $where .= " and features like '%-$category-%'";
  3301. }
  3302. if ($warehouse) {
  3303. $where .= " and warehouse = '$warehouse'";
  3304. }
  3305. $xzid = '';
  3306. if ($excelid) {
  3307. $excelid = explode(',', trim($excelid, ','));
  3308. foreach ($excelid as $key => $value) {
  3309. $xzid .= " id = " . $value . " or";
  3310. }
  3311. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3312. }
  3313. //取得信息列表
  3314. /**
  3315. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3316. $rows = array();$list = array();
  3317. foreach ($info_list as $key=>$value)
  3318. {
  3319. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3320. }
  3321. **/
  3322. $wt = array();
  3323. $whlabel_type = $this->whlabel_type->find_all();
  3324. foreach ($whlabel_type as $v) {
  3325. $wt[$v['id']] = $v['title'];
  3326. }
  3327. $wh = array();
  3328. $w = $this->warehouse->find_all('1=1', 'id,title');
  3329. foreach ($w as $v) {
  3330. $wh[$v['id']] = $v['title'];
  3331. }
  3332. $list = array();
  3333. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3334. foreach ($rows as $key => $value) {
  3335. if (isset($wt[$value['type']])) {
  3336. $rows[$key]['type'] = $wt[$value['type']];
  3337. } else {
  3338. $rows[$key]['type'] = '未设置';
  3339. }
  3340. $bm = '03';
  3341. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3342. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3343. $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');
  3344. $details = array();
  3345. $cpid = array();
  3346. $cpbz = array();
  3347. $c = 0;
  3348. $g = 0;
  3349. $x = 0;
  3350. $t = 0;
  3351. $s = 0;
  3352. $q = 0;
  3353. foreach ($sd as $k => $v) {
  3354. if ($v['state'] == 0) {
  3355. $c++;
  3356. if ($v['cpid'] != 0) {
  3357. $cpid[$v['cpid']] = $v['cpid'];
  3358. }
  3359. if ($v['cpbz'] != '') {
  3360. $cpbz[$v['cpbz']] = $v['cpbz'];
  3361. }
  3362. }
  3363. if ($v['state'] != 9) {
  3364. $g++;
  3365. }
  3366. if ($v['state'] == 1) {
  3367. $x++;
  3368. }
  3369. if ($v['state'] == 2) {
  3370. $t++;
  3371. }
  3372. if ($v['state'] == 8) {
  3373. $s++;
  3374. }
  3375. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3376. $q++;
  3377. }
  3378. $details[$v['details']] = $v['details'];
  3379. }
  3380. $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'] . '"');
  3381. $rows[$key]['details'] = implode("、", $details);
  3382. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3383. $number = $value['number'];
  3384. $ftime = time() - 15 * 24 * 3600;
  3385. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3386. $rows[$key]['number'] = $g;
  3387. $rows[$key]['c'] = $c;
  3388. $rows[$key]['x'] = $x;
  3389. $rows[$key]['t'] = $t;
  3390. $rows[$key]['s'] = $s;
  3391. $rows[$key]['q'] = $q;
  3392. $rows[$key]['z'] = $z;
  3393. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3394. $features = explode('-', trim($features, '-'));
  3395. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3396. // $pm = $classid;
  3397. // $jm = $classid;
  3398. // foreach($features as $k=>$v)
  3399. // {
  3400. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3401. // {
  3402. // if($typeclass[$v]['bm'] != '')
  3403. // {
  3404. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3405. // }
  3406. // }
  3407. // if($v != 0)
  3408. // {
  3409. // if(!isset($typeclass[$v]))
  3410. // {
  3411. // continue;
  3412. // }
  3413. // if(isset($pm[$typeclass[$v]['classid']]))
  3414. // {
  3415. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3416. // {
  3417. // $tz = explode('|',$typeclass[$v]['zh']);
  3418. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3419. // }
  3420. // else
  3421. // {
  3422. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3423. // }
  3424. // }
  3425. // if(isset($jm[$typeclass[$v]['classid']]))
  3426. // {
  3427. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3428. // }
  3429. // }
  3430. // }
  3431. // $jm = array_filter($jm);
  3432. // $rows[$key]['bs'] = implode("-",$jm);
  3433. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3434. // $zh = implode(" ",$pm);
  3435. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3436. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3437. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3438. // $rows[$key]['features'] = $zh;
  3439. }
  3440. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3441. $final_list = [];
  3442. foreach ($list as $k => $v) {
  3443. if (empty($v['sku'])) {
  3444. continue;
  3445. }
  3446. $final_list[] = [
  3447. "warehouse" => $v["warehouse"],
  3448. "purchase" => $v["purchase"],
  3449. "details" => $v["details"],
  3450. "cpid" => $v["cpid"],
  3451. "dbcontent" => $v["dbcontent"],
  3452. "sku" => $v["sku"],
  3453. "cs" => $v["bm"],
  3454. "bs" => $v["jm"],
  3455. "title" => $v["title"],
  3456. "features" => $v["pm"],
  3457. "cpbz" => $v["cpbz"],
  3458. "sm" => $v["sm"],
  3459. "type" => $v["type"],
  3460. "number" => $v["number"],
  3461. "c" => $v["c"],
  3462. "x" => $v["x"],
  3463. "t" => $v["t"],
  3464. "s" => $v["s"],
  3465. "q" => $v["q"],
  3466. "z" => $v["z"],
  3467. "weight" => $v['weight'],
  3468. ];
  3469. }
  3470. $title = "总进销存统计表";
  3471. $titlename = "<table border=1>
  3472. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3473. <tr align='center'>
  3474. <td>仓库</td>
  3475. <td>供应商</td>
  3476. <td>位置</td>
  3477. <td>库存编码</td>
  3478. <td>类目</td>
  3479. <td>SKU</td>
  3480. <td>用友编码</td>
  3481. <td>用友料号</td>
  3482. <td>商品名称</td>
  3483. <td>商品中文</td>
  3484. <td>产品备注</td>
  3485. <td>说明</td>
  3486. <td>类型</td>
  3487. <td>入库总量</td>
  3488. <td>库存数量</td>
  3489. <td>销售数量</td>
  3490. <td>退货数量</td>
  3491. <td>删除数量</td>
  3492. <td>其它操作</td>
  3493. <td>占单数量</td>
  3494. <td>重量(g)</td>
  3495. </tr>
  3496. </table>";
  3497. $filename = $title . ".xls";
  3498. $tail = "";
  3499. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3500. }
  3501. }
  3502. //入库导出
  3503. public function _excelr()
  3504. {
  3505. if (isset($_GET['excel'])) {
  3506. $category = $this->input->get('category', true);
  3507. $size = $this->input->get('size', true);
  3508. $grade = $this->input->get('grade', true);
  3509. $color = $this->input->get('color', true);
  3510. $lowe = $this->input->get('lowe', true);
  3511. $sku = $this->input->get('sku', true);
  3512. $warehouse = $this->input->get('warehouse', true);
  3513. $purchase = $this->input->get('purchase', true);
  3514. $ktime = $this->input->get('ktime', true);
  3515. $jtime = $this->input->get('jtime', true);
  3516. $ktime = strtotime($ktime);
  3517. $jtime = strtotime($jtime);
  3518. $where = "1=1";
  3519. $gj = "";
  3520. $ck = "";
  3521. if ($category) {
  3522. $where .= " and features like '%-$category-%'";
  3523. }
  3524. if ($size) {
  3525. $where .= " and features like '%-$size-%'";
  3526. }
  3527. if ($grade) {
  3528. $where .= " and features like '%-$grade-%'";
  3529. }
  3530. if ($color) {
  3531. $where .= " and features like '%-$color-%'";
  3532. }
  3533. if ($lowe) {
  3534. $where .= " and features like '%-$lowe-%'";
  3535. }
  3536. if ($warehouse) {
  3537. $where .= " and warehouse = '$warehouse'";
  3538. }
  3539. if ($purchase) {
  3540. $where .= " and purchase = '$purchase'";
  3541. }
  3542. if ($sku) {
  3543. $where .= " and sku = '$sku'";
  3544. }
  3545. if ($ktime && $jtime) {
  3546. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3547. }
  3548. //数据排序
  3549. $order_str = "id desc";
  3550. if (empty($page)) {
  3551. $start = 0;
  3552. $perpage = 1;
  3553. } else {
  3554. $start = ($page - 1) * $perpage;
  3555. }
  3556. $list = array();
  3557. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3558. foreach ($rows as $value) {
  3559. $ck = $this->warehouse->read($value['warehouse']);
  3560. $warehouse = $ck['title'];
  3561. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3562. $retreatwarehouse = $tkck['title'];
  3563. $gy = $this->purchase->read($value['purchase']);
  3564. $purchase = $gy['title'];
  3565. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3566. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3567. }
  3568. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3569. $titlename = "<table border=1>
  3570. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3571. <tr align='center'>
  3572. <td>仓库</td>
  3573. <td>SKU</td>
  3574. <td>产品</td>
  3575. <td>时间</td>
  3576. <td>数量</td>
  3577. </tr>
  3578. </table>";
  3579. $filename = $title . ".xls";
  3580. $tail = "";
  3581. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3582. }
  3583. }
  3584. //出库、退库导出
  3585. public function _excelct()
  3586. {
  3587. $classid = $this->classid->sku();
  3588. $pm = $classid;
  3589. $typeclass = array();
  3590. $tc = $this->typeclass->find_all();
  3591. foreach ($tc as $v) {
  3592. $typeclass[$v['id']] = $v;
  3593. }
  3594. $prc = array();
  3595. $purchase = $this->purchase->find_all();
  3596. foreach ($purchase as $k => $v) {
  3597. $prc[$v['id']] = $v['title'];
  3598. }
  3599. if (isset($_GET['excel'])) {
  3600. $wh = array();
  3601. $w = $this->warehouse->find_all('1=1', 'id,title');
  3602. foreach ($w as $v) {
  3603. $wh[$v['id']] = $v['title'];
  3604. }
  3605. $type = $this->input->get('excel', true);
  3606. $category = $this->input->get('category', true);
  3607. $size = $this->input->get('size', true);
  3608. $grade = $this->input->get('grade', true);
  3609. $color = $this->input->get('color', true);
  3610. $lowe = $this->input->get('lowe', true);
  3611. $sku = $this->input->get('sku', true);
  3612. $warehouse = $this->input->get('warehouse', true);
  3613. $lacetype = $this->input->get('lacetype', true);
  3614. $lacecolor = $this->input->get('lacecolor', true);
  3615. $density = $this->input->get('density', true);
  3616. $haircap = $this->input->get('haircap', true);
  3617. $purchase = $this->input->get('purchase', true);
  3618. $title = $this->input->get('title', true);
  3619. $state = $this->input->get('state', true);
  3620. $sid = $this->input->get('sid', true);
  3621. $ktime = $this->input->get('ktime', true);
  3622. $jtime = $this->input->get('jtime', true);
  3623. $ktime = strtotime($ktime);
  3624. $jtime = strtotime($jtime);
  3625. $where = "1=1";
  3626. $gj = "";
  3627. $ck = "";
  3628. if ($category) {
  3629. $where .= " and features like '%-$category-%'";
  3630. }
  3631. if ($size) {
  3632. $where .= " and features like '%-$size-%'";
  3633. }
  3634. if ($grade) {
  3635. $where .= " and features like '%-$grade-%'";
  3636. }
  3637. if ($color) {
  3638. $where .= " and features like '%-$color-%'";
  3639. }
  3640. if ($lowe) {
  3641. $where .= " and features like '%-$lowe-%'";
  3642. }
  3643. if ($warehouse) {
  3644. $where .= " and warehouse = '$warehouse'";
  3645. }
  3646. if ($purchase) {
  3647. $where .= " and purchase = '$purchase'";
  3648. }
  3649. if ($state) {
  3650. $where .= " and state = '$state'";
  3651. }
  3652. if ($lacetype) {
  3653. $where .= " and features like '%-$lacetype-%'";
  3654. }
  3655. if ($lacecolor) {
  3656. $where .= " and features like '%-$lacecolor-%'";
  3657. }
  3658. if ($density) {
  3659. $where .= " and features like '%-$density-%'";
  3660. }
  3661. if ($haircap) {
  3662. $where .= " and features like '%-$haircap-%'";
  3663. }
  3664. if ($title) {
  3665. $title = trim($title, ' ');
  3666. $title = trim($title, ' ');
  3667. $where .= " and title like '%$title%'";
  3668. }
  3669. if ($sku) {
  3670. $sku = trim($sku, ' ');
  3671. $sku = trim($sku, ' ');
  3672. $where .= " and sku like '%$sku%'";
  3673. }
  3674. if ($ktime && $jtime) {
  3675. if ($type == 1) {
  3676. $tl = '出库';
  3677. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3678. } else if ($type == 2) {
  3679. $tl = '退库';
  3680. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3681. } else if ($type == 3) {
  3682. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3683. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3684. } else if ($type == 4) {
  3685. $tl = '出库+零售';
  3686. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3687. } else if ($type == 5) {
  3688. $tl = '零售';
  3689. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3690. }
  3691. }
  3692. $sidwhere = '';
  3693. if ($sid) {
  3694. $sd = "";
  3695. $s = explode(',', trim($sid, ','));
  3696. foreach ($s as $value) {
  3697. $sd .= " id = " . $value . " or";
  3698. }
  3699. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3700. }
  3701. //数据排序
  3702. $order_str = "time desc";
  3703. if (empty($page)) {
  3704. $start = 0;
  3705. $perpage = 1;
  3706. } else {
  3707. $start = ($page - 1) * $perpage;
  3708. }
  3709. //取得信息列表
  3710. if ($type != 3 && $type != 5) {
  3711. if ($type == 1 || $type == 4) {
  3712. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3713. foreach ($info_list as $key => $value) {
  3714. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3715. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3716. $warehouse = $this->warehouse->read($value['warehouse']);
  3717. $info_list[$key]['warehouse'] = $warehouse['title'];
  3718. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3719. $features = explode('-', trim($features, '-'));
  3720. $pm = $classid;
  3721. foreach ($features as $k => $v) {
  3722. if ($v != 0) {
  3723. if (!isset($typeclass[$v])) {
  3724. continue;
  3725. }
  3726. if (isset($pm[$typeclass[$v]['classid']])) {
  3727. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3728. $tz = explode('|', $typeclass[$v]['zh']);
  3729. $pm[$typeclass[$v]['classid']] = $tz[0];
  3730. } else {
  3731. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3732. }
  3733. }
  3734. }
  3735. }
  3736. $zh = implode(" ", $pm);
  3737. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3738. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3739. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3740. $info_list[$key]['features'] = $zh;
  3741. }
  3742. $final_list = [];
  3743. foreach($info_list as $k=>$v){
  3744. $number = "";
  3745. if(!empty($v['orderinfo'])){
  3746. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3747. if(!empty($tmp_info['number'])){
  3748. $number = $tmp_info['number'];
  3749. }
  3750. }
  3751. $final_list[] = [
  3752. 'warehouse'=>$v['warehouse'],
  3753. 'purchase'=>$v['purchase'],
  3754. 'sku'=>$v['sku'],
  3755. 'title'=>$v['title'],
  3756. 'features'=>$v['features'],
  3757. 'label'=>$v['label'],
  3758. 'orderinfo'=>$v['orderinfo'],
  3759. 'number'=>$number,
  3760. 'waybill'=>$v['waybill'],
  3761. 'outk'=>$v['outk'],
  3762. ];
  3763. }
  3764. } else {
  3765. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3766. foreach ($info_list as $key => $value) {
  3767. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3768. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3769. $warehouse = $this->warehouse->read($value['warehouse']);
  3770. $info_list[$key]['warehouse'] = $warehouse['title'];
  3771. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3772. $features = explode('-', trim($features, '-'));
  3773. $pm = $classid;
  3774. foreach ($features as $k => $v) {
  3775. if ($v != 0) {
  3776. if (!isset($typeclass[$v])) {
  3777. continue;
  3778. }
  3779. if (isset($pm[$typeclass[$v]['classid']])) {
  3780. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3781. $tz = explode('|', $typeclass[$v]['zh']);
  3782. $pm[$typeclass[$v]['classid']] = $tz[0];
  3783. } else {
  3784. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3785. }
  3786. }
  3787. }
  3788. }
  3789. $zh = implode(" ", $pm);
  3790. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3791. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3792. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3793. $info_list[$key]['features'] = $zh;
  3794. }
  3795. $final_list = [];
  3796. foreach($info_list as $k=>$v){
  3797. $number = "";
  3798. if(!empty($v['orderinfo'])){
  3799. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  3800. if(!empty($tmp_info['number'])){
  3801. $number = $tmp_info['number'];
  3802. }
  3803. }
  3804. $final_list[] = [
  3805. 'warehouse'=>$v['warehouse'],
  3806. 'purchase'=>$v['purchase'],
  3807. 'sku'=>$v['sku'],
  3808. 'title'=>$v['title'],
  3809. 'features'=>$v['features'],
  3810. 'label'=>$v['label'],
  3811. 'orderinfo'=>$v['orderinfo'],
  3812. 'number'=>$number,
  3813. 'waybill'=>$v['waybill'],
  3814. 'retreat'=>$v['retreat'],
  3815. ];
  3816. }
  3817. }
  3818. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3819. $titlename = "<table border=1>
  3820. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  3821. <tr align='center'>
  3822. <td>仓库</td>
  3823. <td>供应商</td>
  3824. <td>SKU</td>
  3825. <td>商品名称</td>
  3826. <td>商品中文</td>
  3827. <td>标签</td>
  3828. <td>订单号</td>
  3829. <td>订单编码</td>
  3830. <td>运单号</td>
  3831. <td>" . $tl . "时间(中国时间)</td>
  3832. </tr>
  3833. </table>";
  3834. $filename = $title . ".xls";
  3835. $tail = "";
  3836. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3837. } else if ($type == 5) {
  3838. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $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]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减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. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3869. $titlename = "<table border=1>
  3870. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3871. <tr align='center'>
  3872. <td>仓库</td>
  3873. <td>供应商</td>
  3874. <td>SKU</td>
  3875. <td>商品名称</td>
  3876. <td>商品中文</td>
  3877. <td>标签</td>
  3878. <td>" . $tl . "时间(中国时间)</td>
  3879. </tr>
  3880. </table>";
  3881. $filename = $title . ".xls";
  3882. $tail = "";
  3883. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3884. } else {
  3885. /**
  3886. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3887. $rows = array();$list = array();
  3888. foreach ($info_list as $key=>$value)
  3889. {
  3890. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3891. }
  3892. **/
  3893. $wh = array();
  3894. $w = $this->warehouse->find_all('1=1', 'id,title');
  3895. foreach ($w as $v) {
  3896. $wh[$v['id']] = $v['title'];
  3897. }
  3898. $wt = array();
  3899. $whlabel_type = $this->whlabel_type->find_all();
  3900. foreach ($whlabel_type as $v) {
  3901. $wt[$v['id']] = $v['title'];
  3902. }
  3903. $classid = $this->classid->sku();
  3904. $list = array();
  3905. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3906. foreach ($rows as $key => $value) {
  3907. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3908. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3909. $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');
  3910. $details = array();
  3911. $cpid = array();
  3912. $cpbz = array();
  3913. $c = 0;
  3914. $g = 0;
  3915. $x = 0;
  3916. $t = 0;
  3917. $s = 0;
  3918. $q = 0;
  3919. foreach ($sd as $k => $v) {
  3920. if ($v['state'] == 0) {
  3921. $c++;
  3922. }
  3923. if ($v['state'] != 9) {
  3924. $g++;
  3925. }
  3926. if ($v['outk'] > 1) {
  3927. $x++;
  3928. }
  3929. if ($v['retreat'] > 0) {
  3930. $t++;
  3931. }
  3932. if ($v['state'] == 8) {
  3933. $s++;
  3934. }
  3935. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3936. $q++;
  3937. }
  3938. $details[$v['details']] = $v['details'];
  3939. if ($v['cpid'] != 0) {
  3940. $cpid[$v['cpid']] = $v['cpid'];
  3941. }
  3942. if ($v['cpbz'] != '') {
  3943. $cpbz[$v['cpbz']] = $v['cpbz'];
  3944. }
  3945. }
  3946. if (isset($wt[$value['type']])) {
  3947. $rows[$key]['type'] = $wt[$value['type']];
  3948. } else {
  3949. $rows[$key]['type'] = '未设置';
  3950. }
  3951. $rows[$key]['details'] = implode("、", $details);
  3952. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3953. $ftime = time() - 15 * 24 * 3600;
  3954. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3955. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3956. $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);
  3957. $rows[$key]['c'] = $c;
  3958. $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);
  3959. $rows[$key]['t'] = $t;
  3960. $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'] . '"');
  3961. $rows[$key]['z'] = $z;
  3962. // $jm = $classid;
  3963. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3964. $features = explode('-', trim($features, '-'));
  3965. // $pm = $classid;
  3966. // foreach ($features as $k => $v) {
  3967. // if ($v != 0) {
  3968. // if (!isset($typeclass[$v])) {
  3969. // continue;
  3970. // }
  3971. // if (isset($pm[$typeclass[$v]['classid']])) {
  3972. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3973. // $tz = explode('|', $typeclass[$v]['zh']);
  3974. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3975. // } else {
  3976. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3977. // }
  3978. // if (isset($jm[$typeclass[$v]['classid']])) {
  3979. // if ($typeclass[$v]['jm']) {
  3980. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3981. // }
  3982. // }
  3983. // }
  3984. // }
  3985. // }
  3986. // $zh = implode(" ", $pm);
  3987. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3988. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3989. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3990. // $rows[$key]['features'] = $zh;
  3991. // $jm = array_filter($jm); //去除空值
  3992. // $jm = implode("-", $jm);
  3993. // $rows[$key]['jm'] = $jm;
  3994. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  3995. }
  3996. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  3997. // echo "<pre>";
  3998. // print_r($tmp_list);
  3999. // die;
  4000. $final_list =[];
  4001. foreach($tmp_list as $k=>$v){
  4002. $final_list[] = [
  4003. "warehouse"=>$v['warehouse'],
  4004. "purchase"=>$v['purchase'],
  4005. "details"=>$v['details'],
  4006. "cpid"=>$v['cpid'],
  4007. "sku"=>$v['sku'],
  4008. "title"=>$v['title'],
  4009. "features"=>$v['pm'],
  4010. "cpbz"=>$v['cpbz'],
  4011. "sm"=>$v['sm'],
  4012. "type"=>$v['type'],
  4013. "g"=>$v["g"],
  4014. "c"=>$v["c"],
  4015. "x"=>$v["x"],
  4016. "t"=>$v["t"],
  4017. "z"=>$v["z"],
  4018. "jm"=>$v["jm"],
  4019. "weight"=>$v["weight"],
  4020. "asd"=>$v["asd"],
  4021. ];
  4022. }
  4023. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4024. $titlename = "<table border=1>
  4025. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4026. <tr align='center'>
  4027. <td>仓库</td>
  4028. <td>供应商</td>
  4029. <td>位置</td>
  4030. <td>库存编码</td>
  4031. <td>SKU</td>
  4032. <td>商品名称</td>
  4033. <td>商品中文</td>
  4034. <td>产品备注</td>
  4035. <td>说明</td>
  4036. <td>类型</td>
  4037. <td>入库总量</td>
  4038. <td>库存数量</td>
  4039. <td>销售数量</td>
  4040. <td>退货数量</td>
  4041. <td>占单数量</td>
  4042. <td>料号</td>
  4043. <td>重量</td>
  4044. <td>类目</td>
  4045. </tr>
  4046. </table>";
  4047. $filename = $title . ".xls";
  4048. $tail = "";
  4049. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4050. }
  4051. }
  4052. }
  4053. //出库+入库数据整合
  4054. public function _excelcr()
  4055. {
  4056. if (isset($_GET['excel'])) {
  4057. $type = $this->input->get('excel', true);
  4058. $category = $this->input->get('category', true);
  4059. $size = $this->input->get('size', true);
  4060. $grade = $this->input->get('grade', true);
  4061. $color = $this->input->get('color', true);
  4062. $lowe = $this->input->get('lowe', true);
  4063. $sku = $this->input->get('sku', true);
  4064. $warehouse = $this->input->get('warehouse', true);
  4065. $purchase = $this->input->get('purchase', true);
  4066. $state = $this->input->get('state', true);
  4067. $sid = $this->input->get('sid', true);
  4068. $ktime = $this->input->get('ktime', true);
  4069. $jtime = $this->input->get('jtime', true);
  4070. $ktime = strtotime($ktime);
  4071. $jtime = strtotime($jtime);
  4072. $where = "1=1";
  4073. $gj = "";
  4074. $ck = "";
  4075. if ($category) {
  4076. $where .= " and features like '%-$category-%'";
  4077. }
  4078. if ($size) {
  4079. $where .= " and features like '%-$size-%'";
  4080. }
  4081. if ($grade) {
  4082. $where .= " and features like '%-$grade-%'";
  4083. }
  4084. if ($color) {
  4085. $where .= " and features like '%-$color-%'";
  4086. }
  4087. if ($lowe) {
  4088. $where .= " and features like '%-$lowe-%'";
  4089. }
  4090. if ($warehouse) {
  4091. $where .= " and warehouse = '$warehouse'";
  4092. }
  4093. if ($purchase) {
  4094. $where .= " and purchase = '$purchase'";
  4095. }
  4096. if ($state) {
  4097. $where .= " and state = '$state'";
  4098. }
  4099. if ($sku) {
  4100. $where .= " and sku like '%$sku%'";
  4101. }
  4102. if ($ktime && $jtime) {
  4103. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4104. }
  4105. $sidwhere = '';
  4106. if ($sid) {
  4107. $sd = "";
  4108. $s = explode(',', trim($sid, ','));
  4109. foreach ($s as $value) {
  4110. $sd .= " id = " . $value . " or";
  4111. }
  4112. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4113. }
  4114. //取得信息列表
  4115. $timeread = $ktime;
  4116. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4117. $timelist = array();
  4118. for ($i = 0; $i < $timenum; $i++) {
  4119. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4120. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4121. }
  4122. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4123. //echo "<pre>";
  4124. //print_r($info_list);
  4125. //exit();
  4126. $rows = array();
  4127. $list = array();
  4128. foreach ($info_list as $key => $value) {
  4129. $thistime = $timelist;
  4130. if (isset($rows[strtolower($value['sku'])])) {
  4131. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4132. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4133. }
  4134. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4135. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4136. }
  4137. } else {
  4138. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4139. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4140. }
  4141. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4142. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4143. }
  4144. $rows[strtolower($value['sku'])] = $thistime;
  4145. }
  4146. }
  4147. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4148. <head>
  4149. <!--[if gte mso 9]><xml>
  4150. <x:ExcelWorkbook>
  4151. <x:ExcelWorksheets>
  4152. <x:ExcelWorksheet>
  4153. <x:Name>EXCEL</x:Name>
  4154. <x:WorksheetOptions>
  4155. <x:Print>
  4156. <x:ValidPrinterInfo />
  4157. </x:Print>
  4158. </x:WorksheetOptions>
  4159. </x:ExcelWorksheet>
  4160. </x:ExcelWorksheets>
  4161. </x:ExcelWorkbook>
  4162. </xml>
  4163. <![endif]-->
  4164. </head><body>";
  4165. $str .= "<table border=1><tr><td>SKU</td>";
  4166. foreach ($timelist as $k => $v) {
  4167. $str .= "<td>" . $k . "出库</td>";
  4168. $str .= "<td>" . $k . "入库</td>";
  4169. }
  4170. $str .= "</tr></table>";
  4171. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4172. foreach ($rows as $key => $val) {
  4173. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4174. foreach ($val as $k => $v) {
  4175. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4176. if ($val[$k]['r'] > 0) {
  4177. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4178. } else {
  4179. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4180. }
  4181. }
  4182. $str .= "</tr>";
  4183. }
  4184. $str .= "</table>";
  4185. $str .= "</body></html>";
  4186. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4187. header("Content-type: application/octet-stream");
  4188. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4189. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4190. header("Pragma: no-cache");
  4191. header("Expires: 0");
  4192. exit($str);
  4193. }
  4194. }
  4195. //数量调整模板导出
  4196. public function _presetout()
  4197. {
  4198. if (isset($_GET['excel'])) {
  4199. $where = "sku != 'Preset' and purchase != 0";
  4200. //数据排序
  4201. $order_str = "id desc";
  4202. if (empty($page)) {
  4203. $start = 0;
  4204. $perpage = 1;
  4205. } else {
  4206. $start = ($page - 1) * $perpage;
  4207. }
  4208. //取得信息列表
  4209. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4210. $rows = array();
  4211. $list = array();
  4212. foreach ($info_list as $value) {
  4213. $warehouse = $this->warehouse->read($value['warehouse']);
  4214. $number = $value['number'];
  4215. $ftime = time() - 15 * 24 * 3600;
  4216. $purchase = $this->purchase->read($value['purchase']);
  4217. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4218. }
  4219. $title = "库存模板";
  4220. $titlename = "<table border=1>
  4221. <tr align='center'>
  4222. <td>仓库</td>
  4223. <td>供应商编码</td>
  4224. <td>SKU</td>
  4225. <td>增减数量(正数或负数)</td>
  4226. <td>增减备注</td>
  4227. <td>扣减方式:0减少库存1删除库存</td>
  4228. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4229. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4230. </tr>
  4231. </table>";
  4232. $filename = $title . ".xls";
  4233. $tail = "";
  4234. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4235. }
  4236. }
  4237. //数量调整模板导入
  4238. public function _presetedit()
  4239. {
  4240. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4241. $config['upload_path'] = '.' . $dir;
  4242. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4243. $config['allowed_types'] = 'xls|xlsx|csv';
  4244. $config['max_size'] = 10240;
  4245. $this->load->library('upload', $config);
  4246. $this->upload->initialize($config);
  4247. if ($this->upload->do_upload('userfile')) {
  4248. $full_path = $dir . $this->upload->data('file_name');
  4249. $fileName = '.' . $full_path;
  4250. if (!file_exists($fileName)) {
  4251. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4252. exit;
  4253. } else {
  4254. require_once "./data/excel/PHPExcel/IOFactory.php";
  4255. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4256. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4257. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4258. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4259. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4260. ++$column; //如果列数大于26行
  4261. $list = array();
  4262. for ($i = 2; $i <= $row; $i++) // 行数循环
  4263. {
  4264. $data = array();
  4265. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4266. {
  4267. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4268. }
  4269. $list[] = $data;
  4270. }
  4271. }
  4272. $i = 0;
  4273. $j = 0;
  4274. $ed = array();
  4275. foreach ($list as $key => $value) {
  4276. $time = time();
  4277. if ($value['0'] == "") {
  4278. continue;
  4279. }
  4280. $warehouse = $this->warehouse->get_title($value['0']);
  4281. $purchase = $this->purchase->get_bm($value['1']);
  4282. $sku = $value['2'];
  4283. $num = $value['3']; //调整数量
  4284. $text = $value['4']; //扣减说明
  4285. $type = $value['5']; //调整方式0扣减1删除
  4286. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4287. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4288. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4289. if (!$purchase) //如果没有这个SKU
  4290. {
  4291. $ed[] = array($purchase . '-不存在此供应商编码');
  4292. $j++;
  4293. continue;
  4294. }
  4295. if (!$d) //如果没有这个SKU
  4296. {
  4297. $ed[] = array($sku . '-库存中不存在此SKU');
  4298. $j++;
  4299. continue;
  4300. }
  4301. if (!isset($warehouse['id'])) {
  4302. $ed[] = array($sku . '-仓库名错误!');
  4303. $j++;
  4304. continue;
  4305. }
  4306. if ($type != '0' && $type != '1') {
  4307. $ed[] = array($sku . '-扣减方式填写错误!');
  4308. $j++;
  4309. continue;
  4310. }
  4311. if ($num < 0) //扣减库存
  4312. {
  4313. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4314. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4315. $j++;
  4316. continue;
  4317. }
  4318. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4319. if (count($data) < abs($num)) {
  4320. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4321. $j++;
  4322. continue;
  4323. }
  4324. if ($type == 0) //如果扣减方式为 扣减库存
  4325. {
  4326. for ($i = 0; $i < abs($num); $i++) {
  4327. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4328. }
  4329. } else if ($type == 1) {
  4330. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4331. if (count($zt) > 0) {
  4332. $ed[] = array($sku . '-有在途库存无法删除!');
  4333. $j++;
  4334. continue;
  4335. }
  4336. for ($i = 0; $i < abs($num); $i++) {
  4337. $this->whlabel->remove($data[$i]['id']);
  4338. }
  4339. }
  4340. } else if ($num > 0) //增加库存
  4341. {
  4342. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4343. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4344. $j++;
  4345. continue;
  4346. }
  4347. $post['sku'] = $d['sku'];
  4348. $post['shop'] = $d['shop'];
  4349. $post['warehouse'] = $warehouse['id'];
  4350. $post['purchase'] = $purchase['id'];
  4351. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4352. $post['state'] = 0;
  4353. $post['title'] = $d['title'];
  4354. $post['number'] = $d['number'];
  4355. $post['features'] = $d['features'];
  4356. $post['enter'] = $time;
  4357. $post['time'] = $time; //操作时间
  4358. $post['rktype'] = $rktype;
  4359. for ($i = 0; $i < $num; $i++) {
  4360. $post['label'] = time() . rand(100, 999) . $i;
  4361. $this->whlabel->insert($post);
  4362. }
  4363. }
  4364. sleep(1); //防止入库时间一样,需要延迟1秒
  4365. }
  4366. if ($j > 0) {
  4367. $tt = date('Ymd', time());
  4368. $title = '库存导入错误信息-' . $tt;
  4369. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4370. $tail = "\n";
  4371. $filename = $title . ".xls";
  4372. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4373. $dir = '/data/excel/' . $time . '/';
  4374. $file_name = 'error_' . $time . rand(1000, 9999);
  4375. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4376. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4377. fwrite($myfile, $ecl);
  4378. fclose($myfile);
  4379. $error = $dir . $file_name . '.xls';
  4380. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4381. exit;
  4382. } else {
  4383. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4384. exit;
  4385. }
  4386. }
  4387. }
  4388. //笛卡儿积
  4389. function cp($ps, $sets, $list)
  4390. {
  4391. $result = array();
  4392. $j = 0;
  4393. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4394. if ($i == 0) {
  4395. $result = $sets[$i];
  4396. }
  4397. $tmp = array();
  4398. foreach ($result as $res) {
  4399. foreach ($sets[$i + 1] as $set) {
  4400. $tmp[] = $res . ',' . $set;
  4401. }
  4402. }
  4403. $result = $tmp;
  4404. }
  4405. $this->db->trans_begin();
  4406. foreach ($result as $v) {
  4407. $post = array();
  4408. $title = "";
  4409. $num = "";
  4410. $data = explode(',', $v);
  4411. for ($i = 0; $i < count($list); $i++) {
  4412. $post[$list[$i]] = $data[$i];
  4413. $typeclass = $this->typeclass->read($data[$i]);
  4414. $title = $title . $typeclass['title'] . " ";
  4415. if ($data[$i] != 0) {
  4416. $num .= $data[$i]; //所有数据ID拼接
  4417. }
  4418. }
  4419. foreach ($ps as $kp => $vp) {
  4420. $post[$kp] = $vp;
  4421. }
  4422. $post['number'] = $num;
  4423. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4424. if ($info_list) {
  4425. $j++;
  4426. } else {
  4427. $skunum = $this->whlabel->find_count();
  4428. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4429. $post['title'] = rtrim($title, ' ');
  4430. $this->whlabel->insert($post);
  4431. }
  4432. }
  4433. if ($this->db->trans_status() === FALSE) {
  4434. $this->db->trans_commit();
  4435. return NULL;
  4436. } else {
  4437. $this->db->trans_commit();
  4438. return $j;
  4439. }
  4440. }
  4441. public function _kj($arg_array)
  4442. {
  4443. if (isset($_POST['sku'])) {
  4444. $time = time();
  4445. $sku = $this->input->post('sku', true);
  4446. $warehouse = $this->input->post('warehouse', true);
  4447. $num = $this->input->post('num', true);
  4448. $text = $this->input->post('text', true);
  4449. $purchase = $this->input->post('purchase', true);
  4450. $cktype = $this->input->post('cktype', true);
  4451. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4452. if ($cktype != 1 && $text == '') {
  4453. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4454. exit;
  4455. }
  4456. if ($num > count($order)) {
  4457. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4458. exit;
  4459. } else {
  4460. for ($i = 0; $i < $num; $i++) {
  4461. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4462. }
  4463. }
  4464. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4465. exit;
  4466. }
  4467. $uid = $this->whlabel->read($arg_array[0]);
  4468. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4469. $this->data['data'] = $uid;
  4470. $this->_Template('whlabel_kj', $this->data);
  4471. }
  4472. public function _summary($arg_array)
  4473. {
  4474. $prc = array();
  4475. $purchase = $this->purchase->find_all();
  4476. foreach ($purchase as $k => $v) {
  4477. $prc[$v['id']] = $v['title'];
  4478. }
  4479. if (isset($_GET['excel'])) {
  4480. $ktime = $this->input->get('ktime', true);
  4481. $jtime = $this->input->get('jtime', true);
  4482. $ktime = strtotime($ktime);
  4483. $jtime = strtotime($jtime);
  4484. $where = "1=1";
  4485. if ($ktime && $jtime) {
  4486. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4487. }
  4488. //数据排序
  4489. $order_str = "time desc";
  4490. if (empty($page)) {
  4491. $start = 0;
  4492. $perpage = 1;
  4493. } else {
  4494. $start = ($page - 1) * $perpage;
  4495. }
  4496. //取得信息列表
  4497. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4498. foreach ($info_list as $key => $value) {
  4499. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4500. $warehouse = $this->warehouse->read($value['warehouse']);
  4501. $info_list[$key]['warehouse'] = $warehouse['title'];
  4502. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4503. $details = array();
  4504. $cpid = array();
  4505. foreach ($x as $k => $v) {
  4506. if ($v['details'] != '') {
  4507. $details[$v['details']] = $v['details'];
  4508. }
  4509. if ($v['cpid'] != 0) {
  4510. $cpid[$v['cpid']] = $v['cpid'];
  4511. }
  4512. }
  4513. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4514. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4515. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4516. $info_list[$key]['s'] = $s;
  4517. $info_list[$key]['x'] = count($x);
  4518. }
  4519. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4520. $titlename = "<table border=1>
  4521. <tr align='center'>
  4522. <td>仓库</td>
  4523. <td>供应商</td>
  4524. <td>出库位置</td>
  4525. <td>出库编码</td>
  4526. <td>SKU</td>
  4527. <td>产品名</td>
  4528. <td>总剩余库存</td>
  4529. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4530. </tr>
  4531. </table>";
  4532. $filename = $title . ".xls";
  4533. $tail = "";
  4534. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4535. }
  4536. }
  4537. //usps发货清单
  4538. public function _manifest()
  4539. {
  4540. if (isset($_POST['manifest'])) {
  4541. $wltext = $this->input->post('wltext', true);
  4542. $time = time() - 16 * 3600;
  4543. $ptime = strtotime(date('Y-m-d', $time));
  4544. $waybill = array();
  4545. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4546. foreach ($fullorder as $v) {
  4547. $waybill[$v['waybill']] = $v['waybill'];
  4548. }
  4549. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4550. foreach ($fullordersmt as $v) {
  4551. $waybill[$v['waybill']] = $v['waybill'];
  4552. }
  4553. $wltext = explode(';', $wltext);
  4554. foreach ($wltext as $v) {
  4555. if (isset($waybill[$v])) {
  4556. unset($waybill[$v]);
  4557. }
  4558. }
  4559. $data = $this->usps->get_manifest($waybill);
  4560. if (isset($data['Description'])) {
  4561. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4562. exit;
  4563. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4564. $bctime = date('Ymd', time());
  4565. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4566. echo json_encode(array('msg' => $pdf, 'success' => true));
  4567. exit;
  4568. } else {
  4569. echo json_encode(array('msg' => $data, 'success' => false));
  4570. exit;
  4571. }
  4572. }
  4573. }
  4574. public function _pdf($pdf, $title, $bctime)
  4575. {
  4576. $pdf_path = './data/pdf/' . $bctime . '/';
  4577. $file_base64 = $pdf;
  4578. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4579. $file_base64 = base64_decode($file_base64);
  4580. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4581. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4582. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4583. }
  4584. /**
  4585. *
  4586. *
  4587. *
  4588. 进销存占单异常索引
  4589. *
  4590. *
  4591. *
  4592. **/
  4593. public function _abnormal()
  4594. {
  4595. $post = $this->input->post(NULL, TRUE);
  4596. if (isset($post['page'])) {
  4597. $page = $this->input->post('page', true);
  4598. $perpage = $this->input->post('perpage', true);
  4599. $sku = $this->input->post('sku', true);
  4600. $where = "1=1";
  4601. //数据排序
  4602. $order_str = "id desc";
  4603. if (empty($page)) {
  4604. $start = 0;
  4605. $perpage = 1;
  4606. } else {
  4607. $start = ($page - 1) * $perpage;
  4608. }
  4609. //取得信息列表
  4610. $info_list = $this->whlabel->find_all($where, '*');
  4611. $rows = array();
  4612. $list = array();
  4613. foreach ($info_list as $key => $value) {
  4614. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4615. }
  4616. foreach ($rows as $value) {
  4617. $warehouse = $this->warehouse->read($value['warehouse']);
  4618. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4619. $number = $value['number'];
  4620. $ftime = time() - 15 * 24 * 3600;
  4621. if ($value['shop'] != '') {
  4622. $shop = $value['shop'];
  4623. $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');
  4624. $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');
  4625. $order = array_merge($orderdlz, $ordersmt);
  4626. $od = 0;
  4627. $a = '';
  4628. $orid = '';
  4629. foreach ($order as $v) {
  4630. $or = explode('|', ltrim($v['whlabel'], '|'));
  4631. for ($i = 0; $i < count($or); $i++) {
  4632. $orod = explode('-', $or[$i]);
  4633. if ($orod[0] == $number) {
  4634. $od += $orod[1];
  4635. }
  4636. }
  4637. $orid .= $v['number'] . '-';
  4638. }
  4639. } else {
  4640. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4641. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4642. $order = array_merge($orderdlz, $ordersmt);
  4643. $od = 0;
  4644. $a = '';
  4645. $orid = '';
  4646. $qt = array();
  4647. foreach ($order as $v) {
  4648. $or = explode('|', ltrim($v['whlabel'], '|'));
  4649. for ($i = 0; $i < count($or); $i++) {
  4650. $orod = explode('-', $or[$i]);
  4651. if ($orod[0] == $number) {
  4652. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4653. if ($czzs > 0) {
  4654. if (isset($qt[$v['shop']])) {
  4655. if ($qt[$v['shop']] < $orod[1]) {
  4656. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4657. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4658. } else {
  4659. $qt[$v['shop']] -= $orod[1];
  4660. }
  4661. } else {
  4662. $qt[$v['shop']] = $czzs;
  4663. }
  4664. } else {
  4665. $od += $orod[1];
  4666. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4667. }
  4668. }
  4669. }
  4670. }
  4671. }
  4672. $z = $od . '(' . $orid . ')'; //查看订单号
  4673. //$z = $od;
  4674. if ($od > $c) {
  4675. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4676. }
  4677. }
  4678. $listdata = array_slice($list, $start, $perpage);
  4679. $total = count($list);
  4680. $pagenum = ceil($total / $perpage);
  4681. $over = $total - ($start + $perpage);
  4682. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4683. echo json_encode($rows);
  4684. exit;
  4685. }
  4686. $this->_Template('whlabel_abnormal', $this->data);
  4687. }
  4688. /**
  4689. *
  4690. *
  4691. *
  4692. 进销存占单异常索引
  4693. *
  4694. *
  4695. *
  4696. **/
  4697. public function _error()
  4698. {
  4699. $post = $this->input->post(NULL, TRUE);
  4700. if (isset($post['page'])) {
  4701. $page = $this->input->post('page', true);
  4702. $perpage = $this->input->post('perpage', true);
  4703. $sku = $this->input->post('sku', true);
  4704. $warehouse = $this->input->post('warehouse', true);
  4705. $ktime = $this->input->post('ktime', true);
  4706. $jtime = $this->input->post('jtime', true);
  4707. $ktime = strtotime($ktime);
  4708. $jtime = strtotime($jtime);
  4709. $where = "sku != 'Preset'";
  4710. $gj = '';
  4711. if ($sku) {
  4712. $where .= " and sku like '%$sku%'";
  4713. } else {
  4714. if ($ktime && $jtime) {
  4715. $gj = " and time > '$ktime' and time < '$jtime'";
  4716. }
  4717. }
  4718. if ($warehouse) {
  4719. $where .= " and warehouse = '$warehouse'";
  4720. }
  4721. //数据排序
  4722. $order_str = "id desc";
  4723. if (empty($page)) {
  4724. $start = 0;
  4725. $perpage = 1;
  4726. } else {
  4727. $start = ($page - 1) * $perpage;
  4728. }
  4729. //取得信息列表
  4730. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4731. $rows = array();
  4732. $list = array();
  4733. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4734. // foreach ($info_list as $value)
  4735. // {
  4736. // $warehouse = $this->warehouse->read($value['warehouse']);
  4737. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4738. // $number = $value['number'];$ftime = time()-15*24*3600;
  4739. // if($c < 1)
  4740. // {
  4741. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4742. // }
  4743. // }
  4744. $warehouse_list = $this->warehouse->find_all();
  4745. $warehouse_list = array_column($warehouse_list, null, 'id');
  4746. foreach ($info_list as $value) {
  4747. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4748. 'title' => "",
  4749. ];
  4750. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4751. $number = $value['number'];
  4752. $ftime = time() - 15 * 24 * 3600;
  4753. if ($c < 1) {
  4754. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4755. }
  4756. }
  4757. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4758. // $query = $this->db->query($sql);
  4759. // $info_list = $query->result_array();
  4760. // $sql_two = "select title,id from crowd_warehouse";
  4761. // $query_two = $this->db->query($sql_two);
  4762. // $warehouse_list = $query_two->result_array();
  4763. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4764. // foreach ($info_list as $value)
  4765. // {
  4766. // if(isset($warehouse_arr[$value['warehouse']])){
  4767. // $warehouse = $warehouse_arr[$value['warehouse']];
  4768. // }else{
  4769. // $warehouse = [
  4770. // 'id'=>0,
  4771. // 'title'=>"异常",
  4772. // ];
  4773. // }
  4774. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4775. // $number = $value['number'];$ftime = time()-15*24*3600;
  4776. // if($c < 1)
  4777. // {
  4778. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4779. // }
  4780. // }
  4781. $listdata = array_slice($list, $start, $perpage);
  4782. $total = count($list);
  4783. $pagenum = ceil($total / $perpage);
  4784. $over = $total - ($start + $perpage);
  4785. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4786. echo json_encode($rows);
  4787. exit;
  4788. }
  4789. if (isset($post['s'])) {
  4790. $id_arr = $this->input->post('s');
  4791. $id_arr = explode(',', trim($id_arr, ','));
  4792. if (!$id_arr) {
  4793. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4794. exit;
  4795. }
  4796. //循环删除记录
  4797. foreach ($id_arr as $v) {
  4798. $dd = $this->whlabel->read($v);
  4799. if (!isset($dd['id'])) {
  4800. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4801. exit;
  4802. }
  4803. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4804. if (isset($zt[0])) {
  4805. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4806. exit;
  4807. }
  4808. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4809. foreach ($deldd as $vv) {
  4810. $this->whlabel->remove($vv['id']);
  4811. }
  4812. }
  4813. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4814. exit;
  4815. }
  4816. $this->_Template('whlabel_error', $this->data);
  4817. }
  4818. public function _errorexcel()
  4819. {
  4820. $post = $this->input->post(NULL, TRUE);
  4821. if (isset($_GET['page'])) {
  4822. $page = $this->input->get('page', true);
  4823. $perpage = $this->input->get('perpage', true);
  4824. $sku = $this->input->get('sku', true);
  4825. $warehouse = $this->input->get('warehouse', true);
  4826. $ktime = $this->input->get('ktime', true);
  4827. $jtime = $this->input->get('jtime', true);
  4828. $ktime = strtotime($ktime);
  4829. $jtime = strtotime($jtime);
  4830. $where = "sku != 'Preset'";
  4831. $gj = '';
  4832. if ($sku) {
  4833. $where .= " and sku like '%$sku%'";
  4834. } else {
  4835. if ($ktime && $jtime) {
  4836. $gj = " and time > '$ktime' and time < '$jtime'";
  4837. }
  4838. }
  4839. if ($warehouse) {
  4840. $where .= " and warehouse = '$warehouse'";
  4841. }
  4842. //数据排序
  4843. $order_str = "id desc";
  4844. if (empty($page)) {
  4845. $start = 0;
  4846. $perpage = 1;
  4847. } else {
  4848. $start = ($page - 1) * $perpage;
  4849. }
  4850. //取得信息列表
  4851. $rows = array();
  4852. $list = array();
  4853. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4854. foreach ($info_list as $value) {
  4855. $warehouse = $this->warehouse->read($value['warehouse']);
  4856. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4857. $number = $value['number'];
  4858. $ftime = time() - 15 * 24 * 3600;
  4859. if ($c < 1) {
  4860. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4861. }
  4862. }
  4863. $title = "0库存汇总";
  4864. $titlename = "<table border=1>
  4865. <tr align='center'>
  4866. <td>仓库</td>
  4867. <td>SKU</td>
  4868. <td>产品</td>
  4869. <td>当前库存</td>
  4870. </tr>
  4871. </table>";
  4872. $filename = $title . ".xls";
  4873. $tail = "";
  4874. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4875. }
  4876. }
  4877. /**
  4878. *
  4879. *
  4880. * 占单
  4881. *
  4882. *
  4883. **/
  4884. public function _kcyz()
  4885. {
  4886. $post = $this->input->post(NULL, TRUE);
  4887. if (isset($post['warehouse'])) {
  4888. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4889. exit; //不再使用
  4890. $warehouse = $this->input->post('warehouse', true);
  4891. $whlabel = $this->input->post('whlabel', true);
  4892. $id = $this->input->post('id', true);
  4893. $shop = $this->input->post('shop', true);
  4894. $number = $this->input->post('number', true);
  4895. if (!$whlabel || $whlabel == '|') {
  4896. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4897. exit;
  4898. }
  4899. $pp = explode('|', trim($whlabel, '|'));
  4900. $x = 0;
  4901. $save = array();
  4902. foreach ($pp as $va) {
  4903. $num = explode('-', $va);
  4904. if ($number) {
  4905. $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 = '')"); //通用
  4906. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4907. } else {
  4908. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4909. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4910. }
  4911. $x++;
  4912. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4913. $save[] = $x - 1;
  4914. continue; //提前先加X不然出错,所以要减1
  4915. }
  4916. }
  4917. if (isset($save[0])) {
  4918. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4919. exit;
  4920. } else {
  4921. echo json_encode(array('success' => true));
  4922. exit;
  4923. }
  4924. }
  4925. }
  4926. public function _db()
  4927. {
  4928. $post = $this->input->post(NULL, TRUE);
  4929. if (isset($post['page'])) {
  4930. $page = $this->input->post('page', true);
  4931. $perpage = $this->input->post('perpage', true);
  4932. $sku = $this->input->post('sku', true);
  4933. $number = $this->input->post('number', true);
  4934. $warehouse = $this->input->post('warehouse', true);
  4935. $purchase = $this->input->post('purchase', true);
  4936. $orderinfo = $this->input->post('orderinfo', true);
  4937. $waybill = $this->input->post('waybill', true);
  4938. $category = $this->input->post('category', true);
  4939. $size = $this->input->post('size', true);
  4940. $grade = $this->input->post('grade', true);
  4941. $color = $this->input->post('color', true);
  4942. $lowe = $this->input->post('lowe', true);
  4943. $state = $this->input->post('state', true);
  4944. $label = $this->input->post('label', true);
  4945. $timetk = $this->input->post('timetkk', true);
  4946. $timetj = $this->input->post('timetjj', true);
  4947. $timetk = strtotime($timetk);
  4948. $timetj = strtotime($timetj);
  4949. $where = "dbtime > 0";
  4950. if ($timetk && $timetj) {
  4951. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4952. }
  4953. if ($sku) {
  4954. $where .= " and sku = '$sku'";
  4955. }
  4956. if ($warehouse) {
  4957. $where .= " and warehouse = '$warehouse'";
  4958. if ($warehouse == 12) {
  4959. $w = 'specialstock';
  4960. } else {
  4961. $w = 'whlabel';
  4962. }
  4963. }
  4964. if ($purchase) {
  4965. $where .= " and purchase = '$purchase'";
  4966. }
  4967. if ($category) {
  4968. $where .= " and features like '%-$category-%'";
  4969. }
  4970. if ($size) {
  4971. $where .= " and features like '%-$size-%'";
  4972. }
  4973. if ($grade) {
  4974. $where .= " and features like '%-$grade-%'";
  4975. }
  4976. if ($color) {
  4977. $where .= " and features like '%-$color-%'";
  4978. }
  4979. if ($lowe) {
  4980. $where .= " and features like '%-$lowe-%'";
  4981. }
  4982. if ($state != '') {
  4983. $where .= " and state = '$state'";
  4984. }
  4985. //数据排序
  4986. $order_str = "dbtime desc";
  4987. if (empty($page)) {
  4988. $start = 0;
  4989. $perpage = 1;
  4990. } else {
  4991. $start = ($page - 1) * $perpage;
  4992. }
  4993. //取得信息列表
  4994. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  4995. foreach ($info_list as $key => $value) {
  4996. $warehouse = $this->$w->read($value['warehouse']);
  4997. $info_list[$key]['warehouse'] = $warehouse['title'];
  4998. $purchase = $this->purchase->read($value['purchase']);
  4999. $info_list[$key]['purchase'] = $purchase['title'];
  5000. if ($value['enter'] != 0) {
  5001. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5002. } else {
  5003. $info_list[$key]['enter'] = "";
  5004. }
  5005. if ($value['dbtime'] != 0) {
  5006. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5007. } else {
  5008. $info_list[$key]['dbtime'] = "";
  5009. }
  5010. if ($value['state'] == 0) {
  5011. $info_list[$key]['state'] = "在库";
  5012. } else if ($value['state'] == 1) {
  5013. $info_list[$key]['state'] = "出库";
  5014. } else if ($value['state'] == 2) {
  5015. $info_list[$key]['state'] = "退库";
  5016. } else if ($value['state'] == 3) {
  5017. $info_list[$key]['state'] = "调拨中";
  5018. } else if ($value['state'] == 4) {
  5019. $info_list[$key]['state'] = "再加工";
  5020. } else if ($value['state'] == 5) {
  5021. $info_list[$key]['state'] = "维修中";
  5022. } else if ($value['state'] == 6) {
  5023. $info_list[$key]['state'] = "盘亏";
  5024. } else if ($value['state'] == 7) {
  5025. $info_list[$key]['state'] = "更换标签";
  5026. } else if ($value['state'] == 8) {
  5027. $info_list[$key]['state'] = "其它";
  5028. } else if ($value['state'] == 9) {
  5029. $info_list[$key]['state'] = "预设";
  5030. }
  5031. }
  5032. $total = $this->whlabel->find_count($where);
  5033. $pagenum = ceil($total / $perpage);
  5034. $over = $total - ($start + $perpage);
  5035. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5036. echo json_encode($rows);
  5037. exit;
  5038. }
  5039. if (isset($post['outsku'])) {
  5040. $time = time();
  5041. $cz = $this->input->post('cz', true);
  5042. $label = $this->input->post('outsku', true);
  5043. $sl = $this->input->post('sl', true);
  5044. $num = $this->input->post('num', true);
  5045. //$warehouse = $this->input->post('warehouse',true);
  5046. if (!$sl) {
  5047. $sl = 1;
  5048. }
  5049. if (!$warehouse) {
  5050. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5051. exit;
  5052. }
  5053. $dblabel = $this->whlabellabel->get_label($label);
  5054. if ($dblabel) {
  5055. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5056. if (count($data) < 1) {
  5057. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5058. exit;
  5059. }
  5060. if (count($data) < $num) {
  5061. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5062. exit;
  5063. }
  5064. for ($i = 0; $i < $sl; $i++) {
  5065. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5066. }
  5067. echo json_encode(array('success' => true));
  5068. exit;
  5069. } else {
  5070. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5071. exit;
  5072. }
  5073. }
  5074. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5075. $this->_Template('whlabel_db', $this->data);
  5076. }
  5077. public function _dbrk()
  5078. {
  5079. $post = $this->input->post(NULL, TRUE);
  5080. if (isset($post['page'])) {
  5081. $page = $this->input->post('page', true);
  5082. $perpage = $this->input->post('perpage', true);
  5083. $sku = $this->input->post('sku', true);
  5084. $number = $this->input->post('number', true);
  5085. $warehouse = $this->input->post('warehouse', true);
  5086. $purchase = $this->input->post('purchase', true);
  5087. $orderinfo = $this->input->post('orderinfo', true);
  5088. $waybill = $this->input->post('waybill', true);
  5089. $category = $this->input->post('category', true);
  5090. $size = $this->input->post('size', true);
  5091. $grade = $this->input->post('grade', true);
  5092. $color = $this->input->post('color', true);
  5093. $lowe = $this->input->post('lowe', true);
  5094. $state = $this->input->post('state', true);
  5095. $label = $this->input->post('label', true);
  5096. $ctime = $this->input->post('ctime', true);
  5097. $timetk = $this->input->post('timetkk', true);
  5098. $timetj = $this->input->post('timetjj', true);
  5099. $timetk = strtotime($timetk);
  5100. $timetj = strtotime($timetj);
  5101. $where = "dbtime > 0";
  5102. if ($timetk && $timetj) {
  5103. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5104. }
  5105. if ($sku) {
  5106. $where .= " and sku = '$sku'";
  5107. }
  5108. if ($warehouse) {
  5109. $where .= " and warehouse = '$warehouse'";
  5110. }
  5111. if ($purchase) {
  5112. $where .= " and purchase = '$purchase'";
  5113. }
  5114. if ($category) {
  5115. $where .= " and features like '%-$category-%'";
  5116. }
  5117. if ($size) {
  5118. $where .= " and features like '%-$size-%'";
  5119. }
  5120. if ($grade) {
  5121. $where .= " and features like '%-$grade-%'";
  5122. }
  5123. if ($color) {
  5124. $where .= " and features like '%-$color-%'";
  5125. }
  5126. if ($lowe) {
  5127. $where .= " and features like '%-$lowe-%'";
  5128. }
  5129. if ($state != '') {
  5130. $where .= " and state = '$state'";
  5131. }
  5132. //数据排序
  5133. $order_str = "dbtime desc";
  5134. if (empty($page)) {
  5135. $start = 0;
  5136. $perpage = 1;
  5137. } else {
  5138. $start = ($page - 1) * $perpage;
  5139. }
  5140. //取得信息列表
  5141. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5142. foreach ($info_list as $key => $value) {
  5143. $warehouse = $this->warehouse->read($value['warehouse']);
  5144. $info_list[$key]['warehouse'] = $warehouse['title'];
  5145. $purchase = $this->purchase->read($value['purchase']);
  5146. $info_list[$key]['purchase'] = $purchase['title'];
  5147. if ($value['enter'] != 0) {
  5148. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5149. } else {
  5150. $info_list[$key]['enter'] = "";
  5151. }
  5152. if ($value['dbtime'] != 0) {
  5153. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5154. } else {
  5155. $info_list[$key]['dbtime'] = "";
  5156. }
  5157. if ($value['state'] == 0) {
  5158. $info_list[$key]['state'] = "在库";
  5159. } else if ($value['state'] == 1) {
  5160. $info_list[$key]['state'] = "出库";
  5161. } else if ($value['state'] == 2) {
  5162. $info_list[$key]['state'] = "退库";
  5163. } else if ($value['state'] == 3) {
  5164. $info_list[$key]['state'] = "调拨中";
  5165. } else if ($value['state'] == 4) {
  5166. $info_list[$key]['state'] = "再加工";
  5167. } else if ($value['state'] == 5) {
  5168. $info_list[$key]['state'] = "维修中";
  5169. } else if ($value['state'] == 6) {
  5170. $info_list[$key]['state'] = "盘亏";
  5171. } else if ($value['state'] == 7) {
  5172. $info_list[$key]['state'] = "更换标签";
  5173. } else if ($value['state'] == 8) {
  5174. $info_list[$key]['state'] = "其它";
  5175. } else if ($value['state'] == 9) {
  5176. $info_list[$key]['state'] = "预设";
  5177. }
  5178. }
  5179. $total = $this->whlabel->find_count($where);
  5180. $pagenum = ceil($total / $perpage);
  5181. $over = $total - ($start + $perpage);
  5182. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5183. echo json_encode($rows);
  5184. exit;
  5185. }
  5186. if (isset($post['rsku'])) {
  5187. $cz = $this->input->post('cz', true);
  5188. $label = $this->input->post('rsku', true);
  5189. $sl = $this->input->post('sl', true);
  5190. $warehouse = $this->input->post('warehouse', true);
  5191. if (!$sl) {
  5192. $sl = 1;
  5193. }
  5194. if (!$warehouse) {
  5195. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5196. exit;
  5197. }
  5198. $dblabel = $this->whlabellabel->get_label($label);
  5199. if ($dblabel) {
  5200. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5201. if (count($data) < 1) {
  5202. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5203. exit;
  5204. }
  5205. if ($sl > count($data)) {
  5206. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5207. exit;
  5208. }
  5209. $time = time();
  5210. for ($i = 0; $i < $sl; $i++) {
  5211. $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']);
  5212. }
  5213. echo json_encode(array('success' => true));
  5214. exit;
  5215. } else {
  5216. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5217. exit;
  5218. }
  5219. }
  5220. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5221. $this->_Template('whlabel_dbrk', $this->data);
  5222. }
  5223. public function _whlabelczdc()
  5224. {
  5225. if (isset($_GET['excel'])) {
  5226. //数据排序
  5227. $order_str = "id desc";
  5228. if (empty($page)) {
  5229. $start = 0;
  5230. $perpage = 1;
  5231. } else {
  5232. $start = ($page - 1) * $perpage;
  5233. }
  5234. $state = $this->input->get('state', true);
  5235. $sku = $this->input->get('sku', true);
  5236. $ctime = $this->input->get('ctime', true);
  5237. $category = $this->input->get('category', true);
  5238. $size = $this->input->get('size', true);
  5239. $grade = $this->input->get('grade', true);
  5240. $color = $this->input->get('color', true);
  5241. $lowe = $this->input->get('lowe', true);
  5242. $timetk = $this->input->get('timetkk', true);
  5243. $timetj = $this->input->get('timetjj', true);
  5244. $timetk = strtotime($timetk);
  5245. $timetj = strtotime($timetj);
  5246. $where = "dbtime > 0";
  5247. if ($timetk && $timetj) {
  5248. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5249. }
  5250. if ($category) {
  5251. $where .= " and features like '%-$category-%'";
  5252. }
  5253. if ($size) {
  5254. $where .= " and features like '%-$size-%'";
  5255. }
  5256. if ($grade) {
  5257. $where .= " and features like '%-$grade-%'";
  5258. }
  5259. if ($color) {
  5260. $where .= " and features like '%-$color-%'";
  5261. }
  5262. if ($lowe) {
  5263. $where .= " and features like '%-$lowe-%'";
  5264. }
  5265. //取得信息列表
  5266. $info_list = $this->whlabel->find_all($where, '*');
  5267. $rows = array();
  5268. $list = array();
  5269. foreach ($info_list as $key => $value) {
  5270. $rows[$value['sku']] = $value; //所有数据sku
  5271. }
  5272. foreach ($rows as $value) {
  5273. $warehouse = $this->warehouse->read($value['warehouse']);
  5274. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5275. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5276. if ($value['orderinfo'] == 0) {
  5277. $info_list[$key]['orderinfo'] = "";
  5278. }
  5279. if ($value['waybill'] == 0) {
  5280. $info_list[$key]['waybill'] = "";
  5281. }
  5282. if ($value['state'] == 0) {
  5283. $value['state'] = "在库";
  5284. } else if ($value['state'] == 3) {
  5285. $value['state'] = "调拨中";
  5286. }
  5287. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5288. }
  5289. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5290. $titlename = "<table border=1>
  5291. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5292. <tr align='center'>
  5293. <td>SKU</td>
  5294. <td>产品</td>
  5295. <td>调拨数量</td>
  5296. <td>入库数量</td>
  5297. </tr>
  5298. </table>";
  5299. $filename = $title . ".xls";
  5300. $tail = "";
  5301. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5302. }
  5303. }
  5304. public function _print($arg_array)
  5305. {
  5306. if (isset($_SESSION['api'])) {
  5307. $user = $this->user->get_api($_SESSION['api']);
  5308. $usp = $user;
  5309. $fgshop = "";
  5310. $sid = "";
  5311. $wid = "";
  5312. $wtype = "";
  5313. $usersp = explode('|', trim($user['shop'], '|'));
  5314. $userwh = explode('|', trim($user['warehouse'], '|'));
  5315. foreach ($usersp as $value) {
  5316. $fgshop .= " shop = " . $value . " or";
  5317. $sid .= " id = " . $value . " or";
  5318. }
  5319. foreach ($userwh as $value) {
  5320. $wid .= " id = " . $value . " or";
  5321. $wtype .= " type = " . $value . " or";
  5322. }
  5323. }
  5324. $post = $this->input->post(NULL, TRUE);
  5325. if (isset($post['tmsku'])) {
  5326. $tmsku = $this->input->post('tmsku', true);
  5327. if (is_numeric($tmsku)) {
  5328. $yyh = $this->whlabellabel->get_label($tmsku);
  5329. } else {
  5330. $yyh = $this->whlabellabel->get_sku($tmsku);
  5331. }
  5332. if ($yyh) {
  5333. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5334. exit;
  5335. } else {
  5336. echo json_encode(array('success' => false));
  5337. exit;
  5338. }
  5339. }
  5340. $classid = $this->classid->sku();
  5341. $pm = $classid;
  5342. $scsku = $classid;
  5343. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5344. if (isset($post['warehouse'])) {
  5345. if ($post['warehouse']) {
  5346. $list = array();
  5347. $num = "";
  5348. $title = "";
  5349. $features = "";
  5350. $order = 0;
  5351. $post['shop'] = '';
  5352. $brand = $this->input->post('brand', true);
  5353. if ($brand != '0,') {
  5354. $b = $this->brand->read(rtrim($brand, ','));
  5355. if ($b) {
  5356. $post['shop'] = str_replace('|', ',', $b['shop']);
  5357. }
  5358. }
  5359. $post['details'] = $this->input->post('details', true); //打印数量
  5360. $xbqnum = $this->input->post('xbqnum', true);
  5361. $post['purchase'] = $this->input->post('purchase', true);
  5362. $post['warehouse'] = $this->input->post('warehouse', true);
  5363. $post['purchase'] = $this->input->post('purchase', true);
  5364. $post['retreatwarehouse'] = $post['warehouse'];
  5365. $post['cpbz'] = $this->input->post('cpbz', true);
  5366. $post['state'] = 9;
  5367. $category = $this->input->post('category', true);
  5368. $list['category'] = $category;
  5369. $list['hairtype'] = $this->input->post('hairtype', true);
  5370. $list['grade'] = $this->input->post('grade', true);
  5371. $size = $this->input->post('size', true);
  5372. $list['size'] = rtrim($size, ',');
  5373. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5374. $list['extension'] = $this->input->post('extension', true);
  5375. if ($category == 1297) {
  5376. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5377. }
  5378. if ($category == 1702) {
  5379. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5380. $list['syother'] = $this->input->post('syother', true);
  5381. }
  5382. if ($category == 133) {
  5383. $list['fittype'] = $this->input->post('fittype', true);
  5384. $list['acother'] = $this->input->post('acother', true);
  5385. }
  5386. $list['color'] = $this->input->post('color', true);
  5387. $list['lowe'] = $this->input->post('lowe', true);
  5388. if ($category == 127) {
  5389. $list['type'] = $this->input->post('type', true);
  5390. $list['headroad'] = $this->input->post('headroad', true);
  5391. $list['density'] = $this->input->post('density', true);
  5392. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5393. $list['lacesize'] = $this->input->post('lacesize', true);
  5394. }
  5395. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5396. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5397. }
  5398. if ($category == 128) {
  5399. $list['lacetype'] = $this->input->post('lacetype', true);
  5400. $list['haircap'] = $this->input->post('haircap', true);
  5401. $list['density'] = $this->input->post('density', true);
  5402. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5403. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5404. $list['wigother'] = $this->input->post('wigother', true);
  5405. $list['wigother1'] = $this->input->post('wigother1', true);
  5406. $list['wigother2'] = $this->input->post('wigother2', true);
  5407. }
  5408. if ($category == 129) {
  5409. $list['wide'] = $this->input->post('wide', true);
  5410. }
  5411. if ($category == 131) {
  5412. $list['gifttype'] = $this->input->post('gifttype', true);
  5413. $list['giftother'] = $this->input->post('giftother', true);
  5414. }
  5415. if ($category == 134) {
  5416. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5417. }
  5418. if ($category == 1297) {
  5419. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5420. $list['sywigother'] = $this->input->post('sywigother', true);
  5421. }
  5422. if ($category == 130 || $category == 133 || $category == 1702) {
  5423. $list['items'] = $this->input->post('items', true);
  5424. $list['weight'] = $this->input->post('weight', true);
  5425. }
  5426. if ($category == 1702) {
  5427. $list['syhairther'] = $this->input->post('syhairther', true);
  5428. }
  5429. foreach ($list as $k => $v) {
  5430. if ($v != 0) {
  5431. $num .= $v;
  5432. $features .= $v . '-';
  5433. $post[$k] = $v;
  5434. $typeclass = $this->typeclass->read($v);
  5435. if (isset($pm[$typeclass['classid']])) {
  5436. if (stripos($typeclass['zh'], '|') !== false) {
  5437. $exzh = explode('|', $typeclass['zh']);
  5438. $pm[$typeclass['classid']] = $exzh[0];
  5439. } else {
  5440. $pm[$typeclass['classid']] = $typeclass['zh'];
  5441. }
  5442. }
  5443. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5444. if ($k != 'size') {
  5445. $title .= $typeclass['title'] . " ";
  5446. }
  5447. }
  5448. }
  5449. $typeclass = $this->typeclass->read($list['size']);
  5450. $title .= $typeclass['title'];
  5451. $time = time();
  5452. $post['title'] = rtrim($title, ' ');
  5453. $post['number'] = $num;
  5454. $post['features'] = '-' . $features;
  5455. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5456. $featurespp = explode('-', trim($featurespp, '-'));
  5457. if (isset($featurespp[5])) {
  5458. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5459. } else {
  5460. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5461. }
  5462. $post['enter'] = $time;
  5463. $post['time'] = $time; //操作时间
  5464. $scsku = implode("-", $scsku);
  5465. $zh = implode(" ", $pm);
  5466. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5467. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5468. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5469. $post['sku'] = $bqsku;
  5470. $label = time() . rand(0, 9);
  5471. $post['label'] = $label;
  5472. $cpid = $this->whlabellabel->find_count();
  5473. $post['cpid'] = $cpid + 1;
  5474. $cpid = $post['cpid'];
  5475. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5476. //if($whlabelbarcode)
  5477. //{
  5478. //$post['label'] = $whlabelbarcode['label'];
  5479. //if(!$this->whlabellabel->insert($post))
  5480. //{
  5481. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5482. //}
  5483. //}
  5484. //else
  5485. //{
  5486. $this->db->trans_begin();
  5487. $this->whlabellabel->insert($post);
  5488. //$this->whlabelbarcode->insert($post);
  5489. if ($this->db->trans_status() === TRUE) {
  5490. $this->db->trans_commit();
  5491. } else {
  5492. $this->db->trans_rollback();
  5493. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5494. exit;
  5495. }
  5496. //}
  5497. $warehouse_name = "";
  5498. $warehouse = $post['warehouse'];
  5499. if($warehouse == 12){
  5500. $warehouse_name = "特殊库存库";
  5501. }
  5502. // if($warehouse == 13){
  5503. // $warehouse_name = "许昌仓";
  5504. // }
  5505. // if($warehouse == 5){
  5506. // $warehouse_name = "美国店";
  5507. // }
  5508. // if($warehouse == 16){
  5509. // $warehouse_name = "定制头套仓";
  5510. // }
  5511. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5512. if(!empty($warehouse_name)){
  5513. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  5514. }
  5515. $purchase = $this->purchase->read($post['purchase']);
  5516. 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));
  5517. exit; //特殊仓目前不需要仓库选项
  5518. }
  5519. }
  5520. if (isset($_SESSION['api'])) {
  5521. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5522. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5523. $this->data['wlshop'] = $wlshop;
  5524. $this->data['warehouse'] = $warehouse;
  5525. }
  5526. $whlabelwz = $this->whlabelwz->find_all();
  5527. $this->data['whlabelwz'] = $whlabelwz;
  5528. $this->_Template('whlabel_print', $this->data);
  5529. }
  5530. public function _usaprint($arg_array)
  5531. {
  5532. if (isset($_SESSION['api'])) {
  5533. $user = $this->user->get_api($_SESSION['api']);
  5534. $usp = $user;
  5535. $fgshop = "";
  5536. $sid = "";
  5537. $wid = "";
  5538. $wtype = "";
  5539. $usersp = explode('|', trim($user['shop'], '|'));
  5540. $userwh = explode('|', trim($user['warehouse'], '|'));
  5541. foreach ($usersp as $value) {
  5542. $fgshop .= " shop = " . $value . " or";
  5543. $sid .= " id = " . $value . " or";
  5544. }
  5545. foreach ($userwh as $value) {
  5546. $wid .= " id = " . $value . " or";
  5547. $wtype .= " type = " . $value . " or";
  5548. }
  5549. }
  5550. $post = $this->input->post(NULL, TRUE);
  5551. if (isset($post['tmsku'])) {
  5552. $tmsku = $this->input->post('tmsku', true);
  5553. if (is_numeric($tmsku)) {
  5554. $yyh = $this->whlabellabel->get_label($tmsku);
  5555. } else {
  5556. $yyh = $this->whlabellabel->get_sku($tmsku);
  5557. }
  5558. if ($yyh) {
  5559. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5560. exit;
  5561. } else {
  5562. echo json_encode(array('success' => false));
  5563. exit;
  5564. }
  5565. }
  5566. $classid = $this->classid->sku();
  5567. $pm = $classid;
  5568. $scsku = $classid;
  5569. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5570. if (isset($post['warehouse'])) {
  5571. if ($post['warehouse']) {
  5572. $list = array();
  5573. $num = "";
  5574. $title = "";
  5575. $features = "";
  5576. $order = 0;
  5577. $post['shop'] = '';
  5578. $brand = $this->input->post('brand', true);
  5579. if ($brand != '0,') {
  5580. $b = $this->brand->read(rtrim($brand, ','));
  5581. if ($b) {
  5582. $post['shop'] = str_replace('|', ',', $b['shop']);
  5583. }
  5584. }
  5585. $post['details'] = $this->input->post('details', true); //打印数量
  5586. $xbqnum = $this->input->post('xbqnum', true);
  5587. $post['purchase'] = $this->input->post('purchase', true);
  5588. $post['warehouse'] = $this->input->post('warehouse', true);
  5589. $post['purchase'] = $this->input->post('purchase', true);
  5590. $post['retreatwarehouse'] = $post['warehouse'];
  5591. $post['cpbz'] = $this->input->post('cpbz', true);
  5592. $post['state'] = 9;
  5593. $category = $this->input->post('category', true);
  5594. $list['category'] = $category;
  5595. $list['hairtype'] = $this->input->post('hairtype', true);
  5596. $list['grade'] = $this->input->post('grade', true);
  5597. $size = $this->input->post('size', true);
  5598. $list['size'] = rtrim($size, ',');
  5599. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5600. $list['extension'] = $this->input->post('extension', true);
  5601. if ($category == 1297) {
  5602. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5603. }
  5604. if ($category == 1702) {
  5605. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5606. $list['syother'] = $this->input->post('syother', true);
  5607. }
  5608. if ($category == 133) {
  5609. $list['fittype'] = $this->input->post('fittype', true);
  5610. $list['acother'] = $this->input->post('acother', true);
  5611. }
  5612. $list['color'] = $this->input->post('color', true);
  5613. $list['lowe'] = $this->input->post('lowe', true);
  5614. if ($category == 127) {
  5615. $list['type'] = $this->input->post('type', true);
  5616. $list['headroad'] = $this->input->post('headroad', true);
  5617. $list['density'] = $this->input->post('density', true);
  5618. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5619. $list['lacesize'] = $this->input->post('lacesize', true);
  5620. }
  5621. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5622. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5623. }
  5624. if ($category == 128) {
  5625. $list['lacetype'] = $this->input->post('lacetype', true);
  5626. $list['haircap'] = $this->input->post('haircap', true);
  5627. $list['density'] = $this->input->post('density', true);
  5628. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5629. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5630. $list['wigother'] = $this->input->post('wigother', true);
  5631. $list['wigother1'] = $this->input->post('wigother1', true);
  5632. $list['wigother2'] = $this->input->post('wigother2', true);
  5633. }
  5634. if ($category == 129) {
  5635. $list['wide'] = $this->input->post('wide', true);
  5636. }
  5637. if ($category == 131) {
  5638. $list['gifttype'] = $this->input->post('gifttype', true);
  5639. $list['giftother'] = $this->input->post('giftother', true);
  5640. }
  5641. if ($category == 134) {
  5642. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5643. }
  5644. if ($category == 1297) {
  5645. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5646. $list['sywigother'] = $this->input->post('sywigother', true);
  5647. }
  5648. if ($category == 130 || $category == 133 || $category == 1702) {
  5649. $list['items'] = $this->input->post('items', true);
  5650. $list['weight'] = $this->input->post('weight', true);
  5651. }
  5652. if ($category == 1702) {
  5653. $list['syhairther'] = $this->input->post('syhairther', true);
  5654. }
  5655. foreach ($list as $k => $v) {
  5656. if ($v != 0) {
  5657. $num .= $v;
  5658. $features .= $v . '-';
  5659. $post[$k] = $v;
  5660. $typeclass = $this->typeclass->read($v);
  5661. if (isset($pm[$typeclass['classid']])) {
  5662. if (stripos($typeclass['zh'], '|') !== false) {
  5663. $exzh = explode('|', $typeclass['zh']);
  5664. $pm[$typeclass['classid']] = $exzh[0];
  5665. } else {
  5666. $pm[$typeclass['classid']] = $typeclass['zh'];
  5667. }
  5668. }
  5669. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5670. if ($k != 'size') {
  5671. $title .= $typeclass['title'] . " ";
  5672. }
  5673. }
  5674. }
  5675. $typeclass = $this->typeclass->read($list['size']);
  5676. $title .= $typeclass['title'];
  5677. $time = time();
  5678. $post['title'] = rtrim($title, ' ');
  5679. $post['number'] = $num;
  5680. $post['features'] = '-' . $features;
  5681. $fp = $this->whlabel->get_features($post['features']);
  5682. if (!$fp) {
  5683. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5684. exit;
  5685. }
  5686. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5687. $featurespp = explode('-', trim($featurespp, '-'));
  5688. if (isset($featurespp[5])) {
  5689. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5690. } else {
  5691. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5692. }
  5693. $post['enter'] = $time;
  5694. $post['time'] = $time; //操作时间
  5695. $scsku = implode("-", $scsku);
  5696. $zh = implode(" ", $pm);
  5697. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5698. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5699. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5700. $post['sku'] = $fp['sku'];
  5701. $post['label'] = $fp['sku'];
  5702. $cpid = $this->whlabellabel->find_count();
  5703. $post['cpid'] = $cpid + 1;
  5704. $cpid = $post['cpid'];
  5705. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5706. //if($whlabelbarcode)
  5707. //{
  5708. //$post['label'] = $whlabelbarcode['label'];
  5709. //if(!$this->whlabellabel->insert($post))
  5710. //{
  5711. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5712. //}
  5713. //}
  5714. //else
  5715. //{
  5716. $this->db->trans_begin();
  5717. $this->whlabellabel->insert($post);
  5718. //$this->whlabelbarcode->insert($post);
  5719. if ($this->db->trans_status() === TRUE) {
  5720. $this->db->trans_commit();
  5721. } else {
  5722. $this->db->trans_rollback();
  5723. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5724. exit;
  5725. }
  5726. //}
  5727. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5728. $purchase = $this->purchase->read($post['purchase']);
  5729. 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));
  5730. exit; //特殊仓目前不需要仓库选项
  5731. }
  5732. }
  5733. if (isset($_SESSION['api'])) {
  5734. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5735. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5736. $this->data['wlshop'] = $wlshop;
  5737. $this->data['warehouse'] = $warehouse;
  5738. }
  5739. $whlabelwz = $this->whlabelwz->find_all();
  5740. $this->data['whlabelwz'] = $whlabelwz;
  5741. $this->_Template('whlabel_usaprint', $this->data);
  5742. }
  5743. public function _printrk($arg_array)
  5744. {
  5745. $prc = array();
  5746. $purchase = $this->purchase->find_all();
  5747. foreach ($purchase as $k => $v) {
  5748. $prc[$v['id']] = $v['title'];
  5749. }
  5750. $post = $this->input->post(NULL, TRUE);
  5751. if (isset($post['page'])) {
  5752. $page = $this->input->post('page', true);
  5753. $perpage = $this->input->post('perpage', true);
  5754. $sku = $this->input->post('sku', true);
  5755. $bs = $this->input->post('bs', true);
  5756. $number = $this->input->post('number', true);
  5757. $warehouse = $this->input->post('warehouse', true);
  5758. $purchase = $this->input->post('purchase', true);
  5759. $orderinfo = $this->input->post('orderinfo', true);
  5760. $waybill = $this->input->post('waybill', true);
  5761. $category = $this->input->post('category', true);
  5762. $size = $this->input->post('size', true);
  5763. $grade = $this->input->post('grade', true);
  5764. $color = $this->input->post('color', true);
  5765. $lowe = $this->input->post('lowe', true);
  5766. $state = $this->input->post('state', true);
  5767. $label = $this->input->post('label', true);
  5768. $timetk = $this->input->post('ktime', true);
  5769. $timetj = $this->input->post('jtime', true);
  5770. $timetk = strtotime($timetk);
  5771. $timetj = strtotime($timetj);
  5772. $where = "1=1 ";
  5773. if ($timetk && $timetj) {
  5774. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5775. }
  5776. if ($sku) {
  5777. $where .= " and sku = '$sku'";
  5778. }
  5779. if ($bs != '') {
  5780. $where .= " and bs = '$bs'";
  5781. }
  5782. if ($number) {
  5783. $where .= " and number = '$number'";
  5784. }
  5785. if ($warehouse) {
  5786. $where .= " and warehouse = '$warehouse'";
  5787. }
  5788. if ($purchase) {
  5789. $where .= " and purchase = '$purchase'";
  5790. }
  5791. if ($orderinfo) {
  5792. $where .= " and orderinfo = '$orderinfo'";
  5793. }
  5794. if ($waybill) {
  5795. $where .= " and waybill = '$waybill'";
  5796. }
  5797. if ($category) {
  5798. $where .= " and features like '%-$category-%'";
  5799. }
  5800. if ($size) {
  5801. $where .= " and features like '%-$size-%'";
  5802. }
  5803. if ($grade) {
  5804. $where .= " and features like '%-$grade-%'";
  5805. }
  5806. if ($color) {
  5807. $where .= " and features like '%-$color-%'";
  5808. }
  5809. if ($lowe) {
  5810. $where .= " and features like '%-$lowe-%'";
  5811. }
  5812. if ($label) {
  5813. $where .= " and label = '$label'";
  5814. }
  5815. if ($state || $state == 0) {
  5816. $where .= " and state = '$state'";
  5817. }
  5818. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5819. //数据排序
  5820. $order_str = "enter desc";
  5821. if (empty($page)) {
  5822. $start = 0;
  5823. $perpage = 1;
  5824. } else {
  5825. $start = ($page - 1) * $perpage;
  5826. }
  5827. //取得信息列表
  5828. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5829. foreach ($info_list as $key => $value) {
  5830. $warehouse = $this->warehouse->read($value['warehouse']);
  5831. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5832. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5833. if ($value['state'] == 0) {
  5834. $info_list[$key]['state'] = "在库";
  5835. } else if ($value['state'] == 1) {
  5836. $info_list[$key]['state'] = "出库";
  5837. } else if ($value['state'] == 2) {
  5838. $info_list[$key]['state'] = "退库";
  5839. } else if ($value['state'] == 3) {
  5840. $info_list[$key]['state'] = "调拨中";
  5841. } else if ($value['state'] == 4) {
  5842. $info_list[$key]['state'] = "再加工";
  5843. } else if ($value['state'] == 5) {
  5844. $info_list[$key]['state'] = "维修中";
  5845. } else if ($value['state'] == 6) {
  5846. $info_list[$key]['state'] = "盘亏";
  5847. } else if ($value['state'] == 7) {
  5848. $info_list[$key]['state'] = "更换标签";
  5849. } else if ($value['state'] == 8) {
  5850. $info_list[$key]['state'] = "其它";
  5851. } else if ($value['state'] == 9) {
  5852. $info_list[$key]['state'] = "预设";
  5853. } else if ($value['state'] == 10) {
  5854. $info_list[$key]['state'] = "美店零售";
  5855. }
  5856. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5857. }
  5858. $total = $this->$ck->find_count($where);
  5859. $pagenum = ceil($total / $perpage);
  5860. $over = $total - ($start + $perpage);
  5861. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5862. echo json_encode($rows);
  5863. exit;
  5864. }
  5865. if (isset($post['tmsku'])) {
  5866. $time = time();
  5867. $tmsku = $this->input->post('tmsku', true);
  5868. //$post['shop'] = $this->input->post('shop',true);
  5869. $num = $this->input->post('num', true);
  5870. $rktype = $this->input->post('rktype', true);
  5871. if ($num > 200) {
  5872. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5873. exit;
  5874. }
  5875. if (!$rktype) {
  5876. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5877. }
  5878. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5879. /**
  5880. $wz = array();
  5881. foreach ($rk as $key=>$value)
  5882. {
  5883. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5884. }
  5885. if(count($wz) > 1)
  5886. {
  5887. $wz = array_values($wz);
  5888. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5889. }
  5890. **/
  5891. if (isset($rk[0]['purchase'])) {
  5892. $rk = $rk[0];
  5893. $j = 0;
  5894. $post['purchase'] = $rk['purchase'];
  5895. $post['warehouse'] = $rk['warehouse'];
  5896. $post['retreatwarehouse'] = $rk['warehouse'];
  5897. $post['sku'] = $rk['sku'];
  5898. $post['number'] = $rk['number'];
  5899. $post['features'] = $rk['features'];
  5900. $post['title'] = $rk['title'];
  5901. $post['enter'] = $time;
  5902. $post['time'] = $time;
  5903. $post['bs'] = 1;
  5904. $post['shop'] = $rk['shop'];
  5905. $post['details'] = $rk['details'];
  5906. $post['cpid'] = $rk['cpid'];
  5907. $post['cpbz'] = $rk['cpbz'];
  5908. //$post['rktype'] = $rktype;
  5909. $warehouse = $this->warehouse->read($rk['warehouse']);
  5910. if ($warehouse['bdck'] == '') {
  5911. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5912. exit;
  5913. } else {
  5914. $bdck = $warehouse['bdck'];
  5915. }
  5916. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5917. if (isset($pdwz['details'])) {
  5918. if ($pdwz['details'] != $post['details']) {
  5919. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5920. exit;
  5921. }
  5922. }
  5923. $post['featurespp'] = $rk['featurespp'];
  5924. if ($post['warehouse'] == '5') {
  5925. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5926. if ($yza) {
  5927. if ($post['features'] != $yza[0]['features']) {
  5928. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5929. exit;
  5930. }
  5931. }
  5932. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5933. if ($yzb) {
  5934. if ($post['sku'] != $yzb[0]['sku']) {
  5935. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5936. exit;
  5937. }
  5938. }
  5939. }
  5940. for ($i = 0; $i < $num; $i++) {
  5941. $post['label'] = time() . rand(100, 999) . $i;
  5942. if ($this->$bdck->insert($post)) {
  5943. $j++;
  5944. }
  5945. }
  5946. /**
  5947. if($post['warehouse'] != 12)
  5948. {
  5949. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5950. }
  5951. **/
  5952. if ($j == $num) {
  5953. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5954. exit;
  5955. } else {
  5956. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5957. exit;
  5958. }
  5959. } else {
  5960. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5961. exit;
  5962. }
  5963. }
  5964. $this->_Template('whlabel_printrk', $this->data);
  5965. }
  5966. public function _printxzrk($arg_array)
  5967. {
  5968. $post = $this->input->post(NULL, TRUE);
  5969. if (isset($post['wzid'])) {
  5970. $time = time();
  5971. $id = $this->input->post('wzid', true);
  5972. //$post['shop'] = $this->input->post('shop',true);
  5973. $num = 1;
  5974. $rk = $this->whlabellabel->read($id);
  5975. if (isset($rk['purchase'])) {
  5976. $x = 0;
  5977. $post['purchase'] = $rk['purchase'];
  5978. $post['warehouse'] = $rk['warehouse'];
  5979. $post['retreatwarehouse'] = $rk['warehouse'];
  5980. $post['sku'] = $rk['sku'];
  5981. $post['number'] = $rk['number'];
  5982. $post['features'] = $rk['features'];
  5983. $post['title'] = $rk['title'];
  5984. $post['enter'] = $time;
  5985. $post['time'] = $time;
  5986. $post['bs'] = 1;
  5987. $post['shop'] = $rk['shop'];
  5988. $post['details'] = $rk['details'];
  5989. $post['cpid'] = $rk['cpid'];
  5990. $post['cpbz'] = $rk['cpbz'];
  5991. $warehouse = $this->warehouse->read($rk['warehouse']);
  5992. if ($warehouse['bdck'] == '') {
  5993. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  5994. exit;
  5995. } else {
  5996. $bdck = $warehouse['bdck'];
  5997. }
  5998. $post['featurespp'] = $rk['featurespp'];
  5999. $this->db->trans_begin();
  6000. for ($i = 0; $i < $num; $i++) {
  6001. $post['label'] = time() . rand(100, 999) . $i;
  6002. $this->$bdck->insert($post);
  6003. }
  6004. /**
  6005. if($post['warehouse'] != 12)
  6006. {
  6007. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6008. }
  6009. **/
  6010. if ($this->db->trans_status() === TRUE) {
  6011. $this->db->trans_commit();
  6012. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6013. exit;
  6014. } else {
  6015. $this->db->trans_rollback();
  6016. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6017. exit;
  6018. }
  6019. } else {
  6020. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6021. exit;
  6022. }
  6023. }
  6024. }
  6025. public function _printck($arg_array)
  6026. {
  6027. $prc = array();
  6028. $purchase = $this->purchase->find_all();
  6029. foreach ($purchase as $k => $v) {
  6030. $prc[$v['id']] = $v['title'];
  6031. }
  6032. $post = $this->input->post(NULL, TRUE);
  6033. if (isset($post['page'])) {
  6034. $page = $this->input->post('page', true);
  6035. $perpage = $this->input->post('perpage', true);
  6036. $sku = $this->input->post('sku', true);
  6037. $bs = $this->input->post('bs', true);
  6038. $number = $this->input->post('number', true);
  6039. $warehouse = $this->input->post('warehouse', true);
  6040. $purchase = $this->input->post('purchase', true);
  6041. $orderinfo = $this->input->post('orderinfo', true);
  6042. $waybill = $this->input->post('waybill', true);
  6043. $category = $this->input->post('category', true);
  6044. $size = $this->input->post('size', true);
  6045. $grade = $this->input->post('grade', true);
  6046. $color = $this->input->post('color', true);
  6047. $lowe = $this->input->post('lowe', true);
  6048. $state = $this->input->post('state', true);
  6049. $label = $this->input->post('label', true);
  6050. $timetk = $this->input->post('ktime', true);
  6051. $timetj = $this->input->post('jtime', true);
  6052. $timetk = strtotime($timetk);
  6053. $timetj = strtotime($timetj);
  6054. $where = "state=1 ";
  6055. if ($timetk && $timetj) {
  6056. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6057. }
  6058. if ($sku) {
  6059. $where .= " and sku = '$sku'";
  6060. }
  6061. if ($bs != '') {
  6062. $where .= " and bs = '$bs'";
  6063. }
  6064. if ($number) {
  6065. $where .= " and number = '$number'";
  6066. }
  6067. if ($warehouse) {
  6068. $where .= " and warehouse = '$warehouse'";
  6069. }
  6070. if ($purchase) {
  6071. $where .= " and purchase = '$purchase'";
  6072. }
  6073. if ($orderinfo) {
  6074. $where .= " and orderinfo = '$orderinfo'";
  6075. }
  6076. if ($waybill) {
  6077. $where .= " and waybill = '$waybill'";
  6078. }
  6079. if ($category) {
  6080. $where .= " and features like '%-$category-%'";
  6081. }
  6082. if ($size) {
  6083. $where .= " and features like '%-$size-%'";
  6084. }
  6085. if ($grade) {
  6086. $where .= " and features like '%-$grade-%'";
  6087. }
  6088. if ($color) {
  6089. $where .= " and features like '%-$color-%'";
  6090. }
  6091. if ($lowe) {
  6092. $where .= " and features like '%-$lowe-%'";
  6093. }
  6094. if ($label) {
  6095. $where .= " and label = '$label'";
  6096. }
  6097. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6098. //数据排序
  6099. $order_str = "outk desc";
  6100. if (empty($page)) {
  6101. $start = 0;
  6102. $perpage = 1;
  6103. } else {
  6104. $start = ($page - 1) * $perpage;
  6105. }
  6106. //取得信息列表
  6107. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6108. foreach ($info_list as $key => $value) {
  6109. $warehouse = $this->warehouse->read($value['warehouse']);
  6110. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6111. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6112. if ($value['state'] == 0) {
  6113. $info_list[$key]['state'] = "在库";
  6114. } else if ($value['state'] == 1) {
  6115. $info_list[$key]['state'] = "出库";
  6116. } else if ($value['state'] == 2) {
  6117. $info_list[$key]['state'] = "退库";
  6118. } else if ($value['state'] == 3) {
  6119. $info_list[$key]['state'] = "调拨中";
  6120. } else if ($value['state'] == 4) {
  6121. $info_list[$key]['state'] = "再加工";
  6122. } else if ($value['state'] == 5) {
  6123. $info_list[$key]['state'] = "维修中";
  6124. } else if ($value['state'] == 6) {
  6125. $info_list[$key]['state'] = "盘亏";
  6126. } else if ($value['state'] == 7) {
  6127. $info_list[$key]['state'] = "更换标签";
  6128. } else if ($value['state'] == 8) {
  6129. $info_list[$key]['state'] = "其它";
  6130. } else if ($value['state'] == 9) {
  6131. $info_list[$key]['state'] = "预设";
  6132. } else if ($value['state'] == 10) {
  6133. $info_list[$key]['state'] = "美店零售";
  6134. }
  6135. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6136. }
  6137. $total = $this->$ck->find_count($where);
  6138. $pagenum = ceil($total / $perpage);
  6139. $over = $total - ($start + $perpage);
  6140. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6141. echo json_encode($rows);
  6142. exit;
  6143. }
  6144. if (isset($post['tmsku'])) {
  6145. $time = time();
  6146. $tmsku = $this->input->post('tmsku', true);
  6147. //$post['shop'] = $this->input->post('shop',true);
  6148. $num = $this->input->post('num', true);
  6149. $cktype = $this->input->post('cktype', true);
  6150. $label = $this->whlabellabel->get_label($tmsku);
  6151. if (!$cktype) {
  6152. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6153. }
  6154. if (!isset($label['warehouse'])) {
  6155. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6156. exit;
  6157. }
  6158. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6159. if (stripos($label['features'], '-126-') !== false) {
  6160. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6161. } else {
  6162. $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 = ''");
  6163. }
  6164. $j = 0;
  6165. if (count($ck) >= $num) {
  6166. for ($i = 0; $i < $num; $i++) {
  6167. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6168. {
  6169. $j++;
  6170. }
  6171. }
  6172. if ($j == $num) {
  6173. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6174. exit;
  6175. } else {
  6176. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6177. exit;
  6178. }
  6179. } else {
  6180. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6181. exit;
  6182. }
  6183. }
  6184. $this->_Template('whlabel_printck', $this->data);
  6185. }
  6186. public function _printexcel()
  6187. {
  6188. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6189. $config['upload_path'] = '.' . $dir;
  6190. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6191. $config['allowed_types'] = 'xls|xlsx|csv';
  6192. $config['max_size'] = 10240;
  6193. $this->load->library('upload', $config);
  6194. $this->upload->initialize($config);
  6195. if ($this->upload->do_upload('userfile')) {
  6196. $full_path = $dir . $this->upload->data('file_name');
  6197. $fileName = '.' . $full_path;
  6198. if (!file_exists($fileName)) {
  6199. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6200. exit;
  6201. } else {
  6202. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6203. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6204. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6205. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6206. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6207. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6208. ++$column; //如果列数大于26行
  6209. $list = array();
  6210. for ($i = 2; $i <= $row; $i++) // 行数循环
  6211. {
  6212. $data = array();
  6213. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6214. {
  6215. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6216. }
  6217. $list[] = $data;
  6218. }
  6219. }
  6220. $ed = array();
  6221. $i = 0;
  6222. $j = 0;
  6223. $dcdata = array();
  6224. $yc = '';
  6225. $cmf_arr = array_column($list, '1');
  6226. array_multisort($cmf_arr, SORT_ASC, $list);
  6227. foreach ($list as $key => $value) {
  6228. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6229. if ($typeclass) {
  6230. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6231. } else {
  6232. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6233. $i++;
  6234. continue;
  6235. }
  6236. }
  6237. if ($i > 0) {
  6238. $yc = $i . '条异常';
  6239. }
  6240. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6241. exit;
  6242. }
  6243. }
  6244. public function _uck()
  6245. {
  6246. if (isset($_GET['excel'])) {
  6247. $tc = array();
  6248. $typeclass = $this->typeclass->find_all();
  6249. foreach ($typeclass as $v) {
  6250. $tc[$v['id']] = $v['zh'];
  6251. }
  6252. $data = array();
  6253. $t = array();
  6254. $rq = '';
  6255. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6256. $ts = $ts / (24 * 3600);
  6257. for ($i = 0; $i < $ts; $i++) {
  6258. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6259. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6260. }
  6261. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6262. foreach ($info_list as $k => $v) {
  6263. $features = explode('-', trim($v['features'], '-'));
  6264. if (!isset($features[3]) || !isset($features[4])) {
  6265. continue;
  6266. }
  6267. $data[$k][0] = $tc[$features[0]]; //类型
  6268. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6269. $data[$k][2] = $tc[$features[4]]; //曲度
  6270. $data[$k][3] = '';
  6271. if (isset($data[$k][1])) {
  6272. $data[$k][3] .= $data[$k][1];
  6273. }
  6274. if (isset($data[$k][2])) {
  6275. $data[$k][3] .= $data[$k][2];
  6276. }
  6277. if (isset($features[5])) {
  6278. $data[$k][3] .= $tc[$features[5]];
  6279. }
  6280. if (isset($features[2])) {
  6281. $data[$k][3] .= $tc[$features[2]];
  6282. }
  6283. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6284. $data[$k][4] = $v['sku'];
  6285. $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())) . '))'); //月初库存
  6286. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6287. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6288. $ztrq = '';
  6289. $ztsl = '';
  6290. if (count($zt) > 0) {
  6291. foreach ($zt as $vv) {
  6292. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6293. $ztsl .= $vv['num'] . '<br>';
  6294. }
  6295. }
  6296. $data[$k][] = trim($ztsl, '<br>');
  6297. $data[$k][] = trim($ztrq, '<br>');
  6298. $byck = 0;
  6299. foreach ($t as $vv) {
  6300. $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));
  6301. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6302. $byck += $sl;
  6303. }
  6304. $data[$k][] = ($byck > 0) ? $byck : '';
  6305. }
  6306. $title = "详情 " . date("Y-m-d", time());
  6307. $titlename = "<table border=1>
  6308. <tr align='center'>
  6309. <td>类别</td>
  6310. <td>颜色</td>
  6311. <td>曲度</td>
  6312. <td>名称</td>
  6313. <td>SKU</td>
  6314. <td>月初库存</td>
  6315. <td>剩余库存</td>
  6316. <td>在途数量</td>
  6317. <td>预达日期</td>" .
  6318. $rq
  6319. . "<td>本月出库</td></tr>
  6320. </table>";
  6321. $filename = $title . ".xls";
  6322. $tail = "";
  6323. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6324. }
  6325. }
  6326. public function _whlabelexcelzh()
  6327. {
  6328. if (isset($_GET['excel'])) {
  6329. $where = "sku != 'Preset'";
  6330. //数据排序
  6331. $order_str = "id desc";
  6332. if (empty($page)) {
  6333. $start = 0;
  6334. $perpage = 1;
  6335. } else {
  6336. $start = ($page - 1) * $perpage;
  6337. }
  6338. $category = $this->input->get('category', true);
  6339. $warehouse = $this->input->get('warehouse', true);
  6340. $excelid = $this->input->get('sid', true);
  6341. if ($category) {
  6342. $where .= " and features like '%-$category-%'";
  6343. }
  6344. if ($warehouse) {
  6345. $where .= " and warehouse = '$warehouse'";
  6346. }
  6347. $xzid = '';
  6348. if ($excelid) {
  6349. $excelid = explode(',', trim($excelid, ','));
  6350. foreach ($excelid as $key => $value) {
  6351. $xzid .= " id = " . $value . " or";
  6352. }
  6353. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6354. }
  6355. //取得信息列表
  6356. /**
  6357. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6358. $rows = array();$list = array();
  6359. foreach ($info_list as $key=>$value)
  6360. {
  6361. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6362. }
  6363. **/
  6364. $list = array();
  6365. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6366. foreach ($rows as $key => $value) {
  6367. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6368. $zh = '';
  6369. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6370. foreach ($zt as $v) {
  6371. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6372. }
  6373. $zt = array_sum(array_column($zt, 'num'));
  6374. $number = $value['number'];
  6375. $ftime = time() - 15 * 24 * 3600;
  6376. $warehouse = $this->warehouse->read($value['warehouse']);
  6377. $rows[$key]['warehouse'] = $warehouse['title'];
  6378. $rows[$key]['number'] = $c;
  6379. $rows[$key]['features'] = $zh;
  6380. $rows[$key]['hb'] = $c + $zt;
  6381. }
  6382. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6383. $titlename = "<table border=1>
  6384. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6385. <tr align='center'>
  6386. <td>仓库</td>
  6387. <td>SKU</td>
  6388. <td>产品</td>
  6389. <td>库存数量</td>
  6390. <td>在途数量及预达日期</td>
  6391. <td>在途+库存数量</td>
  6392. </tr>
  6393. </table>";
  6394. $filename = $title . ".xls";
  6395. $tail = "";
  6396. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6397. }
  6398. if (isset($_GET['excel'])) {
  6399. $warehouse = $this->input->get('warehouse', true);
  6400. $sku = $this->input->get('sku', true);
  6401. $cz = $this->input->get('cz', true);
  6402. $text = $this->input->post('text', true);
  6403. $xztime = $this->input->get('xztime', true);
  6404. $timetk = $this->input->get('timetk', true);
  6405. $timetj = $this->input->get('timetj', true);
  6406. $timetk = strtotime($timetk);
  6407. $timetj = strtotime($timetj);
  6408. $where = "time = '0' ";
  6409. if ($warehouse) {
  6410. $where .= " and warehouse = '$warehouse'";
  6411. }
  6412. if ($sku) {
  6413. $where .= " and sku = '$sku'";
  6414. }
  6415. if ($text) {
  6416. $where .= " and text like '%$text%'";
  6417. }
  6418. if ($cz != '') {
  6419. $where .= " and cz = '$cz'";
  6420. }
  6421. if ($timetk && $timetj) {
  6422. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6423. }
  6424. //数据排序
  6425. $order_str = $xztime . " desc";
  6426. //取得信息列表
  6427. $zh = array();
  6428. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6429. foreach ($info_list as $v) {
  6430. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6431. $warehouse = $this->warehouse->read($v['warehouse']);
  6432. $v['warehouse'] = $warehouse['title'];
  6433. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6434. $v['stime'] = date('Y-m-d', $v['stime']);
  6435. if (isset($zh[$v['features']])) {
  6436. $zh[$v['features']]['num'] += $v['num'];
  6437. } else {
  6438. $zh[$v['features']] = $v;
  6439. }
  6440. $zh[$v['features']]['features'] = $c;
  6441. }
  6442. $title = "在途数据" . date('Y-m-d', time());
  6443. $titlename = "<table border=1>
  6444. <tr align='center'>
  6445. <td>仓库</td>
  6446. <td>SKU</td>
  6447. <td>名称</td>
  6448. <td>在途数量</td>
  6449. <td>库存数量</td>
  6450. <td>添加在途日期</td>
  6451. <td>预达日期</td>
  6452. <td>备注</td>
  6453. </tr>
  6454. </table>";
  6455. $filename = $title . ".xls";
  6456. $tail = "";
  6457. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6458. }
  6459. }
  6460. public function _fc()
  6461. {
  6462. $vip = 0;
  6463. if (isset($_SESSION['api'])) {
  6464. $user = $this->user->get_api($_SESSION['api']);
  6465. if ($user['vip'] == 1) {
  6466. $vip = 1;
  6467. }
  6468. } else {
  6469. header('Location: /');
  6470. exit;
  6471. }
  6472. $post = $this->input->post(NULL, TRUE);
  6473. if (isset($post['page'])) {
  6474. $page = $this->input->post('page', true);
  6475. $perpage = $this->input->post('perpage', true);
  6476. $category = $this->input->post('category', true);
  6477. $size = $this->input->post('size', true);
  6478. $grade = $this->input->post('grade', true);
  6479. $color = $this->input->post('color', true);
  6480. $lowe = $this->input->post('lowe', true);
  6481. $sku = $this->input->post('sku');
  6482. $title = $this->input->post('title');
  6483. $warehouse = $this->input->post('warehouse', true);
  6484. $usa = $this->input->post('usa', true);
  6485. $purchase = $this->input->post('purchase', true);
  6486. $lacetype = $this->input->post('lacetype', true);
  6487. $haircap = $this->input->post('haircap', true);
  6488. $density = $this->input->post('density', true);
  6489. $details = $this->input->post('details', true);
  6490. $state = $this->input->post('state', true);
  6491. $ktime = $this->input->post('ktime', true);
  6492. $jtime = $this->input->post('jtime', true);
  6493. $ktime = strtotime($ktime);
  6494. $jtime = strtotime($jtime);
  6495. $where = "state = '11'";
  6496. $gj = "";
  6497. $ck = "";
  6498. if ($lacetype) {
  6499. $where .= " and features like '%-$lacetype-%'";
  6500. }
  6501. if ($category) {
  6502. $where .= " and features like '%-$category-%'";
  6503. }
  6504. if ($size) {
  6505. $where .= " and features like '%-$size-%'";
  6506. }
  6507. if ($grade) {
  6508. $where .= " and features like '%-$grade-%'";
  6509. }
  6510. if ($color) {
  6511. $where .= " and features like '%-$color-%'";
  6512. }
  6513. if ($lowe) {
  6514. $where .= " and features like '%-$lowe-%'";
  6515. }
  6516. if ($haircap) {
  6517. $where .= " and features like '%-$haircap-%'";
  6518. }
  6519. if ($density) {
  6520. $where .= " and features like '%-$density-%'";
  6521. }
  6522. if ($usa) {
  6523. if (!$warehouse) {
  6524. $where .= " and (warehouse = '5' or warehouse = '8')";
  6525. }
  6526. }
  6527. if ($warehouse) {
  6528. $where .= " and warehouse = '$warehouse'";
  6529. }
  6530. if ($details) {
  6531. $where .= " and details = '$details'";
  6532. }
  6533. if ($purchase) {
  6534. $where .= " and purchase = '$purchase'";
  6535. }
  6536. if ($state) {
  6537. $where .= " and state = '$state'";
  6538. }
  6539. if ($ktime && $jtime) {
  6540. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6541. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6542. }
  6543. //数据排序
  6544. $order_str = "id desc";
  6545. if (empty($page)) {
  6546. $start = 0;
  6547. $perpage = 1;
  6548. } else {
  6549. $start = ($page - 1) * $perpage;
  6550. }
  6551. if ($sku) {
  6552. $sku = trim($sku, ' ');
  6553. $sku = trim($sku, ' ');
  6554. $where .= " and sku like '%$sku%'";
  6555. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6556. } else if ($title) {
  6557. $title = trim($title, ' ');
  6558. $title = trim($title, ' ');
  6559. $where .= " and title like '%$title%'";
  6560. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6561. } else {
  6562. //$where .= " and time > '$ktime' and time < '$jtime'";
  6563. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6564. }
  6565. //取得信息列表
  6566. $rows = array();
  6567. $list = array();
  6568. foreach ($info_list as $key => $value) {
  6569. $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'] . '"');
  6570. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6571. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6572. $warehouse = $this->warehouse->read($value['warehouse']);
  6573. $info_list[$key]['warehouse'] = $warehouse['title'];
  6574. $info_list[$key]['number'] = $g;
  6575. $info_list[$key]['features'] = $x;
  6576. $info_list[$key]['x'] = $s;
  6577. }
  6578. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6579. $pagenum = ceil($total / $perpage);
  6580. $over = $total - ($start + $perpage);
  6581. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6582. echo json_encode($rows);
  6583. exit;
  6584. }
  6585. $this->data['vip'] = $vip;
  6586. $this->_Template('whlabel_fc', $this->data);
  6587. }
  6588. public function _fcmb()
  6589. {
  6590. $where = "sku != 'Preset'";
  6591. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6592. foreach ($rows as $k => $v) {
  6593. $warehouse = $this->warehouse->read($v['warehouse']);
  6594. $rows[$k]['warehouse'] = $warehouse['title'];
  6595. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6596. $rows[$k]['t'] = '';
  6597. $rows[$k]['n'] = '';
  6598. }
  6599. $title = "封货产品数据导入模板";
  6600. $titlename = "<table border=1>
  6601. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6602. <tr align='center'>
  6603. <td>仓库</td>
  6604. <td>SKU</td>
  6605. <td>产品</td>
  6606. <td>封存产品总数量</td>
  6607. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6608. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6609. </tr>
  6610. </table>";
  6611. $filename = $title . ".xls";
  6612. $tail = "";
  6613. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6614. }
  6615. public function _fcexcel()
  6616. {
  6617. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6618. $config['upload_path'] = '.' . $dir;
  6619. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6620. $config['allowed_types'] = 'xls|xlsx|csv';
  6621. $config['max_size'] = 10240;
  6622. $this->load->library('upload', $config);
  6623. $this->upload->initialize($config);
  6624. if ($this->upload->do_upload('userfile')) {
  6625. $full_path = $dir . $this->upload->data('file_name');
  6626. $fileName = '.' . $full_path;
  6627. if (!file_exists($fileName)) {
  6628. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6629. exit;
  6630. } else {
  6631. libxml_use_internal_errors(true);
  6632. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6633. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6634. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6635. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6636. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6637. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6638. ++$column; //如果列数大于26行
  6639. $list = array();
  6640. for ($i = 2; $i <= $row; $i++) // 行数循环
  6641. {
  6642. $data = array();
  6643. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6644. {
  6645. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6646. }
  6647. $list[] = $data;
  6648. }
  6649. }
  6650. $i = 0;
  6651. $j = 0;
  6652. $ed = array();
  6653. foreach ($list as $key => $value) {
  6654. $time = time();
  6655. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6656. continue;
  6657. }
  6658. $warehouse = $this->warehouse->get_title($value['0']);
  6659. $sku = $value['1'];
  6660. $type = $value['4']; //调整方式0扣减1删除
  6661. $num = $value['5']; //调整数量
  6662. //$text = $value['4'];//扣减说明
  6663. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6664. if (!$d) //如果没有这个SKU
  6665. {
  6666. $ed[] = array($sku . '-库存中不存在此SKU');
  6667. $j++;
  6668. continue;
  6669. }
  6670. if (!isset($warehouse['id'])) {
  6671. $ed[] = array($sku . '-仓库名错误!');
  6672. $j++;
  6673. continue;
  6674. }
  6675. if ($type == 1 || $type == 2) //扣减库存
  6676. {
  6677. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6678. if (count($data) < abs($num)) {
  6679. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6680. $j++;
  6681. continue;
  6682. }
  6683. if ($type == 1) //转入库存
  6684. {
  6685. for ($i = 0; $i < abs($num); $i++) {
  6686. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6687. }
  6688. } else if ($type == 2) //删除
  6689. {
  6690. for ($i = 0; $i < abs($num); $i++) {
  6691. $this->whlabel->remove($data[$i]['id']);
  6692. }
  6693. }
  6694. } else if ($type == 0) //增加库存
  6695. {
  6696. $post['sku'] = $d['sku'];
  6697. $post['shop'] = '';
  6698. $post['warehouse'] = $warehouse['id'];
  6699. $post['purchase'] = $d['purchase'];
  6700. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6701. $post['state'] = 11;
  6702. $post['title'] = $d['title'];
  6703. $post['number'] = $d['number'];
  6704. $post['features'] = $d['features'];
  6705. $post['enter'] = $time;
  6706. $post['time'] = $time; //操作时间
  6707. for ($i = 0; $i < $num; $i++) {
  6708. $post['label'] = time() . rand(100, 999) . $i;
  6709. $this->whlabel->insert($post);
  6710. }
  6711. }
  6712. sleep(1); //防止入库时间一样,需要延迟1秒
  6713. }
  6714. if ($j > 0) {
  6715. $tt = date('Ymd', time());
  6716. $title = '库存导入错误信息-' . $tt;
  6717. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6718. $tail = "\n";
  6719. $filename = $title . ".xls";
  6720. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6721. $dir = '/data/excel/' . $time . '/';
  6722. $file_name = 'error_' . $time . rand(1000, 9999);
  6723. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6724. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6725. fwrite($myfile, $ecl);
  6726. fclose($myfile);
  6727. $error = $dir . $file_name . '.xls';
  6728. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6729. exit;
  6730. } else {
  6731. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6732. exit;
  6733. }
  6734. }
  6735. }
  6736. public function _fcjxc($arg_array)
  6737. {
  6738. if (isset($_GET['excel'])) {
  6739. $category = $this->input->get('category', true);
  6740. $size = $this->input->get('size', true);
  6741. $grade = $this->input->get('grade', true);
  6742. $color = $this->input->get('color', true);
  6743. $lowe = $this->input->get('lowe', true);
  6744. $sku = $this->input->get('sku');
  6745. $title = $this->input->get('title');
  6746. $warehouse = $arg_array[0];
  6747. $usa = $this->input->get('usa', true);
  6748. $purchase = $this->input->get('purchase', true);
  6749. $lacetype = $this->input->get('lacetype', true);
  6750. $haircap = $this->input->get('haircap', true);
  6751. $density = $this->input->get('density', true);
  6752. $title = $this->input->get('title', true);
  6753. $state = $this->input->get('state', true);
  6754. $ktime = $this->input->get('ktime', true);
  6755. $jtime = $this->input->get('jtime', true);
  6756. $where = "state=11";
  6757. $gj = "";
  6758. $ck = "";
  6759. if ($lacetype) {
  6760. $where .= " and features like '%-$lacetype-%'";
  6761. }
  6762. if ($category) {
  6763. $where .= " and features like '%-$category-%'";
  6764. }
  6765. if ($size) {
  6766. $where .= " and features like '%-$size-%'";
  6767. }
  6768. if ($grade) {
  6769. $where .= " and features like '%-$grade-%'";
  6770. }
  6771. if ($color) {
  6772. $where .= " and features like '%-$color-%'";
  6773. }
  6774. if ($lowe) {
  6775. $where .= " and features like '%-$lowe-%'";
  6776. }
  6777. if ($haircap) {
  6778. $where .= " and features like '%-$haircap-%'";
  6779. }
  6780. if ($density) {
  6781. $where .= " and features like '%-$density-%'";
  6782. }
  6783. if ($usa) {
  6784. if (!$warehouse) {
  6785. $where .= " and (warehouse = '5' or warehouse = '8')";
  6786. }
  6787. }
  6788. if ($warehouse) {
  6789. $where .= " and warehouse = '$warehouse'";
  6790. }
  6791. if ($purchase) {
  6792. $where .= " and purchase = '$purchase'";
  6793. }
  6794. if ($state) {
  6795. $where .= " and state = '$state'";
  6796. }
  6797. $order_str = "id desc";
  6798. if ($sku) {
  6799. $sku = trim($sku, ' ');
  6800. $sku = trim($sku, ' ');
  6801. $where .= " and sku like '%$sku%'";
  6802. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6803. } else if ($title) {
  6804. $title = trim($title, ' ');
  6805. $title = trim($title, ' ');
  6806. $where .= " and title like '%$title%'";
  6807. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6808. } else {
  6809. //$where .= " and time > '$ktime' and time < '$jtime'";
  6810. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6811. }
  6812. //取得信息列表
  6813. $rows = array();
  6814. $list = array();
  6815. foreach ($info_list as $key => $value) {
  6816. $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'] . '"');
  6817. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6818. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6819. $rows[$key] = $value;
  6820. $warehouse = $this->warehouse->read($value['warehouse']);
  6821. $rows[$key]['warehouse'] = $warehouse['title'];
  6822. $rows[$key]['features'] = $g;
  6823. $rows[$key]['a'] = $x;
  6824. $rows[$key]['b'] = $s;
  6825. }
  6826. $title = "总统计表";
  6827. $titlename = "<table border=1>
  6828. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6829. <tr align='center'>
  6830. <td>仓库</td>
  6831. <td>SKU</td>
  6832. <td>产品名称</td>
  6833. <td>录入总量</td>
  6834. <td>取出总量</td>
  6835. <td>剩余总量</td>
  6836. </tr>
  6837. </table>";
  6838. $filename = $title . ".xls";
  6839. $tail = "";
  6840. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6841. }
  6842. $vip = 0;
  6843. if (isset($_SESSION['api'])) {
  6844. $user = $this->user->get_api($_SESSION['api']);
  6845. if ($user['vip'] == 1) {
  6846. $vip = 1;
  6847. }
  6848. } else {
  6849. header('Location: /');
  6850. exit;
  6851. }
  6852. $post = $this->input->post(NULL, TRUE);
  6853. if (isset($post['page'])) {
  6854. $page = $this->input->post('page', true);
  6855. $perpage = $this->input->post('perpage', true);
  6856. $category = $this->input->post('category', true);
  6857. $size = $this->input->post('size', true);
  6858. $grade = $this->input->post('grade', true);
  6859. $color = $this->input->post('color', true);
  6860. $lowe = $this->input->post('lowe', true);
  6861. $sku = $this->input->post('sku');
  6862. $title = $this->input->post('title');
  6863. $warehouse = $arg_array[0];
  6864. $usa = $this->input->post('usa', true);
  6865. $purchase = $this->input->post('purchase', true);
  6866. $lacetype = $this->input->post('lacetype', true);
  6867. $haircap = $this->input->post('haircap', true);
  6868. $density = $this->input->post('density', true);
  6869. $title = $this->input->post('title', true);
  6870. $state = $this->input->post('state', true);
  6871. $ktime = $this->input->post('ktime', true);
  6872. $jtime = $this->input->post('jtime', true);
  6873. $ktime = strtotime($ktime);
  6874. $jtime = strtotime($jtime);
  6875. $where = "state=11";
  6876. $gj = "";
  6877. $ck = "";
  6878. if ($lacetype) {
  6879. $where .= " and features like '%-$lacetype-%'";
  6880. }
  6881. if ($category) {
  6882. $where .= " and features like '%-$category-%'";
  6883. }
  6884. if ($size) {
  6885. $where .= " and features like '%-$size-%'";
  6886. }
  6887. if ($grade) {
  6888. $where .= " and features like '%-$grade-%'";
  6889. }
  6890. if ($color) {
  6891. $where .= " and features like '%-$color-%'";
  6892. }
  6893. if ($lowe) {
  6894. $where .= " and features like '%-$lowe-%'";
  6895. }
  6896. if ($haircap) {
  6897. $where .= " and features like '%-$haircap-%'";
  6898. }
  6899. if ($density) {
  6900. $where .= " and features like '%-$density-%'";
  6901. }
  6902. if ($usa) {
  6903. if (!$warehouse) {
  6904. $where .= " and (warehouse = '5' or warehouse = '8')";
  6905. }
  6906. }
  6907. if ($warehouse) {
  6908. $where .= " and warehouse = '$warehouse'";
  6909. }
  6910. if ($purchase) {
  6911. $where .= " and purchase = '$purchase'";
  6912. }
  6913. if ($state) {
  6914. $where .= " and state = '$state'";
  6915. }
  6916. if ($ktime && $jtime) {
  6917. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6918. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6919. }
  6920. //数据排序
  6921. $order_str = "id desc";
  6922. $xs = 0;
  6923. $rows = array();
  6924. $list = array();
  6925. if (empty($page)) {
  6926. $start = 0;
  6927. $perpage = 1;
  6928. } else {
  6929. $start = ($page - 1) * $perpage;
  6930. }
  6931. if ($sku || $title) {
  6932. if ($title) {
  6933. $title = trim($title, ' ');
  6934. $title = trim($title, ' ');
  6935. $where .= " and title like '%$title%'";
  6936. } else {
  6937. $sku = trim($sku, ' ');
  6938. $sku = trim($sku, ' ');
  6939. $where .= " and sku like '%$sku%'";
  6940. }
  6941. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6942. foreach ($info_list as $key => $value) {
  6943. $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'] . '"');
  6944. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6945. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6946. $rows[$key] = $value;
  6947. $warehouse = $this->warehouse->read($value['warehouse']);
  6948. $rows[$key]['warehouse'] = $warehouse['title'];
  6949. $rows[$key]['features'] = $g;
  6950. $rows[$key]['a'] = $x;
  6951. $rows[$key]['b'] = $s;
  6952. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6953. $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天销量
  6954. $yj = $c / ($xl / 30);
  6955. if ($yj < 7) {
  6956. $rows[$key]['y'] = round($yj) . '天销量';
  6957. } else {
  6958. $rows[$key]['y'] = '正常';
  6959. }
  6960. }
  6961. } else {
  6962. //$where .= " and time > '$ktime' and time < '$jtime'";
  6963. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6964. foreach ($info_list as $key => $value) {
  6965. $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'] . '"');
  6966. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6967. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6968. $zs[$key] = $value;
  6969. $warehouse = $this->warehouse->read($value['warehouse']);
  6970. $zs[$key]['warehouse'] = $warehouse['title'];
  6971. $zs[$key]['features'] = $g;
  6972. $zs[$key]['a'] = $x;
  6973. $zs[$key]['b'] = $s;
  6974. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6975. $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天销量
  6976. $yj = $c / ($xl / 30);
  6977. if ($yj < 7) {
  6978. $zs[$key]['y'] = round($yj) . '天销量';
  6979. $rows[$key] = $zs[$key];
  6980. }
  6981. }
  6982. }
  6983. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  6984. $pagenum = ceil($total / $perpage);
  6985. $over = $total - ($start + $perpage);
  6986. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  6987. echo json_encode($rows);
  6988. exit;
  6989. }
  6990. $this->data['arg_array'] = $arg_array[0];
  6991. $this->_Template('whlabel_fcjxc', $this->data);
  6992. }
  6993. public function _0kcdel()
  6994. {
  6995. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6996. $config['upload_path'] = '.' . $dir;
  6997. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6998. $config['allowed_types'] = 'xls|xlsx|csv';
  6999. $config['max_size'] = 10240;
  7000. $this->load->library('upload', $config);
  7001. $this->upload->initialize($config);
  7002. if ($this->upload->do_upload('userfile')) {
  7003. $full_path = $dir . $this->upload->data('file_name');
  7004. $fileName = '.' . $full_path;
  7005. if (!file_exists($fileName)) {
  7006. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7007. exit;
  7008. } else {
  7009. require_once "./data/excel/PHPExcel/IOFactory.php";
  7010. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7011. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7012. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7013. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7014. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7015. ++$column; //如果列数大于26行
  7016. $list = array();
  7017. for ($i = 2; $i <= $row; $i++) // 行数循环
  7018. {
  7019. $data = array();
  7020. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7021. {
  7022. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7023. }
  7024. $list[] = $data;
  7025. }
  7026. }
  7027. $i = 0;
  7028. $j = 0;
  7029. $ed = array();
  7030. foreach ($list as $key => $value) {
  7031. $time = time();
  7032. if ($value['0'] == "" || $value['1'] == "") {
  7033. continue;
  7034. }
  7035. $warehouse = $this->warehouse->get_title($value['0']);
  7036. $sku = $value['1'];
  7037. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7038. if (!$d) //如果没有这个SKU
  7039. {
  7040. $ed[] = array($sku . '-库存中不存在此SKU');
  7041. $j++;
  7042. continue;
  7043. }
  7044. if (!isset($warehouse['id'])) {
  7045. $ed[] = array($sku . '-仓库名错误!');
  7046. $j++;
  7047. continue;
  7048. }
  7049. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7050. if ($z < 1) {
  7051. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7052. foreach ($z as $v) {
  7053. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7054. if (count($zt) > 0) {
  7055. $ed[] = array($sku . '-有在途库存无法删除!');
  7056. $j++;
  7057. continue;
  7058. }
  7059. $this->whlabel->remove($v['id']);
  7060. }
  7061. } else {
  7062. $ed[] = array($sku . '-非0库存!');
  7063. $j++;
  7064. continue;
  7065. }
  7066. }
  7067. if ($j > 0) {
  7068. $tt = date('Ymd', time());
  7069. $title = '删除0库存错误信息-' . $tt;
  7070. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7071. $tail = "\n";
  7072. $filename = $title . ".xls";
  7073. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7074. $dir = '/data/excel/' . $time . '/';
  7075. $file_name = 'error_' . $time . rand(1000, 9999);
  7076. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7077. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7078. fwrite($myfile, $ecl);
  7079. fclose($myfile);
  7080. $error = $dir . $file_name . '.xls';
  7081. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7082. exit;
  7083. } else {
  7084. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7085. exit;
  7086. }
  7087. }
  7088. }
  7089. public function _gbhtype()
  7090. {
  7091. $post = $this->input->post(NULL, TRUE);
  7092. if (isset($post['s'])) {
  7093. $n = $this->input->post('n');
  7094. $d = $this->input->post('s');
  7095. if (!$d) {
  7096. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7097. exit;
  7098. }
  7099. $d = explode(',', trim($d, ','));
  7100. $t = $this->whlabel_type->read($n);
  7101. //循环删除记录
  7102. foreach ($d as $v) {
  7103. $u = $this->whlabel->read($v);
  7104. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7105. foreach ($data as $val) {
  7106. $this->whlabel->save(array('type' => $n), $val['id']);
  7107. }
  7108. }
  7109. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7110. }
  7111. }
  7112. //出库、退库导出
  7113. public function _dccrtype()
  7114. {
  7115. $classid = $this->classid->sku();
  7116. $pm = $classid;
  7117. $typeclass = array();
  7118. $tc = $this->typeclass->find_all();
  7119. foreach ($tc as $v) {
  7120. $typeclass[$v['id']] = $v;
  7121. }
  7122. $prc = array();
  7123. $purchase = $this->purchase->find_all();
  7124. foreach ($purchase as $k => $v) {
  7125. $prc[$v['id']] = $v['title'];
  7126. }
  7127. if (isset($_GET['sid'])) {
  7128. $wh = array();
  7129. $w = $this->warehouse->find_all('1=1', 'id,title');
  7130. foreach ($w as $v) {
  7131. $wh[$v['id']] = $v['title'];
  7132. }
  7133. $type = $this->input->get('excel', true);
  7134. $category = $this->input->get('category', true);
  7135. $size = $this->input->get('size', true);
  7136. $grade = $this->input->get('grade', true);
  7137. $color = $this->input->get('color', true);
  7138. $lowe = $this->input->get('lowe', true);
  7139. $sku = $this->input->get('sku', true);
  7140. $warehouse = $this->input->get('warehouse', true);
  7141. $lacetype = $this->input->get('lacetype', true);
  7142. $lacecolor = $this->input->get('lacecolor', true);
  7143. $density = $this->input->get('density', true);
  7144. $haircap = $this->input->get('haircap', true);
  7145. $purchase = $this->input->get('purchase', true);
  7146. $title = $this->input->get('title', true);
  7147. $state = $this->input->get('state', true);
  7148. $sid = $this->input->get('sid', true);
  7149. $ktime = $this->input->get('ktime', true);
  7150. $jtime = $this->input->get('jtime', true);
  7151. $ktime = strtotime($ktime);
  7152. $jtime = strtotime($jtime);
  7153. $where = "1=1";
  7154. $gj = "";
  7155. $ck = "";
  7156. if ($category) {
  7157. $where .= " and features like '%-$category-%'";
  7158. }
  7159. if ($size) {
  7160. $where .= " and features like '%-$size-%'";
  7161. }
  7162. if ($grade) {
  7163. $where .= " and features like '%-$grade-%'";
  7164. }
  7165. if ($color) {
  7166. $where .= " and features like '%-$color-%'";
  7167. }
  7168. if ($lowe) {
  7169. $where .= " and features like '%-$lowe-%'";
  7170. }
  7171. if ($warehouse) {
  7172. $where .= " and warehouse = '$warehouse'";
  7173. }
  7174. if ($purchase) {
  7175. $where .= " and purchase = '$purchase'";
  7176. }
  7177. if ($state) {
  7178. $where .= " and state = '$state'";
  7179. }
  7180. if ($lacetype) {
  7181. $where .= " and features like '%-$lacetype-%'";
  7182. }
  7183. if ($lacecolor) {
  7184. $where .= " and features like '%-$lacecolor-%'";
  7185. }
  7186. if ($density) {
  7187. $where .= " and features like '%-$density-%'";
  7188. }
  7189. if ($haircap) {
  7190. $where .= " and features like '%-$haircap-%'";
  7191. }
  7192. if ($title) {
  7193. $title = trim($title, ' ');
  7194. $title = trim($title, ' ');
  7195. $where .= " and title like '%$title%'";
  7196. }
  7197. if ($sku) {
  7198. $sku = trim($sku, ' ');
  7199. $sku = trim($sku, ' ');
  7200. $where .= " and sku like '%$sku%'";
  7201. }
  7202. if ($ktime && $jtime) {
  7203. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7204. }
  7205. $sidwhere = '';
  7206. if ($sid) {
  7207. $sd = "";
  7208. $s = explode(',', trim($sid, ','));
  7209. foreach ($s as $value) {
  7210. $sd .= " id = " . $value . " or";
  7211. }
  7212. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7213. }
  7214. //数据排序
  7215. $order_str = "time desc";
  7216. if (empty($page)) {
  7217. $start = 0;
  7218. $perpage = 1;
  7219. } else {
  7220. $start = ($page - 1) * $perpage;
  7221. }
  7222. $wh = array();
  7223. $w = $this->warehouse->find_all('1=1', 'id,title');
  7224. foreach ($w as $v) {
  7225. $wh[$v['id']] = $v['title'];
  7226. }
  7227. $wt = array();
  7228. $whlabel_type = $this->whlabel_type->find_all();
  7229. foreach ($whlabel_type as $v) {
  7230. $wt[$v['id']] = $v['title'];
  7231. }
  7232. $classid = $this->classid->sku();
  7233. $list = array();
  7234. $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');
  7235. foreach ($rows_r as $key => $value) {
  7236. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7237. $pm = $classid;
  7238. $jm = $classid;
  7239. $rows_r[$key]['enter'] = '入库';
  7240. $rows_r[$key]['time'] = $value['enter'];
  7241. if ($value['rktype'] == 1) {
  7242. $rows_r[$key]['rktype'] = '采购入库';
  7243. } else if ($value['rktype'] == 2) {
  7244. $rows_r[$key]['rktype'] = '盘盈调整';
  7245. } else if ($value['rktype'] == 3) {
  7246. $rows_r[$key]['rktype'] = '其他调整入库';
  7247. } else if ($value['rktype'] == 4) {
  7248. $rows_r[$key]['rktype'] = '其他调整入库';
  7249. } else if ($value['rktype'] == 5) {
  7250. $rows_r[$key]['rktype'] = '退库入库';
  7251. } else if ($value['rktype'] == 6) {
  7252. $rows_r[$key]['rktype'] = '退货可用入库';
  7253. } else if ($value['rktype'] == 7) {
  7254. $rows_r[$key]['rktype'] = '形态转换入库';
  7255. } else {
  7256. $rows_r[$key]['rktype'] = '';
  7257. }
  7258. $features = explode('-', trim($value['features'], '-'));
  7259. foreach ($features as $v) {
  7260. if (isset($typeclass[$v])) {
  7261. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7262. $pm[$typeclass[$v]['classid']] = $zh[0];
  7263. }
  7264. if (isset($typeclass[$v])) {
  7265. if (isset($jm[$typeclass[$v]['classid']])) {
  7266. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7267. }
  7268. }
  7269. }
  7270. $zh = implode(" ", $pm);
  7271. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7272. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7273. $rows_r[$key]['zh'] = $zh;
  7274. $jm = array_filter($jm);
  7275. $rows_r[$key]['features'] = implode("-", $jm);
  7276. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7277. }
  7278. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7279. foreach ($rows_c as $key => $value) {
  7280. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7281. $pm = $classid;
  7282. $jm = $classid;
  7283. $rows_c[$key]['time'] = $value['outk'];
  7284. $rows_c[$key]['outk'] = '出库';
  7285. if ($value['cktype'] == 1) {
  7286. $rows_c[$key]['cktype'] = '销售出库';
  7287. } else if ($value['cktype'] == 2) {
  7288. $rows_c[$key]['cktype'] = '销售美国出库';
  7289. } else if ($value['cktype'] == 3) {
  7290. $rows_c[$key]['cktype'] = '盘亏调整';
  7291. } else if ($value['cktype'] == 4) {
  7292. $rows_c[$key]['cktype'] = '其他调整出库';
  7293. } else if ($value['cktype'] == 5) {
  7294. $rows_c[$key]['cktype'] = '形态转换出库';
  7295. } else {
  7296. $rows_c[$key]['cktype'] = '';
  7297. }
  7298. $features = explode('-', trim($value['features'], '-'));
  7299. foreach ($features as $v) {
  7300. if (isset($typeclass[$v])) {
  7301. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7302. $pm[$typeclass[$v]['classid']] = $zh[0];
  7303. }
  7304. if (isset($typeclass[$v])) {
  7305. if (isset($jm[$typeclass[$v]['classid']])) {
  7306. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7307. }
  7308. }
  7309. }
  7310. $zh = implode(" ", $pm);
  7311. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7312. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7313. $rows_c[$key]['zh'] = $zh;
  7314. $jm = array_filter($jm);
  7315. $rows_c[$key]['features'] = implode("-", $jm);
  7316. $rows_c[$key]['number'] = 1;
  7317. }
  7318. $merged = $rows_r;
  7319. foreach ($rows_c as $key => $value) {
  7320. if (isset($merged[$key])) {
  7321. $merged[] = $value;
  7322. } else {
  7323. $merged[$key] = $value;
  7324. }
  7325. }
  7326. usort($merged, function ($a, $b) {
  7327. return $a['time'] - $b['time'];
  7328. });
  7329. foreach ($merged as $key => $value) {
  7330. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7331. }
  7332. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7333. $titlename = "<table border=1>
  7334. <tr align='center'>
  7335. <td>仓库</td>
  7336. <td>SKU</td>
  7337. <td>商品名称</td>
  7338. <td>仓库品名</td>
  7339. <td>料号</td>
  7340. <td>时间</td>
  7341. <td>操作</td>
  7342. <td>类型</td>
  7343. <td>数量</td>
  7344. <td>备注</td>
  7345. </tr>
  7346. </table>";
  7347. $filename = $title . ".xlsx";
  7348. $tail = "";
  7349. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7350. }
  7351. }
  7352. }