Whlabel.php 256 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413
  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. }
  44. //定义方法的调用规则 获取URI第二段值
  45. public function _remap($arg, $arg_array)
  46. {
  47. if ($arg == 'existence') //在库标签
  48. {
  49. $this->_existence();
  50. } else if ($arg == 'cpbqdc') //在库标签
  51. {
  52. $this->_cpbqdc();
  53. } else if ($arg == 'type') //进销存浏览
  54. {
  55. $this->_type();
  56. } else if ($arg == 'typedy') //进销存浏览店员页面
  57. {
  58. $this->_typedy($arg_array);
  59. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  60. {
  61. $this->_typedy_ck($arg_array);
  62. } else if ($arg == 'typeck') {
  63. $this->_typeck($arg_array);
  64. } else if ($arg == 'whlabeckdc') {
  65. $this->_whlabeckdc($arg_array);
  66. } else if ($arg == 'usatype') //美仓进销存浏览
  67. {
  68. $this->_usatype();
  69. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  70. {
  71. $this->_usatypeapp();
  72. } else if ($arg == 'enteradd') //入库操作
  73. {
  74. $this->_enteradd();
  75. } else if ($arg == 'enteredit') //修改
  76. {
  77. $this->_enteredit($arg_array);
  78. } else if ($arg == 'enter') //入库浏览
  79. {
  80. $this->_enter();
  81. } else if ($arg == 'out') //出库浏览
  82. {
  83. $this->_out();
  84. } else if ($arg == 'label') //出库标签浏览
  85. {
  86. $this->_label();
  87. } else if ($arg == 'outorder') //独立站出库订单
  88. {
  89. $this->_outorder();
  90. } else if ($arg == 'soutorder') //速卖通出库订单
  91. {
  92. $this->_soutorder();
  93. } else if ($arg == 'toutorder') //TT出库订单
  94. {
  95. $this->_toutorder();
  96. }else if ($arg == 'aoutorder') //amz出库订单
  97. {
  98. $this->_aoutorder();
  99. } else if ($arg == 'retreat') //退库订单
  100. {
  101. $this->_retreat();
  102. } else if ($arg == 'retreatlk') //退库订单
  103. {
  104. $this->_retreatlk();
  105. } else if ($arg == 'change') //更换标签
  106. {
  107. $this->_change();
  108. } else if ($arg == 'del') //删除
  109. {
  110. $this->_del();
  111. } else if ($arg == 'exceljxc') //进销存信息导出
  112. {
  113. $this->_exceljxc();
  114. } else if ($arg == 'excelr') //入库信息导出
  115. {
  116. $this->_excelr();
  117. } else if ($arg == 'excelct') //出库、退库信息导出
  118. {
  119. $this->_excelct();
  120. } else if ($arg == 'dccrtype') //根据出入库类型导出
  121. {
  122. $this->_dccrtype();
  123. } else if ($arg == 'excelcr') //出库、退库信息导出
  124. {
  125. $this->_excelcr();
  126. } else if ($arg == 'kcyz') //库存验证
  127. {
  128. $this->_kcyz();
  129. } else if ($arg == 'kj') //库存扣减
  130. {
  131. $this->_kj($arg_array);
  132. } else if ($arg == 'presetout') //预设库存导入
  133. {
  134. $this->_presetout($arg_array);
  135. } else if ($arg == 'presetedit') //预设库存导入
  136. {
  137. $this->_presetedit($arg_array);
  138. } else if ($arg == 'summary') //汇总导出
  139. {
  140. $this->_summary($arg_array);
  141. } else if ($arg == 'manifest') //usps发货清单
  142. {
  143. $this->_manifest();
  144. } else if ($arg == 'abnormal') //占单异常
  145. {
  146. $this->_abnormal();
  147. } else if ($arg == 'error') //0库存SKU
  148. {
  149. $this->_error();
  150. } else if ($arg == 'errorexcel') //0库存SKU导出
  151. {
  152. $this->_errorexcel();
  153. } else if ($arg == 'db') {
  154. $this->_db();
  155. } else if ($arg == 'dbrk') {
  156. $this->_dbrk();
  157. } else if ($arg == 'whlabelczdc') {
  158. $this->_whlabelczdc();
  159. } else if ($arg == 'print') {
  160. $this->_print($arg_array);
  161. } else if ($arg == 'usaprint') {
  162. $this->_usaprint($arg_array);
  163. } else if ($arg == 'printck') {
  164. $this->_printck($arg_array);
  165. } else if ($arg == 'printrk') {
  166. $this->_printrk($arg_array);
  167. } else if ($arg == 'printxzrk') {
  168. $this->_printxzrk($arg_array);
  169. } else if ($arg == 'printexcel') {
  170. $this->_printexcel($arg_array);
  171. } else if ($arg == 'uck') {
  172. $this->_uck();
  173. } else if ($arg == 'whlabelexcelzh') {
  174. $this->_whlabelexcelzh();
  175. } else if ($arg == 'fc') {
  176. $this->_fc();
  177. } else if ($arg == 'fcmb') {
  178. $this->_fcmb();
  179. } else if ($arg == 'fcexcel') {
  180. $this->_fcexcel();
  181. } else if ($arg == 'fcjxc') {
  182. $this->_fcjxc($arg_array);
  183. } else if ($arg == '0kcdel') {
  184. $this->_0kcdel(); //导表删除0库存
  185. } else if ($arg == 'gbhtype') {
  186. $this->_gbhtype(); //更改备货状态
  187. } else {
  188. $this->_index();
  189. }
  190. }
  191. //管理
  192. public function _index()
  193. {
  194. $post = $this->input->post(NULL, TRUE);
  195. if (isset($post['page'])) {
  196. $page = $this->input->post('page', true);
  197. $perpage = $this->input->post('perpage', true);
  198. $sku = $this->input->post('sku', true);
  199. $number = $this->input->post('number', true);
  200. $warehouse = $this->input->post('warehouse', true);
  201. $purchase = $this->input->post('purchase', true);
  202. $orderinfo = $this->input->post('orderinfo', true);
  203. $waybill = $this->input->post('waybill', true);
  204. $category = $this->input->post('category', true);
  205. $size = $this->input->post('size', true);
  206. $grade = $this->input->post('grade', true);
  207. $color = $this->input->post('color', true);
  208. $lowe = $this->input->post('lowe', true);
  209. $state = $this->input->post('state', true);
  210. $label = $this->input->post('label', true);
  211. $timetk = $this->input->post('timetkk', true);
  212. $timetj = $this->input->post('timetjj', true);
  213. $timetk = strtotime($timetk);
  214. $timetj = strtotime($timetj);
  215. $where = "1=1 ";
  216. if ($timetk && $timetj) {
  217. $where .= " and time > '$timetk' and time < '$timetj'";
  218. }
  219. if ($sku) {
  220. $where .= " and sku = '$sku'";
  221. }
  222. if ($number) {
  223. $where .= " and number = '$number'";
  224. }
  225. if ($warehouse) {
  226. $where .= " and warehouse = '$warehouse'";
  227. }
  228. if ($purchase) {
  229. $where .= " and purchase = '$purchase'";
  230. }
  231. if ($orderinfo) {
  232. $where .= " and orderinfo = '$orderinfo'";
  233. }
  234. if ($waybill) {
  235. $where .= " and waybill = '$waybill'";
  236. }
  237. if ($category) {
  238. $where .= " and features like '%-$category-%'";
  239. }
  240. if ($size) {
  241. $where .= " and features like '%-$size-%'";
  242. }
  243. if ($grade) {
  244. $where .= " and features like '%-$grade-%'";
  245. }
  246. if ($color) {
  247. $where .= " and features like '%-$color-%'";
  248. }
  249. if ($lowe) {
  250. $where .= " and features like '%-$lowe-%'";
  251. }
  252. if ($label) {
  253. $where .= " and label = '$label'";
  254. }
  255. if ($state != '') {
  256. $where .= " and state = '$state'";
  257. }
  258. //数据排序
  259. $order_str = "time desc";
  260. if (empty($page)) {
  261. $start = 0;
  262. $perpage = 1;
  263. } else {
  264. $start = ($page - 1) * $perpage;
  265. }
  266. //取得信息列表
  267. $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);
  268. foreach ($info_list as $key => $value) {
  269. $warehouse = $this->warehouse->read($value['warehouse']);
  270. $info_list[$key]['warehouse'] = $warehouse['title'];
  271. $purchase = $this->purchase->read($value['purchase']);
  272. $info_list[$key]['purchase'] = $purchase['title'];
  273. if ($value['enter'] != 0) {
  274. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  275. } else {
  276. $info_list[$key]['enter'] = "";
  277. }
  278. if ($value['outk'] != 0) {
  279. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  280. } else {
  281. $info_list[$key]['outk'] = "";
  282. }
  283. if ($value['printing'] != 0) {
  284. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  285. } else {
  286. $info_list[$key]['printing'] = "";
  287. }
  288. if ($value['orderinfo'] == 0) {
  289. $info_list[$key]['orderinfo'] = "";
  290. }
  291. if ($value['waybill'] == 0) {
  292. $info_list[$key]['waybill'] = "";
  293. }
  294. if ($value['state'] == 0) {
  295. $info_list[$key]['state'] = "在库";
  296. } else if ($value['state'] == 1) {
  297. $info_list[$key]['state'] = "出库";
  298. } else if ($value['state'] == 2) {
  299. $info_list[$key]['state'] = "退库";
  300. } else if ($value['state'] == 3) {
  301. $info_list[$key]['state'] = "调拨中";
  302. } else if ($value['state'] == 4) {
  303. $info_list[$key]['state'] = "再加工";
  304. } else if ($value['state'] == 5) {
  305. $info_list[$key]['state'] = "维修中";
  306. } else if ($value['state'] == 6) {
  307. $info_list[$key]['state'] = "盘亏";
  308. } else if ($value['state'] == 7) {
  309. $info_list[$key]['state'] = "更换标签";
  310. } else if ($value['state'] == 8) {
  311. $info_list[$key]['state'] = "其它";
  312. } else if ($value['state'] == 9) {
  313. $info_list[$key]['state'] = "预设";
  314. } else if ($value['state'] == 10) {
  315. $info_list[$key]['state'] = "美店零售";
  316. }
  317. if ($value['text'] == "") {
  318. $info_list[$key]['text'] = "";
  319. }
  320. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  321. }
  322. $total = $this->whlabel->find_count($where);
  323. $pagenum = ceil($total / $perpage);
  324. $over = $total - ($start + $perpage);
  325. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  326. echo json_encode($rows);
  327. exit;
  328. }
  329. if (isset($post['outsku'])) {
  330. $cz = $this->input->post('cz', true);
  331. if ($cz == '1') {
  332. $sku = $this->input->post('outsku', true);
  333. if ($sku) {
  334. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  335. if (count($data) < 1) {
  336. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  337. exit;
  338. }
  339. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 1), $data[0]['id']);
  340. echo json_encode(array('success' => true));
  341. exit;
  342. }
  343. } else {
  344. $sku = $this->input->post('outsku', true);
  345. if ($sku) {
  346. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  347. if (count($data) < 1) {
  348. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  349. exit;
  350. }
  351. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  352. echo json_encode(array('success' => true));
  353. exit;
  354. }
  355. }
  356. }
  357. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  358. $this->_Template('whlabel', $this->data);
  359. }
  360. //在库标签
  361. public function _existence()
  362. {
  363. $post = $this->input->post(NULL, TRUE);
  364. if (isset($post['s'])) {
  365. $id_arr = $this->input->post('s');
  366. $id_arr = explode(',', $id_arr);
  367. if (!$id_arr) {
  368. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  369. exit;
  370. }
  371. //循环删除记录
  372. foreach ($id_arr as $v) {
  373. $sid = $this->whlabel->read($v);
  374. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  375. if ($count > 0) {
  376. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  377. exit;
  378. }
  379. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  380. if (count($zt) > 0) {
  381. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  382. exit;
  383. }
  384. $this->whlabel->remove($v);
  385. }
  386. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  387. exit;
  388. }
  389. if (isset($post['page'])) {
  390. $page = $this->input->post('page', true);
  391. $perpage = $this->input->post('perpage', true);
  392. $warehouse = $this->input->post('warehouse', true);
  393. $label = $this->input->post('label', true);
  394. $where = "1=1 and state = 0";
  395. if ($warehouse) {
  396. $where .= " and warehouse = '$warehouse'";
  397. }
  398. if ($label) {
  399. $where .= " and label = '$label'";
  400. }
  401. //数据排序
  402. $order_str = "time asc";
  403. if (empty($page)) {
  404. $start = 0;
  405. $perpage = 1;
  406. } else {
  407. $start = ($page - 1) * $perpage;
  408. }
  409. //取得信息列表
  410. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  411. foreach ($info_list as $key => $value) {
  412. if ($value['enter'] != 0) {
  413. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  414. } else {
  415. $info_list[$key]['enter'] = "";
  416. }
  417. if ($value['printing'] != 0) {
  418. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  419. } else {
  420. $info_list[$key]['printing'] = "";
  421. }
  422. }
  423. $total = $this->whlabel->find_count($where);
  424. $pagenum = ceil($total / $perpage);
  425. $over = $total - ($start + $perpage);
  426. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  427. echo json_encode($rows);
  428. exit;
  429. }
  430. $this->_Template('whlabel_existence', $this->data);
  431. }
  432. //进销存浏览
  433. public function _typedy($arg_array)
  434. {
  435. $prc = array();
  436. $purchase = $this->purchase->find_all();
  437. foreach ($purchase as $k => $v) {
  438. $prc[$v['id']] = $v['title'];
  439. }
  440. $post = $this->input->post(NULL, TRUE);
  441. if (isset($post['page'])) {
  442. $page = $this->input->post('page', true);
  443. $perpage = $this->input->post('perpage', true);
  444. $category = $this->input->post('category', true);
  445. $size = $this->input->post('size', true);
  446. $grade = $this->input->post('grade', true);
  447. $color = $this->input->post('color', true);
  448. $lowe = $this->input->post('lowe', true);
  449. $sku = $this->input->post('sku');
  450. $title = $this->input->post('title');
  451. $warehouse = $this->input->post('warehouse', true);
  452. $usa = $this->input->post('usa', true);
  453. $purchase = $this->input->post('purchase', true);
  454. $lacetype = $this->input->post('lacetype', true);
  455. $haircap = $this->input->post('haircap', true);
  456. $density = $this->input->post('density', true);
  457. $details = $this->input->post('details', true);
  458. $state = $this->input->post('state', true);
  459. $lacecolor = $this->input->post('lacecolor', true);
  460. $hairnumber = $this->input->post('hairnumber', true);
  461. $cklx = $this->input->post('cklx', true);
  462. $ktime = $this->input->post('ktime', true);
  463. $jtime = $this->input->post('jtime', true);
  464. $ktime = strtotime($ktime);
  465. $jtime = strtotime($jtime);
  466. $where = "1=1";
  467. $gj = "";
  468. $ck = "";
  469. if ($usa) {
  470. if (!$warehouse) {
  471. $where .= " and (warehouse = '5' or warehouse = '8')";
  472. }
  473. }
  474. if ($warehouse) {
  475. $where .= " and warehouse = '$warehouse'";
  476. }
  477. if ($details) {
  478. $where .= " and details = '$details'";
  479. }
  480. if ($purchase) {
  481. $where .= " and purchase = '$purchase'";
  482. }
  483. if ($state) {
  484. $where .= " and state = '$state'";
  485. }
  486. if ($lacetype) {
  487. $where .= " and features like '%-$lacetype-%'";
  488. }
  489. if ($category) {
  490. $where .= " and features like '%-$category-%'";
  491. }
  492. if ($size) {
  493. $where .= " and features like '%-$size-%'";
  494. }
  495. if ($grade) {
  496. $where .= " and features like '%-$grade-%'";
  497. }
  498. if ($color) {
  499. $where .= " and features like '%-$color-%'";
  500. }
  501. if ($lowe) {
  502. $where .= " and features like '%-$lowe-%'";
  503. }
  504. if ($haircap) {
  505. $where .= " and features like '%-$haircap-%'";
  506. }
  507. if ($density) {
  508. $where .= " and features like '%-$density-%'";
  509. }
  510. if ($lacecolor) {
  511. $where .= " and features like '%-$lacecolor-%'";
  512. }
  513. if (!empty($hairnumber)) {
  514. $where .= " and features like '%-128-%' ";
  515. if ($hairnumber < 0) {
  516. $class_list = $this->typeclass->find_all('classid = 43');
  517. foreach ($class_list as $v) {
  518. $where .= " and features not like '%-" . $v['id'] . "-%'";
  519. }
  520. } else {
  521. $where .= " and features like '%-$hairnumber-%'";
  522. }
  523. }
  524. $where_add = '';
  525. if ($cklx) {
  526. $shop = $this->shop->read($cklx);
  527. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  528. }
  529. if ($ktime && $jtime) {
  530. $gj = " and enter > '$ktime' and enter < '$jtime'";
  531. $ck = " and outk > '$ktime' and outk < '$jtime'";
  532. }
  533. //数据排序
  534. $order_str = "id desc";
  535. if (empty($page)) {
  536. $start = 0;
  537. $perpage = 1;
  538. } else {
  539. $start = ($page - 1) * $perpage;
  540. }
  541. if ($sku) {
  542. $sku = trim($sku, ' ');
  543. $sku = trim($sku, ' ');
  544. $where .= " and sku like '%$sku%'";
  545. $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);
  546. } else if ($title) {
  547. $title = trim($title, ' ');
  548. $title = trim($title, ' ');
  549. $where .= " and title like '%$title%'";
  550. $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);
  551. } else {
  552. //$where .= " and time > '$ktime' and time < '$jtime'";
  553. $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);
  554. }
  555. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  556. foreach ($info_list as $k => $v) {
  557. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  558. unset($info_list[$k]['pm']);
  559. unset($info_list[$k]['jm']);
  560. unset($info_list[$k]['bm']);
  561. }
  562. //取得信息列表
  563. $rows = array();
  564. $list = array();
  565. foreach ($info_list as $key => $value) {
  566. $warehouse = $this->warehouse->read($value['warehouse']);
  567. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  568. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  569. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  570. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  571. $number = $value['number'];
  572. $ftime = time() - 15 * 24 * 3600;
  573. $info_list[$key]['warehouse'] = $warehouse['title'];
  574. $info_list[$key]['features'] = count($c);
  575. $z = count($z); //查看订单号
  576. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  577. $ztdata = '';
  578. if (count($zt) > 0) {
  579. foreach ($zt as $vv) {
  580. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  581. }
  582. }
  583. $info_list[$key]['number'] = $ztdata;
  584. $info_list[$key]['sm'] = $z;
  585. $details = array();
  586. $cpid = array();
  587. foreach ($c as $k => $v) {
  588. $details[$v['details']] = $v['details'];
  589. if ($v['cpid'] != 0) {
  590. $cpid[$v['cpid']] = $v['cpid'];
  591. }
  592. }
  593. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  594. if ($value['shop'] != '') {
  595. $shop = explode(',', trim($value['shop'], ','));
  596. $shop = $this->shop->read($shop[0]);
  597. $info_list[$key]['shop'] = $shop['shopname'];
  598. }
  599. }
  600. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  601. $pagenum = ceil($total / $perpage);
  602. $over = $total - ($start + $perpage);
  603. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  604. echo json_encode($rows);
  605. exit;
  606. }
  607. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  608. $this->_Template('whlabel_typedy', $this->data);
  609. }
  610. //进销存浏览
  611. public function _typedy_ck($arg_array)
  612. {
  613. $prc = array();
  614. $purchase = $this->purchase->find_all();
  615. foreach ($purchase as $k => $v) {
  616. $prc[$v['id']] = $v['title'];
  617. }
  618. $post = $this->input->post(NULL, TRUE);
  619. if (isset($post['page'])) {
  620. $page = $this->input->post('page', true);
  621. $perpage = $this->input->post('perpage', true);
  622. $category = $this->input->post('category', true);
  623. $size = $this->input->post('size', true);
  624. $grade = $this->input->post('grade', true);
  625. $color = $this->input->post('color', true);
  626. $lowe = $this->input->post('lowe', true);
  627. $sku = $this->input->post('sku');
  628. $title = $this->input->post('title');
  629. $warehouse = $this->input->post('warehouse', true);
  630. $usa = $this->input->post('usa', true);
  631. $purchase = $this->input->post('purchase', true);
  632. $lacetype = $this->input->post('lacetype', true);
  633. $haircap = $this->input->post('haircap', true);
  634. $density = $this->input->post('density', true);
  635. $details = $this->input->post('details', true);
  636. $state = $this->input->post('state', true);
  637. $lacecolor = $this->input->post('lacecolor', true);
  638. $cklx = $this->input->post('cklx', true);
  639. $ktime = $this->input->post('ktime', true);
  640. $jtime = $this->input->post('jtime', true);
  641. $ktime = strtotime($ktime);
  642. $jtime = strtotime($jtime);
  643. $where = "1=1";
  644. $gj = "";
  645. $ck = "";
  646. if ($lacetype) {
  647. $where .= " and features like '%-$lacetype-%'";
  648. }
  649. if ($category) {
  650. $where .= " and features like '%-$category-%'";
  651. }
  652. if ($size) {
  653. $where .= " and features like '%-$size-%'";
  654. }
  655. if ($grade) {
  656. $where .= " and features like '%-$grade-%'";
  657. }
  658. if ($color) {
  659. $where .= " and features like '%-$color-%'";
  660. }
  661. if ($lowe) {
  662. $where .= " and features like '%-$lowe-%'";
  663. }
  664. if ($haircap) {
  665. $where .= " and features like '%-$haircap-%'";
  666. }
  667. if ($density) {
  668. $where .= " and features like '%-$density-%'";
  669. }
  670. if ($lacecolor) {
  671. $where .= " and features like '%-$lacecolor-%'";
  672. }
  673. if ($usa) {
  674. if (!$warehouse) {
  675. $where .= " and (warehouse = '5' or warehouse = '8')";
  676. }
  677. }
  678. if ($warehouse) {
  679. $where .= " and warehouse = '$warehouse'";
  680. }
  681. if ($details) {
  682. $where .= " and details = '$details'";
  683. }
  684. if ($purchase) {
  685. $where .= " and purchase = '$purchase'";
  686. }
  687. if ($state) {
  688. $where .= " and state = '$state'";
  689. }
  690. $where_add = '';
  691. if ($cklx) {
  692. $shop = $this->shop->read($cklx);
  693. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  694. }
  695. if ($ktime && $jtime) {
  696. $gj = " and enter > '$ktime' and enter < '$jtime'";
  697. $ck = " and outk > '$ktime' and outk < '$jtime'";
  698. }
  699. //数据排序
  700. $order_str = "id desc";
  701. if (empty($page)) {
  702. $start = 0;
  703. $perpage = 1;
  704. } else {
  705. $start = ($page - 1) * $perpage;
  706. }
  707. if ($sku) {
  708. $sku = trim($sku, ' ');
  709. $sku = trim($sku, ' ');
  710. $where .= " and sku like '%$sku%'";
  711. $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);
  712. } else if ($title) {
  713. $title = trim($title, ' ');
  714. $title = trim($title, ' ');
  715. $where .= " and title like '%$title%'";
  716. $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);
  717. } else {
  718. //$where .= " and time > '$ktime' and time < '$jtime'";
  719. $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);
  720. }
  721. //取得信息列表
  722. $rows = array();
  723. $list = array();
  724. foreach ($info_list as $key => $value) {
  725. $warehouse = $this->warehouse->read($value['warehouse']);
  726. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  727. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  728. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  729. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  730. $ftime = time() - 15 * 24 * 3600;
  731. $info_list[$key]['warehouse'] = $warehouse['title'];
  732. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  733. //$z = count($z);//查看订单号
  734. //$info_list[$key]['zd'] = $z;
  735. $details = array();
  736. $cpid = array();
  737. foreach ($c as $k => $v) {
  738. $details[$v['details']] = $v['details'];
  739. if ($v['cpid'] != 0) {
  740. $cpid[$v['cpid']] = $v['cpid'];
  741. }
  742. }
  743. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  744. if ($value['shop'] != '') {
  745. $shop = explode(',', trim($value['shop'], ','));
  746. $shop = $this->shop->read($shop[0]);
  747. $info_list[$key]['shop'] = $shop['shopname'];
  748. }
  749. }
  750. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  751. $pagenum = ceil($total / $perpage);
  752. $over = $total - ($start + $perpage);
  753. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  754. echo json_encode($rows);
  755. exit;
  756. }
  757. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  758. $this->_Template('whlabel_typedy_ck', $this->data);
  759. }
  760. public function _typeck($arg_array)
  761. {
  762. $prc = array();
  763. $purchase = $this->purchase->find_all();
  764. foreach ($purchase as $k => $v) {
  765. $prc[$v['id']] = $v['title'];
  766. }
  767. $post = $this->input->post(NULL, TRUE);
  768. if (isset($post['page'])) {
  769. $page = $this->input->post('page', true);
  770. $perpage = $this->input->post('perpage', true);
  771. $category = $this->input->post('category', true);
  772. $size = $this->input->post('size', true);
  773. $grade = $this->input->post('grade', true);
  774. $color = $this->input->post('color', true);
  775. $lacecolor = $this->input->post('lacecolor', true);
  776. $lowe = $this->input->post('lowe', true);
  777. $sku = $this->input->post('sku');
  778. $title = $this->input->post('title');
  779. $warehouse = 13;
  780. $usa = $this->input->post('usa', true);
  781. $purchase = $this->input->post('purchase', true);
  782. $lacetype = $this->input->post('lacetype', true);
  783. $haircap = $this->input->post('haircap', true);
  784. $density = $this->input->post('density', true);
  785. $details = $this->input->post('details', true);
  786. $state = $this->input->post('state', true);
  787. $ktime = $this->input->post('ktime', true);
  788. $jtime = $this->input->post('jtime', true);
  789. $ktime = strtotime($ktime);
  790. $jtime = strtotime($jtime);
  791. $where = "1=1";
  792. $gj = "";
  793. $ck = "";
  794. if ($lacetype) {
  795. $where .= " and features like '%-$lacetype-%'";
  796. }
  797. if ($category) {
  798. $where .= " and features like '%-$category-%'";
  799. }
  800. if ($size) {
  801. $where .= " and features like '%-$size-%'";
  802. }
  803. if ($grade) {
  804. $where .= " and features like '%-$grade-%'";
  805. }
  806. if ($color) {
  807. $where .= " and features like '%-$color-%'";
  808. }
  809. if ($lacecolor) {
  810. $where .= " and features like '%-$lacecolor-%'";
  811. }
  812. if ($lowe) {
  813. $where .= " and features like '%-$lowe-%'";
  814. }
  815. if ($haircap) {
  816. $where .= " and features like '%-$haircap-%'";
  817. }
  818. if ($density) {
  819. $where .= " and features like '%-$density-%'";
  820. }
  821. if ($warehouse) {
  822. $where .= " and warehouse = '$warehouse'";
  823. }
  824. if ($details) {
  825. $where .= " and details = '$details'";
  826. }
  827. if ($purchase) {
  828. $where .= " and purchase = '$purchase'";
  829. }
  830. if ($state) {
  831. $where .= " and state = '$state'";
  832. }
  833. if ($ktime && $jtime) {
  834. $gj = " and enter > '$ktime' and enter < '$jtime'";
  835. $ck = " and outk > '$ktime' and outk < '$jtime'";
  836. }
  837. //数据排序
  838. $order_str = "id desc";
  839. if (empty($page)) {
  840. $start = 0;
  841. $perpage = 1;
  842. } else {
  843. $start = ($page - 1) * $perpage;
  844. }
  845. if ($sku) {
  846. $sku = trim($sku, ' ');
  847. $sku = trim($sku, ' ');
  848. $where .= " and sku like '%$sku%'";
  849. } else if ($title) {
  850. $title = trim($title, ' ');
  851. $title = trim($title, ' ');
  852. $where .= " and title like '%$title%'";
  853. }
  854. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  855. //取得信息列表
  856. $t = array();
  857. $typeclass = $this->typeclass->find_all();
  858. foreach ($typeclass as $v) {
  859. $t[$v['id']] = $v;
  860. }
  861. $rows = array();
  862. $list = array();
  863. foreach ($info_list as $key => $value) {
  864. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  865. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  866. $warehouse = $this->warehouse->read($value['warehouse']);
  867. $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');
  868. $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'] . '"');
  869. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  870. $number = $value['number'];
  871. $ftime = time() - 15 * 24 * 3600;
  872. $z = count($z); //查看订单号
  873. $info_list[$key]['warehouse'] = $warehouse['title'];
  874. $info_list[$key]['features'] = count($c);
  875. $info_list[$key]['number'] = $z;
  876. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  877. $details = array();
  878. $cpid = array();
  879. foreach ($c as $k => $v) {
  880. $details[$v['details']] = $v['details'];
  881. if ($v['cpid'] != 0) {
  882. $cpid[$v['cpid']] = $v['cpid'];
  883. }
  884. }
  885. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  886. $classid = $this->classid->sku();
  887. $pm = $classid;
  888. $features = explode('-', trim($value['features'], '-'));
  889. foreach ($features as $v) {
  890. $zh = explode('|', trim($t[$v]['zh'], '|'));
  891. $pm[$t[$v]['classid']] = $zh[0];
  892. }
  893. $zh = implode(" ", $pm);
  894. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  895. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  896. $info_list[$key]['sm'] = $zh;
  897. }
  898. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  899. $pagenum = ceil($total / $perpage);
  900. $over = $total - ($start + $perpage);
  901. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  902. echo json_encode($rows);
  903. exit;
  904. }
  905. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  906. $this->_Template('whlabel_typeck', $this->data);
  907. }
  908. //进销存导出
  909. public function _whlabeckdc()
  910. {
  911. $prc = array();
  912. $purchase = $this->purchase->find_all();
  913. foreach ($purchase as $k => $v) {
  914. $prc[$v['id']] = $v['title'];
  915. }
  916. if (isset($_GET['excel'])) {
  917. $where = "sku != 'Preset'";
  918. //数据排序
  919. $order_str = "id desc";
  920. if (empty($page)) {
  921. $start = 0;
  922. $perpage = 1;
  923. } else {
  924. $start = ($page - 1) * $perpage;
  925. }
  926. $category = $this->input->get('category', true);
  927. $color = $this->input->get('color', true);
  928. $lowe = $this->input->get('lowe', true);
  929. $lacetype = $this->input->get('lacetype', true);
  930. $size = $this->input->get('size', true);
  931. $density = $this->input->get('density', true);
  932. $haircap = $this->input->get('haircap', true);
  933. $sku = $this->input->get('sku', true);
  934. $details = $this->input->get('details', true);
  935. $warehouse = 13;
  936. $excelid = $this->input->get('sid', true);
  937. if ($category) {
  938. $where .= " and features like '%-$category-%'";
  939. }
  940. if ($color) {
  941. $where .= " and features like '%-$color-%'";
  942. }
  943. if ($lowe) {
  944. $where .= " and features like '%-$lowe-%'";
  945. }
  946. if ($lacetype) {
  947. $where .= " and features like '%-$lacetype-%'";
  948. }
  949. if ($size) {
  950. $where .= " and features like '%-$size-%'";
  951. }
  952. if ($density) {
  953. $where .= " and features like '%-$density-%'";
  954. }
  955. if ($haircap) {
  956. $where .= " and features like '%-$haircap-%'";
  957. }
  958. if ($warehouse) {
  959. $where .= " and warehouse = '$warehouse'";
  960. }
  961. if ($sku) {
  962. $where .= " and sku like '%$sku%'";
  963. }
  964. if ($details) {
  965. $where .= " and details = '$details'";
  966. }
  967. $xzid = '';
  968. if ($excelid) {
  969. $excelid = explode(',', trim($excelid, ','));
  970. foreach ($excelid as $key => $value) {
  971. $xzid .= " id = " . $value . " or";
  972. }
  973. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  974. }
  975. //取得信息列表
  976. /**
  977. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  978. $rows = array();$list = array();
  979. foreach ($info_list as $key=>$value)
  980. {
  981. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  982. }
  983. **/
  984. $wh = array();
  985. $w = $this->warehouse->find_all('1=1', 'id,title');
  986. foreach ($w as $v) {
  987. $wh[$v['id']] = $v['title'];
  988. }
  989. $tc = array();
  990. $tcdata = array();
  991. $typeclass = $this->typeclass->find_all();
  992. foreach ($typeclass as $v) {
  993. $tc[$v['id']] = $v;
  994. }
  995. $list = array();
  996. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,number,features');
  997. foreach ($rows as $key => $value) {
  998. $bm = '03';
  999. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  1000. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1001. $classid = $this->classid->sku();
  1002. $pm = $classid;
  1003. $jm = $classid;
  1004. $features = explode('-', trim($value['features'], '-'));
  1005. foreach ($features as $v) {
  1006. if (isset($tc[$v]) && isset($bmpx[$tc[$v]['classid']])) {
  1007. if ($tc[$v]['bm'] != '') {
  1008. $bmpx[$tc[$v]['classid']] = $tc[$v]['bm'];
  1009. }
  1010. }
  1011. if (isset($tc[$v])) {
  1012. $zh = explode('|', trim($tc[$v]['zh'], '|'));
  1013. $pm[$tc[$v]['classid']] = $zh[0];
  1014. }
  1015. if (isset($tc[$v])) {
  1016. if (isset($jm[$tc[$v]['classid']])) {
  1017. $jm[$tc[$v]['classid']] = $tc[$v]['jm'];
  1018. }
  1019. }
  1020. }
  1021. $zh = implode(" ", $pm);
  1022. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  1023. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1024. $rows[$key]['dbcontent'] = $zh;
  1025. $rows[$key]['cpbz'] = $bm . implode("", $bmpx);
  1026. $jm = array_filter($jm);
  1027. $rows[$key]['cs'] = implode("-", $jm);
  1028. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  1029. $details = array();
  1030. $cpid = array();
  1031. $cpbz = array();
  1032. $c = 0;
  1033. $g = 0;
  1034. $x = 0;
  1035. $t = 0;
  1036. $s = 0;
  1037. $q = 0;
  1038. foreach ($sd as $k => $v) {
  1039. if ($v['state'] == 0) {
  1040. $c++;
  1041. }
  1042. if ($v['state'] != 9) {
  1043. $g++;
  1044. }
  1045. if ($v['state'] == 1) {
  1046. $x++;
  1047. }
  1048. if ($v['state'] == 2) {
  1049. $t++;
  1050. }
  1051. if ($v['state'] == 8) {
  1052. $s++;
  1053. }
  1054. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1055. $q++;
  1056. }
  1057. $details[$v['details']] = $v['details'];
  1058. if ($v['cpid'] != 0) {
  1059. $cpid[$v['cpid']] = $v['cpid'];
  1060. }
  1061. if ($v['cpbz'] != '') {
  1062. $cpbz[$v['cpbz']] = $v['cpbz'];
  1063. }
  1064. }
  1065. $rows[$key]['details'] = implode("、", $details);
  1066. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1067. $number = $value['number'];
  1068. $ftime = time() - 15 * 24 * 3600;
  1069. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1070. $rows[$key]['number'] = $g;
  1071. $rows[$key]['features'] = $c;
  1072. $rows[$key]['x'] = $x;
  1073. $rows[$key]['t'] = $t;
  1074. $rows[$key]['s'] = $s;
  1075. $rows[$key]['q'] = $q;
  1076. $rows[$key]['wzsl'] = count($details);
  1077. }
  1078. $title = "进销存统计表" . date('Y-m-d', time());
  1079. $titlename = "<table border=1>
  1080. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1081. <tr align='center'>
  1082. <td>仓库</td>
  1083. <td>供应商</td>
  1084. <td>位置</td>
  1085. <td>库存编码</td>
  1086. <td>SKU</td>
  1087. <td>用友编码</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. </tr>
  1099. </table>";
  1100. $filename = $title . ".xls";
  1101. $tail = "";
  1102. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1103. }
  1104. }
  1105. public function _type()
  1106. {
  1107. $vip = 0;
  1108. if (isset($_SESSION['api'])) {
  1109. $user = $this->user->get_api($_SESSION['api']);
  1110. $fgshop = "";
  1111. $sid = "";
  1112. $usersp = explode('|', trim($user['shop'], '|'));
  1113. foreach ($usersp as $value) {
  1114. $fgshop .= " shop = " . $value . " or";
  1115. $sid .= " id = " . $value . " or";
  1116. }
  1117. if ($user['vip'] == 1) {
  1118. $vip = 1;
  1119. }
  1120. } else {
  1121. header('Location: /');
  1122. exit;
  1123. }
  1124. $prc = array();
  1125. $purchase = $this->purchase->find_all();
  1126. foreach ($purchase as $k => $v) {
  1127. $prc[$v['id']] = $v['title'];
  1128. }
  1129. $company = array();
  1130. $ct = $this->company->find_all();
  1131. foreach ($ct as $k => $v) {
  1132. $company[$v['id']] = $v['title'];
  1133. }
  1134. $sp = array();
  1135. $s = $this->shop->find_all('1=1', 'id,shopname');
  1136. foreach ($s as $v) {
  1137. $sp[$v['id']] = $v['shopname'];
  1138. }
  1139. $wh = array();
  1140. $w = $this->warehouse->find_all('1=1', 'id,title');
  1141. foreach ($w as $v) {
  1142. $wh[$v['id']] = $v['title'];
  1143. }
  1144. $post = $this->input->post(NULL, TRUE);
  1145. if (isset($post['page'])) {
  1146. $page = $this->input->post('page', true);
  1147. $perpage = $this->input->post('perpage', true);
  1148. $category = $this->input->post('category', true);
  1149. $size = $this->input->post('size', true);
  1150. $grade = $this->input->post('grade', true);
  1151. $color = $this->input->post('color', true);
  1152. $lowe = $this->input->post('lowe', true);
  1153. $sku = $this->input->post('sku');
  1154. $title = $this->input->post('title');
  1155. $warehouse = $this->input->post('warehouse', true);
  1156. $usa = $this->input->post('usa', true);
  1157. $purchase = $this->input->post('purchase', true);
  1158. $lacetype = $this->input->post('lacetype', true);
  1159. $haircap = $this->input->post('haircap', true);
  1160. $density = $this->input->post('density', true);
  1161. $details = $this->input->post('details', true);
  1162. $state = $this->input->post('state', true);
  1163. $shop = $this->input->post('shop', true);
  1164. $lacecolor = $this->input->post('lacecolor', true);
  1165. $hairnumber = $this->input->post('hairnumber', true);
  1166. $type = $this->input->post('type', true);
  1167. $ktime = $this->input->post('ktime', true);
  1168. $jtime = $this->input->post('jtime', true);
  1169. $ktime = strtotime($ktime);
  1170. $jtime = strtotime($jtime);
  1171. $cpbz = $this->input->post('cpbz', true);
  1172. $where = "1=1";
  1173. $gj = "";
  1174. $ck = "";
  1175. if ($usa) {
  1176. if (!$warehouse) {
  1177. $where .= " and (warehouse = '5' or warehouse = '8')";
  1178. }
  1179. }
  1180. if ($warehouse) {
  1181. $where .= " and warehouse = '$warehouse'";
  1182. }
  1183. if ($details) {
  1184. $where .= " and details = '$details'";
  1185. }
  1186. if ($purchase) {
  1187. $where .= " and purchase = '$purchase'";
  1188. }
  1189. if ($state) {
  1190. $where .= " and state = '$state'";
  1191. }
  1192. if ($shop) {
  1193. $where .= " and shop like '%$shop%'";
  1194. }
  1195. if ($type) {
  1196. $where .= " and type = '$type'";
  1197. }
  1198. if ($ktime && $jtime) {
  1199. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1200. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1201. }
  1202. if ($cpbz) {
  1203. $where .= " and cpbz like '%$cpbz%' ";
  1204. }
  1205. if ($lacecolor) {
  1206. $where .= " and features like '%-$lacecolor-%'";
  1207. }
  1208. if ($lacetype) {
  1209. $where .= " and features like '%-$lacetype-%'";
  1210. }
  1211. if ($category) {
  1212. $where .= " and features like '%-$category-%'";
  1213. }
  1214. if ($size) {
  1215. $where .= " and features like '%-$size-%'";
  1216. }
  1217. if ($grade) {
  1218. $where .= " and features like '%-$grade-%'";
  1219. }
  1220. if ($color) {
  1221. $where .= " and features like '%-$color-%'";
  1222. }
  1223. if ($lowe) {
  1224. $where .= " and features like '%-$lowe-%'";
  1225. }
  1226. if ($haircap) {
  1227. $where .= " and features like '%-$haircap-%'";
  1228. }
  1229. if ($density) {
  1230. $where .= " and features like '%-$density-%'";
  1231. }
  1232. if (!empty($hairnumber)) {
  1233. $where .= " and features like '%-128-%' ";
  1234. if ($hairnumber < 0) {
  1235. $class_list = $this->typeclass->find_all('classid = 43');
  1236. foreach ($class_list as $v) {
  1237. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1238. }
  1239. } else {
  1240. $where .= " and features like '%-$hairnumber-%'";
  1241. }
  1242. }
  1243. //数据排序
  1244. $order_str = "id desc";
  1245. if (empty($page)) {
  1246. $start = 0;
  1247. $perpage = 1;
  1248. } else {
  1249. $start = ($page - 1) * $perpage;
  1250. }
  1251. $fjnr = '';
  1252. if ($sku) {
  1253. $sku = trim($sku, ' ');
  1254. $sku = trim($sku, ' ');
  1255. $fjnr .= " and sku like '%$sku%'";
  1256. }
  1257. if ($title) {
  1258. $title = trim($title, ' ');
  1259. $title = trim($title, ' ');
  1260. $fjnr .= " and title like '%$title%'";
  1261. }
  1262. $wt = array();
  1263. $whlabel_type = $this->whlabel_type->find_all();
  1264. foreach ($whlabel_type as $v) {
  1265. $wt[$v['id']] = $v['title'];
  1266. }
  1267. //$where .= " and time > '$ktime' and time < '$jtime'";
  1268. $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
  1269. //取得信息列表
  1270. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1271. $rows = array();
  1272. $list = array();
  1273. foreach ($info_list as $key => $value) {
  1274. if (isset($wt[$value['type']])) {
  1275. $info_list[$key]['type'] = $wt[$value['type']];
  1276. } else {
  1277. $info_list[$key]['type'] = '未设置';
  1278. }
  1279. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1280. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1281. $ztdata = '';
  1282. if (count($zt) > 0) {
  1283. foreach ($zt as $vv) {
  1284. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1285. }
  1286. }
  1287. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1288. $cdata = array_filter($qbdata, function ($item) {
  1289. return $item['state'] < 1;
  1290. });
  1291. $c = array_sum(array_column($cdata, 'jnum'));
  1292. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1293. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1294. });
  1295. $g = array_sum(array_column($gdata, 'jnum'));
  1296. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1297. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1298. });
  1299. $x = array_sum(array_column($xdata, 'jnum'));
  1300. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1301. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1302. });
  1303. $t = array_sum(array_column($tdata, 'jnum'));
  1304. $zdata = array_filter($qbdata, function ($item) {
  1305. return $item['zd'] != "" && $item['state'] < 1;
  1306. });
  1307. $z = array_sum(array_column($zdata, 'jnum'));
  1308. $zdata = array_filter($qbdata, function ($item) {
  1309. return $item['zd'] != "" && $item['state'] < 1;
  1310. });
  1311. $z = array_sum(array_column($zdata, 'jnum'));
  1312. //$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');
  1313. //$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'].'"');
  1314. //$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'].'"');
  1315. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1316. //$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'].'"');
  1317. $details = array();
  1318. $cpid = array();
  1319. $od = array();
  1320. $odid = '';
  1321. $companytitle = '';
  1322. foreach ($qbdata as $v) {
  1323. if ($v['zd'] != "" && $v['state'] < 1) {
  1324. if (!isset($od[$v['zd']])) {
  1325. $od[$v['zd']] = 1; //所有数据sku
  1326. } else {
  1327. $od[$v['zd']] = $od[$v['zd']] + 1;
  1328. }
  1329. }
  1330. if ($v['state'] < 1) {
  1331. $details[$v['details']] = $v['details'];
  1332. if ($v['cpid'] != 0) {
  1333. $cpid[$v['cpid']] = $v['cpid'];
  1334. }
  1335. }
  1336. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1337. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1338. }
  1339. }
  1340. foreach ($od as $k => $vv) {
  1341. $odid .= $k . '数量' . $vv;
  1342. }
  1343. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  1344. $number = $value['number'];
  1345. $ftime = time() - 15 * 24 * 3600;
  1346. $z = $z . '(' . $odid . ')'; //查看订单号
  1347. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1348. $info_list[$key]['features'] = $c;
  1349. $info_list[$key]['number'] = $ztdata;
  1350. $info_list[$key]['sm'] = $g;
  1351. $info_list[$key]['x'] = $x;
  1352. $info_list[$key]['t'] = $t;
  1353. $info_list[$key]['z'] = $z;
  1354. /**
  1355. foreach ($cdata as $k=>$v)
  1356. {
  1357. $details[$v['details']] = $v['details'];
  1358. if($v['cpid'] != 0)
  1359. {
  1360. $cpid[$v['cpid']] = $v['cpid'];
  1361. }
  1362. }
  1363. **/
  1364. $info_list[$key]['shop'] = '';
  1365. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1366. if ($value['shop'] != '') {
  1367. $shop = explode(',', trim($value['shop'], ','));
  1368. $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1369. }
  1370. $info_list[$key]['shop'] .= $companytitle;
  1371. /**
  1372. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1373. if(isset($companytitle[0]))
  1374. {
  1375. foreach ($companytitle as $k=>$v)
  1376. {
  1377. if($v['companytitle'] != '')
  1378. {
  1379. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1380. }
  1381. }
  1382. }
  1383. **/
  1384. }
  1385. $final_all_list = [];
  1386. foreach ($info_list as $k => $v) {
  1387. $final_all_list[] = [
  1388. 'id' => $v['id'],
  1389. "warehouse" => $v["warehouse"],
  1390. "purchase" => $v["purchase"],
  1391. "sku" => $v["sku"],
  1392. "title" => $v["title"] . "<br/>" . $v["pm"],
  1393. "details" => $v["details"],
  1394. "shop" => $v["shop"],
  1395. "cpbz" => $v["cpbz"],
  1396. "type" => $v["type"],
  1397. "features" => $v["features"],
  1398. "number" => $v["number"],
  1399. "sm" => $v["sm"],
  1400. "x" => $v["x"],
  1401. "t" => $v["t"],
  1402. "z" => $v["z"]
  1403. ];
  1404. }
  1405. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1406. $pagenum = ceil($total / $perpage);
  1407. $over = $total - ($start + $perpage);
  1408. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1409. echo json_encode($rows);
  1410. exit;
  1411. }
  1412. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1413. $this->data['shop'] = $wlshop;
  1414. $this->data['vip'] = $vip;
  1415. $this->_Template('whlabel_type', $this->data);
  1416. }
  1417. //美仓进销存浏览
  1418. public function _usatype()
  1419. {
  1420. if (isset($_SESSION['api'])) {
  1421. $user = $this->user->get_api($_SESSION['api']);
  1422. $usp = $user;
  1423. $fgshop = "";
  1424. $sid = "";
  1425. $wid = "";
  1426. $wtype = "";
  1427. $userwh = explode('|', trim($user['warehouse'], '|'));
  1428. foreach ($userwh as $value) {
  1429. $wid .= " id = " . $value . " or";
  1430. $wtype .= " type = " . $value . " or";
  1431. }
  1432. }
  1433. $prc = array();
  1434. $purchase = $this->purchase->find_all();
  1435. foreach ($purchase as $k => $v) {
  1436. $prc[$v['id']] = $v['title'];
  1437. }
  1438. $post = $this->input->post(NULL, TRUE);
  1439. if (isset($post['page'])) {
  1440. $page = $this->input->post('page', true);
  1441. $perpage = $this->input->post('perpage', true);
  1442. $category = $this->input->post('category', true);
  1443. $size = $this->input->post('size', true);
  1444. $grade = $this->input->post('grade', true);
  1445. $color = $this->input->post('color', true);
  1446. $lowe = $this->input->post('lowe', true);
  1447. $sku = $this->input->post('sku');
  1448. $title = $this->input->post('title');
  1449. $warehouse = $this->input->post('warehouse', true);
  1450. $usa = $this->input->post('usa', true);
  1451. $purchase = $this->input->post('purchase', true);
  1452. $lacetype = $this->input->post('lacetype', true);
  1453. $haircap = $this->input->post('haircap', true);
  1454. $density = $this->input->post('density', true);
  1455. $details = $this->input->post('details', true);
  1456. $state = $this->input->post('state', true);
  1457. $lacecolor = $this->input->post('lacecolor', true);
  1458. $cklx = $this->input->post('cklx', true);
  1459. $ktime = $this->input->post('ktime', true);
  1460. $jtime = $this->input->post('jtime', true);
  1461. $ktime = strtotime($ktime);
  1462. $jtime = strtotime($jtime);
  1463. $where = "1=1";
  1464. $gj = "";
  1465. $ck = "";
  1466. if ($lacetype) {
  1467. $where .= " and features like '%-$lacetype-%'";
  1468. }
  1469. if ($category) {
  1470. $where .= " and features like '%-$category-%'";
  1471. }
  1472. if ($size) {
  1473. $where .= " and features like '%-$size-%'";
  1474. }
  1475. if ($grade) {
  1476. $where .= " and features like '%-$grade-%'";
  1477. }
  1478. if ($color) {
  1479. $where .= " and features like '%-$color-%'";
  1480. }
  1481. if ($lowe) {
  1482. $where .= " and features like '%-$lowe-%'";
  1483. }
  1484. if ($haircap) {
  1485. $where .= " and features like '%-$haircap-%'";
  1486. }
  1487. if ($density) {
  1488. $where .= " and features like '%-$density-%'";
  1489. }
  1490. if ($lacecolor) {
  1491. $where .= " and features like '%-$lacecolor-%'";
  1492. }
  1493. if ($usa) {
  1494. if (!$warehouse) {
  1495. $where .= " and (warehouse = '5' or warehouse = '8')";
  1496. }
  1497. }
  1498. if ($warehouse) {
  1499. $where .= " and warehouse = '$warehouse'";
  1500. }
  1501. if ($details) {
  1502. $where .= " and details = '$details'";
  1503. }
  1504. if ($purchase) {
  1505. $where .= " and purchase = '$purchase'";
  1506. }
  1507. if ($state) {
  1508. $where .= " and state = '$state'";
  1509. }
  1510. $where_add = '';
  1511. if ($cklx) {
  1512. $shop = $this->shop->read($cklx);
  1513. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1514. }
  1515. if ($ktime && $jtime) {
  1516. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1517. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1518. }
  1519. //数据排序
  1520. $order_str = "id desc";
  1521. if (empty($page)) {
  1522. $start = 0;
  1523. $perpage = 1;
  1524. } else {
  1525. $start = ($page - 1) * $perpage;
  1526. }
  1527. if ($sku) {
  1528. $sku = trim($sku, ' ');
  1529. $sku = trim($sku, ' ');
  1530. $where .= " and sku like '%$sku%'";
  1531. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1532. } else if ($title) {
  1533. $title = trim($title, ' ');
  1534. $title = trim($title, ' ');
  1535. $where .= " and title like '%$title%'";
  1536. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1537. } else {
  1538. //$where .= " and time > '$ktime' and time < '$jtime'";
  1539. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1540. }
  1541. //取得信息列表
  1542. $rows = array();
  1543. $list = array();
  1544. foreach ($info_list as $key => $value) {
  1545. $warehouse = $this->warehouse->read($value['warehouse']);
  1546. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1547. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1548. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1549. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1550. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1551. $od = array();
  1552. $odid = '';
  1553. foreach ($z as $v) {
  1554. if (!isset($od[$v['zd']])) {
  1555. $od[$v['zd']] = 1; //所有数据sku
  1556. } else {
  1557. $od[$v['zd']] = $od[$v['zd']] + 1;
  1558. }
  1559. }
  1560. foreach ($od as $k => $vv) {
  1561. $odid .= $k . '数量' . $vv . ' ';
  1562. }
  1563. $z = count($z) . '(' . $odid . ')'; //查看订单号
  1564. $info_list[$key]['features'] = $c;
  1565. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1566. $ztdata = '';
  1567. if (count($zt) > 0) {
  1568. foreach ($zt as $vv) {
  1569. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1570. }
  1571. }
  1572. $info_list[$key]['warehouse'] = $ztdata;
  1573. $info_list[$key]['g'] = $g;
  1574. $info_list[$key]['x'] = $x;
  1575. $info_list[$key]['t'] = $t;
  1576. $info_list[$key]['z'] = $z;
  1577. }
  1578. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  1579. $pagenum = ceil($total / $perpage);
  1580. $over = $total - ($start + $perpage);
  1581. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  1582. echo json_encode($rows);
  1583. exit;
  1584. }
  1585. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  1586. $this->data['warehouse'] = $warehouse;
  1587. $this->_Template('whlabel_typeusa', $this->data);
  1588. }
  1589. //美仓进销存浏览
  1590. public function _usatypeapp()
  1591. {
  1592. $post = $this->input->post(NULL, TRUE);
  1593. if (isset($post['page'])) {
  1594. $page = $this->input->post('page', true);
  1595. $perpage = $this->input->post('perpage', true);
  1596. $sku = $this->input->post('sku', true);
  1597. $warehouse = 5;
  1598. $title = $this->input->post('title', true);
  1599. $state = $this->input->post('state', true);
  1600. $ktime = $this->input->post('ktime', true);
  1601. $jtime = $this->input->post('jtime', true);
  1602. $ktime = strtotime($ktime);
  1603. $jtime = strtotime($jtime);
  1604. $where = "1=1";
  1605. $gj = "";
  1606. $ck = "";
  1607. if ($title) {
  1608. $st = explode(' ', trim($title, ' '));
  1609. foreach ($st as $v) {
  1610. $where .= " and title like '%$v%'";
  1611. }
  1612. }
  1613. if ($warehouse) {
  1614. $where .= " and warehouse = '$warehouse'";
  1615. }
  1616. if ($state) {
  1617. $where .= " and state = '$state'";
  1618. }
  1619. if ($sku) {
  1620. $where .= " and sku like '%$sku%'";
  1621. }
  1622. if ($ktime && $jtime) {
  1623. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1624. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1625. }
  1626. //数据排序
  1627. $order_str = "id desc";
  1628. if (empty($page)) {
  1629. $start = 0;
  1630. $perpage = 1;
  1631. } else {
  1632. $start = ($page - 1) * $perpage;
  1633. }
  1634. //取得信息列表
  1635. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  1636. $rows = array();
  1637. $list = array();
  1638. foreach ($info_list as $key => $value) {
  1639. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  1640. }
  1641. $rowsdq = array_slice($rows, $start, $perpage);
  1642. foreach ($rowsdq as $value) {
  1643. $warehouse = $this->warehouse->read($value['warehouse']);
  1644. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  1645. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  1646. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  1647. $od = array();
  1648. $odid = '';
  1649. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  1650. }
  1651. $total = count($rows);
  1652. $pagenum = ceil($total / $perpage);
  1653. $over = $total - ($start + $perpage);
  1654. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  1655. echo json_encode($rows);
  1656. exit;
  1657. }
  1658. $this->_Template('phone/p_usatypeapp', $this->data);
  1659. }
  1660. //入库操作
  1661. public function _enteradd()
  1662. {
  1663. $dt = 0;
  1664. if (isset($_SESSION['api'])) {
  1665. $user = $this->user->get_api($_SESSION['api']);
  1666. $usp = $user;
  1667. $fgshop = "";
  1668. $sid = "";
  1669. $user = explode('|', trim($user['shop'], '|'));
  1670. foreach ($user as $value) {
  1671. $fgshop .= " shop = " . $value . " or";
  1672. $sid .= " id = " . $value . " or";
  1673. }
  1674. }
  1675. $tc = $this->typeclass->find_all();
  1676. $typeclass = array();
  1677. foreach ($tc as $v) {
  1678. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  1679. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  1680. }
  1681. $post = $this->input->post(NULL, TRUE);
  1682. if (isset($post['sku'])) {
  1683. $list = array();
  1684. $num = "";
  1685. $title = "";
  1686. $features = "";
  1687. $order = $this->input->post('order', true);
  1688. $shop = $this->input->post('shop', true);
  1689. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1690. $sku = $this->input->post('sku', true);
  1691. $post['sm'] = $this->input->post('sm', true);
  1692. $post['warehouse'] = $this->input->post('warehouse', true);
  1693. $post['purchase'] = $this->input->post('purchase', true);
  1694. $post['retreatwarehouse'] = $post['warehouse'];
  1695. $post['state'] = $this->input->post('state', true);
  1696. $post['rktype'] = $this->input->post('rktype', true);
  1697. $post['text'] = $this->input->post('text', true);
  1698. $category = $this->input->post('category', true);
  1699. $list['category'] = $category;
  1700. $list['hairtype'] = $this->input->post('hairtype', true);
  1701. $list['grade'] = $this->input->post('grade', true);
  1702. $size = $this->input->post('size', true);
  1703. $xzsku = $this->input->post('xzsku', true);
  1704. $list['size'] = rtrim($size, ',');
  1705. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1706. $list['extension'] = $this->input->post('extension', true);
  1707. if ($category == 1297) {
  1708. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1709. }
  1710. if ($category == 1702) {
  1711. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1712. $list['syother'] = $this->input->post('syother', true);
  1713. }
  1714. if ($category == 133) {
  1715. $list['fittype'] = $this->input->post('fittype', true);
  1716. $list['acother'] = $this->input->post('acother', true);
  1717. }
  1718. $list['color'] = $this->input->post('color', true);
  1719. $list['lowe'] = $this->input->post('lowe', true);
  1720. if (!$post['purchase']) {
  1721. $post['purchase'] = 1;
  1722. }
  1723. if ($category == 127) {
  1724. $list['type'] = $this->input->post('type', true);
  1725. $list['headroad'] = $this->input->post('headroad', true);
  1726. $list['density'] = $this->input->post('density', true);
  1727. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1728. $list['lacesize'] = $this->input->post('lacesize', true);
  1729. }
  1730. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1731. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1732. }
  1733. if ($category == 128) {
  1734. $list['lacetype'] = $this->input->post('lacetype', true);
  1735. $list['haircap'] = $this->input->post('haircap', true);
  1736. $list['density'] = $this->input->post('density', true);
  1737. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1738. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1739. $list['wigother'] = $this->input->post('wigother', true);
  1740. $list['wigother2'] = $this->input->post('wigother2', true);
  1741. }
  1742. if ($category == 129) {
  1743. $list['wide'] = $this->input->post('wide', true);
  1744. }
  1745. if ($category == 131) {
  1746. $list['gifttype'] = $this->input->post('gifttype', true);
  1747. $list['giftother'] = $this->input->post('giftother', true);
  1748. }
  1749. if ($category == 134) {
  1750. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1751. }
  1752. if ($category == 1297) {
  1753. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1754. $list['sywigother'] = $this->input->post('sywigother', true);
  1755. }
  1756. if ($category == 130 || $category == 133 || $category == 1702) {
  1757. $list['items'] = $this->input->post('items', true);
  1758. $list['weight'] = $this->input->post('weight', true);
  1759. }
  1760. if ($category == 1702) {
  1761. $list['syhairther'] = $this->input->post('syhairther', true);
  1762. }
  1763. $classid = $this->classid->sku();
  1764. $scsku = $classid;
  1765. $pm = $classid;
  1766. foreach ($list as $k => $v) {
  1767. if ($v != 0) {
  1768. $num .= $v;
  1769. $features .= $v . '-';
  1770. $post[$k] = $v;
  1771. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  1772. if ($k != 'size') {
  1773. $title .= $typeclass[$v]['title'] . " ";
  1774. }
  1775. if (isset($pm[$typeclass[$v]['classid']])) {
  1776. if ($typeclass[$v]['title'] == '9A') {
  1777. $pm[$typeclass[$v]['classid']] = '9A';
  1778. } else if ($typeclass[$v]['title'] == '10A') {
  1779. $pm[$typeclass[$v]['classid']] = '10A';
  1780. } else {
  1781. $clzh = $typeclass[$v]['zh'];
  1782. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  1783. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  1784. $clzh = $clzh[0];
  1785. }
  1786. $pm[$typeclass[$v]['classid']] = $clzh;
  1787. }
  1788. }
  1789. }
  1790. }
  1791. $zh = implode(" ", $pm);
  1792. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  1793. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  1794. if ($list['size']) {
  1795. $typeclass = $this->typeclass->read($list['size']);
  1796. $title .= $typeclass['title'];
  1797. }
  1798. $time = time();
  1799. if ($xzsku) {
  1800. $scsku = implode("-", $scsku);
  1801. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  1802. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  1803. $post['sku'] = trim($scsku, ' ');
  1804. } else {
  1805. $post['sku'] = $sku;
  1806. }
  1807. //$post['sku'] = trim($sku,' ');
  1808. $post['title'] = rtrim($title, ' ');
  1809. $post['number'] = $num;
  1810. $post['features'] = '-' . $features;
  1811. $post['enter'] = $time;
  1812. $post['time'] = $time; //操作时间
  1813. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1814. if ($yza) {
  1815. if ($post['features'] != $yza[0]['features']) {
  1816. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  1817. exit;
  1818. }
  1819. }
  1820. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  1821. if ($yzb) {
  1822. if ($post['sku'] != $yzb[0]['sku']) {
  1823. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  1824. exit;
  1825. }
  1826. }
  1827. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  1828. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  1829. exit;
  1830. }
  1831. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  1832. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  1833. exit;
  1834. }
  1835. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  1836. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  1837. exit;
  1838. }
  1839. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  1840. if (isset($yz[0]['type'])) {
  1841. $post['type'] = $yz[0]['type'];
  1842. }
  1843. if ($post['state'] == 9) //如果选择预设库存
  1844. {
  1845. $this->whlabel->insert($post);
  1846. } else {
  1847. /**
  1848. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  1849. if($ljg == 1)
  1850. {
  1851. for($i=0;$i<$order;$i++)
  1852. {
  1853. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  1854. $this->whlabel->insert($post);
  1855. }
  1856. }
  1857. **/
  1858. //if($post['warehouse'] == '5')
  1859. //{
  1860. //}
  1861. $yydata = $post;
  1862. $yydata['zh'] = $zh;
  1863. /**
  1864. $wl = $this->apiyy->get_cjlp($yydata);
  1865. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  1866. {
  1867. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  1868. }
  1869. if($wl['Data'][0]['m_isSucess'] != 1)
  1870. {
  1871. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  1872. }
  1873. **/
  1874. for ($i = 0; $i < $order; $i++) {
  1875. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  1876. $this->whlabel->insert($post);
  1877. }
  1878. }
  1879. echo json_encode(array('msg' => '入库成功', 'success' => true));
  1880. exit;
  1881. }
  1882. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1883. $this->data['wlshop'] = $wlshop;
  1884. $this->_Template('whlabel_enteradd', $this->data);
  1885. }
  1886. //修改产品
  1887. public function _enteredit($arg_array)
  1888. {
  1889. $dt = 0;
  1890. if (isset($_SESSION['api'])) {
  1891. $user = $this->user->get_api($_SESSION['api']);
  1892. $usp = $user;
  1893. $fgshop = "";
  1894. $sid = "";
  1895. $user = explode('|', trim($user['shop'], '|'));
  1896. foreach ($user as $value) {
  1897. $fgshop .= " shop = " . $value . " or";
  1898. $sid .= " id = " . $value . " or";
  1899. }
  1900. }
  1901. $post = $this->input->post(NULL, TRUE);
  1902. if (isset($post['sku'])) {
  1903. $list = array();
  1904. $num = "";
  1905. $title = "";
  1906. $features = "";
  1907. $id = $this->input->post('id', true);
  1908. $order = $this->input->post('order', true);
  1909. $shop = $this->input->post('shop', true);
  1910. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  1911. $post['sku'] = $this->input->post('sku', true);
  1912. $post['sm'] = $this->input->post('sm', true);
  1913. $post['warehouse'] = $this->input->post('warehouse', true);
  1914. $post['purchase'] = $this->input->post('purchase', true);
  1915. $post['retreatwarehouse'] = $post['warehouse'];
  1916. $category = $this->input->post('category', true);
  1917. $list['category'] = $category;
  1918. $list['hairtype'] = $this->input->post('hairtype', true);
  1919. $list['grade'] = $this->input->post('grade', true);
  1920. $size = $this->input->post('size', true);
  1921. $list['size'] = rtrim($size, ',');
  1922. $post['rktype'] = $this->input->post('rktype', true);
  1923. $post['text'] = $this->input->post('text', true);
  1924. $list['hairnumber'] = $this->input->post('hairnumber', true);
  1925. $list['extension'] = $this->input->post('extension', true);
  1926. if ($category == 1297) {
  1927. $list['sywignumber'] = $this->input->post('sywignumber', true);
  1928. }
  1929. if ($category == 1702) {
  1930. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  1931. $list['syother'] = $this->input->post('syother', true);
  1932. }
  1933. if ($category == 133) {
  1934. $list['fittype'] = $this->input->post('fittype', true);
  1935. $list['acother'] = $this->input->post('acother', true);
  1936. }
  1937. $list['color'] = $this->input->post('color', true);
  1938. $list['lowe'] = $this->input->post('lowe', true);
  1939. if (!$post['purchase']) {
  1940. $post['purchase'] = 1;
  1941. }
  1942. if ($category == 127) {
  1943. $list['type'] = $this->input->post('type', true);
  1944. $list['headroad'] = $this->input->post('headroad', true);
  1945. $list['density'] = $this->input->post('density', true);
  1946. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  1947. $list['lacesize'] = $this->input->post('lacesize', true);
  1948. }
  1949. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1950. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1951. }
  1952. if ($category == 128) {
  1953. $list['lacetype'] = $this->input->post('lacetype', true);
  1954. $list['haircap'] = $this->input->post('haircap', true);
  1955. $list['density'] = $this->input->post('density', true);
  1956. $list['lacecolor'] = $this->input->post('lacecolor', true);
  1957. $list['lacetypes'] = $this->input->post('lacetypes', true);
  1958. $list['wigother'] = $this->input->post('wigother', true);
  1959. $list['wigother2'] = $this->input->post('wigother2', true);
  1960. }
  1961. if ($category == 129) {
  1962. $list['wide'] = $this->input->post('wide', true);
  1963. }
  1964. if ($category == 131) {
  1965. $list['gifttype'] = $this->input->post('gifttype', true);
  1966. $list['giftother'] = $this->input->post('giftother', true);
  1967. }
  1968. if ($category == 134) {
  1969. $list['pieceweight'] = $this->input->post('pieceweight', true);
  1970. }
  1971. if ($category == 1297) {
  1972. $list['synthetictype'] = $this->input->post('synthetictype', true);
  1973. $list['sywigother'] = $this->input->post('sywigother', true);
  1974. }
  1975. if ($category == 130 || $category == 133 || $category == 1702) {
  1976. $list['items'] = $this->input->post('items', true);
  1977. $list['weight'] = $this->input->post('weight', true);
  1978. }
  1979. if ($category == 1702) {
  1980. $list['syhairther'] = $this->input->post('syhairther', true);
  1981. }
  1982. foreach ($list as $k => $v) {
  1983. if ($v != 0) {
  1984. $num .= $v;
  1985. $features .= $v . '-';
  1986. $typeclass = $this->typeclass->read($v);
  1987. if ($k != 'size') {
  1988. $title .= $typeclass['title'] . " ";
  1989. }
  1990. }
  1991. }
  1992. $typeclass = $this->typeclass->read($list['size']);
  1993. $title .= $typeclass['title'];
  1994. $time = time();
  1995. $post['title'] = rtrim($title, ' ');
  1996. $post['number'] = $num;
  1997. $post['features'] = '-' . $features;
  1998. $post['time'] = $time; //操作时间
  1999. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2000. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2001. exit;
  2002. }
  2003. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2004. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2005. exit;
  2006. }
  2007. $uid = $this->whlabel->read($id);
  2008. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2009. if ($datanum > 0) {
  2010. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2011. exit;
  2012. }
  2013. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2014. {
  2015. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2016. if ($yza) {
  2017. if ($post['features'] != $yza[0]['features']) {
  2018. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2019. exit;
  2020. }
  2021. }
  2022. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2023. if ($yzb) {
  2024. if ($post['sku'] != $yzb[0]['sku']) {
  2025. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2026. exit;
  2027. }
  2028. }
  2029. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2030. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2031. exit;
  2032. }
  2033. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2034. foreach ($data as $v) {
  2035. $post['id'] = $v['id'];
  2036. $this->whlabel->save($post, $v['id']);
  2037. }
  2038. } else {
  2039. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2040. if ($data > 0) {
  2041. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2042. exit;
  2043. } else {
  2044. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2045. foreach ($data as $v) {
  2046. $post['id'] = $v['id'];
  2047. $this->whlabel->save($post, $v['id']);
  2048. }
  2049. }
  2050. }
  2051. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2052. exit;
  2053. }
  2054. $uid = $this->whlabel->read($arg_array[0]);
  2055. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2056. $this->data['enter'] = $uid;
  2057. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2058. $this->data['wlshop'] = $wlshop;
  2059. $this->_Template('whlabel_enteredit', $this->data);
  2060. }
  2061. //入库浏览
  2062. public function _enter()
  2063. {
  2064. $post = $this->input->post(NULL, TRUE);
  2065. if (isset($post['s'])) {
  2066. $id_arr = $this->input->post('s');
  2067. $id_arr = explode(',', $id_arr);
  2068. if (!$id_arr) {
  2069. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2070. exit;
  2071. }
  2072. //循环删除记录
  2073. foreach ($id_arr as $v) {
  2074. $sid = $this->whlabel->read($v);
  2075. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2076. if ($count > 0) {
  2077. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2078. exit;
  2079. }
  2080. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2081. foreach ($info_list as $va) {
  2082. $this->whlabel->remove($va['id']);
  2083. }
  2084. }
  2085. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2086. exit;
  2087. }
  2088. $sp = array();
  2089. $s = $this->shop->find_all('1=1', 'id,shopname');
  2090. foreach ($s as $v) {
  2091. $sp[$v['id']] = $v['shopname'];
  2092. }
  2093. $wh = array();
  2094. $w = $this->warehouse->find_all('1=1', 'id,title');
  2095. foreach ($w as $v) {
  2096. $wh[$v['id']] = $v['title'];
  2097. }
  2098. if (isset($post['page'])) {
  2099. $page = $this->input->post('page', true);
  2100. $perpage = $this->input->post('perpage', true);
  2101. $category = $this->input->post('category', true);
  2102. $size = $this->input->post('size', true);
  2103. $grade = $this->input->post('grade', true);
  2104. $color = $this->input->post('color', true);
  2105. $lowe = $this->input->post('lowe', true);
  2106. $sku = $this->input->post('sku', true);
  2107. $warehouse = $this->input->post('warehouse', true);
  2108. $purchase = $this->input->post('purchase', true);
  2109. $ktime = $this->input->post('ktime', true);
  2110. $jtime = $this->input->post('jtime', true);
  2111. $ktime = strtotime($ktime);
  2112. $jtime = strtotime($jtime);
  2113. $where = "1=1";
  2114. $gj = "";
  2115. $ck = "";
  2116. if ($category) {
  2117. $where .= " and features like '%-$category-%'";
  2118. }
  2119. if ($size) {
  2120. $where .= " and features like '%-$size-%'";
  2121. }
  2122. if ($grade) {
  2123. $where .= " and features like '%-$grade-%'";
  2124. }
  2125. if ($color) {
  2126. $where .= " and features like '%-$color-%'";
  2127. }
  2128. if ($lowe) {
  2129. $where .= " and features like '%-$lowe-%'";
  2130. }
  2131. if ($warehouse) {
  2132. $where .= " and warehouse = '$warehouse'";
  2133. }
  2134. if ($purchase) {
  2135. $where .= " and purchase = '$purchase'";
  2136. }
  2137. if ($sku) {
  2138. $where .= " and sku like '%$sku%'";
  2139. }
  2140. if ($ktime && $jtime) {
  2141. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2142. }
  2143. //数据排序
  2144. $order_str = "enter desc";
  2145. if (empty($page)) {
  2146. $start = 0;
  2147. $perpage = 1;
  2148. } else {
  2149. $start = ($page - 1) * $perpage;
  2150. }
  2151. //取得信息列表
  2152. $info_list = $this->whlabel->find_pc($where, 'enter,warehouse,sku', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2153. foreach ($info_list as $k => $v) {
  2154. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2155. if ($v['shop'] == '') {
  2156. $s = '通用';
  2157. } else {
  2158. $info_list[$k]['shop'] = '';
  2159. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2160. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2161. }
  2162. }
  2163. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2164. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2165. $info_list[$k]['g'] = $g;
  2166. }
  2167. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2168. $pagenum = ceil($total / $perpage);
  2169. $over = $total - ($start + $perpage);
  2170. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2171. echo json_encode($rows);
  2172. exit;
  2173. }
  2174. $this->_Template('whlabel_enter', $this->data);
  2175. }
  2176. //出库浏览
  2177. public function _out()
  2178. {
  2179. $post = $this->input->post(NULL, TRUE);
  2180. if (isset($post['page'])) {
  2181. $page = $this->input->post('page', true);
  2182. $perpage = $this->input->post('perpage', true);
  2183. $category = $this->input->post('category', true);
  2184. $size = $this->input->post('size', true);
  2185. $grade = $this->input->post('grade', true);
  2186. $color = $this->input->post('color', true);
  2187. $lowe = $this->input->post('lowe', true);
  2188. $sku = $this->input->post('sku', true);
  2189. $warehouse = $this->input->post('warehouse', true);
  2190. $purchase = $this->input->post('purchase', true);
  2191. $state = $this->input->post('state', true);
  2192. $ktime = $this->input->post('ktime', true);
  2193. $jtime = $this->input->post('jtime', true);
  2194. $ktime = strtotime($ktime);
  2195. $jtime = strtotime($jtime);
  2196. $where = "state=3";
  2197. $gj = "";
  2198. $ck = "";
  2199. if ($category) {
  2200. $where .= " and features like '%-$category-%'";
  2201. }
  2202. if ($size) {
  2203. $where .= " and features like '%-$size-%'";
  2204. }
  2205. if ($grade) {
  2206. $where .= " and features like '%-$grade-%'";
  2207. }
  2208. if ($color) {
  2209. $where .= " and features like '%-$color-%'";
  2210. }
  2211. if ($lowe) {
  2212. $where .= " and features like '%-$lowe-%'";
  2213. }
  2214. if ($state) {
  2215. $where .= " and state = '$state'";
  2216. }
  2217. if ($warehouse) {
  2218. $where .= " and warehouse = '$warehouse'";
  2219. }
  2220. if ($purchase) {
  2221. $where .= " and purchase = '$purchase'";
  2222. }
  2223. if ($sku) {
  2224. $where .= " and sku = '$sku'";
  2225. }
  2226. if ($ktime && $jtime) {
  2227. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2228. }
  2229. //数据排序
  2230. $order_str = "id desc";
  2231. if (empty($page)) {
  2232. $start = 0;
  2233. $perpage = 1;
  2234. } else {
  2235. $start = ($page - 1) * $perpage;
  2236. }
  2237. //取得信息列表
  2238. $info_list = $this->whlabel->find_all($where, 'sku');
  2239. $rows = array();
  2240. $list = array();
  2241. foreach ($info_list as $key => $value) {
  2242. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2243. }
  2244. $rows = array_unique($rows); //删除重复记录
  2245. foreach ($rows as $key => $value) {
  2246. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2247. $ck = $this->warehouse->read($data['warehouse']);
  2248. $warehouse = $ck['title'];
  2249. $gy = $this->purchase->read($data['purchase']);
  2250. $purchase = $gy['purchase'];
  2251. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2252. $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);
  2253. }
  2254. $total = count($list);
  2255. $pagenum = ceil($total / $perpage);
  2256. $over = $total - ($start + $perpage);
  2257. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2258. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2259. echo json_encode($rows);
  2260. exit;
  2261. }
  2262. $this->_Template('whlabel_out', $this->data);
  2263. }
  2264. //出库标签浏览
  2265. public function _label()
  2266. {
  2267. $post = $this->input->post(NULL, TRUE);
  2268. if (isset($post['page'])) {
  2269. $page = $this->input->post('page', true);
  2270. $perpage = $this->input->post('perpage', true);
  2271. $sku = $this->input->post('sku', true);
  2272. $warehouse = $this->input->post('warehouse', true);
  2273. $purchase = $this->input->post('purchase', true);
  2274. $orderinfo = $this->input->post('orderinfo', true);
  2275. $waybill = $this->input->post('waybill', true);
  2276. $category = $this->input->post('category', true);
  2277. $size = $this->input->post('size', true);
  2278. $grade = $this->input->post('grade', true);
  2279. $color = $this->input->post('color', true);
  2280. $lowe = $this->input->post('lowe', true);
  2281. $where = "state=1";
  2282. if ($sku) {
  2283. $where .= " and sku = '$sku'";
  2284. }
  2285. if ($warehouse) {
  2286. $where .= " and warehouse = '$warehouse'";
  2287. }
  2288. if ($purchase) {
  2289. $where .= " and purchase = '$purchase'";
  2290. }
  2291. if ($orderinfo) {
  2292. $where .= " and orderinfo = '$orderinfo'";
  2293. }
  2294. if ($waybill) {
  2295. $where .= " and waybill = '$waybill'";
  2296. }
  2297. if ($category) {
  2298. $where .= " and features like '%-$category-%'";
  2299. }
  2300. if ($size) {
  2301. $where .= " and features like '%-$size-%'";
  2302. }
  2303. if ($grade) {
  2304. $where .= " and features like '%-$grade-%'";
  2305. }
  2306. if ($color) {
  2307. $where .= " and features like '%-$color-%'";
  2308. }
  2309. if ($lowe) {
  2310. $where .= " and features like '%-$lowe-%'";
  2311. }
  2312. //数据排序
  2313. $order_str = "outk desc";
  2314. if (empty($page)) {
  2315. $start = 0;
  2316. $perpage = 1;
  2317. } else {
  2318. $start = ($page - 1) * $perpage;
  2319. }
  2320. //取得信息列表
  2321. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2322. foreach ($info_list as $key => $value) {
  2323. $warehouse = $this->warehouse->read($value['warehouse']);
  2324. $info_list[$key]['warehouse'] = $warehouse['title'];
  2325. $purchase = $this->purchase->read($value['purchase']);
  2326. $info_list[$key]['purchase'] = $purchase['title'];
  2327. if ($value['outk'] != 0) {
  2328. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2329. } else {
  2330. $info_list[$key]['outk'] = "";
  2331. }
  2332. if ($value['orderinfo'] == 0) {
  2333. $info_list[$key]['orderinfo'] = "";
  2334. }
  2335. if ($value['waybill'] == 0) {
  2336. $info_list[$key]['waybill'] = "";
  2337. }
  2338. }
  2339. $total = $this->whlabel->find_count($where);
  2340. $pagenum = ceil($total / $perpage);
  2341. $over = $total - ($start + $perpage);
  2342. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2343. echo json_encode($rows);
  2344. exit;
  2345. }
  2346. $this->_Template('whlabel_label', $this->data);
  2347. }
  2348. //独立站出库订单
  2349. public function _outorder()
  2350. {
  2351. if (isset($_SESSION['api'])) {
  2352. $user = $this->user->get_api($_SESSION['api']);
  2353. $usp = $user;
  2354. $fgshop = "";
  2355. $sid = "";
  2356. $user = explode('|', trim($user['shop'], '|'));
  2357. foreach ($user as $value) {
  2358. $fgshop .= " shop = " . $value . " or";
  2359. $sid .= " id = " . $value . " or";
  2360. }
  2361. } else {
  2362. echo "请重新登录";
  2363. }
  2364. $post = $this->input->post(NULL, TRUE);
  2365. if (isset($post['page'])) {
  2366. $page = $this->input->post('page', true);
  2367. $perpage = $this->input->post('perpage', true);
  2368. $warehouse = $this->input->post('warehouse', true);
  2369. $xztime = $this->input->post('xztime', true);
  2370. $timetk = $this->input->post('timetkk', true);
  2371. $timetj = $this->input->post('timetjj', true);
  2372. $shop = $this->input->post('shop', true);
  2373. $source = $this->input->post('source', true);
  2374. $orderinfo = $this->input->post('orderinfo', true);
  2375. $number = $this->input->post('number', true);
  2376. $sfxh = $this->input->post('sfxh', true);
  2377. $express = $this->input->post('express', true);
  2378. $waybill = $this->input->post('waybill', true);
  2379. $library = $this->input->post('library', true);
  2380. $country = $this->input->post('country', true);
  2381. $so = $this->input->post('so', true);
  2382. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2383. $print = $this->input->post('print', true);
  2384. $state = $this->input->post('state', true);
  2385. $orderurl = $this->input->post('orderurl', true);
  2386. $timetk = strtotime($timetk);
  2387. $timetj = strtotime($timetj);
  2388. /**
  2389. $sj = $this->input->post('sj',true);
  2390. if($sj)
  2391. {
  2392. $sj = $this->input->post('sj',true);
  2393. }
  2394. else
  2395. {
  2396. $sj = "fullorder";
  2397. }
  2398. **/
  2399. $sj = "fullorder";
  2400. $where = "1=1";
  2401. if ($warehouse) {
  2402. $where .= " and type = '$warehouse'";
  2403. }
  2404. if ($timetk && $timetj) {
  2405. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2406. }
  2407. if ($orderinfo) {
  2408. $where .= " and orderinfo = '$orderinfo'";
  2409. }
  2410. if ($number) {
  2411. $where .= " and number = '$number'";
  2412. }
  2413. if ($express) {
  2414. $where .= " and express = '$express'";
  2415. }
  2416. if ($waybill) {
  2417. $where .= " and waybill = '$waybill'";
  2418. }
  2419. if ($library) {
  2420. $where .= " and library = '$library'";
  2421. }
  2422. if ($print) {
  2423. $where .= " and print = '$print'";
  2424. }
  2425. if ($libraryconfirm) {
  2426. $where .= " and libraryconfirm = '$libraryconfirm'";
  2427. }
  2428. if ($state) {
  2429. $where .= " and state = '$state'";
  2430. }
  2431. if ($shop) {
  2432. $where .= " and shop = '$shop'";
  2433. }
  2434. if ($country) {
  2435. $where .= " and country = '$country'";
  2436. }
  2437. if ($sfxh != '') {
  2438. $where .= " and sfxh = '$sfxh'";
  2439. }
  2440. if ($so) {
  2441. $where .= " and shipremarks like '%$so%'";
  2442. }
  2443. if ($source) {
  2444. if ($source == '2d') {
  2445. $where .= " and source >= '2'";
  2446. } else {
  2447. $where .= " and source = '$source'";
  2448. }
  2449. }
  2450. if (isset($_SESSION['api'])) {
  2451. foreach ($user as $value) {
  2452. $fgshop .= " shop = " . $value . " or";
  2453. }
  2454. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2455. }
  2456. if ($orderurl) {
  2457. $url = $this->orderurl->read($orderurl);
  2458. $where .= " and link like '%" . $url['url'] . "%'";
  2459. }
  2460. //数据排序
  2461. $order_str = "librarytime desc";
  2462. if (empty($page)) {
  2463. $start = 0;
  2464. $perpage = 1;
  2465. } else {
  2466. $start = ($page - 1) * $perpage;
  2467. }
  2468. //取得信息列表
  2469. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2470. //格式化数据
  2471. foreach ($info_list as $key => $value) {
  2472. $shop = $this->shop->read($value['shop']);
  2473. $info_list[$key]['shop'] = $shop['shopname'];
  2474. $express = $this->express->read($value['express']);
  2475. $info_list[$key]['express'] = $express['servicename'];
  2476. $warehouse = $this->warehouse->read($value['type']);
  2477. $info_list[$key]['type'] = $warehouse['title'];
  2478. if ($value['librarytime'] == '0') {
  2479. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2480. } else {
  2481. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2482. }
  2483. }
  2484. $total = $this->$sj->find_count($where);
  2485. $pagenum = ceil($total / $perpage);
  2486. $over = $total - ($start + $perpage);
  2487. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2488. echo json_encode($rows);
  2489. exit;
  2490. }
  2491. $this->data['express'] = $this->express->find_all();
  2492. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2493. $this->data['wlshop'] = $wlshop;
  2494. $user = $this->user->get_api($_SESSION['api']);
  2495. $powerid = $this->power->read($user['power']);
  2496. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2497. $pid = '';
  2498. foreach ($powertext as $v) {
  2499. $pid .= " id = " . $v . " or";
  2500. }
  2501. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2502. $this->data['fullorderexcel'] = $fullorderexcel;
  2503. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2504. $this->data['orderurl'] = $orderurl;
  2505. $this->_Template('whlabel_outorder', $this->data);
  2506. }
  2507. //tt出库
  2508. public function _toutorder()
  2509. {
  2510. if (isset($_SESSION['api'])) {
  2511. $user = $this->user->get_api($_SESSION['api']);
  2512. $usp = $user;
  2513. $fgshop = "";
  2514. $sid = "";
  2515. $user = explode('|', trim($user['shop'], '|'));
  2516. foreach ($user as $value) {
  2517. $fgshop .= " shop = " . $value . " or";
  2518. $sid .= " id = " . $value . " or";
  2519. }
  2520. } else {
  2521. echo "请重新登录";
  2522. }
  2523. $post = $this->input->post(NULL, TRUE);
  2524. if (isset($post['page'])) {
  2525. $page = $this->input->post('page', true);
  2526. $perpage = $this->input->post('perpage', true);
  2527. $warehouse = $this->input->post('warehouse', true);
  2528. $xztime = $this->input->post('xztime', true);
  2529. $timetk = $this->input->post('timetkk', true);
  2530. $timetj = $this->input->post('timetjj', true);
  2531. $shop = $this->input->post('shop', true);
  2532. $source = $this->input->post('source', true);
  2533. $orderinfo = $this->input->post('orderinfo', true);
  2534. $number = $this->input->post('number', true);
  2535. $sfxh = $this->input->post('sfxh', true);
  2536. $express = $this->input->post('express', true);
  2537. $waybill = $this->input->post('waybill', true);
  2538. $library = $this->input->post('library', true);
  2539. $country = $this->input->post('country', true);
  2540. $so = $this->input->post('so', true);
  2541. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2542. $print = $this->input->post('print', true);
  2543. $state = $this->input->post('state', true);
  2544. $orderurl = $this->input->post('orderurl', true);
  2545. $timetk = strtotime($timetk);
  2546. $timetj = strtotime($timetj);
  2547. /**
  2548. $sj = $this->input->post('sj',true);
  2549. if($sj)
  2550. {
  2551. $sj = $this->input->post('sj',true);
  2552. }
  2553. else
  2554. {
  2555. $sj = "fullorder";
  2556. }
  2557. **/
  2558. $sj = "fullordertt";
  2559. $where = "1=1";
  2560. if ($warehouse) {
  2561. $where .= " and type = '$warehouse'";
  2562. }
  2563. if ($timetk && $timetj) {
  2564. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2565. }
  2566. if ($orderinfo) {
  2567. $where .= " and orderinfo = '$orderinfo'";
  2568. }
  2569. if ($number) {
  2570. $where .= " and number = '$number'";
  2571. }
  2572. if ($express) {
  2573. $where .= " and express = '$express'";
  2574. }
  2575. if ($waybill) {
  2576. $where .= " and waybill = '$waybill'";
  2577. }
  2578. if ($library) {
  2579. $where .= " and library = '$library'";
  2580. }
  2581. if ($print) {
  2582. $where .= " and print = '$print'";
  2583. }
  2584. if ($libraryconfirm) {
  2585. $where .= " and libraryconfirm = '$libraryconfirm'";
  2586. }
  2587. if ($state) {
  2588. $where .= " and state = '$state'";
  2589. }
  2590. if ($shop) {
  2591. $where .= " and shop = '$shop'";
  2592. }
  2593. if ($country) {
  2594. $where .= " and country = '$country'";
  2595. }
  2596. if ($sfxh != '') {
  2597. $where .= " and sfxh = '$sfxh'";
  2598. }
  2599. if ($so) {
  2600. $where .= " and shipremarks like '%$so%'";
  2601. }
  2602. if ($source) {
  2603. if ($source == '2d') {
  2604. $where .= " and source >= '2'";
  2605. } else {
  2606. $where .= " and source = '$source'";
  2607. }
  2608. }
  2609. if (isset($_SESSION['api'])) {
  2610. foreach ($user as $value) {
  2611. $fgshop .= " shop = " . $value . " or";
  2612. }
  2613. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2614. }
  2615. if ($orderurl) {
  2616. $url = $this->orderurl->read($orderurl);
  2617. $where .= " and link like '%" . $url['url'] . "%'";
  2618. }
  2619. //数据排序
  2620. $order_str = "librarytime desc";
  2621. if (empty($page)) {
  2622. $start = 0;
  2623. $perpage = 1;
  2624. } else {
  2625. $start = ($page - 1) * $perpage;
  2626. }
  2627. //取得信息列表
  2628. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2629. //格式化数据
  2630. foreach ($info_list as $key => $value) {
  2631. $shop = $this->shop->read($value['shop']);
  2632. $info_list[$key]['shop'] = $shop['shopname'];
  2633. $express = $this->express->read($value['express']);
  2634. $info_list[$key]['express'] = $express['servicename'];
  2635. $warehouse = $this->warehouse->read($value['type']);
  2636. $info_list[$key]['type'] = $warehouse['title'];
  2637. if ($value['librarytime'] == '0') {
  2638. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2639. } else {
  2640. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2641. }
  2642. }
  2643. $total = $this->$sj->find_count($where);
  2644. $pagenum = ceil($total / $perpage);
  2645. $over = $total - ($start + $perpage);
  2646. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2647. echo json_encode($rows);
  2648. exit;
  2649. }
  2650. $this->data['express'] = $this->express->find_all();
  2651. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2652. $this->data['wlshop'] = $wlshop;
  2653. $user = $this->user->get_api($_SESSION['api']);
  2654. $powerid = $this->power->read($user['power']);
  2655. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2656. $pid = '';
  2657. foreach ($powertext as $v) {
  2658. $pid .= " id = " . $v . " or";
  2659. }
  2660. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2661. $this->data['fullorderexcel'] = $fullorderexcel;
  2662. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2663. $this->data['orderurl'] = $orderurl;
  2664. $this->_Template('whlabel_toutorder', $this->data);
  2665. }
  2666. //tt出库
  2667. public function _aoutorder()
  2668. {
  2669. if (isset($_SESSION['api'])) {
  2670. $user = $this->user->get_api($_SESSION['api']);
  2671. $usp = $user;
  2672. $fgshop = "";
  2673. $sid = "";
  2674. $user = explode('|', trim($user['shop'], '|'));
  2675. foreach ($user as $value) {
  2676. $fgshop .= " shop = " . $value . " or";
  2677. $sid .= " id = " . $value . " or";
  2678. }
  2679. } else {
  2680. echo "请重新登录";
  2681. }
  2682. $post = $this->input->post(NULL, TRUE);
  2683. if (isset($post['page'])) {
  2684. $page = $this->input->post('page', true);
  2685. $perpage = $this->input->post('perpage', true);
  2686. $warehouse = $this->input->post('warehouse', true);
  2687. $xztime = $this->input->post('xztime', true);
  2688. $timetk = $this->input->post('timetkk', true);
  2689. $timetj = $this->input->post('timetjj', true);
  2690. $shop = $this->input->post('shop', true);
  2691. $source = $this->input->post('source', true);
  2692. $orderinfo = $this->input->post('orderinfo', true);
  2693. $number = $this->input->post('number', true);
  2694. $sfxh = $this->input->post('sfxh', true);
  2695. $express = $this->input->post('express', true);
  2696. $waybill = $this->input->post('waybill', true);
  2697. $library = $this->input->post('library', true);
  2698. $country = $this->input->post('country', true);
  2699. $so = $this->input->post('so', true);
  2700. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2701. $print = $this->input->post('print', true);
  2702. $state = $this->input->post('state', true);
  2703. $orderurl = $this->input->post('orderurl', true);
  2704. $timetk = strtotime($timetk);
  2705. $timetj = strtotime($timetj);
  2706. /**
  2707. $sj = $this->input->post('sj',true);
  2708. if($sj)
  2709. {
  2710. $sj = $this->input->post('sj',true);
  2711. }
  2712. else
  2713. {
  2714. $sj = "fullorder";
  2715. }
  2716. **/
  2717. $sj = "fullorderamz";
  2718. $where = "1=1";
  2719. if ($warehouse) {
  2720. $where .= " and type = '$warehouse'";
  2721. }
  2722. if ($timetk && $timetj) {
  2723. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2724. }
  2725. if ($orderinfo) {
  2726. $where .= " and orderinfo = '$orderinfo'";
  2727. }
  2728. if ($number) {
  2729. $where .= " and number = '$number'";
  2730. }
  2731. if ($express) {
  2732. $where .= " and express = '$express'";
  2733. }
  2734. if ($waybill) {
  2735. $where .= " and waybill = '$waybill'";
  2736. }
  2737. if ($library) {
  2738. $where .= " and library = '$library'";
  2739. }
  2740. if ($print) {
  2741. $where .= " and print = '$print'";
  2742. }
  2743. if ($libraryconfirm) {
  2744. $where .= " and libraryconfirm = '$libraryconfirm'";
  2745. }
  2746. if ($state) {
  2747. $where .= " and state = '$state'";
  2748. }
  2749. if ($shop) {
  2750. $where .= " and shop = '$shop'";
  2751. }
  2752. if ($country) {
  2753. $where .= " and country = '$country'";
  2754. }
  2755. if ($sfxh != '') {
  2756. $where .= " and sfxh = '$sfxh'";
  2757. }
  2758. if ($so) {
  2759. $where .= " and shipremarks like '%$so%'";
  2760. }
  2761. if ($source) {
  2762. if ($source == '2d') {
  2763. $where .= " and source >= '2'";
  2764. } else {
  2765. $where .= " and source = '$source'";
  2766. }
  2767. }
  2768. if (isset($_SESSION['api'])) {
  2769. foreach ($user as $value) {
  2770. $fgshop .= " shop = " . $value . " or";
  2771. }
  2772. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2773. }
  2774. if ($orderurl) {
  2775. $url = $this->orderurl->read($orderurl);
  2776. $where .= " and link like '%" . $url['url'] . "%'";
  2777. }
  2778. //数据排序
  2779. $order_str = "librarytime desc";
  2780. if (empty($page)) {
  2781. $start = 0;
  2782. $perpage = 1;
  2783. } else {
  2784. $start = ($page - 1) * $perpage;
  2785. }
  2786. //取得信息列表
  2787. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2788. //格式化数据
  2789. foreach ($info_list as $key => $value) {
  2790. $shop = $this->shop->read($value['shop']);
  2791. $info_list[$key]['shop'] = $shop['shopname'];
  2792. $express = $this->express->read($value['express']);
  2793. $info_list[$key]['express'] = $express['servicename'];
  2794. $warehouse = $this->warehouse->read($value['type']);
  2795. $info_list[$key]['type'] = $warehouse['title'];
  2796. if ($value['librarytime'] == '0') {
  2797. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2798. } else {
  2799. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2800. }
  2801. }
  2802. $total = $this->$sj->find_count($where);
  2803. $pagenum = ceil($total / $perpage);
  2804. $over = $total - ($start + $perpage);
  2805. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2806. echo json_encode($rows);
  2807. exit;
  2808. }
  2809. $this->data['express'] = $this->express->find_all();
  2810. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2811. $this->data['wlshop'] = $wlshop;
  2812. $user = $this->user->get_api($_SESSION['api']);
  2813. $powerid = $this->power->read($user['power']);
  2814. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2815. $pid = '';
  2816. foreach ($powertext as $v) {
  2817. $pid .= " id = " . $v . " or";
  2818. }
  2819. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2820. $this->data['fullorderexcel'] = $fullorderexcel;
  2821. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2822. $this->data['orderurl'] = $orderurl;
  2823. $this->_Template('whlabel_aoutorder', $this->data);
  2824. }
  2825. //速卖通出库订单
  2826. public function _soutorder()
  2827. {
  2828. if (isset($_SESSION['api'])) {
  2829. $user = $this->user->get_api($_SESSION['api']);
  2830. $usp = $user;
  2831. $fgshop = "";
  2832. $sid = "";
  2833. $user = explode('|', trim($user['shop'], '|'));
  2834. foreach ($user as $value) {
  2835. $sid .= " id = " . $value . " or";
  2836. }
  2837. }
  2838. $post = $this->input->post(NULL, TRUE);
  2839. if (isset($post['page'])) {
  2840. $page = $this->input->post('page', true);
  2841. $perpage = $this->input->post('perpage', true);
  2842. $warehouse = $this->input->post('warehouse', true);
  2843. $xztime = $this->input->post('xztime', true);
  2844. $timetk = $this->input->post('timetkk', true);
  2845. $timetj = $this->input->post('timetjj', true);
  2846. $shop = $this->input->post('shop', true);
  2847. $source = $this->input->post('source', true);
  2848. $orderinfo = $this->input->post('orderinfo', true);
  2849. $number = $this->input->post('number', true);
  2850. $express = $this->input->post('express', true);
  2851. $waybill = $this->input->post('waybill', true);
  2852. $library = $this->input->post('library', true);
  2853. $country = $this->input->post('country', true);
  2854. $sfxh = $this->input->post('sfxh', true);
  2855. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2856. $print = $this->input->post('print', true);
  2857. $state = $this->input->post('state', true);
  2858. $so = $this->input->post('so', true);
  2859. $timetk = strtotime($timetk);
  2860. $timetj = strtotime($timetj);
  2861. /**
  2862. $sj = $this->input->post('sj',true);
  2863. if($sj)
  2864. {
  2865. $sj = $this->input->post('sj',true);
  2866. }
  2867. else
  2868. {
  2869. $sj = "fullorder";
  2870. }
  2871. **/
  2872. $sj = "fullordersmt";
  2873. $where = "1=1";
  2874. if ($warehouse) {
  2875. $where .= " and type = '$warehouse'";
  2876. }
  2877. if ($timetk && $timetj) {
  2878. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2879. }
  2880. if ($orderinfo) {
  2881. $where .= " and orderinfo = '$orderinfo'";
  2882. }
  2883. if ($number) {
  2884. $where .= " and number = '$number'";
  2885. }
  2886. if ($express) {
  2887. $where .= " and express = '$express'";
  2888. }
  2889. if ($waybill) {
  2890. $where .= " and waybill = '$waybill'";
  2891. }
  2892. if ($library) {
  2893. $where .= " and library = '$library'";
  2894. }
  2895. if ($print) {
  2896. $where .= " and print = '$print'";
  2897. }
  2898. if ($libraryconfirm) {
  2899. $where .= " and libraryconfirm = '$libraryconfirm'";
  2900. }
  2901. if ($state) {
  2902. $where .= " and state = '$state'";
  2903. }
  2904. if ($shop) {
  2905. $where .= " and shop = '$shop'";
  2906. }
  2907. if ($sfxh != '') {
  2908. $where .= " and sfxh = '$sfxh'";
  2909. }
  2910. if ($so) {
  2911. $where .= " and shipremarks like '%$so%'";
  2912. }
  2913. if ($source) {
  2914. $where .= " and source = '$source'";
  2915. }
  2916. if ($country) {
  2917. $where .= " and country = '$country'";
  2918. } else {
  2919. if (isset($_SESSION['api'])) {
  2920. foreach ($user as $value) {
  2921. $fgshop .= " shop = " . $value . " or";
  2922. }
  2923. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2924. }
  2925. }
  2926. //数据排序
  2927. $order_str = "librarytime desc";
  2928. if (empty($page)) {
  2929. $start = 0;
  2930. $perpage = 1;
  2931. } else {
  2932. $start = ($page - 1) * $perpage;
  2933. }
  2934. //取得信息列表
  2935. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2936. //格式化数据
  2937. foreach ($info_list as $key => $value) {
  2938. $shop = $this->shop->read($value['shop']);
  2939. $info_list[$key]['shop'] = $shop['shopname'];
  2940. $express = $this->express->read($value['express']);
  2941. $info_list[$key]['express'] = $express['servicename'];
  2942. $warehouse = $this->warehouse->read($value['type']);
  2943. $info_list[$key]['type'] = $warehouse['title'];
  2944. if ($value['librarytime'] == '0') {
  2945. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2946. } else {
  2947. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2948. }
  2949. }
  2950. $total = $this->$sj->find_count($where);
  2951. $pagenum = ceil($total / $perpage);
  2952. $over = $total - ($start + $perpage);
  2953. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2954. echo json_encode($rows);
  2955. exit;
  2956. }
  2957. $this->data['express'] = $this->express->find_all();
  2958. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2959. $this->data['wlshop'] = $wlshop;
  2960. $user = $this->user->get_api($_SESSION['api']);
  2961. $powerid = $this->power->read($user['power']);
  2962. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2963. $pid = '';
  2964. foreach ($powertext as $v) {
  2965. $pid .= " id = " . $v . " or";
  2966. }
  2967. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2968. $this->data['fullorderexcel'] = $fullorderexcel;
  2969. $this->_Template('whlabel_soutorder', $this->data);
  2970. }
  2971. //订单退库
  2972. public function _retreat()
  2973. {
  2974. $post = $this->input->post(NULL, TRUE);
  2975. if (isset($post['page'])) {
  2976. $page = $this->input->post('page', true);
  2977. $perpage = $this->input->post('perpage', true);
  2978. $warehouse = $this->input->post('warehouse', true);
  2979. $timetk = $this->input->post('timetk', true);
  2980. $timetj = $this->input->post('timetj', true);
  2981. $shop = $this->input->post('shop', true);
  2982. $source = $this->input->post('source', true);
  2983. $state = $this->input->post('state', true);
  2984. $review = $this->input->post('review', true);
  2985. $state = $this->input->post('state', true);
  2986. $express = $this->input->post('express', true);
  2987. $orderinfo = $this->input->post('orderinfo', true);
  2988. $user = $this->input->post('user', true);
  2989. $name = $this->input->post('name', true);
  2990. $waybill = $this->input->post('waybill', true);
  2991. $timetk = strtotime($timetk);
  2992. $timetj = strtotime($timetj);
  2993. $where = "(state=206 or state=210) and mergeid = 0";
  2994. if ($warehouse) {
  2995. $where .= " and state = '$warehouse'";
  2996. }
  2997. if ($timetk && $timetj) {
  2998. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  2999. }
  3000. if ($shop) {
  3001. $where .= " and shop = '$shop'";
  3002. }
  3003. if ($source) {
  3004. $where .= " and source = '$source'";
  3005. }
  3006. if ($state) {
  3007. $where .= " and state = '$state'";
  3008. }
  3009. if ($review) {
  3010. $where .= " and review = '$review'";
  3011. }
  3012. if ($state) {
  3013. $where .= " and state = '$state'";
  3014. }
  3015. if ($express) {
  3016. $where .= " and express = '$express'";
  3017. }
  3018. if ($orderinfo) {
  3019. $where .= " and orderinfo = '$orderinfo'";
  3020. }
  3021. if ($user) {
  3022. $where .= " and user = '$user'";
  3023. }
  3024. if ($name) {
  3025. $where .= " and name = '$name'";
  3026. }
  3027. if ($waybill) {
  3028. $where .= " and waybill = '$waybill'";
  3029. }
  3030. //数据排序
  3031. $order_str = "id desc";
  3032. if (empty($page)) {
  3033. $start = 0;
  3034. $perpage = 1;
  3035. } else {
  3036. $start = ($page - 1) * $perpage;
  3037. }
  3038. //取得信息列表
  3039. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3040. //格式化数据
  3041. foreach ($info_list as $key => $value) {
  3042. $shop = $this->shop->read($value['shop']);
  3043. $info_list[$key]['shop'] = $shop['shopname'];
  3044. $warehouse = $this->warehouse->read($value['warehouse']);
  3045. $info_list[$key]['warehouse'] = $warehouse['title'];
  3046. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3047. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3048. if ($value['waybill'] == 0) {
  3049. $info_list[$key]['waybill'] = "";
  3050. }
  3051. $express = $this->express->read($value['express']);
  3052. $info_list[$key]['express'] = $express['title'];
  3053. $typeclass = $this->typeclass->read($value['state']);
  3054. $info_list[$key]['state'] = $typeclass['title'];
  3055. }
  3056. $total = $this->fullorder->find_count($where);
  3057. $pagenum = ceil($total / $perpage);
  3058. $over = $total - ($start + $perpage);
  3059. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3060. echo json_encode($rows);
  3061. exit;
  3062. }
  3063. $this->data['express'] = $this->express->find_all();
  3064. $this->_Template('whlabel_retreat', $this->data);
  3065. }
  3066. //退库标签浏览
  3067. public function _retreatlk()
  3068. {
  3069. $post = $this->input->post(NULL, TRUE);
  3070. if (isset($post['page'])) {
  3071. $page = $this->input->post('page', true);
  3072. $perpage = $this->input->post('perpage', true);
  3073. $timetk = $this->input->post('timetk', true);
  3074. $timetj = $this->input->post('timetj', true);
  3075. $sku = $this->input->post('sku', true);
  3076. $warehouse = $this->input->post('warehouse', true);
  3077. $purchase = $this->input->post('purchase', true);
  3078. $orderinfo = $this->input->post('orderinfo', true);
  3079. $waybill = $this->input->post('waybill', true);
  3080. $category = $this->input->post('category', true);
  3081. $size = $this->input->post('size', true);
  3082. $grade = $this->input->post('grade', true);
  3083. $color = $this->input->post('color', true);
  3084. $lowe = $this->input->post('lowe', true);
  3085. $state = $this->input->post('state', true);
  3086. $timetk = strtotime($timetk);
  3087. $timetj = strtotime($timetj);
  3088. $where = "state=2";
  3089. if ($timetk && $timetj) {
  3090. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3091. }
  3092. if ($sku) {
  3093. $where .= " and sku = '$sku'";
  3094. }
  3095. if ($warehouse) {
  3096. $where .= " and warehouse = '$warehouse'";
  3097. }
  3098. if ($purchase) {
  3099. $where .= " and purchase = '$purchase'";
  3100. }
  3101. if ($orderinfo) {
  3102. $where .= " and orderinfo = '$orderinfo'";
  3103. }
  3104. if ($waybill) {
  3105. $where .= " and waybill = '$waybill'";
  3106. }
  3107. if ($category) {
  3108. $where .= " and features like '%-$category-%'";
  3109. }
  3110. if ($size) {
  3111. $where .= " and features like '%-$size-%'";
  3112. }
  3113. if ($grade) {
  3114. $where .= " and features like '%-$grade-%'";
  3115. }
  3116. if ($color) {
  3117. $where .= " and features like '%-$color-%'";
  3118. }
  3119. if ($lowe) {
  3120. $where .= " and features like '%-$lowe-%'";
  3121. }
  3122. //数据排序
  3123. $order_str = "time desc";
  3124. if (empty($page)) {
  3125. $start = 0;
  3126. $perpage = 1;
  3127. } else {
  3128. $start = ($page - 1) * $perpage;
  3129. }
  3130. //取得信息列表
  3131. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3132. foreach ($info_list as $key => $value) {
  3133. $warehouse = $this->warehouse->read($value['warehouse']);
  3134. $info_list[$key]['warehouse'] = $warehouse['title'];
  3135. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3136. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3137. $purchase = $this->purchase->read($value['purchase']);
  3138. $info_list[$key]['purchase'] = $purchase['title'];
  3139. if ($value['outk'] != 0) {
  3140. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3141. } else {
  3142. $info_list[$key]['outk'] = "";
  3143. }
  3144. if ($value['retreat'] != 0) {
  3145. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3146. } else {
  3147. $info_list[$key]['retreat'] = "";
  3148. }
  3149. if ($value['orderinfo'] == 0) {
  3150. $info_list[$key]['orderinfo'] = "";
  3151. }
  3152. if ($value['waybill'] == 0) {
  3153. $info_list[$key]['waybill'] = "";
  3154. }
  3155. }
  3156. $total = $this->whlabel->find_count($where);
  3157. $pagenum = ceil($total / $perpage);
  3158. $over = $total - ($start + $perpage);
  3159. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3160. echo json_encode($rows);
  3161. exit;
  3162. }
  3163. $this->_Template('whlabel_retreatlk', $this->data);
  3164. }
  3165. //更换标签及浏览
  3166. public function _change()
  3167. {
  3168. $post = $this->input->post(NULL, TRUE);
  3169. if (isset($post['page'])) {
  3170. $page = $this->input->post('page', true);
  3171. $perpage = $this->input->post('perpage', true);
  3172. $timetk = $this->input->post('timetk', true);
  3173. $timetj = $this->input->post('timetj', true);
  3174. $label = $this->input->post('label', true);
  3175. $oldlabel = $this->input->post('oldlabel', true);
  3176. $timetk = strtotime($timetk);
  3177. $timetj = strtotime($timetj);
  3178. $where = "state=10 ";
  3179. if ($timetk && $timetj) {
  3180. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3181. }
  3182. if ($label) {
  3183. $where .= " and label = '$label'";
  3184. }
  3185. if ($oldlabel) {
  3186. $where .= " and oldlabel = '$oldlabel'";
  3187. }
  3188. //数据排序
  3189. $order_str = "time asc";
  3190. if (empty($page)) {
  3191. $start = 0;
  3192. $perpage = 1;
  3193. } else {
  3194. $start = ($page - 1) * $perpage;
  3195. }
  3196. //取得信息列表
  3197. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3198. foreach ($info_list as $key => $value) {
  3199. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3200. }
  3201. $total = $this->whlabel->find_count($where);
  3202. $pagenum = ceil($total / $perpage);
  3203. $over = $total - ($start + $perpage);
  3204. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3205. echo json_encode($rows);
  3206. exit;
  3207. }
  3208. $this->_Template('whlabel_change', $this->data);
  3209. }
  3210. //产品标签
  3211. public function _cpbqdc()
  3212. {
  3213. if (isset($_GET['excel'])) {
  3214. $where = "1=1";
  3215. //数据排序
  3216. $order_str = "id desc";
  3217. if (empty($page)) {
  3218. $start = 0;
  3219. $perpage = 1;
  3220. } else {
  3221. $start = ($page - 1) * $perpage;
  3222. }
  3223. $warehouse = $this->input->get('warehouse', true);
  3224. $state = $this->input->get('state', true);
  3225. $timetk = $this->input->get('timetkk', true);
  3226. $timetj = $this->input->get('timetjj', true);
  3227. $timetk = strtotime($timetk);
  3228. $timetj = strtotime($timetj);
  3229. if ($warehouse) {
  3230. $where .= " and warehouse = '$warehouse'";
  3231. }
  3232. if ($state || $state == 0) {
  3233. $where .= " and state = '$state'";
  3234. }
  3235. if ($timetk && $timetj) {
  3236. $where .= " and time > '$timetk' and time < '$timetj'";
  3237. }
  3238. //取得信息列表
  3239. $info_list = $this->whlabel->find_all($where, '*');
  3240. $rows = array();
  3241. $list = array();
  3242. foreach ($info_list as $key => $value) {
  3243. $rows[$value['time']] = $value; //所有数据sku
  3244. }
  3245. foreach ($rows as $value) {
  3246. $warehouse = $this->warehouse->read($value['warehouse']);
  3247. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3248. $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);
  3249. }
  3250. $title = "产品标签统计表";
  3251. $titlename = "<table border=1>
  3252. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3253. <tr align='center'>
  3254. <td>仓库</td>
  3255. <td>SKU</td>
  3256. <td>产品</td>
  3257. <td>入库时间</td>
  3258. <td>操作时间</td>
  3259. <td>备注</td>
  3260. <td>数量</td>
  3261. </tr>
  3262. </table>";
  3263. $filename = $title . ".xls";
  3264. $tail = "";
  3265. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3266. }
  3267. }
  3268. //进销存导出
  3269. public function _exceljxc()
  3270. {
  3271. $classid = $this->classid->sku();
  3272. $pm = $classid;
  3273. $typeclass = array();
  3274. $tc = $this->typeclass->find_all();
  3275. foreach ($tc as $v) {
  3276. $typeclass[$v['id']] = $v;
  3277. }
  3278. $prc = array();
  3279. $purchase = $this->purchase->find_all();
  3280. foreach ($purchase as $k => $v) {
  3281. $prc[$v['id']] = $v['title'];
  3282. }
  3283. if (isset($_GET['excel'])) {
  3284. $where = "sku != 'Preset'";
  3285. //数据排序
  3286. $order_str = "id desc";
  3287. if (empty($page)) {
  3288. $start = 0;
  3289. $perpage = 1;
  3290. } else {
  3291. $start = ($page - 1) * $perpage;
  3292. }
  3293. $category = $this->input->get('category', true);
  3294. $warehouse = $this->input->get('warehouse', true);
  3295. $excelid = $this->input->get('sid', true);
  3296. if ($category) {
  3297. $where .= " and features like '%-$category-%'";
  3298. }
  3299. if ($warehouse) {
  3300. $where .= " and warehouse = '$warehouse'";
  3301. }
  3302. $xzid = '';
  3303. if ($excelid) {
  3304. $excelid = explode(',', trim($excelid, ','));
  3305. foreach ($excelid as $key => $value) {
  3306. $xzid .= " id = " . $value . " or";
  3307. }
  3308. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3309. }
  3310. //取得信息列表
  3311. /**
  3312. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3313. $rows = array();$list = array();
  3314. foreach ($info_list as $key=>$value)
  3315. {
  3316. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3317. }
  3318. **/
  3319. $wt = array();
  3320. $whlabel_type = $this->whlabel_type->find_all();
  3321. foreach ($whlabel_type as $v) {
  3322. $wt[$v['id']] = $v['title'];
  3323. }
  3324. $wh = array();
  3325. $w = $this->warehouse->find_all('1=1', 'id,title');
  3326. foreach ($w as $v) {
  3327. $wh[$v['id']] = $v['title'];
  3328. }
  3329. $list = array();
  3330. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3331. foreach ($rows as $key => $value) {
  3332. if (isset($wt[$value['type']])) {
  3333. $rows[$key]['type'] = $wt[$value['type']];
  3334. } else {
  3335. $rows[$key]['type'] = '未设置';
  3336. }
  3337. $bm = '03';
  3338. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3339. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3340. $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');
  3341. $details = array();
  3342. $cpid = array();
  3343. $cpbz = array();
  3344. $c = 0;
  3345. $g = 0;
  3346. $x = 0;
  3347. $t = 0;
  3348. $s = 0;
  3349. $q = 0;
  3350. foreach ($sd as $k => $v) {
  3351. if ($v['state'] == 0) {
  3352. $c++;
  3353. if ($v['cpid'] != 0) {
  3354. $cpid[$v['cpid']] = $v['cpid'];
  3355. }
  3356. if ($v['cpbz'] != '') {
  3357. $cpbz[$v['cpbz']] = $v['cpbz'];
  3358. }
  3359. }
  3360. if ($v['state'] != 9) {
  3361. $g++;
  3362. }
  3363. if ($v['state'] == 1) {
  3364. $x++;
  3365. }
  3366. if ($v['state'] == 2) {
  3367. $t++;
  3368. }
  3369. if ($v['state'] == 8) {
  3370. $s++;
  3371. }
  3372. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3373. $q++;
  3374. }
  3375. $details[$v['details']] = $v['details'];
  3376. }
  3377. $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'] . '"');
  3378. $rows[$key]['details'] = implode("、", $details);
  3379. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3380. $number = $value['number'];
  3381. $ftime = time() - 15 * 24 * 3600;
  3382. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3383. $rows[$key]['number'] = $g;
  3384. $rows[$key]['c'] = $c;
  3385. $rows[$key]['x'] = $x;
  3386. $rows[$key]['t'] = $t;
  3387. $rows[$key]['s'] = $s;
  3388. $rows[$key]['q'] = $q;
  3389. $rows[$key]['z'] = $z;
  3390. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3391. $features = explode('-', trim($features, '-'));
  3392. $rows[$key]['dbcontent'] = $typeclass[$features[0]]['title'];
  3393. // $pm = $classid;
  3394. // $jm = $classid;
  3395. // foreach($features as $k=>$v)
  3396. // {
  3397. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3398. // {
  3399. // if($typeclass[$v]['bm'] != '')
  3400. // {
  3401. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3402. // }
  3403. // }
  3404. // if($v != 0)
  3405. // {
  3406. // if(!isset($typeclass[$v]))
  3407. // {
  3408. // continue;
  3409. // }
  3410. // if(isset($pm[$typeclass[$v]['classid']]))
  3411. // {
  3412. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3413. // {
  3414. // $tz = explode('|',$typeclass[$v]['zh']);
  3415. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3416. // }
  3417. // else
  3418. // {
  3419. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3420. // }
  3421. // }
  3422. // if(isset($jm[$typeclass[$v]['classid']]))
  3423. // {
  3424. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3425. // }
  3426. // }
  3427. // }
  3428. // $jm = array_filter($jm);
  3429. // $rows[$key]['bs'] = implode("-",$jm);
  3430. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3431. // $zh = implode(" ",$pm);
  3432. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3433. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3434. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3435. // $rows[$key]['features'] = $zh;
  3436. }
  3437. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3438. $final_list = [];
  3439. foreach ($list as $k => $v) {
  3440. if (empty($v['sku'])) {
  3441. continue;
  3442. }
  3443. $final_list[] = [
  3444. "warehouse" => $v["warehouse"],
  3445. "purchase" => $v["purchase"],
  3446. "details" => $v["details"],
  3447. "cpid" => $v["cpid"],
  3448. "dbcontent" => $v["dbcontent"],
  3449. "sku" => $v["sku"],
  3450. "cs" => $v["bm"],
  3451. "bs" => $v["jm"],
  3452. "title" => $v["title"],
  3453. "features" => $v["pm"],
  3454. "cpbz" => $v["cpbz"],
  3455. "sm" => $v["sm"],
  3456. "type" => $v["type"],
  3457. "number" => $v["number"],
  3458. "c" => $v["c"],
  3459. "x" => $v["x"],
  3460. "t" => $v["t"],
  3461. "s" => $v["s"],
  3462. "q" => $v["q"],
  3463. "z" => $v["z"],
  3464. "weight" => $v['weight'],
  3465. ];
  3466. }
  3467. $title = "总进销存统计表";
  3468. $titlename = "<table border=1>
  3469. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3470. <tr align='center'>
  3471. <td>仓库</td>
  3472. <td>供应商</td>
  3473. <td>位置</td>
  3474. <td>库存编码</td>
  3475. <td>类目</td>
  3476. <td>SKU</td>
  3477. <td>用友编码</td>
  3478. <td>用友料号</td>
  3479. <td>商品名称</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>重量(g)</td>
  3492. </tr>
  3493. </table>";
  3494. $filename = $title . ".xls";
  3495. $tail = "";
  3496. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  3497. }
  3498. }
  3499. //入库导出
  3500. public function _excelr()
  3501. {
  3502. if (isset($_GET['excel'])) {
  3503. $category = $this->input->get('category', true);
  3504. $size = $this->input->get('size', true);
  3505. $grade = $this->input->get('grade', true);
  3506. $color = $this->input->get('color', true);
  3507. $lowe = $this->input->get('lowe', true);
  3508. $sku = $this->input->get('sku', true);
  3509. $warehouse = $this->input->get('warehouse', true);
  3510. $purchase = $this->input->get('purchase', true);
  3511. $ktime = $this->input->get('ktime', true);
  3512. $jtime = $this->input->get('jtime', true);
  3513. $ktime = strtotime($ktime);
  3514. $jtime = strtotime($jtime);
  3515. $where = "1=1";
  3516. $gj = "";
  3517. $ck = "";
  3518. if ($category) {
  3519. $where .= " and features like '%-$category-%'";
  3520. }
  3521. if ($size) {
  3522. $where .= " and features like '%-$size-%'";
  3523. }
  3524. if ($grade) {
  3525. $where .= " and features like '%-$grade-%'";
  3526. }
  3527. if ($color) {
  3528. $where .= " and features like '%-$color-%'";
  3529. }
  3530. if ($lowe) {
  3531. $where .= " and features like '%-$lowe-%'";
  3532. }
  3533. if ($warehouse) {
  3534. $where .= " and warehouse = '$warehouse'";
  3535. }
  3536. if ($purchase) {
  3537. $where .= " and purchase = '$purchase'";
  3538. }
  3539. if ($sku) {
  3540. $where .= " and sku = '$sku'";
  3541. }
  3542. if ($ktime && $jtime) {
  3543. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  3544. }
  3545. //数据排序
  3546. $order_str = "id desc";
  3547. if (empty($page)) {
  3548. $start = 0;
  3549. $perpage = 1;
  3550. } else {
  3551. $start = ($page - 1) * $perpage;
  3552. }
  3553. $list = array();
  3554. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  3555. foreach ($rows as $value) {
  3556. $ck = $this->warehouse->read($value['warehouse']);
  3557. $warehouse = $ck['title'];
  3558. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  3559. $retreatwarehouse = $tkck['title'];
  3560. $gy = $this->purchase->read($value['purchase']);
  3561. $purchase = $gy['title'];
  3562. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  3563. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  3564. }
  3565. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  3566. $titlename = "<table border=1>
  3567. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  3568. <tr align='center'>
  3569. <td>仓库</td>
  3570. <td>SKU</td>
  3571. <td>产品</td>
  3572. <td>时间</td>
  3573. <td>数量</td>
  3574. </tr>
  3575. </table>";
  3576. $filename = $title . ".xls";
  3577. $tail = "";
  3578. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3579. }
  3580. }
  3581. //出库、退库导出
  3582. public function _excelct()
  3583. {
  3584. $classid = $this->classid->sku();
  3585. $pm = $classid;
  3586. $typeclass = array();
  3587. $tc = $this->typeclass->find_all();
  3588. foreach ($tc as $v) {
  3589. $typeclass[$v['id']] = $v;
  3590. }
  3591. $prc = array();
  3592. $purchase = $this->purchase->find_all();
  3593. foreach ($purchase as $k => $v) {
  3594. $prc[$v['id']] = $v['title'];
  3595. }
  3596. if (isset($_GET['excel'])) {
  3597. $wh = array();
  3598. $w = $this->warehouse->find_all('1=1', 'id,title');
  3599. foreach ($w as $v) {
  3600. $wh[$v['id']] = $v['title'];
  3601. }
  3602. $type = $this->input->get('excel', true);
  3603. $category = $this->input->get('category', true);
  3604. $size = $this->input->get('size', true);
  3605. $grade = $this->input->get('grade', true);
  3606. $color = $this->input->get('color', true);
  3607. $lowe = $this->input->get('lowe', true);
  3608. $sku = $this->input->get('sku', true);
  3609. $warehouse = $this->input->get('warehouse', true);
  3610. $lacetype = $this->input->get('lacetype', true);
  3611. $lacecolor = $this->input->get('lacecolor', true);
  3612. $density = $this->input->get('density', true);
  3613. $haircap = $this->input->get('haircap', true);
  3614. $purchase = $this->input->get('purchase', true);
  3615. $title = $this->input->get('title', true);
  3616. $state = $this->input->get('state', true);
  3617. $sid = $this->input->get('sid', true);
  3618. $ktime = $this->input->get('ktime', true);
  3619. $jtime = $this->input->get('jtime', true);
  3620. $ktime = strtotime($ktime);
  3621. $jtime = strtotime($jtime);
  3622. $where = "1=1";
  3623. $gj = "";
  3624. $ck = "";
  3625. if ($category) {
  3626. $where .= " and features like '%-$category-%'";
  3627. }
  3628. if ($size) {
  3629. $where .= " and features like '%-$size-%'";
  3630. }
  3631. if ($grade) {
  3632. $where .= " and features like '%-$grade-%'";
  3633. }
  3634. if ($color) {
  3635. $where .= " and features like '%-$color-%'";
  3636. }
  3637. if ($lowe) {
  3638. $where .= " and features like '%-$lowe-%'";
  3639. }
  3640. if ($warehouse) {
  3641. $where .= " and warehouse = '$warehouse'";
  3642. }
  3643. if ($purchase) {
  3644. $where .= " and purchase = '$purchase'";
  3645. }
  3646. if ($state) {
  3647. $where .= " and state = '$state'";
  3648. }
  3649. if ($lacetype) {
  3650. $where .= " and features like '%-$lacetype-%'";
  3651. }
  3652. if ($lacecolor) {
  3653. $where .= " and features like '%-$lacecolor-%'";
  3654. }
  3655. if ($density) {
  3656. $where .= " and features like '%-$density-%'";
  3657. }
  3658. if ($haircap) {
  3659. $where .= " and features like '%-$haircap-%'";
  3660. }
  3661. if ($title) {
  3662. $title = trim($title, ' ');
  3663. $title = trim($title, ' ');
  3664. $where .= " and title like '%$title%'";
  3665. }
  3666. if ($sku) {
  3667. $sku = trim($sku, ' ');
  3668. $sku = trim($sku, ' ');
  3669. $where .= " and sku like '%$sku%'";
  3670. }
  3671. if ($ktime && $jtime) {
  3672. if ($type == 1) {
  3673. $tl = '出库';
  3674. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  3675. } else if ($type == 2) {
  3676. $tl = '退库';
  3677. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  3678. } else if ($type == 3) {
  3679. $gj = " and enter > '$ktime' and enter < '$jtime'";
  3680. $ck = " and outk > '$ktime' and outk < '$jtime'";
  3681. } else if ($type == 4) {
  3682. $tl = '出库+零售';
  3683. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  3684. } else if ($type == 5) {
  3685. $tl = '零售';
  3686. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  3687. }
  3688. }
  3689. $sidwhere = '';
  3690. if ($sid) {
  3691. $sd = "";
  3692. $s = explode(',', trim($sid, ','));
  3693. foreach ($s as $value) {
  3694. $sd .= " id = " . $value . " or";
  3695. }
  3696. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  3697. }
  3698. //数据排序
  3699. $order_str = "time desc";
  3700. if (empty($page)) {
  3701. $start = 0;
  3702. $perpage = 1;
  3703. } else {
  3704. $start = ($page - 1) * $perpage;
  3705. }
  3706. //取得信息列表
  3707. if ($type != 3 && $type != 5) {
  3708. if ($type == 1 || $type == 4) {
  3709. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  3710. foreach ($info_list as $key => $value) {
  3711. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3712. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3713. $warehouse = $this->warehouse->read($value['warehouse']);
  3714. $info_list[$key]['warehouse'] = $warehouse['title'];
  3715. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3716. $features = explode('-', trim($features, '-'));
  3717. $pm = $classid;
  3718. foreach ($features as $k => $v) {
  3719. if ($v != 0) {
  3720. if (!isset($typeclass[$v])) {
  3721. continue;
  3722. }
  3723. if (isset($pm[$typeclass[$v]['classid']])) {
  3724. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3725. $tz = explode('|', $typeclass[$v]['zh']);
  3726. $pm[$typeclass[$v]['classid']] = $tz[0];
  3727. } else {
  3728. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3729. }
  3730. }
  3731. }
  3732. }
  3733. $zh = implode(" ", $pm);
  3734. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3735. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3736. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3737. $info_list[$key]['features'] = $zh;
  3738. }
  3739. } else {
  3740. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  3741. foreach ($info_list as $key => $value) {
  3742. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3743. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  3744. $warehouse = $this->warehouse->read($value['warehouse']);
  3745. $info_list[$key]['warehouse'] = $warehouse['title'];
  3746. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3747. $features = explode('-', trim($features, '-'));
  3748. $pm = $classid;
  3749. foreach ($features as $k => $v) {
  3750. if ($v != 0) {
  3751. if (!isset($typeclass[$v])) {
  3752. continue;
  3753. }
  3754. if (isset($pm[$typeclass[$v]['classid']])) {
  3755. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3756. $tz = explode('|', $typeclass[$v]['zh']);
  3757. $pm[$typeclass[$v]['classid']] = $tz[0];
  3758. } else {
  3759. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3760. }
  3761. }
  3762. }
  3763. }
  3764. $zh = implode(" ", $pm);
  3765. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3766. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3767. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3768. $info_list[$key]['features'] = $zh;
  3769. }
  3770. }
  3771. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3772. $titlename = "<table border=1>
  3773. <tr><th colspan='8' align='center'><h3>" . $title . "<h3></th></tr>
  3774. <tr align='center'>
  3775. <td>仓库</td>
  3776. <td>供应商</td>
  3777. <td>SKU</td>
  3778. <td>商品名称</td>
  3779. <td>商品中文</td>
  3780. <td>标签</td>
  3781. <td>订单号</td>
  3782. <td>运单号</td>
  3783. <td>" . $tl . "时间(中国时间)</td>
  3784. </tr>
  3785. </table>";
  3786. $filename = $title . ".xls";
  3787. $tail = "";
  3788. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3789. } else if ($type == 5) {
  3790. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  3791. foreach ($info_list as $key => $value) {
  3792. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3793. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  3794. $warehouse = $this->warehouse->read($value['warehouse']);
  3795. $info_list[$key]['warehouse'] = $warehouse['title'];
  3796. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3797. $features = explode('-', trim($features, '-'));
  3798. $pm = $classid;
  3799. foreach ($features as $k => $v) {
  3800. if ($v != 0) {
  3801. if (!isset($typeclass[$v])) {
  3802. continue;
  3803. }
  3804. if (isset($pm[$typeclass[$v]['classid']])) {
  3805. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3806. $tz = explode('|', $typeclass[$v]['zh']);
  3807. $pm[$typeclass[$v]['classid']] = $tz[0];
  3808. } else {
  3809. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3810. }
  3811. }
  3812. }
  3813. }
  3814. $zh = implode(" ", $pm);
  3815. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3816. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3817. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3818. $info_list[$key]['features'] = $zh;
  3819. }
  3820. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  3821. $titlename = "<table border=1>
  3822. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3823. <tr align='center'>
  3824. <td>仓库</td>
  3825. <td>供应商</td>
  3826. <td>SKU</td>
  3827. <td>商品名称</td>
  3828. <td>商品中文</td>
  3829. <td>标签</td>
  3830. <td>" . $tl . "时间(中国时间)</td>
  3831. </tr>
  3832. </table>";
  3833. $filename = $title . ".xls";
  3834. $tail = "";
  3835. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  3836. } else {
  3837. /**
  3838. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  3839. $rows = array();$list = array();
  3840. foreach ($info_list as $key=>$value)
  3841. {
  3842. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  3843. }
  3844. **/
  3845. $wh = array();
  3846. $w = $this->warehouse->find_all('1=1', 'id,title');
  3847. foreach ($w as $v) {
  3848. $wh[$v['id']] = $v['title'];
  3849. }
  3850. $wt = array();
  3851. $whlabel_type = $this->whlabel_type->find_all();
  3852. foreach ($whlabel_type as $v) {
  3853. $wt[$v['id']] = $v['title'];
  3854. }
  3855. $classid = $this->classid->sku();
  3856. $list = array();
  3857. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  3858. foreach ($rows as $key => $value) {
  3859. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3860. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3861. $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');
  3862. $details = array();
  3863. $cpid = array();
  3864. $cpbz = array();
  3865. $c = 0;
  3866. $g = 0;
  3867. $x = 0;
  3868. $t = 0;
  3869. $s = 0;
  3870. $q = 0;
  3871. foreach ($sd as $k => $v) {
  3872. if ($v['state'] == 0) {
  3873. $c++;
  3874. }
  3875. if ($v['state'] != 9) {
  3876. $g++;
  3877. }
  3878. if ($v['outk'] > 1) {
  3879. $x++;
  3880. }
  3881. if ($v['retreat'] > 0) {
  3882. $t++;
  3883. }
  3884. if ($v['state'] == 8) {
  3885. $s++;
  3886. }
  3887. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3888. $q++;
  3889. }
  3890. $details[$v['details']] = $v['details'];
  3891. if ($v['cpid'] != 0) {
  3892. $cpid[$v['cpid']] = $v['cpid'];
  3893. }
  3894. if ($v['cpbz'] != '') {
  3895. $cpbz[$v['cpbz']] = $v['cpbz'];
  3896. }
  3897. }
  3898. if (isset($wt[$value['type']])) {
  3899. $rows[$key]['type'] = $wt[$value['type']];
  3900. } else {
  3901. $rows[$key]['type'] = '未设置';
  3902. }
  3903. $rows[$key]['details'] = implode("、", $details);
  3904. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3905. $ftime = time() - 15 * 24 * 3600;
  3906. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  3907. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  3908. $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);
  3909. $rows[$key]['c'] = $c;
  3910. $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);
  3911. $rows[$key]['t'] = $t;
  3912. $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'] . '"');
  3913. $rows[$key]['z'] = $z;
  3914. // $jm = $classid;
  3915. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3916. $features = explode('-', trim($features, '-'));
  3917. // $pm = $classid;
  3918. // foreach ($features as $k => $v) {
  3919. // if ($v != 0) {
  3920. // if (!isset($typeclass[$v])) {
  3921. // continue;
  3922. // }
  3923. // if (isset($pm[$typeclass[$v]['classid']])) {
  3924. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  3925. // $tz = explode('|', $typeclass[$v]['zh']);
  3926. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3927. // } else {
  3928. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3929. // }
  3930. // if (isset($jm[$typeclass[$v]['classid']])) {
  3931. // if ($typeclass[$v]['jm']) {
  3932. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3933. // }
  3934. // }
  3935. // }
  3936. // }
  3937. // }
  3938. // $zh = implode(" ", $pm);
  3939. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  3940. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  3941. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  3942. // $rows[$key]['features'] = $zh;
  3943. // $jm = array_filter($jm); //去除空值
  3944. // $jm = implode("-", $jm);
  3945. // $rows[$key]['jm'] = $jm;
  3946. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  3947. }
  3948. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  3949. // echo "<pre>";
  3950. // print_r($tmp_list);
  3951. // die;
  3952. $final_list =[];
  3953. foreach($tmp_list as $k=>$v){
  3954. $final_list[] = [
  3955. "warehouse"=>$v['warehouse'],
  3956. "purchase"=>$v['purchase'],
  3957. "details"=>$v['details'],
  3958. "cpid"=>$v['cpid'],
  3959. "sku"=>$v['sku'],
  3960. "title"=>$v['title'],
  3961. "features"=>$v['pm'],
  3962. "cpbz"=>$v['cpbz'],
  3963. "sm"=>$v['sm'],
  3964. "type"=>$v['type'],
  3965. "g"=>$v["g"],
  3966. "c"=>$v["c"],
  3967. "x"=>$v["x"],
  3968. "t"=>$v["t"],
  3969. "z"=>$v["z"],
  3970. "jm"=>$v["jm"],
  3971. "weight"=>$v["weight"],
  3972. "asd"=>$v["asd"],
  3973. ];
  3974. }
  3975. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  3976. $titlename = "<table border=1>
  3977. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  3978. <tr align='center'>
  3979. <td>仓库</td>
  3980. <td>供应商</td>
  3981. <td>位置</td>
  3982. <td>库存编码</td>
  3983. <td>SKU</td>
  3984. <td>商品名称</td>
  3985. <td>商品中文</td>
  3986. <td>产品备注</td>
  3987. <td>说明</td>
  3988. <td>类型</td>
  3989. <td>入库总量</td>
  3990. <td>库存数量</td>
  3991. <td>销售数量</td>
  3992. <td>退货数量</td>
  3993. <td>占单数量</td>
  3994. <td>料号</td>
  3995. <td>重量</td>
  3996. <td>类目</td>
  3997. </tr>
  3998. </table>";
  3999. $filename = $title . ".xls";
  4000. $tail = "";
  4001. $this->excel->get_fz2($final_list, $titlename, $filename, $tail);
  4002. }
  4003. }
  4004. }
  4005. //出库+入库数据整合
  4006. public function _excelcr()
  4007. {
  4008. if (isset($_GET['excel'])) {
  4009. $type = $this->input->get('excel', true);
  4010. $category = $this->input->get('category', true);
  4011. $size = $this->input->get('size', true);
  4012. $grade = $this->input->get('grade', true);
  4013. $color = $this->input->get('color', true);
  4014. $lowe = $this->input->get('lowe', true);
  4015. $sku = $this->input->get('sku', true);
  4016. $warehouse = $this->input->get('warehouse', true);
  4017. $purchase = $this->input->get('purchase', true);
  4018. $state = $this->input->get('state', true);
  4019. $sid = $this->input->get('sid', true);
  4020. $ktime = $this->input->get('ktime', true);
  4021. $jtime = $this->input->get('jtime', true);
  4022. $ktime = strtotime($ktime);
  4023. $jtime = strtotime($jtime);
  4024. $where = "1=1";
  4025. $gj = "";
  4026. $ck = "";
  4027. if ($category) {
  4028. $where .= " and features like '%-$category-%'";
  4029. }
  4030. if ($size) {
  4031. $where .= " and features like '%-$size-%'";
  4032. }
  4033. if ($grade) {
  4034. $where .= " and features like '%-$grade-%'";
  4035. }
  4036. if ($color) {
  4037. $where .= " and features like '%-$color-%'";
  4038. }
  4039. if ($lowe) {
  4040. $where .= " and features like '%-$lowe-%'";
  4041. }
  4042. if ($warehouse) {
  4043. $where .= " and warehouse = '$warehouse'";
  4044. }
  4045. if ($purchase) {
  4046. $where .= " and purchase = '$purchase'";
  4047. }
  4048. if ($state) {
  4049. $where .= " and state = '$state'";
  4050. }
  4051. if ($sku) {
  4052. $where .= " and sku like '%$sku%'";
  4053. }
  4054. if ($ktime && $jtime) {
  4055. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4056. }
  4057. $sidwhere = '';
  4058. if ($sid) {
  4059. $sd = "";
  4060. $s = explode(',', trim($sid, ','));
  4061. foreach ($s as $value) {
  4062. $sd .= " id = " . $value . " or";
  4063. }
  4064. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4065. }
  4066. //取得信息列表
  4067. $timeread = $ktime;
  4068. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4069. $timelist = array();
  4070. for ($i = 0; $i < $timenum; $i++) {
  4071. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4072. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4073. }
  4074. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4075. //echo "<pre>";
  4076. //print_r($info_list);
  4077. //exit();
  4078. $rows = array();
  4079. $list = array();
  4080. foreach ($info_list as $key => $value) {
  4081. $thistime = $timelist;
  4082. if (isset($rows[strtolower($value['sku'])])) {
  4083. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4084. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4085. }
  4086. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4087. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4088. }
  4089. } else {
  4090. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4091. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4092. }
  4093. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4094. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4095. }
  4096. $rows[strtolower($value['sku'])] = $thistime;
  4097. }
  4098. }
  4099. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4100. <head>
  4101. <!--[if gte mso 9]><xml>
  4102. <x:ExcelWorkbook>
  4103. <x:ExcelWorksheets>
  4104. <x:ExcelWorksheet>
  4105. <x:Name>EXCEL</x:Name>
  4106. <x:WorksheetOptions>
  4107. <x:Print>
  4108. <x:ValidPrinterInfo />
  4109. </x:Print>
  4110. </x:WorksheetOptions>
  4111. </x:ExcelWorksheet>
  4112. </x:ExcelWorksheets>
  4113. </x:ExcelWorkbook>
  4114. </xml>
  4115. <![endif]-->
  4116. </head><body>";
  4117. $str .= "<table border=1><tr><td>SKU</td>";
  4118. foreach ($timelist as $k => $v) {
  4119. $str .= "<td>" . $k . "出库</td>";
  4120. $str .= "<td>" . $k . "入库</td>";
  4121. }
  4122. $str .= "</tr></table>";
  4123. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4124. foreach ($rows as $key => $val) {
  4125. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4126. foreach ($val as $k => $v) {
  4127. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4128. if ($val[$k]['r'] > 0) {
  4129. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4130. } else {
  4131. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4132. }
  4133. }
  4134. $str .= "</tr>";
  4135. }
  4136. $str .= "</table>";
  4137. $str .= "</body></html>";
  4138. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4139. header("Content-type: application/octet-stream");
  4140. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4141. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4142. header("Pragma: no-cache");
  4143. header("Expires: 0");
  4144. exit($str);
  4145. }
  4146. }
  4147. //数量调整模板导出
  4148. public function _presetout()
  4149. {
  4150. if (isset($_GET['excel'])) {
  4151. $where = "sku != 'Preset' and purchase != 0";
  4152. //数据排序
  4153. $order_str = "id desc";
  4154. if (empty($page)) {
  4155. $start = 0;
  4156. $perpage = 1;
  4157. } else {
  4158. $start = ($page - 1) * $perpage;
  4159. }
  4160. //取得信息列表
  4161. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4162. $rows = array();
  4163. $list = array();
  4164. foreach ($info_list as $value) {
  4165. $warehouse = $this->warehouse->read($value['warehouse']);
  4166. $number = $value['number'];
  4167. $ftime = time() - 15 * 24 * 3600;
  4168. $purchase = $this->purchase->read($value['purchase']);
  4169. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '0', '', '');
  4170. }
  4171. $title = "库存模板";
  4172. $titlename = "<table border=1>
  4173. <tr align='center'>
  4174. <td>仓库</td>
  4175. <td>供应商编码</td>
  4176. <td>SKU</td>
  4177. <td>增减数量(正数或负数)</td>
  4178. <td>增减备注</td>
  4179. <td>扣减方式:0减少库存1删除库存</td>
  4180. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4181. <td>扣减类型(扣减为必填,填数字):1.销售出库2.销售美国出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4182. </tr>
  4183. </table>";
  4184. $filename = $title . ".xls";
  4185. $tail = "";
  4186. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4187. }
  4188. }
  4189. //数量调整模板导入
  4190. public function _presetedit()
  4191. {
  4192. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4193. $config['upload_path'] = '.' . $dir;
  4194. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4195. $config['allowed_types'] = 'xls|xlsx|csv';
  4196. $config['max_size'] = 10240;
  4197. $this->load->library('upload', $config);
  4198. $this->upload->initialize($config);
  4199. if ($this->upload->do_upload('userfile')) {
  4200. $full_path = $dir . $this->upload->data('file_name');
  4201. $fileName = '.' . $full_path;
  4202. if (!file_exists($fileName)) {
  4203. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4204. exit;
  4205. } else {
  4206. require_once "./data/excel/PHPExcel/IOFactory.php";
  4207. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4208. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4209. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4210. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4211. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4212. ++$column; //如果列数大于26行
  4213. $list = array();
  4214. for ($i = 2; $i <= $row; $i++) // 行数循环
  4215. {
  4216. $data = array();
  4217. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4218. {
  4219. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4220. }
  4221. $list[] = $data;
  4222. }
  4223. }
  4224. $i = 0;
  4225. $j = 0;
  4226. $ed = array();
  4227. foreach ($list as $key => $value) {
  4228. $time = time();
  4229. if ($value['0'] == "") {
  4230. continue;
  4231. }
  4232. $warehouse = $this->warehouse->get_title($value['0']);
  4233. $purchase = $this->purchase->get_bm($value['1']);
  4234. $sku = $value['2'];
  4235. $num = $value['3']; //调整数量
  4236. $text = $value['4']; //扣减说明
  4237. $type = $value['5']; //调整方式0扣减1删除
  4238. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4239. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4240. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4241. if (!$purchase) //如果没有这个SKU
  4242. {
  4243. $ed[] = array($purchase . '-不存在此供应商编码');
  4244. $j++;
  4245. continue;
  4246. }
  4247. if (!$d) //如果没有这个SKU
  4248. {
  4249. $ed[] = array($sku . '-库存中不存在此SKU');
  4250. $j++;
  4251. continue;
  4252. }
  4253. if (!isset($warehouse['id'])) {
  4254. $ed[] = array($sku . '-仓库名错误!');
  4255. $j++;
  4256. continue;
  4257. }
  4258. if ($type != '0' && $type != '1') {
  4259. $ed[] = array($sku . '-扣减方式填写错误!');
  4260. $j++;
  4261. continue;
  4262. }
  4263. if ($num < 0) //扣减库存
  4264. {
  4265. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4266. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4267. $j++;
  4268. continue;
  4269. }
  4270. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4271. if (count($data) < abs($num)) {
  4272. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4273. $j++;
  4274. continue;
  4275. }
  4276. if ($type == 0) //如果扣减方式为 扣减库存
  4277. {
  4278. for ($i = 0; $i < abs($num); $i++) {
  4279. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4280. }
  4281. } else if ($type == 1) {
  4282. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4283. if (count($zt) > 0) {
  4284. $ed[] = array($sku . '-有在途库存无法删除!');
  4285. $j++;
  4286. continue;
  4287. }
  4288. for ($i = 0; $i < abs($num); $i++) {
  4289. $this->whlabel->remove($data[$i]['id']);
  4290. }
  4291. }
  4292. } else if ($num > 0) //增加库存
  4293. {
  4294. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4295. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4296. $j++;
  4297. continue;
  4298. }
  4299. $post['sku'] = $d['sku'];
  4300. $post['shop'] = $d['shop'];
  4301. $post['warehouse'] = $warehouse['id'];
  4302. $post['purchase'] = $purchase['id'];
  4303. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4304. $post['state'] = 0;
  4305. $post['title'] = $d['title'];
  4306. $post['number'] = $d['number'];
  4307. $post['features'] = $d['features'];
  4308. $post['enter'] = $time;
  4309. $post['time'] = $time; //操作时间
  4310. $post['rktype'] = $rktype;
  4311. for ($i = 0; $i < $num; $i++) {
  4312. $post['label'] = time() . rand(100, 999) . $i;
  4313. $this->whlabel->insert($post);
  4314. }
  4315. }
  4316. sleep(1); //防止入库时间一样,需要延迟1秒
  4317. }
  4318. if ($j > 0) {
  4319. $tt = date('Ymd', time());
  4320. $title = '库存导入错误信息-' . $tt;
  4321. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4322. $tail = "\n";
  4323. $filename = $title . ".xls";
  4324. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4325. $dir = '/data/excel/' . $time . '/';
  4326. $file_name = 'error_' . $time . rand(1000, 9999);
  4327. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4328. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4329. fwrite($myfile, $ecl);
  4330. fclose($myfile);
  4331. $error = $dir . $file_name . '.xls';
  4332. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4333. exit;
  4334. } else {
  4335. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4336. exit;
  4337. }
  4338. }
  4339. }
  4340. //笛卡儿积
  4341. function cp($ps, $sets, $list)
  4342. {
  4343. $result = array();
  4344. $j = 0;
  4345. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  4346. if ($i == 0) {
  4347. $result = $sets[$i];
  4348. }
  4349. $tmp = array();
  4350. foreach ($result as $res) {
  4351. foreach ($sets[$i + 1] as $set) {
  4352. $tmp[] = $res . ',' . $set;
  4353. }
  4354. }
  4355. $result = $tmp;
  4356. }
  4357. $this->db->trans_begin();
  4358. foreach ($result as $v) {
  4359. $post = array();
  4360. $title = "";
  4361. $num = "";
  4362. $data = explode(',', $v);
  4363. for ($i = 0; $i < count($list); $i++) {
  4364. $post[$list[$i]] = $data[$i];
  4365. $typeclass = $this->typeclass->read($data[$i]);
  4366. $title = $title . $typeclass['title'] . " ";
  4367. if ($data[$i] != 0) {
  4368. $num .= $data[$i]; //所有数据ID拼接
  4369. }
  4370. }
  4371. foreach ($ps as $kp => $vp) {
  4372. $post[$kp] = $vp;
  4373. }
  4374. $post['number'] = $num;
  4375. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  4376. if ($info_list) {
  4377. $j++;
  4378. } else {
  4379. $skunum = $this->whlabel->find_count();
  4380. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  4381. $post['title'] = rtrim($title, ' ');
  4382. $this->whlabel->insert($post);
  4383. }
  4384. }
  4385. if ($this->db->trans_status() === FALSE) {
  4386. $this->db->trans_commit();
  4387. return NULL;
  4388. } else {
  4389. $this->db->trans_commit();
  4390. return $j;
  4391. }
  4392. }
  4393. public function _kj($arg_array)
  4394. {
  4395. if (isset($_POST['sku'])) {
  4396. $time = time();
  4397. $sku = $this->input->post('sku', true);
  4398. $warehouse = $this->input->post('warehouse', true);
  4399. $num = $this->input->post('num', true);
  4400. $text = $this->input->post('text', true);
  4401. $purchase = $this->input->post('purchase', true);
  4402. $cktype = $this->input->post('cktype', true);
  4403. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  4404. if ($cktype != 1 && $text == '') {
  4405. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  4406. exit;
  4407. }
  4408. if ($num > count($order)) {
  4409. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  4410. exit;
  4411. } else {
  4412. for ($i = 0; $i < $num; $i++) {
  4413. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  4414. }
  4415. }
  4416. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  4417. exit;
  4418. }
  4419. $uid = $this->whlabel->read($arg_array[0]);
  4420. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  4421. $this->data['data'] = $uid;
  4422. $this->_Template('whlabel_kj', $this->data);
  4423. }
  4424. public function _summary($arg_array)
  4425. {
  4426. $prc = array();
  4427. $purchase = $this->purchase->find_all();
  4428. foreach ($purchase as $k => $v) {
  4429. $prc[$v['id']] = $v['title'];
  4430. }
  4431. if (isset($_GET['excel'])) {
  4432. $ktime = $this->input->get('ktime', true);
  4433. $jtime = $this->input->get('jtime', true);
  4434. $ktime = strtotime($ktime);
  4435. $jtime = strtotime($jtime);
  4436. $where = "1=1";
  4437. if ($ktime && $jtime) {
  4438. $where .= " and outk > '$ktime' and outk < '$jtime'";
  4439. }
  4440. //数据排序
  4441. $order_str = "time desc";
  4442. if (empty($page)) {
  4443. $start = 0;
  4444. $perpage = 1;
  4445. } else {
  4446. $start = ($page - 1) * $perpage;
  4447. }
  4448. //取得信息列表
  4449. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  4450. foreach ($info_list as $key => $value) {
  4451. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4452. $warehouse = $this->warehouse->read($value['warehouse']);
  4453. $info_list[$key]['warehouse'] = $warehouse['title'];
  4454. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  4455. $details = array();
  4456. $cpid = array();
  4457. foreach ($x as $k => $v) {
  4458. if ($v['details'] != '') {
  4459. $details[$v['details']] = $v['details'];
  4460. }
  4461. if ($v['cpid'] != 0) {
  4462. $cpid[$v['cpid']] = $v['cpid'];
  4463. }
  4464. }
  4465. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  4466. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4467. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  4468. $info_list[$key]['s'] = $s;
  4469. $info_list[$key]['x'] = count($x);
  4470. }
  4471. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  4472. $titlename = "<table border=1>
  4473. <tr align='center'>
  4474. <td>仓库</td>
  4475. <td>供应商</td>
  4476. <td>出库位置</td>
  4477. <td>出库编码</td>
  4478. <td>SKU</td>
  4479. <td>产品名</td>
  4480. <td>总剩余库存</td>
  4481. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  4482. </tr>
  4483. </table>";
  4484. $filename = $title . ".xls";
  4485. $tail = "";
  4486. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  4487. }
  4488. }
  4489. //usps发货清单
  4490. public function _manifest()
  4491. {
  4492. if (isset($_POST['manifest'])) {
  4493. $wltext = $this->input->post('wltext', true);
  4494. $time = time() - 16 * 3600;
  4495. $ptime = strtotime(date('Y-m-d', $time));
  4496. $waybill = array();
  4497. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4498. foreach ($fullorder as $v) {
  4499. $waybill[$v['waybill']] = $v['waybill'];
  4500. }
  4501. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  4502. foreach ($fullordersmt as $v) {
  4503. $waybill[$v['waybill']] = $v['waybill'];
  4504. }
  4505. $wltext = explode(';', $wltext);
  4506. foreach ($wltext as $v) {
  4507. if (isset($waybill[$v])) {
  4508. unset($waybill[$v]);
  4509. }
  4510. }
  4511. $data = $this->usps->get_manifest($waybill);
  4512. if (isset($data['Description'])) {
  4513. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  4514. exit;
  4515. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  4516. $bctime = date('Ymd', time());
  4517. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  4518. echo json_encode(array('msg' => $pdf, 'success' => true));
  4519. exit;
  4520. } else {
  4521. echo json_encode(array('msg' => $data, 'success' => false));
  4522. exit;
  4523. }
  4524. }
  4525. }
  4526. public function _pdf($pdf, $title, $bctime)
  4527. {
  4528. $pdf_path = './data/pdf/' . $bctime . '/';
  4529. $file_base64 = $pdf;
  4530. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4531. $file_base64 = base64_decode($file_base64);
  4532. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  4533. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  4534. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  4535. }
  4536. /**
  4537. *
  4538. *
  4539. *
  4540. 进销存占单异常索引
  4541. *
  4542. *
  4543. *
  4544. **/
  4545. public function _abnormal()
  4546. {
  4547. $post = $this->input->post(NULL, TRUE);
  4548. if (isset($post['page'])) {
  4549. $page = $this->input->post('page', true);
  4550. $perpage = $this->input->post('perpage', true);
  4551. $sku = $this->input->post('sku', true);
  4552. $where = "1=1";
  4553. //数据排序
  4554. $order_str = "id desc";
  4555. if (empty($page)) {
  4556. $start = 0;
  4557. $perpage = 1;
  4558. } else {
  4559. $start = ($page - 1) * $perpage;
  4560. }
  4561. //取得信息列表
  4562. $info_list = $this->whlabel->find_all($where, '*');
  4563. $rows = array();
  4564. $list = array();
  4565. foreach ($info_list as $key => $value) {
  4566. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  4567. }
  4568. foreach ($rows as $value) {
  4569. $warehouse = $this->warehouse->read($value['warehouse']);
  4570. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  4571. $number = $value['number'];
  4572. $ftime = time() - 15 * 24 * 3600;
  4573. if ($value['shop'] != '') {
  4574. $shop = $value['shop'];
  4575. $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');
  4576. $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');
  4577. $order = array_merge($orderdlz, $ordersmt);
  4578. $od = 0;
  4579. $a = '';
  4580. $orid = '';
  4581. foreach ($order as $v) {
  4582. $or = explode('|', ltrim($v['whlabel'], '|'));
  4583. for ($i = 0; $i < count($or); $i++) {
  4584. $orod = explode('-', $or[$i]);
  4585. if ($orod[0] == $number) {
  4586. $od += $orod[1];
  4587. }
  4588. }
  4589. $orid .= $v['number'] . '-';
  4590. }
  4591. } else {
  4592. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4593. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  4594. $order = array_merge($orderdlz, $ordersmt);
  4595. $od = 0;
  4596. $a = '';
  4597. $orid = '';
  4598. $qt = array();
  4599. foreach ($order as $v) {
  4600. $or = explode('|', ltrim($v['whlabel'], '|'));
  4601. for ($i = 0; $i < count($or); $i++) {
  4602. $orod = explode('-', $or[$i]);
  4603. if ($orod[0] == $number) {
  4604. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  4605. if ($czzs > 0) {
  4606. if (isset($qt[$v['shop']])) {
  4607. if ($qt[$v['shop']] < $orod[1]) {
  4608. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  4609. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4610. } else {
  4611. $qt[$v['shop']] -= $orod[1];
  4612. }
  4613. } else {
  4614. $qt[$v['shop']] = $czzs;
  4615. }
  4616. } else {
  4617. $od += $orod[1];
  4618. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  4619. }
  4620. }
  4621. }
  4622. }
  4623. }
  4624. $z = $od . '(' . $orid . ')'; //查看订单号
  4625. //$z = $od;
  4626. if ($od > $c) {
  4627. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  4628. }
  4629. }
  4630. $listdata = array_slice($list, $start, $perpage);
  4631. $total = count($list);
  4632. $pagenum = ceil($total / $perpage);
  4633. $over = $total - ($start + $perpage);
  4634. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4635. echo json_encode($rows);
  4636. exit;
  4637. }
  4638. $this->_Template('whlabel_abnormal', $this->data);
  4639. }
  4640. /**
  4641. *
  4642. *
  4643. *
  4644. 进销存占单异常索引
  4645. *
  4646. *
  4647. *
  4648. **/
  4649. public function _error()
  4650. {
  4651. $post = $this->input->post(NULL, TRUE);
  4652. if (isset($post['page'])) {
  4653. $page = $this->input->post('page', true);
  4654. $perpage = $this->input->post('perpage', true);
  4655. $sku = $this->input->post('sku', true);
  4656. $warehouse = $this->input->post('warehouse', true);
  4657. $ktime = $this->input->post('ktime', true);
  4658. $jtime = $this->input->post('jtime', true);
  4659. $ktime = strtotime($ktime);
  4660. $jtime = strtotime($jtime);
  4661. $where = "sku != 'Preset'";
  4662. $gj = '';
  4663. if ($sku) {
  4664. $where .= " and sku like '%$sku%'";
  4665. } else {
  4666. if ($ktime && $jtime) {
  4667. $gj = " and time > '$ktime' and time < '$jtime'";
  4668. }
  4669. }
  4670. if ($warehouse) {
  4671. $where .= " and warehouse = '$warehouse'";
  4672. }
  4673. //数据排序
  4674. $order_str = "id desc";
  4675. if (empty($page)) {
  4676. $start = 0;
  4677. $perpage = 1;
  4678. } else {
  4679. $start = ($page - 1) * $perpage;
  4680. }
  4681. //取得信息列表
  4682. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  4683. $rows = array();
  4684. $list = array();
  4685. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4686. // foreach ($info_list as $value)
  4687. // {
  4688. // $warehouse = $this->warehouse->read($value['warehouse']);
  4689. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4690. // $number = $value['number'];$ftime = time()-15*24*3600;
  4691. // if($c < 1)
  4692. // {
  4693. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4694. // }
  4695. // }
  4696. $warehouse_list = $this->warehouse->find_all();
  4697. $warehouse_list = array_column($warehouse_list, null, 'id');
  4698. foreach ($info_list as $value) {
  4699. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  4700. 'title' => "",
  4701. ];
  4702. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4703. $number = $value['number'];
  4704. $ftime = time() - 15 * 24 * 3600;
  4705. if ($c < 1) {
  4706. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4707. }
  4708. }
  4709. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  4710. // $query = $this->db->query($sql);
  4711. // $info_list = $query->result_array();
  4712. // $sql_two = "select title,id from crowd_warehouse";
  4713. // $query_two = $this->db->query($sql_two);
  4714. // $warehouse_list = $query_two->result_array();
  4715. // $warehouse_arr = array_column($warehouse_list,null,'id');
  4716. // foreach ($info_list as $value)
  4717. // {
  4718. // if(isset($warehouse_arr[$value['warehouse']])){
  4719. // $warehouse = $warehouse_arr[$value['warehouse']];
  4720. // }else{
  4721. // $warehouse = [
  4722. // 'id'=>0,
  4723. // 'title'=>"异常",
  4724. // ];
  4725. // }
  4726. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  4727. // $number = $value['number'];$ftime = time()-15*24*3600;
  4728. // if($c < 1)
  4729. // {
  4730. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  4731. // }
  4732. // }
  4733. $listdata = array_slice($list, $start, $perpage);
  4734. $total = count($list);
  4735. $pagenum = ceil($total / $perpage);
  4736. $over = $total - ($start + $perpage);
  4737. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  4738. echo json_encode($rows);
  4739. exit;
  4740. }
  4741. if (isset($post['s'])) {
  4742. $id_arr = $this->input->post('s');
  4743. $id_arr = explode(',', trim($id_arr, ','));
  4744. if (!$id_arr) {
  4745. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  4746. exit;
  4747. }
  4748. //循环删除记录
  4749. foreach ($id_arr as $v) {
  4750. $dd = $this->whlabel->read($v);
  4751. if (!isset($dd['id'])) {
  4752. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  4753. exit;
  4754. }
  4755. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  4756. if (isset($zt[0])) {
  4757. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  4758. exit;
  4759. }
  4760. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  4761. foreach ($deldd as $vv) {
  4762. $this->whlabel->remove($vv['id']);
  4763. }
  4764. }
  4765. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  4766. exit;
  4767. }
  4768. $this->_Template('whlabel_error', $this->data);
  4769. }
  4770. public function _errorexcel()
  4771. {
  4772. $post = $this->input->post(NULL, TRUE);
  4773. if (isset($_GET['page'])) {
  4774. $page = $this->input->get('page', true);
  4775. $perpage = $this->input->get('perpage', true);
  4776. $sku = $this->input->get('sku', true);
  4777. $warehouse = $this->input->get('warehouse', true);
  4778. $ktime = $this->input->get('ktime', true);
  4779. $jtime = $this->input->get('jtime', true);
  4780. $ktime = strtotime($ktime);
  4781. $jtime = strtotime($jtime);
  4782. $where = "sku != 'Preset'";
  4783. $gj = '';
  4784. if ($sku) {
  4785. $where .= " and sku like '%$sku%'";
  4786. } else {
  4787. if ($ktime && $jtime) {
  4788. $gj = " and time > '$ktime' and time < '$jtime'";
  4789. }
  4790. }
  4791. if ($warehouse) {
  4792. $where .= " and warehouse = '$warehouse'";
  4793. }
  4794. //数据排序
  4795. $order_str = "id desc";
  4796. if (empty($page)) {
  4797. $start = 0;
  4798. $perpage = 1;
  4799. } else {
  4800. $start = ($page - 1) * $perpage;
  4801. }
  4802. //取得信息列表
  4803. $rows = array();
  4804. $list = array();
  4805. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  4806. foreach ($info_list as $value) {
  4807. $warehouse = $this->warehouse->read($value['warehouse']);
  4808. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  4809. $number = $value['number'];
  4810. $ftime = time() - 15 * 24 * 3600;
  4811. if ($c < 1) {
  4812. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  4813. }
  4814. }
  4815. $title = "0库存汇总";
  4816. $titlename = "<table border=1>
  4817. <tr align='center'>
  4818. <td>仓库</td>
  4819. <td>SKU</td>
  4820. <td>产品</td>
  4821. <td>当前库存</td>
  4822. </tr>
  4823. </table>";
  4824. $filename = $title . ".xls";
  4825. $tail = "";
  4826. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4827. }
  4828. }
  4829. /**
  4830. *
  4831. *
  4832. * 占单
  4833. *
  4834. *
  4835. **/
  4836. public function _kcyz()
  4837. {
  4838. $post = $this->input->post(NULL, TRUE);
  4839. if (isset($post['warehouse'])) {
  4840. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  4841. exit; //不再使用
  4842. $warehouse = $this->input->post('warehouse', true);
  4843. $whlabel = $this->input->post('whlabel', true);
  4844. $id = $this->input->post('id', true);
  4845. $shop = $this->input->post('shop', true);
  4846. $number = $this->input->post('number', true);
  4847. if (!$whlabel || $whlabel == '|') {
  4848. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  4849. exit;
  4850. }
  4851. $pp = explode('|', trim($whlabel, '|'));
  4852. $x = 0;
  4853. $save = array();
  4854. foreach ($pp as $va) {
  4855. $num = explode('-', $va);
  4856. if ($number) {
  4857. $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 = '')"); //通用
  4858. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  4859. } else {
  4860. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  4861. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  4862. }
  4863. $x++;
  4864. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  4865. $save[] = $x - 1;
  4866. continue; //提前先加X不然出错,所以要减1
  4867. }
  4868. }
  4869. if (isset($save[0])) {
  4870. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  4871. exit;
  4872. } else {
  4873. echo json_encode(array('success' => true));
  4874. exit;
  4875. }
  4876. }
  4877. }
  4878. public function _db()
  4879. {
  4880. $post = $this->input->post(NULL, TRUE);
  4881. if (isset($post['page'])) {
  4882. $page = $this->input->post('page', true);
  4883. $perpage = $this->input->post('perpage', true);
  4884. $sku = $this->input->post('sku', true);
  4885. $number = $this->input->post('number', true);
  4886. $warehouse = $this->input->post('warehouse', true);
  4887. $purchase = $this->input->post('purchase', true);
  4888. $orderinfo = $this->input->post('orderinfo', true);
  4889. $waybill = $this->input->post('waybill', true);
  4890. $category = $this->input->post('category', true);
  4891. $size = $this->input->post('size', true);
  4892. $grade = $this->input->post('grade', true);
  4893. $color = $this->input->post('color', true);
  4894. $lowe = $this->input->post('lowe', true);
  4895. $state = $this->input->post('state', true);
  4896. $label = $this->input->post('label', true);
  4897. $timetk = $this->input->post('timetkk', true);
  4898. $timetj = $this->input->post('timetjj', true);
  4899. $timetk = strtotime($timetk);
  4900. $timetj = strtotime($timetj);
  4901. $where = "dbtime > 0";
  4902. if ($timetk && $timetj) {
  4903. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  4904. }
  4905. if ($sku) {
  4906. $where .= " and sku = '$sku'";
  4907. }
  4908. if ($warehouse) {
  4909. $where .= " and warehouse = '$warehouse'";
  4910. if ($warehouse == 12) {
  4911. $w = 'specialstock';
  4912. } else {
  4913. $w = 'whlabel';
  4914. }
  4915. }
  4916. if ($purchase) {
  4917. $where .= " and purchase = '$purchase'";
  4918. }
  4919. if ($category) {
  4920. $where .= " and features like '%-$category-%'";
  4921. }
  4922. if ($size) {
  4923. $where .= " and features like '%-$size-%'";
  4924. }
  4925. if ($grade) {
  4926. $where .= " and features like '%-$grade-%'";
  4927. }
  4928. if ($color) {
  4929. $where .= " and features like '%-$color-%'";
  4930. }
  4931. if ($lowe) {
  4932. $where .= " and features like '%-$lowe-%'";
  4933. }
  4934. if ($state != '') {
  4935. $where .= " and state = '$state'";
  4936. }
  4937. //数据排序
  4938. $order_str = "dbtime desc";
  4939. if (empty($page)) {
  4940. $start = 0;
  4941. $perpage = 1;
  4942. } else {
  4943. $start = ($page - 1) * $perpage;
  4944. }
  4945. //取得信息列表
  4946. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  4947. foreach ($info_list as $key => $value) {
  4948. $warehouse = $this->$w->read($value['warehouse']);
  4949. $info_list[$key]['warehouse'] = $warehouse['title'];
  4950. $purchase = $this->purchase->read($value['purchase']);
  4951. $info_list[$key]['purchase'] = $purchase['title'];
  4952. if ($value['enter'] != 0) {
  4953. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  4954. } else {
  4955. $info_list[$key]['enter'] = "";
  4956. }
  4957. if ($value['dbtime'] != 0) {
  4958. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  4959. } else {
  4960. $info_list[$key]['dbtime'] = "";
  4961. }
  4962. if ($value['state'] == 0) {
  4963. $info_list[$key]['state'] = "在库";
  4964. } else if ($value['state'] == 1) {
  4965. $info_list[$key]['state'] = "出库";
  4966. } else if ($value['state'] == 2) {
  4967. $info_list[$key]['state'] = "退库";
  4968. } else if ($value['state'] == 3) {
  4969. $info_list[$key]['state'] = "调拨中";
  4970. } else if ($value['state'] == 4) {
  4971. $info_list[$key]['state'] = "再加工";
  4972. } else if ($value['state'] == 5) {
  4973. $info_list[$key]['state'] = "维修中";
  4974. } else if ($value['state'] == 6) {
  4975. $info_list[$key]['state'] = "盘亏";
  4976. } else if ($value['state'] == 7) {
  4977. $info_list[$key]['state'] = "更换标签";
  4978. } else if ($value['state'] == 8) {
  4979. $info_list[$key]['state'] = "其它";
  4980. } else if ($value['state'] == 9) {
  4981. $info_list[$key]['state'] = "预设";
  4982. }
  4983. }
  4984. $total = $this->whlabel->find_count($where);
  4985. $pagenum = ceil($total / $perpage);
  4986. $over = $total - ($start + $perpage);
  4987. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  4988. echo json_encode($rows);
  4989. exit;
  4990. }
  4991. if (isset($post['outsku'])) {
  4992. $time = time();
  4993. $cz = $this->input->post('cz', true);
  4994. $label = $this->input->post('outsku', true);
  4995. $sl = $this->input->post('sl', true);
  4996. $num = $this->input->post('num', true);
  4997. //$warehouse = $this->input->post('warehouse',true);
  4998. if (!$sl) {
  4999. $sl = 1;
  5000. }
  5001. if (!$warehouse) {
  5002. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5003. exit;
  5004. }
  5005. $dblabel = $this->whlabellabel->get_label($label);
  5006. if ($dblabel) {
  5007. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5008. if (count($data) < 1) {
  5009. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5010. exit;
  5011. }
  5012. if (count($data) < $num) {
  5013. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5014. exit;
  5015. }
  5016. for ($i = 0; $i < $sl; $i++) {
  5017. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5018. }
  5019. echo json_encode(array('success' => true));
  5020. exit;
  5021. } else {
  5022. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5023. exit;
  5024. }
  5025. }
  5026. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5027. $this->_Template('whlabel_db', $this->data);
  5028. }
  5029. public function _dbrk()
  5030. {
  5031. $post = $this->input->post(NULL, TRUE);
  5032. if (isset($post['page'])) {
  5033. $page = $this->input->post('page', true);
  5034. $perpage = $this->input->post('perpage', true);
  5035. $sku = $this->input->post('sku', true);
  5036. $number = $this->input->post('number', true);
  5037. $warehouse = $this->input->post('warehouse', true);
  5038. $purchase = $this->input->post('purchase', true);
  5039. $orderinfo = $this->input->post('orderinfo', true);
  5040. $waybill = $this->input->post('waybill', true);
  5041. $category = $this->input->post('category', true);
  5042. $size = $this->input->post('size', true);
  5043. $grade = $this->input->post('grade', true);
  5044. $color = $this->input->post('color', true);
  5045. $lowe = $this->input->post('lowe', true);
  5046. $state = $this->input->post('state', true);
  5047. $label = $this->input->post('label', true);
  5048. $ctime = $this->input->post('ctime', true);
  5049. $timetk = $this->input->post('timetkk', true);
  5050. $timetj = $this->input->post('timetjj', true);
  5051. $timetk = strtotime($timetk);
  5052. $timetj = strtotime($timetj);
  5053. $where = "dbtime > 0";
  5054. if ($timetk && $timetj) {
  5055. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5056. }
  5057. if ($sku) {
  5058. $where .= " and sku = '$sku'";
  5059. }
  5060. if ($warehouse) {
  5061. $where .= " and warehouse = '$warehouse'";
  5062. }
  5063. if ($purchase) {
  5064. $where .= " and purchase = '$purchase'";
  5065. }
  5066. if ($category) {
  5067. $where .= " and features like '%-$category-%'";
  5068. }
  5069. if ($size) {
  5070. $where .= " and features like '%-$size-%'";
  5071. }
  5072. if ($grade) {
  5073. $where .= " and features like '%-$grade-%'";
  5074. }
  5075. if ($color) {
  5076. $where .= " and features like '%-$color-%'";
  5077. }
  5078. if ($lowe) {
  5079. $where .= " and features like '%-$lowe-%'";
  5080. }
  5081. if ($state != '') {
  5082. $where .= " and state = '$state'";
  5083. }
  5084. //数据排序
  5085. $order_str = "dbtime desc";
  5086. if (empty($page)) {
  5087. $start = 0;
  5088. $perpage = 1;
  5089. } else {
  5090. $start = ($page - 1) * $perpage;
  5091. }
  5092. //取得信息列表
  5093. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5094. foreach ($info_list as $key => $value) {
  5095. $warehouse = $this->warehouse->read($value['warehouse']);
  5096. $info_list[$key]['warehouse'] = $warehouse['title'];
  5097. $purchase = $this->purchase->read($value['purchase']);
  5098. $info_list[$key]['purchase'] = $purchase['title'];
  5099. if ($value['enter'] != 0) {
  5100. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5101. } else {
  5102. $info_list[$key]['enter'] = "";
  5103. }
  5104. if ($value['dbtime'] != 0) {
  5105. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5106. } else {
  5107. $info_list[$key]['dbtime'] = "";
  5108. }
  5109. if ($value['state'] == 0) {
  5110. $info_list[$key]['state'] = "在库";
  5111. } else if ($value['state'] == 1) {
  5112. $info_list[$key]['state'] = "出库";
  5113. } else if ($value['state'] == 2) {
  5114. $info_list[$key]['state'] = "退库";
  5115. } else if ($value['state'] == 3) {
  5116. $info_list[$key]['state'] = "调拨中";
  5117. } else if ($value['state'] == 4) {
  5118. $info_list[$key]['state'] = "再加工";
  5119. } else if ($value['state'] == 5) {
  5120. $info_list[$key]['state'] = "维修中";
  5121. } else if ($value['state'] == 6) {
  5122. $info_list[$key]['state'] = "盘亏";
  5123. } else if ($value['state'] == 7) {
  5124. $info_list[$key]['state'] = "更换标签";
  5125. } else if ($value['state'] == 8) {
  5126. $info_list[$key]['state'] = "其它";
  5127. } else if ($value['state'] == 9) {
  5128. $info_list[$key]['state'] = "预设";
  5129. }
  5130. }
  5131. $total = $this->whlabel->find_count($where);
  5132. $pagenum = ceil($total / $perpage);
  5133. $over = $total - ($start + $perpage);
  5134. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5135. echo json_encode($rows);
  5136. exit;
  5137. }
  5138. if (isset($post['rsku'])) {
  5139. $cz = $this->input->post('cz', true);
  5140. $label = $this->input->post('rsku', true);
  5141. $sl = $this->input->post('sl', true);
  5142. $warehouse = $this->input->post('warehouse', true);
  5143. if (!$sl) {
  5144. $sl = 1;
  5145. }
  5146. if (!$warehouse) {
  5147. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5148. exit;
  5149. }
  5150. $dblabel = $this->whlabellabel->get_label($label);
  5151. if ($dblabel) {
  5152. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5153. if (count($data) < 1) {
  5154. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5155. exit;
  5156. }
  5157. if ($sl > count($data)) {
  5158. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5159. exit;
  5160. }
  5161. $time = time();
  5162. for ($i = 0; $i < $sl; $i++) {
  5163. $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']);
  5164. }
  5165. echo json_encode(array('success' => true));
  5166. exit;
  5167. } else {
  5168. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5169. exit;
  5170. }
  5171. }
  5172. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5173. $this->_Template('whlabel_dbrk', $this->data);
  5174. }
  5175. public function _whlabelczdc()
  5176. {
  5177. if (isset($_GET['excel'])) {
  5178. //数据排序
  5179. $order_str = "id desc";
  5180. if (empty($page)) {
  5181. $start = 0;
  5182. $perpage = 1;
  5183. } else {
  5184. $start = ($page - 1) * $perpage;
  5185. }
  5186. $state = $this->input->get('state', true);
  5187. $sku = $this->input->get('sku', true);
  5188. $ctime = $this->input->get('ctime', true);
  5189. $category = $this->input->get('category', true);
  5190. $size = $this->input->get('size', true);
  5191. $grade = $this->input->get('grade', true);
  5192. $color = $this->input->get('color', true);
  5193. $lowe = $this->input->get('lowe', true);
  5194. $timetk = $this->input->get('timetkk', true);
  5195. $timetj = $this->input->get('timetjj', true);
  5196. $timetk = strtotime($timetk);
  5197. $timetj = strtotime($timetj);
  5198. $where = "dbtime > 0";
  5199. if ($timetk && $timetj) {
  5200. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5201. }
  5202. if ($category) {
  5203. $where .= " and features like '%-$category-%'";
  5204. }
  5205. if ($size) {
  5206. $where .= " and features like '%-$size-%'";
  5207. }
  5208. if ($grade) {
  5209. $where .= " and features like '%-$grade-%'";
  5210. }
  5211. if ($color) {
  5212. $where .= " and features like '%-$color-%'";
  5213. }
  5214. if ($lowe) {
  5215. $where .= " and features like '%-$lowe-%'";
  5216. }
  5217. //取得信息列表
  5218. $info_list = $this->whlabel->find_all($where, '*');
  5219. $rows = array();
  5220. $list = array();
  5221. foreach ($info_list as $key => $value) {
  5222. $rows[$value['sku']] = $value; //所有数据sku
  5223. }
  5224. foreach ($rows as $value) {
  5225. $warehouse = $this->warehouse->read($value['warehouse']);
  5226. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5227. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5228. if ($value['orderinfo'] == 0) {
  5229. $info_list[$key]['orderinfo'] = "";
  5230. }
  5231. if ($value['waybill'] == 0) {
  5232. $info_list[$key]['waybill'] = "";
  5233. }
  5234. if ($value['state'] == 0) {
  5235. $value['state'] = "在库";
  5236. } else if ($value['state'] == 3) {
  5237. $value['state'] = "调拨中";
  5238. }
  5239. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5240. }
  5241. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5242. $titlename = "<table border=1>
  5243. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5244. <tr align='center'>
  5245. <td>SKU</td>
  5246. <td>产品</td>
  5247. <td>调拨数量</td>
  5248. <td>入库数量</td>
  5249. </tr>
  5250. </table>";
  5251. $filename = $title . ".xls";
  5252. $tail = "";
  5253. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5254. }
  5255. }
  5256. public function _print($arg_array)
  5257. {
  5258. if (isset($_SESSION['api'])) {
  5259. $user = $this->user->get_api($_SESSION['api']);
  5260. $usp = $user;
  5261. $fgshop = "";
  5262. $sid = "";
  5263. $wid = "";
  5264. $wtype = "";
  5265. $usersp = explode('|', trim($user['shop'], '|'));
  5266. $userwh = explode('|', trim($user['warehouse'], '|'));
  5267. foreach ($usersp as $value) {
  5268. $fgshop .= " shop = " . $value . " or";
  5269. $sid .= " id = " . $value . " or";
  5270. }
  5271. foreach ($userwh as $value) {
  5272. $wid .= " id = " . $value . " or";
  5273. $wtype .= " type = " . $value . " or";
  5274. }
  5275. }
  5276. $post = $this->input->post(NULL, TRUE);
  5277. if (isset($post['tmsku'])) {
  5278. $tmsku = $this->input->post('tmsku', true);
  5279. if (is_numeric($tmsku)) {
  5280. $yyh = $this->whlabellabel->get_label($tmsku);
  5281. } else {
  5282. $yyh = $this->whlabellabel->get_sku($tmsku);
  5283. }
  5284. if ($yyh) {
  5285. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5286. exit;
  5287. } else {
  5288. echo json_encode(array('success' => false));
  5289. exit;
  5290. }
  5291. }
  5292. $classid = $this->classid->sku();
  5293. $pm = $classid;
  5294. $scsku = $classid;
  5295. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5296. if (isset($post['warehouse'])) {
  5297. if ($post['warehouse']) {
  5298. $list = array();
  5299. $num = "";
  5300. $title = "";
  5301. $features = "";
  5302. $order = 0;
  5303. $post['shop'] = '';
  5304. $brand = $this->input->post('brand', true);
  5305. if ($brand != '0,') {
  5306. $b = $this->brand->read(rtrim($brand, ','));
  5307. if ($b) {
  5308. $post['shop'] = str_replace('|', ',', $b['shop']);
  5309. }
  5310. }
  5311. $post['details'] = $this->input->post('details', true); //打印数量
  5312. $xbqnum = $this->input->post('xbqnum', true);
  5313. $post['purchase'] = $this->input->post('purchase', true);
  5314. $post['warehouse'] = $this->input->post('warehouse', true);
  5315. $post['purchase'] = $this->input->post('purchase', true);
  5316. $post['retreatwarehouse'] = $post['warehouse'];
  5317. $post['cpbz'] = $this->input->post('cpbz', true);
  5318. $post['state'] = 9;
  5319. $category = $this->input->post('category', true);
  5320. $list['category'] = $category;
  5321. $list['hairtype'] = $this->input->post('hairtype', true);
  5322. $list['grade'] = $this->input->post('grade', true);
  5323. $size = $this->input->post('size', true);
  5324. $list['size'] = rtrim($size, ',');
  5325. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5326. $list['extension'] = $this->input->post('extension', true);
  5327. if ($category == 1297) {
  5328. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5329. }
  5330. if ($category == 1702) {
  5331. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5332. $list['syother'] = $this->input->post('syother', true);
  5333. }
  5334. if ($category == 133) {
  5335. $list['fittype'] = $this->input->post('fittype', true);
  5336. $list['acother'] = $this->input->post('acother', true);
  5337. }
  5338. $list['color'] = $this->input->post('color', true);
  5339. $list['lowe'] = $this->input->post('lowe', true);
  5340. if ($category == 127) {
  5341. $list['type'] = $this->input->post('type', true);
  5342. $list['headroad'] = $this->input->post('headroad', true);
  5343. $list['density'] = $this->input->post('density', true);
  5344. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5345. $list['lacesize'] = $this->input->post('lacesize', true);
  5346. }
  5347. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5348. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5349. }
  5350. if ($category == 128) {
  5351. $list['lacetype'] = $this->input->post('lacetype', true);
  5352. $list['haircap'] = $this->input->post('haircap', true);
  5353. $list['density'] = $this->input->post('density', true);
  5354. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5355. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5356. $list['wigother'] = $this->input->post('wigother', true);
  5357. $list['wigother2'] = $this->input->post('wigother2', true);
  5358. }
  5359. if ($category == 129) {
  5360. $list['wide'] = $this->input->post('wide', true);
  5361. }
  5362. if ($category == 131) {
  5363. $list['gifttype'] = $this->input->post('gifttype', true);
  5364. $list['giftother'] = $this->input->post('giftother', true);
  5365. }
  5366. if ($category == 134) {
  5367. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5368. }
  5369. if ($category == 1297) {
  5370. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5371. $list['sywigother'] = $this->input->post('sywigother', true);
  5372. }
  5373. if ($category == 130 || $category == 133 || $category == 1702) {
  5374. $list['items'] = $this->input->post('items', true);
  5375. $list['weight'] = $this->input->post('weight', true);
  5376. }
  5377. if ($category == 1702) {
  5378. $list['syhairther'] = $this->input->post('syhairther', true);
  5379. }
  5380. foreach ($list as $k => $v) {
  5381. if ($v != 0) {
  5382. $num .= $v;
  5383. $features .= $v . '-';
  5384. $post[$k] = $v;
  5385. $typeclass = $this->typeclass->read($v);
  5386. if (isset($pm[$typeclass['classid']])) {
  5387. if (stripos($typeclass['zh'], '|') !== false) {
  5388. $exzh = explode('|', $typeclass['zh']);
  5389. $pm[$typeclass['classid']] = $exzh[0];
  5390. } else {
  5391. $pm[$typeclass['classid']] = $typeclass['zh'];
  5392. }
  5393. }
  5394. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5395. if ($k != 'size') {
  5396. $title .= $typeclass['title'] . " ";
  5397. }
  5398. }
  5399. }
  5400. $typeclass = $this->typeclass->read($list['size']);
  5401. $title .= $typeclass['title'];
  5402. $time = time();
  5403. $post['title'] = rtrim($title, ' ');
  5404. $post['number'] = $num;
  5405. $post['features'] = '-' . $features;
  5406. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5407. $featurespp = explode('-', trim($featurespp, '-'));
  5408. if (isset($featurespp[5])) {
  5409. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5410. } else {
  5411. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5412. }
  5413. $post['enter'] = $time;
  5414. $post['time'] = $time; //操作时间
  5415. $scsku = implode("-", $scsku);
  5416. $zh = implode(" ", $pm);
  5417. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5418. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5419. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5420. $post['sku'] = $bqsku;
  5421. $label = time() . rand(0, 9);
  5422. $post['label'] = $label;
  5423. $cpid = $this->whlabellabel->find_count();
  5424. $post['cpid'] = $cpid + 1;
  5425. $cpid = $post['cpid'];
  5426. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5427. //if($whlabelbarcode)
  5428. //{
  5429. //$post['label'] = $whlabelbarcode['label'];
  5430. //if(!$this->whlabellabel->insert($post))
  5431. //{
  5432. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5433. //}
  5434. //}
  5435. //else
  5436. //{
  5437. $this->db->trans_begin();
  5438. $this->whlabellabel->insert($post);
  5439. //$this->whlabelbarcode->insert($post);
  5440. if ($this->db->trans_status() === TRUE) {
  5441. $this->db->trans_commit();
  5442. } else {
  5443. $this->db->trans_rollback();
  5444. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5445. exit;
  5446. }
  5447. //}
  5448. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5449. $purchase = $this->purchase->read($post['purchase']);
  5450. 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));
  5451. exit; //特殊仓目前不需要仓库选项
  5452. }
  5453. }
  5454. if (isset($_SESSION['api'])) {
  5455. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5456. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5457. $this->data['wlshop'] = $wlshop;
  5458. $this->data['warehouse'] = $warehouse;
  5459. }
  5460. $whlabelwz = $this->whlabelwz->find_all();
  5461. $this->data['whlabelwz'] = $whlabelwz;
  5462. $this->_Template('whlabel_print', $this->data);
  5463. }
  5464. public function _usaprint($arg_array)
  5465. {
  5466. if (isset($_SESSION['api'])) {
  5467. $user = $this->user->get_api($_SESSION['api']);
  5468. $usp = $user;
  5469. $fgshop = "";
  5470. $sid = "";
  5471. $wid = "";
  5472. $wtype = "";
  5473. $usersp = explode('|', trim($user['shop'], '|'));
  5474. $userwh = explode('|', trim($user['warehouse'], '|'));
  5475. foreach ($usersp as $value) {
  5476. $fgshop .= " shop = " . $value . " or";
  5477. $sid .= " id = " . $value . " or";
  5478. }
  5479. foreach ($userwh as $value) {
  5480. $wid .= " id = " . $value . " or";
  5481. $wtype .= " type = " . $value . " or";
  5482. }
  5483. }
  5484. $post = $this->input->post(NULL, TRUE);
  5485. if (isset($post['tmsku'])) {
  5486. $tmsku = $this->input->post('tmsku', true);
  5487. if (is_numeric($tmsku)) {
  5488. $yyh = $this->whlabellabel->get_label($tmsku);
  5489. } else {
  5490. $yyh = $this->whlabellabel->get_sku($tmsku);
  5491. }
  5492. if ($yyh) {
  5493. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  5494. exit;
  5495. } else {
  5496. echo json_encode(array('success' => false));
  5497. exit;
  5498. }
  5499. }
  5500. $classid = $this->classid->sku();
  5501. $pm = $classid;
  5502. $scsku = $classid;
  5503. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  5504. if (isset($post['warehouse'])) {
  5505. if ($post['warehouse']) {
  5506. $list = array();
  5507. $num = "";
  5508. $title = "";
  5509. $features = "";
  5510. $order = 0;
  5511. $post['shop'] = '';
  5512. $brand = $this->input->post('brand', true);
  5513. if ($brand != '0,') {
  5514. $b = $this->brand->read(rtrim($brand, ','));
  5515. if ($b) {
  5516. $post['shop'] = str_replace('|', ',', $b['shop']);
  5517. }
  5518. }
  5519. $post['details'] = $this->input->post('details', true); //打印数量
  5520. $xbqnum = $this->input->post('xbqnum', true);
  5521. $post['purchase'] = $this->input->post('purchase', true);
  5522. $post['warehouse'] = $this->input->post('warehouse', true);
  5523. $post['purchase'] = $this->input->post('purchase', true);
  5524. $post['retreatwarehouse'] = $post['warehouse'];
  5525. $post['cpbz'] = $this->input->post('cpbz', true);
  5526. $post['state'] = 9;
  5527. $category = $this->input->post('category', true);
  5528. $list['category'] = $category;
  5529. $list['hairtype'] = $this->input->post('hairtype', true);
  5530. $list['grade'] = $this->input->post('grade', true);
  5531. $size = $this->input->post('size', true);
  5532. $list['size'] = rtrim($size, ',');
  5533. $list['hairnumber'] = $this->input->post('hairnumber', true);
  5534. $list['extension'] = $this->input->post('extension', true);
  5535. if ($category == 1297) {
  5536. $list['sywignumber'] = $this->input->post('sywignumber', true);
  5537. }
  5538. if ($category == 1702) {
  5539. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  5540. $list['syother'] = $this->input->post('syother', true);
  5541. }
  5542. if ($category == 133) {
  5543. $list['fittype'] = $this->input->post('fittype', true);
  5544. $list['acother'] = $this->input->post('acother', true);
  5545. }
  5546. $list['color'] = $this->input->post('color', true);
  5547. $list['lowe'] = $this->input->post('lowe', true);
  5548. if ($category == 127) {
  5549. $list['type'] = $this->input->post('type', true);
  5550. $list['headroad'] = $this->input->post('headroad', true);
  5551. $list['density'] = $this->input->post('density', true);
  5552. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  5553. $list['lacesize'] = $this->input->post('lacesize', true);
  5554. }
  5555. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5556. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5557. }
  5558. if ($category == 128) {
  5559. $list['lacetype'] = $this->input->post('lacetype', true);
  5560. $list['haircap'] = $this->input->post('haircap', true);
  5561. $list['density'] = $this->input->post('density', true);
  5562. $list['lacecolor'] = $this->input->post('lacecolor', true);
  5563. $list['lacetypes'] = $this->input->post('lacetypes', true);
  5564. $list['wigother'] = $this->input->post('wigother', true);
  5565. $list['wigother2'] = $this->input->post('wigother2', true);
  5566. }
  5567. if ($category == 129) {
  5568. $list['wide'] = $this->input->post('wide', true);
  5569. }
  5570. if ($category == 131) {
  5571. $list['gifttype'] = $this->input->post('gifttype', true);
  5572. $list['giftother'] = $this->input->post('giftother', true);
  5573. }
  5574. if ($category == 134) {
  5575. $list['pieceweight'] = $this->input->post('pieceweight', true);
  5576. }
  5577. if ($category == 1297) {
  5578. $list['synthetictype'] = $this->input->post('synthetictype', true);
  5579. $list['sywigother'] = $this->input->post('sywigother', true);
  5580. }
  5581. if ($category == 130 || $category == 133 || $category == 1702) {
  5582. $list['items'] = $this->input->post('items', true);
  5583. $list['weight'] = $this->input->post('weight', true);
  5584. }
  5585. if ($category == 1702) {
  5586. $list['syhairther'] = $this->input->post('syhairther', true);
  5587. }
  5588. foreach ($list as $k => $v) {
  5589. if ($v != 0) {
  5590. $num .= $v;
  5591. $features .= $v . '-';
  5592. $post[$k] = $v;
  5593. $typeclass = $this->typeclass->read($v);
  5594. if (isset($pm[$typeclass['classid']])) {
  5595. if (stripos($typeclass['zh'], '|') !== false) {
  5596. $exzh = explode('|', $typeclass['zh']);
  5597. $pm[$typeclass['classid']] = $exzh[0];
  5598. } else {
  5599. $pm[$typeclass['classid']] = $typeclass['zh'];
  5600. }
  5601. }
  5602. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  5603. if ($k != 'size') {
  5604. $title .= $typeclass['title'] . " ";
  5605. }
  5606. }
  5607. }
  5608. $typeclass = $this->typeclass->read($list['size']);
  5609. $title .= $typeclass['title'];
  5610. $time = time();
  5611. $post['title'] = rtrim($title, ' ');
  5612. $post['number'] = $num;
  5613. $post['features'] = '-' . $features;
  5614. $fp = $this->whlabel->get_features($post['features']);
  5615. if (!$fp) {
  5616. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  5617. exit;
  5618. }
  5619. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  5620. $featurespp = explode('-', trim($featurespp, '-'));
  5621. if (isset($featurespp[5])) {
  5622. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  5623. } else {
  5624. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  5625. }
  5626. $post['enter'] = $time;
  5627. $post['time'] = $time; //操作时间
  5628. $scsku = implode("-", $scsku);
  5629. $zh = implode(" ", $pm);
  5630. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  5631. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  5632. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  5633. $post['sku'] = $fp['sku'];
  5634. $post['label'] = $fp['sku'];
  5635. $cpid = $this->whlabellabel->find_count();
  5636. $post['cpid'] = $cpid + 1;
  5637. $cpid = $post['cpid'];
  5638. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  5639. //if($whlabelbarcode)
  5640. //{
  5641. //$post['label'] = $whlabelbarcode['label'];
  5642. //if(!$this->whlabellabel->insert($post))
  5643. //{
  5644. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  5645. //}
  5646. //}
  5647. //else
  5648. //{
  5649. $this->db->trans_begin();
  5650. $this->whlabellabel->insert($post);
  5651. //$this->whlabelbarcode->insert($post);
  5652. if ($this->db->trans_status() === TRUE) {
  5653. $this->db->trans_commit();
  5654. } else {
  5655. $this->db->trans_rollback();
  5656. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  5657. exit;
  5658. }
  5659. //}
  5660. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  5661. $purchase = $this->purchase->read($post['purchase']);
  5662. 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));
  5663. exit; //特殊仓目前不需要仓库选项
  5664. }
  5665. }
  5666. if (isset($_SESSION['api'])) {
  5667. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  5668. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  5669. $this->data['wlshop'] = $wlshop;
  5670. $this->data['warehouse'] = $warehouse;
  5671. }
  5672. $whlabelwz = $this->whlabelwz->find_all();
  5673. $this->data['whlabelwz'] = $whlabelwz;
  5674. $this->_Template('whlabel_usaprint', $this->data);
  5675. }
  5676. public function _printrk($arg_array)
  5677. {
  5678. $prc = array();
  5679. $purchase = $this->purchase->find_all();
  5680. foreach ($purchase as $k => $v) {
  5681. $prc[$v['id']] = $v['title'];
  5682. }
  5683. $post = $this->input->post(NULL, TRUE);
  5684. if (isset($post['page'])) {
  5685. $page = $this->input->post('page', true);
  5686. $perpage = $this->input->post('perpage', true);
  5687. $sku = $this->input->post('sku', true);
  5688. $bs = $this->input->post('bs', true);
  5689. $number = $this->input->post('number', true);
  5690. $warehouse = $this->input->post('warehouse', true);
  5691. $purchase = $this->input->post('purchase', true);
  5692. $orderinfo = $this->input->post('orderinfo', true);
  5693. $waybill = $this->input->post('waybill', true);
  5694. $category = $this->input->post('category', true);
  5695. $size = $this->input->post('size', true);
  5696. $grade = $this->input->post('grade', true);
  5697. $color = $this->input->post('color', true);
  5698. $lowe = $this->input->post('lowe', true);
  5699. $state = $this->input->post('state', true);
  5700. $label = $this->input->post('label', true);
  5701. $timetk = $this->input->post('ktime', true);
  5702. $timetj = $this->input->post('jtime', true);
  5703. $timetk = strtotime($timetk);
  5704. $timetj = strtotime($timetj);
  5705. $where = "1=1 ";
  5706. if ($timetk && $timetj) {
  5707. $where .= " and enter > '$timetk' and enter < '$timetj'";
  5708. }
  5709. if ($sku) {
  5710. $where .= " and sku = '$sku'";
  5711. }
  5712. if ($bs != '') {
  5713. $where .= " and bs = '$bs'";
  5714. }
  5715. if ($number) {
  5716. $where .= " and number = '$number'";
  5717. }
  5718. if ($warehouse) {
  5719. $where .= " and warehouse = '$warehouse'";
  5720. }
  5721. if ($purchase) {
  5722. $where .= " and purchase = '$purchase'";
  5723. }
  5724. if ($orderinfo) {
  5725. $where .= " and orderinfo = '$orderinfo'";
  5726. }
  5727. if ($waybill) {
  5728. $where .= " and waybill = '$waybill'";
  5729. }
  5730. if ($category) {
  5731. $where .= " and features like '%-$category-%'";
  5732. }
  5733. if ($size) {
  5734. $where .= " and features like '%-$size-%'";
  5735. }
  5736. if ($grade) {
  5737. $where .= " and features like '%-$grade-%'";
  5738. }
  5739. if ($color) {
  5740. $where .= " and features like '%-$color-%'";
  5741. }
  5742. if ($lowe) {
  5743. $where .= " and features like '%-$lowe-%'";
  5744. }
  5745. if ($label) {
  5746. $where .= " and label = '$label'";
  5747. }
  5748. if ($state || $state == 0) {
  5749. $where .= " and state = '$state'";
  5750. }
  5751. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  5752. //数据排序
  5753. $order_str = "enter desc";
  5754. if (empty($page)) {
  5755. $start = 0;
  5756. $perpage = 1;
  5757. } else {
  5758. $start = ($page - 1) * $perpage;
  5759. }
  5760. //取得信息列表
  5761. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  5762. foreach ($info_list as $key => $value) {
  5763. $warehouse = $this->warehouse->read($value['warehouse']);
  5764. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  5765. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5766. if ($value['state'] == 0) {
  5767. $info_list[$key]['state'] = "在库";
  5768. } else if ($value['state'] == 1) {
  5769. $info_list[$key]['state'] = "出库";
  5770. } else if ($value['state'] == 2) {
  5771. $info_list[$key]['state'] = "退库";
  5772. } else if ($value['state'] == 3) {
  5773. $info_list[$key]['state'] = "调拨中";
  5774. } else if ($value['state'] == 4) {
  5775. $info_list[$key]['state'] = "再加工";
  5776. } else if ($value['state'] == 5) {
  5777. $info_list[$key]['state'] = "维修中";
  5778. } else if ($value['state'] == 6) {
  5779. $info_list[$key]['state'] = "盘亏";
  5780. } else if ($value['state'] == 7) {
  5781. $info_list[$key]['state'] = "更换标签";
  5782. } else if ($value['state'] == 8) {
  5783. $info_list[$key]['state'] = "其它";
  5784. } else if ($value['state'] == 9) {
  5785. $info_list[$key]['state'] = "预设";
  5786. } else if ($value['state'] == 10) {
  5787. $info_list[$key]['state'] = "美店零售";
  5788. }
  5789. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  5790. }
  5791. $total = $this->$ck->find_count($where);
  5792. $pagenum = ceil($total / $perpage);
  5793. $over = $total - ($start + $perpage);
  5794. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5795. echo json_encode($rows);
  5796. exit;
  5797. }
  5798. if (isset($post['tmsku'])) {
  5799. $time = time();
  5800. $tmsku = $this->input->post('tmsku', true);
  5801. //$post['shop'] = $this->input->post('shop',true);
  5802. $num = $this->input->post('num', true);
  5803. $rktype = $this->input->post('rktype', true);
  5804. if ($num > 200) {
  5805. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  5806. exit;
  5807. }
  5808. if (!$rktype) {
  5809. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  5810. }
  5811. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  5812. /**
  5813. $wz = array();
  5814. foreach ($rk as $key=>$value)
  5815. {
  5816. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  5817. }
  5818. if(count($wz) > 1)
  5819. {
  5820. $wz = array_values($wz);
  5821. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  5822. }
  5823. **/
  5824. if (isset($rk[0]['purchase'])) {
  5825. $rk = $rk[0];
  5826. $j = 0;
  5827. $post['purchase'] = $rk['purchase'];
  5828. $post['warehouse'] = $rk['warehouse'];
  5829. $post['retreatwarehouse'] = $rk['warehouse'];
  5830. $post['sku'] = $rk['sku'];
  5831. $post['number'] = $rk['number'];
  5832. $post['features'] = $rk['features'];
  5833. $post['title'] = $rk['title'];
  5834. $post['enter'] = $time;
  5835. $post['time'] = $time;
  5836. $post['bs'] = 1;
  5837. $post['shop'] = $rk['shop'];
  5838. $post['details'] = $rk['details'];
  5839. $post['cpid'] = $rk['cpid'];
  5840. $post['cpbz'] = $rk['cpbz'];
  5841. //$post['rktype'] = $rktype;
  5842. $warehouse = $this->warehouse->read($rk['warehouse']);
  5843. if ($warehouse['bdck'] == '') {
  5844. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  5845. exit;
  5846. } else {
  5847. $bdck = $warehouse['bdck'];
  5848. }
  5849. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  5850. if (isset($pdwz['details'])) {
  5851. if ($pdwz['details'] != $post['details']) {
  5852. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  5853. exit;
  5854. }
  5855. }
  5856. $post['featurespp'] = $rk['featurespp'];
  5857. if ($post['warehouse'] == '5') {
  5858. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5859. if ($yza) {
  5860. if ($post['features'] != $yza[0]['features']) {
  5861. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  5862. exit;
  5863. }
  5864. }
  5865. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  5866. if ($yzb) {
  5867. if ($post['sku'] != $yzb[0]['sku']) {
  5868. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  5869. exit;
  5870. }
  5871. }
  5872. }
  5873. for ($i = 0; $i < $num; $i++) {
  5874. $post['label'] = time() . rand(100, 999) . $i;
  5875. if ($this->$bdck->insert($post)) {
  5876. $j++;
  5877. }
  5878. }
  5879. /**
  5880. if($post['warehouse'] != 12)
  5881. {
  5882. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5883. }
  5884. **/
  5885. if ($j == $num) {
  5886. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  5887. exit;
  5888. } else {
  5889. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  5890. exit;
  5891. }
  5892. } else {
  5893. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5894. exit;
  5895. }
  5896. }
  5897. $this->_Template('whlabel_printrk', $this->data);
  5898. }
  5899. public function _printxzrk($arg_array)
  5900. {
  5901. $post = $this->input->post(NULL, TRUE);
  5902. if (isset($post['wzid'])) {
  5903. $time = time();
  5904. $id = $this->input->post('wzid', true);
  5905. //$post['shop'] = $this->input->post('shop',true);
  5906. $num = 1;
  5907. $rk = $this->whlabellabel->read($id);
  5908. if (isset($rk['purchase'])) {
  5909. $x = 0;
  5910. $post['purchase'] = $rk['purchase'];
  5911. $post['warehouse'] = $rk['warehouse'];
  5912. $post['retreatwarehouse'] = $rk['warehouse'];
  5913. $post['sku'] = $rk['sku'];
  5914. $post['number'] = $rk['number'];
  5915. $post['features'] = $rk['features'];
  5916. $post['title'] = $rk['title'];
  5917. $post['enter'] = $time;
  5918. $post['time'] = $time;
  5919. $post['bs'] = 1;
  5920. $post['shop'] = $rk['shop'];
  5921. $post['details'] = $rk['details'];
  5922. $post['cpid'] = $rk['cpid'];
  5923. $post['cpbz'] = $rk['cpbz'];
  5924. $warehouse = $this->warehouse->read($rk['warehouse']);
  5925. if ($warehouse['bdck'] == '') {
  5926. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  5927. exit;
  5928. } else {
  5929. $bdck = $warehouse['bdck'];
  5930. }
  5931. $post['featurespp'] = $rk['featurespp'];
  5932. $this->db->trans_begin();
  5933. for ($i = 0; $i < $num; $i++) {
  5934. $post['label'] = time() . rand(100, 999) . $i;
  5935. $this->$bdck->insert($post);
  5936. }
  5937. /**
  5938. if($post['warehouse'] != 12)
  5939. {
  5940. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  5941. }
  5942. **/
  5943. if ($this->db->trans_status() === TRUE) {
  5944. $this->db->trans_commit();
  5945. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  5946. exit;
  5947. } else {
  5948. $this->db->trans_rollback();
  5949. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  5950. exit;
  5951. }
  5952. } else {
  5953. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  5954. exit;
  5955. }
  5956. }
  5957. }
  5958. public function _printck($arg_array)
  5959. {
  5960. $prc = array();
  5961. $purchase = $this->purchase->find_all();
  5962. foreach ($purchase as $k => $v) {
  5963. $prc[$v['id']] = $v['title'];
  5964. }
  5965. $post = $this->input->post(NULL, TRUE);
  5966. if (isset($post['page'])) {
  5967. $page = $this->input->post('page', true);
  5968. $perpage = $this->input->post('perpage', true);
  5969. $sku = $this->input->post('sku', true);
  5970. $bs = $this->input->post('bs', true);
  5971. $number = $this->input->post('number', true);
  5972. $warehouse = $this->input->post('warehouse', true);
  5973. $purchase = $this->input->post('purchase', true);
  5974. $orderinfo = $this->input->post('orderinfo', true);
  5975. $waybill = $this->input->post('waybill', true);
  5976. $category = $this->input->post('category', true);
  5977. $size = $this->input->post('size', true);
  5978. $grade = $this->input->post('grade', true);
  5979. $color = $this->input->post('color', true);
  5980. $lowe = $this->input->post('lowe', true);
  5981. $state = $this->input->post('state', true);
  5982. $label = $this->input->post('label', true);
  5983. $timetk = $this->input->post('ktime', true);
  5984. $timetj = $this->input->post('jtime', true);
  5985. $timetk = strtotime($timetk);
  5986. $timetj = strtotime($timetj);
  5987. $where = "state=1 ";
  5988. if ($timetk && $timetj) {
  5989. $where .= " and outk > '$timetk' and outk < '$timetj'";
  5990. }
  5991. if ($sku) {
  5992. $where .= " and sku = '$sku'";
  5993. }
  5994. if ($bs != '') {
  5995. $where .= " and bs = '$bs'";
  5996. }
  5997. if ($number) {
  5998. $where .= " and number = '$number'";
  5999. }
  6000. if ($warehouse) {
  6001. $where .= " and warehouse = '$warehouse'";
  6002. }
  6003. if ($purchase) {
  6004. $where .= " and purchase = '$purchase'";
  6005. }
  6006. if ($orderinfo) {
  6007. $where .= " and orderinfo = '$orderinfo'";
  6008. }
  6009. if ($waybill) {
  6010. $where .= " and waybill = '$waybill'";
  6011. }
  6012. if ($category) {
  6013. $where .= " and features like '%-$category-%'";
  6014. }
  6015. if ($size) {
  6016. $where .= " and features like '%-$size-%'";
  6017. }
  6018. if ($grade) {
  6019. $where .= " and features like '%-$grade-%'";
  6020. }
  6021. if ($color) {
  6022. $where .= " and features like '%-$color-%'";
  6023. }
  6024. if ($lowe) {
  6025. $where .= " and features like '%-$lowe-%'";
  6026. }
  6027. if ($label) {
  6028. $where .= " and label = '$label'";
  6029. }
  6030. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6031. //数据排序
  6032. $order_str = "outk desc";
  6033. if (empty($page)) {
  6034. $start = 0;
  6035. $perpage = 1;
  6036. } else {
  6037. $start = ($page - 1) * $perpage;
  6038. }
  6039. //取得信息列表
  6040. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6041. foreach ($info_list as $key => $value) {
  6042. $warehouse = $this->warehouse->read($value['warehouse']);
  6043. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6044. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6045. if ($value['state'] == 0) {
  6046. $info_list[$key]['state'] = "在库";
  6047. } else if ($value['state'] == 1) {
  6048. $info_list[$key]['state'] = "出库";
  6049. } else if ($value['state'] == 2) {
  6050. $info_list[$key]['state'] = "退库";
  6051. } else if ($value['state'] == 3) {
  6052. $info_list[$key]['state'] = "调拨中";
  6053. } else if ($value['state'] == 4) {
  6054. $info_list[$key]['state'] = "再加工";
  6055. } else if ($value['state'] == 5) {
  6056. $info_list[$key]['state'] = "维修中";
  6057. } else if ($value['state'] == 6) {
  6058. $info_list[$key]['state'] = "盘亏";
  6059. } else if ($value['state'] == 7) {
  6060. $info_list[$key]['state'] = "更换标签";
  6061. } else if ($value['state'] == 8) {
  6062. $info_list[$key]['state'] = "其它";
  6063. } else if ($value['state'] == 9) {
  6064. $info_list[$key]['state'] = "预设";
  6065. } else if ($value['state'] == 10) {
  6066. $info_list[$key]['state'] = "美店零售";
  6067. }
  6068. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6069. }
  6070. $total = $this->$ck->find_count($where);
  6071. $pagenum = ceil($total / $perpage);
  6072. $over = $total - ($start + $perpage);
  6073. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6074. echo json_encode($rows);
  6075. exit;
  6076. }
  6077. if (isset($post['tmsku'])) {
  6078. $time = time();
  6079. $tmsku = $this->input->post('tmsku', true);
  6080. //$post['shop'] = $this->input->post('shop',true);
  6081. $num = $this->input->post('num', true);
  6082. $cktype = $this->input->post('cktype', true);
  6083. $label = $this->whlabellabel->get_label($tmsku);
  6084. if (!$cktype) {
  6085. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6086. }
  6087. if (!isset($label['warehouse'])) {
  6088. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6089. exit;
  6090. }
  6091. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6092. if (stripos($label['features'], '-126-') !== false) {
  6093. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and zd = ''");
  6094. } else {
  6095. $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 = ''");
  6096. }
  6097. $j = 0;
  6098. if (count($ck) >= $num) {
  6099. for ($i = 0; $i < $num; $i++) {
  6100. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6101. {
  6102. $j++;
  6103. }
  6104. }
  6105. if ($j == $num) {
  6106. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6107. exit;
  6108. } else {
  6109. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6110. exit;
  6111. }
  6112. } else {
  6113. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6114. exit;
  6115. }
  6116. }
  6117. $this->_Template('whlabel_printck', $this->data);
  6118. }
  6119. public function _printexcel()
  6120. {
  6121. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6122. $config['upload_path'] = '.' . $dir;
  6123. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6124. $config['allowed_types'] = 'xls|xlsx|csv';
  6125. $config['max_size'] = 10240;
  6126. $this->load->library('upload', $config);
  6127. $this->upload->initialize($config);
  6128. if ($this->upload->do_upload('userfile')) {
  6129. $full_path = $dir . $this->upload->data('file_name');
  6130. $fileName = '.' . $full_path;
  6131. if (!file_exists($fileName)) {
  6132. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6133. exit;
  6134. } else {
  6135. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6136. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6137. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6138. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6139. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6140. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6141. ++$column; //如果列数大于26行
  6142. $list = array();
  6143. for ($i = 2; $i <= $row; $i++) // 行数循环
  6144. {
  6145. $data = array();
  6146. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6147. {
  6148. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6149. }
  6150. $list[] = $data;
  6151. }
  6152. }
  6153. $ed = array();
  6154. $i = 0;
  6155. $j = 0;
  6156. $dcdata = array();
  6157. $yc = '';
  6158. $cmf_arr = array_column($list, '1');
  6159. array_multisort($cmf_arr, SORT_ASC, $list);
  6160. foreach ($list as $key => $value) {
  6161. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6162. if ($typeclass) {
  6163. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6164. } else {
  6165. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6166. $i++;
  6167. continue;
  6168. }
  6169. }
  6170. if ($i > 0) {
  6171. $yc = $i . '条异常';
  6172. }
  6173. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6174. exit;
  6175. }
  6176. }
  6177. public function _uck()
  6178. {
  6179. if (isset($_GET['excel'])) {
  6180. $tc = array();
  6181. $typeclass = $this->typeclass->find_all();
  6182. foreach ($typeclass as $v) {
  6183. $tc[$v['id']] = $v['zh'];
  6184. }
  6185. $data = array();
  6186. $t = array();
  6187. $rq = '';
  6188. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6189. $ts = $ts / (24 * 3600);
  6190. for ($i = 0; $i < $ts; $i++) {
  6191. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6192. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6193. }
  6194. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  6195. foreach ($info_list as $k => $v) {
  6196. $features = explode('-', trim($v['features'], '-'));
  6197. if (!isset($features[3]) || !isset($features[4])) {
  6198. continue;
  6199. }
  6200. $data[$k][0] = $tc[$features[0]]; //类型
  6201. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  6202. $data[$k][2] = $tc[$features[4]]; //曲度
  6203. $data[$k][3] = '';
  6204. if (isset($data[$k][1])) {
  6205. $data[$k][3] .= $data[$k][1];
  6206. }
  6207. if (isset($data[$k][2])) {
  6208. $data[$k][3] .= $data[$k][2];
  6209. }
  6210. if (isset($features[5])) {
  6211. $data[$k][3] .= $tc[$features[5]];
  6212. }
  6213. if (isset($features[2])) {
  6214. $data[$k][3] .= $tc[$features[2]];
  6215. }
  6216. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  6217. $data[$k][4] = $v['sku'];
  6218. $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())) . '))'); //月初库存
  6219. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  6220. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  6221. $ztrq = '';
  6222. $ztsl = '';
  6223. if (count($zt) > 0) {
  6224. foreach ($zt as $vv) {
  6225. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  6226. $ztsl .= $vv['num'] . '<br>';
  6227. }
  6228. }
  6229. $data[$k][] = trim($ztsl, '<br>');
  6230. $data[$k][] = trim($ztrq, '<br>');
  6231. $byck = 0;
  6232. foreach ($t as $vv) {
  6233. $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));
  6234. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  6235. $byck += $sl;
  6236. }
  6237. $data[$k][] = ($byck > 0) ? $byck : '';
  6238. }
  6239. $title = "详情 " . date("Y-m-d", time());
  6240. $titlename = "<table border=1>
  6241. <tr align='center'>
  6242. <td>类别</td>
  6243. <td>颜色</td>
  6244. <td>曲度</td>
  6245. <td>名称</td>
  6246. <td>SKU</td>
  6247. <td>月初库存</td>
  6248. <td>剩余库存</td>
  6249. <td>在途数量</td>
  6250. <td>预达日期</td>" .
  6251. $rq
  6252. . "<td>本月出库</td></tr>
  6253. </table>";
  6254. $filename = $title . ".xls";
  6255. $tail = "";
  6256. $this->excel->get_fz2($data, $titlename, $filename, $tail);
  6257. }
  6258. }
  6259. public function _whlabelexcelzh()
  6260. {
  6261. if (isset($_GET['excel'])) {
  6262. $where = "sku != 'Preset'";
  6263. //数据排序
  6264. $order_str = "id desc";
  6265. if (empty($page)) {
  6266. $start = 0;
  6267. $perpage = 1;
  6268. } else {
  6269. $start = ($page - 1) * $perpage;
  6270. }
  6271. $category = $this->input->get('category', true);
  6272. $warehouse = $this->input->get('warehouse', true);
  6273. $excelid = $this->input->get('sid', true);
  6274. if ($category) {
  6275. $where .= " and features like '%-$category-%'";
  6276. }
  6277. if ($warehouse) {
  6278. $where .= " and warehouse = '$warehouse'";
  6279. }
  6280. $xzid = '';
  6281. if ($excelid) {
  6282. $excelid = explode(',', trim($excelid, ','));
  6283. foreach ($excelid as $key => $value) {
  6284. $xzid .= " id = " . $value . " or";
  6285. }
  6286. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  6287. }
  6288. //取得信息列表
  6289. /**
  6290. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  6291. $rows = array();$list = array();
  6292. foreach ($info_list as $key=>$value)
  6293. {
  6294. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  6295. }
  6296. **/
  6297. $list = array();
  6298. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  6299. foreach ($rows as $key => $value) {
  6300. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  6301. $zh = '';
  6302. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  6303. foreach ($zt as $v) {
  6304. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  6305. }
  6306. $zt = array_sum(array_column($zt, 'num'));
  6307. $number = $value['number'];
  6308. $ftime = time() - 15 * 24 * 3600;
  6309. $warehouse = $this->warehouse->read($value['warehouse']);
  6310. $rows[$key]['warehouse'] = $warehouse['title'];
  6311. $rows[$key]['number'] = $c;
  6312. $rows[$key]['features'] = $zh;
  6313. $rows[$key]['hb'] = $c + $zt;
  6314. }
  6315. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  6316. $titlename = "<table border=1>
  6317. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  6318. <tr align='center'>
  6319. <td>仓库</td>
  6320. <td>SKU</td>
  6321. <td>产品</td>
  6322. <td>库存数量</td>
  6323. <td>在途数量及预达日期</td>
  6324. <td>在途+库存数量</td>
  6325. </tr>
  6326. </table>";
  6327. $filename = $title . ".xls";
  6328. $tail = "";
  6329. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6330. }
  6331. if (isset($_GET['excel'])) {
  6332. $warehouse = $this->input->get('warehouse', true);
  6333. $sku = $this->input->get('sku', true);
  6334. $cz = $this->input->get('cz', true);
  6335. $text = $this->input->post('text', true);
  6336. $xztime = $this->input->get('xztime', true);
  6337. $timetk = $this->input->get('timetk', true);
  6338. $timetj = $this->input->get('timetj', true);
  6339. $timetk = strtotime($timetk);
  6340. $timetj = strtotime($timetj);
  6341. $where = "time = '0' ";
  6342. if ($warehouse) {
  6343. $where .= " and warehouse = '$warehouse'";
  6344. }
  6345. if ($sku) {
  6346. $where .= " and sku = '$sku'";
  6347. }
  6348. if ($text) {
  6349. $where .= " and text like '%$text%'";
  6350. }
  6351. if ($cz != '') {
  6352. $where .= " and cz = '$cz'";
  6353. }
  6354. if ($timetk && $timetj) {
  6355. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  6356. }
  6357. //数据排序
  6358. $order_str = $xztime . " desc";
  6359. //取得信息列表
  6360. $zh = array();
  6361. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  6362. foreach ($info_list as $v) {
  6363. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  6364. $warehouse = $this->warehouse->read($v['warehouse']);
  6365. $v['warehouse'] = $warehouse['title'];
  6366. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  6367. $v['stime'] = date('Y-m-d', $v['stime']);
  6368. if (isset($zh[$v['features']])) {
  6369. $zh[$v['features']]['num'] += $v['num'];
  6370. } else {
  6371. $zh[$v['features']] = $v;
  6372. }
  6373. $zh[$v['features']]['features'] = $c;
  6374. }
  6375. $title = "在途数据" . date('Y-m-d', time());
  6376. $titlename = "<table border=1>
  6377. <tr align='center'>
  6378. <td>仓库</td>
  6379. <td>SKU</td>
  6380. <td>名称</td>
  6381. <td>在途数量</td>
  6382. <td>库存数量</td>
  6383. <td>添加在途日期</td>
  6384. <td>预达日期</td>
  6385. <td>备注</td>
  6386. </tr>
  6387. </table>";
  6388. $filename = $title . ".xls";
  6389. $tail = "";
  6390. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  6391. }
  6392. }
  6393. public function _fc()
  6394. {
  6395. $vip = 0;
  6396. if (isset($_SESSION['api'])) {
  6397. $user = $this->user->get_api($_SESSION['api']);
  6398. if ($user['vip'] == 1) {
  6399. $vip = 1;
  6400. }
  6401. } else {
  6402. header('Location: /');
  6403. exit;
  6404. }
  6405. $post = $this->input->post(NULL, TRUE);
  6406. if (isset($post['page'])) {
  6407. $page = $this->input->post('page', true);
  6408. $perpage = $this->input->post('perpage', true);
  6409. $category = $this->input->post('category', true);
  6410. $size = $this->input->post('size', true);
  6411. $grade = $this->input->post('grade', true);
  6412. $color = $this->input->post('color', true);
  6413. $lowe = $this->input->post('lowe', true);
  6414. $sku = $this->input->post('sku');
  6415. $title = $this->input->post('title');
  6416. $warehouse = $this->input->post('warehouse', true);
  6417. $usa = $this->input->post('usa', true);
  6418. $purchase = $this->input->post('purchase', true);
  6419. $lacetype = $this->input->post('lacetype', true);
  6420. $haircap = $this->input->post('haircap', true);
  6421. $density = $this->input->post('density', true);
  6422. $details = $this->input->post('details', true);
  6423. $state = $this->input->post('state', true);
  6424. $ktime = $this->input->post('ktime', true);
  6425. $jtime = $this->input->post('jtime', true);
  6426. $ktime = strtotime($ktime);
  6427. $jtime = strtotime($jtime);
  6428. $where = "state = '11'";
  6429. $gj = "";
  6430. $ck = "";
  6431. if ($lacetype) {
  6432. $where .= " and features like '%-$lacetype-%'";
  6433. }
  6434. if ($category) {
  6435. $where .= " and features like '%-$category-%'";
  6436. }
  6437. if ($size) {
  6438. $where .= " and features like '%-$size-%'";
  6439. }
  6440. if ($grade) {
  6441. $where .= " and features like '%-$grade-%'";
  6442. }
  6443. if ($color) {
  6444. $where .= " and features like '%-$color-%'";
  6445. }
  6446. if ($lowe) {
  6447. $where .= " and features like '%-$lowe-%'";
  6448. }
  6449. if ($haircap) {
  6450. $where .= " and features like '%-$haircap-%'";
  6451. }
  6452. if ($density) {
  6453. $where .= " and features like '%-$density-%'";
  6454. }
  6455. if ($usa) {
  6456. if (!$warehouse) {
  6457. $where .= " and (warehouse = '5' or warehouse = '8')";
  6458. }
  6459. }
  6460. if ($warehouse) {
  6461. $where .= " and warehouse = '$warehouse'";
  6462. }
  6463. if ($details) {
  6464. $where .= " and details = '$details'";
  6465. }
  6466. if ($purchase) {
  6467. $where .= " and purchase = '$purchase'";
  6468. }
  6469. if ($state) {
  6470. $where .= " and state = '$state'";
  6471. }
  6472. if ($ktime && $jtime) {
  6473. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6474. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6475. }
  6476. //数据排序
  6477. $order_str = "id desc";
  6478. if (empty($page)) {
  6479. $start = 0;
  6480. $perpage = 1;
  6481. } else {
  6482. $start = ($page - 1) * $perpage;
  6483. }
  6484. if ($sku) {
  6485. $sku = trim($sku, ' ');
  6486. $sku = trim($sku, ' ');
  6487. $where .= " and sku like '%$sku%'";
  6488. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6489. } else if ($title) {
  6490. $title = trim($title, ' ');
  6491. $title = trim($title, ' ');
  6492. $where .= " and title like '%$title%'";
  6493. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6494. } else {
  6495. //$where .= " and time > '$ktime' and time < '$jtime'";
  6496. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  6497. }
  6498. //取得信息列表
  6499. $rows = array();
  6500. $list = array();
  6501. foreach ($info_list as $key => $value) {
  6502. $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'] . '"');
  6503. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6504. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6505. $warehouse = $this->warehouse->read($value['warehouse']);
  6506. $info_list[$key]['warehouse'] = $warehouse['title'];
  6507. $info_list[$key]['number'] = $g;
  6508. $info_list[$key]['features'] = $x;
  6509. $info_list[$key]['x'] = $s;
  6510. }
  6511. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  6512. $pagenum = ceil($total / $perpage);
  6513. $over = $total - ($start + $perpage);
  6514. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6515. echo json_encode($rows);
  6516. exit;
  6517. }
  6518. $this->data['vip'] = $vip;
  6519. $this->_Template('whlabel_fc', $this->data);
  6520. }
  6521. public function _fcmb()
  6522. {
  6523. $where = "sku != 'Preset'";
  6524. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  6525. foreach ($rows as $k => $v) {
  6526. $warehouse = $this->warehouse->read($v['warehouse']);
  6527. $rows[$k]['warehouse'] = $warehouse['title'];
  6528. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  6529. $rows[$k]['t'] = '';
  6530. $rows[$k]['n'] = '';
  6531. }
  6532. $title = "封货产品数据导入模板";
  6533. $titlename = "<table border=1>
  6534. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6535. <tr align='center'>
  6536. <td>仓库</td>
  6537. <td>SKU</td>
  6538. <td>产品</td>
  6539. <td>封存产品总数量</td>
  6540. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  6541. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  6542. </tr>
  6543. </table>";
  6544. $filename = $title . ".xls";
  6545. $tail = "";
  6546. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6547. }
  6548. public function _fcexcel()
  6549. {
  6550. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6551. $config['upload_path'] = '.' . $dir;
  6552. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6553. $config['allowed_types'] = 'xls|xlsx|csv';
  6554. $config['max_size'] = 10240;
  6555. $this->load->library('upload', $config);
  6556. $this->upload->initialize($config);
  6557. if ($this->upload->do_upload('userfile')) {
  6558. $full_path = $dir . $this->upload->data('file_name');
  6559. $fileName = '.' . $full_path;
  6560. if (!file_exists($fileName)) {
  6561. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6562. exit;
  6563. } else {
  6564. libxml_use_internal_errors(true);
  6565. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6566. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6567. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6568. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6569. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6570. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6571. ++$column; //如果列数大于26行
  6572. $list = array();
  6573. for ($i = 2; $i <= $row; $i++) // 行数循环
  6574. {
  6575. $data = array();
  6576. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6577. {
  6578. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6579. }
  6580. $list[] = $data;
  6581. }
  6582. }
  6583. $i = 0;
  6584. $j = 0;
  6585. $ed = array();
  6586. foreach ($list as $key => $value) {
  6587. $time = time();
  6588. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  6589. continue;
  6590. }
  6591. $warehouse = $this->warehouse->get_title($value['0']);
  6592. $sku = $value['1'];
  6593. $type = $value['4']; //调整方式0扣减1删除
  6594. $num = $value['5']; //调整数量
  6595. //$text = $value['4'];//扣减说明
  6596. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6597. if (!$d) //如果没有这个SKU
  6598. {
  6599. $ed[] = array($sku . '-库存中不存在此SKU');
  6600. $j++;
  6601. continue;
  6602. }
  6603. if (!isset($warehouse['id'])) {
  6604. $ed[] = array($sku . '-仓库名错误!');
  6605. $j++;
  6606. continue;
  6607. }
  6608. if ($type == 1 || $type == 2) //扣减库存
  6609. {
  6610. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  6611. if (count($data) < abs($num)) {
  6612. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  6613. $j++;
  6614. continue;
  6615. }
  6616. if ($type == 1) //转入库存
  6617. {
  6618. for ($i = 0; $i < abs($num); $i++) {
  6619. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  6620. }
  6621. } else if ($type == 2) //删除
  6622. {
  6623. for ($i = 0; $i < abs($num); $i++) {
  6624. $this->whlabel->remove($data[$i]['id']);
  6625. }
  6626. }
  6627. } else if ($type == 0) //增加库存
  6628. {
  6629. $post['sku'] = $d['sku'];
  6630. $post['shop'] = '';
  6631. $post['warehouse'] = $warehouse['id'];
  6632. $post['purchase'] = $d['purchase'];
  6633. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  6634. $post['state'] = 11;
  6635. $post['title'] = $d['title'];
  6636. $post['number'] = $d['number'];
  6637. $post['features'] = $d['features'];
  6638. $post['enter'] = $time;
  6639. $post['time'] = $time; //操作时间
  6640. for ($i = 0; $i < $num; $i++) {
  6641. $post['label'] = time() . rand(100, 999) . $i;
  6642. $this->whlabel->insert($post);
  6643. }
  6644. }
  6645. sleep(1); //防止入库时间一样,需要延迟1秒
  6646. }
  6647. if ($j > 0) {
  6648. $tt = date('Ymd', time());
  6649. $title = '库存导入错误信息-' . $tt;
  6650. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  6651. $tail = "\n";
  6652. $filename = $title . ".xls";
  6653. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  6654. $dir = '/data/excel/' . $time . '/';
  6655. $file_name = 'error_' . $time . rand(1000, 9999);
  6656. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  6657. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  6658. fwrite($myfile, $ecl);
  6659. fclose($myfile);
  6660. $error = $dir . $file_name . '.xls';
  6661. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  6662. exit;
  6663. } else {
  6664. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  6665. exit;
  6666. }
  6667. }
  6668. }
  6669. public function _fcjxc($arg_array)
  6670. {
  6671. if (isset($_GET['excel'])) {
  6672. $category = $this->input->get('category', true);
  6673. $size = $this->input->get('size', true);
  6674. $grade = $this->input->get('grade', true);
  6675. $color = $this->input->get('color', true);
  6676. $lowe = $this->input->get('lowe', true);
  6677. $sku = $this->input->get('sku');
  6678. $title = $this->input->get('title');
  6679. $warehouse = $arg_array[0];
  6680. $usa = $this->input->get('usa', true);
  6681. $purchase = $this->input->get('purchase', true);
  6682. $lacetype = $this->input->get('lacetype', true);
  6683. $haircap = $this->input->get('haircap', true);
  6684. $density = $this->input->get('density', true);
  6685. $title = $this->input->get('title', true);
  6686. $state = $this->input->get('state', true);
  6687. $ktime = $this->input->get('ktime', true);
  6688. $jtime = $this->input->get('jtime', true);
  6689. $where = "state=11";
  6690. $gj = "";
  6691. $ck = "";
  6692. if ($lacetype) {
  6693. $where .= " and features like '%-$lacetype-%'";
  6694. }
  6695. if ($category) {
  6696. $where .= " and features like '%-$category-%'";
  6697. }
  6698. if ($size) {
  6699. $where .= " and features like '%-$size-%'";
  6700. }
  6701. if ($grade) {
  6702. $where .= " and features like '%-$grade-%'";
  6703. }
  6704. if ($color) {
  6705. $where .= " and features like '%-$color-%'";
  6706. }
  6707. if ($lowe) {
  6708. $where .= " and features like '%-$lowe-%'";
  6709. }
  6710. if ($haircap) {
  6711. $where .= " and features like '%-$haircap-%'";
  6712. }
  6713. if ($density) {
  6714. $where .= " and features like '%-$density-%'";
  6715. }
  6716. if ($usa) {
  6717. if (!$warehouse) {
  6718. $where .= " and (warehouse = '5' or warehouse = '8')";
  6719. }
  6720. }
  6721. if ($warehouse) {
  6722. $where .= " and warehouse = '$warehouse'";
  6723. }
  6724. if ($purchase) {
  6725. $where .= " and purchase = '$purchase'";
  6726. }
  6727. if ($state) {
  6728. $where .= " and state = '$state'";
  6729. }
  6730. $order_str = "id desc";
  6731. if ($sku) {
  6732. $sku = trim($sku, ' ');
  6733. $sku = trim($sku, ' ');
  6734. $where .= " and sku like '%$sku%'";
  6735. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6736. } else if ($title) {
  6737. $title = trim($title, ' ');
  6738. $title = trim($title, ' ');
  6739. $where .= " and title like '%$title%'";
  6740. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6741. } else {
  6742. //$where .= " and time > '$ktime' and time < '$jtime'";
  6743. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  6744. }
  6745. //取得信息列表
  6746. $rows = array();
  6747. $list = array();
  6748. foreach ($info_list as $key => $value) {
  6749. $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'] . '"');
  6750. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6751. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6752. $rows[$key] = $value;
  6753. $warehouse = $this->warehouse->read($value['warehouse']);
  6754. $rows[$key]['warehouse'] = $warehouse['title'];
  6755. $rows[$key]['features'] = $g;
  6756. $rows[$key]['a'] = $x;
  6757. $rows[$key]['b'] = $s;
  6758. }
  6759. $title = "总统计表";
  6760. $titlename = "<table border=1>
  6761. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  6762. <tr align='center'>
  6763. <td>仓库</td>
  6764. <td>SKU</td>
  6765. <td>产品名称</td>
  6766. <td>录入总量</td>
  6767. <td>取出总量</td>
  6768. <td>剩余总量</td>
  6769. </tr>
  6770. </table>";
  6771. $filename = $title . ".xls";
  6772. $tail = "";
  6773. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  6774. }
  6775. $vip = 0;
  6776. if (isset($_SESSION['api'])) {
  6777. $user = $this->user->get_api($_SESSION['api']);
  6778. if ($user['vip'] == 1) {
  6779. $vip = 1;
  6780. }
  6781. } else {
  6782. header('Location: /');
  6783. exit;
  6784. }
  6785. $post = $this->input->post(NULL, TRUE);
  6786. if (isset($post['page'])) {
  6787. $page = $this->input->post('page', true);
  6788. $perpage = $this->input->post('perpage', true);
  6789. $category = $this->input->post('category', true);
  6790. $size = $this->input->post('size', true);
  6791. $grade = $this->input->post('grade', true);
  6792. $color = $this->input->post('color', true);
  6793. $lowe = $this->input->post('lowe', true);
  6794. $sku = $this->input->post('sku');
  6795. $title = $this->input->post('title');
  6796. $warehouse = $arg_array[0];
  6797. $usa = $this->input->post('usa', true);
  6798. $purchase = $this->input->post('purchase', true);
  6799. $lacetype = $this->input->post('lacetype', true);
  6800. $haircap = $this->input->post('haircap', true);
  6801. $density = $this->input->post('density', true);
  6802. $title = $this->input->post('title', true);
  6803. $state = $this->input->post('state', true);
  6804. $ktime = $this->input->post('ktime', true);
  6805. $jtime = $this->input->post('jtime', true);
  6806. $ktime = strtotime($ktime);
  6807. $jtime = strtotime($jtime);
  6808. $where = "state=11";
  6809. $gj = "";
  6810. $ck = "";
  6811. if ($lacetype) {
  6812. $where .= " and features like '%-$lacetype-%'";
  6813. }
  6814. if ($category) {
  6815. $where .= " and features like '%-$category-%'";
  6816. }
  6817. if ($size) {
  6818. $where .= " and features like '%-$size-%'";
  6819. }
  6820. if ($grade) {
  6821. $where .= " and features like '%-$grade-%'";
  6822. }
  6823. if ($color) {
  6824. $where .= " and features like '%-$color-%'";
  6825. }
  6826. if ($lowe) {
  6827. $where .= " and features like '%-$lowe-%'";
  6828. }
  6829. if ($haircap) {
  6830. $where .= " and features like '%-$haircap-%'";
  6831. }
  6832. if ($density) {
  6833. $where .= " and features like '%-$density-%'";
  6834. }
  6835. if ($usa) {
  6836. if (!$warehouse) {
  6837. $where .= " and (warehouse = '5' or warehouse = '8')";
  6838. }
  6839. }
  6840. if ($warehouse) {
  6841. $where .= " and warehouse = '$warehouse'";
  6842. }
  6843. if ($purchase) {
  6844. $where .= " and purchase = '$purchase'";
  6845. }
  6846. if ($state) {
  6847. $where .= " and state = '$state'";
  6848. }
  6849. if ($ktime && $jtime) {
  6850. $gj = " and enter > '$ktime' and enter < '$jtime'";
  6851. $ck = " and outk > '$ktime' and outk < '$jtime'";
  6852. }
  6853. //数据排序
  6854. $order_str = "id desc";
  6855. $xs = 0;
  6856. $rows = array();
  6857. $list = array();
  6858. if (empty($page)) {
  6859. $start = 0;
  6860. $perpage = 1;
  6861. } else {
  6862. $start = ($page - 1) * $perpage;
  6863. }
  6864. if ($sku || $title) {
  6865. if ($title) {
  6866. $title = trim($title, ' ');
  6867. $title = trim($title, ' ');
  6868. $where .= " and title like '%$title%'";
  6869. } else {
  6870. $sku = trim($sku, ' ');
  6871. $sku = trim($sku, ' ');
  6872. $where .= " and sku like '%$sku%'";
  6873. }
  6874. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6875. foreach ($info_list as $key => $value) {
  6876. $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'] . '"');
  6877. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6878. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6879. $rows[$key] = $value;
  6880. $warehouse = $this->warehouse->read($value['warehouse']);
  6881. $rows[$key]['warehouse'] = $warehouse['title'];
  6882. $rows[$key]['features'] = $g;
  6883. $rows[$key]['a'] = $x;
  6884. $rows[$key]['b'] = $s;
  6885. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6886. $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天销量
  6887. $yj = $c / ($xl / 30);
  6888. if ($yj < 7) {
  6889. $rows[$key]['y'] = round($yj) . '天销量';
  6890. } else {
  6891. $rows[$key]['y'] = '正常';
  6892. }
  6893. }
  6894. } else {
  6895. //$where .= " and time > '$ktime' and time < '$jtime'";
  6896. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  6897. foreach ($info_list as $key => $value) {
  6898. $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'] . '"');
  6899. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  6900. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  6901. $zs[$key] = $value;
  6902. $warehouse = $this->warehouse->read($value['warehouse']);
  6903. $zs[$key]['warehouse'] = $warehouse['title'];
  6904. $zs[$key]['features'] = $g;
  6905. $zs[$key]['a'] = $x;
  6906. $zs[$key]['b'] = $s;
  6907. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  6908. $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天销量
  6909. $yj = $c / ($xl / 30);
  6910. if ($yj < 7) {
  6911. $zs[$key]['y'] = round($yj) . '天销量';
  6912. $rows[$key] = $zs[$key];
  6913. }
  6914. }
  6915. }
  6916. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  6917. $pagenum = ceil($total / $perpage);
  6918. $over = $total - ($start + $perpage);
  6919. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  6920. echo json_encode($rows);
  6921. exit;
  6922. }
  6923. $this->data['arg_array'] = $arg_array[0];
  6924. $this->_Template('whlabel_fcjxc', $this->data);
  6925. }
  6926. public function _0kcdel()
  6927. {
  6928. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6929. $config['upload_path'] = '.' . $dir;
  6930. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6931. $config['allowed_types'] = 'xls|xlsx|csv';
  6932. $config['max_size'] = 10240;
  6933. $this->load->library('upload', $config);
  6934. $this->upload->initialize($config);
  6935. if ($this->upload->do_upload('userfile')) {
  6936. $full_path = $dir . $this->upload->data('file_name');
  6937. $fileName = '.' . $full_path;
  6938. if (!file_exists($fileName)) {
  6939. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6940. exit;
  6941. } else {
  6942. require_once "./data/excel/PHPExcel/IOFactory.php";
  6943. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6944. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6945. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6946. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6947. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6948. ++$column; //如果列数大于26行
  6949. $list = array();
  6950. for ($i = 2; $i <= $row; $i++) // 行数循环
  6951. {
  6952. $data = array();
  6953. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6954. {
  6955. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6956. }
  6957. $list[] = $data;
  6958. }
  6959. }
  6960. $i = 0;
  6961. $j = 0;
  6962. $ed = array();
  6963. foreach ($list as $key => $value) {
  6964. $time = time();
  6965. if ($value['0'] == "" || $value['1'] == "") {
  6966. continue;
  6967. }
  6968. $warehouse = $this->warehouse->get_title($value['0']);
  6969. $sku = $value['1'];
  6970. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  6971. if (!$d) //如果没有这个SKU
  6972. {
  6973. $ed[] = array($sku . '-库存中不存在此SKU');
  6974. $j++;
  6975. continue;
  6976. }
  6977. if (!isset($warehouse['id'])) {
  6978. $ed[] = array($sku . '-仓库名错误!');
  6979. $j++;
  6980. continue;
  6981. }
  6982. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  6983. if ($z < 1) {
  6984. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  6985. foreach ($z as $v) {
  6986. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  6987. if (count($zt) > 0) {
  6988. $ed[] = array($sku . '-有在途库存无法删除!');
  6989. $j++;
  6990. continue;
  6991. }
  6992. $this->whlabel->remove($v['id']);
  6993. }
  6994. } else {
  6995. $ed[] = array($sku . '-非0库存!');
  6996. $j++;
  6997. continue;
  6998. }
  6999. }
  7000. if ($j > 0) {
  7001. $tt = date('Ymd', time());
  7002. $title = '删除0库存错误信息-' . $tt;
  7003. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7004. $tail = "\n";
  7005. $filename = $title . ".xls";
  7006. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7007. $dir = '/data/excel/' . $time . '/';
  7008. $file_name = 'error_' . $time . rand(1000, 9999);
  7009. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7010. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7011. fwrite($myfile, $ecl);
  7012. fclose($myfile);
  7013. $error = $dir . $file_name . '.xls';
  7014. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7015. exit;
  7016. } else {
  7017. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7018. exit;
  7019. }
  7020. }
  7021. }
  7022. public function _gbhtype()
  7023. {
  7024. $post = $this->input->post(NULL, TRUE);
  7025. if (isset($post['s'])) {
  7026. $n = $this->input->post('n');
  7027. $d = $this->input->post('s');
  7028. if (!$d) {
  7029. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7030. exit;
  7031. }
  7032. $d = explode(',', trim($d, ','));
  7033. $t = $this->whlabel_type->read($n);
  7034. //循环删除记录
  7035. foreach ($d as $v) {
  7036. $u = $this->whlabel->read($v);
  7037. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7038. foreach ($data as $val) {
  7039. $this->whlabel->save(array('type' => $n), $val['id']);
  7040. }
  7041. }
  7042. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  7043. }
  7044. }
  7045. //出库、退库导出
  7046. public function _dccrtype()
  7047. {
  7048. $classid = $this->classid->sku();
  7049. $pm = $classid;
  7050. $typeclass = array();
  7051. $tc = $this->typeclass->find_all();
  7052. foreach ($tc as $v) {
  7053. $typeclass[$v['id']] = $v;
  7054. }
  7055. $prc = array();
  7056. $purchase = $this->purchase->find_all();
  7057. foreach ($purchase as $k => $v) {
  7058. $prc[$v['id']] = $v['title'];
  7059. }
  7060. if (isset($_GET['sid'])) {
  7061. $wh = array();
  7062. $w = $this->warehouse->find_all('1=1', 'id,title');
  7063. foreach ($w as $v) {
  7064. $wh[$v['id']] = $v['title'];
  7065. }
  7066. $type = $this->input->get('excel', true);
  7067. $category = $this->input->get('category', true);
  7068. $size = $this->input->get('size', true);
  7069. $grade = $this->input->get('grade', true);
  7070. $color = $this->input->get('color', true);
  7071. $lowe = $this->input->get('lowe', true);
  7072. $sku = $this->input->get('sku', true);
  7073. $warehouse = $this->input->get('warehouse', true);
  7074. $lacetype = $this->input->get('lacetype', true);
  7075. $lacecolor = $this->input->get('lacecolor', true);
  7076. $density = $this->input->get('density', true);
  7077. $haircap = $this->input->get('haircap', true);
  7078. $purchase = $this->input->get('purchase', true);
  7079. $title = $this->input->get('title', true);
  7080. $state = $this->input->get('state', true);
  7081. $sid = $this->input->get('sid', true);
  7082. $ktime = $this->input->get('ktime', true);
  7083. $jtime = $this->input->get('jtime', true);
  7084. $ktime = strtotime($ktime);
  7085. $jtime = strtotime($jtime);
  7086. $where = "1=1";
  7087. $gj = "";
  7088. $ck = "";
  7089. if ($category) {
  7090. $where .= " and features like '%-$category-%'";
  7091. }
  7092. if ($size) {
  7093. $where .= " and features like '%-$size-%'";
  7094. }
  7095. if ($grade) {
  7096. $where .= " and features like '%-$grade-%'";
  7097. }
  7098. if ($color) {
  7099. $where .= " and features like '%-$color-%'";
  7100. }
  7101. if ($lowe) {
  7102. $where .= " and features like '%-$lowe-%'";
  7103. }
  7104. if ($warehouse) {
  7105. $where .= " and warehouse = '$warehouse'";
  7106. }
  7107. if ($purchase) {
  7108. $where .= " and purchase = '$purchase'";
  7109. }
  7110. if ($state) {
  7111. $where .= " and state = '$state'";
  7112. }
  7113. if ($lacetype) {
  7114. $where .= " and features like '%-$lacetype-%'";
  7115. }
  7116. if ($lacecolor) {
  7117. $where .= " and features like '%-$lacecolor-%'";
  7118. }
  7119. if ($density) {
  7120. $where .= " and features like '%-$density-%'";
  7121. }
  7122. if ($haircap) {
  7123. $where .= " and features like '%-$haircap-%'";
  7124. }
  7125. if ($title) {
  7126. $title = trim($title, ' ');
  7127. $title = trim($title, ' ');
  7128. $where .= " and title like '%$title%'";
  7129. }
  7130. if ($sku) {
  7131. $sku = trim($sku, ' ');
  7132. $sku = trim($sku, ' ');
  7133. $where .= " and sku like '%$sku%'";
  7134. }
  7135. if ($ktime && $jtime) {
  7136. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  7137. }
  7138. $sidwhere = '';
  7139. if ($sid) {
  7140. $sd = "";
  7141. $s = explode(',', trim($sid, ','));
  7142. foreach ($s as $value) {
  7143. $sd .= " id = " . $value . " or";
  7144. }
  7145. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  7146. }
  7147. //数据排序
  7148. $order_str = "time desc";
  7149. if (empty($page)) {
  7150. $start = 0;
  7151. $perpage = 1;
  7152. } else {
  7153. $start = ($page - 1) * $perpage;
  7154. }
  7155. $wh = array();
  7156. $w = $this->warehouse->find_all('1=1', 'id,title');
  7157. foreach ($w as $v) {
  7158. $wh[$v['id']] = $v['title'];
  7159. }
  7160. $wt = array();
  7161. $whlabel_type = $this->whlabel_type->find_all();
  7162. foreach ($whlabel_type as $v) {
  7163. $wt[$v['id']] = $v['title'];
  7164. }
  7165. $classid = $this->classid->sku();
  7166. $list = array();
  7167. $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');
  7168. foreach ($rows_r as $key => $value) {
  7169. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  7170. $pm = $classid;
  7171. $jm = $classid;
  7172. $rows_r[$key]['enter'] = '入库';
  7173. $rows_r[$key]['time'] = $value['enter'];
  7174. if ($value['rktype'] == 1) {
  7175. $rows_r[$key]['rktype'] = '采购入库';
  7176. } else if ($value['rktype'] == 2) {
  7177. $rows_r[$key]['rktype'] = '盘盈调整';
  7178. } else if ($value['rktype'] == 3) {
  7179. $rows_r[$key]['rktype'] = '其他调整入库';
  7180. } else if ($value['rktype'] == 4) {
  7181. $rows_r[$key]['rktype'] = '其他调整入库';
  7182. } else if ($value['rktype'] == 5) {
  7183. $rows_r[$key]['rktype'] = '退库入库';
  7184. } else if ($value['rktype'] == 6) {
  7185. $rows_r[$key]['rktype'] = '退货可用入库';
  7186. } else if ($value['rktype'] == 7) {
  7187. $rows_r[$key]['rktype'] = '形态转换入库';
  7188. } else {
  7189. $rows_r[$key]['rktype'] = '';
  7190. }
  7191. $features = explode('-', trim($value['features'], '-'));
  7192. foreach ($features as $v) {
  7193. if (isset($typeclass[$v])) {
  7194. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7195. $pm[$typeclass[$v]['classid']] = $zh[0];
  7196. }
  7197. if (isset($typeclass[$v])) {
  7198. if (isset($jm[$typeclass[$v]['classid']])) {
  7199. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7200. }
  7201. }
  7202. }
  7203. $zh = implode(" ", $pm);
  7204. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7205. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7206. $rows_r[$key]['zh'] = $zh;
  7207. $jm = array_filter($jm);
  7208. $rows_r[$key]['features'] = implode("-", $jm);
  7209. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  7210. }
  7211. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout');
  7212. foreach ($rows_c as $key => $value) {
  7213. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  7214. $pm = $classid;
  7215. $jm = $classid;
  7216. $rows_c[$key]['time'] = $value['outk'];
  7217. $rows_c[$key]['outk'] = '出库';
  7218. if ($value['cktype'] == 1) {
  7219. $rows_c[$key]['cktype'] = '销售出库';
  7220. } else if ($value['cktype'] == 2) {
  7221. $rows_c[$key]['cktype'] = '销售美国出库';
  7222. } else if ($value['cktype'] == 3) {
  7223. $rows_c[$key]['cktype'] = '盘亏调整';
  7224. } else if ($value['cktype'] == 4) {
  7225. $rows_c[$key]['cktype'] = '其他调整出库';
  7226. } else if ($value['cktype'] == 5) {
  7227. $rows_c[$key]['cktype'] = '形态转换出库';
  7228. } else {
  7229. $rows_c[$key]['cktype'] = '';
  7230. }
  7231. $features = explode('-', trim($value['features'], '-'));
  7232. foreach ($features as $v) {
  7233. if (isset($typeclass[$v])) {
  7234. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  7235. $pm[$typeclass[$v]['classid']] = $zh[0];
  7236. }
  7237. if (isset($typeclass[$v])) {
  7238. if (isset($jm[$typeclass[$v]['classid']])) {
  7239. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  7240. }
  7241. }
  7242. }
  7243. $zh = implode(" ", $pm);
  7244. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  7245. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  7246. $rows_c[$key]['zh'] = $zh;
  7247. $jm = array_filter($jm);
  7248. $rows_c[$key]['features'] = implode("-", $jm);
  7249. $rows_c[$key]['number'] = 1;
  7250. }
  7251. $merged = $rows_r;
  7252. foreach ($rows_c as $key => $value) {
  7253. if (isset($merged[$key])) {
  7254. $merged[] = $value;
  7255. } else {
  7256. $merged[$key] = $value;
  7257. }
  7258. }
  7259. usort($merged, function ($a, $b) {
  7260. return $a['time'] - $b['time'];
  7261. });
  7262. foreach ($merged as $key => $value) {
  7263. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  7264. }
  7265. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  7266. $titlename = "<table border=1>
  7267. <tr align='center'>
  7268. <td>仓库</td>
  7269. <td>SKU</td>
  7270. <td>商品名称</td>
  7271. <td>仓库品名</td>
  7272. <td>料号</td>
  7273. <td>时间</td>
  7274. <td>操作</td>
  7275. <td>类型</td>
  7276. <td>数量</td>
  7277. <td>备注</td>
  7278. </tr>
  7279. </table>";
  7280. $filename = $title . ".xlsx";
  7281. $tail = "";
  7282. $this->excel->get_fz2($merged, $titlename, $filename, $tail);
  7283. }
  7284. }
  7285. }